@xyo-network/react-payload-plugin-resolver 7.5.8 → 7.5.12
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/contexts/PayloadSetPluginResolver/Provider.d.ts.map +1 -1
- package/dist/browser/index.mjs +64 -53
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +152 -27
- package/src/PayloadRenderPluginResolver.ts +0 -36
- package/src/contexts/PayloadPluginResolver/Context.ts +0 -7
- package/src/contexts/PayloadPluginResolver/Provider.tsx +0 -34
- package/src/contexts/PayloadPluginResolver/State.ts +0 -8
- package/src/contexts/PayloadPluginResolver/index.ts +0 -4
- package/src/contexts/PayloadPluginResolver/use.ts +0 -7
- package/src/contexts/PayloadRenderPluginResolver/Context.ts +0 -7
- package/src/contexts/PayloadRenderPluginResolver/Provider.tsx +0 -34
- package/src/contexts/PayloadRenderPluginResolver/State.ts +0 -9
- package/src/contexts/PayloadRenderPluginResolver/index.ts +0 -4
- package/src/contexts/PayloadRenderPluginResolver/use.ts +0 -7
- package/src/contexts/PayloadSetPluginResolver/Context.ts +0 -7
- package/src/contexts/PayloadSetPluginResolver/Provider.tsx +0 -34
- package/src/contexts/PayloadSetPluginResolver/State.ts +0 -7
- package/src/contexts/PayloadSetPluginResolver/index.ts +0 -4
- package/src/contexts/PayloadSetPluginResolver/use.ts +0 -7
- package/src/contexts/index.ts +0 -3
- package/src/index.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/PayloadSetPluginResolver/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/PayloadSetPluginResolver/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAC9E,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,MAAM,MAAM,qCAAqC,GAAG,sBAAsB,CAAC;IACzE,QAAQ,EAAE,wBAAwB,CAAA;CACnC,CAAC,CAAA;AAEF,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CAAC,qCAAqC,CAwB5F,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,59 +1,68 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/contexts/PayloadPluginResolver/Context.ts
|
|
5
2
|
import { createContextEx } from "@xylabs/react-shared";
|
|
6
3
|
var PayloadPluginResolverContext = createContextEx();
|
|
7
4
|
|
|
8
5
|
// src/contexts/PayloadPluginResolver/Provider.tsx
|
|
9
|
-
import
|
|
10
|
-
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var PayloadPluginResolverProvider = ({
|
|
9
|
+
resolver: resolverProp,
|
|
10
|
+
required = false,
|
|
11
|
+
children
|
|
12
|
+
}) => {
|
|
11
13
|
const [resolver, setResolver] = useState(resolverProp);
|
|
12
14
|
const value = useMemo(() => ({
|
|
13
15
|
provided: true,
|
|
14
16
|
resolver,
|
|
15
17
|
setResolver
|
|
16
|
-
}), [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
}), [resolver, setResolver]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
PayloadPluginResolverContext,
|
|
21
|
+
{
|
|
22
|
+
value,
|
|
23
|
+
children: resolver ? children : required ? null : children
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
};
|
|
24
27
|
|
|
25
28
|
// src/contexts/PayloadPluginResolver/use.ts
|
|
26
29
|
import { useContextEx } from "@xylabs/react-shared";
|
|
27
|
-
var usePayloadPluginResolver =
|
|
30
|
+
var usePayloadPluginResolver = (required = false) => {
|
|
28
31
|
return useContextEx(PayloadPluginResolverContext, "PayloadPluginResolver", required);
|
|
29
|
-
}
|
|
32
|
+
};
|
|
30
33
|
|
|
31
34
|
// src/contexts/PayloadRenderPluginResolver/Context.ts
|
|
32
35
|
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
33
36
|
var PayloadRenderPluginResolverContext = createContextEx2();
|
|
34
37
|
|
|
35
38
|
// src/contexts/PayloadRenderPluginResolver/Provider.tsx
|
|
36
|
-
import
|
|
37
|
-
|
|
39
|
+
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
40
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
41
|
+
var PayloadRenderPluginResolverProvider = ({
|
|
42
|
+
resolver: resolverProp,
|
|
43
|
+
required = false,
|
|
44
|
+
children
|
|
45
|
+
}) => {
|
|
38
46
|
const [resolver, setResolver] = useState2(resolverProp);
|
|
39
47
|
const value = useMemo2(() => ({
|
|
40
48
|
resolver,
|
|
41
49
|
provided: true,
|
|
42
50
|
setResolver
|
|
43
|
-
}), [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
}), [resolver, setResolver]);
|
|
52
|
+
return /* @__PURE__ */ jsx2(
|
|
53
|
+
PayloadRenderPluginResolverContext,
|
|
54
|
+
{
|
|
55
|
+
value,
|
|
56
|
+
children: resolver ? children : required ? null : children
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
51
60
|
|
|
52
61
|
// src/contexts/PayloadRenderPluginResolver/use.ts
|
|
53
62
|
import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
|
|
54
|
-
var usePayloadRenderPluginResolver =
|
|
63
|
+
var usePayloadRenderPluginResolver = (required = false) => {
|
|
55
64
|
return useContextEx2(PayloadRenderPluginResolverContext, "PayloadRenderPluginResolver", required);
|
|
56
|
-
}
|
|
65
|
+
};
|
|
57
66
|
|
|
58
67
|
// src/contexts/PayloadSetPluginResolver/Context.ts
|
|
59
68
|
import { createContextEx as createContextEx3 } from "@xylabs/react-shared";
|
|
@@ -61,30 +70,37 @@ var PayloadSetPluginResolverContext = createContextEx3();
|
|
|
61
70
|
|
|
62
71
|
// src/contexts/PayloadSetPluginResolver/Provider.tsx
|
|
63
72
|
import { useResetState } from "@xylabs/react-hooks";
|
|
64
|
-
import
|
|
65
|
-
|
|
73
|
+
import { useMemo as useMemo3 } from "react";
|
|
74
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
75
|
+
var PayloadSetPluginResolverProvider = ({
|
|
76
|
+
resolver: resolverProp,
|
|
77
|
+
required = false,
|
|
78
|
+
children
|
|
79
|
+
}) => {
|
|
66
80
|
const [resolver, setResolver] = useResetState(resolverProp);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
const value = useMemo3(() => ({
|
|
82
|
+
provided: true,
|
|
83
|
+
resolver,
|
|
84
|
+
setResolver
|
|
85
|
+
}), [resolver, setResolver]);
|
|
86
|
+
return /* @__PURE__ */ jsx3(
|
|
87
|
+
PayloadSetPluginResolverContext,
|
|
88
|
+
{
|
|
89
|
+
value,
|
|
90
|
+
children: resolver ? children : required ? null : children
|
|
72
91
|
}
|
|
73
|
-
|
|
74
|
-
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
75
94
|
|
|
76
95
|
// src/contexts/PayloadSetPluginResolver/use.ts
|
|
77
96
|
import { useContextEx as useContextEx3 } from "@xylabs/react-shared";
|
|
78
|
-
var usePayloadSetPluginResolver =
|
|
97
|
+
var usePayloadSetPluginResolver = (required = false) => {
|
|
79
98
|
return useContextEx3(PayloadSetPluginResolverContext, "PayloadSetPluginResolver", required);
|
|
80
|
-
}
|
|
99
|
+
};
|
|
81
100
|
|
|
82
101
|
// src/PayloadRenderPluginResolver.ts
|
|
83
102
|
import { assertEx } from "@xylabs/sdk-js";
|
|
84
103
|
var PayloadRenderPluginResolver = class {
|
|
85
|
-
static {
|
|
86
|
-
__name(this, "PayloadRenderPluginResolver");
|
|
87
|
-
}
|
|
88
104
|
plugins = [];
|
|
89
105
|
schemaDefaultPlugin = /* @__PURE__ */ new Map();
|
|
90
106
|
list(payload) {
|
|
@@ -92,9 +108,7 @@ var PayloadRenderPluginResolver = class {
|
|
|
92
108
|
return this.plugins;
|
|
93
109
|
}
|
|
94
110
|
const defaultPlugin = this.schemaDefaultPlugin.get(payload.schema);
|
|
95
|
-
const result = defaultPlugin ? [
|
|
96
|
-
defaultPlugin
|
|
97
|
-
] : [];
|
|
111
|
+
const result = defaultPlugin ? [defaultPlugin] : [];
|
|
98
112
|
for (const plugin of this.plugins) {
|
|
99
113
|
if (defaultPlugin !== plugin && plugin.canRender(payload)) {
|
|
100
114
|
result.push(plugin);
|
|
@@ -104,18 +118,15 @@ var PayloadRenderPluginResolver = class {
|
|
|
104
118
|
}
|
|
105
119
|
register(plugin, defaultForSchema) {
|
|
106
120
|
this.plugins.push(plugin);
|
|
107
|
-
if (defaultForSchema)
|
|
108
|
-
|
|
109
|
-
schema
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
121
|
+
if (defaultForSchema)
|
|
122
|
+
for (const schema of defaultForSchema) {
|
|
123
|
+
assertEx(plugin.canRender({ schema }), () => "Default renderer must be able to render schema");
|
|
124
|
+
this.schemaDefaultPlugin.set(schema, plugin);
|
|
125
|
+
}
|
|
113
126
|
return this;
|
|
114
127
|
}
|
|
115
128
|
resolve(payload) {
|
|
116
|
-
return this.schemaDefaultPlugin.get(payload.schema) ?? [
|
|
117
|
-
...this.plugins.values()
|
|
118
|
-
].find((plugin) => plugin.canRender(payload));
|
|
129
|
+
return this.schemaDefaultPlugin.get(payload.schema) ?? [...this.plugins.values()].find((plugin) => plugin.canRender(payload));
|
|
119
130
|
}
|
|
120
131
|
};
|
|
121
132
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contexts/PayloadPluginResolver/Context.ts","../../src/contexts/PayloadPluginResolver/Provider.tsx","../../src/contexts/PayloadPluginResolver/use.ts","../../src/contexts/PayloadRenderPluginResolver/Context.ts","../../src/contexts/PayloadRenderPluginResolver/Provider.tsx","../../src/contexts/PayloadRenderPluginResolver/use.ts","../../src/contexts/PayloadSetPluginResolver/Context.ts","../../src/contexts/PayloadSetPluginResolver/Provider.tsx","../../src/contexts/PayloadSetPluginResolver/use.ts","../../src/PayloadRenderPluginResolver.ts"],"sourcesContent":["import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadPluginResolverState } from './State.ts'\n\nconst PayloadPluginResolverContext = createContextEx<PayloadPluginResolverState>()\n\nexport { PayloadPluginResolverContext }\n","import type { ContextExProviderProps } from '@xylabs/react-shared'\nimport type { PayloadPluginResolver } from '@xyo-network/payload-plugin'\nimport React, { useMemo, useState } from 'react'\n\nimport { PayloadPluginResolverContext } from './Context.ts'\nimport type { PayloadPluginResolverState } from './State.ts'\n\nexport type PayloadPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadPluginResolver\n}>\n\nexport const PayloadPluginResolverProvider: React.FC<PayloadPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useState<PayloadPluginResolver>(resolverProp)\n\n const value: PayloadPluginResolverState = useMemo(() => ({\n provided: true, resolver, setResolver,\n }), [resolver, setResolver])\n\n return (\n <PayloadPluginResolverContext\n value={value}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadPluginResolverContext } from './Context.ts'\n\nexport const usePayloadPluginResolver = (required = false) => {\n return useContextEx(PayloadPluginResolverContext, 'PayloadPluginResolver', required)\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadRenderPluginResolverState } from './State.ts'\n\nconst PayloadRenderPluginResolverContext = createContextEx<PayloadRenderPluginResolverState>()\n\nexport { PayloadRenderPluginResolverContext }\n","import type { ContextExProviderProps } from '@xylabs/react-shared'\nimport React, { useMemo, useState } from 'react'\n\nimport type { PayloadRenderPluginResolver } from '../../PayloadRenderPluginResolver.ts'\nimport { PayloadRenderPluginResolverContext } from './Context.ts'\nimport type { PayloadRenderPluginResolverState } from './State.ts'\n\nexport type PayloadRenderPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadRenderPluginResolver\n}>\n\nexport const PayloadRenderPluginResolverProvider: React.FC<PayloadRenderPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useState<PayloadRenderPluginResolver>(resolverProp)\n\n const value: PayloadRenderPluginResolverState = useMemo(() => ({\n resolver, provided: true, setResolver,\n }), [resolver, setResolver])\n\n return (\n <PayloadRenderPluginResolverContext\n value={value}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadRenderPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadRenderPluginResolverContext } from './Context.ts'\n\nexport const usePayloadRenderPluginResolver = (required = false) => {\n return useContextEx(PayloadRenderPluginResolverContext, 'PayloadRenderPluginResolver', required)\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadSetPluginResolverState } from './State.ts'\n\nconst PayloadSetPluginResolverContext = createContextEx<PayloadSetPluginResolverState>()\n\nexport { PayloadSetPluginResolverContext }\n","import { useResetState } from '@xylabs/react-hooks'\nimport type { ContextExProviderProps } from '@xylabs/react-shared'\nimport type { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'\nimport React from 'react'\n\nimport { PayloadSetPluginResolverContext } from './Context.ts'\n\nexport type PayloadSetPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadSetPluginResolver\n}>\n\nexport const PayloadSetPluginResolverProvider: React.FC<PayloadSetPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useResetState<PayloadSetPluginResolver>(resolverProp)\n\n return (\n <PayloadSetPluginResolverContext\n value={{\n provided: true,\n resolver,\n setResolver,\n }}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadSetPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadSetPluginResolverContext } from './Context.ts'\n\nexport const usePayloadSetPluginResolver = (required = false) => {\n return useContextEx(PayloadSetPluginResolverContext, 'PayloadSetPluginResolver', required)\n}\n","import { assertEx } from '@xylabs/sdk-js'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { PayloadRenderPlugin } from '@xyo-network/react-payload-plugin'\n\nexport class PayloadRenderPluginResolver {\n protected plugins: PayloadRenderPlugin[] = []\n protected schemaDefaultPlugin = new Map<string, PayloadRenderPlugin>()\n\n list(payload?: Payload) {\n if (!payload) {\n return this.plugins\n }\n const defaultPlugin = this.schemaDefaultPlugin.get(payload.schema)\n const result = defaultPlugin ? [defaultPlugin] : []\n for (const plugin of this.plugins) {\n if (defaultPlugin !== plugin && plugin.canRender(payload)) {\n result.push(plugin)\n }\n }\n return result\n }\n\n register(plugin: PayloadRenderPlugin, defaultForSchema?: Schema[]) {\n this.plugins.push(plugin)\n if (defaultForSchema)\n for (const schema of defaultForSchema) {\n assertEx(plugin.canRender({ schema }), () => 'Default renderer must be able to render schema')\n this.schemaDefaultPlugin.set(schema, plugin)\n }\n return this\n }\n\n resolve(payload: Payload) {\n return this.schemaDefaultPlugin.get(payload.schema) ?? [...this.plugins.values()].find(plugin => plugin.canRender(payload))\n }\n}\n"],"mappings":";;;;AAAA,SAASA,uBAAuB;AAIhC,IAAMC,+BAA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Context","React","useMemo","useState","PayloadPluginResolverProvider","resolver","resolverProp","required","children","setResolver","useState","value","useMemo","provided","PayloadPluginResolverContext","useContextEx","usePayloadPluginResolver","required","useContextEx","PayloadPluginResolverContext","createContextEx","PayloadRenderPluginResolverContext","React","useMemo","useState","PayloadRenderPluginResolverProvider","resolver","resolverProp","required","children","setResolver","useState","value","useMemo","provided","React","PayloadRenderPluginResolverContext","useContextEx","usePayloadRenderPluginResolver","required","useContextEx","PayloadRenderPluginResolverContext","createContextEx","PayloadSetPluginResolverContext","useResetState","React","PayloadSetPluginResolverProvider","resolver","resolverProp","required","children","setResolver","useResetState","React","PayloadSetPluginResolverContext","value","provided","useContextEx","usePayloadSetPluginResolver","required","useContextEx","PayloadSetPluginResolverContext","assertEx","PayloadRenderPluginResolver","plugins","schemaDefaultPlugin","Map","list","payload","defaultPlugin","get","schema","result","plugin","canRender","push","register","defaultForSchema","assertEx","set","resolve","values","find"]}
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/PayloadPluginResolver/Context.ts","../../src/contexts/PayloadPluginResolver/Provider.tsx","../../src/contexts/PayloadPluginResolver/use.ts","../../src/contexts/PayloadRenderPluginResolver/Context.ts","../../src/contexts/PayloadRenderPluginResolver/Provider.tsx","../../src/contexts/PayloadRenderPluginResolver/use.ts","../../src/contexts/PayloadSetPluginResolver/Context.ts","../../src/contexts/PayloadSetPluginResolver/Provider.tsx","../../src/contexts/PayloadSetPluginResolver/use.ts","../../src/PayloadRenderPluginResolver.ts"],"sourcesContent":["import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadPluginResolverState } from './State.ts'\n\nconst PayloadPluginResolverContext = createContextEx<PayloadPluginResolverState>()\n\nexport { PayloadPluginResolverContext }\n","import type { ContextExProviderProps } from '@xylabs/react-shared'\nimport type { PayloadPluginResolver } from '@xyo-network/payload-plugin'\nimport React, { useMemo, useState } from 'react'\n\nimport { PayloadPluginResolverContext } from './Context.ts'\nimport type { PayloadPluginResolverState } from './State.ts'\n\nexport type PayloadPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadPluginResolver\n}>\n\nexport const PayloadPluginResolverProvider: React.FC<PayloadPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useState<PayloadPluginResolver>(resolverProp)\n\n const value: PayloadPluginResolverState = useMemo(() => ({\n provided: true, resolver, setResolver,\n }), [resolver, setResolver])\n\n return (\n <PayloadPluginResolverContext\n value={value}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadPluginResolverContext } from './Context.ts'\n\nexport const usePayloadPluginResolver = (required = false) => {\n return useContextEx(PayloadPluginResolverContext, 'PayloadPluginResolver', required)\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadRenderPluginResolverState } from './State.ts'\n\nconst PayloadRenderPluginResolverContext = createContextEx<PayloadRenderPluginResolverState>()\n\nexport { PayloadRenderPluginResolverContext }\n","import type { ContextExProviderProps } from '@xylabs/react-shared'\nimport React, { useMemo, useState } from 'react'\n\nimport type { PayloadRenderPluginResolver } from '../../PayloadRenderPluginResolver.ts'\nimport { PayloadRenderPluginResolverContext } from './Context.ts'\nimport type { PayloadRenderPluginResolverState } from './State.ts'\n\nexport type PayloadRenderPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadRenderPluginResolver\n}>\n\nexport const PayloadRenderPluginResolverProvider: React.FC<PayloadRenderPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useState<PayloadRenderPluginResolver>(resolverProp)\n\n const value: PayloadRenderPluginResolverState = useMemo(() => ({\n resolver, provided: true, setResolver,\n }), [resolver, setResolver])\n\n return (\n <PayloadRenderPluginResolverContext\n value={value}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadRenderPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadRenderPluginResolverContext } from './Context.ts'\n\nexport const usePayloadRenderPluginResolver = (required = false) => {\n return useContextEx(PayloadRenderPluginResolverContext, 'PayloadRenderPluginResolver', required)\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { PayloadSetPluginResolverState } from './State.ts'\n\nconst PayloadSetPluginResolverContext = createContextEx<PayloadSetPluginResolverState>()\n\nexport { PayloadSetPluginResolverContext }\n","import { useResetState } from '@xylabs/react-hooks'\nimport type { ContextExProviderProps } from '@xylabs/react-shared'\nimport type { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'\nimport React, { useMemo } from 'react'\n\nimport { PayloadSetPluginResolverContext } from './Context.ts'\n\nexport type PayloadSetPluginResolverProviderProps = ContextExProviderProps<{\n resolver: PayloadSetPluginResolver\n}>\n\nexport const PayloadSetPluginResolverProvider: React.FC<PayloadSetPluginResolverProviderProps> = ({\n resolver: resolverProp,\n required = false,\n children,\n}) => {\n const [resolver, setResolver] = useResetState<PayloadSetPluginResolver>(resolverProp)\n\n const value = useMemo(() => ({\n provided: true as const,\n resolver,\n setResolver,\n }), [resolver, setResolver])\n\n return (\n <PayloadSetPluginResolverContext\n value={value}\n >\n {resolver\n ? children\n : required\n ? null\n : children}\n </PayloadSetPluginResolverContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { PayloadSetPluginResolverContext } from './Context.ts'\n\nexport const usePayloadSetPluginResolver = (required = false) => {\n return useContextEx(PayloadSetPluginResolverContext, 'PayloadSetPluginResolver', required)\n}\n","import { assertEx } from '@xylabs/sdk-js'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { PayloadRenderPlugin } from '@xyo-network/react-payload-plugin'\n\nexport class PayloadRenderPluginResolver {\n protected plugins: PayloadRenderPlugin[] = []\n protected schemaDefaultPlugin = new Map<string, PayloadRenderPlugin>()\n\n list(payload?: Payload) {\n if (!payload) {\n return this.plugins\n }\n const defaultPlugin = this.schemaDefaultPlugin.get(payload.schema)\n const result = defaultPlugin ? [defaultPlugin] : []\n for (const plugin of this.plugins) {\n if (defaultPlugin !== plugin && plugin.canRender(payload)) {\n result.push(plugin)\n }\n }\n return result\n }\n\n register(plugin: PayloadRenderPlugin, defaultForSchema?: Schema[]) {\n this.plugins.push(plugin)\n if (defaultForSchema)\n for (const schema of defaultForSchema) {\n assertEx(plugin.canRender({ schema }), () => 'Default renderer must be able to render schema')\n this.schemaDefaultPlugin.set(schema, plugin)\n }\n return this\n }\n\n resolve(payload: Payload) {\n return this.schemaDefaultPlugin.get(payload.schema) ?? [...this.plugins.values()].find(plugin => plugin.canRender(payload))\n }\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAIhC,IAAM,+BAA+B,gBAA4C;;;ACFjF,SAAgB,SAAS,gBAAgB;AAqBrC;AAZG,IAAM,gCAA8E,CAAC;AAAA,EAC1F,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AACF,MAAM;AACJ,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,YAAY;AAE5E,QAAM,QAAoC,QAAQ,OAAO;AAAA,IACvD,UAAU;AAAA,IAAM;AAAA,IAAU;AAAA,EAC5B,IAAI,CAAC,UAAU,WAAW,CAAC;AAE3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MAEC,qBACG,WACA,WACE,OACA;AAAA;AAAA,EACR;AAEJ;;;ACjCA,SAAS,oBAAoB;AAItB,IAAM,2BAA2B,CAAC,WAAW,UAAU;AAC5D,SAAO,aAAa,8BAA8B,yBAAyB,QAAQ;AACrF;;;ACNA,SAAS,mBAAAA,wBAAuB;AAIhC,IAAM,qCAAqCA,iBAAkD;;;ACH7F,SAAgB,WAAAC,UAAS,YAAAC,iBAAgB;AAsBrC,gBAAAC,YAAA;AAZG,IAAM,sCAA0F,CAAC;AAAA,EACtG,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AACF,MAAM;AACJ,QAAM,CAAC,UAAU,WAAW,IAAIC,UAAsC,YAAY;AAElF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aAAa,IAAI,CAAC;AAClD,eAAW,UAAU,KAAK,SAAS;AACjC,UAAI,kBAAkB,UAAU,OAAO,UAAU,OAAO,GAAG;AACzD,eAAO,KAAK,MAAM;AAAA,MACpB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,QAA6B,kBAA6B;AACjE,SAAK,QAAQ,KAAK,MAAM;AACxB,QAAI;AACF,iBAAW,UAAU,kBAAkB;AACrC,iBAAS,OAAO,UAAU,EAAE,OAAO,CAAC,GAAG,MAAM,gDAAgD;AAC7F,aAAK,oBAAoB,IAAI,QAAQ,MAAM;AAAA,MAC7C;AACF,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,SAAkB;AACxB,WAAO,KAAK,oBAAoB,IAAI,QAAQ,MAAM,KAAK,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC,EAAE,KAAK,YAAU,OAAO,UAAU,OAAO,CAAC;AAAA,EAC5H;AACF;","names":["createContextEx","useMemo","useState","jsx","useState","useMemo","useContextEx","useContextEx","createContextEx","useMemo","jsx","useMemo","useContextEx","useContextEx"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-payload-plugin-resolver",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.12",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -36,45 +36,170 @@
|
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
|
-
"module": "dist/browser/index.mjs",
|
|
40
|
-
"types": "dist/browser/index.d.ts",
|
|
41
39
|
"files": [
|
|
42
40
|
"dist",
|
|
43
|
-
"
|
|
41
|
+
"README.md"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@xylabs/react-shared": "~7.1.17",
|
|
48
|
-
"@xylabs/sdk-js": "~5.0.90",
|
|
49
|
-
"@xyo-network/payload-model": "~5.3.17",
|
|
50
|
-
"@xyo-network/payload-plugin": "~5.3.17",
|
|
51
|
-
"@xyo-network/payloadset-plugin": "~5.3.17",
|
|
52
|
-
"@xyo-network/react-payload-plugin": "7.5.8"
|
|
44
|
+
"@xyo-network/react-payload-plugin": "~7.5.12"
|
|
53
45
|
},
|
|
54
46
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@emotion/
|
|
57
|
-
"@
|
|
58
|
-
"@mui/material": "
|
|
47
|
+
"@bitauth/libauth": "~3.0.0",
|
|
48
|
+
"@emotion/react": "^11.14.0",
|
|
49
|
+
"@emotion/styled": "^11.14.1",
|
|
50
|
+
"@mui/icons-material": "^7.3.10",
|
|
51
|
+
"@mui/material": "^7.3.10",
|
|
52
|
+
"@mui/system": "^7.3.10",
|
|
53
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
54
|
+
"@opentelemetry/api": "^1.9.1",
|
|
55
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
56
|
+
"@scure/base": "~2.2.0",
|
|
57
|
+
"@textea/json-viewer": "~4.0.1",
|
|
58
|
+
"@types/node": "~25.6.0",
|
|
59
59
|
"@types/react": "^19.2.14",
|
|
60
|
-
"@xylabs/
|
|
61
|
-
"@xylabs/
|
|
62
|
-
"react": "
|
|
63
|
-
"react-
|
|
64
|
-
"react-
|
|
60
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
61
|
+
"@xylabs/react-button": "~7.1.20",
|
|
62
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
63
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
64
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
65
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
66
|
+
"@xylabs/react-link": "~7.1.20",
|
|
67
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
68
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
69
|
+
"@xylabs/react-select": "~7.1.20",
|
|
70
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
71
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
72
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
73
|
+
"@xylabs/threads": "~5.0.100",
|
|
74
|
+
"@xylabs/toolchain": "~7.11.9",
|
|
75
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
76
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
77
|
+
"@xylabs/tsconfig-react": "~7.11.9",
|
|
78
|
+
"@xylabs/zod": "~5.0.100",
|
|
79
|
+
"@xyo-network/account": "~5.5.1",
|
|
80
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
81
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
82
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
83
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
84
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
85
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
86
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
87
|
+
"@xyo-network/diviner-schema-list": "~5.5.5",
|
|
88
|
+
"@xyo-network/diviner-schema-stats": "~5.5.2",
|
|
89
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
90
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
91
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
92
|
+
"@xyo-network/node-core-types": "~4.1.10",
|
|
93
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
94
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
95
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
96
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
97
|
+
"@xyo-network/payload-plugin": "^5.5.1",
|
|
98
|
+
"@xyo-network/payload-validator": "^5.5.1",
|
|
99
|
+
"@xyo-network/payloadset-plugin": "^5.5.5",
|
|
100
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
101
|
+
"@xyo-network/schema-cache": "~5.5.1",
|
|
102
|
+
"@xyo-network/schema-payload-plugin": "~5.5.1",
|
|
103
|
+
"@xyo-network/typeof": "~5.3.30",
|
|
104
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
105
|
+
"ajv": "^8.18.0",
|
|
106
|
+
"async-mutex": "^0.5.0",
|
|
107
|
+
"axios": "^1.15.2",
|
|
108
|
+
"bn.js": "^5.2.3",
|
|
109
|
+
"bowser": "^2.14.1",
|
|
110
|
+
"buffer": "^6.0.3",
|
|
111
|
+
"chalk": "^5.6.2",
|
|
112
|
+
"debug": "~4.4.3",
|
|
113
|
+
"esbuild": "~0.28.0",
|
|
114
|
+
"eslint": "^10.2.1",
|
|
115
|
+
"ethers": "^6.16.0",
|
|
116
|
+
"fast-deep-equal": "~3.1.3",
|
|
117
|
+
"hash-wasm": "~4.12.0",
|
|
118
|
+
"js-cookie": "~3.0.5",
|
|
119
|
+
"lru-cache": "^11.3.5",
|
|
120
|
+
"observable-fns": "~0.6.1",
|
|
121
|
+
"pako": "^2.1.0",
|
|
122
|
+
"react": "^19.2.5",
|
|
123
|
+
"react-dom": "^19.2.5",
|
|
124
|
+
"react-router-dom": "^7.14.2",
|
|
125
|
+
"spark-md5": "~3.0.2",
|
|
65
126
|
"typescript": "^5.9.3",
|
|
127
|
+
"wasm-feature-detect": "~1.8.0",
|
|
66
128
|
"zod": "^4.3.6"
|
|
67
129
|
},
|
|
68
130
|
"peerDependencies": {
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
131
|
+
"@emotion/react": "^11.14.0",
|
|
132
|
+
"@emotion/styled": "^11.14.1",
|
|
133
|
+
"@mui/icons-material": "^7.3.10",
|
|
134
|
+
"@mui/material": "^7.3.10",
|
|
135
|
+
"@mui/system": "^7.3.10",
|
|
136
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
137
|
+
"@opentelemetry/api": "^1.9.1",
|
|
138
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
139
|
+
"@scure/base": "~2.2.0",
|
|
140
|
+
"@textea/json-viewer": "~4.0.1",
|
|
141
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
142
|
+
"@xylabs/react-button": "~7.1.20",
|
|
143
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
144
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
145
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
146
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
147
|
+
"@xylabs/react-link": "~7.1.20",
|
|
148
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
149
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
150
|
+
"@xylabs/react-select": "~7.1.20",
|
|
151
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
152
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
153
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
154
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
155
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
156
|
+
"@xylabs/zod": "~5.0.100",
|
|
157
|
+
"@xyo-network/account": "~5.5.1",
|
|
158
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
159
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
160
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
161
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
162
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
163
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
164
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
165
|
+
"@xyo-network/diviner-schema-list": "~5.5.5",
|
|
166
|
+
"@xyo-network/diviner-schema-stats": "~5.5.2",
|
|
167
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
168
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
169
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
170
|
+
"@xyo-network/node-core-types": "~4.1.10",
|
|
171
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
172
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
173
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
174
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
175
|
+
"@xyo-network/payload-plugin": "^5.5.1",
|
|
176
|
+
"@xyo-network/payload-validator": "^5.5.1",
|
|
177
|
+
"@xyo-network/payloadset-plugin": "^5.5.5",
|
|
178
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
179
|
+
"@xyo-network/schema-cache": "~5.5.1",
|
|
180
|
+
"@xyo-network/schema-payload-plugin": "~5.5.1",
|
|
181
|
+
"@xyo-network/typeof": "~5.3.30",
|
|
182
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
183
|
+
"ajv": "^8.18.0",
|
|
184
|
+
"async-mutex": "^0.5.0",
|
|
185
|
+
"axios": "^1.15.2",
|
|
186
|
+
"bn.js": "^5.2.3",
|
|
187
|
+
"bowser": "^2.14.1",
|
|
188
|
+
"buffer": "^6.0.3",
|
|
189
|
+
"chalk": "^5.6.2",
|
|
190
|
+
"ethers": "^6.16.0",
|
|
191
|
+
"fast-deep-equal": "~3.1.3",
|
|
192
|
+
"js-cookie": "~3.0.5",
|
|
193
|
+
"lru-cache": "^11.3.5",
|
|
194
|
+
"pako": "^2.1.0",
|
|
195
|
+
"react": "^19.2.5",
|
|
196
|
+
"react-dom": "^19.2.5",
|
|
197
|
+
"react-router-dom": "^7.14.2",
|
|
198
|
+
"spark-md5": "~3.0.2",
|
|
199
|
+
"zod": "^4.3.6"
|
|
75
200
|
},
|
|
76
201
|
"publishConfig": {
|
|
77
202
|
"access": "public"
|
|
78
203
|
},
|
|
79
204
|
"docs": "dist/docs.json"
|
|
80
|
-
}
|
|
205
|
+
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import type { Payload, Schema } from '@xyo-network/payload-model'
|
|
3
|
-
import type { PayloadRenderPlugin } from '@xyo-network/react-payload-plugin'
|
|
4
|
-
|
|
5
|
-
export class PayloadRenderPluginResolver {
|
|
6
|
-
protected plugins: PayloadRenderPlugin[] = []
|
|
7
|
-
protected schemaDefaultPlugin = new Map<string, PayloadRenderPlugin>()
|
|
8
|
-
|
|
9
|
-
list(payload?: Payload) {
|
|
10
|
-
if (!payload) {
|
|
11
|
-
return this.plugins
|
|
12
|
-
}
|
|
13
|
-
const defaultPlugin = this.schemaDefaultPlugin.get(payload.schema)
|
|
14
|
-
const result = defaultPlugin ? [defaultPlugin] : []
|
|
15
|
-
for (const plugin of this.plugins) {
|
|
16
|
-
if (defaultPlugin !== plugin && plugin.canRender(payload)) {
|
|
17
|
-
result.push(plugin)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
register(plugin: PayloadRenderPlugin, defaultForSchema?: Schema[]) {
|
|
24
|
-
this.plugins.push(plugin)
|
|
25
|
-
if (defaultForSchema)
|
|
26
|
-
for (const schema of defaultForSchema) {
|
|
27
|
-
assertEx(plugin.canRender({ schema }), () => 'Default renderer must be able to render schema')
|
|
28
|
-
this.schemaDefaultPlugin.set(schema, plugin)
|
|
29
|
-
}
|
|
30
|
-
return this
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
resolve(payload: Payload) {
|
|
34
|
-
return this.schemaDefaultPlugin.get(payload.schema) ?? [...this.plugins.values()].find(plugin => plugin.canRender(payload))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ContextExProviderProps } from '@xylabs/react-shared'
|
|
2
|
-
import type { PayloadPluginResolver } from '@xyo-network/payload-plugin'
|
|
3
|
-
import React, { useMemo, useState } from 'react'
|
|
4
|
-
|
|
5
|
-
import { PayloadPluginResolverContext } from './Context.ts'
|
|
6
|
-
import type { PayloadPluginResolverState } from './State.ts'
|
|
7
|
-
|
|
8
|
-
export type PayloadPluginResolverProviderProps = ContextExProviderProps<{
|
|
9
|
-
resolver: PayloadPluginResolver
|
|
10
|
-
}>
|
|
11
|
-
|
|
12
|
-
export const PayloadPluginResolverProvider: React.FC<PayloadPluginResolverProviderProps> = ({
|
|
13
|
-
resolver: resolverProp,
|
|
14
|
-
required = false,
|
|
15
|
-
children,
|
|
16
|
-
}) => {
|
|
17
|
-
const [resolver, setResolver] = useState<PayloadPluginResolver>(resolverProp)
|
|
18
|
-
|
|
19
|
-
const value: PayloadPluginResolverState = useMemo(() => ({
|
|
20
|
-
provided: true, resolver, setResolver,
|
|
21
|
-
}), [resolver, setResolver])
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<PayloadPluginResolverContext
|
|
25
|
-
value={value}
|
|
26
|
-
>
|
|
27
|
-
{resolver
|
|
28
|
-
? children
|
|
29
|
-
: required
|
|
30
|
-
? null
|
|
31
|
-
: children}
|
|
32
|
-
</PayloadPluginResolverContext>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ContextExState } from '@xylabs/react-shared'
|
|
2
|
-
import type { PayloadPluginResolver } from '@xyo-network/payload-plugin'
|
|
3
|
-
import type { Dispatch } from 'react'
|
|
4
|
-
|
|
5
|
-
export type PayloadPluginResolverState = ContextExState<{
|
|
6
|
-
resolver?: PayloadPluginResolver
|
|
7
|
-
setResolver?: Dispatch<PayloadPluginResolver>
|
|
8
|
-
}>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContextEx } from '@xylabs/react-shared'
|
|
2
|
-
|
|
3
|
-
import { PayloadPluginResolverContext } from './Context.ts'
|
|
4
|
-
|
|
5
|
-
export const usePayloadPluginResolver = (required = false) => {
|
|
6
|
-
return useContextEx(PayloadPluginResolverContext, 'PayloadPluginResolver', required)
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createContextEx } from '@xylabs/react-shared'
|
|
2
|
-
|
|
3
|
-
import type { PayloadRenderPluginResolverState } from './State.ts'
|
|
4
|
-
|
|
5
|
-
const PayloadRenderPluginResolverContext = createContextEx<PayloadRenderPluginResolverState>()
|
|
6
|
-
|
|
7
|
-
export { PayloadRenderPluginResolverContext }
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ContextExProviderProps } from '@xylabs/react-shared'
|
|
2
|
-
import React, { useMemo, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import type { PayloadRenderPluginResolver } from '../../PayloadRenderPluginResolver.ts'
|
|
5
|
-
import { PayloadRenderPluginResolverContext } from './Context.ts'
|
|
6
|
-
import type { PayloadRenderPluginResolverState } from './State.ts'
|
|
7
|
-
|
|
8
|
-
export type PayloadRenderPluginResolverProviderProps = ContextExProviderProps<{
|
|
9
|
-
resolver: PayloadRenderPluginResolver
|
|
10
|
-
}>
|
|
11
|
-
|
|
12
|
-
export const PayloadRenderPluginResolverProvider: React.FC<PayloadRenderPluginResolverProviderProps> = ({
|
|
13
|
-
resolver: resolverProp,
|
|
14
|
-
required = false,
|
|
15
|
-
children,
|
|
16
|
-
}) => {
|
|
17
|
-
const [resolver, setResolver] = useState<PayloadRenderPluginResolver>(resolverProp)
|
|
18
|
-
|
|
19
|
-
const value: PayloadRenderPluginResolverState = useMemo(() => ({
|
|
20
|
-
resolver, provided: true, setResolver,
|
|
21
|
-
}), [resolver, setResolver])
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<PayloadRenderPluginResolverContext
|
|
25
|
-
value={value}
|
|
26
|
-
>
|
|
27
|
-
{resolver
|
|
28
|
-
? children
|
|
29
|
-
: required
|
|
30
|
-
? null
|
|
31
|
-
: children}
|
|
32
|
-
</PayloadRenderPluginResolverContext>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ContextExState } from '@xylabs/react-shared'
|
|
2
|
-
import type { Dispatch } from 'react'
|
|
3
|
-
|
|
4
|
-
import type { PayloadRenderPluginResolver } from '../../PayloadRenderPluginResolver.ts'
|
|
5
|
-
|
|
6
|
-
export type PayloadRenderPluginResolverState = ContextExState<{
|
|
7
|
-
resolver?: PayloadRenderPluginResolver
|
|
8
|
-
setResolver?: Dispatch<PayloadRenderPluginResolver>
|
|
9
|
-
}>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContextEx } from '@xylabs/react-shared'
|
|
2
|
-
|
|
3
|
-
import { PayloadRenderPluginResolverContext } from './Context.ts'
|
|
4
|
-
|
|
5
|
-
export const usePayloadRenderPluginResolver = (required = false) => {
|
|
6
|
-
return useContextEx(PayloadRenderPluginResolverContext, 'PayloadRenderPluginResolver', required)
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useResetState } from '@xylabs/react-hooks'
|
|
2
|
-
import type { ContextExProviderProps } from '@xylabs/react-shared'
|
|
3
|
-
import type { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { PayloadSetPluginResolverContext } from './Context.ts'
|
|
7
|
-
|
|
8
|
-
export type PayloadSetPluginResolverProviderProps = ContextExProviderProps<{
|
|
9
|
-
resolver: PayloadSetPluginResolver
|
|
10
|
-
}>
|
|
11
|
-
|
|
12
|
-
export const PayloadSetPluginResolverProvider: React.FC<PayloadSetPluginResolverProviderProps> = ({
|
|
13
|
-
resolver: resolverProp,
|
|
14
|
-
required = false,
|
|
15
|
-
children,
|
|
16
|
-
}) => {
|
|
17
|
-
const [resolver, setResolver] = useResetState<PayloadSetPluginResolver>(resolverProp)
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<PayloadSetPluginResolverContext
|
|
21
|
-
value={{
|
|
22
|
-
provided: true,
|
|
23
|
-
resolver,
|
|
24
|
-
setResolver,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
{resolver
|
|
28
|
-
? children
|
|
29
|
-
: required
|
|
30
|
-
? null
|
|
31
|
-
: children}
|
|
32
|
-
</PayloadSetPluginResolverContext>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContextEx } from '@xylabs/react-shared'
|
|
2
|
-
|
|
3
|
-
import { PayloadSetPluginResolverContext } from './Context.ts'
|
|
4
|
-
|
|
5
|
-
export const usePayloadSetPluginResolver = (required = false) => {
|
|
6
|
-
return useContextEx(PayloadSetPluginResolverContext, 'PayloadSetPluginResolver', required)
|
|
7
|
-
}
|
package/src/contexts/index.ts
DELETED
package/src/index.ts
DELETED