@xyo-network/react-sentinel 2.74.0 → 2.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/browser/hooks/node/index.d.cts +2 -0
  2. package/dist/browser/hooks/node/index.d.cts.map +1 -1
  3. package/dist/browser/hooks/node/index.d.mts +2 -0
  4. package/dist/browser/hooks/node/index.d.mts.map +1 -1
  5. package/dist/browser/hooks/node/index.d.ts +2 -0
  6. package/dist/browser/hooks/node/index.d.ts.map +1 -1
  7. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.cts +4 -0
  8. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.cts.map +1 -0
  9. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.mts +4 -0
  10. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.mts.map +1 -0
  11. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.ts +4 -0
  12. package/dist/browser/hooks/node/useWeakSentinelFromNode.d.ts.map +1 -0
  13. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.cts +5 -0
  14. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.cts.map +1 -0
  15. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.mts +5 -0
  16. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.mts.map +1 -0
  17. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.ts +5 -0
  18. package/dist/browser/hooks/node/useWeakSentinelsFromNode.d.ts.map +1 -0
  19. package/dist/browser/index.cjs +38 -1
  20. package/dist/browser/index.cjs.map +1 -1
  21. package/dist/browser/index.js +38 -1
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/node/hooks/node/index.d.cts +2 -0
  24. package/dist/node/hooks/node/index.d.cts.map +1 -1
  25. package/dist/node/hooks/node/index.d.mts +2 -0
  26. package/dist/node/hooks/node/index.d.mts.map +1 -1
  27. package/dist/node/hooks/node/index.d.ts +2 -0
  28. package/dist/node/hooks/node/index.d.ts.map +1 -1
  29. package/dist/node/hooks/node/useWeakSentinelFromNode.d.cts +4 -0
  30. package/dist/node/hooks/node/useWeakSentinelFromNode.d.cts.map +1 -0
  31. package/dist/node/hooks/node/useWeakSentinelFromNode.d.mts +4 -0
  32. package/dist/node/hooks/node/useWeakSentinelFromNode.d.mts.map +1 -0
  33. package/dist/node/hooks/node/useWeakSentinelFromNode.d.ts +4 -0
  34. package/dist/node/hooks/node/useWeakSentinelFromNode.d.ts.map +1 -0
  35. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.cts +5 -0
  36. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.cts.map +1 -0
  37. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.mts +5 -0
  38. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.mts.map +1 -0
  39. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.ts +5 -0
  40. package/dist/node/hooks/node/useWeakSentinelsFromNode.d.ts.map +1 -0
  41. package/dist/node/index.cjs +41 -2
  42. package/dist/node/index.cjs.map +1 -1
  43. package/dist/node/index.js +38 -1
  44. package/dist/node/index.js.map +1 -1
  45. package/package.json +20 -19
  46. package/src/hooks/node/index.ts +2 -0
  47. package/src/hooks/node/useWeakSentinelFromNode.tsx +17 -0
  48. package/src/hooks/node/useWeakSentinelsFromNode.tsx +25 -0
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -28,7 +28,9 @@ __export(src_exports, {
28
28
  SentinelReportStatus: () => SentinelReportStatus,
29
29
  useSentinelContext: () => useSentinelContext,
30
30
  useSentinelFromNode: () => useSentinelFromNode,
31
- useSentinelsFromNode: () => useSentinelsFromNode
31
+ useSentinelsFromNode: () => useSentinelsFromNode,
32
+ useWeakSentinelFromNode: () => useWeakSentinelFromNode,
33
+ useWeakSentinelsFromNode: () => useWeakSentinelsFromNode
32
34
  });
33
35
  module.exports = __toCommonJS(src_exports);
34
36
 
@@ -235,4 +237,39 @@ var useSentinelsFromNode = (filter, config) => {
235
237
  void 0
236
238
  ] : [modules, error];
237
239
  };
