@xyo-network/react-archivist 7.5.8 → 7.5.11
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/index.mjs +212 -300
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +150 -45
- package/src/components/Card/Card.stories.tsx +0 -82
- package/src/components/Card/Card.tsx +0 -22
- package/src/components/Card/CardActions.tsx +0 -9
- package/src/components/Card/CardContent.tsx +0 -42
- package/src/components/Card/CardHeader.tsx +0 -27
- package/src/components/Card/components/ArchivistParent.tsx +0 -26
- package/src/components/Card/components/ArchivistParents.tsx +0 -53
- package/src/components/Card/components/Stats/ArchivistStats.stories.tsx +0 -36
- package/src/components/Card/components/Stats/ArchivistStats.tsx +0 -60
- package/src/components/Card/components/Stats/MemoryArchivistStats.stories.tsx +0 -60
- package/src/components/Card/components/Stats/MemoryArchivistStats.tsx +0 -83
- package/src/components/Card/components/Stats/index.ts +0 -2
- package/src/components/Card/components/index.ts +0 -3
- package/src/components/Card/index.ts +0 -3
- package/src/components/Details/Details.stories.tsx +0 -74
- package/src/components/Details/Details.tsx +0 -74
- package/src/components/Details/index.ts +0 -1
- package/src/components/index.ts +0 -2
- package/src/hooks/index.ts +0 -2
- package/src/hooks/node/index.ts +0 -4
- package/src/hooks/node/useArchivistFromNode.tsx +0 -19
- package/src/hooks/node/useArchivistsFromNode.tsx +0 -28
- package/src/hooks/node/useWeakArchivistFromNode.tsx +0 -11
- package/src/hooks/node/useWeakArchivistsFromNode.tsx +0 -27
- package/src/hooks/queries/index.ts +0 -4
- package/src/hooks/queries/useArchivistAll.tsx +0 -22
- package/src/hooks/queries/useArchivistGet.tsx +0 -21
- package/src/hooks/queries/useWeakArchivistAll.tsx +0 -22
- package/src/hooks/queries/useWeakArchivistGet.tsx +0 -22
- package/src/index.ts +0 -2
package/dist/browser/index.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
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 { ModuleCardActions } from "@xyo-network/react-module";
|
|
7
|
-
import React7 from "react";
|
|
8
4
|
|
|
9
5
|
// src/components/Card/CardContent.tsx
|
|
10
6
|
import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
|
|
@@ -12,113 +8,95 @@ import { FlexGrowRow } from "@xylabs/react-flexbox";
|
|
|
12
8
|
import { ModuleWrapper } from "@xyo-network/module-wrapper";
|
|
13
9
|
import { ModuleCardContent } from "@xyo-network/react-module";
|
|
14
10
|
import { useWallet } from "@xyo-network/react-wallet";
|
|
15
|
-
import
|
|
11
|
+
import { useState as useState3 } from "react";
|
|
16
12
|
|
|
17
13
|
// src/components/Card/components/ArchivistParent.tsx
|
|
18
14
|
import { ListItem, Typography } from "@mui/material";
|
|
19
|
-
import
|
|
20
|
-
var ArchivistParent =
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
ml: 0.5
|
|
29
|
-
}
|
|
30
|
-
}, address)));
|
|
31
|
-
})), "ArchivistParent");
|
|
15
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var ArchivistParent = ({ archivistType, parentArchivists }) => /* @__PURE__ */ jsx(Fragment, { children: parentArchivists?.map((address) => {
|
|
17
|
+
return /* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsxs(Typography, { variant: "subtitle2", children: [
|
|
18
|
+
archivistType,
|
|
19
|
+
":",
|
|
20
|
+
" ",
|
|
21
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", sx: { ml: 0.5 }, children: address })
|
|
22
|
+
] }) }, address);
|
|
23
|
+
}) });
|
|
32
24
|
|
|
33
25
|
// src/components/Card/components/ArchivistParents.tsx
|
|
34
26
|
import { ArrowRightRounded as ArrowRightRoundedIcon } from "@mui/icons-material";
|
|
35
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
Collapse,
|
|
29
|
+
IconButton,
|
|
30
|
+
List,
|
|
31
|
+
Paper,
|
|
32
|
+
Typography as Typography2
|
|
33
|
+
} from "@mui/material";
|
|
36
34
|
import { FlexCol } from "@xylabs/react-flexbox";
|
|
37
|
-
import
|
|
38
|
-
|
|
35
|
+
import { useState } from "react";
|
|
36
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
37
|
+
var ArchivistParents = ({ config, ...props }) => {
|
|
39
38
|
const [parentArchivistCollapse, setParentArchivistCollapse] = useState(false);
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
archivistType: "Commit",
|
|
65
|
-
parentArchivists: commit
|
|
66
|
-
}), /* @__PURE__ */ React2.createElement(ArchivistParent, {
|
|
67
|
-
archivistType: "Read",
|
|
68
|
-
parentArchivists: read
|
|
69
|
-
}), /* @__PURE__ */ React2.createElement(ArchivistParent, {
|
|
70
|
-
archivistType: "Write",
|
|
71
|
-
parentArchivists: write
|
|
72
|
-
}))))) : null);
|
|
73
|
-
}, "ArchivistParents");
|
|
39
|
+
const {
|
|
40
|
+
commit,
|
|
41
|
+
read,
|
|
42
|
+
write
|
|
43
|
+
} = config?.parents ?? {};
|
|
44
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: commit || read || write ? /* @__PURE__ */ jsxs2(FlexCol, { alignItems: "start", ...props, children: [
|
|
45
|
+
/* @__PURE__ */ jsxs2("span", { onClick: () => setParentArchivistCollapse(!parentArchivistCollapse), children: [
|
|
46
|
+
/* @__PURE__ */ jsx2(
|
|
47
|
+
Typography2,
|
|
48
|
+
{
|
|
49
|
+
variant: "subtitle2",
|
|
50
|
+
sx: { cursor: "pointer", display: "inline-block" },
|
|
51
|
+
children: "Parents"
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx2(IconButton, { size: "small", children: /* @__PURE__ */ jsx2(ArrowRightRoundedIcon, { sx: { rotate: parentArchivistCollapse ? "90deg" : "0deg", transition: "all .25s" } }) })
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ jsx2(Collapse, { in: parentArchivistCollapse, children: /* @__PURE__ */ jsx2(Paper, { elevation: 2, children: /* @__PURE__ */ jsxs2(List, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx2(ArchivistParent, { archivistType: "Commit", parentArchivists: commit }),
|
|
58
|
+
/* @__PURE__ */ jsx2(ArchivistParent, { archivistType: "Read", parentArchivists: read }),
|
|
59
|
+
/* @__PURE__ */ jsx2(ArchivistParent, { archivistType: "Write", parentArchivists: write })
|
|
60
|
+
] }) }) })
|
|
61
|
+
] }) : null });
|
|
62
|
+
};
|
|
74
63
|
|
|
75
64
|
// src/components/Card/components/Stats/ArchivistStats.tsx
|
|
76
65
|
import { Badge, Tooltip } from "@mui/material";
|
|
77
66
|
import { FlexRow } from "@xylabs/react-flexbox";
|
|
78
|
-
import React3 from "react";
|
|
79
67
|
import { BsFileEarmarkCode } from "react-icons/bs";
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
title: "
|
|
94
|
-
|
|
95
|
-
badgeContent:
|
|
96
|
-
color: "primary"
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}))) : null, Object.entries(schemas ?? {}).length > 0 ? /* @__PURE__ */ React3.createElement(Tooltip, {
|
|
100
|
-
title: "Schemas"
|
|
101
|
-
}, /* @__PURE__ */ React3.createElement(Badge, {
|
|
102
|
-
badgeContent: Object.entries(schemas ?? {}).length,
|
|
103
|
-
color: "primary"
|
|
104
|
-
}, /* @__PURE__ */ React3.createElement(BsFileEarmarkCode, {
|
|
105
|
-
size: 20
|
|
106
|
-
}))) : null, Object.entries(addresses ?? {}).length > 0 ? /* @__PURE__ */ React3.createElement(Tooltip, {
|
|
107
|
-
title: "Addresses"
|
|
108
|
-
}, /* @__PURE__ */ React3.createElement(Badge, {
|
|
109
|
-
badgeContent: Object.entries(addresses ?? {}).length,
|
|
110
|
-
color: "primary"
|
|
111
|
-
}, /* @__PURE__ */ React3.createElement(VscOrganization, {
|
|
112
|
-
size: 20
|
|
113
|
-
}))) : null);
|
|
114
|
-
}, "ArchivistStats");
|
|
68
|
+
import {
|
|
69
|
+
VscOrganization,
|
|
70
|
+
VscSymbolMethod,
|
|
71
|
+
VscSymbolNamespace
|
|
72
|
+
} from "react-icons/vsc";
|
|
73
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
74
|
+
var ArchivistStats = ({
|
|
75
|
+
addresses,
|
|
76
|
+
boundWitnesses,
|
|
77
|
+
payloads,
|
|
78
|
+
schemas
|
|
79
|
+
}) => {
|
|
80
|
+
return /* @__PURE__ */ jsxs3(FlexRow, { gap: 2, mr: 0.5, children: [
|
|
81
|
+
payloads?.length ? /* @__PURE__ */ jsx3(Tooltip, { title: "Payloads", children: /* @__PURE__ */ jsx3(Badge, { badgeContent: payloads?.length, color: "primary", children: /* @__PURE__ */ jsx3(VscSymbolNamespace, { size: 20 }) }) }) : null,
|
|
82
|
+
boundWitnesses?.length ? /* @__PURE__ */ jsx3(Tooltip, { title: "Blocks", children: /* @__PURE__ */ jsx3(Badge, { badgeContent: boundWitnesses?.length, color: "primary", children: /* @__PURE__ */ jsx3(VscSymbolMethod, { size: 20 }) }) }) : null,
|
|
83
|
+
Object.entries(schemas ?? {}).length > 0 ? /* @__PURE__ */ jsx3(Tooltip, { title: "Schemas", children: /* @__PURE__ */ jsx3(Badge, { badgeContent: Object.entries(schemas ?? {}).length, color: "primary", children: /* @__PURE__ */ jsx3(BsFileEarmarkCode, { size: 20 }) }) }) : null,
|
|
84
|
+
Object.entries(addresses ?? {}).length > 0 ? /* @__PURE__ */ jsx3(Tooltip, { title: "Addresses", children: /* @__PURE__ */ jsx3(Badge, { badgeContent: Object.entries(addresses ?? {}).length, color: "primary", children: /* @__PURE__ */ jsx3(VscOrganization, { size: 20 }) }) }) : null
|
|
85
|
+
] });
|
|
86
|
+
};
|
|
115
87
|
|
|
116
88
|
// src/components/Card/components/Stats/MemoryArchivistStats.tsx
|
|
117
89
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
118
90
|
import { ArchivistAllQuerySchema } from "@xyo-network/archivist-model";
|
|
119
91
|
import { asBoundWitness, BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
120
|
-
import
|
|
121
|
-
|
|
92
|
+
import {
|
|
93
|
+
useCallback,
|
|
94
|
+
useEffect,
|
|
95
|
+
useMemo,
|
|
96
|
+
useState as useState2
|
|
97
|
+
} from "react";
|
|
98
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
99
|
+
var MemoryArchivistsStats = ({ archivist }) => {
|
|
122
100
|
const [all, setAll] = useState2();
|
|
123
101
|
const getAll = useCallback(async (archivist2) => {
|
|
124
102
|
const all2 = await archivist2?.all?.();
|
|
@@ -139,26 +117,19 @@ var MemoryArchivistsStats = /* @__PURE__ */ __name(({ archivist }) => {
|
|
|
139
117
|
return () => {
|
|
140
118
|
for (const listener of listeners) listener?.();
|
|
141
119
|
};
|
|
142
|
-
}, [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
]);
|
|
156
|
-
const payloads = useMemo(() => all === null ? [] : all?.filter((payload) => payload.schema !== BoundWitnessSchema), [
|
|
157
|
-
all
|
|
158
|
-
]);
|
|
159
|
-
const boundWitnesses = useMemo(() => all === null ? [] : all?.filter((payload) => payload.schema === BoundWitnessSchema), [
|
|
160
|
-
all
|
|
161
|
-
]);
|
|
120
|
+
}, [archivist, getAll]);
|
|
121
|
+
useAsyncEffect(
|
|
122
|
+
async () => {
|
|
123
|
+
if (archivist?.queries.includes(ArchivistAllQuerySchema)) {
|
|
124
|
+
await getAll(archivist);
|
|
125
|
+
} else {
|
|
126
|
+
setAll(null);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[archivist, getAll]
|
|
130
|
+
);
|
|
131
|
+
const payloads = useMemo(() => all === null ? [] : all?.filter((payload) => payload.schema !== BoundWitnessSchema), [all]);
|
|
132
|
+
const boundWitnesses = useMemo(() => all === null ? [] : all?.filter((payload) => payload.schema === BoundWitnessSchema), [all]);
|
|
162
133
|
const addresses = useMemo(() => {
|
|
163
134
|
const addressCounts = {};
|
|
164
135
|
if (all) {
|
|
@@ -172,9 +143,7 @@ var MemoryArchivistsStats = /* @__PURE__ */ __name(({ archivist }) => {
|
|
|
172
143
|
}
|
|
173
144
|
}
|
|
174
145
|
return addressCounts;
|
|
175
|
-
}, [
|
|
176
|
-
all
|
|
177
|
-
]);
|
|
146
|
+
}, [all]);
|
|
178
147
|
const schemas = useMemo(() => {
|
|
179
148
|
const schemaCounts = {};
|
|
180
149
|
if (all) {
|
|
@@ -183,86 +152,78 @@ var MemoryArchivistsStats = /* @__PURE__ */ __name(({ archivist }) => {
|
|
|
183
152
|
}
|
|
184
153
|
}
|
|
185
154
|
return schemaCounts;
|
|
186
|
-
}, [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return /* @__PURE__ */ React4.createElement(ArchivistStats, {
|
|
190
|
-
addresses,
|
|
191
|
-
boundWitnesses,
|
|
192
|
-
payloads,
|
|
193
|
-
schemas
|
|
194
|
-
});
|
|
195
|
-
}, "MemoryArchivistsStats");
|
|
155
|
+
}, [all]);
|
|
156
|
+
return /* @__PURE__ */ jsx4(ArchivistStats, { addresses, boundWitnesses, payloads, schemas });
|
|
157
|
+
};
|
|
196
158
|
|
|
197
159
|
// src/components/Card/CardContent.tsx
|
|
198
|
-
|
|
160
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
161
|
+
var ArchivistCardContent = ({
|
|
162
|
+
children,
|
|
163
|
+
mod,
|
|
164
|
+
...props
|
|
165
|
+
}) => {
|
|
199
166
|
const [config, setConfig] = useState3();
|
|
200
167
|
const [wallet] = useWallet();
|
|
201
|
-
useAsyncEffect2(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
168
|
+
useAsyncEffect2(
|
|
169
|
+
async (mounted) => {
|
|
170
|
+
if (wallet && mod) {
|
|
171
|
+
const wrapper = ModuleWrapper.wrap(mod, wallet);
|
|
172
|
+
const payloads = await wrapper?.state();
|
|
173
|
+
if (mounted()) {
|
|
174
|
+
setConfig(payloads?.[0]);
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
setConfig(void 0);
|
|
207
178
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
]);
|
|
215
|
-
|
|
216
|
-
mod,
|
|
217
|
-
...props
|
|
218
|
-
}, /* @__PURE__ */ React5.createElement(FlexGrowRow, {
|
|
219
|
-
flexWrap: "wrap",
|
|
220
|
-
justifyContent: "start",
|
|
221
|
-
gap: 2
|
|
222
|
-
}, children, /* @__PURE__ */ React5.createElement(ArchivistParents, {
|
|
223
|
-
config
|
|
224
|
-
})));
|
|
225
|
-
}, "ArchivistCardContent");
|
|
179
|
+
},
|
|
180
|
+
[mod, wallet]
|
|
181
|
+
);
|
|
182
|
+
return /* @__PURE__ */ jsx5(ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ jsxs4(FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
183
|
+
children,
|
|
184
|
+
/* @__PURE__ */ jsx5(ArchivistParents, { config })
|
|
185
|
+
] }) });
|
|
186
|
+
};
|
|
226
187
|
|
|
227
188
|
// src/components/Card/CardHeader.tsx
|
|
228
189
|
import { MemoryArchivistConfigSchema } from "@xyo-network/archivist-memory";
|
|
229
190
|
import { ModuleCardHeader } from "@xyo-network/react-module";
|
|
230
|
-
import
|
|
231
|
-
|
|
191
|
+
import { useMemo as useMemo2 } from "react";
|
|
192
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
193
|
+
var ArchivistStats2 = (archivist) => {
|
|
232
194
|
const { config } = archivist ?? {};
|
|
233
195
|
switch (config?.schema) {
|
|
234
196
|
case MemoryArchivistConfigSchema: {
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
-
archivist
|
|
237
|
-
});
|
|
197
|
+
return /* @__PURE__ */ jsx6(MemoryArchivistsStats, { archivist });
|
|
238
198
|
}
|
|
239
199
|
default: {
|
|
240
200
|
return;
|
|
241
201
|
}
|
|
242
202
|
}
|
|
243
|
-
}
|
|
244
|
-
var ArchivistCardHeader =
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
...props
|
|
253
|
-
});
|
|
254
|
-
}, "ArchivistCardHeader");
|
|
203
|
+
};
|
|
204
|
+
var ArchivistCardHeader = ({
|
|
205
|
+
title,
|
|
206
|
+
mod,
|
|
207
|
+
...props
|
|
208
|
+
}) => {
|
|
209
|
+
const Stats = useMemo2(() => ArchivistStats2(mod), [mod]);
|
|
210
|
+
return /* @__PURE__ */ jsx6(ModuleCardHeader, { mod, title: title ?? mod?.config.name ?? "Archivist", action: Stats, ...props });
|
|
211
|
+
};
|
|
255
212
|
|
|
256
213
|
// src/components/Card/Card.tsx
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
214
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
215
|
+
var ArchivistCard = ({
|
|
216
|
+
children,
|
|
217
|
+
mod,
|
|
218
|
+
...props
|
|
219
|
+
}) => {
|
|
220
|
+
return /* @__PURE__ */ jsxs5(Card, { ...props, children: [
|
|
221
|
+
/* @__PURE__ */ jsx7(ArchivistCardHeader, { mod }),
|
|
222
|
+
/* @__PURE__ */ jsx7(ArchivistCardContent, { mod }),
|
|
223
|
+
children,
|
|
224
|
+
/* @__PURE__ */ jsx7(ModuleCardActions, { mod })
|
|
225
|
+
] });
|
|
226
|
+
};
|
|
266
227
|
|
|
267
228
|
// src/components/Details/Details.tsx
|
|
268
229
|
import { ButtonGroup, Typography as Typography3 } from "@mui/material";
|
|
@@ -271,38 +232,29 @@ import { ButtonEx } from "@xylabs/react-button";
|
|
|
271
232
|
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
272
233
|
import { ArchivistClearQuerySchema, ArchivistCommitQuerySchema } from "@xyo-network/archivist-model";
|
|
273
234
|
import { QueryBoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
274
|
-
import
|
|
235
|
+
import { useState as useState6 } from "react";
|
|
275
236
|
|
|
276
237
|
// src/hooks/node/useArchivistFromNode.tsx
|
|
277
238
|
import { asArchivistInstance } from "@xyo-network/archivist-model";
|
|
278
239
|
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
279
|
-
var useArchivistFromNode =
|
|
240
|
+
var useArchivistFromNode = (nameOrAddressOrInstance, config) => {
|
|
280
241
|
const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
281
242
|
const instance = asArchivistInstance(mod);
|
|
282
243
|
if (mod && !instance) {
|
|
283
244
|
const error2 = new Error(`Resolved module is not a ArchivistInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`);
|
|
284
245
|
console.error(error2.message);
|
|
285
|
-
return [
|
|
286
|
-
void 0,
|
|
287
|
-
error2
|
|
288
|
-
];
|
|
246
|
+
return [void 0, error2];
|
|
289
247
|
}
|
|
290
|
-
return [
|
|
291
|
-
|
|
292
|
-
error
|
|
293
|
-
];
|
|
294
|
-
}, "useArchivistFromNode");
|
|
248
|
+
return [instance, error];
|
|
249
|
+
};
|
|
295
250
|
|
|
296
251
|
// src/hooks/node/useArchivistsFromNode.tsx
|
|
297
252
|
import { isArchivistInstance } from "@xyo-network/archivist-model";
|
|
298
253
|
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
299
|
-
var useArchivistsFromNode =
|
|
254
|
+
var useArchivistsFromNode = (ids, config) => {
|
|
300
255
|
const [modules, error] = useModulesFromNode(ids, config);
|
|
301
256
|
if (error) {
|
|
302
|
-
return [
|
|
303
|
-
null,
|
|
304
|
-
error
|
|
305
|
-
];
|
|
257
|
+
return [null, error];
|
|
306
258
|
}
|
|
307
259
|
return modules ? [
|
|
308
260
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
@@ -313,33 +265,24 @@ var useArchivistsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
313
265
|
return prev;
|
|
314
266
|
}, []),
|
|
315
267
|
void 0
|
|
316
|
-
] : [
|
|
317
|
-
|
|
318
|
-
error
|
|
319
|
-
];
|
|
320
|
-
}, "useArchivistsFromNode");
|
|
268
|
+
] : [modules, error];
|
|
269
|
+
};
|
|
321
270
|
|
|
322
271
|
// src/hooks/node/useWeakArchivistFromNode.tsx
|
|
323
272
|
import { isArchivistInstance as isArchivistInstance2 } from "@xyo-network/archivist-model";
|
|
324
273
|
import { useWeakModuleFromNode } from "@xyo-network/react-node";
|
|
325
|
-
var useWeakArchivistFromNode =
|
|
326
|
-
return useWeakModuleFromNode(nameOrAddressOrInstance, {
|
|
327
|
-
|
|
328
|
-
...config
|
|
329
|
-
});
|
|
330
|
-
}, "useWeakArchivistFromNode");
|
|
274
|
+
var useWeakArchivistFromNode = (nameOrAddressOrInstance, config) => {
|
|
275
|
+
return useWeakModuleFromNode(nameOrAddressOrInstance, { identity: isArchivistInstance2, ...config });
|
|
276
|
+
};
|
|
331
277
|
|
|
332
278
|
// src/hooks/node/useWeakArchivistsFromNode.tsx
|
|
333
279
|
import { exists } from "@xylabs/sdk-js";
|
|
334
280
|
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/archivist-model";
|
|
335
281
|
import { useWeakModulesFromNode } from "@xyo-network/react-node";
|
|
336
|
-
var useWeakArchivistsFromNode =
|
|
282
|
+
var useWeakArchivistsFromNode = (ids, config) => {
|
|
337
283
|
const [modules, error] = useWeakModulesFromNode(ids, config);
|
|
338
284
|
if (error) {
|
|
339
|
-
return [
|
|
340
|
-
null,
|
|
341
|
-
error
|
|
342
|
-
];
|
|
285
|
+
return [null, error];
|
|
343
286
|
}
|
|
344
287
|
return [
|
|
345
288
|
modules?.map((mod) => {
|
|
@@ -350,13 +293,13 @@ var useWeakArchivistsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
350
293
|
}).filter(exists) ?? [],
|
|
351
294
|
void 0
|
|
352
295
|
];
|
|
353
|
-
}
|
|
296
|
+
};
|
|
354
297
|
|
|
355
298
|
// src/hooks/queries/useArchivistAll.tsx
|
|
356
299
|
import { usePromise } from "@xylabs/react-promise";
|
|
357
300
|
import { useRefresh } from "@xyo-network/react-module";
|
|
358
301
|
import { useState as useState4 } from "react";
|
|
359
|
-
var useArchivistAll =
|
|
302
|
+
var useArchivistAll = (archivist) => {
|
|
360
303
|
const [error, setError] = useState4();
|
|
361
304
|
const [enabled, refresh] = useRefresh();
|
|
362
305
|
const payloads = usePromise(async () => {
|
|
@@ -368,43 +311,28 @@ var useArchivistAll = /* @__PURE__ */ __name((archivist) => {
|
|
|
368
311
|
const error2 = ex;
|
|
369
312
|
setError(error2);
|
|
370
313
|
}
|
|
371
|
-
}, [
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
]);
|
|
375
|
-
return [
|
|
376
|
-
payloads,
|
|
377
|
-
error,
|
|
378
|
-
refresh
|
|
379
|
-
];
|
|
380
|
-
}, "useArchivistAll");
|
|
314
|
+
}, [archivist, enabled]);
|
|
315
|
+
return [payloads, error, refresh];
|
|
316
|
+
};
|
|
381
317
|
|
|
382
318
|
// src/hooks/queries/useArchivistGet.tsx
|
|
383
319
|
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
384
320
|
import { useRefresh as useRefresh2 } from "@xyo-network/react-module";
|
|
385
|
-
var useArchivistGet =
|
|
321
|
+
var useArchivistGet = (archivist, hashes) => {
|
|
386
322
|
const [enabled, refresh] = useRefresh2();
|
|
387
323
|
const [payloads, error] = usePromise2(async () => {
|
|
388
324
|
if (enabled && archivist && hashes) {
|
|
389
325
|
return await archivist.get(hashes);
|
|
390
326
|
}
|
|
391
|
-
}, [
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
enabled
|
|
395
|
-
]);
|
|
396
|
-
return [
|
|
397
|
-
payloads,
|
|
398
|
-
error,
|
|
399
|
-
refresh
|
|
400
|
-
];
|
|
401
|
-
}, "useArchivistGet");
|
|
327
|
+
}, [archivist, hashes, enabled]);
|
|
328
|
+
return [payloads, error, refresh];
|
|
329
|
+
};
|
|
402
330
|
|
|
403
331
|
// src/hooks/queries/useWeakArchivistAll.tsx
|
|
404
332
|
import { usePromise as usePromise3 } from "@xylabs/react-promise";
|
|
405
333
|
import { useRefresh as useRefresh3 } from "@xyo-network/react-module";
|
|
406
334
|
import { useState as useState5 } from "react";
|
|
407
|
-
var useWeakArchivistAll =
|
|
335
|
+
var useWeakArchivistAll = (archivist) => {
|
|
408
336
|
const [error, setError] = useState5();
|
|
409
337
|
const [enabled, refresh] = useRefresh3();
|
|
410
338
|
const payloads = usePromise3(async () => {
|
|
@@ -416,91 +344,75 @@ var useWeakArchivistAll = /* @__PURE__ */ __name((archivist) => {
|
|
|
416
344
|
const error2 = ex;
|
|
417
345
|
setError(error2);
|
|
418
346
|
}
|
|
419
|
-
}, [
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
]);
|
|
423
|
-
return [
|
|
424
|
-
payloads,
|
|
425
|
-
error,
|
|
426
|
-
refresh
|
|
427
|
-
];
|
|
428
|
-
}, "useWeakArchivistAll");
|
|
347
|
+
}, [archivist, enabled]);
|
|
348
|
+
return [payloads, error, refresh];
|
|
349
|
+
};
|
|
429
350
|
|
|
430
351
|
// src/hooks/queries/useWeakArchivistGet.tsx
|
|
431
352
|
import { usePromise as usePromise4 } from "@xylabs/react-promise";
|
|
432
353
|
import { useRefresh as useRefresh4 } from "@xyo-network/react-module";
|
|
433
|
-
var useWeakArchivistGet =
|
|
354
|
+
var useWeakArchivistGet = (archivist, hashes) => {
|
|
434
355
|
const [enabled, refresh] = useRefresh4();
|
|
435
356
|
const [payloads, error] = usePromise4(async () => {
|
|
436
357
|
const archivistInstance = archivist?.deref();
|
|
437
358
|
if (enabled && archivistInstance && hashes) {
|
|
438
359
|
return await archivistInstance.get(hashes);
|
|
439
360
|
}
|
|
440
|
-
}, [
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
enabled
|
|
444
|
-
]);
|
|
445
|
-
return [
|
|
446
|
-
payloads,
|
|
447
|
-
error,
|
|
448
|
-
refresh
|
|
449
|
-
];
|
|
450
|
-
}, "useWeakArchivistGet");
|
|
361
|
+
}, [archivist, hashes, enabled]);
|
|
362
|
+
return [payloads, error, refresh];
|
|
363
|
+
};
|
|
451
364
|
|
|
452
365
|
// src/components/Details/Details.tsx
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
};
|
|
366
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
367
|
+
var testQueryCommit = { schema: ArchivistCommitQuerySchema };
|
|
456
368
|
var testQueryCommitBoundWitnessBuilder = new QueryBoundWitnessBuilder().query(testQueryCommit);
|
|
457
|
-
var testQueryClear = {
|
|
458
|
-
schema: ArchivistClearQuerySchema
|
|
459
|
-
};
|
|
369
|
+
var testQueryClear = { schema: ArchivistClearQuerySchema };
|
|
460
370
|
var testQueryClearBoundWitnessBuilder = new QueryBoundWitnessBuilder().query(testQueryClear);
|
|
461
|
-
var ArchivistDetails =
|
|
371
|
+
var ArchivistDetails = ({ address, ...props }) => {
|
|
462
372
|
const [archivist] = useWeakArchivistFromNode(address);
|
|
463
373
|
const [payloads, setPayloads] = useState6();
|
|
464
374
|
const [refresh, setRefresh] = useState6(0);
|
|
465
375
|
const [queryableCommit, setQueryableCommit] = useState6(false);
|
|
466
376
|
const [queryableClear, setQueryableClear] = useState6(false);
|
|
467
|
-
useAsyncEffect3(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
testQueryCommit
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
377
|
+
useAsyncEffect3(
|
|
378
|
+
async () => {
|
|
379
|
+
const instance = archivist?.deref();
|
|
380
|
+
if (instance) {
|
|
381
|
+
const [commitBW] = await testQueryCommitBoundWitnessBuilder.build();
|
|
382
|
+
const [clearBW] = await testQueryClearBoundWitnessBuilder.build();
|
|
383
|
+
setQueryableCommit(await instance?.queryable(commitBW, [testQueryCommit]));
|
|
384
|
+
setQueryableClear(await instance?.queryable(clearBW, [testQueryClear]));
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
[archivist]
|
|
388
|
+
);
|
|
389
|
+
useAsyncEffect3(
|
|
390
|
+
async (mounted) => {
|
|
391
|
+
const payloads2 = await archivist?.deref()?.all?.();
|
|
392
|
+
if (mounted()) {
|
|
393
|
+
setPayloads(payloads2);
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
[archivist, refresh]
|
|
397
|
+
);
|
|
398
|
+
return /* @__PURE__ */ jsxs6(FlexCol2, { ...props, children: [
|
|
399
|
+
/* @__PURE__ */ jsx8(Typography3, { children: `Payloads: ${payloads ? payloads.length : "-"}` }),
|
|
400
|
+
/* @__PURE__ */ jsxs6(ButtonGroup, { children: [
|
|
401
|
+
/* @__PURE__ */ jsx8(ButtonEx, { disabled: payloads?.length === 0 || !archivist || !queryableCommit, onClick: () => archivist?.deref()?.commit?.(), children: "Commit" }),
|
|
402
|
+
/* @__PURE__ */ jsx8(ButtonEx, { disabled: !archivist || !queryableClear, onClick: () => archivist?.deref()?.clear?.(), children: "Clear" }),
|
|
403
|
+
/* @__PURE__ */ jsx8(
|
|
404
|
+
ButtonEx,
|
|
405
|
+
{
|
|
406
|
+
disabled: !archivist,
|
|
407
|
+
onClick: () => {
|
|
408
|
+
setRefresh(refresh + 1);
|
|
409
|
+
},
|
|
410
|
+
children: "Refresh"
|
|
411
|
+
}
|
|
412
|
+
)
|
|
413
|
+
] })
|
|
414
|
+
] });
|
|
415
|
+
};
|
|
504
416
|
export {
|
|
505
417
|
ArchivistCard,
|
|
506
418
|
ArchivistCardContent,
|