@xyo-network/react-sentinel 2.77.0-rc.1 → 2.77.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/contexts/Provider.d.cts +0 -2
- package/dist/browser/contexts/Provider.d.cts.map +1 -1
- package/dist/browser/contexts/Provider.d.mts +0 -2
- package/dist/browser/contexts/Provider.d.mts.map +1 -1
- package/dist/browser/contexts/Provider.d.ts +0 -2
- package/dist/browser/contexts/Provider.d.ts.map +1 -1
- package/dist/browser/index.cjs +1 -267
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -244
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/contexts/Provider.d.cts +0 -2
- package/dist/neutral/contexts/Provider.d.cts.map +1 -1
- package/dist/neutral/contexts/Provider.d.mts +0 -2
- package/dist/neutral/contexts/Provider.d.mts.map +1 -1
- package/dist/neutral/contexts/Provider.d.ts +0 -2
- package/dist/neutral/contexts/Provider.d.ts.map +1 -1
- package/dist/neutral/index.cjs +1 -267
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +1 -244
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/contexts/Provider.d.cts +0 -2
- package/dist/node/contexts/Provider.d.cts.map +1 -1
- package/dist/node/contexts/Provider.d.mts +0 -2
- package/dist/node/contexts/Provider.d.mts.map +1 -1
- package/dist/node/contexts/Provider.d.ts +0 -2
- package/dist/node/contexts/Provider.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -283
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -246
- package/dist/node/index.js.map +1 -1
- package/package.json +28 -23
|
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
|
|
|
4
4
|
import { ModuleFilter } from '@xyo-network/module-model';
|
|
5
5
|
import { WitnessInstance } from '@xyo-network/witness-model';
|
|
6
6
|
export interface SentinelProviderProps {
|
|
7
|
-
/** Account used by the sentinel for signing */
|
|
8
7
|
account: AccountInstance;
|
|
9
|
-
/** @deprecated - sentinel no longer uses archive but relies on an archivist */
|
|
10
8
|
archive?: string;
|
|
11
9
|
archivist?: string;
|
|
12
10
|
filter?: ModuleFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,eAAe,CAAA;IAExB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
|
|
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
|
|
|
4
4
|
import { ModuleFilter } from '@xyo-network/module-model';
|
|
5
5
|
import { WitnessInstance } from '@xyo-network/witness-model';
|
|
6
6
|
export interface SentinelProviderProps {
|
|
7
|
-
/** Account used by the sentinel for signing */
|
|
8
7
|
account: AccountInstance;
|
|
9
|
-
/** @deprecated - sentinel no longer uses archive but relies on an archivist */
|
|
10
8
|
archive?: string;
|
|
11
9
|
archivist?: string;
|
|
12
10
|
filter?: ModuleFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,eAAe,CAAA;IAExB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
|
|
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
|
|
|
4
4
|
import { ModuleFilter } from '@xyo-network/module-model';
|
|
5
5
|
import { WitnessInstance } from '@xyo-network/witness-model';
|
|
6
6
|
export interface SentinelProviderProps {
|
|
7
|
-
/** Account used by the sentinel for signing */
|
|
8
7
|
account: AccountInstance;
|
|
9
|
-
/** @deprecated - sentinel no longer uses archive but relies on an archivist */
|
|
10
8
|
archive?: string;
|
|
11
9
|
archivist?: string;
|
|
12
10
|
filter?: ModuleFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,eAAe,CAAA;IAExB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -1,268 +1,2 @@
|
|
|
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/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
SentinelCard: () => SentinelCard,
|
|
24
|
-
SentinelCardContent: () => SentinelCardContent,
|
|
25
|
-
SentinelCardHeader: () => SentinelCardHeader,
|
|
26
|
-
SentinelContext: () => SentinelContext,
|
|
27
|
-
SentinelProvider: () => SentinelProvider,
|
|
28
|
-
SentinelReportStatus: () => SentinelReportStatus,
|
|
29
|
-
useSentinelContext: () => useSentinelContext,
|
|
30
|
-
useSentinelFromNode: () => useSentinelFromNode,
|
|
31
|
-
useSentinelsFromNode: () => useSentinelsFromNode,
|
|
32
|
-
useWeakSentinelFromNode: () => useWeakSentinelFromNode,
|
|
33
|
-
useWeakSentinelsFromNode: () => useWeakSentinelsFromNode
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
|
|
37
|
-
// src/components/Card/Card.tsx
|
|
38
|
-
var import_material = require("@mui/material");
|
|
39
|
-
var import_react_promise = require("@xylabs/react-promise");
|
|
40
|
-
var import_react = require("react");
|
|
41
|
-
|
|
42
|
-
// src/components/Card/CardActions.tsx
|
|
43
|
-
var import_react_button = require("@xylabs/react-button");
|
|
44
|
-
var import_react_module = require("@xyo-network/react-module");
|
|
45
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
-
var SentinelCardActions = ({ onReport, mod, ...props }) => {
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_module.ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_button.ButtonEx, { onClick: () => onReport?.(mod), size: "small", variant: "outlined", children: "Report" }) });
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/components/Card/CardContent.tsx
|
|
51
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
52
|
-
var import_react_module2 = require("@xyo-network/react-module");
|
|
53
|
-
var import_react_payload_raw_info = require("@xyo-network/react-payload-raw-info");
|
|
54
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
55
|
-
var SentinelCardContent = ({ children, report, mod, ...props }) => {
|
|
56
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_module2.ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
57
|
-
report ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_payload_raw_info.JsonViewerEx, { value: report }) : null,
|
|
58
|
-
children
|
|
59
|
-
] }) });
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// src/components/Card/CardHeader.tsx
|
|
63
|
-
var import_react_module3 = require("@xyo-network/react-module");
|
|
64
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
65
|
-
var SentinelCardHeader = ({ title, mod, ...props }) => {
|
|
66
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_module3.ModuleCardHeader, { mod, title: title ?? mod?.config.name ?? "Sentinel", ...props });
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/components/Card/Card.tsx
|
|
70
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
71
|
-
var SentinelCard = ({ children, inPayloads, mod, ...props }) => {
|
|
72
|
-
const [retry, setRetry] = (0, import_react.useState)(-1);
|
|
73
|
-
const [report] = (0, import_react_promise.usePromise)(async () => {
|
|
74
|
-
if (retry >= 0) {
|
|
75
|
-
return await mod?.report(inPayloads);
|
|
76
|
-
}
|
|
77
|
-
}, [mod, retry, inPayloads]);
|
|
78
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material.Card, { ...props, children: [
|
|
79
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardHeader, { mod }),
|
|
80
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardContent, { mod, report }),
|
|
81
|
-
children,
|
|
82
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
|
|
83
|
-
] });
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/contexts/Context.ts
|
|
87
|
-
var import_react_shared = require("@xyo-network/react-shared");
|
|
88
|
-
var SentinelContext = (0, import_react_shared.createContextEx)();
|
|
89
|
-
|
|
90
|
-
// src/contexts/Provider.tsx
|
|
91
|
-
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
92
|
-
var import_react_witness = require("@xyo-network/react-witness");
|
|
93
|
-
var import_sentinel_memory = require("@xyo-network/sentinel-memory");
|
|
94
|
-
var import_sentinel_model = require("@xyo-network/sentinel-model");
|
|
95
|
-
var import_witness_model = require("@xyo-network/witness-model");
|
|
96
|
-
var import_react2 = require("react");
|
|
97
|
-
|
|
98
|
-
// src/contexts/State.ts
|
|
99
|
-
var SentinelReportStatus = /* @__PURE__ */ ((SentinelReportStatus2) => {
|
|
100
|
-
SentinelReportStatus2["Idle"] = "idle";
|
|
101
|
-
SentinelReportStatus2["Queued"] = "queued";
|
|
102
|
-
SentinelReportStatus2["Started"] = "started";
|
|
103
|
-
SentinelReportStatus2["Succeeded"] = "succeeded";
|
|
104
|
-
SentinelReportStatus2["Failed"] = "failed";
|
|
105
|
-
return SentinelReportStatus2;
|
|
106
|
-
})(SentinelReportStatus || {});
|
|
107
|
-
|
|
108
|
-
// src/contexts/Provider.tsx
|
|
109
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
110
|
-
var SentinelProvider = ({ account, archivist, children, filter, name, required = false }) => {
|
|
111
|
-
const [sentinel, setSentinel] = (0, import_react2.useState)();
|
|
112
|
-
const [history, setHistory] = (0, import_react2.useState)();
|
|
113
|
-
const [progress, setProgress] = (0, import_react2.useState)({});
|
|
114
|
-
const [status, setStatus] = (0, import_react2.useState)("idle" /* Idle */);
|
|
115
|
-
const [reportingErrors, setReportingErrors] = (0, import_react2.useState)();
|
|
116
|
-
const [witnesses] = (0, import_react_witness.useWitnessesFromNode)(filter);
|
|
117
|
-
(0, import_react_async_effect.useAsyncEffect)(
|
|
118
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
|
-
async (mounted) => {
|
|
120
|
-
const sentinel2 = await import_sentinel_memory.MemorySentinel.create({
|
|
121
|
-
account,
|
|
122
|
-
config: {
|
|
123
|
-
archivists: archivist ? [archivist] : void 0,
|
|
124
|
-
name,
|
|
125
|
-
schema: import_sentinel_model.SentinelConfigSchema,
|
|
126
|
-
synchronous: true,
|
|
127
|
-
// eslint-disable-next-line id-denylist
|
|
128
|
-
tasks: witnesses?.map((mod) => ({ module: mod.address }))
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
const offCallbacks = [];
|
|
132
|
-
offCallbacks.push(
|
|
133
|
-
sentinel2.on("reportEnd", ({ module: mod, outPayloads }) => {
|
|
134
|
-
if (mounted()) {
|
|
135
|
-
setProgress({
|
|
136
|
-
archivists: progress.archivists,
|
|
137
|
-
witnesses: progress.witnesses
|
|
138
|
-
});
|
|
139
|
-
setStatus(outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
|
|
140
|
-
setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)]);
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
);
|
|
144
|
-
offCallbacks.push(
|
|
145
|
-
sentinel2.on("reportStart", () => {
|
|
146
|
-
if (mounted()) {
|
|
147
|
-
setProgress({ archivists: {}, witnesses: {} });
|
|
148
|
-
setStatus("started" /* Started */);
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
if (witnesses)
|
|
153
|
-
for (const witness of witnesses) {
|
|
154
|
-
offCallbacks.push(
|
|
155
|
-
witness.on("observeEnd", ({ module: mod, outPayloads }) => {
|
|
156
|
-
const witnesses2 = progress.witnesses ?? {};
|
|
157
|
-
witnesses2[witness.address] = {
|
|
158
|
-
status: outPayloads?.length ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
|
|
159
|
-
witness: (0, import_witness_model.asWitnessInstance)(mod, () => `Module is not a witness [${mod.id}]`)
|
|
160
|
-
};
|
|
161
|
-
if (mounted()) {
|
|
162
|
-
setProgress({
|
|
163
|
-
archivists: progress.archivists,
|
|
164
|
-
witnesses: witnesses2
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
offCallbacks.push(
|
|
170
|
-
witness.on("observeStart", ({ module: mod }) => {
|
|
171
|
-
const witnesses2 = progress.witnesses ?? {};
|
|
172
|
-
witnesses2[witness.address] = {
|
|
173
|
-
status: "started" /* Started */,
|
|
174
|
-
witness: (0, import_witness_model.asWitnessInstance)(mod, () => `Module is not a witness [${mod.id}]`)
|
|
175
|
-
};
|
|
176
|
-
if (mounted()) {
|
|
177
|
-
setProgress({
|
|
178
|
-
archivists: progress.archivists,
|
|
179
|
-
witnesses: witnesses2
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
setSentinel(sentinel2);
|
|
186
|
-
return () => {
|
|
187
|
-
for (const callback of offCallbacks) {
|
|
188
|
-
callback();
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
193
|
-
[account, archivist, witnesses]
|
|
194
|
-
);
|
|
195
|
-
(0, import_react2.useEffect)(() => {
|
|
196
|
-
setHistory(sentinel?.history);
|
|
197
|
-
}, [sentinel]);
|
|
198
|
-
return !required || sentinel ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SentinelContext.Provider, { value: { history, progress, provided: true, reportingErrors, sentinel, status }, children }) : null;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
// src/contexts/use.ts
|
|
202
|
-
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
203
|
-
var useSentinelContext = () => {
|
|
204
|
-
const { sentinel, history, progress, reportingErrors, status } = (0, import_react_shared2.useContextEx)(SentinelContext, "Sentinel");
|
|
205
|
-
return { history, progress, reportingErrors, sentinel, status };
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// src/hooks/node/useSentinelFromNode.tsx
|
|
209
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
210
|
-
var import_sentinel_model2 = require("@xyo-network/sentinel-model");
|
|
211
|
-
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
212
|
-
const [mod, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
|
|
213
|
-
const instance = (0, import_sentinel_model2.asSentinelInstance)(mod);
|
|
214
|
-
if (mod && !instance) {
|
|
215
|
-
const error2 = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`);
|
|
216
|
-
console.error(error2.message);
|
|
217
|
-
return [void 0, error2];
|
|
218
|
-
}
|
|
219
|
-
return [instance, error];
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
// src/hooks/node/useSentinelsFromNode.tsx
|
|
223
|
-
var import_react_node2 = require("@xyo-network/react-node");
|
|
224
|
-
var import_sentinel_model3 = require("@xyo-network/sentinel-model");
|
|
225
|
-
var useSentinelsFromNode = (filter, config) => {
|
|
226
|
-
const [modules, error] = (0, import_react_node2.useModulesFromNode)(filter, config);
|
|
227
|
-
if (error) {
|
|
228
|
-
return [null, error];
|
|
229
|
-
}
|
|
230
|
-
return modules ? [
|
|
231
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
232
|
-
modules.reduce((prev, mod) => {
|
|
233
|
-
if ((0, import_sentinel_model3.isSentinelInstance)(mod)) {
|
|
234
|
-
prev.push(mod);
|
|
235
|
-
}
|
|
236
|
-
return prev;
|
|
237
|
-
}, []),
|
|
238
|
-
void 0
|
|
239
|
-
] : [modules, error];
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// src/hooks/node/useWeakSentinelFromNode.tsx
|
|
243
|
-
var import_react_node3 = require("@xyo-network/react-node");
|
|
244
|
-
var import_sentinel_model4 = require("@xyo-network/sentinel-model");
|
|
245
|
-
var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
246
|
-
return (0, import_react_node3.useWeakModuleFromNode)(nameOrAddressOrInstance, { identity: import_sentinel_model4.isSentinelInstance, ...config });
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
// src/hooks/node/useWeakSentinelsFromNode.tsx
|
|
250
|
-
var import_exists = require("@xylabs/exists");
|
|
251
|
-
var import_react_node4 = require("@xyo-network/react-node");
|
|
252
|
-
var import_sentinel_model5 = require("@xyo-network/sentinel-model");
|
|
253
|
-
var useWeakSentinelsFromNode = (filter, config) => {
|
|
254
|
-
const [modules, error] = (0, import_react_node4.useWeakModulesFromNode)(filter, config);
|
|
255
|
-
if (error) {
|
|
256
|
-
return [null, error];
|
|
257
|
-
}
|
|
258
|
-
return [
|
|
259
|
-
modules?.map((mod) => {
|
|
260
|
-
const instance = (0, import_sentinel_model5.asSentinelInstance)(mod?.deref());
|
|
261
|
-
if (instance) {
|
|
262
|
-
return new WeakRef(instance);
|
|
263
|
-
}
|
|
264
|
-
}).filter(import_exists.exists) ?? [],
|
|
265
|
-
void 0
|
|
266
|
-
];
|
|
267
|
-
};
|
|
1
|
+
"use strict";var x=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var me=(n,e)=>{for(var t in e)x(n,t,{get:e[t],enumerable:!0})},pe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of le(e))!ae.call(n,r)&&r!==t&&x(n,r,{get:()=>e[r],enumerable:!(o=de(e,r))||o.enumerable});return n};var ce=n=>pe(x({},"__esModule",{value:!0}),n);var xe={};me(xe,{SentinelCard:()=>ue,SentinelCardContent:()=>h,SentinelCardHeader:()=>F,SentinelContext:()=>f,SentinelProvider:()=>fe,SentinelReportStatus:()=>z,useSentinelContext:()=>Se,useSentinelFromNode:()=>Ce,useSentinelsFromNode:()=>ge,useWeakSentinelFromNode:()=>Pe,useWeakSentinelsFromNode:()=>Me});module.exports=ce(xe);var $=require("@mui/material"),b=require("@xylabs/react-promise"),q=require("react");var W=require("@xylabs/react-button"),y=require("@xyo-network/react-module"),R=require("react/jsx-runtime"),E=({onReport:n,mod:e,...t})=>(0,R.jsx)(y.ModuleCardActions,{mod:e,...t,children:(0,R.jsx)(W.ButtonEx,{onClick:()=>n?.(e),size:"small",variant:"outlined",children:"Report"})});var A=require("@xylabs/react-flexbox"),N=require("@xyo-network/react-module"),k=require("@xyo-network/react-payload-raw-info"),u=require("react/jsx-runtime"),h=({children:n,report:e,mod:t,...o})=>(0,u.jsx)(N.ModuleCardContent,{mod:t,...o,children:(0,u.jsxs)(A.FlexGrowRow,{flexWrap:"wrap",justifyContent:"start",gap:2,children:[e?(0,u.jsx)(k.JsonViewerEx,{value:e}):null,n]})});var B=require("@xyo-network/react-module"),H=require("react/jsx-runtime"),F=({title:n,mod:e,...t})=>(0,H.jsx)(B.ModuleCardHeader,{mod:e,title:n??e?.config.name??"Sentinel",...t});var p=require("react/jsx-runtime"),ue=({children:n,inPayloads:e,mod:t,...o})=>{let[r,s]=(0,q.useState)(-1),[m]=(0,b.usePromise)(async()=>{if(r>=0)return await t?.report(e)},[t,r,e]);return(0,p.jsxs)($.Card,{...o,children:[(0,p.jsx)(F,{mod:t}),(0,p.jsx)(h,{mod:t,report:m}),n,(0,p.jsx)(E,{mod:t,onReport:()=>s(r+1)})]})};var G=require("@xyo-network/react-shared"),f=(0,G.createContextEx)();var J=require("@xylabs/react-async-effect"),Q=require("@xyo-network/react-witness"),V=require("@xyo-network/sentinel-memory"),D=require("@xyo-network/sentinel-model"),I=require("@xyo-network/witness-model"),d=require("react");var z=(s=>(s.Idle="idle",s.Queued="queued",s.Started="started",s.Succeeded="succeeded",s.Failed="failed",s))(z||{});var K=require("react/jsx-runtime"),fe=({account:n,archivist:e,children:t,filter:o,name:r,required:s=!1})=>{let[m,te]=(0,d.useState)(),[ne,re]=(0,d.useState)(),[l,S]=(0,d.useState)({}),[oe,v]=(0,d.useState)("idle"),[se,ie]=(0,d.useState)(),[C]=(0,Q.useWitnessesFromNode)(o);return(0,J.useAsyncEffect)(async g=>{let M=await V.MemorySentinel.create({account:n,config:{archivists:e?[e]:void 0,name:r,schema:D.SentinelConfigSchema,synchronous:!0,tasks:C?.map(i=>({module:i.address}))}}),c=[];if(c.push(M.on("reportEnd",({module:i,outPayloads:a})=>{g()&&(S({archivists:l.archivists,witnesses:l.witnesses}),v(a?.length?"succeeded":"failed"),ie([new Error(`Witness failed [${i?.config?.name??i.address}]`)]))})),c.push(M.on("reportStart",()=>{g()&&(S({archivists:{},witnesses:{}}),v("started"))})),C)for(let i of C)c.push(i.on("observeEnd",({module:a,outPayloads:P})=>{let w=l.witnesses??{};w[i.address]={status:P?.length?"succeeded":"failed",witness:(0,I.asWitnessInstance)(a,()=>`Module is not a witness [${a.id}]`)},g()&&S({archivists:l.archivists,witnesses:w})})),c.push(i.on("observeStart",({module:a})=>{let P=l.witnesses??{};P[i.address]={status:"started",witness:(0,I.asWitnessInstance)(a,()=>`Module is not a witness [${a.id}]`)},g()&&S({archivists:l.archivists,witnesses:P})}));return te(M),()=>{for(let i of c)i()}},[n,e,C]),(0,d.useEffect)(()=>{re(m?.history)},[m]),!s||m?(0,K.jsx)(f.Provider,{value:{history:ne,progress:l,provided:!0,reportingErrors:se,sentinel:m,status:oe},children:t}):null};var L=require("@xyo-network/react-shared");var Se=()=>{let{sentinel:n,history:e,progress:t,reportingErrors:o,status:r}=(0,L.useContextEx)(f,"Sentinel");return{history:e,progress:t,reportingErrors:o,sentinel:n,status:r}};var O=require("@xyo-network/react-node"),T=require("@xyo-network/sentinel-model"),Ce=(n,e)=>{let[t,o]=(0,O.useModuleFromNode)(n,e),r=(0,T.asSentinelInstance)(t);if(t&&!r){let s=new Error(`Resolved module is not a SentinelInstance [${t.config?.schema}:${t.config?.name}:${t.address}]`);return console.error(s.message),[void 0,s]}return[r,o]};var U=require("@xyo-network/react-node"),X=require("@xyo-network/sentinel-model"),ge=(n,e)=>{let[t,o]=(0,U.useModulesFromNode)(n,e);return o?[null,o]:t?[t.reduce((r,s)=>((0,X.isSentinelInstance)(s)&&r.push(s),r),[]),void 0]:[t,o]};var Y=require("@xyo-network/react-node"),Z=require("@xyo-network/sentinel-model"),Pe=(n,e)=>(0,Y.useWeakModuleFromNode)(n,{identity:Z.isSentinelInstance,...e});var _=require("@xylabs/exists"),j=require("@xyo-network/react-node"),ee=require("@xyo-network/sentinel-model"),Me=(n,e)=>{let[t,o]=(0,j.useWeakModulesFromNode)(n,e);return o?[null,o]:[t?.map(r=>{let s=(0,ee.asSentinelInstance)(r?.deref());if(s)return new WeakRef(s)}).filter(_.exists)??[],void 0]};
|
|
268
2
|
//# 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","../../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, mod, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} 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?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} 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, mod, ...props }) => {\n return (\n <ModuleCardContent mod={mod} {...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, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: mod, 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 [${mod?.config?.name ?? mod.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: mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.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: mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.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","// eslint-disable-next-line import/no-deprecated\nimport { 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 // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\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 // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\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((mod) => {\n const instance = asSentinelInstance(mod?.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,KAAK,GAAG,MAAM,MAAM;AACtG,SACE,4CAAC,yCAAkB,KAAW,GAAG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AAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;;;AC1BA,IAAAC,qBAAgE;AAChE,IAAAC,yBAAqD;AAE9C,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,aAAO,0CAAwC,yBAAyB,EAAE,UAAU,2CAAoB,GAAG,OAAO,CAAC;AACrH;;;ACRA,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,IACL,SACI,IAAI,CAAC,QAAQ;AACb,YAAM,eAAW,2CAAmB,KAAK,MAAM,CAAC;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,CAAC,EACA,OAAO,oBAAM,KAAK,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["import_react_module","import_jsx_runtime","import_react_module","import_jsx_runtime","import_jsx_runtime","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","witnesses","import_react_shared","import_sentinel_model","error","import_react_node","import_sentinel_model","import_react_node","import_sentinel_model","import_react_node","import_sentinel_model"]}
|
|
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, mod, ...props }) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} 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?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} 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, mod, ...props }) => {\n return (\n <ModuleCardContent mod={mod} {...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, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: mod, 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 [${mod?.config?.name ?? mod.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: mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.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: mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.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","// eslint-disable-next-line import/no-deprecated\nimport { 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 // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\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 // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\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((mod) => {\n const instance = asSentinelInstance(mod?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":"mbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,GAAA,wBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,qBAAAC,GAAA,yBAAAC,EAAA,uBAAAC,GAAA,wBAAAC,GAAA,yBAAAC,GAAA,4BAAAC,GAAA,6BAAAC,KAAA,eAAAC,GAAAb,ICAA,IAAAc,EAAgC,yBAChCC,EAA2B,iCAI3BC,EAAyB,iBCJzB,IAAAC,EAAyB,gCACzBC,EAAqD,qCAW/CC,EAAA,6BAHOC,EAA0D,CAAC,CAAE,SAAAC,EAAU,IAAAC,EAAK,GAAGC,CAAM,OAE9F,OAAC,qBAAkB,IAAKD,EAAM,GAAGC,EAC/B,mBAAC,YAAS,QAAS,IAAMF,IAAWC,CAAG,EAAG,KAAM,QAAS,QAAS,WAAY,kBAE9E,EACF,ECfJ,IAAAE,EAA4B,iCAE5BC,EAAqD,qCACrDC,EAA6B,+CAYvBC,EAAA,6BAHOC,EAA0D,CAAC,CAAE,SAAAC,EAAU,OAAAC,EAAQ,IAAAC,EAAK,GAAGC,CAAM,OAEtG,OAAC,qBAAkB,IAAKD,EAAM,GAAGC,EAC/B,oBAAC,eAAY,SAAS,OAAO,eAAe,QAAQ,IAAK,EACtD,UAAAF,KACC,OAAC,gBAAa,MAAOA,EAAQ,EAC7B,KACDD,GACH,EACF,ECrBJ,IAAAI,EAAoD,qCAI3CC,EAAA,6BADIC,EAAsF,CAAC,CAAE,MAAAC,EAAO,IAAAC,EAAK,GAAGC,CAAM,OAClH,OAAC,oBAA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AAyD,mCACzDC,EAAqD,uCAExCC,GAAuB,CAClCC,EACAC,IAC+D,CAE/D,GAAM,CAACC,EAASC,CAAK,KAAI,sBAAmBH,EAAQC,CAAM,EAC1D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEdD,EACH,CAEEA,EAAQ,OAA2B,CAACE,EAAMC,QACpC,sBAAmBA,CAAG,GACxBD,EAAK,KAAKC,CAAG,EAERD,GACN,CAAC,CAAC,EACL,MACF,EACA,CAACF,EAASC,CAAK,CACrB,EC1BA,IAAAG,EAAgE,mCAChEC,EAAqD,uCAExCC,GAA0B,CACrCC,EACAC,OAEO,yBAAwCD,EAAyB,CAAE,SAAU,qBAAoB,GAAGC,CAAO,CAAC,ECPrH,IAAAC,EAAuB,0BAEvBC,EAA6D,mCAC7DC,GAAqD,uCAExCC,GAA2B,CACtCC,EACAC,IACwE,CACxE,GAAM,CAACC,EAASC,CAAK,KAAI,0BAAuBH,EAAQC,CAAM,EAC9D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEd,CACLD,GACI,IAAKE,GAAQ,CACb,IAAMC,KAAW,uBAAmBD,GAAK,MAAM,CAAC,EAChD,GAAIC,EACF,OAAO,IAAI,QAAQA,CAAQ,CAE/B,CAAC,EACA,OAAO,QAAM,GAAK,CAAC,EACtB,MACF,CACF","names":["src_exports","__export","SentinelCard","SentinelCardContent","SentinelCardHeader","SentinelContext","SentinelProvider","SentinelReportStatus","useSentinelContext","useSentinelFromNode","useSentinelsFromNode","useWeakSentinelFromNode","useWeakSentinelsFromNode","__toCommonJS","import_material","import_react_promise","import_react","import_react_button","import_react_module","import_jsx_runtime","SentinelCardActions","onReport","mod","props","import_react_flexbox","import_react_module","import_react_payload_raw_info","import_jsx_runtime","SentinelCardContent","children","report","mod","props","import_react_module","import_jsx_runtime","SentinelCardHeader","title","mod","props","import_jsx_runtime","SentinelCard","children","inPayloads","mod","props","retry","setRetry","report","SentinelCardHeader","SentinelCardContent","SentinelCardActions","import_react_shared","SentinelContext","import_react_async_effect","import_react_witness","import_sentinel_memory","import_sentinel_model","import_witness_model","import_react","SentinelReportStatus","import_jsx_runtime","SentinelProvider","account","archivist","children","filter","name","required","sentinel","setSentinel","history","setHistory","progress","setProgress","status","setStatus","reportingErrors","setReportingErrors","witnesses","mounted","mod","offCallbacks","outPayloads","witness","callback","SentinelContext","import_react_shared","useSentinelContext","sentinel","history","progress","reportingErrors","status","SentinelContext","import_react_node","import_sentinel_model","useSentinelFromNode","nameOrAddressOrInstance","config","mod","error","instance","import_react_node","import_sentinel_model","useSentinelsFromNode","filter","config","modules","error","prev","mod","import_react_node","import_sentinel_model","useWeakSentinelFromNode","nameOrAddressOrInstance","config","import_exists","import_react_node","import_sentinel_model","useWeakSentinelsFromNode","filter","config","modules","error","mod","instance"]}
|