@graphql-box/worker-client 5.4.10 → 5.4.12
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/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +16 -16
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +1 -0
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +1 -0
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/main.ts +2 -1
- package/src/types.ts +1 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/es.array.push.js");var e=require("@graphql-box/core"),t=require("@graphql-box/helpers"),r=require("eventemitter3"),s=require("graphql"),a=require("lodash-es"),o=require("uuid"),n=require("iterall"),i=require("@cachemap/core-worker");const u="graphqlBox",c="message",h="request",p="subscribe",g=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};function l(e,t,r,s){var a,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(a=e[i])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function d(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class q{static _getMessageContext({hasDeferOrStream:e=!1,
|
|
1
|
+
"use strict";require("core-js/modules/es.array.push.js");var e=require("@graphql-box/core"),t=require("@graphql-box/helpers"),r=require("eventemitter3"),s=require("graphql"),a=require("lodash-es"),o=require("uuid"),n=require("iterall"),i=require("@cachemap/core-worker");const u="graphqlBox",c="message",h="request",p="subscribe",g=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};function l(e,t,r,s){var a,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(a=e[i])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function d(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class q{static _getMessageContext({hasDeferOrStream:e=!1,initiator:t,operation:r,requestID:s}){return{hasDeferOrStream:e,initiator:t,operation:r,requestID:s}}static _resolve({cacheMetadata:e,...t},r,{requestID:s}){const a={...t,requestID:s};return r.returnCacheMetadata&&e&&(a._cacheMetadata=e),a}constructor(a){this._onMessage=({data:r})=>{if(!t.isPlainObject(r))return;const{context:a,method:o,result:n,type:i}=r;if(i!==u)return;const{_cacheMetadata:c,...h}=n,g={...t.deserializeErrors(h),requestID:a.requestID};if(c&&(g._cacheMetadata=t.rehydrateCacheMetadata(c)),o===p)this._debugManager?.log(e.SUBSCRIPTION_RESOLVED,{context:a,result:g,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(a.requestID,g);else if(a.hasDeferOrStream){const r=this._pending.get(a.requestID);if(r){const e=new t.EventAsyncIterator(this._eventEmitter,a.requestID);r.resolve(e.getIterator())}this._debugManager?.log(e.REQUEST_RESOLVED,{context:a,result:g,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(a.requestID,g)}else{const t=this._pending.get(a.requestID);if(!t)return;this._debugManager?.log(e.REQUEST_RESOLVED,{context:a,result:g,stats:{endTime:this._debugManager.now()}}),a.operation===s.OperationTypeNode.QUERY&&t.requestData&&t.options&&t.context&&this._cacheManager.cacheQuery(t.requestData,void 0,g,t.options,t.context),t.resolve(g)}},this._messageQueue=[],this._pending=new Map;const o=[];if(t.isPlainObject(a)||o.push(new t.ArgsError("@graphql-box/worker-client expected options to ba a plain object.")),"cache"in a||o.push(new t.ArgsError("@graphql-box/worker-client expected options.cache.")),"cacheManager"in a||o.push(new t.ArgsError("@graphql-box/worker-client expected options.cacheManager.")),"requestParser"in a||o.push(new t.ArgsError("@graphql-box/worker-client expected options.requestParser.")),a.lazyWorkerInit||"worker"in a||o.push(new t.ArgsError("@graphql-box/worker-client expected options.worker.")),o.length>0)throw new t.GroupedError("@graphql-box/worker-client argument validation errors.",o);this._cache=a.cache,this._cacheManager=a.cacheManager,this._debugManager=a.debugManager??null,this._eventEmitter=new r.EventEmitter,this._experimentalDeferStreamSupport=a.experimentalDeferStreamSupport??!1,this._requestParser=a.requestParser,"function"==typeof a.worker?Promise.resolve(a.worker()).then((e=>{this._worker=e,this._addEventListener(),this._releaseMessageQueue()})).catch((e=>{throw e})):a.worker&&(this._worker=a.worker,this._addEventListener())}get cache(){return this._cache}get cacheManager(){return this._cacheManager}async mutate(e,t={},r={}){return this._request(e,t,this._getRequestContext(s.OperationTypeNode.MUTATION,e,r))}async query(e,t={},r={}){return this._query(e,t,this._getRequestContext(s.OperationTypeNode.QUERY,e,r))}async request(e,t={},r={}){return this._request(e,t,this._getRequestContext(s.OperationTypeNode.QUERY,e,r))}async subscribe(e,t={}){return this._subscribe(e,t,this._getRequestContext(s.OperationTypeNode.SUBSCRIPTION,e))}set worker(e){this._worker=e,this._addEventListener(),this._releaseMessageQueue()}_addEventListener(){if(!this._worker)throw new Error("A worker is required for the WorkerClient to work correctly.");this._worker.addEventListener(c,this._onMessage)}_getRequestContext(e,r,s={}){return{debugManager:this._debugManager,experimentalDeferStreamSupport:this._experimentalDeferStreamSupport,fieldTypeMap:new Map,filteredRequest:"",operation:e,operationName:"",originalRequestHash:t.hashRequest(r),parsedRequest:"",queryFiltered:!1,request:r,requestComplexity:null,requestDepth:null,requestID:o.v4(),...s}}async _query(e,r,s){try{const{ast:a,request:o}=this._requestParser.updateRequest(e,r,s),n={ast:a,hash:t.hashRequest(o),request:o},i=await this._cacheManager.checkQueryResponseCacheEntry(n.hash,r,s);return i?q._resolve(i,r,s):await new Promise((t=>{this._worker?this._worker.postMessage({context:q._getMessageContext(s),method:h,options:r,request:e,type:u}):this._messageQueue.push({context:q._getMessageContext(s),method:h,options:r,request:e,type:u}),this._pending.set(s.requestID,{context:s,options:r,requestData:n,resolve:t})}))}catch(e){return{errors:[a.isError(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:s.requestID}}}_releaseMessageQueue(){if(!this._worker)throw new Error("A worker is required for the WorkerClient to work correctly.");const e=[...this._messageQueue];this._messageQueue=[];for(const t of e)this._worker.postMessage(t)}async _request(e,t,r){try{return await new Promise((s=>{this._worker?this._worker.postMessage({context:q._getMessageContext(r),method:h,options:t,request:e,type:u}):this._messageQueue.push({context:q._getMessageContext(r),method:h,options:t,request:e,type:u}),this._pending.set(r.requestID,{resolve:s})}))}catch(e){return{errors:[a.isError(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:r.requestID}}}_subscribe(e,r,s){try{this._worker?this._worker.postMessage({context:q._getMessageContext(s),method:p,options:r,request:e,type:u}):this._messageQueue.push({context:q._getMessageContext(s),method:p,options:r,request:e,type:u});const a=new t.EventAsyncIterator(this._eventEmitter,s.requestID);return Promise.resolve(a.getIterator())}catch(e){const t=a.isError(e)?e:new Error("@graphql-box/worker-client subscribe had an unexpected error.");return Promise.resolve({errors:[t],requestID:s.requestID})}}}l([(t,r,s)=>{const a=s.value;a&&(s.value=async function(...t){return new Promise((r=>{(async()=>{const{debugManager:s,...o}=t[2];if(!s)return void r(await a.apply(this,t));const i=g(t[0]),u=s.now();s.log(e.REQUEST_EXECUTED,{context:{...o,operationName:i},options:t[1],request:t[0],stats:{startTime:u}});const c=await a.apply(this,t),h=s.now(),p=h-u;r(c),n.isAsyncIterable(c)||s.log(e.REQUEST_RESOLVED,{context:{...o,operationName:i},options:t[1],request:t[0],result:c,stats:{duration:p,endTime:h,startTime:u}})})()}))})},d("design:type",Function),d("design:paramtypes",[String,"undefined"==typeof RequestOptions?Object:RequestOptions,"undefined"==typeof RequestContext?Object:RequestContext]),d("design:returntype",Promise)],q.prototype,"_request",null),l([(t,r,s)=>{const a=s.value;a&&(s.value=async function(...t){return new Promise((r=>{(async()=>{const{debugManager:s,...o}=t[2];if(!s)return void r(await a.apply(this,t));const n=g(t[0]),i=s.now();s.log(e.SUBSCRIPTION_EXECUTED,{context:{...o,operationName:n},options:t[1],request:t[0],stats:{startTime:i}});const u=await a.apply(this,t);r(u)})()}))})},d("design:type",Function),d("design:paramtypes",[String,"undefined"==typeof RequestOptions?Object:RequestOptions,"undefined"==typeof RequestContext?Object:RequestContext]),d("design:returntype","undefined"==typeof Promise?Object:Promise)],q.prototype,"_subscribe",null);const _=(e,r)=>{const{context:s,method:a,options:o,request:i}=e;a===h?(async(e,r,s,a,o)=>{const i=await o.request(e,s,a);if(!n.isAsyncIterable(i)){const{_cacheMetadata:e,...s}=i,o=t.serializeErrors({...s});return e&&(o._cacheMetadata=t.dehydrateCacheMetadata(e)),void globalThis.postMessage({context:a,method:r,result:o,type:u})}n.forAwaitEach(i,(({_cacheMetadata:e,...s})=>{const o=t.serializeErrors({...s});e&&(o._cacheMetadata=t.dehydrateCacheMetadata(e)),globalThis.postMessage({context:a,method:r,result:o,type:u})}))})(i,a,o,s,r):(async(e,r,s,a,o)=>{const i=await o.subscribe(e,s,a);n.isAsyncIterable(i)?n.forAwaitEach(i,(({_cacheMetadata:e,...s})=>{const o=t.serializeErrors({...s});e&&(o._cacheMetadata=t.dehydrateCacheMetadata(e)),globalThis.postMessage({context:a,method:r,result:o,type:u})})):globalThis.postMessage({context:a,method:r,result:t.serializeErrors(i),type:u})})(i,a,o,s,r)};exports.CACHEMAP="cachemap",exports.GRAPHQL_BOX=u,exports.MESSAGE=c,exports.REQUEST=h,exports.SUBSCRIBE=p,exports.WorkerClient=q,exports.handleMessage=_,exports.registerWorker=({client:e})=>{globalThis.addEventListener(c,(({data:t})=>{t.type===u?_(t,e):e.cache&&i.handleMessage(t,e.cache)}))};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../worker-client/src//constants.ts","../worker-client/src//helpers/operationNameRegex.ts","../worker-client/src//main.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.ts","../worker-client/src//helpers/isGraphqlBoxMessageRequestPayload.ts","../worker-client/src//registerWorker.ts"],"sourcesContent":["export const CACHEMAP = 'cachemap';\nexport const GRAPHQL_BOX = 'graphqlBox';\nexport const MESSAGE = 'message';\nexport const REQUEST = 'request';\nexport const SUBSCRIBE = 'subscribe';\n","export const operationNameRegex = (request: string) => {\n const output = /(query|mutation|subscription) ([A-Za-z]+)(\\(| {)/.exec(request);\n return output ? output[2] : '';\n};\n","import { type CoreWorker } from '@cachemap/core-worker';\nimport { type CacheManagerDef } from '@graphql-box/cache-manager';\nimport {\n type DebugManagerDef,\n type PartialRequestContext,\n type PartialRequestResult,\n type PartialResponseData,\n REQUEST_RESOLVED,\n type RawResponseDataWithMaybeCacheMetadata,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_RESOLVED,\n} from '@graphql-box/core';\nimport {\n ArgsError,\n EventAsyncIterator,\n GroupedError,\n deserializeErrors,\n hashRequest,\n isPlainObject,\n rehydrateCacheMetadata,\n} from '@graphql-box/helpers';\nimport { type RequestParserDef } from '@graphql-box/request-parser';\nimport { EventEmitter } from 'eventemitter3';\nimport { OperationTypeNode } from 'graphql';\nimport { isError } from 'lodash-es';\nimport { v4 as uuid } from 'uuid';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE } from './constants.ts';\nimport { logRequest } from './debug/logRequest.ts';\nimport { logSubscription } from './debug/logSubscription.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MessageResponsePayload,\n type PendingResolver,\n type PendingTracker,\n type UserOptions,\n} from './types.ts';\n\nexport class WorkerClient {\n private static _getMessageContext({\n hasDeferOrStream = false,\n operation,\n requestID,\n }: RequestContext): MessageContext {\n return { hasDeferOrStream, operation, requestID };\n }\n\n private static _resolve(\n { cacheMetadata, ...rest }: PartialResponseData,\n options: RequestOptions,\n { requestID }: RequestContext,\n ): PartialRequestResult {\n const result: PartialRequestResult = { ...rest, requestID };\n\n if (options.returnCacheMetadata && cacheMetadata) {\n result._cacheMetadata = cacheMetadata;\n }\n\n return result;\n }\n\n private _onMessage = ({ data }: MessageEvent<MessageResponsePayload>): void => {\n if (!isPlainObject(data)) {\n return;\n }\n\n const { context, method, result, type } = data;\n\n if (type !== GRAPHQL_BOX) {\n return;\n }\n\n const { _cacheMetadata, ...otherProps } = result;\n const response: PartialRequestResult = { ...deserializeErrors(otherProps), requestID: context.requestID };\n\n if (_cacheMetadata) {\n response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);\n }\n\n if (method === SUBSCRIBE) {\n this._debugManager?.log(SUBSCRIPTION_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else if (context.hasDeferOrStream) {\n const pending = this._pending.get(context.requestID);\n\n if (pending) {\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n pending.resolve(eventAsyncIterator.getIterator());\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else {\n const pending = this._pending.get(context.requestID);\n\n if (!pending) {\n return;\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n if (context.operation === OperationTypeNode.QUERY && pending.requestData && pending.options && pending.context) {\n void this._cacheManager.cacheQuery(\n pending.requestData,\n undefined,\n // Need to look at what type guards can be put in place\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n response as RawResponseDataWithMaybeCacheMetadata,\n pending.options,\n pending.context,\n );\n }\n\n pending.resolve(response);\n }\n };\n\n /**\n * This cache instance does not actually store anything itself,\n * it is for communicating with the worker cache that the worker\n * client is using within the worker.\n */\n private _cache: CoreWorker;\n private _cacheManager: CacheManagerDef;\n private _debugManager: DebugManagerDef | null;\n private _eventEmitter: EventEmitter;\n private _experimentalDeferStreamSupport: boolean;\n private _messageQueue: MessageRequestPayload[] = [];\n private _pending: PendingTracker = new Map();\n private _requestParser: RequestParserDef;\n private _worker: Worker | undefined;\n\n constructor(options: UserOptions) {\n const errors: ArgsError[] = [];\n\n if (!isPlainObject(options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));\n }\n\n if (!('cache' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));\n }\n\n if (!('cacheManager' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cacheManager.'));\n }\n\n if (!('requestParser' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.requestParser.'));\n }\n\n if (!options.lazyWorkerInit && !('worker' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));\n }\n\n if (errors.length > 0) {\n throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);\n }\n\n this._cache = options.cache;\n this._cacheManager = options.cacheManager;\n this._debugManager = options.debugManager ?? null;\n this._eventEmitter = new EventEmitter();\n this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;\n this._requestParser = options.requestParser;\n\n if (typeof options.worker === 'function') {\n Promise.resolve(options.worker())\n .then(worker => {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n })\n .catch((error: unknown) => {\n throw error;\n });\n } else if (options.worker) {\n this._worker = options.worker;\n this._addEventListener();\n }\n }\n\n get cache(): CoreWorker {\n return this._cache;\n }\n\n get cacheManager(): CacheManagerDef {\n return this._cacheManager;\n }\n\n public async mutate(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));\n }\n\n public async query(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._query(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async request(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async subscribe(request: string, options: RequestOptions = {}) {\n return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));\n }\n\n public set worker(worker: Worker) {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n }\n\n private _addEventListener(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n this._worker.addEventListener(MESSAGE, this._onMessage);\n }\n\n private _getRequestContext(\n operation: OperationTypeNode,\n request: string,\n context: PartialRequestContext = {},\n ): RequestContext {\n return {\n debugManager: this._debugManager,\n experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,\n fieldTypeMap: new Map(),\n filteredRequest: '',\n operation,\n operationName: '',\n originalRequestHash: hashRequest(request),\n parsedRequest: '',\n queryFiltered: false,\n request,\n requestComplexity: null,\n requestDepth: null,\n requestID: uuid(),\n ...context,\n };\n }\n\n private async _query(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n const { ast, request: updateRequest } = this._requestParser.updateRequest(request, options, context);\n const requestData = { ast, hash: hashRequest(updateRequest), request: updateRequest };\n const checkResult = await this._cacheManager.checkQueryResponseCacheEntry(requestData.hash, options, context);\n\n if (checkResult) {\n return WorkerClient._resolve(checkResult, options, context);\n }\n\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { context, options, requestData, resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n private _releaseMessageQueue(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n const messageQueue = [...this._messageQueue];\n this._messageQueue = [];\n\n for (const message of messageQueue) {\n this._worker.postMessage(message);\n }\n }\n\n @logRequest()\n private async _request(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n @logSubscription()\n private _subscribe(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n return Promise.resolve(eventAsyncIterator.getIterator());\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client subscribe had an unexpected error.');\n\n return Promise.resolve({ errors: [confirmedError], requestID: context.requestID });\n }\n }\n}\n","import {\n type PartialRequestResult,\n REQUEST_EXECUTED,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { isAsyncIterable } from 'iterall';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logRequest = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(REQUEST_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n const endTime = debugManager.now();\n const duration = endTime - startTime;\n resolve(result);\n\n if (isAsyncIterable(result)) {\n return;\n }\n\n debugManager.log(REQUEST_RESOLVED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n result,\n stats: { duration, endTime, startTime },\n });\n })();\n });\n };\n };\n};\n","import {\n type PartialRequestResult,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_EXECUTED,\n} from '@graphql-box/core';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logSubscription = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(SUBSCRIPTION_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n resolve(result);\n })();\n });\n };\n };\n};\n","import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';\nimport { GRAPHQL_BOX } from '../constants.ts';\nimport { type MessageRequestPayload } from '../types.ts';\n\nexport const isGraphqlBoxMessageRequestPayload = (\n payload: MessageRequestPayload | CachemapMessageRequestPayload,\n): payload is MessageRequestPayload => payload.type === GRAPHQL_BOX;\n","import {\n type PostMessage as CachemapMessageRequestPayload,\n handleMessage as handleCachemapMessage,\n} from '@cachemap/core-worker';\nimport { type Client } from '@graphql-box/client';\nimport { type PartialDehydratedRequestResult, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';\nimport { dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';\nimport { forAwaitEach, isAsyncIterable } from 'iterall';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST } from './constants.ts';\nimport { isGraphqlBoxMessageRequestPayload } from './helpers/isGraphqlBoxMessageRequestPayload.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MethodNames,\n type RegisterWorkerOptions,\n} from './types.ts';\n\nconst handleRequest = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const requestResult = await client.request(request, options, context);\n\n if (!isAsyncIterable(requestResult)) {\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const { _cacheMetadata, ...otherProps } = requestResult as PartialRequestResult;\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n return;\n }\n\n void forAwaitEach(requestResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nconst handleSubscription = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const subscribeResult = await client.subscribe(request, options, context);\n\n if (!isAsyncIterable(subscribeResult)) {\n globalThis.postMessage({\n context,\n method,\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n result: serializeErrors(subscribeResult as PartialRequestResult),\n type: GRAPHQL_BOX,\n });\n\n return;\n }\n\n void forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nexport const handleMessage = (data: MessageRequestPayload, client: Client): void => {\n const { context, method, options, request } = data;\n\n if (method === REQUEST) {\n void handleRequest(request, method, options, context, client);\n } else {\n void handleSubscription(request, method, options, context, client);\n }\n};\n\nexport const registerWorker = ({ client }: RegisterWorkerOptions): void => {\n const onMessage = ({ data }: MessageEvent<MessageRequestPayload | CachemapMessageRequestPayload>): void => {\n if (isGraphqlBoxMessageRequestPayload(data)) {\n handleMessage(data, client);\n } else if (client.cache) {\n void handleCachemapMessage(data, client.cache);\n }\n };\n\n globalThis.addEventListener(MESSAGE, onMessage);\n};\n"],"names":["GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","WorkerClient","_getMessageContext","hasDeferOrStream","operation","requestID","_resolve","cacheMetadata","rest","options","result","returnCacheMetadata","_cacheMetadata","constructor","_onMessage","data","isPlainObject","context","method","type","otherProps","response","deserializeErrors","rehydrateCacheMetadata","this","_debugManager","log","SUBSCRIPTION_RESOLVED","stats","endTime","now","_eventEmitter","emit","pending","_pending","get","eventAsyncIterator","EventAsyncIterator","resolve","getIterator","REQUEST_RESOLVED","OperationTypeNode","QUERY","requestData","_cacheManager","cacheQuery","undefined","_messageQueue","Map","errors","push","ArgsError","lazyWorkerInit","length","GroupedError","_cache","cache","cacheManager","debugManager","EventEmitter","_experimentalDeferStreamSupport","experimentalDeferStreamSupport","_requestParser","requestParser","worker","Promise","then","_worker","_addEventListener","_releaseMessageQueue","catch","error","mutate","_request","_getRequestContext","MUTATION","query","_query","subscribe","_subscribe","SUBSCRIPTION","Error","addEventListener","fieldTypeMap","filteredRequest","operationName","originalRequestHash","hashRequest","parsedRequest","queryFiltered","requestComplexity","requestDepth","uuid","ast","updateRequest","hash","checkResult","checkQueryResponseCacheEntry","postMessage","set","isError","messageQueue","message","confirmedError","_target","_propertyName","descriptor","value","async","args","otherContext","apply","derivedOperationName","startTime","REQUEST_EXECUTED","duration","isAsyncIterable","SUBSCRIPTION_EXECUTED","handleMessage","client","requestResult","serializeErrors","dehydrateCacheMetadata","globalThis","forAwaitEach","handleRequest","subscribeResult","handleSubscription","handleCachemap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src//helpers/operationNameRegex.ts","../worker-client/src//main.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.ts","../worker-client/src//helpers/isGraphqlBoxMessageRequestPayload.ts","../worker-client/src//registerWorker.ts"],"sourcesContent":["export const CACHEMAP = 'cachemap';\nexport const GRAPHQL_BOX = 'graphqlBox';\nexport const MESSAGE = 'message';\nexport const REQUEST = 'request';\nexport const SUBSCRIBE = 'subscribe';\n","export const operationNameRegex = (request: string) => {\n const output = /(query|mutation|subscription) ([A-Za-z]+)(\\(| {)/.exec(request);\n return output ? output[2] : '';\n};\n","import { type CoreWorker } from '@cachemap/core-worker';\nimport { type CacheManagerDef } from '@graphql-box/cache-manager';\nimport {\n type DebugManagerDef,\n type PartialRequestContext,\n type PartialRequestResult,\n type PartialResponseData,\n REQUEST_RESOLVED,\n type RawResponseDataWithMaybeCacheMetadata,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_RESOLVED,\n} from '@graphql-box/core';\nimport {\n ArgsError,\n EventAsyncIterator,\n GroupedError,\n deserializeErrors,\n hashRequest,\n isPlainObject,\n rehydrateCacheMetadata,\n} from '@graphql-box/helpers';\nimport { type RequestParserDef } from '@graphql-box/request-parser';\nimport { EventEmitter } from 'eventemitter3';\nimport { OperationTypeNode } from 'graphql';\nimport { isError } from 'lodash-es';\nimport { v4 as uuid } from 'uuid';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE } from './constants.ts';\nimport { logRequest } from './debug/logRequest.ts';\nimport { logSubscription } from './debug/logSubscription.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MessageResponsePayload,\n type PendingResolver,\n type PendingTracker,\n type UserOptions,\n} from './types.ts';\n\nexport class WorkerClient {\n private static _getMessageContext({\n hasDeferOrStream = false,\n initiator,\n operation,\n requestID,\n }: RequestContext): MessageContext {\n return { hasDeferOrStream, initiator, operation, requestID };\n }\n\n private static _resolve(\n { cacheMetadata, ...rest }: PartialResponseData,\n options: RequestOptions,\n { requestID }: RequestContext,\n ): PartialRequestResult {\n const result: PartialRequestResult = { ...rest, requestID };\n\n if (options.returnCacheMetadata && cacheMetadata) {\n result._cacheMetadata = cacheMetadata;\n }\n\n return result;\n }\n\n private _onMessage = ({ data }: MessageEvent<MessageResponsePayload>): void => {\n if (!isPlainObject(data)) {\n return;\n }\n\n const { context, method, result, type } = data;\n\n if (type !== GRAPHQL_BOX) {\n return;\n }\n\n const { _cacheMetadata, ...otherProps } = result;\n const response: PartialRequestResult = { ...deserializeErrors(otherProps), requestID: context.requestID };\n\n if (_cacheMetadata) {\n response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);\n }\n\n if (method === SUBSCRIBE) {\n this._debugManager?.log(SUBSCRIPTION_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else if (context.hasDeferOrStream) {\n const pending = this._pending.get(context.requestID);\n\n if (pending) {\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n pending.resolve(eventAsyncIterator.getIterator());\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else {\n const pending = this._pending.get(context.requestID);\n\n if (!pending) {\n return;\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n if (context.operation === OperationTypeNode.QUERY && pending.requestData && pending.options && pending.context) {\n void this._cacheManager.cacheQuery(\n pending.requestData,\n undefined,\n // Need to look at what type guards can be put in place\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n response as RawResponseDataWithMaybeCacheMetadata,\n pending.options,\n pending.context,\n );\n }\n\n pending.resolve(response);\n }\n };\n\n /**\n * This cache instance does not actually store anything itself,\n * it is for communicating with the worker cache that the worker\n * client is using within the worker.\n */\n private _cache: CoreWorker;\n private _cacheManager: CacheManagerDef;\n private _debugManager: DebugManagerDef | null;\n private _eventEmitter: EventEmitter;\n private _experimentalDeferStreamSupport: boolean;\n private _messageQueue: MessageRequestPayload[] = [];\n private _pending: PendingTracker = new Map();\n private _requestParser: RequestParserDef;\n private _worker: Worker | undefined;\n\n constructor(options: UserOptions) {\n const errors: ArgsError[] = [];\n\n if (!isPlainObject(options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));\n }\n\n if (!('cache' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));\n }\n\n if (!('cacheManager' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cacheManager.'));\n }\n\n if (!('requestParser' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.requestParser.'));\n }\n\n if (!options.lazyWorkerInit && !('worker' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));\n }\n\n if (errors.length > 0) {\n throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);\n }\n\n this._cache = options.cache;\n this._cacheManager = options.cacheManager;\n this._debugManager = options.debugManager ?? null;\n this._eventEmitter = new EventEmitter();\n this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;\n this._requestParser = options.requestParser;\n\n if (typeof options.worker === 'function') {\n Promise.resolve(options.worker())\n .then(worker => {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n })\n .catch((error: unknown) => {\n throw error;\n });\n } else if (options.worker) {\n this._worker = options.worker;\n this._addEventListener();\n }\n }\n\n get cache(): CoreWorker {\n return this._cache;\n }\n\n get cacheManager(): CacheManagerDef {\n return this._cacheManager;\n }\n\n public async mutate(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));\n }\n\n public async query(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._query(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async request(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async subscribe(request: string, options: RequestOptions = {}) {\n return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));\n }\n\n public set worker(worker: Worker) {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n }\n\n private _addEventListener(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n this._worker.addEventListener(MESSAGE, this._onMessage);\n }\n\n private _getRequestContext(\n operation: OperationTypeNode,\n request: string,\n context: PartialRequestContext = {},\n ): RequestContext {\n return {\n debugManager: this._debugManager,\n experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,\n fieldTypeMap: new Map(),\n filteredRequest: '',\n operation,\n operationName: '',\n originalRequestHash: hashRequest(request),\n parsedRequest: '',\n queryFiltered: false,\n request,\n requestComplexity: null,\n requestDepth: null,\n requestID: uuid(),\n ...context,\n };\n }\n\n private async _query(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n const { ast, request: updateRequest } = this._requestParser.updateRequest(request, options, context);\n const requestData = { ast, hash: hashRequest(updateRequest), request: updateRequest };\n const checkResult = await this._cacheManager.checkQueryResponseCacheEntry(requestData.hash, options, context);\n\n if (checkResult) {\n return WorkerClient._resolve(checkResult, options, context);\n }\n\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { context, options, requestData, resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n private _releaseMessageQueue(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n const messageQueue = [...this._messageQueue];\n this._messageQueue = [];\n\n for (const message of messageQueue) {\n this._worker.postMessage(message);\n }\n }\n\n @logRequest()\n private async _request(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n @logSubscription()\n private _subscribe(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n return Promise.resolve(eventAsyncIterator.getIterator());\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client subscribe had an unexpected error.');\n\n return Promise.resolve({ errors: [confirmedError], requestID: context.requestID });\n }\n }\n}\n","import {\n type PartialRequestResult,\n REQUEST_EXECUTED,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { isAsyncIterable } from 'iterall';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logRequest = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(REQUEST_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n const endTime = debugManager.now();\n const duration = endTime - startTime;\n resolve(result);\n\n if (isAsyncIterable(result)) {\n return;\n }\n\n debugManager.log(REQUEST_RESOLVED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n result,\n stats: { duration, endTime, startTime },\n });\n })();\n });\n };\n };\n};\n","import {\n type PartialRequestResult,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_EXECUTED,\n} from '@graphql-box/core';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logSubscription = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(SUBSCRIPTION_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n resolve(result);\n })();\n });\n };\n };\n};\n","import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';\nimport { GRAPHQL_BOX } from '../constants.ts';\nimport { type MessageRequestPayload } from '../types.ts';\n\nexport const isGraphqlBoxMessageRequestPayload = (\n payload: MessageRequestPayload | CachemapMessageRequestPayload,\n): payload is MessageRequestPayload => payload.type === GRAPHQL_BOX;\n","import {\n type PostMessage as CachemapMessageRequestPayload,\n handleMessage as handleCachemapMessage,\n} from '@cachemap/core-worker';\nimport { type Client } from '@graphql-box/client';\nimport { type PartialDehydratedRequestResult, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';\nimport { dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';\nimport { forAwaitEach, isAsyncIterable } from 'iterall';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST } from './constants.ts';\nimport { isGraphqlBoxMessageRequestPayload } from './helpers/isGraphqlBoxMessageRequestPayload.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MethodNames,\n type RegisterWorkerOptions,\n} from './types.ts';\n\nconst handleRequest = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const requestResult = await client.request(request, options, context);\n\n if (!isAsyncIterable(requestResult)) {\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const { _cacheMetadata, ...otherProps } = requestResult as PartialRequestResult;\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n return;\n }\n\n void forAwaitEach(requestResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nconst handleSubscription = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const subscribeResult = await client.subscribe(request, options, context);\n\n if (!isAsyncIterable(subscribeResult)) {\n globalThis.postMessage({\n context,\n method,\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n result: serializeErrors(subscribeResult as PartialRequestResult),\n type: GRAPHQL_BOX,\n });\n\n return;\n }\n\n void forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nexport const handleMessage = (data: MessageRequestPayload, client: Client): void => {\n const { context, method, options, request } = data;\n\n if (method === REQUEST) {\n void handleRequest(request, method, options, context, client);\n } else {\n void handleSubscription(request, method, options, context, client);\n }\n};\n\nexport const registerWorker = ({ client }: RegisterWorkerOptions): void => {\n const onMessage = ({ data }: MessageEvent<MessageRequestPayload | CachemapMessageRequestPayload>): void => {\n if (isGraphqlBoxMessageRequestPayload(data)) {\n handleMessage(data, client);\n } else if (client.cache) {\n void handleCachemapMessage(data, client.cache);\n }\n };\n\n globalThis.addEventListener(MESSAGE, onMessage);\n};\n"],"names":["GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","WorkerClient","_getMessageContext","hasDeferOrStream","initiator","operation","requestID","_resolve","cacheMetadata","rest","options","result","returnCacheMetadata","_cacheMetadata","constructor","_onMessage","data","isPlainObject","context","method","type","otherProps","response","deserializeErrors","rehydrateCacheMetadata","this","_debugManager","log","SUBSCRIPTION_RESOLVED","stats","endTime","now","_eventEmitter","emit","pending","_pending","get","eventAsyncIterator","EventAsyncIterator","resolve","getIterator","REQUEST_RESOLVED","OperationTypeNode","QUERY","requestData","_cacheManager","cacheQuery","undefined","_messageQueue","Map","errors","push","ArgsError","lazyWorkerInit","length","GroupedError","_cache","cache","cacheManager","debugManager","EventEmitter","_experimentalDeferStreamSupport","experimentalDeferStreamSupport","_requestParser","requestParser","worker","Promise","then","_worker","_addEventListener","_releaseMessageQueue","catch","error","mutate","_request","_getRequestContext","MUTATION","query","_query","subscribe","_subscribe","SUBSCRIPTION","Error","addEventListener","fieldTypeMap","filteredRequest","operationName","originalRequestHash","hashRequest","parsedRequest","queryFiltered","requestComplexity","requestDepth","uuid","ast","updateRequest","hash","checkResult","checkQueryResponseCacheEntry","postMessage","set","isError","messageQueue","message","confirmedError","_target","_propertyName","descriptor","value","async","args","otherContext","apply","derivedOperationName","startTime","REQUEST_EXECUTED","duration","isAsyncIterable","SUBSCRIPTION_EXECUTED","handleMessage","client","requestResult","serializeErrors","dehydrateCacheMetadata","globalThis","forAwaitEach","handleRequest","subscribeResult","handleSubscription","handleCachemapMessage","onMessage"],"mappings":"+QAAO,MACMA,EAAc,aACdC,EAAU,UACVC,EAAU,UACVC,EAAY,YCJZC,EAAsBC,IACjC,MAAMC,EAAS,mDAAmDC,KAAKF,GACvE,OAAOC,EAASA,EAAO,GAAK,EAAA,qbCqCvB,MAAME,EACX,yBAAeC,EAAmBC,iBAChCA,GAAmB,EAAKC,UACxBA,EAASC,UACTA,EAASC,UACTA,IAEA,MAAO,CAAEH,mBAAkBC,YAAWC,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aJ,GAAe,EAAG5G,oBAAmBQ,MACrD,MAAMV,EAAyC+G,EAAAA,gBAAgB,IAAKrG,IAEhER,IACFF,EAAOE,eAAiB8G,EAAuB9G,uBAAAA,IAGjD+G,WAAWzB,YAAY,CAAEjF,UAASC,SAAQR,SAAQS,KAAM3B,GAAY,GACtE,EAwCOqI,CAAchI,EAASqB,EAAQT,EAASQ,EAASsG,GArC/BX,OACzB/G,EACAqB,EACAT,EACAQ,EACAsG,KAEA,MAAMO,QAAwBP,EAAOzC,UAAUjF,EAASY,EAASQ,GAE5DmG,EAAAA,gBAAgBU,GAahBF,EAAAA,aAAaE,GAAiB,EAAGlH,oBAAmBQ,MACvD,MAAMV,EAAyC+G,EAAAA,gBAAgB,IAAKrG,IAEhER,IACFF,EAAOE,eAAiB8G,EAAuB9G,uBAAAA,IAGjD+G,WAAWzB,YAAY,CAAEjF,UAASC,SAAQR,SAAQS,KAAM3B,GAAY,IAnBpEmI,WAAWzB,YAAY,CACrBjF,UACAC,SAGAR,OAAQ+G,EAAgBK,gBAAAA,GACxB3G,KAAM3B,GAcV,EASOuI,CAAmBlI,EAASqB,EAAQT,EAASQ,EAASsG,EAC7D,mBN3FsB,+JM8FM,EAAGA,aAS/BI,WAAWzC,iBAAiBzF,GARV,EAAGsB,WACmBA,ED1FKI,OAAS3B,EC2FlD8H,EAAcvG,EAAMwG,GACXA,EAAO/D,OACXwE,gBAAsBjH,EAAMwG,EAAO/D,MAC1C,GAGmCyE"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"core-js/modules/es.array.push.js";import{REQUEST_EXECUTED as e,REQUEST_RESOLVED as t,SUBSCRIPTION_EXECUTED as r,SUBSCRIPTION_RESOLVED as s}from"@graphql-box/core";import{isPlainObject as o,deserializeErrors as a,rehydrateCacheMetadata as n,EventAsyncIterator as i,ArgsError as u,GroupedError as c,hashRequest as h,serializeErrors as p,dehydrateCacheMetadata as g}from"@graphql-box/helpers";import{EventEmitter as l}from"eventemitter3";import{OperationTypeNode as d}from"graphql";import{isError as q}from"lodash-es";import{v4 as _}from"uuid";import{isAsyncIterable as m,forAwaitEach as w}from"iterall";import{handleMessage as f}from"@cachemap/core-worker";const y="cachemap",x="graphqlBox",M="message",b="request",k="subscribe",D=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};function v(e,t,r,s){var o,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(n=(a<3?o(n):a>3?o(t,r,n):o(t,r))||n);return a>3&&n&&Object.defineProperty(t,r,n),n}function R(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class I{static _getMessageContext({hasDeferOrStream:e=!1,
|
|
1
|
+
import"core-js/modules/es.array.push.js";import{REQUEST_EXECUTED as e,REQUEST_RESOLVED as t,SUBSCRIPTION_EXECUTED as r,SUBSCRIPTION_RESOLVED as s}from"@graphql-box/core";import{isPlainObject as o,deserializeErrors as a,rehydrateCacheMetadata as n,EventAsyncIterator as i,ArgsError as u,GroupedError as c,hashRequest as h,serializeErrors as p,dehydrateCacheMetadata as g}from"@graphql-box/helpers";import{EventEmitter as l}from"eventemitter3";import{OperationTypeNode as d}from"graphql";import{isError as q}from"lodash-es";import{v4 as _}from"uuid";import{isAsyncIterable as m,forAwaitEach as w}from"iterall";import{handleMessage as f}from"@cachemap/core-worker";const y="cachemap",x="graphqlBox",M="message",b="request",k="subscribe",D=e=>{const t=/(query|mutation|subscription) ([A-Za-z]+)(\(| {)/.exec(e);return t?t[2]:""};function v(e,t,r,s){var o,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(n=(a<3?o(n):a>3?o(t,r,n):o(t,r))||n);return a>3&&n&&Object.defineProperty(t,r,n),n}function R(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class I{static _getMessageContext({hasDeferOrStream:e=!1,initiator:t,operation:r,requestID:s}){return{hasDeferOrStream:e,initiator:t,operation:r,requestID:s}}static _resolve({cacheMetadata:e,...t},r,{requestID:s}){const o={...t,requestID:s};return r.returnCacheMetadata&&e&&(o._cacheMetadata=e),o}constructor(e){this._onMessage=({data:e})=>{if(!o(e))return;const{context:r,method:u,result:c,type:h}=e;if(h!==x)return;const{_cacheMetadata:p,...g}=c,l={...a(g),requestID:r.requestID};if(p&&(l._cacheMetadata=n(p)),u===k)this._debugManager?.log(s,{context:r,result:l,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(r.requestID,l);else if(r.hasDeferOrStream){const e=this._pending.get(r.requestID);if(e){const t=new i(this._eventEmitter,r.requestID);e.resolve(t.getIterator())}this._debugManager?.log(t,{context:r,result:l,stats:{endTime:this._debugManager.now()}}),this._eventEmitter.emit(r.requestID,l)}else{const e=this._pending.get(r.requestID);if(!e)return;this._debugManager?.log(t,{context:r,result:l,stats:{endTime:this._debugManager.now()}}),r.operation===d.QUERY&&e.requestData&&e.options&&e.context&&this._cacheManager.cacheQuery(e.requestData,void 0,l,e.options,e.context),e.resolve(l)}},this._messageQueue=[],this._pending=new Map;const r=[];if(o(e)||r.push(new u("@graphql-box/worker-client expected options to ba a plain object.")),"cache"in e||r.push(new u("@graphql-box/worker-client expected options.cache.")),"cacheManager"in e||r.push(new u("@graphql-box/worker-client expected options.cacheManager.")),"requestParser"in e||r.push(new u("@graphql-box/worker-client expected options.requestParser.")),e.lazyWorkerInit||"worker"in e||r.push(new u("@graphql-box/worker-client expected options.worker.")),r.length>0)throw new c("@graphql-box/worker-client argument validation errors.",r);this._cache=e.cache,this._cacheManager=e.cacheManager,this._debugManager=e.debugManager??null,this._eventEmitter=new l,this._experimentalDeferStreamSupport=e.experimentalDeferStreamSupport??!1,this._requestParser=e.requestParser,"function"==typeof e.worker?Promise.resolve(e.worker()).then((e=>{this._worker=e,this._addEventListener(),this._releaseMessageQueue()})).catch((e=>{throw e})):e.worker&&(this._worker=e.worker,this._addEventListener())}get cache(){return this._cache}get cacheManager(){return this._cacheManager}async mutate(e,t={},r={}){return this._request(e,t,this._getRequestContext(d.MUTATION,e,r))}async query(e,t={},r={}){return this._query(e,t,this._getRequestContext(d.QUERY,e,r))}async request(e,t={},r={}){return this._request(e,t,this._getRequestContext(d.QUERY,e,r))}async subscribe(e,t={}){return this._subscribe(e,t,this._getRequestContext(d.SUBSCRIPTION,e))}set worker(e){this._worker=e,this._addEventListener(),this._releaseMessageQueue()}_addEventListener(){if(!this._worker)throw new Error("A worker is required for the WorkerClient to work correctly.");this._worker.addEventListener(M,this._onMessage)}_getRequestContext(e,t,r={}){return{debugManager:this._debugManager,experimentalDeferStreamSupport:this._experimentalDeferStreamSupport,fieldTypeMap:new Map,filteredRequest:"",operation:e,operationName:"",originalRequestHash:h(t),parsedRequest:"",queryFiltered:!1,request:t,requestComplexity:null,requestDepth:null,requestID:_(),...r}}async _query(e,t,r){try{const{ast:s,request:o}=this._requestParser.updateRequest(e,t,r),a={ast:s,hash:h(o),request:o},n=await this._cacheManager.checkQueryResponseCacheEntry(a.hash,t,r);return n?I._resolve(n,t,r):await new Promise((s=>{this._worker?this._worker.postMessage({context:I._getMessageContext(r),method:b,options:t,request:e,type:x}):this._messageQueue.push({context:I._getMessageContext(r),method:b,options:t,request:e,type:x}),this._pending.set(r.requestID,{context:r,options:t,requestData:a,resolve:s})}))}catch(e){return{errors:[q(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:r.requestID}}}_releaseMessageQueue(){if(!this._worker)throw new Error("A worker is required for the WorkerClient to work correctly.");const e=[...this._messageQueue];this._messageQueue=[];for(const t of e)this._worker.postMessage(t)}async _request(e,t,r){try{return await new Promise((s=>{this._worker?this._worker.postMessage({context:I._getMessageContext(r),method:b,options:t,request:e,type:x}):this._messageQueue.push({context:I._getMessageContext(r),method:b,options:t,request:e,type:x}),this._pending.set(r.requestID,{resolve:s})}))}catch(e){return{errors:[q(e)?e:new Error("@graphql-box/worker-client request had an unexpected error.")],requestID:r.requestID}}}_subscribe(e,t,r){try{this._worker?this._worker.postMessage({context:I._getMessageContext(r),method:k,options:t,request:e,type:x}):this._messageQueue.push({context:I._getMessageContext(r),method:k,options:t,request:e,type:x});const s=new i(this._eventEmitter,r.requestID);return Promise.resolve(s.getIterator())}catch(e){const t=q(e)?e:new Error("@graphql-box/worker-client subscribe had an unexpected error.");return Promise.resolve({errors:[t],requestID:r.requestID})}}}v([(r,s,o)=>{const a=o.value;a&&(o.value=async function(...r){return new Promise((s=>{(async()=>{const{debugManager:o,...n}=r[2];if(!o)return void s(await a.apply(this,r));const i=D(r[0]),u=o.now();o.log(e,{context:{...n,operationName:i},options:r[1],request:r[0],stats:{startTime:u}});const c=await a.apply(this,r),h=o.now(),p=h-u;s(c),m(c)||o.log(t,{context:{...n,operationName:i},options:r[1],request:r[0],result:c,stats:{duration:p,endTime:h,startTime:u}})})()}))})},R("design:type",Function),R("design:paramtypes",[String,"undefined"==typeof RequestOptions?Object:RequestOptions,"undefined"==typeof RequestContext?Object:RequestContext]),R("design:returntype",Promise)],I.prototype,"_request",null),v([(e,t,s)=>{const o=s.value;o&&(s.value=async function(...e){return new Promise((t=>{(async()=>{const{debugManager:s,...a}=e[2];if(!s)return void t(await o.apply(this,e));const n=D(e[0]),i=s.now();s.log(r,{context:{...a,operationName:n},options:e[1],request:e[0],stats:{startTime:i}});const u=await o.apply(this,e);t(u)})()}))})},R("design:type",Function),R("design:paramtypes",[String,"undefined"==typeof RequestOptions?Object:RequestOptions,"undefined"==typeof RequestContext?Object:RequestContext]),R("design:returntype","undefined"==typeof Promise?Object:Promise)],I.prototype,"_subscribe",null);const C=(e,t)=>{const{context:r,method:s,options:o,request:a}=e;s===b?(async(e,t,r,s,o)=>{const a=await o.request(e,r,s);if(!m(a)){const{_cacheMetadata:e,...r}=a,o=p({...r});return e&&(o._cacheMetadata=g(e)),void globalThis.postMessage({context:s,method:t,result:o,type:x})}w(a,(({_cacheMetadata:e,...r})=>{const o=p({...r});e&&(o._cacheMetadata=g(e)),globalThis.postMessage({context:s,method:t,result:o,type:x})}))})(a,s,o,r,t):(async(e,t,r,s,o)=>{const a=await o.subscribe(e,r,s);m(a)?w(a,(({_cacheMetadata:e,...r})=>{const o=p({...r});e&&(o._cacheMetadata=g(e)),globalThis.postMessage({context:s,method:t,result:o,type:x})})):globalThis.postMessage({context:s,method:t,result:p(a),type:x})})(a,s,o,r,t)},E=({client:e})=>{globalThis.addEventListener(M,(({data:t})=>{t.type===x?C(t,e):e.cache&&f(t,e.cache)}))};export{y as CACHEMAP,x as GRAPHQL_BOX,M as MESSAGE,b as REQUEST,k as SUBSCRIBE,I as WorkerClient,C as handleMessage,E as registerWorker};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../worker-client/src//constants.ts","../worker-client/src//helpers/operationNameRegex.ts","../worker-client/src//main.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.ts","../worker-client/src//helpers/isGraphqlBoxMessageRequestPayload.ts","../worker-client/src//registerWorker.ts"],"sourcesContent":["export const CACHEMAP = 'cachemap';\nexport const GRAPHQL_BOX = 'graphqlBox';\nexport const MESSAGE = 'message';\nexport const REQUEST = 'request';\nexport const SUBSCRIBE = 'subscribe';\n","export const operationNameRegex = (request: string) => {\n const output = /(query|mutation|subscription) ([A-Za-z]+)(\\(| {)/.exec(request);\n return output ? output[2] : '';\n};\n","import { type CoreWorker } from '@cachemap/core-worker';\nimport { type CacheManagerDef } from '@graphql-box/cache-manager';\nimport {\n type DebugManagerDef,\n type PartialRequestContext,\n type PartialRequestResult,\n type PartialResponseData,\n REQUEST_RESOLVED,\n type RawResponseDataWithMaybeCacheMetadata,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_RESOLVED,\n} from '@graphql-box/core';\nimport {\n ArgsError,\n EventAsyncIterator,\n GroupedError,\n deserializeErrors,\n hashRequest,\n isPlainObject,\n rehydrateCacheMetadata,\n} from '@graphql-box/helpers';\nimport { type RequestParserDef } from '@graphql-box/request-parser';\nimport { EventEmitter } from 'eventemitter3';\nimport { OperationTypeNode } from 'graphql';\nimport { isError } from 'lodash-es';\nimport { v4 as uuid } from 'uuid';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE } from './constants.ts';\nimport { logRequest } from './debug/logRequest.ts';\nimport { logSubscription } from './debug/logSubscription.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MessageResponsePayload,\n type PendingResolver,\n type PendingTracker,\n type UserOptions,\n} from './types.ts';\n\nexport class WorkerClient {\n private static _getMessageContext({\n hasDeferOrStream = false,\n operation,\n requestID,\n }: RequestContext): MessageContext {\n return { hasDeferOrStream, operation, requestID };\n }\n\n private static _resolve(\n { cacheMetadata, ...rest }: PartialResponseData,\n options: RequestOptions,\n { requestID }: RequestContext,\n ): PartialRequestResult {\n const result: PartialRequestResult = { ...rest, requestID };\n\n if (options.returnCacheMetadata && cacheMetadata) {\n result._cacheMetadata = cacheMetadata;\n }\n\n return result;\n }\n\n private _onMessage = ({ data }: MessageEvent<MessageResponsePayload>): void => {\n if (!isPlainObject(data)) {\n return;\n }\n\n const { context, method, result, type } = data;\n\n if (type !== GRAPHQL_BOX) {\n return;\n }\n\n const { _cacheMetadata, ...otherProps } = result;\n const response: PartialRequestResult = { ...deserializeErrors(otherProps), requestID: context.requestID };\n\n if (_cacheMetadata) {\n response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);\n }\n\n if (method === SUBSCRIBE) {\n this._debugManager?.log(SUBSCRIPTION_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else if (context.hasDeferOrStream) {\n const pending = this._pending.get(context.requestID);\n\n if (pending) {\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n pending.resolve(eventAsyncIterator.getIterator());\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else {\n const pending = this._pending.get(context.requestID);\n\n if (!pending) {\n return;\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n if (context.operation === OperationTypeNode.QUERY && pending.requestData && pending.options && pending.context) {\n void this._cacheManager.cacheQuery(\n pending.requestData,\n undefined,\n // Need to look at what type guards can be put in place\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n response as RawResponseDataWithMaybeCacheMetadata,\n pending.options,\n pending.context,\n );\n }\n\n pending.resolve(response);\n }\n };\n\n /**\n * This cache instance does not actually store anything itself,\n * it is for communicating with the worker cache that the worker\n * client is using within the worker.\n */\n private _cache: CoreWorker;\n private _cacheManager: CacheManagerDef;\n private _debugManager: DebugManagerDef | null;\n private _eventEmitter: EventEmitter;\n private _experimentalDeferStreamSupport: boolean;\n private _messageQueue: MessageRequestPayload[] = [];\n private _pending: PendingTracker = new Map();\n private _requestParser: RequestParserDef;\n private _worker: Worker | undefined;\n\n constructor(options: UserOptions) {\n const errors: ArgsError[] = [];\n\n if (!isPlainObject(options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));\n }\n\n if (!('cache' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));\n }\n\n if (!('cacheManager' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cacheManager.'));\n }\n\n if (!('requestParser' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.requestParser.'));\n }\n\n if (!options.lazyWorkerInit && !('worker' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));\n }\n\n if (errors.length > 0) {\n throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);\n }\n\n this._cache = options.cache;\n this._cacheManager = options.cacheManager;\n this._debugManager = options.debugManager ?? null;\n this._eventEmitter = new EventEmitter();\n this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;\n this._requestParser = options.requestParser;\n\n if (typeof options.worker === 'function') {\n Promise.resolve(options.worker())\n .then(worker => {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n })\n .catch((error: unknown) => {\n throw error;\n });\n } else if (options.worker) {\n this._worker = options.worker;\n this._addEventListener();\n }\n }\n\n get cache(): CoreWorker {\n return this._cache;\n }\n\n get cacheManager(): CacheManagerDef {\n return this._cacheManager;\n }\n\n public async mutate(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));\n }\n\n public async query(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._query(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async request(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async subscribe(request: string, options: RequestOptions = {}) {\n return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));\n }\n\n public set worker(worker: Worker) {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n }\n\n private _addEventListener(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n this._worker.addEventListener(MESSAGE, this._onMessage);\n }\n\n private _getRequestContext(\n operation: OperationTypeNode,\n request: string,\n context: PartialRequestContext = {},\n ): RequestContext {\n return {\n debugManager: this._debugManager,\n experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,\n fieldTypeMap: new Map(),\n filteredRequest: '',\n operation,\n operationName: '',\n originalRequestHash: hashRequest(request),\n parsedRequest: '',\n queryFiltered: false,\n request,\n requestComplexity: null,\n requestDepth: null,\n requestID: uuid(),\n ...context,\n };\n }\n\n private async _query(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n const { ast, request: updateRequest } = this._requestParser.updateRequest(request, options, context);\n const requestData = { ast, hash: hashRequest(updateRequest), request: updateRequest };\n const checkResult = await this._cacheManager.checkQueryResponseCacheEntry(requestData.hash, options, context);\n\n if (checkResult) {\n return WorkerClient._resolve(checkResult, options, context);\n }\n\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { context, options, requestData, resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n private _releaseMessageQueue(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n const messageQueue = [...this._messageQueue];\n this._messageQueue = [];\n\n for (const message of messageQueue) {\n this._worker.postMessage(message);\n }\n }\n\n @logRequest()\n private async _request(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n @logSubscription()\n private _subscribe(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n return Promise.resolve(eventAsyncIterator.getIterator());\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client subscribe had an unexpected error.');\n\n return Promise.resolve({ errors: [confirmedError], requestID: context.requestID });\n }\n }\n}\n","import {\n type PartialRequestResult,\n REQUEST_EXECUTED,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { isAsyncIterable } from 'iterall';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logRequest = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(REQUEST_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n const endTime = debugManager.now();\n const duration = endTime - startTime;\n resolve(result);\n\n if (isAsyncIterable(result)) {\n return;\n }\n\n debugManager.log(REQUEST_RESOLVED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n result,\n stats: { duration, endTime, startTime },\n });\n })();\n });\n };\n };\n};\n","import {\n type PartialRequestResult,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_EXECUTED,\n} from '@graphql-box/core';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logSubscription = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(SUBSCRIPTION_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n resolve(result);\n })();\n });\n };\n };\n};\n","import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';\nimport { GRAPHQL_BOX } from '../constants.ts';\nimport { type MessageRequestPayload } from '../types.ts';\n\nexport const isGraphqlBoxMessageRequestPayload = (\n payload: MessageRequestPayload | CachemapMessageRequestPayload,\n): payload is MessageRequestPayload => payload.type === GRAPHQL_BOX;\n","import {\n type PostMessage as CachemapMessageRequestPayload,\n handleMessage as handleCachemapMessage,\n} from '@cachemap/core-worker';\nimport { type Client } from '@graphql-box/client';\nimport { type PartialDehydratedRequestResult, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';\nimport { dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';\nimport { forAwaitEach, isAsyncIterable } from 'iterall';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST } from './constants.ts';\nimport { isGraphqlBoxMessageRequestPayload } from './helpers/isGraphqlBoxMessageRequestPayload.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MethodNames,\n type RegisterWorkerOptions,\n} from './types.ts';\n\nconst handleRequest = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const requestResult = await client.request(request, options, context);\n\n if (!isAsyncIterable(requestResult)) {\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const { _cacheMetadata, ...otherProps } = requestResult as PartialRequestResult;\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n return;\n }\n\n void forAwaitEach(requestResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nconst handleSubscription = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const subscribeResult = await client.subscribe(request, options, context);\n\n if (!isAsyncIterable(subscribeResult)) {\n globalThis.postMessage({\n context,\n method,\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n result: serializeErrors(subscribeResult as PartialRequestResult),\n type: GRAPHQL_BOX,\n });\n\n return;\n }\n\n void forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nexport const handleMessage = (data: MessageRequestPayload, client: Client): void => {\n const { context, method, options, request } = data;\n\n if (method === REQUEST) {\n void handleRequest(request, method, options, context, client);\n } else {\n void handleSubscription(request, method, options, context, client);\n }\n};\n\nexport const registerWorker = ({ client }: RegisterWorkerOptions): void => {\n const onMessage = ({ data }: MessageEvent<MessageRequestPayload | CachemapMessageRequestPayload>): void => {\n if (isGraphqlBoxMessageRequestPayload(data)) {\n handleMessage(data, client);\n } else if (client.cache) {\n void handleCachemapMessage(data, client.cache);\n }\n };\n\n globalThis.addEventListener(MESSAGE, onMessage);\n};\n"],"names":["CACHEMAP","GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","WorkerClient","_getMessageContext","hasDeferOrStream","operation","requestID","_resolve","cacheMetadata","rest","options","result","returnCacheMetadata","_cacheMetadata","constructor","_onMessage","data","isPlainObject","context","method","type","otherProps","response","deserializeErrors","rehydrateCacheMetadata","this","_debugManager","log","SUBSCRIPTION_RESOLVED","stats","endTime","now","_eventEmitter","emit","pending","_pending","get","eventAsyncIterator","EventAsyncIterator","resolve","getIterator","REQUEST_RESOLVED","OperationTypeNode","QUERY","requestData","_cacheManager","cacheQuery","undefined","_messageQueue","Map","errors","push","ArgsError","lazyWorkerInit","length","GroupedError","_cache","cache","cacheManager","debugManager","EventEmitter","_experimentalDeferStreamSupport","experimentalDeferStreamSupport","_requestParser","requestParser","worker","Promise","then","_worker","_addEventListener","_releaseMessageQueue","catch","error","mutate","_request","_getRequestContext","MUTATION","query","_query","subscribe","_subscribe","SUBSCRIPTION","Error","addEventListener","fieldTypeMap","filteredRequest","operationName","originalRequestHash","hashRequest","parsedRequest","queryFiltered","requestComplexity","requestDepth","uuid","ast","updateRequest","hash","checkResult","checkQueryResponseCacheEntry","postMessage","set","isError","messageQueue","message","confirmedError","_target","_propertyName","descriptor","value","async","args","otherContext","apply","derivedOperationName","startTime","REQUEST_EXECUTED","duration","isAsyncIterable","SUBSCRIPTION_EXECUTED","handleMessage","client","requestResult","serializeErrors","dehydrateCacheMetadata","globalThis","forAwaitEach","handleRequest","subscribeResult","handleSubscription","registerWorker","handleCachemapMessage","onMessage"],"mappings":"spBAAO,MAAMA,EAAW,WACXC,EAAc,aACdC,EAAU,UACVC,EAAU,UACVC,EAAY,YCJZC,EAAsBC,IACjC,MAAMC,EAAS,mDAAmDC,KAAKF,GACvE,OAAOC,EAASA,EAAO,GAAK,EAAA,qbCqCvB,MAAME,EACX,yBAAeC,EAAmBC,iBAChCA,GAAmB,EAAKC,UACxBA,EAASC,UACTA,IAEA,MAAO,CAAEF,mBAAkBC,YAAWC,YACxC,CAEA,eAAeC,EACbC,cAAEA,KAAkBC,GACpBC,GACAJ,UAAEA,IAEF,MAAMK,EAA+B,IAAKF,EAAMH,aAMhD,OAJII,EAAQE,qBAAuBJ,IACjCG,EAAOE,eAAiBL,GAGnBG,CACT,CAuFAG,WAAAA,CAAYJ,QArFJK,WAAa,EAAGC,WACtB,IAAKC,EAAcD,GACjB,OAGF,MAAME,QAAEA,EAAOC,OAAEA,EAAMR,OAAEA,EAAMS,KAAEA,GAASJ,EAE1C,GAAII,IAAS1B,EACX,OAGF,MAAMmB,eAAEA,KAAmBQ,GAAeV,EACpCW,EAAiC,IAAKC,EAAkBF,GAAaf,UAAWY,EAAQZ,WAM9F,GAJIO,IACFS,EAAST,eAAiBW,EAAuB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T,aAS/BI,WAAWzC,iBAAiBxF,GARV,EAAGqB,WACmBA,ED1FKI,OAAS1B,EC2FlD6H,EAAcvG,EAAMwG,GACXA,EAAO/D,OACXyE,EAAsBlH,EAAMwG,EAAO/D,MAC1C,GAGmC0E"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../worker-client/src//constants.ts","../worker-client/src//helpers/operationNameRegex.ts","../worker-client/src//main.ts","../worker-client/src//debug/logRequest.ts","../worker-client/src//debug/logSubscription.ts","../worker-client/src//helpers/isGraphqlBoxMessageRequestPayload.ts","../worker-client/src//registerWorker.ts"],"sourcesContent":["export const CACHEMAP = 'cachemap';\nexport const GRAPHQL_BOX = 'graphqlBox';\nexport const MESSAGE = 'message';\nexport const REQUEST = 'request';\nexport const SUBSCRIBE = 'subscribe';\n","export const operationNameRegex = (request: string) => {\n const output = /(query|mutation|subscription) ([A-Za-z]+)(\\(| {)/.exec(request);\n return output ? output[2] : '';\n};\n","import { type CoreWorker } from '@cachemap/core-worker';\nimport { type CacheManagerDef } from '@graphql-box/cache-manager';\nimport {\n type DebugManagerDef,\n type PartialRequestContext,\n type PartialRequestResult,\n type PartialResponseData,\n REQUEST_RESOLVED,\n type RawResponseDataWithMaybeCacheMetadata,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_RESOLVED,\n} from '@graphql-box/core';\nimport {\n ArgsError,\n EventAsyncIterator,\n GroupedError,\n deserializeErrors,\n hashRequest,\n isPlainObject,\n rehydrateCacheMetadata,\n} from '@graphql-box/helpers';\nimport { type RequestParserDef } from '@graphql-box/request-parser';\nimport { EventEmitter } from 'eventemitter3';\nimport { OperationTypeNode } from 'graphql';\nimport { isError } from 'lodash-es';\nimport { v4 as uuid } from 'uuid';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST, SUBSCRIBE } from './constants.ts';\nimport { logRequest } from './debug/logRequest.ts';\nimport { logSubscription } from './debug/logSubscription.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MessageResponsePayload,\n type PendingResolver,\n type PendingTracker,\n type UserOptions,\n} from './types.ts';\n\nexport class WorkerClient {\n private static _getMessageContext({\n hasDeferOrStream = false,\n initiator,\n operation,\n requestID,\n }: RequestContext): MessageContext {\n return { hasDeferOrStream, initiator, operation, requestID };\n }\n\n private static _resolve(\n { cacheMetadata, ...rest }: PartialResponseData,\n options: RequestOptions,\n { requestID }: RequestContext,\n ): PartialRequestResult {\n const result: PartialRequestResult = { ...rest, requestID };\n\n if (options.returnCacheMetadata && cacheMetadata) {\n result._cacheMetadata = cacheMetadata;\n }\n\n return result;\n }\n\n private _onMessage = ({ data }: MessageEvent<MessageResponsePayload>): void => {\n if (!isPlainObject(data)) {\n return;\n }\n\n const { context, method, result, type } = data;\n\n if (type !== GRAPHQL_BOX) {\n return;\n }\n\n const { _cacheMetadata, ...otherProps } = result;\n const response: PartialRequestResult = { ...deserializeErrors(otherProps), requestID: context.requestID };\n\n if (_cacheMetadata) {\n response._cacheMetadata = rehydrateCacheMetadata(_cacheMetadata);\n }\n\n if (method === SUBSCRIBE) {\n this._debugManager?.log(SUBSCRIPTION_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else if (context.hasDeferOrStream) {\n const pending = this._pending.get(context.requestID);\n\n if (pending) {\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n pending.resolve(eventAsyncIterator.getIterator());\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n this._eventEmitter.emit(context.requestID, response);\n } else {\n const pending = this._pending.get(context.requestID);\n\n if (!pending) {\n return;\n }\n\n this._debugManager?.log(REQUEST_RESOLVED, {\n context,\n result: response,\n stats: { endTime: this._debugManager.now() },\n });\n\n if (context.operation === OperationTypeNode.QUERY && pending.requestData && pending.options && pending.context) {\n void this._cacheManager.cacheQuery(\n pending.requestData,\n undefined,\n // Need to look at what type guards can be put in place\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n response as RawResponseDataWithMaybeCacheMetadata,\n pending.options,\n pending.context,\n );\n }\n\n pending.resolve(response);\n }\n };\n\n /**\n * This cache instance does not actually store anything itself,\n * it is for communicating with the worker cache that the worker\n * client is using within the worker.\n */\n private _cache: CoreWorker;\n private _cacheManager: CacheManagerDef;\n private _debugManager: DebugManagerDef | null;\n private _eventEmitter: EventEmitter;\n private _experimentalDeferStreamSupport: boolean;\n private _messageQueue: MessageRequestPayload[] = [];\n private _pending: PendingTracker = new Map();\n private _requestParser: RequestParserDef;\n private _worker: Worker | undefined;\n\n constructor(options: UserOptions) {\n const errors: ArgsError[] = [];\n\n if (!isPlainObject(options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options to ba a plain object.'));\n }\n\n if (!('cache' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));\n }\n\n if (!('cacheManager' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.cacheManager.'));\n }\n\n if (!('requestParser' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.requestParser.'));\n }\n\n if (!options.lazyWorkerInit && !('worker' in options)) {\n errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));\n }\n\n if (errors.length > 0) {\n throw new GroupedError('@graphql-box/worker-client argument validation errors.', errors);\n }\n\n this._cache = options.cache;\n this._cacheManager = options.cacheManager;\n this._debugManager = options.debugManager ?? null;\n this._eventEmitter = new EventEmitter();\n this._experimentalDeferStreamSupport = options.experimentalDeferStreamSupport ?? false;\n this._requestParser = options.requestParser;\n\n if (typeof options.worker === 'function') {\n Promise.resolve(options.worker())\n .then(worker => {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n })\n .catch((error: unknown) => {\n throw error;\n });\n } else if (options.worker) {\n this._worker = options.worker;\n this._addEventListener();\n }\n }\n\n get cache(): CoreWorker {\n return this._cache;\n }\n\n get cacheManager(): CacheManagerDef {\n return this._cacheManager;\n }\n\n public async mutate(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.MUTATION, request, context));\n }\n\n public async query(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._query(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async request(request: string, options: RequestOptions = {}, context: PartialRequestContext = {}) {\n return this._request(request, options, this._getRequestContext(OperationTypeNode.QUERY, request, context));\n }\n\n public async subscribe(request: string, options: RequestOptions = {}) {\n return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));\n }\n\n public set worker(worker: Worker) {\n this._worker = worker;\n this._addEventListener();\n this._releaseMessageQueue();\n }\n\n private _addEventListener(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n this._worker.addEventListener(MESSAGE, this._onMessage);\n }\n\n private _getRequestContext(\n operation: OperationTypeNode,\n request: string,\n context: PartialRequestContext = {},\n ): RequestContext {\n return {\n debugManager: this._debugManager,\n experimentalDeferStreamSupport: this._experimentalDeferStreamSupport,\n fieldTypeMap: new Map(),\n filteredRequest: '',\n operation,\n operationName: '',\n originalRequestHash: hashRequest(request),\n parsedRequest: '',\n queryFiltered: false,\n request,\n requestComplexity: null,\n requestDepth: null,\n requestID: uuid(),\n ...context,\n };\n }\n\n private async _query(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n const { ast, request: updateRequest } = this._requestParser.updateRequest(request, options, context);\n const requestData = { ast, hash: hashRequest(updateRequest), request: updateRequest };\n const checkResult = await this._cacheManager.checkQueryResponseCacheEntry(requestData.hash, options, context);\n\n if (checkResult) {\n return WorkerClient._resolve(checkResult, options, context);\n }\n\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { context, options, requestData, resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n private _releaseMessageQueue(): void {\n if (!this._worker) {\n throw new Error('A worker is required for the WorkerClient to work correctly.');\n }\n\n const messageQueue = [...this._messageQueue];\n this._messageQueue = [];\n\n for (const message of messageQueue) {\n this._worker.postMessage(message);\n }\n }\n\n @logRequest()\n private async _request(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n return await new Promise((resolve: PendingResolver) => {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: REQUEST,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n this._pending.set(context.requestID, { resolve });\n });\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client request had an unexpected error.');\n\n return { errors: [confirmedError], requestID: context.requestID };\n }\n }\n\n @logSubscription()\n private _subscribe(\n request: string,\n options: RequestOptions,\n context: RequestContext,\n ): Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>> {\n try {\n if (this._worker) {\n this._worker.postMessage({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n } else {\n this._messageQueue.push({\n context: WorkerClient._getMessageContext(context),\n method: SUBSCRIBE,\n options,\n request,\n type: GRAPHQL_BOX,\n });\n }\n\n const eventAsyncIterator = new EventAsyncIterator<PartialRequestResult>(this._eventEmitter, context.requestID);\n return Promise.resolve(eventAsyncIterator.getIterator());\n } catch (error) {\n const confirmedError = isError(error)\n ? error\n : new Error('@graphql-box/worker-client subscribe had an unexpected error.');\n\n return Promise.resolve({ errors: [confirmedError], requestID: context.requestID });\n }\n }\n}\n","import {\n type PartialRequestResult,\n REQUEST_EXECUTED,\n REQUEST_RESOLVED,\n type RequestContext,\n type RequestOptions,\n} from '@graphql-box/core';\nimport { isAsyncIterable } from 'iterall';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logRequest = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(REQUEST_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n const endTime = debugManager.now();\n const duration = endTime - startTime;\n resolve(result);\n\n if (isAsyncIterable(result)) {\n return;\n }\n\n debugManager.log(REQUEST_RESOLVED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n result,\n stats: { duration, endTime, startTime },\n });\n })();\n });\n };\n };\n};\n","import {\n type PartialRequestResult,\n type RequestContext,\n type RequestOptions,\n SUBSCRIPTION_EXECUTED,\n} from '@graphql-box/core';\nimport { operationNameRegex } from '../helpers/operationNameRegex.ts';\nimport { type WorkerClient } from '../main.ts';\n\ntype Descriptor = (\n request: string,\n options: RequestOptions,\n context: RequestContext,\n) => Promise<PartialRequestResult | AsyncIterableIterator<PartialRequestResult | undefined>>;\n\nexport const logSubscription = () => {\n return (_target: WorkerClient, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {\n const method = descriptor.value;\n\n if (!method) {\n return;\n }\n\n descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {\n return new Promise(resolve => {\n void (async () => {\n const { debugManager, ...otherContext } = args[2];\n\n if (!debugManager) {\n resolve(await method.apply(this, args));\n return;\n }\n\n const derivedOperationName = operationNameRegex(args[0]);\n const startTime = debugManager.now();\n\n debugManager.log(SUBSCRIPTION_EXECUTED, {\n context: { ...otherContext, operationName: derivedOperationName },\n options: args[1],\n request: args[0],\n stats: { startTime },\n });\n\n const result = await method.apply(this, args);\n resolve(result);\n })();\n });\n };\n };\n};\n","import { type PostMessage as CachemapMessageRequestPayload } from '@cachemap/core-worker';\nimport { GRAPHQL_BOX } from '../constants.ts';\nimport { type MessageRequestPayload } from '../types.ts';\n\nexport const isGraphqlBoxMessageRequestPayload = (\n payload: MessageRequestPayload | CachemapMessageRequestPayload,\n): payload is MessageRequestPayload => payload.type === GRAPHQL_BOX;\n","import {\n type PostMessage as CachemapMessageRequestPayload,\n handleMessage as handleCachemapMessage,\n} from '@cachemap/core-worker';\nimport { type Client } from '@graphql-box/client';\nimport { type PartialDehydratedRequestResult, type PartialRequestResult, type RequestOptions } from '@graphql-box/core';\nimport { dehydrateCacheMetadata, serializeErrors } from '@graphql-box/helpers';\nimport { forAwaitEach, isAsyncIterable } from 'iterall';\nimport { GRAPHQL_BOX, MESSAGE, REQUEST } from './constants.ts';\nimport { isGraphqlBoxMessageRequestPayload } from './helpers/isGraphqlBoxMessageRequestPayload.ts';\nimport {\n type MessageContext,\n type MessageRequestPayload,\n type MethodNames,\n type RegisterWorkerOptions,\n} from './types.ts';\n\nconst handleRequest = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const requestResult = await client.request(request, options, context);\n\n if (!isAsyncIterable(requestResult)) {\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const { _cacheMetadata, ...otherProps } = requestResult as PartialRequestResult;\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n return;\n }\n\n void forAwaitEach(requestResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nconst handleSubscription = async (\n request: string,\n method: MethodNames,\n options: RequestOptions,\n context: MessageContext,\n client: Client,\n): Promise<void> => {\n const subscribeResult = await client.subscribe(request, options, context);\n\n if (!isAsyncIterable(subscribeResult)) {\n globalThis.postMessage({\n context,\n method,\n // Need to replace this casting with a type guard\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n result: serializeErrors(subscribeResult as PartialRequestResult),\n type: GRAPHQL_BOX,\n });\n\n return;\n }\n\n void forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: PartialRequestResult) => {\n const result: PartialDehydratedRequestResult = serializeErrors({ ...otherProps });\n\n if (_cacheMetadata) {\n result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);\n }\n\n globalThis.postMessage({ context, method, result, type: GRAPHQL_BOX });\n });\n};\n\nexport const handleMessage = (data: MessageRequestPayload, client: Client): void => {\n const { context, method, options, request } = data;\n\n if (method === REQUEST) {\n void handleRequest(request, method, options, context, client);\n } else {\n void handleSubscription(request, method, options, context, client);\n }\n};\n\nexport const registerWorker = ({ client }: RegisterWorkerOptions): void => {\n const onMessage = ({ data }: MessageEvent<MessageRequestPayload | CachemapMessageRequestPayload>): void => {\n if (isGraphqlBoxMessageRequestPayload(data)) {\n handleMessage(data, client);\n } else if (client.cache) {\n void handleCachemapMessage(data, client.cache);\n }\n };\n\n globalThis.addEventListener(MESSAGE, onMessage);\n};\n"],"names":["CACHEMAP","GRAPHQL_BOX","MESSAGE","REQUEST","SUBSCRIBE","operationNameRegex","request","output","exec","WorkerClient","_getMessageContext","hasDeferOrStream","initiator","operation","requestID","_resolve","cacheMetadata","rest","options","result","returnCacheMetadata","_cacheMetadata","constructor","_onMessage","data","isPlainObject","context","method","type","otherProps","response","deserializeErrors","rehydrateCacheMetadata","this","_debugManager","log","SUBSCRIPTION_RESOLVED","stats","endTime","now","_eventEmitter","emit","pending","_pending","get","eventAsyncIterator","EventAsyncIterator","resolve","getIterator","REQUEST_RESOLVED","OperationTypeNode","QUERY","requestData","_cacheManager","cacheQuery","undefined","_messageQueue","Map","errors","push","ArgsError","lazyWorkerInit","length","GroupedError","_cache","cache","cacheManager","debugManager","EventEmitter","_experimentalDeferStreamSupport","experimentalDeferStreamSupport","_requestParser","requestParser","worker","Promise","then","_worker","_addEventListener","_releaseMessageQueue","catch","error","mutate","_request","_getRequestContext","MUTATION","query","_query","subscribe","_subscribe","SUBSCRIPTION","Error","addEventListener","fieldTypeMap","filteredRequest","operationName","originalRequestHash","hashRequest","parsedRequest","queryFiltered","requestComplexity","requestDepth","uuid","ast","updateRequest","hash","checkResult","checkQueryResponseCacheEntry","postMessage","set","isError","messageQueue","message","confirmedError","_target","_propertyName","descriptor","value","async","args","otherContext","apply","derivedOperationName","startTime","REQUEST_EXECUTED","duration","isAsyncIterable","SUBSCRIPTION_EXECUTED","handleMessage","client","requestResult","serializeErrors","dehydrateCacheMetadata","globalThis","forAwaitEach","handleRequest","subscribeResult","handleSubscription","registerWorker","handleCachemapMessage","onMessage"],"mappings":"spBAAO,MAAMA,EAAW,WACXC,EAAc,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,UAASC,SAAQR,SAAQS,KAAM3B,GAE1D,CAEKoI,EAAaJ,GAAe,EAAG5G,oBAAmBQ,MACrD,MAAMV,EAAyC+G,EAAgB,IAAKrG,IAEhER,IACFF,EAAOE,eAAiB8G,EAAuB9G,IAGjD+G,WAAWzB,YAAY,CAAEjF,UAASC,SAAQR,SAAQS,KAAM3B,GAAY,GACtE,EAwCOqI,CAAchI,EAASqB,EAAQT,EAASQ,EAASsG,GArC/BX,OACzB/G,EACAqB,EACAT,EACAQ,EACAsG,KAEA,MAAMO,QAAwBP,EAAOzC,UAAUjF,EAASY,EAASQ,GAE5DmG,EAAgBU,GAahBF,EAAaE,GAAiB,EAAGlH,oBAAmBQ,MACvD,MAAMV,EAAyC+G,EAAgB,IAAKrG,IAEhER,IACFF,EAAOE,eAAiB8G,EAAuB9G,IAGjD+G,WAAWzB,YAAY,CAAEjF,UAASC,SAAQR,SAAQS,KAAM3B,GAAY,IAnBpEmI,WAAWzB,YAAY,CACrBjF,UACAC,SAGAR,OAAQ+G,EAAgBK,GACxB3G,KAAM3B,GAcV,EASOuI,CAAmBlI,EAASqB,EAAQT,EAASQ,EAASsG,EAC7D,EAGWS,EAAiB,EAAGT,aAS/BI,WAAWzC,iBAAiBzF,GARV,EAAGsB,WACmBA,ED1FKI,OAAS3B,EC2FlD8H,EAAcvG,EAAMwG,GACXA,EAAO/D,OACXyE,EAAsBlH,EAAMwG,EAAO/D,MAC1C,GAGmC0E"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
-----------------------------
|
|
2
2
|
Rollup File Analysis
|
|
3
3
|
-----------------------------
|
|
4
|
-
bundle size: 19.
|
|
5
|
-
original size: 20.
|
|
6
|
-
code reduction:
|
|
4
|
+
bundle size: 19.706 KB
|
|
5
|
+
original size: 20.261 KB
|
|
6
|
+
code reduction: 2.74 %
|
|
7
7
|
module count: 8
|
|
8
8
|
|
|
9
9
|
█████████████████████████████████░░░░░░░░░░░░░░░░░
|
|
10
10
|
file: /src/main.ts
|
|
11
|
-
bundle space: 66.
|
|
12
|
-
rendered size:
|
|
13
|
-
original size: 12.
|
|
11
|
+
bundle space: 66.51 %
|
|
12
|
+
rendered size: 13.107 KB
|
|
13
|
+
original size: 12.234 KB
|
|
14
14
|
code reduction: 0 %
|
|
15
15
|
dependents: 1
|
|
16
16
|
- /src/index.ts
|
|
17
17
|
|
|
18
18
|
███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
19
19
|
file: /src/registerWorker.ts
|
|
20
|
-
bundle space: 14.
|
|
21
|
-
rendered size: 2.
|
|
20
|
+
bundle space: 14.5 %
|
|
21
|
+
rendered size: 2.857 KB
|
|
22
22
|
original size: 3.638 KB
|
|
23
|
-
code reduction:
|
|
23
|
+
code reduction: 21.47 %
|
|
24
24
|
dependents: 1
|
|
25
25
|
- /src/index.ts
|
|
26
26
|
|
|
27
27
|
█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
28
28
|
file: /src/debug/logRequest.ts
|
|
29
|
-
bundle space: 10.
|
|
30
|
-
rendered size: 2.
|
|
29
|
+
bundle space: 10.43 %
|
|
30
|
+
rendered size: 2.056 KB
|
|
31
31
|
original size: 2.006 KB
|
|
32
32
|
code reduction: 0 %
|
|
33
33
|
dependents: 1
|
|
@@ -35,16 +35,16 @@ dependents: 1
|
|
|
35
35
|
|
|
36
36
|
███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
37
37
|
file: /src/debug/logSubscription.ts
|
|
38
|
-
bundle space: 6.
|
|
39
|
-
rendered size: 1.
|
|
38
|
+
bundle space: 6.57 %
|
|
39
|
+
rendered size: 1.294 KB
|
|
40
40
|
original size: 1.516 KB
|
|
41
|
-
code reduction: 14.
|
|
41
|
+
code reduction: 14.64 %
|
|
42
42
|
dependents: 1
|
|
43
43
|
- /src/main.ts
|
|
44
44
|
|
|
45
45
|
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
46
46
|
file: /src/helpers/operationNameRegex.ts
|
|
47
|
-
bundle space: 0.
|
|
47
|
+
bundle space: 0.83 %
|
|
48
48
|
rendered size: 163 Bytes
|
|
49
49
|
original size: 177 Bytes
|
|
50
50
|
code reduction: 7.91 %
|
|
@@ -54,7 +54,7 @@ dependents: 2
|
|
|
54
54
|
|
|
55
55
|
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
56
56
|
file: /src/constants.ts
|
|
57
|
-
bundle space: 0.
|
|
57
|
+
bundle space: 0.75 %
|
|
58
58
|
rendered size: 147 Bytes
|
|
59
59
|
original size: 183 Bytes
|
|
60
60
|
code reduction: 19.67 %
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAKzB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,kBAAkB;
|
|
1
|
+
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAKzB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAML,KAAK,WAAW,EACjB,MAA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C;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAKzB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,kBAAkB;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAKzB,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IASjC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAcvB,OAAO,CAAC,UAAU,CAoEhB;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,+BAA+B,CAAU;IACjD,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,cAAc,CAAmB;IACzC,OAAO,CAAC,OAAO,CAAqB;gBAExB,OAAO,EAAE,WA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