240
+
241
+ // src/hooks/node/useWeakSentinelFromNode.tsx
242
+ var import_react_node3 = require("@xyo-network/react-node");
243
+ var import_sentinel_model4 = require("@xyo-network/sentinel-model");
244
+ var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
245
+ const [module2, error] = (0, import_react_node3.useWeakModuleFromNode)(nameOrAddressOrInstance, config);
246
+ const instance = module2?.deref();
247
+ const sentinel = (0, import_sentinel_model4.asSentinelInstance)(instance);
248
+ if (instance && !sentinel) {
249
+ const error2 = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`);
250
+ console.error(error2.message);
251
+ return [void 0, error2];
252
+ }
253
+ return [sentinel ? new WeakRef(sentinel) : void 0, error];
254
+ };
255
+
256
+ // src/hooks/node/useWeakSentinelsFromNode.tsx
257
+ var import_exists = require("@xylabs/exists");
258
+ var import_react_node4 = require("@xyo-network/react-node");
259
+ var import_sentinel_model5 = require("@xyo-network/sentinel-model");
260
+ var useWeakSentinelsFromNode = (filter, config) => {
261
+ const [modules, error] = (0, import_react_node4.useWeakModulesFromNode)(filter, config);
262
+ if (error) {
263
+ return [null, error];
264
+ }
265
+ return [
266
+ modules?.map((module2) => {
267
+ const instance = (0, import_sentinel_model5.asSentinelInstance)(module2?.deref());
268
+ if (instance) {
269
+ return new WeakRef(instance);
270
+ }
271
+ }).filter(import_exists.exists) ?? [],
272
+ void 0
273
+ ];
274
+ };
238
275
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAC/D,QAAM,CAAC,SAAS,KAAK,QAAI,uCAAmB,QAAQ,MAAM;AAC1D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO,UACH;AAAA;AAAA,IAEE,QAAQ,OAA2B,CAAC,MAAMC,YAAW;AACnD,cAAI,2CAAmBA,OAAM,GAAG;AAC9B,aAAK,KAAKA,OAAM;AAAA,MAClB;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;","names":["module","import_react_module","import_jsx_runtime","module","import_react_module","import_jsx_runtime","module","import_jsx_runtime","module","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","module","witnesses","import_react_shared","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config)\n const instance = module?.deref()\n const sentinel = asSentinelInstance(instance)\n if (instance && !sentinel) {\n const error = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [sentinel ? new WeakRef(sentinel) : undefined, error]\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((module) => {\n const instance = asSentinelInstance(module?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAgC;AAChC,2BAA2B;A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x_runtime","module","import_react_module","import_jsx_runtime","module","import_jsx_runtime","module","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","module","witnesses","import_react_shared","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module","import_react_node","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module"]}
@@ -201,6 +201,41 @@ var useSentinelsFromNode = (filter, config) => {
201
201
  void 0
202
202
  ] : [modules, error];
203
203
  };
204
+
205
+ // src/hooks/node/useWeakSentinelFromNode.tsx
206
+ import { useWeakModuleFromNode } from "@xyo-network/react-node";
207
+ import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
208
+ var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
209
+ const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config);
210
+ const instance = module?.deref();
211
+ const sentinel = asSentinelInstance2(instance);
212
+ if (instance && !sentinel) {
213
+ const error2 = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`);
214
+ console.error(error2.message);
215
+ return [void 0, error2];
216
+ }
217
+ return [sentinel ? new WeakRef(sentinel) : void 0, error];
218
+ };
219
+
220
+ // src/hooks/node/useWeakSentinelsFromNode.tsx
221
+ import { exists } from "@xylabs/exists";
222
+ import { useWeakModulesFromNode } from "@xyo-network/react-node";
223
+ import { asSentinelInstance as asSentinelInstance3 } from "@xyo-network/sentinel-model";
224
+ var useWeakSentinelsFromNode = (filter, config) => {
225
+ const [modules, error] = useWeakModulesFromNode(filter, config);
226
+ if (error) {
227
+ return [null, error];
228
+ }
229
+ return [
230
+ modules?.map((module) => {
231
+ const instance = asSentinelInstance3(module?.deref());
232
+ if (instance) {
233
+ return new WeakRef(instance);
234
+ }
235
+ }).filter(exists) ?? [],
236
+ void 0
237
+ ];
238
+ };
204
239
  export {
205
240
  SentinelCard,
206
241
  SentinelCardContent,
@@ -210,6 +245,8 @@ export {
210
245
  SentinelReportStatus,
211
246
  useSentinelContext,
212
247
  useSentinelFromNode,
213
- useSentinelsFromNode
248
+ useSentinelsFromNode,
249
+ useWeakSentinelFromNode,
250
+ useWeakSentinelsFromNode
214
251
  };
215
252
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n"],"mappings":";AAAA,SAAS,YAAuB;AAChC,SAAS,kBAAkB;AAI3B,SAAS,gBAAgB;;;ACJzB,SAAS,gBAAgB;AACzB,SAAS,yBAA4C;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,GAAG,MAAM,MAAM;AACzG,SACE,oBAAC,qBAAkB,QAAiB,GAAG,OACrC,8BAAC,YAAS,SAAS,MAAM,WAAW,MAAM,GAAG,MAAM,SA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K,KAAK,MAAM;AAAA,MAClB;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","jsx","useState","sentinel","witnesses","error"]}
1
+ {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config)\n const instance = module?.deref()\n const sentinel = asSentinelInstance(instance)\n if (instance && !sentinel) {\n const error = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [sentinel ? new WeakRef(sentinel) : undefined, error]\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((module) => {\n const instance = asSentinelInstance(module?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";AAAA,SAAS,YAAuB;AAChC,SAAS,kBAAkB;AAI3B,SAAS,gBAAgB;;;ACJzB,SAAS,gBAAgB;AACzB,SAAS,yBAA4C;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,GAAG,MAAM,MAAM;AACzG,SACE,oBAAC,qBAAkB,QAAiB,GAAG,OACrC,8BAAC,YAAS,SAAS,MAAM,WAAW,MAAM,GAAG,MAAM,SAAS,SAAS,YAAY,oBAEjF,GACF;AAEJ;;;ACjBA,SAAS,mBAAmB;AAE5B,SAAS,yBAA4C;AACrD,SAAS,oBAAoB;AAYvB,SAEI,OAAAA,MAFJ;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,QAAQ,GAAG,MAAM,MAAM;AACjH,SACE,gBAAAA,KAAC,qBAAkB,QAAiB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AAK,IAAI,sBAAsB,yBAAyB,MAAM;AAC7E,QAAM,WAAW,QAAQ,MAAM;AAC/B,QAAM,WAAWA,oBAAmB,QAAQ;AAC5C,MAAI,YAAY,CAAC,UAAU;AACzB,UAAMC,SAAQ,IAAI,MAAM,6CAA6C,SAAS,EAAE,GAAG;AACnF,YAAQ,MAAMA,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,WAAW,IAAI,QAAQ,QAAQ,IAAI,QAAW,KAAK;AAC7D;;;AChBA,SAAS,cAAc;AAEvB,SAA+B,8BAA8B;AAC7D,SAAS,sBAAAC,2BAA4C;AAE9C,IAAM,2BAA2B,CACtC,QACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,QAAQ,MAAM;AAC9D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,IACL,SACI,IAAI,CAAC,WAAW;AAChB,YAAM,WAAWA,oBAAmB,QAAQ,MAAM,CAAC;AACnD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,CAAC,EACA,OAAO,MAAM,KAAK,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","jsx","useState","sentinel","witnesses","error","asSentinelInstance","error","asSentinelInstance"]}
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -1,3 +1,5 @@
1
1
  export * from './useSentinelFromNode';
2
2
  export * from './useSentinelsFromNode';
3
+ export * from './useWeakSentinelFromNode';
4
+ export * from './useWeakSentinelsFromNode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
2
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
3
+ export declare const useWeakSentinelFromNode: (nameOrAddressOrInstance?: string | SentinelInstance, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance> | undefined, Error | undefined];
4
+ //# sourceMappingURL=useWeakSentinelFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelFromNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,uBAAuB,6BACR,MAAM,GAAG,gBAAgB,WAC1C,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAU3D,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ModuleFilter } from '@xyo-network/module-model';
2
+ import { ModuleFromNodeConfig } from '@xyo-network/react-node';
3
+ import { SentinelInstance } from '@xyo-network/sentinel-model';
4
+ export declare const useWeakSentinelsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined];
5
+ //# sourceMappingURL=useWeakSentinelsFromNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWeakSentinelsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,yBAAyB,CAAA;AACtF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAElF,eAAO,MAAM,wBAAwB,YAC1B,YAAY,WACZ,oBAAoB,KAC5B,CAAC,QAAQ,gBAAgB,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAgBpE,CAAA"}
@@ -28,7 +28,9 @@ __export(src_exports, {
28
28
  SentinelReportStatus: () => SentinelReportStatus,
29
29
  useSentinelContext: () => useSentinelContext,
30
30
  useSentinelFromNode: () => useSentinelFromNode,
31
- useSentinelsFromNode: () => useSentinelsFromNode
31
+ useSentinelsFromNode: () => useSentinelsFromNode,
32
+ useWeakSentinelFromNode: () => useWeakSentinelFromNode,
33
+ useWeakSentinelsFromNode: () => useWeakSentinelsFromNode
32
34
  });
33
35
  module.exports = __toCommonJS(src_exports);
34
36
 
@@ -237,6 +239,41 @@ var useSentinelsFromNode = (filter, config) => {
237
239
  void 0
238
240
  ] : [modules, error];
239
241
  };
242
+
243
+ // src/hooks/node/useWeakSentinelFromNode.tsx
244
+ var import_react_node3 = require("@xyo-network/react-node");
245
+ var import_sentinel_model4 = require("@xyo-network/sentinel-model");
246
+ var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
247
+ const [module2, error] = (0, import_react_node3.useWeakModuleFromNode)(nameOrAddressOrInstance, config);
248
+ const instance = module2 == null ? void 0 : module2.deref();
249
+ const sentinel = (0, import_sentinel_model4.asSentinelInstance)(instance);
250
+ if (instance && !sentinel) {
251
+ const error2 = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`);
252
+ console.error(error2.message);
253
+ return [void 0, error2];
254
+ }
255
+ return [sentinel ? new WeakRef(sentinel) : void 0, error];
256
+ };
257
+
258
+ // src/hooks/node/useWeakSentinelsFromNode.tsx
259
+ var import_exists = require("@xylabs/exists");
260
+ var import_react_node4 = require("@xyo-network/react-node");
261
+ var import_sentinel_model5 = require("@xyo-network/sentinel-model");
262
+ var useWeakSentinelsFromNode = (filter, config) => {
263
+ const [modules, error] = (0, import_react_node4.useWeakModulesFromNode)(filter, config);
264
+ if (error) {
265
+ return [null, error];
266
+ }
267
+ return [
268
+ (modules == null ? void 0 : modules.map((module2) => {
269
+ const instance = (0, import_sentinel_model5.asSentinelInstance)(module2 == null ? void 0 : module2.deref());
270
+ if (instance) {
271
+ return new WeakRef(instance);
272
+ }
273
+ }).filter(import_exists.exists)) ?? [],
274
+ void 0
275
+ ];
276
+ };
240
277
  // Annotate the CommonJS export names for ESM import in node:
241
278
  0 && (module.exports = {
242
279
  SentinelCard,
@@ -247,6 +284,8 @@ var useSentinelsFromNode = (filter, config) => {
247
284
  SentinelReportStatus,
248
285
  useSentinelContext,
249
286
  useSentinelFromNode,
250
- useSentinelsFromNode
287
+ useSentinelsFromNode,
288
+ useWeakSentinelFromNode,
289
+ useWeakSentinelsFromNode
251
290
  });
252
291
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAgC;AAChC,2BAA2B;AAI3B,mBAAyB;;;ACJzB,0BAAyB;AACzB,0BAAqD;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAAA,SAAQ,GAAG,MAAM,MAAM;AACzG,SACE,4CAAC,yCAAkB,QAAQA,SAAS,GAAG,OACrC,sDAAC,gCAAS,SAAS,MAAM,qCAAWA,UAAS,MAAM,SAAS,SAAS,YAAY,oBAEjF,GACF;AAEJ;;;ACjBA,2BAA4B;AAE5B,IAAAC,uBAAqD;AACrD,oCAA6B;AAYvB,IAAAC,sBAAA;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,QAAAC,SAAQ,GAAG,MAAM,MAAM;AACjH,SACE,6CAAC,0CAAkB,QAAQA,SAAS,GAAG,OACrC,wDAAC,oCAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACC,6CAAC,8CAAa,OAAO,QAAQ,IAC7B;AAAA,IACD;AAAA,KACH,GACF;AAEJ;;;ACvBA,IAAAC,uBAAoD;AAI3C,IAAAC,sBAAA;AADF,IAAM,qBAAsF,CAAC,EAAE,OAAO,QAAAC,SAAQ,GAAG,MAAM,MAAM;AAClI,SAAO,6CAAC,yCAAiB,QAAQA,SAAQ,OAAO,UAASA,WAAA,gBAAAA,QAAQ,OAAO,SAAQ,YAAa,GAAG,OAAO;AACzG;;;AHkBI,IAAAC,sB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I,qCAAkB,yBAAyB,MAAM;AACzE,QAAM,eAAW,2CAAmBA,OAAM;AAC1C,MAAIA,WAAU,CAAC,UAAU;AACvB,UAAMC,SAAQ,IAAI,MAAM,+CAA8C,KAAAD,QAAO,WAAP,mBAAe,MAAM,KAAI,KAAAA,QAAO,WAAP,mBAAe,IAAI,IAAIA,QAAO,OAAO,GAAG;AACvI,YAAQ,MAAMC,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;;;ACdA,IAAAC,qBAAyD;AACzD,IAAAC,yBAAqD;AAE9C,IAAM,uBAAuB,CAClC,QACA,WAC+D;AAC/D,QAAM,CAAC,SAAS,KAAK,QAAI,uCAAmB,QAAQ,MAAM;AAC1D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO,UACH;AAAA;AAAA,IAEE,QAAQ,OAA2B,CAAC,MAAMC,YAAW;AACnD,cAAI,2CAAmBA,OAAM,GAAG;AAC9B,aAAK,KAAKA,OAAM;AAAA,MAClB;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;","names":["module","import_react_module","import_jsx_runtime","module","import_react_module","import_jsx_runtime","module","import_jsx_runtime","module","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","module","witnesses","import_react_shared","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config)\n const instance = module?.deref()\n const sentinel = asSentinelInstance(instance)\n if (instance && !sentinel) {\n const error = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [sentinel ? new WeakRef(sentinel) : undefined, error]\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((module) => {\n const instance = asSentinelInstance(module?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAgC;AAChC,2BAA2B;AAI3B,mBAAyB;;;ACJzB,0BAAyB;AACzB,0BAAqD;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAAA,SAAQ,GAAG,MAAM,MAAM;AACzG,SACE,4CAAC,yCAAkB,QAAQA,SAAS,GAAG,OACrC,sDAAC,gCAAS,SAAS,MAAM,qCAAWA,UAAS,MAAM,SAAS,SAAS,YAAY,oBAEjF,GACF;AAEJ;;;ACjBA,2BAA4B;AAE5B,IAAAC,uBAAqD;AACrD,oCAA6B;AAYvB,IAAAC,sBAAA;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,QAAAC,SAAQ,GAAG,MAAM,MAAM;AACjH,SACE,6CAAC,0CAAkB,QAAQA,SAAS,GAAG,OACrC,wDAAC,oCAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACC,6CAAC,8CAAa,OAAO,QAAQ,IAC7B;AAAA,IACD;AAAA,KACH,GACF;AAEJ;;;ACvBA,IAAAC,uBAAoD;AAI3C,IAAAC,sBAAA;AADF,IAAM,qBAAsF,CAAC,EAAE,OAAO,QAAAC,SAAQ,GAAG,MAAM,MAAM;AAClI,SAAO,6CAAC,yCAAiB,QAAQA,SAAQ,OAAO,UAASA,WAAA,gBAAAA,QAAQ,OAAO,SAAQ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,WAAW,IAAI,QAAQ,QAAQ,IAAI,QAAW,KAAK;AAC7D;;;AChBA,oBAAuB;AAEvB,IAAAC,qBAA6D;AAC7D,IAAAC,yBAAqD;AAE9C,IAAM,2BAA2B,CACtC,QACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,QAAI,2CAAuB,QAAQ,MAAM;AAC9D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,KACL,mCACI,IAAI,CAACC,YAAW;AAChB,YAAM,eAAW,2CAAmBA,WAAA,gBAAAA,QAAQ,OAAO;AACnD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,GACC,OAAO,0BAAW,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["module","import_react_module","import_jsx_runtime","module","import_react_module","import_jsx_runtime","module","import_jsx_runtime","module","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","module","witnesses","import_react_shared","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module","import_react_node","import_sentinel_model","module","error","import_react_node","import_sentinel_model","module"]}
@@ -203,6 +203,41 @@ var useSentinelsFromNode = (filter, config) => {
203
203
  void 0
204
204
  ] : [modules, error];
205
205
  };
206
+
207
+ // src/hooks/node/useWeakSentinelFromNode.tsx
208
+ import { useWeakModuleFromNode } from "@xyo-network/react-node";
209
+ import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
210
+ var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
211
+ const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config);
212
+ const instance = module == null ? void 0 : module.deref();
213
+ const sentinel = asSentinelInstance2(instance);
214
+ if (instance && !sentinel) {
215
+ const error2 = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`);
216
+ console.error(error2.message);
217
+ return [void 0, error2];
218
+ }
219
+ return [sentinel ? new WeakRef(sentinel) : void 0, error];
220
+ };
221
+
222
+ // src/hooks/node/useWeakSentinelsFromNode.tsx
223
+ import { exists } from "@xylabs/exists";
224
+ import { useWeakModulesFromNode } from "@xyo-network/react-node";
225
+ import { asSentinelInstance as asSentinelInstance3 } from "@xyo-network/sentinel-model";
226
+ var useWeakSentinelsFromNode = (filter, config) => {
227
+ const [modules, error] = useWeakModulesFromNode(filter, config);
228
+ if (error) {
229
+ return [null, error];
230
+ }
231
+ return [
232
+ (modules == null ? void 0 : modules.map((module) => {
233
+ const instance = asSentinelInstance3(module == null ? void 0 : module.deref());
234
+ if (instance) {
235
+ return new WeakRef(instance);
236
+ }
237
+ }).filter(exists)) ?? [],
238
+ void 0
239
+ ];
240
+ };
206
241
  export {
207
242
  SentinelCard,
208
243
  SentinelCardContent,
@@ -212,6 +247,8 @@ export {
212
247
  SentinelReportStatus,
213
248
  useSentinelContext,
214
249
  useSentinelFromNode,
215
- useSentinelsFromNode
250
+ useSentinelsFromNode,
251
+ useWeakSentinelFromNode,
252
+ useWeakSentinelsFromNode
216
253
  };
217
254
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n"],"mappings":";AAAA,SAAS,YAAuB;AAChC,SAAS,kBAAkB;AAI3B,SAAS,gBAAgB;;;ACJzB,SAAS,gBAAgB;AACzB,SAAS,yBAA4C;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,GAAG,MAAM,MAAM;AACzG,SACE,oBAAC,qBAAkB,QAAiB,GAAG,OACrC,8BAAC,YAAS,SAAS,MAAM,qCAAW,SAAS,MAAM,SAAS,SAAS,YAAY,oBAEjF,GACF;AAEJ;;;ACjBA,SAAS,mBAAmB;AAE5B,SAAS,yBAA4C;AACrD,SAAS,oBAAoB;AAYvB,SAEI,OAAAA,MAFJ;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,QAAQ,GAAG,MAAM,MAAM;AACjH,SACE,gBAAAA,KAAC,qBAAkB,QAAiB,GAAG,OACrC,+BAAC,eAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACC,gBAAAA,KAAC,gBAAa,OAAO,QAAQ,IAC7B;AAAA,IACD;AAAA,KACH,GACF;AAEJ;;;ACvBA,SAAS,wBAA2C;AAI3C,gBAAAC,YAAA;AADF,IAAM,qBAAsF,CAAC,EAAE,OAAO,QAAQ,GAAG,MAAM,MAAM;AAClI,SAAO,gBAAAA,KAAC,oBAAiB,QAAgB,OAAO,UAAS,iCAAQ,OAAO,SAAQ,YAAa,GAAG,OAAO;AACzG;;;AHkBI,SACE,OAAAC,MADF,QAAAC,aAAA;AARG,IAAM,eAA4C,CAAC,EAAE,UAAU,YAAY,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AAM;AAC1C,MAAI,UAAU,CAAC,UAAU;AACvB,UAAMI,SAAQ,IAAI,MAAM,+CAA8C,YAAO,WAAP,mBAAe,MAAM,KAAI,YAAO,WAAP,mBAAe,IAAI,IAAI,OAAO,OAAO,GAAG;AACvI,YAAQ,MAAMA,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;;;ACdA,SAA+B,0BAA0B;AACzD,SAAS,0BAA4C;AAE9C,IAAM,uBAAuB,CAClC,QACA,WAC+D;AAC/D,QAAM,CAAC,SAAS,KAAK,IAAI,mBAAmB,QAAQ,MAAM;AAC1D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO,UACH;AAAA;AAAA,IAEE,QAAQ,OAA2B,CAAC,MAAM,WAAW;AACnD,UAAI,mBAAmB,MAAM,GAAG;AAC9B,aAAK,KAAK,MAAM;AAAA,MAClB;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","jsx","useState","sentinel","witnesses","error"]}
1
+ {"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, module, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await module?.report(inPayloads)\n }\n }, [module, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader module={module} />\n <SentinelCardContent module={module} report={report} />\n {children}\n <SentinelCardActions module={module} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (module?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, module, ...props }) => {\n return (\n <ModuleCardActions module={module} {...props}>\n <ButtonEx onClick={() => onReport?.(module)} size={'small'} variant={'outlined'}>\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance> &\n CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({ children, report, module, ...props }) => {\n return (\n <ModuleCardContent module={module} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report ?\n <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, module, ...props }) => {\n return <ModuleCardHeader module={module} title={title ?? module?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n tasks: witnesses?.map((module) => ({ module: module.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${module?.config?.name ?? module.address}]`)])\n }\n }),\n )\n offCallbacks.push(\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n )\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ module, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(module, () => `Module is not a witness [${module.id}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(module)\n if (module && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return modules ?\n [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config)\n const instance = module?.deref()\n const sentinel = asSentinelInstance(instance)\n if (instance && !sentinel) {\n const error = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [sentinel ? new WeakRef(sentinel) : undefined, error]\n}\n","import { exists } from '@xylabs/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((module) => {\n const instance = asSentinelInstance(module?.deref())\n if (instance)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,WAAWA,oBAAmB,iCAAQ,OAAO;AACnD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,GACC,OAAO,YAAW,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","SentinelReportStatus","jsx","useState","sentinel","witnesses","error","asSentinelInstance","error","asSentinelInstance"]}
package/package.json CHANGED
@@ -10,33 +10,34 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
11
11
  },
