@pixotope/query 0.2.0 → 0.5.0
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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/CHANGELOG.md +20 -0
- package/dist/index.cjs +64 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -6
- package/dist/index.d.ts +92 -6
- package/dist/index.js +59 -43
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/factories.ts +23 -12
- package/src/index.ts +3 -0
- package/src/proxyBinders.ts +24 -0
- package/src/useQuery.test.ts +4 -5
- package/src/useQuery.ts +39 -36
- package/src/useSubscription.ts +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pixotope/query@0.
|
|
2
|
+
> @pixotope/query@0.5.0 build /home/circleci/project/packages/query
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m21.28 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m42.77 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 27ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m22.62 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m42.90 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 28ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 1516ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m13.79 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.79 KB[39m
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @pixotope/query@0.
|
|
2
|
+
> @pixotope/query@0.5.0 test /home/circleci/project/packages/query
|
|
3
3
|
> vitest
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv3.2.4 [39m[90m/home/circleci/project/packages/query[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m src/useSubscriptionCore.test.ts [2m([22m[2m21 tests[22m[2m)[22m[32m
|
|
9
|
-
[32m✓[39m src/useQuery.test.ts [2m([22m[2m17 tests[22m[2m)[22m[33m
|
|
8
|
+
[32m✓[39m src/useSubscriptionCore.test.ts [2m([22m[2m21 tests[22m[2m)[22m[32m 96[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/useQuery.test.ts [2m([22m[2m17 tests[22m[2m)[22m[33m 410[2mms[22m[39m
|
|
10
10
|
|
|
11
11
|
[2m Test Files [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
12
12
|
[2m Tests [22m [1m[32m38 passed[39m[22m[90m (38)[39m
|
|
13
|
-
[2m Start at [22m
|
|
14
|
-
[2m Duration [22m 3.
|
|
13
|
+
[2m Start at [22m 17:03:20
|
|
14
|
+
[2m Duration [22m 3.52s[2m (transform 319ms, setup 294ms, collect 630ms, tests 506ms, environment 2.43s, prepare 1.66s)[22m
|
|
15
15
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @pixotope/query
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f814fd0: - improved and simplified `useQuery`
|
|
8
|
+
|
|
9
|
+
## 0.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 2546f76: - general type and compatibility improvements
|
|
14
|
+
|
|
15
|
+
## 0.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- f89bd57: `@pixotope/query`
|
|
20
|
+
|
|
21
|
+
- feat: add useMutation and useSubscriptionCore exports to query package
|
|
22
|
+
|
|
3
23
|
## 0.2.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -148,12 +148,16 @@ var require_comparison = __commonJS({
|
|
|
148
148
|
// src/index.ts
|
|
149
149
|
var index_exports = {};
|
|
150
150
|
__export(index_exports, {
|
|
151
|
+
ComparisonFailError: () => ComparisonFailError,
|
|
151
152
|
bindClientSocketProxy: () => bindClientSocketProxy,
|
|
153
|
+
bindPromiseFunction: () => bindPromiseFunction,
|
|
152
154
|
buildMutationHook: () => buildMutationHook,
|
|
153
155
|
buildQueryHook: () => buildQueryHook,
|
|
154
156
|
buildServiceSubscriptionHook: () => buildServiceSubscriptionHook,
|
|
157
|
+
useMutation: () => useMutation,
|
|
155
158
|
useQuery: () => useQuery,
|
|
156
|
-
useSubscription: () => useSubscription
|
|
159
|
+
useSubscription: () => useSubscription,
|
|
160
|
+
useSubscriptionCore: () => useSubscriptionCore
|
|
157
161
|
});
|
|
158
162
|
module.exports = __toCommonJS(index_exports);
|
|
159
163
|
|
|
@@ -282,6 +286,7 @@ var import_react2 = require("react");
|
|
|
282
286
|
function normalizeQueryKey(queryKey) {
|
|
283
287
|
return JSON.stringify(queryKey);
|
|
284
288
|
}
|
|
289
|
+
var getRandomUUID = () => Math.random().toString(36).substring(2, 15);
|
|
285
290
|
var useQuery = (_a) => {
|
|
286
291
|
var _b = _a, {
|
|
287
292
|
queryFn
|
|
@@ -303,7 +308,6 @@ var useQuery = (_a) => {
|
|
|
303
308
|
key: queryKeyPassed
|
|
304
309
|
} = options;
|
|
305
310
|
const queryKey = normalizeQueryKey(queryKeyPassed != null ? queryKeyPassed : []);
|
|
306
|
-
const promiseResolutionInProgress = (0, import_react2.useRef)(false);
|
|
307
311
|
const lastFetchedAt = (0, import_react2.useRef)(null);
|
|
308
312
|
const lastQueryKey = (0, import_react2.useRef)(void 0);
|
|
309
313
|
const queryFnRef = (0, import_react2.useRef)(queryFn);
|
|
@@ -332,6 +336,7 @@ var useQuery = (_a) => {
|
|
|
332
336
|
stateless,
|
|
333
337
|
timeout
|
|
334
338
|
};
|
|
339
|
+
const requestIdRef = (0, import_react2.useRef)(getRandomUUID());
|
|
335
340
|
const [status, setStatus] = (0, import_react2.useState)(() => {
|
|
336
341
|
return "idle";
|
|
337
342
|
});
|
|
@@ -364,7 +369,9 @@ var useQuery = (_a) => {
|
|
|
364
369
|
const refetch = (0, import_react2.useCallback)(
|
|
365
370
|
(params = void 0) => __async(null, null, function* () {
|
|
366
371
|
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
367
|
-
|
|
372
|
+
const requestId = getRandomUUID();
|
|
373
|
+
requestIdRef.current = requestId;
|
|
374
|
+
if (!internalOptionsRef.current.enabled) {
|
|
368
375
|
return;
|
|
369
376
|
}
|
|
370
377
|
setStatus("loading");
|
|
@@ -381,9 +388,10 @@ var useQuery = (_a) => {
|
|
|
381
388
|
)
|
|
382
389
|
] : []
|
|
383
390
|
];
|
|
384
|
-
promiseResolutionInProgress.current = true;
|
|
385
391
|
const res = yield Promise.race(promises);
|
|
386
|
-
|
|
392
|
+
if (requestIdRef.current !== requestId) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
387
395
|
if (res === "timeout") {
|
|
388
396
|
throw new Error("timeout");
|
|
389
397
|
}
|
|
@@ -411,36 +419,17 @@ var useQuery = (_a) => {
|
|
|
411
419
|
refetch();
|
|
412
420
|
}, [refetch]);
|
|
413
421
|
(0, import_react2.useEffect)(() => {
|
|
414
|
-
|
|
415
|
-
refetch();
|
|
416
|
-
}
|
|
417
|
-
}, [enabled, refetch, queryKey]);
|
|
418
|
-
(0, import_react2.useEffect)(() => {
|
|
419
|
-
if (lastQueryKey.current === void 0) {
|
|
420
|
-
lastQueryKey.current = queryKey;
|
|
421
|
-
refetch();
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
if (queryKey !== lastQueryKey.current) {
|
|
425
|
-
lastQueryKey.current = queryKey;
|
|
426
|
-
refetch();
|
|
427
|
-
}
|
|
428
|
-
}, [queryKey, refetch, enabled]);
|
|
429
|
-
(0, import_react2.useEffect)(() => {
|
|
422
|
+
const cleanups = [];
|
|
430
423
|
if (refetchOnWindowFocus) {
|
|
431
424
|
const queryHandleFocus = () => {
|
|
432
|
-
|
|
433
|
-
refetch();
|
|
434
|
-
}
|
|
425
|
+
refetch();
|
|
435
426
|
};
|
|
436
427
|
window.addEventListener("focus", queryHandleFocus);
|
|
437
|
-
|
|
428
|
+
cleanups.push(() => {
|
|
438
429
|
window.removeEventListener("focus", queryHandleFocus);
|
|
439
|
-
};
|
|
430
|
+
});
|
|
440
431
|
}
|
|
441
|
-
|
|
442
|
-
(0, import_react2.useEffect)(() => {
|
|
443
|
-
if (refetchInterval !== 0) {
|
|
432
|
+
if (refetchInterval > 0) {
|
|
444
433
|
const interval = setInterval(
|
|
445
434
|
() => {
|
|
446
435
|
if (shouldRefetch()) {
|
|
@@ -449,11 +438,25 @@ var useQuery = (_a) => {
|
|
|
449
438
|
},
|
|
450
439
|
Math.max(refetchInterval, 1e3)
|
|
451
440
|
);
|
|
452
|
-
|
|
441
|
+
cleanups.push(() => {
|
|
453
442
|
clearInterval(interval);
|
|
454
|
-
};
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
if (lastQueryKey.current === void 0 || queryKey !== lastQueryKey.current) {
|
|
446
|
+
lastQueryKey.current = queryKey;
|
|
447
|
+
refetch();
|
|
455
448
|
}
|
|
456
|
-
|
|
449
|
+
return () => {
|
|
450
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
451
|
+
};
|
|
452
|
+
}, [
|
|
453
|
+
queryKey,
|
|
454
|
+
enabled,
|
|
455
|
+
refetchOnWindowFocus,
|
|
456
|
+
refetchInterval,
|
|
457
|
+
shouldRefetch,
|
|
458
|
+
refetch
|
|
459
|
+
]);
|
|
457
460
|
return {
|
|
458
461
|
data: select && data !== void 0 ? select(data) : data,
|
|
459
462
|
error,
|
|
@@ -464,7 +467,7 @@ var useQuery = (_a) => {
|
|
|
464
467
|
};
|
|
465
468
|
|
|
466
469
|
// src/factories.ts
|
|
467
|
-
var useCallMutationBase = (
|
|
470
|
+
var useCallMutationBase = (promiseFunc, functionName, service, options) => {
|
|
468
471
|
const _a = (0, import_react3.useMemo)(() => options != null ? options : {}, [options]), {
|
|
469
472
|
avoidTimeout = true,
|
|
470
473
|
customTimeout = void 0
|
|
@@ -475,7 +478,7 @@ var useCallMutationBase = (clientProxy, functionName, service, options) => {
|
|
|
475
478
|
const mutationFn = (0, import_react3.useCallback)(
|
|
476
479
|
(parameters) => __async(null, null, function* () {
|
|
477
480
|
try {
|
|
478
|
-
|
|
481
|
+
return yield promiseFunc({
|
|
479
482
|
service,
|
|
480
483
|
functionName: functionName.toString(),
|
|
481
484
|
parameters,
|
|
@@ -484,7 +487,6 @@ var useCallMutationBase = (clientProxy, functionName, service, options) => {
|
|
|
484
487
|
customTimeout
|
|
485
488
|
}
|
|
486
489
|
});
|
|
487
|
-
return res.message.Result;
|
|
488
490
|
} catch (e) {
|
|
489
491
|
throw e.message;
|
|
490
492
|
}
|
|
@@ -495,13 +497,13 @@ var useCallMutationBase = (clientProxy, functionName, service, options) => {
|
|
|
495
497
|
mutationFn
|
|
496
498
|
}, rest));
|
|
497
499
|
};
|
|
498
|
-
function buildMutationHook(
|
|
500
|
+
function buildMutationHook(promiseFunc, genTargetService) {
|
|
499
501
|
return function useCallMutationBuilder(func, options) {
|
|
500
502
|
const targetService = genTargetService(options == null ? void 0 : options.machine);
|
|
501
|
-
return useCallMutationBase(
|
|
503
|
+
return useCallMutationBase(promiseFunc, func, targetService, options);
|
|
502
504
|
};
|
|
503
505
|
}
|
|
504
|
-
var useCallQueryBase = (
|
|
506
|
+
var useCallQueryBase = (promiseFunction, functionName, params, service, options) => {
|
|
505
507
|
const _a = (0, import_react3.useMemo)(() => options != null ? options : {}, [options]), {
|
|
506
508
|
avoidTimeout = true,
|
|
507
509
|
customTimeout = void 0
|
|
@@ -512,7 +514,7 @@ var useCallQueryBase = (clientProxy, functionName, params, service, options) =>
|
|
|
512
514
|
const queryFn = (0, import_react3.useCallback)(
|
|
513
515
|
(refetchParams, overrideTargetMachine) => __async(null, null, function* () {
|
|
514
516
|
try {
|
|
515
|
-
|
|
517
|
+
return yield promiseFunction({
|
|
516
518
|
service: overrideTargetMachine != null ? overrideTargetMachine : service,
|
|
517
519
|
functionName: functionName.toString(),
|
|
518
520
|
parameters: refetchParams != null ? refetchParams : params,
|
|
@@ -521,7 +523,6 @@ var useCallQueryBase = (clientProxy, functionName, params, service, options) =>
|
|
|
521
523
|
customTimeout
|
|
522
524
|
}
|
|
523
525
|
});
|
|
524
|
-
return res.message.Result;
|
|
525
526
|
} catch (e) {
|
|
526
527
|
if (e instanceof Error) {
|
|
527
528
|
throw e;
|
|
@@ -535,10 +536,10 @@ var useCallQueryBase = (clientProxy, functionName, params, service, options) =>
|
|
|
535
536
|
queryFn
|
|
536
537
|
}, rest));
|
|
537
538
|
};
|
|
538
|
-
function buildQueryHook(
|
|
539
|
+
function buildQueryHook(promiseFunction, getTargetService) {
|
|
539
540
|
return function useCallQueryBuilder(func, params, options) {
|
|
540
541
|
const targetService = getTargetService(options == null ? void 0 : options.machine);
|
|
541
|
-
return useCallQueryBase(
|
|
542
|
+
return useCallQueryBase(promiseFunction, func, params, targetService, options);
|
|
542
543
|
};
|
|
543
544
|
}
|
|
544
545
|
|
|
@@ -678,16 +679,35 @@ function buildServiceSubscriptionHook(subscriptionHandler, targetMachine) {
|
|
|
678
679
|
);
|
|
679
680
|
};
|
|
680
681
|
}
|
|
682
|
+
|
|
683
|
+
// src/proxyBinders.ts
|
|
681
684
|
function bindClientSocketProxy(socketClientProxy) {
|
|
682
|
-
return (...args) =>
|
|
685
|
+
return (...args) => {
|
|
686
|
+
const _a = args[0], { callback: cbHook } = _a, rest = __objRest(_a, ["callback"]);
|
|
687
|
+
return socketClientProxy.mirror(__spreadProps(__spreadValues({}, rest), {
|
|
688
|
+
callback: (message) => {
|
|
689
|
+
cbHook(message.message);
|
|
690
|
+
}
|
|
691
|
+
}))[0];
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function bindPromiseFunction(clientSocketProxy) {
|
|
695
|
+
return (...args) => __async(null, null, function* () {
|
|
696
|
+
const res = yield clientSocketProxy.callAsync(...args);
|
|
697
|
+
return res.message.Result;
|
|
698
|
+
});
|
|
683
699
|
}
|
|
684
700
|
// Annotate the CommonJS export names for ESM import in node:
|
|
685
701
|
0 && (module.exports = {
|
|
702
|
+
ComparisonFailError,
|
|
686
703
|
bindClientSocketProxy,
|
|
704
|
+
bindPromiseFunction,
|
|
687
705
|
buildMutationHook,
|
|
688
706
|
buildQueryHook,
|
|
689
707
|
buildServiceSubscriptionHook,
|
|
708
|
+
useMutation,
|
|
690
709
|
useQuery,
|
|
691
|
-
useSubscription
|
|
710
|
+
useSubscription,
|
|
711
|
+
useSubscriptionCore
|
|
692
712
|
});
|
|
693
713
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/dist/comparison/index.js","../src/index.ts","../src/factories.ts","../src/useMutation.ts","../src/useQuery.ts","../src/useSubscriptionCore.ts","../src/useSubscription.ts"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/comparison/index.ts\nvar comparison_exports = {};\n__export(comparison_exports, {\n shallowEqual: () => shallowEqual\n});\nmodule.exports = __toCommonJS(comparison_exports);\n\n// src/comparison/shallowEqual.ts\nfunction shallowEqual(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {\n return false;\n }\n }\n return true;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n shallowEqual\n});\n","export * from \"./factories\";\nexport * from \"./useSubscription\";\nexport * from \"./useQuery\";\n","import { useCallback, useMemo } from \"react\";\nimport { MutationOptions, useMutation } from \"./useMutation\";\nimport { QueryOptions, useQuery } from \"./useQuery\";\nimport type { ZMQProxyWSClient } from \"@pixotope/zmq-client\";\n\nexport type MutationInfo<TData, TError, TParams> = {\n data: TData;\n error: TError;\n params: TParams;\n};\n\ntype FnToParamsBase = Record<string, MutationInfo<unknown, unknown, unknown>>;\n\nconst useCallMutationBase = <\n TFnToParams extends FnToParamsBase,\n TData = unknown,\n TError = unknown,\n TParams = unknown,\n>(\n clientProxy: ZMQProxyWSClient,\n functionName: keyof TFnToParams,\n service: string,\n options?: Omit<MutationOptions<TData, TError, TParams>, \"mutationFn\"> & {\n avoidTimeout?: boolean;\n customTimeout?: number;\n }\n) => {\n const {\n avoidTimeout = true,\n customTimeout = undefined,\n ...rest\n } = useMemo(() => options ?? {}, [options]);\n const mutationFn = useCallback(\n async (parameters: TParams) => {\n try {\n const res = await clientProxy.callAsync<TData, TParams>({\n service,\n functionName: functionName.toString(),\n parameters,\n options: {\n avoidTimeout,\n customTimeout,\n },\n });\n\n return res.message.Result;\n } catch (e: any) {\n throw e.message;\n }\n },\n [avoidTimeout, customTimeout, functionName, service]\n );\n\n return useMutation<TData, TError, TParams>({\n mutationFn,\n ...rest,\n });\n};\n\nexport function buildMutationHook<TFnToParams extends FnToParamsBase>(\n socketClientProxy: ZMQProxyWSClient,\n genTargetService: (machine: string | undefined) => string\n) {\n return function useCallMutationBuilder<TFn extends keyof TFnToParams>(\n func: TFn,\n options?: Parameters<\n typeof useCallMutationBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"]\n >\n >[3] & { machine?: string }\n ) {\n const targetService = genTargetService(options?.machine);\n\n return useCallMutationBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"]\n >(socketClientProxy, func, targetService, options);\n };\n}\n\nconst useCallQueryBase = <\n TFnToParams extends FnToParamsBase,\n TData = unknown,\n TError = unknown,\n TParams = unknown,\n TSelect = TData,\n>(\n clientProxy: ZMQProxyWSClient,\n functionName: keyof TFnToParams,\n params: TParams,\n service: string,\n options?: Omit<QueryOptions<TData, TError, TParams, TSelect>, \"queryFn\"> & {\n avoidTimeout?: boolean;\n customTimeout?: number;\n }\n) => {\n const {\n avoidTimeout = true,\n customTimeout = undefined,\n ...rest\n } = useMemo(() => options ?? {}, [options]);\n const queryFn = useCallback(\n async (refetchParams: TParams | void, overrideTargetMachine?: string) => {\n try {\n const res = await clientProxy.callAsync<TData, TParams>({\n service: overrideTargetMachine ?? service,\n functionName: functionName.toString(),\n parameters: refetchParams ?? params,\n options: {\n avoidTimeout,\n customTimeout,\n },\n });\n return res.message.Result;\n } catch (e) {\n if (e instanceof Error) {\n throw e;\n }\n throw new Error(e as string);\n }\n },\n [avoidTimeout, customTimeout, functionName, service, params]\n );\n\n return useQuery<TData, TError, TParams, TSelect>({\n queryFn,\n ...rest,\n });\n};\n\nexport function buildQueryHook<TFnToParams extends FnToParamsBase>(\n clientSocketProxy: ZMQProxyWSClient,\n getTargetService: (machine: string | undefined) => string\n) {\n return function useCallQueryBuilder<\n TFn extends keyof TFnToParams,\n TSelect = TFnToParams[TFn][\"data\"],\n >(\n func: TFn,\n params: TFnToParams[TFn][\"params\"],\n options?: Parameters<\n typeof useCallQueryBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"],\n TSelect\n >\n >[4] & { machine?: string }\n ) {\n const targetService = getTargetService(options?.machine);\n\n return useCallQueryBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"],\n TSelect\n >(clientSocketProxy, func, params, targetService, options);\n };\n}\n","import { useCallback, useRef, useState } from \"react\";\n\nexport type MutationFunction<TData = unknown, TParams = unknown> = (\n params: TParams,\n overrideTargetMachine?: string\n) => Promise<TData>;\n\nexport interface MutationOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n> {\n mutationFn: MutationFunction<TData, TParams>;\n params?: TParams;\n onSuccess?: (data: TData, variables: TParams) => Promise<unknown> | unknown;\n onError?: (error: TError, variables: TParams) => Promise<unknown> | unknown;\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TParams\n ) => Promise<unknown> | unknown;\n compareOrThrow?: (result: TData | TError) => boolean;\n timeout?: number;\n prepareParams?: (variables: TParams, defaults?: TParams) => TParams;\n}\n\nexport interface MutateOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n> {\n onSuccess?: (data: TData, variables: TParams) => void;\n onError?: (error: TError, variables: TParams) => void;\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TParams\n ) => void;\n}\n\ntype MutationStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\ntype RaceErrorReason = \"timeout\";\ntype RacePromises<T> = Promise<T | RaceErrorReason>;\n\nexport class ComparisonFailError<TPayload = unknown> extends Error {\n public readonly payload: TPayload;\n\n constructor(message: string, payload: TPayload) {\n super(message);\n this.name = this.constructor.name;\n this.payload = payload;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ComparisonFailError);\n }\n }\n}\n\n/**\n * `useMutation` is a hook that allows you to perform a mutation/push updates to the services while\n * providing extensive API to tap into the status and results of the mutation.\n * @param mutationFn The mutation function to be called when the `mutate` function is called.\n * `useMutation` does not care about what the function does, all it needs it a function that returns\n * a promise.\n * @param options Options to configure the mutation.\n * @returns An object with the following properties:\n * - `mutateAsync`: A function that takes in the variables and returns a promise that resolves to the\n * result of the mutation. This function can be awaited to get the result of the mutation. Callbacks can\n * be passed to this function to be called when the mutation is successful or when it fails. It's good idea\n * to wrap this function in a try/catch block.\n * - `mutate`: A function that takes in the variables and returns nothing. This function does not\n * return a promise. Callbacks can be passed to this function to be called when the mutation is\n * successful or when it fails.\n * - `status`: The status of the mutation. Can be one of `idle`, `loading`, `success` or `error`.\n * - `result`: The result of the mutation. This is undefined until the mutation is successful.\n * - `reset`: A function that resets the mutation to the initial state.\n * - `error`: The error object if the mutation has failed.\n * @example\n * ```typescript\n * const mutationRes = useMutation({\n * mutationFn: (variables) => {\n * return ZMQHelper.callSomethingAsync(variables)\n * },\n * onSuccess: (data) => {\n * // do something with the result\n * },\n * onError: (error) => {\n * // do something with the error\n * },\n * onSettled: (data, error) => {\n * // do something when the mutation is done\n * }});\n *\n * // call the mutation\n * const res = await mutationRes.mutateAsync({ foo: \"bar\" });\n * // OR\n * mutationRes.mutate({ foo: \"bar\" }, {\n * onSuccess: (data) => {\n * // do something with the result\n * // for example show a toast message\n * // stop local loading state\n * });\n * ```\n */\nexport const useMutation = <TData = unknown, TError = unknown, TParams = void>(\n options: MutationOptions<TData, TError, TParams>\n) => {\n const {\n mutationFn,\n compareOrThrow,\n onError,\n onSettled,\n onSuccess,\n prepareParams,\n params,\n timeout,\n } = options;\n const [status, setStatus] = useState<MutationStatus>(\"idle\");\n const [error, setError] = useState<TError | null>(null);\n const [result, setResult] = useState<TData | undefined>(undefined);\n const mutationFnRef = useRef(mutationFn);\n const internalOptionsRef = useRef({\n params,\n timeout,\n });\n const internalCallbackRefistry = <const>{\n onSuccess,\n onError,\n onSettled,\n compareOrThrow,\n prepareParams,\n };\n const internalCallbackRef = useRef(internalCallbackRefistry);\n internalCallbackRef.current = internalCallbackRefistry;\n\n const mutateAsync = useCallback(\n async (params: TParams, overrideTargetMachine?: string) => {\n setStatus(\"loading\");\n setError(null);\n\n try {\n const promises: RacePromises<TData>[] = [\n mutationFnRef.current(\n internalCallbackRef.current.prepareParams\n ? internalCallbackRef.current.prepareParams(\n params,\n internalOptionsRef.current.params\n )\n : params,\n overrideTargetMachine\n ),\n ...(internalOptionsRef.current.timeout\n ? [\n new Promise<RaceErrorReason>((resolve) =>\n setTimeout(\n () => resolve(\"timeout\"),\n internalOptionsRef.current.timeout\n )\n ),\n ]\n : []),\n ];\n\n const res = await Promise.race(promises);\n\n if (res === \"timeout\") {\n throw new Error(\"timeout\");\n }\n\n if (internalCallbackRef.current.compareOrThrow?.(res)) {\n throw new ComparisonFailError(JSON.stringify(res), res);\n }\n\n setResult(res);\n setStatus(\"success\");\n\n internalCallbackRef.current.onSuccess?.(res, params);\n internalCallbackRef.current.onSettled?.(res, null, params);\n\n return res;\n } catch (error: any) {\n setError(error);\n setStatus(\"error\");\n\n if (internalCallbackRef.current.onError) {\n internalCallbackRef.current.onError(error, params);\n }\n\n if (internalCallbackRef.current.onSettled) {\n internalCallbackRef.current.onSettled(undefined, error, params);\n }\n\n throw error;\n }\n },\n []\n );\n\n const mutate = useCallback(\n (\n variables: TParams,\n options?: MutateOptions<TData, TError, TParams> & {\n overrideTargetMachine?: string;\n }\n ) => {\n mutateAsync(variables, options?.overrideTargetMachine).then(\n (data) => {\n options?.onSuccess?.(data, variables);\n options?.onSettled?.(data, null, variables);\n },\n (error) => {\n options?.onError?.(error, variables);\n options?.onSettled?.(undefined, error, variables);\n }\n );\n },\n [mutateAsync]\n );\n\n return {\n mutateAsync,\n status,\n result,\n mutate,\n reset: () => setStatus(\"idle\"),\n error,\n };\n};\n","import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface QueryOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelectData = TData,\n Stateless extends true | undefined = undefined,\n> {\n queryFn: (params: TParams | undefined | void) => Promise<TData>;\n onSuccess?: (data: TData) => Promise<void> | void;\n onError?: (error: TError) => Promise<void> | void;\n onSettled?: (\n data: TData | undefined,\n error: TError | undefined\n ) => Promise<void> | void;\n timeout?: number;\n enabled?: boolean;\n initialData?: TData | Functionize<TData>;\n select?: (data: TData) => TSelectData;\n refetchOnWindowFocus?: boolean;\n refetchInterval?: number;\n compareOrThrow?: (data: TData) => boolean;\n stateless?: Stateless;\n key?: TQueryKey;\n}\n\ntype Functionize<T> = () => T;\ntype QueryStatus = \"idle\" | \"loading\" | \"success\" | \"error\" | \"timeout\";\ntype RaceErrorReason = \"timeout\";\ntype RacePromises<T> = Promise<T | RaceErrorReason>;\ntype WithData<TData> = { data: TData | undefined };\ntype TQueryKey = readonly any[];\n\nexport type UseQueryResult<\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelectData = TData,\n Stateless extends true | undefined = undefined,\n> = {\n error: TError | null;\n status: QueryStatus;\n refetch: (params: TParams | void | undefined) => Promise<void>;\n reset: () => void;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n} & (Stateless extends true ? {} : WithData<TSelectData>);\n\nfunction normalizeQueryKey(queryKey: TQueryKey): string {\n return JSON.stringify(queryKey);\n}\n\ntype TInternalCallbackRef<TData, TError, TSelectData> = {\n onError?: (error: TError) => Promise<void> | void;\n onSuccess?: (data: TData) => Promise<void> | void;\n onSettled?: (\n data: TData | undefined,\n error: TError | undefined\n ) => Promise<void> | void;\n compareOrThrow?: (data: TData) => boolean;\n select?: (data: TData) => TSelectData;\n};\n\ntype TInternalOptionsRef<TData> = {\n timeout?: number;\n enabled: boolean;\n refetchOnWindowFocus: boolean;\n refetchInterval: number;\n compareOrThrow?: (data: TData) => boolean;\n stateless?: boolean;\n};\n\nexport const useQuery = <\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelected = TData,\n Stateless extends true | undefined = undefined,\n>({\n queryFn,\n ...options\n}: QueryOptions<TData, TError, TParams, TSelected, Stateless>): UseQueryResult<\n TSelected,\n TError,\n TParams,\n TSelected,\n Stateless\n> => {\n const {\n enabled = true,\n refetchOnWindowFocus = false,\n refetchInterval = 0,\n initialData,\n select,\n onError,\n onSuccess,\n onSettled,\n timeout,\n compareOrThrow,\n stateless,\n key: queryKeyPassed,\n } = options;\n const queryKey = normalizeQueryKey(queryKeyPassed ?? []);\n const promiseResolutionInProgress = useRef(false);\n const lastFetchedAt = useRef<number | null>(null);\n const lastQueryKey = useRef<string | undefined>(undefined);\n const queryFnRef = useRef(queryFn);\n queryFnRef.current = queryFn;\n const internalCallbackRef = useRef<\n TInternalCallbackRef<TData, TError, TSelected>\n >({});\n internalCallbackRef.current = {\n onError,\n onSuccess,\n onSettled,\n compareOrThrow,\n select,\n };\n const internalOptionsRef = useRef<TInternalOptionsRef<TData>>({\n enabled,\n refetchOnWindowFocus,\n refetchInterval,\n compareOrThrow,\n stateless,\n timeout,\n });\n internalOptionsRef.current = {\n enabled,\n refetchOnWindowFocus,\n refetchInterval,\n compareOrThrow,\n stateless,\n timeout,\n };\n\n const [status, setStatus] = useState<QueryStatus>(() => {\n return \"idle\";\n });\n const [error, setError] = useState<TError | null>(null);\n const [data, setData] = useState<TData | undefined>(() => {\n if (initialData !== undefined) {\n if (typeof initialData === \"function\") {\n return (initialData as Functionize<TData>)();\n }\n\n return initialData as TData;\n }\n\n return undefined;\n });\n\n const handleSetData = useCallback((data: TData) => {\n if (internalOptionsRef.current.stateless) {\n return;\n }\n\n setData(data);\n }, []);\n\n const shouldRefetch = useCallback(() => {\n if (!internalOptionsRef.current.enabled) {\n return false;\n }\n\n if (lastFetchedAt.current === null) {\n return true;\n }\n\n return (\n new Date().getTime() - lastFetchedAt.current >\n internalOptionsRef.current?.refetchInterval\n );\n }, []);\n\n const refetch = useCallback(\n async (params: TParams | void | undefined = undefined) => {\n if (\n promiseResolutionInProgress.current ||\n !internalOptionsRef.current.enabled\n ) {\n return;\n }\n\n setStatus(\"loading\");\n setError(null);\n\n try {\n const promises: RacePromises<TData>[] = [\n queryFnRef.current(params),\n ...(internalOptionsRef.current.timeout\n ? [\n new Promise<RaceErrorReason>((resolve) =>\n setTimeout(\n () => resolve(\"timeout\"),\n internalOptionsRef.current.timeout\n )\n ),\n ]\n : []),\n ];\n\n promiseResolutionInProgress.current = true;\n const res = await Promise.race(promises);\n promiseResolutionInProgress.current = false;\n\n if (res === \"timeout\") {\n throw new Error(\"timeout\");\n }\n\n handleSetData(res);\n\n if (\n internalCallbackRef.current.compareOrThrow &&\n internalCallbackRef.current.compareOrThrow(res) === true\n ) {\n throw new Error(\"compareOrThrow\");\n }\n\n setStatus(\"success\");\n lastFetchedAt.current = new Date().getTime();\n internalCallbackRef.current.onSuccess?.(res);\n internalCallbackRef.current.onSettled?.(res, undefined);\n } catch (error: any) {\n setError(error);\n setStatus(\"error\");\n internalCallbackRef.current.onError?.(error);\n internalCallbackRef.current.onSettled?.(undefined, error);\n }\n },\n [handleSetData]\n );\n\n const reset = useCallback(() => {\n setData(undefined);\n setStatus(\"idle\");\n setError(null);\n refetch();\n }, [refetch]);\n\n useEffect(() => {\n if (enabled) {\n refetch();\n }\n }, [enabled, refetch, queryKey]);\n\n useEffect(() => {\n if (lastQueryKey.current === undefined) {\n lastQueryKey.current = queryKey;\n refetch();\n return;\n }\n\n if (queryKey !== lastQueryKey.current) {\n lastQueryKey.current = queryKey;\n refetch();\n }\n }, [queryKey, refetch, enabled]);\n\n useEffect(() => {\n if (refetchOnWindowFocus) {\n const queryHandleFocus = () => {\n if (shouldRefetch()) {\n refetch();\n }\n };\n\n window.addEventListener(\"focus\", queryHandleFocus);\n\n return () => {\n window.removeEventListener(\"focus\", queryHandleFocus);\n };\n }\n }, [refetchOnWindowFocus, refetch, shouldRefetch]);\n\n useEffect(() => {\n if (refetchInterval !== 0) {\n const interval = setInterval(\n () => {\n if (shouldRefetch()) {\n refetch();\n }\n },\n Math.max(refetchInterval, 1000)\n );\n\n return () => {\n clearInterval(interval);\n };\n }\n }, [refetch, refetchInterval, shouldRefetch]);\n\n return {\n data:\n select && data !== undefined\n ? select(data as TData)\n : (data as unknown as TSelected),\n error,\n status,\n refetch,\n reset,\n };\n};\n","/**\n * @fileoverview useSubscriptionCore\n * @name useSubscriptionCore.ts\n * @description useSubscriptionCore | This hook handle core subscription logic\n * and provides a way to subscribe and unsubscribe to a topic via any callback\n */\n\nimport { shallowEqual } from \"@pixotope/utils/comparison\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\ntype SubscriptionState = \"idle\" | \"subscribed\" | \"subscribing\";\nexport type MessageHandler<TMessage> = (message: TMessage) => void;\nexport type Connection = {\n acknowledge: () => void;\n};\nexport type SubscriptionCoreOptions<\n TData,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n> = {\n /**\n * @description Function that will be called when the message is received.\n */\n onMessage?: (message: TMessage) => void;\n /**\n * @description Function that will be called when the subscription is created.\n */\n onSubscribed?: (message: TMessage) => void;\n /**\n * @description Function that will be called when the subscription is created.\n */\n onError?: (error: TMessage) => void;\n /**\n * @description Whether the subscription is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * @description Function that will be called to compare the message with the\n * previous message. If the function returns true, the message will be ignored.\n */\n compareOrThrow?: (data: TMessage) => boolean;\n /**\n * @description Function that will be called to select the data from the message.\n */\n select?: (data: TMessage) => TData;\n /**\n * @description Initial state of the subscription.\n * @default undefined\n */\n initialState?: TData;\n /**\n * @description Function that will be called when the subscription is created.\n */\n subscriberFn: (\n handler: MessageHandler<TMessage>,\n connection: Connection\n ) => () => void /** unsubscribe Fn */;\n /**\n * @description Whether the subscription is stateless. Data will not be\n * stored by the hook internally.\n * @default false\n */\n stateless?: Stateless;\n /**\n * @description Custom equality function for comparing data.\n * @default shallowEqual\n */\n isEqual?: <T = TData>(a: T, b: T) => boolean;\n};\n\ntype WithStatus = {\n status: SubscriptionState;\n};\n\ntype WithData<TData> = {\n data: TData;\n};\n\nexport type SubscriptionCoreReturnType<\n TData,\n Stateless extends true | undefined,\n> = {\n reSubscribe: () => void;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n} & (Stateless extends true ? {} : WithStatus & WithData<TData>);\n\n/**\n * @description `useSubscriptionCore` | This hook handle core subscription logic\n * and provides a way to subscribe and unsubscribe to a topic via any callback.\n * The hook expose a handler function. All the consumer code need to do is to\n * call this handler function with the message received from the topic or pass\n * it directly to the callback function that is passed to the subscriberFn.\n * - `status` - current status of the subscription\n * - `data` - the data after the select function is applied to the message\n * - `reSubscribe` - function that can be called to re-subscribe to the topic\n *\n * An example how this hook works can be found in {@link ./useSubscription.ts}\n */\nexport function useSubscriptionCore<\n TData = unknown,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n>(\n options: SubscriptionCoreOptions<TData, TMessage, Stateless>\n): SubscriptionCoreReturnType<TData, Stateless> {\n const {\n enabled = true,\n initialState = undefined,\n onSubscribed,\n stateless,\n compareOrThrow,\n subscriberFn,\n onMessage,\n onError,\n select,\n isEqual = shallowEqual,\n } = options;\n const [status, setStatus] = useState<SubscriptionState>(\"idle\");\n const [data, setData] = useState<TData | undefined>(initialState);\n const unsubcribeRef = useRef<() => void | undefined>(undefined);\n const initialStateRef = useRef(initialState);\n const subscriberFnRef = useRef(subscriberFn);\n const callbackRefRegistry = <const>{\n onMessage,\n onError,\n select,\n compareOrThrow,\n onSubscribed,\n isEqual,\n };\n const internalCallbacksRef = useRef(callbackRefRegistry);\n internalCallbacksRef.current = callbackRefRegistry;\n\n const updateStatus = useCallback(\n (newStatus: SubscriptionState, message?: TMessage) => {\n if (stateless) {\n return;\n }\n\n setStatus((prev) => {\n if (prev === newStatus) {\n return prev;\n }\n\n if (newStatus === \"subscribed\" && message) {\n internalCallbacksRef.current.onSubscribed?.(message);\n }\n\n return newStatus;\n });\n },\n [stateless]\n );\n\n const connection: Connection = useMemo(\n () => ({\n acknowledge: () => {\n updateStatus(\"subscribed\");\n },\n }),\n [updateStatus]\n );\n\n const handler = useCallback(\n async (message: TMessage) => {\n if (internalCallbacksRef.current.compareOrThrow?.(message)) {\n internalCallbacksRef.current.onError?.(message);\n\n return;\n }\n\n const selectedMessage = <TData>(\n (internalCallbacksRef.current.select?.(message) ?? message)\n );\n\n if (!stateless) {\n setData((prev) => {\n if (isEqual(prev, selectedMessage)) {\n return prev;\n }\n\n return selectedMessage;\n });\n }\n\n updateStatus(\"subscribed\", message);\n internalCallbacksRef.current.onMessage?.(message);\n },\n [stateless, updateStatus]\n );\n\n const unsubscribe = useCallback(() => {\n updateStatus(\"idle\");\n unsubcribeRef.current?.();\n unsubcribeRef.current = undefined;\n }, [updateStatus]);\n\n const subscribe = useCallback(() => {\n unsubcribeRef.current?.();\n updateStatus(\"subscribing\");\n setData(initialStateRef.current);\n unsubcribeRef.current = subscriberFnRef.current(handler, connection);\n }, [connection, handler, updateStatus]);\n\n useEffect(() => {\n if (enabled) {\n subscribe();\n } else {\n unsubscribe();\n }\n\n return () => {\n unsubscribe();\n };\n }, [enabled, subscribe, unsubscribe]);\n\n return {\n status,\n data,\n reSubscribe: subscribe,\n } as unknown as any;\n}\n","import type { ZMQProxyWSClient } from \"@pixotope/zmq-client\";\nimport {\n SubscriptionCoreOptions,\n useSubscriptionCore,\n} from \"./useSubscriptionCore\";\n\nexport type SubscriptionOptions<\n TData,\n TMessage = unknown,\n Stateless extends true | undefined = undefined,\n> = Omit<\n SubscriptionCoreOptions<TData, TMessage, Stateless>,\n \"subscriberFn\"\n> & {\n service: string;\n topic: string;\n maxDownwardDepth?: number;\n};\n\nexport type TSubscriptionHandlerFunction<TMessage> = (opts: {\n service: string;\n name: string;\n callback: (message: TMessage) => void;\n maxDownwardDepth?: number;\n}) => () => void;\n\nexport function useSubscription<\n TData = unknown,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n>(\n subscriptionHandler: TSubscriptionHandlerFunction<TMessage>,\n options: SubscriptionOptions<TData, TMessage, Stateless>\n) {\n const { topic, service, maxDownwardDepth = 1000 } = options;\n\n return useSubscriptionCore<TData, TMessage, Stateless>({\n ...options,\n subscriberFn: (handler) => {\n const unsubscribe = subscriptionHandler({\n service,\n name: topic,\n callback: (message: TMessage) => {\n handler(message);\n },\n maxDownwardDepth,\n });\n\n return unsubscribe;\n },\n });\n}\n\nexport function buildServiceSubscriptionHook(\n subscriptionHandler: TSubscriptionHandlerFunction<unknown>,\n targetMachine: (machine: string | undefined) => string\n) {\n return function useSubscriptionBuilder<\n TData,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n >(\n options: Omit<\n SubscriptionOptions<TData, TMessage, Stateless>,\n \"service\"\n > & {\n machine?: string;\n }\n ) {\n const targetService = targetMachine(options.machine);\n return useSubscription<TData, TMessage, Stateless>(\n <TSubscriptionHandlerFunction<TMessage>>subscriptionHandler,\n {\n service: targetService,\n ...options,\n }\n );\n };\n}\n\nexport function bindClientSocketProxy(socketClientProxy: ZMQProxyWSClient) {\n return (\n ...args: Parameters<Parameters<typeof buildServiceSubscriptionHook>[0]>\n ) => socketClientProxy.mirror(...args)[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,sCAAAA,UAAAC,SAAA;AAAA;AACA,QAAIC,aAAY,OAAO;AACvB,QAAIC,oBAAmB,OAAO;AAC9B,QAAIC,qBAAoB,OAAO;AAC/B,QAAIC,gBAAe,OAAO,UAAU;AACpC,QAAIC,YAAW,CAAC,QAAQ,QAAQ;AAC9B,eAAS,QAAQ;AACf,QAAAJ,WAAU,QAAQ,MAAM,EAAE,KAAK,IAAI,IAAI,GAAG,YAAY,KAAK,CAAC;AAAA,IAChE;AACA,QAAIK,eAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,UAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AAClE,iBAAS,OAAOH,mBAAkB,IAAI;AACpC,cAAI,CAACC,cAAa,KAAK,IAAI,GAAG,KAAK,QAAQ;AACzC,YAAAH,WAAU,IAAI,KAAK,EAAE,KAAK,MAAM,KAAK,GAAG,GAAG,YAAY,EAAE,OAAOC,kBAAiB,MAAM,GAAG,MAAM,KAAK,WAAW,CAAC;AAAA,MACvH;AACA,aAAO;AAAA,IACT;AACA,QAAIK,gBAAe,CAAC,QAAQD,aAAYL,WAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AAGzF,QAAI,qBAAqB,CAAC;AAC1B,IAAAI,UAAS,oBAAoB;AAAA,MAC3B,cAAc,MAAMG;AAAA,IACtB,CAAC;AACD,IAAAR,QAAO,UAAUO,cAAa,kBAAkB;AAGhD,aAASC,cAAa,MAAM,MAAM;AAChC,UAAI,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AAM,gBAAY,2BAAY,MAAM;AAtMtC;AAuMI,wBAAc,YAAd;AACA,iBAAa,aAAa;AAC1B,YAAQ,gBAAgB,OAAO;AAC/B,kBAAc,UAAU,gBAAgB,QAAQ,SAAS,UAAU;AAAA,EACrE,GAAG,CAAC,YAAY,SAAS,YAAY,CAAC;AAEtC,+BAAU,MAAM;AACd,QAAI,SAAS;AACX,gBAAU;AAAA,IACZ,OAAO;AACL,kBAAY;AAAA,IACd;AAEA,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,SAAS,WAAW,WAAW,CAAC;AAEpC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,aAAa;AAAA,EACf;AACF;;;ACpMO,SAAS,gBAKd,qBACA,SACA;AACA,QAAM,EAAE,OAAO,SAAS,mBAAmB,IAAK,IAAI;AAEpD,SAAO,oBAAgD,iCAClD,UADkD;AAAA,IAErD,cAAc,CAAC,YAAY;AACzB,YAAM,cAAc,oBAAoB;AAAA,QACtC;AAAA,QACA,MAAM;AAAA,QACN,UAAU,CAAC,YAAsB;AAC/B,kBAAQ,OAAO;AAAA,QACjB;AAAA,QACA;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF,EAAC;AACH;AAEO,SAAS,6BACd,qBACA,eACA;AACA,SAAO,SAAS,uBAKd,SAMA;AACA,UAAM,gBAAgB,cAAc,QAAQ,OAAO;AACnD,WAAO;AAAA,MACmC;AAAA,MACxC;AAAA,QACE,SAAS;AAAA,SACN;AAAA,IAEP;AAAA,EACF;AACF;AAEO,SAAS,sBAAsB,mBAAqC;AACzE,SAAO,IACF,SACA,kBAAkB,OAAO,GAAG,IAAI,EAAE,CAAC;AAC1C;","names":["exports","module","__defProp","__getOwnPropDesc","__getOwnPropNames","__hasOwnProp","__export","__copyProps","__toCommonJS","shallowEqual","import_react","params","error","options","import_react","data","_a","_b","error","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../../utils/dist/comparison/index.js","../src/index.ts","../src/factories.ts","../src/useMutation.ts","../src/useQuery.ts","../src/useSubscriptionCore.ts","../src/useSubscription.ts","../src/proxyBinders.ts"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/comparison/index.ts\nvar comparison_exports = {};\n__export(comparison_exports, {\n shallowEqual: () => shallowEqual\n});\nmodule.exports = __toCommonJS(comparison_exports);\n\n// src/comparison/shallowEqual.ts\nfunction shallowEqual(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {\n return false;\n }\n }\n return true;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n shallowEqual\n});\n","export * from \"./factories\";\nexport * from \"./useSubscription\";\nexport * from \"./useQuery\";\nexport * from \"./useMutation\";\nexport * from \"./useSubscriptionCore\";\nexport * from \"./proxyBinders\";\n","import type { TSocketServerCallOptions, ZMQClient } from \"@pixotope/zmq-client\";\nimport { useCallback, useMemo } from \"react\";\nimport { MutationOptions, useMutation } from \"./useMutation\";\nimport { QueryOptions, useQuery } from \"./useQuery\";\n\nexport type MutationInfo<TData, TError, TParams> = {\n data: TData;\n error: TError;\n params: TParams;\n};\n\ntype FnToParamsBase = Record<string, MutationInfo<unknown, unknown, unknown>>;\n\nexport type TPromiseFunction<TResponse, TParams> = (\n args: Omit<\n ZMQClient.Call<\n TResponse,\n {\n functionName: string;\n parameters: TParams;\n options?: Omit<TSocketServerCallOptions, \"toCallIfNoResponse\">;\n }\n >,\n \"id\"\n >\n) => Promise<TResponse>;\n\nconst useCallMutationBase = <\n TFnToParams extends FnToParamsBase,\n TData = unknown,\n TError = unknown,\n TParams = unknown,\n>(\n promiseFunc: TPromiseFunction<TData, TParams>,\n functionName: keyof TFnToParams,\n service: string,\n options?: Omit<MutationOptions<TData, TError, TParams>, \"mutationFn\"> & {\n avoidTimeout?: boolean;\n customTimeout?: number;\n }\n) => {\n const {\n avoidTimeout = true,\n customTimeout = undefined,\n ...rest\n } = useMemo(() => options ?? {}, [options]);\n const mutationFn = useCallback(\n async (parameters: TParams) => {\n try {\n return await promiseFunc({\n service,\n functionName: functionName.toString(),\n parameters,\n options: {\n avoidTimeout,\n customTimeout,\n },\n });\n } catch (e: any) {\n throw e.message;\n }\n },\n [avoidTimeout, customTimeout, functionName, service]\n );\n\n return useMutation<TData, TError, TParams>({\n mutationFn,\n ...rest,\n });\n};\n\nexport function buildMutationHook<TFnToParams extends FnToParamsBase>(\n promiseFunc: TPromiseFunction<unknown, unknown>,\n genTargetService: (machine: string | undefined) => string\n) {\n return function useCallMutationBuilder<TFn extends keyof TFnToParams>(\n func: TFn,\n options?: Parameters<\n typeof useCallMutationBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"]\n >\n >[3] & { machine?: string }\n ) {\n const targetService = genTargetService(options?.machine);\n\n return useCallMutationBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"]\n >(promiseFunc, func, targetService, options);\n };\n}\n\nconst useCallQueryBase = <\n TFnToParams extends FnToParamsBase,\n TData = unknown,\n TError = unknown,\n TParams = unknown,\n TSelect = TData,\n>(\n promiseFunction: TPromiseFunction<TData, TParams>,\n functionName: keyof TFnToParams,\n params: TParams,\n service: string,\n options?: Omit<QueryOptions<TData, TError, TParams, TSelect>, \"queryFn\"> & {\n avoidTimeout?: boolean;\n customTimeout?: number;\n }\n) => {\n const {\n avoidTimeout = true,\n customTimeout = undefined,\n ...rest\n } = useMemo(() => options ?? {}, [options]);\n const queryFn = useCallback(\n async (refetchParams: TParams | void, overrideTargetMachine?: string) => {\n try {\n return await promiseFunction({\n service: overrideTargetMachine ?? service,\n functionName: functionName.toString(),\n parameters: refetchParams ?? params,\n options: {\n avoidTimeout,\n customTimeout,\n },\n });\n } catch (e) {\n if (e instanceof Error) {\n throw e;\n }\n throw new Error(e as string);\n }\n },\n [avoidTimeout, customTimeout, functionName, service, params]\n );\n\n return useQuery<TData, TError, TParams, TSelect>({\n queryFn,\n ...rest,\n });\n};\n\nexport function buildQueryHook<TFnToParams extends FnToParamsBase>(\n promiseFunction: TPromiseFunction<unknown, unknown>,\n getTargetService: (machine: string | undefined) => string\n) {\n return function useCallQueryBuilder<\n TFn extends keyof TFnToParams,\n TSelect = TFnToParams[TFn][\"data\"],\n >(\n func: TFn,\n params: TFnToParams[TFn][\"params\"],\n options?: Parameters<\n typeof useCallQueryBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"],\n TSelect\n >\n >[4] & { machine?: string }\n ) {\n const targetService = getTargetService(options?.machine);\n\n return useCallQueryBase<\n TFnToParams,\n TFnToParams[TFn][\"data\"],\n TFnToParams[TFn][\"error\"],\n TFnToParams[TFn][\"params\"],\n TSelect\n >(promiseFunction, func, params, targetService, options);\n };\n}\n","import { useCallback, useRef, useState } from \"react\";\n\nexport type MutationFunction<TData = unknown, TParams = unknown> = (\n params: TParams,\n overrideTargetMachine?: string\n) => Promise<TData>;\n\nexport interface MutationOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n> {\n mutationFn: MutationFunction<TData, TParams>;\n params?: TParams;\n onSuccess?: (data: TData, variables: TParams) => Promise<unknown> | unknown;\n onError?: (error: TError, variables: TParams) => Promise<unknown> | unknown;\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TParams\n ) => Promise<unknown> | unknown;\n compareOrThrow?: (result: TData | TError) => boolean;\n timeout?: number;\n prepareParams?: (variables: TParams, defaults?: TParams) => TParams;\n}\n\nexport interface MutateOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n> {\n onSuccess?: (data: TData, variables: TParams) => void;\n onError?: (error: TError, variables: TParams) => void;\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TParams\n ) => void;\n}\n\ntype MutationStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\ntype RaceErrorReason = \"timeout\";\ntype RacePromises<T> = Promise<T | RaceErrorReason>;\n\nexport class ComparisonFailError<TPayload = unknown> extends Error {\n public readonly payload: TPayload;\n\n constructor(message: string, payload: TPayload) {\n super(message);\n this.name = this.constructor.name;\n this.payload = payload;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ComparisonFailError);\n }\n }\n}\n\n/**\n * `useMutation` is a hook that allows you to perform a mutation/push updates to the services while\n * providing extensive API to tap into the status and results of the mutation.\n * @param mutationFn The mutation function to be called when the `mutate` function is called.\n * `useMutation` does not care about what the function does, all it needs it a function that returns\n * a promise.\n * @param options Options to configure the mutation.\n * @returns An object with the following properties:\n * - `mutateAsync`: A function that takes in the variables and returns a promise that resolves to the\n * result of the mutation. This function can be awaited to get the result of the mutation. Callbacks can\n * be passed to this function to be called when the mutation is successful or when it fails. It's good idea\n * to wrap this function in a try/catch block.\n * - `mutate`: A function that takes in the variables and returns nothing. This function does not\n * return a promise. Callbacks can be passed to this function to be called when the mutation is\n * successful or when it fails.\n * - `status`: The status of the mutation. Can be one of `idle`, `loading`, `success` or `error`.\n * - `result`: The result of the mutation. This is undefined until the mutation is successful.\n * - `reset`: A function that resets the mutation to the initial state.\n * - `error`: The error object if the mutation has failed.\n * @example\n * ```typescript\n * const mutationRes = useMutation({\n * mutationFn: (variables) => {\n * return ZMQHelper.callSomethingAsync(variables)\n * },\n * onSuccess: (data) => {\n * // do something with the result\n * },\n * onError: (error) => {\n * // do something with the error\n * },\n * onSettled: (data, error) => {\n * // do something when the mutation is done\n * }});\n *\n * // call the mutation\n * const res = await mutationRes.mutateAsync({ foo: \"bar\" });\n * // OR\n * mutationRes.mutate({ foo: \"bar\" }, {\n * onSuccess: (data) => {\n * // do something with the result\n * // for example show a toast message\n * // stop local loading state\n * });\n * ```\n */\nexport const useMutation = <TData = unknown, TError = unknown, TParams = void>(\n options: MutationOptions<TData, TError, TParams>\n) => {\n const {\n mutationFn,\n compareOrThrow,\n onError,\n onSettled,\n onSuccess,\n prepareParams,\n params,\n timeout,\n } = options;\n const [status, setStatus] = useState<MutationStatus>(\"idle\");\n const [error, setError] = useState<TError | null>(null);\n const [result, setResult] = useState<TData | undefined>(undefined);\n const mutationFnRef = useRef(mutationFn);\n const internalOptionsRef = useRef({\n params,\n timeout,\n });\n const internalCallbackRefistry = <const>{\n onSuccess,\n onError,\n onSettled,\n compareOrThrow,\n prepareParams,\n };\n const internalCallbackRef = useRef(internalCallbackRefistry);\n internalCallbackRef.current = internalCallbackRefistry;\n\n const mutateAsync = useCallback(\n async (params: TParams, overrideTargetMachine?: string) => {\n setStatus(\"loading\");\n setError(null);\n\n try {\n const promises: RacePromises<TData>[] = [\n mutationFnRef.current(\n internalCallbackRef.current.prepareParams\n ? internalCallbackRef.current.prepareParams(\n params,\n internalOptionsRef.current.params\n )\n : params,\n overrideTargetMachine\n ),\n ...(internalOptionsRef.current.timeout\n ? [\n new Promise<RaceErrorReason>((resolve) =>\n setTimeout(\n () => resolve(\"timeout\"),\n internalOptionsRef.current.timeout\n )\n ),\n ]\n : []),\n ];\n\n const res = await Promise.race(promises);\n\n if (res === \"timeout\") {\n throw new Error(\"timeout\");\n }\n\n if (internalCallbackRef.current.compareOrThrow?.(res)) {\n throw new ComparisonFailError(JSON.stringify(res), res);\n }\n\n setResult(res);\n setStatus(\"success\");\n\n internalCallbackRef.current.onSuccess?.(res, params);\n internalCallbackRef.current.onSettled?.(res, null, params);\n\n return res;\n } catch (error: any) {\n setError(error);\n setStatus(\"error\");\n\n if (internalCallbackRef.current.onError) {\n internalCallbackRef.current.onError(error, params);\n }\n\n if (internalCallbackRef.current.onSettled) {\n internalCallbackRef.current.onSettled(undefined, error, params);\n }\n\n throw error;\n }\n },\n []\n );\n\n const mutate = useCallback(\n (\n variables: TParams,\n options?: MutateOptions<TData, TError, TParams> & {\n overrideTargetMachine?: string;\n }\n ) => {\n mutateAsync(variables, options?.overrideTargetMachine).then(\n (data) => {\n options?.onSuccess?.(data, variables);\n options?.onSettled?.(data, null, variables);\n },\n (error) => {\n options?.onError?.(error, variables);\n options?.onSettled?.(undefined, error, variables);\n }\n );\n },\n [mutateAsync]\n );\n\n return {\n mutateAsync,\n status,\n result,\n mutate,\n reset: () => setStatus(\"idle\"),\n error,\n };\n};\n","import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface QueryOptions<\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelectData = TData,\n Stateless extends true | undefined = undefined,\n> {\n queryFn: (params: TParams | undefined | void) => Promise<TData>;\n onSuccess?: (data: TData) => Promise<void> | void;\n onError?: (error: TError) => Promise<void> | void;\n onSettled?: (\n data: TData | undefined,\n error: TError | undefined\n ) => Promise<void> | void;\n timeout?: number;\n enabled?: boolean;\n initialData?: TData | Functionize<TData>;\n select?: (data: TData) => TSelectData;\n refetchOnWindowFocus?: boolean;\n refetchInterval?: number;\n compareOrThrow?: (data: TData) => boolean;\n stateless?: Stateless;\n key?: TQueryKey;\n}\n\ntype Functionize<T> = () => T;\ntype QueryStatus = \"idle\" | \"loading\" | \"success\" | \"error\" | \"timeout\";\ntype RaceErrorReason = \"timeout\";\ntype RacePromises<T> = Promise<T | RaceErrorReason>;\ntype WithData<TData> = { data: TData | undefined };\ntype TQueryKey = readonly any[];\n\nexport type UseQueryResult<\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelectData = TData,\n Stateless extends true | undefined = undefined,\n> = {\n error: TError | null;\n status: QueryStatus;\n refetch: (params: TParams | void | undefined) => Promise<void>;\n reset: () => void;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n} & (Stateless extends true ? {} : WithData<TSelectData>);\n\nfunction normalizeQueryKey(queryKey: TQueryKey): string {\n return JSON.stringify(queryKey);\n}\n\ntype TInternalCallbackRef<TData, TError, TSelectData> = {\n onError?: (error: TError) => Promise<void> | void;\n onSuccess?: (data: TData) => Promise<void> | void;\n onSettled?: (\n data: TData | undefined,\n error: TError | undefined\n ) => Promise<void> | void;\n compareOrThrow?: (data: TData) => boolean;\n select?: (data: TData) => TSelectData;\n};\n\ntype TInternalOptionsRef<TData> = {\n timeout?: number;\n enabled: boolean;\n refetchOnWindowFocus: boolean;\n refetchInterval: number;\n compareOrThrow?: (data: TData) => boolean;\n stateless?: boolean;\n};\n\nconst getRandomUUID = () => Math.random().toString(36).substring(2, 15);\n\nexport const useQuery = <\n TData = unknown,\n TError = unknown,\n TParams = void,\n TSelected = TData,\n Stateless extends true | undefined = undefined,\n>({\n queryFn,\n ...options\n}: QueryOptions<TData, TError, TParams, TSelected, Stateless>): UseQueryResult<\n TSelected,\n TError,\n TParams,\n TSelected,\n Stateless\n> => {\n const {\n enabled = true,\n refetchOnWindowFocus = false,\n refetchInterval = 0,\n initialData,\n select,\n onError,\n onSuccess,\n onSettled,\n timeout,\n compareOrThrow,\n stateless,\n key: queryKeyPassed,\n } = options;\n const queryKey = normalizeQueryKey(queryKeyPassed ?? []);\n const lastFetchedAt = useRef<number | null>(null);\n const lastQueryKey = useRef<string | undefined>(undefined);\n const queryFnRef = useRef(queryFn);\n queryFnRef.current = queryFn;\n const internalCallbackRef = useRef<\n TInternalCallbackRef<TData, TError, TSelected>\n >({});\n internalCallbackRef.current = {\n onError,\n onSuccess,\n onSettled,\n compareOrThrow,\n select,\n };\n const internalOptionsRef = useRef<TInternalOptionsRef<TData>>({\n enabled,\n refetchOnWindowFocus,\n refetchInterval,\n compareOrThrow,\n stateless,\n timeout,\n });\n internalOptionsRef.current = {\n enabled,\n refetchOnWindowFocus,\n refetchInterval,\n compareOrThrow,\n stateless,\n timeout,\n };\n const requestIdRef = useRef(getRandomUUID());\n\n const [status, setStatus] = useState<QueryStatus>(() => {\n return \"idle\";\n });\n const [error, setError] = useState<TError | null>(null);\n const [data, setData] = useState<TData | undefined>(() => {\n if (initialData !== undefined) {\n if (typeof initialData === \"function\") {\n return (initialData as Functionize<TData>)();\n }\n\n return initialData as TData;\n }\n\n return undefined;\n });\n\n const handleSetData = useCallback((data: TData) => {\n if (internalOptionsRef.current.stateless) {\n return;\n }\n\n setData(data);\n }, []);\n\n const shouldRefetch = useCallback(() => {\n if (!internalOptionsRef.current.enabled) {\n return false;\n }\n\n if (lastFetchedAt.current === null) {\n return true;\n }\n\n return (\n new Date().getTime() - lastFetchedAt.current >\n internalOptionsRef.current?.refetchInterval\n );\n }, []);\n\n const refetch = useCallback(\n async (params: TParams | void | undefined = undefined) => {\n const requestId = getRandomUUID();\n requestIdRef.current = requestId;\n if (!internalOptionsRef.current.enabled) {\n return;\n }\n\n setStatus(\"loading\");\n setError(null);\n\n try {\n const promises: RacePromises<TData>[] = [\n queryFnRef.current(params),\n ...(internalOptionsRef.current.timeout\n ? [\n new Promise<RaceErrorReason>((resolve) =>\n setTimeout(\n () => resolve(\"timeout\"),\n internalOptionsRef.current.timeout\n )\n ),\n ]\n : []),\n ];\n\n const res = await Promise.race(promises);\n if (requestIdRef.current !== requestId) {\n return;\n }\n\n if (res === \"timeout\") {\n throw new Error(\"timeout\");\n }\n\n handleSetData(res);\n\n if (\n internalCallbackRef.current.compareOrThrow &&\n internalCallbackRef.current.compareOrThrow(res) === true\n ) {\n throw new Error(\"compareOrThrow\");\n }\n\n setStatus(\"success\");\n lastFetchedAt.current = new Date().getTime();\n internalCallbackRef.current.onSuccess?.(res);\n internalCallbackRef.current.onSettled?.(res, undefined);\n } catch (error: any) {\n setError(error);\n setStatus(\"error\");\n internalCallbackRef.current.onError?.(error);\n internalCallbackRef.current.onSettled?.(undefined, error);\n }\n },\n [handleSetData]\n );\n\n const reset = useCallback(() => {\n setData(undefined);\n setStatus(\"idle\");\n setError(null);\n refetch();\n }, [refetch]);\n\n useEffect(() => {\n const cleanups: (() => void)[] = [];\n\n // If the query should be refetched on window focus, add a listener\n if (refetchOnWindowFocus) {\n const queryHandleFocus = () => {\n refetch();\n };\n\n window.addEventListener(\"focus\", queryHandleFocus);\n\n cleanups.push(() => {\n window.removeEventListener(\"focus\", queryHandleFocus);\n });\n }\n\n // If the query should be refetched on an interval, add an interval\n if (refetchInterval > 0) {\n const interval = setInterval(\n () => {\n if (shouldRefetch()) {\n refetch();\n }\n },\n Math.max(refetchInterval, 1000)\n );\n\n cleanups.push(() => {\n clearInterval(interval);\n });\n }\n\n // If the query key has changed, refetch\n if (\n lastQueryKey.current === undefined ||\n queryKey !== lastQueryKey.current\n ) {\n lastQueryKey.current = queryKey;\n refetch();\n }\n\n return () => {\n cleanups.forEach((cleanup) => cleanup());\n };\n }, [\n queryKey,\n enabled,\n refetchOnWindowFocus,\n refetchInterval,\n shouldRefetch,\n refetch,\n ]);\n\n return {\n data:\n select && data !== undefined\n ? select(data as TData)\n : (data as unknown as TSelected),\n error,\n status,\n refetch,\n reset,\n };\n};\n","/**\n * @fileoverview useSubscriptionCore\n * @name useSubscriptionCore.ts\n * @description useSubscriptionCore | This hook handle core subscription logic\n * and provides a way to subscribe and unsubscribe to a topic via any callback\n */\n\nimport { shallowEqual } from \"@pixotope/utils/comparison\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\ntype SubscriptionState = \"idle\" | \"subscribed\" | \"subscribing\";\nexport type MessageHandler<TMessage> = (message: TMessage) => void;\nexport type Connection = {\n acknowledge: () => void;\n};\nexport type SubscriptionCoreOptions<\n TData,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n> = {\n /**\n * @description Function that will be called when the message is received.\n */\n onMessage?: (message: TMessage) => void;\n /**\n * @description Function that will be called when the subscription is created.\n */\n onSubscribed?: (message: TMessage) => void;\n /**\n * @description Function that will be called when the subscription is created.\n */\n onError?: (error: TMessage) => void;\n /**\n * @description Whether the subscription is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * @description Function that will be called to compare the message with the\n * previous message. If the function returns true, the message will be ignored.\n */\n compareOrThrow?: (data: TMessage) => boolean;\n /**\n * @description Function that will be called to select the data from the message.\n */\n select?: (data: TMessage) => TData;\n /**\n * @description Initial state of the subscription.\n * @default undefined\n */\n initialState?: TData;\n /**\n * @description Function that will be called when the subscription is created.\n */\n subscriberFn: (\n handler: MessageHandler<TMessage>,\n connection: Connection\n ) => () => void /** unsubscribe Fn */;\n /**\n * @description Whether the subscription is stateless. Data will not be\n * stored by the hook internally.\n * @default false\n */\n stateless?: Stateless;\n /**\n * @description Custom equality function for comparing data.\n * @default shallowEqual\n */\n isEqual?: <T = TData>(a: T, b: T) => boolean;\n};\n\ntype WithStatus = {\n status: SubscriptionState;\n};\n\ntype WithData<TData> = {\n data: TData;\n};\n\nexport type SubscriptionCoreReturnType<\n TData,\n Stateless extends true | undefined,\n> = {\n reSubscribe: () => void;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n} & (Stateless extends true ? {} : WithStatus & WithData<TData>);\n\n/**\n * @description `useSubscriptionCore` | This hook handle core subscription logic\n * and provides a way to subscribe and unsubscribe to a topic via any callback.\n * The hook expose a handler function. All the consumer code need to do is to\n * call this handler function with the message received from the topic or pass\n * it directly to the callback function that is passed to the subscriberFn.\n * - `status` - current status of the subscription\n * - `data` - the data after the select function is applied to the message\n * - `reSubscribe` - function that can be called to re-subscribe to the topic\n *\n * An example how this hook works can be found in {@link ./useSubscription.ts}\n */\nexport function useSubscriptionCore<\n TData = unknown,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n>(\n options: SubscriptionCoreOptions<TData, TMessage, Stateless>\n): SubscriptionCoreReturnType<TData, Stateless> {\n const {\n enabled = true,\n initialState = undefined,\n onSubscribed,\n stateless,\n compareOrThrow,\n subscriberFn,\n onMessage,\n onError,\n select,\n isEqual = shallowEqual,\n } = options;\n const [status, setStatus] = useState<SubscriptionState>(\"idle\");\n const [data, setData] = useState<TData | undefined>(initialState);\n const unsubcribeRef = useRef<() => void | undefined>(undefined);\n const initialStateRef = useRef(initialState);\n const subscriberFnRef = useRef(subscriberFn);\n const callbackRefRegistry = <const>{\n onMessage,\n onError,\n select,\n compareOrThrow,\n onSubscribed,\n isEqual,\n };\n const internalCallbacksRef = useRef(callbackRefRegistry);\n internalCallbacksRef.current = callbackRefRegistry;\n\n const updateStatus = useCallback(\n (newStatus: SubscriptionState, message?: TMessage) => {\n if (stateless) {\n return;\n }\n\n setStatus((prev) => {\n if (prev === newStatus) {\n return prev;\n }\n\n if (newStatus === \"subscribed\" && message) {\n internalCallbacksRef.current.onSubscribed?.(message);\n }\n\n return newStatus;\n });\n },\n [stateless]\n );\n\n const connection: Connection = useMemo(\n () => ({\n acknowledge: () => {\n updateStatus(\"subscribed\");\n },\n }),\n [updateStatus]\n );\n\n const handler = useCallback(\n async (message: TMessage) => {\n if (internalCallbacksRef.current.compareOrThrow?.(message)) {\n internalCallbacksRef.current.onError?.(message);\n\n return;\n }\n\n const selectedMessage = <TData>(\n (internalCallbacksRef.current.select?.(message) ?? message)\n );\n\n if (!stateless) {\n setData((prev) => {\n if (isEqual(prev, selectedMessage)) {\n return prev;\n }\n\n return selectedMessage;\n });\n }\n\n updateStatus(\"subscribed\", message);\n internalCallbacksRef.current.onMessage?.(message);\n },\n [stateless, updateStatus]\n );\n\n const unsubscribe = useCallback(() => {\n updateStatus(\"idle\");\n unsubcribeRef.current?.();\n unsubcribeRef.current = undefined;\n }, [updateStatus]);\n\n const subscribe = useCallback(() => {\n unsubcribeRef.current?.();\n updateStatus(\"subscribing\");\n setData(initialStateRef.current);\n unsubcribeRef.current = subscriberFnRef.current(handler, connection);\n }, [connection, handler, updateStatus]);\n\n useEffect(() => {\n if (enabled) {\n subscribe();\n } else {\n unsubscribe();\n }\n\n return () => {\n unsubscribe();\n };\n }, [enabled, subscribe, unsubscribe]);\n\n return {\n status,\n data,\n reSubscribe: subscribe,\n } as unknown as any;\n}\n","import {\n SubscriptionCoreOptions,\n useSubscriptionCore,\n} from \"./useSubscriptionCore\";\n\nexport type SubscriptionOptions<\n TData,\n TMessage = unknown,\n Stateless extends true | undefined = undefined,\n> = Omit<\n SubscriptionCoreOptions<TData, TMessage, Stateless>,\n \"subscriberFn\"\n> & {\n service: string;\n topic: string;\n maxDownwardDepth?: number;\n};\n\nexport type TSubscriptionHandlerFunction<TMessage> = (opts: {\n service: string;\n name: string;\n callback: (message: TMessage) => void;\n maxDownwardDepth?: number;\n}) => () => void;\n\nexport function useSubscription<\n TData = unknown,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n>(\n subscriptionHandler: TSubscriptionHandlerFunction<TMessage>,\n options: SubscriptionOptions<TData, TMessage, Stateless>\n) {\n const { topic, service, maxDownwardDepth = 1000 } = options;\n\n return useSubscriptionCore<TData, TMessage, Stateless>({\n ...options,\n subscriberFn: (handler) => {\n const unsubscribe = subscriptionHandler({\n service,\n name: topic,\n callback: (message: TMessage) => {\n handler(message);\n },\n maxDownwardDepth,\n });\n\n return unsubscribe;\n },\n });\n}\n\nexport function buildServiceSubscriptionHook(\n subscriptionHandler: TSubscriptionHandlerFunction<unknown>,\n targetMachine: (machine: string | undefined) => string\n) {\n return function useSubscriptionBuilder<\n TData,\n TMessage = TData,\n Stateless extends true | undefined = undefined,\n >(\n options: Omit<\n SubscriptionOptions<TData, TMessage, Stateless>,\n \"service\"\n > & {\n machine?: string;\n }\n ) {\n const targetService = targetMachine(options.machine);\n return useSubscription<TData, TMessage, Stateless>(\n <TSubscriptionHandlerFunction<TMessage>>subscriptionHandler,\n {\n service: targetService,\n ...options,\n }\n );\n };\n}\n","import type { ZMQProxyWSClient } from \"@pixotope/zmq-client\";\nimport type { TPromiseFunction } from \"./factories\";\nimport type { buildServiceSubscriptionHook } from \"./useSubscription\";\n\nexport function bindClientSocketProxy(socketClientProxy: ZMQProxyWSClient) {\n return (\n ...args: Parameters<Parameters<typeof buildServiceSubscriptionHook>[0]>\n ) => {\n const { callback: cbHook, ...rest } = args[0];\n return socketClientProxy.mirror({\n ...rest,\n callback: (message) => {\n cbHook(message.message);\n },\n })[0];\n };\n}\n\nexport function bindPromiseFunction(clientSocketProxy: ZMQProxyWSClient) {\n return async (...args: Parameters<TPromiseFunction<unknown, unknown>>) => {\n const res = await clientSocketProxy.callAsync(...args);\n return res.message.Result;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,sCAAAA,UAAAC,SAAA;AAAA;AACA,QAAIC,aAAY,OAAO;AACvB,QAAIC,oBAAmB,OAAO;AAC9B,QAAIC,qBAAoB,OAAO;AAC/B,QAAIC,gBAAe,OAAO,UAAU;AACpC,QAAIC,YAAW,CAAC,QAAQ,QAAQ;AAC9B,eAAS,QAAQ;AACf,QAAAJ,WAAU,QAAQ,MAAM,EAAE,KAAK,IAAI,IAAI,GAAG,YAAY,KAAK,CAAC;AAAA,IAChE;AACA,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Q,OAAO;AAAA,QACjB;AAAA,QACA;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF,EAAC;AACH;AAEO,SAAS,6BACd,qBACA,eACA;AACA,SAAO,SAAS,uBAKd,SAMA;AACA,UAAM,gBAAgB,cAAc,QAAQ,OAAO;AACnD,WAAO;AAAA,MACmC;AAAA,MACxC;AAAA,QACE,SAAS;AAAA,SACN;AAAA,IAEP;AAAA,EACF;AACF;;;ACzEO,SAAS,sBAAsB,mBAAqC;AACzE,SAAO,IACF,SACA;AACH,UAAsC,UAAK,CAAC,GAApC,YAAU,OARtB,IAQ0C,IAAT,iBAAS,IAAT,CAArB;AACR,WAAO,kBAAkB,OAAO,iCAC3B,OAD2B;AAAA,MAE9B,UAAU,CAAC,YAAY;AACrB,eAAO,QAAQ,OAAO;AAAA,MACxB;AAAA,IACF,EAAC,EAAE,CAAC;AAAA,EACN;AACF;AAEO,SAAS,oBAAoB,mBAAqC;AACvE,SAAO,IAAU,SAAyD;AACxE,UAAM,MAAM,MAAM,kBAAkB,UAAU,GAAG,IAAI;AACrD,WAAO,IAAI,QAAQ;AAAA,EACrB;AACF;","names":["exports","module","__defProp","__getOwnPropDesc","__getOwnPropNames","__hasOwnProp","__export","__copyProps","__toCommonJS","shallowEqual","import_react","params","error","options","import_react","data","_a","_b","error","import_react"]}
|