@warp-drive-mirror/experiments 0.2.7-alpha.9 → 0.2.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +2 -1
- package/declarations/data-worker.d.ts +35 -2
- package/declarations/data-worker.d.ts.map +1 -0
- package/declarations/document-storage-CwwTQ49-.d.ts +91 -0
- package/declarations/document-storage-CwwTQ49-.d.ts.map +1 -0
- package/declarations/document-storage.d.ts +2 -1
- package/declarations/image-fetch.d.ts +60 -1
- package/declarations/image-fetch.d.ts.map +1 -0
- package/declarations/image-worker.d.ts +40 -1
- package/declarations/image-worker.d.ts.map +1 -0
- package/declarations/storage.d.ts +359 -0
- package/declarations/storage.d.ts.map +1 -0
- package/declarations/types-CRs-Qww6.d.ts +17 -0
- package/declarations/types-CRs-Qww6.d.ts.map +1 -0
- package/declarations/worker-fetch.d.ts +23 -1
- package/declarations/worker-fetch.d.ts.map +1 -0
- package/dist/data-worker.js +235 -339
- package/dist/data-worker.js.map +1 -0
- package/dist/document-storage-LM925Stz.js +270 -0
- package/dist/document-storage-LM925Stz.js.map +1 -0
- package/dist/document-storage.js +3 -1
- package/dist/image-fetch.js +108 -79
- package/dist/image-fetch.js.map +1 -0
- package/dist/image-worker.js +95 -95
- package/dist/image-worker.js.map +1 -0
- package/dist/storage.js +914 -0
- package/dist/storage.js.map +1 -0
- package/dist/unpkg/dev/data-worker.js +231 -338
- package/dist/unpkg/dev/data-worker.js.map +1 -0
- package/dist/unpkg/dev/document-storage-DkiEg9rY.js +268 -0
- package/dist/unpkg/dev/document-storage-DkiEg9rY.js.map +1 -0
- package/dist/unpkg/dev/document-storage.js +2 -348
- package/dist/unpkg/dev/image-fetch.js +104 -71
- package/dist/unpkg/dev/image-fetch.js.map +1 -0
- package/dist/unpkg/dev/image-worker.js +93 -94
- package/dist/unpkg/dev/image-worker.js.map +1 -0
- package/dist/unpkg/dev/storage.js +913 -0
- package/dist/unpkg/dev/storage.js.map +1 -0
- package/dist/unpkg/dev/worker-fetch.js +112 -145
- package/dist/unpkg/dev/worker-fetch.js.map +1 -0
- package/dist/unpkg/dev-deprecated/data-worker.js +231 -338
- package/dist/unpkg/dev-deprecated/data-worker.js.map +1 -0
- package/dist/unpkg/dev-deprecated/document-storage-DkiEg9rY.js +268 -0
- package/dist/unpkg/dev-deprecated/document-storage-DkiEg9rY.js.map +1 -0
- package/dist/unpkg/dev-deprecated/document-storage.js +2 -348
- package/dist/unpkg/dev-deprecated/image-fetch.js +104 -71
- package/dist/unpkg/dev-deprecated/image-fetch.js.map +1 -0
- package/dist/unpkg/dev-deprecated/image-worker.js +93 -94
- package/dist/unpkg/dev-deprecated/image-worker.js.map +1 -0
- package/dist/unpkg/dev-deprecated/storage.js +913 -0
- package/dist/unpkg/dev-deprecated/storage.js.map +1 -0
- package/dist/unpkg/dev-deprecated/worker-fetch.js +112 -145
- package/dist/unpkg/dev-deprecated/worker-fetch.js.map +1 -0
- package/dist/unpkg/prod/data-worker.js +224 -324
- package/dist/unpkg/prod/data-worker.js.map +1 -0
- package/dist/unpkg/prod/document-storage-D0k_6GM9.js +262 -0
- package/dist/unpkg/prod/document-storage-D0k_6GM9.js.map +1 -0
- package/dist/unpkg/prod/document-storage.js +2 -338
- package/dist/unpkg/prod/image-fetch.js +101 -71
- package/dist/unpkg/prod/image-fetch.js.map +1 -0
- package/dist/unpkg/prod/image-worker.js +93 -94
- package/dist/unpkg/prod/image-worker.js.map +1 -0
- package/dist/unpkg/prod/storage.js +844 -0
- package/dist/unpkg/prod/storage.js.map +1 -0
- package/dist/unpkg/prod/worker-fetch.js +109 -145
- package/dist/unpkg/prod/worker-fetch.js.map +1 -0
- package/dist/unpkg/prod-deprecated/data-worker.js +224 -324
- package/dist/unpkg/prod-deprecated/data-worker.js.map +1 -0
- package/dist/unpkg/prod-deprecated/document-storage-D0k_6GM9.js +262 -0
- package/dist/unpkg/prod-deprecated/document-storage-D0k_6GM9.js.map +1 -0
- package/dist/unpkg/prod-deprecated/document-storage.js +2 -338
- package/dist/unpkg/prod-deprecated/image-fetch.js +101 -71
- package/dist/unpkg/prod-deprecated/image-fetch.js.map +1 -0
- package/dist/unpkg/prod-deprecated/image-worker.js +93 -94
- package/dist/unpkg/prod-deprecated/image-worker.js.map +1 -0
- package/dist/unpkg/prod-deprecated/storage.js +844 -0
- package/dist/unpkg/prod-deprecated/storage.js.map +1 -0
- package/dist/unpkg/prod-deprecated/worker-fetch.js +109 -145
- package/dist/unpkg/prod-deprecated/worker-fetch.js.map +1 -0
- package/dist/worker-fetch.js +116 -153
- package/dist/worker-fetch.js.map +1 -0
- package/package.json +9 -9
- package/declarations/data-worker/cache-handler.d.ts +0 -7
- package/declarations/data-worker/fetch.d.ts +0 -21
- package/declarations/data-worker/types.d.ts +0 -31
- package/declarations/data-worker/utils.d.ts +0 -12
- package/declarations/data-worker/worker.d.ts +0 -23
- package/declarations/document-storage/index.d.ts +0 -90
- package/declarations/image-worker/fetch.d.ts +0 -18
- package/declarations/image-worker/types.d.ts +0 -21
- package/declarations/image-worker/worker.d.ts +0 -14
- package/dist/index-CGCX7hY2.js +0 -349
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,71 @@
|
|
|
1
1
|
# @warp-drive-mirror/experiments Changelog
|
|
2
|
+
|
|
3
|
+
## v5.6.0 (2025-07-01)
|
|
4
|
+
|
|
5
|
+
#### :memo: Documentation
|
|
6
|
+
|
|
7
|
+
* [#9991](https://github.com/warp-drive-data/warp-drive/pull/9991) chore: improve output of typedoc ([@runspired](https://github.com/runspired))
|
|
8
|
+
* [#9989](https://github.com/warp-drive-data/warp-drive/pull/9989) [BREAKING] docs: integrate API docs to the new docs site ([@runspired](https://github.com/runspired))
|
|
9
|
+
|
|
10
|
+
#### :rocket: Enhancement
|
|
11
|
+
|
|
12
|
+
* [#9998](https://github.com/warp-drive-data/warp-drive/pull/9998) feat: extract @ember-data-mirror/store => @warp-drive-mirror/core ([@runspired](https://github.com/runspired))
|
|
13
|
+
|
|
14
|
+
#### :house: Internal
|
|
15
|
+
|
|
16
|
+
* [#9994](https://github.com/warp-drive-data/warp-drive/pull/9994) chore: [@warp-drive-mirror/core] migrate @warp-drive-mirror/core-types @ember-data-mirror/request ([@runspired](https://github.com/runspired))
|
|
17
|
+
|
|
18
|
+
#### Committers: (1)
|
|
19
|
+
|
|
20
|
+
Chris Thoburn ([@runspired](https://github.com/runspired))
|
|
21
|
+
|
|
22
|
+
## v5.5.0 (2025-05-08)
|
|
23
|
+
|
|
24
|
+
#### :memo: Documentation
|
|
25
|
+
|
|
26
|
+
* [#9975](https://github.com/warp-drive-data/warp-drive/pull/9975) types: fixup PolarisMode schema types to check better ([@runspired](https://github.com/runspired))
|
|
27
|
+
|
|
28
|
+
#### :rocket: Enhancement
|
|
29
|
+
|
|
30
|
+
* [#9965](https://github.com/warp-drive-data/warp-drive/pull/9965) feat: universal reactivity hooks ([@runspired](https://github.com/runspired))
|
|
31
|
+
|
|
32
|
+
#### :house: Internal
|
|
33
|
+
|
|
34
|
+
* [#9965](https://github.com/warp-drive-data/warp-drive/pull/9965) feat: universal reactivity hooks ([@runspired](https://github.com/runspired))
|
|
35
|
+
|
|
36
|
+
#### Committers: (1)
|
|
37
|
+
|
|
38
|
+
Chris Thoburn ([@runspired](https://github.com/runspired))
|
|
39
|
+
|
|
40
|
+
## v5.4.0 (2025-04-11)
|
|
41
|
+
|
|
42
|
+
#### :memo: Documentation
|
|
43
|
+
|
|
44
|
+
* [#9778](https://github.com/warp-drive-data/warp-drive/pull/9778) chore: improve contributing guidance for api documentation ([@runspired](https://github.com/runspired))
|
|
45
|
+
* [#9648](https://github.com/warp-drive-data/warp-drive/pull/9648) docs: cleanup usage pattern for RequestManager configuration on store ([@runspired](https://github.com/runspired))
|
|
46
|
+
* [#9512](https://github.com/warp-drive-data/warp-drive/pull/9512) Fix typos in README.md ([@johanrd](https://github.com/johanrd))
|
|
47
|
+
|
|
48
|
+
#### :rocket: Enhancement
|
|
49
|
+
|
|
50
|
+
* [#9884](https://github.com/warp-drive-data/warp-drive/pull/9884) feat: cache patch operations for relationships and documents ([@runspired](https://github.com/runspired))
|
|
51
|
+
* [#9541](https://github.com/warp-drive-data/warp-drive/pull/9541) feat: eslint-plugin-(ember-data|warp-drive) ([@runspired](https://github.com/runspired))
|
|
52
|
+
* [#9524](https://github.com/warp-drive-data/warp-drive/pull/9524) feat: persisted DataWorker and ImageWorker ([@runspired](https://github.com/runspired))
|
|
53
|
+
* [#8698](https://github.com/warp-drive-data/warp-drive/pull/8698) feat: DataWorker | robust cross-tab request deduplication and replay ([@runspired](https://github.com/runspired))
|
|
54
|
+
|
|
55
|
+
#### :house: Internal
|
|
56
|
+
|
|
57
|
+
* [#9780](https://github.com/warp-drive-data/warp-drive/pull/9780) chore: bump @glimmer/component ([@runspired](https://github.com/runspired))
|
|
58
|
+
* [#9759](https://github.com/warp-drive-data/warp-drive/pull/9759) chore: Improve contributing experience ([@runspired](https://github.com/runspired))
|
|
59
|
+
* [#9752](https://github.com/warp-drive-data/warp-drive/pull/9752) chore: tooling upgrades to support WarpDrive package unification ([@runspired](https://github.com/runspired))
|
|
60
|
+
* [#9705](https://github.com/warp-drive-data/warp-drive/pull/9705) chore: make diagnostic shutdown safer, use bun for holodeck server ([@runspired](https://github.com/runspired))
|
|
61
|
+
* [#9697](https://github.com/warp-drive-data/warp-drive/pull/9697) chore: [BREAKING to prior alpha/betas] prepare SchemaRecord for stable, lockdown exports ([@runspired](https://github.com/runspired))
|
|
62
|
+
* [#9629](https://github.com/warp-drive-data/warp-drive/pull/9629) fix: restore * versions and setup publish to not overwrite them ([@runspired](https://github.com/runspired))
|
|
63
|
+
* [#9620](https://github.com/warp-drive-data/warp-drive/pull/9620) Starwars ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
|
|
64
|
+
* [#9596](https://github.com/warp-drive-data/warp-drive/pull/9596) chore: Remove unused `--report-unused-disable-directives` flag ([@gitKrystan](https://github.com/gitKrystan))
|
|
65
|
+
|
|
66
|
+
#### Committers: (4)
|
|
67
|
+
|
|
68
|
+
Chris Thoburn ([@runspired](https://github.com/runspired))
|
|
69
|
+
[@johanrd](https://github.com/johanrd)
|
|
70
|
+
[@NullVoxPopuli](https://github.com/NullVoxPopuli)
|
|
71
|
+
Krystan HuffMenne ([@gitKrystan](https://github.com/gitKrystan))
|
package/README.md
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as DocumentStorage } from "./document-storage-CwwTQ49-.js";
|
|
2
|
+
import { n as RequestEventData, t as AbortEventData } from "./types-CRs-Qww6.js";
|
|
3
|
+
import { CacheHandler as CacheHandler$1, Future } from "@warp-drive-mirror/core/request";
|
|
4
|
+
import { Store } from "@warp-drive-mirror/core";
|
|
5
|
+
//#region src/data-worker/worker.d.ts
|
|
6
|
+
declare class DataWorker {
|
|
7
|
+
store: Store;
|
|
8
|
+
threads: Map<string, MessagePort>;
|
|
9
|
+
pending: Map<string, Map<number, Future<unknown>>>;
|
|
10
|
+
isSharedWorker: boolean;
|
|
11
|
+
options: {
|
|
12
|
+
persisted: boolean;
|
|
13
|
+
scope?: string;
|
|
14
|
+
};
|
|
15
|
+
storage: DocumentStorage;
|
|
16
|
+
constructor(UserStore: typeof Store, options?: {
|
|
17
|
+
persisted: boolean;
|
|
18
|
+
scope?: string;
|
|
19
|
+
});
|
|
20
|
+
initialize(): void;
|
|
21
|
+
setupThread(thread: string, port: MessagePort): void;
|
|
22
|
+
abortRequest(event: AbortEventData): void;
|
|
23
|
+
request(event: RequestEventData): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/data-worker/cache-handler.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* A simplified CacheHandler that hydrates ResourceDataDocuments from the cache
|
|
29
|
+
* with their referenced resources.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
declare const CacheHandler: CacheHandler$1;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CacheHandler, DataWorker };
|
|
35
|
+
//# sourceMappingURL=data-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-worker.d.ts","names":[],"sources":["../src/data-worker/worker.ts","../src/data-worker/cache-handler.ts"],"mappings":";;;;;cASa;EACX,OAAe;EACf,SAAiB,YAAY;EAC7B,SAAiB,YAAY,YAAY;EACzC;EACA;IAAmB;IAAoB;;EACvC,SAAiB;EAEjB,YAAY,kBAAkB,OAAO;IAAY;IAAoB;;EAarE;EAkCA,YAAY,gBAAgB,MAAM;EAqBlC,aAAa,OAAO;EAUpB,QAAc,OAAO,mBAAmB;;;;;;;;;cCnE7B,cAAc"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { StructuredDocument } from "@warp-drive-mirror/core/types/request";
|
|
2
|
+
import { PersistedResourceKey } from "@warp-drive-mirror/core/types/identifier";
|
|
3
|
+
import { ResourceDataDocument, ResourceDocument } from "@warp-drive-mirror/core/types/spec/document";
|
|
4
|
+
import { ExistingResourceObject } from "@warp-drive-mirror/core/types/spec/json-api-raw";
|
|
5
|
+
//#region src/document-storage/index.d.ts
|
|
6
|
+
type DocumentStorageOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The scope of the storage. This is used to enable multiple distinct
|
|
9
|
+
* storage areas within the same origin.
|
|
10
|
+
*
|
|
11
|
+
* One use case for this is to have a separate storage area for each
|
|
12
|
+
* user credential. So for instance, in applications that allow a single
|
|
13
|
+
* user to have multiple accounts, each account can have its own storage!
|
|
14
|
+
*/
|
|
15
|
+
scope: string;
|
|
16
|
+
/**
|
|
17
|
+
* When set to true, if other instances of the storage are created with
|
|
18
|
+
* the same scope, they will not share the same in-memory cache and BroadcastChannel.
|
|
19
|
+
*
|
|
20
|
+
* This is mostly useful for testing purposes to replicate the behavior of
|
|
21
|
+
* multiple tabs or workers.
|
|
22
|
+
*/
|
|
23
|
+
isolated: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* DocumentStorage is specifically designed around WarpDrive Cache and Request concepts.
|
|
27
|
+
*
|
|
28
|
+
* CacheFileDocument is a StructuredDocument (request response) whose `content` is
|
|
29
|
+
* the ResourceDocument returned by inserting the request into a Store's Cache.
|
|
30
|
+
*/
|
|
31
|
+
type CacheFileDocument = StructuredDocument<ResourceDocument>;
|
|
32
|
+
/**
|
|
33
|
+
* A CacheDocument is a reconstructed request response that rehydrates ResourceDocument
|
|
34
|
+
* with the associated resources based on their identifiers.
|
|
35
|
+
*/
|
|
36
|
+
type CacheDocument = StructuredDocument<ResourceDocument<ExistingResourceObject>>;
|
|
37
|
+
type DocumentIdentifier = {
|
|
38
|
+
lid: string;
|
|
39
|
+
};
|
|
40
|
+
type MemCache = {
|
|
41
|
+
documents: Map<string, CacheFileDocument>;
|
|
42
|
+
resources: Map<string, ExistingResourceObject>;
|
|
43
|
+
};
|
|
44
|
+
declare class InternalDocumentStorage {
|
|
45
|
+
readonly options: DocumentStorageOptions;
|
|
46
|
+
_fileHandle: Promise<FileSystemFileHandle>;
|
|
47
|
+
_channel: BroadcastChannel;
|
|
48
|
+
_invalidated: boolean;
|
|
49
|
+
_lastModified: number;
|
|
50
|
+
_cache: MemCache | null;
|
|
51
|
+
_filePromise: Promise<MemCache> | null;
|
|
52
|
+
constructor(options: DocumentStorageOptions);
|
|
53
|
+
_onMessage(_event: MessageEvent): void;
|
|
54
|
+
_open(scope: string): Promise<FileSystemFileHandle>;
|
|
55
|
+
_read(): Promise<MemCache>;
|
|
56
|
+
_patch(documentKey: string, document: CacheFileDocument, updatedResources: Map<string, ExistingResourceObject>): Promise<void>;
|
|
57
|
+
getDocument(key: DocumentIdentifier): Promise<CacheDocument | null>;
|
|
58
|
+
putDocument(document: CacheFileDocument, resourceCollector: (resourceIdentifier: PersistedResourceKey) => ExistingResourceObject): Promise<void>;
|
|
59
|
+
_getResources(document: ResourceDataDocument, resourceCollector: (resourceIdentifier: PersistedResourceKey) => ExistingResourceObject, resources?: Map<string, ExistingResourceObject>): Map<string, ExistingResourceObject>;
|
|
60
|
+
putResources(document: ResourceDataDocument, resourceCollector: (resourceIdentifier: PersistedResourceKey) => ExistingResourceObject): Promise<void>;
|
|
61
|
+
clear(reset?: boolean): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* DocumentStorage is a wrapper around the StorageManager API that provides
|
|
65
|
+
* a simple interface for reading and updating documents and requests.
|
|
66
|
+
*
|
|
67
|
+
* Some goals for this experiment:
|
|
68
|
+
*
|
|
69
|
+
* - optimize for storing requests/documents
|
|
70
|
+
* - optimize for storing resources
|
|
71
|
+
* - optimize for looking up resources associated to a document
|
|
72
|
+
* - optimize for notifying cross-tab when data is updated
|
|
73
|
+
*
|
|
74
|
+
* optional features:
|
|
75
|
+
*
|
|
76
|
+
* - support for offline mode
|
|
77
|
+
* - ?? support for relationship based cache traversal
|
|
78
|
+
* - a way to index records by type + another field (e.g updatedAt/createAt/name)
|
|
79
|
+
* such that simple queries can be done without having to scan all records
|
|
80
|
+
*/
|
|
81
|
+
declare class DocumentStorage {
|
|
82
|
+
readonly _storage: InternalDocumentStorage;
|
|
83
|
+
constructor(options?: Partial<DocumentStorageOptions>);
|
|
84
|
+
getDocument(key: DocumentIdentifier): Promise<CacheDocument | null>;
|
|
85
|
+
putDocument(document: CacheFileDocument, resourceCollector: (resourceIdentifier: PersistedResourceKey) => ExistingResourceObject): Promise<void>;
|
|
86
|
+
putResources(document: ResourceDataDocument, resourceCollector: (resourceIdentifier: PersistedResourceKey) => ExistingResourceObject): Promise<void>;
|
|
87
|
+
clear(reset?: boolean): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { DocumentStorage as t };
|
|
91
|
+
//# sourceMappingURL=document-storage-CwwTQ49-.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-storage-CwwTQ49-.d.ts","names":[],"sources":["../src/document-storage/index.ts"],"mappings":";;;;;KAUY;;;;;;;;;EASV;;;;;;;;EAQA;;;;;;;;KAQG,oBAAoB,mBAAmB;;;;;KAKvC,gBAAgB,mBAAmB,iBAAiB;KAMpD;EAAuB;;KAEvB;EACH,WAAW,YAAY;EACvB,WAAW,YAAY;;cAGnB;WACa,SAAS;EAC1B,aAAqB,QAAQ;EAC7B,UAAkB;EAClB;EACA;EACA,QAAgB;EAChB,cAAsB,QAAQ;EAE9B,YAAY,SAAS;EAWrB,WAAW,QAAQ;EAInB,MAAY,gBAAgB,QAAQ;EAMpC,SAAe,QAAQ;EAmCvB,OACE,qBACA,UAAU,mBACV,kBAAkB,YAAY,0BAC7B;EAuBH,YAAkB,KAAK,qBAAqB,QAAQ;EAqDpD,YACE,UAAU,mBACV,oBAAoB,oBAAoB,yBAAyB,yBAChE;EAkBH,cACE,UAAU,sBACV,oBAAoB,oBAAoB,yBAAyB,wBACjE,YAAW,YAAY,0BACtB,YAAY;EAqBf,aACE,UAAU,sBACV,oBAAoB,oBAAoB,yBAAyB,yBAChE;EAwBH,MAAY,kBAAkB;;;;;;;;;;;;;;;;;;;;cAuInB;WACM,UAAU;EAE3B,YAAY,UAAS,QAAQ;EAoB7B,YAAY,KAAK,qBAAqB,QAAQ;EAI9C,YACE,UAAU,mBACV,oBAAoB,oBAAoB,yBAAyB,yBAChE;EAIH,aACE,UAAU,sBACV,oBAAoB,oBAAoB,yBAAyB,yBAChE;EAIH,MAAM,kBAAkB"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as DocumentStorage } from "./document-storage-CwwTQ49-.js";
|
|
2
|
+
export { DocumentStorage };
|
|
@@ -1 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import { Deferred } from "@warp-drive-mirror/core/request";
|
|
2
|
+
//#region src/image-worker/types.d.ts
|
|
3
|
+
/** Sent by {@link ImageFetch} to request that an image url be loaded. */
|
|
4
|
+
type RequestEventData = {
|
|
5
|
+
type: "load";
|
|
6
|
+
thread: string;
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/image-worker/fetch.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Main-thread client for an {@link ImageWorker}. Sends image `load`
|
|
13
|
+
* requests to a `Worker` or `SharedWorker` running an `ImageWorker`.
|
|
14
|
+
*
|
|
15
|
+
* In FastBoot/SSR, or when constructed with a `null` worker, `ImageFetch`
|
|
16
|
+
* skips worker communication entirely: {@link ImageFetch.load} resolves
|
|
17
|
+
* immediately with the given url.
|
|
18
|
+
*
|
|
19
|
+
* A plain `Worker` is only accepted when running in a `TESTING` build;
|
|
20
|
+
* production usage requires a `SharedWorker`.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare class ImageFetch {
|
|
25
|
+
worker: Worker | SharedWorker;
|
|
26
|
+
threadId: string;
|
|
27
|
+
pending: Map<string, Deferred<string>>;
|
|
28
|
+
channel: MessageChannel;
|
|
29
|
+
cache: Map<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* @param worker - the `Worker` or `SharedWorker` running an
|
|
32
|
+
* {@link ImageWorker}, or `null` to disable worker communication (e.g.
|
|
33
|
+
* in FastBoot/SSR).
|
|
34
|
+
*/
|
|
35
|
+
constructor(worker: Worker | SharedWorker | null);
|
|
36
|
+
cleanupRequest(url: string): Deferred<string> | undefined;
|
|
37
|
+
_send(event: RequestEventData): void;
|
|
38
|
+
/**
|
|
39
|
+
* Requests that the given image url be loaded by the connected
|
|
40
|
+
* {@link ImageWorker}, resolving with an object url for the fetched
|
|
41
|
+
* image's blob once the worker responds (or immediately with the
|
|
42
|
+
* original `url`, in SSR/FastBoot or when this instance was constructed
|
|
43
|
+
* with a `null` worker).
|
|
44
|
+
*
|
|
45
|
+
* The resolved object url is cached in-memory by source url on this
|
|
46
|
+
* instance, so subsequent calls for the same url resolve immediately
|
|
47
|
+
* without another round-trip to the worker.
|
|
48
|
+
*
|
|
49
|
+
* Calling `load` again for a url that is already in-flight (not yet
|
|
50
|
+
* cached) on this instance replaces the pending request rather than
|
|
51
|
+
* joining it — only the most recently issued call for a given url will
|
|
52
|
+
* resolve.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
load(url: string): Promise<string>;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ImageFetch };
|
|
60
|
+
//# sourceMappingURL=image-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-fetch.d.ts","names":[],"sources":["../src/image-worker/types.ts","../src/image-worker/fetch.ts"],"mappings":";;;KA8BY;EACV;EACA;EACA;;;;;;;;;;;;;;;;;cCFW;EACX,QAAgB,SAAS;EACzB;EACA,SAAiB,YAAY;EAC7B,SAAiB;EACjB,OAAe;;;;;;EAOf,YAAY,QAAQ,SAAS;EA0C7B,eAAe,cAAc;EAO7B,MAAM,OAAO;;;;;;;;;;;;;;;;;;;EAuBb,KAAK,cAAc"}
|
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/image-worker/worker.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Runs inside a `Worker` or `SharedWorker` to fetch images on behalf of
|
|
4
|
+
* one or more {@link ImageFetch} instances running on the main thread(s)
|
|
5
|
+
* that connect to it.
|
|
6
|
+
*
|
|
7
|
+
* Each connecting thread registers itself by sending a `connect` message
|
|
8
|
+
* along with a {@link MessagePort}. When a thread sends a `load` request
|
|
9
|
+
* for a url, the worker fetches the image via `fetch`, converts the
|
|
10
|
+
* response into a `Blob`, and creates an object url for it via
|
|
11
|
+
* `URL.createObjectURL`. The fetch for a given url is deduped and cached
|
|
12
|
+
* in-memory for the lifetime of the worker, so repeat `load` requests for
|
|
13
|
+
* the same url — whether from the same or a different connected thread —
|
|
14
|
+
* do not trigger another network request.
|
|
15
|
+
*
|
|
16
|
+
* Only intended for use inside a Worker context: constructing an
|
|
17
|
+
* `ImageWorker` on the main thread is a no-op.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
declare class ImageWorker {
|
|
22
|
+
private threads;
|
|
23
|
+
private pendingImages;
|
|
24
|
+
private options;
|
|
25
|
+
private isSharedWorker;
|
|
26
|
+
private cache;
|
|
27
|
+
/**
|
|
28
|
+
* @param options.persisted - reserved for a future on-disk cache; currently unused.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: {
|
|
31
|
+
persisted: boolean;
|
|
32
|
+
});
|
|
33
|
+
private fetch;
|
|
34
|
+
private initialize;
|
|
35
|
+
private setupThread;
|
|
36
|
+
private request;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { ImageWorker };
|
|
40
|
+
//# sourceMappingURL=image-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-worker.d.ts","names":[],"sources":["../src/image-worker/worker.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;cA+Ba;UACK;UACA;UACA;UACA;UACA;;;;EAKhB,YAAY;IAAY;;UAahB;UAsBA;UA4BA;UAiBM"}
|