12
12
  "dependencies": {
13
+ "@xylabs/exists": "^3.1.11",
13
14
  "@xylabs/react-async-effect": "^3.1.6",
14
15
  "@xylabs/react-button": "^3.1.6",
15
16
  "@xylabs/react-flexbox": "^3.1.6",
16
17
  "@xylabs/react-promise": "^3.1.6",
17
18
  "@xylabs/react-shared": "^3.1.6",
18
- "@xyo-network/account-model": "^2.98.3",
19
- "@xyo-network/archivist-model": "^2.98.3",
20
- "@xyo-network/boundwitness-model": "^2.98.3",
21
- "@xyo-network/module-model": "^2.98.3",
22
- "@xyo-network/payload-model": "^2.98.3",
23
- "@xyo-network/react-module": "~2.74.0",
24
- "@xyo-network/react-node": "~2.74.0",
25
- "@xyo-network/react-payload-raw-info": "~2.74.0",
26
- "@xyo-network/react-shared": "~2.74.0",
27
- "@xyo-network/react-witness": "~2.74.0",
28
- "@xyo-network/sentinel-memory": "^2.98.3",
29
- "@xyo-network/sentinel-model": "^2.98.3",
30
- "@xyo-network/witness-model": "^2.98.3"
19
+ "@xyo-network/account-model": "^2.99.0",
20
+ "@xyo-network/archivist-model": "^2.99.0",
21
+ "@xyo-network/boundwitness-model": "^2.99.0",
22
+ "@xyo-network/module-model": "^2.99.0",
23
+ "@xyo-network/payload-model": "^2.99.0",
24
+ "@xyo-network/react-module": "~2.75.0",
25
+ "@xyo-network/react-node": "~2.75.0",
26
+ "@xyo-network/react-payload-raw-info": "~2.75.0",
27
+ "@xyo-network/react-shared": "~2.75.0",
28
+ "@xyo-network/react-witness": "~2.75.0",
29
+ "@xyo-network/sentinel-memory": "^2.99.0",
30
+ "@xyo-network/sentinel-model": "^2.99.0",
31
+ "@xyo-network/witness-model": "^2.99.0"
31
32
  },
