@seedprotocol/react 0.4.21 → 0.4.22
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/SeedProvider.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +942 -885
- package/dist/index.js.map +1 -1
- package/dist/item.d.ts.map +1 -1
- package/dist/useEasSyncProcesses.d.ts +17 -0
- package/dist/useEasSyncProcesses.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { flushSync as
|
|
3
|
-
import { getClient as
|
|
4
|
-
import { orderBy as
|
|
1
|
+
import qe, { createContext as rt, useContext as nt, useState as S, useCallback as x, useEffect as w, useRef as C, useMemo as N, useLayoutEffect as st } from "react";
|
|
2
|
+
import { flushSync as ue } from "react-dom";
|
|
3
|
+
import { getClient as ge, ClientManagerState as P, eventEmitter as z, BaseDb as j, Item as Ce, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as ne, getAddressesForItemsFilter as ot, seeds as D, getVersionData as it, createNewItem as at, ItemProperty as ie, metadata as k, appState as fe, Schema as be, schemas as X, loadAllSchemasFromDb as ct, SEED_PROTOCOL_SCHEMA_NAME as lt, Model as ae, models as ce, modelSchemas as ve, ModelProperty as ye, properties as te, getPropertySchema as ze, getSchemaNameFromId as dt, BaseFileManager as W, easSyncProcesses as pe, client as ut, resolveMediaRef as ft, normalizeFeedItemFields as yt } from "@seedprotocol/sdk";
|
|
4
|
+
import { orderBy as pt, debounce as He, startCase as Pe } from "lodash-es";
|
|
5
5
|
import G from "debug";
|
|
6
|
-
import { useSelector as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { or as
|
|
9
|
-
import { toSnakeCase as
|
|
10
|
-
import { useQueryClient as
|
|
11
|
-
import
|
|
12
|
-
const
|
|
13
|
-
const t =
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
function
|
|
17
|
-
return
|
|
6
|
+
import { useSelector as Le } from "@xstate/react";
|
|
7
|
+
import { jsx as g, jsxs as U, Fragment as Se } from "react/jsx-runtime";
|
|
8
|
+
import { or as re, isNull as le, eq as q, inArray as Te, sql as mt, isNotNull as Ae, and as xe, gt as ht, like as Qe, desc as Ve } from "drizzle-orm";
|
|
9
|
+
import { toSnakeCase as gt } from "drizzle-orm/casing";
|
|
10
|
+
import { useQueryClient as Z, useQuery as ee, QueryClient as bt, QueryClientProvider as St } from "@tanstack/react-query";
|
|
11
|
+
import vt from "pluralize";
|
|
12
|
+
const Q = () => {
|
|
13
|
+
const t = ge().getService();
|
|
14
|
+
return Le(t, (n) => n.value === P.IDLE);
|
|
15
|
+
}, Me = "addresses.persisted", Ke = rt(0);
|
|
16
|
+
function je() {
|
|
17
|
+
return nt(Ke);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function wt({
|
|
20
20
|
queryClient: e,
|
|
21
21
|
children: t
|
|
22
22
|
}) {
|
|
23
23
|
const [r, n] = S(0), o = x(() => {
|
|
24
24
|
e.invalidateQueries({ queryKey: ["seed", "items"], exact: !1 }), n((a) => a + 1);
|
|
25
25
|
}, [e]);
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
}), [o]), /* @__PURE__ */
|
|
26
|
+
return w(() => (z.on(Me, o), () => {
|
|
27
|
+
z.off(Me, o);
|
|
28
|
+
}), [o]), /* @__PURE__ */ g(Ke.Provider, { value: r, children: t });
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const [t, r] = S(void 0), n =
|
|
30
|
+
function Y(e) {
|
|
31
|
+
const [t, r] = S(void 0), n = C(null), o = Q(), a = N(() => {
|
|
32
32
|
if (!o || !e)
|
|
33
33
|
return null;
|
|
34
34
|
try {
|
|
35
|
-
return
|
|
35
|
+
return j.liveQuery(e);
|
|
36
36
|
} catch (s) {
|
|
37
37
|
return console.error("[useLiveQuery] Failed to create live query:", s), null;
|
|
38
38
|
}
|
|
39
39
|
}, [e, o]);
|
|
40
|
-
return
|
|
40
|
+
return w(() => {
|
|
41
41
|
if (n.current && (n.current.unsubscribe(), n.current = null), !a)
|
|
42
42
|
return;
|
|
43
43
|
const s = a.subscribe({
|
|
44
|
-
next: (
|
|
45
|
-
r(
|
|
44
|
+
next: (c) => {
|
|
45
|
+
r(c !== void 0 ? [...c] : void 0);
|
|
46
46
|
},
|
|
47
|
-
error: (
|
|
48
|
-
console.error("[useLiveQuery] Error:",
|
|
47
|
+
error: (c) => {
|
|
48
|
+
console.error("[useLiveQuery] Error:", c);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
return n.current = s, () => {
|
|
@@ -53,54 +53,63 @@ function ie(e) {
|
|
|
53
53
|
};
|
|
54
54
|
}, [a]), t;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
const [n, o] = S(), [a, s] = S(!!(t || r)), [l,
|
|
58
|
-
if (!!!(
|
|
59
|
-
o(void 0),
|
|
56
|
+
const me = G("seedSdk:react:item"), pr = ({ modelName: e, seedLocalId: t, seedUid: r }) => {
|
|
57
|
+
const [n, o] = S(), [, a] = S(0), [s, c] = S(!!(t || r)), [l, i] = S(null), d = C(void 0), u = C(!1), f = Q(), b = je(), v = C(e), h = C(t), y = C(r), p = N(() => f ? !!(h.current || y.current) : !1, [f, t, r]), E = x(async () => {
|
|
58
|
+
if (!!!(f && (h.current || y.current))) {
|
|
59
|
+
o(void 0), c(!1), i(null);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
try {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
modelName:
|
|
66
|
-
seedLocalId:
|
|
67
|
-
seedUid:
|
|
63
|
+
i(null);
|
|
64
|
+
const _ = await Ce.find({
|
|
65
|
+
modelName: v.current,
|
|
66
|
+
seedLocalId: h.current,
|
|
67
|
+
seedUid: y.current
|
|
68
68
|
});
|
|
69
|
-
if (!
|
|
70
|
-
|
|
69
|
+
if (!_) {
|
|
70
|
+
me("[useItem] [loadItem] no item found", v.current, h.current), o((R) => R && (R.seedLocalId && R.seedLocalId === h.current || R.seedUid && R.seedUid === y.current) ? R : void 0), c(!1), i(null);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
o(
|
|
74
|
-
} catch (
|
|
75
|
-
|
|
73
|
+
o(_), c(!1), i(null);
|
|
74
|
+
} catch (_) {
|
|
75
|
+
me("[useItem] Error loading item:", _), o(void 0), c(!1), i(_);
|
|
76
76
|
}
|
|
77
|
-
}, [
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
}, [
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
}, [f]), I = C(E);
|
|
78
|
+
return w(() => {
|
|
79
|
+
I.current = E;
|
|
80
|
+
}, [E]), w(() => {
|
|
81
|
+
v.current = e, h.current = t, y.current = r;
|
|
82
|
+
}, [e, t, r]), w(() => {
|
|
83
|
+
const m = () => {
|
|
84
|
+
a((_) => _ + 1), I.current();
|
|
85
|
+
};
|
|
86
|
+
return z.on(ne, m), () => {
|
|
87
|
+
z.off(ne, m);
|
|
88
|
+
};
|
|
89
|
+
}, []), w(() => {
|
|
90
|
+
if (!p) {
|
|
91
|
+
!t && !r && (o(void 0), c(!1), i(null));
|
|
83
92
|
return;
|
|
84
93
|
}
|
|
85
|
-
|
|
86
|
-
}, [
|
|
94
|
+
E();
|
|
95
|
+
}, [p, E, t, r, b]), w(() => {
|
|
87
96
|
if (!n) {
|
|
88
|
-
|
|
97
|
+
d.current?.unsubscribe(), d.current = void 0, u.current = !1;
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
100
|
+
d.current?.unsubscribe(), u.current = !1;
|
|
101
|
+
const _ = n.getService().subscribe((R) => {
|
|
102
|
+
R && typeof R == "object" && "value" in R && (R.value === "idle" ? (u.current = !0, c(!1), i(null)) : R.value === "error" ? (i(new Error("Item service error")), c(!1)) : u.current && c(!0));
|
|
94
103
|
});
|
|
95
|
-
return
|
|
96
|
-
|
|
104
|
+
return d.current = _, () => {
|
|
105
|
+
d.current?.unsubscribe(), d.current = void 0;
|
|
97
106
|
};
|
|
98
107
|
}, [n]), {
|
|
99
108
|
item: n,
|
|
100
|
-
isLoading:
|
|
109
|
+
isLoading: s,
|
|
101
110
|
error: l
|
|
102
111
|
};
|
|
103
|
-
},
|
|
112
|
+
}, It = (e, t, r, n, o) => [
|
|
104
113
|
"seed",
|
|
105
114
|
"items",
|
|
106
115
|
e ?? null,
|
|
@@ -108,129 +117,143 @@ const pe = G("seedSdk:react:item"), dr = ({ modelName: e, seedLocalId: t, seedUi
|
|
|
108
117
|
r ?? !1,
|
|
109
118
|
n ?? null,
|
|
110
119
|
o ?? 0
|
|
111
|
-
],
|
|
120
|
+
], mr = ({
|
|
112
121
|
modelName: e,
|
|
113
122
|
deleted: t = !1,
|
|
114
123
|
includeEas: r = !1,
|
|
115
124
|
addressFilter: n
|
|
116
125
|
}) => {
|
|
117
|
-
const o =
|
|
118
|
-
|
|
126
|
+
const o = Q(), a = je(), s = Z();
|
|
127
|
+
w(() => {
|
|
128
|
+
const I = () => {
|
|
129
|
+
s.invalidateQueries({ queryKey: ["seed", "items"] });
|
|
130
|
+
};
|
|
131
|
+
return z.on(ne, I), () => {
|
|
132
|
+
z.off(ne, I);
|
|
133
|
+
};
|
|
134
|
+
}, [s]);
|
|
135
|
+
const c = C([]), l = C(/* @__PURE__ */ new Set()), i = C(!1), [d, u] = S(null);
|
|
136
|
+
w(() => {
|
|
119
137
|
if (n !== "owned" && n !== "watched") {
|
|
120
138
|
u(null);
|
|
121
139
|
return;
|
|
122
140
|
}
|
|
123
|
-
let
|
|
124
|
-
return
|
|
125
|
-
|
|
141
|
+
let I = !1;
|
|
142
|
+
return ot(n).then((m) => {
|
|
143
|
+
I || u(m);
|
|
126
144
|
}), () => {
|
|
127
|
-
|
|
145
|
+
I = !0;
|
|
128
146
|
};
|
|
129
147
|
}, [n, a]);
|
|
130
|
-
const f =
|
|
131
|
-
() =>
|
|
148
|
+
const f = N(
|
|
149
|
+
() => It(e, t, r, n, a),
|
|
132
150
|
[e, t, r, n, a]
|
|
133
151
|
);
|
|
134
|
-
|
|
152
|
+
w(() => {
|
|
135
153
|
i.current = !1;
|
|
136
154
|
}, [f]);
|
|
137
155
|
const {
|
|
138
|
-
data:
|
|
156
|
+
data: b = [],
|
|
139
157
|
isLoading: v,
|
|
140
|
-
error:
|
|
141
|
-
} =
|
|
158
|
+
error: h
|
|
159
|
+
} = ee({
|
|
142
160
|
queryKey: f,
|
|
143
|
-
queryFn: () =>
|
|
161
|
+
queryFn: async () => await Ce.all(e, t, {
|
|
162
|
+
waitForReady: !0,
|
|
163
|
+
includeEas: r,
|
|
164
|
+
addressFilter: n
|
|
165
|
+
}),
|
|
144
166
|
enabled: o,
|
|
145
167
|
// Local SQLite + live invalidation drive freshness; Seed’s default staleTime would keep a
|
|
146
168
|
// mistaken initial [] “fresh” and block refetch when another subscriber mounts.
|
|
147
169
|
staleTime: 0
|
|
148
170
|
});
|
|
149
|
-
|
|
150
|
-
const y = o ?
|
|
171
|
+
c.current = b;
|
|
172
|
+
const y = o ? j.getAppDb() : null, p = N(() => {
|
|
151
173
|
if (!y || (n === "owned" || n === "watched") && d === null)
|
|
152
174
|
return null;
|
|
153
|
-
const
|
|
154
|
-
r ||
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
le(
|
|
175
|
+
const I = [];
|
|
176
|
+
r || I.push(re(le(D.uid), q(D.uid, ""))), e && I.push(q(D.type, gt(e))), n === "owned" ? d && d.length > 0 && I.push(
|
|
177
|
+
re(
|
|
178
|
+
Te(D.publisher, d),
|
|
179
|
+
le(D.publisher)
|
|
158
180
|
)
|
|
159
|
-
) : n === "watched" && (d && d.length > 0 ?
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
181
|
+
) : n === "watched" && (d && d.length > 0 ? I.push(Te(D.publisher, d)) : I.push(mt`1=0`)), t ? I.push(
|
|
182
|
+
re(
|
|
183
|
+
Ae(D._markedForDeletion),
|
|
184
|
+
q(D._markedForDeletion, 1)
|
|
163
185
|
)
|
|
164
|
-
) : (
|
|
165
|
-
|
|
166
|
-
le(
|
|
167
|
-
|
|
186
|
+
) : (I.push(
|
|
187
|
+
re(
|
|
188
|
+
le(D._markedForDeletion),
|
|
189
|
+
q(D._markedForDeletion, 0)
|
|
168
190
|
)
|
|
169
|
-
),
|
|
170
|
-
|
|
191
|
+
), I.push(
|
|
192
|
+
re(le(D.revokedAt), q(D.revokedAt, 0))
|
|
171
193
|
));
|
|
172
|
-
const m =
|
|
194
|
+
const m = it();
|
|
173
195
|
return y.with(m).select({
|
|
174
|
-
localId:
|
|
175
|
-
uid:
|
|
176
|
-
type:
|
|
177
|
-
schemaUid:
|
|
178
|
-
createdAt:
|
|
179
|
-
attestationCreatedAt:
|
|
180
|
-
_markedForDeletion:
|
|
181
|
-
}).from(
|
|
182
|
-
}, [y, o, e, t, r, n, d]), E =
|
|
183
|
-
return
|
|
196
|
+
localId: D.localId,
|
|
197
|
+
uid: D.uid,
|
|
198
|
+
type: D.type,
|
|
199
|
+
schemaUid: D.schemaUid,
|
|
200
|
+
createdAt: D.createdAt,
|
|
201
|
+
attestationCreatedAt: D.attestationCreatedAt,
|
|
202
|
+
_markedForDeletion: D._markedForDeletion
|
|
203
|
+
}).from(D).leftJoin(m, q(D.localId, m.seedLocalId)).where(xe(ht(m.versionsCount, 0), ...I)).groupBy(D.localId);
|
|
204
|
+
}, [y, o, e, t, r, n, d]), E = Y(p);
|
|
205
|
+
return w(() => {
|
|
184
206
|
if (!o || !E) return;
|
|
185
|
-
const
|
|
186
|
-
for (const
|
|
187
|
-
const
|
|
188
|
-
|
|
207
|
+
const I = /* @__PURE__ */ new Set();
|
|
208
|
+
for (const A of E) {
|
|
209
|
+
const B = A.localId || A.uid;
|
|
210
|
+
B && I.add(B);
|
|
189
211
|
}
|
|
190
212
|
const m = /* @__PURE__ */ new Set();
|
|
191
|
-
for (const
|
|
192
|
-
const
|
|
193
|
-
|
|
213
|
+
for (const A of c.current) {
|
|
214
|
+
const B = A.seedLocalId || A.seedUid;
|
|
215
|
+
B && m.add(B);
|
|
194
216
|
}
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
if (I.size === 0 && m.size > 0)
|
|
218
|
+
return;
|
|
219
|
+
if (!i.current && (i.current = !0, I.size > 0 && m.size === 0)) {
|
|
220
|
+
l.current = new Set(I), s.invalidateQueries({ queryKey: f });
|
|
198
221
|
return;
|
|
199
222
|
}
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
223
|
+
const _ = l.current;
|
|
224
|
+
if (_.size === I.size && [..._].every((A) => I.has(A)))
|
|
202
225
|
return;
|
|
203
|
-
if (m.size ===
|
|
204
|
-
|
|
226
|
+
if (m.size === I.size && [...m].every((A) => I.has(A))) {
|
|
227
|
+
l.current = new Set(I);
|
|
205
228
|
return;
|
|
206
229
|
}
|
|
207
|
-
|
|
230
|
+
l.current = new Set(I), s.invalidateQueries({ queryKey: f });
|
|
208
231
|
}, [o, E, s, f]), {
|
|
209
|
-
items:
|
|
210
|
-
|
|
232
|
+
items: pt(
|
|
233
|
+
b,
|
|
211
234
|
[
|
|
212
|
-
(
|
|
235
|
+
(I) => I.lastVersionPublishedAt || I.attestationCreatedAt || I.createdAt
|
|
213
236
|
],
|
|
214
237
|
["desc"]
|
|
215
238
|
),
|
|
216
239
|
isLoading: v,
|
|
217
|
-
error:
|
|
240
|
+
error: h
|
|
218
241
|
};
|
|
219
|
-
},
|
|
242
|
+
}, hr = () => {
|
|
220
243
|
const [e, t] = S(!1), [r, n] = S(null), o = x(() => n(null), []);
|
|
221
244
|
return {
|
|
222
245
|
createItem: x(
|
|
223
|
-
async (s,
|
|
246
|
+
async (s, c) => {
|
|
224
247
|
if (e) {
|
|
225
|
-
|
|
248
|
+
me("[useCreateItem] [createItem] already creating item, skipping");
|
|
226
249
|
return;
|
|
227
250
|
}
|
|
228
|
-
n(null),
|
|
251
|
+
n(null), ue(() => t(!0));
|
|
229
252
|
try {
|
|
230
|
-
const
|
|
231
|
-
return await
|
|
232
|
-
} catch (
|
|
233
|
-
|
|
253
|
+
const l = c ?? {}, { seedLocalId: i } = await at({ modelName: s, ...l });
|
|
254
|
+
return await Ce.find({ modelName: s, seedLocalId: i }) ?? void 0;
|
|
255
|
+
} catch (l) {
|
|
256
|
+
me("[useCreateItem] Error creating item:", l), n(l instanceof Error ? l : new Error(String(l)));
|
|
234
257
|
return;
|
|
235
258
|
} finally {
|
|
236
259
|
queueMicrotask(() => t(!1));
|
|
@@ -242,180 +265,180 @@ const pe = G("seedSdk:react:item"), dr = ({ modelName: e, seedLocalId: t, seedUi
|
|
|
242
265
|
error: r,
|
|
243
266
|
resetError: o
|
|
244
267
|
};
|
|
245
|
-
},
|
|
246
|
-
const [e, t] = S(null), [r, n] = S(!1), [o, a] = S(null), s =
|
|
268
|
+
}, gr = () => {
|
|
269
|
+
const [e, t] = S(null), [r, n] = S(!1), [o, a] = S(null), s = C(void 0), c = x(() => a(null), []), l = x((i) => {
|
|
247
270
|
i && (t(i), a(null), i.publish().catch(() => {
|
|
248
271
|
}));
|
|
249
272
|
}, []);
|
|
250
|
-
return
|
|
273
|
+
return w(() => {
|
|
251
274
|
if (!e) {
|
|
252
275
|
s.current?.unsubscribe(), s.current = void 0, n(!1);
|
|
253
276
|
return;
|
|
254
277
|
}
|
|
255
278
|
s.current?.unsubscribe();
|
|
256
279
|
const i = e.getService(), d = i.subscribe((v) => {
|
|
257
|
-
const
|
|
258
|
-
n(
|
|
280
|
+
const h = v?.value, y = v?.context;
|
|
281
|
+
n(h === "publishing");
|
|
259
282
|
const p = y?._publishError;
|
|
260
283
|
a(p ? new Error(p.message) : null);
|
|
261
284
|
});
|
|
262
285
|
s.current = d;
|
|
263
286
|
const u = i.getSnapshot();
|
|
264
287
|
n(u?.value === "publishing");
|
|
265
|
-
const
|
|
266
|
-
return a(
|
|
288
|
+
const b = u?.context?._publishError;
|
|
289
|
+
return a(b ? new Error(b.message) : null), () => {
|
|
267
290
|
s.current?.unsubscribe(), s.current = void 0;
|
|
268
291
|
};
|
|
269
292
|
}, [e]), {
|
|
270
|
-
publishItem:
|
|
293
|
+
publishItem: l,
|
|
271
294
|
isLoading: r,
|
|
272
295
|
error: o,
|
|
273
|
-
resetError:
|
|
296
|
+
resetError: c
|
|
274
297
|
};
|
|
275
|
-
},
|
|
276
|
-
function
|
|
277
|
-
const r =
|
|
278
|
-
const
|
|
279
|
-
return (
|
|
298
|
+
}, he = G("seedSdk:react:property"), oe = G("seedSdk:react:itemProperties");
|
|
299
|
+
function We(e, t) {
|
|
300
|
+
const r = Q(), [n, o] = S(void 0), [a, s] = S(!1), [c, l] = S(null), i = C(void 0), [, d] = S(0), f = typeof e == "object" && e != null ? e : null, b = f?.itemId, v = f?.seedLocalId, h = f?.seedUid, y = f?.propertyName, p = typeof e == "string" ? e : b !== void 0 && b !== "" ? b : void 0, I = y ?? (typeof e == "string" ? t : void 0), m = N(() => {
|
|
301
|
+
const A = p !== void 0 && p !== "" ? p : v, B = p !== void 0 && p !== "" ? void 0 : h;
|
|
302
|
+
return (A != null || B != null) && I != null && I !== "" ? {
|
|
280
303
|
type: "identifiers",
|
|
281
|
-
seedLocalId:
|
|
282
|
-
seedUid:
|
|
283
|
-
propertyName:
|
|
304
|
+
seedLocalId: A ?? void 0,
|
|
305
|
+
seedUid: B,
|
|
306
|
+
propertyName: I
|
|
284
307
|
} : null;
|
|
285
|
-
}, [p,
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}, [
|
|
291
|
-
const
|
|
308
|
+
}, [p, I, v, h]);
|
|
309
|
+
N(() => m ? !!((m.seedLocalId || m.seedUid) && m.propertyName) : !1, [m]);
|
|
310
|
+
const _ = N(() => !r || !m ? !1 : !!((m.seedLocalId || m.seedUid) && m.propertyName), [r, m]);
|
|
311
|
+
st(() => {
|
|
312
|
+
_ && s(!0);
|
|
313
|
+
}, [_]);
|
|
314
|
+
const R = x(async () => {
|
|
292
315
|
if (!r || !m) {
|
|
293
|
-
o(void 0), s(!1),
|
|
316
|
+
o(void 0), s(!1), l(null);
|
|
294
317
|
return;
|
|
295
318
|
}
|
|
296
319
|
try {
|
|
297
|
-
s(!0),
|
|
298
|
-
const
|
|
299
|
-
if (!
|
|
300
|
-
o(void 0), s(!1),
|
|
320
|
+
s(!0), l(null);
|
|
321
|
+
const A = m.seedLocalId, B = m.seedUid;
|
|
322
|
+
if (!A && !B) {
|
|
323
|
+
o(void 0), s(!1), l(null);
|
|
301
324
|
return;
|
|
302
325
|
}
|
|
303
|
-
const
|
|
326
|
+
const V = await ie.find({
|
|
304
327
|
propertyName: m.propertyName,
|
|
305
|
-
seedLocalId:
|
|
306
|
-
seedUid:
|
|
328
|
+
seedLocalId: A,
|
|
329
|
+
seedUid: B
|
|
307
330
|
});
|
|
308
|
-
if (!
|
|
309
|
-
|
|
310
|
-
`[useItemProperty] [updateItemProperty] no property found for Item.${
|
|
311
|
-
), o(void 0), s(!1),
|
|
331
|
+
if (!V) {
|
|
332
|
+
he(
|
|
333
|
+
`[useItemProperty] [updateItemProperty] no property found for Item.${A || B}.${m.propertyName}`
|
|
334
|
+
), o(void 0), s(!1), l(null);
|
|
312
335
|
return;
|
|
313
336
|
}
|
|
314
|
-
o(
|
|
315
|
-
} catch (
|
|
316
|
-
|
|
337
|
+
o(V), s(!1), l(null);
|
|
338
|
+
} catch (A) {
|
|
339
|
+
he("[useItemProperty] Error updating item property:", A), o(void 0), s(!1), l(A);
|
|
317
340
|
}
|
|
318
341
|
}, [r, m]);
|
|
319
|
-
return
|
|
320
|
-
if (!
|
|
321
|
-
o(void 0), s(!1),
|
|
342
|
+
return w(() => {
|
|
343
|
+
if (!_) {
|
|
344
|
+
o(void 0), s(!1), l(null);
|
|
322
345
|
return;
|
|
323
346
|
}
|
|
324
|
-
n && m && n.propertyName === m.propertyName && (m.seedLocalId != null && n.seedLocalId === m.seedLocalId || m.seedUid != null && n.seedUid === m.seedUid) ||
|
|
325
|
-
}, [
|
|
347
|
+
n && m && n.propertyName === m.propertyName && (m.seedLocalId != null && n.seedLocalId === m.seedLocalId || m.seedUid != null && n.seedUid === m.seedUid) || R();
|
|
348
|
+
}, [_, R, n, m]), w(() => {
|
|
326
349
|
if (!n) {
|
|
327
350
|
i.current?.unsubscribe(), i.current = void 0;
|
|
328
351
|
return;
|
|
329
352
|
}
|
|
330
353
|
i.current?.unsubscribe();
|
|
331
|
-
let
|
|
332
|
-
const L = 50,
|
|
333
|
-
if (
|
|
334
|
-
s(!1),
|
|
335
|
-
const M =
|
|
336
|
-
(
|
|
354
|
+
let A = 0, B = !1, V;
|
|
355
|
+
const L = 50, $ = n.getService().subscribe((F) => {
|
|
356
|
+
if (F && typeof F == "object" && "value" in F && F.value === "idle") {
|
|
357
|
+
s(!1), l(null);
|
|
358
|
+
const M = F.context, J = JSON.stringify([M.renderValue, M.propertyValue]);
|
|
359
|
+
(!B || J !== V) && (B = !0, V = J, d((se) => se + 1));
|
|
337
360
|
return;
|
|
338
361
|
}
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
362
|
+
B = !1, V = void 0;
|
|
363
|
+
const K = Date.now();
|
|
364
|
+
K - A >= L && (A = K, d((M) => M + 1));
|
|
342
365
|
});
|
|
343
|
-
return i.current =
|
|
366
|
+
return i.current = $, () => {
|
|
344
367
|
i.current?.unsubscribe(), i.current = void 0;
|
|
345
368
|
};
|
|
346
369
|
}, [n]), {
|
|
347
370
|
property: n,
|
|
348
371
|
isLoading: a,
|
|
349
|
-
error:
|
|
372
|
+
error: c
|
|
350
373
|
};
|
|
351
374
|
}
|
|
352
|
-
function
|
|
353
|
-
const r = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, o = "seedUid" in e ? e.seedUid : void 0, a = e.propertyName, s =
|
|
354
|
-
() =>
|
|
355
|
-
|
|
375
|
+
function br(e, t = 300) {
|
|
376
|
+
const r = "itemId" in e ? e.itemId : void 0, n = "seedLocalId" in e ? e.seedLocalId : void 0, o = "seedUid" in e ? e.seedUid : void 0, a = e.propertyName, s = N(() => r ? { seedLocalId: r, propertyName: a } : { seedLocalId: n, seedUid: o, propertyName: a }, [r, n, o, a]), { property: c, isLoading: l, error: i } = We(s), d = C(""), u = N(
|
|
377
|
+
() => He((b) => {
|
|
378
|
+
b.getService().send({
|
|
356
379
|
type: "save",
|
|
357
380
|
newValue: d.current
|
|
358
381
|
});
|
|
359
382
|
}, t),
|
|
360
383
|
[t]
|
|
361
384
|
);
|
|
362
|
-
|
|
385
|
+
w(() => () => u.cancel(), [u]);
|
|
363
386
|
const f = x(
|
|
364
|
-
(
|
|
365
|
-
|
|
387
|
+
(b) => {
|
|
388
|
+
c && (d.current = b, c.getService().send({
|
|
366
389
|
type: "updateContext",
|
|
367
|
-
propertyValue:
|
|
368
|
-
renderValue:
|
|
369
|
-
}), u(
|
|
390
|
+
propertyValue: b,
|
|
391
|
+
renderValue: b
|
|
392
|
+
}), u(c));
|
|
370
393
|
},
|
|
371
|
-
[
|
|
394
|
+
[c, u]
|
|
372
395
|
);
|
|
373
396
|
return {
|
|
374
|
-
property:
|
|
397
|
+
property: c,
|
|
375
398
|
setValue: f,
|
|
376
|
-
isLoading:
|
|
399
|
+
isLoading: l,
|
|
377
400
|
error: i
|
|
378
401
|
};
|
|
379
402
|
}
|
|
380
|
-
async function
|
|
403
|
+
async function Et(e, t) {
|
|
381
404
|
if (!e && !t) return [];
|
|
382
|
-
const r =
|
|
405
|
+
const r = j.getAppDb();
|
|
383
406
|
if (!r) return [];
|
|
384
|
-
const n = await
|
|
407
|
+
const n = await ie.all(
|
|
385
408
|
{ seedLocalId: e ?? void 0, seedUid: t ?? void 0 },
|
|
386
409
|
{ waitForReady: !0 }
|
|
387
410
|
), o = [...n], a = /* @__PURE__ */ new Set();
|
|
388
|
-
for (const
|
|
389
|
-
|
|
411
|
+
for (const l of n)
|
|
412
|
+
l.propertyName && a.add(l.propertyName);
|
|
390
413
|
let s;
|
|
391
414
|
if (n.length > 0) {
|
|
392
|
-
const
|
|
393
|
-
s =
|
|
415
|
+
const l = n[0];
|
|
416
|
+
s = l.modelName ?? l.modelType, s && typeof s == "string" && (s = Pe(s));
|
|
394
417
|
}
|
|
395
418
|
if (!s) {
|
|
396
|
-
const
|
|
397
|
-
|
|
419
|
+
const l = await r.select({ type: D.type }).from(D).where(t ? q(D.uid, t) : q(D.localId, e)).limit(1);
|
|
420
|
+
l.length > 0 && l[0].type && (s = Pe(l[0].type));
|
|
398
421
|
}
|
|
399
|
-
const
|
|
422
|
+
const c = [];
|
|
400
423
|
if (s)
|
|
401
424
|
try {
|
|
402
|
-
const { Model:
|
|
425
|
+
const { Model: l } = await import("@seedprotocol/sdk"), i = await l.getByNameAsync(s);
|
|
403
426
|
if (i?.properties)
|
|
404
427
|
for (const d of i.properties)
|
|
405
|
-
d.name &&
|
|
406
|
-
} catch (
|
|
407
|
-
|
|
428
|
+
d.name && c.push(d.name);
|
|
429
|
+
} catch (l) {
|
|
430
|
+
oe(`[useItemProperties] Error getting ModelProperties for ${s}:`, l);
|
|
408
431
|
}
|
|
409
|
-
if (s &&
|
|
410
|
-
const
|
|
411
|
-
for (const d of
|
|
432
|
+
if (s && c.length > 0) {
|
|
433
|
+
const l = n.length > 0 ? n[0].seedLocalId ?? e : e, i = n.length > 0 ? n[0].seedUid ?? t : t;
|
|
434
|
+
for (const d of c)
|
|
412
435
|
if (!a.has(d))
|
|
413
436
|
try {
|
|
414
|
-
const u =
|
|
437
|
+
const u = ie.create(
|
|
415
438
|
{
|
|
416
439
|
propertyName: d,
|
|
417
440
|
modelName: s,
|
|
418
|
-
seedLocalId:
|
|
441
|
+
seedLocalId: l || void 0,
|
|
419
442
|
seedUid: i || void 0,
|
|
420
443
|
propertyValue: null
|
|
421
444
|
},
|
|
@@ -423,111 +446,111 @@ async function St(e, t) {
|
|
|
423
446
|
);
|
|
424
447
|
u && o.push(u);
|
|
425
448
|
} catch (u) {
|
|
426
|
-
|
|
449
|
+
he(`[useItemProperties] Error creating ItemProperty for missing property ${d}:`, u);
|
|
427
450
|
}
|
|
428
451
|
}
|
|
429
452
|
if (e || t) {
|
|
430
|
-
const
|
|
431
|
-
if (
|
|
453
|
+
const l = await r.select({ createdAt: D.createdAt }).from(D).where(t ? q(D.uid, t) : q(D.localId, e)).limit(1);
|
|
454
|
+
if (l.length > 0 && l[0].createdAt) {
|
|
432
455
|
const i = "createdAt";
|
|
433
456
|
if (!o.some((u) => u.propertyName === i) && s)
|
|
434
457
|
try {
|
|
435
|
-
const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? t : t,
|
|
458
|
+
const u = n.length > 0 ? n[0].seedLocalId ?? e : e, f = n.length > 0 ? n[0].seedUid ?? t : t, b = ie.create(
|
|
436
459
|
{
|
|
437
460
|
propertyName: i,
|
|
438
461
|
modelName: s,
|
|
439
462
|
seedLocalId: u || void 0,
|
|
440
463
|
seedUid: f || void 0,
|
|
441
|
-
propertyValue:
|
|
464
|
+
propertyValue: l[0].createdAt.toString()
|
|
442
465
|
},
|
|
443
466
|
{ waitForReady: !1 }
|
|
444
467
|
);
|
|
445
|
-
|
|
468
|
+
b && o.push(b);
|
|
446
469
|
} catch (u) {
|
|
447
|
-
|
|
470
|
+
he("[useItemProperties] Error creating createdAt ItemProperty:", u);
|
|
448
471
|
}
|
|
449
472
|
}
|
|
450
473
|
}
|
|
451
474
|
return o;
|
|
452
475
|
}
|
|
453
|
-
function
|
|
454
|
-
const t =
|
|
476
|
+
function Sr(e) {
|
|
477
|
+
const t = Q(), r = Z(), n = C(void 0), o = N(() => typeof e == "string" ? { type: "itemId", itemId: e } : typeof e == "object" ? {
|
|
455
478
|
type: "identifiers",
|
|
456
479
|
seedLocalId: e.seedLocalId,
|
|
457
480
|
seedUid: e.seedUid
|
|
458
|
-
} : null, [e]), a =
|
|
481
|
+
} : null, [e]), a = N(() => {
|
|
459
482
|
if (o)
|
|
460
483
|
return o.type === "itemId" ? o.itemId : o.seedLocalId;
|
|
461
|
-
}, [o]), s =
|
|
484
|
+
}, [o]), s = N(() => {
|
|
462
485
|
if (!(!o || o.type === "itemId"))
|
|
463
486
|
return o.seedUid;
|
|
464
|
-
}, [o]),
|
|
465
|
-
() => ["seed", "itemProperties",
|
|
466
|
-
[
|
|
487
|
+
}, [o]), c = a ?? s ?? "", l = N(
|
|
488
|
+
() => ["seed", "itemProperties", c],
|
|
489
|
+
[c]
|
|
467
490
|
), {
|
|
468
491
|
data: i = [],
|
|
469
492
|
isLoading: d,
|
|
470
493
|
error: u
|
|
471
|
-
} =
|
|
472
|
-
queryKey:
|
|
473
|
-
queryFn: () =>
|
|
474
|
-
enabled: t && !!
|
|
475
|
-
}), f =
|
|
494
|
+
} = ee({
|
|
495
|
+
queryKey: l,
|
|
496
|
+
queryFn: () => Et(a, s),
|
|
497
|
+
enabled: t && !!c
|
|
498
|
+
}), f = N(() => {
|
|
476
499
|
if (!t || !a && !s)
|
|
477
|
-
return
|
|
478
|
-
const
|
|
479
|
-
if (!
|
|
480
|
-
return
|
|
481
|
-
|
|
482
|
-
const y = s ?
|
|
483
|
-
propertyName:
|
|
484
|
-
propertyValue:
|
|
485
|
-
seedLocalId:
|
|
486
|
-
seedUid:
|
|
487
|
-
modelType:
|
|
488
|
-
schemaUid:
|
|
489
|
-
createdAt:
|
|
490
|
-
attestationCreatedAt:
|
|
491
|
-
}).from(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
500
|
+
return oe("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
501
|
+
const h = j.getAppDb();
|
|
502
|
+
if (!h)
|
|
503
|
+
return oe("[useItemProperties] Query: returning null (no db)"), null;
|
|
504
|
+
oe(`[useItemProperties] Query: creating query for seedLocalId=${a}, seedUid=${s}`);
|
|
505
|
+
const y = s ? h.select({
|
|
506
|
+
propertyName: k.propertyName,
|
|
507
|
+
propertyValue: k.propertyValue,
|
|
508
|
+
seedLocalId: k.seedLocalId,
|
|
509
|
+
seedUid: k.seedUid,
|
|
510
|
+
modelType: k.modelType,
|
|
511
|
+
schemaUid: k.schemaUid,
|
|
512
|
+
createdAt: k.createdAt,
|
|
513
|
+
attestationCreatedAt: k.attestationCreatedAt
|
|
514
|
+
}).from(k).where(
|
|
515
|
+
xe(
|
|
516
|
+
q(k.seedUid, s),
|
|
517
|
+
Ae(k.propertyName)
|
|
495
518
|
)
|
|
496
|
-
) : a ?
|
|
497
|
-
propertyName:
|
|
498
|
-
propertyValue:
|
|
499
|
-
seedLocalId:
|
|
500
|
-
seedUid:
|
|
501
|
-
modelType:
|
|
502
|
-
schemaUid:
|
|
503
|
-
createdAt:
|
|
504
|
-
attestationCreatedAt:
|
|
505
|
-
}).from(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
519
|
+
) : a ? h.select({
|
|
520
|
+
propertyName: k.propertyName,
|
|
521
|
+
propertyValue: k.propertyValue,
|
|
522
|
+
seedLocalId: k.seedLocalId,
|
|
523
|
+
seedUid: k.seedUid,
|
|
524
|
+
modelType: k.modelType,
|
|
525
|
+
schemaUid: k.schemaUid,
|
|
526
|
+
createdAt: k.createdAt,
|
|
527
|
+
attestationCreatedAt: k.attestationCreatedAt
|
|
528
|
+
}).from(k).where(
|
|
529
|
+
xe(
|
|
530
|
+
q(k.seedLocalId, a),
|
|
531
|
+
Ae(k.propertyName)
|
|
509
532
|
)
|
|
510
533
|
) : null;
|
|
511
|
-
return
|
|
512
|
-
}, [t, a, s]),
|
|
513
|
-
if (!
|
|
534
|
+
return oe("[useItemProperties] Query: created query object", { queryType: s ? "seedUid" : "seedLocalId" }), y;
|
|
535
|
+
}, [t, a, s]), b = Y(f), v = N(() => {
|
|
536
|
+
if (!b || b.length === 0)
|
|
514
537
|
return [];
|
|
515
|
-
const
|
|
516
|
-
for (const y of
|
|
538
|
+
const h = /* @__PURE__ */ new Map();
|
|
539
|
+
for (const y of b) {
|
|
517
540
|
if (!y.propertyName) continue;
|
|
518
|
-
const p =
|
|
541
|
+
const p = h.get(y.propertyName);
|
|
519
542
|
if (!p)
|
|
520
|
-
|
|
543
|
+
h.set(y.propertyName, y);
|
|
521
544
|
else {
|
|
522
545
|
const E = p.attestationCreatedAt || p.createdAt || 0;
|
|
523
|
-
(y.attestationCreatedAt || y.createdAt || 0) > E &&
|
|
546
|
+
(y.attestationCreatedAt || y.createdAt || 0) > E && h.set(y.propertyName, y);
|
|
524
547
|
}
|
|
525
548
|
}
|
|
526
|
-
return Array.from(
|
|
527
|
-
}, [
|
|
528
|
-
return
|
|
549
|
+
return Array.from(h.values());
|
|
550
|
+
}, [b]);
|
|
551
|
+
return w(() => {
|
|
529
552
|
if (!t || !a && !s || v === void 0) return;
|
|
530
|
-
const
|
|
553
|
+
const h = JSON.stringify(
|
|
531
554
|
v.map((y) => ({
|
|
532
555
|
propertyName: y.propertyName,
|
|
533
556
|
propertyValue: y.propertyValue,
|
|
@@ -535,8 +558,8 @@ function mr(e) {
|
|
|
535
558
|
seedUid: y.seedUid
|
|
536
559
|
})).sort((y, p) => (y.propertyName || "").localeCompare(p.propertyName || ""))
|
|
537
560
|
);
|
|
538
|
-
n.current !==
|
|
539
|
-
}, [t, v, i, a, s, r,
|
|
561
|
+
n.current !== h && (n.current = h, v.length > 0 && r.invalidateQueries({ queryKey: l }));
|
|
562
|
+
}, [t, v, i, a, s, r, l]), w(() => {
|
|
540
563
|
n.current = void 0;
|
|
541
564
|
}, [a, s]), {
|
|
542
565
|
properties: i,
|
|
@@ -544,29 +567,29 @@ function mr(e) {
|
|
|
544
567
|
error: u
|
|
545
568
|
};
|
|
546
569
|
}
|
|
547
|
-
const
|
|
548
|
-
const e =
|
|
549
|
-
if (!
|
|
570
|
+
const vr = () => {
|
|
571
|
+
const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((c) => {
|
|
572
|
+
if (!c.propertyName || !c.seedLocalId && !c.seedUid || !c.modelName) {
|
|
550
573
|
const d = new Error("seedLocalId or seedUid, propertyName, and modelName are required");
|
|
551
574
|
o(d);
|
|
552
575
|
return;
|
|
553
576
|
}
|
|
554
577
|
o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
578
|
+
const l = ie.create(c, { waitForReady: !1 });
|
|
579
|
+
if (!l) {
|
|
557
580
|
o(new Error("Failed to create item property")), r(!1);
|
|
558
581
|
return;
|
|
559
582
|
}
|
|
560
|
-
const i =
|
|
583
|
+
const i = l.getService().subscribe((d) => {
|
|
561
584
|
if (d?.value === "error") {
|
|
562
585
|
const u = d.context?._loadingError?.error ?? new Error("Failed to create item property");
|
|
563
586
|
o(u instanceof Error ? u : new Error(String(u))), r(!1);
|
|
564
587
|
}
|
|
565
588
|
d?.value === "idle" && (o(null), r(!1));
|
|
566
589
|
});
|
|
567
|
-
return e.current = i,
|
|
590
|
+
return e.current = i, l;
|
|
568
591
|
}, []);
|
|
569
|
-
return
|
|
592
|
+
return w(() => () => {
|
|
570
593
|
e.current?.unsubscribe(), e.current = void 0;
|
|
571
594
|
}, []), {
|
|
572
595
|
create: s,
|
|
@@ -574,26 +597,26 @@ const hr = () => {
|
|
|
574
597
|
error: n,
|
|
575
598
|
resetError: a
|
|
576
599
|
};
|
|
577
|
-
},
|
|
600
|
+
}, wr = () => {
|
|
578
601
|
const [e, t] = S(null), [r, n] = S({
|
|
579
602
|
isLoading: !1,
|
|
580
603
|
error: null
|
|
581
604
|
});
|
|
582
|
-
|
|
605
|
+
w(() => {
|
|
583
606
|
if (!e) {
|
|
584
607
|
n({ isLoading: !1, error: null });
|
|
585
608
|
return;
|
|
586
609
|
}
|
|
587
|
-
const s = e.getService(),
|
|
610
|
+
const s = e.getService(), c = () => {
|
|
588
611
|
const d = s.getSnapshot().context;
|
|
589
612
|
n({
|
|
590
613
|
isLoading: !!d._destroyInProgress,
|
|
591
614
|
error: d._destroyError ? new Error(d._destroyError.message) : null
|
|
592
615
|
});
|
|
593
616
|
};
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
return () =>
|
|
617
|
+
c();
|
|
618
|
+
const l = s.subscribe(c);
|
|
619
|
+
return () => l.unsubscribe();
|
|
597
620
|
}, [e]);
|
|
598
621
|
const o = x(async (s) => {
|
|
599
622
|
s && (t(s), await s.destroy());
|
|
@@ -606,14 +629,14 @@ const hr = () => {
|
|
|
606
629
|
error: r.error,
|
|
607
630
|
resetError: a
|
|
608
631
|
};
|
|
609
|
-
},
|
|
632
|
+
}, Ne = G("seedSdk:react:services"), Lt = ["idle", "ready", "done", "success", "initialized"], Je = (e) => {
|
|
610
633
|
let t = "actor";
|
|
611
634
|
const r = e;
|
|
612
|
-
return e && r.uniqueKey && (t = r.uniqueKey), e && !r.uniqueKey && r.logic && r.logic.config && (t =
|
|
613
|
-
},
|
|
635
|
+
return e && r.uniqueKey && (t = r.uniqueKey), e && !r.uniqueKey && r.logic && r.logic.config && (t = Re(e)), t;
|
|
636
|
+
}, ke = (e) => {
|
|
614
637
|
let t;
|
|
615
|
-
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value),
|
|
616
|
-
},
|
|
638
|
+
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), Je(e) === "global" && t && typeof t == "object" && Object.keys(t).length > 0 && Object.keys(t)[0] === "initialized" && (t = "ready"), t && typeof t == "object" && (t = JSON.stringify(t)), t;
|
|
639
|
+
}, Re = (e) => {
|
|
617
640
|
const t = e;
|
|
618
641
|
if (!e || !t.logic || !t.logic.config || !t._snapshot)
|
|
619
642
|
return;
|
|
@@ -626,36 +649,36 @@ const hr = () => {
|
|
|
626
649
|
try {
|
|
627
650
|
o = e.getSnapshot();
|
|
628
651
|
} catch (a) {
|
|
629
|
-
return
|
|
652
|
+
return Ne("Error:", a), n;
|
|
630
653
|
}
|
|
631
654
|
if (o) {
|
|
632
655
|
const a = o.context;
|
|
633
|
-
a && a.dbName && (n = a.dbName), a && a.modelNamePlural && (n = a.modelNamePlural), a && a.modelName && (n =
|
|
656
|
+
a && a.dbName && (n = a.dbName), a && a.modelNamePlural && (n = a.modelNamePlural), a && a.modelName && (n = vt(a.modelName.toLowerCase()));
|
|
634
657
|
}
|
|
635
658
|
return n;
|
|
636
|
-
},
|
|
659
|
+
}, Ir = (e) => {
|
|
637
660
|
const [t, r] = S(0), n = (s) => {
|
|
638
|
-
let
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
661
|
+
let c = 0;
|
|
662
|
+
const l = s;
|
|
663
|
+
if (l.logic?.states) {
|
|
641
664
|
const i = [], d = [];
|
|
642
|
-
for (const [
|
|
643
|
-
v.tags?.includes("loading") && (i.push(
|
|
644
|
-
const u = d.length, f =
|
|
645
|
-
if (f &&
|
|
665
|
+
for (const [b, v] of Object.entries(l.logic.states))
|
|
666
|
+
v.tags?.includes("loading") && (i.push(b), d.push(v));
|
|
667
|
+
const u = d.length, f = ke(s);
|
|
668
|
+
if (f && Lt.includes(f))
|
|
646
669
|
return 0;
|
|
647
|
-
f && (
|
|
670
|
+
f && (c = i.indexOf(f) / u * 100);
|
|
648
671
|
}
|
|
649
|
-
return
|
|
672
|
+
return c;
|
|
650
673
|
}, o = x(
|
|
651
674
|
(s) => {
|
|
652
675
|
e.getSnapshot().context;
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
676
|
+
const c = e.getSnapshot().value;
|
|
677
|
+
if (c === "done" || c === "success" || c === "idle" || c === "ready") {
|
|
655
678
|
clearInterval(s);
|
|
656
679
|
return;
|
|
657
680
|
}
|
|
658
|
-
r((
|
|
681
|
+
r((l) => l + 1);
|
|
659
682
|
},
|
|
660
683
|
[e]
|
|
661
684
|
), a = x(() => {
|
|
@@ -664,71 +687,71 @@ const hr = () => {
|
|
|
664
687
|
}, 1e3);
|
|
665
688
|
return s;
|
|
666
689
|
}, [o, e]);
|
|
667
|
-
return
|
|
690
|
+
return w(() => {
|
|
668
691
|
const s = a();
|
|
669
692
|
return () => clearInterval(s);
|
|
670
693
|
}, []), {
|
|
671
|
-
name:
|
|
694
|
+
name: Je(e),
|
|
672
695
|
timeElapsed: t,
|
|
673
|
-
value:
|
|
696
|
+
value: ke(e),
|
|
674
697
|
percentComplete: n(e),
|
|
675
|
-
uniqueKey:
|
|
698
|
+
uniqueKey: Re(e)
|
|
676
699
|
};
|
|
677
|
-
},
|
|
678
|
-
const [e, t] = S(!1), { internalStatus: r } =
|
|
679
|
-
return
|
|
700
|
+
}, At = () => {
|
|
701
|
+
const [e, t] = S(!1), { internalStatus: r } = _t();
|
|
702
|
+
return w(() => {
|
|
680
703
|
r === "ready" && t(!0);
|
|
681
|
-
}, [r]),
|
|
704
|
+
}, [r]), w(() => {
|
|
682
705
|
r === "ready" && t(!0);
|
|
683
706
|
}, []), e;
|
|
684
|
-
},
|
|
685
|
-
const [e, t] = S(!1), r =
|
|
686
|
-
for (const
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
`would save to db with snapshot__${
|
|
690
|
-
JSON.stringify(
|
|
707
|
+
}, Er = () => {
|
|
708
|
+
const [e, t] = S(!1), r = xt(), { services: n, percentComplete: o } = Nt(), a = x(async () => {
|
|
709
|
+
for (const c of n) {
|
|
710
|
+
const l = Re(c);
|
|
711
|
+
Ne(
|
|
712
|
+
`would save to db with snapshot__${l}:`,
|
|
713
|
+
JSON.stringify(c.getPersistedSnapshot())
|
|
691
714
|
);
|
|
692
715
|
}
|
|
693
716
|
}, [n]), s = x(async () => {
|
|
694
|
-
const
|
|
695
|
-
return
|
|
717
|
+
const c = j.getAppDb();
|
|
718
|
+
return c ? await c.select().from(fe).where(Qe(fe.key, "snapshot__%")) : [];
|
|
696
719
|
}, []);
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
720
|
+
w(() => !r || e ? void 0 : ((async () => {
|
|
721
|
+
const l = await s();
|
|
722
|
+
Ne("persistedSnapshots:", l), t(!0);
|
|
700
723
|
})(), () => {
|
|
701
724
|
a();
|
|
702
725
|
}), [r, e]);
|
|
703
|
-
},
|
|
704
|
-
const [e, t] = S(!1), r =
|
|
705
|
-
return
|
|
726
|
+
}, xt = () => {
|
|
727
|
+
const [e, t] = S(!1), r = At();
|
|
728
|
+
return w(() => {
|
|
706
729
|
r && (async () => {
|
|
707
|
-
const a = await
|
|
730
|
+
const a = await j.getAppDb().select().from(fe).where(Qe(fe.key, "snapshot__%"));
|
|
708
731
|
a && a.length > 0 && t(!0);
|
|
709
732
|
})();
|
|
710
733
|
}, [r]), e;
|
|
711
|
-
},
|
|
734
|
+
}, Nt = () => {
|
|
712
735
|
const [e, t] = S([]), [r, n] = S(5);
|
|
713
|
-
return
|
|
714
|
-
const a =
|
|
736
|
+
return w(() => {
|
|
737
|
+
const a = ge().getService(), s = a;
|
|
715
738
|
s.uniqueKey = "clientManager", t([s]);
|
|
716
|
-
const
|
|
717
|
-
const i =
|
|
739
|
+
const c = a.subscribe((l) => {
|
|
740
|
+
const i = l.value;
|
|
718
741
|
let d = 0;
|
|
719
|
-
i ===
|
|
742
|
+
i === P.IDLE ? d = 100 : i === P.ADD_MODELS_TO_DB ? d = 90 : i === P.ADD_MODELS_TO_STORE ? d = 80 : i === P.PROCESS_SCHEMA_FILES ? d = 70 : i === P.SAVE_CONFIG ? d = 60 : i === P.DB_INIT ? d = 50 : i === P.FILE_SYSTEM_INIT ? d = 30 : i === P.PLATFORM_CLASSES_INIT && (d = 10), n(d);
|
|
720
743
|
});
|
|
721
744
|
return () => {
|
|
722
|
-
|
|
745
|
+
c.unsubscribe();
|
|
723
746
|
};
|
|
724
747
|
}, []), {
|
|
725
748
|
services: e,
|
|
726
749
|
percentComplete: r
|
|
727
750
|
};
|
|
728
|
-
},
|
|
729
|
-
const t =
|
|
751
|
+
}, _t = () => {
|
|
752
|
+
const t = ge().getService(), r = Le(t, (o) => o.value), n = Le(t, (o) => {
|
|
730
753
|
const a = o.value;
|
|
731
|
-
return a ===
|
|
754
|
+
return a === P.DB_INIT || a === P.SAVE_CONFIG || a === P.PROCESS_SCHEMA_FILES || a === P.ADD_MODELS_TO_STORE || a === P.ADD_MODELS_TO_DB || a === P.IDLE ? "ready" : a;
|
|
732
755
|
});
|
|
733
756
|
return {
|
|
734
757
|
status: r,
|
|
@@ -736,21 +759,21 @@ const hr = () => {
|
|
|
736
759
|
};
|
|
737
760
|
};
|
|
738
761
|
G("seedSdk:react:db");
|
|
739
|
-
const
|
|
762
|
+
const Lr = () => {
|
|
740
763
|
const [e, t] = S(!1), r = x(() => {
|
|
741
764
|
e || t(!0);
|
|
742
765
|
}, []);
|
|
743
|
-
return
|
|
766
|
+
return w(() => {
|
|
744
767
|
let n;
|
|
745
768
|
return (async () => {
|
|
746
|
-
const s =
|
|
747
|
-
if (
|
|
769
|
+
const s = ge().getService(), c = s.getSnapshot().value;
|
|
770
|
+
if (c === P.DB_INIT || c === P.SAVE_CONFIG || c === P.PROCESS_SCHEMA_FILES || c === P.ADD_MODELS_TO_STORE || c === P.ADD_MODELS_TO_DB || c === P.IDLE) {
|
|
748
771
|
r();
|
|
749
772
|
return;
|
|
750
773
|
}
|
|
751
|
-
n = s.subscribe((
|
|
752
|
-
const i =
|
|
753
|
-
(i ===
|
|
774
|
+
n = s.subscribe((l) => {
|
|
775
|
+
const i = l.value;
|
|
776
|
+
(i === P.DB_INIT || i === P.SAVE_CONFIG || i === P.PROCESS_SCHEMA_FILES || i === P.ADD_MODELS_TO_STORE || i === P.ADD_MODELS_TO_DB || i === P.IDLE) && (r(), n?.unsubscribe());
|
|
754
777
|
});
|
|
755
778
|
})(), () => {
|
|
756
779
|
n && n.unsubscribe();
|
|
@@ -758,24 +781,24 @@ const Sr = () => {
|
|
|
758
781
|
}, []), {
|
|
759
782
|
dbsAreReady: e
|
|
760
783
|
};
|
|
761
|
-
},
|
|
762
|
-
const [t, r] = S(null), [n, o] = S(!!e), [a, s] = S(null),
|
|
784
|
+
}, Ge = G("seedSdk:react:schema"), Dt = (e) => {
|
|
785
|
+
const [t, r] = S(null), [n, o] = S(!!e), [a, s] = S(null), c = C(null), l = Q(), i = x((d) => {
|
|
763
786
|
o(!0), s(null);
|
|
764
787
|
try {
|
|
765
|
-
const u =
|
|
788
|
+
const u = be.create(d, {
|
|
766
789
|
waitForReady: !1
|
|
767
790
|
});
|
|
768
791
|
r(u);
|
|
769
792
|
const f = u.getService();
|
|
770
|
-
f.getSnapshot().value === "idle" ? (
|
|
771
|
-
|
|
793
|
+
f.getSnapshot().value === "idle" ? (ue(() => o(!1)), s(null)) : o(!0), c.current = f.subscribe((h) => {
|
|
794
|
+
h.value === "idle" ? (ue(() => o(!1)), s(null)) : o(!0);
|
|
772
795
|
});
|
|
773
796
|
} catch (u) {
|
|
774
|
-
return
|
|
797
|
+
return Ge("[useSchema] Error creating schema:", u), s(u), r(null), o(!1), null;
|
|
775
798
|
}
|
|
776
799
|
}, []);
|
|
777
|
-
return
|
|
778
|
-
if (
|
|
800
|
+
return w(() => {
|
|
801
|
+
if (c.current && (c.current.unsubscribe(), c.current = null), !l) {
|
|
779
802
|
r(null), s(null), o(!1);
|
|
780
803
|
return;
|
|
781
804
|
}
|
|
@@ -784,75 +807,75 @@ const Sr = () => {
|
|
|
784
807
|
return;
|
|
785
808
|
}
|
|
786
809
|
return i(e), () => {
|
|
787
|
-
|
|
810
|
+
c.current && (c.current.unsubscribe(), c.current = null);
|
|
788
811
|
};
|
|
789
|
-
}, [e,
|
|
812
|
+
}, [e, l, i]), {
|
|
790
813
|
schema: t,
|
|
791
814
|
isLoading: n,
|
|
792
815
|
error: a
|
|
793
816
|
};
|
|
794
|
-
},
|
|
795
|
-
const e =
|
|
817
|
+
}, we = ["seed", "schemas"], Ar = () => {
|
|
818
|
+
const e = Q(), t = Z(), r = C(void 0), n = C([]), {
|
|
796
819
|
data: o = [],
|
|
797
820
|
isLoading: a,
|
|
798
821
|
error: s
|
|
799
|
-
} =
|
|
800
|
-
queryKey:
|
|
801
|
-
queryFn: () =>
|
|
822
|
+
} = ee({
|
|
823
|
+
queryKey: we,
|
|
824
|
+
queryFn: () => be.all({ waitForReady: !0 }),
|
|
802
825
|
enabled: e
|
|
803
826
|
});
|
|
804
827
|
n.current = o;
|
|
805
|
-
const
|
|
806
|
-
return
|
|
828
|
+
const c = e ? j.getAppDb() : null, l = N(() => c ? c.select().from(X).orderBy(X.name, Ve(X.version)) : null, [c, e]), i = Y(l);
|
|
829
|
+
return w(() => {
|
|
807
830
|
if (typeof BroadcastChannel > "u") return;
|
|
808
831
|
const d = new BroadcastChannel("seed-schemas-invalidate"), u = () => {
|
|
809
|
-
t.invalidateQueries({ queryKey:
|
|
832
|
+
t.invalidateQueries({ queryKey: we });
|
|
810
833
|
};
|
|
811
834
|
return d.addEventListener("message", u), () => {
|
|
812
835
|
d.removeEventListener("message", u), d.close();
|
|
813
836
|
};
|
|
814
|
-
}, [t]),
|
|
837
|
+
}, [t]), w(() => {
|
|
815
838
|
if (!e || !i)
|
|
816
839
|
return;
|
|
817
840
|
const d = r.current, u = d ? JSON.stringify(d) : "undefined", f = i ? JSON.stringify(i) : "undefined";
|
|
818
841
|
if (u === f && d !== void 0)
|
|
819
842
|
return;
|
|
820
843
|
r.current = i;
|
|
821
|
-
const
|
|
844
|
+
const b = /* @__PURE__ */ new Set();
|
|
822
845
|
for (const p of n.current) {
|
|
823
846
|
const E = p.id || p.schemaFileId;
|
|
824
847
|
if (E)
|
|
825
|
-
|
|
848
|
+
b.add(E);
|
|
826
849
|
else {
|
|
827
|
-
const
|
|
828
|
-
|
|
850
|
+
const I = p.metadata?.name, m = p.version;
|
|
851
|
+
I && m !== void 0 && b.add(`${I}:${m}`);
|
|
829
852
|
}
|
|
830
853
|
}
|
|
831
854
|
const v = /* @__PURE__ */ new Set();
|
|
832
855
|
for (const p of i)
|
|
833
856
|
p.name !== "Seed Protocol" && (p.schemaFileId ? v.add(p.schemaFileId) : p.name != null && p.version !== void 0 && v.add(`${p.name}:${p.version}`));
|
|
834
|
-
const
|
|
835
|
-
!
|
|
857
|
+
const h = b.size === v.size && [...b].every((p) => v.has(p)), y = b.size > 0 && v.size > 0 && [...v].some((p) => !b.has(p));
|
|
858
|
+
!h && y && t.invalidateQueries({ queryKey: we });
|
|
836
859
|
}, [e, i, t]), {
|
|
837
860
|
schemas: o,
|
|
838
861
|
isLoading: a,
|
|
839
862
|
error: s
|
|
840
863
|
};
|
|
841
|
-
},
|
|
842
|
-
const e =
|
|
864
|
+
}, xr = () => {
|
|
865
|
+
const e = C(null), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x((c) => {
|
|
843
866
|
o(null), r(!0), e.current?.unsubscribe(), e.current = null;
|
|
844
|
-
const
|
|
867
|
+
const l = be.create(c, {
|
|
845
868
|
waitForReady: !1
|
|
846
|
-
}), i =
|
|
869
|
+
}), i = l.getService().subscribe((d) => {
|
|
847
870
|
if (d.value === "error") {
|
|
848
871
|
const u = d.context._loadingError?.error;
|
|
849
872
|
o(u instanceof Error ? u : new Error("Failed to create schema")), r(!1);
|
|
850
873
|
}
|
|
851
874
|
d.value === "idle" && (o(null), r(!1));
|
|
852
875
|
});
|
|
853
|
-
return e.current = i,
|
|
876
|
+
return e.current = i, l;
|
|
854
877
|
}, []);
|
|
855
|
-
return
|
|
878
|
+
return w(() => () => {
|
|
856
879
|
e.current?.unsubscribe(), e.current = null;
|
|
857
880
|
}, []), {
|
|
858
881
|
createSchema: s,
|
|
@@ -860,26 +883,26 @@ const Sr = () => {
|
|
|
860
883
|
error: n,
|
|
861
884
|
resetError: a
|
|
862
885
|
};
|
|
863
|
-
},
|
|
886
|
+
}, Nr = () => {
|
|
864
887
|
const [e, t] = S(null), [r, n] = S({
|
|
865
888
|
isLoading: !1,
|
|
866
889
|
error: null
|
|
867
890
|
});
|
|
868
|
-
|
|
891
|
+
w(() => {
|
|
869
892
|
if (!e) {
|
|
870
893
|
n({ isLoading: !1, error: null });
|
|
871
894
|
return;
|
|
872
895
|
}
|
|
873
|
-
const s = e.getService(),
|
|
896
|
+
const s = e.getService(), c = () => {
|
|
874
897
|
const d = s.getSnapshot().context;
|
|
875
898
|
n({
|
|
876
899
|
isLoading: !!d._destroyInProgress,
|
|
877
900
|
error: d._destroyError ? new Error(d._destroyError.message) : null
|
|
878
901
|
});
|
|
879
902
|
};
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
return () =>
|
|
903
|
+
c();
|
|
904
|
+
const l = s.subscribe(c);
|
|
905
|
+
return () => l.unsubscribe();
|
|
883
906
|
}, [e]);
|
|
884
907
|
const o = x(async (s) => {
|
|
885
908
|
s && (t(s), await s.destroy());
|
|
@@ -892,49 +915,49 @@ const Sr = () => {
|
|
|
892
915
|
error: r.error,
|
|
893
916
|
resetError: a
|
|
894
917
|
};
|
|
895
|
-
},
|
|
896
|
-
const [e, t] = S(), r =
|
|
918
|
+
}, _r = () => {
|
|
919
|
+
const [e, t] = S(), r = C(/* @__PURE__ */ new Map()), n = Q(), o = x(async () => {
|
|
897
920
|
if (n)
|
|
898
921
|
try {
|
|
899
|
-
const a = await
|
|
900
|
-
for (const
|
|
901
|
-
const i =
|
|
922
|
+
const a = await ct(), s = /* @__PURE__ */ new Set();
|
|
923
|
+
for (const l of a) {
|
|
924
|
+
const i = l.schema.metadata?.name;
|
|
902
925
|
i && s.add(i);
|
|
903
926
|
}
|
|
904
|
-
const
|
|
905
|
-
for (const
|
|
906
|
-
if (r.current.has(
|
|
907
|
-
const i = r.current.get(
|
|
908
|
-
|
|
927
|
+
const c = /* @__PURE__ */ new Map();
|
|
928
|
+
for (const l of s)
|
|
929
|
+
if (r.current.has(l)) {
|
|
930
|
+
const i = r.current.get(l);
|
|
931
|
+
c.set(l, i);
|
|
909
932
|
} else {
|
|
910
|
-
const i =
|
|
933
|
+
const i = be.create(l, {
|
|
911
934
|
waitForReady: !1
|
|
912
935
|
});
|
|
913
|
-
|
|
936
|
+
c.set(l, i);
|
|
914
937
|
}
|
|
915
|
-
for (const [
|
|
916
|
-
s.has(
|
|
917
|
-
r.current =
|
|
938
|
+
for (const [l, i] of r.current.entries())
|
|
939
|
+
s.has(l) || i.unload();
|
|
940
|
+
r.current = c, t(Array.from(c.values()));
|
|
918
941
|
} catch (a) {
|
|
919
|
-
|
|
942
|
+
Ge("Error fetching all schema versions from database:", a), t(null);
|
|
920
943
|
}
|
|
921
944
|
}, [n]);
|
|
922
|
-
return
|
|
945
|
+
return w(() => {
|
|
923
946
|
n && o();
|
|
924
|
-
}, [n, o]),
|
|
947
|
+
}, [n, o]), w(() => () => {
|
|
925
948
|
r.current.forEach((a) => {
|
|
926
949
|
a.unload();
|
|
927
950
|
}), r.current.clear();
|
|
928
951
|
}, []), e;
|
|
929
|
-
},
|
|
930
|
-
const t =
|
|
952
|
+
}, Dr = () => Dt(lt), Ft = (e) => ["seed", "models", e], $e = /* @__PURE__ */ new Map(), Ct = (e) => {
|
|
953
|
+
const t = Q(), r = Z(), n = C([]), o = N(() => Ft(e), [e]), {
|
|
931
954
|
data: a = [],
|
|
932
955
|
isLoading: s,
|
|
933
|
-
error:
|
|
934
|
-
} =
|
|
956
|
+
error: c
|
|
957
|
+
} = ee({
|
|
935
958
|
queryKey: o,
|
|
936
959
|
queryFn: async () => {
|
|
937
|
-
const y = r.getQueryData(o), p = await
|
|
960
|
+
const y = r.getQueryData(o), p = await ae.all(e, { waitForReady: !1 });
|
|
938
961
|
if (Array.isArray(y) && y.length > 0 && Array.isArray(p) && p.length === 0)
|
|
939
962
|
return [...y];
|
|
940
963
|
if (Array.isArray(p) && p.length === 0) {
|
|
@@ -945,74 +968,74 @@ const Sr = () => {
|
|
|
945
968
|
return p;
|
|
946
969
|
},
|
|
947
970
|
enabled: t && !!e
|
|
948
|
-
}),
|
|
949
|
-
a.length > 0 &&
|
|
950
|
-
const i = n.current.length > 0 ? n.current :
|
|
951
|
-
n.current = d,
|
|
971
|
+
}), l = e && typeof e == "string" ? e : "";
|
|
972
|
+
a.length > 0 && $e.set(l, a);
|
|
973
|
+
const i = n.current.length > 0 ? n.current : $e.get(l), d = e ? a.length > 0 ? a : i?.length ? i : a : a;
|
|
974
|
+
n.current = d, w(() => {
|
|
952
975
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
953
976
|
const y = new BroadcastChannel("seed-models-invalidate"), p = (E) => {
|
|
954
|
-
const { schemaName:
|
|
955
|
-
(e ===
|
|
977
|
+
const { schemaName: I, schemaFileId: m } = E.data || {};
|
|
978
|
+
(e === I || e === m) && (r.invalidateQueries({ queryKey: o }), r.refetchQueries({ queryKey: o }));
|
|
956
979
|
};
|
|
957
980
|
return y.addEventListener("message", p), () => {
|
|
958
981
|
y.removeEventListener("message", p), y.close();
|
|
959
982
|
};
|
|
960
983
|
}, [e, r, o]);
|
|
961
|
-
const u =
|
|
962
|
-
function
|
|
963
|
-
const y =
|
|
984
|
+
const u = C(null), f = C(null);
|
|
985
|
+
function b() {
|
|
986
|
+
const y = j.getAppDb();
|
|
964
987
|
return !y || !e ? null : y.select({
|
|
965
|
-
modelFileId:
|
|
966
|
-
modelName:
|
|
967
|
-
}).from(
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
988
|
+
modelFileId: ce.schemaFileId,
|
|
989
|
+
modelName: ce.name
|
|
990
|
+
}).from(X).innerJoin(ve, q(X.id, ve.schemaId)).innerJoin(ce, q(ve.modelId, ce.id)).where(
|
|
991
|
+
re(
|
|
992
|
+
q(X.schemaFileId, e),
|
|
993
|
+
q(X.name, e)
|
|
971
994
|
)
|
|
972
995
|
);
|
|
973
996
|
}
|
|
974
|
-
const v =
|
|
997
|
+
const v = N(() => {
|
|
975
998
|
if (!e || !t) return null;
|
|
976
999
|
const y = { schemaId: e, ready: t }, p = u.current;
|
|
977
1000
|
if (p && p.schemaId === y.schemaId && p.ready === y.ready && f.current !== null)
|
|
978
1001
|
return f.current;
|
|
979
|
-
const E =
|
|
1002
|
+
const E = b();
|
|
980
1003
|
return E ? (u.current = y, f.current = E, E) : null;
|
|
981
|
-
}, [e, t]),
|
|
982
|
-
return
|
|
983
|
-
if (!t || !
|
|
1004
|
+
}, [e, t]), h = Y(v);
|
|
1005
|
+
return w(() => {
|
|
1006
|
+
if (!t || !h || !e) return;
|
|
984
1007
|
const y = /* @__PURE__ */ new Set();
|
|
985
1008
|
for (const m of n.current) {
|
|
986
|
-
const
|
|
987
|
-
|
|
1009
|
+
const _ = m.id || m.modelFileId;
|
|
1010
|
+
_ ? y.add(_) : m.modelName && y.add(m.modelName);
|
|
988
1011
|
}
|
|
989
1012
|
const p = /* @__PURE__ */ new Set();
|
|
990
|
-
for (const m of
|
|
1013
|
+
for (const m of h)
|
|
991
1014
|
m.modelFileId ? p.add(m.modelFileId) : m.modelName && p.add(m.modelName);
|
|
992
|
-
const E = y.size === p.size && [...y].every((m) => p.has(m)),
|
|
993
|
-
!E &&
|
|
994
|
-
}, [t,
|
|
1015
|
+
const E = y.size === p.size && [...y].every((m) => p.has(m)), I = p.size > 0 && [...p].some((m) => !y.has(m));
|
|
1016
|
+
!E && I && r.invalidateQueries({ queryKey: o });
|
|
1017
|
+
}, [t, h, e, r, o]), {
|
|
995
1018
|
models: d,
|
|
996
1019
|
isLoading: s,
|
|
997
|
-
error:
|
|
1020
|
+
error: c
|
|
998
1021
|
};
|
|
999
|
-
},
|
|
1000
|
-
const r =
|
|
1001
|
-
if (
|
|
1022
|
+
}, Rt = (e, t) => {
|
|
1023
|
+
const r = Q(), [n, o] = S(void 0), [a, s] = S(!1), [c, l] = S(null), i = C(void 0), [, d] = S(0), u = t == null;
|
|
1024
|
+
if (N(() => r ? u ? !!e : !!(e && t) : !1, [r, u, e, t]), w(() => {
|
|
1002
1025
|
if (!r || !u || !e) {
|
|
1003
|
-
o(void 0), s(!1),
|
|
1026
|
+
o(void 0), s(!1), l(null);
|
|
1004
1027
|
return;
|
|
1005
1028
|
}
|
|
1006
1029
|
(async () => {
|
|
1007
1030
|
try {
|
|
1008
|
-
s(!0),
|
|
1009
|
-
const p = await
|
|
1010
|
-
o(p || void 0), s(!1),
|
|
1031
|
+
s(!0), l(null);
|
|
1032
|
+
const p = await ae.createById(e);
|
|
1033
|
+
o(p || void 0), s(!1), l(null);
|
|
1011
1034
|
} catch (p) {
|
|
1012
|
-
console.error("[useModel] Error looking up model by ID:", p), o(void 0), s(!1),
|
|
1035
|
+
console.error("[useModel] Error looking up model by ID:", p), o(void 0), s(!1), l(p);
|
|
1013
1036
|
}
|
|
1014
1037
|
})();
|
|
1015
|
-
}, [r, u, e]),
|
|
1038
|
+
}, [r, u, e]), w(() => {
|
|
1016
1039
|
if (!u || !n) {
|
|
1017
1040
|
i.current?.unsubscribe(), i.current = void 0;
|
|
1018
1041
|
return;
|
|
@@ -1028,34 +1051,34 @@ const Sr = () => {
|
|
|
1028
1051
|
return {
|
|
1029
1052
|
model: n,
|
|
1030
1053
|
isLoading: a,
|
|
1031
|
-
error:
|
|
1054
|
+
error: c
|
|
1032
1055
|
};
|
|
1033
|
-
const { models: f, isLoading:
|
|
1056
|
+
const { models: f, isLoading: b, error: v } = Ct(e), h = N(() => {
|
|
1034
1057
|
if (t)
|
|
1035
1058
|
return f.find((y) => (y.modelName ?? y.name) === t);
|
|
1036
1059
|
}, [f, t]);
|
|
1037
|
-
return
|
|
1038
|
-
if (u || !
|
|
1060
|
+
return w(() => {
|
|
1061
|
+
if (u || !h) {
|
|
1039
1062
|
i.current?.unsubscribe(), i.current = void 0;
|
|
1040
1063
|
return;
|
|
1041
1064
|
}
|
|
1042
1065
|
i.current?.unsubscribe();
|
|
1043
|
-
const y =
|
|
1066
|
+
const y = h.getService().subscribe((p) => {
|
|
1044
1067
|
d((E) => E + 1);
|
|
1045
1068
|
});
|
|
1046
1069
|
return i.current = y, () => {
|
|
1047
1070
|
i.current?.unsubscribe(), i.current = void 0;
|
|
1048
1071
|
};
|
|
1049
|
-
}, [u,
|
|
1050
|
-
model:
|
|
1051
|
-
isLoading:
|
|
1072
|
+
}, [u, h]), {
|
|
1073
|
+
model: h,
|
|
1074
|
+
isLoading: b,
|
|
1052
1075
|
error: v
|
|
1053
1076
|
};
|
|
1054
|
-
},
|
|
1055
|
-
const e =
|
|
1056
|
-
(
|
|
1077
|
+
}, Fr = () => {
|
|
1078
|
+
const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
|
|
1079
|
+
(c, l, i) => {
|
|
1057
1080
|
o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
1058
|
-
const d =
|
|
1081
|
+
const d = ae.create(l, c, {
|
|
1059
1082
|
...i,
|
|
1060
1083
|
waitForReady: !1
|
|
1061
1084
|
}), u = d.getService().subscribe((f) => {
|
|
@@ -1067,7 +1090,7 @@ const Sr = () => {
|
|
|
1067
1090
|
},
|
|
1068
1091
|
[]
|
|
1069
1092
|
);
|
|
1070
|
-
return
|
|
1093
|
+
return w(() => () => {
|
|
1071
1094
|
e.current?.unsubscribe(), e.current = void 0;
|
|
1072
1095
|
}, []), {
|
|
1073
1096
|
create: s,
|
|
@@ -1075,26 +1098,26 @@ const Sr = () => {
|
|
|
1075
1098
|
error: n,
|
|
1076
1099
|
resetError: a
|
|
1077
1100
|
};
|
|
1078
|
-
},
|
|
1101
|
+
}, Cr = () => {
|
|
1079
1102
|
const [e, t] = S(null), [r, n] = S({
|
|
1080
1103
|
isLoading: !1,
|
|
1081
1104
|
error: null
|
|
1082
1105
|
});
|
|
1083
|
-
|
|
1106
|
+
w(() => {
|
|
1084
1107
|
if (!e) {
|
|
1085
1108
|
n({ isLoading: !1, error: null });
|
|
1086
1109
|
return;
|
|
1087
1110
|
}
|
|
1088
|
-
const s = e.getService(),
|
|
1111
|
+
const s = e.getService(), c = () => {
|
|
1089
1112
|
const d = s.getSnapshot().context;
|
|
1090
1113
|
n({
|
|
1091
1114
|
isLoading: !!d._destroyInProgress,
|
|
1092
1115
|
error: d._destroyError ? new Error(d._destroyError.message) : null
|
|
1093
1116
|
});
|
|
1094
1117
|
};
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1097
|
-
return () =>
|
|
1118
|
+
c();
|
|
1119
|
+
const l = s.subscribe(c);
|
|
1120
|
+
return () => l.unsubscribe();
|
|
1098
1121
|
}, [e]);
|
|
1099
1122
|
const o = x(async (s) => {
|
|
1100
1123
|
s && (t(s), await s.destroy());
|
|
@@ -1109,9 +1132,9 @@ const Sr = () => {
|
|
|
1109
1132
|
};
|
|
1110
1133
|
};
|
|
1111
1134
|
G("seedSdk:browser:react:modelProperty");
|
|
1112
|
-
const
|
|
1113
|
-
const { model: r } =
|
|
1114
|
-
|
|
1135
|
+
const Rr = (e, t) => {
|
|
1136
|
+
const { model: r } = Rt(e, t);
|
|
1137
|
+
N(() => {
|
|
1115
1138
|
if (r)
|
|
1116
1139
|
try {
|
|
1117
1140
|
return r.modelName ?? r.name;
|
|
@@ -1119,155 +1142,155 @@ const Fr = (e, t) => {
|
|
|
1119
1142
|
return;
|
|
1120
1143
|
}
|
|
1121
1144
|
}, [r]);
|
|
1122
|
-
const n =
|
|
1145
|
+
const n = Q(), o = Z(), a = N(() => {
|
|
1123
1146
|
if (!r) return null;
|
|
1124
1147
|
try {
|
|
1125
1148
|
return r._getSnapshotContext()._dbId;
|
|
1126
1149
|
} catch {
|
|
1127
1150
|
return null;
|
|
1128
1151
|
}
|
|
1129
|
-
}, [r]), s = r?.id,
|
|
1152
|
+
}, [r]), s = r?.id, c = N(
|
|
1130
1153
|
() => ["seed", "modelProperties", s ?? ""],
|
|
1131
1154
|
[s]
|
|
1132
1155
|
), {
|
|
1133
|
-
data:
|
|
1156
|
+
data: l = [],
|
|
1134
1157
|
isLoading: i,
|
|
1135
1158
|
error: d
|
|
1136
|
-
} =
|
|
1137
|
-
queryKey:
|
|
1138
|
-
queryFn: () =>
|
|
1159
|
+
} = ee({
|
|
1160
|
+
queryKey: c,
|
|
1161
|
+
queryFn: () => ye.all(s, { waitForReady: !0 }),
|
|
1139
1162
|
enabled: n && !!s
|
|
1140
|
-
}), u = n ?
|
|
1141
|
-
id:
|
|
1142
|
-
name:
|
|
1143
|
-
dataType:
|
|
1144
|
-
schemaFileId:
|
|
1145
|
-
}).from(
|
|
1146
|
-
v.current =
|
|
1147
|
-
if (!s ||
|
|
1163
|
+
}), u = n ? j.getAppDb() : null, f = N(() => !u || !a ? null : u.select({
|
|
1164
|
+
id: te.id,
|
|
1165
|
+
name: te.name,
|
|
1166
|
+
dataType: te.dataType,
|
|
1167
|
+
schemaFileId: te.schemaFileId
|
|
1168
|
+
}).from(te).where(q(te.modelId, a)), [u, n, a]), b = Y(f), v = C([]);
|
|
1169
|
+
v.current = l, w(() => {
|
|
1170
|
+
if (!s || l.length > 0 || !o || !c) return;
|
|
1148
1171
|
const p = [400, 1200, 2500].map(
|
|
1149
1172
|
(E) => setTimeout(() => {
|
|
1150
|
-
o.invalidateQueries({ queryKey:
|
|
1173
|
+
o.invalidateQueries({ queryKey: c });
|
|
1151
1174
|
}, E)
|
|
1152
1175
|
);
|
|
1153
1176
|
return () => p.forEach((E) => clearTimeout(E));
|
|
1154
|
-
}, [s,
|
|
1155
|
-
if (!n || !r?.id || !
|
|
1177
|
+
}, [s, l.length, o, c]), w(() => {
|
|
1178
|
+
if (!n || !r?.id || !b || !c) return;
|
|
1156
1179
|
const y = /* @__PURE__ */ new Set();
|
|
1157
1180
|
for (const m of v.current) {
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1181
|
+
const R = m._getSnapshotContext()?.id;
|
|
1182
|
+
R ? y.add(R) : m.name && y.add(m.name);
|
|
1160
1183
|
}
|
|
1161
1184
|
const p = /* @__PURE__ */ new Set();
|
|
1162
|
-
for (const m of
|
|
1185
|
+
for (const m of b)
|
|
1163
1186
|
m.schemaFileId ? p.add(m.schemaFileId) : m.name && p.add(m.name);
|
|
1164
|
-
!(y.size === p.size && (y.size === 0 || [...y].every((m) => p.has(m)))) && (y.size > 0 || p.size > 0) && o.invalidateQueries({ queryKey:
|
|
1165
|
-
}, [n,
|
|
1166
|
-
const
|
|
1187
|
+
!(y.size === p.size && (y.size === 0 || [...y].every((m) => p.has(m)))) && (y.size > 0 || p.size > 0) && o.invalidateQueries({ queryKey: c });
|
|
1188
|
+
}, [n, b, r?.id, o, c]);
|
|
1189
|
+
const h = i && l.length === 0;
|
|
1167
1190
|
return {
|
|
1168
|
-
modelProperties:
|
|
1169
|
-
isLoading:
|
|
1191
|
+
modelProperties: l,
|
|
1192
|
+
isLoading: h,
|
|
1170
1193
|
error: d
|
|
1171
1194
|
};
|
|
1172
|
-
},
|
|
1173
|
-
const r = await
|
|
1195
|
+
}, Pt = async (e, t) => {
|
|
1196
|
+
const r = await ae.createById(e);
|
|
1174
1197
|
if (!r)
|
|
1175
1198
|
return;
|
|
1176
1199
|
const n = r.modelName ?? r.name;
|
|
1177
1200
|
if (n)
|
|
1178
|
-
return
|
|
1201
|
+
return ze(n, t);
|
|
1179
1202
|
};
|
|
1180
|
-
function
|
|
1181
|
-
const n =
|
|
1203
|
+
function Pr(e, t, r) {
|
|
1204
|
+
const n = N(() => r != null ? !!(e && t && r) : t != null ? !!(e && t) : !!e, [e, t, r]), [o, a] = S(void 0), [s, c] = S(n), [l, i] = S(null), d = C(void 0), u = Q(), f = N(() => r != null ? { type: "schemaId", schemaId: e, modelName: t, propertyName: r } : t != null ? { type: "modelFileId", modelFileId: e, propertyName: t } : { type: "propertyFileId", propertyFileId: e }, [e, t, r]), b = N(() => u ? f.type === "propertyFileId" ? !!f.propertyFileId : f.type === "modelFileId" ? !!(f.modelFileId && f.propertyName) : !!(f.schemaId && f.modelName && f.propertyName) : !1, [u, f]), v = x(async () => {
|
|
1182
1205
|
if (!u) {
|
|
1183
|
-
a(void 0),
|
|
1206
|
+
a(void 0), c(!1), i(null);
|
|
1184
1207
|
return;
|
|
1185
1208
|
}
|
|
1186
1209
|
let y, p;
|
|
1187
1210
|
try {
|
|
1188
|
-
if (
|
|
1211
|
+
if (c(!0), i(null), f.type === "propertyFileId") {
|
|
1189
1212
|
if (!f.propertyFileId) {
|
|
1190
|
-
a(void 0),
|
|
1213
|
+
a(void 0), c(!1), i(null);
|
|
1191
1214
|
return;
|
|
1192
1215
|
}
|
|
1193
|
-
const E = await
|
|
1194
|
-
E ? (a(E),
|
|
1216
|
+
const E = await ye.createById(f.propertyFileId);
|
|
1217
|
+
E ? (a(E), c(!1), i(null)) : (a(void 0), c(!1), i(null));
|
|
1195
1218
|
return;
|
|
1196
1219
|
} else if (f.type === "modelFileId") {
|
|
1197
1220
|
if (!f.modelFileId || !f.propertyName) {
|
|
1198
|
-
a(void 0),
|
|
1221
|
+
a(void 0), c(!1), i(null);
|
|
1199
1222
|
return;
|
|
1200
1223
|
}
|
|
1201
|
-
y = await
|
|
1202
|
-
const E = await
|
|
1224
|
+
y = await Pt(f.modelFileId, f.propertyName);
|
|
1225
|
+
const E = await ae.createById(f.modelFileId);
|
|
1203
1226
|
p = E?.modelName ?? E?.name;
|
|
1204
1227
|
} else {
|
|
1205
1228
|
if (!f.schemaId || !f.modelName || !f.propertyName) {
|
|
1206
|
-
a(void 0),
|
|
1229
|
+
a(void 0), c(!1), i(null);
|
|
1207
1230
|
return;
|
|
1208
1231
|
}
|
|
1209
|
-
y = await
|
|
1232
|
+
y = await ze(f.modelName, f.propertyName), p = f.modelName;
|
|
1210
1233
|
}
|
|
1211
1234
|
if (y && p) {
|
|
1212
|
-
const E =
|
|
1235
|
+
const E = ye.create(
|
|
1213
1236
|
{ ...y, modelName: p },
|
|
1214
1237
|
{ waitForReady: !1 }
|
|
1215
|
-
),
|
|
1216
|
-
|
|
1217
|
-
a(
|
|
1238
|
+
), I = E instanceof Promise ? await E : E;
|
|
1239
|
+
ue(() => {
|
|
1240
|
+
a(I), c(!1), i(null);
|
|
1218
1241
|
});
|
|
1219
1242
|
} else
|
|
1220
|
-
a(void 0),
|
|
1243
|
+
a(void 0), c(!1), i(null);
|
|
1221
1244
|
} catch (E) {
|
|
1222
|
-
console.error("[useModelProperty] Error updating model property:", E), a(void 0),
|
|
1245
|
+
console.error("[useModelProperty] Error updating model property:", E), a(void 0), c(!1), i(E);
|
|
1223
1246
|
}
|
|
1224
1247
|
}, [u, f.type, f.propertyFileId, f.modelFileId, f.propertyName, f.schemaId, f.modelName]);
|
|
1225
|
-
|
|
1226
|
-
if (!
|
|
1227
|
-
a(void 0),
|
|
1248
|
+
w(() => {
|
|
1249
|
+
if (!b) {
|
|
1250
|
+
a(void 0), c(!1), i(null);
|
|
1228
1251
|
return;
|
|
1229
1252
|
}
|
|
1230
1253
|
v();
|
|
1231
|
-
}, [
|
|
1232
|
-
const
|
|
1233
|
-
return
|
|
1234
|
-
if (!o || !
|
|
1254
|
+
}, [b, v]);
|
|
1255
|
+
const h = f.type === "propertyFileId";
|
|
1256
|
+
return w(() => {
|
|
1257
|
+
if (!o || !h)
|
|
1235
1258
|
return;
|
|
1236
1259
|
d.current?.unsubscribe();
|
|
1237
|
-
const y =
|
|
1260
|
+
const y = He(v, 100), p = o.getService().subscribe(() => {
|
|
1238
1261
|
y();
|
|
1239
1262
|
});
|
|
1240
1263
|
return d.current = p, () => {
|
|
1241
1264
|
y.cancel(), d.current?.unsubscribe(), d.current = void 0;
|
|
1242
1265
|
};
|
|
1243
|
-
}, [o, v,
|
|
1266
|
+
}, [o, v, h]), {
|
|
1244
1267
|
modelProperty: o,
|
|
1245
1268
|
isLoading: s,
|
|
1246
|
-
error:
|
|
1269
|
+
error: l
|
|
1247
1270
|
};
|
|
1248
1271
|
}
|
|
1249
|
-
const
|
|
1250
|
-
const e =
|
|
1251
|
-
(
|
|
1252
|
-
if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !
|
|
1253
|
-
const
|
|
1254
|
-
throw o(
|
|
1272
|
+
const Tr = () => {
|
|
1273
|
+
const e = C(void 0), [t, r] = S(!1), [n, o] = S(null), a = x(() => o(null), []), s = x(
|
|
1274
|
+
(c, l, i) => {
|
|
1275
|
+
if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !l || !i.name || !i.dataType) {
|
|
1276
|
+
const b = new Error("modelName, property name and dataType are required");
|
|
1277
|
+
throw o(b), r(!1), b;
|
|
1255
1278
|
}
|
|
1256
|
-
const d =
|
|
1257
|
-
{ ...i, modelName:
|
|
1279
|
+
const d = dt(c) ?? c, u = ye.create(
|
|
1280
|
+
{ ...i, modelName: l },
|
|
1258
1281
|
{ waitForReady: !1, schemaName: d }
|
|
1259
|
-
), f = u.getService().subscribe((
|
|
1260
|
-
if (
|
|
1261
|
-
const v =
|
|
1282
|
+
), f = u.getService().subscribe((b) => {
|
|
1283
|
+
if (b.value === "error") {
|
|
1284
|
+
const v = b.context._loadingError?.error ?? new Error("Failed to create model property");
|
|
1262
1285
|
o(v instanceof Error ? v : new Error(String(v))), r(!1);
|
|
1263
1286
|
}
|
|
1264
|
-
|
|
1287
|
+
b.value === "idle" && (o(null), r(!1));
|
|
1265
1288
|
});
|
|
1266
1289
|
return e.current = f, u;
|
|
1267
1290
|
},
|
|
1268
1291
|
[]
|
|
1269
1292
|
);
|
|
1270
|
-
return
|
|
1293
|
+
return w(() => () => {
|
|
1271
1294
|
e.current?.unsubscribe(), e.current = void 0;
|
|
1272
1295
|
}, []), {
|
|
1273
1296
|
create: s,
|
|
@@ -1275,26 +1298,26 @@ const Dr = () => {
|
|
|
1275
1298
|
error: n,
|
|
1276
1299
|
resetError: a
|
|
1277
1300
|
};
|
|
1278
|
-
},
|
|
1301
|
+
}, Mr = () => {
|
|
1279
1302
|
const [e, t] = S(null), [r, n] = S({
|
|
1280
1303
|
isLoading: !1,
|
|
1281
1304
|
error: null
|
|
1282
1305
|
});
|
|
1283
|
-
|
|
1306
|
+
w(() => {
|
|
1284
1307
|
if (!e) {
|
|
1285
1308
|
n({ isLoading: !1, error: null });
|
|
1286
1309
|
return;
|
|
1287
1310
|
}
|
|
1288
|
-
const s = e.getService(),
|
|
1311
|
+
const s = e.getService(), c = () => {
|
|
1289
1312
|
const d = s.getSnapshot().context;
|
|
1290
1313
|
n({
|
|
1291
1314
|
isLoading: !!d._destroyInProgress,
|
|
1292
1315
|
error: d._destroyError ? new Error(d._destroyError.message) : null
|
|
1293
1316
|
});
|
|
1294
1317
|
};
|
|
1295
|
-
|
|
1296
|
-
const
|
|
1297
|
-
return () =>
|
|
1318
|
+
c();
|
|
1319
|
+
const l = s.subscribe(c);
|
|
1320
|
+
return () => l.unsubscribe();
|
|
1298
1321
|
}, [e]);
|
|
1299
1322
|
const o = x(async (s) => {
|
|
1300
1323
|
s && (t(s), await s.destroy());
|
|
@@ -1307,26 +1330,26 @@ const Dr = () => {
|
|
|
1307
1330
|
error: r.error,
|
|
1308
1331
|
resetError: a
|
|
1309
1332
|
};
|
|
1310
|
-
},
|
|
1333
|
+
}, kr = () => {
|
|
1311
1334
|
const [e, t] = S(null), [r, n] = S({
|
|
1312
1335
|
isLoading: !1,
|
|
1313
1336
|
error: null
|
|
1314
1337
|
});
|
|
1315
|
-
|
|
1338
|
+
w(() => {
|
|
1316
1339
|
if (!e) {
|
|
1317
1340
|
n({ isLoading: !1, error: null });
|
|
1318
1341
|
return;
|
|
1319
1342
|
}
|
|
1320
|
-
const s = e.getService(),
|
|
1343
|
+
const s = e.getService(), c = () => {
|
|
1321
1344
|
const d = s.getSnapshot().context;
|
|
1322
1345
|
n({
|
|
1323
1346
|
isLoading: !!d._destroyInProgress,
|
|
1324
1347
|
error: d._destroyError ? new Error(d._destroyError.message) : null
|
|
1325
1348
|
});
|
|
1326
1349
|
};
|
|
1327
|
-
|
|
1328
|
-
const
|
|
1329
|
-
return () =>
|
|
1350
|
+
c();
|
|
1351
|
+
const l = s.subscribe(c);
|
|
1352
|
+
return () => l.unsubscribe();
|
|
1330
1353
|
}, [e]);
|
|
1331
1354
|
const o = x(async (s) => {
|
|
1332
1355
|
s && (t(s), await s.destroy());
|
|
@@ -1339,26 +1362,26 @@ const Dr = () => {
|
|
|
1339
1362
|
error: r.error,
|
|
1340
1363
|
resetError: a
|
|
1341
1364
|
};
|
|
1342
|
-
},
|
|
1343
|
-
function
|
|
1344
|
-
const e =
|
|
1365
|
+
}, Ie = ["seed", "imageFiles"];
|
|
1366
|
+
function $r() {
|
|
1367
|
+
const e = Q(), t = Z(), {
|
|
1345
1368
|
data: r = [],
|
|
1346
1369
|
isLoading: n,
|
|
1347
1370
|
error: o,
|
|
1348
1371
|
refetch: a
|
|
1349
|
-
} =
|
|
1350
|
-
queryKey:
|
|
1351
|
-
queryFn: () =>
|
|
1372
|
+
} = ee({
|
|
1373
|
+
queryKey: Ie,
|
|
1374
|
+
queryFn: () => W.listImageFiles(),
|
|
1352
1375
|
enabled: e
|
|
1353
1376
|
});
|
|
1354
|
-
return
|
|
1355
|
-
const s = (
|
|
1356
|
-
|
|
1357
|
-
},
|
|
1358
|
-
t.invalidateQueries({ queryKey:
|
|
1377
|
+
return w(() => {
|
|
1378
|
+
const s = (l) => {
|
|
1379
|
+
l.includes("/images/") && t.invalidateQueries({ queryKey: Ie });
|
|
1380
|
+
}, c = () => {
|
|
1381
|
+
t.invalidateQueries({ queryKey: Ie });
|
|
1359
1382
|
};
|
|
1360
|
-
return
|
|
1361
|
-
|
|
1383
|
+
return z.on("file-saved", s), z.on("fs.downloadAll.success", c), () => {
|
|
1384
|
+
z.off("file-saved", s), z.off("fs.downloadAll.success", c);
|
|
1362
1385
|
};
|
|
1363
1386
|
}, [t]), {
|
|
1364
1387
|
imageFiles: r,
|
|
@@ -1367,35 +1390,63 @@ function Pr() {
|
|
|
1367
1390
|
refetch: a
|
|
1368
1391
|
};
|
|
1369
1392
|
}
|
|
1370
|
-
const
|
|
1371
|
-
function
|
|
1372
|
-
const t =
|
|
1393
|
+
const Tt = ["seed", "files"];
|
|
1394
|
+
function Br(e = "files") {
|
|
1395
|
+
const t = Q(), r = Z(), n = N(() => [...Tt, e], [e]), {
|
|
1373
1396
|
data: o = [],
|
|
1374
1397
|
isLoading: a,
|
|
1375
1398
|
error: s,
|
|
1376
|
-
refetch:
|
|
1377
|
-
} =
|
|
1399
|
+
refetch: c
|
|
1400
|
+
} = ee({
|
|
1378
1401
|
queryKey: n,
|
|
1379
|
-
queryFn: () =>
|
|
1402
|
+
queryFn: () => W.listFiles(e),
|
|
1380
1403
|
enabled: t
|
|
1381
1404
|
});
|
|
1382
|
-
return
|
|
1383
|
-
const
|
|
1405
|
+
return w(() => {
|
|
1406
|
+
const l = (d) => {
|
|
1384
1407
|
d.includes(`/${e}/`) && r.invalidateQueries({ queryKey: n });
|
|
1385
1408
|
}, i = () => {
|
|
1386
1409
|
r.invalidateQueries({ queryKey: n });
|
|
1387
1410
|
};
|
|
1388
|
-
return
|
|
1389
|
-
|
|
1411
|
+
return z.on("file-saved", l), z.on("fs.downloadAll.success", i), () => {
|
|
1412
|
+
z.off("file-saved", l), z.off("fs.downloadAll.success", i);
|
|
1390
1413
|
};
|
|
1391
1414
|
}, [r, e, n]), {
|
|
1392
1415
|
files: o,
|
|
1393
1416
|
isLoading: a,
|
|
1394
1417
|
error: s instanceof Error ? s : null,
|
|
1395
|
-
refetch:
|
|
1418
|
+
refetch: c
|
|
1396
1419
|
};
|
|
1397
1420
|
}
|
|
1398
|
-
|
|
1421
|
+
function Ye() {
|
|
1422
|
+
const e = j.getAppDb();
|
|
1423
|
+
return N(
|
|
1424
|
+
() => e ? e.select().from(pe).orderBy(Ve(pe.startedAt)) : null,
|
|
1425
|
+
[e]
|
|
1426
|
+
);
|
|
1427
|
+
}
|
|
1428
|
+
function Mt() {
|
|
1429
|
+
const e = Ye(), t = Y(e), r = N(
|
|
1430
|
+
() => t === void 0 ? void 0 : t.filter((n) => n.status !== "in_progress").length,
|
|
1431
|
+
[t]
|
|
1432
|
+
);
|
|
1433
|
+
return { records: t, nonActiveCount: r };
|
|
1434
|
+
}
|
|
1435
|
+
function Or() {
|
|
1436
|
+
const e = Ye();
|
|
1437
|
+
return Y(e);
|
|
1438
|
+
}
|
|
1439
|
+
function Ur() {
|
|
1440
|
+
return Mt().nonActiveCount;
|
|
1441
|
+
}
|
|
1442
|
+
function qr(e) {
|
|
1443
|
+
const t = j.getAppDb(), r = N(
|
|
1444
|
+
() => e != null && t ? t.select().from(pe).where(q(pe.id, e)).limit(1) : null,
|
|
1445
|
+
[t, e]
|
|
1446
|
+
), n = Y(r), o = n === void 0;
|
|
1447
|
+
return { record: n && n.length > 0 ? n[0] : null, isLoading: o };
|
|
1448
|
+
}
|
|
1449
|
+
const kt = {
|
|
1399
1450
|
queries: {
|
|
1400
1451
|
networkMode: "offlineFirst",
|
|
1401
1452
|
gcTime: 1e3 * 60 * 60 * 24,
|
|
@@ -1404,11 +1455,11 @@ const Rt = {
|
|
|
1404
1455
|
// 1 minute - list data can be slightly stale
|
|
1405
1456
|
}
|
|
1406
1457
|
};
|
|
1407
|
-
function
|
|
1408
|
-
return { ...
|
|
1458
|
+
function Xe() {
|
|
1459
|
+
return { ...kt };
|
|
1409
1460
|
}
|
|
1410
|
-
function
|
|
1411
|
-
const t =
|
|
1461
|
+
function $t(e) {
|
|
1462
|
+
const t = Xe();
|
|
1412
1463
|
return e ? {
|
|
1413
1464
|
queries: {
|
|
1414
1465
|
...t.queries,
|
|
@@ -1420,38 +1471,40 @@ function Pt(e) {
|
|
|
1420
1471
|
}
|
|
1421
1472
|
} : t;
|
|
1422
1473
|
}
|
|
1423
|
-
function
|
|
1424
|
-
const t =
|
|
1425
|
-
return new
|
|
1474
|
+
function Bt(e) {
|
|
1475
|
+
const t = Xe(), { defaultOptions: r, ...n } = e ?? {};
|
|
1476
|
+
return new bt({
|
|
1426
1477
|
...n,
|
|
1427
|
-
defaultOptions: r ?
|
|
1478
|
+
defaultOptions: r ? $t(r) : t
|
|
1428
1479
|
});
|
|
1429
1480
|
}
|
|
1430
|
-
let
|
|
1431
|
-
function
|
|
1432
|
-
const t =
|
|
1481
|
+
let _e = null;
|
|
1482
|
+
function zr(e) {
|
|
1483
|
+
const t = _e?.(e);
|
|
1433
1484
|
return typeof window < "u" && window.__SEED_INVALIDATE_ITEM_PROPERTIES__ && window.__SEED_INVALIDATE_ITEM_PROPERTIES__(e), Promise.resolve(t).then(() => {
|
|
1434
1485
|
});
|
|
1435
1486
|
}
|
|
1436
|
-
function
|
|
1437
|
-
return
|
|
1438
|
-
const t = (
|
|
1439
|
-
const
|
|
1440
|
-
return e.invalidateQueries({ queryKey:
|
|
1487
|
+
function Ot({ queryClient: e }) {
|
|
1488
|
+
return w(() => {
|
|
1489
|
+
const t = (o) => {
|
|
1490
|
+
const a = ["seed", "itemProperties", o];
|
|
1491
|
+
return e.invalidateQueries({ queryKey: a }), e.refetchQueries({ queryKey: a });
|
|
1441
1492
|
};
|
|
1442
|
-
|
|
1443
|
-
const r = (
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1493
|
+
_e = t, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = t);
|
|
1494
|
+
const r = (o) => {
|
|
1495
|
+
const a = o?.seedLocalId ?? o?.seedUid;
|
|
1496
|
+
a && t(a);
|
|
1497
|
+
}, n = () => {
|
|
1498
|
+
e.invalidateQueries({ queryKey: ["seed", "items"], exact: !1 });
|
|
1446
1499
|
};
|
|
1447
|
-
return
|
|
1448
|
-
|
|
1500
|
+
return z.on("itemProperty.saved", r), z.on(ne, n), () => {
|
|
1501
|
+
z.off("itemProperty.saved", r), z.off(ne, n), _e = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
|
|
1449
1502
|
};
|
|
1450
1503
|
}, [e]), null;
|
|
1451
1504
|
}
|
|
1452
|
-
function
|
|
1453
|
-
const n =
|
|
1454
|
-
() => t ??
|
|
1505
|
+
function Hr({ children: e, queryClient: t, queryClientRef: r }) {
|
|
1506
|
+
const n = N(
|
|
1507
|
+
() => t ?? Bt(),
|
|
1455
1508
|
[t]
|
|
1456
1509
|
);
|
|
1457
1510
|
if (r && (r.current = n, typeof window < "u")) {
|
|
@@ -1462,13 +1515,13 @@ function kr({ children: e, queryClient: t, queryClientRef: r }) {
|
|
|
1462
1515
|
} catch {
|
|
1463
1516
|
}
|
|
1464
1517
|
}
|
|
1465
|
-
return /* @__PURE__ */
|
|
1466
|
-
/* @__PURE__ */
|
|
1518
|
+
return /* @__PURE__ */ g(St, { client: n, children: /* @__PURE__ */ U(wt, { queryClient: n, children: [
|
|
1519
|
+
/* @__PURE__ */ g(Ot, { queryClient: n }),
|
|
1467
1520
|
e
|
|
1468
1521
|
] }) });
|
|
1469
1522
|
}
|
|
1470
|
-
function
|
|
1471
|
-
return /* @__PURE__ */
|
|
1523
|
+
function Ut() {
|
|
1524
|
+
return /* @__PURE__ */ g(
|
|
1472
1525
|
"div",
|
|
1473
1526
|
{
|
|
1474
1527
|
style: {
|
|
@@ -1482,7 +1535,7 @@ function kt() {
|
|
|
1482
1535
|
}
|
|
1483
1536
|
);
|
|
1484
1537
|
}
|
|
1485
|
-
function
|
|
1538
|
+
function Qr({
|
|
1486
1539
|
initConfig: e,
|
|
1487
1540
|
schema: t,
|
|
1488
1541
|
loadingComponent: r,
|
|
@@ -1490,8 +1543,8 @@ function $r({
|
|
|
1490
1543
|
loadingClassName: o,
|
|
1491
1544
|
children: a
|
|
1492
1545
|
}) {
|
|
1493
|
-
const s =
|
|
1494
|
-
|
|
1546
|
+
const s = Q();
|
|
1547
|
+
w(() => {
|
|
1495
1548
|
const u = t ? {
|
|
1496
1549
|
...e,
|
|
1497
1550
|
config: {
|
|
@@ -1499,9 +1552,9 @@ function $r({
|
|
|
1499
1552
|
schema: t
|
|
1500
1553
|
}
|
|
1501
1554
|
} : e;
|
|
1502
|
-
|
|
1555
|
+
ut.init(u);
|
|
1503
1556
|
}, [e, t]);
|
|
1504
|
-
const
|
|
1557
|
+
const c = r ?? /* @__PURE__ */ g(Ut, {}), l = n ? void 0 : { position: "relative", display: "flex", height: "100vh", width: "100vw" }, i = {
|
|
1505
1558
|
display: s ? "none" : "flex",
|
|
1506
1559
|
...!o && {
|
|
1507
1560
|
position: "absolute",
|
|
@@ -1511,24 +1564,24 @@ function $r({
|
|
|
1511
1564
|
justifyContent: "center"
|
|
1512
1565
|
}
|
|
1513
1566
|
};
|
|
1514
|
-
return /* @__PURE__ */
|
|
1515
|
-
/* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ U("div", { className: n, style: l, children: [
|
|
1568
|
+
/* @__PURE__ */ g(
|
|
1516
1569
|
"div",
|
|
1517
1570
|
{
|
|
1518
1571
|
className: o,
|
|
1519
1572
|
style: i,
|
|
1520
1573
|
"aria-hidden": s,
|
|
1521
|
-
children:
|
|
1574
|
+
children: c
|
|
1522
1575
|
}
|
|
1523
1576
|
),
|
|
1524
|
-
/* @__PURE__ */
|
|
1577
|
+
/* @__PURE__ */ g("div", { style: {
|
|
1525
1578
|
flex: 1,
|
|
1526
1579
|
display: s ? "flex" : "none",
|
|
1527
1580
|
flexDirection: "column"
|
|
1528
1581
|
}, children: a })
|
|
1529
1582
|
] });
|
|
1530
1583
|
}
|
|
1531
|
-
async function
|
|
1584
|
+
async function Ze(e, t = "") {
|
|
1532
1585
|
const r = [];
|
|
1533
1586
|
try {
|
|
1534
1587
|
for await (const [n, o] of e.entries()) {
|
|
@@ -1547,7 +1600,7 @@ async function Je(e, t = "") {
|
|
|
1547
1600
|
console.warn(`Failed to read file ${a}:`, s);
|
|
1548
1601
|
}
|
|
1549
1602
|
else if (o.kind === "directory") {
|
|
1550
|
-
const s = await
|
|
1603
|
+
const s = await Ze(o, a);
|
|
1551
1604
|
r.push(...s);
|
|
1552
1605
|
}
|
|
1553
1606
|
}
|
|
@@ -1556,31 +1609,31 @@ async function Je(e, t = "") {
|
|
|
1556
1609
|
}
|
|
1557
1610
|
return r;
|
|
1558
1611
|
}
|
|
1559
|
-
function
|
|
1560
|
-
const { rootPath: t } = e, [r, n] = S([]), [o, a] = S(!0), [s,
|
|
1561
|
-
a(!0),
|
|
1612
|
+
function qt(e = {}) {
|
|
1613
|
+
const { rootPath: t } = e, [r, n] = S([]), [o, a] = S(!0), [s, c] = S(null), l = x(async () => {
|
|
1614
|
+
a(!0), c(null);
|
|
1562
1615
|
try {
|
|
1563
1616
|
let d = await navigator.storage.getDirectory();
|
|
1564
1617
|
if (t) {
|
|
1565
1618
|
const f = t.split("/").filter(Boolean);
|
|
1566
|
-
for (const
|
|
1567
|
-
d = await d.getDirectoryHandle(
|
|
1619
|
+
for (const b of f)
|
|
1620
|
+
d = await d.getDirectoryHandle(b);
|
|
1568
1621
|
}
|
|
1569
|
-
const u = await
|
|
1570
|
-
n(u.sort((f,
|
|
1622
|
+
const u = await Ze(d, t || "");
|
|
1623
|
+
n(u.sort((f, b) => f.path.localeCompare(b.path)));
|
|
1571
1624
|
} catch (i) {
|
|
1572
|
-
|
|
1625
|
+
c(
|
|
1573
1626
|
"Failed to access OPFS: " + (i instanceof Error ? i.message : String(i))
|
|
1574
1627
|
), console.error("OPFS access error:", i);
|
|
1575
1628
|
} finally {
|
|
1576
1629
|
a(!1);
|
|
1577
1630
|
}
|
|
1578
1631
|
}, [t]);
|
|
1579
|
-
return
|
|
1580
|
-
|
|
1581
|
-
}, [
|
|
1632
|
+
return w(() => {
|
|
1633
|
+
l();
|
|
1634
|
+
}, [l]), { files: r, isLoading: o, error: s, refetch: l };
|
|
1582
1635
|
}
|
|
1583
|
-
const
|
|
1636
|
+
const Be = () => /* @__PURE__ */ g("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__ */ g("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" }) }), zt = () => /* @__PURE__ */ g("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__ */ g("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" }) }), Ht = () => /* @__PURE__ */ g("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__ */ g("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" }) }), Oe = () => /* @__PURE__ */ g("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__ */ g("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" }) }), Qt = () => /* @__PURE__ */ U(
|
|
1584
1637
|
"svg",
|
|
1585
1638
|
{
|
|
1586
1639
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1589,7 +1642,7 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
|
|
|
1589
1642
|
style: { width: 32, height: 32 },
|
|
1590
1643
|
"aria-hidden": !0,
|
|
1591
1644
|
children: [
|
|
1592
|
-
/* @__PURE__ */
|
|
1645
|
+
/* @__PURE__ */ g(
|
|
1593
1646
|
"circle",
|
|
1594
1647
|
{
|
|
1595
1648
|
style: { opacity: 0.25 },
|
|
@@ -1600,7 +1653,7 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
|
|
|
1600
1653
|
strokeWidth: "4"
|
|
1601
1654
|
}
|
|
1602
1655
|
),
|
|
1603
|
-
/* @__PURE__ */
|
|
1656
|
+
/* @__PURE__ */ g(
|
|
1604
1657
|
"path",
|
|
1605
1658
|
{
|
|
1606
1659
|
style: { opacity: 0.75 },
|
|
@@ -1611,24 +1664,24 @@ const ke = () => /* @__PURE__ */ h("svg", { xmlns: "http://www.w3.org/2000/svg",
|
|
|
1611
1664
|
]
|
|
1612
1665
|
}
|
|
1613
1666
|
);
|
|
1614
|
-
function
|
|
1667
|
+
function Vt(e) {
|
|
1615
1668
|
if (e === 0) return "0 Bytes";
|
|
1616
1669
|
const t = 1024, r = ["Bytes", "KB", "MB", "GB"], n = Math.floor(Math.log(e) / Math.log(t));
|
|
1617
1670
|
return Math.round(e / Math.pow(t, n) * 100) / 100 + " " + r[n];
|
|
1618
1671
|
}
|
|
1619
|
-
function
|
|
1672
|
+
function Kt(e) {
|
|
1620
1673
|
return new Date(e).toLocaleString();
|
|
1621
1674
|
}
|
|
1622
|
-
async function
|
|
1675
|
+
async function jt(e, t) {
|
|
1623
1676
|
const r = e.path.split("/").filter(Boolean);
|
|
1624
1677
|
if (r.length === 0) throw new Error("Invalid file path");
|
|
1625
1678
|
let n = t;
|
|
1626
|
-
for (let
|
|
1627
|
-
n = await n.getDirectoryHandle(r[
|
|
1679
|
+
for (let c = 0; c < r.length - 1; c++)
|
|
1680
|
+
n = await n.getDirectoryHandle(r[c]);
|
|
1628
1681
|
const o = r[r.length - 1];
|
|
1629
1682
|
return await (await n.getFileHandle(o)).getFile();
|
|
1630
1683
|
}
|
|
1631
|
-
async function
|
|
1684
|
+
async function Ue(e, t) {
|
|
1632
1685
|
const r = e.split("/").filter(Boolean);
|
|
1633
1686
|
if (r.length === 0) throw new Error("Invalid file path");
|
|
1634
1687
|
let n = t;
|
|
@@ -1637,7 +1690,7 @@ async function Be(e, t) {
|
|
|
1637
1690
|
const o = r[r.length - 1];
|
|
1638
1691
|
await n.removeEntry(o);
|
|
1639
1692
|
}
|
|
1640
|
-
const
|
|
1693
|
+
const Wt = {
|
|
1641
1694
|
light: {
|
|
1642
1695
|
title: "text-gray-900",
|
|
1643
1696
|
description: "text-gray-500",
|
|
@@ -1682,7 +1735,7 @@ const Qt = {
|
|
|
1682
1735
|
actionButton: "text-gray-400 hover:text-indigo-400",
|
|
1683
1736
|
deleteButton: "text-gray-400 hover:text-red-500"
|
|
1684
1737
|
}
|
|
1685
|
-
},
|
|
1738
|
+
}, T = {
|
|
1686
1739
|
container: { padding: "2rem 0" },
|
|
1687
1740
|
header: {
|
|
1688
1741
|
display: "flex",
|
|
@@ -1701,7 +1754,7 @@ const Qt = {
|
|
|
1701
1754
|
errorBox: "rounded-md border p-4 mt-4",
|
|
1702
1755
|
emptyState: "text-center py-12"
|
|
1703
1756
|
};
|
|
1704
|
-
function
|
|
1757
|
+
function Vr({
|
|
1705
1758
|
rootPath: e,
|
|
1706
1759
|
filter: t,
|
|
1707
1760
|
onBeforeDelete: r,
|
|
@@ -1709,110 +1762,110 @@ function Br({
|
|
|
1709
1762
|
onDownload: o,
|
|
1710
1763
|
title: a = "Files",
|
|
1711
1764
|
description: s = "Browse and download all files stored in the Origin Private File System (OPFS).",
|
|
1712
|
-
theme:
|
|
1713
|
-
className:
|
|
1765
|
+
theme: c = "dark",
|
|
1766
|
+
className: l
|
|
1714
1767
|
}) {
|
|
1715
|
-
const i =
|
|
1716
|
-
y((
|
|
1717
|
-
const
|
|
1718
|
-
return
|
|
1768
|
+
const i = Wt[c], { files: d, isLoading: u, error: f, refetch: b } = qt({ rootPath: e }), v = t ? d.filter(t) : d, [h, y] = S(/* @__PURE__ */ new Set()), p = C(null), E = v.length > 0 && h.size === v.length, I = h.size > 0 && h.size < v.length, m = (L) => {
|
|
1769
|
+
y(($) => {
|
|
1770
|
+
const F = new Set($);
|
|
1771
|
+
return F.has(L) ? F.delete(L) : F.add(L), F;
|
|
1719
1772
|
});
|
|
1720
|
-
},
|
|
1773
|
+
}, _ = () => {
|
|
1721
1774
|
y(
|
|
1722
|
-
|
|
1775
|
+
h.size === v.length ? /* @__PURE__ */ new Set() : new Set(v.map((L) => L.path))
|
|
1723
1776
|
);
|
|
1724
1777
|
};
|
|
1725
|
-
|
|
1778
|
+
w(() => {
|
|
1726
1779
|
y(/* @__PURE__ */ new Set());
|
|
1727
|
-
}, [v.length]),
|
|
1728
|
-
p.current && (p.current.indeterminate =
|
|
1729
|
-
}, [
|
|
1730
|
-
const
|
|
1780
|
+
}, [v.length]), w(() => {
|
|
1781
|
+
p.current && (p.current.indeterminate = I);
|
|
1782
|
+
}, [I]);
|
|
1783
|
+
const R = async (L, $ = !1) => {
|
|
1731
1784
|
try {
|
|
1732
|
-
const
|
|
1785
|
+
const F = await navigator.storage.getDirectory(), H = await jt(L, F);
|
|
1733
1786
|
if (o)
|
|
1734
|
-
await o(L,
|
|
1787
|
+
await o(L, H);
|
|
1735
1788
|
else {
|
|
1736
|
-
const
|
|
1737
|
-
M.href =
|
|
1789
|
+
const K = URL.createObjectURL(H), M = document.createElement("a");
|
|
1790
|
+
M.href = K, M.download = L.name, document.body.appendChild(M), M.click(), document.body.removeChild(M), URL.revokeObjectURL(K);
|
|
1738
1791
|
}
|
|
1739
|
-
} catch (
|
|
1740
|
-
const
|
|
1741
|
-
throw
|
|
1792
|
+
} catch (F) {
|
|
1793
|
+
const H = "Failed to download file: " + (F instanceof Error ? F.message : String(F));
|
|
1794
|
+
throw $ || alert(H), F;
|
|
1742
1795
|
}
|
|
1743
|
-
},
|
|
1796
|
+
}, A = async (L) => {
|
|
1744
1797
|
if (!(r && !await r(L)) && confirm(`Are you sure you want to delete "${L.name}"? This action cannot be undone.`))
|
|
1745
1798
|
try {
|
|
1746
|
-
const
|
|
1747
|
-
await
|
|
1748
|
-
} catch (
|
|
1749
|
-
alert("Failed to delete file: " + (
|
|
1799
|
+
const $ = await navigator.storage.getDirectory();
|
|
1800
|
+
await Ue(L.path, $), await b(), await n?.([L.path]);
|
|
1801
|
+
} catch ($) {
|
|
1802
|
+
alert("Failed to delete file: " + ($ instanceof Error ? $.message : String($)));
|
|
1750
1803
|
}
|
|
1751
|
-
},
|
|
1752
|
-
if (
|
|
1753
|
-
const L = v.filter((
|
|
1754
|
-
for (const
|
|
1804
|
+
}, B = async () => {
|
|
1805
|
+
if (h.size === 0) return;
|
|
1806
|
+
const L = v.filter((F) => h.has(F.path)), $ = [];
|
|
1807
|
+
for (const F of L)
|
|
1755
1808
|
try {
|
|
1756
|
-
await
|
|
1757
|
-
} catch (
|
|
1758
|
-
|
|
1809
|
+
await R(F, !0), await new Promise((H) => setTimeout(H, 100));
|
|
1810
|
+
} catch (H) {
|
|
1811
|
+
$.push(`${F.name}: ${H instanceof Error ? H.message : String(H)}`);
|
|
1759
1812
|
}
|
|
1760
|
-
|
|
1761
|
-
${
|
|
1813
|
+
$.length > 0 && alert(`Some downloads failed:
|
|
1814
|
+
${$.join(`
|
|
1762
1815
|
`)}`);
|
|
1763
|
-
},
|
|
1764
|
-
if (
|
|
1765
|
-
const L = v.filter((M) =>
|
|
1816
|
+
}, V = async () => {
|
|
1817
|
+
if (h.size === 0) return;
|
|
1818
|
+
const L = v.filter((M) => h.has(M.path)), $ = L.map((M) => M.name).join(", ");
|
|
1766
1819
|
if (!confirm(
|
|
1767
|
-
`Are you sure you want to delete ${
|
|
1820
|
+
`Are you sure you want to delete ${h.size} file(s)?
|
|
1768
1821
|
|
|
1769
|
-
Files: ${
|
|
1822
|
+
Files: ${$}
|
|
1770
1823
|
|
|
1771
1824
|
This action cannot be undone.`
|
|
1772
1825
|
))
|
|
1773
1826
|
return;
|
|
1774
|
-
const
|
|
1827
|
+
const F = await navigator.storage.getDirectory(), H = [], K = [];
|
|
1775
1828
|
for (const M of L)
|
|
1776
1829
|
if (!(r && !await r(M)))
|
|
1777
1830
|
try {
|
|
1778
|
-
await
|
|
1831
|
+
await Ue(M.path, F), H.push(M.path);
|
|
1779
1832
|
} catch (J) {
|
|
1780
|
-
|
|
1833
|
+
K.push(`${M.name}: ${J instanceof Error ? J.message : String(J)}`);
|
|
1781
1834
|
}
|
|
1782
|
-
y(/* @__PURE__ */ new Set()), await
|
|
1783
|
-
${
|
|
1835
|
+
y(/* @__PURE__ */ new Set()), await b(), H.length > 0 && await n?.(H), K.length > 0 && alert(`Some deletions failed:
|
|
1836
|
+
${K.join(`
|
|
1784
1837
|
`)}`);
|
|
1785
1838
|
};
|
|
1786
|
-
return /* @__PURE__ */
|
|
1787
|
-
/* @__PURE__ */
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
/* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */
|
|
1791
|
-
/* @__PURE__ */
|
|
1839
|
+
return /* @__PURE__ */ U("div", { className: l, style: T.container, children: [
|
|
1840
|
+
/* @__PURE__ */ g("style", { children: "@keyframes opfs-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}" }),
|
|
1841
|
+
/* @__PURE__ */ U("div", { style: T.header, children: [
|
|
1842
|
+
/* @__PURE__ */ U("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
1843
|
+
/* @__PURE__ */ g("h1", { style: T.title, className: i.title, children: a }),
|
|
1844
|
+
/* @__PURE__ */ g("p", { style: T.description, className: i.description, children: s })
|
|
1792
1845
|
] }),
|
|
1793
|
-
/* @__PURE__ */
|
|
1846
|
+
/* @__PURE__ */ g("button", { type: "button", onClick: b, className: T.button, children: "Refresh" })
|
|
1794
1847
|
] }),
|
|
1795
|
-
|
|
1848
|
+
h.size > 0 && /* @__PURE__ */ U(
|
|
1796
1849
|
"div",
|
|
1797
1850
|
{
|
|
1798
1851
|
className: `mt-4 flex items-center justify-between rounded-lg border px-4 py-3 ${i.batchBar}`,
|
|
1799
1852
|
children: [
|
|
1800
|
-
/* @__PURE__ */
|
|
1801
|
-
|
|
1853
|
+
/* @__PURE__ */ U("span", { className: `text-sm font-medium ${i.batchText}`, children: [
|
|
1854
|
+
h.size,
|
|
1802
1855
|
" file",
|
|
1803
|
-
|
|
1856
|
+
h.size === 1 ? "" : "s",
|
|
1804
1857
|
" selected"
|
|
1805
1858
|
] }),
|
|
1806
|
-
/* @__PURE__ */
|
|
1807
|
-
/* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */
|
|
1859
|
+
/* @__PURE__ */ U("div", { className: "flex items-center gap-3", children: [
|
|
1860
|
+
/* @__PURE__ */ g("button", { onClick: B, className: T.button, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
|
|
1861
|
+
/* @__PURE__ */ g(Be, {}),
|
|
1809
1862
|
" Download All"
|
|
1810
1863
|
] }) }),
|
|
1811
|
-
/* @__PURE__ */
|
|
1812
|
-
/* @__PURE__ */
|
|
1864
|
+
/* @__PURE__ */ g("button", { onClick: V, className: T.buttonDanger, children: /* @__PURE__ */ U("span", { className: "inline-flex items-center gap-2", children: [
|
|
1865
|
+
/* @__PURE__ */ g(Oe, {}),
|
|
1813
1866
|
" Delete All"
|
|
1814
1867
|
] }) }),
|
|
1815
|
-
/* @__PURE__ */
|
|
1868
|
+
/* @__PURE__ */ g(
|
|
1816
1869
|
"button",
|
|
1817
1870
|
{
|
|
1818
1871
|
onClick: () => y(/* @__PURE__ */ new Set()),
|
|
@@ -1824,78 +1877,78 @@ ${V.join(`
|
|
|
1824
1877
|
]
|
|
1825
1878
|
}
|
|
1826
1879
|
),
|
|
1827
|
-
/* @__PURE__ */
|
|
1828
|
-
/* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
] }) : f ? /* @__PURE__ */
|
|
1831
|
-
/* @__PURE__ */
|
|
1832
|
-
/* @__PURE__ */
|
|
1833
|
-
] }) : v.length === 0 ? /* @__PURE__ */
|
|
1834
|
-
/* @__PURE__ */
|
|
1835
|
-
/* @__PURE__ */
|
|
1836
|
-
/* @__PURE__ */
|
|
1837
|
-
] }) : /* @__PURE__ */
|
|
1838
|
-
/* @__PURE__ */
|
|
1839
|
-
/* @__PURE__ */
|
|
1880
|
+
/* @__PURE__ */ g("div", { className: "mt-8", children: u ? /* @__PURE__ */ U("div", { className: "flex justify-center items-center py-12 gap-3", children: [
|
|
1881
|
+
/* @__PURE__ */ g("span", { style: { animation: "opfs-spin 1s linear infinite" }, children: /* @__PURE__ */ g(Qt, {}) }),
|
|
1882
|
+
/* @__PURE__ */ g("span", { className: i.loadingText, children: "Loading files..." })
|
|
1883
|
+
] }) : f ? /* @__PURE__ */ U("div", { className: `${T.errorBox} ${i.errorBox}`, children: [
|
|
1884
|
+
/* @__PURE__ */ g("h3", { className: `m-0 text-sm font-medium ${i.errorTitle}`, children: "Error" }),
|
|
1885
|
+
/* @__PURE__ */ g("div", { className: `mt-2 text-sm ${i.errorText}`, children: f })
|
|
1886
|
+
] }) : v.length === 0 ? /* @__PURE__ */ U("div", { className: T.emptyState, children: [
|
|
1887
|
+
/* @__PURE__ */ g("span", { className: i.emptyIcon, children: /* @__PURE__ */ g(zt, {}) }),
|
|
1888
|
+
/* @__PURE__ */ g("h3", { className: `mt-2 text-sm font-semibold ${i.emptyTitle}`, children: "No files" }),
|
|
1889
|
+
/* @__PURE__ */ g("p", { className: `mt-1 text-sm ${i.emptyText}`, children: "No files found in OPFS." })
|
|
1890
|
+
] }) : /* @__PURE__ */ g("div", { className: "overflow-x-auto", children: /* @__PURE__ */ U("table", { className: T.table, children: [
|
|
1891
|
+
/* @__PURE__ */ g("thead", { children: /* @__PURE__ */ U("tr", { className: i.tableBorder, children: [
|
|
1892
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} w-10 ${i.tableHeader}`, children: /* @__PURE__ */ g(
|
|
1840
1893
|
"input",
|
|
1841
1894
|
{
|
|
1842
1895
|
ref: p,
|
|
1843
1896
|
type: "checkbox",
|
|
1844
1897
|
checked: E,
|
|
1845
|
-
onChange:
|
|
1898
|
+
onChange: _,
|
|
1846
1899
|
"aria-label": "Select all"
|
|
1847
1900
|
}
|
|
1848
1901
|
) }),
|
|
1849
|
-
/* @__PURE__ */
|
|
1850
|
-
/* @__PURE__ */
|
|
1851
|
-
/* @__PURE__ */
|
|
1852
|
-
/* @__PURE__ */
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
1902
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Name" }),
|
|
1903
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Path" }),
|
|
1904
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Size" }),
|
|
1905
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Type" }),
|
|
1906
|
+
/* @__PURE__ */ g("th", { className: `${T.tableHeader} ${i.tableHeader}`, children: "Modified" }),
|
|
1907
|
+
/* @__PURE__ */ g(
|
|
1855
1908
|
"th",
|
|
1856
1909
|
{
|
|
1857
|
-
className: `${
|
|
1910
|
+
className: `${T.tableHeader} w-24 ${i.tableHeader}`,
|
|
1858
1911
|
"aria-label": "Actions"
|
|
1859
1912
|
}
|
|
1860
1913
|
)
|
|
1861
1914
|
] }) }),
|
|
1862
|
-
/* @__PURE__ */
|
|
1863
|
-
/* @__PURE__ */
|
|
1915
|
+
/* @__PURE__ */ g("tbody", { className: `divide-y ${i.tableBorder}`, children: v.map((L) => /* @__PURE__ */ U("tr", { className: i.tableRow, children: [
|
|
1916
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ g(
|
|
1864
1917
|
"input",
|
|
1865
1918
|
{
|
|
1866
1919
|
type: "checkbox",
|
|
1867
|
-
checked:
|
|
1920
|
+
checked: h.has(L.path),
|
|
1868
1921
|
onChange: () => m(L.path),
|
|
1869
1922
|
"aria-label": `Select ${L.name}`
|
|
1870
1923
|
}
|
|
1871
1924
|
) }),
|
|
1872
|
-
/* @__PURE__ */
|
|
1873
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCell}`, children: /* @__PURE__ */ U("span", { className: "flex items-center gap-2", children: [
|
|
1926
|
+
/* @__PURE__ */ g(Ht, {}),
|
|
1874
1927
|
L.name
|
|
1875
1928
|
] }) }),
|
|
1876
|
-
/* @__PURE__ */
|
|
1877
|
-
/* @__PURE__ */
|
|
1878
|
-
/* @__PURE__ */
|
|
1879
|
-
/* @__PURE__ */
|
|
1880
|
-
/* @__PURE__ */
|
|
1881
|
-
/* @__PURE__ */
|
|
1929
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: /* @__PURE__ */ g("code", { className: `text-xs px-2 py-1 rounded border ${i.codeBlock}`, children: L.path }) }),
|
|
1930
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: Vt(L.size) }),
|
|
1931
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: L.type }),
|
|
1932
|
+
/* @__PURE__ */ g("td", { className: `${T.tableCell} ${i.tableCellMuted}`, children: Kt(L.lastModified) }),
|
|
1933
|
+
/* @__PURE__ */ g("td", { className: T.tableCell, children: /* @__PURE__ */ U("div", { className: "flex gap-2 justify-end", children: [
|
|
1934
|
+
/* @__PURE__ */ g(
|
|
1882
1935
|
"button",
|
|
1883
1936
|
{
|
|
1884
1937
|
type: "button",
|
|
1885
|
-
onClick: () =>
|
|
1938
|
+
onClick: () => R(L),
|
|
1886
1939
|
title: "Download",
|
|
1887
1940
|
className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${i.actionButton}`,
|
|
1888
|
-
children: /* @__PURE__ */
|
|
1941
|
+
children: /* @__PURE__ */ g(Be, {})
|
|
1889
1942
|
}
|
|
1890
1943
|
),
|
|
1891
|
-
/* @__PURE__ */
|
|
1944
|
+
/* @__PURE__ */ g(
|
|
1892
1945
|
"button",
|
|
1893
1946
|
{
|
|
1894
1947
|
type: "button",
|
|
1895
|
-
onClick: () =>
|
|
1948
|
+
onClick: () => A(L),
|
|
1896
1949
|
title: "Delete",
|
|
1897
1950
|
className: `p-1.5 rounded cursor-pointer bg-transparent border-0 transition-colors ${i.deleteButton}`,
|
|
1898
|
-
children: /* @__PURE__ */
|
|
1951
|
+
children: /* @__PURE__ */ g(Oe, {})
|
|
1899
1952
|
}
|
|
1900
1953
|
)
|
|
1901
1954
|
] }) })
|
|
@@ -1903,118 +1956,118 @@ ${V.join(`
|
|
|
1903
1956
|
] }) }) })
|
|
1904
1957
|
] });
|
|
1905
1958
|
}
|
|
1906
|
-
const
|
|
1959
|
+
const Ee = G("seedSdk:react:SeedImage"), de = /* @__PURE__ */ new Map(), et = (e) => {
|
|
1907
1960
|
const t = /^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/, r = e.match(t);
|
|
1908
1961
|
return r && r[2] ? r[2] : e;
|
|
1909
1962
|
};
|
|
1910
|
-
function
|
|
1963
|
+
function Jt(e) {
|
|
1911
1964
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1912
1965
|
}
|
|
1913
|
-
function
|
|
1914
|
-
const r = new RegExp(`^${
|
|
1966
|
+
function Gt(e, t) {
|
|
1967
|
+
const r = new RegExp(`^${Jt(t)}$`), n = et(e);
|
|
1915
1968
|
return r.test(n);
|
|
1916
1969
|
}
|
|
1917
|
-
const
|
|
1918
|
-
const [o, a] = S(), [s,
|
|
1970
|
+
const Yt = ({ imageProperty: e, width: t, filename: r, ...n }) => {
|
|
1971
|
+
const [o, a] = S(), [s, c] = S(), { property: l } = We({
|
|
1919
1972
|
propertyName: e.propertyName,
|
|
1920
1973
|
seedLocalId: e.seedLocalId,
|
|
1921
1974
|
seedUid: e.seedUid
|
|
1922
|
-
}), i = e ??
|
|
1923
|
-
|
|
1924
|
-
if (
|
|
1925
|
-
return y.current || (y.current = URL.createObjectURL(u),
|
|
1926
|
-
y.current && (URL.revokeObjectURL(y.current), y.current = null),
|
|
1975
|
+
}), i = e ?? l, d = r ?? i?.refResolvedValue ?? i?.value, u = i?.value, f = typeof u == "string" ? u : d, b = u != null && (u instanceof File || u instanceof Blob), [v, h] = S(null), y = qe.useRef(null);
|
|
1976
|
+
w(() => {
|
|
1977
|
+
if (b && (u instanceof File || u instanceof Blob))
|
|
1978
|
+
return y.current || (y.current = URL.createObjectURL(u), h(y.current)), () => {
|
|
1979
|
+
y.current && (URL.revokeObjectURL(y.current), y.current = null), h(null);
|
|
1927
1980
|
};
|
|
1928
|
-
y.current = null,
|
|
1929
|
-
}, [
|
|
1930
|
-
if (!d || u && ((
|
|
1931
|
-
let
|
|
1981
|
+
y.current = null, h(null);
|
|
1982
|
+
}, [b, u]), w(() => {
|
|
1983
|
+
if (!d || u && ((A) => typeof A == "string" && A.startsWith("blob:"))(u) || v) return;
|
|
1984
|
+
let _ = !1;
|
|
1932
1985
|
return (async () => {
|
|
1933
1986
|
try {
|
|
1934
|
-
const
|
|
1935
|
-
if (await
|
|
1936
|
-
const
|
|
1937
|
-
!
|
|
1987
|
+
const A = i?.localStoragePath ? i.localStoragePath : `${W.getFilesPath("images")}/${d}`;
|
|
1988
|
+
if (await W.pathExists(A)) {
|
|
1989
|
+
const V = await W.getContentUrlFromPath(A);
|
|
1990
|
+
!_ && V && c(V);
|
|
1938
1991
|
}
|
|
1939
|
-
} catch (
|
|
1940
|
-
|
|
1992
|
+
} catch (A) {
|
|
1993
|
+
Ee("_getOriginalContentUrl error", A);
|
|
1941
1994
|
}
|
|
1942
1995
|
})(), () => {
|
|
1943
|
-
|
|
1996
|
+
_ = !0;
|
|
1944
1997
|
};
|
|
1945
|
-
}, [d, u, v, i?.localStoragePath]),
|
|
1998
|
+
}, [d, u, v, i?.localStoragePath]), w(() => {
|
|
1946
1999
|
if (!t || !d)
|
|
1947
2000
|
return;
|
|
1948
2001
|
(async () => {
|
|
1949
2002
|
try {
|
|
1950
|
-
const
|
|
1951
|
-
if (
|
|
2003
|
+
const _ = await W.getFs(), R = i?.localStoragePath ? i.localStoragePath.split("/").slice(0, -1).join("/") : W.getFilesPath("images"), V = _.readdirSync(R, { withFileTypes: !0 }).filter((O) => O.isDirectory()).map((O) => parseInt(O.name)), L = V.reduce((O, se) => Math.abs(se - t) < Math.abs(O - t) ? se : O, V[0]), $ = et(d), F = `${$}-${L}`;
|
|
2004
|
+
if (de.has(F))
|
|
1952
2005
|
try {
|
|
1953
|
-
const
|
|
1954
|
-
if (
|
|
1955
|
-
a(
|
|
2006
|
+
const O = de.get(F);
|
|
2007
|
+
if (O && (await fetch(O)).ok) {
|
|
2008
|
+
a(O);
|
|
1956
2009
|
return;
|
|
1957
2010
|
}
|
|
1958
|
-
} catch (
|
|
1959
|
-
|
|
2011
|
+
} catch (O) {
|
|
2012
|
+
Ee("error", O), de.delete(F);
|
|
1960
2013
|
}
|
|
1961
|
-
const
|
|
1962
|
-
if (!
|
|
2014
|
+
const K = _.readdirSync(`${R}/${L}`, { withFileTypes: !0 }).find((O) => O.name ? Gt(O.name, $) : !1);
|
|
2015
|
+
if (!K)
|
|
1963
2016
|
return;
|
|
1964
|
-
const M = `${
|
|
1965
|
-
if (await
|
|
1966
|
-
const
|
|
1967
|
-
|
|
2017
|
+
const M = `${R}/${L}/${K?.name}`;
|
|
2018
|
+
if (await W.pathExists(M)) {
|
|
2019
|
+
const O = await W.getContentUrlFromPath(M);
|
|
2020
|
+
O && (de.set(F, O), a(O));
|
|
1968
2021
|
}
|
|
1969
|
-
} catch (
|
|
1970
|
-
|
|
2022
|
+
} catch (_) {
|
|
2023
|
+
Ee("_getSizedContentUrl error", _);
|
|
1971
2024
|
}
|
|
1972
2025
|
})();
|
|
1973
2026
|
}, [i, t, f, d]);
|
|
1974
2027
|
const p = (m) => typeof m == "string" && m.startsWith("blob:");
|
|
1975
2028
|
if (!(!!o || !!s || !!v || !!f && p(f)) && !d)
|
|
1976
2029
|
return null;
|
|
1977
|
-
const
|
|
1978
|
-
return /* @__PURE__ */
|
|
1979
|
-
},
|
|
1980
|
-
|
|
2030
|
+
const I = o || s || v || (p(f) ? f : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
2031
|
+
return /* @__PURE__ */ g("img", { src: I, alt: n.alt || e.propertyName || "Image", ...n });
|
|
2032
|
+
}, Kr = qe.memo(
|
|
2033
|
+
Yt,
|
|
1981
2034
|
(e, t) => e.imageProperty === t.imageProperty && e.width === t.width && e.filename === t.filename
|
|
1982
2035
|
);
|
|
1983
|
-
function
|
|
1984
|
-
const { value: t, enabled: r = !0, treatAs: n } = e, [o, a] = S(0), [s,
|
|
1985
|
-
|
|
1986
|
-
let
|
|
2036
|
+
function tt(e) {
|
|
2037
|
+
const { value: t, enabled: r = !0, treatAs: n } = e, [o, a] = S(0), [s, c] = S(null), [l, i] = S(null), [d, u] = S("idle");
|
|
2038
|
+
w(() => {
|
|
2039
|
+
let h = !1;
|
|
1987
2040
|
return (async () => {
|
|
1988
2041
|
if (!r || t == null || String(t).trim() === "") {
|
|
1989
|
-
|
|
2042
|
+
h || (c(null), i(null), u("idle"));
|
|
1990
2043
|
return;
|
|
1991
2044
|
}
|
|
1992
|
-
|
|
2045
|
+
h || (u("loading"), i(null));
|
|
1993
2046
|
try {
|
|
1994
|
-
const p = await
|
|
1995
|
-
if (
|
|
1996
|
-
|
|
2047
|
+
const p = await ft(String(t), { treatAs: n });
|
|
2048
|
+
if (h) return;
|
|
2049
|
+
c(p), p.status === "empty" ? u("empty") : p.status === "ready" ? u("ready") : u("unresolved");
|
|
1997
2050
|
} catch (p) {
|
|
1998
|
-
if (
|
|
1999
|
-
i(p instanceof Error ? p : new Error(String(p))),
|
|
2051
|
+
if (h) return;
|
|
2052
|
+
i(p instanceof Error ? p : new Error(String(p))), c(null), u("error");
|
|
2000
2053
|
}
|
|
2001
2054
|
})(), () => {
|
|
2002
|
-
|
|
2055
|
+
h = !0;
|
|
2003
2056
|
};
|
|
2004
2057
|
}, [r, t, n, o]);
|
|
2005
2058
|
const f = x(() => {
|
|
2006
|
-
a((
|
|
2007
|
-
}, []),
|
|
2059
|
+
a((h) => h + 1);
|
|
2060
|
+
}, []), b = s && s.status === "ready" ? s.href : void 0, v = s && s.status === "ready" ? s.source : void 0;
|
|
2008
2061
|
return {
|
|
2009
|
-
href:
|
|
2062
|
+
href: b,
|
|
2010
2063
|
status: d,
|
|
2011
2064
|
source: v,
|
|
2012
|
-
error:
|
|
2065
|
+
error: l,
|
|
2013
2066
|
result: s,
|
|
2014
2067
|
refetch: f
|
|
2015
2068
|
};
|
|
2016
2069
|
}
|
|
2017
|
-
function
|
|
2070
|
+
function jr({
|
|
2018
2071
|
value: e,
|
|
2019
2072
|
enabled: t,
|
|
2020
2073
|
treatAs: r,
|
|
@@ -2022,20 +2075,20 @@ function Ur({
|
|
|
2022
2075
|
alt: o,
|
|
2023
2076
|
...a
|
|
2024
2077
|
}) {
|
|
2025
|
-
const { href: s } =
|
|
2078
|
+
const { href: s } = tt({ value: e, enabled: t, treatAs: r });
|
|
2026
2079
|
if (!s)
|
|
2027
2080
|
return null;
|
|
2028
|
-
const
|
|
2029
|
-
return n ? /* @__PURE__ */
|
|
2081
|
+
const c = { ...a, src: s, alt: o ?? "" };
|
|
2082
|
+
return n ? /* @__PURE__ */ g(Se, { children: n(c) }) : /* @__PURE__ */ g("img", { ...c });
|
|
2030
2083
|
}
|
|
2031
|
-
function
|
|
2084
|
+
function Xt(e) {
|
|
2032
2085
|
try {
|
|
2033
2086
|
return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
|
|
2034
2087
|
} catch {
|
|
2035
2088
|
return "Open";
|
|
2036
2089
|
}
|
|
2037
2090
|
}
|
|
2038
|
-
function
|
|
2091
|
+
function Zt(e) {
|
|
2039
2092
|
try {
|
|
2040
2093
|
const t = new URL(e).protocol;
|
|
2041
2094
|
return t === "http:" || t === "https:";
|
|
@@ -2043,7 +2096,7 @@ function Jt(e) {
|
|
|
2043
2096
|
return !1;
|
|
2044
2097
|
}
|
|
2045
2098
|
}
|
|
2046
|
-
function
|
|
2099
|
+
function Wr({
|
|
2047
2100
|
value: e,
|
|
2048
2101
|
enabled: t,
|
|
2049
2102
|
treatAs: r,
|
|
@@ -2051,40 +2104,40 @@ function zr({
|
|
|
2051
2104
|
render: o,
|
|
2052
2105
|
children: a,
|
|
2053
2106
|
target: s,
|
|
2054
|
-
rel:
|
|
2055
|
-
...
|
|
2107
|
+
rel: c,
|
|
2108
|
+
...l
|
|
2056
2109
|
}) {
|
|
2057
|
-
const { href: i } =
|
|
2110
|
+
const { href: i } = tt({ value: e, enabled: t, treatAs: r });
|
|
2058
2111
|
if (!i)
|
|
2059
2112
|
return null;
|
|
2060
|
-
const d =
|
|
2061
|
-
...
|
|
2113
|
+
const d = Zt(i), u = s !== void 0 ? s : d ? "_blank" : void 0, f = {
|
|
2114
|
+
...l,
|
|
2062
2115
|
href: i,
|
|
2063
2116
|
download: n,
|
|
2064
2117
|
target: u,
|
|
2065
|
-
rel:
|
|
2066
|
-
children: a ??
|
|
2118
|
+
rel: c ?? (d && u === "_blank" ? "noopener noreferrer" : void 0),
|
|
2119
|
+
children: a ?? Xt(i)
|
|
2067
2120
|
};
|
|
2068
|
-
return o ? /* @__PURE__ */
|
|
2121
|
+
return o ? /* @__PURE__ */ g(Se, { children: o(f) }) : /* @__PURE__ */ g("a", { ...f });
|
|
2069
2122
|
}
|
|
2070
|
-
function
|
|
2123
|
+
function er(e) {
|
|
2071
2124
|
return typeof e == "string" && e.trim().length > 0;
|
|
2072
2125
|
}
|
|
2073
|
-
function
|
|
2126
|
+
function Jr({
|
|
2074
2127
|
html: e,
|
|
2075
2128
|
sanitize: t,
|
|
2076
2129
|
render: r,
|
|
2077
2130
|
...n
|
|
2078
2131
|
}) {
|
|
2079
|
-
if (!
|
|
2132
|
+
if (!er(e))
|
|
2080
2133
|
return null;
|
|
2081
2134
|
const o = t(e);
|
|
2082
|
-
return r ? /* @__PURE__ */
|
|
2135
|
+
return r ? /* @__PURE__ */ g(Se, { children: r({ html: o }) }) : /* @__PURE__ */ g("div", { ...n, dangerouslySetInnerHTML: { __html: o } });
|
|
2083
2136
|
}
|
|
2084
|
-
function
|
|
2137
|
+
function De(e, t) {
|
|
2085
2138
|
return e.length <= t ? e : `${e.slice(0, t)}…`;
|
|
2086
2139
|
}
|
|
2087
|
-
function
|
|
2140
|
+
function tr(e) {
|
|
2088
2141
|
const t = e.trim();
|
|
2089
2142
|
return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
|
|
2090
2143
|
}
|
|
@@ -2098,7 +2151,7 @@ function Fe(e, t, r, n, o) {
|
|
|
2098
2151
|
if (e instanceof Date)
|
|
2099
2152
|
return e.toISOString();
|
|
2100
2153
|
if (typeof e == "string")
|
|
2101
|
-
return
|
|
2154
|
+
return De(e, r);
|
|
2102
2155
|
if (e === null || typeof e != "object")
|
|
2103
2156
|
return e;
|
|
2104
2157
|
if (o.has(e))
|
|
@@ -2108,11 +2161,11 @@ function Fe(e, t, r, n, o) {
|
|
|
2108
2161
|
if (o.add(e), Array.isArray(e))
|
|
2109
2162
|
return e.map((s) => Fe(s, t, r, n + 1, o));
|
|
2110
2163
|
const a = {};
|
|
2111
|
-
for (const [s,
|
|
2112
|
-
a[s] = Fe(
|
|
2164
|
+
for (const [s, c] of Object.entries(e))
|
|
2165
|
+
a[s] = Fe(c, t, r, n + 1, o);
|
|
2113
2166
|
return a;
|
|
2114
2167
|
}
|
|
2115
|
-
function
|
|
2168
|
+
function rr(e, t) {
|
|
2116
2169
|
const r = t?.maxDepth ?? 6, n = t?.maxStringLength ?? 5e4, o = t?.space ?? 2;
|
|
2117
2170
|
if (e === void 0)
|
|
2118
2171
|
return "undefined";
|
|
@@ -2120,14 +2173,14 @@ function Xt(e, t) {
|
|
|
2120
2173
|
return "null";
|
|
2121
2174
|
let a = e;
|
|
2122
2175
|
if (typeof e == "string")
|
|
2123
|
-
if (
|
|
2176
|
+
if (tr(e))
|
|
2124
2177
|
try {
|
|
2125
2178
|
a = JSON.parse(e);
|
|
2126
2179
|
} catch {
|
|
2127
|
-
return
|
|
2180
|
+
return De(e, n);
|
|
2128
2181
|
}
|
|
2129
2182
|
else
|
|
2130
|
-
return
|
|
2183
|
+
return De(e, n);
|
|
2131
2184
|
const s = Fe(a, r, n, 0, /* @__PURE__ */ new WeakSet());
|
|
2132
2185
|
try {
|
|
2133
2186
|
return JSON.stringify(s, null, o);
|
|
@@ -2135,75 +2188,79 @@ function Xt(e, t) {
|
|
|
2135
2188
|
return "[Unserializable JSON]";
|
|
2136
2189
|
}
|
|
2137
2190
|
}
|
|
2138
|
-
function
|
|
2191
|
+
function Gr({
|
|
2139
2192
|
value: e,
|
|
2140
2193
|
format: t,
|
|
2141
2194
|
formatOptions: r,
|
|
2142
2195
|
render: n,
|
|
2143
2196
|
...o
|
|
2144
2197
|
}) {
|
|
2145
|
-
const a = t ? t(e) :
|
|
2146
|
-
return n ? /* @__PURE__ */
|
|
2198
|
+
const a = t ? t(e) : rr(e, r);
|
|
2199
|
+
return n ? /* @__PURE__ */ g(Se, { children: n({ text: a }) }) : /* @__PURE__ */ g("pre", { ...o, children: a });
|
|
2147
2200
|
}
|
|
2148
|
-
function
|
|
2149
|
-
return
|
|
2201
|
+
function Yr(e, t) {
|
|
2202
|
+
return N(() => e ? yt(e, t) : {}, [e, t]);
|
|
2150
2203
|
}
|
|
2151
2204
|
export {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2205
|
+
Me as ADDRESSES_PERSISTED_EVENT,
|
|
2206
|
+
Tt as FILES_QUERY_KEY_PREFIX,
|
|
2207
|
+
Vr as OPFSFilesManager,
|
|
2208
|
+
Qr as SeedClientGate,
|
|
2209
|
+
Jr as SeedHtml,
|
|
2210
|
+
Kr as SeedImage,
|
|
2211
|
+
Gr as SeedJson,
|
|
2212
|
+
Wr as SeedMediaFile,
|
|
2213
|
+
jr as SeedMediaImage,
|
|
2214
|
+
Hr as SeedProvider,
|
|
2215
|
+
Bt as createSeedQueryClient,
|
|
2216
|
+
rr as formatSeedJson,
|
|
2217
|
+
Xe as getSeedQueryDefaultOptions,
|
|
2218
|
+
Je as getServiceName,
|
|
2219
|
+
Re as getServiceUniqueKey,
|
|
2220
|
+
ke as getServiceValue,
|
|
2221
|
+
zr as invalidateItemPropertiesForItem,
|
|
2222
|
+
$t as mergeSeedQueryDefaults,
|
|
2223
|
+
_r as useAllSchemaVersions,
|
|
2224
|
+
hr as useCreateItem,
|
|
2225
|
+
vr as useCreateItemProperty,
|
|
2226
|
+
Fr as useCreateModel,
|
|
2227
|
+
Tr as useCreateModelProperty,
|
|
2228
|
+
xr as useCreateSchema,
|
|
2229
|
+
Lr as useDbsAreReady,
|
|
2230
|
+
br as useDebouncedItemProperty,
|
|
2231
|
+
kr as useDeleteItem,
|
|
2232
|
+
wr as useDestroyItemProperty,
|
|
2233
|
+
Cr as useDestroyModel,
|
|
2234
|
+
Mr as useDestroyModelProperty,
|
|
2235
|
+
Nr as useDestroySchema,
|
|
2236
|
+
qr as useEasSyncProcessById,
|
|
2237
|
+
Or as useEasSyncProcesses,
|
|
2238
|
+
Ur as useEasSyncProcessesNonActiveCount,
|
|
2239
|
+
Mt as useEasSyncProcessesState,
|
|
2240
|
+
Br as useFiles,
|
|
2241
|
+
_t as useGlobalServiceStatus,
|
|
2242
|
+
xt as useHasSavedSnapshots,
|
|
2243
|
+
$r as useImageFiles,
|
|
2244
|
+
At as useIsDbReady,
|
|
2245
|
+
pr as useItem,
|
|
2246
|
+
Sr as useItemProperties,
|
|
2247
|
+
We as useItemProperty,
|
|
2248
|
+
mr as useItems,
|
|
2249
|
+
Y as useLiveQuery,
|
|
2250
|
+
Rt as useModel,
|
|
2251
|
+
Rr as useModelProperties,
|
|
2252
|
+
Pr as useModelProperty,
|
|
2253
|
+
Ct as useModels,
|
|
2254
|
+
Yr as useNormalizedFeedItemFields,
|
|
2255
|
+
qt as useOPFSFiles,
|
|
2256
|
+
Er as usePersistedSnapshots,
|
|
2257
|
+
gr as usePublishItem,
|
|
2258
|
+
tt as useResolvedMediaRef,
|
|
2259
|
+
Dt as useSchema,
|
|
2260
|
+
Ar as useSchemas,
|
|
2261
|
+
je as useSeedAddressRevision,
|
|
2262
|
+
Dr as useSeedProtocolSchema,
|
|
2263
|
+
Ir as useService,
|
|
2264
|
+
Nt as useServices
|
|
2208
2265
|
};
|
|
2209
2266
|
//# sourceMappingURL=index.js.map
|