@xyo-network/react-sentinel 7.0.0 → 7.0.2
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.
|
@@ -2,12 +2,12 @@ import type { Meta } from '@storybook/react-vite';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SentinelCard } from './Card.tsx';
|
|
4
4
|
declare const StorybookEntry: Meta<typeof SentinelCard>;
|
|
5
|
-
declare const NftSentinelCard: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
|
|
5
|
+
declare const NftSentinelCard: import(".store/storybook-virtual-fa39dd25b7/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
|
|
6
6
|
component?: React.ElementType;
|
|
7
7
|
} & import("@xyo-network/react-module").ModuleRenderProps<import("@xyo-network/sentinel-model").SentinelInstance<import("@xyo-network/sentinel-model").SentinelParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/sentinel-model").SentinelConfig>>, import("@xyo-network/sentinel-model").SentinelModuleEventData<import("@xyo-network/module-model").Module<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>>> & {
|
|
8
8
|
inPayloads?: import("@xyo-network/payload-model").Payload[];
|
|
9
9
|
}>;
|
|
10
|
-
declare const NftTokensSentinelCard: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
|
|
10
|
+
declare const NftTokensSentinelCard: import(".store/storybook-virtual-fa39dd25b7/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("@mui/material").CardOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "classes" | "className" | "style" | "children" | "sx" | "variant" | "elevation" | "square" | "raised"> & {
|
|
11
11
|
component?: React.ElementType;
|
|
12
12
|
} & import("@xyo-network/react-module").ModuleRenderProps<import("@xyo-network/sentinel-model").SentinelInstance<import("@xyo-network/sentinel-model").SentinelParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/sentinel-model").SentinelConfig>>, import("@xyo-network/sentinel-model").SentinelModuleEventData<import("@xyo-network/module-model").Module<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>>> & {
|
|
13
13
|
inPayloads?: import("@xyo-network/payload-model").Payload[];
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,77 +1,69 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/Card/Card.tsx
|
|
5
2
|
import { Card } from "@mui/material";
|
|
6
3
|
import { usePromise } from "@xylabs/react-promise";
|
|
7
|
-
import
|
|
4
|
+
import { useState } from "react";
|
|
8
5
|
|
|
9
6
|
// src/components/Card/CardActions.tsx
|
|
10
7
|
import { ButtonEx } from "@xylabs/react-button";
|
|
11
8
|
import { ModuleCardActions } from "@xyo-network/react-module";
|
|
12
|
-
import
|
|
13
|
-
var SentinelCardActions =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
variant: "outlined"
|
|
21
|
-
}, "Report"));
|
|
22
|
-
}, "SentinelCardActions");
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var SentinelCardActions = ({
|
|
11
|
+
onReport,
|
|
12
|
+
mod,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
return /* @__PURE__ */ jsx(ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ jsx(ButtonEx, { onClick: () => onReport?.(mod), size: "small", variant: "outlined", children: "Report" }) });
|
|
16
|
+
};
|
|
23
17
|
|
|
24
18
|
// src/components/Card/CardContent.tsx
|
|
25
19
|
import { FlexGrowRow } from "@xylabs/react-flexbox";
|
|
26
20
|
import { ModuleCardContent } from "@xyo-network/react-module";
|
|
27
21
|
import { JsonViewerEx } from "@xyo-network/react-payload-raw-info";
|
|
28
|
-
import
|
|
29
|
-
var SentinelCardContent =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, "SentinelCardContent");
|
|
22
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var SentinelCardContent = ({
|
|
24
|
+
children,
|
|
25
|
+
report,
|
|
26
|
+
mod,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
return /* @__PURE__ */ jsx2(ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ jsxs(FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
30
|
+
report ? /* @__PURE__ */ jsx2(JsonViewerEx, { value: report }) : null,
|
|
31
|
+
children
|
|
32
|
+
] }) });
|
|
33
|
+
};
|
|
41
34
|
|
|
42
35
|
// src/components/Card/CardHeader.tsx
|
|
43
36
|
import { ModuleCardHeader } from "@xyo-network/react-module";
|
|
44
|
-
import
|
|
45
|
-
var SentinelCardHeader =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
37
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
38
|
+
var SentinelCardHeader = ({
|
|
39
|
+
title,
|
|
40
|
+
mod,
|
|
41
|
+
...props
|
|
42
|
+
}) => {
|
|
43
|
+
return /* @__PURE__ */ jsx3(ModuleCardHeader, { mod, title: title ?? mod?.config.name ?? "Sentinel", ...props });
|
|
44
|
+
};
|
|
52
45
|
|
|
53
46
|
// src/components/Card/Card.tsx
|
|
54
|
-
|
|
47
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
48
|
+
var SentinelCard = ({
|
|
49
|
+
children,
|
|
50
|
+
inPayloads,
|
|
51
|
+
mod,
|
|
52
|
+
...props
|
|
53
|
+
}) => {
|
|
55
54
|
const [retry, setRetry] = useState(-1);
|
|
56
55
|
const [report] = usePromise(async () => {
|
|
57
56
|
if (retry >= 0) {
|
|
58
57
|
return await mod?.report(inPayloads);
|
|
59
58
|
}
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
mod,
|
|
69
|
-
report
|
|
70
|
-
}), children, /* @__PURE__ */ React4.createElement(SentinelCardActions, {
|
|
71
|
-
mod,
|
|
72
|
-
onReport: /* @__PURE__ */ __name(() => setRetry(retry + 1), "onReport")
|
|
73
|
-
}));
|
|
74
|
-
}, "SentinelCard");
|
|
59
|
+
}, [mod, retry, inPayloads]);
|
|
60
|
+
return /* @__PURE__ */ jsxs2(Card, { ...props, children: [
|
|
61
|
+
/* @__PURE__ */ jsx4(SentinelCardHeader, { mod }),
|
|
62
|
+
/* @__PURE__ */ jsx4(SentinelCardContent, { mod, report }),
|
|
63
|
+
children,
|
|
64
|
+
/* @__PURE__ */ jsx4(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
75
67
|
|
|
76
68
|
// src/contexts/Context.ts
|
|
77
69
|
import { createContextEx } from "@xylabs/react-shared";
|
|
@@ -83,7 +75,11 @@ import { useWitnessesFromNode } from "@xyo-network/react-witness";
|
|
|
83
75
|
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
84
76
|
import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
|
|
85
77
|
import { asWitnessInstance } from "@xyo-network/witness-model";
|
|
86
|
-
import
|
|
78
|
+
import {
|
|
79
|
+
useEffect,
|
|
80
|
+
useMemo,
|
|
81
|
+
useState as useState2
|
|
82
|
+
} from "react";
|
|
87
83
|
|
|
88
84
|
// src/contexts/State.ts
|
|
89
85
|
import { Enum } from "@xylabs/enum";
|
|
@@ -96,96 +92,95 @@ var SentinelReportStatus = Enum({
|
|
|
96
92
|
});
|
|
97
93
|
|
|
98
94
|
// src/contexts/Provider.tsx
|
|
99
|
-
|
|
95
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
96
|
+
var SentinelProvider = ({
|
|
97
|
+
account,
|
|
98
|
+
archivist,
|
|
99
|
+
children,
|
|
100
|
+
ids,
|
|
101
|
+
name,
|
|
102
|
+
required = false
|
|
103
|
+
}) => {
|
|
100
104
|
const [sentinel, setSentinel] = useState2();
|
|
101
105
|
const [history, setHistory] = useState2();
|
|
102
106
|
const [progress, setProgress] = useState2({});
|
|
103
107
|
const [status, setStatus] = useState2(SentinelReportStatus.Idle);
|
|
104
108
|
const [reportingErrors, setReportingErrors] = useState2();
|
|
105
109
|
const [witnesses] = useWitnessesFromNode(ids);
|
|
106
|
-
useAsyncEffect(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
archivist
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
tasks: witnesses?.map((mod) => ({
|
|
117
|
-
mod: mod.address
|
|
118
|
-
}))
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
const offCallbacks = [];
|
|
122
|
-
offCallbacks.push(sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
|
|
123
|
-
if (mounted()) {
|
|
124
|
-
setProgress({
|
|
125
|
-
archivists: progress.archivists,
|
|
126
|
-
witnesses: progress.witnesses
|
|
127
|
-
});
|
|
128
|
-
setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
|
|
129
|
-
setReportingErrors([
|
|
130
|
-
new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)
|
|
131
|
-
]);
|
|
132
|
-
}
|
|
133
|
-
}), sentinel2.on("reportStart", () => {
|
|
134
|
-
if (mounted()) {
|
|
135
|
-
setProgress({
|
|
136
|
-
archivists: {},
|
|
137
|
-
witnesses: {}
|
|
138
|
-
});
|
|
139
|
-
setStatus(SentinelReportStatus.Started);
|
|
140
|
-
}
|
|
141
|
-
}));
|
|
142
|
-
if (witnesses) for (const witness of witnesses) {
|
|
143
|
-
offCallbacks.push(witness.on("observeEnd", ({ mod, outPayloads }) => {
|
|
144
|
-
const witnesses2 = progress.witnesses ?? {};
|
|
145
|
-
witnesses2[witness.address] = {
|
|
146
|
-
status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
|
|
147
|
-
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, {
|
|
148
|
-
required: true
|
|
149
|
-
})
|
|
150
|
-
};
|
|
151
|
-
if (mounted()) {
|
|
152
|
-
setProgress({
|
|
153
|
-
archivists: progress.archivists,
|
|
154
|
-
witnesses: witnesses2
|
|
155
|
-
});
|
|
110
|
+
useAsyncEffect(
|
|
111
|
+
async (mounted) => {
|
|
112
|
+
const sentinel2 = await MemorySentinel.create({
|
|
113
|
+
account,
|
|
114
|
+
config: {
|
|
115
|
+
archivists: archivist ? [archivist] : void 0,
|
|
116
|
+
name,
|
|
117
|
+
schema: SentinelConfigSchema,
|
|
118
|
+
synchronous: true,
|
|
119
|
+
tasks: witnesses?.map((mod) => ({ mod: mod.address }))
|
|
156
120
|
}
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
121
|
+
});
|
|
122
|
+
const offCallbacks = [];
|
|
123
|
+
offCallbacks.push(
|
|
124
|
+
sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
|
|
125
|
+
if (mounted()) {
|
|
126
|
+
setProgress({
|
|
127
|
+
archivists: progress.archivists,
|
|
128
|
+
witnesses: progress.witnesses
|
|
129
|
+
});
|
|
130
|
+
setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
|
|
131
|
+
setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)]);
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
sentinel2.on("reportStart", () => {
|
|
135
|
+
if (mounted()) {
|
|
136
|
+
setProgress({ archivists: {}, witnesses: {} });
|
|
137
|
+
setStatus(SentinelReportStatus.Started);
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
if (witnesses)
|
|
142
|
+
for (const witness of witnesses) {
|
|
143
|
+
offCallbacks.push(
|
|
144
|
+
witness.on("observeEnd", ({ mod, outPayloads }) => {
|
|
145
|
+
const witnesses2 = progress.witnesses ?? {};
|
|
146
|
+
witnesses2[witness.address] = {
|
|
147
|
+
status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
|
|
148
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
|
|
149
|
+
};
|
|
150
|
+
if (mounted()) {
|
|
151
|
+
setProgress({
|
|
152
|
+
archivists: progress.archivists,
|
|
153
|
+
witnesses: witnesses2
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
witness.on("observeStart", ({ mod }) => {
|
|
158
|
+
const witnesses2 = progress.witnesses ?? {};
|
|
159
|
+
witnesses2[witness.address] = {
|
|
160
|
+
status: SentinelReportStatus.Started,
|
|
161
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
|
|
162
|
+
};
|
|
163
|
+
if (mounted()) {
|
|
164
|
+
setProgress({
|
|
165
|
+
archivists: progress.archivists,
|
|
166
|
+
witnesses: witnesses2
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
);
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
account,
|
|
181
|
-
archivist,
|
|
182
|
-
witnesses
|
|
183
|
-
]);
|
|
172
|
+
setSentinel(sentinel2);
|
|
173
|
+
return () => {
|
|
174
|
+
for (const callback of offCallbacks) {
|
|
175
|
+
callback();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
[account, archivist, witnesses]
|
|
180
|
+
);
|
|
184
181
|
useEffect(() => {
|
|
185
182
|
setHistory(sentinel?.history);
|
|
186
|
-
}, [
|
|
187
|
-
sentinel
|
|
188
|
-
]);
|
|
183
|
+
}, [sentinel]);
|
|
189
184
|
const value = useMemo(() => ({
|
|
190
185
|
history,
|
|
191
186
|
progress,
|
|
@@ -193,22 +188,20 @@ var SentinelProvider = /* @__PURE__ */ __name(({ account, archivist, children, i
|
|
|
193
188
|
reportingErrors,
|
|
194
189
|
sentinel,
|
|
195
190
|
status
|
|
196
|
-
}), [
|
|
191
|
+
}), [history, progress, reportingErrors, sentinel, status]);
|
|
192
|
+
return !required || sentinel ? /* @__PURE__ */ jsx5(SentinelContext, { value, children }) : null;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/contexts/use.ts
|
|
196
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
197
|
+
var useSentinelContext = () => {
|
|
198
|
+
const {
|
|
199
|
+
sentinel,
|
|
197
200
|
history,
|
|
198
201
|
progress,
|
|
199
202
|
reportingErrors,
|
|
200
|
-
sentinel,
|
|
201
203
|
status
|
|
202
|
-
|
|
203
|
-
return !required || sentinel ? /* @__PURE__ */ React5.createElement(SentinelContext, {
|
|
204
|
-
value
|
|
205
|
-
}, children) : null;
|
|
206
|
-
}, "SentinelProvider");
|
|
207
|
-
|
|
208
|
-
// src/contexts/use.ts
|
|
209
|
-
import { useContextEx } from "@xylabs/react-shared";
|
|
210
|
-
var useSentinelContext = /* @__PURE__ */ __name(() => {
|
|
211
|
-
const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, "Sentinel");
|
|
204
|
+
} = useContextEx(SentinelContext, "Sentinel");
|
|
212
205
|
return {
|
|
213
206
|
history,
|
|
214
207
|
progress,
|
|
@@ -216,38 +209,29 @@ var useSentinelContext = /* @__PURE__ */ __name(() => {
|
|
|
216
209
|
sentinel,
|
|
217
210
|
status
|
|
218
211
|
};
|
|
219
|
-
}
|
|
212
|
+
};
|
|
220
213
|
|
|
221
214
|
// src/hooks/node/useSentinelFromNode.tsx
|
|
222
215
|
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
223
216
|
import { asSentinelInstance } from "@xyo-network/sentinel-model";
|
|
224
|
-
var useSentinelFromNode =
|
|
217
|
+
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
225
218
|
const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
226
219
|
const instance = asSentinelInstance(mod);
|
|
227
220
|
if (mod && !instance) {
|
|
228
221
|
const error2 = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`);
|
|
229
222
|
console.error(error2.message);
|
|
230
|
-
return [
|
|
231
|
-
void 0,
|
|
232
|
-
error2
|
|
233
|
-
];
|
|
223
|
+
return [void 0, error2];
|
|
234
224
|
}
|
|
235
|
-
return [
|
|
236
|
-
|
|
237
|
-
error
|
|
238
|
-
];
|
|
239
|
-
}, "useSentinelFromNode");
|
|
225
|
+
return [instance, error];
|
|
226
|
+
};
|
|
240
227
|
|
|
241
228
|
// src/hooks/node/useSentinelsFromNode.tsx
|
|
242
229
|
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
243
230
|
import { isSentinelInstance } from "@xyo-network/sentinel-model";
|
|
244
|
-
var useSentinelsFromNode =
|
|
231
|
+
var useSentinelsFromNode = (ids, config) => {
|
|
245
232
|
const [modules, error] = useModulesFromNode(ids, config);
|
|
246
233
|
if (error) {
|
|
247
|
-
return [
|
|
248
|
-
null,
|
|
249
|
-
error
|
|
250
|
-
];
|
|
234
|
+
return [null, error];
|
|
251
235
|
}
|
|
252
236
|
return modules ? [
|
|
253
237
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
@@ -258,33 +242,24 @@ var useSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
258
242
|
return prev;
|
|
259
243
|
}, []),
|
|
260
244
|
void 0
|
|
261
|
-
] : [
|
|
262
|
-
|
|
263
|
-
error
|
|
264
|
-
];
|
|
265
|
-
}, "useSentinelsFromNode");
|
|
245
|
+
] : [modules, error];
|
|
246
|
+
};
|
|
266
247
|
|
|
267
248
|
// src/hooks/node/useWeakSentinelFromNode.tsx
|
|
268
249
|
import { useWeakModuleFromNode } from "@xyo-network/react-node";
|
|
269
250
|
import { isSentinelInstance as isSentinelInstance2 } from "@xyo-network/sentinel-model";
|
|
270
|
-
var useWeakSentinelFromNode =
|
|
271
|
-
return useWeakModuleFromNode(nameOrAddressOrInstance, {
|
|
272
|
-
|
|
273
|
-
...config
|
|
274
|
-
});
|
|
275
|
-
}, "useWeakSentinelFromNode");
|
|
251
|
+
var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
252
|
+
return useWeakModuleFromNode(nameOrAddressOrInstance, { identity: isSentinelInstance2, ...config });
|
|
253
|
+
};
|
|
276
254
|
|
|
277
255
|
// src/hooks/node/useWeakSentinelsFromNode.tsx
|
|
278
256
|
import { exists } from "@xylabs/exists";
|
|
279
257
|
import { useWeakModulesFromNode } from "@xyo-network/react-node";
|
|
280
258
|
import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
|
|
281
|
-
var useWeakSentinelsFromNode =
|
|
259
|
+
var useWeakSentinelsFromNode = (ids, config) => {
|
|
282
260
|
const [modules, error] = useWeakModulesFromNode(ids, config);
|
|
283
261
|
if (error) {
|
|
284
|
-
return [
|
|
285
|
-
null,
|
|
286
|
-
error
|
|
287
|
-
];
|
|
262
|
+
return [null, error];
|
|
288
263
|
}
|
|
289
264
|
return [
|
|
290
265
|
modules?.map((mod) => {
|
|
@@ -295,7 +270,7 @@ var useWeakSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
295
270
|
}).filter(exists) ?? [],
|
|
296
271
|
void 0
|
|
297
272
|
];
|
|
298
|
-
}
|
|
273
|
+
};
|
|
299
274
|
export {
|
|
300
275
|
SentinelCard,
|
|
301
276
|
SentinelCardContent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\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 type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\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 type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { 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> = ({\n children, report, mod, ...props\n}) => {\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 type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\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 ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\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\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ 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 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', ({ 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}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ 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}]`, { required: true }),\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\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { EnumValue } from '@xylabs/enum'\nimport { Enum } from '@xylabs/enum'\nimport type { ContextExState } from '@xylabs/react-shared'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\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 type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, 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 type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } 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 type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, 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":";;;;AACA,SAASA,YAAY;AACrB,SAASC,kBAAkB;AAI3B,OAAOC,UAASC,gBAAgB;;;ACLhC,SAASC,gBAAgB;AAEzB,SAASC,yBAAyB;AAElC,OAAOC,WAAW;AAOX,IAAMC,sBAA0D,wBAAC,EACtEC,UAAUC,KAAK,GAAGC,MAAAA,MACnB;AACC,SACE,sBAAA,cAACC,mBAAAA;IAAkBF;IAAW,GAAGC;KAC/B,sBAAA,cAACE,UAAAA;IAASC,SAAS,6BAAML,WAAWC,GAAAA,GAAjB;IAAuBK,MAAK;IAAQC,SAAQ;KAAW,QAAA,CAAA;AAKhF,GAVuE;;;ACXvE,SAASC,mBAAmB;AAG5B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAE7B,OAAOC,YAAW;AAOX,IAAMC,sBAA0D,wBA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ACT,GAAG,CAAA,CAAE;IACLI;MAEF;IAACR;IAASC;;AAChB,GApBoC;;;ACLpC,SAASQ,6BAA6B;AAEtC,SAASC,sBAAAA,2BAA0B;AAE5B,IAAMC,0BAA0B,wBACrCC,yBACAC,WAAAA;AAEA,SAAOC,sBAAwCF,yBAAyB;IAAEG,UAAUC;IAAoB,GAAGH;EAAO,CAAA;AACpH,GALuC;;;ACLvC,SAASI,cAAc;AAGvB,SAASC,8BAA8B;AAEvC,SAASC,sBAAAA,2BAA0B;AAE5B,IAAMC,2BAA2B,wBACtCC,KACAC,WAAAA;AAEA,QAAM,CAACC,SAASC,KAAAA,IAASC,uBAAuBJ,KAAKC,MAAAA;AACrD,MAAIE,OAAO;AACT,WAAO;MAAC;MAAMA;;EAChB;AACA,SAAO;IACLD,SACIG,IAAI,CAACC,QAAAA;AACL,YAAMC,WAAWC,oBAAmBF,KAAKG,MAAAA,CAAAA;AACzC,UAAIF,UAAU;AACZ,eAAO,IAAIG,QAAQH,QAAAA;MACrB;IACF,CAAA,EACCI,OAAOC,MAAAA,KAAW,CAAA;IACrBC;;AAEJ,GAnBwC;","names":["Card","usePromise","React","useState","ButtonEx","ModuleCardActions","React","SentinelCardActions","onReport","mod","props","ModuleCardActions","ButtonEx","onClick","size","variant","FlexGrowRow","ModuleCardContent","JsonViewerEx","React","SentinelCardContent","children","report","mod","props","React","ModuleCardContent","FlexGrowRow","flexWrap","justifyContent","gap","JsonViewerEx","value","ModuleCardHeader","React","SentinelCardHeader","title","mod","props","React","ModuleCardHeader","config","name","SentinelCard","children","inPayloads","mod","props","retry","setRetry","useState","report","usePromise","React","Card","SentinelCardHeader","SentinelCardContent","SentinelCardActions","onReport","createContextEx","SentinelContext","useAsyncEffect","useWitnessesFromNode","MemorySentinel","SentinelConfigSchema","asWitnessInstance","React","useEffect","useMemo","useState","Enum","SentinelReportStatus","Idle","Queued","Started","Succeeded","Failed","SentinelProvider","account","archivist","children","ids","name","required","sentinel","setSentinel","useState","history","setHistory","progress","setProgress","status","setStatus","SentinelReportStatus","Idle","reportingErrors","setReportingErrors","witnesses","useWitnessesFromNode","useAsyncEffect","mounted","MemorySentinel","create","config","archivists","undefined","schema","SentinelConfigSchema","synchronous","tasks","map","mod","address","offCallbacks","push","on","outPayloads","length","Succeeded","Failed","Error","Started","witness","asWitnessInstance","id","callback","useEffect","value","useMemo","provided","React","SentinelContext","useContextEx","useSentinelContext","sentinel","history","progress","reportingErrors","status","useContextEx","SentinelContext","useModuleFromNode","asSentinelInstance","useSentinelFromNode","nameOrAddressOrInstance","config","mod","error","useModuleFromNode","instance","asSentinelInstance","Error","schema","name","address","console","message","undefined","useModulesFromNode","isSentinelInstance","useSentinelsFromNode","ids","config","modules","error","useModulesFromNode","reduce","prev","mod","isSentinelInstance","push","undefined","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","useWeakModuleFromNode","identity","isSentinelInstance","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","ids","config","modules","error","useWeakModulesFromNode","map","mod","instance","asSentinelInstance","deref","WeakRef","filter","exists","undefined"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\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 type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\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 type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { 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> = ({\n children, report, mod, ...props\n}) => {\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 type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\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 ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\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\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ 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 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', ({ 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}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ 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}]`, { required: true }),\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\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { EnumValue } from '@xylabs/enum'\nimport { Enum } from '@xylabs/enum'\nimport type { ContextExState } from '@xylabs/react-shared'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\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 type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, 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 type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } 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 type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, 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":";AACA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAI3B,SAAgB,gBAAgB;;;ACLhC,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAc5B;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAK,GAAG;AACpB,MAAM;AACJ,SACE,oBAAC,qBAAkB,KAAW,GAAG,OAC/B,8BAAC,YAAS,SAAS,MAAM,WAAW,GAAG,GAAG,MAAK,SAAQ,SAAQ,YAAW,oBAE1E,GACF;AAEJ;;;ACrBA,SAAS,mBAAmB;AAG5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAcvB,SAEM,OAAAA,MAFN;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAK,GAAG;AAC5B,MAAM;AACJ,SACE,gBAAAA,KAAC,qBAAkB,KAAW,GAAG,OAC/B,+BAAC,eAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACG,gBAAAA,KAA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;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;;;ACzBA,SAAS,6BAA6B;AAEtC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,SAAO,sBAAwC,yBAAyB,EAAE,UAAUA,qBAAoB,GAAG,OAAO,CAAC;AACrH;;;ACVA,SAAS,cAAc;AAGvB,SAAS,8BAA8B;AAEvC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,2BAA2B,CACtC,KACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,KAAK,MAAM;AAC3D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,IACL,SACI,IAAI,CAAC,QAAQ;AACb,YAAM,WAAWA,oBAAmB,KAAK,MAAM,CAAC;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,CAAC,EACA,OAAO,MAAM,KAAK,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","jsx","useState","sentinel","witnesses","error","isSentinelInstance","asSentinelInstance"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-sentinel",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -43,52 +43,55 @@
|
|
|
43
43
|
"src"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@xylabs/enum": "
|
|
47
|
-
"@xylabs/exists": "
|
|
48
|
-
"@xylabs/react-async-effect": "
|
|
49
|
-
"@xylabs/react-button": "
|
|
50
|
-
"@xylabs/react-flexbox": "
|
|
51
|
-
"@xylabs/react-promise": "
|
|
52
|
-
"@xylabs/react-shared": "
|
|
53
|
-
"@xyo-network/account-model": "
|
|
54
|
-
"@xyo-network/archivist-model": "
|
|
55
|
-
"@xyo-network/boundwitness-model": "
|
|
56
|
-
"@xyo-network/module-model": "
|
|
57
|
-
"@xyo-network/payload-model": "
|
|
58
|
-
"@xyo-network/react-module": "^7.0.
|
|
59
|
-
"@xyo-network/react-node": "^7.0.
|
|
60
|
-
"@xyo-network/react-payload-raw-info": "^7.0.
|
|
61
|
-
"@xyo-network/react-witness": "^7.0.
|
|
62
|
-
"@xyo-network/sentinel-memory": "
|
|
63
|
-
"@xyo-network/sentinel-model": "
|
|
64
|
-
"@xyo-network/witness-model": "
|
|
46
|
+
"@xylabs/enum": "~5.0.11",
|
|
47
|
+
"@xylabs/exists": "~5.0.11",
|
|
48
|
+
"@xylabs/react-async-effect": "~7.0.4",
|
|
49
|
+
"@xylabs/react-button": "~7.0.4",
|
|
50
|
+
"@xylabs/react-flexbox": "~7.0.4",
|
|
51
|
+
"@xylabs/react-promise": "~7.0.4",
|
|
52
|
+
"@xylabs/react-shared": "~7.0.4",
|
|
53
|
+
"@xyo-network/account-model": "~5.0.7",
|
|
54
|
+
"@xyo-network/archivist-model": "~5.0.7",
|
|
55
|
+
"@xyo-network/boundwitness-model": "~5.0.7",
|
|
56
|
+
"@xyo-network/module-model": "~5.0.7",
|
|
57
|
+
"@xyo-network/payload-model": "~5.0.7",
|
|
58
|
+
"@xyo-network/react-module": "^7.0.2",
|
|
59
|
+
"@xyo-network/react-node": "^7.0.2",
|
|
60
|
+
"@xyo-network/react-payload-raw-info": "^7.0.2",
|
|
61
|
+
"@xyo-network/react-witness": "^7.0.2",
|
|
62
|
+
"@xyo-network/sentinel-memory": "~5.0.7",
|
|
63
|
+
"@xyo-network/sentinel-model": "~5.0.7",
|
|
64
|
+
"@xyo-network/witness-model": "~5.0.7"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@emotion/react": "
|
|
68
|
-
"@emotion/styled": "
|
|
69
|
-
"@mui/icons-material": "
|
|
70
|
-
"@mui/material": "
|
|
71
|
-
"@storybook/react-vite": "
|
|
72
|
-
"@types/react": "
|
|
73
|
-
"@xylabs/ts-scripts-yarn3": "
|
|
74
|
-
"@xylabs/tsconfig
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"@xyo-network/
|
|
78
|
-
"@xyo-network/
|
|
79
|
-
"@xyo-network/
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
67
|
+
"@emotion/react": "~11.14.0",
|
|
68
|
+
"@emotion/styled": "~11.14.1",
|
|
69
|
+
"@mui/icons-material": "~7.3.1",
|
|
70
|
+
"@mui/material": "~7.3.1",
|
|
71
|
+
"@storybook/react-vite": "~9.1.3",
|
|
72
|
+
"@types/react": "~19.1.11",
|
|
73
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.7",
|
|
74
|
+
"@xylabs/tsconfig": "~7.1.7",
|
|
75
|
+
"@xylabs/tsconfig-dom": "~7.1.7",
|
|
76
|
+
"@xylabs/tsconfig-react": "~7.1.7",
|
|
77
|
+
"@xyo-network/account": "~5.0.7",
|
|
78
|
+
"@xyo-network/evm-call-witness": "~5.0.1",
|
|
79
|
+
"@xyo-network/manifest": "~5.0.7",
|
|
80
|
+
"@xyo-network/module-factory-locator": "~5.0.7",
|
|
81
|
+
"@xyo-network/wallet": "~5.0.7",
|
|
82
|
+
"ethers": "~6.15.0",
|
|
83
|
+
"react": "~19.1.1",
|
|
84
|
+
"react-dom": "~19.1.1",
|
|
85
|
+
"storybook": "~9.1.3",
|
|
86
|
+
"typescript": "~5.9.2",
|
|
87
|
+
"vite": "~7.1.3"
|
|
85
88
|
},
|
|
86
89
|
"peerDependencies": {
|
|
87
90
|
"@mui/icons-material": ">=6 <8",
|
|
88
91
|
"@mui/material": ">=6 <8",
|
|
89
|
-
"ethers": "
|
|
90
|
-
"react": "
|
|
91
|
-
"react-dom": "
|
|
92
|
+
"ethers": "~6",
|
|
93
|
+
"react": "~19",
|
|
94
|
+
"react-dom": "~19"
|
|
92
95
|
},
|
|
93
96
|
"peerDependenciesMeta": {
|
|
94
97
|
"ethers": {
|