@seedprotocol/react 0.4.15 → 0.4.16
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/SeedImage.d.ts.map +1 -1
- package/dist/index.js +566 -555
- package/dist/index.js.map +1 -1
- package/dist/itemProperty.d.ts.map +1 -1
- package/dist/liveQuery.d.ts.map +1 -1
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
|
-
import Te, { useState as w, useRef as
|
|
2
|
-
import { flushSync as
|
|
3
|
-
import { getClient as
|
|
4
|
-
import { orderBy as
|
|
1
|
+
import Te, { useState as w, useRef as F, useMemo as D, useEffect as I, useCallback as x, useLayoutEffect as Ve } from "react";
|
|
2
|
+
import { flushSync as de } from "react-dom";
|
|
3
|
+
import { getClient as me, ClientManagerState as C, BaseDb as W, Item as Ne, getAddressesForItemsFilter as Ke, seeds as A, getVersionData as je, createNewItem as We, ItemProperty as se, metadata as T, appState as ue, Schema as he, schemas as Y, loadAllSchemasFromDb as Ge, SEED_PROTOCOL_SCHEMA_NAME as Je, Model as oe, models as ae, modelSchemas as ge, ModelProperty as fe, properties as ee, getPropertySchema as ke, getSchemaNameFromId as Ye, BaseFileManager as j, eventEmitter as K, client as Xe } from "@seedprotocol/sdk";
|
|
4
|
+
import { orderBy as Ze, debounce as $e, startCase as _e } from "lodash-es";
|
|
5
5
|
import J from "debug";
|
|
6
6
|
import { useSelector as we } from "@xstate/react";
|
|
7
|
-
import { or as
|
|
8
|
-
import { toSnakeCase as
|
|
9
|
-
import { useQueryClient as
|
|
10
|
-
import
|
|
11
|
-
import { jsxs as
|
|
12
|
-
const
|
|
13
|
-
const r =
|
|
14
|
-
return we(r, (n) => n.value ===
|
|
7
|
+
import { or as te, isNull as le, eq as O, inArray as De, sql as et, isNotNull as Ie, and as Ee, gt as tt, like as Be, desc as rt } from "drizzle-orm";
|
|
8
|
+
import { toSnakeCase as nt } from "drizzle-orm/casing";
|
|
9
|
+
import { useQueryClient as X, useQuery as Z, QueryClient as st, QueryClientProvider as ot } from "@tanstack/react-query";
|
|
10
|
+
import it from "pluralize";
|
|
11
|
+
import { jsxs as U, jsx as S } from "react/jsx-runtime";
|
|
12
|
+
const z = () => {
|
|
13
|
+
const r = me().getService();
|
|
14
|
+
return we(r, (n) => n.value === C.IDLE);
|
|
15
15
|
};
|
|
16
|
-
function
|
|
17
|
-
const [r, t] = w(void 0), n =
|
|
18
|
-
if (!
|
|
16
|
+
function ie(e) {
|
|
17
|
+
const [r, t] = w(void 0), n = F(null), i = z(), a = D(() => {
|
|
18
|
+
if (!i || !e)
|
|
19
19
|
return null;
|
|
20
20
|
try {
|
|
21
21
|
return W.liveQuery(e);
|
|
22
|
-
} catch (
|
|
23
|
-
return console.error("[useLiveQuery] Failed to create live query:",
|
|
22
|
+
} catch (o) {
|
|
23
|
+
return console.error("[useLiveQuery] Failed to create live query:", o), null;
|
|
24
24
|
}
|
|
25
|
-
}, [e,
|
|
25
|
+
}, [e, i]);
|
|
26
26
|
return I(() => {
|
|
27
|
-
if (n.current && (n.current.unsubscribe(), n.current = null), !
|
|
27
|
+
if (n.current && (n.current.unsubscribe(), n.current = null), !a)
|
|
28
28
|
return;
|
|
29
|
-
const
|
|
30
|
-
next: (
|
|
31
|
-
|
|
32
|
-
d === u && s !== void 0 || (i.current = a, t(a));
|
|
29
|
+
const o = a.subscribe({
|
|
30
|
+
next: (l) => {
|
|
31
|
+
t(l !== void 0 ? [...l] : void 0);
|
|
33
32
|
},
|
|
34
|
-
error: (
|
|
35
|
-
console.error("[useLiveQuery] Error:",
|
|
33
|
+
error: (l) => {
|
|
34
|
+
console.error("[useLiveQuery] Error:", l);
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
return n.current =
|
|
37
|
+
return n.current = o, () => {
|
|
39
38
|
n.current && (n.current.unsubscribe(), n.current = null);
|
|
40
39
|
};
|
|
41
|
-
}, [
|
|
40
|
+
}, [a]), r;
|
|
42
41
|
}
|
|
43
|
-
const
|
|
44
|
-
const [n, i] = w(), [
|
|
42
|
+
const pe = J("seedSdk:react:item"), jt = ({ modelName: e, seedLocalId: r, seedUid: t }) => {
|
|
43
|
+
const [n, i] = w(), [a, o] = w(!!(r || t)), [l, c] = w(null), s = F(void 0), d = F(!1), u = z(), f = F(e), h = F(r), b = F(t), v = D(() => u ? !!(h.current || b.current) : !1, [u, r, t]), p = x(async () => {
|
|
45
44
|
if (!!!(u && (h.current || b.current))) {
|
|
46
|
-
i(void 0), o(!1),
|
|
45
|
+
i(void 0), o(!1), c(null);
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
48
|
try {
|
|
50
|
-
|
|
49
|
+
c(null);
|
|
51
50
|
const m = await Ne.find({
|
|
52
51
|
modelName: f.current,
|
|
53
52
|
seedLocalId: h.current,
|
|
54
53
|
seedUid: b.current
|
|
55
54
|
});
|
|
56
55
|
if (!m) {
|
|
57
|
-
|
|
56
|
+
pe("[useItem] [loadItem] no item found", f.current, h.current), i((E) => E && (E.seedLocalId && E.seedLocalId === h.current || E.seedUid && E.seedUid === b.current) ? E : void 0), o(!1), c(null);
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
i(m), o(!1),
|
|
59
|
+
i(m), o(!1), c(null);
|
|
61
60
|
} catch (m) {
|
|
62
|
-
|
|
61
|
+
pe("[useItem] Error loading item:", m), i(void 0), o(!1), c(m);
|
|
63
62
|
}
|
|
64
63
|
}, [u]);
|
|
65
64
|
return I(() => {
|
|
66
65
|
f.current = e, h.current = r, b.current = t;
|
|
67
66
|
}, [e, r, t]), I(() => {
|
|
68
67
|
if (!v) {
|
|
69
|
-
!r && !t && (i(void 0), o(!1),
|
|
68
|
+
!r && !t && (i(void 0), o(!1), c(null));
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
71
|
p();
|
|
@@ -77,43 +76,43 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
77
76
|
}
|
|
78
77
|
s.current?.unsubscribe(), d.current = !1;
|
|
79
78
|
const m = n.getService().subscribe((E) => {
|
|
80
|
-
E && typeof E == "object" && "value" in E && (E.value === "idle" ? (d.current = !0, o(!1),
|
|
79
|
+
E && typeof E == "object" && "value" in E && (E.value === "idle" ? (d.current = !0, o(!1), c(null)) : E.value === "error" ? (c(new Error("Item service error")), o(!1)) : d.current && o(!0));
|
|
81
80
|
});
|
|
82
81
|
return s.current = m, () => {
|
|
83
82
|
s.current?.unsubscribe(), s.current = void 0;
|
|
84
83
|
};
|
|
85
84
|
}, [n]), {
|
|
86
85
|
item: n,
|
|
87
|
-
isLoading:
|
|
86
|
+
isLoading: a,
|
|
88
87
|
error: l
|
|
89
88
|
};
|
|
90
|
-
},
|
|
89
|
+
}, at = (e, r, t, n) => ["seed", "items", e ?? null, r ?? !1, t ?? !1, n ?? null], Wt = ({
|
|
91
90
|
modelName: e,
|
|
92
91
|
deleted: r = !1,
|
|
93
92
|
includeEas: t = !1,
|
|
94
93
|
addressFilter: n
|
|
95
94
|
}) => {
|
|
96
|
-
const i =
|
|
95
|
+
const i = z(), a = X(), o = F(void 0), l = F([]), c = F(/* @__PURE__ */ new Set()), [s, d] = w(null);
|
|
97
96
|
I(() => {
|
|
98
97
|
if (n !== "owned" && n !== "watched") {
|
|
99
98
|
d(null);
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
101
|
let m = !1;
|
|
103
|
-
return
|
|
102
|
+
return Ke(n).then((E) => {
|
|
104
103
|
m || d(E);
|
|
105
104
|
}), () => {
|
|
106
105
|
m = !0;
|
|
107
106
|
};
|
|
108
107
|
}, [n]);
|
|
109
108
|
const u = D(
|
|
110
|
-
() =>
|
|
109
|
+
() => at(e, r, t, n),
|
|
111
110
|
[e, r, t, n]
|
|
112
111
|
), {
|
|
113
112
|
data: f = [],
|
|
114
113
|
isLoading: h,
|
|
115
114
|
error: b
|
|
116
|
-
} =
|
|
115
|
+
} = Z({
|
|
117
116
|
queryKey: u,
|
|
118
117
|
queryFn: () => Ne.all(e, r, { waitForReady: !0, includeEas: t, addressFilter: n }),
|
|
119
118
|
enabled: i
|
|
@@ -123,25 +122,25 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
123
122
|
if (!v || (n === "owned" || n === "watched") && s === null)
|
|
124
123
|
return null;
|
|
125
124
|
const m = [];
|
|
126
|
-
t || m.push(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
t || m.push(te(le(A.uid), O(A.uid, ""))), e && m.push(O(A.type, nt(e))), n === "owned" ? s && s.length > 0 && m.push(
|
|
126
|
+
te(
|
|
127
|
+
De(A.publisher, s),
|
|
128
|
+
le(A.publisher)
|
|
130
129
|
)
|
|
131
|
-
) : n === "watched" && (s && s.length > 0 ? m.push(
|
|
132
|
-
|
|
130
|
+
) : n === "watched" && (s && s.length > 0 ? m.push(De(A.publisher, s)) : m.push(et`1=0`)), r ? m.push(
|
|
131
|
+
te(
|
|
133
132
|
Ie(A._markedForDeletion),
|
|
134
133
|
O(A._markedForDeletion, 1)
|
|
135
134
|
)
|
|
136
135
|
) : (m.push(
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
te(
|
|
137
|
+
le(A._markedForDeletion),
|
|
139
138
|
O(A._markedForDeletion, 0)
|
|
140
139
|
)
|
|
141
140
|
), m.push(
|
|
142
|
-
|
|
141
|
+
te(le(A.revokedAt), O(A.revokedAt, 0))
|
|
143
142
|
));
|
|
144
|
-
const E =
|
|
143
|
+
const E = je();
|
|
145
144
|
return v.with(E).select({
|
|
146
145
|
localId: A.localId,
|
|
147
146
|
uid: A.uid,
|
|
@@ -150,31 +149,31 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
150
149
|
createdAt: A.createdAt,
|
|
151
150
|
attestationCreatedAt: A.attestationCreatedAt,
|
|
152
151
|
_markedForDeletion: A._markedForDeletion
|
|
153
|
-
}).from(A).leftJoin(E, O(A.localId, E.seedLocalId)).where(Ee(
|
|
154
|
-
}, [v, i, e, r, t, n, s]), y =
|
|
152
|
+
}).from(A).leftJoin(E, O(A.localId, E.seedLocalId)).where(Ee(tt(E.versionsCount, 0), ...m)).groupBy(A.localId);
|
|
153
|
+
}, [v, i, e, r, t, n, s]), y = ie(p);
|
|
155
154
|
return I(() => {
|
|
156
155
|
if (!i || !y) return;
|
|
157
156
|
const m = /* @__PURE__ */ new Set();
|
|
158
|
-
for (const
|
|
159
|
-
const
|
|
160
|
-
|
|
157
|
+
for (const R of y) {
|
|
158
|
+
const N = R.localId || R.uid;
|
|
159
|
+
N && m.add(N);
|
|
161
160
|
}
|
|
162
161
|
const E = /* @__PURE__ */ new Set();
|
|
163
|
-
for (const
|
|
164
|
-
const
|
|
165
|
-
|
|
162
|
+
for (const R of l.current) {
|
|
163
|
+
const N = R.seedLocalId || R.seedUid;
|
|
164
|
+
N && E.add(N);
|
|
166
165
|
}
|
|
167
166
|
if (m.size === 0 && E.size > 0) return;
|
|
168
|
-
const g =
|
|
169
|
-
if (g.size === m.size && [...g].every((
|
|
167
|
+
const g = c.current;
|
|
168
|
+
if (g.size === m.size && [...g].every((R) => m.has(R)))
|
|
170
169
|
return;
|
|
171
|
-
if (o.current = y, E.size === m.size && [...E].every((
|
|
172
|
-
|
|
170
|
+
if (o.current = y, E.size === m.size && [...E].every((R) => m.has(R))) {
|
|
171
|
+
c.current = new Set(m);
|
|
173
172
|
return;
|
|
174
173
|
}
|
|
175
|
-
|
|
176
|
-
}, [i, y,
|
|
177
|
-
items:
|
|
174
|
+
c.current = new Set(m), a.invalidateQueries({ queryKey: u });
|
|
175
|
+
}, [i, y, a, u]), {
|
|
176
|
+
items: Ze(
|
|
178
177
|
f,
|
|
179
178
|
[
|
|
180
179
|
(m) => m.lastVersionPublishedAt || m.attestationCreatedAt || m.createdAt
|
|
@@ -184,21 +183,21 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
184
183
|
isLoading: h,
|
|
185
184
|
error: b
|
|
186
185
|
};
|
|
187
|
-
},
|
|
186
|
+
}, Gt = () => {
|
|
188
187
|
const [e, r] = w(!1), [t, n] = w(null), i = x(() => n(null), []);
|
|
189
188
|
return {
|
|
190
189
|
createItem: x(
|
|
191
190
|
async (o, l) => {
|
|
192
191
|
if (e) {
|
|
193
|
-
|
|
192
|
+
pe("[useCreateItem] [createItem] already creating item, skipping");
|
|
194
193
|
return;
|
|
195
194
|
}
|
|
196
|
-
n(null),
|
|
195
|
+
n(null), de(() => r(!0));
|
|
197
196
|
try {
|
|
198
|
-
const
|
|
197
|
+
const c = l ?? {}, { seedLocalId: s } = await We({ modelName: o, ...c });
|
|
199
198
|
return await Ne.find({ modelName: o, seedLocalId: s }) ?? void 0;
|
|
200
|
-
} catch (
|
|
201
|
-
|
|
199
|
+
} catch (c) {
|
|
200
|
+
pe("[useCreateItem] Error creating item:", c), n(c instanceof Error ? c : new Error(String(c)));
|
|
202
201
|
return;
|
|
203
202
|
} finally {
|
|
204
203
|
queueMicrotask(() => r(!1));
|
|
@@ -211,8 +210,8 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
211
210
|
resetError: i
|
|
212
211
|
};
|
|
213
212
|
}, Jt = () => {
|
|
214
|
-
const [e, r] = w(null), [t, n] = w(!1), [i,
|
|
215
|
-
s && (r(s),
|
|
213
|
+
const [e, r] = w(null), [t, n] = w(!1), [i, a] = w(null), o = F(void 0), l = x(() => a(null), []), c = x((s) => {
|
|
214
|
+
s && (r(s), a(null), s.publish().catch(() => {
|
|
216
215
|
}));
|
|
217
216
|
}, []);
|
|
218
217
|
return I(() => {
|
|
@@ -225,94 +224,100 @@ const fe = J("seedSdk:react:item"), Kt = ({ modelName: e, seedLocalId: r, seedUi
|
|
|
225
224
|
const v = b?.value, p = b?.context;
|
|
226
225
|
n(v === "publishing");
|
|
227
226
|
const y = p?._publishError;
|
|
228
|
-
|
|
227
|
+
a(y ? new Error(y.message) : null);
|
|
229
228
|
});
|
|
230
229
|
o.current = d;
|
|
231
230
|
const u = s.getSnapshot();
|
|
232
231
|
n(u?.value === "publishing");
|
|
233
232
|
const h = u?.context?._publishError;
|
|
234
|
-
return
|
|
233
|
+
return a(h ? new Error(h.message) : null), () => {
|
|
235
234
|
o.current?.unsubscribe(), o.current = void 0;
|
|
236
235
|
};
|
|
237
236
|
}, [e]), {
|
|
238
|
-
publishItem:
|
|
237
|
+
publishItem: c,
|
|
239
238
|
isLoading: t,
|
|
240
239
|
error: i,
|
|
241
240
|
resetError: l
|
|
242
241
|
};
|
|
243
|
-
},
|
|
242
|
+
}, ye = J("seedSdk:react:property"), ne = J("seedSdk:react:itemProperties");
|
|
244
243
|
function Ue(e, r) {
|
|
245
|
-
const t =
|
|
246
|
-
const
|
|
247
|
-
return (
|
|
244
|
+
const t = z(), [n, i] = w(void 0), [a, o] = w(!1), [l, c] = w(null), s = F(void 0), [, d] = w(0), f = typeof e == "object" && e != null ? e : null, h = f?.itemId, b = f?.seedLocalId, v = f?.seedUid, p = f?.propertyName, y = typeof e == "string" ? e : h !== void 0 && h !== "" ? h : void 0, E = p ?? (typeof e == "string" ? r : void 0), g = D(() => {
|
|
245
|
+
const N = y !== void 0 && y !== "" ? y : b, H = y !== void 0 && y !== "" ? void 0 : v;
|
|
246
|
+
return (N != null || H != null) && E != null && E !== "" ? {
|
|
248
247
|
type: "identifiers",
|
|
249
|
-
seedLocalId:
|
|
250
|
-
seedUid:
|
|
248
|
+
seedLocalId: N ?? void 0,
|
|
249
|
+
seedUid: H,
|
|
251
250
|
propertyName: E
|
|
252
251
|
} : null;
|
|
253
252
|
}, [y, E, b, v]);
|
|
254
253
|
D(() => g ? !!((g.seedLocalId || g.seedUid) && g.propertyName) : !1, [g]);
|
|
255
|
-
const
|
|
254
|
+
const B = D(() => !t || !g ? !1 : !!((g.seedLocalId || g.seedUid) && g.propertyName), [t, g]);
|
|
255
|
+
Ve(() => {
|
|
256
|
+
B && o(!0);
|
|
257
|
+
}, [B]);
|
|
258
|
+
const R = x(async () => {
|
|
256
259
|
if (!t || !g) {
|
|
257
|
-
i(void 0), o(!1),
|
|
260
|
+
i(void 0), o(!1), c(null);
|
|
258
261
|
return;
|
|
259
262
|
}
|
|
260
263
|
try {
|
|
261
|
-
o(!0),
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
264
|
-
i(void 0), o(!1),
|
|
264
|
+
o(!0), c(null);
|
|
265
|
+
const N = g.seedLocalId, H = g.seedUid;
|
|
266
|
+
if (!N && !H) {
|
|
267
|
+
i(void 0), o(!1), c(null);
|
|
265
268
|
return;
|
|
266
269
|
}
|
|
267
|
-
const
|
|
270
|
+
const Q = await se.find({
|
|
268
271
|
propertyName: g.propertyName,
|
|
269
|
-
seedLocalId:
|
|
270
|
-
seedUid:
|
|
272
|
+
seedLocalId: N,
|
|
273
|
+
seedUid: H
|
|
271
274
|
});
|
|
272
|
-
if (!
|
|
273
|
-
|
|
274
|
-
`[useItemProperty] [updateItemProperty] no property found for Item.${
|
|
275
|
-
), i(void 0), o(!1),
|
|
275
|
+
if (!Q) {
|
|
276
|
+
ye(
|
|
277
|
+
`[useItemProperty] [updateItemProperty] no property found for Item.${N || H}.${g.propertyName}`
|
|
278
|
+
), i(void 0), o(!1), c(null);
|
|
276
279
|
return;
|
|
277
280
|
}
|
|
278
|
-
i(
|
|
279
|
-
} catch (
|
|
280
|
-
|
|
281
|
+
i(Q), o(!1), c(null);
|
|
282
|
+
} catch (N) {
|
|
283
|
+
ye("[useItemProperty] Error updating item property:", N), i(void 0), o(!1), c(N);
|
|
281
284
|
}
|
|
282
285
|
}, [t, g]);
|
|
283
286
|
return I(() => {
|
|
284
|
-
if (!
|
|
285
|
-
i(void 0), o(!1),
|
|
287
|
+
if (!B) {
|
|
288
|
+
i(void 0), o(!1), c(null);
|
|
286
289
|
return;
|
|
287
290
|
}
|
|
288
|
-
n && g && n.propertyName === g.propertyName && (g.seedLocalId != null && n.seedLocalId === g.seedLocalId || g.seedUid != null && n.seedUid === g.seedUid) ||
|
|
289
|
-
}, [
|
|
291
|
+
n && g && n.propertyName === g.propertyName && (g.seedLocalId != null && n.seedLocalId === g.seedLocalId || g.seedUid != null && n.seedUid === g.seedUid) || R();
|
|
292
|
+
}, [B, R, n, g]), I(() => {
|
|
290
293
|
if (!n) {
|
|
291
294
|
s.current?.unsubscribe(), s.current = void 0;
|
|
292
295
|
return;
|
|
293
296
|
}
|
|
294
297
|
s.current?.unsubscribe();
|
|
295
|
-
let
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
o(!1),
|
|
298
|
+
let N = 0, H = !1, Q;
|
|
299
|
+
const L = 50, k = n.getService().subscribe((_) => {
|
|
300
|
+
if (_ && typeof _ == "object" && "value" in _ && _.value === "idle") {
|
|
301
|
+
o(!1), c(null);
|
|
302
|
+
const M = _.context, G = JSON.stringify([M.renderValue, M.propertyValue]);
|
|
303
|
+
(!H || G !== Q) && (H = !0, Q = G, d((re) => re + 1));
|
|
299
304
|
return;
|
|
300
305
|
}
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
306
|
+
H = !1, Q = void 0;
|
|
307
|
+
const V = Date.now();
|
|
308
|
+
V - N >= L && (N = V, d((M) => M + 1));
|
|
304
309
|
});
|
|
305
|
-
return s.current =
|
|
310
|
+
return s.current = k, () => {
|
|
306
311
|
s.current?.unsubscribe(), s.current = void 0;
|
|
307
312
|
};
|
|
308
313
|
}, [n]), {
|
|
309
314
|
property: n,
|
|
310
|
-
isLoading:
|
|
315
|
+
isLoading: a,
|
|
311
316
|
error: l
|
|
312
317
|
};
|
|
313
318
|
}
|
|
314
|
-
function
|
|
315
|
-
const t = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, i = "seedUid" in e ? e.seedUid : void 0,
|
|
319
|
+
function Yt(e, r = 300) {
|
|
320
|
+
const t = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, i = "seedUid" in e ? e.seedUid : void 0, a = e.propertyName, o = D(() => t ? { seedLocalId: t, propertyName: a } : { seedLocalId: n, seedUid: i, propertyName: a }, [t, n, i, a]), { property: l, isLoading: c, error: s } = Ue(o), d = F(""), u = D(
|
|
316
321
|
() => $e((h) => {
|
|
317
322
|
h.getService().send({
|
|
318
323
|
type: "save",
|
|
@@ -335,49 +340,49 @@ function Gt(e, r = 300) {
|
|
|
335
340
|
return {
|
|
336
341
|
property: l,
|
|
337
342
|
setValue: f,
|
|
338
|
-
isLoading:
|
|
343
|
+
isLoading: c,
|
|
339
344
|
error: s
|
|
340
345
|
};
|
|
341
346
|
}
|
|
342
|
-
async function
|
|
347
|
+
async function lt(e, r) {
|
|
343
348
|
if (!e && !r) return [];
|
|
344
349
|
const t = W.getAppDb();
|
|
345
350
|
if (!t) return [];
|
|
346
|
-
const n = await
|
|
351
|
+
const n = await se.all(
|
|
347
352
|
{ seedLocalId: e ?? void 0, seedUid: r ?? void 0 },
|
|
348
353
|
{ waitForReady: !0 }
|
|
349
|
-
), i = [...n],
|
|
350
|
-
for (const
|
|
351
|
-
|
|
354
|
+
), i = [...n], a = /* @__PURE__ */ new Set();
|
|
355
|
+
for (const c of n)
|
|
356
|
+
c.propertyName && a.add(c.propertyName);
|
|
352
357
|
let o;
|
|
353
358
|
if (n.length > 0) {
|
|
354
|
-
const
|
|
355
|
-
o =
|
|
359
|
+
const c = n[0];
|
|
360
|
+
o = c.modelName ?? c.modelType, o && typeof o == "string" && (o = _e(o));
|
|
356
361
|
}
|
|
357
362
|
if (!o) {
|
|
358
|
-
const
|
|
359
|
-
|
|
363
|
+
const c = await t.select({ type: A.type }).from(A).where(r ? O(A.uid, r) : O(A.localId, e)).limit(1);
|
|
364
|
+
c.length > 0 && c[0].type && (o = _e(c[0].type));
|
|
360
365
|
}
|
|
361
366
|
const l = [];
|
|
362
367
|
if (o)
|
|
363
368
|
try {
|
|
364
|
-
const { Model:
|
|
369
|
+
const { Model: c } = await import("@seedprotocol/sdk"), s = await c.getByNameAsync(o);
|
|
365
370
|
if (s?.properties)
|
|
366
371
|
for (const d of s.properties)
|
|
367
372
|
d.name && l.push(d.name);
|
|
368
|
-
} catch (
|
|
369
|
-
|
|
373
|
+
} catch (c) {
|
|
374
|
+
ne(`[useItemProperties] Error getting ModelProperties for ${o}:`, c);
|
|
370
375
|
}
|
|
371
376
|
if (o && l.length > 0) {
|
|
372
|
-
const
|
|
377
|
+
const c = n.length > 0 ? n[0].seedLocalId ?? e : e, s = n.length > 0 ? n[0].seedUid ?? r : r;
|
|
373
378
|
for (const d of l)
|
|
374
|
-
if (!
|
|
379
|
+
if (!a.has(d))
|
|
375
380
|
try {
|
|
376
|
-
const u =
|
|
381
|
+
const u = se.create(
|
|
377
382
|
{
|
|
378
383
|
propertyName: d,
|
|
379
384
|
modelName: o,
|
|
380
|
-
seedLocalId:
|
|
385
|
+
seedLocalId: c || void 0,
|
|
381
386
|
seedUid: s || void 0,
|
|
382
387
|
propertyValue: null
|
|
383
388
|
},
|
|
@@ -385,62 +390,62 @@ async function at(e, r) {
|
|
|
385
390
|
);
|
|
386
391
|
u && i.push(u);
|
|
387
392
|
} catch (u) {
|
|
388
|
-
|
|
393
|
+
ye(`[useItemProperties] Error creating ItemProperty for missing property ${d}:`, u);
|
|
389
394
|
}
|
|
390
395
|
}
|
|
391
396
|
if (e || r) {
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
397
|
+
const c = await t.select({ createdAt: A.createdAt }).from(A).where(r ? O(A.uid, r) : O(A.localId, e)).limit(1);
|
|
398
|
+
if (c.length > 0 && c[0].createdAt) {
|
|
394
399
|
const s = "createdAt";
|
|
395
400
|
if (!i.some((u) => u.propertyName === s) && o)
|
|
396
401
|
try {
|
|
397
|
-
const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? r : r, h =
|
|
402
|
+
const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? r : r, h = se.create(
|
|
398
403
|
{
|
|
399
404
|
propertyName: s,
|
|
400
405
|
modelName: o,
|
|
401
406
|
seedLocalId: u || void 0,
|
|
402
407
|
seedUid: f || void 0,
|
|
403
|
-
propertyValue:
|
|
408
|
+
propertyValue: c[0].createdAt.toString()
|
|
404
409
|
},
|
|
405
410
|
{ waitForReady: !1 }
|
|
406
411
|
);
|
|
407
412
|
h && i.push(h);
|
|
408
413
|
} catch (u) {
|
|
409
|
-
|
|
414
|
+
ye("[useItemProperties] Error creating createdAt ItemProperty:", u);
|
|
410
415
|
}
|
|
411
416
|
}
|
|
412
417
|
}
|
|
413
418
|
return i;
|
|
414
419
|
}
|
|
415
|
-
function
|
|
416
|
-
const r =
|
|
420
|
+
function Xt(e) {
|
|
421
|
+
const r = z(), t = X(), n = F(void 0), i = D(() => typeof e == "string" ? { type: "itemId", itemId: e } : typeof e == "object" ? {
|
|
417
422
|
type: "identifiers",
|
|
418
423
|
seedLocalId: e.seedLocalId,
|
|
419
424
|
seedUid: e.seedUid
|
|
420
|
-
} : null, [e]),
|
|
425
|
+
} : null, [e]), a = D(() => {
|
|
421
426
|
if (i)
|
|
422
427
|
return i.type === "itemId" ? i.itemId : i.seedLocalId;
|
|
423
428
|
}, [i]), o = D(() => {
|
|
424
429
|
if (!(!i || i.type === "itemId"))
|
|
425
430
|
return i.seedUid;
|
|
426
|
-
}, [i]), l =
|
|
431
|
+
}, [i]), l = a ?? o ?? "", c = D(
|
|
427
432
|
() => ["seed", "itemProperties", l],
|
|
428
433
|
[l]
|
|
429
434
|
), {
|
|
430
435
|
data: s = [],
|
|
431
436
|
isLoading: d,
|
|
432
437
|
error: u
|
|
433
|
-
} =
|
|
434
|
-
queryKey:
|
|
435
|
-
queryFn: () =>
|
|
438
|
+
} = Z({
|
|
439
|
+
queryKey: c,
|
|
440
|
+
queryFn: () => lt(a, o),
|
|
436
441
|
enabled: r && !!l
|
|
437
442
|
}), f = D(() => {
|
|
438
|
-
if (!r || !
|
|
439
|
-
return
|
|
443
|
+
if (!r || !a && !o)
|
|
444
|
+
return ne("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
440
445
|
const v = W.getAppDb();
|
|
441
446
|
if (!v)
|
|
442
|
-
return
|
|
443
|
-
|
|
447
|
+
return ne("[useItemProperties] Query: returning null (no db)"), null;
|
|
448
|
+
ne(`[useItemProperties] Query: creating query for seedLocalId=${a}, seedUid=${o}`);
|
|
444
449
|
const p = o ? v.select({
|
|
445
450
|
propertyName: T.propertyName,
|
|
446
451
|
propertyValue: T.propertyValue,
|
|
@@ -455,7 +460,7 @@ function Yt(e) {
|
|
|
455
460
|
O(T.seedUid, o),
|
|
456
461
|
Ie(T.propertyName)
|
|
457
462
|
)
|
|
458
|
-
) :
|
|
463
|
+
) : a ? v.select({
|
|
459
464
|
propertyName: T.propertyName,
|
|
460
465
|
propertyValue: T.propertyValue,
|
|
461
466
|
seedLocalId: T.seedLocalId,
|
|
@@ -466,12 +471,12 @@ function Yt(e) {
|
|
|
466
471
|
attestationCreatedAt: T.attestationCreatedAt
|
|
467
472
|
}).from(T).where(
|
|
468
473
|
Ee(
|
|
469
|
-
O(T.seedLocalId,
|
|
474
|
+
O(T.seedLocalId, a),
|
|
470
475
|
Ie(T.propertyName)
|
|
471
476
|
)
|
|
472
477
|
) : null;
|
|
473
|
-
return
|
|
474
|
-
}, [r,
|
|
478
|
+
return ne("[useItemProperties] Query: created query object", { queryType: o ? "seedUid" : "seedLocalId" }), p;
|
|
479
|
+
}, [r, a, o]), h = ie(f), b = D(() => {
|
|
475
480
|
if (!h || h.length === 0)
|
|
476
481
|
return [];
|
|
477
482
|
const v = /* @__PURE__ */ new Map();
|
|
@@ -488,7 +493,7 @@ function Yt(e) {
|
|
|
488
493
|
return Array.from(v.values());
|
|
489
494
|
}, [h]);
|
|
490
495
|
return I(() => {
|
|
491
|
-
if (!r || !
|
|
496
|
+
if (!r || !a && !o || b === void 0) return;
|
|
492
497
|
const v = JSON.stringify(
|
|
493
498
|
b.map((p) => ({
|
|
494
499
|
propertyName: p.propertyName,
|
|
@@ -497,36 +502,36 @@ function Yt(e) {
|
|
|
497
502
|
seedUid: p.seedUid
|
|
498
503
|
})).sort((p, y) => (p.propertyName || "").localeCompare(y.propertyName || ""))
|
|
499
504
|
);
|
|
500
|
-
n.current !== v && (n.current = v, b.length > 0 && t.invalidateQueries({ queryKey:
|
|
501
|
-
}, [r, b, s,
|
|
505
|
+
n.current !== v && (n.current = v, b.length > 0 && t.invalidateQueries({ queryKey: c }));
|
|
506
|
+
}, [r, b, s, a, o, t, c]), I(() => {
|
|
502
507
|
n.current = void 0;
|
|
503
|
-
}, [
|
|
508
|
+
}, [a, o]), {
|
|
504
509
|
properties: s,
|
|
505
510
|
isLoading: d,
|
|
506
511
|
error: u
|
|
507
512
|
};
|
|
508
513
|
}
|
|
509
|
-
const
|
|
510
|
-
const e =
|
|
514
|
+
const Zt = () => {
|
|
515
|
+
const e = F(void 0), [r, t] = w(!1), [n, i] = w(null), a = x(() => i(null), []), o = x((l) => {
|
|
511
516
|
if (!l.propertyName || !l.seedLocalId && !l.seedUid || !l.modelName) {
|
|
512
517
|
const d = new Error("seedLocalId or seedUid, propertyName, and modelName are required");
|
|
513
518
|
i(d);
|
|
514
519
|
return;
|
|
515
520
|
}
|
|
516
521
|
i(null), t(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
517
|
-
const
|
|
518
|
-
if (!
|
|
522
|
+
const c = se.create(l, { waitForReady: !1 });
|
|
523
|
+
if (!c) {
|
|
519
524
|
i(new Error("Failed to create item property")), t(!1);
|
|
520
525
|
return;
|
|
521
526
|
}
|
|
522
|
-
const s =
|
|
527
|
+
const s = c.getService().subscribe((d) => {
|
|
523
528
|
if (d?.value === "error") {
|
|
524
529
|
const u = d.context?._loadingError?.error ?? new Error("Failed to create item property");
|
|
525
530
|
i(u instanceof Error ? u : new Error(String(u))), t(!1);
|
|
526
531
|
}
|
|
527
532
|
d?.value === "idle" && (i(null), t(!1));
|
|
528
533
|
});
|
|
529
|
-
return e.current = s,
|
|
534
|
+
return e.current = s, c;
|
|
530
535
|
}, []);
|
|
531
536
|
return I(() => () => {
|
|
532
537
|
e.current?.unsubscribe(), e.current = void 0;
|
|
@@ -534,9 +539,9 @@ const Xt = () => {
|
|
|
534
539
|
create: o,
|
|
535
540
|
isLoading: r,
|
|
536
541
|
error: n,
|
|
537
|
-
resetError:
|
|
542
|
+
resetError: a
|
|
538
543
|
};
|
|
539
|
-
},
|
|
544
|
+
}, er = () => {
|
|
540
545
|
const [e, r] = w(null), [t, n] = w({
|
|
541
546
|
isLoading: !1,
|
|
542
547
|
error: null
|
|
@@ -554,21 +559,21 @@ const Xt = () => {
|
|
|
554
559
|
});
|
|
555
560
|
};
|
|
556
561
|
l();
|
|
557
|
-
const
|
|
558
|
-
return () =>
|
|
562
|
+
const c = o.subscribe(l);
|
|
563
|
+
return () => c.unsubscribe();
|
|
559
564
|
}, [e]);
|
|
560
565
|
const i = x(async (o) => {
|
|
561
566
|
o && (r(o), await o.destroy());
|
|
562
|
-
}, []),
|
|
567
|
+
}, []), a = x(() => {
|
|
563
568
|
e && e.getService().send({ type: "clearDestroyError" });
|
|
564
569
|
}, [e]);
|
|
565
570
|
return {
|
|
566
571
|
destroy: i,
|
|
567
572
|
isLoading: t.isLoading,
|
|
568
573
|
error: t.error,
|
|
569
|
-
resetError:
|
|
574
|
+
resetError: a
|
|
570
575
|
};
|
|
571
|
-
}, Le = J("seedSdk:react:services"),
|
|
576
|
+
}, Le = J("seedSdk:react:services"), ct = ["idle", "ready", "done", "success", "initialized"], Oe = (e) => {
|
|
572
577
|
let r = "actor";
|
|
573
578
|
const t = e;
|
|
574
579
|
return e && t.uniqueKey && (r = t.uniqueKey), e && !t.uniqueKey && t.logic && t.logic.config && (r = Ae(e)), r;
|
|
@@ -587,24 +592,24 @@ const Xt = () => {
|
|
|
587
592
|
let i;
|
|
588
593
|
try {
|
|
589
594
|
i = e.getSnapshot();
|
|
590
|
-
} catch (
|
|
591
|
-
return Le("Error:",
|
|
595
|
+
} catch (a) {
|
|
596
|
+
return Le("Error:", a), n;
|
|
592
597
|
}
|
|
593
598
|
if (i) {
|
|
594
|
-
const
|
|
595
|
-
|
|
599
|
+
const a = i.context;
|
|
600
|
+
a && a.dbName && (n = a.dbName), a && a.modelNamePlural && (n = a.modelNamePlural), a && a.modelName && (n = it(a.modelName.toLowerCase()));
|
|
596
601
|
}
|
|
597
602
|
return n;
|
|
598
|
-
},
|
|
603
|
+
}, tr = (e) => {
|
|
599
604
|
const [r, t] = w(0), n = (o) => {
|
|
600
605
|
let l = 0;
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
606
|
+
const c = o;
|
|
607
|
+
if (c.logic?.states) {
|
|
603
608
|
const s = [], d = [];
|
|
604
|
-
for (const [h, b] of Object.entries(
|
|
609
|
+
for (const [h, b] of Object.entries(c.logic.states))
|
|
605
610
|
b.tags?.includes("loading") && (s.push(h), d.push(b));
|
|
606
611
|
const u = d.length, f = Fe(o);
|
|
607
|
-
if (f &&
|
|
612
|
+
if (f && ct.includes(f))
|
|
608
613
|
return 0;
|
|
609
614
|
f && (l = s.indexOf(f) / u * 100);
|
|
610
615
|
}
|
|
@@ -617,17 +622,17 @@ const Xt = () => {
|
|
|
617
622
|
clearInterval(o);
|
|
618
623
|
return;
|
|
619
624
|
}
|
|
620
|
-
t((
|
|
625
|
+
t((c) => c + 1);
|
|
621
626
|
},
|
|
622
627
|
[e]
|
|
623
|
-
),
|
|
628
|
+
), a = x(() => {
|
|
624
629
|
const o = setInterval(() => {
|
|
625
630
|
i(o);
|
|
626
631
|
}, 1e3);
|
|
627
632
|
return o;
|
|
628
633
|
}, [i, e]);
|
|
629
634
|
return I(() => {
|
|
630
|
-
const o =
|
|
635
|
+
const o = a();
|
|
631
636
|
return () => clearInterval(o);
|
|
632
637
|
}, []), {
|
|
633
638
|
name: Oe(e),
|
|
@@ -636,49 +641,49 @@ const Xt = () => {
|
|
|
636
641
|
percentComplete: n(e),
|
|
637
642
|
uniqueKey: Ae(e)
|
|
638
643
|
};
|
|
639
|
-
},
|
|
640
|
-
const [e, r] = w(!1), { internalStatus: t } =
|
|
644
|
+
}, dt = () => {
|
|
645
|
+
const [e, r] = w(!1), { internalStatus: t } = pt();
|
|
641
646
|
return I(() => {
|
|
642
647
|
t === "ready" && r(!0);
|
|
643
648
|
}, [t]), I(() => {
|
|
644
649
|
t === "ready" && r(!0);
|
|
645
650
|
}, []), e;
|
|
646
|
-
},
|
|
647
|
-
const [e, r] = w(!1), t =
|
|
651
|
+
}, rr = () => {
|
|
652
|
+
const [e, r] = w(!1), t = ut(), { services: n, percentComplete: i } = ft(), a = x(async () => {
|
|
648
653
|
for (const l of n) {
|
|
649
|
-
const
|
|
654
|
+
const c = Ae(l);
|
|
650
655
|
Le(
|
|
651
|
-
`would save to db with snapshot__${
|
|
656
|
+
`would save to db with snapshot__${c}:`,
|
|
652
657
|
JSON.stringify(l.getPersistedSnapshot())
|
|
653
658
|
);
|
|
654
659
|
}
|
|
655
660
|
}, [n]), o = x(async () => {
|
|
656
661
|
const l = W.getAppDb();
|
|
657
|
-
return l ? await l.select().from(
|
|
662
|
+
return l ? await l.select().from(ue).where(Be(ue.key, "snapshot__%")) : [];
|
|
658
663
|
}, []);
|
|
659
664
|
I(() => !t || e ? void 0 : ((async () => {
|
|
660
|
-
const
|
|
661
|
-
Le("persistedSnapshots:",
|
|
665
|
+
const c = await o();
|
|
666
|
+
Le("persistedSnapshots:", c), r(!0);
|
|
662
667
|
})(), () => {
|
|
663
|
-
|
|
668
|
+
a();
|
|
664
669
|
}), [t, e]);
|
|
665
|
-
},
|
|
666
|
-
const [e, r] = w(!1), t =
|
|
670
|
+
}, ut = () => {
|
|
671
|
+
const [e, r] = w(!1), t = dt();
|
|
667
672
|
return I(() => {
|
|
668
673
|
t && (async () => {
|
|
669
|
-
const
|
|
670
|
-
|
|
674
|
+
const a = await W.getAppDb().select().from(ue).where(Be(ue.key, "snapshot__%"));
|
|
675
|
+
a && a.length > 0 && r(!0);
|
|
671
676
|
})();
|
|
672
677
|
}, [t]), e;
|
|
673
|
-
},
|
|
678
|
+
}, ft = () => {
|
|
674
679
|
const [e, r] = w([]), [t, n] = w(5);
|
|
675
680
|
return I(() => {
|
|
676
|
-
const
|
|
681
|
+
const a = me().getService(), o = a;
|
|
677
682
|
o.uniqueKey = "clientManager", r([o]);
|
|
678
|
-
const l =
|
|
679
|
-
const s =
|
|
683
|
+
const l = a.subscribe((c) => {
|
|
684
|
+
const s = c.value;
|
|
680
685
|
let d = 0;
|
|
681
|
-
s ===
|
|
686
|
+
s === C.IDLE ? d = 100 : s === C.ADD_MODELS_TO_DB ? d = 90 : s === C.ADD_MODELS_TO_STORE ? d = 80 : s === C.PROCESS_SCHEMA_FILES ? d = 70 : s === C.SAVE_CONFIG ? d = 60 : s === C.DB_INIT ? d = 50 : s === C.FILE_SYSTEM_INIT ? d = 30 : s === C.PLATFORM_CLASSES_INIT && (d = 10), n(d);
|
|
682
687
|
});
|
|
683
688
|
return () => {
|
|
684
689
|
l.unsubscribe();
|
|
@@ -687,10 +692,10 @@ const Xt = () => {
|
|
|
687
692
|
services: e,
|
|
688
693
|
percentComplete: t
|
|
689
694
|
};
|
|
690
|
-
},
|
|
691
|
-
const r =
|
|
692
|
-
const
|
|
693
|
-
return
|
|
695
|
+
}, pt = () => {
|
|
696
|
+
const r = me().getService(), t = we(r, (i) => i.value), n = we(r, (i) => {
|
|
697
|
+
const a = i.value;
|
|
698
|
+
return a === C.DB_INIT || a === C.SAVE_CONFIG || a === C.PROCESS_SCHEMA_FILES || a === C.ADD_MODELS_TO_STORE || a === C.ADD_MODELS_TO_DB || a === C.IDLE ? "ready" : a;
|
|
694
699
|
});
|
|
695
700
|
return {
|
|
696
701
|
status: t,
|
|
@@ -698,21 +703,21 @@ const Xt = () => {
|
|
|
698
703
|
};
|
|
699
704
|
};
|
|
700
705
|
J("seedSdk:react:db");
|
|
701
|
-
const
|
|
706
|
+
const nr = () => {
|
|
702
707
|
const [e, r] = w(!1), t = x(() => {
|
|
703
708
|
e || r(!0);
|
|
704
709
|
}, []);
|
|
705
710
|
return I(() => {
|
|
706
711
|
let n;
|
|
707
712
|
return (async () => {
|
|
708
|
-
const o =
|
|
709
|
-
if (l ===
|
|
713
|
+
const o = me().getService(), l = o.getSnapshot().value;
|
|
714
|
+
if (l === C.DB_INIT || l === C.SAVE_CONFIG || l === C.PROCESS_SCHEMA_FILES || l === C.ADD_MODELS_TO_STORE || l === C.ADD_MODELS_TO_DB || l === C.IDLE) {
|
|
710
715
|
t();
|
|
711
716
|
return;
|
|
712
717
|
}
|
|
713
|
-
n = o.subscribe((
|
|
714
|
-
const s =
|
|
715
|
-
(s ===
|
|
718
|
+
n = o.subscribe((c) => {
|
|
719
|
+
const s = c.value;
|
|
720
|
+
(s === C.DB_INIT || s === C.SAVE_CONFIG || s === C.PROCESS_SCHEMA_FILES || s === C.ADD_MODELS_TO_STORE || s === C.ADD_MODELS_TO_DB || s === C.IDLE) && (t(), n?.unsubscribe());
|
|
716
721
|
});
|
|
717
722
|
})(), () => {
|
|
718
723
|
n && n.unsubscribe();
|
|
@@ -720,24 +725,24 @@ const rr = () => {
|
|
|
720
725
|
}, []), {
|
|
721
726
|
dbsAreReady: e
|
|
722
727
|
};
|
|
723
|
-
}, qe = J("seedSdk:react:schema"),
|
|
724
|
-
const [r, t] = w(null), [n, i] = w(!!e), [
|
|
728
|
+
}, qe = J("seedSdk:react:schema"), yt = (e) => {
|
|
729
|
+
const [r, t] = w(null), [n, i] = w(!!e), [a, o] = w(null), l = F(null), c = z(), s = x((d) => {
|
|
725
730
|
i(!0), o(null);
|
|
726
731
|
try {
|
|
727
|
-
const u =
|
|
732
|
+
const u = he.create(d, {
|
|
728
733
|
waitForReady: !1
|
|
729
734
|
});
|
|
730
735
|
t(u);
|
|
731
736
|
const f = u.getService();
|
|
732
|
-
f.getSnapshot().value === "idle" ? (
|
|
733
|
-
v.value === "idle" ? (
|
|
737
|
+
f.getSnapshot().value === "idle" ? (de(() => i(!1)), o(null)) : i(!0), l.current = f.subscribe((v) => {
|
|
738
|
+
v.value === "idle" ? (de(() => i(!1)), o(null)) : i(!0);
|
|
734
739
|
});
|
|
735
740
|
} catch (u) {
|
|
736
741
|
return qe("[useSchema] Error creating schema:", u), o(u), t(null), i(!1), null;
|
|
737
742
|
}
|
|
738
743
|
}, []);
|
|
739
744
|
return I(() => {
|
|
740
|
-
if (l.current && (l.current.unsubscribe(), l.current = null), !
|
|
745
|
+
if (l.current && (l.current.unsubscribe(), l.current = null), !c) {
|
|
741
746
|
t(null), o(null), i(!1);
|
|
742
747
|
return;
|
|
743
748
|
}
|
|
@@ -748,23 +753,23 @@ const rr = () => {
|
|
|
748
753
|
return s(e), () => {
|
|
749
754
|
l.current && (l.current.unsubscribe(), l.current = null);
|
|
750
755
|
};
|
|
751
|
-
}, [e,
|
|
756
|
+
}, [e, c, s]), {
|
|
752
757
|
schema: r,
|
|
753
758
|
isLoading: n,
|
|
754
|
-
error:
|
|
759
|
+
error: a
|
|
755
760
|
};
|
|
756
|
-
}, be = ["seed", "schemas"],
|
|
757
|
-
const e =
|
|
761
|
+
}, be = ["seed", "schemas"], sr = () => {
|
|
762
|
+
const e = z(), r = X(), t = F(void 0), n = F([]), {
|
|
758
763
|
data: i = [],
|
|
759
|
-
isLoading:
|
|
764
|
+
isLoading: a,
|
|
760
765
|
error: o
|
|
761
|
-
} =
|
|
766
|
+
} = Z({
|
|
762
767
|
queryKey: be,
|
|
763
|
-
queryFn: () =>
|
|
768
|
+
queryFn: () => he.all({ waitForReady: !0 }),
|
|
764
769
|
enabled: e
|
|
765
770
|
});
|
|
766
771
|
n.current = i;
|
|
767
|
-
const l = e ? W.getAppDb() : null,
|
|
772
|
+
const l = e ? W.getAppDb() : null, c = D(() => l ? l.select().from(Y).orderBy(Y.name, rt(Y.version)) : null, [l, e]), s = ie(c);
|
|
768
773
|
return I(() => {
|
|
769
774
|
if (typeof BroadcastChannel > "u") return;
|
|
770
775
|
const d = new BroadcastChannel("seed-schemas-invalidate"), u = () => {
|
|
@@ -797,22 +802,22 @@ const rr = () => {
|
|
|
797
802
|
!v && p && r.invalidateQueries({ queryKey: be });
|
|
798
803
|
}, [e, s, r]), {
|
|
799
804
|
schemas: i,
|
|
800
|
-
isLoading:
|
|
805
|
+
isLoading: a,
|
|
801
806
|
error: o
|
|
802
807
|
};
|
|
803
|
-
},
|
|
804
|
-
const e =
|
|
808
|
+
}, or = () => {
|
|
809
|
+
const e = F(null), [r, t] = w(!1), [n, i] = w(null), a = x(() => i(null), []), o = x((l) => {
|
|
805
810
|
i(null), t(!0), e.current?.unsubscribe(), e.current = null;
|
|
806
|
-
const
|
|
811
|
+
const c = he.create(l, {
|
|
807
812
|
waitForReady: !1
|
|
808
|
-
}), s =
|
|
813
|
+
}), s = c.getService().subscribe((d) => {
|
|
809
814
|
if (d.value === "error") {
|
|
810
815
|
const u = d.context._loadingError?.error;
|
|
811
816
|
i(u instanceof Error ? u : new Error("Failed to create schema")), t(!1);
|
|
812
817
|
}
|
|
813
818
|
d.value === "idle" && (i(null), t(!1));
|
|
814
819
|
});
|
|
815
|
-
return e.current = s,
|
|
820
|
+
return e.current = s, c;
|
|
816
821
|
}, []);
|
|
817
822
|
return I(() => () => {
|
|
818
823
|
e.current?.unsubscribe(), e.current = null;
|
|
@@ -820,9 +825,9 @@ const rr = () => {
|
|
|
820
825
|
createSchema: o,
|
|
821
826
|
isLoading: r,
|
|
822
827
|
error: n,
|
|
823
|
-
resetError:
|
|
828
|
+
resetError: a
|
|
824
829
|
};
|
|
825
|
-
},
|
|
830
|
+
}, ir = () => {
|
|
826
831
|
const [e, r] = w(null), [t, n] = w({
|
|
827
832
|
isLoading: !1,
|
|
828
833
|
error: null
|
|
@@ -840,63 +845,63 @@ const rr = () => {
|
|
|
840
845
|
});
|
|
841
846
|
};
|
|
842
847
|
l();
|
|
843
|
-
const
|
|
844
|
-
return () =>
|
|
848
|
+
const c = o.subscribe(l);
|
|
849
|
+
return () => c.unsubscribe();
|
|
845
850
|
}, [e]);
|
|
846
851
|
const i = x(async (o) => {
|
|
847
852
|
o && (r(o), await o.destroy());
|
|
848
|
-
}, []),
|
|
853
|
+
}, []), a = x(() => {
|
|
849
854
|
e && e.getService().send({ type: "clearDestroyError" });
|
|
850
855
|
}, [e]);
|
|
851
856
|
return {
|
|
852
857
|
destroy: i,
|
|
853
858
|
isLoading: t.isLoading,
|
|
854
859
|
error: t.error,
|
|
855
|
-
resetError:
|
|
860
|
+
resetError: a
|
|
856
861
|
};
|
|
857
|
-
},
|
|
858
|
-
const [e, r] = w(), t =
|
|
862
|
+
}, ar = () => {
|
|
863
|
+
const [e, r] = w(), t = F(/* @__PURE__ */ new Map()), n = z(), i = x(async () => {
|
|
859
864
|
if (n)
|
|
860
865
|
try {
|
|
861
|
-
const
|
|
862
|
-
for (const
|
|
863
|
-
const s =
|
|
866
|
+
const a = await Ge(), o = /* @__PURE__ */ new Set();
|
|
867
|
+
for (const c of a) {
|
|
868
|
+
const s = c.schema.metadata?.name;
|
|
864
869
|
s && o.add(s);
|
|
865
870
|
}
|
|
866
871
|
const l = /* @__PURE__ */ new Map();
|
|
867
|
-
for (const
|
|
868
|
-
if (t.current.has(
|
|
869
|
-
const s = t.current.get(
|
|
870
|
-
l.set(
|
|
872
|
+
for (const c of o)
|
|
873
|
+
if (t.current.has(c)) {
|
|
874
|
+
const s = t.current.get(c);
|
|
875
|
+
l.set(c, s);
|
|
871
876
|
} else {
|
|
872
|
-
const s =
|
|
877
|
+
const s = he.create(c, {
|
|
873
878
|
waitForReady: !1
|
|
874
879
|
});
|
|
875
|
-
l.set(
|
|
880
|
+
l.set(c, s);
|
|
876
881
|
}
|
|
877
|
-
for (const [
|
|
878
|
-
o.has(
|
|
882
|
+
for (const [c, s] of t.current.entries())
|
|
883
|
+
o.has(c) || s.unload();
|
|
879
884
|
t.current = l, r(Array.from(l.values()));
|
|
880
|
-
} catch (
|
|
881
|
-
qe("Error fetching all schema versions from database:",
|
|
885
|
+
} catch (a) {
|
|
886
|
+
qe("Error fetching all schema versions from database:", a), r(null);
|
|
882
887
|
}
|
|
883
888
|
}, [n]);
|
|
884
889
|
return I(() => {
|
|
885
890
|
n && i();
|
|
886
891
|
}, [n, i]), I(() => () => {
|
|
887
|
-
t.current.forEach((
|
|
888
|
-
|
|
892
|
+
t.current.forEach((a) => {
|
|
893
|
+
a.unload();
|
|
889
894
|
}), t.current.clear();
|
|
890
895
|
}, []), e;
|
|
891
|
-
},
|
|
892
|
-
const r =
|
|
893
|
-
data:
|
|
896
|
+
}, lr = () => yt(Je), mt = (e) => ["seed", "models", e], Ce = /* @__PURE__ */ new Map(), ht = (e) => {
|
|
897
|
+
const r = z(), t = X(), n = F([]), i = D(() => mt(e), [e]), {
|
|
898
|
+
data: a = [],
|
|
894
899
|
isLoading: o,
|
|
895
900
|
error: l
|
|
896
|
-
} =
|
|
901
|
+
} = Z({
|
|
897
902
|
queryKey: i,
|
|
898
903
|
queryFn: async () => {
|
|
899
|
-
const p = t.getQueryData(i), y = await
|
|
904
|
+
const p = t.getQueryData(i), y = await oe.all(e, { waitForReady: !1 });
|
|
900
905
|
if (Array.isArray(p) && p.length > 0 && Array.isArray(y) && y.length === 0)
|
|
901
906
|
return [...p];
|
|
902
907
|
if (Array.isArray(y) && y.length === 0) {
|
|
@@ -907,9 +912,9 @@ const rr = () => {
|
|
|
907
912
|
return y;
|
|
908
913
|
},
|
|
909
914
|
enabled: r && !!e
|
|
910
|
-
}),
|
|
911
|
-
|
|
912
|
-
const s = n.current.length > 0 ? n.current : Ce.get(
|
|
915
|
+
}), c = e && typeof e == "string" ? e : "";
|
|
916
|
+
a.length > 0 && Ce.set(c, a);
|
|
917
|
+
const s = n.current.length > 0 ? n.current : Ce.get(c), d = e ? a.length > 0 ? a : s?.length ? s : a : a;
|
|
913
918
|
n.current = d, I(() => {
|
|
914
919
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
915
920
|
const p = new BroadcastChannel("seed-models-invalidate"), y = (m) => {
|
|
@@ -920,16 +925,16 @@ const rr = () => {
|
|
|
920
925
|
p.removeEventListener("message", y), p.close();
|
|
921
926
|
};
|
|
922
927
|
}, [e, t, i]);
|
|
923
|
-
const u =
|
|
928
|
+
const u = F(null), f = F(null);
|
|
924
929
|
function h() {
|
|
925
930
|
const p = W.getAppDb();
|
|
926
931
|
return !p || !e ? null : p.select({
|
|
927
|
-
modelFileId:
|
|
928
|
-
modelName:
|
|
929
|
-
}).from(
|
|
930
|
-
|
|
931
|
-
O(
|
|
932
|
-
O(
|
|
932
|
+
modelFileId: ae.schemaFileId,
|
|
933
|
+
modelName: ae.name
|
|
934
|
+
}).from(Y).innerJoin(ge, O(Y.id, ge.schemaId)).innerJoin(ae, O(ge.modelId, ae.id)).where(
|
|
935
|
+
te(
|
|
936
|
+
O(Y.schemaFileId, e),
|
|
937
|
+
O(Y.name, e)
|
|
933
938
|
)
|
|
934
939
|
);
|
|
935
940
|
}
|
|
@@ -940,13 +945,13 @@ const rr = () => {
|
|
|
940
945
|
return f.current;
|
|
941
946
|
const m = h();
|
|
942
947
|
return m ? (u.current = p, f.current = m, m) : null;
|
|
943
|
-
}, [e, r]), v =
|
|
948
|
+
}, [e, r]), v = ie(b);
|
|
944
949
|
return I(() => {
|
|
945
950
|
if (!r || !v || !e) return;
|
|
946
951
|
const p = /* @__PURE__ */ new Set();
|
|
947
952
|
for (const g of n.current) {
|
|
948
|
-
const
|
|
949
|
-
|
|
953
|
+
const B = g.id || g.modelFileId;
|
|
954
|
+
B ? p.add(B) : g.modelName && p.add(g.modelName);
|
|
950
955
|
}
|
|
951
956
|
const y = /* @__PURE__ */ new Set();
|
|
952
957
|
for (const g of v)
|
|
@@ -958,20 +963,20 @@ const rr = () => {
|
|
|
958
963
|
isLoading: o,
|
|
959
964
|
error: l
|
|
960
965
|
};
|
|
961
|
-
},
|
|
962
|
-
const t =
|
|
966
|
+
}, gt = (e, r) => {
|
|
967
|
+
const t = z(), [n, i] = w(void 0), [a, o] = w(!1), [l, c] = w(null), s = F(void 0), [, d] = w(0), u = r == null;
|
|
963
968
|
if (D(() => t ? u ? !!e : !!(e && r) : !1, [t, u, e, r]), I(() => {
|
|
964
969
|
if (!t || !u || !e) {
|
|
965
|
-
i(void 0), o(!1),
|
|
970
|
+
i(void 0), o(!1), c(null);
|
|
966
971
|
return;
|
|
967
972
|
}
|
|
968
973
|
(async () => {
|
|
969
974
|
try {
|
|
970
|
-
o(!0),
|
|
971
|
-
const y = await
|
|
972
|
-
i(y || void 0), o(!1),
|
|
975
|
+
o(!0), c(null);
|
|
976
|
+
const y = await oe.createById(e);
|
|
977
|
+
i(y || void 0), o(!1), c(null);
|
|
973
978
|
} catch (y) {
|
|
974
|
-
console.error("[useModel] Error looking up model by ID:", y), i(void 0), o(!1),
|
|
979
|
+
console.error("[useModel] Error looking up model by ID:", y), i(void 0), o(!1), c(y);
|
|
975
980
|
}
|
|
976
981
|
})();
|
|
977
982
|
}, [t, u, e]), I(() => {
|
|
@@ -989,10 +994,10 @@ const rr = () => {
|
|
|
989
994
|
}, [u, n]), u)
|
|
990
995
|
return {
|
|
991
996
|
model: n,
|
|
992
|
-
isLoading:
|
|
997
|
+
isLoading: a,
|
|
993
998
|
error: l
|
|
994
999
|
};
|
|
995
|
-
const { models: f, isLoading: h, error: b } =
|
|
1000
|
+
const { models: f, isLoading: h, error: b } = ht(e), v = D(() => {
|
|
996
1001
|
if (r)
|
|
997
1002
|
return f.find((p) => (p.modelName ?? p.name) === r);
|
|
998
1003
|
}, [f, r]);
|
|
@@ -1013,11 +1018,11 @@ const rr = () => {
|
|
|
1013
1018
|
isLoading: h,
|
|
1014
1019
|
error: b
|
|
1015
1020
|
};
|
|
1016
|
-
},
|
|
1017
|
-
const e =
|
|
1018
|
-
(l,
|
|
1021
|
+
}, cr = () => {
|
|
1022
|
+
const e = F(void 0), [r, t] = w(!1), [n, i] = w(null), a = x(() => i(null), []), o = x(
|
|
1023
|
+
(l, c, s) => {
|
|
1019
1024
|
i(null), t(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
1020
|
-
const d =
|
|
1025
|
+
const d = oe.create(c, l, {
|
|
1021
1026
|
...s,
|
|
1022
1027
|
waitForReady: !1
|
|
1023
1028
|
}), u = d.getService().subscribe((f) => {
|
|
@@ -1035,9 +1040,9 @@ const rr = () => {
|
|
|
1035
1040
|
create: o,
|
|
1036
1041
|
isLoading: r,
|
|
1037
1042
|
error: n,
|
|
1038
|
-
resetError:
|
|
1043
|
+
resetError: a
|
|
1039
1044
|
};
|
|
1040
|
-
},
|
|
1045
|
+
}, dr = () => {
|
|
1041
1046
|
const [e, r] = w(null), [t, n] = w({
|
|
1042
1047
|
isLoading: !1,
|
|
1043
1048
|
error: null
|
|
@@ -1055,24 +1060,24 @@ const rr = () => {
|
|
|
1055
1060
|
});
|
|
1056
1061
|
};
|
|
1057
1062
|
l();
|
|
1058
|
-
const
|
|
1059
|
-
return () =>
|
|
1063
|
+
const c = o.subscribe(l);
|
|
1064
|
+
return () => c.unsubscribe();
|
|
1060
1065
|
}, [e]);
|
|
1061
1066
|
const i = x(async (o) => {
|
|
1062
1067
|
o && (r(o), await o.destroy());
|
|
1063
|
-
}, []),
|
|
1068
|
+
}, []), a = x(() => {
|
|
1064
1069
|
e && e.getService().send({ type: "clearDestroyError" });
|
|
1065
1070
|
}, [e]);
|
|
1066
1071
|
return {
|
|
1067
1072
|
destroy: i,
|
|
1068
1073
|
isLoading: t.isLoading,
|
|
1069
1074
|
error: t.error,
|
|
1070
|
-
resetError:
|
|
1075
|
+
resetError: a
|
|
1071
1076
|
};
|
|
1072
1077
|
};
|
|
1073
1078
|
J("seedSdk:browser:react:modelProperty");
|
|
1074
|
-
const
|
|
1075
|
-
const { model: t } =
|
|
1079
|
+
const ur = (e, r) => {
|
|
1080
|
+
const { model: t } = gt(e, r);
|
|
1076
1081
|
D(() => {
|
|
1077
1082
|
if (t)
|
|
1078
1083
|
try {
|
|
@@ -1081,7 +1086,7 @@ const dr = (e, r) => {
|
|
|
1081
1086
|
return;
|
|
1082
1087
|
}
|
|
1083
1088
|
}, [t]);
|
|
1084
|
-
const n =
|
|
1089
|
+
const n = z(), i = X(), a = D(() => {
|
|
1085
1090
|
if (!t) return null;
|
|
1086
1091
|
try {
|
|
1087
1092
|
return t._getSnapshotContext()._dbId;
|
|
@@ -1092,101 +1097,101 @@ const dr = (e, r) => {
|
|
|
1092
1097
|
() => ["seed", "modelProperties", o ?? ""],
|
|
1093
1098
|
[o]
|
|
1094
1099
|
), {
|
|
1095
|
-
data:
|
|
1100
|
+
data: c = [],
|
|
1096
1101
|
isLoading: s,
|
|
1097
1102
|
error: d
|
|
1098
|
-
} =
|
|
1103
|
+
} = Z({
|
|
1099
1104
|
queryKey: l,
|
|
1100
|
-
queryFn: () =>
|
|
1105
|
+
queryFn: () => fe.all(o, { waitForReady: !0 }),
|
|
1101
1106
|
enabled: n && !!o
|
|
1102
|
-
}), u = n ? W.getAppDb() : null, f = D(() => !u || !
|
|
1103
|
-
id:
|
|
1104
|
-
name:
|
|
1105
|
-
dataType:
|
|
1106
|
-
schemaFileId:
|
|
1107
|
-
}).from(
|
|
1108
|
-
b.current =
|
|
1109
|
-
if (!o ||
|
|
1107
|
+
}), u = n ? W.getAppDb() : null, f = D(() => !u || !a ? null : u.select({
|
|
1108
|
+
id: ee.id,
|
|
1109
|
+
name: ee.name,
|
|
1110
|
+
dataType: ee.dataType,
|
|
1111
|
+
schemaFileId: ee.schemaFileId
|
|
1112
|
+
}).from(ee).where(O(ee.modelId, a)), [u, n, a]), h = ie(f), b = F([]);
|
|
1113
|
+
b.current = c, I(() => {
|
|
1114
|
+
if (!o || c.length > 0 || !i || !l) return;
|
|
1110
1115
|
const y = [400, 1200, 2500].map(
|
|
1111
1116
|
(m) => setTimeout(() => {
|
|
1112
1117
|
i.invalidateQueries({ queryKey: l });
|
|
1113
1118
|
}, m)
|
|
1114
1119
|
);
|
|
1115
1120
|
return () => y.forEach((m) => clearTimeout(m));
|
|
1116
|
-
}, [o,
|
|
1121
|
+
}, [o, c.length, i, l]), I(() => {
|
|
1117
1122
|
if (!n || !t?.id || !h || !l) return;
|
|
1118
1123
|
const p = /* @__PURE__ */ new Set();
|
|
1119
1124
|
for (const g of b.current) {
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1125
|
+
const R = g._getSnapshotContext()?.id;
|
|
1126
|
+
R ? p.add(R) : g.name && p.add(g.name);
|
|
1122
1127
|
}
|
|
1123
1128
|
const y = /* @__PURE__ */ new Set();
|
|
1124
1129
|
for (const g of h)
|
|
1125
1130
|
g.schemaFileId ? y.add(g.schemaFileId) : g.name && y.add(g.name);
|
|
1126
1131
|
!(p.size === y.size && (p.size === 0 || [...p].every((g) => y.has(g)))) && (p.size > 0 || y.size > 0) && i.invalidateQueries({ queryKey: l });
|
|
1127
1132
|
}, [n, h, t?.id, i, l]);
|
|
1128
|
-
const v = s &&
|
|
1133
|
+
const v = s && c.length === 0;
|
|
1129
1134
|
return {
|
|
1130
|
-
modelProperties:
|
|
1135
|
+
modelProperties: c,
|
|
1131
1136
|
isLoading: v,
|
|
1132
1137
|
error: d
|
|
1133
1138
|
};
|
|
1134
|
-
},
|
|
1135
|
-
const t = await
|
|
1139
|
+
}, bt = async (e, r) => {
|
|
1140
|
+
const t = await oe.createById(e);
|
|
1136
1141
|
if (!t)
|
|
1137
1142
|
return;
|
|
1138
1143
|
const n = t.modelName ?? t.name;
|
|
1139
1144
|
if (n)
|
|
1140
1145
|
return ke(n, r);
|
|
1141
1146
|
};
|
|
1142
|
-
function
|
|
1143
|
-
const n = D(() => t != null ? !!(e && r && t) : r != null ? !!(e && r) : !!e, [e, r, t]), [i,
|
|
1147
|
+
function fr(e, r, t) {
|
|
1148
|
+
const n = D(() => t != null ? !!(e && r && t) : r != null ? !!(e && r) : !!e, [e, r, t]), [i, a] = w(void 0), [o, l] = w(n), [c, s] = w(null), d = F(void 0), u = z(), f = D(() => t != null ? { type: "schemaId", schemaId: e, modelName: r, propertyName: t } : r != null ? { type: "modelFileId", modelFileId: e, propertyName: r } : { type: "propertyFileId", propertyFileId: e }, [e, r, t]), h = D(() => u ? f.type === "propertyFileId" ? !!f.propertyFileId : f.type === "modelFileId" ? !!(f.modelFileId && f.propertyName) : !!(f.schemaId && f.modelName && f.propertyName) : !1, [u, f]), b = x(async () => {
|
|
1144
1149
|
if (!u) {
|
|
1145
|
-
|
|
1150
|
+
a(void 0), l(!1), s(null);
|
|
1146
1151
|
return;
|
|
1147
1152
|
}
|
|
1148
1153
|
let p, y;
|
|
1149
1154
|
try {
|
|
1150
1155
|
if (l(!0), s(null), f.type === "propertyFileId") {
|
|
1151
1156
|
if (!f.propertyFileId) {
|
|
1152
|
-
|
|
1157
|
+
a(void 0), l(!1), s(null);
|
|
1153
1158
|
return;
|
|
1154
1159
|
}
|
|
1155
|
-
const m = await
|
|
1156
|
-
m ? (
|
|
1160
|
+
const m = await fe.createById(f.propertyFileId);
|
|
1161
|
+
m ? (a(m), l(!1), s(null)) : (a(void 0), l(!1), s(null));
|
|
1157
1162
|
return;
|
|
1158
1163
|
} else if (f.type === "modelFileId") {
|
|
1159
1164
|
if (!f.modelFileId || !f.propertyName) {
|
|
1160
|
-
|
|
1165
|
+
a(void 0), l(!1), s(null);
|
|
1161
1166
|
return;
|
|
1162
1167
|
}
|
|
1163
|
-
p = await
|
|
1164
|
-
const m = await
|
|
1168
|
+
p = await bt(f.modelFileId, f.propertyName);
|
|
1169
|
+
const m = await oe.createById(f.modelFileId);
|
|
1165
1170
|
y = m?.modelName ?? m?.name;
|
|
1166
1171
|
} else {
|
|
1167
1172
|
if (!f.schemaId || !f.modelName || !f.propertyName) {
|
|
1168
|
-
|
|
1173
|
+
a(void 0), l(!1), s(null);
|
|
1169
1174
|
return;
|
|
1170
1175
|
}
|
|
1171
1176
|
p = await ke(f.modelName, f.propertyName), y = f.modelName;
|
|
1172
1177
|
}
|
|
1173
1178
|
if (p && y) {
|
|
1174
|
-
const m =
|
|
1179
|
+
const m = fe.create(
|
|
1175
1180
|
{ ...p, modelName: y },
|
|
1176
1181
|
{ waitForReady: !1 }
|
|
1177
1182
|
), E = m instanceof Promise ? await m : m;
|
|
1178
|
-
|
|
1179
|
-
|
|
1183
|
+
de(() => {
|
|
1184
|
+
a(E), l(!1), s(null);
|
|
1180
1185
|
});
|
|
1181
1186
|
} else
|
|
1182
|
-
|
|
1187
|
+
a(void 0), l(!1), s(null);
|
|
1183
1188
|
} catch (m) {
|
|
1184
|
-
console.error("[useModelProperty] Error updating model property:", m),
|
|
1189
|
+
console.error("[useModelProperty] Error updating model property:", m), a(void 0), l(!1), s(m);
|
|
1185
1190
|
}
|
|
1186
1191
|
}, [u, f.type, f.propertyFileId, f.modelFileId, f.propertyName, f.schemaId, f.modelName]);
|
|
1187
1192
|
I(() => {
|
|
1188
1193
|
if (!h) {
|
|
1189
|
-
|
|
1194
|
+
a(void 0), l(!1), s(null);
|
|
1190
1195
|
return;
|
|
1191
1196
|
}
|
|
1192
1197
|
b();
|
|
@@ -1205,18 +1210,18 @@ function ur(e, r, t) {
|
|
|
1205
1210
|
}, [i, b, v]), {
|
|
1206
1211
|
modelProperty: i,
|
|
1207
1212
|
isLoading: o,
|
|
1208
|
-
error:
|
|
1213
|
+
error: c
|
|
1209
1214
|
};
|
|
1210
1215
|
}
|
|
1211
|
-
const
|
|
1212
|
-
const e =
|
|
1213
|
-
(l,
|
|
1214
|
-
if (i(null), t(!0), e.current?.unsubscribe(), e.current = void 0, !
|
|
1216
|
+
const pr = () => {
|
|
1217
|
+
const e = F(void 0), [r, t] = w(!1), [n, i] = w(null), a = x(() => i(null), []), o = x(
|
|
1218
|
+
(l, c, s) => {
|
|
1219
|
+
if (i(null), t(!0), e.current?.unsubscribe(), e.current = void 0, !c || !s.name || !s.dataType) {
|
|
1215
1220
|
const h = new Error("modelName, property name and dataType are required");
|
|
1216
1221
|
throw i(h), t(!1), h;
|
|
1217
1222
|
}
|
|
1218
|
-
const d =
|
|
1219
|
-
{ ...s, modelName:
|
|
1223
|
+
const d = Ye(l) ?? l, u = fe.create(
|
|
1224
|
+
{ ...s, modelName: c },
|
|
1220
1225
|
{ waitForReady: !1, schemaName: d }
|
|
1221
1226
|
), f = u.getService().subscribe((h) => {
|
|
1222
1227
|
if (h.value === "error") {
|
|
@@ -1235,9 +1240,9 @@ const fr = () => {
|
|
|
1235
1240
|
create: o,
|
|
1236
1241
|
isLoading: r,
|
|
1237
1242
|
error: n,
|
|
1238
|
-
resetError:
|
|
1243
|
+
resetError: a
|
|
1239
1244
|
};
|
|
1240
|
-
},
|
|
1245
|
+
}, yr = () => {
|
|
1241
1246
|
const [e, r] = w(null), [t, n] = w({
|
|
1242
1247
|
isLoading: !1,
|
|
1243
1248
|
error: null
|
|
@@ -1255,21 +1260,21 @@ const fr = () => {
|
|
|
1255
1260
|
});
|
|
1256
1261
|
};
|
|
1257
1262
|
l();
|
|
1258
|
-
const
|
|
1259
|
-
return () =>
|
|
1263
|
+
const c = o.subscribe(l);
|
|
1264
|
+
return () => c.unsubscribe();
|
|
1260
1265
|
}, [e]);
|
|
1261
1266
|
const i = x(async (o) => {
|
|
1262
1267
|
o && (r(o), await o.destroy());
|
|
1263
|
-
}, []),
|
|
1268
|
+
}, []), a = x(() => {
|
|
1264
1269
|
e && e.getService().send({ type: "clearDestroyError" });
|
|
1265
1270
|
}, [e]);
|
|
1266
1271
|
return {
|
|
1267
1272
|
destroy: i,
|
|
1268
1273
|
isLoading: t.isLoading,
|
|
1269
1274
|
error: t.error,
|
|
1270
|
-
resetError:
|
|
1275
|
+
resetError: a
|
|
1271
1276
|
};
|
|
1272
|
-
},
|
|
1277
|
+
}, mr = () => {
|
|
1273
1278
|
const [e, r] = w(null), [t, n] = w({
|
|
1274
1279
|
isLoading: !1,
|
|
1275
1280
|
error: null
|
|
@@ -1287,77 +1292,77 @@ const fr = () => {
|
|
|
1287
1292
|
});
|
|
1288
1293
|
};
|
|
1289
1294
|
l();
|
|
1290
|
-
const
|
|
1291
|
-
return () =>
|
|
1295
|
+
const c = o.subscribe(l);
|
|
1296
|
+
return () => c.unsubscribe();
|
|
1292
1297
|
}, [e]);
|
|
1293
1298
|
const i = x(async (o) => {
|
|
1294
1299
|
o && (r(o), await o.destroy());
|
|
1295
|
-
}, []),
|
|
1300
|
+
}, []), a = x(() => {
|
|
1296
1301
|
e && e.getService().send({ type: "clearDestroyError" });
|
|
1297
1302
|
}, [e]);
|
|
1298
1303
|
return {
|
|
1299
1304
|
deleteItem: i,
|
|
1300
1305
|
isLoading: t.isLoading,
|
|
1301
1306
|
error: t.error,
|
|
1302
|
-
resetError:
|
|
1307
|
+
resetError: a
|
|
1303
1308
|
};
|
|
1304
1309
|
}, ve = ["seed", "imageFiles"];
|
|
1305
|
-
function
|
|
1306
|
-
const e =
|
|
1310
|
+
function hr() {
|
|
1311
|
+
const e = z(), r = X(), {
|
|
1307
1312
|
data: t = [],
|
|
1308
1313
|
isLoading: n,
|
|
1309
1314
|
error: i,
|
|
1310
|
-
refetch:
|
|
1311
|
-
} =
|
|
1315
|
+
refetch: a
|
|
1316
|
+
} = Z({
|
|
1312
1317
|
queryKey: ve,
|
|
1313
1318
|
queryFn: () => j.listImageFiles(),
|
|
1314
1319
|
enabled: e
|
|
1315
1320
|
});
|
|
1316
1321
|
return I(() => {
|
|
1317
|
-
const o = (
|
|
1318
|
-
|
|
1322
|
+
const o = (c) => {
|
|
1323
|
+
c.includes("/images/") && r.invalidateQueries({ queryKey: ve });
|
|
1319
1324
|
}, l = () => {
|
|
1320
1325
|
r.invalidateQueries({ queryKey: ve });
|
|
1321
1326
|
};
|
|
1322
|
-
return
|
|
1323
|
-
|
|
1327
|
+
return K.on("file-saved", o), K.on("fs.downloadAll.success", l), () => {
|
|
1328
|
+
K.off("file-saved", o), K.off("fs.downloadAll.success", l);
|
|
1324
1329
|
};
|
|
1325
1330
|
}, [r]), {
|
|
1326
1331
|
imageFiles: t,
|
|
1327
1332
|
isLoading: n,
|
|
1328
1333
|
error: i instanceof Error ? i : null,
|
|
1329
|
-
refetch:
|
|
1334
|
+
refetch: a
|
|
1330
1335
|
};
|
|
1331
1336
|
}
|
|
1332
|
-
const
|
|
1333
|
-
function
|
|
1334
|
-
const r =
|
|
1337
|
+
const vt = ["seed", "files"];
|
|
1338
|
+
function gr(e = "files") {
|
|
1339
|
+
const r = z(), t = X(), n = D(() => [...vt, e], [e]), {
|
|
1335
1340
|
data: i = [],
|
|
1336
|
-
isLoading:
|
|
1341
|
+
isLoading: a,
|
|
1337
1342
|
error: o,
|
|
1338
1343
|
refetch: l
|
|
1339
|
-
} =
|
|
1344
|
+
} = Z({
|
|
1340
1345
|
queryKey: n,
|
|
1341
1346
|
queryFn: () => j.listFiles(e),
|
|
1342
1347
|
enabled: r
|
|
1343
1348
|
});
|
|
1344
1349
|
return I(() => {
|
|
1345
|
-
const
|
|
1350
|
+
const c = (d) => {
|
|
1346
1351
|
d.includes(`/${e}/`) && t.invalidateQueries({ queryKey: n });
|
|
1347
1352
|
}, s = () => {
|
|
1348
1353
|
t.invalidateQueries({ queryKey: n });
|
|
1349
1354
|
};
|
|
1350
|
-
return
|
|
1351
|
-
|
|
1355
|
+
return K.on("file-saved", c), K.on("fs.downloadAll.success", s), () => {
|
|
1356
|
+
K.off("file-saved", c), K.off("fs.downloadAll.success", s);
|
|
1352
1357
|
};
|
|
1353
1358
|
}, [t, e, n]), {
|
|
1354
1359
|
files: i,
|
|
1355
|
-
isLoading:
|
|
1360
|
+
isLoading: a,
|
|
1356
1361
|
error: o instanceof Error ? o : null,
|
|
1357
1362
|
refetch: l
|
|
1358
1363
|
};
|
|
1359
1364
|
}
|
|
1360
|
-
const
|
|
1365
|
+
const St = {
|
|
1361
1366
|
queries: {
|
|
1362
1367
|
networkMode: "offlineFirst",
|
|
1363
1368
|
gcTime: 1e3 * 60 * 60 * 24,
|
|
@@ -1367,9 +1372,9 @@ const vt = {
|
|
|
1367
1372
|
}
|
|
1368
1373
|
};
|
|
1369
1374
|
function ze() {
|
|
1370
|
-
return { ...
|
|
1375
|
+
return { ...St };
|
|
1371
1376
|
}
|
|
1372
|
-
function
|
|
1377
|
+
function wt(e) {
|
|
1373
1378
|
const r = ze();
|
|
1374
1379
|
return e ? {
|
|
1375
1380
|
queries: {
|
|
@@ -1382,20 +1387,20 @@ function St(e) {
|
|
|
1382
1387
|
}
|
|
1383
1388
|
} : r;
|
|
1384
1389
|
}
|
|
1385
|
-
function
|
|
1390
|
+
function It(e) {
|
|
1386
1391
|
const r = ze(), { defaultOptions: t, ...n } = e ?? {};
|
|
1387
|
-
return new
|
|
1392
|
+
return new st({
|
|
1388
1393
|
...n,
|
|
1389
|
-
defaultOptions: t ?
|
|
1394
|
+
defaultOptions: t ? wt(t) : r
|
|
1390
1395
|
});
|
|
1391
1396
|
}
|
|
1392
1397
|
let xe = null;
|
|
1393
|
-
function
|
|
1398
|
+
function br(e) {
|
|
1394
1399
|
const r = xe?.(e);
|
|
1395
1400
|
return typeof window < "u" && window.__SEED_INVALIDATE_ITEM_PROPERTIES__ && window.__SEED_INVALIDATE_ITEM_PROPERTIES__(e), Promise.resolve(r).then(() => {
|
|
1396
1401
|
});
|
|
1397
1402
|
}
|
|
1398
|
-
function
|
|
1403
|
+
function Et({ queryClient: e }) {
|
|
1399
1404
|
return I(() => {
|
|
1400
1405
|
const r = (n) => {
|
|
1401
1406
|
const i = ["seed", "itemProperties", n];
|
|
@@ -1406,14 +1411,14 @@ function It({ queryClient: e }) {
|
|
|
1406
1411
|
const i = n?.seedLocalId ?? n?.seedUid;
|
|
1407
1412
|
i && r(i);
|
|
1408
1413
|
};
|
|
1409
|
-
return
|
|
1410
|
-
|
|
1414
|
+
return K.on("itemProperty.saved", t), () => {
|
|
1415
|
+
K.off("itemProperty.saved", t), xe = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
|
|
1411
1416
|
};
|
|
1412
1417
|
}, [e]), null;
|
|
1413
1418
|
}
|
|
1414
|
-
function
|
|
1419
|
+
function vr({ children: e, queryClient: r, queryClientRef: t }) {
|
|
1415
1420
|
const n = D(
|
|
1416
|
-
() => r ??
|
|
1421
|
+
() => r ?? It(),
|
|
1417
1422
|
[r]
|
|
1418
1423
|
);
|
|
1419
1424
|
if (t && (t.current = n, typeof window < "u")) {
|
|
@@ -1424,12 +1429,12 @@ function br({ children: e, queryClient: r, queryClientRef: t }) {
|
|
|
1424
1429
|
} catch {
|
|
1425
1430
|
}
|
|
1426
1431
|
}
|
|
1427
|
-
return /* @__PURE__ */
|
|
1428
|
-
/* @__PURE__ */ S(
|
|
1432
|
+
return /* @__PURE__ */ U(ot, { client: n, children: [
|
|
1433
|
+
/* @__PURE__ */ S(Et, { queryClient: n }),
|
|
1429
1434
|
e
|
|
1430
1435
|
] });
|
|
1431
1436
|
}
|
|
1432
|
-
function
|
|
1437
|
+
function Lt() {
|
|
1433
1438
|
return /* @__PURE__ */ S(
|
|
1434
1439
|
"div",
|
|
1435
1440
|
{
|
|
@@ -1444,15 +1449,15 @@ function Et() {
|
|
|
1444
1449
|
}
|
|
1445
1450
|
);
|
|
1446
1451
|
}
|
|
1447
|
-
function
|
|
1452
|
+
function Sr({
|
|
1448
1453
|
initConfig: e,
|
|
1449
1454
|
schema: r,
|
|
1450
1455
|
loadingComponent: t,
|
|
1451
1456
|
wrapperClassName: n,
|
|
1452
1457
|
loadingClassName: i,
|
|
1453
|
-
children:
|
|
1458
|
+
children: a
|
|
1454
1459
|
}) {
|
|
1455
|
-
const o =
|
|
1460
|
+
const o = z();
|
|
1456
1461
|
I(() => {
|
|
1457
1462
|
const u = r ? {
|
|
1458
1463
|
...e,
|
|
@@ -1461,9 +1466,9 @@ function vr({
|
|
|
1461
1466
|
schema: r
|
|
1462
1467
|
}
|
|
1463
1468
|
} : e;
|
|
1464
|
-
|
|
1469
|
+
Xe.init(u);
|
|
1465
1470
|
}, [e, r]);
|
|
1466
|
-
const l = t ?? /* @__PURE__ */ S(
|
|
1471
|
+
const l = t ?? /* @__PURE__ */ S(Lt, {}), c = n ? void 0 : { position: "relative", display: "flex", height: "100vh", width: "100vw" }, s = {
|
|
1467
1472
|
display: o ? "none" : "flex",
|
|
1468
1473
|
...!i && {
|
|
1469
1474
|
position: "absolute",
|
|
@@ -1473,7 +1478,7 @@ function vr({
|
|
|
1473
1478
|
justifyContent: "center"
|
|
1474
1479
|
}
|
|
1475
1480
|
};
|
|
1476
|
-
return /* @__PURE__ */
|
|
1481
|
+
return /* @__PURE__ */ U("div", { className: n, style: c, children: [
|
|
1477
1482
|
/* @__PURE__ */ S(
|
|
1478
1483
|
"div",
|
|
1479
1484
|
{
|
|
@@ -1487,29 +1492,29 @@ function vr({
|
|
|
1487
1492
|
flex: 1,
|
|
1488
1493
|
display: o ? "flex" : "none",
|
|
1489
1494
|
flexDirection: "column"
|
|
1490
|
-
}, children:
|
|
1495
|
+
}, children: a })
|
|
1491
1496
|
] });
|
|
1492
1497
|
}
|
|
1493
1498
|
async function He(e, r = "") {
|
|
1494
1499
|
const t = [];
|
|
1495
1500
|
try {
|
|
1496
1501
|
for await (const [n, i] of e.entries()) {
|
|
1497
|
-
const
|
|
1502
|
+
const a = r ? `${r}/${n}` : n;
|
|
1498
1503
|
if (i.kind === "file")
|
|
1499
1504
|
try {
|
|
1500
1505
|
const o = await i.getFile();
|
|
1501
1506
|
t.push({
|
|
1502
1507
|
name: n,
|
|
1503
|
-
path:
|
|
1508
|
+
path: a,
|
|
1504
1509
|
size: o.size,
|
|
1505
1510
|
type: o.type || "application/octet-stream",
|
|
1506
1511
|
lastModified: o.lastModified
|
|
1507
1512
|
});
|
|
1508
1513
|
} catch (o) {
|
|
1509
|
-
console.warn(`Failed to read file ${
|
|
1514
|
+
console.warn(`Failed to read file ${a}:`, o);
|
|
1510
1515
|
}
|
|
1511
1516
|
else if (i.kind === "directory") {
|
|
1512
|
-
const o = await He(i,
|
|
1517
|
+
const o = await He(i, a);
|
|
1513
1518
|
t.push(...o);
|
|
1514
1519
|
}
|
|
1515
1520
|
}
|
|
@@ -1518,9 +1523,9 @@ async function He(e, r = "") {
|
|
|
1518
1523
|
}
|
|
1519
1524
|
return t;
|
|
1520
1525
|
}
|
|
1521
|
-
function
|
|
1522
|
-
const { rootPath: r } = e, [t, n] = w([]), [i,
|
|
1523
|
-
|
|
1526
|
+
function xt(e = {}) {
|
|
1527
|
+
const { rootPath: r } = e, [t, n] = w([]), [i, a] = w(!0), [o, l] = w(null), c = x(async () => {
|
|
1528
|
+
a(!0), l(null);
|
|
1524
1529
|
try {
|
|
1525
1530
|
let d = await navigator.storage.getDirectory();
|
|
1526
1531
|
if (r) {
|
|
@@ -1535,14 +1540,14 @@ function Lt(e = {}) {
|
|
|
1535
1540
|
"Failed to access OPFS: " + (s instanceof Error ? s.message : String(s))
|
|
1536
1541
|
), console.error("OPFS access error:", s);
|
|
1537
1542
|
} finally {
|
|
1538
|
-
|
|
1543
|
+
a(!1);
|
|
1539
1544
|
}
|
|
1540
1545
|
}, [r]);
|
|
1541
1546
|
return I(() => {
|
|
1542
|
-
|
|
1543
|
-
}, [
|
|
1547
|
+
c();
|
|
1548
|
+
}, [c]), { files: t, isLoading: i, error: o, refetch: c };
|
|
1544
1549
|
}
|
|
1545
|
-
const Pe = () => /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ S("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" }) }),
|
|
1550
|
+
const Pe = () => /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ S("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" }) }), Nt = () => /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 48, height: 48 }, children: /* @__PURE__ */ S("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M2.25 12.75V12a2.25 2.25 0 012.25-2.25h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z" }) }), At = () => /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ S("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" }) }), Re = () => /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", style: { width: 20, height: 20 }, children: /* @__PURE__ */ S("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" }) }), _t = () => /* @__PURE__ */ U(
|
|
1546
1551
|
"svg",
|
|
1547
1552
|
{
|
|
1548
1553
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1578,10 +1583,10 @@ function Dt(e) {
|
|
|
1578
1583
|
const r = 1024, t = ["Bytes", "KB", "MB", "GB"], n = Math.floor(Math.log(e) / Math.log(r));
|
|
1579
1584
|
return Math.round(e / Math.pow(r, n) * 100) / 100 + " " + t[n];
|
|
1580
1585
|
}
|
|
1581
|
-
function
|
|
1586
|
+
function Ft(e) {
|
|
1582
1587
|
return new Date(e).toLocaleString();
|
|
1583
1588
|
}
|
|
1584
|
-
async function
|
|
1589
|
+
async function Ct(e, r) {
|
|
1585
1590
|
const t = e.path.split("/").filter(Boolean);
|
|
1586
1591
|
if (t.length === 0) throw new Error("Invalid file path");
|
|
1587
1592
|
let n = r;
|
|
@@ -1594,12 +1599,12 @@ async function Me(e, r) {
|
|
|
1594
1599
|
const t = e.split("/").filter(Boolean);
|
|
1595
1600
|
if (t.length === 0) throw new Error("Invalid file path");
|
|
1596
1601
|
let n = r;
|
|
1597
|
-
for (let
|
|
1598
|
-
n = await n.getDirectoryHandle(t[
|
|
1602
|
+
for (let a = 0; a < t.length - 1; a++)
|
|
1603
|
+
n = await n.getDirectoryHandle(t[a]);
|
|
1599
1604
|
const i = t[t.length - 1];
|
|
1600
1605
|
await n.removeEntry(i);
|
|
1601
1606
|
}
|
|
1602
|
-
const
|
|
1607
|
+
const Pt = {
|
|
1603
1608
|
light: {
|
|
1604
1609
|
title: "text-gray-900",
|
|
1605
1610
|
description: "text-gray-500",
|
|
@@ -1644,7 +1649,7 @@ const Ct = {
|
|
|
1644
1649
|
actionButton: "text-gray-400 hover:text-indigo-400",
|
|
1645
1650
|
deleteButton: "text-gray-400 hover:text-red-500"
|
|
1646
1651
|
}
|
|
1647
|
-
},
|
|
1652
|
+
}, P = {
|
|
1648
1653
|
container: { padding: "2rem 0" },
|
|
1649
1654
|
header: {
|
|
1650
1655
|
display: "flex",
|
|
@@ -1663,23 +1668,23 @@ const Ct = {
|
|
|
1663
1668
|
errorBox: "rounded-md border p-4 mt-4",
|
|
1664
1669
|
emptyState: "text-center py-12"
|
|
1665
1670
|
};
|
|
1666
|
-
function
|
|
1671
|
+
function wr({
|
|
1667
1672
|
rootPath: e,
|
|
1668
1673
|
filter: r,
|
|
1669
1674
|
onBeforeDelete: t,
|
|
1670
1675
|
onAfterDelete: n,
|
|
1671
1676
|
onDownload: i,
|
|
1672
|
-
title:
|
|
1677
|
+
title: a = "Files",
|
|
1673
1678
|
description: o = "Browse and download all files stored in the Origin Private File System (OPFS).",
|
|
1674
1679
|
theme: l = "dark",
|
|
1675
|
-
className:
|
|
1680
|
+
className: c
|
|
1676
1681
|
}) {
|
|
1677
|
-
const s =
|
|
1678
|
-
p((
|
|
1679
|
-
const
|
|
1680
|
-
return
|
|
1682
|
+
const s = Pt[l], { files: d, isLoading: u, error: f, refetch: h } = xt({ rootPath: e }), b = r ? d.filter(r) : d, [v, p] = w(/* @__PURE__ */ new Set()), y = F(null), m = b.length > 0 && v.size === b.length, E = v.size > 0 && v.size < b.length, g = (L) => {
|
|
1683
|
+
p((k) => {
|
|
1684
|
+
const _ = new Set(k);
|
|
1685
|
+
return _.has(L) ? _.delete(L) : _.add(L), _;
|
|
1681
1686
|
});
|
|
1682
|
-
},
|
|
1687
|
+
}, B = () => {
|
|
1683
1688
|
p(
|
|
1684
1689
|
v.size === b.length ? /* @__PURE__ */ new Set() : new Set(b.map((L) => L.path))
|
|
1685
1690
|
);
|
|
@@ -1689,88 +1694,88 @@ function Sr({
|
|
|
1689
1694
|
}, [b.length]), I(() => {
|
|
1690
1695
|
y.current && (y.current.indeterminate = E);
|
|
1691
1696
|
}, [E]);
|
|
1692
|
-
const
|
|
1697
|
+
const R = async (L, k = !1) => {
|
|
1693
1698
|
try {
|
|
1694
|
-
const
|
|
1699
|
+
const _ = await navigator.storage.getDirectory(), q = await Ct(L, _);
|
|
1695
1700
|
if (i)
|
|
1696
|
-
await i(L,
|
|
1701
|
+
await i(L, q);
|
|
1697
1702
|
else {
|
|
1698
|
-
const
|
|
1699
|
-
|
|
1703
|
+
const V = URL.createObjectURL(q), M = document.createElement("a");
|
|
1704
|
+
M.href = V, M.download = L.name, document.body.appendChild(M), M.click(), document.body.removeChild(M), URL.revokeObjectURL(V);
|
|
1700
1705
|
}
|
|
1701
|
-
} catch (
|
|
1702
|
-
const
|
|
1703
|
-
throw
|
|
1706
|
+
} catch (_) {
|
|
1707
|
+
const q = "Failed to download file: " + (_ instanceof Error ? _.message : String(_));
|
|
1708
|
+
throw k || alert(q), _;
|
|
1704
1709
|
}
|
|
1705
|
-
},
|
|
1710
|
+
}, N = async (L) => {
|
|
1706
1711
|
if (!(t && !await t(L)) && confirm(`Are you sure you want to delete "${L.name}"? This action cannot be undone.`))
|
|
1707
1712
|
try {
|
|
1708
|
-
const
|
|
1709
|
-
await Me(L.path,
|
|
1710
|
-
} catch (
|
|
1711
|
-
alert("Failed to delete file: " + (
|
|
1713
|
+
const k = await navigator.storage.getDirectory();
|
|
1714
|
+
await Me(L.path, k), await h(), await n?.([L.path]);
|
|
1715
|
+
} catch (k) {
|
|
1716
|
+
alert("Failed to delete file: " + (k instanceof Error ? k.message : String(k)));
|
|
1712
1717
|
}
|
|
1713
|
-
},
|
|
1718
|
+
}, H = async () => {
|
|
1714
1719
|
if (v.size === 0) return;
|
|
1715
|
-
const L = b.filter((
|
|
1716
|
-
for (const
|
|
1720
|
+
const L = b.filter((_) => v.has(_.path)), k = [];
|
|
1721
|
+
for (const _ of L)
|
|
1717
1722
|
try {
|
|
1718
|
-
await
|
|
1719
|
-
} catch (
|
|
1720
|
-
|
|
1723
|
+
await R(_, !0), await new Promise((q) => setTimeout(q, 100));
|
|
1724
|
+
} catch (q) {
|
|
1725
|
+
k.push(`${_.name}: ${q instanceof Error ? q.message : String(q)}`);
|
|
1721
1726
|
}
|
|
1722
|
-
|
|
1723
|
-
${
|
|
1727
|
+
k.length > 0 && alert(`Some downloads failed:
|
|
1728
|
+
${k.join(`
|
|
1724
1729
|
`)}`);
|
|
1725
|
-
},
|
|
1730
|
+
}, Q = async () => {
|
|
1726
1731
|
if (v.size === 0) return;
|
|
1727
|
-
const L = b.filter((
|
|
1732
|
+
const L = b.filter((M) => v.has(M.path)), k = L.map((M) => M.name).join(", ");
|
|
1728
1733
|
if (!confirm(
|
|
1729
1734
|
`Are you sure you want to delete ${v.size} file(s)?
|
|
1730
1735
|
|
|
1731
|
-
Files: ${
|
|
1736
|
+
Files: ${k}
|
|
1732
1737
|
|
|
1733
1738
|
This action cannot be undone.`
|
|
1734
1739
|
))
|
|
1735
1740
|
return;
|
|
1736
|
-
const
|
|
1737
|
-
for (const
|
|
1738
|
-
if (!(t && !await t(
|
|
1741
|
+
const _ = await navigator.storage.getDirectory(), q = [], V = [];
|
|
1742
|
+
for (const M of L)
|
|
1743
|
+
if (!(t && !await t(M)))
|
|
1739
1744
|
try {
|
|
1740
|
-
await Me(
|
|
1741
|
-
} catch (
|
|
1742
|
-
|
|
1745
|
+
await Me(M.path, _), q.push(M.path);
|
|
1746
|
+
} catch (G) {
|
|
1747
|
+
V.push(`${M.name}: ${G instanceof Error ? G.message : String(G)}`);
|
|
1743
1748
|
}
|
|
1744
|
-
p(/* @__PURE__ */ new Set()), await h(),
|
|
1745
|
-
${
|
|
1749
|
+
p(/* @__PURE__ */ new Set()), await h(), q.length > 0 && await n?.(q), V.length > 0 && alert(`Some deletions failed:
|
|
1750
|
+
${V.join(`
|
|
1746
1751
|
`)}`);
|
|
1747
1752
|
};
|
|
1748
|
-
return /* @__PURE__ */
|
|
1753
|
+
return /* @__PURE__ */ U("div", { className: c, style: P.container, children: [
|
|
1749
1754
|
/* @__PURE__ */ S("style", { children: "@keyframes opfs-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}" }),
|
|
1750
|
-
/* @__PURE__ */
|
|
1751
|
-
/* @__PURE__ */
|
|
1752
|
-
/* @__PURE__ */ S("h1", { style:
|
|
1753
|
-
/* @__PURE__ */ S("p", { style:
|
|
1755
|
+
/* @__PURE__ */ U("div", { style: P.header, children: [
|
|
1756
|
+
/* @__PURE__ */ U("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
1757
|
+
/* @__PURE__ */ S("h1", { style: P.title, className: s.title, children: a }),
|
|
1758
|
+
/* @__PURE__ */ S("p", { style: P.description, className: s.description, children: o })
|
|
1754
1759
|
] }),
|
|
1755
|
-
/* @__PURE__ */ S("button", { type: "button", onClick: h, className:
|
|
1760
|
+
/* @__PURE__ */ S("button", { type: "button", onClick: h, className: P.button, children: "Refresh" })
|
|
1756
1761
|
] }),
|
|
1757
|
-
v.size > 0 && /* @__PURE__ */
|
|
1762
|
+
v.size > 0 && /* @__PURE__ */ U(
|
|
1758
1763
|
"div",
|
|
1759
1764
|
{
|
|
1760
1765
|
className: `mt-4 flex items-center justify-between rounded-lg border px-4 py-3 ${s.batchBar}`,
|
|
1761
1766
|
children: [
|
|
1762
|
-
/* @__PURE__ */
|
|
1767
|
+
/* @__PURE__ */ U("span", { className: `text-sm font-medium ${s.batchText}`, children: [
|
|
1763
1768
|
v.size,
|
|
1764
1769
|
" file",
|
|
1765
1770
|
v.size === 1 ? "" : "s",
|
|
1766
1771
|
" selected"
|
|
1767
1772
|
] }),
|
|
1768
|
-
/* @__PURE__ */
|
|
1769
|
-
/* @__PURE__ */ S("button", { onClick:
|
|
1773
|
+
/* @__PURE__ */ U("div", { className: "flex items-center gap-3", children: [
|
|
1774
|
+
/* @__PURE__ */ S("button", { onClick: H, className: P.button, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
|
|
1770
1775
|
/* @__PURE__ */ S(Pe, {}),
|
|
1771
1776
|
" Download All"
|
|
1772
1777
|
] }) }),
|
|
1773
|
-
/* @__PURE__ */ S("button", { onClick:
|
|
1778
|
+
/* @__PURE__ */ S("button", { onClick: Q, className: P.buttonDanger, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
|
|
1774
1779
|
/* @__PURE__ */ S(Re, {}),
|
|
1775
1780
|
" Delete All"
|
|
1776
1781
|
] }) }),
|
|
@@ -1786,43 +1791,43 @@ ${Q.join(`
|
|
|
1786
1791
|
]
|
|
1787
1792
|
}
|
|
1788
1793
|
),
|
|
1789
|
-
/* @__PURE__ */ S("div", { className: "mt-8", children: u ? /* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */ S("span", { style: { animation: "opfs-spin 1s linear infinite" }, children: /* @__PURE__ */ S(
|
|
1794
|
+
/* @__PURE__ */ S("div", { className: "mt-8", children: u ? /* @__PURE__ */ U("div", { className: "flex justify-center items-center py-12 gap-3", children: [
|
|
1795
|
+
/* @__PURE__ */ S("span", { style: { animation: "opfs-spin 1s linear infinite" }, children: /* @__PURE__ */ S(_t, {}) }),
|
|
1791
1796
|
/* @__PURE__ */ S("span", { className: s.loadingText, children: "Loading files..." })
|
|
1792
|
-
] }) : f ? /* @__PURE__ */
|
|
1797
|
+
] }) : f ? /* @__PURE__ */ U("div", { className: `${P.errorBox} ${s.errorBox}`, children: [
|
|
1793
1798
|
/* @__PURE__ */ S("h3", { className: `m-0 text-sm font-medium ${s.errorTitle}`, children: "Error" }),
|
|
1794
1799
|
/* @__PURE__ */ S("div", { className: `mt-2 text-sm ${s.errorText}`, children: f })
|
|
1795
|
-
] }) : b.length === 0 ? /* @__PURE__ */
|
|
1796
|
-
/* @__PURE__ */ S("span", { className: s.emptyIcon, children: /* @__PURE__ */ S(
|
|
1800
|
+
] }) : b.length === 0 ? /* @__PURE__ */ U("div", { className: P.emptyState, children: [
|
|
1801
|
+
/* @__PURE__ */ S("span", { className: s.emptyIcon, children: /* @__PURE__ */ S(Nt, {}) }),
|
|
1797
1802
|
/* @__PURE__ */ S("h3", { className: `mt-2 text-sm font-semibold ${s.emptyTitle}`, children: "No files" }),
|
|
1798
1803
|
/* @__PURE__ */ S("p", { className: `mt-1 text-sm ${s.emptyText}`, children: "No files found in OPFS." })
|
|
1799
|
-
] }) : /* @__PURE__ */ S("div", { className: "overflow-x-auto", children: /* @__PURE__ */
|
|
1800
|
-
/* @__PURE__ */ S("thead", { children: /* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1804
|
+
] }) : /* @__PURE__ */ S("div", { className: "overflow-x-auto", children: /* @__PURE__ */ U("table", { className: P.table, children: [
|
|
1805
|
+
/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ U("tr", { className: s.tableBorder, children: [
|
|
1806
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} w-10 ${s.tableHeader}`, children: /* @__PURE__ */ S(
|
|
1802
1807
|
"input",
|
|
1803
1808
|
{
|
|
1804
1809
|
ref: y,
|
|
1805
1810
|
type: "checkbox",
|
|
1806
1811
|
checked: m,
|
|
1807
|
-
onChange:
|
|
1812
|
+
onChange: B,
|
|
1808
1813
|
"aria-label": "Select all"
|
|
1809
1814
|
}
|
|
1810
1815
|
) }),
|
|
1811
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1812
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1813
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1814
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1815
|
-
/* @__PURE__ */ S("th", { className: `${
|
|
1816
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} ${s.tableHeader}`, children: "Name" }),
|
|
1817
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} ${s.tableHeader}`, children: "Path" }),
|
|
1818
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} ${s.tableHeader}`, children: "Size" }),
|
|
1819
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} ${s.tableHeader}`, children: "Type" }),
|
|
1820
|
+
/* @__PURE__ */ S("th", { className: `${P.tableHeader} ${s.tableHeader}`, children: "Modified" }),
|
|
1816
1821
|
/* @__PURE__ */ S(
|
|
1817
1822
|
"th",
|
|
1818
1823
|
{
|
|
1819
|
-
className: `${
|
|
1824
|
+
className: `${P.tableHeader} w-24 ${s.tableHeader}`,
|
|
1820
1825
|
"aria-label": "Actions"
|
|
1821
1826
|
}
|
|
1822
1827
|
)
|
|
1823
1828
|
] }) }),
|
|
1824
|
-
/* @__PURE__ */ S("tbody", { className: `divide-y ${s.tableBorder}`, children: b.map((L) => /* @__PURE__ */
|
|
1825
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1829
|
+
/* @__PURE__ */ S("tbody", { className: `divide-y ${s.tableBorder}`, children: b.map((L) => /* @__PURE__ */ U("tr", { className: s.tableRow, children: [
|
|
1830
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCell}`, children: /* @__PURE__ */ S(
|
|
1826
1831
|
"input",
|
|
1827
1832
|
{
|
|
1828
1833
|
type: "checkbox",
|
|
@@ -1831,20 +1836,20 @@ ${Q.join(`
|
|
|
1831
1836
|
"aria-label": `Select ${L.name}`
|
|
1832
1837
|
}
|
|
1833
1838
|
) }),
|
|
1834
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1835
|
-
/* @__PURE__ */ S(
|
|
1839
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCell}`, children: /* @__PURE__ */ U("span", { className: "flex items-center gap-2", children: [
|
|
1840
|
+
/* @__PURE__ */ S(At, {}),
|
|
1836
1841
|
L.name
|
|
1837
1842
|
] }) }),
|
|
1838
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1839
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1840
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1841
|
-
/* @__PURE__ */ S("td", { className: `${
|
|
1842
|
-
/* @__PURE__ */ S("td", { className:
|
|
1843
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCellMuted}`, children: /* @__PURE__ */ S("code", { className: `text-xs px-2 py-1 rounded border ${s.codeBlock}`, children: L.path }) }),
|
|
1844
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCellMuted}`, children: Dt(L.size) }),
|
|
1845
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCellMuted}`, children: L.type }),
|
|
1846
|
+
/* @__PURE__ */ S("td", { className: `${P.tableCell} ${s.tableCellMuted}`, children: Ft(L.lastModified) }),
|
|
1847
|
+
/* @__PURE__ */ S("td", { className: P.tableCell, children: /* @__PURE__ */ U("div", { className: "flex gap-2 justify-end", children: [
|
|
1843
1848
|
/* @__PURE__ */ S(
|
|
1844
1849
|
"button",
|
|
1845
1850
|
{
|
|
1846
1851
|
type: "button",
|
|
1847
|
-
onClick: () =>
|
|
1852
|
+
onClick: () => R(L),
|
|
1848
1853
|
title: "Download",
|
|
1849
1854
|
className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${s.actionButton}`,
|
|
1850
1855
|
children: /* @__PURE__ */ S(Pe, {})
|
|
@@ -1854,7 +1859,7 @@ ${Q.join(`
|
|
|
1854
1859
|
"button",
|
|
1855
1860
|
{
|
|
1856
1861
|
type: "button",
|
|
1857
|
-
onClick: () =>
|
|
1862
|
+
onClick: () => N(L),
|
|
1858
1863
|
title: "Delete",
|
|
1859
1864
|
className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${s.deleteButton}`,
|
|
1860
1865
|
children: /* @__PURE__ */ S(Re, {})
|
|
@@ -1865,65 +1870,71 @@ ${Q.join(`
|
|
|
1865
1870
|
] }) }) })
|
|
1866
1871
|
] });
|
|
1867
1872
|
}
|
|
1868
|
-
const Se = J("seedSdk:react:SeedImage"),
|
|
1873
|
+
const Se = J("seedSdk:react:SeedImage"), ce = /* @__PURE__ */ new Map(), Qe = (e) => {
|
|
1869
1874
|
const r = /^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/, t = e.match(r);
|
|
1870
1875
|
return t && t[2] ? t[2] : e;
|
|
1871
1876
|
};
|
|
1872
|
-
function
|
|
1877
|
+
function Rt(e) {
|
|
1873
1878
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1874
1879
|
}
|
|
1875
|
-
function
|
|
1876
|
-
const t = new RegExp(`^${
|
|
1880
|
+
function Mt(e, r) {
|
|
1881
|
+
const t = new RegExp(`^${Rt(r)}$`), n = Qe(e);
|
|
1877
1882
|
return t.test(n);
|
|
1878
1883
|
}
|
|
1879
|
-
const
|
|
1880
|
-
const [i,
|
|
1884
|
+
const Tt = ({ imageProperty: e, width: r, filename: t, ...n }) => {
|
|
1885
|
+
const [i, a] = w(), [o, l] = w(), { property: c } = Ue({
|
|
1881
1886
|
propertyName: e.propertyName,
|
|
1882
1887
|
seedLocalId: e.seedLocalId,
|
|
1883
1888
|
seedUid: e.seedUid
|
|
1884
|
-
}), s = e ??
|
|
1889
|
+
}), s = e ?? c, d = t ?? s?.refResolvedValue ?? s?.value, u = s?.value, f = typeof u == "string" ? u : d, h = u != null && (u instanceof File || u instanceof Blob), [b, v] = w(null), p = Te.useRef(null);
|
|
1885
1890
|
I(() => {
|
|
1886
1891
|
if (h && (u instanceof File || u instanceof Blob))
|
|
1887
1892
|
return p.current || (p.current = URL.createObjectURL(u), v(p.current)), () => {
|
|
1888
1893
|
p.current && (URL.revokeObjectURL(p.current), p.current = null), v(null);
|
|
1889
1894
|
};
|
|
1890
1895
|
p.current = null, v(null);
|
|
1891
|
-
}, [h, u]), I(() =>
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1896
|
+
}, [h, u]), I(() => {
|
|
1897
|
+
if (!d || u && ((N) => typeof N == "string" && N.startsWith("blob:"))(u) || b) return;
|
|
1898
|
+
let B = !1;
|
|
1899
|
+
return (async () => {
|
|
1900
|
+
try {
|
|
1901
|
+
const N = s?.localStoragePath ? s.localStoragePath : `${j.getFilesPath("images")}/${d}`;
|
|
1902
|
+
if (await j.pathExists(N)) {
|
|
1903
|
+
const Q = await j.getContentUrlFromPath(N);
|
|
1904
|
+
!B && Q && l(Q);
|
|
1905
|
+
}
|
|
1906
|
+
} catch (N) {
|
|
1907
|
+
Se("_getOriginalContentUrl error", N);
|
|
1897
1908
|
}
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1909
|
+
})(), () => {
|
|
1910
|
+
B = !0;
|
|
1911
|
+
};
|
|
1912
|
+
}, [d, u, b, s?.localStoragePath]), I(() => {
|
|
1902
1913
|
if (!r || !d)
|
|
1903
1914
|
return;
|
|
1904
1915
|
(async () => {
|
|
1905
1916
|
try {
|
|
1906
|
-
const
|
|
1907
|
-
if (
|
|
1917
|
+
const B = await j.getFs(), R = s?.localStoragePath ? s.localStoragePath.split("/").slice(0, -1).join("/") : j.getFilesPath("images"), Q = B.readdirSync(R, { withFileTypes: !0 }).filter(($) => $.isDirectory()).map(($) => parseInt($.name)), L = Q.reduce(($, re) => Math.abs(re - r) < Math.abs($ - r) ? re : $, Q[0]), k = Qe(d), _ = `${k}-${L}`;
|
|
1918
|
+
if (ce.has(_))
|
|
1908
1919
|
try {
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1911
|
-
|
|
1920
|
+
const $ = ce.get(_);
|
|
1921
|
+
if ($ && (await fetch($)).ok) {
|
|
1922
|
+
a($);
|
|
1912
1923
|
return;
|
|
1913
1924
|
}
|
|
1914
|
-
} catch (
|
|
1915
|
-
Se("error",
|
|
1925
|
+
} catch ($) {
|
|
1926
|
+
Se("error", $), ce.delete(_);
|
|
1916
1927
|
}
|
|
1917
|
-
const
|
|
1918
|
-
if (!
|
|
1928
|
+
const V = B.readdirSync(`${R}/${L}`, { withFileTypes: !0 }).find(($) => $.name ? Mt($.name, k) : !1);
|
|
1929
|
+
if (!V)
|
|
1919
1930
|
return;
|
|
1920
|
-
const
|
|
1921
|
-
if (await j.pathExists(
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1931
|
+
const M = `${R}/${L}/${V?.name}`;
|
|
1932
|
+
if (await j.pathExists(M)) {
|
|
1933
|
+
const $ = await j.getContentUrlFromPath(M);
|
|
1934
|
+
$ && (ce.set(_, $), a($));
|
|
1924
1935
|
}
|
|
1925
|
-
} catch (
|
|
1926
|
-
Se("_getSizedContentUrl error",
|
|
1936
|
+
} catch (B) {
|
|
1937
|
+
Se("_getSizedContentUrl error", B);
|
|
1927
1938
|
}
|
|
1928
1939
|
})();
|
|
1929
1940
|
}, [s, r, f, d]);
|
|
@@ -1932,57 +1943,57 @@ const Mt = ({ imageProperty: e, width: r, filename: t, ...n }) => {
|
|
|
1932
1943
|
return null;
|
|
1933
1944
|
const E = i || o || b || (y(f) ? f : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
1934
1945
|
return /* @__PURE__ */ S("img", { src: E, alt: n.alt || e.propertyName || "Image", ...n });
|
|
1935
|
-
},
|
|
1936
|
-
|
|
1946
|
+
}, Ir = Te.memo(
|
|
1947
|
+
Tt,
|
|
1937
1948
|
(e, r) => e.imageProperty === r.imageProperty && e.width === r.width && e.filename === r.filename
|
|
1938
1949
|
);
|
|
1939
1950
|
export {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1951
|
+
vt as FILES_QUERY_KEY_PREFIX,
|
|
1952
|
+
wr as OPFSFilesManager,
|
|
1953
|
+
Sr as SeedClientGate,
|
|
1954
|
+
Ir as SeedImage,
|
|
1955
|
+
vr as SeedProvider,
|
|
1956
|
+
It as createSeedQueryClient,
|
|
1946
1957
|
ze as getSeedQueryDefaultOptions,
|
|
1947
1958
|
Oe as getServiceName,
|
|
1948
1959
|
Ae as getServiceUniqueKey,
|
|
1949
1960
|
Fe as getServiceValue,
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1961
|
+
br as invalidateItemPropertiesForItem,
|
|
1962
|
+
wt as mergeSeedQueryDefaults,
|
|
1963
|
+
ar as useAllSchemaVersions,
|
|
1964
|
+
Gt as useCreateItem,
|
|
1965
|
+
Zt as useCreateItemProperty,
|
|
1966
|
+
cr as useCreateModel,
|
|
1967
|
+
pr as useCreateModelProperty,
|
|
1968
|
+
or as useCreateSchema,
|
|
1969
|
+
nr as useDbsAreReady,
|
|
1970
|
+
Yt as useDebouncedItemProperty,
|
|
1971
|
+
mr as useDeleteItem,
|
|
1972
|
+
er as useDestroyItemProperty,
|
|
1973
|
+
dr as useDestroyModel,
|
|
1974
|
+
yr as useDestroyModelProperty,
|
|
1975
|
+
ir as useDestroySchema,
|
|
1976
|
+
gr as useFiles,
|
|
1977
|
+
pt as useGlobalServiceStatus,
|
|
1978
|
+
ut as useHasSavedSnapshots,
|
|
1979
|
+
hr as useImageFiles,
|
|
1980
|
+
dt as useIsDbReady,
|
|
1981
|
+
jt as useItem,
|
|
1982
|
+
Xt as useItemProperties,
|
|
1972
1983
|
Ue as useItemProperty,
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1984
|
+
Wt as useItems,
|
|
1985
|
+
ie as useLiveQuery,
|
|
1986
|
+
gt as useModel,
|
|
1987
|
+
ur as useModelProperties,
|
|
1988
|
+
fr as useModelProperty,
|
|
1989
|
+
ht as useModels,
|
|
1990
|
+
xt as useOPFSFiles,
|
|
1991
|
+
rr as usePersistedSnapshots,
|
|
1981
1992
|
Jt as usePublishItem,
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1993
|
+
yt as useSchema,
|
|
1994
|
+
sr as useSchemas,
|
|
1995
|
+
lr as useSeedProtocolSchema,
|
|
1996
|
+
tr as useService,
|
|
1997
|
+
ft as useServices
|
|
1987
1998
|
};
|
|
1988
1999
|
//# sourceMappingURL=index.js.map
|