@xyo-network/react-payload-diviner 2.64.0-rc.7 → 2.64.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 (149) hide show
  1. package/dist/browser/contexts/DivinedPayload/Context.cjs +28 -0
  2. package/dist/{node/contexts/DivinedPayload/Context.mjs.map → browser/contexts/DivinedPayload/Context.cjs.map} +1 -1
  3. package/dist/browser/contexts/DivinedPayload/Context.d.cts +4 -0
  4. package/dist/browser/contexts/DivinedPayload/Context.d.cts.map +1 -0
  5. package/dist/browser/contexts/DivinedPayload/Provider.cjs +111 -0
  6. package/dist/browser/contexts/DivinedPayload/Provider.cjs.map +1 -0
  7. package/dist/browser/contexts/DivinedPayload/Provider.d.cts +9 -0
  8. package/dist/browser/contexts/DivinedPayload/Provider.d.cts.map +1 -0
  9. package/dist/browser/contexts/DivinedPayload/State.cjs +19 -0
  10. package/dist/browser/contexts/DivinedPayload/State.cjs.map +1 -0
  11. package/dist/browser/contexts/DivinedPayload/State.d.cts +9 -0
  12. package/dist/browser/contexts/DivinedPayload/State.d.cts.map +1 -0
  13. package/dist/browser/contexts/DivinedPayload/index.cjs +115 -0
  14. package/dist/browser/contexts/DivinedPayload/index.cjs.map +1 -0
  15. package/dist/browser/contexts/DivinedPayload/index.d.cts +5 -0
  16. package/dist/browser/contexts/DivinedPayload/index.d.cts.map +1 -0
  17. package/dist/browser/contexts/DivinedPayload/use.cjs +34 -0
  18. package/dist/browser/contexts/DivinedPayload/use.cjs.map +1 -0
  19. package/dist/browser/contexts/DivinedPayload/use.d.cts +2 -0
  20. package/dist/browser/contexts/DivinedPayload/use.d.cts.map +1 -0
  21. package/dist/browser/contexts/PayloadDiviner/Context.cjs +28 -0
  22. package/dist/{node/contexts/PayloadDiviner/Context.mjs.map → browser/contexts/PayloadDiviner/Context.cjs.map} +1 -1
  23. package/dist/browser/contexts/PayloadDiviner/Context.d.cts +5 -0
  24. package/dist/browser/contexts/PayloadDiviner/Context.d.cts.map +1 -0
  25. package/dist/browser/contexts/PayloadDiviner/Provider.cjs +53 -0
  26. package/dist/browser/contexts/PayloadDiviner/Provider.cjs.map +1 -0
  27. package/dist/browser/contexts/PayloadDiviner/Provider.d.cts +9 -0
  28. package/dist/browser/contexts/PayloadDiviner/Provider.d.cts.map +1 -0
  29. package/dist/browser/contexts/PayloadDiviner/State.cjs +19 -0
  30. package/dist/browser/contexts/PayloadDiviner/State.cjs.map +1 -0
  31. package/dist/browser/contexts/PayloadDiviner/State.d.cts +7 -0
  32. package/dist/browser/contexts/PayloadDiviner/State.d.cts.map +1 -0
  33. package/dist/browser/contexts/PayloadDiviner/index.cjs +136 -0
  34. package/dist/browser/contexts/PayloadDiviner/index.cjs.map +1 -0
  35. package/dist/browser/contexts/PayloadDiviner/index.d.cts +5 -0
  36. package/dist/browser/contexts/PayloadDiviner/index.d.cts.map +1 -0
  37. package/dist/browser/contexts/PayloadDiviner/use.cjs +111 -0
  38. package/dist/browser/contexts/PayloadDiviner/use.cjs.map +1 -0
  39. package/dist/browser/contexts/PayloadDiviner/use.d.cts +13 -0
  40. package/dist/browser/contexts/PayloadDiviner/use.d.cts.map +1 -0
  41. package/dist/browser/contexts/index.cjs +182 -0
  42. package/dist/browser/contexts/index.cjs.map +1 -0
  43. package/dist/browser/contexts/index.d.cts +3 -0
  44. package/dist/browser/contexts/index.d.cts.map +1 -0
  45. package/dist/browser/index.cjs +182 -0
  46. package/dist/browser/index.cjs.map +1 -0
  47. package/dist/browser/index.d.cts +2 -0
  48. package/dist/browser/index.d.cts.map +1 -0
  49. package/dist/browser/types/images.d.cjs +2 -0
  50. package/dist/docs.json +1796 -0
  51. package/dist/node/contexts/DivinedPayload/Context.cjs +32 -0
  52. package/dist/node/contexts/DivinedPayload/Context.cjs.map +1 -0
  53. package/dist/node/contexts/DivinedPayload/Context.d.cts +4 -0
  54. package/dist/node/contexts/DivinedPayload/Context.d.cts.map +1 -0
  55. package/dist/node/contexts/DivinedPayload/Context.js +5 -28
  56. package/dist/node/contexts/DivinedPayload/Context.js.map +1 -1
  57. package/dist/node/contexts/DivinedPayload/Provider.cjs +117 -0
  58. package/dist/node/contexts/DivinedPayload/Provider.cjs.map +1 -0
  59. package/dist/node/contexts/DivinedPayload/Provider.d.cts +9 -0
  60. package/dist/node/contexts/DivinedPayload/Provider.d.cts.map +1 -0
  61. package/dist/node/contexts/DivinedPayload/Provider.js +73 -47
  62. package/dist/node/contexts/DivinedPayload/Provider.js.map +1 -1
  63. package/dist/node/contexts/DivinedPayload/State.cjs +19 -0
  64. package/dist/node/contexts/DivinedPayload/State.cjs.map +1 -0
  65. package/dist/node/contexts/DivinedPayload/State.d.cts +9 -0
  66. package/dist/node/contexts/DivinedPayload/State.d.cts.map +1 -0
  67. package/dist/node/contexts/DivinedPayload/State.js +0 -16
  68. package/dist/node/contexts/DivinedPayload/State.js.map +1 -1
  69. package/dist/node/contexts/DivinedPayload/index.cjs +123 -0
  70. package/dist/node/contexts/DivinedPayload/index.cjs.map +1 -0
  71. package/dist/node/contexts/DivinedPayload/index.d.cts +5 -0
  72. package/dist/node/contexts/DivinedPayload/index.d.cts.map +1 -0
  73. package/dist/node/contexts/DivinedPayload/index.js +90 -27
  74. package/dist/node/contexts/DivinedPayload/index.js.map +1 -1
  75. package/dist/node/contexts/DivinedPayload/use.cjs +38 -0
  76. package/dist/node/contexts/DivinedPayload/use.cjs.map +1 -0
  77. package/dist/node/contexts/DivinedPayload/use.d.cts +2 -0
  78. package/dist/node/contexts/DivinedPayload/use.d.cts.map +1 -0
  79. package/dist/node/contexts/DivinedPayload/use.js +11 -29
  80. package/dist/node/contexts/DivinedPayload/use.js.map +1 -1
  81. package/dist/node/contexts/PayloadDiviner/Context.cjs +32 -0
  82. package/dist/node/contexts/PayloadDiviner/Context.cjs.map +1 -0
  83. package/dist/node/contexts/PayloadDiviner/Context.d.cts +5 -0
  84. package/dist/node/contexts/PayloadDiviner/Context.d.cts.map +1 -0
  85. package/dist/node/contexts/PayloadDiviner/Context.js +5 -28
  86. package/dist/node/contexts/PayloadDiviner/Context.js.map +1 -1
  87. package/dist/node/contexts/PayloadDiviner/Provider.cjs +57 -0
  88. package/dist/node/contexts/PayloadDiviner/Provider.cjs.map +1 -0
  89. package/dist/node/contexts/PayloadDiviner/Provider.d.cts +9 -0
  90. package/dist/node/contexts/PayloadDiviner/Provider.d.cts.map +1 -0
  91. package/dist/node/contexts/PayloadDiviner/Provider.js +16 -34
  92. package/dist/node/contexts/PayloadDiviner/Provider.js.map +1 -1
  93. package/dist/node/contexts/PayloadDiviner/State.cjs +19 -0
  94. package/dist/node/contexts/PayloadDiviner/State.cjs.map +1 -0
  95. package/dist/node/contexts/PayloadDiviner/State.d.cts +7 -0
  96. package/dist/node/contexts/PayloadDiviner/State.d.cts.map +1 -0
  97. package/dist/node/contexts/PayloadDiviner/State.js +0 -16
  98. package/dist/node/contexts/PayloadDiviner/State.js.map +1 -1
  99. package/dist/node/contexts/PayloadDiviner/index.cjs +144 -0
  100. package/dist/node/contexts/PayloadDiviner/index.cjs.map +1 -0
  101. package/dist/node/contexts/PayloadDiviner/index.d.cts +5 -0
  102. package/dist/node/contexts/PayloadDiviner/index.d.cts.map +1 -0
  103. package/dist/node/contexts/PayloadDiviner/index.js +111 -27
  104. package/dist/node/contexts/PayloadDiviner/index.js.map +1 -1
  105. package/dist/node/contexts/PayloadDiviner/use.cjs +117 -0
  106. package/dist/node/contexts/PayloadDiviner/use.cjs.map +1 -0
  107. package/dist/node/contexts/PayloadDiviner/use.d.cts +13 -0
  108. package/dist/node/contexts/PayloadDiviner/use.d.cts.map +1 -0
  109. package/dist/node/contexts/PayloadDiviner/use.js +32 -52
  110. package/dist/node/contexts/PayloadDiviner/use.js.map +1 -1
  111. package/dist/node/contexts/index.cjs +195 -0
  112. package/dist/node/contexts/index.cjs.map +1 -0
  113. package/dist/node/contexts/index.d.cts +3 -0
  114. package/dist/node/contexts/index.d.cts.map +1 -0
  115. package/dist/node/contexts/index.js +158 -24
  116. package/dist/node/contexts/index.js.map +1 -1
  117. package/dist/node/index.cjs +195 -0
  118. package/dist/node/index.cjs.map +1 -0
  119. package/dist/node/index.d.cts +2 -0
  120. package/dist/node/index.d.cts.map +1 -0
  121. package/dist/node/index.js +158 -22
  122. package/dist/node/index.js.map +1 -1
  123. package/dist/node/types/images.d.cjs +2 -0
  124. package/dist/node/types/images.d.js +0 -1
  125. package/package.json +19 -19
  126. package/dist/node/contexts/DivinedPayload/Context.mjs +0 -6
  127. package/dist/node/contexts/DivinedPayload/Provider.mjs +0 -38
  128. package/dist/node/contexts/DivinedPayload/Provider.mjs.map +0 -1
  129. package/dist/node/contexts/DivinedPayload/State.mjs +0 -1
  130. package/dist/node/contexts/DivinedPayload/index.mjs +0 -5
  131. package/dist/node/contexts/DivinedPayload/index.mjs.map +0 -1
  132. package/dist/node/contexts/DivinedPayload/use.mjs +0 -7
  133. package/dist/node/contexts/DivinedPayload/use.mjs.map +0 -1
  134. package/dist/node/contexts/PayloadDiviner/Context.mjs +0 -6
  135. package/dist/node/contexts/PayloadDiviner/Provider.mjs +0 -26
  136. package/dist/node/contexts/PayloadDiviner/Provider.mjs.map +0 -1
  137. package/dist/node/contexts/PayloadDiviner/State.mjs +0 -1
  138. package/dist/node/contexts/PayloadDiviner/index.mjs +0 -5
  139. package/dist/node/contexts/PayloadDiviner/index.mjs.map +0 -1
  140. package/dist/node/contexts/PayloadDiviner/use.mjs +0 -84
  141. package/dist/node/contexts/PayloadDiviner/use.mjs.map +0 -1
  142. package/dist/node/contexts/index.mjs +0 -3
  143. package/dist/node/contexts/index.mjs.map +0 -1
  144. package/dist/node/index.mjs +0 -2
  145. package/dist/node/index.mjs.map +0 -1
  146. package/dist/node/types/images.d.mjs +0 -1
  147. package/dist/node/types/images.d.mjs.map +0 -1
  148. /package/dist/{node/contexts/DivinedPayload/State.mjs.map → browser/types/images.d.cjs.map} +0 -0
  149. /package/dist/node/{contexts/PayloadDiviner/State.mjs.map → types/images.d.cjs.map} +0 -0
