-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: element cropping & scrolling (#2625)
- Loading branch information
Showing
90 changed files
with
751 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1 @@ | ||
class MockCache { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
private readonly _cache: {[key: string]: Promise<any>}; | ||
|
||
constructor() { | ||
this._cache = {}; | ||
} | ||
|
||
addImage(src: string): Promise<void> { | ||
const result = Promise.resolve(); | ||
this._cache[src] = result; | ||
return result; | ||
} | ||
} | ||
|
||
const current = new MockCache(); | ||
|
||
export class CacheStorage { | ||
static getInstance(): MockCache { | ||
return current; | ||
} | ||
} | ||
export class CacheStorage {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {logger, Logger} from './logger'; | ||
|
||
export class Context { | ||
readonly logger: Logger = logger; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
readonly _cache: {[key: string]: Promise<any>} = {}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
readonly cache: any; | ||
|
||
constructor() { | ||
this.cache = { | ||
addImage: jest.fn().mockImplementation((src: string): Promise<void> => { | ||
const result = Promise.resolve(); | ||
this._cache[src] = result; | ||
return result; | ||
}) | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ export class Logger { | |
error(): void {} | ||
} | ||
|
||
const logger = new Logger(); | ||
export const logger = new Logger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Logger} from './logger'; | ||
import {Cache, ResourceOptions} from './cache-storage'; | ||
import {Bounds} from '../css/layout/bounds'; | ||
|
||
export type ContextOptions = { | ||
logging: boolean; | ||
cache?: Cache; | ||
} & ResourceOptions; | ||
|
||
export class Context { | ||
private readonly instanceName = `#${Context.instanceCount++}`; | ||
readonly logger: Logger; | ||
readonly cache: Cache; | ||
|
||
private static instanceCount = 1; | ||
|
||
constructor(options: ContextOptions, public windowBounds: Bounds) { | ||
this.logger = new Logger({id: this.instanceName, enabled: options.logging}); | ||
this.cache = options.cache ?? new Cache(this, options); | ||
} | ||
} |
Oops, something went wrong.