@xyo-network/react-sentinel 2.64.9 → 2.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/contexts/use.d.cts +5 -28
- package/dist/browser/contexts/use.d.cts.map +1 -1
- package/dist/browser/contexts/use.d.mts +5 -28
- package/dist/browser/contexts/use.d.mts.map +1 -1
- package/dist/browser/contexts/use.d.ts +5 -28
- package/dist/browser/contexts/use.d.ts.map +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/node/contexts/use.d.cts +5 -28
- package/dist/node/contexts/use.d.cts.map +1 -1
- package/dist/node/contexts/use.d.mts +5 -28
- package/dist/node/contexts/use.d.mts.map +1 -1
- package/dist/node/contexts/use.d.ts +5 -28
- package/dist/node/contexts/use.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +15 -15
- package/src/contexts/Provider.tsx +1 -1
- package/dist/browser/contexts/Context.cjs +0 -28
- package/dist/browser/contexts/Context.cjs.map +0 -1
- package/dist/browser/contexts/Context.js +0 -7
- package/dist/browser/contexts/Context.js.map +0 -1
- package/dist/browser/contexts/Provider.cjs +0 -124
- package/dist/browser/contexts/Provider.cjs.map +0 -1
- package/dist/browser/contexts/Provider.js +0 -103
- package/dist/browser/contexts/Provider.js.map +0 -1
- package/dist/browser/contexts/State.cjs +0 -34
- package/dist/browser/contexts/State.cjs.map +0 -1
- package/dist/browser/contexts/State.js +0 -13
- package/dist/browser/contexts/State.js.map +0 -1
- package/dist/browser/contexts/index.cjs +0 -146
- package/dist/browser/contexts/index.cjs.map +0 -1
- package/dist/browser/contexts/index.js +0 -123
- package/dist/browser/contexts/index.js.map +0 -1
- package/dist/browser/contexts/use.cjs +0 -37
- package/dist/browser/contexts/use.cjs.map +0 -1
- package/dist/browser/contexts/use.js +0 -16
- package/dist/browser/contexts/use.js.map +0 -1
- package/dist/browser/hooks/index.cjs +0 -64
- package/dist/browser/hooks/index.cjs.map +0 -1
- package/dist/browser/hooks/index.js +0 -41
- package/dist/browser/hooks/index.js.map +0 -1
- package/dist/browser/hooks/node/index.cjs +0 -64
- package/dist/browser/hooks/node/index.cjs.map +0 -1
- package/dist/browser/hooks/node/index.js +0 -41
- package/dist/browser/hooks/node/index.js.map +0 -1
- package/dist/browser/hooks/node/useSentinelFromNode.cjs +0 -38
- package/dist/browser/hooks/node/useSentinelFromNode.cjs.map +0 -1
- package/dist/browser/hooks/node/useSentinelFromNode.js +0 -17
- package/dist/browser/hooks/node/useSentinelFromNode.js.map +0 -1
- package/dist/browser/hooks/node/useSentinelsFromNode.cjs +0 -47
- package/dist/browser/hooks/node/useSentinelsFromNode.cjs.map +0 -1
- package/dist/browser/hooks/node/useSentinelsFromNode.js +0 -26
- package/dist/browser/hooks/node/useSentinelsFromNode.js.map +0 -1
- package/dist/docs.json +0 -2133
- package/dist/node/contexts/Context.cjs +0 -32
- package/dist/node/contexts/Context.cjs.map +0 -1
- package/dist/node/contexts/Context.js +0 -7
- package/dist/node/contexts/Context.js.map +0 -1
- package/dist/node/contexts/Provider.cjs +0 -129
- package/dist/node/contexts/Provider.cjs.map +0 -1
- package/dist/node/contexts/Provider.js +0 -104
- package/dist/node/contexts/Provider.js.map +0 -1
- package/dist/node/contexts/State.cjs +0 -38
- package/dist/node/contexts/State.cjs.map +0 -1
- package/dist/node/contexts/State.js +0 -13
- package/dist/node/contexts/State.js.map +0 -1
- package/dist/node/contexts/index.cjs +0 -154
- package/dist/node/contexts/index.cjs.map +0 -1
- package/dist/node/contexts/index.js +0 -124
- package/dist/node/contexts/index.js.map +0 -1
- package/dist/node/contexts/use.cjs +0 -41
- package/dist/node/contexts/use.cjs.map +0 -1
- package/dist/node/contexts/use.js +0 -16
- package/dist/node/contexts/use.js.map +0 -1
- package/dist/node/hooks/index.cjs +0 -70
- package/dist/node/hooks/index.cjs.map +0 -1
- package/dist/node/hooks/index.js +0 -42
- package/dist/node/hooks/index.js.map +0 -1
- package/dist/node/hooks/node/index.cjs +0 -70
- package/dist/node/hooks/node/index.cjs.map +0 -1
- package/dist/node/hooks/node/index.js +0 -42
- package/dist/node/hooks/node/index.js.map +0 -1
- package/dist/node/hooks/node/useSentinelFromNode.cjs +0 -43
- package/dist/node/hooks/node/useSentinelFromNode.cjs.map +0 -1
- package/dist/node/hooks/node/useSentinelFromNode.js +0 -18
- package/dist/node/hooks/node/useSentinelFromNode.js.map +0 -1
- package/dist/node/hooks/node/useSentinelsFromNode.cjs +0 -51
- package/dist/node/hooks/node/useSentinelsFromNode.cjs.map +0 -1
- package/dist/node/hooks/node/useSentinelsFromNode.js +0 -26
- package/dist/node/hooks/node/useSentinelsFromNode.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contexts/index.ts","../../../src/contexts/Context.ts","../../../src/contexts/Provider.tsx","../../../src/contexts/State.ts","../../../src/contexts/use.ts"],"sourcesContent":["export * from './Context'\nexport * from './Provider'\nexport * from './State'\nexport * from './use'\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { 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'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel, SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel'\nimport { WitnessInstance } from '@xyo-network/witness'\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 witnesses: witnesses?.map((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([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 witnesses?.forEach((witness) => {\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: module,\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: module,\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 offCallbacks.forEach((callback) => {\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'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel'\nimport { WitnessModule } from '@xyo-network/witness'\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"],"mappings":"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","names":["SentinelReportStatus","sentinel","module","witnesses","import_react_shared"]}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// src/contexts/Context.ts
|
|
2
|
-
import { createContextEx } from "@xyo-network/react-shared";
|
|
3
|
-
var SentinelContext = createContextEx();
|
|
4
|
-
|
|
5
|
-
// src/contexts/Provider.tsx
|
|
6
|
-
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
7
|
-
import { useWitnessesFromNode } from "@xyo-network/react-witness";
|
|
8
|
-
import { MemorySentinel, SentinelConfigSchema } from "@xyo-network/sentinel";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
|
|
11
|
-
// src/contexts/State.ts
|
|
12
|
-
var SentinelReportStatus = /* @__PURE__ */ ((SentinelReportStatus2) => {
|
|
13
|
-
SentinelReportStatus2["Idle"] = "idle";
|
|
14
|
-
SentinelReportStatus2["Queued"] = "queued";
|
|
15
|
-
SentinelReportStatus2["Started"] = "started";
|
|
16
|
-
SentinelReportStatus2["Succeeded"] = "succeeded";
|
|
17
|
-
SentinelReportStatus2["Failed"] = "failed";
|
|
18
|
-
return SentinelReportStatus2;
|
|
19
|
-
})(SentinelReportStatus || {});
|
|
20
|
-
|
|
21
|
-
// src/contexts/Provider.tsx
|
|
22
|
-
import { jsx } from "react/jsx-runtime";
|
|
23
|
-
var SentinelProvider = ({ account, archivist, children, filter, name, required = false }) => {
|
|
24
|
-
const [sentinel, setSentinel] = useState();
|
|
25
|
-
const [history, setHistory] = useState();
|
|
26
|
-
const [progress, setProgress] = useState({});
|
|
27
|
-
const [status, setStatus] = useState("idle" /* Idle */);
|
|
28
|
-
const [reportingErrors, setReportingErrors] = useState();
|
|
29
|
-
const [witnesses] = useWitnessesFromNode(filter);
|
|
30
|
-
useAsyncEffect(
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
async (mounted) => {
|
|
33
|
-
const sentinel2 = await MemorySentinel.create({
|
|
34
|
-
account,
|
|
35
|
-
config: {
|
|
36
|
-
archivists: archivist ? [archivist] : void 0,
|
|
37
|
-
name,
|
|
38
|
-
schema: SentinelConfigSchema,
|
|
39
|
-
witnesses: witnesses?.map((module) => module.address)
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
const offCallbacks = [];
|
|
43
|
-
offCallbacks.push(
|
|
44
|
-
sentinel2.on("reportEnd", ({ module, outPayloads }) => {
|
|
45
|
-
if (mounted()) {
|
|
46
|
-
setProgress({
|
|
47
|
-
archivists: progress.archivists,
|
|
48
|
-
witnesses: progress.witnesses
|
|
49
|
-
});
|
|
50
|
-
setStatus(outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
|
|
51
|
-
setReportingErrors([Error(`Witness failed [${module?.config?.name ?? module.address}]`)]);
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
offCallbacks.push(
|
|
56
|
-
sentinel2.on("reportStart", () => {
|
|
57
|
-
if (mounted()) {
|
|
58
|
-
setProgress({ archivists: {}, witnesses: {} });
|
|
59
|
-
setStatus("started" /* Started */);
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
);
|
|
63
|
-
witnesses?.forEach((witness) => {
|
|
64
|
-
offCallbacks.push(
|
|
65
|
-
witness.on("observeEnd", ({ module, outPayloads }) => {
|
|
66
|
-
const witnesses2 = progress.witnesses ?? {};
|
|
67
|
-
witnesses2[witness.address] = {
|
|
68
|
-
status: outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
|
|
69
|
-
witness: module
|
|
70
|
-
};
|
|
71
|
-
if (mounted()) {
|
|
72
|
-
setProgress({
|
|
73
|
-
archivists: progress.archivists,
|
|
74
|
-
witnesses: witnesses2
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
);
|
|
79
|
-
offCallbacks.push(
|
|
80
|
-
witness.on("observeStart", ({ module }) => {
|
|
81
|
-
const witnesses2 = progress.witnesses ?? {};
|
|
82
|
-
witnesses2[witness.address] = {
|
|
83
|
-
status: "started" /* Started */,
|
|
84
|
-
witness: module
|
|
85
|
-
};
|
|
86
|
-
if (mounted()) {
|
|
87
|
-
setProgress({
|
|
88
|
-
archivists: progress.archivists,
|
|
89
|
-
witnesses: witnesses2
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
setSentinel(sentinel2);
|
|
96
|
-
return () => {
|
|
97
|
-
offCallbacks.forEach((callback) => {
|
|
98
|
-
callback();
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
-
[account, archivist, witnesses]
|
|
104
|
-
);
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
setHistory(sentinel?.history);
|
|
107
|
-
}, [sentinel]);
|
|
108
|
-
return !required || sentinel ? /* @__PURE__ */ jsx(SentinelContext.Provider, { value: { history, progress, provided: true, reportingErrors, sentinel, status }, children }) : null;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/contexts/use.ts
|
|
112
|
-
import { useContextEx } from "@xyo-network/react-shared";
|
|
113
|
-
var useSentinelContext = () => {
|
|
114
|
-
const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, "Sentinel");
|
|
115
|
-
return { history, progress, reportingErrors, sentinel, status };
|
|
116
|
-
};
|
|
117
|
-
export {
|
|
118
|
-
SentinelContext,
|
|
119
|
-
SentinelProvider,
|
|
120
|
-
SentinelReportStatus,
|
|
121
|
-
useSentinelContext
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contexts/Context.ts","../../../src/contexts/Provider.tsx","../../../src/contexts/State.ts","../../../src/contexts/use.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { 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'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel, SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel'\nimport { WitnessInstance } from '@xyo-network/witness'\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 witnesses: witnesses?.map((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([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 witnesses?.forEach((witness) => {\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: module,\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: module,\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 offCallbacks.forEach((callback) => {\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'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel'\nimport { WitnessModule } from '@xyo-network/witness'\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"],"mappings":"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","names":["SentinelReportStatus","sentinel","witnesses"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/contexts/use.ts
|
|
21
|
-
var use_exports = {};
|
|
22
|
-
__export(use_exports, {
|
|
23
|
-
useSentinelContext: () => useSentinelContext
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(use_exports);
|
|
26
|
-
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
27
|
-
|
|
28
|
-
// src/contexts/Context.ts
|
|
29
|
-
var import_react_shared = require("@xyo-network/react-shared");
|
|
30
|
-
var SentinelContext = (0, import_react_shared.createContextEx)();
|
|
31
|
-
|
|
32
|
-
// src/contexts/use.ts
|
|
33
|
-
var useSentinelContext = () => {
|
|
34
|
-
const { sentinel, history, progress, reportingErrors, status } = (0, import_react_shared2.useContextEx)(SentinelContext, "Sentinel");
|
|
35
|
-
return { history, progress, reportingErrors, sentinel, status };
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=use.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contexts/use.ts","../../../src/contexts/Context.ts"],"sourcesContent":["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 { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,uBAA6B;;;ACA7B,0BAAgC;AAIzB,IAAM,sBAAkB,qCAAsC;;;ADA9D,IAAM,qBAAqB,MAAM;AACtC,QAAM,EAAE,UAAU,SAAS,UAAU,iBAAiB,OAAO,QAAI,mCAAa,iBAAiB,UAAU;AACzG,SAAO,EAAE,SAAS,UAAU,iBAAiB,UAAU,OAAO;AAChE;","names":["import_react_shared"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/contexts/use.ts
|
|
2
|
-
import { useContextEx } from "@xyo-network/react-shared";
|
|
3
|
-
|
|
4
|
-
// src/contexts/Context.ts
|
|
5
|
-
import { createContextEx } from "@xyo-network/react-shared";
|
|
6
|
-
var SentinelContext = createContextEx();
|
|
7
|
-
|
|
8
|
-
// src/contexts/use.ts
|
|
9
|
-
var useSentinelContext = () => {
|
|
10
|
-
const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, "Sentinel");
|
|
11
|
-
return { history, progress, reportingErrors, sentinel, status };
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
useSentinelContext
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=use.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/contexts/use.ts","../../../src/contexts/Context.ts"],"sourcesContent":["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 { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,SAAS,uBAAuB;AAIzB,IAAM,kBAAkB,gBAAsC;;;ADA9D,IAAM,qBAAqB,MAAM;AACtC,QAAM,EAAE,UAAU,SAAS,UAAU,iBAAiB,OAAO,IAAI,aAAa,iBAAiB,UAAU;AACzG,SAAO,EAAE,SAAS,UAAU,iBAAiB,UAAU,OAAO;AAChE;","names":[]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/hooks/index.ts
|
|
21
|
-
var hooks_exports = {};
|
|
22
|
-
__export(hooks_exports, {
|
|
23
|
-
useSentinelFromNode: () => useSentinelFromNode,
|
|
24
|
-
useSentinelsFromNode: () => useSentinelsFromNode
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
29
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
30
|
-
var import_sentinel = require("@xyo-network/sentinel");
|
|
31
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
32
|
-
const [module2, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
|
|
33
|
-
const instance = (0, import_sentinel.asSentinelInstance)(module2);
|
|
34
|
-
if (module2 && !instance) {
|
|
35
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module2.config?.schema}:${module2.config?.name}:${module2.address}]`);
|
|
36
|
-
console.error(error2.message);
|
|
37
|
-
return [void 0, error2];
|
|
38
|
-
}
|
|
39
|
-
return [instance, error];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
43
|
-
var import_react_node2 = require("@xyo-network/react-node");
|
|
44
|
-
var import_sentinel2 = require("@xyo-network/sentinel");
|
|
45
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
46
|
-
const [modules, error] = (0, import_react_node2.useModulesFromNode)(filter, config);
|
|
47
|
-
if (error) {
|
|
48
|
-
return [null, error];
|
|
49
|
-
}
|
|
50
|
-
if (modules) {
|
|
51
|
-
return [
|
|
52
|
-
modules.reduce((prev, module2) => {
|
|
53
|
-
if ((0, import_sentinel2.isSentinelInstance)(module2)) {
|
|
54
|
-
prev.push(module2);
|
|
55
|
-
}
|
|
56
|
-
return prev;
|
|
57
|
-
}, []),
|
|
58
|
-
void 0
|
|
59
|
-
];
|
|
60
|
-
} else {
|
|
61
|
-
return [modules, error];
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/index.ts","../../../src/hooks/node/useSentinelFromNode.tsx","../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["export * from './node'\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAAwD;AACxD,sBAAqD;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAACA,SAAQ,KAAK,QAAI,qCAAkB,yBAAyB,MAAM;AACzE,QAAM,eAAW,oCAAmBA,OAAM;AAC1C,MAAIA,WAAU,CAAC,UAAU;AACvB,UAAMC,SAAQ,MAAM,8CAA8CD,QAAO,QAAQ,MAAM,IAAIA,QAAO,QAAQ,IAAI,IAAIA,QAAO,OAAO,GAAG;AACnI,YAAQ,MAAMC,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;;;ACdA,IAAAC,qBAAyD;AACzD,IAAAC,mBAAqD;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,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAMC,YAAW;AACnD,gBAAI,qCAAmBA,OAAM,GAAG;AAC9B,eAAK,KAAKA,OAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":["module","error","import_react_node","import_sentinel","module"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
2
|
-
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
3
|
-
import { asSentinelInstance } from "@xyo-network/sentinel";
|
|
4
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
5
|
-
const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
6
|
-
const instance = asSentinelInstance(module);
|
|
7
|
-
if (module && !instance) {
|
|
8
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`);
|
|
9
|
-
console.error(error2.message);
|
|
10
|
-
return [void 0, error2];
|
|
11
|
-
}
|
|
12
|
-
return [instance, error];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
16
|
-
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
17
|
-
import { isSentinelInstance } from "@xyo-network/sentinel";
|
|
18
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
19
|
-
const [modules, error] = useModulesFromNode(filter, config);
|
|
20
|
-
if (error) {
|
|
21
|
-
return [null, error];
|
|
22
|
-
}
|
|
23
|
-
if (modules) {
|
|
24
|
-
return [
|
|
25
|
-
modules.reduce((prev, module) => {
|
|
26
|
-
if (isSentinelInstance(module)) {
|
|
27
|
-
prev.push(module);
|
|
28
|
-
}
|
|
29
|
-
return prev;
|
|
30
|
-
}, []),
|
|
31
|
-
void 0
|
|
32
|
-
];
|
|
33
|
-
} else {
|
|
34
|
-
return [modules, error];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
useSentinelFromNode,
|
|
39
|
-
useSentinelsFromNode
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/node/useSentinelFromNode.tsx","../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";AAAA,SAA+B,yBAAyB;AACxD,SAAS,0BAA4C;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAAC,QAAQ,KAAK,IAAI,kBAAkB,yBAAyB,MAAM;AACzE,QAAM,WAAW,mBAAmB,MAAM;AAC1C,MAAI,UAAU,CAAC,UAAU;AACvB,UAAMA,SAAQ,MAAM,8CAA8C,OAAO,QAAQ,MAAM,IAAI,OAAO,QAAQ,IAAI,IAAI,OAAO,OAAO,GAAG;AACnI,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,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAM,WAAW;AACnD,YAAI,mBAAmB,MAAM,GAAG;AAC9B,eAAK,KAAK,MAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":["error"]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/hooks/node/index.ts
|
|
21
|
-
var node_exports = {};
|
|
22
|
-
__export(node_exports, {
|
|
23
|
-
useSentinelFromNode: () => useSentinelFromNode,
|
|
24
|
-
useSentinelsFromNode: () => useSentinelsFromNode
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(node_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
29
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
30
|
-
var import_sentinel = require("@xyo-network/sentinel");
|
|
31
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
32
|
-
const [module2, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
|
|
33
|
-
const instance = (0, import_sentinel.asSentinelInstance)(module2);
|
|
34
|
-
if (module2 && !instance) {
|
|
35
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module2.config?.schema}:${module2.config?.name}:${module2.address}]`);
|
|
36
|
-
console.error(error2.message);
|
|
37
|
-
return [void 0, error2];
|
|
38
|
-
}
|
|
39
|
-
return [instance, error];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
43
|
-
var import_react_node2 = require("@xyo-network/react-node");
|
|
44
|
-
var import_sentinel2 = require("@xyo-network/sentinel");
|
|
45
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
46
|
-
const [modules, error] = (0, import_react_node2.useModulesFromNode)(filter, config);
|
|
47
|
-
if (error) {
|
|
48
|
-
return [null, error];
|
|
49
|
-
}
|
|
50
|
-
if (modules) {
|
|
51
|
-
return [
|
|
52
|
-
modules.reduce((prev, module2) => {
|
|
53
|
-
if ((0, import_sentinel2.isSentinelInstance)(module2)) {
|
|
54
|
-
prev.push(module2);
|
|
55
|
-
}
|
|
56
|
-
return prev;
|
|
57
|
-
}, []),
|
|
58
|
-
void 0
|
|
59
|
-
];
|
|
60
|
-
} else {
|
|
61
|
-
return [modules, error];
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/index.ts","../../../../src/hooks/node/useSentinelFromNode.tsx","../../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["export * from './useSentinelFromNode'\nexport * from './useSentinelsFromNode'\n","import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAAwD;AACxD,sBAAqD;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAACA,SAAQ,KAAK,QAAI,qCAAkB,yBAAyB,MAAM;AACzE,QAAM,eAAW,oCAAmBA,OAAM;AAC1C,MAAIA,WAAU,CAAC,UAAU;AACvB,UAAMC,SAAQ,MAAM,8CAA8CD,QAAO,QAAQ,MAAM,IAAIA,QAAO,QAAQ,IAAI,IAAIA,QAAO,OAAO,GAAG;AACnI,YAAQ,MAAMC,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;;;ACdA,IAAAC,qBAAyD;AACzD,IAAAC,mBAAqD;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,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAMC,YAAW;AACnD,gBAAI,qCAAmBA,OAAM,GAAG;AAC9B,eAAK,KAAKA,OAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":["module","error","import_react_node","import_sentinel","module"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
2
|
-
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
3
|
-
import { asSentinelInstance } from "@xyo-network/sentinel";
|
|
4
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
5
|
-
const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
6
|
-
const instance = asSentinelInstance(module);
|
|
7
|
-
if (module && !instance) {
|
|
8
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`);
|
|
9
|
-
console.error(error2.message);
|
|
10
|
-
return [void 0, error2];
|
|
11
|
-
}
|
|
12
|
-
return [instance, error];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
16
|
-
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
17
|
-
import { isSentinelInstance } from "@xyo-network/sentinel";
|
|
18
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
19
|
-
const [modules, error] = useModulesFromNode(filter, config);
|
|
20
|
-
if (error) {
|
|
21
|
-
return [null, error];
|
|
22
|
-
}
|
|
23
|
-
if (modules) {
|
|
24
|
-
return [
|
|
25
|
-
modules.reduce((prev, module) => {
|
|
26
|
-
if (isSentinelInstance(module)) {
|
|
27
|
-
prev.push(module);
|
|
28
|
-
}
|
|
29
|
-
return prev;
|
|
30
|
-
}, []),
|
|
31
|
-
void 0
|
|
32
|
-
];
|
|
33
|
-
} else {
|
|
34
|
-
return [modules, error];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
useSentinelFromNode,
|
|
39
|
-
useSentinelsFromNode
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/useSentinelFromNode.tsx","../../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";AAAA,SAA+B,yBAAyB;AACxD,SAAS,0BAA4C;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAAC,QAAQ,KAAK,IAAI,kBAAkB,yBAAyB,MAAM;AACzE,QAAM,WAAW,mBAAmB,MAAM;AAC1C,MAAI,UAAU,CAAC,UAAU;AACvB,UAAMA,SAAQ,MAAM,8CAA8C,OAAO,QAAQ,MAAM,IAAI,OAAO,QAAQ,IAAI,IAAI,OAAO,OAAO,GAAG;AACnI,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,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAM,WAAW;AACnD,YAAI,mBAAmB,MAAM,GAAG;AAC9B,eAAK,KAAK,MAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":["error"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
21
|
-
var useSentinelFromNode_exports = {};
|
|
22
|
-
__export(useSentinelFromNode_exports, {
|
|
23
|
-
useSentinelFromNode: () => useSentinelFromNode
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(useSentinelFromNode_exports);
|
|
26
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
27
|
-
var import_sentinel = require("@xyo-network/sentinel");
|
|
28
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
29
|
-
const [module2, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
|
|
30
|
-
const instance = (0, import_sentinel.asSentinelInstance)(module2);
|
|
31
|
-
if (module2 && !instance) {
|
|
32
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module2.config?.schema}:${module2.config?.name}:${module2.address}]`);
|
|
33
|
-
console.error(error2.message);
|
|
34
|
-
return [void 0, error2];
|
|
35
|
-
}
|
|
36
|
-
return [instance, error];
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=useSentinelFromNode.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/useSentinelFromNode.tsx"],"sourcesContent":["import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAwD;AACxD,sBAAqD;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAACA,SAAQ,KAAK,QAAI,qCAAkB,yBAAyB,MAAM;AACzE,QAAM,eAAW,oCAAmBA,OAAM;AAC1C,MAAIA,WAAU,CAAC,UAAU;AACvB,UAAMC,SAAQ,MAAM,8CAA8CD,QAAO,QAAQ,MAAM,IAAIA,QAAO,QAAQ,IAAI,IAAIA,QAAO,OAAO,GAAG;AACnI,YAAQ,MAAMC,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;","names":["module","error"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
2
|
-
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
3
|
-
import { asSentinelInstance } from "@xyo-network/sentinel";
|
|
4
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
5
|
-
const [module, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
6
|
-
const instance = asSentinelInstance(module);
|
|
7
|
-
if (module && !instance) {
|
|
8
|
-
const error2 = Error(`Resolved module is not a SentinelInstance [${module.config?.schema}:${module.config?.name}:${module.address}]`);
|
|
9
|
-
console.error(error2.message);
|
|
10
|
-
return [void 0, error2];
|
|
11
|
-
}
|
|
12
|
-
return [instance, error];
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
useSentinelFromNode
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=useSentinelFromNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/useSentinelFromNode.tsx"],"sourcesContent":["import { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 = 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"],"mappings":";AAAA,SAA+B,yBAAyB;AACxD,SAAS,0BAA4C;AAE9C,IAAM,sBAAsB,CACjC,yBACA,WACsD;AACtD,QAAM,CAAC,QAAQ,KAAK,IAAI,kBAAkB,yBAAyB,MAAM;AACzE,QAAM,WAAW,mBAAmB,MAAM;AAC1C,MAAI,UAAU,CAAC,UAAU;AACvB,UAAMA,SAAQ,MAAM,8CAA8C,OAAO,QAAQ,MAAM,IAAI,OAAO,QAAQ,IAAI,IAAI,OAAO,OAAO,GAAG;AACnI,YAAQ,MAAMA,OAAM,OAAO;AAC3B,WAAO,CAAC,QAAWA,MAAK;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,KAAK;AACzB;","names":["error"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
21
|
-
var useSentinelsFromNode_exports = {};
|
|
22
|
-
__export(useSentinelsFromNode_exports, {
|
|
23
|
-
useSentinelsFromNode: () => useSentinelsFromNode
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(useSentinelsFromNode_exports);
|
|
26
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
27
|
-
var import_sentinel = require("@xyo-network/sentinel");
|
|
28
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
29
|
-
const [modules, error] = (0, import_react_node.useModulesFromNode)(filter, config);
|
|
30
|
-
if (error) {
|
|
31
|
-
return [null, error];
|
|
32
|
-
}
|
|
33
|
-
if (modules) {
|
|
34
|
-
return [
|
|
35
|
-
modules.reduce((prev, module2) => {
|
|
36
|
-
if ((0, import_sentinel.isSentinelInstance)(module2)) {
|
|
37
|
-
prev.push(module2);
|
|
38
|
-
}
|
|
39
|
-
return prev;
|
|
40
|
-
}, []),
|
|
41
|
-
void 0
|
|
42
|
-
];
|
|
43
|
-
} else {
|
|
44
|
-
return [modules, error];
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=useSentinelsFromNode.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAyD;AACzD,sBAAqD;AAE9C,IAAM,uBAAuB,CAClC,QACA,WAC+D;AAC/D,QAAM,CAAC,SAAS,KAAK,QAAI,sCAAmB,QAAQ,MAAM;AAC1D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAMA,YAAW;AACnD,gBAAI,oCAAmBA,OAAM,GAAG;AAC9B,eAAK,KAAKA,OAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":["module"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
2
|
-
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
3
|
-
import { isSentinelInstance } from "@xyo-network/sentinel";
|
|
4
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
5
|
-
const [modules, error] = useModulesFromNode(filter, config);
|
|
6
|
-
if (error) {
|
|
7
|
-
return [null, error];
|
|
8
|
-
}
|
|
9
|
-
if (modules) {
|
|
10
|
-
return [
|
|
11
|
-
modules.reduce((prev, module) => {
|
|
12
|
-
if (isSentinelInstance(module)) {
|
|
13
|
-
prev.push(module);
|
|
14
|
-
}
|
|
15
|
-
return prev;
|
|
16
|
-
}, []),
|
|
17
|
-
void 0
|
|
18
|
-
];
|
|
19
|
-
} else {
|
|
20
|
-
return [modules, error];
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
useSentinelsFromNode
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=useSentinelsFromNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/node/useSentinelsFromNode.tsx"],"sourcesContent":["import { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel'\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 if (modules) {\n return [\n modules.reduce<SentinelInstance[]>((prev, module) => {\n if (isSentinelInstance(module)) {\n prev.push(module)\n }\n return prev\n }, []),\n undefined,\n ]\n } else {\n return [modules, error]\n }\n}\n"],"mappings":";AACA,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,MAAI,SAAS;AACX,WAAO;AAAA,MACL,QAAQ,OAA2B,CAAC,MAAM,WAAW;AACnD,YAAI,mBAAmB,MAAM,GAAG;AAC9B,eAAK,KAAK,MAAM;AAAA,QAClB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,OAAO;AACL,WAAO,CAAC,SAAS,KAAK;AAAA,EACxB;AACF;","names":[]}
|