@xyo-network/react-payload-diviner 2.81.10 → 2.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +47 -2
- package/dist/browser/index.mjs +201 -0
- package/dist/browser/index.mjs.map +1 -0
- package/package.json +18 -34
- package/src/contexts/DivinedPayload/{Context.tsx → Context.ts} +1 -1
- package/src/contexts/DivinedPayload/Provider.tsx +5 -3
- package/src/contexts/DivinedPayload/index.ts +4 -4
- package/src/contexts/DivinedPayload/use.ts +1 -1
- package/src/contexts/PayloadDiviner/Context.ts +1 -1
- package/src/contexts/PayloadDiviner/Provider.tsx +10 -12
- package/src/contexts/PayloadDiviner/index.ts +4 -4
- package/src/contexts/PayloadDiviner/use.ts +5 -7
- package/src/contexts/index.ts +2 -2
- package/src/index.ts +1 -1
- package/xy.config.ts +12 -0
- package/dist/browser/contexts/DivinedPayload/Context.d.cts +0 -3
- package/dist/browser/contexts/DivinedPayload/Context.d.cts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/Context.d.mts +0 -3
- package/dist/browser/contexts/DivinedPayload/Context.d.mts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/Context.d.ts +0 -3
- package/dist/browser/contexts/DivinedPayload/Context.d.ts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/Provider.d.cts +0 -8
- package/dist/browser/contexts/DivinedPayload/Provider.d.cts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/Provider.d.mts +0 -8
- package/dist/browser/contexts/DivinedPayload/Provider.d.mts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/Provider.d.ts +0 -8
- package/dist/browser/contexts/DivinedPayload/Provider.d.ts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/State.d.cts +0 -9
- package/dist/browser/contexts/DivinedPayload/State.d.cts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/State.d.mts +0 -9
- package/dist/browser/contexts/DivinedPayload/State.d.mts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/State.d.ts +0 -9
- package/dist/browser/contexts/DivinedPayload/State.d.ts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/index.d.cts +0 -5
- package/dist/browser/contexts/DivinedPayload/index.d.cts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/index.d.mts +0 -5
- package/dist/browser/contexts/DivinedPayload/index.d.mts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/index.d.ts +0 -5
- package/dist/browser/contexts/DivinedPayload/index.d.ts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/use.d.cts +0 -2
- package/dist/browser/contexts/DivinedPayload/use.d.cts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/use.d.mts +0 -2
- package/dist/browser/contexts/DivinedPayload/use.d.mts.map +0 -1
- package/dist/browser/contexts/DivinedPayload/use.d.ts +0 -2
- package/dist/browser/contexts/DivinedPayload/use.d.ts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Context.d.cts +0 -4
- package/dist/browser/contexts/PayloadDiviner/Context.d.cts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Context.d.mts +0 -4
- package/dist/browser/contexts/PayloadDiviner/Context.d.mts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Context.d.ts +0 -4
- package/dist/browser/contexts/PayloadDiviner/Context.d.ts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Provider.d.cts +0 -7
- package/dist/browser/contexts/PayloadDiviner/Provider.d.cts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Provider.d.mts +0 -7
- package/dist/browser/contexts/PayloadDiviner/Provider.d.mts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/Provider.d.ts +0 -7
- package/dist/browser/contexts/PayloadDiviner/Provider.d.ts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/State.d.cts +0 -7
- package/dist/browser/contexts/PayloadDiviner/State.d.cts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/State.d.mts +0 -7
- package/dist/browser/contexts/PayloadDiviner/State.d.mts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/State.d.ts +0 -7
- package/dist/browser/contexts/PayloadDiviner/State.d.ts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/index.d.cts +0 -5
- package/dist/browser/contexts/PayloadDiviner/index.d.cts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/index.d.mts +0 -5
- package/dist/browser/contexts/PayloadDiviner/index.d.mts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/index.d.ts +0 -5
- package/dist/browser/contexts/PayloadDiviner/index.d.ts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/use.d.cts +0 -10
- package/dist/browser/contexts/PayloadDiviner/use.d.cts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/use.d.mts +0 -10
- package/dist/browser/contexts/PayloadDiviner/use.d.mts.map +0 -1
- package/dist/browser/contexts/PayloadDiviner/use.d.ts +0 -10
- package/dist/browser/contexts/PayloadDiviner/use.d.ts.map +0 -1
- package/dist/browser/contexts/index.d.cts +0 -3
- package/dist/browser/contexts/index.d.cts.map +0 -1
- package/dist/browser/contexts/index.d.mts +0 -3
- package/dist/browser/contexts/index.d.mts.map +0 -1
- package/dist/browser/contexts/index.d.ts +0 -3
- package/dist/browser/contexts/index.d.ts.map +0 -1
- package/dist/browser/index.cjs +0 -184
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.d.cts +0 -2
- package/dist/browser/index.d.cts.map +0 -1
- package/dist/browser/index.d.mts +0 -2
- package/dist/browser/index.d.mts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -161
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Context.d.cts +0 -3
- package/dist/neutral/contexts/DivinedPayload/Context.d.cts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Context.d.mts +0 -3
- package/dist/neutral/contexts/DivinedPayload/Context.d.mts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Context.d.ts +0 -3
- package/dist/neutral/contexts/DivinedPayload/Context.d.ts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Provider.d.cts +0 -8
- package/dist/neutral/contexts/DivinedPayload/Provider.d.cts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Provider.d.mts +0 -8
- package/dist/neutral/contexts/DivinedPayload/Provider.d.mts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/Provider.d.ts +0 -8
- package/dist/neutral/contexts/DivinedPayload/Provider.d.ts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/State.d.cts +0 -9
- package/dist/neutral/contexts/DivinedPayload/State.d.cts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/State.d.mts +0 -9
- package/dist/neutral/contexts/DivinedPayload/State.d.mts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/State.d.ts +0 -9
- package/dist/neutral/contexts/DivinedPayload/State.d.ts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/index.d.cts +0 -5
- package/dist/neutral/contexts/DivinedPayload/index.d.cts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/index.d.mts +0 -5
- package/dist/neutral/contexts/DivinedPayload/index.d.mts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/index.d.ts +0 -5
- package/dist/neutral/contexts/DivinedPayload/index.d.ts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/use.d.cts +0 -2
- package/dist/neutral/contexts/DivinedPayload/use.d.cts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/use.d.mts +0 -2
- package/dist/neutral/contexts/DivinedPayload/use.d.mts.map +0 -1
- package/dist/neutral/contexts/DivinedPayload/use.d.ts +0 -2
- package/dist/neutral/contexts/DivinedPayload/use.d.ts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Context.d.cts +0 -4
- package/dist/neutral/contexts/PayloadDiviner/Context.d.cts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Context.d.mts +0 -4
- package/dist/neutral/contexts/PayloadDiviner/Context.d.mts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Context.d.ts +0 -4
- package/dist/neutral/contexts/PayloadDiviner/Context.d.ts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.cts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.cts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.mts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.mts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.ts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/Provider.d.ts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/State.d.cts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/State.d.cts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/State.d.mts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/State.d.mts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/State.d.ts +0 -7
- package/dist/neutral/contexts/PayloadDiviner/State.d.ts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/index.d.cts +0 -5
- package/dist/neutral/contexts/PayloadDiviner/index.d.cts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/index.d.mts +0 -5
- package/dist/neutral/contexts/PayloadDiviner/index.d.mts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/index.d.ts +0 -5
- package/dist/neutral/contexts/PayloadDiviner/index.d.ts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/use.d.cts +0 -10
- package/dist/neutral/contexts/PayloadDiviner/use.d.cts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/use.d.mts +0 -10
- package/dist/neutral/contexts/PayloadDiviner/use.d.mts.map +0 -1
- package/dist/neutral/contexts/PayloadDiviner/use.d.ts +0 -10
- package/dist/neutral/contexts/PayloadDiviner/use.d.ts.map +0 -1
- package/dist/neutral/contexts/index.d.cts +0 -3
- package/dist/neutral/contexts/index.d.cts.map +0 -1
- package/dist/neutral/contexts/index.d.mts +0 -3
- package/dist/neutral/contexts/index.d.mts.map +0 -1
- package/dist/neutral/contexts/index.d.ts +0 -3
- package/dist/neutral/contexts/index.d.ts.map +0 -1
- package/dist/neutral/index.cjs +0 -184
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.d.cts +0 -2
- package/dist/neutral/index.d.cts.map +0 -1
- package/dist/neutral/index.d.mts +0 -2
- package/dist/neutral/index.d.mts.map +0 -1
- package/dist/neutral/index.d.ts +0 -2
- package/dist/neutral/index.d.ts.map +0 -1
- package/dist/neutral/index.js +0 -161
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/contexts/DivinedPayload/Context.d.cts +0 -3
- package/dist/node/contexts/DivinedPayload/Context.d.cts.map +0 -1
- package/dist/node/contexts/DivinedPayload/Context.d.mts +0 -3
- package/dist/node/contexts/DivinedPayload/Context.d.mts.map +0 -1
- package/dist/node/contexts/DivinedPayload/Context.d.ts +0 -3
- package/dist/node/contexts/DivinedPayload/Context.d.ts.map +0 -1
- package/dist/node/contexts/DivinedPayload/Provider.d.cts +0 -8
- package/dist/node/contexts/DivinedPayload/Provider.d.cts.map +0 -1
- package/dist/node/contexts/DivinedPayload/Provider.d.mts +0 -8
- package/dist/node/contexts/DivinedPayload/Provider.d.mts.map +0 -1
- package/dist/node/contexts/DivinedPayload/Provider.d.ts +0 -8
- package/dist/node/contexts/DivinedPayload/Provider.d.ts.map +0 -1
- package/dist/node/contexts/DivinedPayload/State.d.cts +0 -9
- package/dist/node/contexts/DivinedPayload/State.d.cts.map +0 -1
- package/dist/node/contexts/DivinedPayload/State.d.mts +0 -9
- package/dist/node/contexts/DivinedPayload/State.d.mts.map +0 -1
- package/dist/node/contexts/DivinedPayload/State.d.ts +0 -9
- package/dist/node/contexts/DivinedPayload/State.d.ts.map +0 -1
- package/dist/node/contexts/DivinedPayload/index.d.cts +0 -5
- package/dist/node/contexts/DivinedPayload/index.d.cts.map +0 -1
- package/dist/node/contexts/DivinedPayload/index.d.mts +0 -5
- package/dist/node/contexts/DivinedPayload/index.d.mts.map +0 -1
- package/dist/node/contexts/DivinedPayload/index.d.ts +0 -5
- package/dist/node/contexts/DivinedPayload/index.d.ts.map +0 -1
- package/dist/node/contexts/DivinedPayload/use.d.cts +0 -2
- package/dist/node/contexts/DivinedPayload/use.d.cts.map +0 -1
- package/dist/node/contexts/DivinedPayload/use.d.mts +0 -2
- package/dist/node/contexts/DivinedPayload/use.d.mts.map +0 -1
- package/dist/node/contexts/DivinedPayload/use.d.ts +0 -2
- package/dist/node/contexts/DivinedPayload/use.d.ts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Context.d.cts +0 -4
- package/dist/node/contexts/PayloadDiviner/Context.d.cts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Context.d.mts +0 -4
- package/dist/node/contexts/PayloadDiviner/Context.d.mts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Context.d.ts +0 -4
- package/dist/node/contexts/PayloadDiviner/Context.d.ts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Provider.d.cts +0 -7
- package/dist/node/contexts/PayloadDiviner/Provider.d.cts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Provider.d.mts +0 -7
- package/dist/node/contexts/PayloadDiviner/Provider.d.mts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/Provider.d.ts +0 -7
- package/dist/node/contexts/PayloadDiviner/Provider.d.ts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/State.d.cts +0 -7
- package/dist/node/contexts/PayloadDiviner/State.d.cts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/State.d.mts +0 -7
- package/dist/node/contexts/PayloadDiviner/State.d.mts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/State.d.ts +0 -7
- package/dist/node/contexts/PayloadDiviner/State.d.ts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/index.d.cts +0 -5
- package/dist/node/contexts/PayloadDiviner/index.d.cts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/index.d.mts +0 -5
- package/dist/node/contexts/PayloadDiviner/index.d.mts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/index.d.ts +0 -5
- package/dist/node/contexts/PayloadDiviner/index.d.ts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/use.d.cts +0 -10
- package/dist/node/contexts/PayloadDiviner/use.d.cts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/use.d.mts +0 -10
- package/dist/node/contexts/PayloadDiviner/use.d.mts.map +0 -1
- package/dist/node/contexts/PayloadDiviner/use.d.ts +0 -10
- package/dist/node/contexts/PayloadDiviner/use.d.ts.map +0 -1
- package/dist/node/contexts/index.d.cts +0 -3
- package/dist/node/contexts/index.d.cts.map +0 -1
- package/dist/node/contexts/index.d.mts +0 -3
- package/dist/node/contexts/index.d.mts.map +0 -1
- package/dist/node/contexts/index.d.ts +0 -3
- package/dist/node/contexts/index.d.ts.map +0 -1
- package/dist/node/index.cjs +0 -197
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -2
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.mts +0 -2
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -161
- package/dist/node/index.js.map +0 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,2 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { Dispatch } from 'react';
|
|
3
|
+
import * as _xyo_network_react_shared from '@xyo-network/react-shared';
|
|
4
|
+
import { ContextExState, ContextExProviderProps } from '@xyo-network/react-shared';
|
|
5
|
+
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
6
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
7
|
+
import { WithChildren } from '@xylabs/react-shared';
|
|
8
|
+
import { PayloadDiviner } from '@xyo-network/diviner-payload-abstract';
|
|
9
|
+
|
|
10
|
+
interface DivinedPayloadState extends ContextExState {
|
|
11
|
+
payload?: Payload | null;
|
|
12
|
+
payloadError?: Error;
|
|
13
|
+
setPayload?: Dispatch<Payload | null | undefined>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const DivinedPayloadContext: React.Context<DivinedPayloadState & _xyo_network_react_shared.ContextExState>;
|
|
17
|
+
|
|
18
|
+
interface DivinedPayloadProviderProps extends WithChildren {
|
|
19
|
+
hash?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const DivinedPayloadProvider: React__default.FC<DivinedPayloadProviderProps>;
|
|
22
|
+
declare const DivinedPayloadWithHandleInner: React__default.FC<WithChildren>;
|
|
23
|
+
declare const DivinedPayloadWithHandleProvider: React__default.FC<DivinedPayloadProviderProps>;
|
|
24
|
+
|
|
25
|
+
declare const useDivinedPayload: () => Omit<DivinedPayloadState & _xyo_network_react_shared.ContextExState, "provided">;
|
|
26
|
+
|
|
27
|
+
interface PayloadDivinerState {
|
|
28
|
+
diviner?: PayloadDiviner;
|
|
29
|
+
setDiviner?: Dispatch<PayloadDiviner>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare const PayloadDivinerContext: React.Context<PayloadDivinerState & _xyo_network_react_shared.ContextExState>;
|
|
33
|
+
|
|
34
|
+
type PayloadDivinerProviderProps = ContextExProviderProps<{
|
|
35
|
+
diviner?: PayloadDiviner;
|
|
36
|
+
}>;
|
|
37
|
+
declare const PayloadDivinerProvider: React__default.FC<PayloadDivinerProviderProps>;
|
|
38
|
+
|
|
39
|
+
declare const usePayloadDiviner: (required?: boolean) => Omit<PayloadDivinerState & _xyo_network_react_shared.ContextExState, "provided">;
|
|
40
|
+
declare const useDivinePayload: <T extends Payload = {
|
|
41
|
+
schema: string;
|
|
42
|
+
} & _xyo_network_payload_model.PayloadFields>(huri?: string) => [T | undefined | null, Dispatch<T | null | undefined>, Error | undefined];
|
|
43
|
+
declare const useDivinePayloads: <T extends Payload = {
|
|
44
|
+
schema: string;
|
|
45
|
+
} & _xyo_network_payload_model.PayloadFields>(huriList: string[]) => [(T | null)[] | undefined, Dispatch<(T | null)[] | undefined>, Error[] | undefined];
|
|
46
|
+
|
|
47
|
+
export { DivinedPayloadContext, DivinedPayloadProvider, type DivinedPayloadProviderProps, type DivinedPayloadState, DivinedPayloadWithHandleInner, DivinedPayloadWithHandleProvider, PayloadDivinerContext, PayloadDivinerProvider, type PayloadDivinerProviderProps, type PayloadDivinerState, useDivinePayload, useDivinePayloads, useDivinedPayload, usePayloadDiviner };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/contexts/DivinedPayload/Context.ts
|
|
5
|
+
import { createContextEx } from "@xyo-network/react-shared";
|
|
6
|
+
var DivinedPayloadContext = createContextEx();
|
|
7
|
+
|
|
8
|
+
// src/contexts/DivinedPayload/Provider.tsx
|
|
9
|
+
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
|
10
|
+
import { ErrorRender } from "@xyo-network/react-error";
|
|
11
|
+
import { useBuildHuri } from "@xyo-network/react-payload-huri";
|
|
12
|
+
import React2 from "react";
|
|
13
|
+
import { useParams, useSearchParams } from "react-router-dom";
|
|
14
|
+
|
|
15
|
+
// src/contexts/PayloadDiviner/Context.ts
|
|
16
|
+
import { createContextEx as createContextEx2 } from "@xyo-network/react-shared";
|
|
17
|
+
var PayloadDivinerContext = createContextEx2();
|
|
18
|
+
|
|
19
|
+
// src/contexts/PayloadDiviner/Provider.tsx
|
|
20
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
21
|
+
var PayloadDivinerProvider = /* @__PURE__ */ __name(({ diviner: divinerProp, required = false, children }) => {
|
|
22
|
+
const [diviner, setDiviner] = useState(divinerProp);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (divinerProp) {
|
|
25
|
+
setDiviner(divinerProp);
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
divinerProp
|
|
29
|
+
]);
|
|
30
|
+
const value = useMemo(() => ({
|
|
31
|
+
diviner: diviner === divinerProp ? diviner : void 0,
|
|
32
|
+
provided: true,
|
|
33
|
+
setDiviner
|
|
34
|
+
}), [
|
|
35
|
+
diviner,
|
|
36
|
+
divinerProp,
|
|
37
|
+
setDiviner
|
|
38
|
+
]);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(PayloadDivinerContext.Provider, {
|
|
40
|
+
value
|
|
41
|
+
}, diviner ? children : required ? null : children);
|
|
42
|
+
}, "PayloadDivinerProvider");
|
|
43
|
+
|
|
44
|
+
// src/contexts/PayloadDiviner/use.ts
|
|
45
|
+
import { compact } from "@xylabs/lodash";
|
|
46
|
+
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
47
|
+
import { HuriSchema } from "@xyo-network/diviner-huri";
|
|
48
|
+
import { useContextEx } from "@xyo-network/react-shared";
|
|
49
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
50
|
+
var usePayloadDiviner = /* @__PURE__ */ __name((required = false) => {
|
|
51
|
+
return useContextEx(PayloadDivinerContext, "PayloadDiviner", required);
|
|
52
|
+
}, "usePayloadDiviner");
|
|
53
|
+
var useDivinePayload = /* @__PURE__ */ __name((huri) => {
|
|
54
|
+
const { diviner } = usePayloadDiviner();
|
|
55
|
+
const [payload, setPayload] = useState2();
|
|
56
|
+
const [error, setError] = useState2();
|
|
57
|
+
useEffect2(() => {
|
|
58
|
+
if (diviner) {
|
|
59
|
+
setPayload(void 0);
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
diviner
|
|
63
|
+
]);
|
|
64
|
+
useAsyncEffect(async (mounted) => {
|
|
65
|
+
if (huri && diviner && payload === void 0) {
|
|
66
|
+
try {
|
|
67
|
+
const huriPayload = {
|
|
68
|
+
huri: [
|
|
69
|
+
huri
|
|
70
|
+
],
|
|
71
|
+
schema: HuriSchema
|
|
72
|
+
};
|
|
73
|
+
const [payload2] = await diviner?.divine([
|
|
74
|
+
huriPayload
|
|
75
|
+
]) ?? [];
|
|
76
|
+
if (mounted()) {
|
|
77
|
+
setPayload(payload2 ? payload2 : null);
|
|
78
|
+
}
|
|
79
|
+
} catch (ex) {
|
|
80
|
+
if (mounted()) {
|
|
81
|
+
setError(ex);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
diviner,
|
|
87
|
+
huri,
|
|
88
|
+
payload
|
|
89
|
+
]);
|
|
90
|
+
return [
|
|
91
|
+
payload,
|
|
92
|
+
setPayload,
|
|
93
|
+
error
|
|
94
|
+
];
|
|
95
|
+
}, "useDivinePayload");
|
|
96
|
+
var useDivinePayloads = /* @__PURE__ */ __name((huriList) => {
|
|
97
|
+
const { diviner } = usePayloadDiviner();
|
|
98
|
+
const [payloads, setPayloads] = useState2();
|
|
99
|
+
const [errors, setErrors] = useState2();
|
|
100
|
+
useEffect2(() => {
|
|
101
|
+
if (diviner) {
|
|
102
|
+
setPayloads(void 0);
|
|
103
|
+
}
|
|
104
|
+
}, [
|
|
105
|
+
diviner
|
|
106
|
+
]);
|
|
107
|
+
useAsyncEffect(async (mounted) => {
|
|
108
|
+
console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`);
|
|
109
|
+
const payloads2 = await Promise.allSettled(huriList.map(async (huri) => {
|
|
110
|
+
const huriPayload = {
|
|
111
|
+
huri: [
|
|
112
|
+
huri
|
|
113
|
+
],
|
|
114
|
+
schema: HuriSchema
|
|
115
|
+
};
|
|
116
|
+
const [payload] = await diviner?.divine([
|
|
117
|
+
huriPayload
|
|
118
|
+
]) ?? [];
|
|
119
|
+
return payload;
|
|
120
|
+
}));
|
|
121
|
+
if (mounted()) {
|
|
122
|
+
setPayloads([
|
|
123
|
+
...payloads2.values()
|
|
124
|
+
].map((value) => value.status === "rejected" ? null : value.value));
|
|
125
|
+
setErrors(compact([
|
|
126
|
+
...payloads2.values()
|
|
127
|
+
].map((value) => value.status === "rejected" ? new Error("divine failed", {
|
|
128
|
+
cause: value.reason
|
|
129
|
+
}) : void 0)));
|
|
130
|
+
if (mounted()) {
|
|
131
|
+
setPayloads([
|
|
132
|
+
...payloads2.values()
|
|
133
|
+
].map((value) => value.status === "rejected" ? null : value.value));
|
|
134
|
+
setErrors(compact([
|
|
135
|
+
...payloads2.values()
|
|
136
|
+
].map((value) => value.status === "rejected" ? new Error("divine failed", {
|
|
137
|
+
cause: value.reason
|
|
138
|
+
}) : void 0)));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, [
|
|
142
|
+
diviner,
|
|
143
|
+
huriList,
|
|
144
|
+
payloads
|
|
145
|
+
]);
|
|
146
|
+
return [
|
|
147
|
+
payloads,
|
|
148
|
+
setPayloads,
|
|
149
|
+
errors
|
|
150
|
+
];
|
|
151
|
+
}, "useDivinePayloads");
|
|
152
|
+
|
|
153
|
+
// src/contexts/DivinedPayload/use.ts
|
|
154
|
+
import { useContextEx as useContextEx2 } from "@xyo-network/react-shared";
|
|
155
|
+
var useDivinedPayload = /* @__PURE__ */ __name(() => useContextEx2(DivinedPayloadContext, "DivinedPayload", true), "useDivinedPayload");
|
|
156
|
+
|
|
157
|
+
// src/contexts/DivinedPayload/Provider.tsx
|
|
158
|
+
var DivinedPayloadProvider = /* @__PURE__ */ __name(({ children, hash }) => {
|
|
159
|
+
const { hash: hashParam } = useParams();
|
|
160
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
161
|
+
const [params] = useSearchParams();
|
|
162
|
+
const huriSearchParameter = params.get("huri");
|
|
163
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
164
|
+
const huriUri = hash ?? decodedHuriParam ?? huriFromHashParam;
|
|
165
|
+
const [payload, setPayload, payloadError] = useDivinePayload(huriUri);
|
|
166
|
+
return /* @__PURE__ */ React2.createElement(DivinedPayloadContext.Provider, {
|
|
167
|
+
value: {
|
|
168
|
+
payload,
|
|
169
|
+
payloadError,
|
|
170
|
+
provided: true,
|
|
171
|
+
setPayload
|
|
172
|
+
}
|
|
173
|
+
}, children);
|
|
174
|
+
}, "DivinedPayloadProvider");
|
|
175
|
+
var DivinedPayloadWithHandleInner = /* @__PURE__ */ __name(({ children }) => {
|
|
176
|
+
const { payloadError } = useDivinedPayload();
|
|
177
|
+
return /* @__PURE__ */ React2.createElement(ErrorRender, {
|
|
178
|
+
error: payloadError ? {
|
|
179
|
+
message: payloadError.message,
|
|
180
|
+
schema: ModuleErrorSchema,
|
|
181
|
+
sources: []
|
|
182
|
+
} : void 0,
|
|
183
|
+
errorContext: "Divined Payload Provider"
|
|
184
|
+
}, children);
|
|
185
|
+
}, "DivinedPayloadWithHandleInner");
|
|
186
|
+
var DivinedPayloadWithHandleProvider = /* @__PURE__ */ __name(({ children, ...props }) => {
|
|
187
|
+
return /* @__PURE__ */ React2.createElement(DivinedPayloadProvider, props, /* @__PURE__ */ React2.createElement(DivinedPayloadWithHandleInner, null, children));
|
|
188
|
+
}, "DivinedPayloadWithHandleProvider");
|
|
189
|
+
export {
|
|
190
|
+
DivinedPayloadContext,
|
|
191
|
+
DivinedPayloadProvider,
|
|
192
|
+
DivinedPayloadWithHandleInner,
|
|
193
|
+
DivinedPayloadWithHandleProvider,
|
|
194
|
+
PayloadDivinerContext,
|
|
195
|
+
PayloadDivinerProvider,
|
|
196
|
+
useDivinePayload,
|
|
197
|
+
useDivinePayloads,
|
|
198
|
+
useDivinedPayload,
|
|
199
|
+
usePayloadDiviner
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/DivinedPayload/Context.ts","../../src/contexts/DivinedPayload/Provider.tsx","../../src/contexts/PayloadDiviner/Context.ts","../../src/contexts/PayloadDiviner/Provider.tsx","../../src/contexts/PayloadDiviner/use.ts","../../src/contexts/DivinedPayload/use.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { DivinedPayloadState } from './State.ts'\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 React from 'react'\nimport { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useDivinePayload } from '../PayloadDiviner/index.ts'\nimport { DivinedPayloadContext } from './Context.ts'\nimport { useDivinedPayload } from './use.ts'\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 ?? huriFromHashParam\n\n const [payload, setPayload, payloadError] = useDivinePayload(huriUri)\n\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\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.ts'\n\nconst PayloadDivinerContext = createContextEx<PayloadDivinerState>()\n\nexport { PayloadDivinerContext }\n","import { PayloadDiviner } from '@xyo-network/diviner-payload-abstract'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context.ts'\n\nexport type PayloadDivinerProviderProps = ContextExProviderProps<{\n /** Required */\n diviner?: PayloadDiviner\n}>\n\nexport const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({ diviner: divinerProp, required = false, children }) => {\n const [diviner, setDiviner] = useState<PayloadDiviner | undefined>(divinerProp)\n\n useEffect(() => {\n if (divinerProp) {\n setDiviner(divinerProp)\n }\n }, [divinerProp])\n\n const value = useMemo(() => ({ diviner: diviner === divinerProp ? diviner : undefined, provided: true, setDiviner }), [diviner, divinerProp, setDiviner])\n\n return (\n <PayloadDivinerContext.Provider\n value={value}\n >\n {diviner\n ? children\n : required\n ? null\n : 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-huri'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\nimport { useContextEx } from '@xyo-network/react-shared'\nimport { Dispatch, useEffect, useState } from 'react'\n\nimport { PayloadDivinerContext } from './Context.ts'\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 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 WithMeta<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 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(\n [...payloads.values()].map(value => (value.status === 'rejected' ? new Error('divine failed', { cause: value.reason }) : undefined)),\n ),\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' ? new 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.ts'\n\nexport const useDivinedPayload = () => useContextEx(DivinedPayloadContext, 'DivinedPayload', true)\n"],"mappings":";;;;AAAA,SAASA,uBAAuB;AAIzB,IAAMC,wBAAwBD,gBAAAA;;;ACHrC,SAASE,yBAAyB;AAClC,SAASC,mBAAmB;AAC5B,SAASC,o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S,CAAA;IAAG,IAAIC;IAClGC,cAAa;KAEZ/B,QAAAA;AAGP,GAXqE;AAa9D,IAAMgC,mCAA0E,wBAAC,EAAEhC,UAAU,GAAGiC,MAAAA,MAAO;AAC5G,SACE,gBAAAhB,OAAA,cAAClB,wBAA2BkC,OAC1B,gBAAAhB,OAAA,cAACK,+BAAAA,MAA+BtB,QAAAA,CAAAA;AAGtC,GANuF;","names":["createContextEx","DivinedPayloadContext","ModuleErrorSchema","ErrorRender","useBuildHuri","React","useParams","useSearchParams","createContextEx","PayloadDivinerContext","React","useEffect","useMemo","useState","PayloadDivinerProvider","diviner","divinerProp","required","children","setDiviner","useState","useEffect","value","useMemo","undefined","provided","PayloadDivinerContext","Provider","compact","useAsyncEffect","HuriSchema","useContextEx","useEffect","useState","usePayloadDiviner","required","useContextEx","PayloadDivinerContext","useDivinePayload","huri","diviner","payload","setPayload","useState","error","setError","useEffect","undefined","useAsyncEffect","mounted","huriPayload","schema","HuriSchema","divine","ex","useDivinePayloads","huriList","payloads","setPayloads","errors","setErrors","console","log","JSON","stringify","Promise","allSettled","map","values","value","status","compact","Error","cause","reason","useContextEx","useDivinedPayload","useContextEx","DivinedPayloadContext","DivinedPayloadProvider","children","hash","hashParam","useParams","huriFromHashParam","useBuildHuri","params","useSearchParams","huriSearchParameter","get","decodedHuriParam","decodeURIComponent","huriUri","payload","setPayload","payloadError","useDivinePayload","React","DivinedPayloadContext","Provider","value","provided","DivinedPayloadWithHandleInner","useDivinedPayload","ErrorRender","error","message","schema","ModuleErrorSchema","sources","undefined","errorContext","DivinedPayloadWithHandleProvider","props"]}
|
package/package.json
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/lodash": "^3.6.
|
|
14
|
-
"@xylabs/react-async-effect": "^3.4.
|
|
15
|
-
"@xylabs/react-shared": "^3.4.
|
|
16
|
-
"@xyo-network/diviner-huri": "^2.
|
|
17
|
-
"@xyo-network/diviner-payload-abstract": "^2.
|
|
18
|
-
"@xyo-network/payload-model": "^2.
|
|
19
|
-
"@xyo-network/react-error": "^2.
|
|
20
|
-
"@xyo-network/react-payload-huri": "^2.
|
|
21
|
-
"@xyo-network/react-shared": "^2.
|
|
22
|
-
"react-router-dom": "^6.
|
|
13
|
+
"@xylabs/lodash": "^3.6.12",
|
|
14
|
+
"@xylabs/react-async-effect": "^3.4.2",
|
|
15
|
+
"@xylabs/react-shared": "^3.4.2",
|
|
16
|
+
"@xyo-network/diviner-huri": "^2.111.3",
|
|
17
|
+
"@xyo-network/diviner-payload-abstract": "^2.111.3",
|
|
18
|
+
"@xyo-network/payload-model": "^2.111.3",
|
|
19
|
+
"@xyo-network/react-error": "^2.83.0",
|
|
20
|
+
"@xyo-network/react-payload-huri": "^2.83.0",
|
|
21
|
+
"@xyo-network/react-shared": "^2.83.0",
|
|
22
|
+
"react-router-dom": "^6.26.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
25
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.7",
|
|
26
26
|
"typescript": "^5.5.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -36,32 +36,16 @@
|
|
|
36
36
|
"docs": "dist/docs.json",
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"default": "./dist/node/index.js"
|
|
43
|
-
},
|
|
44
|
-
"require": {
|
|
45
|
-
"types": "./dist/node/index.d.cts",
|
|
46
|
-
"default": "./dist/node/index.cjs"
|
|
47
|
-
}
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/browser/index.d.ts",
|
|
41
|
+
"default": "./dist/browser/index.mjs"
|
|
48
42
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
"types": "./dist/browser/index.d.mts",
|
|
52
|
-
"default": "./dist/browser/index.js"
|
|
53
|
-
},
|
|
54
|
-
"require": {
|
|
55
|
-
"types": "./dist/browser/index.d.cts",
|
|
56
|
-
"default": "./dist/browser/index.cjs"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"default": "./dist/browser/index.js"
|
|
43
|
+
"types": "./dist/browser/index.d.ts",
|
|
44
|
+
"default": "./dist/browser/index.mjs"
|
|
60
45
|
},
|
|
61
46
|
"./package.json": "./package.json"
|
|
62
47
|
},
|
|
63
|
-
"
|
|
64
|
-
"module": "dist/browser/index.js",
|
|
48
|
+
"module": "dist/browser/index.mjs",
|
|
65
49
|
"homepage": "https://xyo.network",
|
|
66
50
|
"keywords": [
|
|
67
51
|
"xyo",
|
|
@@ -83,6 +67,6 @@
|
|
|
83
67
|
},
|
|
84
68
|
"sideEffects": false,
|
|
85
69
|
"types": "dist/browser/index.d.ts",
|
|
86
|
-
"version": "2.
|
|
70
|
+
"version": "2.83.0",
|
|
87
71
|
"type": "module"
|
|
88
72
|
}
|
|
@@ -2,11 +2,12 @@ import type { WithChildren } from '@xylabs/react-shared'
|
|
|
2
2
|
import { ModuleErrorSchema } from '@xyo-network/payload-model'
|
|
3
3
|
import { ErrorRender } from '@xyo-network/react-error'
|
|
4
4
|
import { useBuildHuri } from '@xyo-network/react-payload-huri'
|
|
5
|
+
import React from 'react'
|
|
5
6
|
import { useParams, useSearchParams } from 'react-router-dom'
|
|
6
7
|
|
|
7
|
-
import { useDivinePayload } from '../PayloadDiviner/index.
|
|
8
|
-
import { DivinedPayloadContext } from './Context.
|
|
9
|
-
import { useDivinedPayload } from './use.
|
|
8
|
+
import { useDivinePayload } from '../PayloadDiviner/index.ts'
|
|
9
|
+
import { DivinedPayloadContext } from './Context.ts'
|
|
10
|
+
import { useDivinedPayload } from './use.ts'
|
|
10
11
|
|
|
11
12
|
export interface DivinedPayloadProviderProps extends WithChildren {
|
|
12
13
|
hash?: string
|
|
@@ -24,6 +25,7 @@ export const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps> = ({
|
|
|
24
25
|
|
|
25
26
|
const [payload, setPayload, payloadError] = useDivinePayload(huriUri)
|
|
26
27
|
|
|
28
|
+
// eslint-disable-next-line @eslint-react/no-unstable-context-value
|
|
27
29
|
return <DivinedPayloadContext.Provider value={{ payload, payloadError, provided: true, setPayload }}>{children}</DivinedPayloadContext.Provider>
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Context.
|
|
2
|
-
export * from './Provider.
|
|
3
|
-
export * from './State.
|
|
4
|
-
export * from './use.
|
|
1
|
+
export * from './Context.ts'
|
|
2
|
+
export * from './Provider.tsx'
|
|
3
|
+
export * from './State.ts'
|
|
4
|
+
export * from './use.ts'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContextEx } from '@xyo-network/react-shared'
|
|
2
2
|
|
|
3
|
-
import { DivinedPayloadContext } from './Context.
|
|
3
|
+
import { DivinedPayloadContext } from './Context.ts'
|
|
4
4
|
|
|
5
5
|
export const useDivinedPayload = () => useContextEx(DivinedPayloadContext, 'DivinedPayload', true)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PayloadDiviner } from '@xyo-network/diviner-payload-abstract'
|
|
2
2
|
import { ContextExProviderProps } from '@xyo-network/react-shared'
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
3
|
+
import React, { useEffect, useMemo, useState } from 'react'
|
|
4
4
|
|
|
5
|
-
import { PayloadDivinerContext } from './Context.
|
|
5
|
+
import { PayloadDivinerContext } from './Context.ts'
|
|
6
6
|
|
|
7
7
|
export type PayloadDivinerProviderProps = ContextExProviderProps<{
|
|
8
8
|
/** Required */
|
|
@@ -18,19 +18,17 @@ export const PayloadDivinerProvider: React.FC<PayloadDivinerProviderProps> = ({
|
|
|
18
18
|
}
|
|
19
19
|
}, [divinerProp])
|
|
20
20
|
|
|
21
|
+
const value = useMemo(() => ({ diviner: diviner === divinerProp ? diviner : undefined, provided: true, setDiviner }), [diviner, divinerProp, setDiviner])
|
|
22
|
+
|
|
21
23
|
return (
|
|
22
24
|
<PayloadDivinerContext.Provider
|
|
23
|
-
value={
|
|
24
|
-
diviner: diviner === divinerProp ? diviner : undefined,
|
|
25
|
-
provided: true,
|
|
26
|
-
setDiviner,
|
|
27
|
-
}}
|
|
25
|
+
value={value}
|
|
28
26
|
>
|
|
29
|
-
{diviner
|
|
30
|
-
children
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
{diviner
|
|
28
|
+
? children
|
|
29
|
+
: required
|
|
30
|
+
? null
|
|
31
|
+
: children}
|
|
34
32
|
</PayloadDivinerContext.Provider>
|
|
35
33
|
)
|
|
36
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Context.
|
|
2
|
-
export * from './Provider.
|
|
3
|
-
export * from './State.
|
|
4
|
-
export * from './use.
|
|
1
|
+
export * from './Context.ts'
|
|
2
|
+
export * from './Provider.tsx'
|
|
3
|
+
export * from './State.ts'
|
|
4
|
+
export * from './use.ts'
|
|
@@ -5,7 +5,7 @@ import { Payload, WithMeta } from '@xyo-network/payload-model'
|
|
|
5
5
|
import { useContextEx } from '@xyo-network/react-shared'
|
|
6
6
|
import { Dispatch, useEffect, useState } from 'react'
|
|
7
7
|
|
|
8
|
-
import { PayloadDivinerContext } from './Context.
|
|
8
|
+
import { PayloadDivinerContext } from './Context.ts'
|
|
9
9
|
|
|
10
10
|
export const usePayloadDiviner = (required = false) => {
|
|
11
11
|
return useContextEx(PayloadDivinerContext, 'PayloadDiviner', required)
|
|
@@ -25,7 +25,6 @@ export const useDivinePayload = <T extends Payload = Payload>(
|
|
|
25
25
|
}, [diviner])
|
|
26
26
|
|
|
27
27
|
useAsyncEffect(
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
28
|
async (mounted) => {
|
|
30
29
|
if (huri && diviner && payload === undefined) {
|
|
31
30
|
try {
|
|
@@ -61,7 +60,6 @@ export const useDivinePayloads = <T extends Payload = Payload>(
|
|
|
61
60
|
}, [diviner])
|
|
62
61
|
|
|
63
62
|
useAsyncEffect(
|
|
64
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
63
|
async (mounted) => {
|
|
66
64
|
console.log(`huriList: ${JSON.stringify(huriList, null, 2)}`)
|
|
67
65
|
const payloads = await Promise.allSettled(
|
|
@@ -72,17 +70,17 @@ export const useDivinePayloads = <T extends Payload = Payload>(
|
|
|
72
70
|
}),
|
|
73
71
|
)
|
|
74
72
|
if (mounted()) {
|
|
75
|
-
setPayloads([...payloads.values()].map(
|
|
73
|
+
setPayloads([...payloads.values()].map(value => (value.status === 'rejected' ? null : value.value)) as (T | null)[])
|
|
76
74
|
setErrors(
|
|
77
75
|
compact(
|
|
78
|
-
[...payloads.values()].map(
|
|
76
|
+
[...payloads.values()].map(value => (value.status === 'rejected' ? new Error('divine failed', { cause: value.reason }) : undefined)),
|
|
79
77
|
),
|
|
80
78
|
)
|
|
81
79
|
if (mounted()) {
|
|
82
|
-
setPayloads([...payloads.values()].map(
|
|
80
|
+
setPayloads([...payloads.values()].map(value => (value.status === 'rejected' ? null : value.value)) as (T | null)[])
|
|
83
81
|
setErrors(
|
|
84
82
|
compact(
|
|
85
|
-
[...payloads.values()].map(
|
|
83
|
+
[...payloads.values()].map(value => (value.status === 'rejected' ? new Error('divine failed', { cause: value.reason }) : undefined)),
|
|
86
84
|
),
|
|
87
85
|
)
|
|
88
86
|
}
|
package/src/contexts/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './DivinedPayload/index.
|
|
2
|
-
export * from './PayloadDiviner/index.
|
|
1
|
+
export * from './DivinedPayload/index.ts'
|
|
2
|
+
export * from './PayloadDiviner/index.ts'
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './contexts/index.
|
|
1
|
+
export * from './contexts/index.ts'
|
package/xy.config.ts
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,eAAO,MAAM,qBAAqB,mGAAyC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,eAAO,MAAM,qBAAqB,mGAAyC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/DivinedPayload/Context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,eAAO,MAAM,qBAAqB,mGAAyC,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { WithChildren } from '@xylabs/react-shared';
|
|
2
|
-
export interface DivinedPayloadProviderProps extends WithChildren {
|
|
3
|
-
hash?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps>;
|
|
6
|
-
export declare const DivinedPayloadWithHandleInner: React.FC<WithChildren>;
|
|
7
|
-
export declare const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps>;
|
|
8
|
-
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { WithChildren } from '@xylabs/react-shared';
|
|
2
|
-
export interface DivinedPayloadProviderProps extends WithChildren {
|
|
3
|
-
hash?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps>;
|
|
6
|
-
export declare const DivinedPayloadWithHandleInner: React.FC<WithChildren>;
|
|
7
|
-
export declare const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps>;
|
|
8
|
-
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { WithChildren } from '@xylabs/react-shared';
|
|
2
|
-
export interface DivinedPayloadProviderProps extends WithChildren {
|
|
3
|
-
hash?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const DivinedPayloadProvider: React.FC<DivinedPayloadProviderProps>;
|
|
6
|
-
export declare const DivinedPayloadWithHandleInner: React.FC<WithChildren>;
|
|
7
|
-
export declare const DivinedPayloadWithHandleProvider: React.FC<DivinedPayloadProviderProps>;
|
|
8
|
-
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|