@seedprotocol/react 0.7.10-next.1344.g3828e8a → 0.7.10-next.1362.g50ca0dd
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/index.js +1018 -988
- package/dist/index.js.map +1 -1
- package/dist/item.d.ts.map +1 -1
- package/dist/model.d.ts +4 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/modelProperty.d.ts +1 -1
- package/dist/modelProperty.d.ts.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/useHeldEntities.d.ts +24 -0
- package/dist/useHeldEntities.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import e, { createContext as t, useCallback as n, useContext as r, useEffect as i, useInsertionEffect as a, useMemo as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
3
3
|
import { flushSync as u } from "react-dom";
|
|
4
|
-
import { BaseArweaveClient as d, BaseDb as f, BaseFileManager as p, ClientManagerState as m, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as h, FILES_CHANGED_EVENT as g, Item as _, ItemProperty as v, ItemPropertySaveValidationError as y, MachineIds as b, Model as x, ModelProperty as S, SEED_PROTOCOL_SCHEMA_NAME as C, Schema as w, client as T, easName as ee, easSyncProcesses as E, ensureImageLocal as D, eventEmitter as O, getAddressesForItemsFilter as te, getArweaveReadBaseUrls as k, getClient as ne, getPropertySchema as A, getSchemaNameFromId as re, getVersionData as ie, isChangeFeedRunning as j, isClientReadySnapshot as ae, isValidEasAttestationUid as M, loadAllSchemasFromDb as oe, metadata as N, modelSchemas as se, models as ce, normalizeArweaveTxIdForEnsure as le, normalizeFeedItemFields as P, ownedSeedsSql as F, pickLatestMetadataRowPerProperty as ue, placeholderUidSql as de, properties as I, publisherInAddressListSql as fe, resolveMediaRef as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { QueryClient as
|
|
9
|
-
import { and as
|
|
10
|
-
import
|
|
4
|
+
import { BaseArweaveClient as d, BaseDb as f, BaseFileManager as p, ClientManagerState as m, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as h, FILES_CHANGED_EVENT as g, Item as _, ItemProperty as v, ItemPropertySaveValidationError as y, MachineIds as b, Model as x, ModelProperty as S, SEED_PROTOCOL_SCHEMA_NAME as C, Schema as w, client as T, easName as ee, easSyncProcesses as E, ensureImageLocal as D, eventEmitter as O, getAddressesForItemsFilter as te, getArweaveReadBaseUrls as k, getClient as ne, getPropertySchema as A, getSchemaNameFromId as re, getVersionData as ie, isChangeFeedRunning as j, isClientReadySnapshot as ae, isValidEasAttestationUid as M, loadAllSchemasFromDb as oe, metadata as N, modelSchemas as se, models as ce, normalizeArweaveTxIdForEnsure as le, normalizeFeedItemFields as P, ownedSeedsSql as F, pickLatestMetadataRowPerProperty as ue, placeholderUidSql as de, properties as I, publisherInAddressListSql as fe, resolveMediaRef as pe, schemas as L, seeds as R, watchEntityRows as me } from "@seedprotocol/sdk";
|
|
5
|
+
import { debounce as he, orderBy as ge, startCase as _e } from "lodash-es";
|
|
6
|
+
import ve from "debug";
|
|
7
|
+
import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
|
|
8
|
+
import { QueryClient as ye, QueryClientContext as be, QueryClientProvider as H, useQuery as U, useQueryClient as xe } from "@tanstack/react-query";
|
|
9
|
+
import { and as W, desc as Se, eq as G, gt as Ce, isNotNull as we, isNull as Te, or as Ee } from "drizzle-orm";
|
|
10
|
+
import De from "pluralize";
|
|
11
11
|
//#region src/client.ts
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
let t =
|
|
12
|
+
var Oe = (e) => ne().subscribeService(e), ke = () => ne().getService(), Ae = () => l(Oe, ke, ke);
|
|
13
|
+
function K(e) {
|
|
14
|
+
let t = Ae(), r = s(e);
|
|
15
15
|
r.current = e;
|
|
16
16
|
let i = n((e) => {
|
|
17
17
|
let n = t.subscribe({
|
|
@@ -25,11 +25,35 @@ function q(e) {
|
|
|
25
25
|
}, [t]), a = () => r.current(t.getSnapshot());
|
|
26
26
|
return l(i, a, a);
|
|
27
27
|
}
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
var q = () => K(ae);
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/useHeldEntities.ts
|
|
31
|
+
function J(e, t, n) {
|
|
32
|
+
i(() => {
|
|
33
|
+
let r = e.filter((e) => t(e));
|
|
34
|
+
r.length < e.length && n();
|
|
35
|
+
let i = !1, a = r.map((e) => e.getService().subscribe({ complete: () => {
|
|
36
|
+
i || (i = !0, n());
|
|
37
|
+
} }));
|
|
38
|
+
return () => {
|
|
39
|
+
for (let e of a) e.unsubscribe();
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
for (let e of r) e.unload();
|
|
42
|
+
}, 0);
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
e,
|
|
46
|
+
t,
|
|
47
|
+
n
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/addressesPersistedEventName.ts
|
|
52
|
+
var je = "addresses.persisted", Me = "localCopies.removed", Ne = t(0);
|
|
53
|
+
function Pe() {
|
|
54
|
+
return r(Ne);
|
|
31
55
|
}
|
|
32
|
-
function
|
|
56
|
+
function Fe({ queryClient: e, children: t }) {
|
|
33
57
|
let [r, a] = c(0), o = n(() => {
|
|
34
58
|
e.invalidateQueries({
|
|
35
59
|
queryKey: ["seed", "items"],
|
|
@@ -42,19 +66,19 @@ function Ne({ queryClient: e, children: t }) {
|
|
|
42
66
|
exact: !1
|
|
43
67
|
}), a((e) => e + 1);
|
|
44
68
|
}, [e]);
|
|
45
|
-
return i(() => (O.on(
|
|
46
|
-
O.off(
|
|
47
|
-
}), [o]), /* @__PURE__ */
|
|
69
|
+
return i(() => (O.on(je, o), O.on(Me, o), () => {
|
|
70
|
+
O.off(je, o), O.off(Me, o);
|
|
71
|
+
}), [o]), /* @__PURE__ */ B(Ne.Provider, {
|
|
48
72
|
value: r,
|
|
49
73
|
children: t
|
|
50
74
|
});
|
|
51
75
|
}
|
|
52
76
|
//#endregion
|
|
53
77
|
//#region src/liveQuery.ts
|
|
54
|
-
function
|
|
55
|
-
return
|
|
78
|
+
function Y(e) {
|
|
79
|
+
return ze(e).data;
|
|
56
80
|
}
|
|
57
|
-
function
|
|
81
|
+
function Ie(e) {
|
|
58
82
|
if (e && typeof e == "object" && typeof e.toSQL == "function") try {
|
|
59
83
|
let { sql: t, params: n } = e.toSQL();
|
|
60
84
|
return `sql:${t}|${JSON.stringify(n)}`;
|
|
@@ -63,19 +87,19 @@ function Pe(e) {
|
|
|
63
87
|
}
|
|
64
88
|
return e;
|
|
65
89
|
}
|
|
66
|
-
var
|
|
90
|
+
var Le = [
|
|
67
91
|
500,
|
|
68
92
|
1e3,
|
|
69
93
|
2e3,
|
|
70
94
|
5e3,
|
|
71
95
|
1e4,
|
|
72
96
|
3e4
|
|
73
|
-
],
|
|
74
|
-
function
|
|
97
|
+
], Re = (e) => e instanceof Error ? e : Error(String(e));
|
|
98
|
+
function ze(e) {
|
|
75
99
|
let [t, n] = c({
|
|
76
100
|
data: void 0,
|
|
77
101
|
error: null
|
|
78
|
-
}), [r, a] = c(0), o =
|
|
102
|
+
}), [r, a] = c(0), o = q(), l = Ie(e), u = s(e);
|
|
79
103
|
u.current = e;
|
|
80
104
|
let d = s(0), p = s(null);
|
|
81
105
|
return i(() => {
|
|
@@ -92,9 +116,9 @@ function Le(e) {
|
|
|
92
116
|
let r, i = (e) => {
|
|
93
117
|
n((t) => ({
|
|
94
118
|
data: t.data,
|
|
95
|
-
error:
|
|
119
|
+
error: Re(e)
|
|
96
120
|
}));
|
|
97
|
-
let t =
|
|
121
|
+
let t = Le[Math.min(d.current, Le.length - 1)];
|
|
98
122
|
d.current += 1, r = setTimeout(() => a((e) => e + 1), t);
|
|
99
123
|
}, s;
|
|
100
124
|
try {
|
|
@@ -121,16 +145,16 @@ function Le(e) {
|
|
|
121
145
|
}
|
|
122
146
|
//#endregion
|
|
123
147
|
//#region src/queryClient.ts
|
|
124
|
-
var
|
|
148
|
+
var Be = { queries: {
|
|
125
149
|
networkMode: "offlineFirst",
|
|
126
150
|
gcTime: 864e5,
|
|
127
151
|
staleTime: 6e4
|
|
128
152
|
} };
|
|
129
|
-
function
|
|
130
|
-
return { ...
|
|
153
|
+
function Ve() {
|
|
154
|
+
return { ...Be };
|
|
131
155
|
}
|
|
132
|
-
function
|
|
133
|
-
let t =
|
|
156
|
+
function He(e) {
|
|
157
|
+
let t = Ve();
|
|
134
158
|
return e ? {
|
|
135
159
|
queries: {
|
|
136
160
|
...t.queries,
|
|
@@ -142,33 +166,33 @@ function Be(e) {
|
|
|
142
166
|
}
|
|
143
167
|
} : t;
|
|
144
168
|
}
|
|
145
|
-
function
|
|
146
|
-
let t =
|
|
147
|
-
return new
|
|
169
|
+
function Ue(e) {
|
|
170
|
+
let t = Ve(), { defaultOptions: n, ...r } = e ?? {};
|
|
171
|
+
return new ye({
|
|
148
172
|
...r,
|
|
149
|
-
defaultOptions: n ?
|
|
173
|
+
defaultOptions: n ? He(n) : t
|
|
150
174
|
});
|
|
151
175
|
}
|
|
152
|
-
var
|
|
176
|
+
var We, Ge = !1, Ke = () => {
|
|
153
177
|
try {
|
|
154
178
|
return process.env.NODE_ENV !== "production";
|
|
155
179
|
} catch {
|
|
156
180
|
return !1;
|
|
157
181
|
}
|
|
158
182
|
};
|
|
159
|
-
function
|
|
160
|
-
return r(
|
|
183
|
+
function X() {
|
|
184
|
+
return r(be) || (!Ge && Ke() && (Ge = !0, console.warn("[@seedprotocol/react] A Seed hook ran outside SeedProvider (no QueryClientProvider found), so it uses a shared fallback QueryClient. Wrap the app in <SeedProvider>: from 0.8 these hooks will throw without it.")), We ?? (We = Ue()), We);
|
|
161
185
|
}
|
|
162
186
|
//#endregion
|
|
163
187
|
//#region src/item.ts
|
|
164
|
-
var
|
|
188
|
+
var qe = ve("seedSdk:react:item"), Je = (e) => [
|
|
165
189
|
"seed",
|
|
166
190
|
"item",
|
|
167
191
|
e ?? null
|
|
168
|
-
],
|
|
169
|
-
let a = t || r, [, l] = c(0), [, u] = c(0), [d, f] = c(!1), [p, m] = c(null), g = s(!1), v =
|
|
192
|
+
], Ye = ({ modelName: e, seedLocalId: t, seedUid: r }) => {
|
|
193
|
+
let a = t || r, [, l] = c(0), [, u] = c(0), [d, f] = c(!1), [p, m] = c(null), g = s(!1), v = q(), y = X(), b = o(() => Je(a), [a]), x = s(b);
|
|
170
194
|
x.current = b;
|
|
171
|
-
let S =
|
|
195
|
+
let S = U({
|
|
172
196
|
queryKey: b,
|
|
173
197
|
queryFn: async () => {
|
|
174
198
|
let n = _.peekReady(a) ?? await _.find({
|
|
@@ -178,7 +202,7 @@ var Ge = _e("seedSdk:react:item"), Ke = (e) => [
|
|
|
178
202
|
hold: !1
|
|
179
203
|
});
|
|
180
204
|
if (n) return n;
|
|
181
|
-
|
|
205
|
+
qe("[useItem] no item found", e, a);
|
|
182
206
|
let i = y.getQueryData(b);
|
|
183
207
|
return i && i.getService().getSnapshot().status === "active" ? i : null;
|
|
184
208
|
},
|
|
@@ -191,7 +215,7 @@ var Ge = _e("seedSdk:react:item"), Ke = (e) => [
|
|
|
191
215
|
}, y), C = S.data ?? void 0, w = n(() => {
|
|
192
216
|
y.invalidateQueries({ queryKey: x.current });
|
|
193
217
|
}, [y]);
|
|
194
|
-
return
|
|
218
|
+
return J(o(() => C ? [C] : [], [C]), Xe, w), i(() => {
|
|
195
219
|
let e = () => {
|
|
196
220
|
l((e) => e + 1), y.invalidateQueries({ queryKey: x.current });
|
|
197
221
|
};
|
|
@@ -234,18 +258,7 @@ var Ge = _e("seedSdk:react:item"), Ke = (e) => [
|
|
|
234
258
|
isLoading: !!a && S.isPending || d,
|
|
235
259
|
error: p ?? S.error
|
|
236
260
|
};
|
|
237
|
-
}
|
|
238
|
-
function Je(e, t) {
|
|
239
|
-
i(() => {
|
|
240
|
-
let n = e.filter((e) => _.retain(e));
|
|
241
|
-
return n.length < e.length && t(), () => {
|
|
242
|
-
setTimeout(() => {
|
|
243
|
-
for (let e of n) e.unload();
|
|
244
|
-
}, 0);
|
|
245
|
-
};
|
|
246
|
-
}, [e, t]);
|
|
247
|
-
}
|
|
248
|
-
var Ye = [], Xe = (e) => {
|
|
261
|
+
}, Xe = (e) => _.retain(e), Ze = [], Qe = (e) => {
|
|
249
262
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
250
263
|
for (let r of e ?? []) {
|
|
251
264
|
if (!r.localId) continue;
|
|
@@ -256,7 +269,7 @@ var Ye = [], Xe = (e) => {
|
|
|
256
269
|
signature: n.sort().join(","),
|
|
257
270
|
sortTimes: t
|
|
258
271
|
};
|
|
259
|
-
},
|
|
272
|
+
}, $e = (e, t, n, r, i, a, o) => [
|
|
260
273
|
"seed",
|
|
261
274
|
"items",
|
|
262
275
|
e ?? null,
|
|
@@ -268,8 +281,8 @@ var Ye = [], Xe = (e) => {
|
|
|
268
281
|
modelFileId: a ?? null,
|
|
269
282
|
schemaName: o ?? null
|
|
270
283
|
}] : []
|
|
271
|
-
],
|
|
272
|
-
let d =
|
|
284
|
+
], et = ({ modelName: e, modelFileId: t, schemaName: r, deleted: a = !1, includeEas: l = !1, addressFilter: u }) => {
|
|
285
|
+
let d = q(), p = Pe(), m = xe();
|
|
273
286
|
i(() => {
|
|
274
287
|
let e = () => {
|
|
275
288
|
m.invalidateQueries({ queryKey: ["seed", "items"] });
|
|
@@ -291,7 +304,7 @@ var Ye = [], Xe = (e) => {
|
|
|
291
304
|
e = !0;
|
|
292
305
|
};
|
|
293
306
|
}, [u, p]);
|
|
294
|
-
let C = o(() =>
|
|
307
|
+
let C = o(() => $e(e, a, l, u, p, t, r), [
|
|
295
308
|
e,
|
|
296
309
|
a,
|
|
297
310
|
l,
|
|
@@ -303,7 +316,7 @@ var Ye = [], Xe = (e) => {
|
|
|
303
316
|
i(() => {
|
|
304
317
|
v.current = /* @__PURE__ */ new Set();
|
|
305
318
|
}, [C]);
|
|
306
|
-
let { data: w =
|
|
319
|
+
let { data: w = Ze, isLoading: T, isFetching: E, dataUpdatedAt: D, error: k } = U({
|
|
307
320
|
queryKey: C,
|
|
308
321
|
queryFn: async ({ signal: n }) => (y.current++, await _.all(e, a, {
|
|
309
322
|
hold: !1,
|
|
@@ -320,24 +333,24 @@ var Ye = [], Xe = (e) => {
|
|
|
320
333
|
});
|
|
321
334
|
g.current = w;
|
|
322
335
|
let ne = s(C);
|
|
323
|
-
ne.current = C,
|
|
336
|
+
ne.current = C, J(w, Xe, n(() => {
|
|
324
337
|
m.invalidateQueries({ queryKey: ne.current });
|
|
325
338
|
}, [m]));
|
|
326
|
-
let A = d ? f.getAppDb() : null, re =
|
|
339
|
+
let A = d ? f.getAppDb() : null, re = Y(o(() => {
|
|
327
340
|
if (!A || (u === "owned" || u === "watched") && x === null) return null;
|
|
328
341
|
let t = [];
|
|
329
|
-
l || t.push(de(
|
|
342
|
+
l || t.push(de(R.uid)), e && t.push(G(R.type, ee(e))), u === "owned" ? t.push(F(x ?? [])) : u === "watched" && t.push(fe(R.publisher, x ?? [])), a ? t.push(G(R._markedForDeletion, 1)) : (t.push(Ee(Te(R._markedForDeletion), G(R._markedForDeletion, 0))), t.push(Ee(Te(R.revokedAt), G(R.revokedAt, 0))));
|
|
330
343
|
let n = ie();
|
|
331
344
|
return A.with(n).select({
|
|
332
|
-
localId:
|
|
333
|
-
uid:
|
|
334
|
-
type:
|
|
335
|
-
schemaUid:
|
|
336
|
-
createdAt:
|
|
337
|
-
attestationCreatedAt:
|
|
345
|
+
localId: R.localId,
|
|
346
|
+
uid: R.uid,
|
|
347
|
+
type: R.type,
|
|
348
|
+
schemaUid: R.schemaUid,
|
|
349
|
+
createdAt: R.createdAt,
|
|
350
|
+
attestationCreatedAt: R.attestationCreatedAt,
|
|
338
351
|
lastVersionPublishedAt: n.lastVersionPublishedAt,
|
|
339
|
-
_markedForDeletion:
|
|
340
|
-
}).from(
|
|
352
|
+
_markedForDeletion: R._markedForDeletion
|
|
353
|
+
}).from(R).leftJoin(n, G(R.localId, n.seedLocalId)).where(W(Ce(n.versionsCount, 0), ...t)).groupBy(R.localId);
|
|
341
354
|
}, [
|
|
342
355
|
A,
|
|
343
356
|
d,
|
|
@@ -346,7 +359,7 @@ var Ye = [], Xe = (e) => {
|
|
|
346
359
|
l,
|
|
347
360
|
u,
|
|
348
361
|
x
|
|
349
|
-
])), j = s(
|
|
362
|
+
])), j = s(Qe(void 0)), ae = Qe(re);
|
|
350
363
|
ae.signature !== j.current.signature && (j.current = ae);
|
|
351
364
|
let M = j.current;
|
|
352
365
|
return i(() => {
|
|
@@ -361,7 +374,7 @@ var Ye = [], Xe = (e) => {
|
|
|
361
374
|
let n = e.seedLocalId || e.seedUid;
|
|
362
375
|
n && t.add(n);
|
|
363
376
|
}
|
|
364
|
-
e.size === 0 && t.size > 0 || (
|
|
377
|
+
e.size === 0 && t.size > 0 || (rt(t, e) ? v.current = e : rt(v.current, e) && (y.current > b.current || E) || (v.current = e, b.current = y.current, m.invalidateQueries({ queryKey: C })));
|
|
365
378
|
}, [
|
|
366
379
|
d,
|
|
367
380
|
re,
|
|
@@ -370,15 +383,15 @@ var Ye = [], Xe = (e) => {
|
|
|
370
383
|
D,
|
|
371
384
|
E
|
|
372
385
|
]), {
|
|
373
|
-
items: o(() =>
|
|
386
|
+
items: o(() => ge(w, [(e) => e.seedLocalId && M.sortTimes.get(e.seedLocalId) || e.lastVersionPublishedAt || e.attestationCreatedAt || e.createdAt], ["desc"]), [w, M]),
|
|
374
387
|
isLoading: T || !d,
|
|
375
388
|
error: k
|
|
376
389
|
};
|
|
377
|
-
},
|
|
390
|
+
}, tt = () => {
|
|
378
391
|
let [e, t] = c(!1), [r, i] = c(null), a = s(null), o = n(() => i(null), []);
|
|
379
392
|
return {
|
|
380
393
|
createItem: n((e, n, r) => {
|
|
381
|
-
if (a.current) return
|
|
394
|
+
if (a.current) return qe("[useCreateItem] [createItem] already creating item, returning the in-flight create"), a.current;
|
|
382
395
|
i(null), u(() => t(!0));
|
|
383
396
|
let o = (async () => {
|
|
384
397
|
try {
|
|
@@ -391,7 +404,7 @@ var Ye = [], Xe = (e) => {
|
|
|
391
404
|
...r
|
|
392
405
|
}) ?? void 0;
|
|
393
406
|
} catch (e) {
|
|
394
|
-
|
|
407
|
+
qe("[useCreateItem] Error creating item:", e), i(e instanceof Error ? e : Error(String(e)));
|
|
395
408
|
return;
|
|
396
409
|
} finally {
|
|
397
410
|
a.current = null, queueMicrotask(() => t(!1));
|
|
@@ -403,7 +416,7 @@ var Ye = [], Xe = (e) => {
|
|
|
403
416
|
error: r,
|
|
404
417
|
resetError: o
|
|
405
418
|
};
|
|
406
|
-
},
|
|
419
|
+
}, nt = () => {
|
|
407
420
|
let [e, t] = c(null), [r, a] = c(!1), [o, l] = c(null), u = s(void 0), d = n(() => l(null), []), f = n((e, n) => {
|
|
408
421
|
e && (t(e), l(null), e.publish(n).catch((e) => {
|
|
409
422
|
l(e instanceof Error ? e : Error(String(e)));
|
|
@@ -428,16 +441,16 @@ var Ye = [], Xe = (e) => {
|
|
|
428
441
|
resetError: d
|
|
429
442
|
};
|
|
430
443
|
};
|
|
431
|
-
function
|
|
444
|
+
function rt(e, t) {
|
|
432
445
|
return e.size === t.size && [...e].every((e) => t.has(e));
|
|
433
446
|
}
|
|
434
447
|
//#endregion
|
|
435
448
|
//#region src/entityRows.ts
|
|
436
|
-
function
|
|
437
|
-
let n =
|
|
449
|
+
function it(e, t) {
|
|
450
|
+
let n = q() && j(), r = ze(n ? null : t), [a, o] = c({
|
|
438
451
|
data: void 0,
|
|
439
452
|
error: null
|
|
440
|
-
}), l = e && t ? `${JSON.stringify(e)}|${String(
|
|
453
|
+
}), l = e && t ? `${JSON.stringify(e)}|${String(Ie(t))}` : null, u = s({
|
|
441
454
|
watch: e,
|
|
442
455
|
query: t
|
|
443
456
|
});
|
|
@@ -451,14 +464,14 @@ function nt(e, t) {
|
|
|
451
464
|
});
|
|
452
465
|
let { watch: e, query: t } = u.current;
|
|
453
466
|
if (!n || !l || !e || !t) return;
|
|
454
|
-
let r =
|
|
467
|
+
let r = me(e, () => t.all(), (e) => o({
|
|
455
468
|
data: [...e],
|
|
456
469
|
error: null
|
|
457
470
|
}), {
|
|
458
471
|
immediate: !0,
|
|
459
472
|
onError: (e) => o((t) => ({
|
|
460
473
|
data: t.data,
|
|
461
|
-
error:
|
|
474
|
+
error: Re(e)
|
|
462
475
|
}))
|
|
463
476
|
});
|
|
464
477
|
return () => r.unsubscribe();
|
|
@@ -466,15 +479,15 @@ function nt(e, t) {
|
|
|
466
479
|
}
|
|
467
480
|
//#endregion
|
|
468
481
|
//#region src/itemProperty.ts
|
|
469
|
-
var
|
|
482
|
+
var at = ve("seedSdk:react:property"), ot = ve("seedSdk:react:itemProperties"), st = (e, t, n) => [
|
|
470
483
|
"seed",
|
|
471
484
|
"itemProperty",
|
|
472
485
|
e ?? null,
|
|
473
486
|
t ?? null,
|
|
474
487
|
n
|
|
475
488
|
];
|
|
476
|
-
function
|
|
477
|
-
let n =
|
|
489
|
+
function ct(e, t) {
|
|
490
|
+
let n = q(), r = X(), [, a] = c(0), s = typeof e == "object" && e ? e : null, l = s?.itemId, u = s?.seedLocalId, d = s?.seedUid, f = s?.propertyName, p = typeof e == "string" ? e : l !== void 0 && l !== "" ? l : void 0, m = f ?? (typeof e == "string" ? t : void 0), h = o(() => {
|
|
478
491
|
let e = p !== void 0 && p !== "" ? p : u, t = p !== void 0 && p !== "" ? void 0 : d;
|
|
479
492
|
return (e || t) && m ? {
|
|
480
493
|
type: "identifiers",
|
|
@@ -488,7 +501,7 @@ function ot(e, t) {
|
|
|
488
501
|
m,
|
|
489
502
|
u,
|
|
490
503
|
d
|
|
491
|
-
]), g = o(() =>
|
|
504
|
+
]), g = o(() => st(h?.seedLocalId, h?.seedUid, h?.propertyName ?? ""), [h]), _ = U({
|
|
492
505
|
queryKey: g,
|
|
493
506
|
queryFn: async () => {
|
|
494
507
|
if (!h) return null;
|
|
@@ -502,7 +515,7 @@ function ot(e, t) {
|
|
|
502
515
|
seedUid: h.itemId,
|
|
503
516
|
hold: !1
|
|
504
517
|
}) : void 0, n = e ?? t;
|
|
505
|
-
return n ||
|
|
518
|
+
return n || at(`[useItemProperty] no property found for Item.${h.seedLocalId || h.seedUid}.${h.propertyName}`), n ?? null;
|
|
506
519
|
},
|
|
507
520
|
initialData: () => h ? v.peekReady(h) : void 0,
|
|
508
521
|
staleTime: 0,
|
|
@@ -511,7 +524,7 @@ function ot(e, t) {
|
|
|
511
524
|
retry: !1,
|
|
512
525
|
enabled: n && !!h
|
|
513
526
|
}, r), y = _.data ?? void 0;
|
|
514
|
-
return
|
|
527
|
+
return dt(o(() => y ? [y] : [], [y])), i(() => {
|
|
515
528
|
if (!y) return;
|
|
516
529
|
let e = () => a((e) => e + 1), t = y.getService().getSnapshot()?.context, n = t?.renderValue, r = t?.propertyValue, i = !1, o = 0, s, c = y.getService().subscribe((t) => {
|
|
517
530
|
let a = t?.context ?? {};
|
|
@@ -538,8 +551,8 @@ function ot(e, t) {
|
|
|
538
551
|
error: _.error
|
|
539
552
|
};
|
|
540
553
|
}
|
|
541
|
-
function
|
|
542
|
-
let r = "itemId" in e ? e.itemId : void 0, a = "seedLocalId" in e ? e.seedLocalId : void 0, c = "seedUid" in e ? e.seedUid : void 0, l = e.propertyName, { property: u, isLoading: d, error: f } =
|
|
554
|
+
function lt(e, t = 300) {
|
|
555
|
+
let r = "itemId" in e ? e.itemId : void 0, a = "seedLocalId" in e ? e.seedLocalId : void 0, c = "seedUid" in e ? e.seedUid : void 0, l = e.propertyName, { property: u, isLoading: d, error: f } = ct(o(() => r ? {
|
|
543
556
|
itemId: r,
|
|
544
557
|
propertyName: l
|
|
545
558
|
} : {
|
|
@@ -551,7 +564,7 @@ function st(e, t = 300) {
|
|
|
551
564
|
a,
|
|
552
565
|
c,
|
|
553
566
|
l
|
|
554
|
-
])), p = s(""), m =
|
|
567
|
+
])), p = s(""), m = ut(u), h = o(() => he((e) => {
|
|
555
568
|
e.setValue(p.current);
|
|
556
569
|
}, t), [t]);
|
|
557
570
|
i(() => () => h.flush(), [h]);
|
|
@@ -566,7 +579,7 @@ function st(e, t = 300) {
|
|
|
566
579
|
error: f ?? m
|
|
567
580
|
};
|
|
568
581
|
}
|
|
569
|
-
function
|
|
582
|
+
function ut(e) {
|
|
570
583
|
let [t, n] = c(null);
|
|
571
584
|
return i(() => {
|
|
572
585
|
if (!e) {
|
|
@@ -586,7 +599,7 @@ function ct(e) {
|
|
|
586
599
|
return () => a.unsubscribe();
|
|
587
600
|
}, [e]), t;
|
|
588
601
|
}
|
|
589
|
-
function
|
|
602
|
+
function dt(e) {
|
|
590
603
|
i(() => {
|
|
591
604
|
let t = e.filter((e) => v.retain(e));
|
|
592
605
|
return () => {
|
|
@@ -596,7 +609,7 @@ function lt(e) {
|
|
|
596
609
|
};
|
|
597
610
|
}, [e]);
|
|
598
611
|
}
|
|
599
|
-
async function
|
|
612
|
+
async function ft(e, t) {
|
|
600
613
|
if (!e && !t) return [];
|
|
601
614
|
let n = f.getAppDb();
|
|
602
615
|
if (!n) return [];
|
|
@@ -611,19 +624,19 @@ async function ut(e, t) {
|
|
|
611
624
|
let o;
|
|
612
625
|
if (r.length > 0) {
|
|
613
626
|
let e = r[0];
|
|
614
|
-
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o =
|
|
627
|
+
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o = _e(o));
|
|
615
628
|
}
|
|
616
629
|
let s = await n.select({
|
|
617
|
-
type:
|
|
618
|
-
modelFileId:
|
|
619
|
-
}).from(
|
|
620
|
-
!o && s.length > 0 && s[0].type && (o =
|
|
630
|
+
type: R.type,
|
|
631
|
+
modelFileId: R.modelFileId
|
|
632
|
+
}).from(R).where(t ? G(R.uid, t) : G(R.localId, e)).limit(1), c = s[0]?.modelFileId ?? void 0;
|
|
633
|
+
!o && s.length > 0 && s[0].type && (o = _e(s[0].type));
|
|
621
634
|
let l = [];
|
|
622
635
|
if (o) try {
|
|
623
636
|
let { Model: e } = await import("@seedprotocol/sdk"), t = await e.resolveAsync(o, { modelFileId: c });
|
|
624
637
|
if (t?.properties) for (let e of t.properties) e.name && l.push(e.name);
|
|
625
638
|
} catch (e) {
|
|
626
|
-
|
|
639
|
+
ot(`[useItemProperties] Error getting ModelProperties for ${o}:`, e);
|
|
627
640
|
}
|
|
628
641
|
if (o && l.length > 0) {
|
|
629
642
|
let n = r.length > 0 ? r[0].seedLocalId ?? e : e, s = r.length > 0 ? r[0].seedUid ?? t : t;
|
|
@@ -640,11 +653,11 @@ async function ut(e, t) {
|
|
|
640
653
|
});
|
|
641
654
|
t && i.push(t);
|
|
642
655
|
} catch (t) {
|
|
643
|
-
|
|
656
|
+
at(`[useItemProperties] Error creating ItemProperty for missing property ${e}:`, t);
|
|
644
657
|
}
|
|
645
658
|
}
|
|
646
659
|
if (e || t) {
|
|
647
|
-
let a = await n.select({ createdAt:
|
|
660
|
+
let a = await n.select({ createdAt: R.createdAt }).from(R).where(t ? G(R.uid, t) : G(R.localId, e)).limit(1);
|
|
648
661
|
if (a.length > 0 && a[0].createdAt) {
|
|
649
662
|
let n = "createdAt";
|
|
650
663
|
if (!i.some((e) => e.propertyName === n) && o) try {
|
|
@@ -660,14 +673,14 @@ async function ut(e, t) {
|
|
|
660
673
|
});
|
|
661
674
|
l && i.push(l);
|
|
662
675
|
} catch (e) {
|
|
663
|
-
|
|
676
|
+
at("[useItemProperties] Error creating createdAt ItemProperty:", e);
|
|
664
677
|
}
|
|
665
678
|
}
|
|
666
679
|
}
|
|
667
680
|
return i;
|
|
668
681
|
}
|
|
669
|
-
function
|
|
670
|
-
let t =
|
|
682
|
+
function pt(e) {
|
|
683
|
+
let t = q(), n = xe(), r = s(void 0), a = o(() => typeof e == "string" ? {
|
|
671
684
|
type: "itemId",
|
|
672
685
|
itemId: e
|
|
673
686
|
} : typeof e == "object" ? {
|
|
@@ -682,18 +695,18 @@ function dt(e) {
|
|
|
682
695
|
"seed",
|
|
683
696
|
"itemProperties",
|
|
684
697
|
u
|
|
685
|
-
], [u]), { data: p = [], isLoading: m, error: h } =
|
|
698
|
+
], [u]), { data: p = [], isLoading: m, error: h } = U({
|
|
686
699
|
queryKey: d,
|
|
687
|
-
queryFn: () =>
|
|
700
|
+
queryFn: () => ft(c, l),
|
|
688
701
|
enabled: t && !!u,
|
|
689
702
|
gcTime: 0
|
|
690
703
|
});
|
|
691
|
-
|
|
704
|
+
dt(p);
|
|
692
705
|
let g = o(() => {
|
|
693
|
-
if (!t || !c && !l) return
|
|
706
|
+
if (!t || !c && !l) return ot("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
694
707
|
let e = f.getAppDb();
|
|
695
|
-
if (!e) return
|
|
696
|
-
|
|
708
|
+
if (!e) return ot("[useItemProperties] Query: returning null (no db)"), null;
|
|
709
|
+
ot(`[useItemProperties] Query: creating query for seedLocalId=${c}, seedUid=${l}`);
|
|
697
710
|
let n = l ? e.select({
|
|
698
711
|
propertyName: N.propertyName,
|
|
699
712
|
propertyValue: N.propertyValue,
|
|
@@ -705,7 +718,7 @@ function dt(e) {
|
|
|
705
718
|
attestationCreatedAt: N.attestationCreatedAt,
|
|
706
719
|
localId: N.localId,
|
|
707
720
|
revokedAt: N.revokedAt
|
|
708
|
-
}).from(N).where(G(
|
|
721
|
+
}).from(N).where(W(G(N.seedUid, l), we(N.propertyName))) : c ? e.select({
|
|
709
722
|
propertyName: N.propertyName,
|
|
710
723
|
propertyValue: N.propertyValue,
|
|
711
724
|
seedLocalId: N.seedLocalId,
|
|
@@ -716,13 +729,13 @@ function dt(e) {
|
|
|
716
729
|
attestationCreatedAt: N.attestationCreatedAt,
|
|
717
730
|
localId: N.localId,
|
|
718
731
|
revokedAt: N.revokedAt
|
|
719
|
-
}).from(N).where(G(
|
|
720
|
-
return
|
|
732
|
+
}).from(N).where(W(G(N.seedLocalId, c), we(N.propertyName))) : null;
|
|
733
|
+
return ot("[useItemProperties] Query: created query object", { queryType: l ? "seedUid" : "seedLocalId" }), n;
|
|
721
734
|
}, [
|
|
722
735
|
t,
|
|
723
736
|
c,
|
|
724
737
|
l
|
|
725
|
-
]), _ =
|
|
738
|
+
]), _ = it(o(() => l ? {
|
|
726
739
|
seedUid: l,
|
|
727
740
|
tables: ["metadata"]
|
|
728
741
|
} : c ? {
|
|
@@ -754,7 +767,7 @@ function dt(e) {
|
|
|
754
767
|
error: h
|
|
755
768
|
};
|
|
756
769
|
}
|
|
757
|
-
var
|
|
770
|
+
var mt = () => {
|
|
758
771
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
759
772
|
if (!t.propertyName || !t.seedLocalId && !t.seedUid || !t.modelName) {
|
|
760
773
|
o(/* @__PURE__ */ Error("seedLocalId or seedUid, propertyName, and modelName are required"));
|
|
@@ -782,7 +795,7 @@ var ft = () => {
|
|
|
782
795
|
error: a,
|
|
783
796
|
resetError: l
|
|
784
797
|
};
|
|
785
|
-
},
|
|
798
|
+
}, ht = () => {
|
|
786
799
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
787
800
|
return {
|
|
788
801
|
destroy: n(async (e) => {
|
|
@@ -801,24 +814,24 @@ var ft = () => {
|
|
|
801
814
|
error: r,
|
|
802
815
|
resetError: n(() => i(null), [])
|
|
803
816
|
};
|
|
804
|
-
},
|
|
817
|
+
}, gt = /* @__PURE__ */ new Set([
|
|
805
818
|
m.SAVE_CONFIG,
|
|
806
819
|
m.PROCESS_SCHEMA_FILES,
|
|
807
820
|
m.ADD_MODELS_TO_DB,
|
|
808
821
|
m.IDLE
|
|
809
|
-
]),
|
|
822
|
+
]), _t = (e) => typeof e == "string" && gt.has(e), vt = () => ({ dbsAreReady: K((e) => e.status === "active" && _t(e.value)) }), yt = ve("seedSdk:react:services"), bt = [
|
|
810
823
|
"idle",
|
|
811
824
|
"ready",
|
|
812
825
|
"done",
|
|
813
826
|
"success",
|
|
814
827
|
"initialized"
|
|
815
|
-
],
|
|
828
|
+
], xt = (e) => {
|
|
816
829
|
let t = "actor", n = e;
|
|
817
|
-
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t =
|
|
818
|
-
},
|
|
830
|
+
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t = Ct(e)), t;
|
|
831
|
+
}, St = (e) => {
|
|
819
832
|
let t;
|
|
820
|
-
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value),
|
|
821
|
-
},
|
|
833
|
+
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), xt(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;
|
|
834
|
+
}, Ct = (e) => {
|
|
822
835
|
let t = e;
|
|
823
836
|
if (!e || !t.logic || !t.logic.config || !t._snapshot) return;
|
|
824
837
|
let n = t.logic.config;
|
|
@@ -829,23 +842,23 @@ var ft = () => {
|
|
|
829
842
|
try {
|
|
830
843
|
i = e.getSnapshot();
|
|
831
844
|
} catch (e) {
|
|
832
|
-
return
|
|
845
|
+
return yt("Error:", e), r;
|
|
833
846
|
}
|
|
834
847
|
if (i) {
|
|
835
848
|
let e = i.context;
|
|
836
|
-
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r =
|
|
849
|
+
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r = De(e.modelName.toLowerCase()));
|
|
837
850
|
}
|
|
838
851
|
return r;
|
|
839
|
-
},
|
|
852
|
+
}, wt = (e) => e?.logic?.config?.id === b.CLIENT_MANAGER, Tt = (e) => {
|
|
840
853
|
let t = e?.getSnapshot();
|
|
841
|
-
if (
|
|
842
|
-
let n =
|
|
843
|
-
if (n &&
|
|
854
|
+
if (wt(e)) return t?.status === "active" ? At(t.value) : 0;
|
|
855
|
+
let n = St(e);
|
|
856
|
+
if (n && bt.includes(n)) return 100;
|
|
844
857
|
let r = e?.logic?.states;
|
|
845
858
|
if (!n || !r) return 0;
|
|
846
859
|
let i = Object.entries(r).filter(([, e]) => e.tags?.includes("loading")).map(([e]) => e), a = i.indexOf(n);
|
|
847
860
|
return a < 0 ? 0 : a / i.length * 100;
|
|
848
|
-
},
|
|
861
|
+
}, Et = (e) => {
|
|
849
862
|
let [t, r] = c(0), a = n((t) => {
|
|
850
863
|
let n = e.subscribe({
|
|
851
864
|
next: t,
|
|
@@ -853,7 +866,7 @@ var ft = () => {
|
|
|
853
866
|
complete: t
|
|
854
867
|
});
|
|
855
868
|
return () => n.unsubscribe();
|
|
856
|
-
}, [e]), o = () =>
|
|
869
|
+
}, [e]), o = () => St(e), s = l(a, o, o), u = n((t) => {
|
|
857
870
|
let n = e.getSnapshot().value;
|
|
858
871
|
n === "done" || n === "success" || n === "idle" || n === "ready" ? clearInterval(t) : r((e) => e + 1);
|
|
859
872
|
}, [e]), d = n(() => {
|
|
@@ -866,16 +879,16 @@ var ft = () => {
|
|
|
866
879
|
let e = d();
|
|
867
880
|
return () => clearInterval(e);
|
|
868
881
|
}, []), {
|
|
869
|
-
name:
|
|
882
|
+
name: xt(e),
|
|
870
883
|
timeElapsed: t,
|
|
871
884
|
value: s,
|
|
872
|
-
percentComplete:
|
|
873
|
-
uniqueKey:
|
|
885
|
+
percentComplete: Tt(e),
|
|
886
|
+
uniqueKey: Ct(e)
|
|
874
887
|
};
|
|
875
|
-
},
|
|
876
|
-
let { internalStatus: e } =
|
|
888
|
+
}, Dt = () => {
|
|
889
|
+
let { internalStatus: e } = Mt();
|
|
877
890
|
return e === "ready";
|
|
878
|
-
},
|
|
891
|
+
}, Ot = () => {}, kt = () => !1, At = (e) => {
|
|
879
892
|
switch (e) {
|
|
880
893
|
case m.IDLE: return 100;
|
|
881
894
|
case m.ADD_MODELS_TO_DB: return 90;
|
|
@@ -886,17 +899,17 @@ var ft = () => {
|
|
|
886
899
|
case m.PLATFORM_CLASSES_INIT: return 10;
|
|
887
900
|
default: return 0;
|
|
888
901
|
}
|
|
889
|
-
},
|
|
890
|
-
let e =
|
|
902
|
+
}, jt = () => {
|
|
903
|
+
let e = Ae(), t = K((e) => e.status === "active" ? At(e.value) : 0);
|
|
891
904
|
return {
|
|
892
905
|
services: o(() => (e.uniqueKey = "clientManager", [e]), [e]),
|
|
893
906
|
percentComplete: t
|
|
894
907
|
};
|
|
895
|
-
},
|
|
896
|
-
status:
|
|
897
|
-
internalStatus:
|
|
898
|
-
}),
|
|
899
|
-
function
|
|
908
|
+
}, Mt = () => ({
|
|
909
|
+
status: K((e) => e.value),
|
|
910
|
+
internalStatus: K((e) => e.status === "active" && _t(e.value) ? "ready" : e.value)
|
|
911
|
+
}), Nt = (e) => e instanceof Error ? e : Error(String(e));
|
|
912
|
+
function Pt(e) {
|
|
900
913
|
let t = s(null), r = s(0), [a, o] = c(!1), [l, u] = c(null), d = n(() => u(null), []), f = n((n) => {
|
|
901
914
|
let r = (t) => {
|
|
902
915
|
if (n.status === "error") {
|
|
@@ -906,7 +919,7 @@ function Mt(e) {
|
|
|
906
919
|
}, i = n.getService();
|
|
907
920
|
t.current = i.subscribe(r), r(i.getSnapshot());
|
|
908
921
|
}, [e]), p = n((e) => {
|
|
909
|
-
throw u(
|
|
922
|
+
throw u(Nt(e)), o(!1), e;
|
|
910
923
|
}, []), m = n(() => (t.current?.unsubscribe(), t.current = null, u(null), o(!0), ++r.current), []), h = n((e) => {
|
|
911
924
|
m();
|
|
912
925
|
let t;
|
|
@@ -946,17 +959,20 @@ function Mt(e) {
|
|
|
946
959
|
}
|
|
947
960
|
//#endregion
|
|
948
961
|
//#region src/schema.ts
|
|
949
|
-
var
|
|
950
|
-
let [t, r] = c(null), [a, o] = c(!!e), [s, l] = c(null), d =
|
|
962
|
+
var Ft = ve("seedSdk:react:schema"), It = (e) => {
|
|
963
|
+
let [t, r] = c(null), [a, o] = c(!!e), [s, l] = c(null), d = q(), f = n(async (e, t) => {
|
|
951
964
|
o(!0), l(null);
|
|
952
965
|
try {
|
|
953
|
-
if (!await
|
|
966
|
+
if (!await Lt(e)) {
|
|
954
967
|
if (!t.current) return;
|
|
955
968
|
r(null), o(!1);
|
|
956
969
|
return;
|
|
957
970
|
}
|
|
958
971
|
if (!t.current) return;
|
|
959
|
-
let n = w.create(e, {
|
|
972
|
+
let n = w.create(e, {
|
|
973
|
+
waitForReady: !1,
|
|
974
|
+
hold: !0
|
|
975
|
+
});
|
|
960
976
|
t.instance = n, r(n);
|
|
961
977
|
let i = n.getService(), a = (t) => {
|
|
962
978
|
if (n.status === "ready") u(() => o(!1)), l(null);
|
|
@@ -967,7 +983,7 @@ var Nt = _e("seedSdk:react:schema"), Pt = (e) => {
|
|
|
967
983
|
};
|
|
968
984
|
a(i.getSnapshot()), t.subscription = i.subscribe(a);
|
|
969
985
|
} catch (e) {
|
|
970
|
-
if (
|
|
986
|
+
if (Ft("[useSchema] Error creating schema:", e), !t.current) return;
|
|
971
987
|
l(e), r(null), o(!1);
|
|
972
988
|
}
|
|
973
989
|
}, []);
|
|
@@ -994,64 +1010,66 @@ var Nt = _e("seedSdk:react:schema"), Pt = (e) => {
|
|
|
994
1010
|
error: s
|
|
995
1011
|
};
|
|
996
1012
|
};
|
|
997
|
-
async function
|
|
1013
|
+
async function Lt(e) {
|
|
998
1014
|
if (e === C) return !0;
|
|
999
1015
|
let t = f.getAppDb();
|
|
1000
|
-
return !t || (await t.select({ id:
|
|
1016
|
+
return !t || (await t.select({ id: L.id }).from(L).where(Ee(G(L.name, e), G(L.schemaFileId, e))).limit(1)).length > 0;
|
|
1001
1017
|
}
|
|
1002
|
-
var
|
|
1003
|
-
let e =
|
|
1004
|
-
queryKey:
|
|
1018
|
+
var Rt = ["seed", "schemas"], zt = [], Bt = (e) => w.retain(e), Vt = () => {
|
|
1019
|
+
let e = q(), t = X(), r = s(void 0), a = s([]), { data: c = zt, isLoading: l, error: u } = U({
|
|
1020
|
+
queryKey: Rt,
|
|
1005
1021
|
queryFn: () => w.all({ waitForReady: !0 }),
|
|
1006
1022
|
enabled: e
|
|
1007
1023
|
}, t);
|
|
1008
|
-
|
|
1009
|
-
|
|
1024
|
+
a.current = c, J(c, Bt, n(() => {
|
|
1025
|
+
t.invalidateQueries({ queryKey: Rt });
|
|
1026
|
+
}, [t]));
|
|
1027
|
+
let d = e ? f.getAppDb() : null, p = Y(o(() => d ? d.select().from(L).orderBy(L.name, Se(L.version)) : null, [d, e]));
|
|
1010
1028
|
return i(() => {
|
|
1011
1029
|
if (typeof BroadcastChannel > "u") return;
|
|
1012
1030
|
let e = new BroadcastChannel("seed-schemas-invalidate"), n = () => {
|
|
1013
|
-
t.invalidateQueries({ queryKey:
|
|
1031
|
+
t.invalidateQueries({ queryKey: Rt });
|
|
1014
1032
|
};
|
|
1015
1033
|
return e.addEventListener("message", n), () => {
|
|
1016
1034
|
e.removeEventListener("message", n), e.close();
|
|
1017
1035
|
};
|
|
1018
1036
|
}, [t]), i(() => {
|
|
1019
|
-
if (!e || !
|
|
1020
|
-
let
|
|
1021
|
-
if ((
|
|
1022
|
-
|
|
1023
|
-
let
|
|
1024
|
-
for (let e of
|
|
1037
|
+
if (!e || !p) return;
|
|
1038
|
+
let n = r.current;
|
|
1039
|
+
if ((n ? JSON.stringify(n) : "undefined") === (p ? JSON.stringify(p) : "undefined") && n !== void 0) return;
|
|
1040
|
+
r.current = p;
|
|
1041
|
+
let i = /* @__PURE__ */ new Set();
|
|
1042
|
+
for (let e of a.current) {
|
|
1025
1043
|
if (e.metadata?.name === C) continue;
|
|
1026
1044
|
let t = e.id || e.schemaFileId;
|
|
1027
|
-
if (t)
|
|
1045
|
+
if (t) i.add(t);
|
|
1028
1046
|
else {
|
|
1029
1047
|
let t = e.metadata?.name, n = e.version;
|
|
1030
|
-
t && n !== void 0 &&
|
|
1048
|
+
t && n !== void 0 && i.add(`${t}:${n}`);
|
|
1031
1049
|
}
|
|
1032
1050
|
}
|
|
1033
1051
|
let o = /* @__PURE__ */ new Set();
|
|
1034
|
-
for (let e of
|
|
1035
|
-
let s =
|
|
1036
|
-
!s && (c || l) && t.invalidateQueries({ queryKey:
|
|
1052
|
+
for (let e of p) e.name !== "Seed Protocol" && (e.schemaFileId ? o.add(e.schemaFileId) : e.name != null && e.version !== void 0 && o.add(`${e.name}:${e.version}`));
|
|
1053
|
+
let s = i.size === o.size && [...i].every((e) => o.has(e)), c = i.size > 0 && o.size > 0 && [...o].some((e) => !i.has(e)), l = [...i].some((e) => !o.has(e));
|
|
1054
|
+
!s && (c || l) && t.invalidateQueries({ queryKey: Rt });
|
|
1037
1055
|
}, [
|
|
1038
1056
|
e,
|
|
1039
|
-
|
|
1057
|
+
p,
|
|
1040
1058
|
t
|
|
1041
1059
|
]), {
|
|
1042
|
-
schemas:
|
|
1043
|
-
isLoading:
|
|
1044
|
-
error:
|
|
1060
|
+
schemas: c,
|
|
1061
|
+
isLoading: l,
|
|
1062
|
+
error: u
|
|
1045
1063
|
};
|
|
1046
|
-
},
|
|
1047
|
-
let { run: e, isLoading: t, error: r, resetError: i } =
|
|
1064
|
+
}, Ht = () => {
|
|
1065
|
+
let { run: e, isLoading: t, error: r, resetError: i } = Pt("Failed to create schema");
|
|
1048
1066
|
return {
|
|
1049
1067
|
createSchema: n((t) => e(() => w.create(t, { waitForReady: !1 })), [e]),
|
|
1050
1068
|
isLoading: t,
|
|
1051
1069
|
error: r,
|
|
1052
1070
|
resetError: i
|
|
1053
1071
|
};
|
|
1054
|
-
},
|
|
1072
|
+
}, Ut = () => {
|
|
1055
1073
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1056
1074
|
return {
|
|
1057
1075
|
destroy: n(async (e) => {
|
|
@@ -1070,8 +1088,8 @@ var It = ["seed", "schemas"], Lt = () => {
|
|
|
1070
1088
|
error: r,
|
|
1071
1089
|
resetError: n(() => i(null), [])
|
|
1072
1090
|
};
|
|
1073
|
-
},
|
|
1074
|
-
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a =
|
|
1091
|
+
}, Wt = () => {
|
|
1092
|
+
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a = q(), o = n(async () => {
|
|
1075
1093
|
if (a) try {
|
|
1076
1094
|
let e = await oe(), n = /* @__PURE__ */ new Set();
|
|
1077
1095
|
for (let t of e) {
|
|
@@ -1083,13 +1101,16 @@ var It = ["seed", "schemas"], Lt = () => {
|
|
|
1083
1101
|
let t = r.current.get(e);
|
|
1084
1102
|
i.set(e, t);
|
|
1085
1103
|
} else {
|
|
1086
|
-
let t = w.create(e, {
|
|
1104
|
+
let t = w.create(e, {
|
|
1105
|
+
waitForReady: !1,
|
|
1106
|
+
hold: !0
|
|
1107
|
+
});
|
|
1087
1108
|
i.set(e, t);
|
|
1088
1109
|
}
|
|
1089
1110
|
for (let [e, t] of r.current.entries()) n.has(e) || t.unload();
|
|
1090
1111
|
r.current = i, t(Array.from(i.values()));
|
|
1091
1112
|
} catch (e) {
|
|
1092
|
-
|
|
1113
|
+
Ft("Error fetching all schema versions from database:", e), t(null);
|
|
1093
1114
|
}
|
|
1094
1115
|
}, [a]);
|
|
1095
1116
|
return i(() => {
|
|
@@ -1099,113 +1120,118 @@ var It = ["seed", "schemas"], Lt = () => {
|
|
|
1099
1120
|
e.unload();
|
|
1100
1121
|
}), r.current.clear();
|
|
1101
1122
|
}, []), e;
|
|
1102
|
-
},
|
|
1123
|
+
}, Gt = () => It(C), Kt = (e) => [
|
|
1103
1124
|
"seed",
|
|
1104
1125
|
"models",
|
|
1105
1126
|
e
|
|
1106
|
-
],
|
|
1107
|
-
let t =
|
|
1108
|
-
queryKey:
|
|
1127
|
+
], qt = [], Jt = (e) => x.retain(e), Yt = (e) => e.getService().getSnapshot().status === "active", Xt = (e) => {
|
|
1128
|
+
let t = q(), r = X(), a = s(null), c = o(() => Kt(e), [e]), { data: l = qt, isLoading: u, error: d } = U({
|
|
1129
|
+
queryKey: c,
|
|
1109
1130
|
queryFn: async () => {
|
|
1110
|
-
let t = await x.all(e, { waitForReady: !1 }),
|
|
1111
|
-
return t.length === 0 &&
|
|
1131
|
+
let t = await x.all(e, { waitForReady: !1 }), n = r.getQueryData(c), i = a.current;
|
|
1132
|
+
return t.length === 0 && n && n.length > 0 && n.every(Yt) && (!i || i.size > 0) ? n : t;
|
|
1112
1133
|
},
|
|
1113
1134
|
enabled: t && !!e
|
|
1114
|
-
},
|
|
1115
|
-
|
|
1135
|
+
}, r), p = e ? l : qt, m = s(p);
|
|
1136
|
+
m.current = p, J(p, Jt, n(() => {
|
|
1137
|
+
r.invalidateQueries({ queryKey: c });
|
|
1138
|
+
}, [r, c])), i(() => {
|
|
1116
1139
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
1117
|
-
let t = new BroadcastChannel("seed-models-invalidate"),
|
|
1118
|
-
let { schemaName:
|
|
1119
|
-
(e ===
|
|
1140
|
+
let t = new BroadcastChannel("seed-models-invalidate"), n = (t) => {
|
|
1141
|
+
let { schemaName: n, schemaFileId: i } = t.data || {};
|
|
1142
|
+
(e === n || e === i) && (r.invalidateQueries({ queryKey: c }), r.refetchQueries({ queryKey: c }));
|
|
1120
1143
|
};
|
|
1121
|
-
return t.addEventListener("message",
|
|
1122
|
-
t.removeEventListener("message",
|
|
1144
|
+
return t.addEventListener("message", n), () => {
|
|
1145
|
+
t.removeEventListener("message", n), t.close();
|
|
1123
1146
|
};
|
|
1124
1147
|
}, [
|
|
1125
1148
|
e,
|
|
1126
|
-
|
|
1127
|
-
|
|
1149
|
+
r,
|
|
1150
|
+
c
|
|
1128
1151
|
]);
|
|
1129
|
-
let
|
|
1130
|
-
function
|
|
1152
|
+
let h = s(null), g = s(null);
|
|
1153
|
+
function _() {
|
|
1131
1154
|
let t = f.getAppDb();
|
|
1132
1155
|
return !t || !e ? null : t.select({
|
|
1133
1156
|
modelFileId: ce.schemaFileId,
|
|
1134
1157
|
modelName: ce.name
|
|
1135
|
-
}).from(
|
|
1158
|
+
}).from(L).innerJoin(se, G(L.id, se.schemaId)).innerJoin(ce, G(se.modelId, ce.id)).where(Ee(G(L.schemaFileId, e), G(L.name, e)));
|
|
1136
1159
|
}
|
|
1137
|
-
let
|
|
1160
|
+
let v = Y(o(() => {
|
|
1138
1161
|
if (!e || !t) return null;
|
|
1139
1162
|
let n = {
|
|
1140
1163
|
schemaId: e,
|
|
1141
1164
|
ready: t
|
|
1142
|
-
}, r =
|
|
1143
|
-
if (r && r.schemaId === n.schemaId && r.ready === n.ready &&
|
|
1144
|
-
let i =
|
|
1145
|
-
return i ? (
|
|
1165
|
+
}, r = h.current;
|
|
1166
|
+
if (r && r.schemaId === n.schemaId && r.ready === n.ready && g.current !== null) return g.current;
|
|
1167
|
+
let i = _();
|
|
1168
|
+
return i ? (h.current = n, g.current = i, i) : null;
|
|
1146
1169
|
}, [e, t]));
|
|
1147
1170
|
return i(() => {
|
|
1148
|
-
if (!t || !
|
|
1149
|
-
let
|
|
1150
|
-
for (let e of
|
|
1171
|
+
if (!t || !v || !e) return;
|
|
1172
|
+
let n = /* @__PURE__ */ new Set();
|
|
1173
|
+
for (let e of m.current) {
|
|
1151
1174
|
let t = e.id || e.modelFileId;
|
|
1152
|
-
t ?
|
|
1175
|
+
t ? n.add(t) : e.modelName && n.add(e.modelName);
|
|
1153
1176
|
}
|
|
1154
|
-
let
|
|
1155
|
-
for (let e of
|
|
1156
|
-
|
|
1177
|
+
let i = /* @__PURE__ */ new Set();
|
|
1178
|
+
for (let e of v) e.modelFileId ? i.add(e.modelFileId) : e.modelName && i.add(e.modelName);
|
|
1179
|
+
a.current = i, n.size === i.size && [...n].every((e) => i.has(e)) || r.invalidateQueries({ queryKey: c });
|
|
1157
1180
|
}, [
|
|
1158
1181
|
t,
|
|
1159
|
-
|
|
1182
|
+
v,
|
|
1160
1183
|
e,
|
|
1161
|
-
|
|
1162
|
-
|
|
1184
|
+
r,
|
|
1185
|
+
c
|
|
1163
1186
|
]), {
|
|
1164
|
-
models:
|
|
1165
|
-
isLoading:
|
|
1166
|
-
error:
|
|
1187
|
+
models: p,
|
|
1188
|
+
isLoading: u,
|
|
1189
|
+
error: d
|
|
1167
1190
|
};
|
|
1168
|
-
},
|
|
1169
|
-
let
|
|
1191
|
+
}, Zt = (e, t) => {
|
|
1192
|
+
let r = q(), [a, l] = c(void 0), [u, d] = c(!1), [f, p] = c(null), m = s(void 0), [, h] = c(0), [g, _] = c(0), v = t == null;
|
|
1170
1193
|
i(() => {
|
|
1171
|
-
!
|
|
1194
|
+
!r || !v || !e ? (l(void 0), d(!1), p(null)) : (async () => {
|
|
1172
1195
|
try {
|
|
1173
|
-
|
|
1174
|
-
let t = await x.createById(e
|
|
1175
|
-
|
|
1196
|
+
d(!0), p(null);
|
|
1197
|
+
let t = await x.createById(e);
|
|
1198
|
+
l(t || void 0), d(!1), p(null);
|
|
1176
1199
|
} catch (e) {
|
|
1177
|
-
console.error("[useModel] Error looking up model by ID:", e),
|
|
1200
|
+
console.error("[useModel] Error looking up model by ID:", e), l(void 0), d(!1), p(e);
|
|
1178
1201
|
}
|
|
1179
1202
|
})();
|
|
1180
1203
|
}, [
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
e
|
|
1204
|
+
r,
|
|
1205
|
+
v,
|
|
1206
|
+
e,
|
|
1207
|
+
g
|
|
1184
1208
|
]);
|
|
1185
|
-
let
|
|
1186
|
-
|
|
1209
|
+
let y = n(() => _((e) => e + 1), []);
|
|
1210
|
+
J(o(() => a ? [a] : qt, [a]), Jt, y);
|
|
1211
|
+
let { models: b, isLoading: S, error: C } = Xt(v ? null : e), w = o(() => {
|
|
1212
|
+
if (!v && t) return b.find((e) => (e.modelName ?? e.name) === t);
|
|
1187
1213
|
}, [
|
|
1188
|
-
|
|
1189
|
-
|
|
1214
|
+
v,
|
|
1215
|
+
b,
|
|
1190
1216
|
t
|
|
1191
|
-
]),
|
|
1217
|
+
]), T = v ? a : w;
|
|
1192
1218
|
return i(() => {
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1219
|
+
if (m.current?.unsubscribe(), m.current = void 0, T) return m.current = T.getService().subscribe(() => {
|
|
1220
|
+
h((e) => e + 1);
|
|
1195
1221
|
}), () => {
|
|
1196
|
-
|
|
1222
|
+
m.current?.unsubscribe(), m.current = void 0;
|
|
1197
1223
|
};
|
|
1198
|
-
}, [
|
|
1199
|
-
model:
|
|
1200
|
-
isLoading:
|
|
1201
|
-
error:
|
|
1224
|
+
}, [T]), v ? {
|
|
1225
|
+
model: a,
|
|
1226
|
+
isLoading: u,
|
|
1227
|
+
error: f
|
|
1202
1228
|
} : {
|
|
1203
|
-
model:
|
|
1204
|
-
isLoading:
|
|
1205
|
-
error:
|
|
1229
|
+
model: w,
|
|
1230
|
+
isLoading: S,
|
|
1231
|
+
error: C
|
|
1206
1232
|
};
|
|
1207
|
-
},
|
|
1208
|
-
let { run: e, isLoading: t, error: r, resetError: i } =
|
|
1233
|
+
}, Qt = () => {
|
|
1234
|
+
let { run: e, isLoading: t, error: r, resetError: i } = Pt("Failed to create model");
|
|
1209
1235
|
return {
|
|
1210
1236
|
create: n((t, n, r) => e(() => x.create(n, t, {
|
|
1211
1237
|
...r,
|
|
@@ -1215,7 +1241,7 @@ var It = ["seed", "schemas"], Lt = () => {
|
|
|
1215
1241
|
error: r,
|
|
1216
1242
|
resetError: i
|
|
1217
1243
|
};
|
|
1218
|
-
},
|
|
1244
|
+
}, $t = () => {
|
|
1219
1245
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1220
1246
|
return {
|
|
1221
1247
|
destroy: n(async (e) => {
|
|
@@ -1234,91 +1260,93 @@ var It = ["seed", "schemas"], Lt = () => {
|
|
|
1234
1260
|
error: r,
|
|
1235
1261
|
resetError: n(() => i(null), [])
|
|
1236
1262
|
};
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
//#region src/modelProperty.ts
|
|
1240
|
-
async function qt(e) {
|
|
1263
|
+
}, en = [], tn = (e) => S.retain(e);
|
|
1264
|
+
async function nn(e) {
|
|
1241
1265
|
let t = f.getAppDb();
|
|
1242
1266
|
if (t) {
|
|
1243
|
-
let n = await t.select({ name:
|
|
1267
|
+
let n = await t.select({ name: L.name }).from(L).where(Ee(G(L.name, e), G(L.schemaFileId, e))).limit(1);
|
|
1244
1268
|
if (n[0]?.name) return n[0].name;
|
|
1245
1269
|
}
|
|
1246
1270
|
return re(e) ?? e;
|
|
1247
1271
|
}
|
|
1248
|
-
var
|
|
1249
|
-
let { model:
|
|
1272
|
+
var rn = (e, t) => {
|
|
1273
|
+
let { model: r } = Zt(e, t), a = q(), c = X(), l = sn(r), u = r?.id, d = o(() => [
|
|
1250
1274
|
"seed",
|
|
1251
1275
|
"modelProperties",
|
|
1252
|
-
|
|
1253
|
-
], [
|
|
1254
|
-
queryKey:
|
|
1255
|
-
queryFn: () => S.all(
|
|
1256
|
-
enabled:
|
|
1257
|
-
},
|
|
1276
|
+
u ?? ""
|
|
1277
|
+
], [u]), { data: p = en, isLoading: m, error: h } = U({
|
|
1278
|
+
queryKey: d,
|
|
1279
|
+
queryFn: () => S.all(u, { waitForReady: !0 }),
|
|
1280
|
+
enabled: a && !!u
|
|
1281
|
+
}, c);
|
|
1282
|
+
J(p, tn, n(() => {
|
|
1283
|
+
c.invalidateQueries({ queryKey: d });
|
|
1284
|
+
}, [c, d]));
|
|
1285
|
+
let g = a ? f.getAppDb() : null, _ = Y(o(() => !g || !l ? null : g.select({
|
|
1258
1286
|
id: I.id,
|
|
1259
1287
|
name: I.name,
|
|
1260
1288
|
dataType: I.dataType,
|
|
1261
1289
|
schemaFileId: I.schemaFileId
|
|
1262
|
-
}).from(I).where(
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
])),
|
|
1267
|
-
return
|
|
1268
|
-
if (!
|
|
1290
|
+
}).from(I).where(G(I.modelId, l)), [
|
|
1291
|
+
g,
|
|
1292
|
+
a,
|
|
1293
|
+
l
|
|
1294
|
+
])), v = s([]);
|
|
1295
|
+
return v.current = p, i(() => {
|
|
1296
|
+
if (!u || p.length > 0 || !c || !d) return;
|
|
1269
1297
|
let e = [
|
|
1270
1298
|
400,
|
|
1271
1299
|
1200,
|
|
1272
1300
|
2500
|
|
1273
1301
|
].map((e) => setTimeout(() => {
|
|
1274
|
-
|
|
1302
|
+
c.invalidateQueries({ queryKey: d });
|
|
1275
1303
|
}, e));
|
|
1276
1304
|
return () => e.forEach((e) => clearTimeout(e));
|
|
1277
1305
|
}, [
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1306
|
+
u,
|
|
1307
|
+
p.length,
|
|
1308
|
+
c,
|
|
1309
|
+
d
|
|
1282
1310
|
]), i(() => {
|
|
1283
|
-
if (!
|
|
1311
|
+
if (!a || !r?.id || !_ || !d) return;
|
|
1284
1312
|
let e = /* @__PURE__ */ new Set();
|
|
1285
|
-
for (let t of
|
|
1313
|
+
for (let t of v.current) {
|
|
1286
1314
|
let n = t._getSnapshotContext()?.id;
|
|
1287
1315
|
n ? e.add(n) : t.name && e.add(t.name);
|
|
1288
1316
|
}
|
|
1289
1317
|
let t = /* @__PURE__ */ new Set();
|
|
1290
|
-
for (let e of
|
|
1291
|
-
(e.size !== t.size || e.size !== 0 && ![...e].every((e) => t.has(e))) && (e.size > 0 || t.size > 0) &&
|
|
1318
|
+
for (let e of _) e.schemaFileId ? t.add(e.schemaFileId) : e.name && t.add(e.name);
|
|
1319
|
+
(e.size !== t.size || e.size !== 0 && ![...e].every((e) => t.has(e))) && (e.size > 0 || t.size > 0) && c.invalidateQueries({ queryKey: d });
|
|
1292
1320
|
}, [
|
|
1293
|
-
r,
|
|
1294
|
-
g,
|
|
1295
|
-
n?.id,
|
|
1296
1321
|
a,
|
|
1297
|
-
|
|
1322
|
+
_,
|
|
1323
|
+
r?.id,
|
|
1324
|
+
c,
|
|
1325
|
+
d
|
|
1298
1326
|
]), {
|
|
1299
|
-
modelProperties:
|
|
1300
|
-
isLoading:
|
|
1301
|
-
error:
|
|
1327
|
+
modelProperties: p,
|
|
1328
|
+
isLoading: m && p.length === 0,
|
|
1329
|
+
error: h
|
|
1302
1330
|
};
|
|
1303
|
-
},
|
|
1331
|
+
}, an = [
|
|
1304
1332
|
400,
|
|
1305
1333
|
1200,
|
|
1306
1334
|
2500
|
|
1307
|
-
],
|
|
1335
|
+
], on = (e) => {
|
|
1308
1336
|
if (e) try {
|
|
1309
1337
|
return e._getSnapshotContext()._dbId;
|
|
1310
1338
|
} catch {
|
|
1311
1339
|
return;
|
|
1312
1340
|
}
|
|
1313
|
-
},
|
|
1314
|
-
let [t, n] = c(() =>
|
|
1341
|
+
}, sn = (e) => {
|
|
1342
|
+
let [t, n] = c(() => on(e));
|
|
1315
1343
|
return i(() => {
|
|
1316
|
-
if (n(
|
|
1317
|
-
let t = e.getService().subscribe(() => n(
|
|
1344
|
+
if (n(on(e)), !e) return;
|
|
1345
|
+
let t = e.getService().subscribe(() => n(on(e)));
|
|
1318
1346
|
return () => t.unsubscribe();
|
|
1319
1347
|
}, [e]), t;
|
|
1320
|
-
},
|
|
1321
|
-
let n = await x.createById(e
|
|
1348
|
+
}, cn = async (e, t) => {
|
|
1349
|
+
let n = await x.createById(e);
|
|
1322
1350
|
if (!n) return;
|
|
1323
1351
|
let r = n.modelName ?? n.name;
|
|
1324
1352
|
if (r) return A(r, t, {
|
|
@@ -1326,13 +1354,13 @@ var Jt = (e, t) => {
|
|
|
1326
1354
|
schemaName: n.schemaName
|
|
1327
1355
|
});
|
|
1328
1356
|
};
|
|
1329
|
-
function
|
|
1357
|
+
function ln(...e) {
|
|
1330
1358
|
let [t, r, a] = e, l = Math.min(e.length, 3), d = o(() => l === 3 ? !!(t && r && a) : l === 2 ? !!(t && r) : !!t, [
|
|
1331
1359
|
l,
|
|
1332
1360
|
t,
|
|
1333
1361
|
r,
|
|
1334
1362
|
a
|
|
1335
|
-
]), [f, p] = c(void 0), [m, h] = c(d), [g, _] = c(null), v = s(void 0), y =
|
|
1363
|
+
]), [f, p] = c(void 0), [m, h] = c(d), [g, _] = c(null), v = s(void 0), y = q(), b = o(() => l === 3 ? {
|
|
1336
1364
|
type: "schemaId",
|
|
1337
1365
|
schemaId: t,
|
|
1338
1366
|
modelName: r,
|
|
@@ -1370,15 +1398,15 @@ function $t(...e) {
|
|
|
1370
1398
|
p(void 0), h(!1), _(null);
|
|
1371
1399
|
return;
|
|
1372
1400
|
}
|
|
1373
|
-
t = await
|
|
1374
|
-
let e = await x.createById(b.modelFileId
|
|
1401
|
+
t = await cn(b.modelFileId, b.propertyName);
|
|
1402
|
+
let e = await x.createById(b.modelFileId);
|
|
1375
1403
|
n = e?.modelName ?? e?.name;
|
|
1376
1404
|
} else {
|
|
1377
1405
|
if (!b.schemaId || !b.modelName || !b.propertyName) {
|
|
1378
1406
|
p(void 0), h(!1), _(null);
|
|
1379
1407
|
return;
|
|
1380
1408
|
}
|
|
1381
|
-
let e = await
|
|
1409
|
+
let e = await nn(b.schemaId);
|
|
1382
1410
|
t = await A(b.modelName, b.propertyName, { schemaName: e }), n = b.modelName;
|
|
1383
1411
|
}
|
|
1384
1412
|
if (t && n) {
|
|
@@ -1405,11 +1433,13 @@ function $t(...e) {
|
|
|
1405
1433
|
i(() => {
|
|
1406
1434
|
C ? w() : (p(void 0), h(!1), _(null));
|
|
1407
1435
|
}, [C, w]);
|
|
1408
|
-
let T =
|
|
1409
|
-
|
|
1436
|
+
let T = n(() => void w({ quiet: !0 }), [w]);
|
|
1437
|
+
J(o(() => f ? [f] : en, [f]), tn, T);
|
|
1438
|
+
let ee = s(!1);
|
|
1439
|
+
ee.current = m || !!f || !!g, i(() => {
|
|
1410
1440
|
if (!C || b.type === "propertyFileId") return;
|
|
1411
|
-
let e =
|
|
1412
|
-
|
|
1441
|
+
let e = an.map((e) => setTimeout(() => {
|
|
1442
|
+
ee.current || w({ quiet: !0 });
|
|
1413
1443
|
}, e));
|
|
1414
1444
|
return () => e.forEach((e) => clearTimeout(e));
|
|
1415
1445
|
}, [
|
|
@@ -1417,11 +1447,11 @@ function $t(...e) {
|
|
|
1417
1447
|
b.type,
|
|
1418
1448
|
w
|
|
1419
1449
|
]);
|
|
1420
|
-
let
|
|
1450
|
+
let E = b.type === "propertyFileId";
|
|
1421
1451
|
return i(() => {
|
|
1422
|
-
if (!f || !
|
|
1452
|
+
if (!f || !E) return;
|
|
1423
1453
|
v.current?.unsubscribe();
|
|
1424
|
-
let e =
|
|
1454
|
+
let e = he(w, 100), t = f.getService().subscribe(() => {
|
|
1425
1455
|
e();
|
|
1426
1456
|
});
|
|
1427
1457
|
return v.current = t, () => {
|
|
@@ -1430,19 +1460,19 @@ function $t(...e) {
|
|
|
1430
1460
|
}, [
|
|
1431
1461
|
f,
|
|
1432
1462
|
w,
|
|
1433
|
-
|
|
1463
|
+
E
|
|
1434
1464
|
]), {
|
|
1435
1465
|
modelProperty: f,
|
|
1436
1466
|
isLoading: m,
|
|
1437
1467
|
error: g
|
|
1438
1468
|
};
|
|
1439
1469
|
}
|
|
1440
|
-
var
|
|
1441
|
-
let { runAsync: e, isLoading: t, error: r, resetError: i } =
|
|
1470
|
+
var un = () => {
|
|
1471
|
+
let { runAsync: e, isLoading: t, error: r, resetError: i } = Pt("Failed to create model property");
|
|
1442
1472
|
return {
|
|
1443
1473
|
create: n((t, n, r) => e(async () => {
|
|
1444
1474
|
if (!n || !r.name || !r.dataType) throw Error("modelName, property name and dataType are required");
|
|
1445
|
-
let e = await
|
|
1475
|
+
let e = await nn(t);
|
|
1446
1476
|
return S.create({
|
|
1447
1477
|
...r,
|
|
1448
1478
|
modelName: n
|
|
@@ -1455,7 +1485,7 @@ var en = () => {
|
|
|
1455
1485
|
error: r,
|
|
1456
1486
|
resetError: i
|
|
1457
1487
|
};
|
|
1458
|
-
},
|
|
1488
|
+
}, dn = () => {
|
|
1459
1489
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1460
1490
|
return {
|
|
1461
1491
|
destroy: n(async (e) => {
|
|
@@ -1474,7 +1504,7 @@ var en = () => {
|
|
|
1474
1504
|
error: r,
|
|
1475
1505
|
resetError: n(() => i(null), [])
|
|
1476
1506
|
};
|
|
1477
|
-
},
|
|
1507
|
+
}, fn = () => {
|
|
1478
1508
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1479
1509
|
return {
|
|
1480
1510
|
deleteItem: n(async (e) => {
|
|
@@ -1493,18 +1523,18 @@ var en = () => {
|
|
|
1493
1523
|
error: r,
|
|
1494
1524
|
resetError: n(() => i(null), [])
|
|
1495
1525
|
};
|
|
1496
|
-
},
|
|
1497
|
-
function
|
|
1498
|
-
let e =
|
|
1499
|
-
queryKey:
|
|
1526
|
+
}, pn = ["seed", "imageFiles"];
|
|
1527
|
+
function mn() {
|
|
1528
|
+
let e = q(), t = X(), { data: n = [], isLoading: r, error: a, refetch: o } = U({
|
|
1529
|
+
queryKey: pn,
|
|
1500
1530
|
queryFn: () => p.listImageFiles(),
|
|
1501
1531
|
enabled: e
|
|
1502
1532
|
}, t);
|
|
1503
1533
|
return i(() => {
|
|
1504
1534
|
let e = (e) => {
|
|
1505
|
-
e.includes("/images/") && t.invalidateQueries({ queryKey:
|
|
1535
|
+
e.includes("/images/") && t.invalidateQueries({ queryKey: pn });
|
|
1506
1536
|
}, n = (e) => {
|
|
1507
|
-
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey:
|
|
1537
|
+
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey: pn });
|
|
1508
1538
|
};
|
|
1509
1539
|
return O.on("file-saved", e), O.on(g, n), () => {
|
|
1510
1540
|
O.off("file-saved", e), O.off(g, n);
|
|
@@ -1518,9 +1548,9 @@ function an() {
|
|
|
1518
1548
|
}
|
|
1519
1549
|
//#endregion
|
|
1520
1550
|
//#region src/useFiles.ts
|
|
1521
|
-
var
|
|
1522
|
-
function
|
|
1523
|
-
let t =
|
|
1551
|
+
var hn = ["seed", "files"];
|
|
1552
|
+
function gn(e = "files") {
|
|
1553
|
+
let t = q(), n = X(), r = o(() => [...hn, e], [e]), { data: a = [], isLoading: s, error: c, refetch: l } = U({
|
|
1524
1554
|
queryKey: r,
|
|
1525
1555
|
queryFn: () => p.listFiles(e),
|
|
1526
1556
|
enabled: t
|
|
@@ -1547,28 +1577,28 @@ function sn(e = "files") {
|
|
|
1547
1577
|
}
|
|
1548
1578
|
//#endregion
|
|
1549
1579
|
//#region src/useEasSyncProcesses.ts
|
|
1550
|
-
function
|
|
1551
|
-
return
|
|
1580
|
+
function _n() {
|
|
1581
|
+
return q() ? f.getAppDb() : null;
|
|
1552
1582
|
}
|
|
1553
|
-
function
|
|
1554
|
-
let e =
|
|
1555
|
-
return o(() => e ? e.select().from(E).orderBy(
|
|
1583
|
+
function vn() {
|
|
1584
|
+
let e = _n();
|
|
1585
|
+
return o(() => e ? e.select().from(E).orderBy(Se(E.startedAt)) : null, [e]);
|
|
1556
1586
|
}
|
|
1557
|
-
function
|
|
1558
|
-
let e =
|
|
1587
|
+
function yn() {
|
|
1588
|
+
let e = Y(vn());
|
|
1559
1589
|
return {
|
|
1560
1590
|
records: e,
|
|
1561
1591
|
nonActiveCount: o(() => e === void 0 ? void 0 : e.filter((e) => e.status !== "in_progress").length, [e])
|
|
1562
1592
|
};
|
|
1563
1593
|
}
|
|
1564
|
-
function
|
|
1565
|
-
return
|
|
1594
|
+
function bn() {
|
|
1595
|
+
return Y(vn());
|
|
1566
1596
|
}
|
|
1567
|
-
function
|
|
1568
|
-
return
|
|
1597
|
+
function xn() {
|
|
1598
|
+
return yn().nonActiveCount;
|
|
1569
1599
|
}
|
|
1570
|
-
function
|
|
1571
|
-
let t =
|
|
1600
|
+
function Sn(e) {
|
|
1601
|
+
let t = _n(), n = Y(o(() => e != null && t ? t.select().from(E).where(G(E.id, e)).limit(1) : null, [t, e])), r = e != null && (t == null || n === void 0);
|
|
1572
1602
|
return {
|
|
1573
1603
|
record: n && n.length > 0 ? n[0] : null,
|
|
1574
1604
|
isLoading: r
|
|
@@ -1576,13 +1606,13 @@ function pn(e) {
|
|
|
1576
1606
|
}
|
|
1577
1607
|
//#endregion
|
|
1578
1608
|
//#region src/SeedProvider.tsx
|
|
1579
|
-
var
|
|
1580
|
-
function
|
|
1581
|
-
return Promise.resolve(
|
|
1609
|
+
var Cn = null;
|
|
1610
|
+
function wn(e) {
|
|
1611
|
+
return Promise.resolve(Cn?.(e));
|
|
1582
1612
|
}
|
|
1583
|
-
function
|
|
1613
|
+
function Tn({ queryClient: e }) {
|
|
1584
1614
|
return i(() => {
|
|
1585
|
-
|
|
1615
|
+
Cn = (t) => e.invalidateQueries({ queryKey: [
|
|
1586
1616
|
"seed",
|
|
1587
1617
|
"itemProperties",
|
|
1588
1618
|
t
|
|
@@ -1594,11 +1624,11 @@ function gn({ queryClient: e }) {
|
|
|
1594
1624
|
});
|
|
1595
1625
|
};
|
|
1596
1626
|
return O.on(h, t), () => {
|
|
1597
|
-
O.off(h, t),
|
|
1627
|
+
O.off(h, t), Cn = null;
|
|
1598
1628
|
};
|
|
1599
1629
|
}, [e]), null;
|
|
1600
1630
|
}
|
|
1601
|
-
function
|
|
1631
|
+
function En({ config: e, addresses: t, onInitError: n }) {
|
|
1602
1632
|
let r = s(n);
|
|
1603
1633
|
r.current = n;
|
|
1604
1634
|
let a = s(t);
|
|
@@ -1614,8 +1644,8 @@ function _n({ config: e, addresses: t, onInitError: n }) {
|
|
|
1614
1644
|
});
|
|
1615
1645
|
}, [e, o]), null;
|
|
1616
1646
|
}
|
|
1617
|
-
function
|
|
1618
|
-
let s = o(() => i ??
|
|
1647
|
+
function Dn({ children: e, config: t, addresses: n, onInitError: r, queryClient: i, queryClientRef: a }) {
|
|
1648
|
+
let s = o(() => i ?? Ue(), [i]);
|
|
1619
1649
|
if (a && (a.current = s, typeof window < "u")) {
|
|
1620
1650
|
let e = window;
|
|
1621
1651
|
e.__TEST_SEED_QUERY_CLIENT__ = s;
|
|
@@ -1623,13 +1653,13 @@ function vn({ children: e, config: t, addresses: n, onInitError: r, queryClient:
|
|
|
1623
1653
|
window.parent && window.parent !== window && (window.parent.__TEST_SEED_QUERY_CLIENT__ = s);
|
|
1624
1654
|
} catch {}
|
|
1625
1655
|
}
|
|
1626
|
-
return /* @__PURE__ */
|
|
1656
|
+
return /* @__PURE__ */ B(H, {
|
|
1627
1657
|
client: s,
|
|
1628
|
-
children: /* @__PURE__ */
|
|
1658
|
+
children: /* @__PURE__ */ V(Fe, {
|
|
1629
1659
|
queryClient: s,
|
|
1630
1660
|
children: [
|
|
1631
|
-
/* @__PURE__ */
|
|
1632
|
-
t && /* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ B(Tn, { queryClient: s }),
|
|
1662
|
+
t && /* @__PURE__ */ B(En, {
|
|
1633
1663
|
config: t,
|
|
1634
1664
|
addresses: n,
|
|
1635
1665
|
onInitError: r
|
|
@@ -1641,8 +1671,8 @@ function vn({ children: e, config: t, addresses: n, onInitError: r, queryClient:
|
|
|
1641
1671
|
}
|
|
1642
1672
|
//#endregion
|
|
1643
1673
|
//#region src/SeedClientGate.tsx
|
|
1644
|
-
function
|
|
1645
|
-
return /* @__PURE__ */
|
|
1674
|
+
function On() {
|
|
1675
|
+
return /* @__PURE__ */ B("div", {
|
|
1646
1676
|
style: {
|
|
1647
1677
|
display: "flex",
|
|
1648
1678
|
alignItems: "center",
|
|
@@ -1653,21 +1683,21 @@ function yn() {
|
|
|
1653
1683
|
children: "Loading..."
|
|
1654
1684
|
});
|
|
1655
1685
|
}
|
|
1656
|
-
function
|
|
1686
|
+
function kn(e) {
|
|
1657
1687
|
try {
|
|
1658
1688
|
return JSON.stringify(e ?? null);
|
|
1659
1689
|
} catch {
|
|
1660
1690
|
return e;
|
|
1661
1691
|
}
|
|
1662
1692
|
}
|
|
1663
|
-
function
|
|
1664
|
-
let l =
|
|
1693
|
+
function An({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r, loadingClassName: a, onInitError: o, children: c }) {
|
|
1694
|
+
let l = q(), u = s(o);
|
|
1665
1695
|
u.current = o;
|
|
1666
1696
|
let d = s(e);
|
|
1667
1697
|
d.current = e;
|
|
1668
1698
|
let f = s(t);
|
|
1669
1699
|
f.current = t;
|
|
1670
|
-
let p =
|
|
1700
|
+
let p = kn(e), m = kn(t);
|
|
1671
1701
|
i(() => {
|
|
1672
1702
|
let e = d.current, t = f.current, n = t ? {
|
|
1673
1703
|
...e,
|
|
@@ -1680,7 +1710,7 @@ function xn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1680
1710
|
u.current ? u.current(e) : console.error("[SeedClientGate] client init failed", e);
|
|
1681
1711
|
});
|
|
1682
1712
|
}, [p, m]);
|
|
1683
|
-
let h = n ?? /* @__PURE__ */
|
|
1713
|
+
let h = n ?? /* @__PURE__ */ B(On, {}), g = r ? void 0 : {
|
|
1684
1714
|
position: "relative",
|
|
1685
1715
|
display: "flex",
|
|
1686
1716
|
height: "100vh",
|
|
@@ -1695,15 +1725,15 @@ function xn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1695
1725
|
justifyContent: "center"
|
|
1696
1726
|
}
|
|
1697
1727
|
};
|
|
1698
|
-
return /* @__PURE__ */
|
|
1728
|
+
return /* @__PURE__ */ V("div", {
|
|
1699
1729
|
className: r,
|
|
1700
1730
|
style: g,
|
|
1701
|
-
children: [/* @__PURE__ */
|
|
1731
|
+
children: [/* @__PURE__ */ B("div", {
|
|
1702
1732
|
className: a,
|
|
1703
1733
|
style: _,
|
|
1704
1734
|
"aria-hidden": l,
|
|
1705
1735
|
children: h
|
|
1706
|
-
}), /* @__PURE__ */
|
|
1736
|
+
}), /* @__PURE__ */ B("div", {
|
|
1707
1737
|
style: {
|
|
1708
1738
|
flex: 1,
|
|
1709
1739
|
display: l ? "flex" : "none",
|
|
@@ -1715,54 +1745,54 @@ function xn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1715
1745
|
}
|
|
1716
1746
|
//#endregion
|
|
1717
1747
|
//#region src/opfsPaths.ts
|
|
1718
|
-
function
|
|
1748
|
+
function jn(e) {
|
|
1719
1749
|
let t = e.split("/").filter(Boolean);
|
|
1720
1750
|
if (t.length === 0) throw Error(`Invalid OPFS path: "${e}"`);
|
|
1721
1751
|
return t;
|
|
1722
1752
|
}
|
|
1723
|
-
async function
|
|
1753
|
+
async function Mn(e, t) {
|
|
1724
1754
|
let n = t ?? await navigator.storage.getDirectory();
|
|
1725
1755
|
for (let t of e.split("/").filter(Boolean)) n = await n.getDirectoryHandle(t);
|
|
1726
1756
|
return n;
|
|
1727
1757
|
}
|
|
1728
|
-
async function
|
|
1729
|
-
let n =
|
|
1758
|
+
async function Nn(e, t) {
|
|
1759
|
+
let n = jn(e), r = n.pop();
|
|
1730
1760
|
return {
|
|
1731
|
-
dir: await
|
|
1761
|
+
dir: await Mn(n.join("/"), t),
|
|
1732
1762
|
name: r
|
|
1733
1763
|
};
|
|
1734
1764
|
}
|
|
1735
|
-
async function
|
|
1736
|
-
let { dir: n, name: r } = await
|
|
1765
|
+
async function Pn(e, t) {
|
|
1766
|
+
let { dir: n, name: r } = await Nn(e, t);
|
|
1737
1767
|
return n.getFileHandle(r);
|
|
1738
1768
|
}
|
|
1739
|
-
async function
|
|
1740
|
-
return (await
|
|
1769
|
+
async function Fn(e, t) {
|
|
1770
|
+
return (await Pn(e, t)).getFile();
|
|
1741
1771
|
}
|
|
1742
|
-
async function
|
|
1743
|
-
let { dir: n, name: r } = await
|
|
1772
|
+
async function In(e, t) {
|
|
1773
|
+
let { dir: n, name: r } = await Nn(e, t);
|
|
1744
1774
|
await n.removeEntry(r);
|
|
1745
1775
|
}
|
|
1746
|
-
async function
|
|
1776
|
+
async function Ln(e, t) {
|
|
1747
1777
|
let n = await e.getDirectoryHandle(t), r = [];
|
|
1748
1778
|
for await (let e of n.entries()) r.push(e);
|
|
1749
1779
|
let i = !0;
|
|
1750
|
-
for (let [e, t] of r) (t.kind === "file" || !await
|
|
1780
|
+
for (let [e, t] of r) (t.kind === "file" || !await Ln(n, e)) && (i = !1);
|
|
1751
1781
|
return i && await e.removeEntry(t), i;
|
|
1752
1782
|
}
|
|
1753
|
-
async function
|
|
1783
|
+
async function Rn(e, t) {
|
|
1754
1784
|
try {
|
|
1755
|
-
let { dir: n, name: r } = await
|
|
1756
|
-
return await
|
|
1785
|
+
let { dir: n, name: r } = await Nn(e, t);
|
|
1786
|
+
return await Ln(n, r);
|
|
1757
1787
|
} catch (e) {
|
|
1758
1788
|
if (e instanceof DOMException && e.name === "NotFoundError") return !0;
|
|
1759
1789
|
throw e;
|
|
1760
1790
|
}
|
|
1761
1791
|
}
|
|
1762
|
-
function
|
|
1792
|
+
function zn() {
|
|
1763
1793
|
return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
|
|
1764
1794
|
}
|
|
1765
|
-
var
|
|
1795
|
+
var Bn = [
|
|
1766
1796
|
{
|
|
1767
1797
|
type: "image/jpeg",
|
|
1768
1798
|
test: (e) => e[0] === 255 && e[1] === 216 && e[2] === 255
|
|
@@ -1773,43 +1803,43 @@ var jn = [
|
|
|
1773
1803
|
},
|
|
1774
1804
|
{
|
|
1775
1805
|
type: "image/gif",
|
|
1776
|
-
test: (e) =>
|
|
1806
|
+
test: (e) => Vn(e, 0, 4) === "GIF8"
|
|
1777
1807
|
},
|
|
1778
1808
|
{
|
|
1779
1809
|
type: "image/webp",
|
|
1780
|
-
test: (e) =>
|
|
1810
|
+
test: (e) => Vn(e, 0, 4) === "RIFF" && Vn(e, 8, 12) === "WEBP"
|
|
1781
1811
|
},
|
|
1782
1812
|
{
|
|
1783
1813
|
type: "image/avif",
|
|
1784
|
-
test: (e) =>
|
|
1814
|
+
test: (e) => Vn(e, 4, 8) === "ftyp" && ["avif", "avis"].includes(Vn(e, 8, 12))
|
|
1785
1815
|
},
|
|
1786
1816
|
{
|
|
1787
1817
|
type: "application/vnd.sqlite3",
|
|
1788
|
-
test: (e) =>
|
|
1818
|
+
test: (e) => Vn(e, 0, 15) === "SQLite format 3"
|
|
1789
1819
|
},
|
|
1790
1820
|
{
|
|
1791
1821
|
type: "application/pdf",
|
|
1792
|
-
test: (e) =>
|
|
1822
|
+
test: (e) => Vn(e, 0, 5) === "%PDF-"
|
|
1793
1823
|
}
|
|
1794
1824
|
];
|
|
1795
|
-
function
|
|
1825
|
+
function Vn(e, t, n) {
|
|
1796
1826
|
return String.fromCharCode(...e.subarray(t, n));
|
|
1797
1827
|
}
|
|
1798
|
-
function
|
|
1799
|
-
return
|
|
1828
|
+
function Hn(e) {
|
|
1829
|
+
return Bn.find((t) => t.test(e))?.type;
|
|
1800
1830
|
}
|
|
1801
|
-
async function
|
|
1802
|
-
if (e.size !== 0) return
|
|
1831
|
+
async function Un(e) {
|
|
1832
|
+
if (e.size !== 0) return Hn(new Uint8Array(await e.slice(0, 16).arrayBuffer()));
|
|
1803
1833
|
}
|
|
1804
1834
|
//#endregion
|
|
1805
1835
|
//#region src/useOPFSFiles.ts
|
|
1806
|
-
async function
|
|
1836
|
+
async function Wn(e, t = "") {
|
|
1807
1837
|
let n = [];
|
|
1808
1838
|
try {
|
|
1809
1839
|
for await (let [r, i] of e.entries()) {
|
|
1810
1840
|
let e = t ? `${t}/${r}` : r;
|
|
1811
1841
|
if (i.kind === "file") try {
|
|
1812
|
-
let t = await i.getFile(), a = t.type ? void 0 : await
|
|
1842
|
+
let t = await i.getFile(), a = t.type ? void 0 : await Un(t).catch(() => void 0);
|
|
1813
1843
|
n.push({
|
|
1814
1844
|
name: r,
|
|
1815
1845
|
path: e,
|
|
@@ -1822,7 +1852,7 @@ async function Fn(e, t = "") {
|
|
|
1822
1852
|
console.warn(`Failed to read file ${e}:`, t);
|
|
1823
1853
|
}
|
|
1824
1854
|
else if (i.kind === "directory") {
|
|
1825
|
-
let t = await
|
|
1855
|
+
let t = await Wn(i, e);
|
|
1826
1856
|
n.push(...t);
|
|
1827
1857
|
}
|
|
1828
1858
|
}
|
|
@@ -1831,11 +1861,11 @@ async function Fn(e, t = "") {
|
|
|
1831
1861
|
}
|
|
1832
1862
|
return n;
|
|
1833
1863
|
}
|
|
1834
|
-
function
|
|
1864
|
+
function Gn(e = {}) {
|
|
1835
1865
|
let { rootPath: t } = e, [r, a] = c([]), [o, s] = c(!0), [l, u] = c(!1), [d, f] = c(null), [p, m] = c(null), h = n(async () => {
|
|
1836
1866
|
s(!0), f(null), m(null);
|
|
1837
1867
|
try {
|
|
1838
|
-
let e = await
|
|
1868
|
+
let e = await Wn(await Mn(t ?? ""), t || "");
|
|
1839
1869
|
a(e.sort((e, t) => e.path.localeCompare(t.path)));
|
|
1840
1870
|
} catch (e) {
|
|
1841
1871
|
f("Failed to access OPFS: " + (e instanceof Error ? e.message : String(e))), m(e instanceof Error ? e.name : null), console.error("OPFS access error:", e);
|
|
@@ -1856,96 +1886,96 @@ function In(e = {}) {
|
|
|
1856
1886
|
}
|
|
1857
1887
|
//#endregion
|
|
1858
1888
|
//#region src/OPFSFilesManager/format.ts
|
|
1859
|
-
var
|
|
1889
|
+
var Kn = [
|
|
1860
1890
|
"B",
|
|
1861
1891
|
"KB",
|
|
1862
1892
|
"MB",
|
|
1863
1893
|
"GB",
|
|
1864
1894
|
"TB"
|
|
1865
1895
|
];
|
|
1866
|
-
function
|
|
1896
|
+
function Z(e) {
|
|
1867
1897
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
1868
|
-
let t = Math.min(
|
|
1869
|
-
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${
|
|
1898
|
+
let t = Math.min(Kn.length - 1, Math.floor(Math.log(e) / Math.log(1024))), n = e / 1024 ** t;
|
|
1899
|
+
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${Kn[t]}`;
|
|
1870
1900
|
}
|
|
1871
|
-
var
|
|
1872
|
-
function
|
|
1901
|
+
var qn = 6e4, Jn = 60 * qn, Yn = 24 * Jn;
|
|
1902
|
+
function Xn(e, t = Date.now()) {
|
|
1873
1903
|
let n = t - e;
|
|
1874
|
-
if (n <
|
|
1875
|
-
if (n <
|
|
1876
|
-
if (n <
|
|
1877
|
-
let r = Math.round(n /
|
|
1904
|
+
if (n < qn) return "just now";
|
|
1905
|
+
if (n < Jn) return `${Math.round(n / qn)} min ago`;
|
|
1906
|
+
if (n < Yn) return `${Math.round(n / Jn)} h ago`;
|
|
1907
|
+
let r = Math.round(n / Yn);
|
|
1878
1908
|
return r === 1 ? "yesterday" : r < 30 ? `${r} days ago` : new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" });
|
|
1879
1909
|
}
|
|
1880
|
-
function
|
|
1910
|
+
function Zn(e) {
|
|
1881
1911
|
return new Date(e).toLocaleString(void 0, {
|
|
1882
1912
|
dateStyle: "medium",
|
|
1883
1913
|
timeStyle: "short"
|
|
1884
1914
|
});
|
|
1885
1915
|
}
|
|
1886
|
-
function
|
|
1916
|
+
function Qn(e, t) {
|
|
1887
1917
|
if (e.length <= t) return e;
|
|
1888
1918
|
let n = Math.ceil((t - 1) / 2), r = Math.floor((t - 1) / 2);
|
|
1889
1919
|
return `${e.slice(0, n)}…${e.slice(e.length - r)}`;
|
|
1890
1920
|
}
|
|
1891
1921
|
//#endregion
|
|
1892
1922
|
//#region src/OPFSFilesManager/icons.tsx
|
|
1893
|
-
var
|
|
1894
|
-
check: /* @__PURE__ */
|
|
1895
|
-
chevronLeft: /* @__PURE__ */
|
|
1896
|
-
chevronRight: /* @__PURE__ */
|
|
1897
|
-
copy: /* @__PURE__ */
|
|
1923
|
+
var $n = {
|
|
1924
|
+
check: /* @__PURE__ */ B("path", { d: "M20 6 9 17l-5-5" }),
|
|
1925
|
+
chevronLeft: /* @__PURE__ */ B("path", { d: "m15 18-6-6 6-6" }),
|
|
1926
|
+
chevronRight: /* @__PURE__ */ B("path", { d: "m9 18 6-6-6-6" }),
|
|
1927
|
+
copy: /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("rect", {
|
|
1898
1928
|
width: "14",
|
|
1899
1929
|
height: "14",
|
|
1900
1930
|
x: "8",
|
|
1901
1931
|
y: "8",
|
|
1902
1932
|
rx: "2",
|
|
1903
1933
|
ry: "2"
|
|
1904
|
-
}), /* @__PURE__ */
|
|
1905
|
-
database: /* @__PURE__ */
|
|
1906
|
-
/* @__PURE__ */
|
|
1934
|
+
}), /* @__PURE__ */ B("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })] }),
|
|
1935
|
+
database: /* @__PURE__ */ V(z, { children: [
|
|
1936
|
+
/* @__PURE__ */ B("ellipse", {
|
|
1907
1937
|
cx: "12",
|
|
1908
1938
|
cy: "5",
|
|
1909
1939
|
rx: "9",
|
|
1910
1940
|
ry: "3"
|
|
1911
1941
|
}),
|
|
1912
|
-
/* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1942
|
+
/* @__PURE__ */ B("path", { d: "M3 5V19A9 3 0 0 0 21 19V5" }),
|
|
1943
|
+
/* @__PURE__ */ B("path", { d: "M3 12A9 3 0 0 0 21 12" })
|
|
1914
1944
|
] }),
|
|
1915
|
-
download: /* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
1917
|
-
/* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
1945
|
+
download: /* @__PURE__ */ V(z, { children: [
|
|
1946
|
+
/* @__PURE__ */ B("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1947
|
+
/* @__PURE__ */ B("polyline", { points: "7 10 12 15 17 10" }),
|
|
1948
|
+
/* @__PURE__ */ B("line", {
|
|
1919
1949
|
x1: "12",
|
|
1920
1950
|
x2: "12",
|
|
1921
1951
|
y1: "15",
|
|
1922
1952
|
y2: "3"
|
|
1923
1953
|
})
|
|
1924
1954
|
] }),
|
|
1925
|
-
file: /* @__PURE__ */
|
|
1926
|
-
fileCode: /* @__PURE__ */
|
|
1927
|
-
/* @__PURE__ */
|
|
1928
|
-
/* @__PURE__ */
|
|
1929
|
-
/* @__PURE__ */
|
|
1930
|
-
/* @__PURE__ */
|
|
1955
|
+
file: /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }), /* @__PURE__ */ B("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" })] }),
|
|
1956
|
+
fileCode: /* @__PURE__ */ V(z, { children: [
|
|
1957
|
+
/* @__PURE__ */ B("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
1958
|
+
/* @__PURE__ */ B("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
1959
|
+
/* @__PURE__ */ B("path", { d: "m10 13-2 2 2 2" }),
|
|
1960
|
+
/* @__PURE__ */ B("path", { d: "m14 17 2-2-2-2" })
|
|
1931
1961
|
] }),
|
|
1932
|
-
fileJson: /* @__PURE__ */
|
|
1933
|
-
/* @__PURE__ */
|
|
1934
|
-
/* @__PURE__ */
|
|
1935
|
-
/* @__PURE__ */
|
|
1936
|
-
/* @__PURE__ */
|
|
1962
|
+
fileJson: /* @__PURE__ */ V(z, { children: [
|
|
1963
|
+
/* @__PURE__ */ B("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
1964
|
+
/* @__PURE__ */ B("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
1965
|
+
/* @__PURE__ */ B("path", { d: "M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1" }),
|
|
1966
|
+
/* @__PURE__ */ B("path", { d: "M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1" })
|
|
1937
1967
|
] }),
|
|
1938
|
-
fileText: /* @__PURE__ */
|
|
1939
|
-
/* @__PURE__ */
|
|
1940
|
-
/* @__PURE__ */
|
|
1941
|
-
/* @__PURE__ */
|
|
1942
|
-
/* @__PURE__ */
|
|
1943
|
-
/* @__PURE__ */
|
|
1968
|
+
fileText: /* @__PURE__ */ V(z, { children: [
|
|
1969
|
+
/* @__PURE__ */ B("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
1970
|
+
/* @__PURE__ */ B("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
1971
|
+
/* @__PURE__ */ B("path", { d: "M10 9H8" }),
|
|
1972
|
+
/* @__PURE__ */ B("path", { d: "M16 13H8" }),
|
|
1973
|
+
/* @__PURE__ */ B("path", { d: "M16 17H8" })
|
|
1944
1974
|
] }),
|
|
1945
|
-
folder: /* @__PURE__ */
|
|
1946
|
-
folderOpen: /* @__PURE__ */
|
|
1947
|
-
image: /* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1975
|
+
folder: /* @__PURE__ */ B("path", { d: "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }),
|
|
1976
|
+
folderOpen: /* @__PURE__ */ B("path", { d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" }),
|
|
1977
|
+
image: /* @__PURE__ */ V(z, { children: [
|
|
1978
|
+
/* @__PURE__ */ B("rect", {
|
|
1949
1979
|
width: "18",
|
|
1950
1980
|
height: "18",
|
|
1951
1981
|
x: "3",
|
|
@@ -1953,64 +1983,64 @@ var Wn = {
|
|
|
1953
1983
|
rx: "2",
|
|
1954
1984
|
ry: "2"
|
|
1955
1985
|
}),
|
|
1956
|
-
/* @__PURE__ */
|
|
1986
|
+
/* @__PURE__ */ B("circle", {
|
|
1957
1987
|
cx: "9",
|
|
1958
1988
|
cy: "9",
|
|
1959
1989
|
r: "2"
|
|
1960
1990
|
}),
|
|
1961
|
-
/* @__PURE__ */
|
|
1991
|
+
/* @__PURE__ */ B("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
|
|
1962
1992
|
] }),
|
|
1963
|
-
imageOff: /* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1993
|
+
imageOff: /* @__PURE__ */ V(z, { children: [
|
|
1994
|
+
/* @__PURE__ */ B("line", {
|
|
1965
1995
|
x1: "2",
|
|
1966
1996
|
x2: "22",
|
|
1967
1997
|
y1: "2",
|
|
1968
1998
|
y2: "22"
|
|
1969
1999
|
}),
|
|
1970
|
-
/* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
2000
|
+
/* @__PURE__ */ B("path", { d: "M10.41 10.41a2 2 0 1 1-2.83-2.83" }),
|
|
2001
|
+
/* @__PURE__ */ B("line", {
|
|
1972
2002
|
x1: "13.5",
|
|
1973
2003
|
x2: "6",
|
|
1974
2004
|
y1: "13.5",
|
|
1975
2005
|
y2: "21"
|
|
1976
2006
|
}),
|
|
1977
|
-
/* @__PURE__ */
|
|
2007
|
+
/* @__PURE__ */ B("line", {
|
|
1978
2008
|
x1: "18",
|
|
1979
2009
|
x2: "21",
|
|
1980
2010
|
y1: "12",
|
|
1981
2011
|
y2: "15"
|
|
1982
2012
|
}),
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2013
|
+
/* @__PURE__ */ B("path", { d: "M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59" }),
|
|
2014
|
+
/* @__PURE__ */ B("path", { d: "M21 15V5a2 2 0 0 0-2-2H9" })
|
|
1985
2015
|
] }),
|
|
1986
|
-
layers: /* @__PURE__ */
|
|
1987
|
-
/* @__PURE__ */
|
|
1988
|
-
/* @__PURE__ */
|
|
1989
|
-
/* @__PURE__ */
|
|
2016
|
+
layers: /* @__PURE__ */ V(z, { children: [
|
|
2017
|
+
/* @__PURE__ */ B("path", { d: "m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z" }),
|
|
2018
|
+
/* @__PURE__ */ B("path", { d: "m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65" }),
|
|
2019
|
+
/* @__PURE__ */ B("path", { d: "m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65" })
|
|
1990
2020
|
] }),
|
|
1991
|
-
layoutGrid: /* @__PURE__ */
|
|
1992
|
-
/* @__PURE__ */
|
|
2021
|
+
layoutGrid: /* @__PURE__ */ V(z, { children: [
|
|
2022
|
+
/* @__PURE__ */ B("rect", {
|
|
1993
2023
|
width: "7",
|
|
1994
2024
|
height: "7",
|
|
1995
2025
|
x: "3",
|
|
1996
2026
|
y: "3",
|
|
1997
2027
|
rx: "1"
|
|
1998
2028
|
}),
|
|
1999
|
-
/* @__PURE__ */
|
|
2029
|
+
/* @__PURE__ */ B("rect", {
|
|
2000
2030
|
width: "7",
|
|
2001
2031
|
height: "7",
|
|
2002
2032
|
x: "14",
|
|
2003
2033
|
y: "3",
|
|
2004
2034
|
rx: "1"
|
|
2005
2035
|
}),
|
|
2006
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ B("rect", {
|
|
2007
2037
|
width: "7",
|
|
2008
2038
|
height: "7",
|
|
2009
2039
|
x: "14",
|
|
2010
2040
|
y: "14",
|
|
2011
2041
|
rx: "1"
|
|
2012
2042
|
}),
|
|
2013
|
-
/* @__PURE__ */
|
|
2043
|
+
/* @__PURE__ */ B("rect", {
|
|
2014
2044
|
width: "7",
|
|
2015
2045
|
height: "7",
|
|
2016
2046
|
x: "3",
|
|
@@ -2018,51 +2048,51 @@ var Wn = {
|
|
|
2018
2048
|
rx: "1"
|
|
2019
2049
|
})
|
|
2020
2050
|
] }),
|
|
2021
|
-
list: /* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
/* @__PURE__ */
|
|
2024
|
-
/* @__PURE__ */
|
|
2025
|
-
/* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2051
|
+
list: /* @__PURE__ */ V(z, { children: [
|
|
2052
|
+
/* @__PURE__ */ B("path", { d: "M3 12h.01" }),
|
|
2053
|
+
/* @__PURE__ */ B("path", { d: "M3 18h.01" }),
|
|
2054
|
+
/* @__PURE__ */ B("path", { d: "M3 6h.01" }),
|
|
2055
|
+
/* @__PURE__ */ B("path", { d: "M8 12h13" }),
|
|
2056
|
+
/* @__PURE__ */ B("path", { d: "M8 18h13" }),
|
|
2057
|
+
/* @__PURE__ */ B("path", { d: "M8 6h13" })
|
|
2028
2058
|
] }),
|
|
2029
|
-
refresh: /* @__PURE__ */
|
|
2030
|
-
/* @__PURE__ */
|
|
2031
|
-
/* @__PURE__ */
|
|
2032
|
-
/* @__PURE__ */
|
|
2033
|
-
/* @__PURE__ */
|
|
2059
|
+
refresh: /* @__PURE__ */ V(z, { children: [
|
|
2060
|
+
/* @__PURE__ */ B("path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }),
|
|
2061
|
+
/* @__PURE__ */ B("path", { d: "M21 3v5h-5" }),
|
|
2062
|
+
/* @__PURE__ */ B("path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }),
|
|
2063
|
+
/* @__PURE__ */ B("path", { d: "M8 16H3v5" })
|
|
2034
2064
|
] }),
|
|
2035
|
-
search: /* @__PURE__ */
|
|
2065
|
+
search: /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("circle", {
|
|
2036
2066
|
cx: "11",
|
|
2037
2067
|
cy: "11",
|
|
2038
2068
|
r: "8"
|
|
2039
|
-
}), /* @__PURE__ */
|
|
2040
|
-
trash: /* @__PURE__ */
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
/* @__PURE__ */
|
|
2043
|
-
/* @__PURE__ */
|
|
2044
|
-
/* @__PURE__ */
|
|
2069
|
+
}), /* @__PURE__ */ B("path", { d: "m21 21-4.3-4.3" })] }),
|
|
2070
|
+
trash: /* @__PURE__ */ V(z, { children: [
|
|
2071
|
+
/* @__PURE__ */ B("path", { d: "M3 6h18" }),
|
|
2072
|
+
/* @__PURE__ */ B("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
|
|
2073
|
+
/* @__PURE__ */ B("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" }),
|
|
2074
|
+
/* @__PURE__ */ B("line", {
|
|
2045
2075
|
x1: "10",
|
|
2046
2076
|
x2: "10",
|
|
2047
2077
|
y1: "11",
|
|
2048
2078
|
y2: "17"
|
|
2049
2079
|
}),
|
|
2050
|
-
/* @__PURE__ */
|
|
2080
|
+
/* @__PURE__ */ B("line", {
|
|
2051
2081
|
x1: "14",
|
|
2052
2082
|
x2: "14",
|
|
2053
2083
|
y1: "11",
|
|
2054
2084
|
y2: "17"
|
|
2055
2085
|
})
|
|
2056
2086
|
] }),
|
|
2057
|
-
triangleAlert: /* @__PURE__ */
|
|
2058
|
-
/* @__PURE__ */
|
|
2059
|
-
/* @__PURE__ */
|
|
2060
|
-
/* @__PURE__ */
|
|
2087
|
+
triangleAlert: /* @__PURE__ */ V(z, { children: [
|
|
2088
|
+
/* @__PURE__ */ B("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
2089
|
+
/* @__PURE__ */ B("path", { d: "M12 9v4" }),
|
|
2090
|
+
/* @__PURE__ */ B("path", { d: "M12 17h.01" })
|
|
2061
2091
|
] }),
|
|
2062
|
-
x: /* @__PURE__ */
|
|
2092
|
+
x: /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("path", { d: "M18 6 6 18" }), /* @__PURE__ */ B("path", { d: "m6 6 12 12" })] })
|
|
2063
2093
|
};
|
|
2064
|
-
function
|
|
2065
|
-
return /* @__PURE__ */
|
|
2094
|
+
function Q({ name: e, size: t = 16, strokeWidth: n = 2, className: r }) {
|
|
2095
|
+
return /* @__PURE__ */ B("svg", {
|
|
2066
2096
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2067
2097
|
width: t,
|
|
2068
2098
|
height: t,
|
|
@@ -2075,20 +2105,20 @@ function $({ name: e, size: t = 16, strokeWidth: n = 2, className: r }) {
|
|
|
2075
2105
|
"aria-hidden": "true",
|
|
2076
2106
|
focusable: "false",
|
|
2077
2107
|
className: r,
|
|
2078
|
-
children:
|
|
2108
|
+
children: $n[e]
|
|
2079
2109
|
});
|
|
2080
2110
|
}
|
|
2081
2111
|
//#endregion
|
|
2082
2112
|
//#region src/OPFSFilesManager/DeleteDialog.tsx
|
|
2083
|
-
var
|
|
2084
|
-
function
|
|
2113
|
+
var er = 6;
|
|
2114
|
+
function tr({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
2085
2115
|
let a = s(null);
|
|
2086
2116
|
return i(() => {
|
|
2087
2117
|
let e = a.current;
|
|
2088
2118
|
return e && !e.open && (e.showModal(), e.querySelector("[data-initial-focus]")?.focus()), () => {
|
|
2089
2119
|
e?.open && e.close();
|
|
2090
2120
|
};
|
|
2091
|
-
}, []), /* @__PURE__ */
|
|
2121
|
+
}, []), /* @__PURE__ */ B("dialog", {
|
|
2092
2122
|
ref: a,
|
|
2093
2123
|
className: ["seed-fm-dialog", e].filter(Boolean).join(" "),
|
|
2094
2124
|
"aria-labelledby": "seed-fm-delete-title",
|
|
@@ -2098,7 +2128,7 @@ function Kn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
|
2098
2128
|
onClick: (e) => {
|
|
2099
2129
|
e.target === e.currentTarget && t();
|
|
2100
2130
|
},
|
|
2101
|
-
children: /* @__PURE__ */
|
|
2131
|
+
children: /* @__PURE__ */ B("form", {
|
|
2102
2132
|
method: "dialog",
|
|
2103
2133
|
onSubmit: (e) => {
|
|
2104
2134
|
e.preventDefault(), n();
|
|
@@ -2107,32 +2137,32 @@ function Kn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
|
2107
2137
|
})
|
|
2108
2138
|
});
|
|
2109
2139
|
}
|
|
2110
|
-
function
|
|
2111
|
-
let [s, l] = c(!0), u = e.flatMap((e) => e.variants), d = u.reduce((e, t) => e + t.file.size, 0), f = e.length + (s ? u.length : 0), p = t ? `${t}/` : "", m = r(s), h = m.label ? `${m.label}?` : e.length === 1 ? `Delete ${
|
|
2112
|
-
return /* @__PURE__ */
|
|
2140
|
+
function nr({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel: i, onConfirm: a, className: o }) {
|
|
2141
|
+
let [s, l] = c(!0), u = e.flatMap((e) => e.variants), d = u.reduce((e, t) => e + t.file.size, 0), f = e.length + (s ? u.length : 0), p = t ? `${t}/` : "", m = r(s), h = m.label ? `${m.label}?` : e.length === 1 ? `Delete ${Qn(e[0].file.name, 32)}?` : `Delete ${e.length} files?`;
|
|
2142
|
+
return /* @__PURE__ */ V(tr, {
|
|
2113
2143
|
className: o,
|
|
2114
2144
|
onCancel: i,
|
|
2115
2145
|
onSubmit: () => a(s),
|
|
2116
2146
|
children: [
|
|
2117
|
-
/* @__PURE__ */
|
|
2147
|
+
/* @__PURE__ */ B("h3", {
|
|
2118
2148
|
id: "seed-fm-delete-title",
|
|
2119
2149
|
children: h
|
|
2120
2150
|
}),
|
|
2121
|
-
/* @__PURE__ */
|
|
2151
|
+
/* @__PURE__ */ V("p", { children: [
|
|
2122
2152
|
"This removes ",
|
|
2123
2153
|
e.length === 1 ? "it" : "them",
|
|
2124
2154
|
" from this browser’s private storage. Copies on Arweave or other devices aren’t affected. You can’t undo this."
|
|
2125
2155
|
] }),
|
|
2126
|
-
/* @__PURE__ */
|
|
2156
|
+
/* @__PURE__ */ V("ul", { children: [e.slice(0, er).map((e) => /* @__PURE__ */ V("li", { children: [/* @__PURE__ */ B("code", {
|
|
2127
2157
|
title: e.file.path,
|
|
2128
2158
|
children: e.file.path.startsWith(p) ? e.file.path.slice(p.length) : e.file.path
|
|
2129
|
-
}), /* @__PURE__ */
|
|
2159
|
+
}), /* @__PURE__ */ B("span", { children: Z(e.file.size) })] }, e.file.path)), e.length > er && /* @__PURE__ */ B("li", { children: /* @__PURE__ */ V("span", { children: [
|
|
2130
2160
|
"and ",
|
|
2131
|
-
e.length -
|
|
2161
|
+
e.length - er,
|
|
2132
2162
|
" more"
|
|
2133
2163
|
] }) })] }),
|
|
2134
|
-
u.length > 0 && /* @__PURE__ */
|
|
2135
|
-
/* @__PURE__ */
|
|
2164
|
+
u.length > 0 && /* @__PURE__ */ V("label", { children: [
|
|
2165
|
+
/* @__PURE__ */ B("input", {
|
|
2136
2166
|
type: "checkbox",
|
|
2137
2167
|
className: "seed-fm-checkbox",
|
|
2138
2168
|
checked: s,
|
|
@@ -2143,26 +2173,26 @@ function qn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
2143
2173
|
" resized ",
|
|
2144
2174
|
u.length === 1 ? "copy" : "copies",
|
|
2145
2175
|
" (",
|
|
2146
|
-
|
|
2176
|
+
Z(d),
|
|
2147
2177
|
")"
|
|
2148
2178
|
] }),
|
|
2149
|
-
n && /* @__PURE__ */
|
|
2179
|
+
n && /* @__PURE__ */ V("div", {
|
|
2150
2180
|
className: "seed-fm-warning",
|
|
2151
2181
|
role: "alert",
|
|
2152
|
-
children: [/* @__PURE__ */
|
|
2182
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2153
2183
|
name: "triangleAlert",
|
|
2154
2184
|
size: 16
|
|
2155
|
-
}), /* @__PURE__ */
|
|
2185
|
+
}), /* @__PURE__ */ B("span", { children: n })]
|
|
2156
2186
|
}),
|
|
2157
|
-
/* @__PURE__ */
|
|
2187
|
+
/* @__PURE__ */ V("div", {
|
|
2158
2188
|
className: "seed-fm-dialog-actions",
|
|
2159
|
-
children: [/* @__PURE__ */
|
|
2189
|
+
children: [/* @__PURE__ */ B("button", {
|
|
2160
2190
|
type: "button",
|
|
2161
2191
|
className: "seed-fm-btn",
|
|
2162
2192
|
onClick: i,
|
|
2163
2193
|
"data-initial-focus": !0,
|
|
2164
2194
|
children: "Cancel"
|
|
2165
|
-
}), /* @__PURE__ */
|
|
2195
|
+
}), /* @__PURE__ */ B("button", {
|
|
2166
2196
|
type: "submit",
|
|
2167
2197
|
className: `seed-fm-btn ${m.destructive ? "seed-fm-btn--danger" : "seed-fm-btn--primary"}`,
|
|
2168
2198
|
children: m.label ?? `Delete ${f} ${f === 1 ? "file" : "files"}`
|
|
@@ -2171,43 +2201,43 @@ function qn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
2171
2201
|
]
|
|
2172
2202
|
});
|
|
2173
2203
|
}
|
|
2174
|
-
function
|
|
2204
|
+
function rr({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy: a, onDownload: o, onCancel: s, onConfirm: l, className: u }) {
|
|
2175
2205
|
let [d, f] = c(!1), p = t.reduce((e, t) => e + t.size, 0), m = `${e.path}/`, h = `${t.length} ${t.length === 1 ? "file" : "files"}`, g = t.length - e.fileCount;
|
|
2176
|
-
return /* @__PURE__ */
|
|
2206
|
+
return /* @__PURE__ */ V(tr, {
|
|
2177
2207
|
className: u,
|
|
2178
2208
|
onCancel: s,
|
|
2179
2209
|
onSubmit: l,
|
|
2180
2210
|
children: [
|
|
2181
|
-
/* @__PURE__ */
|
|
2211
|
+
/* @__PURE__ */ B("h3", {
|
|
2182
2212
|
id: "seed-fm-delete-title",
|
|
2183
|
-
children: i.label ? `${i.label}?` : `Delete the “${
|
|
2213
|
+
children: i.label ? `${i.label}?` : `Delete the “${Qn(e.name, 32)}” folder?`
|
|
2184
2214
|
}),
|
|
2185
|
-
/* @__PURE__ */
|
|
2215
|
+
/* @__PURE__ */ V("p", { children: [
|
|
2186
2216
|
"This removes the folder and the ",
|
|
2187
2217
|
h,
|
|
2188
2218
|
" in it (",
|
|
2189
|
-
|
|
2219
|
+
Z(p),
|
|
2190
2220
|
g > 0 && `, including ${g} resized ${g === 1 ? "copy" : "copies"}`,
|
|
2191
2221
|
") from this browser’s private storage. Copies on Arweave or other devices aren’t affected."
|
|
2192
2222
|
] }),
|
|
2193
|
-
/* @__PURE__ */
|
|
2223
|
+
/* @__PURE__ */ V("div", {
|
|
2194
2224
|
className: "seed-fm-irreversible",
|
|
2195
|
-
children: [/* @__PURE__ */
|
|
2225
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2196
2226
|
name: "triangleAlert",
|
|
2197
2227
|
size: 16
|
|
2198
|
-
}), /* @__PURE__ */
|
|
2228
|
+
}), /* @__PURE__ */ V("span", { children: [/* @__PURE__ */ B("strong", { children: "This can’t be undone." }), " Once deleted, these files can’t be recovered from this browser."] })]
|
|
2199
2229
|
}),
|
|
2200
|
-
/* @__PURE__ */
|
|
2230
|
+
/* @__PURE__ */ V("ul", { children: [t.slice(0, er).map((e) => /* @__PURE__ */ V("li", { children: [/* @__PURE__ */ B("code", {
|
|
2201
2231
|
title: e.path,
|
|
2202
2232
|
children: e.path.slice(m.length)
|
|
2203
|
-
}), /* @__PURE__ */
|
|
2233
|
+
}), /* @__PURE__ */ B("span", { children: Z(e.size) })] }, e.path)), t.length > er && /* @__PURE__ */ B("li", { children: /* @__PURE__ */ V("span", { children: [
|
|
2204
2234
|
"and ",
|
|
2205
|
-
t.length -
|
|
2235
|
+
t.length - er,
|
|
2206
2236
|
" more"
|
|
2207
2237
|
] }) })] }),
|
|
2208
|
-
/* @__PURE__ */
|
|
2238
|
+
/* @__PURE__ */ V("div", {
|
|
2209
2239
|
className: "seed-fm-keepcopy",
|
|
2210
|
-
children: [/* @__PURE__ */
|
|
2240
|
+
children: [/* @__PURE__ */ B("span", { children: d ? "Saved a copy to your computer." : "Want a copy first? Save the folder to your computer." }), /* @__PURE__ */ V("button", {
|
|
2211
2241
|
type: "button",
|
|
2212
2242
|
className: "seed-fm-btn",
|
|
2213
2243
|
disabled: a,
|
|
@@ -2215,7 +2245,7 @@ function Jn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2215
2245
|
await o() && f(!0);
|
|
2216
2246
|
},
|
|
2217
2247
|
children: [
|
|
2218
|
-
/* @__PURE__ */
|
|
2248
|
+
/* @__PURE__ */ B(Q, {
|
|
2219
2249
|
name: d ? "check" : "download",
|
|
2220
2250
|
size: 15
|
|
2221
2251
|
}),
|
|
@@ -2224,7 +2254,7 @@ function Jn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2224
2254
|
]
|
|
2225
2255
|
})]
|
|
2226
2256
|
}),
|
|
2227
|
-
n > 0 && /* @__PURE__ */
|
|
2257
|
+
n > 0 && /* @__PURE__ */ V("p", { children: [
|
|
2228
2258
|
n,
|
|
2229
2259
|
" other ",
|
|
2230
2260
|
n === 1 ? "file" : "files",
|
|
@@ -2233,23 +2263,23 @@ function Jn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2233
2263
|
" ",
|
|
2234
2264
|
"hidden here and won’t be deleted, so the folder itself will stay."
|
|
2235
2265
|
] }),
|
|
2236
|
-
r && /* @__PURE__ */
|
|
2266
|
+
r && /* @__PURE__ */ V("div", {
|
|
2237
2267
|
className: "seed-fm-warning",
|
|
2238
2268
|
role: "alert",
|
|
2239
|
-
children: [/* @__PURE__ */
|
|
2269
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2240
2270
|
name: "triangleAlert",
|
|
2241
2271
|
size: 16
|
|
2242
|
-
}), /* @__PURE__ */
|
|
2272
|
+
}), /* @__PURE__ */ B("span", { children: r })]
|
|
2243
2273
|
}),
|
|
2244
|
-
/* @__PURE__ */
|
|
2274
|
+
/* @__PURE__ */ V("div", {
|
|
2245
2275
|
className: "seed-fm-dialog-actions",
|
|
2246
|
-
children: [/* @__PURE__ */
|
|
2276
|
+
children: [/* @__PURE__ */ B("button", {
|
|
2247
2277
|
type: "button",
|
|
2248
2278
|
className: "seed-fm-btn",
|
|
2249
2279
|
onClick: s,
|
|
2250
2280
|
"data-initial-focus": !0,
|
|
2251
2281
|
children: "Cancel"
|
|
2252
|
-
}), /* @__PURE__ */
|
|
2282
|
+
}), /* @__PURE__ */ B("button", {
|
|
2253
2283
|
type: "submit",
|
|
2254
2284
|
disabled: a,
|
|
2255
2285
|
className: `seed-fm-btn ${i.destructive ? "seed-fm-btn--danger" : "seed-fm-btn--primary"}`,
|
|
@@ -2261,42 +2291,42 @@ function Jn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2261
2291
|
}
|
|
2262
2292
|
//#endregion
|
|
2263
2293
|
//#region src/OPFSFilesManager/fileModel.ts
|
|
2264
|
-
function
|
|
2294
|
+
function ir(e) {
|
|
2265
2295
|
return e.detectedType ?? e.type;
|
|
2266
2296
|
}
|
|
2267
|
-
var
|
|
2268
|
-
function
|
|
2269
|
-
let t =
|
|
2270
|
-
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" ||
|
|
2297
|
+
var ar = /\.(db|sqlite|sqlite3)(-journal|-wal|-shm)?$/i;
|
|
2298
|
+
function $(e) {
|
|
2299
|
+
let t = ir(e);
|
|
2300
|
+
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" || ar.test(e.name) ? "database" : t === "application/json" || /\.json$/i.test(e.name) ? "json" : t === "text/html" || /\.html?$/i.test(e.name) ? "html" : t.startsWith("text/") ? "text" : "other";
|
|
2271
2301
|
}
|
|
2272
|
-
function
|
|
2302
|
+
function or(e) {
|
|
2273
2303
|
let t = /\.([a-z0-9-]{1,12})$/i.exec(e.name)?.[1];
|
|
2274
2304
|
if (t) return t.toLowerCase();
|
|
2275
|
-
let n =
|
|
2305
|
+
let n = ir(e);
|
|
2276
2306
|
return n === "application/octet-stream" ? "bin" : n.split("/")[1]?.replace(/^vnd\./, "") ?? "bin";
|
|
2277
2307
|
}
|
|
2278
|
-
var
|
|
2279
|
-
function
|
|
2280
|
-
let t =
|
|
2308
|
+
var sr = /^(.*\/)?images\/(\d+)\/([^/]+)\.webp$/, cr = /^(.*\/)?images\/([^/]+)$/, lr = (e) => e.replace(/\.[^/.]+$/, "");
|
|
2309
|
+
function ur(e) {
|
|
2310
|
+
let t = sr.exec(e);
|
|
2281
2311
|
return t ? {
|
|
2282
2312
|
key: `${t[1] ?? ""}images/${t[3]}`,
|
|
2283
2313
|
width: Number(t[2])
|
|
2284
2314
|
} : null;
|
|
2285
2315
|
}
|
|
2286
|
-
function
|
|
2287
|
-
let t =
|
|
2288
|
-
return t ? `${t[1] ?? ""}images/${
|
|
2316
|
+
function dr(e) {
|
|
2317
|
+
let t = cr.exec(e);
|
|
2318
|
+
return t ? `${t[1] ?? ""}images/${lr(t[2])}` : null;
|
|
2289
2319
|
}
|
|
2290
|
-
var
|
|
2320
|
+
var fr = (e) => ({
|
|
2291
2321
|
file: e,
|
|
2292
2322
|
variants: [],
|
|
2293
2323
|
totalSize: e.size
|
|
2294
2324
|
});
|
|
2295
|
-
function
|
|
2296
|
-
if (!t) return e.map(
|
|
2325
|
+
function pr(e, t) {
|
|
2326
|
+
if (!t) return e.map(fr);
|
|
2297
2327
|
let n = /* @__PURE__ */ new Map(), r = [], i = [];
|
|
2298
2328
|
for (let t of e) {
|
|
2299
|
-
let e =
|
|
2329
|
+
let e = ur(t.path);
|
|
2300
2330
|
if (e) {
|
|
2301
2331
|
i.push({
|
|
2302
2332
|
file: t,
|
|
@@ -2304,27 +2334,27 @@ function ar(e, t) {
|
|
|
2304
2334
|
});
|
|
2305
2335
|
continue;
|
|
2306
2336
|
}
|
|
2307
|
-
let a =
|
|
2337
|
+
let a = fr(t);
|
|
2308
2338
|
r.push(a);
|
|
2309
|
-
let o =
|
|
2310
|
-
o &&
|
|
2339
|
+
let o = dr(t.path);
|
|
2340
|
+
o && $(t) === "image" && n.set(o, a);
|
|
2311
2341
|
}
|
|
2312
2342
|
for (let e of i) {
|
|
2313
2343
|
let t = n.get(e.key);
|
|
2314
2344
|
t ? (t.variants.push({
|
|
2315
2345
|
file: e.file,
|
|
2316
2346
|
width: e.width
|
|
2317
|
-
}), t.totalSize += e.file.size) : r.push(
|
|
2347
|
+
}), t.totalSize += e.file.size) : r.push(fr(e.file));
|
|
2318
2348
|
}
|
|
2319
2349
|
for (let e of n.values()) e.variants.sort((e, t) => e.width - t.width);
|
|
2320
2350
|
return r;
|
|
2321
2351
|
}
|
|
2322
|
-
var
|
|
2323
|
-
function
|
|
2352
|
+
var mr = (e, t) => e ? `${e}/${t}` : t;
|
|
2353
|
+
function hr(e, t, n = {}) {
|
|
2324
2354
|
let r = t ? `${t}/` : "", i = e.filter((e) => e.file.path.startsWith(r)), a = n.query?.trim().toLowerCase();
|
|
2325
2355
|
if (a) return {
|
|
2326
2356
|
folders: [],
|
|
2327
|
-
entries:
|
|
2357
|
+
entries: gr(i.filter((e) => e.file.path.slice(r.length).toLowerCase().includes(a)), n.sort)
|
|
2328
2358
|
};
|
|
2329
2359
|
let o = /* @__PURE__ */ new Map(), s = [];
|
|
2330
2360
|
for (let e of i) {
|
|
@@ -2335,7 +2365,7 @@ function sr(e, t, n = {}) {
|
|
|
2335
2365
|
}
|
|
2336
2366
|
let a = n.slice(0, i), c = o.get(a) ?? {
|
|
2337
2367
|
name: a,
|
|
2338
|
-
path:
|
|
2368
|
+
path: mr(t, a),
|
|
2339
2369
|
fileCount: 0,
|
|
2340
2370
|
size: 0
|
|
2341
2371
|
};
|
|
@@ -2343,10 +2373,10 @@ function sr(e, t, n = {}) {
|
|
|
2343
2373
|
}
|
|
2344
2374
|
return {
|
|
2345
2375
|
folders: [...o.values()].sort((e, t) => e.name.localeCompare(t.name)),
|
|
2346
|
-
entries:
|
|
2376
|
+
entries: gr(s, n.sort)
|
|
2347
2377
|
};
|
|
2348
2378
|
}
|
|
2349
|
-
function
|
|
2379
|
+
function gr(e, t = "name") {
|
|
2350
2380
|
let n = {
|
|
2351
2381
|
name: (e, t) => e.file.name.localeCompare(t.file.name),
|
|
2352
2382
|
modified: (e, t) => t.file.lastModified - e.file.lastModified,
|
|
@@ -2354,7 +2384,7 @@ function cr(e, t = "name") {
|
|
|
2354
2384
|
};
|
|
2355
2385
|
return [...e].sort(n[t]);
|
|
2356
2386
|
}
|
|
2357
|
-
function
|
|
2387
|
+
function _r(e) {
|
|
2358
2388
|
let t = {
|
|
2359
2389
|
image: 0,
|
|
2360
2390
|
database: 0,
|
|
@@ -2363,34 +2393,34 @@ function lr(e) {
|
|
|
2363
2393
|
text: 0,
|
|
2364
2394
|
other: 0
|
|
2365
2395
|
};
|
|
2366
|
-
for (let n of e) t[
|
|
2396
|
+
for (let n of e) t[$(n)] += n.size;
|
|
2367
2397
|
return t;
|
|
2368
2398
|
}
|
|
2369
|
-
function
|
|
2399
|
+
function vr(e) {
|
|
2370
2400
|
return e.find((e) => /(^|\/)db\/seed\.db$/.test(e.path)) ? "This includes the Seed database. The app loses its local items and drafts, and anything not yet published is gone. Reload the app afterwards." : null;
|
|
2371
2401
|
}
|
|
2372
2402
|
//#endregion
|
|
2373
2403
|
//#region src/OPFSFilesManager/useThumbnail.ts
|
|
2374
|
-
var
|
|
2375
|
-
function
|
|
2404
|
+
var yr = 400, br = 262144, xr = 4, Sr = 3e4, Cr = 0, wr = [];
|
|
2405
|
+
function Tr(e) {
|
|
2376
2406
|
return new Promise((t, n) => {
|
|
2377
2407
|
let r = () => {
|
|
2378
|
-
|
|
2379
|
-
|
|
2408
|
+
Cr++, e().then(t, n).finally(() => {
|
|
2409
|
+
Cr--, wr.shift()?.();
|
|
2380
2410
|
});
|
|
2381
2411
|
};
|
|
2382
|
-
|
|
2412
|
+
Cr < xr ? r() : wr.push(r);
|
|
2383
2413
|
});
|
|
2384
2414
|
}
|
|
2385
|
-
var
|
|
2386
|
-
function
|
|
2387
|
-
let n =
|
|
2415
|
+
var Er = /* @__PURE__ */ new Map();
|
|
2416
|
+
function Dr(e, t) {
|
|
2417
|
+
let n = Er.get(e);
|
|
2388
2418
|
if (!n) {
|
|
2389
2419
|
let r = {
|
|
2390
2420
|
refs: 0,
|
|
2391
2421
|
promise: Promise.resolve("")
|
|
2392
2422
|
};
|
|
2393
|
-
r.promise =
|
|
2423
|
+
r.promise = Tr(t).then((e) => (r.url = URL.createObjectURL(e), r.url)), Er.set(e, r), n = r;
|
|
2394
2424
|
}
|
|
2395
2425
|
n.timer && (clearTimeout(n.timer), n.timer = void 0), n.refs++;
|
|
2396
2426
|
let r = n, i = !1;
|
|
@@ -2398,15 +2428,15 @@ function yr(e, t) {
|
|
|
2398
2428
|
promise: r.promise,
|
|
2399
2429
|
release: () => {
|
|
2400
2430
|
i || (i = !0, r.refs--, !(r.refs > 0) && (r.timer = setTimeout(() => {
|
|
2401
|
-
r.url && URL.revokeObjectURL(r.url),
|
|
2402
|
-
},
|
|
2431
|
+
r.url && URL.revokeObjectURL(r.url), Er.get(e) === r && Er.delete(e);
|
|
2432
|
+
}, Sr)));
|
|
2403
2433
|
}
|
|
2404
2434
|
};
|
|
2405
2435
|
}
|
|
2406
|
-
async function
|
|
2407
|
-
if (e.size <
|
|
2436
|
+
async function Or(e) {
|
|
2437
|
+
if (e.size < br || typeof createImageBitmap != "function") return e;
|
|
2408
2438
|
let t = await createImageBitmap(e, {
|
|
2409
|
-
resizeWidth:
|
|
2439
|
+
resizeWidth: yr,
|
|
2410
2440
|
resizeQuality: "medium"
|
|
2411
2441
|
});
|
|
2412
2442
|
try {
|
|
@@ -2423,22 +2453,22 @@ async function br(e) {
|
|
|
2423
2453
|
t.close();
|
|
2424
2454
|
}
|
|
2425
2455
|
}
|
|
2426
|
-
async function
|
|
2456
|
+
async function kr(e) {
|
|
2427
2457
|
let t = e.variants[0];
|
|
2428
|
-
return t ?
|
|
2458
|
+
return t ? Fn(t.file.path) : Or(await Fn(e.file.path));
|
|
2429
2459
|
}
|
|
2430
|
-
var
|
|
2431
|
-
function
|
|
2432
|
-
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (
|
|
2433
|
-
for (let t of e) t.isIntersecting && (
|
|
2434
|
-
}, { rootMargin: "300px" })),
|
|
2435
|
-
|
|
2460
|
+
var Ar = /* @__PURE__ */ new WeakMap(), jr = null;
|
|
2461
|
+
function Mr(e, t) {
|
|
2462
|
+
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (jr ?? (jr = new IntersectionObserver((e) => {
|
|
2463
|
+
for (let t of e) t.isIntersecting && (jr.unobserve(t.target), Ar.get(t.target)?.(), Ar.delete(t.target));
|
|
2464
|
+
}, { rootMargin: "300px" })), Ar.set(e, t), jr.observe(e), () => {
|
|
2465
|
+
Ar.delete(e), jr?.unobserve(e);
|
|
2436
2466
|
});
|
|
2437
2467
|
}
|
|
2438
|
-
function
|
|
2439
|
-
let t =
|
|
2468
|
+
function Nr(e) {
|
|
2469
|
+
let t = $(e.file) === "image", [r, a] = c(null), [o, s] = c(!1), [l, u] = c(null), [d, f] = c("idle"), p = n((e) => a(e), []);
|
|
2440
2470
|
i(() => {
|
|
2441
|
-
if (t && r && !o) return
|
|
2471
|
+
if (t && r && !o) return Mr(r, () => s(!0));
|
|
2442
2472
|
}, [
|
|
2443
2473
|
t,
|
|
2444
2474
|
r,
|
|
@@ -2449,7 +2479,7 @@ function Tr(e) {
|
|
|
2449
2479
|
if (!t || !o) return;
|
|
2450
2480
|
let n = !1;
|
|
2451
2481
|
f("loading");
|
|
2452
|
-
let r =
|
|
2482
|
+
let r = Dr(_, () => kr(e));
|
|
2453
2483
|
return r.promise.then((e) => {
|
|
2454
2484
|
n || (u(e), f("ready"));
|
|
2455
2485
|
}, () => {
|
|
@@ -2472,7 +2502,7 @@ function Tr(e) {
|
|
|
2472
2502
|
}
|
|
2473
2503
|
//#endregion
|
|
2474
2504
|
//#region src/OPFSFilesManager/FileThumbnail.tsx
|
|
2475
|
-
var
|
|
2505
|
+
var Pr = {
|
|
2476
2506
|
image: {
|
|
2477
2507
|
icon: "image",
|
|
2478
2508
|
label: "Images",
|
|
@@ -2503,53 +2533,53 @@ var Er = {
|
|
|
2503
2533
|
label: "Other",
|
|
2504
2534
|
color: "var(--seed-kind-other)"
|
|
2505
2535
|
}
|
|
2506
|
-
},
|
|
2507
|
-
function
|
|
2508
|
-
let r =
|
|
2536
|
+
}, Fr = (e) => ({ "--seed-kind": Pr[e].color }), Ir = (e) => /png|webp|gif|avif|svg/.test(ir(e.file));
|
|
2537
|
+
function Lr({ entry: e, size: t, children: n }) {
|
|
2538
|
+
let r = $(e.file), { ref: i, url: a, status: o, markError: s } = Nr(e), c = r === "image" && o === "error", l = r === "image" && a && !c, u = [
|
|
2509
2539
|
t === "tile" ? "seed-fm-thumb" : "seed-fm-mini",
|
|
2510
|
-
l &&
|
|
2540
|
+
l && Ir(e) ? "seed-fm-thumb--checker" : "",
|
|
2511
2541
|
r === "image" && o === "loading" ? "seed-fm-skeleton" : ""
|
|
2512
2542
|
].filter(Boolean).join(" "), d;
|
|
2513
|
-
return d = l ? /* @__PURE__ */
|
|
2543
|
+
return d = l ? /* @__PURE__ */ B("img", {
|
|
2514
2544
|
src: a,
|
|
2515
2545
|
alt: "",
|
|
2516
2546
|
decoding: "async",
|
|
2517
2547
|
draggable: !1,
|
|
2518
2548
|
onError: s
|
|
2519
|
-
}) : t === "mini" ? /* @__PURE__ */
|
|
2520
|
-
name: c ? "imageOff" :
|
|
2549
|
+
}) : t === "mini" ? /* @__PURE__ */ B(Q, {
|
|
2550
|
+
name: c ? "imageOff" : Pr[r].icon,
|
|
2521
2551
|
size: 16
|
|
2522
|
-
}) : r === "image" && !c ? null : /* @__PURE__ */
|
|
2552
|
+
}) : r === "image" && !c ? null : /* @__PURE__ */ V("span", {
|
|
2523
2553
|
className: "seed-fm-kind",
|
|
2524
|
-
children: [/* @__PURE__ */
|
|
2525
|
-
name: c ? "imageOff" :
|
|
2554
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2555
|
+
name: c ? "imageOff" : Pr[r].icon,
|
|
2526
2556
|
size: 28,
|
|
2527
2557
|
strokeWidth: 1.6
|
|
2528
|
-
}), c ? /* @__PURE__ */
|
|
2558
|
+
}), c ? /* @__PURE__ */ B("span", {
|
|
2529
2559
|
className: "seed-fm-kind-error",
|
|
2530
2560
|
children: "Can’t decode image"
|
|
2531
|
-
}) : /* @__PURE__ */
|
|
2561
|
+
}) : /* @__PURE__ */ B("span", {
|
|
2532
2562
|
className: "seed-fm-ext",
|
|
2533
|
-
children:
|
|
2563
|
+
children: or(e.file)
|
|
2534
2564
|
})]
|
|
2535
|
-
}), /* @__PURE__ */
|
|
2565
|
+
}), /* @__PURE__ */ V("span", {
|
|
2536
2566
|
ref: i,
|
|
2537
2567
|
className: u,
|
|
2538
|
-
style:
|
|
2568
|
+
style: Fr(r),
|
|
2539
2569
|
children: [d, n]
|
|
2540
2570
|
});
|
|
2541
2571
|
}
|
|
2542
2572
|
//#endregion
|
|
2543
2573
|
//#region src/OPFSFilesManager/FileGrid.tsx
|
|
2544
|
-
function
|
|
2545
|
-
return /* @__PURE__ */
|
|
2574
|
+
function Rr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i, tileClassName: a }) {
|
|
2575
|
+
return /* @__PURE__ */ B("ul", {
|
|
2546
2576
|
className: ["seed-fm-grid", i].filter(Boolean).join(" "),
|
|
2547
2577
|
role: "listbox",
|
|
2548
2578
|
"aria-label": "Files",
|
|
2549
2579
|
"aria-multiselectable": "true",
|
|
2550
2580
|
children: e.map((e, i) => {
|
|
2551
2581
|
let { file: o, variants: s } = e, c = t.has(o.path);
|
|
2552
|
-
return /* @__PURE__ */
|
|
2582
|
+
return /* @__PURE__ */ V("li", {
|
|
2553
2583
|
role: "option",
|
|
2554
2584
|
tabIndex: 0,
|
|
2555
2585
|
"aria-selected": c,
|
|
@@ -2561,10 +2591,10 @@ function Ar({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2561
2591
|
onKeyDown: (t) => {
|
|
2562
2592
|
t.target === t.currentTarget && (t.key === "Enter" ? (t.preventDefault(), n(e, i, t)) : t.key === " " && (t.preventDefault(), r(e, i, t.shiftKey)));
|
|
2563
2593
|
},
|
|
2564
|
-
children: [/* @__PURE__ */
|
|
2594
|
+
children: [/* @__PURE__ */ V(Lr, {
|
|
2565
2595
|
entry: e,
|
|
2566
2596
|
size: "tile",
|
|
2567
|
-
children: [/* @__PURE__ */
|
|
2597
|
+
children: [/* @__PURE__ */ B("button", {
|
|
2568
2598
|
type: "button",
|
|
2569
2599
|
className: "seed-fm-check",
|
|
2570
2600
|
tabIndex: -1,
|
|
@@ -2572,16 +2602,16 @@ function Ar({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2572
2602
|
onClick: (t) => {
|
|
2573
2603
|
t.stopPropagation(), r(e, i, t.shiftKey);
|
|
2574
2604
|
},
|
|
2575
|
-
children: c && /* @__PURE__ */
|
|
2605
|
+
children: c && /* @__PURE__ */ B(Q, {
|
|
2576
2606
|
name: "check",
|
|
2577
2607
|
size: 14,
|
|
2578
2608
|
strokeWidth: 3
|
|
2579
2609
|
})
|
|
2580
|
-
}), s.length > 0 && /* @__PURE__ */
|
|
2610
|
+
}), s.length > 0 && /* @__PURE__ */ V("span", {
|
|
2581
2611
|
className: "seed-fm-badge",
|
|
2582
2612
|
title: "Resized copies are grouped with this image",
|
|
2583
2613
|
children: [
|
|
2584
|
-
/* @__PURE__ */
|
|
2614
|
+
/* @__PURE__ */ B(Q, {
|
|
2585
2615
|
name: "layers",
|
|
2586
2616
|
size: 11,
|
|
2587
2617
|
strokeWidth: 2.2
|
|
@@ -2591,21 +2621,21 @@ function Ar({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2591
2621
|
s.length === 1 ? "size" : "sizes"
|
|
2592
2622
|
]
|
|
2593
2623
|
})]
|
|
2594
|
-
}), /* @__PURE__ */
|
|
2624
|
+
}), /* @__PURE__ */ V("span", {
|
|
2595
2625
|
className: "seed-fm-tile-meta",
|
|
2596
|
-
children: [/* @__PURE__ */
|
|
2626
|
+
children: [/* @__PURE__ */ B("span", {
|
|
2597
2627
|
className: "seed-fm-tile-name",
|
|
2598
|
-
children:
|
|
2599
|
-
}), /* @__PURE__ */
|
|
2628
|
+
children: Qn(o.name, 24)
|
|
2629
|
+
}), /* @__PURE__ */ V("span", {
|
|
2600
2630
|
className: "seed-fm-tile-sub",
|
|
2601
2631
|
children: [
|
|
2602
|
-
|
|
2632
|
+
Z(o.size),
|
|
2603
2633
|
" ·",
|
|
2604
2634
|
" ",
|
|
2605
|
-
/* @__PURE__ */
|
|
2635
|
+
/* @__PURE__ */ B("time", {
|
|
2606
2636
|
dateTime: new Date(o.lastModified).toISOString(),
|
|
2607
|
-
title:
|
|
2608
|
-
children:
|
|
2637
|
+
title: Zn(o.lastModified),
|
|
2638
|
+
children: Xn(o.lastModified)
|
|
2609
2639
|
})
|
|
2610
2640
|
]
|
|
2611
2641
|
})]
|
|
@@ -2616,20 +2646,20 @@ function Ar({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2616
2646
|
}
|
|
2617
2647
|
//#endregion
|
|
2618
2648
|
//#region src/OPFSFilesManager/FileList.tsx
|
|
2619
|
-
function
|
|
2649
|
+
function zr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onToggleAll: o, onDownload: c, onDelete: l, deleteActionFor: u, className: d, rowClassName: f }) {
|
|
2620
2650
|
let p = s(null), m = e.filter((e) => t.has(e.file.path)).length, h = e.length > 0 && m === e.length;
|
|
2621
2651
|
i(() => {
|
|
2622
2652
|
p.current && (p.current.indeterminate = m > 0 && !h);
|
|
2623
2653
|
}, [m, h]);
|
|
2624
2654
|
let g = n ? `${n}/` : "";
|
|
2625
|
-
return /* @__PURE__ */
|
|
2655
|
+
return /* @__PURE__ */ B("div", {
|
|
2626
2656
|
className: "seed-fm-list-wrap",
|
|
2627
|
-
children: /* @__PURE__ */
|
|
2657
|
+
children: /* @__PURE__ */ V("table", {
|
|
2628
2658
|
className: ["seed-fm-list", d].filter(Boolean).join(" "),
|
|
2629
|
-
children: [/* @__PURE__ */
|
|
2630
|
-
/* @__PURE__ */
|
|
2659
|
+
children: [/* @__PURE__ */ B("thead", { children: /* @__PURE__ */ V("tr", { children: [
|
|
2660
|
+
/* @__PURE__ */ B("th", {
|
|
2631
2661
|
style: { width: 28 },
|
|
2632
|
-
children: /* @__PURE__ */
|
|
2662
|
+
children: /* @__PURE__ */ B("input", {
|
|
2633
2663
|
ref: p,
|
|
2634
2664
|
type: "checkbox",
|
|
2635
2665
|
className: "seed-fm-checkbox",
|
|
@@ -2638,34 +2668,34 @@ function jr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2638
2668
|
"aria-label": "Select all"
|
|
2639
2669
|
})
|
|
2640
2670
|
}),
|
|
2641
|
-
/* @__PURE__ */
|
|
2642
|
-
/* @__PURE__ */
|
|
2671
|
+
/* @__PURE__ */ B("th", { children: "Name" }),
|
|
2672
|
+
/* @__PURE__ */ B("th", {
|
|
2643
2673
|
className: "seed-fm-col-type",
|
|
2644
2674
|
children: "Type"
|
|
2645
2675
|
}),
|
|
2646
|
-
/* @__PURE__ */
|
|
2676
|
+
/* @__PURE__ */ B("th", {
|
|
2647
2677
|
className: "seed-fm-num seed-fm-col-size",
|
|
2648
2678
|
children: "Size"
|
|
2649
2679
|
}),
|
|
2650
|
-
/* @__PURE__ */
|
|
2680
|
+
/* @__PURE__ */ B("th", {
|
|
2651
2681
|
className: "seed-fm-col-modified",
|
|
2652
2682
|
children: "Modified"
|
|
2653
2683
|
}),
|
|
2654
|
-
/* @__PURE__ */
|
|
2684
|
+
/* @__PURE__ */ B("th", { children: /* @__PURE__ */ B("span", {
|
|
2655
2685
|
className: "seed-fm-visually-hidden",
|
|
2656
2686
|
children: "Actions"
|
|
2657
2687
|
}) })
|
|
2658
|
-
] }) }), /* @__PURE__ */
|
|
2688
|
+
] }) }), /* @__PURE__ */ B("tbody", { children: e.map((e, n) => {
|
|
2659
2689
|
let { file: i } = e, o = t.has(i.path), s = u(e);
|
|
2660
|
-
return /* @__PURE__ */
|
|
2690
|
+
return /* @__PURE__ */ V("tr", {
|
|
2661
2691
|
"data-path": i.path,
|
|
2662
2692
|
"aria-selected": o,
|
|
2663
2693
|
className: ["seed-fm-row", f].filter(Boolean).join(" "),
|
|
2664
2694
|
onClick: (t) => r(e, n, t),
|
|
2665
2695
|
children: [
|
|
2666
|
-
/* @__PURE__ */
|
|
2696
|
+
/* @__PURE__ */ B("td", {
|
|
2667
2697
|
onClick: (e) => e.stopPropagation(),
|
|
2668
|
-
children: /* @__PURE__ */
|
|
2698
|
+
children: /* @__PURE__ */ B("input", {
|
|
2669
2699
|
type: "checkbox",
|
|
2670
2700
|
className: "seed-fm-checkbox",
|
|
2671
2701
|
checked: o,
|
|
@@ -2674,61 +2704,61 @@ function jr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2674
2704
|
"aria-label": `Select ${i.name}`
|
|
2675
2705
|
})
|
|
2676
2706
|
}),
|
|
2677
|
-
/* @__PURE__ */
|
|
2707
|
+
/* @__PURE__ */ B("td", { children: /* @__PURE__ */ V("span", {
|
|
2678
2708
|
className: "seed-fm-namecell",
|
|
2679
|
-
children: [/* @__PURE__ */
|
|
2709
|
+
children: [/* @__PURE__ */ B(Lr, {
|
|
2680
2710
|
entry: e,
|
|
2681
2711
|
size: "mini"
|
|
2682
|
-
}), /* @__PURE__ */
|
|
2712
|
+
}), /* @__PURE__ */ V("span", { children: [/* @__PURE__ */ B("button", {
|
|
2683
2713
|
type: "button",
|
|
2684
2714
|
className: "seed-fm-row-name seed-fm-row-open",
|
|
2685
2715
|
onClick: (t) => {
|
|
2686
2716
|
t.stopPropagation(), r(e, n, t);
|
|
2687
2717
|
},
|
|
2688
2718
|
children: i.name
|
|
2689
|
-
}), i.path.slice(g.length) !== i.name && /* @__PURE__ */
|
|
2719
|
+
}), i.path.slice(g.length) !== i.name && /* @__PURE__ */ B("span", {
|
|
2690
2720
|
className: "seed-fm-row-path",
|
|
2691
2721
|
children: i.path.slice(g.length)
|
|
2692
2722
|
})] })]
|
|
2693
2723
|
}) }),
|
|
2694
|
-
/* @__PURE__ */
|
|
2724
|
+
/* @__PURE__ */ B("td", {
|
|
2695
2725
|
className: "seed-fm-col-type",
|
|
2696
|
-
children: /* @__PURE__ */
|
|
2726
|
+
children: /* @__PURE__ */ V("span", {
|
|
2697
2727
|
className: "seed-fm-type",
|
|
2698
|
-
style:
|
|
2699
|
-
children: [
|
|
2728
|
+
style: Fr($(i)),
|
|
2729
|
+
children: [ir(i), i.detectedType && /* @__PURE__ */ B("small", { children: "detected" })]
|
|
2700
2730
|
})
|
|
2701
2731
|
}),
|
|
2702
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ B("td", {
|
|
2703
2733
|
className: "seed-fm-num seed-fm-col-size",
|
|
2704
2734
|
title: `${i.size.toLocaleString()} bytes`,
|
|
2705
|
-
children:
|
|
2735
|
+
children: Z(e.totalSize)
|
|
2706
2736
|
}),
|
|
2707
|
-
/* @__PURE__ */
|
|
2737
|
+
/* @__PURE__ */ B("td", {
|
|
2708
2738
|
className: "seed-fm-when seed-fm-col-modified",
|
|
2709
|
-
title:
|
|
2710
|
-
children:
|
|
2739
|
+
title: Zn(i.lastModified),
|
|
2740
|
+
children: Xn(i.lastModified)
|
|
2711
2741
|
}),
|
|
2712
|
-
/* @__PURE__ */
|
|
2742
|
+
/* @__PURE__ */ V("td", {
|
|
2713
2743
|
className: "seed-fm-actions",
|
|
2714
2744
|
onClick: (e) => e.stopPropagation(),
|
|
2715
|
-
children: [/* @__PURE__ */
|
|
2745
|
+
children: [/* @__PURE__ */ B("button", {
|
|
2716
2746
|
type: "button",
|
|
2717
2747
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2718
2748
|
"aria-label": `Download ${i.name}`,
|
|
2719
2749
|
title: "Download",
|
|
2720
2750
|
onClick: () => c(e),
|
|
2721
|
-
children: /* @__PURE__ */
|
|
2751
|
+
children: /* @__PURE__ */ B(Q, {
|
|
2722
2752
|
name: "download",
|
|
2723
2753
|
size: 15
|
|
2724
2754
|
})
|
|
2725
|
-
}), /* @__PURE__ */
|
|
2755
|
+
}), /* @__PURE__ */ B("button", {
|
|
2726
2756
|
type: "button",
|
|
2727
2757
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2728
2758
|
"aria-label": s.label ? `${s.label}: ${i.name}` : `Delete ${i.name}`,
|
|
2729
2759
|
title: s.label ?? "Delete",
|
|
2730
2760
|
onClick: () => l(e),
|
|
2731
|
-
children: /* @__PURE__ */
|
|
2761
|
+
children: /* @__PURE__ */ B(Q, {
|
|
2732
2762
|
name: "trash",
|
|
2733
2763
|
size: 15
|
|
2734
2764
|
})
|
|
@@ -2742,22 +2772,22 @@ function jr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2742
2772
|
}
|
|
2743
2773
|
//#endregion
|
|
2744
2774
|
//#region src/OPFSFilesManager/PreviewPanel.tsx
|
|
2745
|
-
var
|
|
2746
|
-
function
|
|
2747
|
-
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o =
|
|
2775
|
+
var Br = 1048576, Vr = 32768;
|
|
2776
|
+
function Hr(e) {
|
|
2777
|
+
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o = $(e.file), s = e.file.size;
|
|
2748
2778
|
return i(() => {
|
|
2749
2779
|
let e = !1, t = null;
|
|
2750
2780
|
return n({ kind: "loading" }), (async () => {
|
|
2751
|
-
if (o === "image") return t = URL.createObjectURL(await
|
|
2781
|
+
if (o === "image") return t = URL.createObjectURL(await Fn(r)), {
|
|
2752
2782
|
kind: "image",
|
|
2753
2783
|
url: t
|
|
2754
2784
|
};
|
|
2755
2785
|
if (o === "json" || o === "html" || o === "text") {
|
|
2756
|
-
if (s >
|
|
2786
|
+
if (s > Br) return {
|
|
2757
2787
|
kind: "none",
|
|
2758
2788
|
message: "This file is too large to preview."
|
|
2759
2789
|
};
|
|
2760
|
-
let e = await
|
|
2790
|
+
let e = await Fn(r), t = e.size > Vr, n = await e.slice(0, Vr).text();
|
|
2761
2791
|
if (o === "json" && !t) try {
|
|
2762
2792
|
n = JSON.stringify(JSON.parse(n), null, 2);
|
|
2763
2793
|
} catch {}
|
|
@@ -2791,15 +2821,15 @@ function Pr(e) {
|
|
|
2791
2821
|
o
|
|
2792
2822
|
]), t;
|
|
2793
2823
|
}
|
|
2794
|
-
function
|
|
2795
|
-
let { file: f, variants: p } = e, m =
|
|
2824
|
+
function Ur({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onDelete: o, deleteAction: l, onCopyPath: u, className: d }) {
|
|
2825
|
+
let { file: f, variants: p } = e, m = $(f), h = Hr(e), [g, _] = c(null), [v, y] = c(!1), b = s(null);
|
|
2796
2826
|
i(() => {
|
|
2797
2827
|
_(null), y(!1);
|
|
2798
2828
|
}, [f.path]), i(() => {
|
|
2799
2829
|
b.current?.focus();
|
|
2800
2830
|
}, []);
|
|
2801
2831
|
let x = `seed-fm-panel-${encodeURIComponent(f.path)}`, S = p.reduce((e, t) => e + t.file.size, 0), C;
|
|
2802
|
-
if (h.kind === "image" && !v) C = /* @__PURE__ */
|
|
2832
|
+
if (h.kind === "image" && !v) C = /* @__PURE__ */ B("img", {
|
|
2803
2833
|
src: h.url,
|
|
2804
2834
|
alt: `Preview of ${f.name}`,
|
|
2805
2835
|
onLoad: (e) => _({
|
|
@@ -2808,144 +2838,144 @@ function Fr({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2808
2838
|
}),
|
|
2809
2839
|
onError: () => y(!0)
|
|
2810
2840
|
});
|
|
2811
|
-
else if (h.kind === "text") C = /* @__PURE__ */
|
|
2841
|
+
else if (h.kind === "text") C = /* @__PURE__ */ V("pre", { children: [h.text, h.truncated && "\n…"] });
|
|
2812
2842
|
else if (h.kind === "loading") C = null;
|
|
2813
2843
|
else {
|
|
2814
2844
|
let e = h.kind === "none" ? h.message : "The browser can’t decode this image. The file may be corrupt or not an image.";
|
|
2815
|
-
C = /* @__PURE__ */
|
|
2845
|
+
C = /* @__PURE__ */ V("span", {
|
|
2816
2846
|
className: "seed-fm-preview-note",
|
|
2817
|
-
children: [/* @__PURE__ */
|
|
2818
|
-
name: v ? "imageOff" :
|
|
2847
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2848
|
+
name: v ? "imageOff" : Pr[m].icon,
|
|
2819
2849
|
size: 32,
|
|
2820
2850
|
strokeWidth: 1.5
|
|
2821
2851
|
}), e]
|
|
2822
2852
|
});
|
|
2823
2853
|
}
|
|
2824
|
-
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(
|
|
2825
|
-
return /* @__PURE__ */
|
|
2854
|
+
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(ir(f));
|
|
2855
|
+
return /* @__PURE__ */ V("aside", {
|
|
2826
2856
|
className: ["seed-fm-panel", d].filter(Boolean).join(" "),
|
|
2827
2857
|
role: "dialog",
|
|
2828
2858
|
"aria-modal": "false",
|
|
2829
2859
|
"aria-labelledby": x,
|
|
2830
2860
|
children: [
|
|
2831
|
-
/* @__PURE__ */
|
|
2861
|
+
/* @__PURE__ */ V("div", {
|
|
2832
2862
|
className: "seed-fm-panel-head",
|
|
2833
2863
|
children: [
|
|
2834
|
-
/* @__PURE__ */
|
|
2864
|
+
/* @__PURE__ */ B("h3", {
|
|
2835
2865
|
id: x,
|
|
2836
2866
|
title: f.name,
|
|
2837
2867
|
children: f.name
|
|
2838
2868
|
}),
|
|
2839
|
-
/* @__PURE__ */
|
|
2869
|
+
/* @__PURE__ */ B("button", {
|
|
2840
2870
|
type: "button",
|
|
2841
2871
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2842
2872
|
"aria-label": "Previous file",
|
|
2843
2873
|
disabled: !n,
|
|
2844
2874
|
onClick: n ?? void 0,
|
|
2845
|
-
children: /* @__PURE__ */
|
|
2875
|
+
children: /* @__PURE__ */ B(Q, { name: "chevronLeft" })
|
|
2846
2876
|
}),
|
|
2847
|
-
/* @__PURE__ */
|
|
2877
|
+
/* @__PURE__ */ B("button", {
|
|
2848
2878
|
type: "button",
|
|
2849
2879
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2850
2880
|
"aria-label": "Next file",
|
|
2851
2881
|
disabled: !r,
|
|
2852
2882
|
onClick: r ?? void 0,
|
|
2853
|
-
children: /* @__PURE__ */
|
|
2883
|
+
children: /* @__PURE__ */ B(Q, { name: "chevronRight" })
|
|
2854
2884
|
}),
|
|
2855
|
-
/* @__PURE__ */
|
|
2885
|
+
/* @__PURE__ */ B("button", {
|
|
2856
2886
|
ref: b,
|
|
2857
2887
|
type: "button",
|
|
2858
2888
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2859
2889
|
"aria-label": "Close details",
|
|
2860
2890
|
onClick: t,
|
|
2861
|
-
children: /* @__PURE__ */
|
|
2891
|
+
children: /* @__PURE__ */ B(Q, { name: "x" })
|
|
2862
2892
|
})
|
|
2863
2893
|
]
|
|
2864
2894
|
}),
|
|
2865
|
-
/* @__PURE__ */
|
|
2895
|
+
/* @__PURE__ */ V("div", {
|
|
2866
2896
|
className: "seed-fm-panel-body",
|
|
2867
2897
|
children: [
|
|
2868
|
-
/* @__PURE__ */
|
|
2898
|
+
/* @__PURE__ */ B("div", {
|
|
2869
2899
|
className: [
|
|
2870
2900
|
"seed-fm-preview",
|
|
2871
2901
|
w ? "seed-fm-thumb--checker" : "",
|
|
2872
2902
|
h.kind === "loading" ? "seed-fm-skeleton" : ""
|
|
2873
2903
|
].filter(Boolean).join(" "),
|
|
2874
|
-
style:
|
|
2904
|
+
style: Fr(m),
|
|
2875
2905
|
children: C
|
|
2876
2906
|
}),
|
|
2877
|
-
/* @__PURE__ */
|
|
2907
|
+
/* @__PURE__ */ V("dl", {
|
|
2878
2908
|
className: "seed-fm-details",
|
|
2879
2909
|
children: [
|
|
2880
|
-
/* @__PURE__ */
|
|
2881
|
-
/* @__PURE__ */
|
|
2910
|
+
/* @__PURE__ */ B("dt", { children: "Path" }),
|
|
2911
|
+
/* @__PURE__ */ B("dd", { children: /* @__PURE__ */ V("span", {
|
|
2882
2912
|
className: "seed-fm-path",
|
|
2883
|
-
children: [/* @__PURE__ */
|
|
2913
|
+
children: [/* @__PURE__ */ B("code", { children: f.path }), /* @__PURE__ */ B("button", {
|
|
2884
2914
|
type: "button",
|
|
2885
2915
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon",
|
|
2886
2916
|
"aria-label": "Copy path",
|
|
2887
2917
|
title: "Copy path",
|
|
2888
2918
|
onClick: u,
|
|
2889
|
-
children: /* @__PURE__ */
|
|
2919
|
+
children: /* @__PURE__ */ B(Q, {
|
|
2890
2920
|
name: "copy",
|
|
2891
2921
|
size: 13
|
|
2892
2922
|
})
|
|
2893
2923
|
})]
|
|
2894
2924
|
}) }),
|
|
2895
|
-
/* @__PURE__ */
|
|
2896
|
-
/* @__PURE__ */
|
|
2897
|
-
|
|
2925
|
+
/* @__PURE__ */ B("dt", { children: "Size" }),
|
|
2926
|
+
/* @__PURE__ */ V("dd", { children: [
|
|
2927
|
+
Z(f.size),
|
|
2898
2928
|
" ",
|
|
2899
|
-
/* @__PURE__ */
|
|
2929
|
+
/* @__PURE__ */ V("small", { children: [f.size.toLocaleString(), " bytes"] })
|
|
2900
2930
|
] }),
|
|
2901
|
-
/* @__PURE__ */
|
|
2902
|
-
/* @__PURE__ */
|
|
2931
|
+
/* @__PURE__ */ B("dt", { children: "Type" }),
|
|
2932
|
+
/* @__PURE__ */ V("dd", { children: [ir(f), f.detectedType && /* @__PURE__ */ V("small", { children: [
|
|
2903
2933
|
" from file contents. File.type is “",
|
|
2904
2934
|
f.type,
|
|
2905
2935
|
"”"
|
|
2906
2936
|
] })] }),
|
|
2907
|
-
g && /* @__PURE__ */
|
|
2937
|
+
g && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("dt", { children: "Dimensions" }), /* @__PURE__ */ V("dd", { children: [
|
|
2908
2938
|
g.width.toLocaleString(),
|
|
2909
2939
|
" × ",
|
|
2910
2940
|
g.height.toLocaleString(),
|
|
2911
2941
|
" px"
|
|
2912
2942
|
] })] }),
|
|
2913
|
-
/* @__PURE__ */
|
|
2914
|
-
/* @__PURE__ */
|
|
2915
|
-
|
|
2943
|
+
/* @__PURE__ */ B("dt", { children: "Modified" }),
|
|
2944
|
+
/* @__PURE__ */ V("dd", { children: [
|
|
2945
|
+
Zn(f.lastModified),
|
|
2916
2946
|
" ",
|
|
2917
|
-
/* @__PURE__ */
|
|
2947
|
+
/* @__PURE__ */ B("small", { children: Xn(f.lastModified) })
|
|
2918
2948
|
] })
|
|
2919
2949
|
]
|
|
2920
2950
|
}),
|
|
2921
|
-
p.length > 0 && /* @__PURE__ */
|
|
2951
|
+
p.length > 0 && /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ V("div", {
|
|
2922
2952
|
className: "seed-fm-section-label",
|
|
2923
|
-
children: ["Resized copies · ",
|
|
2924
|
-
}), /* @__PURE__ */
|
|
2953
|
+
children: ["Resized copies · ", Z(S)]
|
|
2954
|
+
}), /* @__PURE__ */ B("ul", {
|
|
2925
2955
|
className: "seed-fm-variants",
|
|
2926
|
-
children: p.map((e) => /* @__PURE__ */
|
|
2956
|
+
children: p.map((e) => /* @__PURE__ */ V("li", {
|
|
2927
2957
|
title: e.file.path,
|
|
2928
|
-
children: [/* @__PURE__ */
|
|
2958
|
+
children: [/* @__PURE__ */ V("span", { children: [e.width, "w · webp"] }), /* @__PURE__ */ B("span", { children: Z(e.file.size) })]
|
|
2929
2959
|
}, e.file.path))
|
|
2930
2960
|
})] })
|
|
2931
2961
|
]
|
|
2932
2962
|
}),
|
|
2933
|
-
/* @__PURE__ */
|
|
2963
|
+
/* @__PURE__ */ V("div", {
|
|
2934
2964
|
className: "seed-fm-panel-foot",
|
|
2935
|
-
children: [/* @__PURE__ */
|
|
2965
|
+
children: [/* @__PURE__ */ V("button", {
|
|
2936
2966
|
type: "button",
|
|
2937
2967
|
className: "seed-fm-btn seed-fm-btn--primary",
|
|
2938
2968
|
onClick: a,
|
|
2939
|
-
children: [/* @__PURE__ */
|
|
2969
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
2940
2970
|
name: "download",
|
|
2941
2971
|
size: 15
|
|
2942
2972
|
}), " Download"]
|
|
2943
|
-
}), /* @__PURE__ */
|
|
2973
|
+
}), /* @__PURE__ */ V("button", {
|
|
2944
2974
|
type: "button",
|
|
2945
2975
|
className: `seed-fm-btn${l.destructive ? " seed-fm-btn--danger-text" : ""}`,
|
|
2946
2976
|
onClick: o,
|
|
2947
2977
|
children: [
|
|
2948
|
-
/* @__PURE__ */
|
|
2978
|
+
/* @__PURE__ */ B(Q, {
|
|
2949
2979
|
name: "trash",
|
|
2950
2980
|
size: 15
|
|
2951
2981
|
}),
|
|
@@ -2959,18 +2989,18 @@ function Fr({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2959
2989
|
}
|
|
2960
2990
|
//#endregion
|
|
2961
2991
|
//#region src/OPFSFilesManager/styles.ts
|
|
2962
|
-
var
|
|
2992
|
+
var Wr = "seed-opfs-files-manager-styles", Gr = "seed-opfs-files-manager", Kr = "\n --seed-bg: #fbfcfb;\n --seed-surface: #ffffff;\n --seed-sunken: #f0f3f1;\n --seed-hover: #e9eeeb;\n --seed-fg: #18211d;\n --seed-fg-muted: #5a6861;\n --seed-fg-faint: #8a978f;\n --seed-border: #dfe5e1;\n --seed-border-strong: #c5cfc9;\n --seed-accent: #2c6b59;\n --seed-accent-fg: #ffffff;\n --seed-accent-soft: #e0eee8;\n --seed-danger: #b4332a;\n --seed-danger-fg: #ffffff;\n --seed-danger-soft: #fbe7e4;\n --seed-danger-inverse: #ff9a8f;\n --seed-warn: #8a5208;\n --seed-warn-soft: #fdf1dc;\n --seed-kind-image: #2f7d68;\n --seed-kind-database: #6a4fb3;\n --seed-kind-json: #a2620e;\n --seed-kind-html: #b0413a;\n --seed-kind-text: #3f6f9a;\n --seed-kind-other: #66736c;\n --seed-checker-a: #eef1ef;\n --seed-checker-b: #ffffff;\n --seed-shadow: 0 10px 30px rgb(16 24 20 / 0.14), 0 2px 6px rgb(16 24 20 / 0.08);\n --seed-backdrop: rgb(8 12 10 / 0.42);\n", qr = "\n --seed-bg: #111816;\n --seed-surface: #171f1c;\n --seed-sunken: #1d2723;\n --seed-hover: #24302b;\n --seed-fg: #e4ebe7;\n --seed-fg-muted: #9daba3;\n --seed-fg-faint: #6f7d76;\n --seed-border: #29342f;\n --seed-border-strong: #3a4842;\n --seed-accent: #6cc0a3;\n --seed-accent-fg: #0c1a15;\n --seed-accent-soft: #1c3a30;\n --seed-danger: #f08277;\n --seed-danger-fg: #2a0d0a;\n --seed-danger-soft: #3b1c19;\n --seed-danger-inverse: #b4332a;\n --seed-warn: #e9b062;\n --seed-warn-soft: #382a14;\n --seed-kind-image: #6cc0a3;\n --seed-kind-database: #b29cf0;\n --seed-kind-json: #e3ad5c;\n --seed-kind-html: #ef8a80;\n --seed-kind-text: #8fb8de;\n --seed-kind-other: #9aa8a0;\n --seed-checker-a: #1d2723;\n --seed-checker-b: #24302b;\n --seed-shadow: 0 12px 34px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.4);\n --seed-backdrop: rgb(0 0 0 / 0.55);\n color-scheme: dark;\n", Jr = `@layer ${Gr} {\n${`
|
|
2963
2993
|
.seed-fm {
|
|
2964
|
-
${
|
|
2994
|
+
${Kr}
|
|
2965
2995
|
--seed-radius-sm: 6px;
|
|
2966
2996
|
--seed-radius-md: 8px;
|
|
2967
2997
|
--seed-radius-lg: 12px;
|
|
2968
2998
|
--seed-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2969
2999
|
color-scheme: light;
|
|
2970
3000
|
}
|
|
2971
|
-
.seed-fm[data-seed-theme="dark"] { ${
|
|
3001
|
+
.seed-fm[data-seed-theme="dark"] { ${qr} }
|
|
2972
3002
|
@media (prefers-color-scheme: dark) {
|
|
2973
|
-
.seed-fm[data-seed-theme="system"] { ${
|
|
3003
|
+
.seed-fm[data-seed-theme="system"] { ${qr} }
|
|
2974
3004
|
}
|
|
2975
3005
|
|
|
2976
3006
|
.seed-fm { position: relative; color: var(--seed-fg); background: var(--seed-bg); font-family: inherit; font-size: 14px; line-height: 1.45; }
|
|
@@ -3178,14 +3208,14 @@ var Ir = "seed-opfs-files-manager-styles", Lr = "seed-opfs-files-manager", Rr =
|
|
|
3178
3208
|
.seed-fm-thumb img { transition: none; }
|
|
3179
3209
|
}
|
|
3180
3210
|
`}\n}`;
|
|
3181
|
-
function
|
|
3211
|
+
function Yr() {
|
|
3182
3212
|
if (typeof document > "u" || document.getElementById("seed-opfs-files-manager-styles")) return;
|
|
3183
3213
|
let e = document.createElement("style");
|
|
3184
|
-
e.id =
|
|
3214
|
+
e.id = Wr, e.textContent = Jr, document.head.appendChild(e);
|
|
3185
3215
|
}
|
|
3186
3216
|
//#endregion
|
|
3187
3217
|
//#region src/OPFSFilesManager/useStorageEstimate.ts
|
|
3188
|
-
function
|
|
3218
|
+
function Xr(e) {
|
|
3189
3219
|
let [t, n] = c(null);
|
|
3190
3220
|
return i(() => {
|
|
3191
3221
|
if (typeof navigator > "u" || typeof navigator.storage?.estimate != "function") return;
|
|
@@ -3202,40 +3232,40 @@ function Hr(e) {
|
|
|
3202
3232
|
}
|
|
3203
3233
|
//#endregion
|
|
3204
3234
|
//#region src/OPFSFilesManager/zip.ts
|
|
3205
|
-
var
|
|
3206
|
-
function
|
|
3207
|
-
if (
|
|
3208
|
-
|
|
3235
|
+
var Zr = null;
|
|
3236
|
+
function Qr() {
|
|
3237
|
+
if (Zr) return Zr;
|
|
3238
|
+
Zr = /* @__PURE__ */ new Uint32Array(256);
|
|
3209
3239
|
for (let e = 0; e < 256; e++) {
|
|
3210
3240
|
let t = e;
|
|
3211
3241
|
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
3212
|
-
|
|
3242
|
+
Zr[e] = t >>> 0;
|
|
3213
3243
|
}
|
|
3214
|
-
return
|
|
3244
|
+
return Zr;
|
|
3215
3245
|
}
|
|
3216
|
-
function
|
|
3217
|
-
let t =
|
|
3246
|
+
function $r(e) {
|
|
3247
|
+
let t = Qr(), n = 4294967295;
|
|
3218
3248
|
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
3219
3249
|
return (n ^ 4294967295) >>> 0;
|
|
3220
3250
|
}
|
|
3221
|
-
function
|
|
3251
|
+
function ei(e) {
|
|
3222
3252
|
let t = new Date(e), n = Math.max(1980, t.getFullYear());
|
|
3223
3253
|
return {
|
|
3224
3254
|
time: t.getHours() << 11 | t.getMinutes() << 5 | Math.floor(t.getSeconds() / 2),
|
|
3225
3255
|
date: n - 1980 << 9 | t.getMonth() + 1 << 5 | t.getDate()
|
|
3226
3256
|
};
|
|
3227
3257
|
}
|
|
3228
|
-
var
|
|
3229
|
-
async function
|
|
3258
|
+
var ti = 2048, ni = 4294967295;
|
|
3259
|
+
async function ri(e) {
|
|
3230
3260
|
if (e.length > 65535) throw Error("Too many files for a ZIP archive (max 65,535).");
|
|
3231
3261
|
let t = new TextEncoder(), n = [], r = [], i = 0;
|
|
3232
3262
|
for (let a of e) {
|
|
3233
|
-
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s =
|
|
3234
|
-
if (i + o.length + 30 + e.length >
|
|
3263
|
+
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s = $r(o), { time: c, date: l } = ei(a.lastModified ?? Date.now());
|
|
3264
|
+
if (i + o.length + 30 + e.length > ni) throw Error("Selection is too large for a ZIP archive (max 4 GB).");
|
|
3235
3265
|
let u = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(30));
|
|
3236
|
-
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6,
|
|
3266
|
+
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6, ti, !0), u.setUint16(8, 0, !0), u.setUint16(10, c, !0), u.setUint16(12, l, !0), u.setUint32(14, s, !0), u.setUint32(18, o.length, !0), u.setUint32(22, o.length, !0), u.setUint16(26, e.length, !0), u.setUint16(28, 0, !0), n.push(u.buffer, e, o);
|
|
3237
3267
|
let d = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(46));
|
|
3238
|
-
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8,
|
|
3268
|
+
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, ti, !0), d.setUint16(10, 0, !0), d.setUint16(12, c, !0), d.setUint16(14, l, !0), d.setUint32(16, s, !0), d.setUint32(20, o.length, !0), d.setUint32(24, o.length, !0), d.setUint16(28, e.length, !0), d.setUint32(42, i, !0);
|
|
3239
3269
|
let f = new Uint8Array(46 + e.length);
|
|
3240
3270
|
f.set(new Uint8Array(d.buffer), 0), f.set(e, 46), r.push(f), i += 30 + e.length + o.length;
|
|
3241
3271
|
}
|
|
@@ -3248,12 +3278,12 @@ async function Yr(e) {
|
|
|
3248
3278
|
}
|
|
3249
3279
|
//#endregion
|
|
3250
3280
|
//#region src/OPFSFilesManager/OPFSFilesManager.tsx
|
|
3251
|
-
var
|
|
3252
|
-
function
|
|
3281
|
+
var ii = "Everything this app stores in the browser’s private file system (OPFS).", ai = 4e3, oi = (e) => e instanceof Error ? e.message : String(e), si = (e, t, n = `${t}s`) => `${e} ${e === 1 ? t : n}`, ci = (e) => (e ?? "").split("/").filter(Boolean).join("/");
|
|
3282
|
+
function li(e, t) {
|
|
3253
3283
|
let n = URL.createObjectURL(t), r = document.createElement("a");
|
|
3254
3284
|
r.href = n, r.download = e, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
3255
3285
|
}
|
|
3256
|
-
function
|
|
3286
|
+
function ui() {
|
|
3257
3287
|
let [e, t] = c([]), r = s(/* @__PURE__ */ new Set());
|
|
3258
3288
|
return i(() => {
|
|
3259
3289
|
let e = r.current;
|
|
@@ -3269,12 +3299,12 @@ function ni() {
|
|
|
3269
3299
|
}]);
|
|
3270
3300
|
let a = setTimeout(() => {
|
|
3271
3301
|
r.current.delete(a), t((e) => e.filter((e) => e.id !== i));
|
|
3272
|
-
},
|
|
3302
|
+
}, ai);
|
|
3273
3303
|
r.current.add(a);
|
|
3274
3304
|
}, [])
|
|
3275
3305
|
};
|
|
3276
3306
|
}
|
|
3277
|
-
var
|
|
3307
|
+
var di = [
|
|
3278
3308
|
"image",
|
|
3279
3309
|
"database",
|
|
3280
3310
|
"json",
|
|
@@ -3282,76 +3312,76 @@ var ri = [
|
|
|
3282
3312
|
"text",
|
|
3283
3313
|
"other"
|
|
3284
3314
|
];
|
|
3285
|
-
function
|
|
3286
|
-
let n =
|
|
3287
|
-
label:
|
|
3315
|
+
function fi({ files: e, estimate: t }) {
|
|
3316
|
+
let n = _r(e), r = e.reduce((e, t) => e + t.size, 0), i = t ? Math.max(0, t.usage - r) : 0, a = r + i, o = [...di.filter((e) => n[e] > 0).map((e) => ({
|
|
3317
|
+
label: Pr[e].label,
|
|
3288
3318
|
size: n[e],
|
|
3289
|
-
color:
|
|
3319
|
+
color: Pr[e].color
|
|
3290
3320
|
})), ...i > 0 ? [{
|
|
3291
3321
|
label: "Other site data",
|
|
3292
3322
|
size: i,
|
|
3293
3323
|
color: "var(--seed-border-strong)"
|
|
3294
3324
|
}] : []];
|
|
3295
|
-
return /* @__PURE__ */
|
|
3325
|
+
return /* @__PURE__ */ V("div", {
|
|
3296
3326
|
className: "seed-fm-usage",
|
|
3297
3327
|
title: "From navigator.storage.estimate(). Browsers round these numbers.",
|
|
3298
|
-
children: [/* @__PURE__ */
|
|
3328
|
+
children: [/* @__PURE__ */ V("div", {
|
|
3299
3329
|
className: "seed-fm-usage-row",
|
|
3300
|
-
children: [/* @__PURE__ */
|
|
3301
|
-
/* @__PURE__ */
|
|
3330
|
+
children: [/* @__PURE__ */ V("span", { children: [
|
|
3331
|
+
/* @__PURE__ */ B("strong", { children: Z(t ? t.usage : r) }),
|
|
3302
3332
|
" ",
|
|
3303
|
-
t ? "used by this site" : `in ${
|
|
3304
|
-
] }), t && /* @__PURE__ */
|
|
3305
|
-
}), a > 0 && /* @__PURE__ */
|
|
3333
|
+
t ? "used by this site" : `in ${si(e.length, "file")}`
|
|
3334
|
+
] }), t && /* @__PURE__ */ V("span", { children: [Z(t.quota), " available"] })]
|
|
3335
|
+
}), a > 0 && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("div", {
|
|
3306
3336
|
className: "seed-fm-meter",
|
|
3307
3337
|
role: "img",
|
|
3308
3338
|
"aria-label": "Storage used, by file type",
|
|
3309
|
-
children: o.map((e) => /* @__PURE__ */
|
|
3339
|
+
children: o.map((e) => /* @__PURE__ */ B("span", { style: {
|
|
3310
3340
|
width: `${e.size / a * 100}%`,
|
|
3311
3341
|
background: e.color
|
|
3312
3342
|
} }, e.label))
|
|
3313
|
-
}), /* @__PURE__ */
|
|
3343
|
+
}), /* @__PURE__ */ B("ul", {
|
|
3314
3344
|
className: "seed-fm-legend",
|
|
3315
|
-
children: o.map((e) => /* @__PURE__ */
|
|
3345
|
+
children: o.map((e) => /* @__PURE__ */ V("li", {
|
|
3316
3346
|
style: { "--seed-swatch": e.color },
|
|
3317
3347
|
children: [
|
|
3318
3348
|
e.label,
|
|
3319
3349
|
" ",
|
|
3320
|
-
|
|
3350
|
+
Z(e.size)
|
|
3321
3351
|
]
|
|
3322
3352
|
}, e.label))
|
|
3323
3353
|
})] })]
|
|
3324
3354
|
});
|
|
3325
3355
|
}
|
|
3326
|
-
function
|
|
3327
|
-
return /* @__PURE__ */
|
|
3356
|
+
function pi({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
3357
|
+
return /* @__PURE__ */ V("div", {
|
|
3328
3358
|
className: `seed-fm-state${r === "error" ? " seed-fm-state--error" : ""}`,
|
|
3329
3359
|
role: r === "error" ? "alert" : void 0,
|
|
3330
3360
|
children: [
|
|
3331
|
-
/* @__PURE__ */
|
|
3361
|
+
/* @__PURE__ */ B("span", {
|
|
3332
3362
|
className: "seed-fm-state-icon",
|
|
3333
|
-
children: /* @__PURE__ */
|
|
3363
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3334
3364
|
name: e,
|
|
3335
3365
|
size: 22
|
|
3336
3366
|
})
|
|
3337
3367
|
}),
|
|
3338
|
-
/* @__PURE__ */
|
|
3339
|
-
/* @__PURE__ */
|
|
3368
|
+
/* @__PURE__ */ B("h3", { children: t }),
|
|
3369
|
+
/* @__PURE__ */ B("p", { children: n }),
|
|
3340
3370
|
i
|
|
3341
3371
|
]
|
|
3342
3372
|
});
|
|
3343
3373
|
}
|
|
3344
|
-
function
|
|
3374
|
+
function mi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDownload: l, title: u = "Files", description: d = ii, headingLevel: f = 2, theme: p = "system", className: m, classNames: h = {}, defaultView: g, groupImageVariants: _ = !0, deleteWarning: v = vr, confirmDelete: y, deleteAction: b, onNotify: x }) {
|
|
3345
3375
|
a(() => {
|
|
3346
|
-
p !== "none" &&
|
|
3376
|
+
p !== "none" && Yr();
|
|
3347
3377
|
}, [p]);
|
|
3348
|
-
let S =
|
|
3378
|
+
let S = ci(e), C = S ? S.split("/").pop() : "OPFS", w = (e, t) => [t, h[e]].filter(Boolean).join(" "), { files: T, isLoading: ee, hasLoaded: E, error: D, errorName: O, refetch: te } = Gn({ rootPath: e }), k = o(() => t ? T.filter(t) : T, [T, t]), ne = Xr(T), [A, re] = c(_);
|
|
3349
3379
|
i(() => re(_), [_]);
|
|
3350
|
-
let ie = o(() =>
|
|
3380
|
+
let ie = o(() => pr(k, A), [k, A]), [j, ae] = c(S);
|
|
3351
3381
|
i(() => ae(S), [S]);
|
|
3352
|
-
let [M, oe] = c(""), [N, se] = c("name"), [ce, le] = c(g), [P, F] = c(() => /* @__PURE__ */ new Set()), ue = s(null), [de, I] = c(null), fe = s(null), [
|
|
3353
|
-
x ? x(e, t, n) :
|
|
3354
|
-
},
|
|
3382
|
+
let [M, oe] = c(""), [N, se] = c("name"), [ce, le] = c(g), [P, F] = c(() => /* @__PURE__ */ new Set()), ue = s(null), [de, I] = c(null), fe = s(null), [pe, L] = c(null), [R, me] = c(null), [he, ge] = c(!1), { toasts: _e, showToast: ve } = ui(), ye = (e, t, n) => {
|
|
3383
|
+
x ? x(e, t, n) : ve(e, t);
|
|
3384
|
+
}, be = o(() => hr(ie, j, {
|
|
3355
3385
|
query: M,
|
|
3356
3386
|
sort: N
|
|
3357
3387
|
}), [
|
|
@@ -3359,118 +3389,118 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3359
3389
|
j,
|
|
3360
3390
|
M,
|
|
3361
3391
|
N
|
|
3362
|
-
]),
|
|
3392
|
+
]), H = be.entries, U = H.length ? H.filter((e) => $(e.file) === "image").length / H.length : 0, xe = ce ?? (U >= .5 ? "grid" : "list"), W = o(() => new Map(ie.map((e) => [e.file.path, e])), [ie]), Se = o(() => [...P].map((e) => W.get(e)).filter((e) => !!e), [P, W]), G = de ? W.get(de) ?? null : null, Ce = G ? H.indexOf(G) : -1;
|
|
3363
3393
|
i(() => {
|
|
3364
3394
|
F((e) => {
|
|
3365
|
-
let t = new Set([...e].filter((e) =>
|
|
3395
|
+
let t = new Set([...e].filter((e) => W.has(e)));
|
|
3366
3396
|
return t.size === e.size ? e : t;
|
|
3367
3397
|
});
|
|
3368
|
-
}, [
|
|
3369
|
-
let
|
|
3398
|
+
}, [W]);
|
|
3399
|
+
let we = (e) => {
|
|
3370
3400
|
ae(e), oe(""), F(/* @__PURE__ */ new Set()), ue.current = null, I(null);
|
|
3371
|
-
},
|
|
3401
|
+
}, Te = (e, t, n) => {
|
|
3372
3402
|
let r = ue.current;
|
|
3373
3403
|
F((i) => {
|
|
3374
3404
|
let a = new Set(i);
|
|
3375
3405
|
if (n && r != null) {
|
|
3376
3406
|
let [e, n] = r < t ? [r, t] : [t, r];
|
|
3377
|
-
for (let t of
|
|
3407
|
+
for (let t of H.slice(e, n + 1)) a.add(t.file.path);
|
|
3378
3408
|
} else a.has(e.file.path) ? a.delete(e.file.path) : a.add(e.file.path);
|
|
3379
3409
|
return a;
|
|
3380
3410
|
}), (!n || r == null) && (ue.current = t);
|
|
3381
|
-
},
|
|
3411
|
+
}, Ee = (e) => {
|
|
3382
3412
|
de || (fe.current = document.activeElement), I(e);
|
|
3383
|
-
},
|
|
3413
|
+
}, De = () => {
|
|
3384
3414
|
I(null), fe.current?.focus?.(), fe.current = null;
|
|
3385
|
-
},
|
|
3415
|
+
}, Oe = (e, t, n) => {
|
|
3386
3416
|
let r = n.shiftKey || n.metaKey || n.ctrlKey;
|
|
3387
|
-
P.size > 0 || r ?
|
|
3388
|
-
},
|
|
3389
|
-
let e =
|
|
3417
|
+
P.size > 0 || r ? Te(e, t, n.shiftKey) : Ee(e.file.path);
|
|
3418
|
+
}, ke = () => {
|
|
3419
|
+
let e = H.every((e) => P.has(e.file.path));
|
|
3390
3420
|
F((t) => {
|
|
3391
3421
|
let n = new Set(t);
|
|
3392
|
-
for (let t of
|
|
3422
|
+
for (let t of H) e ? n.delete(t.file.path) : n.add(t.file.path);
|
|
3393
3423
|
return n;
|
|
3394
3424
|
});
|
|
3395
|
-
},
|
|
3396
|
-
l ? await l(e, t) :
|
|
3397
|
-
},
|
|
3425
|
+
}, Ae = (e) => S && e.startsWith(`${S}/`) ? e.slice(S.length + 1) : e, K = async (e, t) => {
|
|
3426
|
+
l ? await l(e, t) : li(e.name, t);
|
|
3427
|
+
}, q = async (e, t) => {
|
|
3398
3428
|
if (e.length === 0) return !1;
|
|
3399
|
-
|
|
3429
|
+
ge(!0);
|
|
3400
3430
|
try {
|
|
3401
3431
|
if (e.length === 1 && !t) {
|
|
3402
3432
|
let [t] = e;
|
|
3403
|
-
return await
|
|
3433
|
+
return await K(t, await Fn(t.path)), !0;
|
|
3404
3434
|
}
|
|
3405
|
-
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await
|
|
3406
|
-
name: t ? e.path.slice(n.length) :
|
|
3407
|
-
data: await
|
|
3435
|
+
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await ri(await Promise.all(e.map(async (e) => ({
|
|
3436
|
+
name: t ? e.path.slice(n.length) : Ae(e.path),
|
|
3437
|
+
data: await Fn(e.path),
|
|
3408
3438
|
lastModified: e.lastModified
|
|
3409
3439
|
})))), i = `${t ? t.name : C}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`;
|
|
3410
|
-
return await
|
|
3440
|
+
return await K({
|
|
3411
3441
|
name: i,
|
|
3412
3442
|
path: i,
|
|
3413
3443
|
size: r.size,
|
|
3414
3444
|
type: "application/zip",
|
|
3415
3445
|
lastModified: Date.now()
|
|
3416
|
-
}, r),
|
|
3446
|
+
}, r), ye(`Saved ${i} with ${si(e.length, "file")}`, "success", {
|
|
3417
3447
|
kind: "download",
|
|
3418
3448
|
paths: e.map((e) => e.path),
|
|
3419
3449
|
fileName: i
|
|
3420
3450
|
}), !0;
|
|
3421
3451
|
} catch (t) {
|
|
3422
|
-
return
|
|
3452
|
+
return ye(`Couldn’t download: ${oi(t)}`, "error", {
|
|
3423
3453
|
kind: "download",
|
|
3424
3454
|
paths: e.map((e) => e.path),
|
|
3425
|
-
error:
|
|
3455
|
+
error: oi(t)
|
|
3426
3456
|
}), !1;
|
|
3427
3457
|
} finally {
|
|
3428
|
-
|
|
3458
|
+
ge(!1);
|
|
3429
3459
|
}
|
|
3430
|
-
},
|
|
3460
|
+
}, J = (e) => q(e.map((e) => e.file)), je = (e, t) => e.flatMap((e) => [e.file, ...t ? e.variants.map((e) => e.file) : []]), Me = (e) => {
|
|
3431
3461
|
let t = b?.(e);
|
|
3432
3462
|
return {
|
|
3433
3463
|
label: t?.label,
|
|
3434
3464
|
destructive: t?.destructive !== !1
|
|
3435
3465
|
};
|
|
3436
|
-
},
|
|
3437
|
-
|
|
3466
|
+
}, Ne = (e) => Me(je(e, !0)), Pe = async (e, t) => {
|
|
3467
|
+
ge(!0);
|
|
3438
3468
|
let i = [], a = [], o = [], s = !1;
|
|
3439
3469
|
try {
|
|
3440
3470
|
let r = await navigator.storage.getDirectory();
|
|
3441
3471
|
for (let t of e) if (n && !await n(t)) o.push(t.path);
|
|
3442
3472
|
else try {
|
|
3443
|
-
await
|
|
3473
|
+
await In(t.path, r), i.push(t.path);
|
|
3444
3474
|
} catch (e) {
|
|
3445
3475
|
a.push({
|
|
3446
3476
|
path: t.path,
|
|
3447
|
-
error:
|
|
3477
|
+
error: oi(e)
|
|
3448
3478
|
});
|
|
3449
3479
|
}
|
|
3450
3480
|
if (t) try {
|
|
3451
|
-
s = await
|
|
3481
|
+
s = await Rn(t.path, r);
|
|
3452
3482
|
} catch (e) {
|
|
3453
3483
|
a.push({
|
|
3454
3484
|
path: t.path,
|
|
3455
|
-
error:
|
|
3485
|
+
error: oi(e)
|
|
3456
3486
|
});
|
|
3457
3487
|
}
|
|
3458
3488
|
} catch (e) {
|
|
3459
3489
|
a.push({
|
|
3460
3490
|
path: "",
|
|
3461
|
-
error:
|
|
3491
|
+
error: oi(e)
|
|
3462
3492
|
});
|
|
3463
3493
|
}
|
|
3464
3494
|
F((e) => {
|
|
3465
3495
|
let t = new Set(e);
|
|
3466
3496
|
return i.forEach((e) => t.delete(e)), t;
|
|
3467
|
-
}), de && i.includes(de) && I(null), await te(),
|
|
3468
|
-
let c = [s ? `Deleted the ${t.name} folder (${
|
|
3497
|
+
}), de && i.includes(de) && I(null), await te(), ge(!1);
|
|
3498
|
+
let c = [s ? `Deleted the ${t.name} folder (${si(i.length, "file")})` : i.length > 0 ? `Deleted ${si(i.length, "file")}` : "Nothing deleted"];
|
|
3469
3499
|
if (o.length && c.push(`${o.length} kept by onBeforeDelete`), a.length) {
|
|
3470
3500
|
let e = a.map((e) => e.path ? `${e.path.split("/").pop()}: ${e.error}` : e.error);
|
|
3471
3501
|
c.push(`${a.length} failed (${e.join("; ")})`);
|
|
3472
3502
|
}
|
|
3473
|
-
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`),
|
|
3503
|
+
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`), ye(c.join(". "), a.length ? "error" : "success", {
|
|
3474
3504
|
kind: "delete",
|
|
3475
3505
|
deleted: i,
|
|
3476
3506
|
skipped: o,
|
|
@@ -3480,98 +3510,98 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3480
3510
|
folderRemoved: s
|
|
3481
3511
|
}
|
|
3482
3512
|
}), i.length > 0 && await r?.(i);
|
|
3483
|
-
},
|
|
3513
|
+
}, Fe = async (e) => {
|
|
3484
3514
|
if (e.length === 0) return;
|
|
3485
3515
|
if (!y) {
|
|
3486
|
-
|
|
3516
|
+
L(e);
|
|
3487
3517
|
return;
|
|
3488
3518
|
}
|
|
3489
|
-
let t =
|
|
3490
|
-
await y(t) && await
|
|
3491
|
-
},
|
|
3519
|
+
let t = je(e, !0);
|
|
3520
|
+
await y(t) && await Pe(t);
|
|
3521
|
+
}, Y = (e) => k.filter((t) => t.path.startsWith(`${e.path}/`)), Ie = async (e) => {
|
|
3492
3522
|
if (!y) {
|
|
3493
|
-
|
|
3523
|
+
me(e);
|
|
3494
3524
|
return;
|
|
3495
3525
|
}
|
|
3496
|
-
let t =
|
|
3497
|
-
await y(t) && await
|
|
3498
|
-
},
|
|
3499
|
-
let t = () =>
|
|
3526
|
+
let t = Y(e);
|
|
3527
|
+
await y(t) && await Pe(t, e);
|
|
3528
|
+
}, Le = (e) => {
|
|
3529
|
+
let t = () => ye("Path copied", "success", {
|
|
3500
3530
|
kind: "copy-path",
|
|
3501
3531
|
path: e
|
|
3502
|
-
}), n = (t) =>
|
|
3532
|
+
}), n = (t) => ye("Couldn’t copy. Select the path text instead.", "error", {
|
|
3503
3533
|
kind: "copy-path",
|
|
3504
3534
|
path: e,
|
|
3505
|
-
error: t === void 0 ? "Clipboard unavailable" :
|
|
3535
|
+
error: t === void 0 ? "Clipboard unavailable" : oi(t)
|
|
3506
3536
|
});
|
|
3507
3537
|
try {
|
|
3508
3538
|
navigator.clipboard.writeText(e).then(t, n);
|
|
3509
3539
|
} catch (e) {
|
|
3510
3540
|
n(e);
|
|
3511
3541
|
}
|
|
3512
|
-
},
|
|
3513
|
-
if (
|
|
3542
|
+
}, Re = (e) => {
|
|
3543
|
+
if (pe || R) return;
|
|
3514
3544
|
let t = e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement;
|
|
3515
3545
|
if (e.key === "Escape") {
|
|
3516
|
-
if (de)
|
|
3546
|
+
if (de) De();
|
|
3517
3547
|
else if (P.size > 0) F(/* @__PURE__ */ new Set());
|
|
3518
3548
|
else return;
|
|
3519
3549
|
e.preventDefault();
|
|
3520
|
-
} else if (
|
|
3521
|
-
let t =
|
|
3550
|
+
} else if (G && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
3551
|
+
let t = H[Ce + (e.key === "ArrowRight" ? 1 : -1)];
|
|
3522
3552
|
t && I(t.file.path), e.preventDefault();
|
|
3523
3553
|
}
|
|
3524
|
-
},
|
|
3554
|
+
}, ze = o(() => k.some((e) => ur(e.path)), [k]), Be = /(^|\/)images(\/\d+)?$/.test(j), Ve = [{
|
|
3525
3555
|
label: C,
|
|
3526
3556
|
path: S
|
|
3527
3557
|
}, ...(j.length > S.length ? j.slice(S ? S.length + 1 : 0).split("/") : []).map((e, t, n) => ({
|
|
3528
3558
|
label: e,
|
|
3529
3559
|
path: [S, ...n.slice(0, t + 1)].filter(Boolean).join("/")
|
|
3530
|
-
}))],
|
|
3531
|
-
if (!
|
|
3560
|
+
}))], He = `h${f}`, Ue = Se.reduce((e, t) => e + t.file.size, 0), We;
|
|
3561
|
+
if (!zn()) We = /* @__PURE__ */ B(pi, {
|
|
3532
3562
|
icon: "triangleAlert",
|
|
3533
3563
|
tone: "error",
|
|
3534
3564
|
title: "This browser doesn’t support private file storage",
|
|
3535
3565
|
children: "OPFS isn’t available here. Some private browsing windows and older browsers turn it off. Try a current version of Chrome, Edge, Firefox, or Safari in a normal window."
|
|
3536
3566
|
});
|
|
3537
3567
|
else if (D) {
|
|
3538
|
-
let e = /* @__PURE__ */
|
|
3568
|
+
let e = /* @__PURE__ */ V("button", {
|
|
3539
3569
|
type: "button",
|
|
3540
3570
|
className: "seed-fm-btn",
|
|
3541
3571
|
onClick: () => te(),
|
|
3542
|
-
children: [/* @__PURE__ */
|
|
3572
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
3543
3573
|
name: "refresh",
|
|
3544
3574
|
size: 15
|
|
3545
3575
|
}), " Try again"]
|
|
3546
3576
|
});
|
|
3547
|
-
|
|
3577
|
+
We = O === "NotFoundError" && S ? /* @__PURE__ */ V(pi, {
|
|
3548
3578
|
icon: "triangleAlert",
|
|
3549
3579
|
tone: "error",
|
|
3550
3580
|
title: `Can’t open ${S}`,
|
|
3551
3581
|
action: e,
|
|
3552
3582
|
children: [
|
|
3553
3583
|
"The folder ",
|
|
3554
|
-
/* @__PURE__ */
|
|
3584
|
+
/* @__PURE__ */ B("code", { children: S }),
|
|
3555
3585
|
" doesn’t exist in this browser’s private storage yet. Check the",
|
|
3556
3586
|
" ",
|
|
3557
|
-
/* @__PURE__ */
|
|
3587
|
+
/* @__PURE__ */ B("code", { children: "rootPath" }),
|
|
3558
3588
|
" prop, or open the app once so the SDK creates it."
|
|
3559
3589
|
]
|
|
3560
|
-
}) : /* @__PURE__ */
|
|
3590
|
+
}) : /* @__PURE__ */ B(pi, {
|
|
3561
3591
|
icon: "triangleAlert",
|
|
3562
3592
|
tone: "error",
|
|
3563
3593
|
title: "Can’t read private storage",
|
|
3564
3594
|
action: e,
|
|
3565
3595
|
children: D
|
|
3566
3596
|
});
|
|
3567
|
-
} else
|
|
3597
|
+
} else We = E ? ie.length === 0 ? /* @__PURE__ */ B(pi, {
|
|
3568
3598
|
icon: "folderOpen",
|
|
3569
3599
|
title: `No files in ${C} yet`,
|
|
3570
3600
|
children: "Files show up here when the app saves images, JSON, or HTML to this browser’s private storage, for example after you add an image to a post or sync content from Arweave."
|
|
3571
|
-
}) :
|
|
3601
|
+
}) : be.folders.length === 0 && H.length === 0 ? M ? /* @__PURE__ */ V(pi, {
|
|
3572
3602
|
icon: "search",
|
|
3573
3603
|
title: `No matches for “${M}”`,
|
|
3574
|
-
action: /* @__PURE__ */
|
|
3604
|
+
action: /* @__PURE__ */ B("button", {
|
|
3575
3605
|
type: "button",
|
|
3576
3606
|
className: "seed-fm-btn",
|
|
3577
3607
|
onClick: () => oe(""),
|
|
@@ -3579,145 +3609,145 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3579
3609
|
}),
|
|
3580
3610
|
children: [
|
|
3581
3611
|
"Search covers file names and paths in ",
|
|
3582
|
-
|
|
3612
|
+
Ve[Ve.length - 1].label,
|
|
3583
3613
|
" and every folder inside it."
|
|
3584
3614
|
]
|
|
3585
|
-
}) : /* @__PURE__ */
|
|
3615
|
+
}) : /* @__PURE__ */ B(pi, {
|
|
3586
3616
|
icon: "folderOpen",
|
|
3587
3617
|
title: "This folder is empty",
|
|
3588
3618
|
children: "Everything in it has been deleted or filtered out."
|
|
3589
|
-
}) : /* @__PURE__ */
|
|
3619
|
+
}) : /* @__PURE__ */ V(z, { children: [be.folders.length > 0 && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("div", {
|
|
3590
3620
|
className: "seed-fm-section-label",
|
|
3591
3621
|
children: "Folders"
|
|
3592
|
-
}), /* @__PURE__ */
|
|
3622
|
+
}), /* @__PURE__ */ B("ul", {
|
|
3593
3623
|
className: "seed-fm-folders",
|
|
3594
|
-
children:
|
|
3624
|
+
children: be.folders.map((e) => /* @__PURE__ */ V("li", { children: [/* @__PURE__ */ V("button", {
|
|
3595
3625
|
type: "button",
|
|
3596
3626
|
className: w("folder", "seed-fm-folder"),
|
|
3597
|
-
onClick: () =>
|
|
3598
|
-
children: [/* @__PURE__ */
|
|
3627
|
+
onClick: () => we(e.path),
|
|
3628
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
3599
3629
|
name: "folder",
|
|
3600
3630
|
size: 20,
|
|
3601
3631
|
strokeWidth: 1.75
|
|
3602
|
-
}), /* @__PURE__ */
|
|
3632
|
+
}), /* @__PURE__ */ V("span", { children: [/* @__PURE__ */ B("span", {
|
|
3603
3633
|
className: "seed-fm-folder-name",
|
|
3604
3634
|
children: e.name
|
|
3605
|
-
}), /* @__PURE__ */
|
|
3635
|
+
}), /* @__PURE__ */ V("span", {
|
|
3606
3636
|
className: "seed-fm-folder-meta",
|
|
3607
3637
|
children: [
|
|
3608
|
-
|
|
3638
|
+
si(e.fileCount, "file"),
|
|
3609
3639
|
" · ",
|
|
3610
|
-
|
|
3640
|
+
Z(e.size)
|
|
3611
3641
|
]
|
|
3612
3642
|
})] })]
|
|
3613
|
-
}), /* @__PURE__ */
|
|
3643
|
+
}), /* @__PURE__ */ B("button", {
|
|
3614
3644
|
type: "button",
|
|
3615
3645
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon seed-fm-folder-delete",
|
|
3616
3646
|
"aria-label": `Delete folder ${e.name}`,
|
|
3617
3647
|
title: "Delete folder",
|
|
3618
|
-
disabled:
|
|
3619
|
-
onClick: () =>
|
|
3620
|
-
children: /* @__PURE__ */
|
|
3648
|
+
disabled: he,
|
|
3649
|
+
onClick: () => Ie(e),
|
|
3650
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3621
3651
|
name: "trash",
|
|
3622
3652
|
size: 15
|
|
3623
3653
|
})
|
|
3624
3654
|
})] }, e.path))
|
|
3625
|
-
})] }),
|
|
3655
|
+
})] }), H.length > 0 && /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("div", {
|
|
3626
3656
|
className: "seed-fm-section-label",
|
|
3627
|
-
children: M ?
|
|
3628
|
-
}),
|
|
3629
|
-
entries:
|
|
3657
|
+
children: M ? si(H.length, "result") : "Files"
|
|
3658
|
+
}), xe === "grid" ? /* @__PURE__ */ B(Rr, {
|
|
3659
|
+
entries: H,
|
|
3630
3660
|
selected: P,
|
|
3631
|
-
onActivate:
|
|
3632
|
-
onToggle:
|
|
3661
|
+
onActivate: Oe,
|
|
3662
|
+
onToggle: Te,
|
|
3633
3663
|
className: h.grid,
|
|
3634
3664
|
tileClassName: h.tile
|
|
3635
|
-
}) : /* @__PURE__ */
|
|
3636
|
-
entries:
|
|
3665
|
+
}) : /* @__PURE__ */ B(zr, {
|
|
3666
|
+
entries: H,
|
|
3637
3667
|
selected: P,
|
|
3638
3668
|
cwd: j,
|
|
3639
|
-
onActivate:
|
|
3640
|
-
onToggle:
|
|
3641
|
-
onToggleAll:
|
|
3642
|
-
onDownload: (e) =>
|
|
3643
|
-
onDelete: (e) =>
|
|
3644
|
-
deleteActionFor: (e) =>
|
|
3669
|
+
onActivate: Oe,
|
|
3670
|
+
onToggle: Te,
|
|
3671
|
+
onToggleAll: ke,
|
|
3672
|
+
onDownload: (e) => J([e]),
|
|
3673
|
+
onDelete: (e) => Fe([e]),
|
|
3674
|
+
deleteActionFor: (e) => Ne([e]),
|
|
3645
3675
|
className: h.list,
|
|
3646
3676
|
rowClassName: h.row
|
|
3647
|
-
})] })] }) : /* @__PURE__ */
|
|
3677
|
+
})] })] }) : /* @__PURE__ */ B("ul", {
|
|
3648
3678
|
className: w("grid", "seed-fm-grid"),
|
|
3649
3679
|
"aria-busy": "true",
|
|
3650
3680
|
"aria-label": "Loading files",
|
|
3651
|
-
children: Array.from({ length: 8 }, (e, t) => /* @__PURE__ */
|
|
3681
|
+
children: Array.from({ length: 8 }, (e, t) => /* @__PURE__ */ B("li", {
|
|
3652
3682
|
className: "seed-fm-tile",
|
|
3653
|
-
children: /* @__PURE__ */
|
|
3683
|
+
children: /* @__PURE__ */ B("span", { className: "seed-fm-thumb seed-fm-skeleton" })
|
|
3654
3684
|
}, t))
|
|
3655
3685
|
});
|
|
3656
|
-
let
|
|
3657
|
-
return /* @__PURE__ */
|
|
3686
|
+
let Ge = pe ? je(pe, !0) : [], Ke = R ? Y(R) : [], X = P.size > 0 ? Ne(Se) : null;
|
|
3687
|
+
return /* @__PURE__ */ V("div", {
|
|
3658
3688
|
className: [w("root", "seed-fm"), m].filter(Boolean).join(" "),
|
|
3659
3689
|
"data-seed-theme": p === "none" ? void 0 : p,
|
|
3660
3690
|
"data-selecting": P.size > 0 || void 0,
|
|
3661
|
-
onKeyDown:
|
|
3691
|
+
onKeyDown: Re,
|
|
3662
3692
|
children: [
|
|
3663
|
-
/* @__PURE__ */
|
|
3693
|
+
/* @__PURE__ */ V("div", {
|
|
3664
3694
|
className: "seed-fm-frame",
|
|
3665
3695
|
children: [
|
|
3666
|
-
/* @__PURE__ */
|
|
3696
|
+
/* @__PURE__ */ V("header", {
|
|
3667
3697
|
className: w("header", "seed-fm-header"),
|
|
3668
3698
|
children: [
|
|
3669
|
-
/* @__PURE__ */
|
|
3699
|
+
/* @__PURE__ */ V("div", {
|
|
3670
3700
|
className: "seed-fm-titles",
|
|
3671
|
-
children: [/* @__PURE__ */
|
|
3701
|
+
children: [/* @__PURE__ */ B(He, {
|
|
3672
3702
|
className: "seed-fm-title",
|
|
3673
3703
|
children: u
|
|
3674
|
-
}), d && /* @__PURE__ */
|
|
3704
|
+
}), d && /* @__PURE__ */ B("p", {
|
|
3675
3705
|
className: "seed-fm-description",
|
|
3676
3706
|
children: d
|
|
3677
3707
|
})]
|
|
3678
3708
|
}),
|
|
3679
|
-
E && !D && /* @__PURE__ */
|
|
3709
|
+
E && !D && /* @__PURE__ */ B(fi, {
|
|
3680
3710
|
files: k,
|
|
3681
3711
|
estimate: ne
|
|
3682
3712
|
}),
|
|
3683
|
-
/* @__PURE__ */
|
|
3713
|
+
/* @__PURE__ */ B("button", {
|
|
3684
3714
|
type: "button",
|
|
3685
3715
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3686
3716
|
onClick: () => te(),
|
|
3687
3717
|
"aria-label": "Refresh",
|
|
3688
3718
|
title: "Refresh",
|
|
3689
3719
|
"data-busy": ee && E,
|
|
3690
|
-
children: /* @__PURE__ */
|
|
3720
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3691
3721
|
name: "refresh",
|
|
3692
3722
|
size: 15
|
|
3693
3723
|
})
|
|
3694
3724
|
})
|
|
3695
3725
|
]
|
|
3696
3726
|
}),
|
|
3697
|
-
E && !D && ie.length > 0 && /* @__PURE__ */
|
|
3727
|
+
E && !D && ie.length > 0 && /* @__PURE__ */ V("div", {
|
|
3698
3728
|
className: w("toolbar", "seed-fm-toolbar"),
|
|
3699
3729
|
children: [
|
|
3700
|
-
/* @__PURE__ */
|
|
3730
|
+
/* @__PURE__ */ B("nav", {
|
|
3701
3731
|
"aria-label": "Folder",
|
|
3702
|
-
children: /* @__PURE__ */
|
|
3732
|
+
children: /* @__PURE__ */ B("ol", {
|
|
3703
3733
|
className: "seed-fm-crumbs",
|
|
3704
|
-
children:
|
|
3734
|
+
children: Ve.map((e, t) => /* @__PURE__ */ V("li", { children: [t > 0 && /* @__PURE__ */ B(Q, {
|
|
3705
3735
|
name: "chevronRight",
|
|
3706
3736
|
size: 14
|
|
3707
|
-
}), /* @__PURE__ */
|
|
3737
|
+
}), /* @__PURE__ */ B("button", {
|
|
3708
3738
|
type: "button",
|
|
3709
|
-
onClick: () =>
|
|
3710
|
-
"aria-current": t ===
|
|
3739
|
+
onClick: () => we(e.path),
|
|
3740
|
+
"aria-current": t === Ve.length - 1 ? "page" : void 0,
|
|
3711
3741
|
children: e.label
|
|
3712
3742
|
})] }, e.path || "/"))
|
|
3713
3743
|
})
|
|
3714
3744
|
}),
|
|
3715
|
-
/* @__PURE__ */
|
|
3745
|
+
/* @__PURE__ */ V("label", {
|
|
3716
3746
|
className: "seed-fm-search",
|
|
3717
|
-
children: [/* @__PURE__ */
|
|
3747
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
3718
3748
|
name: "search",
|
|
3719
3749
|
size: 14
|
|
3720
|
-
}), /* @__PURE__ */
|
|
3750
|
+
}), /* @__PURE__ */ B("input", {
|
|
3721
3751
|
type: "search",
|
|
3722
3752
|
value: M,
|
|
3723
3753
|
onChange: (e) => oe(e.target.value),
|
|
@@ -3725,59 +3755,59 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3725
3755
|
"aria-label": "Search files"
|
|
3726
3756
|
})]
|
|
3727
3757
|
}),
|
|
3728
|
-
/* @__PURE__ */
|
|
3758
|
+
/* @__PURE__ */ V("select", {
|
|
3729
3759
|
className: "seed-fm-select",
|
|
3730
3760
|
value: N,
|
|
3731
3761
|
onChange: (e) => se(e.target.value),
|
|
3732
3762
|
"aria-label": "Sort by",
|
|
3733
3763
|
children: [
|
|
3734
|
-
/* @__PURE__ */
|
|
3764
|
+
/* @__PURE__ */ B("option", {
|
|
3735
3765
|
value: "name",
|
|
3736
3766
|
children: "Name"
|
|
3737
3767
|
}),
|
|
3738
|
-
/* @__PURE__ */
|
|
3768
|
+
/* @__PURE__ */ B("option", {
|
|
3739
3769
|
value: "modified",
|
|
3740
3770
|
children: "Recently modified"
|
|
3741
3771
|
}),
|
|
3742
|
-
/* @__PURE__ */
|
|
3772
|
+
/* @__PURE__ */ B("option", {
|
|
3743
3773
|
value: "size",
|
|
3744
3774
|
children: "Largest"
|
|
3745
3775
|
})
|
|
3746
3776
|
]
|
|
3747
3777
|
}),
|
|
3748
|
-
/* @__PURE__ */
|
|
3778
|
+
/* @__PURE__ */ V("div", {
|
|
3749
3779
|
className: "seed-fm-viewtoggle",
|
|
3750
3780
|
role: "group",
|
|
3751
3781
|
"aria-label": "View",
|
|
3752
|
-
children: [/* @__PURE__ */
|
|
3782
|
+
children: [/* @__PURE__ */ B("button", {
|
|
3753
3783
|
type: "button",
|
|
3754
|
-
"aria-pressed":
|
|
3784
|
+
"aria-pressed": xe === "grid",
|
|
3755
3785
|
"aria-label": "Grid view",
|
|
3756
3786
|
onClick: () => le("grid"),
|
|
3757
|
-
children: /* @__PURE__ */
|
|
3787
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3758
3788
|
name: "layoutGrid",
|
|
3759
3789
|
size: 15
|
|
3760
3790
|
})
|
|
3761
|
-
}), /* @__PURE__ */
|
|
3791
|
+
}), /* @__PURE__ */ B("button", {
|
|
3762
3792
|
type: "button",
|
|
3763
|
-
"aria-pressed":
|
|
3793
|
+
"aria-pressed": xe === "list",
|
|
3764
3794
|
"aria-label": "List view",
|
|
3765
3795
|
onClick: () => le("list"),
|
|
3766
|
-
children: /* @__PURE__ */
|
|
3796
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3767
3797
|
name: "list",
|
|
3768
3798
|
size: 15
|
|
3769
3799
|
})
|
|
3770
3800
|
})]
|
|
3771
3801
|
}),
|
|
3772
|
-
|
|
3802
|
+
ze && Be && /* @__PURE__ */ V("p", {
|
|
3773
3803
|
className: "seed-fm-hint",
|
|
3774
3804
|
children: [
|
|
3775
|
-
/* @__PURE__ */
|
|
3805
|
+
/* @__PURE__ */ B(Q, {
|
|
3776
3806
|
name: "layers",
|
|
3777
3807
|
size: 13
|
|
3778
3808
|
}),
|
|
3779
3809
|
A ? "Resized copies are grouped with their original image." : "Resized copies are shown in their size folders.",
|
|
3780
|
-
/* @__PURE__ */
|
|
3810
|
+
/* @__PURE__ */ B("button", {
|
|
3781
3811
|
type: "button",
|
|
3782
3812
|
className: "seed-fm-linkbtn",
|
|
3783
3813
|
onClick: () => {
|
|
@@ -3789,31 +3819,31 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3789
3819
|
})
|
|
3790
3820
|
]
|
|
3791
3821
|
}),
|
|
3792
|
-
/* @__PURE__ */
|
|
3822
|
+
/* @__PURE__ */ B("div", {
|
|
3793
3823
|
className: w("body", "seed-fm-body"),
|
|
3794
|
-
children:
|
|
3824
|
+
children: We
|
|
3795
3825
|
}),
|
|
3796
|
-
|
|
3826
|
+
X && /* @__PURE__ */ V("div", {
|
|
3797
3827
|
className: w("batchBar", "seed-fm-batch"),
|
|
3798
3828
|
role: "toolbar",
|
|
3799
3829
|
"aria-label": "Selected files",
|
|
3800
3830
|
children: [
|
|
3801
|
-
/* @__PURE__ */
|
|
3831
|
+
/* @__PURE__ */ V("span", {
|
|
3802
3832
|
className: "seed-fm-batch-count",
|
|
3803
3833
|
"aria-live": "polite",
|
|
3804
3834
|
children: [
|
|
3805
3835
|
P.size,
|
|
3806
3836
|
" selected ",
|
|
3807
|
-
/* @__PURE__ */
|
|
3837
|
+
/* @__PURE__ */ V("span", { children: ["· ", Z(Ue)] })
|
|
3808
3838
|
]
|
|
3809
3839
|
}),
|
|
3810
|
-
/* @__PURE__ */
|
|
3840
|
+
/* @__PURE__ */ V("button", {
|
|
3811
3841
|
type: "button",
|
|
3812
3842
|
className: "seed-fm-btn",
|
|
3813
|
-
disabled:
|
|
3814
|
-
onClick: () =>
|
|
3843
|
+
disabled: he,
|
|
3844
|
+
onClick: () => J(Se),
|
|
3815
3845
|
children: [
|
|
3816
|
-
/* @__PURE__ */
|
|
3846
|
+
/* @__PURE__ */ B(Q, {
|
|
3817
3847
|
name: "download",
|
|
3818
3848
|
size: 15
|
|
3819
3849
|
}),
|
|
@@ -3821,26 +3851,26 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3821
3851
|
P.size > 1 ? "Download .zip" : "Download"
|
|
3822
3852
|
]
|
|
3823
3853
|
}),
|
|
3824
|
-
/* @__PURE__ */
|
|
3854
|
+
/* @__PURE__ */ V("button", {
|
|
3825
3855
|
type: "button",
|
|
3826
|
-
className: `seed-fm-btn${
|
|
3827
|
-
disabled:
|
|
3828
|
-
onClick: () =>
|
|
3856
|
+
className: `seed-fm-btn${X.destructive ? " seed-fm-btn--danger-text" : ""}`,
|
|
3857
|
+
disabled: he,
|
|
3858
|
+
onClick: () => Fe(Se),
|
|
3829
3859
|
children: [
|
|
3830
|
-
/* @__PURE__ */
|
|
3860
|
+
/* @__PURE__ */ B(Q, {
|
|
3831
3861
|
name: "trash",
|
|
3832
3862
|
size: 15
|
|
3833
3863
|
}),
|
|
3834
3864
|
" ",
|
|
3835
|
-
|
|
3865
|
+
X.label ?? "Delete"
|
|
3836
3866
|
]
|
|
3837
3867
|
}),
|
|
3838
|
-
/* @__PURE__ */
|
|
3868
|
+
/* @__PURE__ */ B("button", {
|
|
3839
3869
|
type: "button",
|
|
3840
3870
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3841
3871
|
"aria-label": "Clear selection",
|
|
3842
3872
|
onClick: () => F(/* @__PURE__ */ new Set()),
|
|
3843
|
-
children: /* @__PURE__ */
|
|
3873
|
+
children: /* @__PURE__ */ B(Q, {
|
|
3844
3874
|
name: "x",
|
|
3845
3875
|
size: 15
|
|
3846
3876
|
})
|
|
@@ -3849,49 +3879,49 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3849
3879
|
})
|
|
3850
3880
|
]
|
|
3851
3881
|
}),
|
|
3852
|
-
|
|
3853
|
-
entry:
|
|
3882
|
+
G && /* @__PURE__ */ B(Ur, {
|
|
3883
|
+
entry: G,
|
|
3854
3884
|
className: h.panel,
|
|
3855
|
-
onClose:
|
|
3856
|
-
onPrevious:
|
|
3857
|
-
onNext:
|
|
3858
|
-
onDownload: () =>
|
|
3859
|
-
onDelete: () =>
|
|
3860
|
-
deleteAction:
|
|
3861
|
-
onCopyPath: () =>
|
|
3885
|
+
onClose: De,
|
|
3886
|
+
onPrevious: Ce > 0 ? () => I(H[Ce - 1].file.path) : null,
|
|
3887
|
+
onNext: Ce >= 0 && Ce < H.length - 1 ? () => I(H[Ce + 1].file.path) : null,
|
|
3888
|
+
onDownload: () => J([G]),
|
|
3889
|
+
onDelete: () => Fe([G]),
|
|
3890
|
+
deleteAction: Ne([G]),
|
|
3891
|
+
onCopyPath: () => Le(G.file.path)
|
|
3862
3892
|
}, "panel"),
|
|
3863
|
-
|
|
3864
|
-
entries:
|
|
3893
|
+
pe && /* @__PURE__ */ B(nr, {
|
|
3894
|
+
entries: pe,
|
|
3865
3895
|
rootPath: S,
|
|
3866
|
-
warning: v(
|
|
3867
|
-
deleteActionFor: (e) => je(
|
|
3896
|
+
warning: v(Ge),
|
|
3897
|
+
deleteActionFor: (e) => Me(je(pe, e)),
|
|
3868
3898
|
className: h.dialog,
|
|
3869
|
-
onCancel: () =>
|
|
3899
|
+
onCancel: () => L(null),
|
|
3870
3900
|
onConfirm: (e) => {
|
|
3871
|
-
let t =
|
|
3872
|
-
|
|
3901
|
+
let t = je(pe, e);
|
|
3902
|
+
L(null), Pe(t);
|
|
3873
3903
|
}
|
|
3874
3904
|
}),
|
|
3875
|
-
|
|
3876
|
-
folder:
|
|
3877
|
-
files:
|
|
3878
|
-
hiddenCount: T.filter((e) => e.path.startsWith(`${
|
|
3879
|
-
warning: v(
|
|
3880
|
-
action:
|
|
3881
|
-
busy:
|
|
3905
|
+
R && /* @__PURE__ */ B(rr, {
|
|
3906
|
+
folder: R,
|
|
3907
|
+
files: Ke,
|
|
3908
|
+
hiddenCount: T.filter((e) => e.path.startsWith(`${R.path}/`)).length - Ke.length,
|
|
3909
|
+
warning: v(Ke),
|
|
3910
|
+
action: Me(Ke),
|
|
3911
|
+
busy: he,
|
|
3882
3912
|
className: h.dialog,
|
|
3883
|
-
onDownload: () =>
|
|
3884
|
-
onCancel: () =>
|
|
3913
|
+
onDownload: () => q(Ke, R),
|
|
3914
|
+
onCancel: () => me(null),
|
|
3885
3915
|
onConfirm: () => {
|
|
3886
|
-
|
|
3916
|
+
me(null), Pe(Ke, R);
|
|
3887
3917
|
}
|
|
3888
3918
|
}),
|
|
3889
|
-
!x && /* @__PURE__ */
|
|
3919
|
+
!x && /* @__PURE__ */ B("ul", {
|
|
3890
3920
|
className: "seed-fm-toasts",
|
|
3891
3921
|
"aria-live": "polite",
|
|
3892
|
-
children:
|
|
3922
|
+
children: _e.map((e) => /* @__PURE__ */ V("li", {
|
|
3893
3923
|
className: w("toast", `seed-fm-toast${e.tone === "error" ? " seed-fm-toast--error" : ""}`),
|
|
3894
|
-
children: [/* @__PURE__ */
|
|
3924
|
+
children: [/* @__PURE__ */ B(Q, {
|
|
3895
3925
|
name: e.tone === "error" ? "triangleAlert" : "check",
|
|
3896
3926
|
size: 15,
|
|
3897
3927
|
strokeWidth: 2.5
|
|
@@ -3903,15 +3933,15 @@ function oi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3903
3933
|
}
|
|
3904
3934
|
//#endregion
|
|
3905
3935
|
//#region src/useEnsureLocalImage.ts
|
|
3906
|
-
var
|
|
3936
|
+
var hi = (e) => {
|
|
3907
3937
|
try {
|
|
3908
3938
|
return e.getService?.()?.getSnapshot?.()?.context?.storageTransactionId || void 0;
|
|
3909
3939
|
} catch {
|
|
3910
3940
|
return;
|
|
3911
3941
|
}
|
|
3912
3942
|
};
|
|
3913
|
-
function
|
|
3914
|
-
let { imageProperty: t, filename: r, width: a, enabled: s = !0 } = e, [l, u] = c(null), [f, p] = c("idle"), m = t?.refResolvedValue, h = t?.value, g = typeof h == "string" ? h : void 0, _ =
|
|
3943
|
+
function gi(e) {
|
|
3944
|
+
let { imageProperty: t, filename: r, width: a, enabled: s = !0 } = e, [l, u] = c(null), [f, p] = c("idle"), m = t?.refResolvedValue, h = t?.value, g = typeof h == "string" ? h : void 0, _ = hi(t), v = o(() => le(_) ?? le(r) ?? le(m) ?? le(g), [
|
|
3915
3945
|
_,
|
|
3916
3946
|
r,
|
|
3917
3947
|
m,
|
|
@@ -3979,23 +4009,23 @@ function ci(e) {
|
|
|
3979
4009
|
}
|
|
3980
4010
|
//#endregion
|
|
3981
4011
|
//#region src/SeedImage.tsx
|
|
3982
|
-
var
|
|
4012
|
+
var _i = ve("seedSdk:react:SeedImage"), vi = /* @__PURE__ */ new Map(), yi = (e) => {
|
|
3983
4013
|
let t = e.match(/^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/);
|
|
3984
4014
|
return t && t[2] ? t[2] : e;
|
|
3985
4015
|
};
|
|
3986
|
-
function
|
|
4016
|
+
function bi(e) {
|
|
3987
4017
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3988
4018
|
}
|
|
3989
|
-
function
|
|
3990
|
-
let n = RegExp(`^${
|
|
4019
|
+
function xi(e, t) {
|
|
4020
|
+
let n = RegExp(`^${bi(t)}$`), r = yi(e);
|
|
3991
4021
|
return n.test(r);
|
|
3992
4022
|
}
|
|
3993
|
-
var
|
|
3994
|
-
let [l, u] = c(), [d, f] = c(), { property: m } =
|
|
4023
|
+
var Si = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o }, s) => {
|
|
4024
|
+
let [l, u] = c(), [d, f] = c(), { property: m } = ct({
|
|
3995
4025
|
propertyName: t.propertyName,
|
|
3996
4026
|
seedLocalId: t.seedLocalId,
|
|
3997
4027
|
seedUid: t.seedUid
|
|
3998
|
-
}), h = t ?? m, g = r ?? h?.refResolvedValue ?? h?.value, { status: _, gatewayHref: v, onGatewayError: y } =
|
|
4028
|
+
}), h = t ?? m, g = r ?? h?.refResolvedValue ?? h?.value, { status: _, gatewayHref: v, onGatewayError: y } = gi({
|
|
3999
4029
|
imageProperty: h ?? t,
|
|
4000
4030
|
filename: r,
|
|
4001
4031
|
width: n,
|
|
@@ -4019,7 +4049,7 @@ var mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4019
4049
|
!e && n && f(n);
|
|
4020
4050
|
}
|
|
4021
4051
|
} catch (e) {
|
|
4022
|
-
|
|
4052
|
+
_i("_getOriginalContentUrl error", e);
|
|
4023
4053
|
}
|
|
4024
4054
|
})(), () => {
|
|
4025
4055
|
e = !0;
|
|
@@ -4035,25 +4065,25 @@ var mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4035
4065
|
try {
|
|
4036
4066
|
let e = await p.getFs(), t = h?.localStoragePath ? h.localStoragePath.split("/").slice(0, -1).join("/") : p.getFilesPath("images"), r = e.readdirSync(t, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => parseInt(e.name)).filter((e) => !Number.isNaN(e));
|
|
4037
4067
|
if (r.length === 0) return;
|
|
4038
|
-
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a =
|
|
4039
|
-
if (
|
|
4040
|
-
let e =
|
|
4068
|
+
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a = yi(g), o = `${a}-${i}`;
|
|
4069
|
+
if (vi.has(o)) try {
|
|
4070
|
+
let e = vi.get(o);
|
|
4041
4071
|
if (e && (await fetch(e)).ok) {
|
|
4042
4072
|
u(e);
|
|
4043
4073
|
return;
|
|
4044
4074
|
}
|
|
4045
4075
|
} catch (e) {
|
|
4046
|
-
|
|
4076
|
+
_i("error", e), vi.delete(o);
|
|
4047
4077
|
}
|
|
4048
|
-
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ?
|
|
4078
|
+
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ? xi(e.name, a) : !1);
|
|
4049
4079
|
if (!s) return;
|
|
4050
4080
|
let c = `${t}/${i}/${s?.name}`;
|
|
4051
4081
|
if (await p.pathExists(c)) {
|
|
4052
4082
|
let e = await p.getContentUrlFromPath(c);
|
|
4053
|
-
e && (
|
|
4083
|
+
e && (vi.set(o, e), u(e));
|
|
4054
4084
|
}
|
|
4055
4085
|
} catch (e) {
|
|
4056
|
-
|
|
4086
|
+
_i("_getSizedContentUrl error", e);
|
|
4057
4087
|
}
|
|
4058
4088
|
})();
|
|
4059
4089
|
}, [
|
|
@@ -4068,7 +4098,7 @@ var mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4068
4098
|
let D = l || d || C || (ee(x) ? x : void 0) || (a && !E ? v : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", { onError: O, ...te } = o, k = (e) => {
|
|
4069
4099
|
v && D === v && y(), O?.(e);
|
|
4070
4100
|
};
|
|
4071
|
-
return /* @__PURE__ */
|
|
4101
|
+
return /* @__PURE__ */ B("img", {
|
|
4072
4102
|
src: D,
|
|
4073
4103
|
alt: o.alt || t.propertyName || "Image",
|
|
4074
4104
|
width: n,
|
|
@@ -4079,7 +4109,7 @@ var mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4079
4109
|
}));
|
|
4080
4110
|
//#endregion
|
|
4081
4111
|
//#region src/useResolvedMediaRef.ts
|
|
4082
|
-
function
|
|
4112
|
+
function Ci(e) {
|
|
4083
4113
|
let { value: t, enabled: r = !0, treatAs: a } = e, [o, s] = c(0), l = JSON.stringify([
|
|
4084
4114
|
r,
|
|
4085
4115
|
t ?? null,
|
|
@@ -4103,7 +4133,7 @@ function hi(e) {
|
|
|
4103
4133
|
error: null
|
|
4104
4134
|
});
|
|
4105
4135
|
try {
|
|
4106
|
-
let r = await
|
|
4136
|
+
let r = await pe(String(t), { treatAs: a }), i = r.status === "ready" && r.source === "localBlob" ? r.href : void 0;
|
|
4107
4137
|
if (e) {
|
|
4108
4138
|
i && URL.revokeObjectURL(i);
|
|
4109
4139
|
return;
|
|
@@ -4149,8 +4179,8 @@ function hi(e) {
|
|
|
4149
4179
|
}
|
|
4150
4180
|
//#endregion
|
|
4151
4181
|
//#region src/SeedMediaImage.tsx
|
|
4152
|
-
function
|
|
4153
|
-
let { href: o } =
|
|
4182
|
+
function wi({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
4183
|
+
let { href: o } = Ci({
|
|
4154
4184
|
value: e,
|
|
4155
4185
|
enabled: t,
|
|
4156
4186
|
treatAs: n
|
|
@@ -4161,18 +4191,18 @@ function gi({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
|
4161
4191
|
src: o,
|
|
4162
4192
|
alt: i ?? ""
|
|
4163
4193
|
};
|
|
4164
|
-
return r ? /* @__PURE__ */
|
|
4194
|
+
return r ? /* @__PURE__ */ B(z, { children: r(s) }) : /* @__PURE__ */ B("img", { ...s });
|
|
4165
4195
|
}
|
|
4166
4196
|
//#endregion
|
|
4167
4197
|
//#region src/SeedMediaFile.tsx
|
|
4168
|
-
function
|
|
4198
|
+
function Ti(e) {
|
|
4169
4199
|
try {
|
|
4170
4200
|
return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
|
|
4171
4201
|
} catch {
|
|
4172
4202
|
return "Open";
|
|
4173
4203
|
}
|
|
4174
4204
|
}
|
|
4175
|
-
function
|
|
4205
|
+
function Ei(e) {
|
|
4176
4206
|
try {
|
|
4177
4207
|
let t = new URL(e).protocol;
|
|
4178
4208
|
return t === "http:" || t === "https:";
|
|
@@ -4180,27 +4210,27 @@ function vi(e) {
|
|
|
4180
4210
|
return !1;
|
|
4181
4211
|
}
|
|
4182
4212
|
}
|
|
4183
|
-
function
|
|
4184
|
-
let { href: l } =
|
|
4213
|
+
function Di({ value: e, enabled: t, treatAs: n, download: r, render: i, children: a, target: o, rel: s, ...c }) {
|
|
4214
|
+
let { href: l } = Ci({
|
|
4185
4215
|
value: e,
|
|
4186
4216
|
enabled: t,
|
|
4187
4217
|
treatAs: n
|
|
4188
4218
|
});
|
|
4189
4219
|
if (!l) return null;
|
|
4190
|
-
let u =
|
|
4220
|
+
let u = Ei(l), d = o === void 0 ? u ? "_blank" : void 0 : o, f = {
|
|
4191
4221
|
...c,
|
|
4192
4222
|
href: l,
|
|
4193
4223
|
download: r,
|
|
4194
4224
|
target: d,
|
|
4195
4225
|
rel: s ?? (u && d === "_blank" ? "noopener noreferrer" : void 0),
|
|
4196
|
-
children: a ??
|
|
4226
|
+
children: a ?? Ti(l)
|
|
4197
4227
|
};
|
|
4198
|
-
return i ? /* @__PURE__ */
|
|
4228
|
+
return i ? /* @__PURE__ */ B(z, { children: i(f) }) : /* @__PURE__ */ B("a", { ...f });
|
|
4199
4229
|
}
|
|
4200
4230
|
//#endregion
|
|
4201
4231
|
//#region src/SeedMediaAudio.tsx
|
|
4202
|
-
function
|
|
4203
|
-
let { href: o } =
|
|
4232
|
+
function Oi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
4233
|
+
let { href: o } = Ci({
|
|
4204
4234
|
value: e,
|
|
4205
4235
|
enabled: t,
|
|
4206
4236
|
treatAs: n
|
|
@@ -4211,12 +4241,12 @@ function bi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
4211
4241
|
src: o,
|
|
4212
4242
|
controls: i
|
|
4213
4243
|
};
|
|
4214
|
-
return r ? /* @__PURE__ */
|
|
4244
|
+
return r ? /* @__PURE__ */ B(z, { children: r(s) }) : /* @__PURE__ */ B("audio", { ...s });
|
|
4215
4245
|
}
|
|
4216
4246
|
//#endregion
|
|
4217
4247
|
//#region src/SeedMediaVideo.tsx
|
|
4218
|
-
function
|
|
4219
|
-
let { href: o } =
|
|
4248
|
+
function ki({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
4249
|
+
let { href: o } = Ci({
|
|
4220
4250
|
value: e,
|
|
4221
4251
|
enabled: t,
|
|
4222
4252
|
treatAs: n
|
|
@@ -4227,63 +4257,63 @@ function xi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
4227
4257
|
src: o,
|
|
4228
4258
|
controls: i
|
|
4229
4259
|
};
|
|
4230
|
-
return r ? /* @__PURE__ */
|
|
4260
|
+
return r ? /* @__PURE__ */ B(z, { children: r(s) }) : /* @__PURE__ */ B("video", { ...s });
|
|
4231
4261
|
}
|
|
4232
4262
|
//#endregion
|
|
4233
4263
|
//#region src/SeedHtml.tsx
|
|
4234
|
-
function
|
|
4264
|
+
function Ai(e) {
|
|
4235
4265
|
return typeof e == "string" && e.trim().length > 0;
|
|
4236
4266
|
}
|
|
4237
|
-
function
|
|
4238
|
-
if (!
|
|
4267
|
+
function ji({ html: e, sanitize: t, render: n, ...r }) {
|
|
4268
|
+
if (!Ai(e)) return null;
|
|
4239
4269
|
let i = t(e);
|
|
4240
|
-
return n ? /* @__PURE__ */
|
|
4270
|
+
return n ? /* @__PURE__ */ B(z, { children: n({ html: i }) }) : /* @__PURE__ */ B("div", {
|
|
4241
4271
|
...r,
|
|
4242
4272
|
dangerouslySetInnerHTML: { __html: i }
|
|
4243
4273
|
});
|
|
4244
4274
|
}
|
|
4245
4275
|
//#endregion
|
|
4246
4276
|
//#region src/formatSeedJson.ts
|
|
4247
|
-
function
|
|
4277
|
+
function Mi(e, t) {
|
|
4248
4278
|
return e.length <= t ? e : `${e.slice(0, t)}…`;
|
|
4249
4279
|
}
|
|
4250
|
-
function
|
|
4280
|
+
function Ni(e) {
|
|
4251
4281
|
let t = e.trim();
|
|
4252
4282
|
return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
|
|
4253
4283
|
}
|
|
4254
|
-
function
|
|
4284
|
+
function Pi(e, t, n, r, i) {
|
|
4255
4285
|
if (typeof e == "bigint") return String(e);
|
|
4256
4286
|
if (typeof e == "symbol") return e.toString();
|
|
4257
4287
|
if (typeof e == "function") return "[Function]";
|
|
4258
4288
|
if (e instanceof Date) return e.toISOString();
|
|
4259
|
-
if (typeof e == "string") return
|
|
4289
|
+
if (typeof e == "string") return Mi(e, n);
|
|
4260
4290
|
if (typeof e != "object" || !e) return e;
|
|
4261
4291
|
if (i.has(e)) return "[Circular]";
|
|
4262
4292
|
if (r >= t) return "[Max depth]";
|
|
4263
4293
|
i.add(e);
|
|
4264
4294
|
try {
|
|
4265
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
4295
|
+
if (Array.isArray(e)) return e.map((e) => Pi(e, t, n, r + 1, i));
|
|
4266
4296
|
let a = {};
|
|
4267
|
-
for (let [o, s] of Object.entries(e)) a[o] =
|
|
4297
|
+
for (let [o, s] of Object.entries(e)) a[o] = Pi(s, t, n, r + 1, i);
|
|
4268
4298
|
return a;
|
|
4269
4299
|
} finally {
|
|
4270
4300
|
i.delete(e);
|
|
4271
4301
|
}
|
|
4272
4302
|
}
|
|
4273
|
-
function
|
|
4303
|
+
function Fi(e, t) {
|
|
4274
4304
|
let n = t?.maxDepth ?? 6, r = t?.maxStringLength ?? 5e4, i = t?.space ?? 2;
|
|
4275
4305
|
if (e === void 0) return "undefined";
|
|
4276
4306
|
if (e === null) return "null";
|
|
4277
4307
|
let a = e;
|
|
4278
4308
|
if (typeof e == "string") {
|
|
4279
|
-
if (
|
|
4309
|
+
if (Ni(e)) try {
|
|
4280
4310
|
a = JSON.parse(e);
|
|
4281
4311
|
} catch {
|
|
4282
|
-
return
|
|
4312
|
+
return Mi(e, r);
|
|
4283
4313
|
}
|
|
4284
|
-
else return
|
|
4314
|
+
else return Mi(e, r);
|
|
4285
4315
|
}
|
|
4286
|
-
let o =
|
|
4316
|
+
let o = Pi(a, n, r, 0, /* @__PURE__ */ new WeakSet());
|
|
4287
4317
|
try {
|
|
4288
4318
|
return JSON.stringify(o, null, i);
|
|
4289
4319
|
} catch {
|
|
@@ -4292,19 +4322,19 @@ function Di(e, t) {
|
|
|
4292
4322
|
}
|
|
4293
4323
|
//#endregion
|
|
4294
4324
|
//#region src/SeedJson.tsx
|
|
4295
|
-
function
|
|
4296
|
-
let a = t ? t(e) :
|
|
4297
|
-
return r ? /* @__PURE__ */
|
|
4325
|
+
function Ii({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
4326
|
+
let a = t ? t(e) : Fi(e, n);
|
|
4327
|
+
return r ? /* @__PURE__ */ B(z, { children: r({ text: a }) }) : /* @__PURE__ */ B("pre", {
|
|
4298
4328
|
...i,
|
|
4299
4329
|
children: a
|
|
4300
4330
|
});
|
|
4301
4331
|
}
|
|
4302
4332
|
//#endregion
|
|
4303
4333
|
//#region src/useNormalizedFeedItemFields.ts
|
|
4304
|
-
function
|
|
4334
|
+
function Li(e, t) {
|
|
4305
4335
|
return o(() => e ? P(e, t) : {}, [e, t]);
|
|
4306
4336
|
}
|
|
4307
4337
|
//#endregion
|
|
4308
|
-
export {
|
|
4338
|
+
export { je as ADDRESSES_PERSISTED_EVENT, hn as FILES_QUERY_KEY_PREFIX, Me as LOCAL_COPIES_REMOVED_EVENT, mi as OPFSFilesManager, Jr as OPFS_FILES_MANAGER_CSS, An as SeedClientGate, ji as SeedHtml, Si as SeedImage, Ii as SeedJson, Oi as SeedMediaAudio, Di as SeedMediaFile, wi as SeedMediaImage, ki as SeedMediaVideo, Dn as SeedProvider, Ue as createSeedQueryClient, Fi as formatSeedJson, st as getItemPropertyQueryKey, Je as getItemQueryKey, Tt as getPercentComplete, Ve as getSeedQueryDefaultOptions, xt as getServiceName, Ct as getServiceUniqueKey, St as getServiceValue, wn as invalidateItemPropertiesForItem, _t as isDbReadyState, He as mergeSeedQueryDefaults, Wt as useAllSchemaVersions, K as useClientSelector, Ae as useClientService, tt as useCreateItem, mt as useCreateItemProperty, Qt as useCreateModel, un as useCreateModelProperty, Ht as useCreateSchema, vt as useDbsAreReady, lt as useDebouncedItemProperty, fn as useDeleteItem, ht as useDestroyItemProperty, $t as useDestroyModel, dn as useDestroyModelProperty, Ut as useDestroySchema, Sn as useEasSyncProcessById, bn as useEasSyncProcesses, xn as useEasSyncProcessesNonActiveCount, yn as useEasSyncProcessesState, gi as useEnsureLocalImage, gn as useFiles, Mt as useGlobalServiceStatus, kt as useHasSavedSnapshots, mn as useImageFiles, q as useIsClientReady, Dt as useIsDbReady, Ye as useItem, pt as useItemProperties, ct as useItemProperty, et as useItems, Y as useLiveQuery, ze as useLiveQueryState, Zt as useModel, rn as useModelProperties, ln as useModelProperty, Xt as useModels, Li as useNormalizedFeedItemFields, Gn as useOPFSFiles, Ot as usePersistedSnapshots, nt as usePublishItem, Ci as useResolvedMediaRef, It as useSchema, Vt as useSchemas, Pe as useSeedAddressRevision, Gt as useSeedProtocolSchema, Et as useService, jt as useServices, Xr as useStorageEstimate, Nr as useThumbnail };
|
|
4309
4339
|
|
|
4310
4340
|
//# sourceMappingURL=index.js.map
|