@xyo-network/react-payload-diviner 2.64.9 → 2.65.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.
Files changed (110) hide show
  1. package/dist/browser/contexts/PayloadDiviner/use.d.cts +4 -4
  2. package/dist/browser/contexts/PayloadDiviner/use.d.cts.map +1 -1
  3. package/dist/browser/contexts/PayloadDiviner/use.d.mts +4 -4
  4. package/dist/browser/contexts/PayloadDiviner/use.d.mts.map +1 -1
  5. package/dist/browser/contexts/PayloadDiviner/use.d.ts +4 -4
  6. package/dist/browser/contexts/PayloadDiviner/use.d.ts.map +1 -1
  7. package/dist/node/contexts/PayloadDiviner/use.d.cts +4 -4
  8. package/dist/node/contexts/PayloadDiviner/use.d.cts.map +1 -1
  9. package/dist/node/contexts/PayloadDiviner/use.d.mts +4 -4
  10. package/dist/node/contexts/PayloadDiviner/use.d.mts.map +1 -1
  11. package/dist/node/contexts/PayloadDiviner/use.d.ts +4 -4
  12. package/dist/node/contexts/PayloadDiviner/use.d.ts.map +1 -1
  13. package/package.json +10 -10
  14. package/dist/browser/contexts/DivinedPayload/Context.cjs +0 -28
  15. package/dist/browser/contexts/DivinedPayload/Context.cjs.map +0 -1
  16. package/dist/browser/contexts/DivinedPayload/Context.js +0 -7
  17. package/dist/browser/contexts/DivinedPayload/Context.js.map +0 -1
  18. package/dist/browser/contexts/DivinedPayload/Provider.cjs +0 -111
  19. package/dist/browser/contexts/DivinedPayload/Provider.cjs.map +0 -1
  20. package/dist/browser/contexts/DivinedPayload/Provider.js +0 -90
  21. package/dist/browser/contexts/DivinedPayload/Provider.js.map +0 -1
  22. package/dist/browser/contexts/DivinedPayload/State.cjs +0 -19
  23. package/dist/browser/contexts/DivinedPayload/State.cjs.map +0 -1
  24. package/dist/browser/contexts/DivinedPayload/State.js +0 -1
  25. package/dist/browser/contexts/DivinedPayload/State.js.map +0 -1
  26. package/dist/browser/contexts/DivinedPayload/index.cjs +0 -115
  27. package/dist/browser/contexts/DivinedPayload/index.cjs.map +0 -1
  28. package/dist/browser/contexts/DivinedPayload/index.js +0 -92
  29. package/dist/browser/contexts/DivinedPayload/index.js.map +0 -1
  30. package/dist/browser/contexts/DivinedPayload/use.cjs +0 -34
  31. package/dist/browser/contexts/DivinedPayload/use.cjs.map +0 -1
  32. package/dist/browser/contexts/DivinedPayload/use.js +0 -13
  33. package/dist/browser/contexts/DivinedPayload/use.js.map +0 -1
  34. package/dist/browser/contexts/PayloadDiviner/Context.cjs +0 -28
  35. package/dist/browser/contexts/PayloadDiviner/Context.cjs.map +0 -1
  36. package/dist/browser/contexts/PayloadDiviner/Context.js +0 -7
  37. package/dist/browser/contexts/PayloadDiviner/Context.js.map +0 -1
  38. package/dist/browser/contexts/PayloadDiviner/Provider.cjs +0 -53
  39. package/dist/browser/contexts/PayloadDiviner/Provider.cjs.map +0 -1
  40. package/dist/browser/contexts/PayloadDiviner/Provider.js +0 -32
  41. package/dist/browser/contexts/PayloadDiviner/Provider.js.map +0 -1
  42. package/dist/browser/contexts/PayloadDiviner/State.cjs +0 -19
  43. package/dist/browser/contexts/PayloadDiviner/State.cjs.map +0 -1
  44. package/dist/browser/contexts/PayloadDiviner/State.js +0 -1
  45. package/dist/browser/contexts/PayloadDiviner/State.js.map +0 -1
  46. package/dist/browser/contexts/PayloadDiviner/index.cjs +0 -136
  47. package/dist/browser/contexts/PayloadDiviner/index.cjs.map +0 -1
  48. package/dist/browser/contexts/PayloadDiviner/index.js +0 -113
  49. package/dist/browser/contexts/PayloadDiviner/index.js.map +0 -1
  50. package/dist/browser/contexts/PayloadDiviner/use.cjs +0 -111
  51. package/dist/browser/contexts/PayloadDiviner/use.cjs.map +0 -1
  52. package/dist/browser/contexts/PayloadDiviner/use.js +0 -90
  53. package/dist/browser/contexts/PayloadDiviner/use.js.map +0 -1
  54. package/dist/browser/contexts/index.cjs +0 -182
  55. package/dist/browser/contexts/index.cjs.map +0 -1
  56. package/dist/browser/contexts/index.js +0 -159
  57. package/dist/browser/contexts/index.js.map +0 -1
  58. package/dist/browser/types/images.d.cjs +0 -2
  59. package/dist/browser/types/images.d.cjs.map +0 -1
  60. package/dist/browser/types/images.d.js +0 -1
  61. package/dist/browser/types/images.d.js.map +0 -1
  62. package/dist/docs.json +0 -1796
  63. package/dist/node/contexts/DivinedPayload/Context.cjs +0 -32
  64. package/dist/node/contexts/DivinedPayload/Context.cjs.map +0 -1
  65. package/dist/node/contexts/DivinedPayload/Context.js +0 -7
  66. package/dist/node/contexts/DivinedPayload/Context.js.map +0 -1
  67. package/dist/node/contexts/DivinedPayload/Provider.cjs +0 -117
  68. package/dist/node/contexts/DivinedPayload/Provider.cjs.map +0 -1
  69. package/dist/node/contexts/DivinedPayload/Provider.js +0 -90
  70. package/dist/node/contexts/DivinedPayload/Provider.js.map +0 -1
  71. package/dist/node/contexts/DivinedPayload/State.cjs +0 -19
  72. package/dist/node/contexts/DivinedPayload/State.cjs.map +0 -1
  73. package/dist/node/contexts/DivinedPayload/State.js +0 -1
  74. package/dist/node/contexts/DivinedPayload/State.js.map +0 -1
  75. package/dist/node/contexts/DivinedPayload/index.cjs +0 -123
  76. package/dist/node/contexts/DivinedPayload/index.cjs.map +0 -1
  77. package/dist/node/contexts/DivinedPayload/index.js +0 -92
  78. package/dist/node/contexts/DivinedPayload/index.js.map +0 -1
  79. package/dist/node/contexts/DivinedPayload/use.cjs +0 -38
  80. package/dist/node/contexts/DivinedPayload/use.cjs.map +0 -1
  81. package/dist/node/contexts/DivinedPayload/use.js +0 -13
  82. package/dist/node/contexts/DivinedPayload/use.js.map +0 -1
  83. package/dist/node/contexts/PayloadDiviner/Context.cjs +0 -32
  84. package/dist/node/contexts/PayloadDiviner/Context.cjs.map +0 -1
  85. package/dist/node/contexts/PayloadDiviner/Context.js +0 -7
  86. package/dist/node/contexts/PayloadDiviner/Context.js.map +0 -1
  87. package/dist/node/contexts/PayloadDiviner/Provider.cjs +0 -57
  88. package/dist/node/contexts/PayloadDiviner/Provider.cjs.map +0 -1
  89. package/dist/node/contexts/PayloadDiviner/Provider.js +0 -32
  90. package/dist/node/contexts/PayloadDiviner/Provider.js.map +0 -1
  91. package/dist/node/contexts/PayloadDiviner/State.cjs +0 -19
  92. package/dist/node/contexts/PayloadDiviner/State.cjs.map +0 -1
  93. package/dist/node/contexts/PayloadDiviner/State.js +0 -1
  94. package/dist/node/contexts/PayloadDiviner/State.js.map +0 -1
  95. package/dist/node/contexts/PayloadDiviner/index.cjs +0 -144
  96. package/dist/node/contexts/PayloadDiviner/index.cjs.map +0 -1
  97. package/dist/node/contexts/PayloadDiviner/index.js +0 -113
  98. package/dist/node/contexts/PayloadDiviner/index.js.map +0 -1
  99. package/dist/node/contexts/PayloadDiviner/use.cjs +0 -117
  100. package/dist/node/contexts/PayloadDiviner/use.cjs.map +0 -1
  101. package/dist/node/contexts/PayloadDiviner/use.js +0 -90
  102. package/dist/node/contexts/PayloadDiviner/use.js.map +0 -1
  103. package/dist/node/contexts/index.cjs +0 -195
  104. package/dist/node/contexts/index.cjs.map +0 -1
  105. package/dist/node/contexts/index.js +0 -159
  106. package/dist/node/contexts/index.js.map +0 -1
  107. package/dist/node/types/images.d.cjs +0 -2
  108. package/dist/node/types/images.d.cjs.map +0 -1
  109. package/dist/node/types/images.d.js +0 -1
  110. package/dist/node/types/images.d.js.map +0 -1