32
33
  "devDependencies": {
33
- "@storybook/react": "^7.6.17",
34
+ "@storybook/react": "^7.6.18",
34
35
  "@xylabs/ts-scripts-yarn3": "^3.9.1",
35
36
  "@xylabs/tsconfig-react": "^3.9.1",
36
- "@xyo-network/account": "^2.98.3",
37
- "@xyo-network/evm-call-witness": "^2.93.1",
38
- "@xyo-network/manifest": "^2.98.3",
39
- "@xyo-network/module-factory-locator": "^2.98.3",
37
+ "@xyo-network/account": "^2.99.0",
38
+ "@xyo-network/evm-call-witness": "^2.94.0",
39
+ "@xyo-network/manifest": "^2.99.0",
40
+ "@xyo-network/module-factory-locator": "^2.99.0",
40
41
  "ethers": "^6.12.0",
41
42
  "typescript": "^5.4.5"
42
43
  },
@@ -100,6 +101,6 @@
100
101
  },
101
102
  "sideEffects": false,
102
103
  "types": "dist/browser/index.d.ts",
103
- "version": "2.74.0",
104
+ "version": "2.75.0",
104
105
  "type": "module"
105
106
  }
@@ -1,2 +1,4 @@
1
1
  export * from './useSentinelFromNode'
