@warp-drive-mirror/experiments 0.0.1-alpha.99 → 0.0.1-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/README.md +2 -1
- package/dist/data-worker.js +124 -31
- package/dist/data-worker.js.map +1 -1
- package/dist/document-storage.js +1 -243
- package/dist/document-storage.js.map +1 -1
- package/dist/image-fetch.js +78 -0
- package/dist/image-fetch.js.map +1 -0
- package/dist/image-worker.js +98 -0
- package/dist/image-worker.js.map +1 -0
- package/dist/index-Cn3o840t.js +349 -0
- package/dist/index-Cn3o840t.js.map +1 -0
- package/dist/persisted-cache.js +19 -19
- package/dist/persisted-cache.js.map +1 -1
- package/dist/worker-fetch.js +24 -11
- package/dist/worker-fetch.js.map +1 -1
- package/package.json +37 -21
- package/unstable-preview-types/data-worker/cache-handler.d.ts.map +1 -1
- package/unstable-preview-types/data-worker/fetch.d.ts.map +1 -1
- package/unstable-preview-types/data-worker/worker.d.ts +11 -1
- package/unstable-preview-types/data-worker/worker.d.ts.map +1 -1
- package/unstable-preview-types/document-storage/index.d.ts +4 -1
- package/unstable-preview-types/document-storage/index.d.ts.map +1 -1
- package/unstable-preview-types/image-fetch.d.ts +4 -0
- package/unstable-preview-types/image-fetch.d.ts.map +1 -0
- package/unstable-preview-types/image-worker/fetch.d.ts +21 -0
- package/unstable-preview-types/image-worker/fetch.d.ts.map +1 -0
- package/unstable-preview-types/image-worker/types.d.ts +24 -0
- package/unstable-preview-types/image-worker/types.d.ts.map +1 -0
- package/unstable-preview-types/image-worker/worker.d.ts +20 -0
- package/unstable-preview-types/image-worker/worker.d.ts.map +1 -0
- package/unstable-preview-types/image-worker.d.ts +4 -0
- package/unstable-preview-types/image-worker.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +13 -8
- package/unstable-preview-types/persisted-cache/cache.d.ts +19 -19
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Cn3o840t.js","sources":["../src/document-storage/index.ts"],"sourcesContent":["import type { RequestInfo, ResponseInfo, StructuredDocument } from '@ember-data-mirror/request';\nimport type { StoreRequestContext } from '@ember-data-mirror/store';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\nimport type { ExistingRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';\nimport type { ResourceDataDocument, ResourceDocument } from '@warp-drive-mirror/core-types/spec/document';\nimport type { ExistingResourceObject } from '@warp-drive-mirror/core-types/spec/json-api-raw';\n\nexport const WARP_DRIVE_STORAGE_FILE_NAME = 'warp-drive_document-storage';\nexport const WARP_DRIVE_STORAGE_VERSION = 1;\n\nexport type DocumentStorageOptions = {\n /**\n * The scope of the storage. This is used to enable multiple distinct\n * storage areas within the same origin.\n *\n * One use case for this is to have a separate storage area for each\n * user credential. So for instance, in applications that allow a single\n * user to have multiple accounts, each account can have its own storage!\n */\n scope: string;\n /**\n * When set to true, if other instances of the storage are created with\n * the same scope, they will not share the same in-memory cache and BroadcastChannel.\n *\n * This is mostly useful for testing purposes to replicate the behavior of\n * multiple tabs or workers.\n */\n isolated: boolean;\n};\n/**\n * DocumentStorage is specifically designed around WarpDrive Cache and Request concepts.\n *\n * CacheFileDocument is a StructuredDocument (request response) whose `content` is\n * the ResourceDocument returned by inserting the request into a Store's Cache.\n */\ntype CacheFileDocument = StructuredDocument<ResourceDocument<ExistingRecordIdentifier>>;\n/**\n * A CacheDocument is a reconstructed request response that rehydrates ResourceDocument\n * with the associated resources based on their identifiers.\n */\ntype CacheDocument = StructuredDocument<ResourceDocument<ExistingResourceObject>>;\ntype CacheResourceEntry = [string, ExistingResourceObject];\ntype CacheFile = {\n documents: [string, CacheFileDocument][];\n resources: CacheResourceEntry[];\n};\ntype DocumentIdentifier = { lid: string };\n\ntype MemCache = {\n documents: Map<string, CacheFileDocument>;\n resources: Map<string, ExistingResourceObject>;\n};\n\nclass InternalDocumentStorage {\n declare readonly options: DocumentStorageOptions;\n declare _fileHandle: Promise<FileSystemFileHandle>;\n declare _channel: BroadcastChannel;\n declare _invalidated: boolean;\n declare _lastModified: number;\n declare _cache: MemCache | null;\n declare _filePromise: Promise<MemCache> | null;\n\n constructor(options: DocumentStorageOptions) {\n this.options = options;\n\n this._lastModified = 0;\n this._invalidated = true;\n this._fileHandle = this._open(options.scope);\n this._channel = Object.assign(new BroadcastChannel(options.scope), {\n onmessage: this._onMessage.bind(this),\n });\n }\n\n _onMessage(_event: MessageEvent) {\n this._invalidated = true;\n }\n\n async _open(scope: string) {\n const directoryHandle = await navigator.storage.getDirectory();\n const fileHandle = await directoryHandle.getFileHandle(scope, { create: true });\n return fileHandle;\n }\n\n async _read(): Promise<MemCache> {\n if (this._filePromise) {\n return this._filePromise;\n }\n\n if (this._invalidated) {\n const updateFile = async () => {\n const fileHandle = await this._fileHandle;\n const file = await fileHandle.getFile();\n\n const lastModified = file.lastModified;\n if (lastModified === this._lastModified && this._cache) {\n return this._cache;\n }\n\n const contents = await file.text();\n const cache = contents ? (JSON.parse(contents) as CacheFile) : ({ documents: [], resources: [] } as CacheFile);\n\n const documents = new Map(cache.documents);\n const resources = new Map(cache.resources);\n\n const cacheMap = { documents, resources };\n this._cache = cacheMap;\n this._invalidated = false;\n this._lastModified = lastModified;\n return cacheMap;\n };\n this._filePromise = updateFile();\n await this._filePromise;\n this._filePromise = null;\n }\n\n return this._cache!;\n }\n\n async _patch(\n documentKey: string,\n document: CacheFileDocument,\n updatedResources: Map<string, ExistingResourceObject>\n ) {\n const fileHandle = await this._fileHandle;\n // secure a lock before getting latest state\n const writable = await fileHandle.createWritable();\n\n const cache = await this._read();\n cache.documents.set(documentKey, document);\n updatedResources.forEach((resource, key) => {\n cache.resources.set(key, resource);\n });\n\n const documents = [...cache.documents.entries()];\n const resources = [...cache.resources.entries()];\n const cacheFile: CacheFile = {\n documents,\n resources,\n };\n\n await writable.write(JSON.stringify(cacheFile));\n await writable.close();\n this._channel.postMessage({ type: 'patch', key: documentKey, resources: [...updatedResources.keys()] });\n }\n\n async getDocument(key: DocumentIdentifier): Promise<CacheDocument | null> {\n const cache = await this._read();\n // clone the document to avoid leaking the internal cache\n const document = safeDocumentHydrate(cache.documents.get(key.lid));\n\n if (!document) {\n return null;\n }\n\n // expand the document with the resources\n if (document.content) {\n if (docHasData(document.content)) {\n let data: ExistingResourceObject | ExistingResourceObject[] | null = null;\n if (Array.isArray(document.content.data)) {\n data = document.content.data.map((resourceIdentifier) => {\n const resource = cache.resources.get(resourceIdentifier.lid);\n if (!resource) {\n throw new Error(`Resource not found for ${resourceIdentifier.lid}`);\n }\n\n // clone the resource to avoid leaking the internal cache\n return structuredClone(resource);\n });\n } else if (document.content.data) {\n const resource = cache.resources.get(document.content.data.lid);\n if (!resource) {\n throw new Error(`Resource not found for ${document.content.data.lid}`);\n }\n\n // clone the resource to avoid leaking the internal cache\n data = structuredClone(resource);\n }\n\n if (document.content.included) {\n const included = document.content.included.map((resourceIdentifier) => {\n const resource = cache.resources.get(resourceIdentifier.lid);\n if (!resource) {\n throw new Error(`Resource not found for ${resourceIdentifier.lid}`);\n }\n\n // clone the resource to avoid leaking the internal cache\n return structuredClone(resource);\n });\n document.content.included = included as ExistingRecordIdentifier[];\n }\n\n document.content.data = data as unknown as ResourceDataDocument<ExistingRecordIdentifier>['data'];\n }\n }\n\n return document as CacheDocument;\n }\n\n async putDocument(\n document: CacheFileDocument,\n resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject\n ): Promise<void> {\n const resources = new Map<string, ExistingResourceObject>();\n\n if (!document.content) {\n throw new Error(`Document content is missing, only finalized documents can be stored`);\n }\n\n if (!document.content.lid) {\n throw new Error(`Document content is missing a lid, only documents with a cache-key can be stored`);\n }\n\n if (docHasData(document.content)) {\n this._getResources(document.content, resourceCollector, resources);\n }\n\n await this._patch(document.content.lid, safeDocumentSerialize(document), resources);\n }\n\n _getResources(\n document: ResourceDataDocument<ExistingRecordIdentifier>,\n resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject,\n resources: Map<string, ExistingResourceObject> = new Map<string, ExistingResourceObject>()\n ) {\n if (Array.isArray(document.data)) {\n document.data.forEach((resourceIdentifier) => {\n const resource = resourceCollector(resourceIdentifier);\n resources.set(resourceIdentifier.lid, structuredClone(resource));\n });\n } else if (document.data) {\n const resource = resourceCollector(document.data);\n resources.set(document.data.lid, structuredClone(resource));\n }\n\n if (document.included) {\n document.included.forEach((resourceIdentifier) => {\n const resource = resourceCollector(resourceIdentifier);\n resources.set(resourceIdentifier.lid, structuredClone(resource));\n });\n }\n\n return resources;\n }\n\n async putResources(\n document: ResourceDataDocument<ExistingRecordIdentifier>,\n resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject\n ) {\n const fileHandle = await this._fileHandle;\n // secure a lock before getting latest state\n const writable = await fileHandle.createWritable();\n\n const cache = await this._read();\n const updatedResources = this._getResources(document, resourceCollector);\n\n updatedResources.forEach((resource, key) => {\n cache.resources.set(key, resource);\n });\n\n const documents = [...cache.documents.entries()];\n const resources = [...cache.resources.entries()];\n const cacheFile: CacheFile = {\n documents,\n resources,\n };\n\n await writable.write(JSON.stringify(cacheFile));\n await writable.close();\n this._channel.postMessage({ type: 'patch', key: null, resources: [...updatedResources.keys()] });\n }\n\n async clear(reset?: boolean) {\n const fileHandle = await this._fileHandle;\n const writable = await fileHandle.createWritable();\n await writable.write('');\n await writable.close();\n\n this._invalidated = true;\n this._lastModified = 0;\n this._cache = null;\n this._filePromise = null;\n this._channel.postMessage({ type: 'clear' });\n\n if (!reset) {\n this._channel.close();\n this._channel = null as unknown as BroadcastChannel;\n\n if (!this.options.isolated) {\n Storages.delete(this.options.scope);\n }\n }\n }\n}\n\nfunction safeDocumentSerialize<T>(document: T): T {\n assert(`Expected to receive a document`, document && typeof document === 'object');\n const doc = document as unknown as {\n request?: StoreRequestContext['request'];\n response?: Response;\n content?: unknown;\n };\n const newDoc: { request?: unknown; response?: unknown; content?: unknown } = {};\n if ('request' in doc) {\n newDoc.request = prepareRequest(doc.request!);\n }\n if ('response' in doc) {\n newDoc.response = prepareResponse(doc.response!);\n }\n\n if ('content' in doc) {\n newDoc.content = structuredClone(doc.content);\n }\n\n return newDoc as T;\n}\n\nfunction prepareRequest(request: StoreRequestContext['request']): RequestInfo {\n const { signal, headers } = request;\n const requestCopy = Object.assign({}, request) as RequestInfo;\n\n delete requestCopy.store;\n\n if (signal instanceof AbortSignal) {\n delete requestCopy.signal;\n }\n\n if (headers instanceof Headers) {\n requestCopy.headers = Array.from(headers.entries()) as unknown as Headers;\n }\n\n return requestCopy;\n}\n\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\nfunction prepareResponse(response: Response | ResponseInfo | null) {\n if (!response) return null;\n\n const clone: Partial<Mutable<Response>> = {};\n\n if (response.headers) {\n clone.headers = Array.from(response.headers.entries()) as unknown as Headers;\n }\n\n clone.ok = response.ok;\n clone.redirected = response.redirected;\n clone.status = response.status;\n clone.statusText = response.statusText;\n clone.type = response.type;\n clone.url = response.url;\n\n return clone;\n}\n\nfunction safeDocumentHydrate<T>(document: T): T {\n assert(`Expected to receive a document`, document && typeof document === 'object');\n const doc = document as unknown as {\n request?: Request | StoreRequestContext['request'];\n response?: Response;\n content?: unknown;\n };\n const newDoc: { request?: StoreRequestContext['request'] | Request; response?: Response; content?: unknown } = {};\n\n if ('request' in doc) {\n const headers = new Headers(doc.request!.headers);\n const req = Object.assign({}, doc.request, { headers });\n newDoc.request = new Request(doc.request!.url ?? '', req);\n }\n\n if ('response' in doc) {\n const headers = new Headers(doc.response!.headers);\n const resp = Object.assign({}, doc.response, { headers });\n newDoc.response = new Response(null, resp);\n }\n\n if ('content' in doc) {\n newDoc.content = structuredClone(doc.content);\n }\n\n return newDoc as T;\n}\n\nfunction docHasData<T>(doc: ResourceDocument<T>): doc is ResourceDataDocument<T> {\n return 'data' in doc;\n}\n\nconst Storages = new Map<string, WeakRef<InternalDocumentStorage>>();\n\n/**\n * DocumentStorage is a wrapper around the StorageManager API that provides\n * a simple interface for reading and updating documents and requests.\n *\n * Some goals for this experiment:\n *\n * - optimize for storing requests/documents\n * - optimize for storing resources\n * - optimize for looking up resources associated to a document\n * - optimize for notifying cross-tab when data is updated\n *\n * optional features:\n *\n * - support for offline mode\n * - ?? support for relationship based cache traversal\n * - a way to index records by type + another field (e.g updatedAt/createAt/name)\n * such that simple queries can be done without having to scan all records\n */\nexport class DocumentStorage {\n declare readonly _storage: InternalDocumentStorage;\n\n constructor(options: Partial<DocumentStorageOptions> = {}) {\n options.isolated = options.isolated ?? false;\n options.scope = options.scope ?? 'default';\n\n const fileName = `${WARP_DRIVE_STORAGE_FILE_NAME}@version_${WARP_DRIVE_STORAGE_VERSION}:${options.scope}`;\n if (!options.isolated && Storages.has(fileName)) {\n const storage = Storages.get(fileName);\n if (storage) {\n this._storage = storage.deref()!;\n return;\n }\n }\n\n const storage = new InternalDocumentStorage({ scope: fileName, isolated: options.isolated });\n this._storage = storage;\n if (!options.isolated) {\n Storages.set(fileName, new WeakRef(storage));\n }\n }\n\n getDocument(key: DocumentIdentifier): Promise<CacheDocument | null> {\n return this._storage.getDocument(key);\n }\n\n putDocument(\n document: CacheFileDocument,\n resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject\n ): Promise<void> {\n return this._storage.putDocument(document, resourceCollector);\n }\n\n putResources(\n document: ResourceDataDocument<ExistingRecordIdentifier>,\n resourceCollector: (resourceIdentifier: ExistingRecordIdentifier) => ExistingResourceObject\n ): Promise<void> {\n return this._storage.putResources(document, resourceCollector);\n }\n\n clear(reset?: boolean) {\n return this._storage.clear(reset);\n }\n}\n"],"names":["WARP_DRIVE_STORAGE_FILE_NAME","WARP_DRIVE_STORAGE_VERSION","InternalDocumentStorage","constructor","options","_lastModified","_invalidated","_fileHandle","_open","scope","_channel","Object","assign","BroadcastChannel","onmessage","_onMessage","bind","_event","directoryHandle","navigator","storage","getDirectory","fileHandle","getFileHandle","create","_read","_filePromise","updateFile","file","getFile","lastModified","_cache","contents","text","cache","JSON","parse","documents","resources","Map","cacheMap","_patch","documentKey","document","updatedResources","writable","createWritable","set","forEach","resource","key","entries","cacheFile","write","stringify","close","postMessage","type","keys","getDocument","safeDocumentHydrate","get","lid","content","docHasData","data","Array","isArray","map","resourceIdentifier","Error","structuredClone","included","putDocument","resourceCollector","_getResources","safeDocumentSerialize","putResources","clear","reset","isolated","Storages","delete","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","doc","newDoc","request","prepareRequest","response","prepareResponse","signal","headers","requestCopy","store","AbortSignal","Headers","from","clone","ok","redirected","status","statusText","url","req","Request","resp","Response","DocumentStorage","fileName","has","_storage","deref","WeakRef"],"mappings":";;AAOO,MAAMA,4BAA4B,GAAG,6BAA6B,CAAA;AAClE,MAAMC,0BAA0B,GAAG,CAAC,CAAA;;AAqB3C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAcA,MAAMC,uBAAuB,CAAC;EAS5BC,WAAWA,CAACC,OAA+B,EAAE;IAC3C,IAAI,CAACA,OAAO,GAAGA,OAAO,CAAA;IAEtB,IAAI,CAACC,aAAa,GAAG,CAAC,CAAA;IACtB,IAAI,CAACC,YAAY,GAAG,IAAI,CAAA;IACxB,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACK,KAAK,CAAC,CAAA;AAC5C,IAAA,IAAI,CAACC,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAAC,IAAIC,gBAAgB,CAACT,OAAO,CAACK,KAAK,CAAC,EAAE;AACjEK,MAAAA,SAAS,EAAE,IAAI,CAACC,UAAU,CAACC,IAAI,CAAC,IAAI,CAAA;AACtC,KAAC,CAAC,CAAA;AACJ,GAAA;EAEAD,UAAUA,CAACE,MAAoB,EAAE;IAC/B,IAAI,CAACX,YAAY,GAAG,IAAI,CAAA;AAC1B,GAAA;EAEA,MAAME,KAAKA,CAACC,KAAa,EAAE;IACzB,MAAMS,eAAe,GAAG,MAAMC,SAAS,CAACC,OAAO,CAACC,YA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xD,WAAW,CAACT,GAAG,CAAC,CAAA;AACvC,GAAA;AAEAuB,EAAAA,WAAWA,CACT9B,QAA2B,EAC3B+B,iBAA2F,EAC5E;IACf,OAAO,IAAI,CAACyC,QAAQ,CAAC1C,WAAW,CAAC9B,QAAQ,EAAE+B,iBAAiB,CAAC,CAAA;AAC/D,GAAA;AAEAG,EAAAA,YAAYA,CACVlC,QAAwD,EACxD+B,iBAA2F,EAC5E;IACf,OAAO,IAAI,CAACyC,QAAQ,CAACtC,YAAY,CAAClC,QAAQ,EAAE+B,iBAAiB,CAAC,CAAA;AAChE,GAAA;EAEAI,KAAKA,CAACC,KAAe,EAAE;AACrB,IAAA,OAAO,IAAI,CAACoC,QAAQ,CAACrC,KAAK,CAACC,KAAK,CAAC,CAAA;AACnC,GAAA;AACF;;;;"}
|
package/dist/persisted-cache.js
CHANGED
|
@@ -35,7 +35,7 @@ class PersistedCache {
|
|
|
35
35
|
*
|
|
36
36
|
* @method put
|
|
37
37
|
* @param {StructuredDocument} doc
|
|
38
|
-
* @
|
|
38
|
+
* @return {ResourceDocument}
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
put(doc) {
|
|
@@ -76,7 +76,7 @@ class PersistedCache {
|
|
|
76
76
|
* @method patch
|
|
77
77
|
* @internal
|
|
78
78
|
* @param op the operation to perform
|
|
79
|
-
* @
|
|
79
|
+
* @return {void}
|
|
80
80
|
*/
|
|
81
81
|
patch(op) {
|
|
82
82
|
this._cache.patch(op);
|
|
@@ -124,7 +124,7 @@ class PersistedCache {
|
|
|
124
124
|
* @method peek
|
|
125
125
|
* @internal
|
|
126
126
|
* @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
|
|
127
|
-
* @
|
|
127
|
+
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
128
128
|
*/
|
|
129
129
|
|
|
130
130
|
peek(identifier) {
|
|
@@ -137,7 +137,7 @@ class PersistedCache {
|
|
|
137
137
|
*
|
|
138
138
|
* @method peekRequest
|
|
139
139
|
* @param {StableDocumentIdentifier}
|
|
140
|
-
* @
|
|
140
|
+
* @return {StableDocumentIdentifier | null}
|
|
141
141
|
* @internal
|
|
142
142
|
*/
|
|
143
143
|
peekRequest(identifier) {
|
|
@@ -152,7 +152,7 @@ class PersistedCache {
|
|
|
152
152
|
* @param identifier
|
|
153
153
|
* @param data
|
|
154
154
|
* @param hasRecord
|
|
155
|
-
* @
|
|
155
|
+
* @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
|
|
156
156
|
*/
|
|
157
157
|
upsert(identifier, data, hasRecord) {
|
|
158
158
|
return this._cache.upsert(identifier, data, hasRecord);
|
|
@@ -170,7 +170,7 @@ class PersistedCache {
|
|
|
170
170
|
*
|
|
171
171
|
* @method fork
|
|
172
172
|
* @internal
|
|
173
|
-
* @
|
|
173
|
+
* @return Promise<Cache>
|
|
174
174
|
*/
|
|
175
175
|
fork() {
|
|
176
176
|
return this._cache.fork();
|
|
@@ -186,7 +186,7 @@ class PersistedCache {
|
|
|
186
186
|
* @method merge
|
|
187
187
|
* @param {Cache} cache
|
|
188
188
|
* @internal
|
|
189
|
-
* @
|
|
189
|
+
* @return Promise<void>
|
|
190
190
|
*/
|
|
191
191
|
merge(cache) {
|
|
192
192
|
return this._cache.merge(cache);
|
|
@@ -238,7 +238,7 @@ class PersistedCache {
|
|
|
238
238
|
* via `cache.hydrate`.
|
|
239
239
|
*
|
|
240
240
|
* @method dump
|
|
241
|
-
* @
|
|
241
|
+
* @return {Promise<ReadableStream>}
|
|
242
242
|
* @internal
|
|
243
243
|
*/
|
|
244
244
|
dump() {
|
|
@@ -259,7 +259,7 @@ class PersistedCache {
|
|
|
259
259
|
*
|
|
260
260
|
* @method hydrate
|
|
261
261
|
* @param {ReadableStream} stream
|
|
262
|
-
* @
|
|
262
|
+
* @return {Promise<void>}
|
|
263
263
|
* @internal
|
|
264
264
|
*/
|
|
265
265
|
hydrate(stream) {
|
|
@@ -347,7 +347,7 @@ class PersistedCache {
|
|
|
347
347
|
* @internal
|
|
348
348
|
* @param identifier
|
|
349
349
|
* @param propertyName
|
|
350
|
-
* @
|
|
350
|
+
* @return {unknown}
|
|
351
351
|
*/
|
|
352
352
|
getAttr(identifier, field) {
|
|
353
353
|
return this._cache.getAttr(identifier, field);
|
|
@@ -372,7 +372,7 @@ class PersistedCache {
|
|
|
372
372
|
* @method changedAttrs
|
|
373
373
|
* @internal
|
|
374
374
|
* @param identifier
|
|
375
|
-
* @
|
|
375
|
+
* @return
|
|
376
376
|
*/
|
|
377
377
|
changedAttrs(identifier) {
|
|
378
378
|
return this._cache.changedAttrs(identifier);
|
|
@@ -384,7 +384,7 @@ class PersistedCache {
|
|
|
384
384
|
* @method hasChangedAttrs
|
|
385
385
|
* @internal
|
|
386
386
|
* @param identifier
|
|
387
|
-
* @
|
|
387
|
+
* @return {boolean}
|
|
388
388
|
*/
|
|
389
389
|
hasChangedAttrs(identifier) {
|
|
390
390
|
return this._cache.hasChangedAttrs(identifier);
|
|
@@ -396,7 +396,7 @@ class PersistedCache {
|
|
|
396
396
|
* @method rollbackAttrs
|
|
397
397
|
* @internal
|
|
398
398
|
* @param identifier
|
|
399
|
-
* @
|
|
399
|
+
* @return the names of attributes that were restored
|
|
400
400
|
*/
|
|
401
401
|
rollbackAttrs(identifier) {
|
|
402
402
|
return this._cache.rollbackAttrs(identifier);
|
|
@@ -471,7 +471,7 @@ class PersistedCache {
|
|
|
471
471
|
* @internal
|
|
472
472
|
* @param identifier
|
|
473
473
|
* @param propertyName
|
|
474
|
-
* @
|
|
474
|
+
* @return resource relationship object
|
|
475
475
|
*/
|
|
476
476
|
getRelationship(identifier, field, isCollection) {
|
|
477
477
|
return this._cache.getRelationship(identifier, field, isCollection);
|
|
@@ -499,7 +499,7 @@ class PersistedCache {
|
|
|
499
499
|
* @method getErrors
|
|
500
500
|
* @internal
|
|
501
501
|
* @param identifier
|
|
502
|
-
* @
|
|
502
|
+
* @return
|
|
503
503
|
*/
|
|
504
504
|
getErrors(identifier) {
|
|
505
505
|
return this._cache.getErrors(identifier);
|
|
@@ -511,7 +511,7 @@ class PersistedCache {
|
|
|
511
511
|
* @method isEmpty
|
|
512
512
|
* @internal
|
|
513
513
|
* @param identifier
|
|
514
|
-
* @
|
|
514
|
+
* @return {boolean}
|
|
515
515
|
*/
|
|
516
516
|
isEmpty(identifier) {
|
|
517
517
|
return this._cache.isEmpty(identifier);
|
|
@@ -524,7 +524,7 @@ class PersistedCache {
|
|
|
524
524
|
* @method isNew
|
|
525
525
|
* @internal
|
|
526
526
|
* @param identifier
|
|
527
|
-
* @
|
|
527
|
+
* @return {boolean}
|
|
528
528
|
*/
|
|
529
529
|
isNew(identifier) {
|
|
530
530
|
return this._cache.isNew(identifier);
|
|
@@ -537,7 +537,7 @@ class PersistedCache {
|
|
|
537
537
|
* @method isDeleted
|
|
538
538
|
* @internal
|
|
539
539
|
* @param identifier
|
|
540
|
-
* @
|
|
540
|
+
* @return {boolean}
|
|
541
541
|
*/
|
|
542
542
|
isDeleted(identifier) {
|
|
543
543
|
return this._cache.isDeleted(identifier);
|
|
@@ -550,7 +550,7 @@ class PersistedCache {
|
|
|
550
550
|
* @method isDeletionCommitted
|
|
551
551
|
* @internal
|
|
552
552
|
* @param identifier
|
|
553
|
-
* @
|
|
553
|
+
* @return {boolean}
|
|
554
554
|
*/
|
|
555
555
|
isDeletionCommitted(identifier) {
|
|
556
556
|
return this._cache.isDeletionCommitted(identifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persisted-cache.js","sources":["../src/persisted-cache/cache.ts"],"sourcesContent":["import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';\nimport type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive-mirror/core-types/cache';\nimport type { ResourceBlob } from '@warp-drive-mirror/core-types/cache/aliases';\nimport type { Change } from '@warp-drive-mirror/core-types/cache/change';\nimport type { Mutation } from '@warp-drive-mirror/core-types/cache/mutations';\nimport type { Operation } from '@warp-drive-mirror/core-types/cache/operations';\nimport type { CollectionRelationship, ResourceRelationship } from '@warp-drive-mirror/core-types/cache/relationship';\nimport type { StableDocumentIdentifier, StableExistingRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';\nimport type { Value } from '@warp-drive-mirror/core-types/json/raw';\nimport type { TypeFromInstanceOrString } from '@warp-drive-mirror/core-types/record';\nimport type { RequestContext, StructuredDataDocument, StructuredDocument } from '@warp-drive-mirror/core-types/request';\nimport type { ResourceDocument, SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\nimport type { ApiError } from '@warp-drive-mirror/core-types/spec/error';\n/**\n * The PersistedCache wraps a Cache to enhance it with\n * Persisted Storage capabilities.\n *\n * @class PersistedCache\n * @internal\n */\nexport class PersistedCache implements Cache {\n declare _cache: Cache;\n declare _db: IDBDatabase;\n declare version: '2';\n\n constructor(cache: Cache, db: IDBDatabase) {\n this.version = '2';\n this._cache = cache;\n this._db = db;\n }\n\n // Cache Management\n // ================\n\n /**\n * Cache the response to a request\n *\n * Unlike `store.push` which has UPSERT\n * semantics, `put` has `replace` semantics similar to\n * the `http` method `PUT`\n *\n * the individually cacheabl\n * e resource data it may contain\n * should upsert, but the document data surrounding it should\n * fully replace any existing information\n *\n * Note that in order to support inserting arbitrary data\n * to the cache that did not originate from a request `put`\n * should expect to sometimes encounter a document with only\n * a `content` member and therefor must not assume the existence\n * of `request` and `response` on the document.\n *\n * @method put\n * @param {StructuredDocument} doc\n * @returns {ResourceDocument}\n * @internal\n */\n put<T>(doc: StructuredDocument<T> | { content: T }): ResourceDocument {\n const result = this._cache.put(doc);\n\n if (!result.lid) {\n return result;\n }\n\n const transaction = this._db.transaction(['request', 'resource'], 'readwrite', { durability: 'relaxed' });\n const request = this._cache.peekRequest({ lid: result.lid })!;\n\n const requests = transaction.objectStore('request');\n const resources = transaction.objectStore('resource');\n\n requests.put(request);\n\n if ('data' in result && result.data) {\n const resourceData: StableExistingRecordIdentifier[] = Array.isArray(result.data) ? result.data : [result.data];\n resourceData.forEach((identifier) => {\n resources.put(this._cache.peek(identifier), identifier.lid);\n });\n }\n\n if ('included' in result && result.included) {\n const included: StableExistingRecordIdentifier[] = result.included;\n included.forEach((identifier) => {\n resources.put(this._cache.peek(identifier), identifier.lid);\n });\n }\n\n return result;\n }\n\n /**\n * Perform an operation on the cache to update the remote state.\n *\n * Note: currently the only valid operation is a MergeOperation\n * which occurs when a collision of identifiers is detected.\n *\n * @method patch\n * @internal\n * @param op the operation to perform\n * @returns {void}\n */\n patch(op: Operation): void {\n this._cache.patch(op);\n }\n\n /**\n * Update resource data with a local mutation. Currently supports operations\n * on relationships only.\n *\n * @method mutate\n * @internal\n * @param mutation\n */\n mutate(mutation: Mutation): void {\n this._cache.mutate(mutation);\n }\n\n /**\n * Peek resource data from the Cache.\n *\n * In development, if the return value\n * is JSON the return value\n * will be deep-cloned and deep-frozen\n * to prevent mutation thereby enforcing cache\n * Immutability.\n *\n * This form of peek is useful for implementations\n * that want to feed raw-data from cache to the UI\n * or which want to interact with a blob of data\n * directly from the presentation cache.\n *\n * An implementation might want to do this because\n * de-referencing records which read from their own\n * blob is generally safer because the record does\n * not require retainining connections to the Store\n * and Cache to present data on a per-field basis.\n *\n * This generally takes the place of `getAttr` as\n * an API and may even take the place of `getRelationship`\n * depending on implementation specifics, though this\n * latter usage is less recommended due to the advantages\n * of the Graph handling necessary entanglements and\n * notifications for relational data.\n *\n * @method peek\n * @internal\n * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier\n * @returns {ResourceDocument | ResourceBlob | null} the known resource data\n */\n peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;\n peek(identifier: StableDocumentIdentifier): ResourceDocument | null;\n peek(identifier: StableRecordIdentifier | StableDocumentIdentifier): unknown {\n return this._cache.peek(identifier);\n }\n\n /**\n * Peek the Cache for the existing request data associated with\n * a cacheable request\n *\n * @method peekRequest\n * @param {StableDocumentIdentifier}\n * @returns {StableDocumentIdentifier | null}\n * @internal\n */\n peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null {\n return this._cache.peekRequest(identifier);\n }\n\n /**\n * Push resource data from a remote source into the cache for this identifier\n *\n * @method upsert\n * @internal\n * @param identifier\n * @param data\n * @param hasRecord\n * @returns {void | string[]} if `hasRecord` is true then calculated key changes should be returned\n */\n upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[] {\n return this._cache.upsert(identifier, data, hasRecord);\n }\n\n // Cache Forking Support\n // =====================\n\n /**\n * Create a fork of the cache from the current state.\n *\n * Applications should typically not call this method themselves,\n * preferring instead to fork at the Store level, which will\n * utilize this method to fork the cache.\n *\n * @method fork\n * @internal\n * @returns Promise<Cache>\n */\n fork(): Promise<Cache> {\n return this._cache.fork();\n }\n\n /**\n * Merge a fork back into a parent Cache.\n *\n * Applications should typically not call this method themselves,\n * preferring instead to merge at the Store level, which will\n * utilize this method to merge the caches.\n *\n * @method merge\n * @param {Cache} cache\n * @internal\n * @returns Promise<void>\n */\n merge(cache: Cache): Promise<void> {\n return this._cache.merge(cache);\n }\n\n /**\n * Generate the list of changes applied to all\n * record in the store.\n *\n * Each individual resource or document that has\n * been mutated should be described as an individual\n * `Change` entry in the returned array.\n *\n * A `Change` is described by an object containing up to\n * three properties: (1) the `identifier` of the entity that\n * changed; (2) the `op` code of that change being one of\n * `upsert` or `remove`, and if the op is `upsert` a `patch`\n * containing the data to merge into the cache for the given\n * entity.\n *\n * This `patch` is opaque to the Store but should be understood\n * by the Cache and may expect to be utilized by an Adapter\n * when generating data during a `save` operation.\n *\n * It is generally recommended that the `patch` contain only\n * the updated state, ignoring fields that are unchanged\n *\n * ```ts\n * interface Change {\n * identifier: StableRecordIdentifier | StableDocumentIdentifier;\n * op: 'upsert' | 'remove';\n * patch?: unknown;\n * }\n * ```\n *\n * @method diff\n * @internal\n */\n diff(): Promise<Change[]> {\n return this._cache.diff();\n }\n\n // SSR Support\n // ===========\n\n /**\n * Serialize the entire contents of the Cache into a Stream\n * which may be fed back into a new instance of the same Cache\n * via `cache.hydrate`.\n *\n * @method dump\n * @returns {Promise<ReadableStream>}\n * @internal\n */\n dump(): Promise<ReadableStream<unknown>> {\n return this._cache.dump();\n }\n\n /**\n * hydrate a Cache from a Stream with content previously serialized\n * from another instance of the same Cache, resolving when hydration\n * is complete.\n *\n * This method should expect to be called both in the context of restoring\n * the Cache during application rehydration after SSR **AND** at unknown\n * times during the lifetime of an already booted application when it is\n * desired to bulk-load additional information into the cache. This latter\n * behavior supports optimizing pre/fetching of data for route transitions\n * via data-only SSR modes.\n *\n * @method hydrate\n * @param {ReadableStream} stream\n * @returns {Promise<void>}\n * @internal\n */\n hydrate(stream: ReadableStream<unknown>): Promise<void> {\n return this._cache.hydrate(stream);\n }\n\n // Cache\n // =====\n\n // Resource Support\n // ================\n\n /**\n * [LIFECYLCE] Signal to the cache that a new record has been instantiated on the client\n *\n * It returns properties from options that should be set on the record during the create\n * process. This return value behavior is deprecated.\n *\n * @method clientDidCreate\n * @internal\n * @param identifier\n * @param options\n */\n clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown> {\n return this._cache.clientDidCreate(identifier, options);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * will be part of a save transaction.\n *\n * @method willCommit\n * @internal\n * @param identifier\n */\n willCommit(identifier: StableRecordIdentifier, context: RequestContext): void {\n this._cache.willCommit(identifier, context);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * was successfully updated as part of a save transaction.\n *\n * @method didCommit\n * @internal\n * @param identifier\n * @param data\n */\n didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument {\n return this._cache.didCommit(identifier, result);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * was update via a save transaction failed.\n *\n * @method commitWasRejected\n * @internal\n * @param identifier\n * @param errors\n */\n commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void {\n this._cache.commitWasRejected(identifier, errors);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that all data for a resource\n * should be cleared.\n *\n * @method unloadRecord\n * @internal\n * @param identifier\n */\n unloadRecord(identifier: StableRecordIdentifier): void {\n this._cache.unloadRecord(identifier);\n }\n\n // Granular Resource Data APIs\n // ===========================\n\n /**\n * Retrieve the data for an attribute from the cache\n *\n * @method getAttr\n * @internal\n * @param identifier\n * @param propertyName\n * @returns {unknown}\n */\n getAttr(identifier: StableRecordIdentifier, field: string): Value | undefined {\n return this._cache.getAttr(identifier, field);\n }\n\n /**\n * Mutate the data for an attribute in the cache\n *\n * @method setAttr\n * @internal\n * @param identifier\n * @param propertyName\n * @param value\n */\n setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void {\n this._cache.setAttr(identifier, propertyName, value);\n }\n\n /**\n * Query the cache for the changed attributes of a resource.\n *\n * @method changedAttrs\n * @internal\n * @param identifier\n * @returns\n */\n changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash {\n return this._cache.changedAttrs(identifier);\n }\n\n /**\n * Query the cache for whether any mutated attributes exist\n *\n * @method hasChangedAttrs\n * @internal\n * @param identifier\n * @returns {boolean}\n */\n hasChangedAttrs(identifier: StableRecordIdentifier): boolean {\n return this._cache.hasChangedAttrs(identifier);\n }\n\n /**\n * Tell the cache to discard any uncommitted mutations to attributes\n *\n * @method rollbackAttrs\n * @internal\n * @param identifier\n * @returns the names of attributes that were restored\n */\n rollbackAttrs(identifier: StableRecordIdentifier): string[] {\n return this._cache.rollbackAttrs(identifier);\n }\n\n /**\n * Query the cache for the changes to relationships of a resource.\n *\n * Returns a map of relationship names to RelationshipDiff objects.\n *\n * ```ts\n * type RelationshipDiff =\n | {\n kind: 'collection';\n remoteState: StableRecordIdentifier[];\n additions: Set<StableRecordIdentifier>;\n removals: Set<StableRecordIdentifier>;\n localState: StableRecordIdentifier[];\n reordered: boolean;\n }\n | {\n kind: 'resource';\n remoteState: StableRecordIdentifier | null;\n localState: StableRecordIdentifier | null;\n };\n ```\n *\n * @method changedRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {Map<string, RelationshipDiff>}\n */\n changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff> {\n return this._cache.changedRelationships(identifier);\n }\n\n /**\n * Query the cache for whether any mutated attributes exist\n *\n * @method hasChangedRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {boolean}\n */\n hasChangedRelationships(identifier: StableRecordIdentifier): boolean {\n return this._cache.hasChangedRelationships(identifier);\n }\n\n /**\n * Tell the cache to discard any uncommitted mutations to relationships.\n *\n * This will also discard the change on any appropriate inverses.\n *\n * This method is a candidate to become a mutation\n *\n * @method rollbackRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {string[]} the names of relationships that were restored\n */\n rollbackRelationships(identifier: StableRecordIdentifier): string[] {\n return this._cache.rollbackRelationships(identifier);\n }\n\n // Relationships\n // =============\n\n /**\n * Query the cache for the current state of a relationship property\n *\n * @method getRelationship\n * @internal\n * @param identifier\n * @param propertyName\n * @returns resource relationship object\n */\n getRelationship(\n identifier: StableRecordIdentifier,\n field: string,\n isCollection?: boolean\n ): ResourceRelationship | CollectionRelationship {\n return this._cache.getRelationship(identifier, field, isCollection);\n }\n\n // Resource State\n // ===============\n\n /**\n * Update the cache state for the given resource to be marked as locally deleted,\n * or remove such a mark.\n *\n * @method setIsDeleted\n * @internal\n * @param identifier\n * @param isDeleted\n */\n setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void {\n this._cache.setIsDeleted(identifier, isDeleted);\n }\n\n /**\n * Query the cache for any validation errors applicable to the given resource.\n *\n * @method getErrors\n * @internal\n * @param identifier\n * @returns\n */\n getErrors(identifier: StableRecordIdentifier): ApiError[] {\n return this._cache.getErrors(identifier);\n }\n\n /**\n * Query the cache for whether a given resource has any available data\n *\n * @method isEmpty\n * @internal\n * @param identifier\n * @returns {boolean}\n */\n isEmpty(identifier: StableRecordIdentifier): boolean {\n return this._cache.isEmpty(identifier);\n }\n\n /**\n * Query the cache for whether a given resource was created locally and not\n * yet persisted.\n *\n * @method isNew\n * @internal\n * @param identifier\n * @returns {boolean}\n */\n isNew(identifier: StableRecordIdentifier): boolean {\n return this._cache.isNew(identifier);\n }\n\n /**\n * Query the cache for whether a given resource is marked as deleted (but not\n * necessarily persisted yet).\n *\n * @method isDeleted\n * @internal\n * @param identifier\n * @returns {boolean}\n */\n isDeleted(identifier: StableRecordIdentifier): boolean {\n return this._cache.isDeleted(identifier);\n }\n\n /**\n * Query the cache for whether a given resource has been deleted and that deletion\n * has also been persisted.\n *\n * @method isDeletionCommitted\n * @internal\n * @param identifier\n * @returns {boolean}\n */\n isDeletionCommitted(identifier: StableRecordIdentifier): boolean {\n return this._cache.isDeletionCommitted(identifier);\n }\n}\n"],"names":["PersistedCache","constructor","cache","db","version","_cache","_db","put","doc","result","lid","transaction","durability","request","peekRequest","requests","objectStore","resources","data","resourceData","Array","isArray","forEach","identifier","peek","included","patch","op","mutate","mutation","upsert","hasRecord","fork","merge","diff","dump","hydrate","stream","clientDidCreate","options","willCommit","context","didCommit","commitWasRejected","errors","unloadRecord","getAttr","field","setAttr","propertyName","value","changedAttrs","hasChangedAttrs","rollbackAttrs","changedRelationships","hasChangedRelationships","rollbackRelationships","getRelationship","isCollection","setIsDeleted","isDeleted","getErrors","isEmpty","isNew","isDeletionCommitted"],"mappings":"AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAkB;AAK3CC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,EAAe,EAAE;IACzC,IAAI,CAACC,OAAO,GAAG,GAAG,CAAA;IAClB,IAAI,CAACC,MAAM,GAAGH,KAAK,CAAA;IACnB,IAAI,CAACI,GAAG,GAAGH,EAAE,CAAA;AACf,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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IAAI,CAAC1B,MAAM,CAACyB,MAAM,CAACP,UAAU,EAAEL,IAAI,EAAEa,SAAS,CAAC,CAAA;AACxD,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,IAAIA,GAAmB;AACrB,IAAA,OAAO,IAAI,CAAC3B,MAAM,CAAC2B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,KAAKA,CAAC/B,KAAY,EAAiB;AACjC,IAAA,OAAO,IAAI,CAACG,MAAM,CAAC4B,KAAK,CAAC/B,KAAK,CAAC,CAAA;AACjC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEgC,EAAAA,IAAIA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAAC7B,MAAM,CAAC6B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,IAAIA,GAAqC;AACvC,IAAA,OAAO,IAAI,CAAC9B,MAAM,CAAC8B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,OAAOA,CAACC,MAA+B,EAAiB;AACtD,IAAA,OAAO,IAAI,CAAChC,MAAM,CAAC+B,OAAO,CAACC,MAAM,CAAC,CAAA;AACpC,GAAA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,eAAeA,CAACf,UAAkC,EAAEgB,OAAiC,EAA2B;IAC9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YAAY,EAAEC,KAAK,CAAC,CAAA;AACtD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,YAAYA,CAAC5B,UAAkC,EAAyB;AACtE,IAAA,OAAO,IAAI,CAAClB,MAAM,CAAC8C,YAAY,CAAC5B,UAAU,CAAC,CAAA;AAC7C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE6B,eAAeA,CAAC7B,UAAkC,EAAW;AAC3D,IAAA,OAAO,IAAI,CAAClB,MAAM,CAAC+C,eAAe,CAAC7B,UAAU,CAAC,CAAA;AAChD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE8B,aAAaA,CAAC9B,UAAkC,EAAY;AAC1D,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACgD,aAAa,CAAC9B,UAAU,CAAC,CAAA;AAC9C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE+B,oBAAoBA,CAAC/B,UAAkC,EAAiC;AACtF,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACiD,oBAAoB,CAAC/B,UAAU,CAAC,CAAA;AACrD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEgC,uBAAuBA,CAAChC,UAAkC,EAAW;AACnE,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACkD,uBAAuB,CAAChC,UAAU,CAAC,CAAA;AACxD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEiC,qBAAqBA,CAACjC,UAAkC,EAAY;AAClE,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACmD,qBAAqB,CAACjC,UAAU,CAAC,CAAA;AACtD,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEkC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
|
1
|
+
{"version":3,"file":"persisted-cache.js","sources":["../src/persisted-cache/cache.ts"],"sourcesContent":["import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';\nimport type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive-mirror/core-types/cache';\nimport type { ResourceBlob } from '@warp-drive-mirror/core-types/cache/aliases';\nimport type { Change } from '@warp-drive-mirror/core-types/cache/change';\nimport type { Mutation } from '@warp-drive-mirror/core-types/cache/mutations';\nimport type { Operation } from '@warp-drive-mirror/core-types/cache/operations';\nimport type { CollectionRelationship, ResourceRelationship } from '@warp-drive-mirror/core-types/cache/relationship';\nimport type { StableDocumentIdentifier, StableExistingRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';\nimport type { Value } from '@warp-drive-mirror/core-types/json/raw';\nimport type { TypeFromInstanceOrString } from '@warp-drive-mirror/core-types/record';\nimport type { RequestContext, StructuredDataDocument, StructuredDocument } from '@warp-drive-mirror/core-types/request';\nimport type { ResourceDocument, SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\nimport type { ApiError } from '@warp-drive-mirror/core-types/spec/error';\n/**\n * The PersistedCache wraps a Cache to enhance it with\n * Persisted Storage capabilities.\n *\n * @class PersistedCache\n * @internal\n */\nexport class PersistedCache implements Cache {\n declare _cache: Cache;\n declare _db: IDBDatabase;\n declare version: '2';\n\n constructor(cache: Cache, db: IDBDatabase) {\n this.version = '2';\n this._cache = cache;\n this._db = db;\n }\n\n // Cache Management\n // ================\n\n /**\n * Cache the response to a request\n *\n * Unlike `store.push` which has UPSERT\n * semantics, `put` has `replace` semantics similar to\n * the `http` method `PUT`\n *\n * the individually cacheabl\n * e resource data it may contain\n * should upsert, but the document data surrounding it should\n * fully replace any existing information\n *\n * Note that in order to support inserting arbitrary data\n * to the cache that did not originate from a request `put`\n * should expect to sometimes encounter a document with only\n * a `content` member and therefor must not assume the existence\n * of `request` and `response` on the document.\n *\n * @method put\n * @param {StructuredDocument} doc\n * @return {ResourceDocument}\n * @internal\n */\n put<T>(doc: StructuredDocument<T> | { content: T }): ResourceDocument {\n const result = this._cache.put(doc);\n\n if (!result.lid) {\n return result;\n }\n\n const transaction = this._db.transaction(['request', 'resource'], 'readwrite', { durability: 'relaxed' });\n const request = this._cache.peekRequest({ lid: result.lid })!;\n\n const requests = transaction.objectStore('request');\n const resources = transaction.objectStore('resource');\n\n requests.put(request);\n\n if ('data' in result && result.data) {\n const resourceData: StableExistingRecordIdentifier[] = Array.isArray(result.data) ? result.data : [result.data];\n resourceData.forEach((identifier) => {\n resources.put(this._cache.peek(identifier), identifier.lid);\n });\n }\n\n if ('included' in result && result.included) {\n const included: StableExistingRecordIdentifier[] = result.included;\n included.forEach((identifier) => {\n resources.put(this._cache.peek(identifier), identifier.lid);\n });\n }\n\n return result;\n }\n\n /**\n * Perform an operation on the cache to update the remote state.\n *\n * Note: currently the only valid operation is a MergeOperation\n * which occurs when a collision of identifiers is detected.\n *\n * @method patch\n * @internal\n * @param op the operation to perform\n * @return {void}\n */\n patch(op: Operation): void {\n this._cache.patch(op);\n }\n\n /**\n * Update resource data with a local mutation. Currently supports operations\n * on relationships only.\n *\n * @method mutate\n * @internal\n * @param mutation\n */\n mutate(mutation: Mutation): void {\n this._cache.mutate(mutation);\n }\n\n /**\n * Peek resource data from the Cache.\n *\n * In development, if the return value\n * is JSON the return value\n * will be deep-cloned and deep-frozen\n * to prevent mutation thereby enforcing cache\n * Immutability.\n *\n * This form of peek is useful for implementations\n * that want to feed raw-data from cache to the UI\n * or which want to interact with a blob of data\n * directly from the presentation cache.\n *\n * An implementation might want to do this because\n * de-referencing records which read from their own\n * blob is generally safer because the record does\n * not require retainining connections to the Store\n * and Cache to present data on a per-field basis.\n *\n * This generally takes the place of `getAttr` as\n * an API and may even take the place of `getRelationship`\n * depending on implementation specifics, though this\n * latter usage is less recommended due to the advantages\n * of the Graph handling necessary entanglements and\n * notifications for relational data.\n *\n * @method peek\n * @internal\n * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier\n * @return {ResourceDocument | ResourceBlob | null} the known resource data\n */\n peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;\n peek(identifier: StableDocumentIdentifier): ResourceDocument | null;\n peek(identifier: StableRecordIdentifier | StableDocumentIdentifier): unknown {\n return this._cache.peek(identifier);\n }\n\n /**\n * Peek the Cache for the existing request data associated with\n * a cacheable request\n *\n * @method peekRequest\n * @param {StableDocumentIdentifier}\n * @return {StableDocumentIdentifier | null}\n * @internal\n */\n peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null {\n return this._cache.peekRequest(identifier);\n }\n\n /**\n * Push resource data from a remote source into the cache for this identifier\n *\n * @method upsert\n * @internal\n * @param identifier\n * @param data\n * @param hasRecord\n * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned\n */\n upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[] {\n return this._cache.upsert(identifier, data, hasRecord);\n }\n\n // Cache Forking Support\n // =====================\n\n /**\n * Create a fork of the cache from the current state.\n *\n * Applications should typically not call this method themselves,\n * preferring instead to fork at the Store level, which will\n * utilize this method to fork the cache.\n *\n * @method fork\n * @internal\n * @return Promise<Cache>\n */\n fork(): Promise<Cache> {\n return this._cache.fork();\n }\n\n /**\n * Merge a fork back into a parent Cache.\n *\n * Applications should typically not call this method themselves,\n * preferring instead to merge at the Store level, which will\n * utilize this method to merge the caches.\n *\n * @method merge\n * @param {Cache} cache\n * @internal\n * @return Promise<void>\n */\n merge(cache: Cache): Promise<void> {\n return this._cache.merge(cache);\n }\n\n /**\n * Generate the list of changes applied to all\n * record in the store.\n *\n * Each individual resource or document that has\n * been mutated should be described as an individual\n * `Change` entry in the returned array.\n *\n * A `Change` is described by an object containing up to\n * three properties: (1) the `identifier` of the entity that\n * changed; (2) the `op` code of that change being one of\n * `upsert` or `remove`, and if the op is `upsert` a `patch`\n * containing the data to merge into the cache for the given\n * entity.\n *\n * This `patch` is opaque to the Store but should be understood\n * by the Cache and may expect to be utilized by an Adapter\n * when generating data during a `save` operation.\n *\n * It is generally recommended that the `patch` contain only\n * the updated state, ignoring fields that are unchanged\n *\n * ```ts\n * interface Change {\n * identifier: StableRecordIdentifier | StableDocumentIdentifier;\n * op: 'upsert' | 'remove';\n * patch?: unknown;\n * }\n * ```\n *\n * @method diff\n * @internal\n */\n diff(): Promise<Change[]> {\n return this._cache.diff();\n }\n\n // SSR Support\n // ===========\n\n /**\n * Serialize the entire contents of the Cache into a Stream\n * which may be fed back into a new instance of the same Cache\n * via `cache.hydrate`.\n *\n * @method dump\n * @return {Promise<ReadableStream>}\n * @internal\n */\n dump(): Promise<ReadableStream<unknown>> {\n return this._cache.dump();\n }\n\n /**\n * hydrate a Cache from a Stream with content previously serialized\n * from another instance of the same Cache, resolving when hydration\n * is complete.\n *\n * This method should expect to be called both in the context of restoring\n * the Cache during application rehydration after SSR **AND** at unknown\n * times during the lifetime of an already booted application when it is\n * desired to bulk-load additional information into the cache. This latter\n * behavior supports optimizing pre/fetching of data for route transitions\n * via data-only SSR modes.\n *\n * @method hydrate\n * @param {ReadableStream} stream\n * @return {Promise<void>}\n * @internal\n */\n hydrate(stream: ReadableStream<unknown>): Promise<void> {\n return this._cache.hydrate(stream);\n }\n\n // Cache\n // =====\n\n // Resource Support\n // ================\n\n /**\n * [LIFECYLCE] Signal to the cache that a new record has been instantiated on the client\n *\n * It returns properties from options that should be set on the record during the create\n * process. This return value behavior is deprecated.\n *\n * @method clientDidCreate\n * @internal\n * @param identifier\n * @param options\n */\n clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, unknown>): Record<string, unknown> {\n return this._cache.clientDidCreate(identifier, options);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * will be part of a save transaction.\n *\n * @method willCommit\n * @internal\n * @param identifier\n */\n willCommit(identifier: StableRecordIdentifier, context: RequestContext): void {\n this._cache.willCommit(identifier, context);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * was successfully updated as part of a save transaction.\n *\n * @method didCommit\n * @internal\n * @param identifier\n * @param data\n */\n didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument {\n return this._cache.didCommit(identifier, result);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that a resource\n * was update via a save transaction failed.\n *\n * @method commitWasRejected\n * @internal\n * @param identifier\n * @param errors\n */\n commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void {\n this._cache.commitWasRejected(identifier, errors);\n }\n\n /**\n * [LIFECYCLE] Signals to the cache that all data for a resource\n * should be cleared.\n *\n * @method unloadRecord\n * @internal\n * @param identifier\n */\n unloadRecord(identifier: StableRecordIdentifier): void {\n this._cache.unloadRecord(identifier);\n }\n\n // Granular Resource Data APIs\n // ===========================\n\n /**\n * Retrieve the data for an attribute from the cache\n *\n * @method getAttr\n * @internal\n * @param identifier\n * @param propertyName\n * @return {unknown}\n */\n getAttr(identifier: StableRecordIdentifier, field: string): Value | undefined {\n return this._cache.getAttr(identifier, field);\n }\n\n /**\n * Mutate the data for an attribute in the cache\n *\n * @method setAttr\n * @internal\n * @param identifier\n * @param propertyName\n * @param value\n */\n setAttr(identifier: StableRecordIdentifier, propertyName: string, value: Value): void {\n this._cache.setAttr(identifier, propertyName, value);\n }\n\n /**\n * Query the cache for the changed attributes of a resource.\n *\n * @method changedAttrs\n * @internal\n * @param identifier\n * @return\n */\n changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash {\n return this._cache.changedAttrs(identifier);\n }\n\n /**\n * Query the cache for whether any mutated attributes exist\n *\n * @method hasChangedAttrs\n * @internal\n * @param identifier\n * @return {boolean}\n */\n hasChangedAttrs(identifier: StableRecordIdentifier): boolean {\n return this._cache.hasChangedAttrs(identifier);\n }\n\n /**\n * Tell the cache to discard any uncommitted mutations to attributes\n *\n * @method rollbackAttrs\n * @internal\n * @param identifier\n * @return the names of attributes that were restored\n */\n rollbackAttrs(identifier: StableRecordIdentifier): string[] {\n return this._cache.rollbackAttrs(identifier);\n }\n\n /**\n * Query the cache for the changes to relationships of a resource.\n *\n * Returns a map of relationship names to RelationshipDiff objects.\n *\n * ```ts\n * type RelationshipDiff =\n | {\n kind: 'collection';\n remoteState: StableRecordIdentifier[];\n additions: Set<StableRecordIdentifier>;\n removals: Set<StableRecordIdentifier>;\n localState: StableRecordIdentifier[];\n reordered: boolean;\n }\n | {\n kind: 'resource';\n remoteState: StableRecordIdentifier | null;\n localState: StableRecordIdentifier | null;\n };\n ```\n *\n * @method changedRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {Map<string, RelationshipDiff>}\n */\n changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff> {\n return this._cache.changedRelationships(identifier);\n }\n\n /**\n * Query the cache for whether any mutated attributes exist\n *\n * @method hasChangedRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {boolean}\n */\n hasChangedRelationships(identifier: StableRecordIdentifier): boolean {\n return this._cache.hasChangedRelationships(identifier);\n }\n\n /**\n * Tell the cache to discard any uncommitted mutations to relationships.\n *\n * This will also discard the change on any appropriate inverses.\n *\n * This method is a candidate to become a mutation\n *\n * @method rollbackRelationships\n * @public\n * @param {StableRecordIdentifier} identifier\n * @return {string[]} the names of relationships that were restored\n */\n rollbackRelationships(identifier: StableRecordIdentifier): string[] {\n return this._cache.rollbackRelationships(identifier);\n }\n\n // Relationships\n // =============\n\n /**\n * Query the cache for the current state of a relationship property\n *\n * @method getRelationship\n * @internal\n * @param identifier\n * @param propertyName\n * @return resource relationship object\n */\n getRelationship(\n identifier: StableRecordIdentifier,\n field: string,\n isCollection?: boolean\n ): ResourceRelationship | CollectionRelationship {\n return this._cache.getRelationship(identifier, field, isCollection);\n }\n\n // Resource State\n // ===============\n\n /**\n * Update the cache state for the given resource to be marked as locally deleted,\n * or remove such a mark.\n *\n * @method setIsDeleted\n * @internal\n * @param identifier\n * @param isDeleted\n */\n setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void {\n this._cache.setIsDeleted(identifier, isDeleted);\n }\n\n /**\n * Query the cache for any validation errors applicable to the given resource.\n *\n * @method getErrors\n * @internal\n * @param identifier\n * @return\n */\n getErrors(identifier: StableRecordIdentifier): ApiError[] {\n return this._cache.getErrors(identifier);\n }\n\n /**\n * Query the cache for whether a given resource has any available data\n *\n * @method isEmpty\n * @internal\n * @param identifier\n * @return {boolean}\n */\n isEmpty(identifier: StableRecordIdentifier): boolean {\n return this._cache.isEmpty(identifier);\n }\n\n /**\n * Query the cache for whether a given resource was created locally and not\n * yet persisted.\n *\n * @method isNew\n * @internal\n * @param identifier\n * @return {boolean}\n */\n isNew(identifier: StableRecordIdentifier): boolean {\n return this._cache.isNew(identifier);\n }\n\n /**\n * Query the cache for whether a given resource is marked as deleted (but not\n * necessarily persisted yet).\n *\n * @method isDeleted\n * @internal\n * @param identifier\n * @return {boolean}\n */\n isDeleted(identifier: StableRecordIdentifier): boolean {\n return this._cache.isDeleted(identifier);\n }\n\n /**\n * Query the cache for whether a given resource has been deleted and that deletion\n * has also been persisted.\n *\n * @method isDeletionCommitted\n * @internal\n * @param identifier\n * @return {boolean}\n */\n isDeletionCommitted(identifier: StableRecordIdentifier): boolean {\n return this._cache.isDeletionCommitted(identifier);\n }\n}\n"],"names":["PersistedCache","constructor","cache","db","version","_cache","_db","put","doc","result","lid","transaction","durability","request","peekRequest","requests","objectStore","resources","data","resourceData","Array","isArray","forEach","identifier","peek","included","patch","op","mutate","mutation","upsert","hasRecord","fork","merge","diff","dump","hydrate","stream","clientDidCreate","options","willCommit","context","didCommit","commitWasRejected","errors","unloadRecord","getAttr","field","setAttr","propertyName","value","changedAttrs","hasChangedAttrs","rollbackAttrs","changedRelationships","hasChangedRelationships","rollbackRelationships","getRelationship","isCollection","setIsDeleted","isDeleted","getErrors","isEmpty","isNew","isDeletionCommitted"],"mappings":"AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAkB;AAK3CC,E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AEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACET,WAAWA,CAACS,UAAoC,EAA+C;AAC7F,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACS,WAAW,CAACS,UAAU,CAAC,CAAA;AAC5C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEO,EAAAA,MAAMA,CAACP,UAAkC,EAAEL,IAAkB,EAAEa,SAAkB,EAAmB;IAClG,OAAO,IAAI,CAAC1B,MAAM,CAACyB,MAAM,CAACP,UAAU,EAAEL,IAAI,EAAEa,SAAS,CAAC,CAAA;AACxD,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,IAAIA,GAAmB;AACrB,IAAA,OAAO,IAAI,CAAC3B,MAAM,CAAC2B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,KAAKA,CAAC/B,KAAY,EAAiB;AACjC,IAAA,OAAO,IAAI,CAACG,MAAM,CAAC4B,KAAK,CAAC/B,KAAK,CAAC,CAAA;AACjC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEgC,EAAAA,IAAIA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAAC7B,MAAM,CAAC6B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,IAAIA,GAAqC;AACvC,IAAA,OAAO,IAAI,CAAC9B,MAAM,CAAC8B,IAAI,EAAE,CAAA;AAC3B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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BAAuB,CAAChC,UAAU,CAAC,CAAA;AACxD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEiC,qBAAqBA,CAACjC,UAAkC,EAAY;AAClE,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACmD,qBAAqB,CAACjC,UAAU,CAAC,CAAA;AACtD,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEkC,EAAAA,eAAeA,CACblC,UAAkC,EAClCwB,KAAa,EACbW,YAAsB,EACyB;IAC/C,OAAO,IAAI,CAACrD,MAAM,CAACoD,eAAe,CAAClC,UAAU,EAAEwB,KAAK,EAAEW,YAAY,CAAC,CAAA;AACrE,GAAA;;AAEA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,YAAYA,CAACpC,UAAkC,EAAEqC,SAAkB,EAAQ;IACzE,IAAI,CAACvD,MAAM,CAACsD,YAAY,CAACpC,UAAU,EAAEqC,SAAS,CAAC,CAAA;AACjD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACtC,UAAkC,EAAc;AACxD,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACwD,SAAS,CAACtC,UAAU,CAAC,CAAA;AAC1C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEuC,OAAOA,CAACvC,UAAkC,EAAW;AACnD,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACyD,OAAO,CAACvC,UAAU,CAAC,CAAA;AACxC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEwC,KAAKA,CAACxC,UAAkC,EAAW;AACjD,IAAA,OAAO,IAAI,CAAClB,MAAM,CAAC0D,KAAK,CAACxC,UAAU,CAAC,CAAA;AACtC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEqC,SAASA,CAACrC,UAAkC,EAAW;AACrD,IAAA,OAAO,IAAI,CAAClB,MAAM,CAACuD,SAAS,CAACrC,UAAU,CAAC,CAAA;AAC1C,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEyC,mBAAmBA,CAACzC,UAAkC,EAAW;AAC/D,IAAA,OAAO,IAAI,CAAClB,MAAM,CAAC2D,mBAAmB,CAACzC,UAAU,CAAC,CAAA;AACpD,GAAA;AACF;;;;"}
|
package/dist/worker-fetch.js
CHANGED
|
@@ -24,21 +24,15 @@ class WorkerFetch {
|
|
|
24
24
|
constructor(worker) {
|
|
25
25
|
this.threadId = isServerEnv ? '' : crypto.randomUUID();
|
|
26
26
|
this.pending = new Map();
|
|
27
|
-
const isTesting = macroCondition(getGlobalConfig().
|
|
28
|
-
macroCondition(getGlobalConfig().
|
|
27
|
+
const isTesting = macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING) ? true : false;
|
|
28
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
29
29
|
if (!test) {
|
|
30
30
|
throw new Error(`Expected a SharedWorker instance`);
|
|
31
31
|
}
|
|
32
32
|
})(isTesting || isServerEnv || worker instanceof SharedWorker) : {};
|
|
33
33
|
this.worker = worker;
|
|
34
34
|
if (!isServerEnv) {
|
|
35
|
-
|
|
36
|
-
const port = this.worker instanceof SharedWorker ? this.worker.port : this.worker;
|
|
37
|
-
port.postMessage({
|
|
38
|
-
type: 'connect',
|
|
39
|
-
thread: this.threadId
|
|
40
|
-
}, [this.channel.port2]);
|
|
41
|
-
this.channel.port1.onmessage = event => {
|
|
35
|
+
const fn = event => {
|
|
42
36
|
const {
|
|
43
37
|
type,
|
|
44
38
|
id,
|
|
@@ -74,6 +68,20 @@ class WorkerFetch {
|
|
|
74
68
|
return;
|
|
75
69
|
}
|
|
76
70
|
};
|
|
71
|
+
if (worker instanceof SharedWorker) {
|
|
72
|
+
worker.port.postMessage({
|
|
73
|
+
type: 'connect',
|
|
74
|
+
thread: this.threadId
|
|
75
|
+
});
|
|
76
|
+
worker.port.onmessage = fn;
|
|
77
|
+
} else if (worker) {
|
|
78
|
+
this.channel = new MessageChannel();
|
|
79
|
+
worker.postMessage({
|
|
80
|
+
type: 'connect',
|
|
81
|
+
thread: this.threadId
|
|
82
|
+
}, [this.channel.port2]);
|
|
83
|
+
this.channel.port1.onmessage = fn;
|
|
84
|
+
}
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
cleanupRequest(id) {
|
|
@@ -85,7 +93,8 @@ class WorkerFetch {
|
|
|
85
93
|
return info;
|
|
86
94
|
}
|
|
87
95
|
send(event) {
|
|
88
|
-
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
97
|
+
this.worker instanceof SharedWorker ? this.worker.port.postMessage(event) : this.channel.port1.postMessage(event);
|
|
89
98
|
}
|
|
90
99
|
request(context, next) {
|
|
91
100
|
if (isServerEnv) {
|
|
@@ -134,13 +143,17 @@ function enhanceReason(reason) {
|
|
|
134
143
|
}
|
|
135
144
|
function prepareRequest(request) {
|
|
136
145
|
const {
|
|
137
|
-
signal
|
|
146
|
+
signal,
|
|
147
|
+
headers
|
|
138
148
|
} = request;
|
|
139
149
|
const requestCopy = Object.assign({}, request);
|
|
140
150
|
delete requestCopy.store;
|
|
141
151
|
if (signal instanceof AbortSignal) {
|
|
142
152
|
delete requestCopy.signal;
|
|
143
153
|
}
|
|
154
|
+
if (headers instanceof Headers) {
|
|
155
|
+
requestCopy.headers = Array.from(headers.entries());
|
|
156
|
+
}
|
|
144
157
|
return {
|
|
145
158
|
signal: signal || null,
|
|
146
159
|
request: requestCopy
|
package/dist/worker-fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-fetch.js","sources":["../src/data-worker/fetch.ts"],"sourcesContent":["import type { RequestInfo } from '@ember-data-mirror/request';\nimport { createDeferred } from '@ember-data-mirror/request';\nimport type { Context } from '@ember-data-mirror/request/-private/context';\nimport type { Deferred, Future, NextFn } from '@ember-data-mirror/request/-private/types';\nimport { TESTING } from '@warp-drive-mirror/build-config/env';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\nimport type { ApiError } from '@warp-drive-mirror/core-types/spec/error';\n\nimport type { AbortEventData, MainThreadEvent, RequestEventData } from './types';\n\nexport interface FastBoot {\n require(moduleName: string): unknown;\n isFastBoot: boolean;\n request: Request;\n}\n\ndeclare global {\n const FastBoot: undefined | FastBoot;\n}\n\nconst isServerEnv = typeof FastBoot !== 'undefined';\n\nfunction isAggregateError(error: Error & { errors?: ApiError[] }): error is AggregateError & { errors: ApiError[] } {\n return error instanceof AggregateError || (error.name === 'AggregateError' && Array.isArray(error.errors));\n}\n\ntype RobustError = Error & { error: string | object; errors?: ApiError[]; content?: unknown };\n\nfunction stitchTrace(stack: string, origin: string) {\n if (origin.startsWith('Error\\n')) {\n return origin.slice(6) + '\\n' + stack;\n }\n return origin + '\\n' + stack;\n}\n\nfunction cloneError(error: RobustError, stack: string) {\n const isAggregate = isAggregateError(error);\n\n const cloned = (\n isAggregate ? new AggregateError(structuredClone(error.errors), error.message) : new Error(error.message)\n ) as RobustError;\n cloned.stack = stitchTrace(error.stack || '', stack);\n cloned.error = error.error;\n\n // copy over enumerable properties\n Object.assign(cloned, error);\n\n return cloned;\n}\n\nexport class WorkerFetch {\n declare worker: Worker | SharedWorker;\n declare threadId: string;\n declare pending: Map<\n number,\n { context: Context; signal: AbortSignal | null; abortFn: () => void; deferred: Deferred<unknown>; stack: string }\n >;\n declare channel: MessageChannel;\n\n constructor(worker: Worker | SharedWorker | null) {\n this.threadId = isServerEnv ? '' : crypto.randomUUID();\n this.pending = new Map();\n\n const isTesting = TESTING ? true : false;\n assert(`Expected a SharedWorker instance`, isTesting || isServerEnv || worker instanceof SharedWorker);\n this.worker = worker as SharedWorker;\n\n if (!isServerEnv) {\n this.channel = new MessageChannel();\n\n const port = this.worker instanceof SharedWorker ? this.worker.port : this.worker;\n port.postMessage({ type: 'connect', thread: this.threadId }, [this.channel.port2]);\n\n this.channel.port1.onmessage = (event: MainThreadEvent<unknown>) => {\n const { type, id, data } = event.data;\n const info = this.cleanupRequest(id);\n\n // typically this means the request was aborted\n if (!info) {\n return;\n }\n\n if (type === 'success-response') {\n const { deferred } = info;\n\n const { response, content } = data;\n\n if (response) {\n (response as { headers: Headers }).headers = new Headers(response.headers);\n info.context.setResponse(new Response(null, response));\n }\n\n deferred.resolve(content);\n return;\n }\n\n if (type === 'error-response') {\n const { deferred, stack } = info;\n\n deferred.reject(cloneError(data, stack));\n return;\n }\n };\n }\n }\n\n cleanupRequest(id: number) {\n const info = this.pending.get(id);\n this.pending.delete(id);\n\n if (info?.signal) {\n info.signal.removeEventListener('abort', info.abortFn);\n }\n\n return info;\n }\n\n send(event: RequestEventData | AbortEventData) {\n this.channel.port1.postMessage(event);\n }\n\n request<T>(context: Context, next: NextFn<T>): Promise<T> | Future<T> {\n if (isServerEnv) {\n return next(context.request);\n }\n\n const deferred = createDeferred<T>();\n const { signal, request } = prepareRequest(context.request);\n const abortFn = signal\n ? () => {\n deferred.reject(enhanceReason(signal.reason as string));\n this.send({ type: 'abort', thread: this.threadId, id: context.id, data: signal.reason as string });\n this.cleanupRequest(context.id);\n }\n : () => {\n return;\n };\n\n signal?.addEventListener('abort', abortFn);\n\n try {\n throw new Error();\n } catch (e: unknown) {\n this.pending.set(context.id, {\n context,\n deferred,\n signal,\n abortFn,\n stack: (e as Error).stack!,\n });\n }\n\n this.send({\n type: 'request',\n thread: this.threadId,\n id: context.id,\n data: request,\n });\n\n return deferred.promise;\n }\n}\n\nexport function enhanceReason(reason?: string) {\n return new DOMException(reason || 'The user aborted a request.', 'AbortError');\n}\n\nfunction prepareRequest(request: Context['request']): { signal: AbortSignal | null; request: RequestInfo } {\n const { signal } = request;\n const requestCopy = Object.assign({}, request) as RequestInfo;\n\n delete requestCopy.store;\n\n if (signal instanceof AbortSignal) {\n delete requestCopy.signal;\n }\n\n return { signal: signal || null, request: requestCopy };\n}\n"],"names":["isServerEnv","FastBoot","isAggregateError","error","AggregateError","name","Array","isArray","errors","stitchTrace","stack","origin","startsWith","slice","cloneError","isAggregate","cloned","structuredClone","message","Error","Object","assign","WorkerFetch","constructor","worker","threadId","crypto","randomUUID","pending","Map","isTesting","macroCondition","getGlobalConfig","WarpDrive","env","TESTING","DEBUG","test","SharedWorker","channel","MessageChannel","port","postMessage","type","thread","port2","port1","onmessage","event","id","data","info","cleanupRequest","deferred","response","content","headers","Headers","context","setResponse","Response","resolve","reject","get","delete","signal","removeEventListener","abortFn","send","request","next","createDeferred","prepareRequest","enhanceReason","reason","addEventListener","e","set","promise","DOMException","requestCopy","store","AbortSignal"],"mappings":";;;AAoBA,MAAMA,WAAW,GAAG,OAAOC,QAAQ,KAAK,WAAW,CAAA;AAEnD,SAASC,gBAAgBA,CAACC,KAAsC,EAAoD;AAClH,EAAA,OAAOA,KAAK,YAAYC,cAAc,IAAKD,KAAK,CAACE,IAAI,KAAK,gBAAgB,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAACK,MAAM,CAAE,CAAA;AAC5G,CAAA;AAIA,SAASC,WAAWA,CAACC,KAAa,EAAEC,MAAc,EAAE;AAClD,EAAA,IAAIA,MAAM,CAACC,UAAU,CAAC,SAAS,CAAC,EAAE;IAChC,OAAOD,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,GAAGH,KAAK,CAAA;AACvC,GAAA;AACA,EAAA,OAAOC,MAAM,GAAG,IAAI,GAAGD,KAAK,CAAA;AAC9B,CAAA;AAEA,SAASI,UAAUA,CAACX,KAAkB,EAAEO,KAAa,EAAE;AACrD,EAAA,MAAMK,WAAW,GAAGb,gBAAgB,CAACC,KAAK,CAAC,CAAA;EAE3C,MAAMa,MAAM,GACVD,WAAW,GAAG,IAAIX,cAAc,CAACa,eAAe,CAACd,KAAK,CAACK,MAAM,CAAC,EAAEL,KAAK,CAACe,OAAO,CAAC,GA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AI,IAAI;AAAEI,IAAAA,OAAO,EAAEW,WAAAA;GAAa,CAAA;AACzD;;;;"}
|
|
1
|
+
{"version":3,"file":"worker-fetch.js","sources":["../src/data-worker/fetch.ts"],"sourcesContent":["import type { RequestInfo } from '@ember-data-mirror/request';\nimport { createDeferred } from '@ember-data-mirror/request';\nimport type { Context } from '@ember-data-mirror/request/-private/context';\nimport type { Deferred, Future, NextFn } from '@ember-data-mirror/request/-private/types';\nimport { TESTING } from '@warp-drive-mirror/build-config/env';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\nimport type { ApiError } from '@warp-drive-mirror/core-types/spec/error';\n\nimport type { AbortEventData, MainThreadEvent, RequestEventData } from './types';\n\nexport interface FastBoot {\n require(moduleName: string): unknown;\n isFastBoot: boolean;\n request: Request;\n}\n\ndeclare global {\n const FastBoot: undefined | FastBoot;\n}\n\nconst isServerEnv = typeof FastBoot !== 'undefined';\n\nfunction isAggregateError(error: Error & { errors?: ApiError[] }): error is AggregateError & { errors: ApiError[] } {\n return error instanceof AggregateError || (error.name === 'AggregateError' && Array.isArray(error.errors));\n}\n\ntype RobustError = Error & { error: string | object; errors?: ApiError[]; content?: unknown };\n\nfunction stitchTrace(stack: string, origin: string) {\n if (origin.startsWith('Error\\n')) {\n return origin.slice(6) + '\\n' + stack;\n }\n return origin + '\\n' + stack;\n}\n\nfunction cloneError(error: RobustError, stack: string) {\n const isAggregate = isAggregateError(error);\n\n const cloned = (\n isAggregate ? new AggregateError(structuredClone(error.errors), error.message) : new Error(error.message)\n ) as RobustError;\n cloned.stack = stitchTrace(error.stack || '', stack);\n cloned.error = error.error;\n\n // copy over enumerable properties\n Object.assign(cloned, error);\n\n return cloned;\n}\n\nexport class WorkerFetch {\n declare worker: Worker | SharedWorker;\n declare threadId: string;\n declare pending: Map<\n number,\n { context: Context; signal: AbortSignal | null; abortFn: () => void; deferred: Deferred<unknown>; stack: string }\n >;\n declare channel: MessageChannel;\n\n constructor(worker: Worker | SharedWorker | null) {\n this.threadId = isServerEnv ? '' : crypto.randomUUID();\n this.pending = new Map();\n\n const isTesting = TESTING ? true : false;\n assert(`Expected a SharedWorker instance`, isTesting || isServerEnv || worker instanceof SharedWorker);\n this.worker = worker as SharedWorker;\n\n if (!isServerEnv) {\n const fn = (event: MainThreadEvent<unknown>) => {\n const { type, id, data } = event.data;\n const info = this.cleanupRequest(id);\n\n // typically this means the request was aborted\n if (!info) {\n return;\n }\n\n if (type === 'success-response') {\n const { deferred } = info;\n\n const { response, content } = data;\n\n if (response) {\n (response as { headers: Headers }).headers = new Headers(response.headers);\n info.context.setResponse(new Response(null, response));\n }\n\n deferred.resolve(content);\n return;\n }\n\n if (type === 'error-response') {\n const { deferred, stack } = info;\n\n deferred.reject(cloneError(data, stack));\n return;\n }\n };\n\n if (worker instanceof SharedWorker) {\n worker.port.postMessage({ type: 'connect', thread: this.threadId });\n worker.port.onmessage = fn;\n } else if (worker) {\n this.channel = new MessageChannel();\n worker.postMessage({ type: 'connect', thread: this.threadId }, [this.channel.port2]);\n\n this.channel.port1.onmessage = fn;\n }\n }\n }\n\n cleanupRequest(id: number) {\n const info = this.pending.get(id);\n this.pending.delete(id);\n\n if (info?.signal) {\n info.signal.removeEventListener('abort', info.abortFn);\n }\n\n return info;\n }\n\n send(event: RequestEventData | AbortEventData) {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n this.worker instanceof SharedWorker ? this.worker.port.postMessage(event) : this.channel.port1.postMessage(event);\n }\n\n request<T>(context: Context, next: NextFn<T>): Promise<T> | Future<T> {\n if (isServerEnv) {\n return next(context.request);\n }\n\n const deferred = createDeferred<T>();\n const { signal, request } = prepareRequest(context.request);\n const abortFn = signal\n ? () => {\n deferred.reject(enhanceReason(signal.reason as string));\n this.send({ type: 'abort', thread: this.threadId, id: context.id, data: signal.reason as string });\n this.cleanupRequest(context.id);\n }\n : () => {\n return;\n };\n\n signal?.addEventListener('abort', abortFn);\n\n try {\n throw new Error();\n } catch (e: unknown) {\n this.pending.set(context.id, {\n context,\n deferred,\n signal,\n abortFn,\n stack: (e as Error).stack!,\n });\n }\n\n this.send({\n type: 'request',\n thread: this.threadId,\n id: context.id,\n data: request,\n });\n\n return deferred.promise;\n }\n}\n\nexport function enhanceReason(reason?: string) {\n return new DOMException(reason || 'The user aborted a request.', 'AbortError');\n}\n\nfunction prepareRequest(request: Context['request']): { signal: AbortSignal | null; request: RequestInfo } {\n const { signal, headers } = request;\n const requestCopy = Object.assign({}, request) as RequestInfo;\n\n delete requestCopy.store;\n\n if (signal instanceof AbortSignal) {\n delete requestCopy.signal;\n }\n\n if (headers instanceof Headers) {\n requestCopy.headers = Array.from(headers.entries()) as unknown as Headers;\n }\n\n return { signal: signal || null, request: requestCopy };\n}\n"],"names":["isServerEnv","FastBoot","isAggregateError","error","AggregateError","name","Array","isArray","errors","stitchTrace","stack","origin","startsWith","slice","cloneError","isAggregate","cloned","structuredClone","message","Error","Object","assign","WorkerFetch","constructor","worker","threadId","crypto","randomUUID","pending","Map","isTesting","macroCondition","getGlobalConfig","WarpDrive","env","TESTING","DEBUG","test","SharedWorker","fn","event","type","id","data","info","cleanupRequest","deferred","response","content","headers","Headers","context","setResponse","Response","resolve","reject","port","postMessage","thread","onmessage","channel","MessageChannel","port2","port1","get","delete","signal","removeEventListener","abortFn","send","request","next","createDeferred","prepareRequest","enhanceReason","reason","addEventListener","e","set","promise","DOMException","requestCopy","store","AbortSignal","from","entries"],"mappings":";;;AAoBA,MAAMA,WAAW,GAAG,OAAOC,QAAQ,KAAK,WAAW,CAAA;AAEnD,SAASC,gBAAgBA,CAACC,KAAsC,EAAoD;AAClH,EAAA,OAAOA,KAAK,YAAYC,cAAc,IAAKD,KAAK,CAACE,IAAI,KAAK,gBAAgB,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAACK,MAAM,CAAE,CAAA;AAC5G,CAAA;AAIA,SAASC,WAAWA,CAACC,KAAa,EAAEC,MAAc,EAAE;AAClD,EAAA,IAAIA,MAAM,CAACC,UAAU,C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C,CAAC,CAAA;AACJ,KAAA;IAEA,IAAI,CAAC2D,IAAI,CAAC;AACR5B,MAAAA,IAAI,EAAE,SAAS;MACfiB,MAAM,EAAE,IAAI,CAACjC,QAAQ;MACrBiB,EAAE,EAAES,OAAO,CAACT,EAAE;AACdC,MAAAA,IAAI,EAAE2B,OAAAA;AACR,KAAC,CAAC,CAAA;IAEF,OAAOxB,QAAQ,CAACiC,OAAO,CAAA;AACzB,GAAA;AACF,CAAA;AAEO,SAASL,aAAaA,CAACC,MAAe,EAAE;EAC7C,OAAO,IAAIK,YAAY,CAACL,MAAM,IAAI,6BAA6B,EAAE,YAAY,CAAC,CAAA;AAChF,CAAA;AAEA,SAASF,cAAcA,CAACH,OAA2B,EAAwD;EACzG,MAAM;IAAEJ,MAAM;AAAEjB,IAAAA,OAAAA;AAAQ,GAAC,GAAGqB,OAAO,CAAA;EACnC,MAAMW,WAAW,GAAG7D,MAAM,CAACC,MAAM,CAAC,EAAE,EAAEiD,OAAO,CAAgB,CAAA;EAE7D,OAAOW,WAAW,CAACC,KAAK,CAAA;EAExB,IAAIhB,MAAM,YAAYiB,WAAW,EAAE;IACjC,OAAOF,WAAW,CAACf,MAAM,CAAA;AAC3B,GAAA;EAEA,IAAIjB,OAAO,YAAYC,OAAO,EAAE;AAC9B+B,IAAAA,WAAW,CAAChC,OAAO,GAAG3C,KAAK,CAAC8E,IAAI,CAACnC,OAAO,CAACoC,OAAO,EAAE,CAAuB,CAAA;AAC3E,GAAA;EAEA,OAAO;IAAEnB,MAAM,EAAEA,MAAM,IAAI,IAAI;AAAEI,IAAAA,OAAO,EAAEW,WAAAA;GAAa,CAAA;AACzD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive-mirror/experiments",
|
|
3
3
|
"description": "Experimental features for EmberData/WarpDrive",
|
|
4
|
-
"version": "0.0.1-
|
|
4
|
+
"version": "0.0.1-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
7
7
|
"repository": {
|
|
@@ -23,6 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"./worker-fetch": {
|
|
25
25
|
"default": "./dist/worker-fetch.js"
|
|
26
|
+
},
|
|
27
|
+
"./image-worker": {
|
|
28
|
+
"default": "./dist/image-worker.js"
|
|
29
|
+
},
|
|
30
|
+
"./image-fetch": {
|
|
31
|
+
"default": "./dist/image-fetch.js"
|
|
32
|
+
},
|
|
33
|
+
"./unstable-preview-types": {
|
|
34
|
+
"types": "./unstable-preview-types/index.d.ts"
|
|
26
35
|
}
|
|
27
36
|
},
|
|
28
37
|
"files": [
|
|
@@ -34,17 +43,12 @@
|
|
|
34
43
|
"NCC-1701-a-blue.svg",
|
|
35
44
|
"NCC-1701-a.svg"
|
|
36
45
|
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"lint": "eslint . --quiet --cache --cache-strategy=content --report-unused-disable-directives",
|
|
39
|
-
"build:pkg": "vite build;",
|
|
40
|
-
"sync-hardlinks": "bun run sync-dependencies-meta-injected"
|
|
41
|
-
},
|
|
42
46
|
"peerDependencies": {
|
|
43
47
|
"@sqlite.org/sqlite-wasm": "3.46.0-build2",
|
|
44
|
-
"@ember-data-mirror/request": "5.4.0-
|
|
45
|
-
"@ember-data-mirror/request-utils": "5.4.0-
|
|
46
|
-
"@ember-data-mirror/store": "5.4.0-
|
|
47
|
-
"@warp-drive-mirror/core-types": "0.0.0-
|
|
48
|
+
"@ember-data-mirror/request": "5.4.0-beta.13",
|
|
49
|
+
"@ember-data-mirror/request-utils": "5.4.0-beta.13",
|
|
50
|
+
"@ember-data-mirror/store": "5.4.0-beta.13",
|
|
51
|
+
"@warp-drive-mirror/core-types": "0.0.0-beta.13"
|
|
48
52
|
},
|
|
49
53
|
"peerDependenciesMeta": {
|
|
50
54
|
"@sqlite.org/sqlite-wasm": {
|
|
@@ -52,31 +56,43 @@
|
|
|
52
56
|
}
|
|
53
57
|
},
|
|
54
58
|
"dependencies": {
|
|
55
|
-
"@embroider/macros": "^1.16.
|
|
56
|
-
"@warp-drive-mirror/build-config": "0.0.0-
|
|
59
|
+
"@embroider/macros": "^1.16.6",
|
|
60
|
+
"@warp-drive-mirror/build-config": "0.0.0-beta.8"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
63
|
"@babel/core": "^7.24.5",
|
|
60
64
|
"@babel/plugin-transform-typescript": "^7.24.5",
|
|
61
65
|
"@babel/preset-env": "^7.24.5",
|
|
62
66
|
"@babel/preset-typescript": "^7.24.1",
|
|
63
|
-
"@ember-data-mirror/request": "5.4.0-
|
|
64
|
-
"@ember-data-mirror/request-utils": "5.4.0-
|
|
65
|
-
"@ember-data-mirror/store": "5.4.0-
|
|
66
|
-
"@ember-data-mirror/tracking": "5.4.0-
|
|
67
|
+
"@ember-data-mirror/request": "5.4.0-beta.13",
|
|
68
|
+
"@ember-data-mirror/request-utils": "5.4.0-beta.13",
|
|
69
|
+
"@ember-data-mirror/store": "5.4.0-beta.13",
|
|
70
|
+
"@ember-data-mirror/tracking": "5.4.0-beta.13",
|
|
67
71
|
"@glimmer/component": "^1.1.2",
|
|
68
|
-
"@warp-drive-mirror/core-types": "0.0.0-
|
|
69
|
-
"@warp-drive/internal-config": "5.4.0-
|
|
70
|
-
"ember-source": "~5.
|
|
72
|
+
"@warp-drive-mirror/core-types": "0.0.0-beta.13",
|
|
73
|
+
"@warp-drive/internal-config": "5.4.0-beta.13",
|
|
74
|
+
"ember-source": "~5.12.0",
|
|
71
75
|
"pnpm-sync-dependencies-meta-injected": "0.0.14",
|
|
72
76
|
"@sqlite.org/sqlite-wasm": "3.46.0-build2",
|
|
73
|
-
"typescript": "^5.
|
|
77
|
+
"typescript": "^5.7.2",
|
|
74
78
|
"vite": "^5.2.11"
|
|
75
79
|
},
|
|
76
80
|
"engines": {
|
|
77
|
-
"node": ">= 18.20.
|
|
81
|
+
"node": ">= 18.20.4"
|
|
78
82
|
},
|
|
79
83
|
"volta": {
|
|
80
84
|
"extends": "../../../../../../package.json"
|
|
85
|
+
},
|
|
86
|
+
"typesVersions": {
|
|
87
|
+
"*": {
|
|
88
|
+
"unstable-preview-types": [
|
|
89
|
+
"./unstable-preview-types"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"lint": "eslint . --quiet --cache --cache-strategy=content",
|
|
95
|
+
"build:pkg": "vite build;",
|
|
96
|
+
"sync-hardlinks": "bun run sync-dependencies-meta-injected"
|
|
81
97
|
}
|
|
82
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-handler.d.ts","sourceRoot":"","sources":["../../src/data-worker/cache-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cache-handler.d.ts","sourceRoot":"","sources":["../../src/data-worker/cache-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAkB,MAAM,qBAAqB,CAAC;AAuB5F;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,gBAmC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/data-worker/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAKnF,OAAO,KAAK,EAAE,cAAc,EAAmB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB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