@xyo-network/react-schema 2.78.0 → 2.78.1

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.
@@ -1,2 +1,341 @@
1
- import{NewReleases as L,OpenInNew as A,Verified as z}from"@mui/icons-material";import{IconButton as y}from"@mui/material";import{useAsyncEffect as F}from"@xylabs/react-async-effect";import{LinkEx as B}from"@xylabs/react-link";import{useEvent as w}from"@xyo-network/react-event";import{Property as T,PropertyValue as g}from"@xyo-network/react-property";import{SchemaCache as Q}from"@xyo-network/schema-cache";import{forwardRef as H,useState as O}from"react";import{Fragment as G,jsx as u,jsxs as k}from"react/jsx-runtime";var V=t=>{let[n,a]=O();return F(async s=>{if(t){let o=await Q.instance.get(t);s()&&a(o)}},[t]),n},q=H(({showLinkNames:t=!0,showOpenNewWindowLink:n=!0,showStatusIcon:a=!0,titleProps:s,value:o,...e},r)=>{var S;let i=V(o),[f,c]=w(),[h,l]=w(),m=(d,b=!1)=>{d==null||d("schema","click",JSON.stringify({openNewWindow:b,schema:o}))};return k(T,{ref:r,title:"Schema",value:o,tip:"Schema sent with the payload",titleProps:s,...e,children:[o&&a?i===null?u(y,{ref:f,size:"small",onClick:()=>m(c),children:u(L,{color:"warning",fontSize:"inherit"})}):i===void 0?u(y,{ref:f,size:"small",onClick:()=>m(c),children:u(L,{color:"disabled",fontSize:"inherit"})}):u(y,{rel:"noopener noreferrer",size:"small",target:"_blank",href:((S=i==null?void 0:i.huri)==null?void 0:S.href)??"",children:u(z,{color:"success",fontSize:"inherit"})}):null,o?k(G,{children:[t?u(B,{display:"block",width:"100%",sx:{cursor:"pointer"},children:u(g,{ref:h,value:o,title:"view schema",onClick:()=>m(l)})}):u(g,{ref:h,value:o,title:"view schema",onClick:()=>m(l)}),n?u(y,{ref:f,size:"small",onClick:()=>m(c,!0),children:u(A,{fontSize:"inherit"})}):null]}):null]})});q.displayName="SchemaProperty";import{MenuItem as D,Typography as Pe}from"@mui/material";import{SelectEx as Ee}from"@xylabs/react-select";import{createContextEx as J}from"@xyo-network/react-shared";var p=J();import{compact as le}from"@xylabs/lodash";import{useEffect as he,useState as I}from"react";import{useAsyncEffect as Y}from"@xylabs/react-async-effect";import{PayloadBuilder as _}from"@xyo-network/payload-builder";import{ModuleErrorSchema as K}from"@xyo-network/payload-model";import{SchemaCache as U}from"@xyo-network/schema-cache";import{useState as P}from"react";var Ge=t=>{let[n,a]=P(!1),[s,o]=P(),[e,r]=P(),[i,f]=P();return Y(async c=>{let h=!n&&!e&&!s,l=t!==i;if(t&&h||t&&l)try{let m=await U.instance.get(t);c()&&(r(m),a(m==null))}catch(m){let S=m;console.error(m),c()&&o({message:S.message,schema:K,sources:[]})}l&&f(t)},[s,n,t,i,e]),{notFound:n,schemaHuri:e==null?void 0:e.huri,schemaPayload:e&&new _(e==null?void 0:e.payload).fields(e.payload).build(),xyoError:s}};import{useAsyncEffect as X}from"@xylabs/react-async-effect";import{SchemaCache as Z}from"@xyo-network/schema-cache";import{useState as $}from"react";var Ue=t=>{let[n,a]=$();return X(async s=>{if(t){let o=await Promise.allSettled(t==null?void 0:t.map(({name:e})=>Z.instance.get(e)));s()&&a(o.map(e=>{var r;return e.status==="fulfilled"?(r=e.value)==null?void 0:r.payload:void 0}).filter(e=>e!=null))}},[t]),n};import{useAsyncEffect as j}from"@xylabs/react-async-effect";import{SchemaListQuerySchema as ee}from"@xyo-network/diviner-schema-list-model";import{useWeakDivinerFromNode as te}from"@xyo-network/react-diviner";import{useEffect as re,useMemo as oe,useState as M}from"react";var ot=(t,n="SchemaListDiviner")=>{let[a,s]=M(),[o,e]=M(),[r,i]=te(n),f=oe(()=>t?[{address:t,schema:ee}]:void 0,[t]);return re(()=>{r===null&&(s(null),e(void 0))},[r]),j(async c=>{let h=r==null?void 0:r.deref();if(h)try{let l=await h.divine(f);c()&&(s(l==null?void 0:l[0]),e(void 0))}catch(l){e(l),s(void 0)}},[r,i,f]),[a,o]};import{useAsyncEffect as ae}from"@xylabs/react-async-effect";import{SchemaStatsDivinerSchema as ne,SchemaStatsQuerySchema as ie}from"@xyo-network/diviner-schema-stats-model";import{TYPES as se}from"@xyo-network/node-core-types";import{isPayloadOfSchemaTypeWithMeta as ce}from"@xyo-network/payload-model";import{useWeakDivinerFromNode as me}from"@xyo-network/react-diviner";import{useMemo as fe,useState as x}from"react";var W=(t,n=se.SchemaStatsDiviner)=>{let[a,s]=x(1),[o,e]=me(n),[r,i]=x(),f=()=>s(m=>m+1),[c,h]=x(),l=fe(()=>({address:t,schema:ie}),[t]);return ae(async m=>{let S=o==null?void 0:o.deref();if(S)if(e)m()&&(i(e),h(void 0));else try{let d=(await S.divine([l])).filter(ce(ne));m()&&(h(d),i(void 0))}catch(d){i(d),h(void 0)}},[o,a,e,l]),[c,r,f]};import{jsx as ue}from"react/jsx-runtime";var N=({defaultSchema:t,knownSchemaList:n=[],...a})=>{let[s,o]=I(t),[e,r]=I(n),[i]=W();return he(()=>{if(i){let f=le(i.map(({name:c})=>c));r(f)}},[i]),ue(p.Provider,{value:{provided:!0,schema:s,schemaList:n??e,setSchema:o,setSchemaList:r},...a})};import{useCallback as R,useEffect as de}from"react";import{useSearchParams as pe}from"react-router-dom";import{useContextEx as Se}from"@xyo-network/react-shared";var E=(t=!1)=>Se(p,"Schema",t);import{jsx as v}from"react/jsx-runtime";var ye=({children:t})=>{let{schema:n,setSchema:a,schemaList:s}=E(),[o,e]=pe(),r=o.get("schema"),i=R(c=>{c?(o.set("schema",c),e(o,{replace:!0}),a==null||a(c)):o.delete("network")},[o,e,a]),f=R(c=>{i(c),a==null||a(c)},[i,a]);return de(()=>{r!==n&&(r===void 0&&n!==void 0?f(n):r&&(a==null||a(r)))},[r,n,i,a,f]),v(p.Provider,{value:{provided:!0,schema:n,schemaList:s,setSchema:f},children:t})},Dt=({knownSchemaList:t,defaultSchema:n,...a})=>v(N,{knownSchemaList:t,defaultSchema:n,children:v(ye,{...a})});import{jsx as C,jsxs as xe}from"react/jsx-runtime";var Qt=({onChange:t,variant:n="outlined",...a})=>{let{schema:s,setSchema:o,schemaList:e}=E(!1);return xe(Ee,{variant:n,size:"small",value:s??"none",onChange:(r,i)=>{r.target.value!==s&&(t==null||t(r,i),o==null||o(r.target.value))},renderValue:r=>C(Pe,{children:r==="none"?"- None -":r}),...a,children:[e==null?void 0:e.map((r,i)=>C(D,{value:r,children:r},i)),C(D,{value:"none",children:"- None -"},"none")]})};export{p as SchemaContext,N as SchemaMemoryProvider,q as SchemaProperty,Dt as SchemaRouteProvider,Qt as SchemaSelectEx,Ge as useGetSchemaPayload,E as useSchema,Ue as useSchemaDefinitions,ot as useSchemaList,W as useSchemaStats};
1
+ // src/components/Property/SchemaProperty.tsx
2
+ import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from "@mui/icons-material";
3
+ import { IconButton } from "@mui/material";
4
+ import { useAsyncEffect } from "@xylabs/react-async-effect";
5
+ import { LinkEx } from "@xylabs/react-link";
6
+ import { useEvent } from "@xyo-network/react-event";
7
+ import { Property, PropertyValue } from "@xyo-network/react-property";
8
+ import { SchemaCache } from "@xyo-network/schema-cache";
9
+ import { forwardRef, useState } from "react";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ var useResolveSchema = (schema) => {
12
+ const [entry, setEntry] = useState();
13
+ useAsyncEffect(
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ async (mounted) => {
16
+ if (schema) {
17
+ const entry2 = await SchemaCache.instance.get(schema);
18
+ if (mounted()) {
19
+ setEntry(entry2);
20
+ }
21
+ }
22
+ },
23
+ [schema]
24
+ );
25
+ return entry;
26
+ };
27
+ var SchemaProperty = forwardRef(
28
+ ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
29
+ var _a;
30
+ const resolvedSchema = useResolveSchema(value);
31
+ const [buttonRef, buttonDispatch] = useEvent();
32
+ const [divRef, divDispatch] = useEvent();
33
+ const onClick = (dispatch, openNewWindow = false) => {
34
+ dispatch == null ? void 0 : dispatch(
35
+ "schema",
36
+ "click",
37
+ JSON.stringify({
38
+ openNewWindow,
39
+ schema: value
40
+ })
41
+ );
42
+ };
43
+ return /* @__PURE__ */ jsxs(Property, { ref: forwardedRef, title: "Schema", value, tip: "Schema sent with the payload", titleProps, ...props, children: [
44
+ value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "warning", fontSize: "inherit" }) }) : resolvedSchema === void 0 ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "disabled", fontSize: "inherit" }) }) : /* @__PURE__ */ jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: ((_a = resolvedSchema == null ? void 0 : resolvedSchema.huri) == null ? void 0 : _a.href) ?? "", children: /* @__PURE__ */ jsx(VerifiedIcon, { color: "success", fontSize: "inherit" }) }) : null,
45
+ value ? /* @__PURE__ */ jsxs(Fragment, { children: [
46
+ showLinkNames ? /* @__PURE__ */ jsx(LinkEx, { display: "block", width: "100%", sx: { cursor: "pointer" }, children: /* @__PURE__ */ jsx(PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }) }) : /* @__PURE__ */ jsx(PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }),
47
+ showOpenNewWindowLink ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch, true), children: /* @__PURE__ */ jsx(OpenInNewIcon, { fontSize: "inherit" }) }) : null
48
+ ] }) : null
49
+ ] });
50
+ }
51
+ );
52
+ SchemaProperty.displayName = "SchemaProperty";
53
+
54
+ // src/components/SelectEx/SchemaSelectEx.tsx
55
+ import { MenuItem, Typography } from "@mui/material";
56
+ import { SelectEx } from "@xylabs/react-select";
57
+
58
+ // src/contexts/Schema/Context.ts
59
+ import { createContextEx } from "@xyo-network/react-shared";
60
+ var SchemaContext = createContextEx();
61
+
62
+ // src/contexts/Schema/Provider/Memory.tsx
63
+ import { compact } from "@xylabs/lodash";
64
+ import { useEffect as useEffect2, useState as useState6 } from "react";
65
+
66
+ // src/hooks/useGetSchema.tsx
67
+ import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
68
+ import { PayloadBuilder } from "@xyo-network/payload-builder";
69
+ import { ModuleErrorSchema } from "@xyo-network/payload-model";
70
+ import { SchemaCache as SchemaCache2 } from "@xyo-network/schema-cache";
71
+ import { useState as useState2 } from "react";
72
+ var useGetSchemaPayload = (schema) => {
73
+ const [notFound, setNotFound] = useState2(false);
74
+ const [xyoError, setError] = useState2();
75
+ const [schemaCacheEntry, setSchemaCacheEntry] = useState2();
76
+ const [schemaLocal, setSchemaLocal] = useState2();
77
+ useAsyncEffect2(
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ async (mounted) => {
80
+ const firstRequest = !notFound && !schemaCacheEntry && !xyoError;
81
+ const schemaChanged = schema !== schemaLocal;
82
+ if (schema && firstRequest || schema && schemaChanged) {
83
+ try {
84
+ const schemaCacheEntry2 = await SchemaCache2.instance.get(schema);
85
+ if (mounted()) {
86
+ setSchemaCacheEntry(schemaCacheEntry2);
87
+ setNotFound(schemaCacheEntry2 === null || schemaCacheEntry2 === void 0);
88
+ }
89
+ } catch (e) {
90
+ const error = e;
91
+ console.error(e);
92
+ if (mounted()) {
93
+ setError({ message: error.message, schema: ModuleErrorSchema, sources: [] });
94
+ }
95
+ }
96
+ }
97
+ if (schemaChanged) {
98
+ setSchemaLocal(schema);
99
+ }
100
+ },
101
+ [xyoError, notFound, schema, schemaLocal, schemaCacheEntry]
102
+ );
103
+ return {
104
+ notFound,
105
+ schemaHuri: schemaCacheEntry == null ? void 0 : schemaCacheEntry.huri,
106
+ schemaPayload: schemaCacheEntry ? new PayloadBuilder(schemaCacheEntry == null ? void 0 : schemaCacheEntry.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,
107
+ xyoError
108
+ };
109
+ };
110
+
111
+ // src/hooks/useSchemaDefinitions.tsx
112
+ import { useAsyncEffect as useAsyncEffect3 } from "@xylabs/react-async-effect";
113
+ import { SchemaCache as SchemaCache3 } from "@xyo-network/schema-cache";
114
+ import { useState as useState3 } from "react";
115
+ var useSchemaDefinitions = (schemaList) => {
116
+ const [schemaPayloads, setSchemaPayloads] = useState3();
117
+ useAsyncEffect3(
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ async (mounted) => {
120
+ if (schemaList) {
121
+ const promiseResults = await Promise.allSettled(schemaList == null ? void 0 : schemaList.map(({ name }) => SchemaCache3.instance.get(name)));
122
+ if (mounted()) {
123
+ setSchemaPayloads(
124
+ promiseResults.map((result) => {
125
+ var _a;
126
+ return result.status === "fulfilled" ? (_a = result.value) == null ? void 0 : _a.payload : void 0;
127
+ }).filter((item) => item !== void 0 && item !== null)
128
+ );
129
+ }
130
+ }
131
+ },
132
+ [schemaList]
133
+ );
134
+ return schemaPayloads;
135
+ };
136
+
137
+ // src/hooks/useSchemaList.tsx
138
+ import { useAsyncEffect as useAsyncEffect4 } from "@xylabs/react-async-effect";
139
+ import { SchemaListQuerySchema } from "@xyo-network/diviner-schema-list-model";
140
+ import { useWeakDivinerFromNode } from "@xyo-network/react-diviner";
141
+ import { useEffect, useMemo, useState as useState4 } from "react";
142
+ var useSchemaList = (address, nameOrAddress = "SchemaListDiviner") => {
143
+ const [schemaList, setSchemaList] = useState4();
144
+ const [error, setError] = useState4();
145
+ const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress);
146
+ const query = useMemo(
147
+ () => address ? [
148
+ {
149
+ address,
150
+ schema: SchemaListQuerySchema
151
+ }
152
+ ] : void 0,
153
+ [address]
154
+ );
155
+ useEffect(() => {
156
+ if (diviner === null) {
157
+ setSchemaList(null);
158
+ setError(void 0);
159
+ }
160
+ }, [diviner]);
161
+ useAsyncEffect4(
162
+ // eslint-disable-next-line react-hooks/exhaustive-deps, require-await
163
+ async (mounted) => {
164
+ const divinerInstance = diviner == null ? void 0 : diviner.deref();
165
+ if (divinerInstance) {
166
+ try {
167
+ const response = await divinerInstance.divine(query);
168
+ if (mounted()) {
169
+ setSchemaList(response == null ? void 0 : response[0]);
170
+ setError(void 0);
171
+ }
172
+ } catch (e) {
173
+ setError(e);
174
+ setSchemaList(void 0);
175
+ }
176
+ }
177
+ },
178
+ [diviner, divinerError, query]
179
+ );
180
+ return [schemaList, error];
181
+ };
182
+
183
+ // src/hooks/useSchemaStats.tsx
184
+ import { useAsyncEffect as useAsyncEffect5 } from "@xylabs/react-async-effect";
185
+ import {
186
+ SchemaStatsDivinerSchema,
187
+ SchemaStatsQuerySchema
188
+ } from "@xyo-network/diviner-schema-stats-model";
189
+ import { TYPES } from "@xyo-network/node-core-types";
190
+ import { isPayloadOfSchemaTypeWithMeta } from "@xyo-network/payload-model";
191
+ import { useWeakDivinerFromNode as useWeakDivinerFromNode2 } from "@xyo-network/react-diviner";
192
+ import { useMemo as useMemo2, useState as useState5 } from "react";
193
+ var useSchemaStats = (statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner) => {
194
+ const [refresh, setRefresh] = useState5(1);
195
+ const [diviner, divinerError] = useWeakDivinerFromNode2(nameOrAddress);
196
+ const [error, setError] = useState5();
197
+ const refreshHistory = () => setRefresh((previous) => previous + 1);
198
+ const [schemaList, setSchemaList] = useState5();
199
+ const query = useMemo2(
200
+ () => ({
201
+ address: statsAddress,
202
+ schema: SchemaStatsQuerySchema
203
+ }),
204
+ [statsAddress]
205
+ );
206
+ useAsyncEffect5(
207
+ // eslint-disable-next-line react-hooks/exhaustive-deps
208
+ async (mounted) => {
209
+ const instance = diviner == null ? void 0 : diviner.deref();
210
+ if (instance) {
211
+ if (divinerError) {
212
+ if (mounted()) {
213
+ setError(divinerError);
214
+ setSchemaList(void 0);
215
+ }
216
+ } else {
217
+ try {
218
+ const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema));
219
+ if (mounted()) {
220
+ setSchemaList(schemas);
221
+ setError(void 0);
222
+ }
223
+ } catch (ex) {
224
+ setError(ex);
225
+ setSchemaList(void 0);
226
+ }
227
+ }
228
+ }
229
+ },
230
+ [diviner, refresh, divinerError, query]
231
+ );
232
+ return [schemaList, error, refreshHistory];
233
+ };
234
+
235
+ // src/contexts/Schema/Provider/Memory.tsx
236
+ import { jsx as jsx2 } from "react/jsx-runtime";
237
+ var SchemaMemoryProvider = ({ defaultSchema, knownSchemaList = [], ...props }) => {
238
+ const [schema, setSchema] = useState6(defaultSchema);
239
+ const [schemaList, setSchemaList] = useState6(knownSchemaList);
240
+ const [fetchedSchemaStats] = useSchemaStats();
241
+ useEffect2(() => {
242
+ if (fetchedSchemaStats) {
243
+ const schemaList2 = compact(fetchedSchemaStats.map(({ name }) => name));
244
+ setSchemaList(schemaList2);
245
+ }
246
+ }, [fetchedSchemaStats]);
247
+ return /* @__PURE__ */ jsx2(SchemaContext.Provider, { value: { provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }, ...props });
248
+ };
249
+
250
+ // src/contexts/Schema/Provider/Route.tsx
251
+ import { useCallback, useEffect as useEffect3 } from "react";
252
+ import { useSearchParams } from "react-router-dom";
253
+
254
+ // src/contexts/Schema/use.ts
255
+ import { useContextEx } from "@xyo-network/react-shared";
256
+ var useSchema = (required = false) => {
257
+ return useContextEx(SchemaContext, "Schema", required);
258
+ };
259
+
260
+ // src/contexts/Schema/Provider/Route.tsx
261
+ import { jsx as jsx3 } from "react/jsx-runtime";
262
+ var SchemaRouteProviderInner = ({ children }) => {
263
+ const { schema, setSchema, schemaList } = useSchema();
264
+ const [params, setParams] = useSearchParams();
265
+ const routeSchema = params.get("schema");
266
+ const setSchemaParam = useCallback(
267
+ (schema2) => {
268
+ if (schema2) {
269
+ params.set("schema", schema2);
270
+ setParams(params, { replace: true });
271
+ setSchema == null ? void 0 : setSchema(schema2);
272
+ } else {
273
+ params.delete("network");
274
+ }
275
+ },
276
+ [params, setParams, setSchema]
277
+ );
278
+ const setSchemaLocal = useCallback(
279
+ (schema2) => {
280
+ setSchemaParam(schema2);
281
+ setSchema == null ? void 0 : setSchema(schema2);
282
+ },
283
+ [setSchemaParam, setSchema]
284
+ );
285
+ useEffect3(() => {
286
+ if (routeSchema !== schema) {
287
+ if (routeSchema === void 0 && schema !== void 0) {
288
+ setSchemaLocal(schema);
289
+ } else if (routeSchema) {
290
+ setSchema == null ? void 0 : setSchema(routeSchema);
291
+ }
292
+ }
293
+ }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal]);
294
+ return /* @__PURE__ */ jsx3(SchemaContext.Provider, { value: { provided: true, schema, schemaList, setSchema: setSchemaLocal }, children });
295
+ };
296
+ var SchemaRouteProvider = ({ knownSchemaList, defaultSchema, ...props }) => {
297
+ return /* @__PURE__ */ jsx3(SchemaMemoryProvider, { knownSchemaList, defaultSchema, children: /* @__PURE__ */ jsx3(SchemaRouteProviderInner, { ...props }) });
298
+ };
299
+
300
+ // src/components/SelectEx/SchemaSelectEx.tsx
301
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
302
+ var SchemaSelectEx = ({ onChange, variant = "outlined", ...props }) => {
303
+ const { schema, setSchema, schemaList } = useSchema(false);
304
+ return /* @__PURE__ */ jsxs2(
305
+ SelectEx,
306
+ {
307
+ variant,
308
+ size: "small",
309
+ value: schema ?? "none",
310
+ onChange: (event, child) => {
311
+ if (event.target.value !== schema) {
312
+ onChange == null ? void 0 : onChange(event, child);
313
+ setSchema == null ? void 0 : setSchema(event.target.value);
314
+ }
315
+ },
316
+ renderValue: (value) => {
317
+ return /* @__PURE__ */ jsx4(Typography, { children: value === "none" ? "- None -" : value });
318
+ },
319
+ ...props,
320
+ children: [
321
+ schemaList == null ? void 0 : schemaList.map((schema2, index) => {
322
+ return /* @__PURE__ */ jsx4(MenuItem, { value: schema2, children: schema2 }, index);
323
+ }),
324
+ /* @__PURE__ */ jsx4(MenuItem, { value: "none", children: "- None -" }, "none")
325
+ ]
326
+ }
327
+ );
328
+ };
329
+ export {
330
+ SchemaContext,
331
+ SchemaMemoryProvider,
332
+ SchemaProperty,
333
+ SchemaRouteProvider,
334
+ SchemaSelectEx,
335
+ useGetSchemaPayload,
336
+ useSchema,
337
+ useSchemaDefinitions,
338
+ useSchemaList,
339
+ useSchemaStats
340
+ };
2
341
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { LinkEx } from '@xylabs/react-link'\nimport { EventDispatch, EventNoun, useEvent } from '@xyo-network/react-event'\nimport { Property, PropertyProps, PropertyValue } from '@xyo-network/react-property'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { forwardRef, useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(\n ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property ref={forwardedRef} title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon ?\n resolvedSchema === null ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n : resolvedSchema === undefined ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n : <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n\n : null}\n {value ?\n <>\n {showLinkNames ?\n <LinkEx display=\"block\" width=\"100%\" sx={{ cursor: 'pointer' }}>\n <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />\n </LinkEx>\n : <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />}\n {showOpenNewWindowLink ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n : null}\n </>\n : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, variant = 'outlined', ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema, index) => {\n return (\n <MenuItem key={index} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks'\nimport { SchemaContext } from '../Context'\nimport { SchemaProviderProps } from './Props'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList = [], ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string) => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setError] = useState<ModuleError>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setError({ message: error.message, schema: ModuleErrorSchema, sources: [] })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport type SchemaList = { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map((result) => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter((item) => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { WithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address ?\n [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n useEffect(() => {\n if (diviner === null) {\n setSchemaList(null)\n setError(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps, require-await\n async (mounted) => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n try {\n const response = (await divinerInstance.divine(query)) as WithMeta<SchemaListPayload>[]\n if (mounted()) {\n setSchemaList(response?.[0])\n setError(undefined)\n }\n } catch (e) {\n setError(e as Error)\n setSchemaList(undefined)\n }\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { isPayloadOfSchemaTypeWithMeta, WithMeta, WithSources } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<WithMeta<SchemaStatsPayload>>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const instance = diviner?.deref()\n if (instance) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema)) as WithSources<\n WithMeta<SchemaStatsPayload>\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { useCallback, useEffect } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context'\nimport { useSchema } from '../use'\nimport { SchemaMemoryProvider } from './Memory'\nimport { SchemaProviderProps } from './Props'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n //update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n //if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n //sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n //if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n //if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList, setSchema: setSchemaLocal }}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":"AAAA,OAAS,eAAeA,EAAiB,aAAaC,EAAe,YAAYC,MAAoB,sBACrG,OAAS,cAAAC,MAAkB,gBAC3B,OAAS,kBAAAC,MAAsB,6BAC/B,OAAS,UAAAC,MAAc,qBACvB,OAAmC,YAAAC,MAAgB,2BACnD,OAAS,YAAAC,EAAyB,iBAAAC,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,EAAe,GAAGC,CAAM,IAExHnB,EAACoB,EAAA,CAAqB,gBAAiBH,EAAiB,cAAeC,EACrE,SAAAlB,EAACC,GAAA,CAA0B,GAAGkB,EAAO,EACvC,EPhDA,OAWW,OAAAE,EAXX,QAAAC,OAAA,oBAJG,IAAMC,GAAgD,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAU,WAAY,GAAGC,CAAM,IAAM,CAC7G,GAAM,CAAE,OAAAC,EAAQ,UAAAC,EAAW,WAAAC,CAAW,EAAIC,EAAU,EAAK,EAEzD,OACER,GAACS,GAAA,CACC,QAASN,EACT,KAAK,QACL,MAAOE,GAAU,OACjB,SAAU,CAACK,EAAOC,IAAU,CACtBD,EAAM,OAAO,QAAUL,IACzBH,GAAA,MAAAA,EAAWQ,EAAOC,GAClBL,GAAA,MAAAA,EAAYI,EAAM,OAAO,OAE7B,EACA,YAAcE,GACLb,EAACc,GAAA,CAAY,SAAAD,IAAU,OAAS,WAAaA,EAAM,EAE3D,GAAGR,EAEH,UAAAG,GAAA,YAAAA,EAAY,IAAI,CAACF,EAAQS,IAEtBf,EAACgB,EAAA,CAAqB,MAAOV,EAC1B,SAAAA,GADYS,CAEf,GAGJf,EAACgB,EAAA,CAAoB,MAAM,OAAO,qBAApB,MAEd,GACF,CAEJ","names":["NewReleasesIcon","OpenInNewIcon","VerifiedIcon","IconButton","useAsyncEffect","LinkEx","useEvent","Property","PropertyValue","SchemaCache","forwardRef","useState","Fragment","jsx","jsxs","useResolveSchema","schema","entry","setEntry","mounted","SchemaProperty","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","forwardedRef","_a","resolvedSchema","buttonRef","buttonDispatch","divRef","divDispatch","onClick","dispatch","openNewWindow","MenuItem","Typography","SelectEx","createContextEx","SchemaContext","compact","useEffect","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","xyoError","setError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","mounted","firstRequest","schemaChanged","e","error","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","mounted","promiseResults","name","result","_a","item","useAsyncEffect","SchemaListQuerySchema","useWeakDivinerFromNode","useEffect","useMemo","useState","useSchemaList","address","nameOrAddress","schemaList","setSchemaList","error","setError","diviner","divinerError","query","mounted","divinerInstance","response","e","useAsyncEffect","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaTypeWithMeta","useWeakDivinerFromNode","useMemo","useState","useSchemaStats","statsAddress","nameOrAddress","refresh","setRefresh","diviner","divinerError","error","setError","refreshHistory","previous","schemaList","setSchemaList","query","mounted","instance","schemas","ex","jsx","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useEffect","compact","name","SchemaContext","useCallback","useEffect","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","jsx","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","setSchemaParam","useCallback","setSchemaLocal","useEffect","SchemaContext","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","jsx","jsxs","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","SelectEx","event","child","value","Typography","index","MenuItem"]}
1
+ {"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { LinkEx } from '@xylabs/react-link'\nimport { EventDispatch, EventNoun, useEvent } from '@xyo-network/react-event'\nimport { Property, PropertyProps, PropertyValue } from '@xyo-network/react-property'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { forwardRef, useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(\n ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property ref={forwardedRef} title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon ?\n resolvedSchema === null ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n : resolvedSchema === undefined ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n : <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n\n : null}\n {value ?\n <>\n {showLinkNames ?\n <LinkEx display=\"block\" width=\"100%\" sx={{ cursor: 'pointer' }}>\n <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />\n </LinkEx>\n : <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />}\n {showOpenNewWindowLink ?\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n : null}\n </>\n : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, variant = 'outlined', ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema, index) => {\n return (\n <MenuItem key={index} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks'\nimport { SchemaContext } from '../Context'\nimport { SchemaProviderProps } from './Props'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList = [], ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string) => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setError] = useState<ModuleError>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setError({ message: error.message, schema: ModuleErrorSchema, sources: [] })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport type SchemaList = { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map((result) => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter((item) => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { WithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address ?\n [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n useEffect(() => {\n if (diviner === null) {\n setSchemaList(null)\n setError(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps, require-await\n async (mounted) => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n try {\n const response = (await divinerInstance.divine(query)) as WithMeta<SchemaListPayload>[]\n if (mounted()) {\n setSchemaList(response?.[0])\n setError(undefined)\n }\n } catch (e) {\n setError(e as Error)\n setSchemaList(undefined)\n }\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { isPayloadOfSchemaTypeWithMeta, WithMeta, WithSources } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<WithMeta<SchemaStatsPayload>>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const instance = diviner?.deref()\n if (instance) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema)) as WithSources<\n WithMeta<SchemaStatsPayload>\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { useCallback, useEffect } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context'\nimport { useSchema } from '../use'\nimport { SchemaMemoryProvider } from './Memory'\nimport { SchemaProviderProps } from './Props'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n //update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n //if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n //sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n //if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n //if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList, setSchema: setSchemaLocal }}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB,aAAa,eAAe,YAAY,oBAAoB;AACrG,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAmC,gBAAgB;AACnD,SAAS,UAAyB,qBAAqB;AACvD,SAAS,mBAAqC;AAC9C,SAAS,YAAY,gBAAgB;AAgDvB,SAYJ,UAZI,KAYJ,YAZI;AAvCd,IAAM,mBAAmB,CAAC,WAAoB;AAC5C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC;AAC5D;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,QAAQ;AACV,cAAMA,SAAQ,MAAM,YAAY,SAAS,IAAI,MAAM;AACnD,YAAI,QAAQ,GAAG;AACb,mBAASA,MAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,iBAAiB;AAAA,EAC5B,CAAC,EAAE,gBAAgB,MAAM,wBAAwB,MAAM,iBAAiB,MAAM,YAAY,OAAO,GAAG,MAAM,GAAG,iBAAiB;AAlChI;AAmCI,UAAM,iBAAiB,iBAAiB,KAAK;AAC7C,UAAM,CAAC,WAAW,cAAc,IAAI,SAA4B;AAChE,UAAM,CAAC,QAAQ,WAAW,IAAI,SAAyB;AAEvD,UAAM,UAAU,CAAC,UAAsD,gBAAgB,UAAU;AAC/F;AAAA,QACE;AAAA,QACA;AAAA,QACA,KAAK,UAAU;AAAA,UACb;AAAA,UACA,QAA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OAAO;AAClB,iDAAY,MAAM,OAAO;AAAA,QAC3B;AAAA,MACF;AAAA,MACA,aAAa,CAAC,UAAU;AACtB,eAAO,gBAAAD,KAAC,cAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,iDAAY,IAAI,CAACE,SAAQ,UAAU;AAClC,iBACE,gBAAAF,KAAC,YAAqB,OAAOE,SAC1B,UAAAA,WADY,KAEf;AAAA,QAEJ;AAAA,QACA,gBAAAF,KAAC,YAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["entry","useEffect","useState","useAsyncEffect","SchemaCache","useState","schemaCacheEntry","useAsyncEffect","SchemaCache","useState","useAsyncEffect","useState","useAsyncEffect","useWeakDivinerFromNode","useMemo","useState","jsx","useState","useEffect","schemaList","useEffect","jsx","schema","useEffect","jsx","jsxs","schema"]}
package/package.json CHANGED
@@ -10,37 +10,37 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xylabs/hex": "^3.5.1",
14
- "@xylabs/lodash": "^3.5.1",
13
+ "@xylabs/hex": "^3.5.2",
14
+ "@xylabs/lodash": "^3.5.2",
15
15
  "@xylabs/react-async-effect": "^3.1.7",
16
16
  "@xylabs/react-link": "^3.1.7",
17
17
  "@xylabs/react-select": "^3.1.7",
18
18
  "@xylabs/react-shared": "^3.1.7",
19
- "@xyo-network/diviner-schema-list-model": "^2.107.0",
20
- "@xyo-network/diviner-schema-stats-model": "^2.107.0",
19
+ "@xyo-network/diviner-schema-list-model": "^2.107.6",
20
+ "@xyo-network/diviner-schema-stats-model": "^2.107.6",
21
21
  "@xyo-network/node-core-types": "^2.88.8",
22
- "@xyo-network/payload-builder": "^2.107.0",
23
- "@xyo-network/payload-model": "^2.107.0",
24
- "@xyo-network/react-diviner": "~2.78.0",
25
- "@xyo-network/react-event": "~2.78.0",
26
- "@xyo-network/react-property": "~2.78.0",
27
- "@xyo-network/react-shared": "~2.78.0",
28
- "@xyo-network/schema-cache": "^2.107.0",
29
- "@xyo-network/schema-payload-plugin": "^2.107.0",
22
+ "@xyo-network/payload-builder": "^2.107.6",
23
+ "@xyo-network/payload-model": "^2.107.6",
24
+ "@xyo-network/react-diviner": "^2.78.1",
25
+ "@xyo-network/react-event": "^2.78.1",
26
+ "@xyo-network/react-property": "^2.78.1",
27
+ "@xyo-network/react-shared": "^2.78.1",
28
+ "@xyo-network/schema-cache": "^2.107.6",
29
+ "@xyo-network/schema-payload-plugin": "^2.107.6",
30
30
  "react-router-dom": "^6.24.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@storybook/react": "^7.6.20",
34
34
  "@xylabs/react-flexbox": "^3.1.7",
35
- "@xylabs/ts-scripts-yarn3": "^3.11.8",
36
- "@xylabs/tsconfig-react": "^3.11.8",
37
- "@xyo-network/bridge-http": "^2.107.0",
38
- "@xyo-network/node-memory": "^2.107.0",
39
- "@xyo-network/node-model": "^2.107.0",
40
- "@xyo-network/react-node": "~2.78.0",
41
- "@xyo-network/react-payload-raw-info": "~2.78.0",
42
- "@xyo-network/react-storybook": "~2.78.0",
43
- "@xyo-network/react-wallet": "~2.78.0",
35
+ "@xylabs/ts-scripts-yarn3": "^3.11.12",
36
+ "@xylabs/tsconfig-react": "^3.11.12",
37
+ "@xyo-network/bridge-http": "^2.107.6",
38
+ "@xyo-network/node-memory": "^2.107.6",
39
+ "@xyo-network/node-model": "^2.107.6",
40
+ "@xyo-network/react-node": "^2.78.1",
41
+ "@xyo-network/react-payload-raw-info": "^2.78.1",
42
+ "@xyo-network/react-storybook": "^2.78.1",
43
+ "@xyo-network/react-wallet": "^2.78.1",
44
44
  "typescript": "^5.5.2"
45
45
  },
46
46
  "peerDependencies": {
@@ -103,6 +103,6 @@
103
103
  },
104
104
  "sideEffects": false,
105
105
  "types": "dist/browser/index.d.ts",
106
- "version": "2.78.0",
106
+ "version": "2.78.1",
107
107
  "type": "module"
108
108
  }