@xyo-network/react-schema 7.5.3 → 7.5.4
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/hooks/useSchemaStats.d.ts +1 -1
- package/dist/browser/hooks/useSchemaStats.d.ts.map +1 -1
- package/dist/browser/index.mjs +17 -18
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +32 -32
- package/src/components/SelectEx/SchemaSelectEx.tsx +2 -2
- package/src/hooks/stories/TestSchemaHooks.stories.tsx +2 -2
- package/src/hooks/useGetSchema.stories.tsx +2 -2
- package/src/hooks/useGetSchema.tsx +2 -2
- package/src/hooks/useSchemaStats.tsx +8 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Address } from '@xylabs/sdk-js';
|
|
2
2
|
import type { SchemaStatsPayload } from '@xyo-network/diviner-schema-stats-model';
|
|
3
3
|
import type { Dispatch, SetStateAction } from 'react';
|
|
4
4
|
export declare const useSchemaStats: (statsAddress?: Address, nameOrAddress?: string) => [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSchemaStats.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaStats.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useSchemaStats.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaStats.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,yCAAyC,CAAA;AAShD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAGrD,eAAO,MAAM,cAAc,GACzB,eAAe,OAAO,EACtB,sBAAwC,KACvC,CAAC,kBAAkB,EAAE,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAyCxF,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -126,7 +126,7 @@ var SchemaContext = createContextEx();
|
|
|
126
126
|
|
|
127
127
|
// src/contexts/Schema/Provider/Memory.tsx
|
|
128
128
|
import { exists } from "@xylabs/sdk-js";
|
|
129
|
-
import React2, { useMemo as
|
|
129
|
+
import React2, { useMemo as useMemo2, useState as useState5 } from "react";
|
|
130
130
|
|
|
131
131
|
// src/hooks/useGetSchema.tsx
|
|
132
132
|
import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
|
|
@@ -136,7 +136,7 @@ import { SchemaCache as SchemaCache2 } from "@xyo-network/schema-cache";
|
|
|
136
136
|
import { useState as useState2 } from "react";
|
|
137
137
|
var useGetSchemaPayload = /* @__PURE__ */ __name((schema) => {
|
|
138
138
|
const [notFound, setNotFound] = useState2(false);
|
|
139
|
-
const [xyoError,
|
|
139
|
+
const [xyoError, setXyoError] = useState2();
|
|
140
140
|
const [schemaCacheEntry, setSchemaCacheEntry] = useState2();
|
|
141
141
|
const [schemaLocal, setSchemaLocal] = useState2();
|
|
142
142
|
useAsyncEffect2(async (mounted) => {
|
|
@@ -153,7 +153,7 @@ var useGetSchemaPayload = /* @__PURE__ */ __name((schema) => {
|
|
|
153
153
|
const error = e;
|
|
154
154
|
console.error(e);
|
|
155
155
|
if (mounted()) {
|
|
156
|
-
|
|
156
|
+
setXyoError({
|
|
157
157
|
message: error.message,
|
|
158
158
|
schema: ModuleErrorSchema,
|
|
159
159
|
$sources: []
|
|
@@ -232,26 +232,21 @@ var useSchemaList = /* @__PURE__ */ __name((address, nameOrAddress = "SchemaList
|
|
|
232
232
|
|
|
233
233
|
// src/hooks/useSchemaStats.tsx
|
|
234
234
|
import { useAsyncEffect as useAsyncEffect4 } from "@xylabs/react-async-effect";
|
|
235
|
+
import { isDefined } from "@xylabs/sdk-js";
|
|
235
236
|
import { SchemaStatsDivinerSchema, SchemaStatsQuerySchema } from "@xyo-network/diviner-schema-stats-model";
|
|
236
237
|
import { TYPES } from "@xyo-network/node-core-types";
|
|
237
238
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
238
239
|
import { useWeakDivinerFromNode as useWeakDivinerFromNode2 } from "@xyo-network/react-diviner";
|
|
239
|
-
import {
|
|
240
|
+
import { useState as useState4 } from "react";
|
|
240
241
|
var useSchemaStats = /* @__PURE__ */ __name((statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner) => {
|
|
241
242
|
const [refresh, setRefresh] = useState4(1);
|
|
242
243
|
const [diviner, divinerError] = useWeakDivinerFromNode2(nameOrAddress);
|
|
243
244
|
const [error, setError] = useState4();
|
|
244
245
|
const refreshHistory = /* @__PURE__ */ __name(() => setRefresh((previous) => previous + 1), "refreshHistory");
|
|
245
246
|
const [schemaList, setSchemaList] = useState4();
|
|
246
|
-
const query = useMemo2(() => ({
|
|
247
|
-
address: statsAddress,
|
|
248
|
-
schema: SchemaStatsQuerySchema
|
|
249
|
-
}), [
|
|
250
|
-
statsAddress
|
|
251
|
-
]);
|
|
252
247
|
useAsyncEffect4(async (mounted) => {
|
|
253
248
|
const instance = diviner?.deref();
|
|
254
|
-
if (instance) {
|
|
249
|
+
if (isDefined(instance) && isDefined(statsAddress)) {
|
|
255
250
|
if (divinerError) {
|
|
256
251
|
if (mounted()) {
|
|
257
252
|
setError(divinerError);
|
|
@@ -259,6 +254,10 @@ var useSchemaStats = /* @__PURE__ */ __name((statsAddress, nameOrAddress = TYPES
|
|
|
259
254
|
}
|
|
260
255
|
} else {
|
|
261
256
|
try {
|
|
257
|
+
const query = {
|
|
258
|
+
address: statsAddress,
|
|
259
|
+
schema: SchemaStatsQuerySchema
|
|
260
|
+
};
|
|
262
261
|
const schemas = (await instance.divine([
|
|
263
262
|
query
|
|
264
263
|
])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema));
|
|
@@ -276,7 +275,7 @@ var useSchemaStats = /* @__PURE__ */ __name((statsAddress, nameOrAddress = TYPES
|
|
|
276
275
|
diviner,
|
|
277
276
|
refresh,
|
|
278
277
|
divinerError,
|
|
279
|
-
|
|
278
|
+
statsAddress
|
|
280
279
|
]);
|
|
281
280
|
return [
|
|
282
281
|
schemaList,
|
|
@@ -290,7 +289,7 @@ var SchemaMemoryProvider = /* @__PURE__ */ __name(({ defaultSchema, knownSchemaL
|
|
|
290
289
|
const [schema, setSchema] = useState5(defaultSchema);
|
|
291
290
|
const [schemaList, setSchemaList] = useState5(knownSchemaList);
|
|
292
291
|
const [fetchedSchemaStats] = useSchemaStats();
|
|
293
|
-
|
|
292
|
+
useMemo2(() => {
|
|
294
293
|
if (fetchedSchemaStats) {
|
|
295
294
|
const schemaList2 = fetchedSchemaStats.map(({ name }) => name).filter(exists);
|
|
296
295
|
setSchemaList(schemaList2);
|
|
@@ -298,7 +297,7 @@ var SchemaMemoryProvider = /* @__PURE__ */ __name(({ defaultSchema, knownSchemaL
|
|
|
298
297
|
}, [
|
|
299
298
|
fetchedSchemaStats
|
|
300
299
|
]);
|
|
301
|
-
const value =
|
|
300
|
+
const value = useMemo2(() => ({
|
|
302
301
|
provided: true,
|
|
303
302
|
schema,
|
|
304
303
|
schemaList: knownSchemaList ?? schemaList,
|
|
@@ -316,7 +315,7 @@ var SchemaMemoryProvider = /* @__PURE__ */ __name(({ defaultSchema, knownSchemaL
|
|
|
316
315
|
}, "SchemaMemoryProvider");
|
|
317
316
|
|
|
318
317
|
// src/contexts/Schema/Provider/Route.tsx
|
|
319
|
-
import React3, { useCallback, useEffect, useMemo as
|
|
318
|
+
import React3, { useCallback, useEffect, useMemo as useMemo3 } from "react";
|
|
320
319
|
import { useSearchParams } from "react-router-dom";
|
|
321
320
|
|
|
322
321
|
// src/contexts/Schema/use.ts
|
|
@@ -367,7 +366,7 @@ var SchemaRouteProviderInner = /* @__PURE__ */ __name(({ children }) => {
|
|
|
367
366
|
setSchema,
|
|
368
367
|
setSchemaLocal
|
|
369
368
|
]);
|
|
370
|
-
const value =
|
|
369
|
+
const value = useMemo3(() => ({
|
|
371
370
|
provided: true,
|
|
372
371
|
schema,
|
|
373
372
|
schemaList,
|
|
@@ -405,9 +404,9 @@ var SchemaSelectEx = /* @__PURE__ */ __name(({ onChange, variant = "outlined", .
|
|
|
405
404
|
return /* @__PURE__ */ React4.createElement(Typography, null, value === "none" ? "- None -" : value);
|
|
406
405
|
}, "renderValue"),
|
|
407
406
|
...props
|
|
408
|
-
}, schemaList?.map((schema2
|
|
407
|
+
}, schemaList?.map((schema2) => {
|
|
409
408
|
return /* @__PURE__ */ React4.createElement(MenuItem, {
|
|
410
|
-
key:
|
|
409
|
+
key: schemaList.indexOf(schema2),
|
|
411
410
|
value: schema2
|
|
412
411
|
}, schema2);
|
|
413
412
|
}), /* @__PURE__ */ React4.createElement(MenuItem, {
|
|
@@ -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 {\n NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,\n} from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { 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 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: React.FC<SchemaPropertyProps> = ({\n showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props\n}) => {\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 title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <FlexGrowRow ref={divRef} justifyContent=\"space-between\">\n {showLinkNames\n ? (\n <LinkEx\n display=\"block\"\n width=\"100%\"\n sx={{ cursor: 'pointer' }}\n >\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n </LinkEx>\n )\n : (\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n )}\n {showOpenNewWindowLink\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch, true)\n }}\n >\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </FlexGrowRow>\n )\n : null}\n </Property>\n )\n}\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({\n onChange, variant = 'outlined', ...props\n}) => {\n const {\n schema, setSchema, schemaList,\n } = 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 '@xylabs/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/sdk-js'\nimport type { PropsWithChildren } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n defaultSchema, knownSchemaList, ...props\n}) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useMemo(() => {\n if (fetchedSchemaStats) {\n const schemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,\n }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError, WithSources } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { 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<WithSources<ModuleError>>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\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({\n message: error.message, schema: ModuleErrorSchema, $sources: [],\n })\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 type { 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 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 { usePromise } from '@xylabs/react-promise'\nimport type { Address } from '@xylabs/sdk-js'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list-model'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useMemo } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\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 const [schemaList, error] = usePromise(\n async () => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n const response = (await divinerInstance.divine(query)) as SchemaListPayload[]\n return response.at(0)\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { Address } from '@xylabs/sdk-js'\nimport type {\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n} from '@xyo-network/diviner-schema-stats-model'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { 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<SchemaStatsPayload>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\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(isPayloadOfSchemaType(SchemaStatsDivinerSchema)) as WithSources<\n 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 { PropsWithChildren } from 'react'\nimport React, {\n useCallback, useEffect, useMemo,\n} from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<PropsWithChildren> = ({ children }) => {\n const {\n schema, setSchema, schemaList,\n } = 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 const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList, setSchema: setSchemaLocal,\n }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext value={value}>{children}</SchemaContext>\n}\n\nexport const SchemaRouteProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n knownSchemaList, defaultSchema, ...props\n}) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;AAAA,SACEA,eAAeC,iBAAiBC,aAAaC,eAAeC,YAAYC,oBACnE;AACP,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;AAC5B,SAASC,cAAc;AAEvB,SAASC,gBAAgB;AAEzB,SAASC,UAAUC,qBAAqB;AAExC,SAASC,mBAAmB;AAC5B,OAAOC,SAASC,gBAAgB;AAShC,IAAMC,mBAAmB,wBAACC,WAAAA;AACxB,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAAA;AAC1BC,iBACE,OAAOC,YAAAA;AACL,QAAIL,QAAQ;AACV,YAAMC,SAAQ,MAAMK,YAAYC,SAASC,IAAIR,MAAAA;AAC7C,UAAIK,QAAAA,GAAW;AACbH,iBAASD,MAAAA;MACX;IACF;EACF,GACA;IAACD;GAAO;AAEV,SAAOC;AACT,GAdyB;AAgBlB,IAAMQ,iBAAgD,wBAAC,EAC5DC,gBAAgB,MAAMC,wBAAwB,MAAMC,iBAAiB,MAAMC,YAAYC,OAAO,GAAGC,MAAAA,MAClG;AACC,QAAMC,iBAAiBjB,iBAAiBe,KAAAA;AACxC,QAAM,CAACG,WAAWC,cAAAA,IAAkBC,SAAAA;AACpC,QAAM,CAACC,QAAQC,WAAAA,IAAeF,SAAAA;AAE9B,QAAMG,UAAU,w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AAU,YAAY,GAAGC,MAAAA,MACpC;AACC,QAAM,EACJC,QAAQC,WAAWC,WAAU,IAC3BC,UAAU,KAAA;AAEd,SACE,gBAAAC,OAAA,cAACC,UAAAA;IACCP;IACAQ,MAAK;IACLC,OAAOP,UAAU;IACjBH,UAAU,wBAACW,OAAOC,UAAAA;AAChB,UAAID,MAAME,OAAOH,UAAUP,QAAQ;AACjCH,mBAAWW,OAAOC,KAAAA;AAClBR,oBAAYO,MAAME,OAAOH,KAAK;MAChC;IACF,GALU;IAMVI,aAAa,wBAACJ,UAAAA;AACZ,aAAO,gBAAAH,OAAA,cAACQ,YAAAA,MAAYL,UAAU,SAAS,aAAaA,KAAAA;IACtD,GAFa;IAGZ,GAAGR;KAEHG,YAAYW,IAAI,CAACb,SAAQc,UAAAA;AACxB,WACE,gBAAAV,OAAA,cAACW,UAAAA;MAASC,KAAKF;MAAOP,OAAOP;OAC1BA,OAAAA;EAGP,CAAA,GACA,gBAAAI,OAAA,cAACW,UAAAA;IAASC,KAAI;IAAOT,OAAM;KAAO,UAAA,CAAA;AAKxC,GAnC6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","FlexGrowRow","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","title","tip","IconButton","ref","size","current","console","warn","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","FlexGrowRow","justifyContent","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","exists","React","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","useAsyncEffect","mounted","firstRequest","schemaChanged","SchemaCache","instance","get","undefined","e","error","console","message","ModuleErrorSchema","$sources","schemaHuri","huri","schemaPayload","PayloadBuilder","payload","fields","build","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","useState","useAsyncEffect","mounted","promiseResults","Promise","allSettled","map","name","SchemaCache","instance","get","result","status","value","payload","undefined","filter","item","usePromise","SchemaListQuerySchema","useWeakDivinerFromNode","useMemo","useSchemaList","address","nameOrAddress","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","schemaList","error","usePromise","divinerInstance","deref","response","divine","at","useAsyncEffect","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaType","useWeakDivinerFromNode","useMemo","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","query","useMemo","address","schema","SchemaStatsQuerySchema","useAsyncEffect","mounted","instance","deref","undefined","schemas","divine","filter","isPayloadOfSchemaType","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useMemo","map","name","filter","exists","value","provided","React","SchemaContext","React","useCallback","useEffect","useMemo","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","get","setSchemaParam","useCallback","set","replace","delete","setSchemaLocal","useEffect","undefined","value","useMemo","provided","React","SchemaContext","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","index","MenuItem","key"]}
|
|
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 {\n NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,\n} from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { 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 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: React.FC<SchemaPropertyProps> = ({\n showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props\n}) => {\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 title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <FlexGrowRow ref={divRef} justifyContent=\"space-between\">\n {showLinkNames\n ? (\n <LinkEx\n display=\"block\"\n width=\"100%\"\n sx={{ cursor: 'pointer' }}\n >\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n </LinkEx>\n )\n : (\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n )}\n {showOpenNewWindowLink\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch, true)\n }}\n >\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </FlexGrowRow>\n )\n : null}\n </Property>\n )\n}\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({\n onChange, variant = 'outlined', ...props\n}) => {\n const {\n schema, setSchema, schemaList,\n } = 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) => {\n return (\n <MenuItem key={schemaList.indexOf(schema)} 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 '@xylabs/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/sdk-js'\nimport type { PropsWithChildren } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n defaultSchema, knownSchemaList, ...props\n}) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useMemo(() => {\n if (fetchedSchemaStats) {\n const schemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,\n }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError, WithSources } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { 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, setXyoError] = useState<WithSources<ModuleError>>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\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 setXyoError({\n message: error.message, schema: ModuleErrorSchema, $sources: [],\n })\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 type { 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 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 { usePromise } from '@xylabs/react-promise'\nimport type { Address } from '@xylabs/sdk-js'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list-model'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useMemo } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\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 const [schemaList, error] = usePromise(\n async () => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n const response = (await divinerInstance.divine(query)) as SchemaListPayload[]\n return response.at(0)\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { type Address, isDefined } from '@xylabs/sdk-js'\nimport type {\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n} from '@xyo-network/diviner-schema-stats-model'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { 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<SchemaStatsPayload>[]>()\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (isDefined(instance) && isDefined(statsAddress)) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const query = {\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema)) as WithSources<\n 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, statsAddress],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { PropsWithChildren } from 'react'\nimport React, {\n useCallback, useEffect, useMemo,\n} from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<PropsWithChildren> = ({ children }) => {\n const {\n schema, setSchema, schemaList,\n } = 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 const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList, setSchema: setSchemaLocal,\n }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext value={value}>{children}</SchemaContext>\n}\n\nexport const SchemaRouteProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n knownSchemaList, defaultSchema, ...props\n}) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;AAAA,SACEA,eAAeC,iBAAiBC,aAAaC,eAAeC,YAAYC,oBACnE;AACP,SAASC,kBAAkB;AAC3B,S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AI,OAAA,cAACU,UAAAA;MAASC,KAAKb,WAAWc,QAAQhB,OAAAA;MAASO,OAAOP;OAC/CA,OAAAA;EAGP,CAAA,GACA,gBAAAI,OAAA,cAACU,UAAAA;IAASC,KAAI;IAAOR,OAAM;KAAO,UAAA,CAAA;AAKxC,GAnC6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","FlexGrowRow","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","title","tip","IconButton","ref","size","current","console","warn","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","FlexGrowRow","justifyContent","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","exists","React","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setXyoError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","useAsyncEffect","mounted","firstRequest","schemaChanged","SchemaCache","instance","get","undefined","e","error","console","message","ModuleErrorSchema","$sources","schemaHuri","huri","schemaPayload","PayloadBuilder","payload","fields","build","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","useState","useAsyncEffect","mounted","promiseResults","Promise","allSettled","map","name","SchemaCache","instance","get","result","status","value","payload","undefined","filter","item","usePromise","SchemaListQuerySchema","useWeakDivinerFromNode","useMemo","useSchemaList","address","nameOrAddress","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","schemaList","error","usePromise","divinerInstance","deref","response","divine","at","useAsyncEffect","isDefined","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaType","useWeakDivinerFromNode","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","useAsyncEffect","mounted","instance","deref","isDefined","undefined","query","address","schema","SchemaStatsQuerySchema","schemas","divine","filter","isPayloadOfSchemaType","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useMemo","map","name","filter","exists","value","provided","React","SchemaContext","React","useCallback","useEffect","useMemo","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","get","setSchemaParam","useCallback","set","replace","delete","setSchemaLocal","useEffect","undefined","value","useMemo","provided","React","SchemaContext","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","MenuItem","key","indexOf"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-schema",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.4",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -43,49 +43,49 @@
|
|
|
43
43
|
"src"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@xylabs/react-async-effect": "~7.1.
|
|
47
|
-
"@xylabs/react-flexbox": "~7.1.
|
|
48
|
-
"@xylabs/react-link": "~7.1.
|
|
49
|
-
"@xylabs/react-promise": "~7.1.
|
|
50
|
-
"@xylabs/react-select": "~7.1.
|
|
51
|
-
"@xylabs/react-shared": "~7.1.
|
|
52
|
-
"@xylabs/sdk-js": "~5.0.
|
|
53
|
-
"@xyo-network/diviner-schema-list-model": "~5.3.
|
|
54
|
-
"@xyo-network/diviner-schema-stats-model": "~5.3.
|
|
46
|
+
"@xylabs/react-async-effect": "~7.1.15",
|
|
47
|
+
"@xylabs/react-flexbox": "~7.1.15",
|
|
48
|
+
"@xylabs/react-link": "~7.1.15",
|
|
49
|
+
"@xylabs/react-promise": "~7.1.15",
|
|
50
|
+
"@xylabs/react-select": "~7.1.15",
|
|
51
|
+
"@xylabs/react-shared": "~7.1.15",
|
|
52
|
+
"@xylabs/sdk-js": "~5.0.79",
|
|
53
|
+
"@xyo-network/diviner-schema-list-model": "~5.3.5",
|
|
54
|
+
"@xyo-network/diviner-schema-stats-model": "~5.3.5",
|
|
55
55
|
"@xyo-network/node-core-types": "~4.1.7",
|
|
56
|
-
"@xyo-network/payload-builder": "~5.3.
|
|
57
|
-
"@xyo-network/payload-model": "~5.3.
|
|
58
|
-
"@xyo-network/react-diviner": "7.5.
|
|
59
|
-
"@xyo-network/react-event": "7.5.
|
|
60
|
-
"@xyo-network/react-property": "7.5.
|
|
61
|
-
"@xyo-network/schema-cache": "~5.3.
|
|
62
|
-
"@xyo-network/schema-payload-plugin": "~5.3.
|
|
56
|
+
"@xyo-network/payload-builder": "~5.3.5",
|
|
57
|
+
"@xyo-network/payload-model": "~5.3.5",
|
|
58
|
+
"@xyo-network/react-diviner": "7.5.4",
|
|
59
|
+
"@xyo-network/react-event": "7.5.4",
|
|
60
|
+
"@xyo-network/react-property": "7.5.4",
|
|
61
|
+
"@xyo-network/schema-cache": "~5.3.5",
|
|
62
|
+
"@xyo-network/schema-payload-plugin": "~5.3.5",
|
|
63
63
|
"react-router-dom": "^7.13.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@emotion/react": "~11.14.0",
|
|
67
67
|
"@emotion/styled": "~11.14.1",
|
|
68
|
-
"@mui/icons-material": "~7.3.
|
|
69
|
-
"@mui/material": "~7.3.
|
|
70
|
-
"@storybook/react-vite": "~10.2.
|
|
71
|
-
"@types/react": "^19.2.
|
|
72
|
-
"@xylabs/react-flexbox": "~7.1.
|
|
73
|
-
"@xylabs/react-hooks": "~7.1.
|
|
74
|
-
"@xylabs/sdk-js": "~5.0.
|
|
68
|
+
"@mui/icons-material": "~7.3.8",
|
|
69
|
+
"@mui/material": "~7.3.8",
|
|
70
|
+
"@storybook/react-vite": "~10.2.9",
|
|
71
|
+
"@types/react": "^19.2.14",
|
|
72
|
+
"@xylabs/react-flexbox": "~7.1.15",
|
|
73
|
+
"@xylabs/react-hooks": "~7.1.15",
|
|
74
|
+
"@xylabs/sdk-js": "~5.0.79",
|
|
75
75
|
"@xylabs/ts-scripts-yarn3": "~7.3.2",
|
|
76
76
|
"@xylabs/tsconfig": "~7.3.2",
|
|
77
77
|
"@xylabs/tsconfig-dom": "~7.3.2",
|
|
78
78
|
"@xylabs/tsconfig-react": "~7.3.2",
|
|
79
|
-
"@xyo-network/bridge-http": "~5.3.
|
|
80
|
-
"@xyo-network/node-memory": "~5.3.
|
|
81
|
-
"@xyo-network/node-model": "~5.3.
|
|
82
|
-
"@xyo-network/react-node": "7.5.
|
|
83
|
-
"@xyo-network/react-payload-raw-info": "7.5.
|
|
84
|
-
"@xyo-network/react-storybook": "7.5.
|
|
85
|
-
"@xyo-network/react-wallet": "7.5.
|
|
79
|
+
"@xyo-network/bridge-http": "~5.3.5",
|
|
80
|
+
"@xyo-network/node-memory": "~5.3.5",
|
|
81
|
+
"@xyo-network/node-model": "~5.3.5",
|
|
82
|
+
"@xyo-network/react-node": "7.5.4",
|
|
83
|
+
"@xyo-network/react-payload-raw-info": "7.5.4",
|
|
84
|
+
"@xyo-network/react-storybook": "7.5.4",
|
|
85
|
+
"@xyo-network/react-wallet": "7.5.4",
|
|
86
86
|
"react": "^19.2.4",
|
|
87
87
|
"react-dom": "^19.2.4",
|
|
88
|
-
"storybook": "~10.2.
|
|
88
|
+
"storybook": "~10.2.9",
|
|
89
89
|
"typescript": "^5.9.3",
|
|
90
90
|
"vite": "~7.3.1",
|
|
91
91
|
"zod": "^4.3.6"
|
|
@@ -30,9 +30,9 @@ export const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({
|
|
|
30
30
|
}}
|
|
31
31
|
{...props}
|
|
32
32
|
>
|
|
33
|
-
{schemaList?.map((schema
|
|
33
|
+
{schemaList?.map((schema) => {
|
|
34
34
|
return (
|
|
35
|
-
<MenuItem key={
|
|
35
|
+
<MenuItem key={schemaList.indexOf(schema)} value={schema}>
|
|
36
36
|
{schema}
|
|
37
37
|
</MenuItem>
|
|
38
38
|
)
|
|
@@ -21,7 +21,7 @@ import { useSchemaList } from '../useSchemaList.tsx'
|
|
|
21
21
|
import { useSchemaStats } from '../useSchemaStats.tsx'
|
|
22
22
|
|
|
23
23
|
const apiConfig = { apiDomain: 'https://api.archivist.xyo.network' }
|
|
24
|
-
const
|
|
24
|
+
const client = { url: 'http://localhost:8080/node' }
|
|
25
25
|
|
|
26
26
|
const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
27
27
|
const [node, setNode] = useState<MemoryNode>()
|
|
@@ -31,7 +31,7 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
|
31
31
|
const node = await MemoryNode.create({ config: { schema: NodeConfigSchema } })
|
|
32
32
|
const bridge = await HttpBridge.create({
|
|
33
33
|
config: {
|
|
34
|
-
|
|
34
|
+
client, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
|
|
35
35
|
},
|
|
36
36
|
})
|
|
37
37
|
await node.register(bridge)
|
|
@@ -21,11 +21,11 @@ const UseGetSchemaComponent: React.FC<{ schema: string }> = ({ schema }) => {
|
|
|
21
21
|
<>
|
|
22
22
|
<Typography variant="body1" fontWeight="bold" mb={2}>
|
|
23
23
|
Example schemas to test:
|
|
24
|
-
{exampleSchemas.map(
|
|
24
|
+
{exampleSchemas.map(schema => (
|
|
25
25
|
<Typography
|
|
26
26
|
component="span"
|
|
27
27
|
mx={1}
|
|
28
|
-
key={
|
|
28
|
+
key={exampleSchemas.indexOf(schema)}
|
|
29
29
|
onClick={() => setSchemaFieldValue(schema)}
|
|
30
30
|
sx={{ cursor: 'pointer', textDecoration: 'underline' }}
|
|
31
31
|
>
|
|
@@ -12,7 +12,7 @@ import { useState } from 'react'
|
|
|
12
12
|
*/
|
|
13
13
|
const useGetSchemaPayload = (schema?: string) => {
|
|
14
14
|
const [notFound, setNotFound] = useState(false)
|
|
15
|
-
const [xyoError,
|
|
15
|
+
const [xyoError, setXyoError] = useState<WithSources<ModuleError>>()
|
|
16
16
|
const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()
|
|
17
17
|
const [schemaLocal, setSchemaLocal] = useState<string>()
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ const useGetSchemaPayload = (schema?: string) => {
|
|
|
32
32
|
const error = e as Error
|
|
33
33
|
console.error(e)
|
|
34
34
|
if (mounted()) {
|
|
35
|
-
|
|
35
|
+
setXyoError({
|
|
36
36
|
message: error.message, schema: ModuleErrorSchema, $sources: [],
|
|
37
37
|
})
|
|
38
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
2
|
-
import type
|
|
2
|
+
import { type Address, isDefined } from '@xylabs/sdk-js'
|
|
3
3
|
import type {
|
|
4
4
|
SchemaStatsPayload,
|
|
5
5
|
SchemaStatsQueryPayload,
|
|
@@ -13,7 +13,7 @@ import type { WithSources } from '@xyo-network/payload-model'
|
|
|
13
13
|
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
14
14
|
import { useWeakDivinerFromNode } from '@xyo-network/react-diviner'
|
|
15
15
|
import type { Dispatch, SetStateAction } from 'react'
|
|
16
|
-
import {
|
|
16
|
+
import { useState } from 'react'
|
|
17
17
|
|
|
18
18
|
export const useSchemaStats = (
|
|
19
19
|
statsAddress?: Address,
|
|
@@ -26,18 +26,10 @@ export const useSchemaStats = (
|
|
|
26
26
|
|
|
27
27
|
const [schemaList, setSchemaList] = useState<WithSources<SchemaStatsPayload>[]>()
|
|
28
28
|
|
|
29
|
-
const query: SchemaStatsQueryPayload = useMemo(
|
|
30
|
-
() => ({
|
|
31
|
-
address: statsAddress,
|
|
32
|
-
schema: SchemaStatsQuerySchema,
|
|
33
|
-
}),
|
|
34
|
-
[statsAddress],
|
|
35
|
-
)
|
|
36
|
-
|
|
37
29
|
useAsyncEffect(
|
|
38
30
|
async (mounted) => {
|
|
39
31
|
const instance = diviner?.deref()
|
|
40
|
-
if (instance) {
|
|
32
|
+
if (isDefined(instance) && isDefined(statsAddress)) {
|
|
41
33
|
if (divinerError) {
|
|
42
34
|
if (mounted()) {
|
|
43
35
|
setError(divinerError)
|
|
@@ -45,6 +37,10 @@ export const useSchemaStats = (
|
|
|
45
37
|
}
|
|
46
38
|
} else {
|
|
47
39
|
try {
|
|
40
|
+
const query = {
|
|
41
|
+
address: statsAddress,
|
|
42
|
+
schema: SchemaStatsQuerySchema,
|
|
43
|
+
}
|
|
48
44
|
const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema)) as WithSources<
|
|
49
45
|
SchemaStatsPayload
|
|
50
46
|
>[]
|
|
@@ -59,7 +55,7 @@ export const useSchemaStats = (
|
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
},
|
|
62
|
-
[diviner, refresh, divinerError,
|
|
58
|
+
[diviner, refresh, divinerError, statsAddress],
|
|
63
59
|
)
|
|
64
60
|
|
|
65
61
|
return [schemaList, error, refreshHistory]
|