@xyo-network/react-archivist 2.77.0 → 2.77.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.
- package/dist/browser/hooks/node/useArchivistFromNode.d.cts +0 -1
- package/dist/browser/hooks/node/useArchivistFromNode.d.cts.map +1 -1
- package/dist/browser/hooks/node/useArchivistFromNode.d.mts +0 -1
- package/dist/browser/hooks/node/useArchivistFromNode.d.mts.map +1 -1
- package/dist/browser/hooks/node/useArchivistFromNode.d.ts +0 -1
- package/dist/browser/hooks/node/useArchivistFromNode.d.ts.map +1 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.cts +0 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.cts.map +1 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.mts +0 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.mts.map +1 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.ts +0 -1
- package/dist/browser/hooks/node/useArchivistsFromNode.d.ts.map +1 -1
- package/dist/browser/index.cjs +1 -414
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -391
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.cts +0 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.cts.map +1 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.mts +0 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.mts.map +1 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.ts +0 -1
- package/dist/neutral/hooks/node/useArchivistFromNode.d.ts.map +1 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.cts +0 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.cts.map +1 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.mts +0 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.mts.map +1 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.ts +0 -1
- package/dist/neutral/hooks/node/useArchivistsFromNode.d.ts.map +1 -1
- package/dist/neutral/index.cjs +1 -414
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +1 -391
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.cts +0 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.cts.map +1 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.mts +0 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.mts.map +1 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.ts +0 -1
- package/dist/node/hooks/node/useArchivistFromNode.d.ts.map +1 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.cts +0 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.cts.map +1 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.mts +0 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.mts.map +1 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.ts +0 -1
- package/dist/node/hooks/node/useArchivistsFromNode.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -440
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -402
- package/dist/node/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Card/Card.stories.tsx +1 -1
- package/src/components/Card/components/Stats/ArchivistStats.stories.tsx +1 -1
- package/src/components/Card/components/Stats/MemoryArchivistStats.stories.tsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useArchivistsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useArchivistsFromNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,8BAA8B,CAAA;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"useArchivistsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useArchivistsFromNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,8BAA8B,CAAA;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAA;AAGlF,eAAO,MAAM,qBAAqB,YACvB,YAAY,WACZ,oBAAoB,KAC5B,CAAC,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAiB5D,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ArchivistInstance } from '@xyo-network/archivist-model';
|
|
2
2
|
import { ModuleFilter } from '@xyo-network/module-model';
|
|
3
3
|
import { ModuleFromNodeConfig } from '@xyo-network/react-node';
|
|
4
|
-
/** @deprecated use useWeakArchivistsFromNode*/
|
|
5
4
|
export declare const useArchivistsFromNode: (filter?: ModuleFilter, config?: ModuleFromNodeConfig) => [ArchivistInstance[] | null | undefined, Error | undefined];
|
|
6
5
|
//# sourceMappingURL=useArchivistsFromNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useArchivistsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useArchivistsFromNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,8BAA8B,CAAA;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"useArchivistsFromNode.d.ts","sourceRoot":"","sources":["../../../../src/hooks/node/useArchivistsFromNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,8BAA8B,CAAA;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAA;AAGlF,eAAO,MAAM,qBAAqB,YACvB,YAAY,WACZ,oBAAoB,KAC5B,CAAC,iBAAiB,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAiB5D,CAAA"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,441 +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
|
-
ArchivistCard: () => ArchivistCard,
|
|
24
|
-
ArchivistCardContent: () => ArchivistCardContent,
|
|
25
|
-
ArchivistCardHeader: () => ArchivistCardHeader,
|
|
26
|
-
ArchivistDetails: () => ArchivistDetails,
|
|
27
|
-
useArchivistAll: () => useArchivistAll,
|
|
28
|
-
useArchivistFromNode: () => useArchivistFromNode,
|
|
29
|
-
useArchivistGet: () => useArchivistGet,
|
|
30
|
-
useArchivistsFromNode: () => useArchivistsFromNode,
|
|
31
|
-
useWeakArchivistAll: () => useWeakArchivistAll,
|
|
32
|
-
useWeakArchivistFromNode: () => useWeakArchivistFromNode,
|
|
33
|
-
useWeakArchivistGet: () => useWeakArchivistGet,
|
|
34
|
-
useWeakArchivistsFromNode: () => useWeakArchivistsFromNode
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
|
|
38
|
-
// src/components/Card/Card.tsx
|
|
39
|
-
var import_material4 = require("@mui/material");
|
|
40
|
-
var import_react_module3 = require("@xyo-network/react-module");
|
|
41
|
-
|
|
42
|
-
// src/components/Card/CardContent.tsx
|
|
43
|
-
var import_react_async_effect2 = require("@xylabs/react-async-effect");
|
|
44
|
-
var import_react_flexbox3 = require("@xylabs/react-flexbox");
|
|
45
|
-
var import_module_wrapper = require("@xyo-network/module-wrapper");
|
|
46
|
-
var import_react_module = require("@xyo-network/react-module");
|
|
47
|
-
var import_react_wallet = require("@xyo-network/react-wallet");
|
|
48
|
-
var import_react3 = require("react");
|
|
49
|
-
|
|
50
|
-
// src/components/Card/components/ArchivistParent.tsx
|
|
51
|
-
var import_material = require("@mui/material");
|
|
52
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
|
-
var ArchivistParent = ({ archivistType, parentArchivists }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: parentArchivists == null ? void 0 : parentArchivists.map((address) => {
|
|
54
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.ListItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Typography, { variant: "subtitle2", children: [
|
|
55
|
-
archivistType,
|
|
56
|
-
":",
|
|
57
|
-
" ",
|
|
58
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", sx: { ml: 0.5 }, children: address })
|
|
59
|
-
] }) }, address);
|
|
60
|
-
}) });
|
|
61
|
-
|
|
62
|
-
// src/components/Card/components/ArchivistParents.tsx
|
|
63
|
-
var import_icons_material = require("@mui/icons-material");
|
|
64
|
-
var import_material2 = require("@mui/material");
|
|
65
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
66
|
-
var import_react = require("react");
|
|
67
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
68
|
-
var ArchivistParents = ({ config, ...props }) => {
|
|
69
|
-
const [parentArchivistCollapse, setParentArchivistCollapse] = (0, import_react.useState)(false);
|
|
70
|
-
const { commit, read, write } = (config == null ? void 0 : config.parents) ?? {};
|
|
71
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: commit || read || write ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexCol, { alignItems: "start", ...props, children: [
|
|
72
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { onClick: () => setParentArchivistCollapse(!parentArchivistCollapse), children: [
|
|
73
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { variant: "subtitle2", sx: { cursor: "pointer", display: "inline-block" }, children: "Parents" }),
|
|
74
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.IconButton, { size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.ArrowRightRounded, { sx: { rotate: parentArchivistCollapse ? "90deg" : "0deg", transition: "all .25s" } }) })
|
|
75
|
-
] }),
|
|
76
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Collapse, { in: parentArchivistCollapse, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Paper, { elevation: 2, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.List, { children: [
|
|
77
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ArchivistParent, { archivistType: "Commit", parentArchivists: commit }),
|
|
78
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ArchivistParent, { archivistType: "Read", parentArchivists: read }),
|
|
79
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ArchivistParent, { archivistType: "Write", parentArchivists: write })
|
|
80
|
-
] }) }) })
|
|
81
|
-
] }) : null });
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/components/Card/components/Stats/ArchivistStats.tsx
|
|
85
|
-
var import_material3 = require("@mui/material");
|
|
86
|
-
var import_react_flexbox2 = require("@xylabs/react-flexbox");
|
|
87
|
-
var import_bs = require("react-icons/bs");
|
|
88
|
-
var import_vsc = require("react-icons/vsc");
|
|
89
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
90
|
-
var ArchivistStats = ({ addresses = {}, boundWitnesses, payloads, schemas = {} }) => {
|
|
91
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_flexbox2.FlexRow, { gap: 2, mr: 0.5, children: [
|
|
92
|
-
(payloads == null ? void 0 : payloads.length) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tooltip, { title: "Payloads", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Badge, { badgeContent: payloads == null ? void 0 : payloads.length, color: "primary", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_vsc.VscSymbolNamespace, { size: 20 }) }) }) : null,
|
|
93
|
-
(boundWitnesses == null ? void 0 : boundWitnesses.length) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tooltip, { title: "Blocks", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Badge, { badgeContent: boundWitnesses == null ? void 0 : boundWitnesses.length, color: "primary", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_vsc.VscSymbolMethod, { size: 20 }) }) }) : null,
|
|
94
|
-
Object.entries(schemas).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tooltip, { title: "Schemas", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Badge, { badgeContent: Object.entries(schemas).length, color: "primary", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_bs.BsFileEarmarkCode, { size: 20 }) }) }) : null,
|
|
95
|
-
Object.entries(addresses).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tooltip, { title: "Addresses", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Badge, { badgeContent: Object.entries(addresses).length, color: "primary", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_vsc.VscOrganization, { size: 20 }) }) }) : null
|
|
96
|
-
] });
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// src/components/Card/components/Stats/MemoryArchivistStats.tsx
|
|
100
|
-
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
101
|
-
var import_archivist_model = require("@xyo-network/archivist-model");
|
|
102
|
-
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
103
|
-
var import_react2 = require("react");
|
|
104
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
105
|
-
var MemoryArchivistsStats = ({ archivist }) => {
|
|
106
|
-
const [all, setAll] = (0, import_react2.useState)();
|
|
107
|
-
const getAll = (0, import_react2.useCallback)(async (archivist2) => {
|
|
108
|
-
var _a;
|
|
109
|
-
const all2 = await ((_a = archivist2 == null ? void 0 : archivist2.all) == null ? void 0 : _a.call(archivist2));
|
|
110
|
-
setAll(all2);
|
|
111
|
-
}, []);
|
|
112
|
-
(0, import_react2.useEffect)(() => {
|
|
113
|
-
const listeners = [];
|
|
114
|
-
if (archivist == null ? void 0 : archivist.queries.includes(import_archivist_model.ArchivistAllQuerySchema)) {
|
|
115
|
-
const insertListener = archivist.on("inserted", async () => {
|
|
116
|
-
await getAll(archivist);
|
|
117
|
-
});
|
|
118
|
-
listeners.push(insertListener);
|
|
119
|
-
const clearListener = archivist.on("cleared", async () => {
|
|
120
|
-
await getAll(archivist);
|
|
121
|
-
});
|
|
122
|
-
listeners.push(clearListener);
|
|
123
|
-
}
|
|
124
|
-
return () => {
|
|
125
|
-
for (const listener of listeners)
|
|
126
|
-
listener == null ? void 0 : listener();
|
|
127
|
-
};
|
|
128
|
-
}, [archivist, getAll]);
|
|
129
|
-
(0, import_react_async_effect.useAsyncEffect)(
|
|
130
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
131
|
-
async () => {
|
|
132
|
-
if (archivist == null ? void 0 : archivist.queries.includes(import_archivist_model.ArchivistAllQuerySchema)) {
|
|
133
|
-
await getAll(archivist);
|
|
134
|
-
} else {
|
|
135
|
-
setAll(null);
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
[archivist, getAll]
|
|
139
|
-
);
|
|
140
|
-
const payloads = (0, import_react2.useMemo)(() => all === null ? [] : all == null ? void 0 : all.filter((payload) => payload.schema !== import_boundwitness_model.BoundWitnessSchema), [all]);
|
|
141
|
-
const boundWitnesses = (0, import_react2.useMemo)(() => all === null ? [] : all == null ? void 0 : all.filter((payload) => payload.schema === import_boundwitness_model.BoundWitnessSchema), [all]);
|
|
142
|
-
const addresses = (0, import_react2.useMemo)(
|
|
143
|
-
() => (all == null ? void 0 : all.reduce(
|
|
144
|
-
(prev, payload) => {
|
|
145
|
-
const w = (0, import_boundwitness_model.asBoundWitness)(payload);
|
|
146
|
-
if (w == null ? void 0 : w.addresses)
|
|
147
|
-
for (const address of (w == null ? void 0 : w.addresses) ?? []) {
|
|
148
|
-
prev[address] = (prev[address] ?? 0) + 1;
|
|
149
|
-
}
|
|
150
|
-
return prev;
|
|
151
|
-
},
|
|
152
|
-
{}
|
|
153
|
-
)) ?? {},
|
|
154
|
-
[all]
|
|
155
|
-
);
|
|
156
|
-
const schemas = (0, import_react2.useMemo)(
|
|
157
|
-
() => (all == null ? void 0 : all.reduce(
|
|
158
|
-
(prev, payload) => {
|
|
159
|
-
prev[payload.schema] = (prev[payload.schema] ?? 0) + 1;
|
|
160
|
-
return prev;
|
|
161
|
-
},
|
|
162
|
-
{}
|
|
163
|
-
)) ?? {},
|
|
164
|
-
[all]
|
|
165
|
-
);
|
|
166
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ArchivistStats, { addresses, boundWitnesses, payloads, schemas });
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// src/components/Card/CardContent.tsx
|
|
170
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
171
|
-
var ArchivistCardContent = ({ children, mod, ...props }) => {
|
|
172
|
-
const [config, setConfig] = (0, import_react3.useState)();
|
|
173
|
-
const [wallet] = (0, import_react_wallet.useWallet)();
|
|
174
|
-
(0, import_react_async_effect2.useAsyncEffect)(
|
|
175
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
176
|
-
async (mounted) => {
|
|
177
|
-
if (wallet && mod) {
|
|
178
|
-
const wrapper = import_module_wrapper.ModuleWrapper.wrap(mod, wallet);
|
|
179
|
-
const payloads = await (wrapper == null ? void 0 : wrapper.state());
|
|
180
|
-
if (mounted()) {
|
|
181
|
-
setConfig(payloads == null ? void 0 : payloads[0]);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
setConfig(void 0);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
[mod, wallet]
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_module.ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_flexbox3.FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
190
|
-
children,
|
|
191
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ArchivistParents, { config })
|
|
192
|
-
] }) });
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// src/components/Card/CardHeader.tsx
|
|
196
|
-
var import_archivist_memory = require("@xyo-network/archivist-memory");
|
|
197
|
-
var import_react_module2 = require("@xyo-network/react-module");
|
|
198
|
-
var import_react4 = require("react");
|
|
199
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
200
|
-
var ArchivistStats2 = (archivist) => {
|
|
201
|
-
switch (archivist == null ? void 0 : archivist.config.schema) {
|
|
202
|
-
case import_archivist_memory.MemoryArchivistConfigSchema: {
|
|
203
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MemoryArchivistsStats, { archivist });
|
|
204
|
-
}
|
|
205
|
-
default: {
|
|
206
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, {});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
var ArchivistCardHeader = ({ title, mod, ...props }) => {
|
|
211
|
-
const Stats = (0, import_react4.useMemo)(() => ArchivistStats2(mod), [mod]);
|
|
212
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_module2.ModuleCardHeader, { mod, title: title ?? (mod == null ? void 0 : mod.config.name) ?? "Archivist", action: Stats, ...props });
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// src/components/Card/Card.tsx
|
|
216
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
217
|
-
var ArchivistCard = ({ children, mod, ...props }) => {
|
|
218
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_material4.Card, { ...props, children: [
|
|
219
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArchivistCardHeader, { mod }),
|
|
220
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ArchivistCardContent, { mod }),
|
|
221
|
-
children,
|
|
222
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_module3.ModuleCardActions, { mod })
|
|
223
|
-
] });
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// src/components/Details/Details.tsx
|
|
227
|
-
var import_material5 = require("@mui/material");
|
|
228
|
-
var import_react_async_effect3 = require("@xylabs/react-async-effect");
|
|
229
|
-
var import_react_button = require("@xylabs/react-button");
|
|
230
|
-
var import_react_flexbox4 = require("@xylabs/react-flexbox");
|
|
231
|
-
var import_archivist_model6 = require("@xyo-network/archivist-model");
|
|
232
|
-
var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
|
|
233
|
-
var import_react7 = require("react");
|
|
234
|
-
|
|
235
|
-
// src/hooks/node/useArchivistFromNode.tsx
|
|
236
|
-
var import_archivist_model2 = require("@xyo-network/archivist-model");
|
|
237
|
-
var import_react_node = require("@xyo-network/react-node");
|
|
238
|
-
var useArchivistFromNode = (nameOrAddressOrInstance, config) => {
|
|
239
|
-
var _a, _b;
|
|
240
|
-
const [mod, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
|
|
241
|
-
const instance = (0, import_archivist_model2.asArchivistInstance)(mod);
|
|
242
|
-
if (mod && !instance) {
|
|
243
|
-
const error2 = new Error(`Resolved module is not a ArchivistInstance [${(_a = mod.config) == null ? void 0 : _a.schema}:${(_b = mod.config) == null ? void 0 : _b.name}:${mod.address}]`);
|
|
244
|
-
console.error(error2.message);
|
|
245
|
-
return [void 0, error2];
|
|
246
|
-
}
|
|
247
|
-
return [instance, error];
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
// src/hooks/node/useArchivistsFromNode.tsx
|
|
251
|
-
var import_archivist_model3 = require("@xyo-network/archivist-model");
|
|
252
|
-
var import_react_node2 = require("@xyo-network/react-node");
|
|
253
|
-
var useArchivistsFromNode = (filter, config) => {
|
|
254
|
-
const [modules, error] = (0, import_react_node2.useModulesFromNode)(filter, config);
|
|
255
|
-
if (error) {
|
|
256
|
-
return [null, error];
|
|
257
|
-
}
|
|
258
|
-
return modules ? [
|
|
259
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
260
|
-
modules.reduce((prev, mod) => {
|
|
261
|
-
if ((0, import_archivist_model3.isArchivistInstance)(mod)) {
|
|
262
|
-
prev.push(mod);
|
|
263
|
-
}
|
|
264
|
-
return prev;
|
|
265
|
-
}, []),
|
|
266
|
-
void 0
|
|
267
|
-
] : [modules, error];
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
// src/hooks/node/useWeakArchivistFromNode.tsx
|
|
271
|
-
var import_archivist_model4 = require("@xyo-network/archivist-model");
|
|
272
|
-
var import_react_node3 = require("@xyo-network/react-node");
|
|
273
|
-
var useWeakArchivistFromNode = (nameOrAddressOrInstance, config) => {
|
|
274
|
-
return (0, import_react_node3.useWeakModuleFromNode)(nameOrAddressOrInstance, { identity: import_archivist_model4.isArchivistInstance, ...config });
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// src/hooks/node/useWeakArchivistsFromNode.tsx
|
|
278
|
-
var import_exists = require("@xylabs/exists");
|
|
279
|
-
var import_archivist_model5 = require("@xyo-network/archivist-model");
|
|
280
|
-
var import_react_node4 = require("@xyo-network/react-node");
|
|
281
|
-
var useWeakArchivistsFromNode = (filter, config) => {
|
|
282
|
-
const [modules, error] = (0, import_react_node4.useWeakModulesFromNode)(filter, config);
|
|
283
|
-
if (error) {
|
|
284
|
-
return [null, error];
|
|
285
|
-
}
|
|
286
|
-
return [
|
|
287
|
-
(modules == null ? void 0 : modules.map((mod) => {
|
|
288
|
-
const instance = (0, import_archivist_model5.asArchivistInstance)(mod == null ? void 0 : mod.deref());
|
|
289
|
-
if (instance) {
|
|
290
|
-
return new WeakRef(instance);
|
|
291
|
-
}
|
|
292
|
-
}).filter(import_exists.exists)) ?? [],
|
|
293
|
-
void 0
|
|
294
|
-
];
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// src/hooks/queries/useArchivistAll.tsx
|
|
298
|
-
var import_react_promise = require("@xylabs/react-promise");
|
|
299
|
-
var import_react_module4 = require("@xyo-network/react-module");
|
|
300
|
-
var import_react5 = require("react");
|
|
301
|
-
var useArchivistAll = (archivist) => {
|
|
302
|
-
const [error, setError] = (0, import_react5.useState)();
|
|
303
|
-
const [enabled, refresh] = (0, import_react_module4.useRefresh)();
|
|
304
|
-
const payloads = (0, import_react_promise.usePromise)(async () => {
|
|
305
|
-
var _a;
|
|
306
|
-
try {
|
|
307
|
-
if (enabled) {
|
|
308
|
-
return await ((_a = archivist == null ? void 0 : archivist.all) == null ? void 0 : _a.call(archivist));
|
|
309
|
-
}
|
|
310
|
-
} catch (ex) {
|
|
311
|
-
const error2 = ex;
|
|
312
|
-
setError(error2);
|
|
313
|
-
}
|
|
314
|
-
}, [archivist, enabled]);
|
|
315
|
-
return [payloads, error, refresh];
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
// src/hooks/queries/useArchivistGet.tsx
|
|
319
|
-
var import_react_promise2 = require("@xylabs/react-promise");
|
|
320
|
-
var import_react_module5 = require("@xyo-network/react-module");
|
|
321
|
-
var useArchivistGet = (archivist, hashes) => {
|
|
322
|
-
const [enabled, refresh] = (0, import_react_module5.useRefresh)();
|
|
323
|
-
const [payloads, error] = (0, import_react_promise2.usePromise)(async () => {
|
|
324
|
-
if (enabled && archivist && hashes) {
|
|
325
|
-
return await archivist.get(hashes);
|
|
326
|
-
}
|
|
327
|
-
}, [archivist, hashes, enabled]);
|
|
328
|
-
return [payloads, error, refresh];
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
// src/hooks/queries/useWeakArchivistAll.tsx
|
|
332
|
-
var import_react_promise3 = require("@xylabs/react-promise");
|
|
333
|
-
var import_react_module6 = require("@xyo-network/react-module");
|
|
334
|
-
var import_react6 = require("react");
|
|
335
|
-
var useWeakArchivistAll = (archivist) => {
|
|
336
|
-
const [error, setError] = (0, import_react6.useState)();
|
|
337
|
-
const [enabled, refresh] = (0, import_react_module6.useRefresh)();
|
|
338
|
-
const payloads = (0, import_react_promise3.usePromise)(async () => {
|
|
339
|
-
var _a, _b;
|
|
340
|
-
try {
|
|
341
|
-
if (enabled) {
|
|
342
|
-
return await ((_b = (_a = archivist == null ? void 0 : archivist.deref()) == null ? void 0 : _a.all) == null ? void 0 : _b.call(_a));
|
|
343
|
-
}
|
|
344
|
-
} catch (ex) {
|
|
345
|
-
const error2 = ex;
|
|
346
|
-
setError(error2);
|
|
347
|
-
}
|
|
348
|
-
}, [archivist, enabled]);
|
|
349
|
-
return [payloads, error, refresh];
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
// src/hooks/queries/useWeakArchivistGet.tsx
|
|
353
|
-
var import_react_promise4 = require("@xylabs/react-promise");
|
|
354
|
-
var import_react_module7 = require("@xyo-network/react-module");
|
|
355
|
-
var useWeakArchivistGet = (archivist, hashes) => {
|
|
356
|
-
const [enabled, refresh] = (0, import_react_module7.useRefresh)();
|
|
357
|
-
const [payloads, error] = (0, import_react_promise4.usePromise)(async () => {
|
|
358
|
-
const archivistInstance = archivist == null ? void 0 : archivist.deref();
|
|
359
|
-
if (enabled && archivistInstance && hashes) {
|
|
360
|
-
return await archivistInstance.get(hashes);
|
|
361
|
-
}
|
|
362
|
-
}, [archivist, hashes, enabled]);
|
|
363
|
-
return [payloads, error, refresh];
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// src/components/Details/Details.tsx
|
|
367
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
368
|
-
var testQueryCommit = { schema: import_archivist_model6.ArchivistCommitQuerySchema };
|
|
369
|
-
var testQueryCommitBoundWitnessBuilder = new import_boundwitness_builder.QueryBoundWitnessBuilder().query(testQueryCommit);
|
|
370
|
-
var testQueryClear = { schema: import_archivist_model6.ArchivistClearQuerySchema };
|
|
371
|
-
var testQueryClearBoundWitnessBuilder = new import_boundwitness_builder.QueryBoundWitnessBuilder().query(testQueryClear);
|
|
372
|
-
var ArchivistDetails = ({ address, ...props }) => {
|
|
373
|
-
const [archivist] = useWeakArchivistFromNode(address);
|
|
374
|
-
const [payloads, setPayloads] = (0, import_react7.useState)();
|
|
375
|
-
const [refresh, setRefresh] = (0, import_react7.useState)(0);
|
|
376
|
-
const [queryableCommit, setQueryableCommit] = (0, import_react7.useState)(false);
|
|
377
|
-
const [queryableClear, setQueryableClear] = (0, import_react7.useState)(false);
|
|
378
|
-
(0, import_react_async_effect3.useAsyncEffect)(
|
|
379
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
380
|
-
async () => {
|
|
381
|
-
const instance = archivist == null ? void 0 : archivist.deref();
|
|
382
|
-
if (instance) {
|
|
383
|
-
const [commitBW] = await (await testQueryCommitBoundWitnessBuilder).build();
|
|
384
|
-
const [clearBW] = await (await testQueryClearBoundWitnessBuilder).build();
|
|
385
|
-
setQueryableCommit(await (instance == null ? void 0 : instance.queryable(commitBW, [testQueryCommit])));
|
|
386
|
-
setQueryableClear(await (instance == null ? void 0 : instance.queryable(clearBW, [testQueryClear])));
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
[archivist]
|
|
390
|
-
);
|
|
391
|
-
(0, import_react_async_effect3.useAsyncEffect)(
|
|
392
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
393
|
-
async (mounted) => {
|
|
394
|
-
var _a, _b;
|
|
395
|
-
const payloads2 = await ((_b = (_a = archivist == null ? void 0 : archivist.deref()) == null ? void 0 : _a.all) == null ? void 0 : _b.call(_a));
|
|
396
|
-
if (mounted()) {
|
|
397
|
-
setPayloads(payloads2);
|
|
398
|
-
}
|
|
399
|
-
},
|
|
400
|
-
[archivist, refresh]
|
|
401
|
-
);
|
|
402
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_flexbox4.FlexCol, { ...props, children: [
|
|
403
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material5.Typography, { children: `Payloads: ${payloads ? payloads.length : "-"}` }),
|
|
404
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material5.ButtonGroup, { children: [
|
|
405
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_button.ButtonEx, { disabled: (payloads == null ? void 0 : payloads.length) === 0 || !archivist || !queryableCommit, onClick: () => {
|
|
406
|
-
var _a, _b;
|
|
407
|
-
return (_b = (_a = archivist == null ? void 0 : archivist.deref()) == null ? void 0 : _a.commit) == null ? void 0 : _b.call(_a);
|
|
408
|
-
}, children: "Commit" }),
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_button.ButtonEx, { disabled: !archivist || !queryableClear, onClick: () => {
|
|
410
|
-
var _a, _b;
|
|
411
|
-
return (_b = (_a = archivist == null ? void 0 : archivist.deref()) == null ? void 0 : _a.clear) == null ? void 0 : _b.call(_a);
|
|
412
|
-
}, children: "Clear" }),
|
|
413
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
414
|
-
import_react_button.ButtonEx,
|
|
415
|
-
{
|
|
416
|
-
disabled: !archivist,
|
|
417
|
-
onClick: () => {
|
|
418
|
-
setRefresh(refresh + 1);
|
|
419
|
-
},
|
|
420
|
-
children: "Refresh"
|
|
421
|
-
}
|
|
422
|
-
)
|
|
423
|
-
] })
|
|
424
|
-
] });
|
|
425
|
-
};
|
|
426
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
427
|
-
0 && (module.exports = {
|
|
428
|
-
ArchivistCard,
|
|
429
|
-
ArchivistCardContent,
|
|
430
|
-
ArchivistCardHeader,
|
|
431
|
-
ArchivistDetails,
|
|
432
|
-
useArchivistAll,
|
|
433
|
-
useArchivistFromNode,
|
|
434
|
-
useArchivistGet,
|
|
435
|
-
useArchivistsFromNode,
|
|
436
|
-
useWeakArchivistAll,
|
|
437
|
-
useWeakArchivistFromNode,
|
|
438
|
-
useWeakArchivistGet,
|
|
439
|
-
useWeakArchivistsFromNode
|
|
440
|
-
});
|
|
1
|
+
"use strict";var S=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Se=(r,e)=>{for(var t in e)S(r,t,{get:e[t],enumerable:!0})},Te=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ke(e))!Ee.call(r,s)&&s!==t&&S(r,s,{get:()=>e[s],enumerable:!(o=Be(e,s))||o.enumerable});return r};var We=r=>Te(S({},"__esModule",{value:!0}),r);var Je={};Se(Je,{ArchivistCard:()=>Qe,ArchivistCardContent:()=>W,ArchivistCardHeader:()=>N,ArchivistDetails:()=>Ue,useArchivistAll:()=>Ge,useArchivistFromNode:()=>He,useArchivistGet:()=>Le,useArchivistsFromNode:()=>qe,useWeakArchivistAll:()=>Oe,useWeakArchivistFromNode:()=>Q,useWeakArchivistGet:()=>$e,useWeakArchivistsFromNode:()=>ze});module.exports=We(Je);var ne=require("@mui/material"),ie=require("@xyo-network/react-module");var Y=require("@xylabs/react-async-effect"),Z=require("@xylabs/react-flexbox"),_=require("@xyo-network/module-wrapper"),j=require("@xyo-network/react-module"),ee=require("@xyo-network/react-wallet"),re=require("react");var I=require("@mui/material"),y=require("react/jsx-runtime"),w=({archivistType:r,parentArchivists:e})=>(0,y.jsx)(y.Fragment,{children:e==null?void 0:e.map(t=>(0,y.jsx)(I.ListItem,{children:(0,y.jsxs)(I.Typography,{variant:"subtitle2",children:[r,":"," ",(0,y.jsx)(I.Typography,{variant:"caption",sx:{ml:.5},children:t})]})},t))});var G=require("@mui/icons-material"),A=require("@mui/material"),L=require("@xylabs/react-flexbox"),O=require("react");var m=require("react/jsx-runtime"),$=({config:r,...e})=>{let[t,o]=(0,O.useState)(!1),{commit:s,read:i,write:a}=(r==null?void 0:r.parents)??{};return(0,m.jsx)(m.Fragment,{children:s||i||a?(0,m.jsxs)(L.FlexCol,{alignItems:"start",...e,children:[(0,m.jsxs)("span",{onClick:()=>o(!t),children:[(0,m.jsx)(A.Typography,{variant:"subtitle2",sx:{cursor:"pointer",display:"inline-block"},children:"Parents"}),(0,m.jsx)(A.IconButton,{size:"small",children:(0,m.jsx)(G.ArrowRightRounded,{sx:{rotate:t?"90deg":"0deg",transition:"all .25s"}})})]}),(0,m.jsx)(A.Collapse,{in:t,children:(0,m.jsx)(A.Paper,{elevation:2,children:(0,m.jsxs)(A.List,{children:[(0,m.jsx)(w,{archivistType:"Commit",parentArchivists:s}),(0,m.jsx)(w,{archivistType:"Read",parentArchivists:i}),(0,m.jsx)(w,{archivistType:"Write",parentArchivists:a})]})})})]}):null})};var h=require("@mui/material"),D=require("@xylabs/react-flexbox"),V=require("react-icons/bs"),x=require("react-icons/vsc"),f=require("react/jsx-runtime"),U=({addresses:r={},boundWitnesses:e,payloads:t,schemas:o={}})=>(0,f.jsxs)(D.FlexRow,{gap:2,mr:.5,children:[t!=null&&t.length?(0,f.jsx)(h.Tooltip,{title:"Payloads",children:(0,f.jsx)(h.Badge,{badgeContent:t==null?void 0:t.length,color:"primary",children:(0,f.jsx)(x.VscSymbolNamespace,{size:20})})}):null,e!=null&&e.length?(0,f.jsx)(h.Tooltip,{title:"Blocks",children:(0,f.jsx)(h.Badge,{badgeContent:e==null?void 0:e.length,color:"primary",children:(0,f.jsx)(x.VscSymbolMethod,{size:20})})}):null,Object.entries(o).length>0?(0,f.jsx)(h.Tooltip,{title:"Schemas",children:(0,f.jsx)(h.Badge,{badgeContent:Object.entries(o).length,color:"primary",children:(0,f.jsx)(V.BsFileEarmarkCode,{size:20})})}):null,Object.entries(r).length>0?(0,f.jsx)(h.Tooltip,{title:"Addresses",children:(0,f.jsx)(h.Badge,{badgeContent:Object.entries(r).length,color:"primary",children:(0,f.jsx)(x.VscOrganization,{size:20})})}):null]});var J=require("@xylabs/react-async-effect"),T=require("@xyo-network/archivist-model"),M=require("@xyo-network/boundwitness-model"),p=require("react");var X=require("react/jsx-runtime"),K=({archivist:r})=>{let[e,t]=(0,p.useState)(),o=(0,p.useCallback)(async n=>{var u;let d=await((u=n==null?void 0:n.all)==null?void 0:u.call(n));t(d)},[]);(0,p.useEffect)(()=>{let n=[];if(r!=null&&r.queries.includes(T.ArchivistAllQuerySchema)){let d=r.on("inserted",async()=>{await o(r)});n.push(d);let u=r.on("cleared",async()=>{await o(r)});n.push(u)}return()=>{for(let d of n)d==null||d()}},[r,o]),(0,J.useAsyncEffect)(async()=>{r!=null&&r.queries.includes(T.ArchivistAllQuerySchema)?await o(r):t(null)},[r,o]);let s=(0,p.useMemo)(()=>e===null?[]:e==null?void 0:e.filter(n=>n.schema!==M.BoundWitnessSchema),[e]),i=(0,p.useMemo)(()=>e===null?[]:e==null?void 0:e.filter(n=>n.schema===M.BoundWitnessSchema),[e]),a=(0,p.useMemo)(()=>(e==null?void 0:e.reduce((n,d)=>{let u=(0,M.asBoundWitness)(d);if(u!=null&&u.addresses)for(let c of(u==null?void 0:u.addresses)??[])n[c]=(n[c]??0)+1;return n},{}))??{},[e]),l=(0,p.useMemo)(()=>(e==null?void 0:e.reduce((n,d)=>(n[d.schema]=(n[d.schema]??0)+1,n),{}))??{},[e]);return(0,X.jsx)(U,{addresses:a,boundWitnesses:i,payloads:s,schemas:l})};var b=require("react/jsx-runtime"),W=({children:r,mod:e,...t})=>{let[o,s]=(0,re.useState)(),[i]=(0,ee.useWallet)();return(0,Y.useAsyncEffect)(async a=>{if(i&&e){let l=_.ModuleWrapper.wrap(e,i),n=await(l==null?void 0:l.state());a()&&s(n==null?void 0:n[0])}else s(void 0)},[e,i]),(0,b.jsx)(j.ModuleCardContent,{mod:e,...t,children:(0,b.jsxs)(Z.FlexGrowRow,{flexWrap:"wrap",justifyContent:"start",gap:2,children:[r,(0,b.jsx)($,{config:o})]})})};var te=require("@xyo-network/archivist-memory"),oe=require("@xyo-network/react-module"),se=require("react");var R=require("react/jsx-runtime"),Ne=r=>{switch(r==null?void 0:r.config.schema){case te.MemoryArchivistConfigSchema:return(0,R.jsx)(K,{archivist:r});default:return(0,R.jsx)(R.Fragment,{})}},N=({title:r,mod:e,...t})=>{let o=(0,se.useMemo)(()=>Ne(e),[e]);return(0,R.jsx)(oe.ModuleCardHeader,{mod:e,title:r??(e==null?void 0:e.config.name)??"Archivist",action:o,...t})};var F=require("react/jsx-runtime"),Qe=({children:r,mod:e,...t})=>(0,F.jsxs)(ne.Card,{...t,children:[(0,F.jsx)(N,{mod:e}),(0,F.jsx)(W,{mod:e}),r,(0,F.jsx)(ie.ModuleCardActions,{mod:e})]});var k=require("@mui/material"),H=require("@xylabs/react-async-effect"),B=require("@xylabs/react-button"),be=require("@xylabs/react-flexbox"),E=require("@xyo-network/archivist-model"),q=require("@xyo-network/boundwitness-builder"),v=require("react");var ae=require("@xyo-network/archivist-model"),ce=require("@xyo-network/react-node"),He=(r,e)=>{var i,a;let[t,o]=(0,ce.useModuleFromNode)(r,e),s=(0,ae.asArchivistInstance)(t);if(t&&!s){let l=new Error(`Resolved module is not a ArchivistInstance [${(i=t.config)==null?void 0:i.schema}:${(a=t.config)==null?void 0:a.name}:${t.address}]`);return console.error(l.message),[void 0,l]}return[s,o]};var me=require("@xyo-network/archivist-model"),le=require("@xyo-network/react-node"),qe=(r,e)=>{let[t,o]=(0,le.useModulesFromNode)(r,e);return o?[null,o]:t?[t.reduce((s,i)=>((0,me.isArchivistInstance)(i)&&s.push(i),s),[]),void 0]:[t,o]};var de=require("@xyo-network/archivist-model"),fe=require("@xyo-network/react-node"),Q=(r,e)=>(0,fe.useWeakModuleFromNode)(r,{identity:de.isArchivistInstance,...e});var ue=require("@xylabs/exists"),pe=require("@xyo-network/archivist-model"),Ae=require("@xyo-network/react-node"),ze=(r,e)=>{let[t,o]=(0,Ae.useWeakModulesFromNode)(r,e);return o?[null,o]:[(t==null?void 0:t.map(s=>{let i=(0,pe.asArchivistInstance)(s==null?void 0:s.deref());if(i)return new WeakRef(i)}).filter(ue.exists))??[],void 0]};var he=require("@xylabs/react-promise"),Ce=require("@xyo-network/react-module"),ye=require("react"),Ge=r=>{let[e,t]=(0,ye.useState)(),[o,s]=(0,Ce.useRefresh)();return[(0,he.usePromise)(async()=>{var a;try{if(o)return await((a=r==null?void 0:r.all)==null?void 0:a.call(r))}catch(l){t(l)}},[r,o]),e,s]};var ge=require("@xylabs/react-promise"),Pe=require("@xyo-network/react-module"),Le=(r,e)=>{let[t,o]=(0,Pe.useRefresh)(),[s,i]=(0,ge.usePromise)(async()=>{if(t&&r&&e)return await r.get(e)},[r,e,t]);return[s,i,o]};var xe=require("@xylabs/react-promise"),Re=require("@xyo-network/react-module"),Fe=require("react"),Oe=r=>{let[e,t]=(0,Fe.useState)(),[o,s]=(0,Re.useRefresh)();return[(0,xe.usePromise)(async()=>{var a,l;try{if(o)return await((l=(a=r==null?void 0:r.deref())==null?void 0:a.all)==null?void 0:l.call(a))}catch(n){t(n)}},[r,o]),e,s]};var Ie=require("@xylabs/react-promise"),Me=require("@xyo-network/react-module"),$e=(r,e)=>{let[t,o]=(0,Me.useRefresh)(),[s,i]=(0,Ie.usePromise)(async()=>{let a=r==null?void 0:r.deref();if(t&&a&&e)return await a.get(e)},[r,e,t]);return[s,i,o]};var g=require("react/jsx-runtime"),ve={schema:E.ArchivistCommitQuerySchema},De=new q.QueryBoundWitnessBuilder().query(ve),we={schema:E.ArchivistClearQuerySchema},Ve=new q.QueryBoundWitnessBuilder().query(we),Ue=({address:r,...e})=>{let[t]=Q(r),[o,s]=(0,v.useState)(),[i,a]=(0,v.useState)(0),[l,n]=(0,v.useState)(!1),[d,u]=(0,v.useState)(!1);return(0,H.useAsyncEffect)(async()=>{let c=t==null?void 0:t.deref();if(c){let[C]=await(await De).build(),[P]=await(await Ve).build();n(await(c==null?void 0:c.queryable(C,[ve]))),u(await(c==null?void 0:c.queryable(P,[we])))}},[t]),(0,H.useAsyncEffect)(async c=>{var P,z;let C=await((z=(P=t==null?void 0:t.deref())==null?void 0:P.all)==null?void 0:z.call(P));c()&&s(C)},[t,i]),(0,g.jsxs)(be.FlexCol,{...e,children:[(0,g.jsx)(k.Typography,{children:`Payloads: ${o?o.length:"-"}`}),(0,g.jsxs)(k.ButtonGroup,{children:[(0,g.jsx)(B.ButtonEx,{disabled:(o==null?void 0:o.length)===0||!t||!l,onClick:()=>{var c,C;return(C=(c=t==null?void 0:t.deref())==null?void 0:c.commit)==null?void 0:C.call(c)},children:"Commit"}),(0,g.jsx)(B.ButtonEx,{disabled:!t||!d,onClick:()=>{var c,C;return(C=(c=t==null?void 0:t.deref())==null?void 0:c.clear)==null?void 0:C.call(c)},children:"Clear"}),(0,g.jsx)(B.ButtonEx,{disabled:!t,onClick:()=>{a(i+1)},children:"Refresh"})]})]})};0&&(module.exports={ArchivistCard,ArchivistCardContent,ArchivistCardHeader,ArchivistDetails,useArchivistAll,useArchivistFromNode,useArchivistGet,useArchivistsFromNode,useWeakArchivistAll,useWeakArchivistFromNode,useWeakArchivistGet,useWeakArchivistsFromNode});
|
|
441
2
|
//# sourceMappingURL=index.cjs.map
|