@@ -0,0 +1,28 @@
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/DivinedPayload/Context.tsx
21
+ var Context_exports = {};
22
+ __export(Context_exports, {
23
+ DivinedPayloadContext: () => DivinedPayloadContext
24
+ });
25
+ module.exports = __toCommonJS(Context_exports);
26
+ var import_react_shared = require("@xyo-network/react-shared");
27
+ var DivinedPayloadContext = (0, import_react_shared.createContextEx)();
28
+ //# sourceMappingURL=Context.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadState } from './State'\n\nexport const DivinedPayloadContext = createContextEx<DivinedPayloadState>()\n"],"mappings":"AAAA,SAAS,uBAAuB;AAIzB,MAAM,wBAAwB,gBAAqC;","names":[]}
1
+ {"version":3,"sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadState } from './State'\n\nexport const DivinedPayloadContext = createContextEx<DivinedPayloadState>()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAIzB,IAAM,4BAAwB,qCAAqC;","names":[]}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { DivinedPayloadState } from './State';
3
+ export declare const DivinedPayloadContext: import("react").Context<DivinedPayloadState & import("@xyo-network/react-shared").ContextExState>;
4
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,qBAAqB,mGAAyC,CAAA"}
@@ -0,0 +1,111 @@
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/DivinedPayload/Provider.tsx
21
+ var Provider_exports = {};
22
+ __export(Provider_exports, {
23
+ DivinedPayloadProvider: () => DivinedPayloadProvider,
24
+ DivinedPayloadWithHandleInner: () => DivinedPayloadWithHandleInner,
25
+ DivinedPayloadWithHandleProvider: () => DivinedPayloadWithHandleProvider
26
+ });
27
+ module.exports = __toCommonJS(Provider_exports);
28
+ var import_payload_model = require("@xyo-network/payload-model");
29
+ var import_react_error = require("@xyo-network/react-error");
30
+ var import_react_payload_huri = require("@xyo-network/react-payload-huri");
31
+ var import_react_router_dom = require("react-router-dom");
32
+
33
+ // src/contexts/PayloadDiviner/Context.ts
34
+ var import_react_shared = require("@xyo-network/react-shared");
35
+ var PayloadDivinerContext = (0, import_react_shared.createContextEx)();
36
+
37
+ // src/contexts/PayloadDiviner/use.ts
38
+ var import_lodash = require("@xylabs/lodash");
39
+ var import_react_async_effect = require("@xylabs/react-async-effect");
40
+ var import_diviner = require("@xyo-network/diviner");
41
+ var import_react_shared2 = require("@xyo-network/react-shared");
42
+ var import_react = require("react");
43
+ var usePayloadDiviner = (required = false) => {
44
+ return (0, import_react_shared2.useContextEx)(PayloadDivinerContext, "PayloadDiviner", required);
45
+ };
46
+ var useDivinePayload = (huri) => {
47
+ const { diviner } = usePayloadDiviner();
48
+ const [payload, setPayload] = (0, import_react.useState)();
49
+ const [error, setError] = (0, import_react.useState)();
50
+ (0, import_react.useEffect)(() => {
51
+ if (diviner) {
52
+ setPayload(void 0);
53
+ }
54
+ }, [diviner]);
55
+ (0, import_react_async_effect.useAsyncEffect)(
56
+ // eslint-disable-next-line react-hooks/exhaustive-deps
57
+ async (mounted) => {
58
+ if (huri && diviner && payload === void 0) {
59
+ try {
60
+ const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
61
+ const [payload2] = await diviner?.divine([huriPayload]) ?? [];
62
+ if (mounted()) {
63
+ setPayload(payload2 ? payload2 : null);
64
+ }
65
+ } catch (ex) {
66
+ if (mounted()) {
67
+ setError(ex);
68
+ }
69
+ }
70
+ }
71
+ },
72
+ [diviner, huri, payload]
73
+ );
74
+ return [payload, setPayload, error];
75
+ };
76
+
77
+ // src/contexts/DivinedPayload/Context.tsx
78
+ var import_react_shared3 = require("@xyo-network/react-shared");
79
+ var DivinedPayloadContext = (0, import_react_shared3.createContextEx)();
80
+
81
+ // src/contexts/DivinedPayload/use.ts
82
+ var import_react_shared4 = require("@xyo-network/react-shared");
83
+ var useDivinedPayload = () => (0, import_react_shared4.useContextEx)(DivinedPayloadContext, "DivinedPayload", true);
84
+
85
+ // src/contexts/DivinedPayload/Provider.tsx
86
+ var import_jsx_runtime = require("react/jsx-runtime");
87
+ var DivinedPayloadProvider = ({ children, hash }) => {
88
+ const { hash: hashParam } = (0, import_react_router_dom.useParams)();
89
+ const huriFromHashParam = (0, import_react_payload_huri.useBuildHuri)(hashParam);
90
+ const [params] = (0, import_react_router_dom.useSearchParams)();
91
+ const huriSearchParameter = params.get("huri");
92
+ const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
93
+ const huriUri = hash ?? (decodedHuriParam ? decodedHuriParam : huriFromHashParam);
94
+ const [payload, setPayload, payloadError] = useDivinePayload(huriUri);
95
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadContext.Provider, { value: { payload, payloadError, provided: true, setPayload }, children });
96
+ };
97
+ var DivinedPayloadWithHandleInner = ({ children }) => {
98
+ const { payloadError } = useDivinedPayload();
99
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
+ import_react_error.ErrorRender,
101
+ {
102
+ error: payloadError ? { message: payloadError.message, schema: import_payload_model.ModuleErrorSchema, sources: [] } : void 0,
103
+ errorContext: "Divined Payload Provider",
104
+ children
105
+ }
106
+ );
107
+ };
108
+ var DivinedPayloadWithHandleProvider = ({ children, ...props }) => {
109
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadProvider, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadWithHandleInner, { children }) });
110
+ };
111
+ //# sourceMappingURL=Provider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/contexts/DivinedPayload/Provider.tsx","../../../../src/contexts/PayloadDiviner/Context.ts","../../../../src/contexts/PayloadDiviner/use.ts","../../../../src/contexts/DivinedPayload/Context.tsx","../../../../src/contexts/DivinedPayload/use.ts"],"sourcesContent":["import type { WithChildren } from '@xylabs/react-shared'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { ErrorRender } from '@xyo-network/react-error'\nimport { useBuildHuri } from '@xyo-network/react-payload-huri'\nimport { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useDivinePayload } from '../PayloadDiviner'\nimport { DivinedPayloadContext } from './Context'\nimport { useDivinedPayload } from './use'\n\nexport interface DivinedPayloadProviderProps extends WithChildren {\n hash?: string\n}\n\nexport const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps> = ({ children, hash }) => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n const huriUri = hash ?? (decodedHuriParam ? decodedHuriParam : huriFromHashParam)\n\n const [payload, setPayload, payloadError] = useDivinePayload(huriUri)\n\n return <DivinedPayloadContext.Provider value={{ payload, payloadError, provided: true, setPayload }}>{children}</DivinedPayloadContext.Provider>\n}\n\nexport const DivinedPayloadWithHandleInner: React.FC<WithChildren> = ({ children }) => {\n const { payloadError } = useDivinedPayload()\n\n return (\n <ErrorRender\n error={payloadError ? { message: payloadError.message, schema: ModuleErrorSchema, sources: [] } : undefined}\n errorContext=\"Divined Payload Provider\"\n >\n {children}\n </ErrorRender>\n )\n}\n\nexport const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps> = ({ children, ...props }) => {\n return (\n <DivinedPayloadProvider {...props}>\n <DivinedPayloadWithHandleInner>{children}</DivinedPayloadWithHandleInner>\n </DivinedPayloadProvider>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\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","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadState } from './State'\n\nexport const DivinedPayloadContext = createContextEx<DivinedPayloadState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadContext } from './Context'\n\nexport const useDivinedPayload = () => useContextEx(DivinedPayloadContext, 'DivinedPayload', true)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAAkC;AAClC,yBAA4B;AAC5B,gCAA6B;AAC7B,8BAA2C;;;ACJ3C,0BAAgC;AAIhC,IAAM,4BAAwB,qCAAqC;;;ACJnE,oBAAwB;AACxB,gCAA+B;AAC/B,qBAAwC;AAExC,IAAAA,uBAA6B;AAC7B,mBAA8C;AAIvC,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,CAAC,OAAO,CAAC;AAEZ;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,QAAQ,WAAW,YAAY,QAAW;AAC5C,YAAI;AACF,gBAAM,cAA2B,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,0BAAW;AACpE,gBAAM,CAACC,QAAO,IAAK,MAAM,SAAS,OAAO,CAAC,WAAW,CAAC,KAAM,CAAC;AAC7D,cAAI,QAAQ,GAAG;AACb,uBAAWA,WAAWA,WAAgB,IAAI;AAAA,UAC5C;AAAA,QACF,SAAS,IAAI;AACX,cAAI,QAAQ,GAAG;AACb,qBAAS,EAAW;AAAA,UACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,MAAM,OAAO;AAAA,EACzB;AAEA,SAAO,CAAC,SAAS,YAAY,KAAK;AACpC;;;AC/CA,IAAAC,uBAAgC;AAIzB,IAAM,4BAAwB,sCAAqC;;;ACJ1E,IAAAC,uBAA6B;AAItB,IAAM,oBAAoB,UAAM,mCAAa,uBAAuB,kBAAkB,IAAI;;;AJsBxF;AAZF,IAAM,yBAAgE,CAAC,EAAE,UAAU,KAAK,MAAM;AACnG,QAAM,EAAE,MAAM,UAAU,QAAI,mCAAU;AAEtC,QAAM,wBAAoB,wCAAa,SAAS;AAEhD,QAAM,CAAC,MAAM,QAAI,yCAAgB;AACjC,QAAM,sBAAsB,OAAO,IAAI,MAAM;AAC7C,QAAM,mBAAmB,mBAAmB,uBAAuB,EAAE;AACrE,QAAM,UAAU,SAAS,mBAAmB,mBAAmB;AAE/D,QAAM,CAAC,SAAS,YAAY,YAAY,IAAI,iBAAiB,OAAO;AAEpE,SAAO,4CAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,SAAS,cAAc,UAAU,MAAM,WAAW,GAAI,UAAS;AACjH;AAEO,IAAM,gCAAwD,CAAC,EAAE,SAAS,MAAM;AACrF,QAAM,EAAE,aAAa,IAAI,kBAAkB;AAE3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,eAAe,EAAE,SAAS,aAAa,SAAS,QAAQ,wCAAmB,SAAS,CAAC,EAAE,IAAI;AAAA,MAClG,cAAa;AAAA,MAEZ;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,mCAA0E,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACjH,SACE,4CAAC,0BAAwB,GAAG,OAC1B,sDAAC,iCAA+B,UAAS,GAC3C;AAEJ;","names":["import_react_shared","payload","import_react_shared","import_react_shared"]}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import type { WithChildren } from '@xylabs/react-shared';
3
+ export interface DivinedPayloadProviderProps extends WithChildren {
4
+ hash?: string;
5
+ }
6
+ export declare const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps>;
7
+ export declare const DivinedPayloadWithHandleInner: React.FC<WithChildren>;
8
+ export declare const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps>;
9
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAUxD,MAAM,WAAW,2BAA4B,SAAQ,YAAY;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAaxE,CAAA;AAED,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAWhE,CAAA;AAED,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAMlF,CAAA"}
@@ -0,0 +1,19 @@
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/DivinedPayload/State.ts
17
+ var State_exports = {};
18
+ module.exports = __toCommonJS(State_exports);
19
+ //# sourceMappingURL=State.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/contexts/DivinedPayload/State.ts"],"sourcesContent":["import { Payload } from '@xyo-network/payload-model'\nimport { ContextExState } from '@xyo-network/react-shared'\nimport { Dispatch } from 'react'\n\nexport interface DivinedPayloadState extends ContextExState {\n payload?: Payload | null\n payloadError?: Error\n setPayload?: Dispatch<Payload | null | undefined>\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { Payload } from '@xyo-network/payload-model';
2
+ import { ContextExState } from '@xyo-network/react-shared';
3
+ import { Dispatch } from 'react';
4
+ export interface DivinedPayloadState extends ContextExState {
5
+ payload?: Payload | null;
6
+ payloadError?: Error;
7
+ setPayload?: Dispatch<Payload | null | undefined>;
8
+ }
9
+ //# sourceMappingURL=State.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/State.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;CAClD"}
@@ -0,0 +1,115 @@
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/DivinedPayload/index.ts
21
+ var DivinedPayload_exports = {};
22
+ __export(DivinedPayload_exports, {
23
+ DivinedPayloadContext: () => DivinedPayloadContext,
24
+ DivinedPayloadProvider: () => DivinedPayloadProvider,
25
+ DivinedPayloadWithHandleInner: () => DivinedPayloadWithHandleInner,
26
+ DivinedPayloadWithHandleProvider: () => DivinedPayloadWithHandleProvider,
27
+ useDivinedPayload: () => useDivinedPayload
28
+ });
29
+ module.exports = __toCommonJS(DivinedPayload_exports);
30
+
31
+ // src/contexts/DivinedPayload/Context.tsx
32
+ var import_react_shared = require("@xyo-network/react-shared");
33
+ var DivinedPayloadContext = (0, import_react_shared.createContextEx)();
34
+
35
+ // src/contexts/DivinedPayload/Provider.tsx
36
+ var import_payload_model = require("@xyo-network/payload-model");
37
+ var import_react_error = require("@xyo-network/react-error");
38
+ var import_react_payload_huri = require("@xyo-network/react-payload-huri");
39
+ var import_react_router_dom = require("react-router-dom");
40
+
41
+ // src/contexts/PayloadDiviner/Context.ts
42
+ var import_react_shared2 = require("@xyo-network/react-shared");
43
+ var PayloadDivinerContext = (0, import_react_shared2.createContextEx)();
44
+
45
+ // src/contexts/PayloadDiviner/use.ts
46
+ var import_lodash = require("@xylabs/lodash");
47
+ var import_react_async_effect = require("@xylabs/react-async-effect");
48
+ var import_diviner = require("@xyo-network/diviner");
49
+ var import_react_shared3 = require("@xyo-network/react-shared");
50
+ var import_react = require("react");
51
+ var usePayloadDiviner = (required = false) => {
52
+ return (0, import_react_shared3.useContextEx)(PayloadDivinerContext, "PayloadDiviner", required);
53
+ };
54
+ var useDivinePayload = (huri) => {
55
+ const { diviner } = usePayloadDiviner();
56
+ const [payload, setPayload] = (0, import_react.useState)();
57
+ const [error, setError] = (0, import_react.useState)();
58
+ (0, import_react.useEffect)(() => {
59
+ if (diviner) {
60
+ setPayload(void 0);
61
+ }
62
+ }, [diviner]);
63
+ (0, import_react_async_effect.useAsyncEffect)(
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ async (mounted) => {
66
+ if (huri && diviner && payload === void 0) {
67
+ try {
68
+ const huriPayload = { huri: [huri], schema: import_diviner.HuriSchema };
69
+ const [payload2] = await diviner?.divine([huriPayload]) ?? [];
70
+ if (mounted()) {
71
+ setPayload(payload2 ? payload2 : null);
72
+ }
73
+ } catch (ex) {
74
+ if (mounted()) {
75
+ setError(ex);
76
+ }
77
+ }
78
+ }
79
+ },
80
+ [diviner, huri, payload]
81
+ );
82
+ return [payload, setPayload, error];
83
+ };
84
+
85
+ // src/contexts/DivinedPayload/use.ts
86
+ var import_react_shared4 = require("@xyo-network/react-shared");
87
+ var useDivinedPayload = () => (0, import_react_shared4.useContextEx)(DivinedPayloadContext, "DivinedPayload", true);
88
+
89
+ // src/contexts/DivinedPayload/Provider.tsx
90
+ var import_jsx_runtime = require("react/jsx-runtime");
91
+ var DivinedPayloadProvider = ({ children, hash }) => {
92
+ const { hash: hashParam } = (0, import_react_router_dom.useParams)();
93
+ const huriFromHashParam = (0, import_react_payload_huri.useBuildHuri)(hashParam);
94
+ const [params] = (0, import_react_router_dom.useSearchParams)();
95
+ const huriSearchParameter = params.get("huri");
96
+ const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
97
+ const huriUri = hash ?? (decodedHuriParam ? decodedHuriParam : huriFromHashParam);
98
+ const [payload, setPayload, payloadError] = useDivinePayload(huriUri);
99
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadContext.Provider, { value: { payload, payloadError, provided: true, setPayload }, children });
100
+ };
101
+ var DivinedPayloadWithHandleInner = ({ children }) => {
102
+ const { payloadError } = useDivinedPayload();
103
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ import_react_error.ErrorRender,
105
+ {
106
+ error: payloadError ? { message: payloadError.message, schema: import_payload_model.ModuleErrorSchema, sources: [] } : void 0,
107
+ errorContext: "Divined Payload Provider",
108
+ children
109
+ }
110
+ );
111
+ };
112
+ var DivinedPayloadWithHandleProvider = ({ children, ...props }) => {
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadProvider, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DivinedPayloadWithHandleInner, { children }) });
114
+ };
115
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/contexts/DivinedPayload/index.ts","../../../../src/contexts/DivinedPayload/Context.tsx","../../../../src/contexts/DivinedPayload/Provider.tsx","../../../../src/contexts/PayloadDiviner/Context.ts","../../../../src/contexts/PayloadDiviner/use.ts","../../../../src/contexts/DivinedPayload/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 { DivinedPayloadState } from './State'\n\nexport const DivinedPayloadContext = createContextEx<DivinedPayloadState>()\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { ErrorRender } from '@xyo-network/react-error'\nimport { useBuildHuri } from '@xyo-network/react-payload-huri'\nimport { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useDivinePayload } from '../PayloadDiviner'\nimport { DivinedPayloadContext } from './Context'\nimport { useDivinedPayload } from './use'\n\nexport interface DivinedPayloadProviderProps extends WithChildren {\n hash?: string\n}\n\nexport const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps> = ({ children, hash }) => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n const huriUri = hash ?? (decodedHuriParam ? decodedHuriParam : huriFromHashParam)\n\n const [payload, setPayload, payloadError] = useDivinePayload(huriUri)\n\n return <DivinedPayloadContext.Provider value={{ payload, payloadError, provided: true, setPayload }}>{children}</DivinedPayloadContext.Provider>\n}\n\nexport const DivinedPayloadWithHandleInner: React.FC<WithChildren> = ({ children }) => {\n const { payloadError } = useDivinedPayload()\n\n return (\n <ErrorRender\n error={payloadError ? { message: payloadError.message, schema: ModuleErrorSchema, sources: [] } : undefined}\n errorContext=\"Divined Payload Provider\"\n >\n {children}\n </ErrorRender>\n )\n}\n\nexport const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps> = ({ children, ...props }) => {\n return (\n <DivinedPayloadProvider {...props}>\n <DivinedPayloadWithHandleInner>{children}</DivinedPayloadWithHandleInner>\n </DivinedPayloadProvider>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { PayloadDivinerState } from './State'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\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","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadContext } from './Context'\n\nexport const useDivinedPayload = () => useContextEx(DivinedPayloadContext, 'DivinedPayload', true)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0BAAgC;AAIzB,IAAM,4BAAwB,qCAAqC;;;ACH1E,2BAAkC;AAClC,yBAA4B;AAC5B,gCAA6B;AAC7B,8BAA2C;;;ACJ3C,IAAAA,uBAAgC;AAIhC,IAAM,4BAAwB,sCAAqC;;;ACJnE,oBAAwB;AACxB,gCAA+B;AAC/B,qBAAwC;AAExC,IAAAC,uBAA6B;AAC7B,mBAA8C;AAIvC,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,CAAC,OAAO,CAAC;AAEZ;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,QAAQ,WAAW,YAAY,QAAW;AAC5C,YAAI;AACF,gBAAM,cAA2B,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,0BAAW;AACpE,gBAAM,CAACC,QAAO,IAAK,MAAM,SAAS,OAAO,CAAC,WAAW,CAAC,KAAM,CAAC;AAC7D,cAAI,QAAQ,GAAG;AACb,uBAAWA,WAAWA,WAAgB,IAAI;AAAA,UAC5C;AAAA,QACF,SAAS,IAAI;AACX,cAAI,QAAQ,GAAG;AACb,qBAAS,EAAW;AAAA,UACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,MAAM,OAAO;AAAA,EACzB;AAEA,SAAO,CAAC,SAAS,YAAY,KAAK;AACpC;;;AC/CA,IAAAC,uBAA6B;AAItB,IAAM,oBAAoB,UAAM,mCAAa,uBAAuB,kBAAkB,IAAI;;;AHsBxF;AAZF,IAAM,yBAAgE,CAAC,EAAE,UAAU,KAAK,MAAM;AACnG,QAAM,EAAE,MAAM,UAAU,QAAI,mCAAU;AAEtC,QAAM,wBAAoB,wCAAa,SAAS;AAEhD,QAAM,CAAC,MAAM,QAAI,yCAAgB;AACjC,QAAM,sBAAsB,OAAO,IAAI,MAAM;AAC7C,QAAM,mBAAmB,mBAAmB,uBAAuB,EAAE;AACrE,QAAM,UAAU,SAAS,mBAAmB,mBAAmB;AAE/D,QAAM,CAAC,SAAS,YAAY,YAAY,IAAI,iBAAiB,OAAO;AAEpE,SAAO,4CAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,SAAS,cAAc,UAAU,MAAM,WAAW,GAAI,UAAS;AACjH;AAEO,IAAM,gCAAwD,CAAC,EAAE,SAAS,MAAM;AACrF,QAAM,EAAE,aAAa,IAAI,kBAAkB;AAE3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,eAAe,EAAE,SAAS,aAAa,SAAS,QAAQ,wCAAmB,SAAS,CAAC,EAAE,IAAI;AAAA,MAClG,cAAa;AAAA,MAEZ;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,mCAA0E,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACjH,SACE,4CAAC,0BAAwB,GAAG,OAC1B,sDAAC,iCAA+B,UAAS,GAC3C;AAEJ;","names":["import_react_shared","import_react_shared","payload","import_react_shared"]}
@@ -0,0 +1,5 @@
1
+ export * from './Context';
2
+ export * from './Provider';
3
+ export * from './State';
4
+ export * from './use';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
@@ -0,0 +1,34 @@
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/DivinedPayload/use.ts
21
+ var use_exports = {};
22
+ __export(use_exports, {
23
+ useDivinedPayload: () => useDivinedPayload
24
+ });
25
+ module.exports = __toCommonJS(use_exports);
26
+ var import_react_shared2 = require("@xyo-network/react-shared");
27
+
28
+ // src/contexts/DivinedPayload/Context.tsx
29
+ var import_react_shared = require("@xyo-network/react-shared");
30
+ var DivinedPayloadContext = (0, import_react_shared.createContextEx)();
31
+
32
+ // src/contexts/DivinedPayload/use.ts
33
+ var useDivinedPayload = () => (0, import_react_shared2.useContextEx)(DivinedPayloadContext, "DivinedPayload", true);
34
+ //# sourceMappingURL=use.cjs.map
@@ -0,0 +1 @@
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;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,uBAA6B;;;ACA7B,0BAAgC;AAIzB,IAAM,4BAAwB,qCAAqC;;;ADAnE,IAAM,oBAAoB,UAAM,mCAAa,uBAAuB,kBAAkB,IAAI;","names":["import_react_shared"]}
@@ -0,0 +1,2 @@
1
+ export declare const useDivinedPayload: () => Omit<import("./State").DivinedPayloadState & import("@xyo-network/react-shared").ContextExState, "provided">;
2
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,oHAAoE,CAAA"}
@@ -0,0 +1,28 @@
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
+ //# sourceMappingURL=Context.cjs.map
@@ -1 +1 @@
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,MAAM,wBAAwB,gBAAqC;","names":[]}
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":[]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { PayloadDivinerState } from './State';
3
+ declare const PayloadDivinerContext: import("react").Context<PayloadDivinerState & import("@xyo-network/react-shared").ContextExState>;
4
+ export { PayloadDivinerContext };
5
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/PayloadDiviner/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE7C,QAAA,MAAM,qBAAqB,mGAAyC,CAAA;AAEpE,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,53 @@
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
+ //# sourceMappingURL=Provider.cjs.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { AbstractPayloadDiviner } from '@xyo-network/diviner';
3
+ import { ContextExProviderProps } from '@xyo-network/react-shared';
4
+ export type PayloadDivinerProviderProps = ContextExProviderProps<{
5
+ /** Required */
6
+ diviner?: AbstractPayloadDiviner;
7
+ }>;
8
+ export declare const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps>;
9
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/PayloadDiviner/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAKlE,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;IAC/D,eAAe;IACf,OAAO,CAAC,EAAE,sBAAsB,CAAA;CACjC,CAAC,CAAA;AAEF,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAoBxE,CAAA"}
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,7 @@
1
+ import { AbstractPayloadDiviner } from '@xyo-network/diviner';
2
+ import { Dispatch } from 'react';
3
+ export interface PayloadDivinerState {
4
+ diviner?: AbstractPayloadDiviner;
5
+ setDiviner?: Dispatch<AbstractPayloadDiviner>;
6
+ }
7
+ //# sourceMappingURL=State.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/PayloadDiviner/State.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,UAAU,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAA;CAC9C"}