2
2
  export * from './useSentinelsFromNode'
3
+ export * from './useWeakSentinelFromNode'
4
+ export * from './useWeakSentinelsFromNode'
@@ -0,0 +1,17 @@
1
+ import { ModuleFromNodeConfig, useWeakModuleFromNode } from '@xyo-network/react-node'
2
+ import { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'
3
+
4
+ export const useWeakSentinelFromNode = (
5
+ nameOrAddressOrInstance?: string | SentinelInstance,
6
+ config?: ModuleFromNodeConfig,
7
+ ): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {
8
+ const [module, error] = useWeakModuleFromNode(nameOrAddressOrInstance, config)
9
+ const instance = module?.deref()
10
+ const sentinel = asSentinelInstance(instance)
11
+ if (instance && !sentinel) {
12
+ const error = new Error(`Resolved module is not a DivinerInstance [${instance.id}]`)
13
+ console.error(error.message)
14
+ return [undefined, error]
15
+ }
16
+ return [sentinel ? new WeakRef(sentinel) : undefined, error]
17
+ }
@@ -0,0 +1,25 @@
1
+ import { exists } from '@xylabs/exists'
2
+ import { ModuleFilter } from '@xyo-network/module-model'
3
+ import { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'
4
+ import { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'
5
+
6
+ export const useWeakSentinelsFromNode = (
7
+ filter?: ModuleFilter,
8
+ config?: ModuleFromNodeConfig,
9
+ ): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {
10
+ const [modules, error] = useWeakModulesFromNode(filter, config)
11
+ if (error) {
12
+ return [null, error]
13
+ }
14
+ return [
15
+ modules
16
+ ?.map((module) => {
17
+ const instance = asSentinelInstance(module?.deref())
18
+ if (instance) {
19
+ return new WeakRef(instance)
20
+ }
21
+ })
22
+ .filter(exists) ?? [],
23
+ undefined,
24
+ ]
25
+ }