@@ -1,13 +0,0 @@
1
- // src/contexts/DivinedPayload/use.ts
2
- import { useContextEx } from "@xyo-network/react-shared";
3
-
4
- // src/contexts/DivinedPayload/Context.tsx
5
- import { createContextEx } from "@xyo-network/react-shared";
6
- var DivinedPayloadContext = createContextEx();
7
-
8
- // src/contexts/DivinedPayload/use.ts
9
- var useDivinedPayload = () => useContextEx(DivinedPayloadContext, "DivinedPayload", true);
10
- export {
11
- useDivinedPayload
12
- };
13
- //# sourceMappingURL=use.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/DivinedPayload/use.ts","../../../../src/contexts/DivinedPayload/Context.tsx"],"sourcesContent":["import { useContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadContext } from './Context'\n\nexport const useDivinedPayload = () => useContextEx(DivinedPayloadContext, 'DivinedPayload', true)\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadState } from './State'\n\nexport const DivinedPayloadContext = createContextEx<DivinedPayloadState>()\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,SAAS,uBAAuB;AAIzB,IAAM,wBAAwB,gBAAqC;;;ADAnE,IAAM,oBAAoB,MAAM,aAAa,uBAAuB,kBAAkB,IAAI;","names":[]}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/contexts/PayloadDiviner/Context.ts
21
- var Context_exports = {};
22
- __export(Context_exports, {
23
- PayloadDivinerContext: () => PayloadDivinerContext
24
- });
25
- module.exports = __toCommonJS(Context_exports);
26
- var import_react_shared = require("@xyo-network/react-shared");
27
- var PayloadDivinerContext = (0, import_react_shared.createContextEx)();
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- PayloadDivinerContext
31
- });
32
- //# sourceMappingURL=Context.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/Context.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAIhC,IAAM,4BAAwB,qCAAqC;","names":[]}
@@ -1,7 +0,0 @@
1
- // src/contexts/PayloadDiviner/Context.ts
2
- import { createContextEx } from "@xyo-network/react-shared";
3
- var PayloadDivinerContext = createContextEx();
4
- export {
5
- PayloadDivinerContext
6
- };
7
- //# sourceMappingURL=Context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/Context.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n"],"mappings":";AAAA,SAAS,uBAAuB;AAIhC,IAAM,wBAAwB,gBAAqC;","names":[]}
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/contexts/PayloadDiviner/Provider.tsx
21
- var Provider_exports = {};
22
- __export(Provider_exports, {
23
- PayloadDivinerProvider: () => PayloadDivinerProvider
24
- });
25
- module.exports = __toCommonJS(Provider_exports);
26
- var import_react = require("react");
27
-
28
- // src/contexts/PayloadDiviner/Context.ts
29
- var import_react_shared = require("@xyo-network/react-shared");
30
- var PayloadDivinerContext = (0, import_react_shared.createContextEx)();
31
-
32
- // src/contexts/PayloadDiviner/Provider.tsx
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- var PayloadDivinerProvider = ({ diviner: divinerProp, required = false, children }) => {
35
- const [diviner, setDiviner] = (0, import_react.useState)(divinerProp);
36
- (0, import_react.useEffect)(() => {
37
- if (divinerProp) {
38
- setDiviner(divinerProp);
39
- }
40
- }, [divinerProp]);
41
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
- PayloadDivinerContext.Provider,
43
- {
44
- value: {
45
- diviner: diviner === divinerProp ? diviner : void 0,
46
- provided: true,
47
- setDiviner
48
- },
49
- children: diviner ? children : required ? null : children
50
- }
51
- );
52
- };
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- PayloadDivinerProvider
56
- });
57
- //# sourceMappingURL=Provider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/Provider.tsx","../../../../src/contexts/PayloadDiviner/Context.ts"],"sourcesContent":["import { AbstractPayloadDiviner } from '@xyo-network/diviner'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport type PayloadDivinerProviderProps = ContextExProviderProps<{\n /** Required */\n diviner?: AbstractPayloadDiviner\n}>\n\nexport const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({ diviner: divinerProp, required = false, children }) => {\n const [diviner, setDiviner] = useState<AbstractPayloadDiviner | undefined>(divinerProp)\n\n useEffect(() => {\n if (divinerProp) {\n setDiviner(divinerProp)\n }\n }, [divinerProp])\n\n return (\n <PayloadDivinerContext.Provider\n value={{\n diviner: diviner === divinerProp ? diviner : undefined,\n provided: true,\n setDiviner,\n }}\n >\n {diviner ? children : required ? null : children}\n </PayloadDivinerContext.Provider>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;;;ACFpC,0BAAgC;AAIhC,IAAM,4BAAwB,qCAAqC;;;ADiB/D;AAVG,IAAM,yBAAgE,CAAC,EAAE,SAAS,aAAa,WAAW,OAAO,SAAS,MAAM;AACrI,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA6C,WAAW;AAEtF,8BAAU,MAAM;AACd,QAAI,aAAa;AACf,iBAAW,WAAW;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC,OAAO;AAAA,QACL,SAAS,YAAY,cAAc,UAAU;AAAA,QAC7C,UAAU;AAAA,QACV;AAAA,MACF;AAAA,MAEC,oBAAU,WAAW,WAAW,OAAO;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
@@ -1,32 +0,0 @@
1
- // src/contexts/PayloadDiviner/Provider.tsx
2
- import { useEffect, useState } from "react";
3
-
4
- // src/contexts/PayloadDiviner/Context.ts
5
- import { createContextEx } from "@xyo-network/react-shared";
6
- var PayloadDivinerContext = createContextEx();
7
-
8
- // src/contexts/PayloadDiviner/Provider.tsx
9
- import { jsx } from "react/jsx-runtime";
10
- var PayloadDivinerProvider = ({ diviner: divinerProp, required = false, children }) => {
11
- const [diviner, setDiviner] = useState(divinerProp);
12
- useEffect(() => {
13
- if (divinerProp) {
14
- setDiviner(divinerProp);
15
- }
16
- }, [divinerProp]);
17
- return /* @__PURE__ */ jsx(
18
- PayloadDivinerContext.Provider,
19
- {
20
- value: {
21
- diviner: diviner === divinerProp ? diviner : void 0,
22
- provided: true,
23
- setDiviner
24
- },
25
- children: diviner ? children : required ? null : children
26
- }
27
- );
28
- };
29
- export {
30
- PayloadDivinerProvider
31
- };
32
- //# sourceMappingURL=Provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/Provider.tsx","../../../../src/contexts/PayloadDiviner/Context.ts"],"sourcesContent":["import { AbstractPayloadDiviner } from '@xyo-network/diviner'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport type PayloadDivinerProviderProps = ContextExProviderProps<{\n /** Required */\n diviner?: AbstractPayloadDiviner\n}>\n\nexport const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({ diviner: divinerProp, required = false, children }) => {\n const [diviner, setDiviner] = useState<AbstractPayloadDiviner | undefined>(divinerProp)\n\n useEffect(() => {\n if (divinerProp) {\n setDiviner(divinerProp)\n }\n }, [divinerProp])\n\n return (\n <PayloadDivinerContext.Provider\n value={{\n diviner: diviner === divinerProp ? diviner : undefined,\n provided: true,\n setDiviner,\n }}\n >\n {diviner ? children : required ? null : children}\n </PayloadDivinerContext.Provider>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n"],"mappings":";AAEA,SAAS,WAAW,gBAAgB;;;ACFpC,SAAS,uBAAuB;AAIhC,IAAM,wBAAwB,gBAAqC;;;ADiB/D;AAVG,IAAM,yBAAgE,CAAC,EAAE,SAAS,aAAa,WAAW,OAAO,SAAS,MAAM;AACrI,QAAM,CAAC,SAAS,UAAU,IAAI,SAA6C,WAAW;AAEtF,YAAU,MAAM;AACd,QAAI,aAAa;AACf,iBAAW,WAAW;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC,OAAO;AAAA,QACL,SAAS,YAAY,cAAc,UAAU;AAAA,QAC7C,UAAU;AAAA,QACV;AAAA,MACF;AAAA,MAEC,oBAAU,WAAW,WAAW,OAAO;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/contexts/PayloadDiviner/State.ts
17
- var State_exports = {};
18
- module.exports = __toCommonJS(State_exports);
19
- //# sourceMappingURL=State.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/State.ts"],"sourcesContent":["import { AbstractPayloadDiviner } from '@xyo-network/diviner'\nimport { Dispatch } from 'react'\n\nexport interface PayloadDivinerState {\n diviner?: AbstractPayloadDiviner\n setDiviner?: Dispatch<AbstractPayloadDiviner>\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=State.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,144 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/contexts/PayloadDiviner/index.ts
21
- var PayloadDiviner_exports = {};
22
- __export(PayloadDiviner_exports, {
23
- PayloadDivinerContext: () => PayloadDivinerContext,
24
- PayloadDivinerProvider: () => PayloadDivinerProvider,
25
- useDivinePayload: () => useDivinePayload,
26
- useDivinePayloads: () => useDivinePayloads,
27
- usePayloadDiviner: () => usePayloadDiviner
28
- });
29
- module.exports = __toCommonJS(PayloadDiviner_exports);
30
-
31
- // src/contexts/PayloadDiviner/Context.ts
32
- var import_react_shared = require("@xyo-network/react-shared");
33
- var PayloadDivinerContext = (0, import_react_shared.createContextEx)();
34
-
35
- // src/contexts/PayloadDiviner/Provider.tsx
36
- var import_react = require("react");
37
- var import_jsx_runtime = require("react/jsx-runtime");
38
- var PayloadDivinerProvider = ({ diviner: divinerProp, required = false, children }) => {
39
- const [diviner, setDiviner] = (0, import_react.useState)(divinerProp);
40
- (0, import_react.useEffect)(() => {
41
- if (divinerProp) {
42
- setDiviner(divinerProp);
43
- }
44
- }, [divinerProp]);
45
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
46
- PayloadDivinerContext.Provider,
47
- {
48
- value: {
49
- diviner: diviner === divinerProp ? diviner : void 0,
50
- provided: true,
51
- setDiviner
52
- },
53
- children: diviner ? children : required ? null : children
54
- }
55
- );
56
- };
57
-
58
- // src/contexts/PayloadDiviner/use.ts
59
- var import_lodash = require("@xylabs/lodash");
60
- var import_react_async_effect = require("@xylabs/react-async-effect");
61
- var import_diviner = require("@xyo-network/diviner");
62
- var import_react_shared2 = require("@xyo-network/react-shared");
63
- var import_react2 = require("react");
64
- var usePayloadDiviner = (required = false) => {
65
- return (0, import_react_shared2.useContextEx)(PayloadDivinerContext, "PayloadDiviner", required);
66
- };
67
- var useDivinePayload = (huri) => {
68
- const { diviner } = usePayloadDiviner();
69
- const [payload, setPayload] = (0, import_react2.useState)();
70
- const [error, setError] = (0, import_react2.useState)();
71
- (0, import_react2.useEffect)(() => {
72
- if (diviner) {
73
- setPayload(void 0);
74
- }
75
- }, [diviner]);
76
- (0, import_react_async_effect.useAsyncEffect)(
77
- // eslint-disable-next-line react-hooks/exhaustive-deps
78
- async (mounted) => {
79
- if (huri && diviner && payload === void 0) {
80
- try {
81
- const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
82
- const [payload2] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
83
- if (mounted()) {
84
- setPayload(payload2 ? payload2 : null);
85
- }
86
- } catch (ex) {
87
- if (mounted()) {
88
- setError(ex);
89
- }
90
- }
91
- }
92
- },
93
- [diviner, huri, payload]
94
- );
95
- return [payload, setPayload, error];
96
- };
97
- var useDivinePayloads = (huriList) => {
98
- const { diviner } = usePayloadDiviner();
99
- const [payloads, setPayloads] = (0, import_react2.useState)();
100
- const [errors, setErrors] = (0, import_react2.useState)();
101
- (0, import_react2.useEffect)(() => {
102
- if (diviner) {
103
- setPayloads(void 0);
104
- }
105
- }, [diviner]);
106
- (0, import_react_async_effect.useAsyncEffect)(
107
- // eslint-disable-next-line react-hooks/exhaustive-deps
108
- async (mounted) => {
109
- console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`);
110
- const payloads2 = await Promise.allSettled(
111
- huriList.map(async (huri) => {
112
- const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
113
- const [payload] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
114
- return payload;
115
- })
116
- );
117
- if (mounted()) {
118
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
119
- setErrors(
120
- (0, import_lodash.compact)([...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0))
121
- );
122
- if (mounted()) {
123
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
124
- setErrors(
125
- (0, import_lodash.compact)(
126
- [...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0)
127
- )
128
- );
129
- }
130
- }
131
- },
132
- [diviner, huriList, payloads]
133
- );
134
- return [payloads, setPayloads, errors];
135
- };
136
- // Annotate the CommonJS export names for ESM import in node:
137
- 0 && (module.exports = {
138
- PayloadDivinerContext,
139
- PayloadDivinerProvider,
140
- useDivinePayload,
141
- useDivinePayloads,
142
- usePayloadDiviner
143
- });
144
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/index.ts","../../../../src/contexts/PayloadDiviner/Context.ts","../../../../src/contexts/PayloadDiviner/Provider.tsx","../../../../src/contexts/PayloadDiviner/use.ts"],"sourcesContent":["export * from './Context'\nexport * from './Provider'\nexport * from './State'\nexport * from './use'\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n","import { AbstractPayloadDiviner } from '@xyo-network/diviner'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport type PayloadDivinerProviderProps = ContextExProviderProps<{\n /** Required */\n diviner?: AbstractPayloadDiviner\n}>\n\nexport const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({ diviner: divinerProp, required = false, children }) => {\n const [diviner, setDiviner] = useState<AbstractPayloadDiviner | undefined>(divinerProp)\n\n useEffect(() => {\n if (divinerProp) {\n setDiviner(divinerProp)\n }\n }, [divinerProp])\n\n return (\n <PayloadDivinerContext.Provider\n value={{\n diviner: diviner === divinerProp ? diviner : undefined,\n provided: true,\n setDiviner,\n }}\n >\n {diviner ? children : required ? null : children}\n </PayloadDivinerContext.Provider>\n )\n}\n","import { compact } from '@xylabs/lodash'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner'\nimport { Payload } from '@xyo-network/payload-model'\nimport { useContextEx } from '@xyo-network/react-shared'\nimport { Dispatch, useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport const usePayloadDiviner = (required = false) => {\n return useContextEx(PayloadDivinerContext, 'PayloadDiviner', required)\n}\n\nexport const useDivinePayload = <T extends Payload = Payload>(\n huri?: string,\n): [T | undefined | null, Dispatch<T | null | undefined>, Error | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payload, setPayload] = useState<T | null>()\n const [error, setError] = useState<Error>()\n\n useEffect(() => {\n if (diviner) {\n setPayload(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (huri && diviner && payload === undefined) {\n try {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n if (mounted()) {\n setPayload(payload ? (payload as T) : null)\n }\n } catch (ex) {\n if (mounted()) {\n setError(ex as Error)\n }\n }\n }\n },\n [diviner, huri, payload],\n )\n\n return [payload, setPayload, error]\n}\n\nexport const useDivinePayloads = <T extends Payload = Payload>(\n huriList: string[],\n): [(T | null)[] | undefined, Dispatch<(T | null)[] | undefined>, Error[] | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payloads, setPayloads] = useState<(T | null)[]>()\n const [errors, setErrors] = useState<Error[]>()\n\n useEffect(() => {\n if (diviner) {\n setPayloads(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`)\n const payloads = await Promise.allSettled(\n huriList.map(async (huri) => {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n return payload\n }),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact([...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined))),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact(\n [...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined)),\n ),\n )\n }\n }\n },\n [diviner, huriList, payloads],\n )\n\n return [payloads, setPayloads, errors]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0BAAgC;AAIhC,IAAM,4BAAwB,qCAAqC;;;ACFnE,mBAAoC;AAmBhC;AAVG,IAAM,yBAAgE,CAAC,EAAE,SAAS,aAAa,WAAW,OAAO,SAAS,MAAM;AACrI,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA6C,WAAW;AAEtF,8BAAU,MAAM;AACd,QAAI,aAAa;AACf,iBAAW,WAAW;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC,OAAO;AAAA,QACL,SAAS,YAAY,cAAc,UAAU;AAAA,QAC7C,UAAU;AAAA,QACV;AAAA,MACF;AAAA,MAEC,oBAAU,WAAW,WAAW,OAAO;AAAA;AAAA,EAC1C;AAEJ;;;AC/BA,oBAAwB;AACxB,gCAA+B;AAC/B,qBAAwC;AAExC,IAAAA,uBAA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M,CAAC,CAAC,EAAE;AAC5D,YAAMC,YAAW,MAAM,QAAQ;AAAA,QAC7B,SAAS,IAAI,OAAO,SAAS;AAC3B,gBAAM,cAA2B,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,0BAAW;AACpE,gBAAM,CAAC,OAAO,IAAK,OAAM,mCAAS,OAAO,CAAC,WAAW,OAAO,CAAC;AAC7D,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AACA,UAAI,QAAQ,GAAG;AACb,oBAAY,CAAC,GAAGA,UAAS,OAAO,CAAC,EAAE,IAAI,CAAC,UAAW,MAAM,WAAW,aAAa,OAAO,MAAM,KAAM,CAAiB;AACrH;AAAA,cACE,uBAAQ,CAAC,GAAGA,UAAS,OAAO,CAAC,EAAE,IAAI,CAAC,UAAW,MAAM,WAAW,aAAa,MAAM,iBAAiB,EAAE,OAAO,MAAM,OAAO,CAAC,IAAI,MAAU,CAAC;AAAA,QAC5I;AACA,YAAI,QAAQ,GAAG;AACb,sBAAY,CAAC,GAAGA,UAAS,OAAO,CAAC,EAAE,IAAI,CAAC,UAAW,MAAM,WAAW,aAAa,OAAO,MAAM,KAAM,CAAiB;AACrH;AAAA,gBACE;AAAA,cACE,CAAC,GAAGA,UAAS,OAAO,CAAC,EAAE,IAAI,CAAC,UAAW,MAAM,WAAW,aAAa,MAAM,iBAAiB,EAAE,OAAO,MAAM,OAAO,CAAC,IAAI,MAAU;AAAA,YACnI;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,UAAU,QAAQ;AAAA,EAC9B;AAEA,SAAO,CAAC,UAAU,aAAa,MAAM;AACvC;","names":["import_react_shared","import_react","payload","payloads"]}
@@ -1,113 +0,0 @@
1
- // src/contexts/PayloadDiviner/Context.ts
2
- import { createContextEx } from "@xyo-network/react-shared";
3
- var PayloadDivinerContext = createContextEx();
4
-
5
- // src/contexts/PayloadDiviner/Provider.tsx
6
- import { useEffect, useState } from "react";
7
- import { jsx } from "react/jsx-runtime";
8
- var PayloadDivinerProvider = ({ diviner: divinerProp, required = false, children }) => {
9
- const [diviner, setDiviner] = useState(divinerProp);
10
- useEffect(() => {
11
- if (divinerProp) {
12
- setDiviner(divinerProp);
13
- }
14
- }, [divinerProp]);
15
- return /* @__PURE__ */ jsx(
16
- PayloadDivinerContext.Provider,
17
- {
18
- value: {
19
- diviner: diviner === divinerProp ? diviner : void 0,
20
- provided: true,
21
- setDiviner
22
- },
23
- children: diviner ? children : required ? null : children
24
- }
25
- );
26
- };
27
-
28
- // src/contexts/PayloadDiviner/use.ts
29
- import { compact } from "@xylabs/lodash";
30
- import { useAsyncEffect } from "@xylabs/react-async-effect";
31
- import { HuriSchema } from "@xyo-network/diviner";
32
- import { useContextEx } from "@xyo-network/react-shared";
33
- import { useEffect as useEffect2, useState as useState2 } from "react";
34
- var usePayloadDiviner = (required = false) => {
35
- return useContextEx(PayloadDivinerContext, "PayloadDiviner", required);
36
- };
37
- var useDivinePayload = (huri) => {
38
- const { diviner } = usePayloadDiviner();
39
- const [payload, setPayload] = useState2();
40
- const [error, setError] = useState2();
41
- useEffect2(() => {
42
- if (diviner) {
43
- setPayload(void 0);
44
- }
45
- }, [diviner]);
46
- useAsyncEffect(
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
- async (mounted) => {
49
- if (huri && diviner && payload === void 0) {
50
- try {
51
- const huriPayload = { huri: [huri], schema: HuriSchema };
52
- const [payload2] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
53
- if (mounted()) {
54
- setPayload(payload2 ? payload2 : null);
55
- }
56
- } catch (ex) {
57
- if (mounted()) {
58
- setError(ex);
59
- }
60
- }
61
- }
62
- },
63
- [diviner, huri, payload]
64
- );
65
- return [payload, setPayload, error];
66
- };
67
- var useDivinePayloads = (huriList) => {
68
- const { diviner } = usePayloadDiviner();
69
- const [payloads, setPayloads] = useState2();
70
- const [errors, setErrors] = useState2();
71
- useEffect2(() => {
72
- if (diviner) {
73
- setPayloads(void 0);
74
- }
75
- }, [diviner]);
76
- useAsyncEffect(
77
- // eslint-disable-next-line react-hooks/exhaustive-deps
78
- async (mounted) => {
79
- console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`);
80
- const payloads2 = await Promise.allSettled(
81
- huriList.map(async (huri) => {
82
- const huriPayload = { huri: [huri], schema: HuriSchema };
83
- const [payload] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
84
- return payload;
85
- })
86
- );
87
- if (mounted()) {
88
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
89
- setErrors(
90
- compact([...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0))
91
- );
92
- if (mounted()) {
93
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
94
- setErrors(
95
- compact(
96
- [...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0)
97
- )
98
- );
99
- }
100
- }
101
- },
102
- [diviner, huriList, payloads]
103
- );
104
- return [payloads, setPayloads, errors];
105
- };
106
- export {
107
- PayloadDivinerContext,
108
- PayloadDivinerProvider,
109
- useDivinePayload,
110
- useDivinePayloads,
111
- usePayloadDiviner
112
- };
113
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/Context.ts","../../../../src/contexts/PayloadDiviner/Provider.tsx","../../../../src/contexts/PayloadDiviner/use.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n","import { AbstractPayloadDiviner } from '@xyo-network/diviner'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport type PayloadDivinerProviderProps = ContextExProviderProps<{\n /** Required */\n diviner?: AbstractPayloadDiviner\n}>\n\nexport const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({ diviner: divinerProp, required = false, children }) => {\n const [diviner, setDiviner] = useState<AbstractPayloadDiviner | undefined>(divinerProp)\n\n useEffect(() => {\n if (divinerProp) {\n setDiviner(divinerProp)\n }\n }, [divinerProp])\n\n return (\n <PayloadDivinerContext.Provider\n value={{\n diviner: diviner === divinerProp ? diviner : undefined,\n provided: true,\n setDiviner,\n }}\n >\n {diviner ? children : required ? null : children}\n </PayloadDivinerContext.Provider>\n )\n}\n","import { compact } from '@xylabs/lodash'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner'\nimport { Payload } from '@xyo-network/payload-model'\nimport { useContextEx } from '@xyo-network/react-shared'\nimport { Dispatch, useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport const usePayloadDiviner = (required = false) => {\n return useContextEx(PayloadDivinerContext, 'PayloadDiviner', required)\n}\n\nexport const useDivinePayload = <T extends Payload = Payload>(\n huri?: string,\n): [T | undefined | null, Dispatch<T | null | undefined>, Error | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payload, setPayload] = useState<T | null>()\n const [error, setError] = useState<Error>()\n\n useEffect(() => {\n if (diviner) {\n setPayload(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (huri && diviner && payload === undefined) {\n try {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n if (mounted()) {\n setPayload(payload ? (payload as T) : null)\n }\n } catch (ex) {\n if (mounted()) {\n setError(ex as Error)\n }\n }\n }\n },\n [diviner, huri, payload],\n )\n\n return [payload, setPayload, error]\n}\n\nexport const useDivinePayloads = <T extends Payload = Payload>(\n huriList: string[],\n): [(T | null)[] | undefined, Dispatch<(T | null)[] | undefined>, Error[] | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payloads, setPayloads] = useState<(T | null)[]>()\n const [errors, setErrors] = useState<Error[]>()\n\n useEffect(() => {\n if (diviner) {\n setPayloads(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`)\n const payloads = await Promise.allSettled(\n huriList.map(async (huri) => {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n return payload\n }),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact([...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined))),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact(\n [...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined)),\n ),\n )\n }\n }\n },\n [diviner, huriList, payloads],\n )\n\n return [payloads, setPayloads, errors]\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAIhC,IAAM,wBAAwB,gBAAqC;;;ACFnE,SAAS,WAAW,gBAAgB;AAmBhC;AAVG,IAAM,yBAAgE,CAAC,EAAE,SAAS,aAAa,WAAW,OAAO,SAAS,MAAM;AACrI,QAAM,CAAC,SAAS,UAAU,IAAI,SAA6C,WAAW;AAEtF,YAAU,MAAM;AACd,QAAI,aAAa;AACf,iBAAW,WAAW;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC,OAAO;AAAA,QACL,SAAS,YAAY,cAAc,UAAU;AAAA,QAC7C,UAAU;AAAA,QACV;AAAA,MACF;AAAA,MAEC,oBAAU,WAAW,WAAW,OAAO;AAAA;AAAA,EAC1C;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__getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/contexts/PayloadDiviner/use.ts
21
- var use_exports = {};
22
- __export(use_exports, {
23
- useDivinePayload: () => useDivinePayload,
24
- useDivinePayloads: () => useDivinePayloads,
25
- usePayloadDiviner: () => usePayloadDiviner
26
- });
27
- module.exports = __toCommonJS(use_exports);
28
- var import_lodash = require("@xylabs/lodash");
29
- var import_react_async_effect = require("@xylabs/react-async-effect");
30
- var import_diviner = require("@xyo-network/diviner");
31
- var import_react_shared2 = require("@xyo-network/react-shared");
32
- var import_react = require("react");
33
-
34
- // src/contexts/PayloadDiviner/Context.ts
35
- var import_react_shared = require("@xyo-network/react-shared");
36
- var PayloadDivinerContext = (0, import_react_shared.createContextEx)();
37
-
38
- // src/contexts/PayloadDiviner/use.ts
39
- var usePayloadDiviner = (required = false) => {
40
- return (0, import_react_shared2.useContextEx)(PayloadDivinerContext, "PayloadDiviner", required);
41
- };
42
- var useDivinePayload = (huri) => {
43
- const { diviner } = usePayloadDiviner();
44
- const [payload, setPayload] = (0, import_react.useState)();
45
- const [error, setError] = (0, import_react.useState)();
46
- (0, import_react.useEffect)(() => {
47
- if (diviner) {
48
- setPayload(void 0);
49
- }
50
- }, [diviner]);
51
- (0, import_react_async_effect.useAsyncEffect)(
52
- // eslint-disable-next-line react-hooks/exhaustive-deps
53
- async (mounted) => {
54
- if (huri && diviner && payload === void 0) {
55
- try {
56
- const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
57
- const [payload2] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
58
- if (mounted()) {
59
- setPayload(payload2 ? payload2 : null);
60
- }
61
- } catch (ex) {
62
- if (mounted()) {
63
- setError(ex);
64
- }
65
- }
66
- }
67
- },
68
- [diviner, huri, payload]
69
- );
70
- return [payload, setPayload, error];
71
- };
72
- var useDivinePayloads = (huriList) => {
73
- const { diviner } = usePayloadDiviner();
74
- const [payloads, setPayloads] = (0, import_react.useState)();
75
- const [errors, setErrors] = (0, import_react.useState)();
76
- (0, import_react.useEffect)(() => {
77
- if (diviner) {
78
- setPayloads(void 0);
79
- }
80
- }, [diviner]);
81
- (0, import_react_async_effect.useAsyncEffect)(
82
- // eslint-disable-next-line react-hooks/exhaustive-deps
83
- async (mounted) => {
84
- console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`);
85
- const payloads2 = await Promise.allSettled(
86
- huriList.map(async (huri) => {
87
- const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
88
- const [payload] = await (diviner == null ? void 0 : diviner.divine([huriPayload])) ?? [];
89
- return payload;
90
- })
91
- );
92
- if (mounted()) {
93
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
94
- setErrors(
95
- (0, import_lodash.compact)([...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0))
96
- );
97
- if (mounted()) {
98
- setPayloads([...payloads2.values()].map((value) => value.status === "rejected" ? null : value.value));
99
- setErrors(
100
- (0, import_lodash.compact)(
101
- [...payloads2.values()].map((value) => value.status === "rejected" ? Error("divine failed", { cause: value.reason }) : void 0)
102
- )
103
- );
104
- }
105
- }
106
- },
107
- [diviner, huriList, payloads]
108
- );
109
- return [payloads, setPayloads, errors];
110
- };
111
- // Annotate the CommonJS export names for ESM import in node:
112
- 0 && (module.exports = {
113
- useDivinePayload,
114
- useDivinePayloads,
115
- usePayloadDiviner
116
- });
117
- //# sourceMappingURL=use.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/contexts/PayloadDiviner/use.ts","../../../../src/contexts/PayloadDiviner/Context.ts"],"sourcesContent":["import { compact } from '@xylabs/lodash'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner'\nimport { Payload } from '@xyo-network/payload-model'\nimport { useContextEx } from '@xyo-network/react-shared'\nimport { Dispatch, useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context'\n\nexport const usePayloadDiviner = (required = false) => {\n return useContextEx(PayloadDivinerContext, 'PayloadDiviner', required)\n}\n\nexport const useDivinePayload = <T extends Payload = Payload>(\n huri?: string,\n): [T | undefined | null, Dispatch<T | null | undefined>, Error | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payload, setPayload] = useState<T | null>()\n const [error, setError] = useState<Error>()\n\n useEffect(() => {\n if (diviner) {\n setPayload(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (huri && diviner && payload === undefined) {\n try {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n if (mounted()) {\n setPayload(payload ? (payload as T) : null)\n }\n } catch (ex) {\n if (mounted()) {\n setError(ex as Error)\n }\n }\n }\n },\n [diviner, huri, payload],\n )\n\n return [payload, setPayload, error]\n}\n\nexport const useDivinePayloads = <T extends Payload = Payload>(\n huriList: string[],\n): [(T | null)[] | undefined, Dispatch<(T | null)[] | undefined>, Error[] | undefined] => {\n const { diviner } = usePayloadDiviner()\n const [payloads, setPayloads] = useState<(T | null)[]>()\n const [errors, setErrors] = useState<Error[]>()\n\n useEffect(() => {\n if (diviner) {\n setPayloads(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`)\n const payloads = await Promise.allSettled(\n huriList.map(async (huri) => {\n const huriPayload: HuriPayload = { huri: [huri], schema: HuriSchema }\n const [payload] = (await diviner?.divine([huriPayload])) ?? []\n return payload\n }),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact([...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined))),\n )\n if (mounted()) {\n setPayloads([...payloads.values()].map((value) => (value.status === 'rejected' ? null : value.value)) as (T | null)[])\n setErrors(\n compact(\n [...payloads.values()].map((value) => (value.status === 'rejected' ? Error('divine failed', { cause: value.reason }) : undefined)),\n ),\n )\n }\n }\n },\n [diviner, huriList, payloads],\n )\n\n return [payloads, setPayloads, errors]\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAwB;AACxB,gCAA+B;AAC/B,qBAAwC;AAExC,IAAAA,uBAA6B;AAC7B,mBAA8C;;;ACL9C,0BAAgC;AAIhC,IAAM,4BAAwB,qCAAqC;;;ADK5D,IAAM,oBAAoB,CAAC,WAAW,UAAU;AACrD,aAAO,mCAAa,uBAAuB,kBAAkB,QAAQ;AACvE;AAEO,IAAM,mBAAmB,CAC9B,SAC8E;AAC9E,QAAM,EAAE,QAAQ,IAAI,kBAAkB;AACtC,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAmB;AACjD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAgB;AAE1C,8BAAU,MAAM;AACd,QAAI,SAAS;AACX,iBAAW,MAAS;AAAA,IACtB;AAAA,EACF,GAAG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