@graphql-box/worker-client 5.4.3 → 5.4.4
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 +18 -18
- package/dist/types/cjs/main.d.cts +1 -0
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +6 -1
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/main.d.ts +1 -0
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +6 -1
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/main.ts +8 -2
- package/src/types.ts +6 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-box/worker-client",
|
|
3
3
|
"description": "The GraphQL Box web worker client module.",
|
|
4
|
-
"version": "5.4.
|
|
4
|
+
"version": "5.4.4",
|
|
5
5
|
"author": "Dylan Aubrey",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/graphql-box",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"iterall": "^1.3.0",
|
|
42
42
|
"lodash-es": "^4.17.21",
|
|
43
43
|
"uuid": "^11.0.3",
|
|
44
|
-
"@graphql-box/
|
|
45
|
-
"@graphql-box/
|
|
44
|
+
"@graphql-box/helpers": "5.4.0",
|
|
45
|
+
"@graphql-box/core": "5.4.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"graphql": "<17",
|
package/src/main.ts
CHANGED
|
@@ -115,7 +115,7 @@ export class WorkerClient {
|
|
|
115
115
|
errors.push(new ArgsError('@graphql-box/worker-client expected options.cache.'));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
if (!('worker' in options)) {
|
|
118
|
+
if (!options.lazyWorkerInit && !('worker' in options)) {
|
|
119
119
|
errors.push(new ArgsError('@graphql-box/worker-client expected options.worker.'));
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -138,7 +138,7 @@ export class WorkerClient {
|
|
|
138
138
|
.catch((error: unknown) => {
|
|
139
139
|
throw error;
|
|
140
140
|
});
|
|
141
|
-
} else {
|
|
141
|
+
} else if (options.worker) {
|
|
142
142
|
this._worker = options.worker;
|
|
143
143
|
this._addEventListener();
|
|
144
144
|
}
|
|
@@ -164,6 +164,12 @@ export class WorkerClient {
|
|
|
164
164
|
return this._subscribe(request, options, this._getRequestContext(OperationTypeNode.SUBSCRIPTION, request));
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
public set worker(worker: Worker) {
|
|
168
|
+
this._worker = worker;
|
|
169
|
+
this._addEventListener();
|
|
170
|
+
this._releaseMessageQueue();
|
|
171
|
+
}
|
|
172
|
+
|
|
167
173
|
private _addEventListener(): void {
|
|
168
174
|
if (!this._worker) {
|
|
169
175
|
throw new Error('A worker is required for the WorkerClient to work correctly.');
|
package/src/types.ts
CHANGED
|
@@ -21,10 +21,15 @@ export interface UserOptions {
|
|
|
21
21
|
* of spec in 16.1.0-experimental-stream-defer.6
|
|
22
22
|
*/
|
|
23
23
|
experimentalDeferStreamSupport?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Must be passed in as true if you are going to
|
|
26
|
+
* initialise the worker after the constructor.
|
|
27
|
+
*/
|
|
28
|
+
lazyWorkerInit?: boolean;
|
|
24
29
|
/**
|
|
25
30
|
* The web worker instance.
|
|
26
31
|
*/
|
|
27
|
-
worker
|
|
32
|
+
worker?: Worker | (() => Worker | Promise<Worker>);
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
export type MethodNames = 'request' | 'subscribe';
|