@seedprotocol/react 0.7.3-next.613.g79a8dfd → 0.7.4-next.711.gce2b766
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/SeedClientGate.d.ts +1 -1
- package/dist/SeedClientGate.d.ts.map +1 -1
- package/dist/SeedImage.d.ts.map +1 -1
- package/dist/index.js +659 -645
- package/dist/index.js.map +1 -1
- package/dist/item.d.ts +6 -2
- package/dist/item.d.ts.map +1 -1
- package/dist/useEnsureLocalImage.d.ts +8 -0
- package/dist/useEnsureLocalImage.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
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 } from "react";
|
|
2
2
|
import { flushSync as l } from "react-dom";
|
|
3
|
-
import { BaseArweaveClient as u, BaseDb as d, BaseFileManager as f, ClientManagerState as p, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as m, FILES_CHANGED_EVENT as h, Item as g, ItemProperty as _, Model as v, ModelProperty as y, SEED_PROTOCOL_SCHEMA_NAME as b, Schema as x, appState as S, client as C, easSyncProcesses as w, ensureImageLocal as T, eventEmitter as E, getAddressesForItemsFilter as ee,
|
|
4
|
-
import { debounce as
|
|
5
|
-
import
|
|
6
|
-
import { useSelector as
|
|
3
|
+
import { BaseArweaveClient as u, BaseDb as d, BaseFileManager as f, ClientManagerState as p, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as m, FILES_CHANGED_EVENT as h, Item as g, ItemProperty as _, Model as v, ModelProperty as y, SEED_PROTOCOL_SCHEMA_NAME as b, Schema as x, appState as S, client as C, easSyncProcesses as w, ensureImageLocal as T, eventEmitter as E, getAddressesForItemsFilter as ee, getArweaveReadBaseUrls as D, getClient as te, getPropertySchema as ne, getSchemaNameFromId as O, getVersionData as re, loadAllSchemasFromDb as ie, metadata as k, modelSchemas as A, models as j, normalizeArweaveTxIdForEnsure as ae, normalizeFeedItemFields as oe, ownedSeedsSql as se, pickLatestMetadataRowPerProperty as ce, placeholderUidSql as le, properties as ue, publisherInAddressListSql as de, resolveMediaRef as M, schemas as N, seeds as P } from "@seedprotocol/sdk";
|
|
4
|
+
import { debounce as F, orderBy as I, startCase as fe } from "lodash-es";
|
|
5
|
+
import L from "debug";
|
|
6
|
+
import { useSelector as pe } from "@xstate/react";
|
|
7
7
|
import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
|
|
8
|
-
import { QueryClient as
|
|
9
|
-
import { and as
|
|
10
|
-
import { toSnakeCase as
|
|
11
|
-
import
|
|
8
|
+
import { QueryClient as V, QueryClientContext as me, QueryClientProvider as he, useQuery as H, useQueryClient as U } from "@tanstack/react-query";
|
|
9
|
+
import { and as ge, desc as _e, eq as W, gt as G, isNotNull as ve, isNull as ye, like as be, or as K } from "drizzle-orm";
|
|
10
|
+
import { toSnakeCase as q } from "drizzle-orm/casing";
|
|
11
|
+
import xe from "pluralize";
|
|
12
12
|
//#region src/client.ts
|
|
13
|
-
var
|
|
14
|
-
let e =
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
function
|
|
18
|
-
return r(
|
|
19
|
-
}
|
|
20
|
-
function
|
|
13
|
+
var J = () => {
|
|
14
|
+
let e = te().getService();
|
|
15
|
+
return pe(e, (e) => e.value === p.IDLE);
|
|
16
|
+
}, Se = "addresses.persisted", Ce = "localCopies.removed", we = t(0);
|
|
17
|
+
function Te() {
|
|
18
|
+
return r(we);
|
|
19
|
+
}
|
|
20
|
+
function Ee({ queryClient: e, children: t }) {
|
|
21
21
|
let [r, a] = c(0), o = n(() => {
|
|
22
22
|
e.invalidateQueries({
|
|
23
23
|
queryKey: ["seed", "items"],
|
|
@@ -30,9 +30,9 @@ function Ce({ queryClient: e, children: t }) {
|
|
|
30
30
|
exact: !1
|
|
31
31
|
}), a((e) => e + 1);
|
|
32
32
|
}, [e]);
|
|
33
|
-
return i(() => (E.on(
|
|
34
|
-
E.off(
|
|
35
|
-
}), [o]), /* @__PURE__ */ z(
|
|
33
|
+
return i(() => (E.on(Se, o), E.on(Ce, o), () => {
|
|
34
|
+
E.off(Se, o), E.off(Ce, o);
|
|
35
|
+
}), [o]), /* @__PURE__ */ z(we.Provider, {
|
|
36
36
|
value: r,
|
|
37
37
|
children: t
|
|
38
38
|
});
|
|
@@ -40,7 +40,7 @@ function Ce({ queryClient: e, children: t }) {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/liveQuery.ts
|
|
42
42
|
function Y(e) {
|
|
43
|
-
let [t, n] = c(void 0), r = s(null), a =
|
|
43
|
+
let [t, n] = c(void 0), r = s(null), a = J(), l = o(() => {
|
|
44
44
|
if (!a || !e) return null;
|
|
45
45
|
try {
|
|
46
46
|
return d.liveQuery(e);
|
|
@@ -65,16 +65,16 @@ function Y(e) {
|
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/queryClient.ts
|
|
68
|
-
var
|
|
68
|
+
var De = { queries: {
|
|
69
69
|
networkMode: "offlineFirst",
|
|
70
70
|
gcTime: 864e5,
|
|
71
71
|
staleTime: 6e4
|
|
72
72
|
} };
|
|
73
|
-
function
|
|
74
|
-
return { ...
|
|
73
|
+
function Oe() {
|
|
74
|
+
return { ...De };
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
let t =
|
|
76
|
+
function ke(e) {
|
|
77
|
+
let t = Oe();
|
|
78
78
|
return e ? {
|
|
79
79
|
queries: {
|
|
80
80
|
...t.queries,
|
|
@@ -86,25 +86,25 @@ function Ee(e) {
|
|
|
86
86
|
}
|
|
87
87
|
} : t;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
91
|
-
return new
|
|
89
|
+
function X(e) {
|
|
90
|
+
let t = Oe(), { defaultOptions: n, ...r } = e ?? {};
|
|
91
|
+
return new V({
|
|
92
92
|
...r,
|
|
93
|
-
defaultOptions: n ?
|
|
93
|
+
defaultOptions: n ? ke(n) : t
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
var
|
|
97
|
-
function
|
|
98
|
-
return r(
|
|
96
|
+
var Ae;
|
|
97
|
+
function je() {
|
|
98
|
+
return r(me) || (Ae ?? (Ae = X()), Ae);
|
|
99
99
|
}
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/item.ts
|
|
102
|
-
var
|
|
102
|
+
var Me = L("seedSdk:react:item"), Ne = (e) => [
|
|
103
103
|
"seed",
|
|
104
104
|
"item",
|
|
105
105
|
e ?? null
|
|
106
|
-
],
|
|
107
|
-
let r = t || n, [, a] = c(0), [, l] = c(0), [u, d] = c(!1), [f, p] = c(null), h = s(!1), _ =
|
|
106
|
+
], Pe = ({ modelName: e, seedLocalId: t, seedUid: n }) => {
|
|
107
|
+
let r = t || n, [, a] = c(0), [, l] = c(0), [u, d] = c(!1), [f, p] = c(null), h = s(!1), _ = J(), v = je(), y = o(() => Ne(r), [r]), b = s(y);
|
|
108
108
|
b.current = y;
|
|
109
109
|
let x = H({
|
|
110
110
|
queryKey: y,
|
|
@@ -115,7 +115,7 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
115
115
|
seedUid: n
|
|
116
116
|
});
|
|
117
117
|
if (i) return i;
|
|
118
|
-
|
|
118
|
+
Me("[useItem] no item found", e, r);
|
|
119
119
|
let a = v.getQueryData(y);
|
|
120
120
|
return a && a.getService().getSnapshot().status === "active" ? a : null;
|
|
121
121
|
},
|
|
@@ -166,7 +166,7 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
166
166
|
isLoading: !!r && x.isPending || u,
|
|
167
167
|
error: f ?? x.error
|
|
168
168
|
};
|
|
169
|
-
},
|
|
169
|
+
}, Fe = (e, t, n, r, i, a, o) => [
|
|
170
170
|
"seed",
|
|
171
171
|
"items",
|
|
172
172
|
e ?? null,
|
|
@@ -178,8 +178,8 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
178
178
|
modelFileId: a ?? null,
|
|
179
179
|
schemaName: o ?? null
|
|
180
180
|
}] : []
|
|
181
|
-
],
|
|
182
|
-
let u =
|
|
181
|
+
], Ie = ({ modelName: e, modelFileId: t, schemaName: n, deleted: r = !1, includeEas: a = !1, addressFilter: l }) => {
|
|
182
|
+
let u = J(), f = Te(), p = U();
|
|
183
183
|
i(() => {
|
|
184
184
|
let e = () => {
|
|
185
185
|
p.invalidateQueries({ queryKey: ["seed", "items"] });
|
|
@@ -201,7 +201,7 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
201
201
|
e = !0;
|
|
202
202
|
};
|
|
203
203
|
}, [l, f]);
|
|
204
|
-
let x = o(() =>
|
|
204
|
+
let x = o(() => Fe(e, r, a, l, f, t, n), [
|
|
205
205
|
e,
|
|
206
206
|
r,
|
|
207
207
|
a,
|
|
@@ -229,17 +229,17 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
229
229
|
let T = u ? d.getAppDb() : null, D = Y(o(() => {
|
|
230
230
|
if (!T || (l === "owned" || l === "watched") && y === null) return null;
|
|
231
231
|
let t = [];
|
|
232
|
-
a || t.push(
|
|
232
|
+
a || t.push(le(P.uid)), e && t.push(W(P.type, q(e))), l === "owned" ? t.push(se(y ?? [])) : l === "watched" && t.push(de(P.publisher, y ?? [])), r ? t.push(K(ve(P._markedForDeletion), W(P._markedForDeletion, 1))) : (t.push(K(ye(P._markedForDeletion), W(P._markedForDeletion, 0))), t.push(K(ye(P.revokedAt), W(P.revokedAt, 0))));
|
|
233
233
|
let n = re();
|
|
234
234
|
return T.with(n).select({
|
|
235
|
-
localId:
|
|
236
|
-
uid:
|
|
237
|
-
type:
|
|
238
|
-
schemaUid:
|
|
239
|
-
createdAt:
|
|
240
|
-
attestationCreatedAt:
|
|
241
|
-
_markedForDeletion:
|
|
242
|
-
}).from(
|
|
235
|
+
localId: P.localId,
|
|
236
|
+
uid: P.uid,
|
|
237
|
+
type: P.type,
|
|
238
|
+
schemaUid: P.schemaUid,
|
|
239
|
+
createdAt: P.createdAt,
|
|
240
|
+
attestationCreatedAt: P.attestationCreatedAt,
|
|
241
|
+
_markedForDeletion: P._markedForDeletion
|
|
242
|
+
}).from(P).leftJoin(n, W(P.localId, n.seedLocalId)).where(ge(G(n.versionsCount, 0), ...t)).groupBy(P.localId);
|
|
243
243
|
}, [
|
|
244
244
|
T,
|
|
245
245
|
u,
|
|
@@ -274,15 +274,15 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
274
274
|
p,
|
|
275
275
|
x
|
|
276
276
|
]), {
|
|
277
|
-
items:
|
|
277
|
+
items: I(S, [(e) => e.lastVersionPublishedAt || e.attestationCreatedAt || e.createdAt], ["desc"]),
|
|
278
278
|
isLoading: C,
|
|
279
279
|
error: w
|
|
280
280
|
};
|
|
281
|
-
},
|
|
281
|
+
}, Le = () => {
|
|
282
282
|
let [e, t] = c(!1), [r, i] = c(null), a = n(() => i(null), []);
|
|
283
283
|
return {
|
|
284
284
|
createItem: n(async (n, r) => {
|
|
285
|
-
if (e)
|
|
285
|
+
if (e) Me("[useCreateItem] [createItem] already creating item, skipping");
|
|
286
286
|
else {
|
|
287
287
|
i(null), l(() => t(!0));
|
|
288
288
|
try {
|
|
@@ -292,7 +292,7 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
292
292
|
...e
|
|
293
293
|
}) ?? void 0;
|
|
294
294
|
} catch (e) {
|
|
295
|
-
|
|
295
|
+
Me("[useCreateItem] Error creating item:", e), i(e instanceof Error ? e : Error(String(e)));
|
|
296
296
|
return;
|
|
297
297
|
} finally {
|
|
298
298
|
queueMicrotask(() => t(!1));
|
|
@@ -303,9 +303,11 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
303
303
|
error: r,
|
|
304
304
|
resetError: a
|
|
305
305
|
};
|
|
306
|
-
},
|
|
307
|
-
let [e, t] = c(null), [r, a] = c(!1), [o, l] = c(null), u = s(void 0), d = n(() => l(null), []), f = n((e) => {
|
|
308
|
-
e && (t(e), l(null), e.publish().catch(() => {
|
|
306
|
+
}, Re = () => {
|
|
307
|
+
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) => {
|
|
308
|
+
e && (t(e), l(null), e.publish(n).catch((e) => {
|
|
309
|
+
l(e instanceof Error ? e : Error(String(e)));
|
|
310
|
+
}));
|
|
309
311
|
}, []);
|
|
310
312
|
return i(() => {
|
|
311
313
|
if (!e) {
|
|
@@ -314,16 +316,9 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
314
316
|
}
|
|
315
317
|
u.current?.unsubscribe();
|
|
316
318
|
let t = e.getService(), n = t.subscribe((e) => {
|
|
317
|
-
|
|
318
|
-
a(t === "publishing");
|
|
319
|
-
let r = n?._publishError;
|
|
320
|
-
l(r ? Error(r.message) : null);
|
|
319
|
+
a(e?.value === "publishing");
|
|
321
320
|
});
|
|
322
|
-
u.current = n
|
|
323
|
-
let r = t.getSnapshot();
|
|
324
|
-
a(r?.value === "publishing");
|
|
325
|
-
let i = r?.context?._publishError;
|
|
326
|
-
return l(i ? Error(i.message) : null), () => {
|
|
321
|
+
return u.current = n, a(t.getSnapshot()?.value === "publishing"), () => {
|
|
327
322
|
u.current?.unsubscribe(), u.current = void 0;
|
|
328
323
|
};
|
|
329
324
|
}, [e]), {
|
|
@@ -332,15 +327,15 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
332
327
|
error: o,
|
|
333
328
|
resetError: d
|
|
334
329
|
};
|
|
335
|
-
},
|
|
330
|
+
}, ze = L("seedSdk:react:property"), Z = L("seedSdk:react:itemProperties"), Be = (e, t, n) => [
|
|
336
331
|
"seed",
|
|
337
332
|
"itemProperty",
|
|
338
333
|
e ?? null,
|
|
339
334
|
t ?? null,
|
|
340
335
|
n
|
|
341
336
|
];
|
|
342
|
-
function
|
|
343
|
-
let n =
|
|
337
|
+
function Ve(e, t) {
|
|
338
|
+
let n = J(), r = je(), [, 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(() => {
|
|
344
339
|
let e = p !== void 0 && p !== "" ? p : u, t = p !== void 0 && p !== "" ? void 0 : d;
|
|
345
340
|
return (e || t) && m ? {
|
|
346
341
|
type: "identifiers",
|
|
@@ -353,7 +348,7 @@ function ze(e, t) {
|
|
|
353
348
|
m,
|
|
354
349
|
u,
|
|
355
350
|
d
|
|
356
|
-
]), g = o(() =>
|
|
351
|
+
]), g = o(() => Be(h?.seedLocalId, h?.seedUid, h?.propertyName ?? ""), [h]), v = H({
|
|
357
352
|
queryKey: g,
|
|
358
353
|
queryFn: async () => {
|
|
359
354
|
if (!h) return null;
|
|
@@ -362,7 +357,7 @@ function ze(e, t) {
|
|
|
362
357
|
seedLocalId: h.seedLocalId,
|
|
363
358
|
seedUid: h.seedUid
|
|
364
359
|
});
|
|
365
|
-
return e ||
|
|
360
|
+
return e || ze(`[useItemProperty] no property found for Item.${h.seedLocalId || h.seedUid}.${h.propertyName}`), e ?? null;
|
|
366
361
|
},
|
|
367
362
|
initialData: () => h ? _.peekReady(h) : void 0,
|
|
368
363
|
staleTime: 0,
|
|
@@ -390,8 +385,8 @@ function ze(e, t) {
|
|
|
390
385
|
error: v.error
|
|
391
386
|
};
|
|
392
387
|
}
|
|
393
|
-
function
|
|
394
|
-
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 } =
|
|
388
|
+
function He(e, t = 300) {
|
|
389
|
+
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 } = Ve(o(() => r ? {
|
|
395
390
|
seedLocalId: r,
|
|
396
391
|
propertyName: l
|
|
397
392
|
} : {
|
|
@@ -403,7 +398,7 @@ function Be(e, t = 300) {
|
|
|
403
398
|
a,
|
|
404
399
|
c,
|
|
405
400
|
l
|
|
406
|
-
])), p = s(""), m = o(() =>
|
|
401
|
+
])), p = s(""), m = o(() => F((e) => {
|
|
407
402
|
e.getService().send({
|
|
408
403
|
type: "save",
|
|
409
404
|
newValue: p.current
|
|
@@ -422,7 +417,7 @@ function Be(e, t = 300) {
|
|
|
422
417
|
error: f
|
|
423
418
|
};
|
|
424
419
|
}
|
|
425
|
-
async function
|
|
420
|
+
async function Ue(e, t) {
|
|
426
421
|
if (!e && !t) return [];
|
|
427
422
|
let n = d.getAppDb();
|
|
428
423
|
if (!n) return [];
|
|
@@ -434,19 +429,19 @@ async function Ve(e, t) {
|
|
|
434
429
|
let o;
|
|
435
430
|
if (r.length > 0) {
|
|
436
431
|
let e = r[0];
|
|
437
|
-
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o =
|
|
432
|
+
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o = fe(o));
|
|
438
433
|
}
|
|
439
434
|
let s = await n.select({
|
|
440
|
-
type:
|
|
441
|
-
modelFileId:
|
|
442
|
-
}).from(
|
|
443
|
-
!o && s.length > 0 && s[0].type && (o =
|
|
435
|
+
type: P.type,
|
|
436
|
+
modelFileId: P.modelFileId
|
|
437
|
+
}).from(P).where(t ? W(P.uid, t) : W(P.localId, e)).limit(1), c = s[0]?.modelFileId ?? void 0;
|
|
438
|
+
!o && s.length > 0 && s[0].type && (o = fe(s[0].type));
|
|
444
439
|
let l = [];
|
|
445
440
|
if (o) try {
|
|
446
441
|
let { Model: e } = await import("@seedprotocol/sdk"), t = await e.resolveAsync(o, { modelFileId: c });
|
|
447
442
|
if (t?.properties) for (let e of t.properties) e.name && l.push(e.name);
|
|
448
443
|
} catch (e) {
|
|
449
|
-
|
|
444
|
+
Z(`[useItemProperties] Error getting ModelProperties for ${o}:`, e);
|
|
450
445
|
}
|
|
451
446
|
if (o && l.length > 0) {
|
|
452
447
|
let n = r.length > 0 ? r[0].seedLocalId ?? e : e, s = r.length > 0 ? r[0].seedUid ?? t : t;
|
|
@@ -460,11 +455,11 @@ async function Ve(e, t) {
|
|
|
460
455
|
}, { waitForReady: !1 });
|
|
461
456
|
t && i.push(t);
|
|
462
457
|
} catch (t) {
|
|
463
|
-
|
|
458
|
+
ze(`[useItemProperties] Error creating ItemProperty for missing property ${e}:`, t);
|
|
464
459
|
}
|
|
465
460
|
}
|
|
466
461
|
if (e || t) {
|
|
467
|
-
let a = await n.select({ createdAt:
|
|
462
|
+
let a = await n.select({ createdAt: P.createdAt }).from(P).where(t ? W(P.uid, t) : W(P.localId, e)).limit(1);
|
|
468
463
|
if (a.length > 0 && a[0].createdAt) {
|
|
469
464
|
let n = "createdAt";
|
|
470
465
|
if (!i.some((e) => e.propertyName === n) && o) try {
|
|
@@ -477,14 +472,14 @@ async function Ve(e, t) {
|
|
|
477
472
|
}, { waitForReady: !1 });
|
|
478
473
|
l && i.push(l);
|
|
479
474
|
} catch (e) {
|
|
480
|
-
|
|
475
|
+
ze("[useItemProperties] Error creating createdAt ItemProperty:", e);
|
|
481
476
|
}
|
|
482
477
|
}
|
|
483
478
|
}
|
|
484
479
|
return i;
|
|
485
480
|
}
|
|
486
|
-
function
|
|
487
|
-
let t =
|
|
481
|
+
function We(e) {
|
|
482
|
+
let t = J(), n = U(), r = s(void 0), a = o(() => typeof e == "string" ? {
|
|
488
483
|
type: "itemId",
|
|
489
484
|
itemId: e
|
|
490
485
|
} : typeof e == "object" ? {
|
|
@@ -501,42 +496,42 @@ function He(e) {
|
|
|
501
496
|
u
|
|
502
497
|
], [u]), { data: p = [], isLoading: m, error: h } = H({
|
|
503
498
|
queryKey: f,
|
|
504
|
-
queryFn: () =>
|
|
499
|
+
queryFn: () => Ue(c, l),
|
|
505
500
|
enabled: t && !!u
|
|
506
501
|
}), g = Y(o(() => {
|
|
507
|
-
if (!t || !c && !l) return
|
|
502
|
+
if (!t || !c && !l) return Z("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
508
503
|
let e = d.getAppDb();
|
|
509
|
-
if (!e) return
|
|
510
|
-
|
|
504
|
+
if (!e) return Z("[useItemProperties] Query: returning null (no db)"), null;
|
|
505
|
+
Z(`[useItemProperties] Query: creating query for seedLocalId=${c}, seedUid=${l}`);
|
|
511
506
|
let n = l ? e.select({
|
|
512
|
-
propertyName:
|
|
513
|
-
propertyValue:
|
|
514
|
-
seedLocalId:
|
|
515
|
-
seedUid:
|
|
516
|
-
modelType:
|
|
517
|
-
schemaUid:
|
|
518
|
-
createdAt:
|
|
519
|
-
attestationCreatedAt:
|
|
520
|
-
localId:
|
|
521
|
-
revokedAt:
|
|
522
|
-
}).from(
|
|
523
|
-
propertyName:
|
|
524
|
-
propertyValue:
|
|
525
|
-
seedLocalId:
|
|
526
|
-
seedUid:
|
|
527
|
-
modelType:
|
|
528
|
-
schemaUid:
|
|
529
|
-
createdAt:
|
|
530
|
-
attestationCreatedAt:
|
|
531
|
-
localId:
|
|
532
|
-
revokedAt:
|
|
533
|
-
}).from(
|
|
534
|
-
return
|
|
507
|
+
propertyName: k.propertyName,
|
|
508
|
+
propertyValue: k.propertyValue,
|
|
509
|
+
seedLocalId: k.seedLocalId,
|
|
510
|
+
seedUid: k.seedUid,
|
|
511
|
+
modelType: k.modelType,
|
|
512
|
+
schemaUid: k.schemaUid,
|
|
513
|
+
createdAt: k.createdAt,
|
|
514
|
+
attestationCreatedAt: k.attestationCreatedAt,
|
|
515
|
+
localId: k.localId,
|
|
516
|
+
revokedAt: k.revokedAt
|
|
517
|
+
}).from(k).where(ge(W(k.seedUid, l), ve(k.propertyName))) : c ? e.select({
|
|
518
|
+
propertyName: k.propertyName,
|
|
519
|
+
propertyValue: k.propertyValue,
|
|
520
|
+
seedLocalId: k.seedLocalId,
|
|
521
|
+
seedUid: k.seedUid,
|
|
522
|
+
modelType: k.modelType,
|
|
523
|
+
schemaUid: k.schemaUid,
|
|
524
|
+
createdAt: k.createdAt,
|
|
525
|
+
attestationCreatedAt: k.attestationCreatedAt,
|
|
526
|
+
localId: k.localId,
|
|
527
|
+
revokedAt: k.revokedAt
|
|
528
|
+
}).from(k).where(ge(W(k.seedLocalId, c), ve(k.propertyName))) : null;
|
|
529
|
+
return Z("[useItemProperties] Query: created query object", { queryType: l ? "seedUid" : "seedLocalId" }), n;
|
|
535
530
|
}, [
|
|
536
531
|
t,
|
|
537
532
|
c,
|
|
538
533
|
l
|
|
539
|
-
])), _ = o(() => !g || g.length === 0 ? [] :
|
|
534
|
+
])), _ = o(() => !g || g.length === 0 ? [] : ce(g), [g]);
|
|
540
535
|
return i(() => {
|
|
541
536
|
if (!t || !c && !l || _ === void 0) return;
|
|
542
537
|
let e = JSON.stringify(_.map((e) => ({
|
|
@@ -562,7 +557,7 @@ function He(e) {
|
|
|
562
557
|
error: h
|
|
563
558
|
};
|
|
564
559
|
}
|
|
565
|
-
var
|
|
560
|
+
var Ge = () => {
|
|
566
561
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
567
562
|
if (!t.propertyName || !t.seedLocalId && !t.seedUid || !t.modelName) {
|
|
568
563
|
o(/* @__PURE__ */ Error("seedLocalId or seedUid, propertyName, and modelName are required"));
|
|
@@ -591,7 +586,7 @@ var Ue = () => {
|
|
|
591
586
|
error: a,
|
|
592
587
|
resetError: l
|
|
593
588
|
};
|
|
594
|
-
},
|
|
589
|
+
}, Ke = () => {
|
|
595
590
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
596
591
|
return {
|
|
597
592
|
destroy: n(async (e) => {
|
|
@@ -612,19 +607,19 @@ var Ue = () => {
|
|
|
612
607
|
error: r,
|
|
613
608
|
resetError: n(() => i(null), [])
|
|
614
609
|
};
|
|
615
|
-
},
|
|
610
|
+
}, qe = L("seedSdk:react:services"), Je = [
|
|
616
611
|
"idle",
|
|
617
612
|
"ready",
|
|
618
613
|
"done",
|
|
619
614
|
"success",
|
|
620
615
|
"initialized"
|
|
621
|
-
],
|
|
616
|
+
], Ye = (e) => {
|
|
622
617
|
let t = "actor", n = e;
|
|
623
|
-
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t =
|
|
624
|
-
},
|
|
618
|
+
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t = Ze(e)), t;
|
|
619
|
+
}, Xe = (e) => {
|
|
625
620
|
let t;
|
|
626
|
-
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value),
|
|
627
|
-
},
|
|
621
|
+
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), Ye(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;
|
|
622
|
+
}, Ze = (e) => {
|
|
628
623
|
let t = e;
|
|
629
624
|
if (!e || !t.logic || !t.logic.config || !t._snapshot) return;
|
|
630
625
|
let n = t.logic.config;
|
|
@@ -635,21 +630,21 @@ var Ue = () => {
|
|
|
635
630
|
try {
|
|
636
631
|
i = e.getSnapshot();
|
|
637
632
|
} catch (e) {
|
|
638
|
-
return
|
|
633
|
+
return qe("Error:", e), r;
|
|
639
634
|
}
|
|
640
635
|
if (i) {
|
|
641
636
|
let e = i.context;
|
|
642
|
-
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r =
|
|
637
|
+
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r = xe(e.modelName.toLowerCase()));
|
|
643
638
|
}
|
|
644
639
|
return r;
|
|
645
|
-
},
|
|
640
|
+
}, Qe = (e) => {
|
|
646
641
|
let [t, r] = c(0), a = (e) => {
|
|
647
642
|
let t = 0, n = e;
|
|
648
643
|
if (n.logic?.states) {
|
|
649
644
|
let r = [], i = [];
|
|
650
645
|
for (let [e, t] of Object.entries(n.logic.states)) t.tags?.includes("loading") && (r.push(e), i.push(t));
|
|
651
|
-
let a = i.length, o =
|
|
652
|
-
if (o &&
|
|
646
|
+
let a = i.length, o = Xe(e);
|
|
647
|
+
if (o && Je.includes(o)) return 0;
|
|
653
648
|
o && (t = r.indexOf(o) / a * 100);
|
|
654
649
|
}
|
|
655
650
|
return t;
|
|
@@ -667,43 +662,43 @@ var Ue = () => {
|
|
|
667
662
|
let e = s();
|
|
668
663
|
return () => clearInterval(e);
|
|
669
664
|
}, []), {
|
|
670
|
-
name:
|
|
665
|
+
name: Ye(e),
|
|
671
666
|
timeElapsed: t,
|
|
672
|
-
value:
|
|
667
|
+
value: Xe(e),
|
|
673
668
|
percentComplete: a(e),
|
|
674
|
-
uniqueKey:
|
|
669
|
+
uniqueKey: Ze(e)
|
|
675
670
|
};
|
|
676
|
-
},
|
|
677
|
-
let [e, t] = c(!1), { internalStatus: n } =
|
|
671
|
+
}, $e = () => {
|
|
672
|
+
let [e, t] = c(!1), { internalStatus: n } = rt();
|
|
678
673
|
return i(() => {
|
|
679
674
|
n === "ready" && t(!0);
|
|
680
675
|
}, [n]), i(() => {
|
|
681
676
|
n === "ready" && t(!0);
|
|
682
677
|
}, []), e;
|
|
683
|
-
},
|
|
684
|
-
let [e, t] = c(!1), r =
|
|
685
|
-
for (let e of a)
|
|
678
|
+
}, et = () => {
|
|
679
|
+
let [e, t] = c(!1), r = tt(), { services: a, percentComplete: o } = nt(), s = n(async () => {
|
|
680
|
+
for (let e of a) qe(`would save to db with snapshot__${Ze(e)}:`, JSON.stringify(e.getPersistedSnapshot()));
|
|
686
681
|
}, [a]), l = n(async () => {
|
|
687
682
|
let e = d.getAppDb();
|
|
688
|
-
return e ? await e.select().from(S).where(
|
|
683
|
+
return e ? await e.select().from(S).where(be(S.key, "snapshot__%")) : [];
|
|
689
684
|
}, []);
|
|
690
685
|
i(() => !r || e ? void 0 : ((async () => {
|
|
691
|
-
|
|
686
|
+
qe("persistedSnapshots:", await l()), t(!0);
|
|
692
687
|
})(), () => {
|
|
693
688
|
s();
|
|
694
689
|
}), [r, e]);
|
|
695
|
-
},
|
|
696
|
-
let [e, t] = c(!1), n =
|
|
690
|
+
}, tt = () => {
|
|
691
|
+
let [e, t] = c(!1), n = $e();
|
|
697
692
|
return i(() => {
|
|
698
693
|
n && (async () => {
|
|
699
|
-
let e = await d.getAppDb().select().from(S).where(
|
|
694
|
+
let e = await d.getAppDb().select().from(S).where(be(S.key, "snapshot__%"));
|
|
700
695
|
e && e.length > 0 && t(!0);
|
|
701
696
|
})();
|
|
702
697
|
}, [n]), e;
|
|
703
|
-
},
|
|
698
|
+
}, nt = () => {
|
|
704
699
|
let [e, t] = c([]), [n, r] = c(5);
|
|
705
700
|
return i(() => {
|
|
706
|
-
let e =
|
|
701
|
+
let e = te().getService(), n = e;
|
|
707
702
|
n.uniqueKey = "clientManager", t([n]);
|
|
708
703
|
let i = e.subscribe((e) => {
|
|
709
704
|
let t = e.value, n = 0;
|
|
@@ -716,11 +711,11 @@ var Ue = () => {
|
|
|
716
711
|
services: e,
|
|
717
712
|
percentComplete: n
|
|
718
713
|
};
|
|
719
|
-
},
|
|
720
|
-
let e =
|
|
714
|
+
}, rt = () => {
|
|
715
|
+
let e = te().getService();
|
|
721
716
|
return {
|
|
722
|
-
status:
|
|
723
|
-
internalStatus:
|
|
717
|
+
status: pe(e, (e) => e.value),
|
|
718
|
+
internalStatus: pe(e, (e) => {
|
|
724
719
|
let t = e.value;
|
|
725
720
|
return t === p.DB_INIT || t === p.SAVE_CONFIG || t === p.PROCESS_SCHEMA_FILES || t === p.ADD_MODELS_TO_STORE || t === p.ADD_MODELS_TO_DB || t === p.IDLE ? "ready" : t;
|
|
726
721
|
})
|
|
@@ -728,15 +723,15 @@ var Ue = () => {
|
|
|
728
723
|
};
|
|
729
724
|
//#endregion
|
|
730
725
|
//#region src/db.ts
|
|
731
|
-
|
|
732
|
-
var
|
|
726
|
+
L("seedSdk:react:db");
|
|
727
|
+
var it = () => {
|
|
733
728
|
let [e, t] = c(!1), r = n(() => {
|
|
734
729
|
e || t(!0);
|
|
735
730
|
}, []);
|
|
736
731
|
return i(() => {
|
|
737
732
|
let e;
|
|
738
733
|
return (async () => {
|
|
739
|
-
let t =
|
|
734
|
+
let t = te().getService(), n = t.getSnapshot().value;
|
|
740
735
|
n === p.DB_INIT || n === p.SAVE_CONFIG || n === p.PROCESS_SCHEMA_FILES || n === p.ADD_MODELS_TO_STORE || n === p.ADD_MODELS_TO_DB || n === p.IDLE ? r() : e = t.subscribe((t) => {
|
|
741
736
|
let n = t.value;
|
|
742
737
|
(n === p.DB_INIT || n === p.SAVE_CONFIG || n === p.PROCESS_SCHEMA_FILES || n === p.ADD_MODELS_TO_STORE || n === p.ADD_MODELS_TO_DB || n === p.IDLE) && (r(), e?.unsubscribe());
|
|
@@ -745,8 +740,8 @@ var tt = () => {
|
|
|
745
740
|
e && e.unsubscribe();
|
|
746
741
|
};
|
|
747
742
|
}, []), { dbsAreReady: e };
|
|
748
|
-
},
|
|
749
|
-
let [t, r] = c(null), [a, o] = c(!!e), [u, d] = c(null), f = s(null), p =
|
|
743
|
+
}, at = L("seedSdk:react:schema"), ot = (e) => {
|
|
744
|
+
let [t, r] = c(null), [a, o] = c(!!e), [u, d] = c(null), f = s(null), p = J(), m = n((e) => {
|
|
750
745
|
o(!0), d(null);
|
|
751
746
|
try {
|
|
752
747
|
let t = x.create(e, { waitForReady: !1 });
|
|
@@ -756,7 +751,7 @@ var tt = () => {
|
|
|
756
751
|
e.value === "idle" ? (l(() => o(!1)), d(null)) : o(!0);
|
|
757
752
|
});
|
|
758
753
|
} catch (e) {
|
|
759
|
-
return
|
|
754
|
+
return at("[useSchema] Error creating schema:", e), d(e), r(null), o(!1), null;
|
|
760
755
|
}
|
|
761
756
|
}, []);
|
|
762
757
|
return i(() => {
|
|
@@ -774,18 +769,18 @@ var tt = () => {
|
|
|
774
769
|
isLoading: a,
|
|
775
770
|
error: u
|
|
776
771
|
};
|
|
777
|
-
},
|
|
778
|
-
let e =
|
|
779
|
-
queryKey:
|
|
772
|
+
}, st = ["seed", "schemas"], ct = () => {
|
|
773
|
+
let e = J(), t = U(), n = s(void 0), r = s([]), { data: a = [], isLoading: c, error: l } = H({
|
|
774
|
+
queryKey: st,
|
|
780
775
|
queryFn: () => x.all({ waitForReady: !0 }),
|
|
781
776
|
enabled: e
|
|
782
777
|
});
|
|
783
778
|
r.current = a;
|
|
784
|
-
let u = e ? d.getAppDb() : null, f = Y(o(() => u ? u.select().from(
|
|
779
|
+
let u = e ? d.getAppDb() : null, f = Y(o(() => u ? u.select().from(N).orderBy(N.name, _e(N.version)) : null, [u, e]));
|
|
785
780
|
return i(() => {
|
|
786
781
|
if (typeof BroadcastChannel > "u") return;
|
|
787
782
|
let e = new BroadcastChannel("seed-schemas-invalidate"), n = () => {
|
|
788
|
-
t.invalidateQueries({ queryKey:
|
|
783
|
+
t.invalidateQueries({ queryKey: st });
|
|
789
784
|
};
|
|
790
785
|
return e.addEventListener("message", n), () => {
|
|
791
786
|
e.removeEventListener("message", n), e.close();
|
|
@@ -807,7 +802,7 @@ var tt = () => {
|
|
|
807
802
|
let o = /* @__PURE__ */ new Set();
|
|
808
803
|
for (let e of f) e.name !== "Seed Protocol" && (e.schemaFileId ? o.add(e.schemaFileId) : e.name != null && e.version !== void 0 && o.add(`${e.name}:${e.version}`));
|
|
809
804
|
let s = a.size === o.size && [...a].every((e) => o.has(e)), c = a.size > 0 && o.size > 0 && [...o].some((e) => !a.has(e));
|
|
810
|
-
!s && c && t.invalidateQueries({ queryKey:
|
|
805
|
+
!s && c && t.invalidateQueries({ queryKey: st });
|
|
811
806
|
}, [
|
|
812
807
|
e,
|
|
813
808
|
f,
|
|
@@ -817,7 +812,7 @@ var tt = () => {
|
|
|
817
812
|
isLoading: c,
|
|
818
813
|
error: l
|
|
819
814
|
};
|
|
820
|
-
},
|
|
815
|
+
}, lt = () => {
|
|
821
816
|
let e = s(null), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
822
817
|
o(null), r(!0), e.current?.unsubscribe(), e.current = null;
|
|
823
818
|
let n = x.create(t, { waitForReady: !1 }), i = n.getService().subscribe((e) => {
|
|
@@ -837,7 +832,7 @@ var tt = () => {
|
|
|
837
832
|
error: a,
|
|
838
833
|
resetError: l
|
|
839
834
|
};
|
|
840
|
-
},
|
|
835
|
+
}, ut = () => {
|
|
841
836
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
842
837
|
return {
|
|
843
838
|
destroy: n(async (e) => {
|
|
@@ -858,8 +853,8 @@ var tt = () => {
|
|
|
858
853
|
error: r,
|
|
859
854
|
resetError: n(() => i(null), [])
|
|
860
855
|
};
|
|
861
|
-
},
|
|
862
|
-
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a =
|
|
856
|
+
}, dt = () => {
|
|
857
|
+
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a = J(), o = n(async () => {
|
|
863
858
|
if (a) try {
|
|
864
859
|
let e = await ie(), n = /* @__PURE__ */ new Set();
|
|
865
860
|
for (let t of e) {
|
|
@@ -877,7 +872,7 @@ var tt = () => {
|
|
|
877
872
|
for (let [e, t] of r.current.entries()) n.has(e) || t.unload();
|
|
878
873
|
r.current = i, t(Array.from(i.values()));
|
|
879
874
|
} catch (e) {
|
|
880
|
-
|
|
875
|
+
at("Error fetching all schema versions from database:", e), t(null);
|
|
881
876
|
}
|
|
882
877
|
}, [a]);
|
|
883
878
|
return i(() => {
|
|
@@ -887,12 +882,12 @@ var tt = () => {
|
|
|
887
882
|
e.unload();
|
|
888
883
|
}), r.current.clear();
|
|
889
884
|
}, []), e;
|
|
890
|
-
},
|
|
885
|
+
}, ft = () => ot(b), pt = (e) => [
|
|
891
886
|
"seed",
|
|
892
887
|
"models",
|
|
893
888
|
e
|
|
894
|
-
],
|
|
895
|
-
let t =
|
|
889
|
+
], mt = /* @__PURE__ */ new Map(), ht = (e) => {
|
|
890
|
+
let t = J(), n = U(), r = s([]), a = o(() => pt(e), [e]), { data: c = [], isLoading: l, error: u } = H({
|
|
896
891
|
queryKey: a,
|
|
897
892
|
queryFn: async () => {
|
|
898
893
|
let t = n.getQueryData(a), r = await v.all(e, { waitForReady: !1 });
|
|
@@ -905,8 +900,8 @@ var tt = () => {
|
|
|
905
900
|
},
|
|
906
901
|
enabled: t && !!e
|
|
907
902
|
}), f = e && typeof e == "string" ? e : "";
|
|
908
|
-
c.length > 0 &&
|
|
909
|
-
let p = r.current.length > 0 ? r.current :
|
|
903
|
+
c.length > 0 && mt.set(f, c);
|
|
904
|
+
let p = r.current.length > 0 ? r.current : mt.get(f), m = e ? c.length > 0 ? c : p?.length ? p : c : c;
|
|
910
905
|
r.current = m, i(() => {
|
|
911
906
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
912
907
|
let t = new BroadcastChannel("seed-models-invalidate"), r = (t) => {
|
|
@@ -925,9 +920,9 @@ var tt = () => {
|
|
|
925
920
|
function _() {
|
|
926
921
|
let t = d.getAppDb();
|
|
927
922
|
return !t || !e ? null : t.select({
|
|
928
|
-
modelFileId:
|
|
929
|
-
modelName:
|
|
930
|
-
}).from(
|
|
923
|
+
modelFileId: j.schemaFileId,
|
|
924
|
+
modelName: j.name
|
|
925
|
+
}).from(N).innerJoin(A, W(N.id, A.schemaId)).innerJoin(j, W(A.modelId, j.id)).where(K(W(N.schemaFileId, e), W(N.name, e)));
|
|
931
926
|
}
|
|
932
927
|
let y = Y(o(() => {
|
|
933
928
|
if (!e || !t) return null;
|
|
@@ -961,8 +956,8 @@ var tt = () => {
|
|
|
961
956
|
isLoading: l,
|
|
962
957
|
error: u
|
|
963
958
|
};
|
|
964
|
-
},
|
|
965
|
-
let n =
|
|
959
|
+
}, gt = (e, t) => {
|
|
960
|
+
let n = J(), [r, a] = c(void 0), [l, u] = c(!1), [d, f] = c(null), p = s(void 0), [, m] = c(0), h = t == null;
|
|
966
961
|
if (o(() => n ? h ? !!e : !!(e && t) : !1, [
|
|
967
962
|
n,
|
|
968
963
|
h,
|
|
@@ -999,7 +994,7 @@ var tt = () => {
|
|
|
999
994
|
isLoading: l,
|
|
1000
995
|
error: d
|
|
1001
996
|
};
|
|
1002
|
-
let { models: g, isLoading: _, error: y } =
|
|
997
|
+
let { models: g, isLoading: _, error: y } = ht(e), b = o(() => {
|
|
1003
998
|
if (t) return g.find((e) => (e.modelName ?? e.name) === t);
|
|
1004
999
|
}, [g, t]);
|
|
1005
1000
|
return i(() => {
|
|
@@ -1019,7 +1014,7 @@ var tt = () => {
|
|
|
1019
1014
|
isLoading: _,
|
|
1020
1015
|
error: y
|
|
1021
1016
|
};
|
|
1022
|
-
},
|
|
1017
|
+
}, _t = () => {
|
|
1023
1018
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t, n, i) => {
|
|
1024
1019
|
o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
1025
1020
|
let a = v.create(n, t, {
|
|
@@ -1038,7 +1033,7 @@ var tt = () => {
|
|
|
1038
1033
|
error: a,
|
|
1039
1034
|
resetError: l
|
|
1040
1035
|
};
|
|
1041
|
-
},
|
|
1036
|
+
}, vt = () => {
|
|
1042
1037
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1043
1038
|
return {
|
|
1044
1039
|
destroy: n(async (e) => {
|
|
@@ -1062,9 +1057,9 @@ var tt = () => {
|
|
|
1062
1057
|
};
|
|
1063
1058
|
//#endregion
|
|
1064
1059
|
//#region src/modelProperty.ts
|
|
1065
|
-
|
|
1066
|
-
var
|
|
1067
|
-
let { model: n } =
|
|
1060
|
+
L("seedSdk:browser:react:modelProperty");
|
|
1061
|
+
var yt = (e, t) => {
|
|
1062
|
+
let { model: n } = gt(e, t);
|
|
1068
1063
|
o(() => {
|
|
1069
1064
|
if (n) try {
|
|
1070
1065
|
return n.modelName ?? n.name;
|
|
@@ -1072,7 +1067,7 @@ var gt = (e, t) => {
|
|
|
1072
1067
|
return;
|
|
1073
1068
|
}
|
|
1074
1069
|
}, [n]);
|
|
1075
|
-
let r =
|
|
1070
|
+
let r = J(), a = U(), c = St(n), l = n?.id, u = o(() => [
|
|
1076
1071
|
"seed",
|
|
1077
1072
|
"modelProperties",
|
|
1078
1073
|
l ?? ""
|
|
@@ -1081,11 +1076,11 @@ var gt = (e, t) => {
|
|
|
1081
1076
|
queryFn: () => y.all(l, { waitForReady: !0 }),
|
|
1082
1077
|
enabled: r && !!l
|
|
1083
1078
|
}), h = r ? d.getAppDb() : null, g = Y(o(() => !h || !c ? null : h.select({
|
|
1084
|
-
id:
|
|
1085
|
-
name:
|
|
1086
|
-
dataType:
|
|
1087
|
-
schemaFileId:
|
|
1088
|
-
}).from(
|
|
1079
|
+
id: ue.id,
|
|
1080
|
+
name: ue.name,
|
|
1081
|
+
dataType: ue.dataType,
|
|
1082
|
+
schemaFileId: ue.schemaFileId
|
|
1083
|
+
}).from(ue).where(W(ue.modelId, c)), [
|
|
1089
1084
|
h,
|
|
1090
1085
|
r,
|
|
1091
1086
|
c
|
|
@@ -1126,38 +1121,38 @@ var gt = (e, t) => {
|
|
|
1126
1121
|
isLoading: p && f.length === 0,
|
|
1127
1122
|
error: m
|
|
1128
1123
|
};
|
|
1129
|
-
},
|
|
1124
|
+
}, bt = [
|
|
1130
1125
|
400,
|
|
1131
1126
|
1200,
|
|
1132
1127
|
2500
|
|
1133
|
-
],
|
|
1128
|
+
], xt = (e) => {
|
|
1134
1129
|
if (e) try {
|
|
1135
1130
|
return e._getSnapshotContext()._dbId;
|
|
1136
1131
|
} catch {
|
|
1137
1132
|
return;
|
|
1138
1133
|
}
|
|
1139
|
-
},
|
|
1140
|
-
let [t, n] = c(() =>
|
|
1134
|
+
}, St = (e) => {
|
|
1135
|
+
let [t, n] = c(() => xt(e));
|
|
1141
1136
|
return i(() => {
|
|
1142
|
-
if (n(
|
|
1143
|
-
let t = e.getService().subscribe(() => n(
|
|
1137
|
+
if (n(xt(e)), !e) return;
|
|
1138
|
+
let t = e.getService().subscribe(() => n(xt(e)));
|
|
1144
1139
|
return () => t.unsubscribe();
|
|
1145
1140
|
}, [e]), t;
|
|
1146
|
-
},
|
|
1141
|
+
}, Ct = async (e, t) => {
|
|
1147
1142
|
let n = await v.createById(e);
|
|
1148
1143
|
if (!n) return;
|
|
1149
1144
|
let r = n.modelName ?? n.name;
|
|
1150
|
-
if (r) return
|
|
1145
|
+
if (r) return ne(r, t, {
|
|
1151
1146
|
modelFileId: e,
|
|
1152
1147
|
schemaName: n.schemaName
|
|
1153
1148
|
});
|
|
1154
1149
|
};
|
|
1155
|
-
function
|
|
1150
|
+
function wt(e, t, r) {
|
|
1156
1151
|
let a = o(() => r == null ? t == null ? !!e : !!(e && t) : !!(e && t && r), [
|
|
1157
1152
|
e,
|
|
1158
1153
|
t,
|
|
1159
1154
|
r
|
|
1160
|
-
]), [u, d] = c(void 0), [f, p] = c(a), [m, h] = c(null), g = s(void 0), _ =
|
|
1155
|
+
]), [u, d] = c(void 0), [f, p] = c(a), [m, h] = c(null), g = s(void 0), _ = J(), b = o(() => r == null ? t == null ? {
|
|
1161
1156
|
type: "propertyFileId",
|
|
1162
1157
|
propertyFileId: e
|
|
1163
1158
|
} : {
|
|
@@ -1194,7 +1189,7 @@ function xt(e, t, r) {
|
|
|
1194
1189
|
d(void 0), p(!1), h(null);
|
|
1195
1190
|
return;
|
|
1196
1191
|
}
|
|
1197
|
-
t = await
|
|
1192
|
+
t = await Ct(b.modelFileId, b.propertyName);
|
|
1198
1193
|
let e = await v.createById(b.modelFileId);
|
|
1199
1194
|
n = e?.modelName ?? e?.name;
|
|
1200
1195
|
} else {
|
|
@@ -1202,8 +1197,8 @@ function xt(e, t, r) {
|
|
|
1202
1197
|
d(void 0), p(!1), h(null);
|
|
1203
1198
|
return;
|
|
1204
1199
|
}
|
|
1205
|
-
let e = await
|
|
1206
|
-
t = await
|
|
1200
|
+
let e = await O(b.schemaId) ?? b.schemaId;
|
|
1201
|
+
t = await ne(b.modelName, b.propertyName, { schemaName: e }), n = b.modelName;
|
|
1207
1202
|
}
|
|
1208
1203
|
if (t && n) {
|
|
1209
1204
|
let e = y.create({
|
|
@@ -1232,7 +1227,7 @@ function xt(e, t, r) {
|
|
|
1232
1227
|
let C = s(!1);
|
|
1233
1228
|
C.current = f || !!u || !!m, i(() => {
|
|
1234
1229
|
if (!x || b.type === "propertyFileId") return;
|
|
1235
|
-
let e =
|
|
1230
|
+
let e = bt.map((e) => setTimeout(() => {
|
|
1236
1231
|
C.current || S({ quiet: !0 });
|
|
1237
1232
|
}, e));
|
|
1238
1233
|
return () => e.forEach((e) => clearTimeout(e));
|
|
@@ -1245,7 +1240,7 @@ function xt(e, t, r) {
|
|
|
1245
1240
|
return i(() => {
|
|
1246
1241
|
if (!u || !w) return;
|
|
1247
1242
|
g.current?.unsubscribe();
|
|
1248
|
-
let e =
|
|
1243
|
+
let e = F(S, 100), t = u.getService().subscribe(() => {
|
|
1249
1244
|
e();
|
|
1250
1245
|
});
|
|
1251
1246
|
return g.current = t, () => {
|
|
@@ -1261,13 +1256,13 @@ function xt(e, t, r) {
|
|
|
1261
1256
|
error: m
|
|
1262
1257
|
};
|
|
1263
1258
|
}
|
|
1264
|
-
var
|
|
1259
|
+
var Tt = () => {
|
|
1265
1260
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t, n, i) => {
|
|
1266
1261
|
if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !n || !i.name || !i.dataType) {
|
|
1267
1262
|
let e = /* @__PURE__ */ Error("modelName, property name and dataType are required");
|
|
1268
1263
|
throw o(e), r(!1), e;
|
|
1269
1264
|
}
|
|
1270
|
-
let a =
|
|
1265
|
+
let a = O(t) ?? t, s = y.create({
|
|
1271
1266
|
...i,
|
|
1272
1267
|
modelName: n
|
|
1273
1268
|
}, {
|
|
@@ -1290,7 +1285,7 @@ var St = () => {
|
|
|
1290
1285
|
error: a,
|
|
1291
1286
|
resetError: l
|
|
1292
1287
|
};
|
|
1293
|
-
},
|
|
1288
|
+
}, Et = () => {
|
|
1294
1289
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1295
1290
|
return {
|
|
1296
1291
|
destroy: n(async (e) => {
|
|
@@ -1311,7 +1306,7 @@ var St = () => {
|
|
|
1311
1306
|
error: r,
|
|
1312
1307
|
resetError: n(() => i(null), [])
|
|
1313
1308
|
};
|
|
1314
|
-
},
|
|
1309
|
+
}, Dt = () => {
|
|
1315
1310
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1316
1311
|
return {
|
|
1317
1312
|
deleteItem: n(async (e) => {
|
|
@@ -1332,20 +1327,20 @@ var St = () => {
|
|
|
1332
1327
|
error: r,
|
|
1333
1328
|
resetError: n(() => i(null), [])
|
|
1334
1329
|
};
|
|
1335
|
-
},
|
|
1336
|
-
function
|
|
1337
|
-
let e =
|
|
1338
|
-
queryKey:
|
|
1330
|
+
}, Ot = ["seed", "imageFiles"];
|
|
1331
|
+
function kt() {
|
|
1332
|
+
let e = J(), t = U(), { data: n = [], isLoading: r, error: a, refetch: o } = H({
|
|
1333
|
+
queryKey: Ot,
|
|
1339
1334
|
queryFn: () => f.listImageFiles(),
|
|
1340
1335
|
enabled: e
|
|
1341
1336
|
});
|
|
1342
1337
|
return i(() => {
|
|
1343
1338
|
let e = (e) => {
|
|
1344
|
-
e.includes("/images/") && t.invalidateQueries({ queryKey:
|
|
1339
|
+
e.includes("/images/") && t.invalidateQueries({ queryKey: Ot });
|
|
1345
1340
|
}, n = () => {
|
|
1346
|
-
t.invalidateQueries({ queryKey:
|
|
1341
|
+
t.invalidateQueries({ queryKey: Ot });
|
|
1347
1342
|
}, r = (e) => {
|
|
1348
|
-
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey:
|
|
1343
|
+
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey: Ot });
|
|
1349
1344
|
};
|
|
1350
1345
|
return E.on("file-saved", e), E.on("fs.downloadAll.success", n), E.on(h, r), () => {
|
|
1351
1346
|
E.off("file-saved", e), E.off("fs.downloadAll.success", n), E.off(h, r);
|
|
@@ -1359,9 +1354,9 @@ function Et() {
|
|
|
1359
1354
|
}
|
|
1360
1355
|
//#endregion
|
|
1361
1356
|
//#region src/useFiles.ts
|
|
1362
|
-
var
|
|
1363
|
-
function
|
|
1364
|
-
let t =
|
|
1357
|
+
var At = ["seed", "files"];
|
|
1358
|
+
function jt(e = "files") {
|
|
1359
|
+
let t = J(), n = U(), r = o(() => [...At, e], [e]), { data: a = [], isLoading: s, error: c, refetch: l } = H({
|
|
1365
1360
|
queryKey: r,
|
|
1366
1361
|
queryFn: () => f.listFiles(e),
|
|
1367
1362
|
enabled: t
|
|
@@ -1390,24 +1385,24 @@ function Ot(e = "files") {
|
|
|
1390
1385
|
}
|
|
1391
1386
|
//#endregion
|
|
1392
1387
|
//#region src/useEasSyncProcesses.ts
|
|
1393
|
-
function
|
|
1388
|
+
function Mt() {
|
|
1394
1389
|
let e = d.getAppDb();
|
|
1395
|
-
return o(() => e ? e.select().from(w).orderBy(
|
|
1390
|
+
return o(() => e ? e.select().from(w).orderBy(_e(w.startedAt)) : null, [e]);
|
|
1396
1391
|
}
|
|
1397
|
-
function
|
|
1398
|
-
let e = Y(
|
|
1392
|
+
function Nt() {
|
|
1393
|
+
let e = Y(Mt());
|
|
1399
1394
|
return {
|
|
1400
1395
|
records: e,
|
|
1401
1396
|
nonActiveCount: o(() => e === void 0 ? void 0 : e.filter((e) => e.status !== "in_progress").length, [e])
|
|
1402
1397
|
};
|
|
1403
1398
|
}
|
|
1404
|
-
function
|
|
1405
|
-
return Y(
|
|
1399
|
+
function Pt() {
|
|
1400
|
+
return Y(Mt());
|
|
1406
1401
|
}
|
|
1407
|
-
function
|
|
1408
|
-
return
|
|
1402
|
+
function Ft() {
|
|
1403
|
+
return Nt().nonActiveCount;
|
|
1409
1404
|
}
|
|
1410
|
-
function
|
|
1405
|
+
function It(e) {
|
|
1411
1406
|
let t = d.getAppDb(), n = Y(o(() => e != null && t ? t.select().from(w).where(W(w.id, e)).limit(1) : null, [t, e])), r = n === void 0;
|
|
1412
1407
|
return {
|
|
1413
1408
|
record: n && n.length > 0 ? n[0] : null,
|
|
@@ -1416,12 +1411,12 @@ function Nt(e) {
|
|
|
1416
1411
|
}
|
|
1417
1412
|
//#endregion
|
|
1418
1413
|
//#region src/SeedProvider.tsx
|
|
1419
|
-
var
|
|
1420
|
-
function
|
|
1421
|
-
let t =
|
|
1414
|
+
var Lt = null;
|
|
1415
|
+
function Rt(e) {
|
|
1416
|
+
let t = Lt?.(e);
|
|
1422
1417
|
return typeof window < "u" && window.__SEED_INVALIDATE_ITEM_PROPERTIES__ && window.__SEED_INVALIDATE_ITEM_PROPERTIES__(e), Promise.resolve(t).then(() => {});
|
|
1423
1418
|
}
|
|
1424
|
-
function
|
|
1419
|
+
function zt({ queryClient: e }) {
|
|
1425
1420
|
return i(() => {
|
|
1426
1421
|
let t = (t) => {
|
|
1427
1422
|
let n = [
|
|
@@ -1431,7 +1426,7 @@ function It({ queryClient: e }) {
|
|
|
1431
1426
|
];
|
|
1432
1427
|
return e.invalidateQueries({ queryKey: n }), e.refetchQueries({ queryKey: n });
|
|
1433
1428
|
};
|
|
1434
|
-
|
|
1429
|
+
Lt = t, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = t);
|
|
1435
1430
|
let n = (e) => {
|
|
1436
1431
|
let n = e?.seedLocalId ?? e?.seedUid;
|
|
1437
1432
|
n && t(n);
|
|
@@ -1442,12 +1437,12 @@ function It({ queryClient: e }) {
|
|
|
1442
1437
|
});
|
|
1443
1438
|
};
|
|
1444
1439
|
return E.on("itemProperty.saved", n), E.on(m, r), () => {
|
|
1445
|
-
E.off("itemProperty.saved", n), E.off(m, r),
|
|
1440
|
+
E.off("itemProperty.saved", n), E.off(m, r), Lt = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
|
|
1446
1441
|
};
|
|
1447
1442
|
}, [e]), null;
|
|
1448
1443
|
}
|
|
1449
|
-
function
|
|
1450
|
-
let r = o(() => t ??
|
|
1444
|
+
function Bt({ children: e, queryClient: t, queryClientRef: n }) {
|
|
1445
|
+
let r = o(() => t ?? X(), [t]);
|
|
1451
1446
|
if (n && (n.current = r, typeof window < "u")) {
|
|
1452
1447
|
let e = window;
|
|
1453
1448
|
e.__TEST_SEED_QUERY_CLIENT__ = r;
|
|
@@ -1455,17 +1450,17 @@ function Lt({ children: e, queryClient: t, queryClientRef: n }) {
|
|
|
1455
1450
|
window.parent && window.parent !== window && (window.parent.__TEST_SEED_QUERY_CLIENT__ = r);
|
|
1456
1451
|
} catch {}
|
|
1457
1452
|
}
|
|
1458
|
-
return /* @__PURE__ */ z(
|
|
1453
|
+
return /* @__PURE__ */ z(he, {
|
|
1459
1454
|
client: r,
|
|
1460
|
-
children: /* @__PURE__ */ B(
|
|
1455
|
+
children: /* @__PURE__ */ B(Ee, {
|
|
1461
1456
|
queryClient: r,
|
|
1462
|
-
children: [/* @__PURE__ */ z(
|
|
1457
|
+
children: [/* @__PURE__ */ z(zt, { queryClient: r }), e]
|
|
1463
1458
|
})
|
|
1464
1459
|
});
|
|
1465
1460
|
}
|
|
1466
1461
|
//#endregion
|
|
1467
1462
|
//#region src/SeedClientGate.tsx
|
|
1468
|
-
function
|
|
1463
|
+
function Vt() {
|
|
1469
1464
|
return /* @__PURE__ */ z("div", {
|
|
1470
1465
|
style: {
|
|
1471
1466
|
display: "flex",
|
|
@@ -1477,8 +1472,8 @@ function Rt() {
|
|
|
1477
1472
|
children: "Loading..."
|
|
1478
1473
|
});
|
|
1479
1474
|
}
|
|
1480
|
-
function
|
|
1481
|
-
let l =
|
|
1475
|
+
function Ht({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r, loadingClassName: a, onInitError: o, children: c }) {
|
|
1476
|
+
let l = J(), u = s(o);
|
|
1482
1477
|
u.current = o, i(() => {
|
|
1483
1478
|
let n = t ? {
|
|
1484
1479
|
...e,
|
|
@@ -1491,7 +1486,7 @@ function zt({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1491
1486
|
u.current ? u.current(e) : console.error("[SeedClientGate] client init failed", e);
|
|
1492
1487
|
});
|
|
1493
1488
|
}, [e, t]);
|
|
1494
|
-
let d = n ?? /* @__PURE__ */ z(
|
|
1489
|
+
let d = n ?? /* @__PURE__ */ z(Vt, {}), f = r ? void 0 : {
|
|
1495
1490
|
position: "relative",
|
|
1496
1491
|
display: "flex",
|
|
1497
1492
|
height: "100vh",
|
|
@@ -1526,54 +1521,54 @@ function zt({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1526
1521
|
}
|
|
1527
1522
|
//#endregion
|
|
1528
1523
|
//#region src/opfsPaths.ts
|
|
1529
|
-
function
|
|
1524
|
+
function Ut(e) {
|
|
1530
1525
|
let t = e.split("/").filter(Boolean);
|
|
1531
1526
|
if (t.length === 0) throw Error(`Invalid OPFS path: "${e}"`);
|
|
1532
1527
|
return t;
|
|
1533
1528
|
}
|
|
1534
|
-
async function
|
|
1529
|
+
async function Wt(e, t) {
|
|
1535
1530
|
let n = t ?? await navigator.storage.getDirectory();
|
|
1536
1531
|
for (let t of e.split("/").filter(Boolean)) n = await n.getDirectoryHandle(t);
|
|
1537
1532
|
return n;
|
|
1538
1533
|
}
|
|
1539
|
-
async function
|
|
1540
|
-
let n =
|
|
1534
|
+
async function Gt(e, t) {
|
|
1535
|
+
let n = Ut(e), r = n.pop();
|
|
1541
1536
|
return {
|
|
1542
|
-
dir: await
|
|
1537
|
+
dir: await Wt(n.join("/"), t),
|
|
1543
1538
|
name: r
|
|
1544
1539
|
};
|
|
1545
1540
|
}
|
|
1546
|
-
async function
|
|
1547
|
-
let { dir: n, name: r } = await
|
|
1541
|
+
async function Kt(e, t) {
|
|
1542
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1548
1543
|
return n.getFileHandle(r);
|
|
1549
1544
|
}
|
|
1550
|
-
async function
|
|
1551
|
-
return (await
|
|
1545
|
+
async function qt(e, t) {
|
|
1546
|
+
return (await Kt(e, t)).getFile();
|
|
1552
1547
|
}
|
|
1553
|
-
async function
|
|
1554
|
-
let { dir: n, name: r } = await
|
|
1548
|
+
async function Jt(e, t) {
|
|
1549
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1555
1550
|
await n.removeEntry(r);
|
|
1556
1551
|
}
|
|
1557
|
-
async function
|
|
1552
|
+
async function Yt(e, t) {
|
|
1558
1553
|
let n = await e.getDirectoryHandle(t), r = [];
|
|
1559
1554
|
for await (let e of n.entries()) r.push(e);
|
|
1560
1555
|
let i = !0;
|
|
1561
|
-
for (let [e, t] of r) (t.kind === "file" || !await
|
|
1556
|
+
for (let [e, t] of r) (t.kind === "file" || !await Yt(n, e)) && (i = !1);
|
|
1562
1557
|
return i && await e.removeEntry(t), i;
|
|
1563
1558
|
}
|
|
1564
|
-
async function
|
|
1559
|
+
async function Xt(e, t) {
|
|
1565
1560
|
try {
|
|
1566
|
-
let { dir: n, name: r } = await
|
|
1567
|
-
return await
|
|
1561
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1562
|
+
return await Yt(n, r);
|
|
1568
1563
|
} catch (e) {
|
|
1569
1564
|
if (e instanceof DOMException && e.name === "NotFoundError") return !0;
|
|
1570
1565
|
throw e;
|
|
1571
1566
|
}
|
|
1572
1567
|
}
|
|
1573
|
-
function
|
|
1568
|
+
function Zt() {
|
|
1574
1569
|
return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
|
|
1575
1570
|
}
|
|
1576
|
-
var
|
|
1571
|
+
var Qt = [
|
|
1577
1572
|
{
|
|
1578
1573
|
type: "image/jpeg",
|
|
1579
1574
|
test: (e) => e[0] === 255 && e[1] === 216 && e[2] === 255
|
|
@@ -1584,43 +1579,43 @@ var Yt = [
|
|
|
1584
1579
|
},
|
|
1585
1580
|
{
|
|
1586
1581
|
type: "image/gif",
|
|
1587
|
-
test: (e) =>
|
|
1582
|
+
test: (e) => $t(e, 0, 4) === "GIF8"
|
|
1588
1583
|
},
|
|
1589
1584
|
{
|
|
1590
1585
|
type: "image/webp",
|
|
1591
|
-
test: (e) =>
|
|
1586
|
+
test: (e) => $t(e, 0, 4) === "RIFF" && $t(e, 8, 12) === "WEBP"
|
|
1592
1587
|
},
|
|
1593
1588
|
{
|
|
1594
1589
|
type: "image/avif",
|
|
1595
|
-
test: (e) =>
|
|
1590
|
+
test: (e) => $t(e, 4, 8) === "ftyp" && ["avif", "avis"].includes($t(e, 8, 12))
|
|
1596
1591
|
},
|
|
1597
1592
|
{
|
|
1598
1593
|
type: "application/vnd.sqlite3",
|
|
1599
|
-
test: (e) =>
|
|
1594
|
+
test: (e) => $t(e, 0, 15) === "SQLite format 3"
|
|
1600
1595
|
},
|
|
1601
1596
|
{
|
|
1602
1597
|
type: "application/pdf",
|
|
1603
|
-
test: (e) =>
|
|
1598
|
+
test: (e) => $t(e, 0, 5) === "%PDF-"
|
|
1604
1599
|
}
|
|
1605
1600
|
];
|
|
1606
|
-
function
|
|
1601
|
+
function $t(e, t, n) {
|
|
1607
1602
|
return String.fromCharCode(...e.subarray(t, n));
|
|
1608
1603
|
}
|
|
1609
|
-
function
|
|
1610
|
-
return
|
|
1604
|
+
function en(e) {
|
|
1605
|
+
return Qt.find((t) => t.test(e))?.type;
|
|
1611
1606
|
}
|
|
1612
|
-
async function
|
|
1613
|
-
if (e.size !== 0) return
|
|
1607
|
+
async function tn(e) {
|
|
1608
|
+
if (e.size !== 0) return en(new Uint8Array(await e.slice(0, 16).arrayBuffer()));
|
|
1614
1609
|
}
|
|
1615
1610
|
//#endregion
|
|
1616
1611
|
//#region src/useOPFSFiles.ts
|
|
1617
|
-
async function
|
|
1612
|
+
async function nn(e, t = "") {
|
|
1618
1613
|
let n = [];
|
|
1619
1614
|
try {
|
|
1620
1615
|
for await (let [r, i] of e.entries()) {
|
|
1621
1616
|
let e = t ? `${t}/${r}` : r;
|
|
1622
1617
|
if (i.kind === "file") try {
|
|
1623
|
-
let t = await i.getFile(), a = t.type ? void 0 : await
|
|
1618
|
+
let t = await i.getFile(), a = t.type ? void 0 : await tn(t).catch(() => void 0);
|
|
1624
1619
|
n.push({
|
|
1625
1620
|
name: r,
|
|
1626
1621
|
path: e,
|
|
@@ -1633,7 +1628,7 @@ async function $t(e, t = "") {
|
|
|
1633
1628
|
console.warn(`Failed to read file ${e}:`, t);
|
|
1634
1629
|
}
|
|
1635
1630
|
else if (i.kind === "directory") {
|
|
1636
|
-
let t = await
|
|
1631
|
+
let t = await nn(i, e);
|
|
1637
1632
|
n.push(...t);
|
|
1638
1633
|
}
|
|
1639
1634
|
}
|
|
@@ -1642,11 +1637,11 @@ async function $t(e, t = "") {
|
|
|
1642
1637
|
}
|
|
1643
1638
|
return n;
|
|
1644
1639
|
}
|
|
1645
|
-
function
|
|
1640
|
+
function rn(e = {}) {
|
|
1646
1641
|
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 () => {
|
|
1647
1642
|
s(!0), f(null), m(null);
|
|
1648
1643
|
try {
|
|
1649
|
-
let e = await
|
|
1644
|
+
let e = await nn(await Wt(t ?? ""), t || "");
|
|
1650
1645
|
a(e.sort((e, t) => e.path.localeCompare(t.path)));
|
|
1651
1646
|
} catch (e) {
|
|
1652
1647
|
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);
|
|
@@ -1667,7 +1662,7 @@ function en(e = {}) {
|
|
|
1667
1662
|
}
|
|
1668
1663
|
//#endregion
|
|
1669
1664
|
//#region src/OPFSFilesManager/format.ts
|
|
1670
|
-
var
|
|
1665
|
+
var an = [
|
|
1671
1666
|
"B",
|
|
1672
1667
|
"KB",
|
|
1673
1668
|
"MB",
|
|
@@ -1676,32 +1671,32 @@ var tn = [
|
|
|
1676
1671
|
];
|
|
1677
1672
|
function Q(e) {
|
|
1678
1673
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
1679
|
-
let t = Math.min(
|
|
1680
|
-
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${
|
|
1674
|
+
let t = Math.min(an.length - 1, Math.floor(Math.log(e) / Math.log(1024))), n = e / 1024 ** t;
|
|
1675
|
+
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${an[t]}`;
|
|
1681
1676
|
}
|
|
1682
|
-
var
|
|
1683
|
-
function
|
|
1677
|
+
var on = 6e4, sn = 60 * on, cn = 24 * sn;
|
|
1678
|
+
function ln(e, t = Date.now()) {
|
|
1684
1679
|
let n = t - e;
|
|
1685
|
-
if (n <
|
|
1686
|
-
if (n <
|
|
1687
|
-
if (n <
|
|
1688
|
-
let r = Math.round(n /
|
|
1680
|
+
if (n < on) return "just now";
|
|
1681
|
+
if (n < sn) return `${Math.round(n / on)} min ago`;
|
|
1682
|
+
if (n < cn) return `${Math.round(n / sn)} h ago`;
|
|
1683
|
+
let r = Math.round(n / cn);
|
|
1689
1684
|
return r === 1 ? "yesterday" : r < 30 ? `${r} days ago` : new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" });
|
|
1690
1685
|
}
|
|
1691
|
-
function
|
|
1686
|
+
function un(e) {
|
|
1692
1687
|
return new Date(e).toLocaleString(void 0, {
|
|
1693
1688
|
dateStyle: "medium",
|
|
1694
1689
|
timeStyle: "short"
|
|
1695
1690
|
});
|
|
1696
1691
|
}
|
|
1697
|
-
function
|
|
1692
|
+
function dn(e, t) {
|
|
1698
1693
|
if (e.length <= t) return e;
|
|
1699
1694
|
let n = Math.ceil((t - 1) / 2), r = Math.floor((t - 1) / 2);
|
|
1700
1695
|
return `${e.slice(0, n)}…${e.slice(e.length - r)}`;
|
|
1701
1696
|
}
|
|
1702
1697
|
//#endregion
|
|
1703
1698
|
//#region src/OPFSFilesManager/icons.tsx
|
|
1704
|
-
var
|
|
1699
|
+
var fn = {
|
|
1705
1700
|
check: /* @__PURE__ */ z("path", { d: "M20 6 9 17l-5-5" }),
|
|
1706
1701
|
chevronLeft: /* @__PURE__ */ z("path", { d: "m15 18-6-6 6-6" }),
|
|
1707
1702
|
chevronRight: /* @__PURE__ */ z("path", { d: "m9 18 6-6-6-6" }),
|
|
@@ -1886,13 +1881,13 @@ function $({ name: e, size: t = 16, strokeWidth: n = 2, className: r }) {
|
|
|
1886
1881
|
"aria-hidden": "true",
|
|
1887
1882
|
focusable: "false",
|
|
1888
1883
|
className: r,
|
|
1889
|
-
children:
|
|
1884
|
+
children: fn[e]
|
|
1890
1885
|
});
|
|
1891
1886
|
}
|
|
1892
1887
|
//#endregion
|
|
1893
1888
|
//#region src/OPFSFilesManager/DeleteDialog.tsx
|
|
1894
|
-
var
|
|
1895
|
-
function
|
|
1889
|
+
var pn = 6;
|
|
1890
|
+
function mn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
1896
1891
|
let a = s(null);
|
|
1897
1892
|
return i(() => {
|
|
1898
1893
|
let e = a.current;
|
|
@@ -1918,9 +1913,9 @@ function dn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
|
1918
1913
|
})
|
|
1919
1914
|
});
|
|
1920
1915
|
}
|
|
1921
|
-
function
|
|
1922
|
-
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 ${
|
|
1923
|
-
return /* @__PURE__ */ B(
|
|
1916
|
+
function hn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel: i, onConfirm: a, className: o }) {
|
|
1917
|
+
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 ${dn(e[0].file.name, 32)}?` : `Delete ${e.length} files?`;
|
|
1918
|
+
return /* @__PURE__ */ B(mn, {
|
|
1924
1919
|
className: o,
|
|
1925
1920
|
onCancel: i,
|
|
1926
1921
|
onSubmit: () => a(s),
|
|
@@ -1934,12 +1929,12 @@ function fn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
1934
1929
|
e.length === 1 ? "it" : "them",
|
|
1935
1930
|
" from this browser’s private storage. Copies on Arweave or other devices aren’t affected. You can’t undo this."
|
|
1936
1931
|
] }),
|
|
1937
|
-
/* @__PURE__ */ B("ul", { children: [e.slice(0,
|
|
1932
|
+
/* @__PURE__ */ B("ul", { children: [e.slice(0, pn).map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ z("code", {
|
|
1938
1933
|
title: e.file.path,
|
|
1939
1934
|
children: e.file.path.startsWith(p) ? e.file.path.slice(p.length) : e.file.path
|
|
1940
|
-
}), /* @__PURE__ */ z("span", { children: Q(e.file.size) })] }, e.file.path)), e.length >
|
|
1935
|
+
}), /* @__PURE__ */ z("span", { children: Q(e.file.size) })] }, e.file.path)), e.length > pn && /* @__PURE__ */ z("li", { children: /* @__PURE__ */ B("span", { children: [
|
|
1941
1936
|
"and ",
|
|
1942
|
-
e.length -
|
|
1937
|
+
e.length - pn,
|
|
1943
1938
|
" more"
|
|
1944
1939
|
] }) })] }),
|
|
1945
1940
|
u.length > 0 && /* @__PURE__ */ B("label", { children: [
|
|
@@ -1982,16 +1977,16 @@ function fn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
1982
1977
|
]
|
|
1983
1978
|
});
|
|
1984
1979
|
}
|
|
1985
|
-
function
|
|
1980
|
+
function gn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy: a, onDownload: o, onCancel: s, onConfirm: l, className: u }) {
|
|
1986
1981
|
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;
|
|
1987
|
-
return /* @__PURE__ */ B(
|
|
1982
|
+
return /* @__PURE__ */ B(mn, {
|
|
1988
1983
|
className: u,
|
|
1989
1984
|
onCancel: s,
|
|
1990
1985
|
onSubmit: l,
|
|
1991
1986
|
children: [
|
|
1992
1987
|
/* @__PURE__ */ z("h3", {
|
|
1993
1988
|
id: "seed-fm-delete-title",
|
|
1994
|
-
children: i.label ? `${i.label}?` : `Delete the “${
|
|
1989
|
+
children: i.label ? `${i.label}?` : `Delete the “${dn(e.name, 32)}” folder?`
|
|
1995
1990
|
}),
|
|
1996
1991
|
/* @__PURE__ */ B("p", { children: [
|
|
1997
1992
|
"This removes the folder and the ",
|
|
@@ -2008,12 +2003,12 @@ function pn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2008
2003
|
size: 16
|
|
2009
2004
|
}), /* @__PURE__ */ B("span", { children: [/* @__PURE__ */ z("strong", { children: "This can’t be undone." }), " Once deleted, these files can’t be recovered from this browser."] })]
|
|
2010
2005
|
}),
|
|
2011
|
-
/* @__PURE__ */ B("ul", { children: [t.slice(0,
|
|
2006
|
+
/* @__PURE__ */ B("ul", { children: [t.slice(0, pn).map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ z("code", {
|
|
2012
2007
|
title: e.path,
|
|
2013
2008
|
children: e.path.slice(m.length)
|
|
2014
|
-
}), /* @__PURE__ */ z("span", { children: Q(e.size) })] }, e.path)), t.length >
|
|
2009
|
+
}), /* @__PURE__ */ z("span", { children: Q(e.size) })] }, e.path)), t.length > pn && /* @__PURE__ */ z("li", { children: /* @__PURE__ */ B("span", { children: [
|
|
2015
2010
|
"and ",
|
|
2016
|
-
t.length -
|
|
2011
|
+
t.length - pn,
|
|
2017
2012
|
" more"
|
|
2018
2013
|
] }) })] }),
|
|
2019
2014
|
/* @__PURE__ */ B("div", {
|
|
@@ -2072,42 +2067,42 @@ function pn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2072
2067
|
}
|
|
2073
2068
|
//#endregion
|
|
2074
2069
|
//#region src/OPFSFilesManager/fileModel.ts
|
|
2075
|
-
function
|
|
2070
|
+
function _n(e) {
|
|
2076
2071
|
return e.detectedType ?? e.type;
|
|
2077
2072
|
}
|
|
2078
|
-
var
|
|
2079
|
-
function
|
|
2080
|
-
let t =
|
|
2081
|
-
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" ||
|
|
2073
|
+
var vn = /\.(db|sqlite|sqlite3)(-journal|-wal|-shm)?$/i;
|
|
2074
|
+
function yn(e) {
|
|
2075
|
+
let t = _n(e);
|
|
2076
|
+
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" || vn.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";
|
|
2082
2077
|
}
|
|
2083
|
-
function
|
|
2078
|
+
function bn(e) {
|
|
2084
2079
|
let t = /\.([a-z0-9-]{1,12})$/i.exec(e.name)?.[1];
|
|
2085
2080
|
if (t) return t.toLowerCase();
|
|
2086
|
-
let n =
|
|
2081
|
+
let n = _n(e);
|
|
2087
2082
|
return n === "application/octet-stream" ? "bin" : n.split("/")[1]?.replace(/^vnd\./, "") ?? "bin";
|
|
2088
2083
|
}
|
|
2089
|
-
var
|
|
2090
|
-
function
|
|
2091
|
-
let t =
|
|
2084
|
+
var xn = /^(.*\/)?images\/(\d+)\/([^/]+)\.webp$/, Sn = /^(.*\/)?images\/([^/]+)$/, Cn = (e) => e.replace(/\.[^/.]+$/, "");
|
|
2085
|
+
function wn(e) {
|
|
2086
|
+
let t = xn.exec(e);
|
|
2092
2087
|
return t ? {
|
|
2093
2088
|
key: `${t[1] ?? ""}images/${t[3]}`,
|
|
2094
2089
|
width: Number(t[2])
|
|
2095
2090
|
} : null;
|
|
2096
2091
|
}
|
|
2097
|
-
function
|
|
2098
|
-
let t =
|
|
2099
|
-
return t ? `${t[1] ?? ""}images/${
|
|
2092
|
+
function Tn(e) {
|
|
2093
|
+
let t = Sn.exec(e);
|
|
2094
|
+
return t ? `${t[1] ?? ""}images/${Cn(t[2])}` : null;
|
|
2100
2095
|
}
|
|
2101
|
-
var
|
|
2096
|
+
var En = (e) => ({
|
|
2102
2097
|
file: e,
|
|
2103
2098
|
variants: [],
|
|
2104
2099
|
totalSize: e.size
|
|
2105
2100
|
});
|
|
2106
|
-
function
|
|
2107
|
-
if (!t) return e.map(
|
|
2101
|
+
function Dn(e, t) {
|
|
2102
|
+
if (!t) return e.map(En);
|
|
2108
2103
|
let n = /* @__PURE__ */ new Map(), r = [], i = [];
|
|
2109
2104
|
for (let t of e) {
|
|
2110
|
-
let e =
|
|
2105
|
+
let e = wn(t.path);
|
|
2111
2106
|
if (e) {
|
|
2112
2107
|
i.push({
|
|
2113
2108
|
file: t,
|
|
@@ -2115,27 +2110,27 @@ function wn(e, t) {
|
|
|
2115
2110
|
});
|
|
2116
2111
|
continue;
|
|
2117
2112
|
}
|
|
2118
|
-
let a =
|
|
2113
|
+
let a = En(t);
|
|
2119
2114
|
r.push(a);
|
|
2120
|
-
let o =
|
|
2121
|
-
o &&
|
|
2115
|
+
let o = Tn(t.path);
|
|
2116
|
+
o && yn(t) === "image" && n.set(o, a);
|
|
2122
2117
|
}
|
|
2123
2118
|
for (let e of i) {
|
|
2124
2119
|
let t = n.get(e.key);
|
|
2125
2120
|
t ? (t.variants.push({
|
|
2126
2121
|
file: e.file,
|
|
2127
2122
|
width: e.width
|
|
2128
|
-
}), t.totalSize += e.file.size) : r.push(
|
|
2123
|
+
}), t.totalSize += e.file.size) : r.push(En(e.file));
|
|
2129
2124
|
}
|
|
2130
2125
|
for (let e of n.values()) e.variants.sort((e, t) => e.width - t.width);
|
|
2131
2126
|
return r;
|
|
2132
2127
|
}
|
|
2133
|
-
var
|
|
2134
|
-
function
|
|
2128
|
+
var On = (e, t) => e ? `${e}/${t}` : t;
|
|
2129
|
+
function kn(e, t, n = {}) {
|
|
2135
2130
|
let r = t ? `${t}/` : "", i = e.filter((e) => e.file.path.startsWith(r)), a = n.query?.trim().toLowerCase();
|
|
2136
2131
|
if (a) return {
|
|
2137
2132
|
folders: [],
|
|
2138
|
-
entries:
|
|
2133
|
+
entries: An(i.filter((e) => e.file.path.slice(r.length).toLowerCase().includes(a)), n.sort)
|
|
2139
2134
|
};
|
|
2140
2135
|
let o = /* @__PURE__ */ new Map(), s = [];
|
|
2141
2136
|
for (let e of i) {
|
|
@@ -2146,7 +2141,7 @@ function En(e, t, n = {}) {
|
|
|
2146
2141
|
}
|
|
2147
2142
|
let a = n.slice(0, i), c = o.get(a) ?? {
|
|
2148
2143
|
name: a,
|
|
2149
|
-
path:
|
|
2144
|
+
path: On(t, a),
|
|
2150
2145
|
fileCount: 0,
|
|
2151
2146
|
size: 0
|
|
2152
2147
|
};
|
|
@@ -2154,10 +2149,10 @@ function En(e, t, n = {}) {
|
|
|
2154
2149
|
}
|
|
2155
2150
|
return {
|
|
2156
2151
|
folders: [...o.values()].sort((e, t) => e.name.localeCompare(t.name)),
|
|
2157
|
-
entries:
|
|
2152
|
+
entries: An(s, n.sort)
|
|
2158
2153
|
};
|
|
2159
2154
|
}
|
|
2160
|
-
function
|
|
2155
|
+
function An(e, t = "name") {
|
|
2161
2156
|
let n = {
|
|
2162
2157
|
name: (e, t) => e.file.name.localeCompare(t.file.name),
|
|
2163
2158
|
modified: (e, t) => t.file.lastModified - e.file.lastModified,
|
|
@@ -2165,7 +2160,7 @@ function Dn(e, t = "name") {
|
|
|
2165
2160
|
};
|
|
2166
2161
|
return [...e].sort(n[t]);
|
|
2167
2162
|
}
|
|
2168
|
-
function
|
|
2163
|
+
function jn(e) {
|
|
2169
2164
|
let t = {
|
|
2170
2165
|
image: 0,
|
|
2171
2166
|
database: 0,
|
|
@@ -2174,34 +2169,34 @@ function On(e) {
|
|
|
2174
2169
|
text: 0,
|
|
2175
2170
|
other: 0
|
|
2176
2171
|
};
|
|
2177
|
-
for (let n of e) t[
|
|
2172
|
+
for (let n of e) t[yn(n)] += n.size;
|
|
2178
2173
|
return t;
|
|
2179
2174
|
}
|
|
2180
|
-
function
|
|
2175
|
+
function Mn(e) {
|
|
2181
2176
|
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;
|
|
2182
2177
|
}
|
|
2183
2178
|
//#endregion
|
|
2184
2179
|
//#region src/OPFSFilesManager/useThumbnail.ts
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2180
|
+
var Nn = 400, Pn = 262144, Fn = 4, In = 3e4, Ln = 0, Rn = [];
|
|
2181
|
+
function zn(e) {
|
|
2187
2182
|
return new Promise((t, n) => {
|
|
2188
2183
|
let r = () => {
|
|
2189
|
-
|
|
2190
|
-
|
|
2184
|
+
Ln++, e().then(t, n).finally(() => {
|
|
2185
|
+
Ln--, Rn.shift()?.();
|
|
2191
2186
|
});
|
|
2192
2187
|
};
|
|
2193
|
-
|
|
2188
|
+
Ln < Fn ? r() : Rn.push(r);
|
|
2194
2189
|
});
|
|
2195
2190
|
}
|
|
2196
|
-
var
|
|
2197
|
-
function
|
|
2198
|
-
let n =
|
|
2191
|
+
var Bn = /* @__PURE__ */ new Map();
|
|
2192
|
+
function Vn(e, t) {
|
|
2193
|
+
let n = Bn.get(e);
|
|
2199
2194
|
if (!n) {
|
|
2200
2195
|
let r = {
|
|
2201
2196
|
refs: 0,
|
|
2202
2197
|
promise: Promise.resolve("")
|
|
2203
2198
|
};
|
|
2204
|
-
r.promise =
|
|
2199
|
+
r.promise = zn(t).then((e) => (r.url = URL.createObjectURL(e), r.url)), Bn.set(e, r), n = r;
|
|
2205
2200
|
}
|
|
2206
2201
|
n.timer && (clearTimeout(n.timer), n.timer = void 0), n.refs++;
|
|
2207
2202
|
let r = n, i = !1;
|
|
@@ -2209,15 +2204,15 @@ function Rn(e, t) {
|
|
|
2209
2204
|
promise: r.promise,
|
|
2210
2205
|
release: () => {
|
|
2211
2206
|
i || (i = !0, r.refs--, !(r.refs > 0) && (r.timer = setTimeout(() => {
|
|
2212
|
-
r.url && URL.revokeObjectURL(r.url),
|
|
2213
|
-
},
|
|
2207
|
+
r.url && URL.revokeObjectURL(r.url), Bn.get(e) === r && Bn.delete(e);
|
|
2208
|
+
}, In)));
|
|
2214
2209
|
}
|
|
2215
2210
|
};
|
|
2216
2211
|
}
|
|
2217
|
-
async function
|
|
2218
|
-
if (e.size <
|
|
2212
|
+
async function Hn(e) {
|
|
2213
|
+
if (e.size < Pn || typeof createImageBitmap != "function") return e;
|
|
2219
2214
|
let t = await createImageBitmap(e, {
|
|
2220
|
-
resizeWidth:
|
|
2215
|
+
resizeWidth: Nn,
|
|
2221
2216
|
resizeQuality: "medium"
|
|
2222
2217
|
});
|
|
2223
2218
|
try {
|
|
@@ -2234,22 +2229,22 @@ async function zn(e) {
|
|
|
2234
2229
|
t.close();
|
|
2235
2230
|
}
|
|
2236
2231
|
}
|
|
2237
|
-
async function
|
|
2232
|
+
async function Un(e) {
|
|
2238
2233
|
let t = e.variants[0];
|
|
2239
|
-
return t ?
|
|
2240
|
-
}
|
|
2241
|
-
var
|
|
2242
|
-
function
|
|
2243
|
-
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (
|
|
2244
|
-
for (let t of e) t.isIntersecting && (
|
|
2245
|
-
}, { rootMargin: "300px" })),
|
|
2246
|
-
|
|
2234
|
+
return t ? qt(t.file.path) : Hn(await qt(e.file.path));
|
|
2235
|
+
}
|
|
2236
|
+
var Wn = /* @__PURE__ */ new WeakMap(), Gn = null;
|
|
2237
|
+
function Kn(e, t) {
|
|
2238
|
+
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (Gn ?? (Gn = new IntersectionObserver((e) => {
|
|
2239
|
+
for (let t of e) t.isIntersecting && (Gn.unobserve(t.target), Wn.get(t.target)?.(), Wn.delete(t.target));
|
|
2240
|
+
}, { rootMargin: "300px" })), Wn.set(e, t), Gn.observe(e), () => {
|
|
2241
|
+
Wn.delete(e), Gn?.unobserve(e);
|
|
2247
2242
|
});
|
|
2248
2243
|
}
|
|
2249
|
-
function
|
|
2250
|
-
let t =
|
|
2244
|
+
function qn(e) {
|
|
2245
|
+
let t = yn(e.file) === "image", [r, a] = c(null), [o, s] = c(!1), [l, u] = c(null), [d, f] = c("idle"), p = n((e) => a(e), []);
|
|
2251
2246
|
i(() => {
|
|
2252
|
-
if (t && r && !o) return
|
|
2247
|
+
if (t && r && !o) return Kn(r, () => s(!0));
|
|
2253
2248
|
}, [
|
|
2254
2249
|
t,
|
|
2255
2250
|
r,
|
|
@@ -2260,7 +2255,7 @@ function Wn(e) {
|
|
|
2260
2255
|
if (!t || !o) return;
|
|
2261
2256
|
let n = !1;
|
|
2262
2257
|
f("loading");
|
|
2263
|
-
let r =
|
|
2258
|
+
let r = Vn(_, () => Un(e));
|
|
2264
2259
|
return r.promise.then((e) => {
|
|
2265
2260
|
n || (u(e), f("ready"));
|
|
2266
2261
|
}, () => {
|
|
@@ -2283,7 +2278,7 @@ function Wn(e) {
|
|
|
2283
2278
|
}
|
|
2284
2279
|
//#endregion
|
|
2285
2280
|
//#region src/OPFSFilesManager/FileThumbnail.tsx
|
|
2286
|
-
var
|
|
2281
|
+
var Jn = {
|
|
2287
2282
|
image: {
|
|
2288
2283
|
icon: "image",
|
|
2289
2284
|
label: "Images",
|
|
@@ -2314,11 +2309,11 @@ var Gn = {
|
|
|
2314
2309
|
label: "Other",
|
|
2315
2310
|
color: "var(--seed-kind-other)"
|
|
2316
2311
|
}
|
|
2317
|
-
},
|
|
2318
|
-
function
|
|
2319
|
-
let r =
|
|
2312
|
+
}, Yn = (e) => ({ "--seed-kind": Jn[e].color }), Xn = (e) => /png|webp|gif|avif|svg/.test(_n(e.file));
|
|
2313
|
+
function Zn({ entry: e, size: t, children: n }) {
|
|
2314
|
+
let r = yn(e.file), { ref: i, url: a, status: o, markError: s } = qn(e), c = r === "image" && o === "error", l = r === "image" && a && !c, u = [
|
|
2320
2315
|
t === "tile" ? "seed-fm-thumb" : "seed-fm-mini",
|
|
2321
|
-
l &&
|
|
2316
|
+
l && Xn(e) ? "seed-fm-thumb--checker" : "",
|
|
2322
2317
|
r === "image" && o === "loading" ? "seed-fm-skeleton" : ""
|
|
2323
2318
|
].filter(Boolean).join(" "), d;
|
|
2324
2319
|
return d = l ? /* @__PURE__ */ z("img", {
|
|
@@ -2328,12 +2323,12 @@ function Jn({ entry: e, size: t, children: n }) {
|
|
|
2328
2323
|
draggable: !1,
|
|
2329
2324
|
onError: s
|
|
2330
2325
|
}) : t === "mini" ? /* @__PURE__ */ z($, {
|
|
2331
|
-
name: c ? "imageOff" :
|
|
2326
|
+
name: c ? "imageOff" : Jn[r].icon,
|
|
2332
2327
|
size: 16
|
|
2333
2328
|
}) : r === "image" && !c ? null : /* @__PURE__ */ B("span", {
|
|
2334
2329
|
className: "seed-fm-kind",
|
|
2335
2330
|
children: [/* @__PURE__ */ z($, {
|
|
2336
|
-
name: c ? "imageOff" :
|
|
2331
|
+
name: c ? "imageOff" : Jn[r].icon,
|
|
2337
2332
|
size: 28,
|
|
2338
2333
|
strokeWidth: 1.6
|
|
2339
2334
|
}), c ? /* @__PURE__ */ z("span", {
|
|
@@ -2341,18 +2336,18 @@ function Jn({ entry: e, size: t, children: n }) {
|
|
|
2341
2336
|
children: "Can’t decode image"
|
|
2342
2337
|
}) : /* @__PURE__ */ z("span", {
|
|
2343
2338
|
className: "seed-fm-ext",
|
|
2344
|
-
children:
|
|
2339
|
+
children: bn(e.file)
|
|
2345
2340
|
})]
|
|
2346
2341
|
}), /* @__PURE__ */ B("span", {
|
|
2347
2342
|
ref: i,
|
|
2348
2343
|
className: u,
|
|
2349
|
-
style:
|
|
2344
|
+
style: Yn(r),
|
|
2350
2345
|
children: [d, n]
|
|
2351
2346
|
});
|
|
2352
2347
|
}
|
|
2353
2348
|
//#endregion
|
|
2354
2349
|
//#region src/OPFSFilesManager/FileGrid.tsx
|
|
2355
|
-
function
|
|
2350
|
+
function Qn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i, tileClassName: a }) {
|
|
2356
2351
|
return /* @__PURE__ */ z("ul", {
|
|
2357
2352
|
className: ["seed-fm-grid", i].filter(Boolean).join(" "),
|
|
2358
2353
|
role: "listbox",
|
|
@@ -2372,7 +2367,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2372
2367
|
onKeyDown: (t) => {
|
|
2373
2368
|
t.target === t.currentTarget && (t.key === "Enter" ? (t.preventDefault(), n(e, i, t)) : t.key === " " && (t.preventDefault(), r(e, i, t.shiftKey)));
|
|
2374
2369
|
},
|
|
2375
|
-
children: [/* @__PURE__ */ B(
|
|
2370
|
+
children: [/* @__PURE__ */ B(Zn, {
|
|
2376
2371
|
entry: e,
|
|
2377
2372
|
size: "tile",
|
|
2378
2373
|
children: [/* @__PURE__ */ z("button", {
|
|
@@ -2406,7 +2401,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2406
2401
|
className: "seed-fm-tile-meta",
|
|
2407
2402
|
children: [/* @__PURE__ */ z("span", {
|
|
2408
2403
|
className: "seed-fm-tile-name",
|
|
2409
|
-
children:
|
|
2404
|
+
children: dn(o.name, 24)
|
|
2410
2405
|
}), /* @__PURE__ */ B("span", {
|
|
2411
2406
|
className: "seed-fm-tile-sub",
|
|
2412
2407
|
children: [
|
|
@@ -2415,8 +2410,8 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2415
2410
|
" ",
|
|
2416
2411
|
/* @__PURE__ */ z("time", {
|
|
2417
2412
|
dateTime: new Date(o.lastModified).toISOString(),
|
|
2418
|
-
title:
|
|
2419
|
-
children:
|
|
2413
|
+
title: un(o.lastModified),
|
|
2414
|
+
children: ln(o.lastModified)
|
|
2420
2415
|
})
|
|
2421
2416
|
]
|
|
2422
2417
|
})]
|
|
@@ -2427,7 +2422,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2427
2422
|
}
|
|
2428
2423
|
//#endregion
|
|
2429
2424
|
//#region src/OPFSFilesManager/FileList.tsx
|
|
2430
|
-
function
|
|
2425
|
+
function $n({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onToggleAll: o, onDownload: c, onDelete: l, deleteActionFor: u, className: d, rowClassName: f }) {
|
|
2431
2426
|
let p = s(null), m = e.filter((e) => t.has(e.file.path)).length, h = e.length > 0 && m === e.length;
|
|
2432
2427
|
i(() => {
|
|
2433
2428
|
p.current && (p.current.indeterminate = m > 0 && !h);
|
|
@@ -2487,7 +2482,7 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2487
2482
|
}),
|
|
2488
2483
|
/* @__PURE__ */ z("td", { children: /* @__PURE__ */ B("span", {
|
|
2489
2484
|
className: "seed-fm-namecell",
|
|
2490
|
-
children: [/* @__PURE__ */ z(
|
|
2485
|
+
children: [/* @__PURE__ */ z(Zn, {
|
|
2491
2486
|
entry: e,
|
|
2492
2487
|
size: "mini"
|
|
2493
2488
|
}), /* @__PURE__ */ B("span", { children: [/* @__PURE__ */ z("button", {
|
|
@@ -2506,8 +2501,8 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2506
2501
|
className: "seed-fm-col-type",
|
|
2507
2502
|
children: /* @__PURE__ */ B("span", {
|
|
2508
2503
|
className: "seed-fm-type",
|
|
2509
|
-
style:
|
|
2510
|
-
children: [
|
|
2504
|
+
style: Yn(yn(i)),
|
|
2505
|
+
children: [_n(i), i.detectedType && /* @__PURE__ */ z("small", { children: "detected" })]
|
|
2511
2506
|
})
|
|
2512
2507
|
}),
|
|
2513
2508
|
/* @__PURE__ */ z("td", {
|
|
@@ -2517,8 +2512,8 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2517
2512
|
}),
|
|
2518
2513
|
/* @__PURE__ */ z("td", {
|
|
2519
2514
|
className: "seed-fm-when seed-fm-col-modified",
|
|
2520
|
-
title:
|
|
2521
|
-
children:
|
|
2515
|
+
title: un(i.lastModified),
|
|
2516
|
+
children: ln(i.lastModified)
|
|
2522
2517
|
}),
|
|
2523
2518
|
/* @__PURE__ */ B("td", {
|
|
2524
2519
|
className: "seed-fm-actions",
|
|
@@ -2553,22 +2548,22 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2553
2548
|
}
|
|
2554
2549
|
//#endregion
|
|
2555
2550
|
//#region src/OPFSFilesManager/PreviewPanel.tsx
|
|
2556
|
-
var
|
|
2557
|
-
function
|
|
2558
|
-
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o =
|
|
2551
|
+
var er = 1048576, tr = 32768;
|
|
2552
|
+
function nr(e) {
|
|
2553
|
+
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o = yn(e.file), s = e.file.size;
|
|
2559
2554
|
return i(() => {
|
|
2560
2555
|
let e = !1, t = null;
|
|
2561
2556
|
return n({ kind: "loading" }), (async () => {
|
|
2562
|
-
if (o === "image") return t = URL.createObjectURL(await
|
|
2557
|
+
if (o === "image") return t = URL.createObjectURL(await qt(r)), {
|
|
2563
2558
|
kind: "image",
|
|
2564
2559
|
url: t
|
|
2565
2560
|
};
|
|
2566
2561
|
if (o === "json" || o === "html" || o === "text") {
|
|
2567
|
-
if (s >
|
|
2562
|
+
if (s > er) return {
|
|
2568
2563
|
kind: "none",
|
|
2569
2564
|
message: "This file is too large to preview."
|
|
2570
2565
|
};
|
|
2571
|
-
let e = await
|
|
2566
|
+
let e = await qt(r), t = e.size > tr, n = await e.slice(0, tr).text();
|
|
2572
2567
|
if (o === "json" && !t) try {
|
|
2573
2568
|
n = JSON.stringify(JSON.parse(n), null, 2);
|
|
2574
2569
|
} catch {}
|
|
@@ -2602,8 +2597,8 @@ function $n(e) {
|
|
|
2602
2597
|
o
|
|
2603
2598
|
]), t;
|
|
2604
2599
|
}
|
|
2605
|
-
function
|
|
2606
|
-
let { file: f, variants: p } = e, m =
|
|
2600
|
+
function rr({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onDelete: o, deleteAction: l, onCopyPath: u, className: d }) {
|
|
2601
|
+
let { file: f, variants: p } = e, m = yn(f), h = nr(e), [g, _] = c(null), [v, y] = c(!1), b = s(null);
|
|
2607
2602
|
i(() => {
|
|
2608
2603
|
_(null), y(!1);
|
|
2609
2604
|
}, [f.path]), i(() => {
|
|
@@ -2626,13 +2621,13 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2626
2621
|
C = /* @__PURE__ */ B("span", {
|
|
2627
2622
|
className: "seed-fm-preview-note",
|
|
2628
2623
|
children: [/* @__PURE__ */ z($, {
|
|
2629
|
-
name: v ? "imageOff" :
|
|
2624
|
+
name: v ? "imageOff" : Jn[m].icon,
|
|
2630
2625
|
size: 32,
|
|
2631
2626
|
strokeWidth: 1.5
|
|
2632
2627
|
}), e]
|
|
2633
2628
|
});
|
|
2634
2629
|
}
|
|
2635
|
-
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(
|
|
2630
|
+
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(_n(f));
|
|
2636
2631
|
return /* @__PURE__ */ B("aside", {
|
|
2637
2632
|
className: ["seed-fm-panel", d].filter(Boolean).join(" "),
|
|
2638
2633
|
role: "dialog",
|
|
@@ -2682,7 +2677,7 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2682
2677
|
w ? "seed-fm-thumb--checker" : "",
|
|
2683
2678
|
h.kind === "loading" ? "seed-fm-skeleton" : ""
|
|
2684
2679
|
].filter(Boolean).join(" "),
|
|
2685
|
-
style:
|
|
2680
|
+
style: Yn(m),
|
|
2686
2681
|
children: C
|
|
2687
2682
|
}),
|
|
2688
2683
|
/* @__PURE__ */ B("dl", {
|
|
@@ -2710,7 +2705,7 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2710
2705
|
/* @__PURE__ */ B("small", { children: [f.size.toLocaleString(), " bytes"] })
|
|
2711
2706
|
] }),
|
|
2712
2707
|
/* @__PURE__ */ z("dt", { children: "Type" }),
|
|
2713
|
-
/* @__PURE__ */ B("dd", { children: [
|
|
2708
|
+
/* @__PURE__ */ B("dd", { children: [_n(f), f.detectedType && /* @__PURE__ */ B("small", { children: [
|
|
2714
2709
|
" from file contents. File.type is “",
|
|
2715
2710
|
f.type,
|
|
2716
2711
|
"”"
|
|
@@ -2723,9 +2718,9 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2723
2718
|
] })] }),
|
|
2724
2719
|
/* @__PURE__ */ z("dt", { children: "Modified" }),
|
|
2725
2720
|
/* @__PURE__ */ B("dd", { children: [
|
|
2726
|
-
|
|
2721
|
+
un(f.lastModified),
|
|
2727
2722
|
" ",
|
|
2728
|
-
/* @__PURE__ */ z("small", { children:
|
|
2723
|
+
/* @__PURE__ */ z("small", { children: ln(f.lastModified) })
|
|
2729
2724
|
] })
|
|
2730
2725
|
]
|
|
2731
2726
|
}),
|
|
@@ -2770,18 +2765,18 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2770
2765
|
}
|
|
2771
2766
|
//#endregion
|
|
2772
2767
|
//#region src/OPFSFilesManager/styles.ts
|
|
2773
|
-
var
|
|
2768
|
+
var ir = "seed-opfs-files-manager-styles", ar = "seed-opfs-files-manager", or = "\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", sr = "\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", cr = `@layer ${ar} {\n${`
|
|
2774
2769
|
.seed-fm {
|
|
2775
|
-
${
|
|
2770
|
+
${or}
|
|
2776
2771
|
--seed-radius-sm: 6px;
|
|
2777
2772
|
--seed-radius-md: 8px;
|
|
2778
2773
|
--seed-radius-lg: 12px;
|
|
2779
2774
|
--seed-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2780
2775
|
color-scheme: light;
|
|
2781
2776
|
}
|
|
2782
|
-
.seed-fm[data-seed-theme="dark"] { ${
|
|
2777
|
+
.seed-fm[data-seed-theme="dark"] { ${sr} }
|
|
2783
2778
|
@media (prefers-color-scheme: dark) {
|
|
2784
|
-
.seed-fm[data-seed-theme="system"] { ${
|
|
2779
|
+
.seed-fm[data-seed-theme="system"] { ${sr} }
|
|
2785
2780
|
}
|
|
2786
2781
|
|
|
2787
2782
|
.seed-fm { position: relative; color: var(--seed-fg); background: var(--seed-bg); font-family: inherit; font-size: 14px; line-height: 1.45; }
|
|
@@ -2989,14 +2984,14 @@ var tr = "seed-opfs-files-manager-styles", nr = "seed-opfs-files-manager", rr =
|
|
|
2989
2984
|
.seed-fm-thumb img { transition: none; }
|
|
2990
2985
|
}
|
|
2991
2986
|
`}\n}`;
|
|
2992
|
-
function
|
|
2987
|
+
function lr() {
|
|
2993
2988
|
if (typeof document > "u" || document.getElementById("seed-opfs-files-manager-styles")) return;
|
|
2994
2989
|
let e = document.createElement("style");
|
|
2995
|
-
e.id =
|
|
2990
|
+
e.id = ir, e.textContent = cr, document.head.appendChild(e);
|
|
2996
2991
|
}
|
|
2997
2992
|
//#endregion
|
|
2998
2993
|
//#region src/OPFSFilesManager/useStorageEstimate.ts
|
|
2999
|
-
function
|
|
2994
|
+
function ur(e) {
|
|
3000
2995
|
let [t, n] = c(null);
|
|
3001
2996
|
return i(() => {
|
|
3002
2997
|
if (typeof navigator > "u" || typeof navigator.storage?.estimate != "function") return;
|
|
@@ -3013,40 +3008,40 @@ function sr(e) {
|
|
|
3013
3008
|
}
|
|
3014
3009
|
//#endregion
|
|
3015
3010
|
//#region src/OPFSFilesManager/zip.ts
|
|
3016
|
-
var
|
|
3017
|
-
function
|
|
3018
|
-
if (
|
|
3019
|
-
|
|
3011
|
+
var dr = null;
|
|
3012
|
+
function fr() {
|
|
3013
|
+
if (dr) return dr;
|
|
3014
|
+
dr = /* @__PURE__ */ new Uint32Array(256);
|
|
3020
3015
|
for (let e = 0; e < 256; e++) {
|
|
3021
3016
|
let t = e;
|
|
3022
3017
|
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
3023
|
-
|
|
3018
|
+
dr[e] = t >>> 0;
|
|
3024
3019
|
}
|
|
3025
|
-
return
|
|
3020
|
+
return dr;
|
|
3026
3021
|
}
|
|
3027
|
-
function
|
|
3028
|
-
let t =
|
|
3022
|
+
function pr(e) {
|
|
3023
|
+
let t = fr(), n = 4294967295;
|
|
3029
3024
|
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
3030
3025
|
return (n ^ 4294967295) >>> 0;
|
|
3031
3026
|
}
|
|
3032
|
-
function
|
|
3027
|
+
function mr(e) {
|
|
3033
3028
|
let t = new Date(e), n = Math.max(1980, t.getFullYear());
|
|
3034
3029
|
return {
|
|
3035
3030
|
time: t.getHours() << 11 | t.getMinutes() << 5 | Math.floor(t.getSeconds() / 2),
|
|
3036
3031
|
date: n - 1980 << 9 | t.getMonth() + 1 << 5 | t.getDate()
|
|
3037
3032
|
};
|
|
3038
3033
|
}
|
|
3039
|
-
var
|
|
3040
|
-
async function
|
|
3034
|
+
var hr = 2048, gr = 4294967295;
|
|
3035
|
+
async function _r(e) {
|
|
3041
3036
|
if (e.length > 65535) throw Error("Too many files for a ZIP archive (max 65,535).");
|
|
3042
3037
|
let t = new TextEncoder(), n = [], r = [], i = 0;
|
|
3043
3038
|
for (let a of e) {
|
|
3044
|
-
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s =
|
|
3045
|
-
if (i + o.length + 30 + e.length >
|
|
3039
|
+
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s = pr(o), { time: c, date: l } = mr(a.lastModified ?? Date.now());
|
|
3040
|
+
if (i + o.length + 30 + e.length > gr) throw Error("Selection is too large for a ZIP archive (max 4 GB).");
|
|
3046
3041
|
let u = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(30));
|
|
3047
|
-
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6,
|
|
3042
|
+
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6, hr, !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);
|
|
3048
3043
|
let d = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(46));
|
|
3049
|
-
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8,
|
|
3044
|
+
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, hr, !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);
|
|
3050
3045
|
let f = new Uint8Array(46 + e.length);
|
|
3051
3046
|
f.set(new Uint8Array(d.buffer), 0), f.set(e, 46), r.push(f), i += 30 + e.length + o.length;
|
|
3052
3047
|
}
|
|
@@ -3059,12 +3054,12 @@ async function mr(e) {
|
|
|
3059
3054
|
}
|
|
3060
3055
|
//#endregion
|
|
3061
3056
|
//#region src/OPFSFilesManager/OPFSFilesManager.tsx
|
|
3062
|
-
var
|
|
3063
|
-
function
|
|
3057
|
+
var vr = "Everything this app stores in the browser’s private file system (OPFS).", yr = 4e3, br = (e) => e instanceof Error ? e.message : String(e), xr = (e, t, n = `${t}s`) => `${e} ${e === 1 ? t : n}`, Sr = (e) => (e ?? "").split("/").filter(Boolean).join("/");
|
|
3058
|
+
function Cr(e, t) {
|
|
3064
3059
|
let n = URL.createObjectURL(t), r = document.createElement("a");
|
|
3065
3060
|
r.href = n, r.download = e, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
3066
3061
|
}
|
|
3067
|
-
function
|
|
3062
|
+
function wr() {
|
|
3068
3063
|
let [e, t] = c([]), r = s(/* @__PURE__ */ new Set());
|
|
3069
3064
|
return i(() => {
|
|
3070
3065
|
let e = r.current;
|
|
@@ -3080,12 +3075,12 @@ function xr() {
|
|
|
3080
3075
|
}]);
|
|
3081
3076
|
let a = setTimeout(() => {
|
|
3082
3077
|
r.current.delete(a), t((e) => e.filter((e) => e.id !== i));
|
|
3083
|
-
},
|
|
3078
|
+
}, yr);
|
|
3084
3079
|
r.current.add(a);
|
|
3085
3080
|
}, [])
|
|
3086
3081
|
};
|
|
3087
3082
|
}
|
|
3088
|
-
var
|
|
3083
|
+
var Tr = [
|
|
3089
3084
|
"image",
|
|
3090
3085
|
"database",
|
|
3091
3086
|
"json",
|
|
@@ -3093,11 +3088,11 @@ var Sr = [
|
|
|
3093
3088
|
"text",
|
|
3094
3089
|
"other"
|
|
3095
3090
|
];
|
|
3096
|
-
function
|
|
3097
|
-
let n =
|
|
3098
|
-
label:
|
|
3091
|
+
function Er({ files: e, estimate: t }) {
|
|
3092
|
+
let n = jn(e), r = e.reduce((e, t) => e + t.size, 0), i = t ? Math.max(0, t.usage - r) : 0, a = r + i, o = [...Tr.filter((e) => n[e] > 0).map((e) => ({
|
|
3093
|
+
label: Jn[e].label,
|
|
3099
3094
|
size: n[e],
|
|
3100
|
-
color:
|
|
3095
|
+
color: Jn[e].color
|
|
3101
3096
|
})), ...i > 0 ? [{
|
|
3102
3097
|
label: "Other site data",
|
|
3103
3098
|
size: i,
|
|
@@ -3111,7 +3106,7 @@ function Cr({ files: e, estimate: t }) {
|
|
|
3111
3106
|
children: [/* @__PURE__ */ B("span", { children: [
|
|
3112
3107
|
/* @__PURE__ */ z("strong", { children: Q(t ? t.usage : r) }),
|
|
3113
3108
|
" ",
|
|
3114
|
-
t ? "used by this site" : `in ${
|
|
3109
|
+
t ? "used by this site" : `in ${xr(e.length, "file")}`
|
|
3115
3110
|
] }), t && /* @__PURE__ */ B("span", { children: [Q(t.quota), " available"] })]
|
|
3116
3111
|
}), a > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3117
3112
|
className: "seed-fm-meter",
|
|
@@ -3134,7 +3129,7 @@ function Cr({ files: e, estimate: t }) {
|
|
|
3134
3129
|
})] })]
|
|
3135
3130
|
});
|
|
3136
3131
|
}
|
|
3137
|
-
function
|
|
3132
|
+
function Dr({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
3138
3133
|
return /* @__PURE__ */ B("div", {
|
|
3139
3134
|
className: `seed-fm-state${r === "error" ? " seed-fm-state--error" : ""}`,
|
|
3140
3135
|
role: r === "error" ? "alert" : void 0,
|
|
@@ -3152,70 +3147,70 @@ function wr({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
|
3152
3147
|
]
|
|
3153
3148
|
});
|
|
3154
3149
|
}
|
|
3155
|
-
function
|
|
3150
|
+
function Or({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDownload: l, title: u = "Files", description: d = vr, headingLevel: f = 2, theme: p = "system", className: m, classNames: h = {}, defaultView: g, groupImageVariants: _ = !0, deleteWarning: v = Mn, confirmDelete: y, deleteAction: b, onNotify: x }) {
|
|
3156
3151
|
a(() => {
|
|
3157
|
-
p !== "none" &&
|
|
3152
|
+
p !== "none" && lr();
|
|
3158
3153
|
}, [p]);
|
|
3159
|
-
let S =
|
|
3160
|
-
i(() =>
|
|
3161
|
-
let
|
|
3162
|
-
i(() =>
|
|
3163
|
-
let [
|
|
3164
|
-
x ? x(e, t, n) :
|
|
3165
|
-
},
|
|
3166
|
-
query:
|
|
3154
|
+
let S = Sr(e), C = S ? S.split("/").pop() : "OPFS", w = (e, t) => [t, h[e]].filter(Boolean).join(" "), { files: T, isLoading: E, hasLoaded: ee, error: D, errorName: te, refetch: ne } = rn({ rootPath: e }), O = o(() => t ? T.filter(t) : T, [T, t]), re = ur(T), [ie, k] = c(_);
|
|
3155
|
+
i(() => k(_), [_]);
|
|
3156
|
+
let A = o(() => Dn(O, ie), [O, ie]), [j, ae] = c(S);
|
|
3157
|
+
i(() => ae(S), [S]);
|
|
3158
|
+
let [oe, se] = c(""), [ce, le] = c("name"), [ue, de] = c(g), [M, N] = c(() => /* @__PURE__ */ new Set()), P = s(null), [F, I] = c(null), fe = s(null), [L, pe] = c(null), [V, me] = c(null), [he, H] = c(!1), { toasts: U, showToast: ge } = wr(), _e = (e, t, n) => {
|
|
3159
|
+
x ? x(e, t, n) : ge(e, t);
|
|
3160
|
+
}, W = o(() => kn(A, j, {
|
|
3161
|
+
query: oe,
|
|
3167
3162
|
sort: ce
|
|
3168
3163
|
}), [
|
|
3169
|
-
k,
|
|
3170
3164
|
A,
|
|
3171
|
-
|
|
3165
|
+
j,
|
|
3166
|
+
oe,
|
|
3172
3167
|
ce
|
|
3173
|
-
]), G =
|
|
3168
|
+
]), G = W.entries, ve = G.length ? G.filter((e) => yn(e.file) === "image").length / G.length : 0, ye = ue ?? (ve >= .5 ? "grid" : "list"), be = o(() => new Map(A.map((e) => [e.file.path, e])), [A]), K = o(() => [...M].map((e) => be.get(e)).filter((e) => !!e), [M, be]), q = F ? be.get(F) ?? null : null, xe = q ? G.indexOf(q) : -1;
|
|
3174
3169
|
i(() => {
|
|
3175
|
-
|
|
3170
|
+
N((e) => {
|
|
3176
3171
|
let t = new Set([...e].filter((e) => be.has(e)));
|
|
3177
3172
|
return t.size === e.size ? e : t;
|
|
3178
3173
|
});
|
|
3179
3174
|
}, [be]);
|
|
3180
|
-
let
|
|
3181
|
-
|
|
3175
|
+
let J = (e) => {
|
|
3176
|
+
ae(e), se(""), N(/* @__PURE__ */ new Set()), P.current = null, I(null);
|
|
3182
3177
|
}, Se = (e, t, n) => {
|
|
3183
|
-
let r =
|
|
3184
|
-
|
|
3178
|
+
let r = P.current;
|
|
3179
|
+
N((i) => {
|
|
3185
3180
|
let a = new Set(i);
|
|
3186
3181
|
if (n && r != null) {
|
|
3187
3182
|
let [e, n] = r < t ? [r, t] : [t, r];
|
|
3188
3183
|
for (let t of G.slice(e, n + 1)) a.add(t.file.path);
|
|
3189
3184
|
} else a.has(e.file.path) ? a.delete(e.file.path) : a.add(e.file.path);
|
|
3190
3185
|
return a;
|
|
3191
|
-
}), (!n || r == null) && (
|
|
3186
|
+
}), (!n || r == null) && (P.current = t);
|
|
3192
3187
|
}, Ce = (e) => {
|
|
3193
|
-
|
|
3194
|
-
},
|
|
3195
|
-
|
|
3196
|
-
},
|
|
3188
|
+
F || (fe.current = document.activeElement), I(e);
|
|
3189
|
+
}, we = () => {
|
|
3190
|
+
I(null), fe.current?.focus?.(), fe.current = null;
|
|
3191
|
+
}, Te = (e, t, n) => {
|
|
3197
3192
|
let r = n.shiftKey || n.metaKey || n.ctrlKey;
|
|
3198
|
-
|
|
3199
|
-
},
|
|
3200
|
-
let e = G.every((e) =>
|
|
3201
|
-
|
|
3193
|
+
M.size > 0 || r ? Se(e, t, n.shiftKey) : Ce(e.file.path);
|
|
3194
|
+
}, Ee = () => {
|
|
3195
|
+
let e = G.every((e) => M.has(e.file.path));
|
|
3196
|
+
N((t) => {
|
|
3202
3197
|
let n = new Set(t);
|
|
3203
3198
|
for (let t of G) e ? n.delete(t.file.path) : n.add(t.file.path);
|
|
3204
3199
|
return n;
|
|
3205
3200
|
});
|
|
3206
|
-
},
|
|
3207
|
-
l ? await l(e, t) :
|
|
3201
|
+
}, Y = (e) => S && e.startsWith(`${S}/`) ? e.slice(S.length + 1) : e, De = async (e, t) => {
|
|
3202
|
+
l ? await l(e, t) : Cr(e.name, t);
|
|
3208
3203
|
}, Oe = async (e, t) => {
|
|
3209
3204
|
if (e.length === 0) return !1;
|
|
3210
|
-
|
|
3205
|
+
H(!0);
|
|
3211
3206
|
try {
|
|
3212
3207
|
if (e.length === 1 && !t) {
|
|
3213
3208
|
let [t] = e;
|
|
3214
|
-
return await De(t, await
|
|
3209
|
+
return await De(t, await qt(t.path)), !0;
|
|
3215
3210
|
}
|
|
3216
|
-
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await
|
|
3217
|
-
name: t ? e.path.slice(n.length) :
|
|
3218
|
-
data: await
|
|
3211
|
+
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await _r(await Promise.all(e.map(async (e) => ({
|
|
3212
|
+
name: t ? e.path.slice(n.length) : Y(e.path),
|
|
3213
|
+
data: await qt(e.path),
|
|
3219
3214
|
lastModified: e.lastModified
|
|
3220
3215
|
})))), i = `${t ? t.name : C}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`;
|
|
3221
3216
|
return await De({
|
|
@@ -3224,19 +3219,19 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3224
3219
|
size: r.size,
|
|
3225
3220
|
type: "application/zip",
|
|
3226
3221
|
lastModified: Date.now()
|
|
3227
|
-
}, r),
|
|
3222
|
+
}, r), _e(`Saved ${i} with ${xr(e.length, "file")}`, "success", {
|
|
3228
3223
|
kind: "download",
|
|
3229
3224
|
paths: e.map((e) => e.path),
|
|
3230
3225
|
fileName: i
|
|
3231
3226
|
}), !0;
|
|
3232
3227
|
} catch (t) {
|
|
3233
|
-
return
|
|
3228
|
+
return _e(`Couldn’t download: ${br(t)}`, "error", {
|
|
3234
3229
|
kind: "download",
|
|
3235
3230
|
paths: e.map((e) => e.path),
|
|
3236
|
-
error:
|
|
3231
|
+
error: br(t)
|
|
3237
3232
|
}), !1;
|
|
3238
3233
|
} finally {
|
|
3239
|
-
|
|
3234
|
+
H(!1);
|
|
3240
3235
|
}
|
|
3241
3236
|
}, ke = (e) => Oe(e.map((e) => e.file)), X = (e, t) => e.flatMap((e) => [e.file, ...t ? e.variants.map((e) => e.file) : []]), Ae = (e) => {
|
|
3242
3237
|
let t = b?.(e);
|
|
@@ -3245,43 +3240,43 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3245
3240
|
destructive: t?.destructive !== !1
|
|
3246
3241
|
};
|
|
3247
3242
|
}, je = (e) => Ae(X(e, !0)), Me = async (e, t) => {
|
|
3248
|
-
|
|
3243
|
+
H(!0);
|
|
3249
3244
|
let i = [], a = [], o = [], s = !1;
|
|
3250
3245
|
try {
|
|
3251
3246
|
let r = await navigator.storage.getDirectory();
|
|
3252
3247
|
for (let t of e) if (n && !await n(t)) o.push(t.path);
|
|
3253
3248
|
else try {
|
|
3254
|
-
await
|
|
3249
|
+
await Jt(t.path, r), i.push(t.path);
|
|
3255
3250
|
} catch (e) {
|
|
3256
3251
|
a.push({
|
|
3257
3252
|
path: t.path,
|
|
3258
|
-
error:
|
|
3253
|
+
error: br(e)
|
|
3259
3254
|
});
|
|
3260
3255
|
}
|
|
3261
3256
|
if (t) try {
|
|
3262
|
-
s = await
|
|
3257
|
+
s = await Xt(t.path, r);
|
|
3263
3258
|
} catch (e) {
|
|
3264
3259
|
a.push({
|
|
3265
3260
|
path: t.path,
|
|
3266
|
-
error:
|
|
3261
|
+
error: br(e)
|
|
3267
3262
|
});
|
|
3268
3263
|
}
|
|
3269
3264
|
} catch (e) {
|
|
3270
3265
|
a.push({
|
|
3271
3266
|
path: "",
|
|
3272
|
-
error:
|
|
3267
|
+
error: br(e)
|
|
3273
3268
|
});
|
|
3274
3269
|
}
|
|
3275
|
-
|
|
3270
|
+
N((e) => {
|
|
3276
3271
|
let t = new Set(e);
|
|
3277
3272
|
return i.forEach((e) => t.delete(e)), t;
|
|
3278
|
-
}),
|
|
3279
|
-
let c = [s ? `Deleted the ${t.name} folder (${
|
|
3273
|
+
}), F && i.includes(F) && I(null), await ne(), H(!1);
|
|
3274
|
+
let c = [s ? `Deleted the ${t.name} folder (${xr(i.length, "file")})` : i.length > 0 ? `Deleted ${xr(i.length, "file")}` : "Nothing deleted"];
|
|
3280
3275
|
if (o.length && c.push(`${o.length} kept by onBeforeDelete`), a.length) {
|
|
3281
3276
|
let e = a.map((e) => e.path ? `${e.path.split("/").pop()}: ${e.error}` : e.error);
|
|
3282
3277
|
c.push(`${a.length} failed (${e.join("; ")})`);
|
|
3283
3278
|
}
|
|
3284
|
-
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`),
|
|
3279
|
+
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`), _e(c.join(". "), a.length ? "error" : "success", {
|
|
3285
3280
|
kind: "delete",
|
|
3286
3281
|
deleted: i,
|
|
3287
3282
|
skipped: o,
|
|
@@ -3294,26 +3289,26 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3294
3289
|
}, Ne = async (e) => {
|
|
3295
3290
|
if (e.length === 0) return;
|
|
3296
3291
|
if (!y) {
|
|
3297
|
-
|
|
3292
|
+
pe(e);
|
|
3298
3293
|
return;
|
|
3299
3294
|
}
|
|
3300
3295
|
let t = X(e, !0);
|
|
3301
3296
|
await y(t) && await Me(t);
|
|
3302
|
-
}, Pe = (e) =>
|
|
3297
|
+
}, Pe = (e) => O.filter((t) => t.path.startsWith(`${e.path}/`)), Fe = async (e) => {
|
|
3303
3298
|
if (!y) {
|
|
3304
|
-
|
|
3299
|
+
me(e);
|
|
3305
3300
|
return;
|
|
3306
3301
|
}
|
|
3307
3302
|
let t = Pe(e);
|
|
3308
3303
|
await y(t) && await Me(t, e);
|
|
3309
3304
|
}, Ie = (e) => {
|
|
3310
|
-
let t = () =>
|
|
3305
|
+
let t = () => _e("Path copied", "success", {
|
|
3311
3306
|
kind: "copy-path",
|
|
3312
3307
|
path: e
|
|
3313
|
-
}), n = (t) =>
|
|
3308
|
+
}), n = (t) => _e("Couldn’t copy. Select the path text instead.", "error", {
|
|
3314
3309
|
kind: "copy-path",
|
|
3315
3310
|
path: e,
|
|
3316
|
-
error: t === void 0 ? "Clipboard unavailable" :
|
|
3311
|
+
error: t === void 0 ? "Clipboard unavailable" : br(t)
|
|
3317
3312
|
});
|
|
3318
3313
|
try {
|
|
3319
3314
|
navigator.clipboard.writeText(e).then(t, n);
|
|
@@ -3321,25 +3316,25 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3321
3316
|
n(e);
|
|
3322
3317
|
}
|
|
3323
3318
|
}, Le = (e) => {
|
|
3324
|
-
if (
|
|
3319
|
+
if (L || V) return;
|
|
3325
3320
|
let t = e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement;
|
|
3326
3321
|
if (e.key === "Escape") {
|
|
3327
|
-
if (
|
|
3328
|
-
else if (
|
|
3322
|
+
if (F) we();
|
|
3323
|
+
else if (M.size > 0) N(/* @__PURE__ */ new Set());
|
|
3329
3324
|
else return;
|
|
3330
3325
|
e.preventDefault();
|
|
3331
3326
|
} else if (q && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
3332
|
-
let t = G[
|
|
3333
|
-
t &&
|
|
3327
|
+
let t = G[xe + (e.key === "ArrowRight" ? 1 : -1)];
|
|
3328
|
+
t && I(t.file.path), e.preventDefault();
|
|
3334
3329
|
}
|
|
3335
|
-
}, Re = o(() =>
|
|
3330
|
+
}, Re = o(() => O.some((e) => wn(e.path)), [O]), ze = /(^|\/)images(\/\d+)?$/.test(j), Z = [{
|
|
3336
3331
|
label: C,
|
|
3337
3332
|
path: S
|
|
3338
|
-
}, ...(
|
|
3333
|
+
}, ...(j.length > S.length ? j.slice(S ? S.length + 1 : 0).split("/") : []).map((e, t, n) => ({
|
|
3339
3334
|
label: e,
|
|
3340
3335
|
path: [S, ...n.slice(0, t + 1)].filter(Boolean).join("/")
|
|
3341
|
-
}))],
|
|
3342
|
-
if (!
|
|
3336
|
+
}))], Be = `h${f}`, Ve = K.reduce((e, t) => e + t.file.size, 0), He;
|
|
3337
|
+
if (!Zt()) He = /* @__PURE__ */ z(Dr, {
|
|
3343
3338
|
icon: "triangleAlert",
|
|
3344
3339
|
tone: "error",
|
|
3345
3340
|
title: "This browser doesn’t support private file storage",
|
|
@@ -3355,7 +3350,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3355
3350
|
size: 15
|
|
3356
3351
|
}), " Try again"]
|
|
3357
3352
|
});
|
|
3358
|
-
|
|
3353
|
+
He = te === "NotFoundError" && S ? /* @__PURE__ */ B(Dr, {
|
|
3359
3354
|
icon: "triangleAlert",
|
|
3360
3355
|
tone: "error",
|
|
3361
3356
|
title: `Can’t open ${S}`,
|
|
@@ -3368,44 +3363,44 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3368
3363
|
/* @__PURE__ */ z("code", { children: "rootPath" }),
|
|
3369
3364
|
" prop, or open the app once so the SDK creates it."
|
|
3370
3365
|
]
|
|
3371
|
-
}) : /* @__PURE__ */ z(
|
|
3366
|
+
}) : /* @__PURE__ */ z(Dr, {
|
|
3372
3367
|
icon: "triangleAlert",
|
|
3373
3368
|
tone: "error",
|
|
3374
3369
|
title: "Can’t read private storage",
|
|
3375
3370
|
action: e,
|
|
3376
3371
|
children: D
|
|
3377
3372
|
});
|
|
3378
|
-
} else
|
|
3373
|
+
} else He = ee ? A.length === 0 ? /* @__PURE__ */ z(Dr, {
|
|
3379
3374
|
icon: "folderOpen",
|
|
3380
3375
|
title: `No files in ${C} yet`,
|
|
3381
3376
|
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."
|
|
3382
|
-
}) :
|
|
3377
|
+
}) : W.folders.length === 0 && G.length === 0 ? oe ? /* @__PURE__ */ B(Dr, {
|
|
3383
3378
|
icon: "search",
|
|
3384
|
-
title: `No matches for “${
|
|
3379
|
+
title: `No matches for “${oe}”`,
|
|
3385
3380
|
action: /* @__PURE__ */ z("button", {
|
|
3386
3381
|
type: "button",
|
|
3387
3382
|
className: "seed-fm-btn",
|
|
3388
|
-
onClick: () =>
|
|
3383
|
+
onClick: () => se(""),
|
|
3389
3384
|
children: "Clear search"
|
|
3390
3385
|
}),
|
|
3391
3386
|
children: [
|
|
3392
3387
|
"Search covers file names and paths in ",
|
|
3393
|
-
|
|
3388
|
+
Z[Z.length - 1].label,
|
|
3394
3389
|
" and every folder inside it."
|
|
3395
3390
|
]
|
|
3396
|
-
}) : /* @__PURE__ */ z(
|
|
3391
|
+
}) : /* @__PURE__ */ z(Dr, {
|
|
3397
3392
|
icon: "folderOpen",
|
|
3398
3393
|
title: "This folder is empty",
|
|
3399
3394
|
children: "Everything in it has been deleted or filtered out."
|
|
3400
|
-
}) : /* @__PURE__ */ B(R, { children: [
|
|
3395
|
+
}) : /* @__PURE__ */ B(R, { children: [W.folders.length > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3401
3396
|
className: "seed-fm-section-label",
|
|
3402
3397
|
children: "Folders"
|
|
3403
3398
|
}), /* @__PURE__ */ z("ul", {
|
|
3404
3399
|
className: "seed-fm-folders",
|
|
3405
|
-
children:
|
|
3400
|
+
children: W.folders.map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ B("button", {
|
|
3406
3401
|
type: "button",
|
|
3407
3402
|
className: w("folder", "seed-fm-folder"),
|
|
3408
|
-
onClick: () =>
|
|
3403
|
+
onClick: () => J(e.path),
|
|
3409
3404
|
children: [/* @__PURE__ */ z($, {
|
|
3410
3405
|
name: "folder",
|
|
3411
3406
|
size: 20,
|
|
@@ -3416,7 +3411,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3416
3411
|
}), /* @__PURE__ */ B("span", {
|
|
3417
3412
|
className: "seed-fm-folder-meta",
|
|
3418
3413
|
children: [
|
|
3419
|
-
|
|
3414
|
+
xr(e.fileCount, "file"),
|
|
3420
3415
|
" · ",
|
|
3421
3416
|
Q(e.size)
|
|
3422
3417
|
]
|
|
@@ -3426,7 +3421,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3426
3421
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon seed-fm-folder-delete",
|
|
3427
3422
|
"aria-label": `Delete folder ${e.name}`,
|
|
3428
3423
|
title: "Delete folder",
|
|
3429
|
-
disabled:
|
|
3424
|
+
disabled: he,
|
|
3430
3425
|
onClick: () => Fe(e),
|
|
3431
3426
|
children: /* @__PURE__ */ z($, {
|
|
3432
3427
|
name: "trash",
|
|
@@ -3435,21 +3430,21 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3435
3430
|
})] }, e.path))
|
|
3436
3431
|
})] }), G.length > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3437
3432
|
className: "seed-fm-section-label",
|
|
3438
|
-
children:
|
|
3439
|
-
}), ye === "grid" ? /* @__PURE__ */ z(
|
|
3433
|
+
children: oe ? xr(G.length, "result") : "Files"
|
|
3434
|
+
}), ye === "grid" ? /* @__PURE__ */ z(Qn, {
|
|
3440
3435
|
entries: G,
|
|
3441
|
-
selected:
|
|
3442
|
-
onActivate:
|
|
3436
|
+
selected: M,
|
|
3437
|
+
onActivate: Te,
|
|
3443
3438
|
onToggle: Se,
|
|
3444
3439
|
className: h.grid,
|
|
3445
3440
|
tileClassName: h.tile
|
|
3446
|
-
}) : /* @__PURE__ */ z(
|
|
3441
|
+
}) : /* @__PURE__ */ z($n, {
|
|
3447
3442
|
entries: G,
|
|
3448
|
-
selected:
|
|
3449
|
-
cwd:
|
|
3450
|
-
onActivate:
|
|
3443
|
+
selected: M,
|
|
3444
|
+
cwd: j,
|
|
3445
|
+
onActivate: Te,
|
|
3451
3446
|
onToggle: Se,
|
|
3452
|
-
onToggleAll:
|
|
3447
|
+
onToggleAll: Ee,
|
|
3453
3448
|
onDownload: (e) => ke([e]),
|
|
3454
3449
|
onDelete: (e) => Ne([e]),
|
|
3455
3450
|
deleteActionFor: (e) => je([e]),
|
|
@@ -3464,11 +3459,11 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3464
3459
|
children: /* @__PURE__ */ z("span", { className: "seed-fm-thumb seed-fm-skeleton" })
|
|
3465
3460
|
}, t))
|
|
3466
3461
|
});
|
|
3467
|
-
let
|
|
3462
|
+
let Ue = L ? X(L, !0) : [], We = V ? Pe(V) : [], Ge = M.size > 0 ? je(K) : null;
|
|
3468
3463
|
return /* @__PURE__ */ B("div", {
|
|
3469
3464
|
className: [w("root", "seed-fm"), m].filter(Boolean).join(" "),
|
|
3470
3465
|
"data-seed-theme": p === "none" ? void 0 : p,
|
|
3471
|
-
"data-selecting":
|
|
3466
|
+
"data-selecting": M.size > 0 || void 0,
|
|
3472
3467
|
onKeyDown: Le,
|
|
3473
3468
|
children: [
|
|
3474
3469
|
/* @__PURE__ */ B("div", {
|
|
@@ -3479,7 +3474,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3479
3474
|
children: [
|
|
3480
3475
|
/* @__PURE__ */ B("div", {
|
|
3481
3476
|
className: "seed-fm-titles",
|
|
3482
|
-
children: [/* @__PURE__ */ z(
|
|
3477
|
+
children: [/* @__PURE__ */ z(Be, {
|
|
3483
3478
|
className: "seed-fm-title",
|
|
3484
3479
|
children: u
|
|
3485
3480
|
}), d && /* @__PURE__ */ z("p", {
|
|
@@ -3487,9 +3482,9 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3487
3482
|
children: d
|
|
3488
3483
|
})]
|
|
3489
3484
|
}),
|
|
3490
|
-
ee && !D && /* @__PURE__ */ z(
|
|
3491
|
-
files:
|
|
3492
|
-
estimate:
|
|
3485
|
+
ee && !D && /* @__PURE__ */ z(Er, {
|
|
3486
|
+
files: O,
|
|
3487
|
+
estimate: re
|
|
3493
3488
|
}),
|
|
3494
3489
|
/* @__PURE__ */ z("button", {
|
|
3495
3490
|
type: "button",
|
|
@@ -3505,20 +3500,20 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3505
3500
|
})
|
|
3506
3501
|
]
|
|
3507
3502
|
}),
|
|
3508
|
-
ee && !D &&
|
|
3503
|
+
ee && !D && A.length > 0 && /* @__PURE__ */ B("div", {
|
|
3509
3504
|
className: w("toolbar", "seed-fm-toolbar"),
|
|
3510
3505
|
children: [
|
|
3511
3506
|
/* @__PURE__ */ z("nav", {
|
|
3512
3507
|
"aria-label": "Folder",
|
|
3513
3508
|
children: /* @__PURE__ */ z("ol", {
|
|
3514
3509
|
className: "seed-fm-crumbs",
|
|
3515
|
-
children:
|
|
3510
|
+
children: Z.map((e, t) => /* @__PURE__ */ B("li", { children: [t > 0 && /* @__PURE__ */ z($, {
|
|
3516
3511
|
name: "chevronRight",
|
|
3517
3512
|
size: 14
|
|
3518
3513
|
}), /* @__PURE__ */ z("button", {
|
|
3519
3514
|
type: "button",
|
|
3520
|
-
onClick: () =>
|
|
3521
|
-
"aria-current": t ===
|
|
3515
|
+
onClick: () => J(e.path),
|
|
3516
|
+
"aria-current": t === Z.length - 1 ? "page" : void 0,
|
|
3522
3517
|
children: e.label
|
|
3523
3518
|
})] }, e.path || "/"))
|
|
3524
3519
|
})
|
|
@@ -3530,8 +3525,8 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3530
3525
|
size: 14
|
|
3531
3526
|
}), /* @__PURE__ */ z("input", {
|
|
3532
3527
|
type: "search",
|
|
3533
|
-
value:
|
|
3534
|
-
onChange: (e) =>
|
|
3528
|
+
value: oe,
|
|
3529
|
+
onChange: (e) => se(e.target.value),
|
|
3535
3530
|
placeholder: "Search names and paths",
|
|
3536
3531
|
"aria-label": "Search files"
|
|
3537
3532
|
})]
|
|
@@ -3564,7 +3559,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3564
3559
|
type: "button",
|
|
3565
3560
|
"aria-pressed": ye === "grid",
|
|
3566
3561
|
"aria-label": "Grid view",
|
|
3567
|
-
onClick: () =>
|
|
3562
|
+
onClick: () => de("grid"),
|
|
3568
3563
|
children: /* @__PURE__ */ z($, {
|
|
3569
3564
|
name: "layoutGrid",
|
|
3570
3565
|
size: 15
|
|
@@ -3573,7 +3568,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3573
3568
|
type: "button",
|
|
3574
3569
|
"aria-pressed": ye === "list",
|
|
3575
3570
|
"aria-label": "List view",
|
|
3576
|
-
onClick: () =>
|
|
3571
|
+
onClick: () => de("list"),
|
|
3577
3572
|
children: /* @__PURE__ */ z($, {
|
|
3578
3573
|
name: "list",
|
|
3579
3574
|
size: 15
|
|
@@ -3587,14 +3582,14 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3587
3582
|
name: "layers",
|
|
3588
3583
|
size: 13
|
|
3589
3584
|
}),
|
|
3590
|
-
|
|
3585
|
+
ie ? "Resized copies are grouped with their original image." : "Resized copies are shown in their size folders.",
|
|
3591
3586
|
/* @__PURE__ */ z("button", {
|
|
3592
3587
|
type: "button",
|
|
3593
3588
|
className: "seed-fm-linkbtn",
|
|
3594
3589
|
onClick: () => {
|
|
3595
|
-
|
|
3590
|
+
k(!ie), N(/* @__PURE__ */ new Set());
|
|
3596
3591
|
},
|
|
3597
|
-
children:
|
|
3592
|
+
children: ie ? "Show as folders" : "Group with originals"
|
|
3598
3593
|
})
|
|
3599
3594
|
]
|
|
3600
3595
|
})
|
|
@@ -3602,7 +3597,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3602
3597
|
}),
|
|
3603
3598
|
/* @__PURE__ */ z("div", {
|
|
3604
3599
|
className: w("body", "seed-fm-body"),
|
|
3605
|
-
children:
|
|
3600
|
+
children: He
|
|
3606
3601
|
}),
|
|
3607
3602
|
Ge && /* @__PURE__ */ B("div", {
|
|
3608
3603
|
className: w("batchBar", "seed-fm-batch"),
|
|
@@ -3613,15 +3608,15 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3613
3608
|
className: "seed-fm-batch-count",
|
|
3614
3609
|
"aria-live": "polite",
|
|
3615
3610
|
children: [
|
|
3616
|
-
|
|
3611
|
+
M.size,
|
|
3617
3612
|
" selected ",
|
|
3618
|
-
/* @__PURE__ */ B("span", { children: ["· ", Q(
|
|
3613
|
+
/* @__PURE__ */ B("span", { children: ["· ", Q(Ve)] })
|
|
3619
3614
|
]
|
|
3620
3615
|
}),
|
|
3621
3616
|
/* @__PURE__ */ B("button", {
|
|
3622
3617
|
type: "button",
|
|
3623
3618
|
className: "seed-fm-btn",
|
|
3624
|
-
disabled:
|
|
3619
|
+
disabled: he,
|
|
3625
3620
|
onClick: () => ke(K),
|
|
3626
3621
|
children: [
|
|
3627
3622
|
/* @__PURE__ */ z($, {
|
|
@@ -3629,13 +3624,13 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3629
3624
|
size: 15
|
|
3630
3625
|
}),
|
|
3631
3626
|
" ",
|
|
3632
|
-
|
|
3627
|
+
M.size > 1 ? "Download .zip" : "Download"
|
|
3633
3628
|
]
|
|
3634
3629
|
}),
|
|
3635
3630
|
/* @__PURE__ */ B("button", {
|
|
3636
3631
|
type: "button",
|
|
3637
3632
|
className: `seed-fm-btn${Ge.destructive ? " seed-fm-btn--danger-text" : ""}`,
|
|
3638
|
-
disabled:
|
|
3633
|
+
disabled: he,
|
|
3639
3634
|
onClick: () => Ne(K),
|
|
3640
3635
|
children: [
|
|
3641
3636
|
/* @__PURE__ */ z($, {
|
|
@@ -3650,7 +3645,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3650
3645
|
type: "button",
|
|
3651
3646
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3652
3647
|
"aria-label": "Clear selection",
|
|
3653
|
-
onClick: () =>
|
|
3648
|
+
onClick: () => N(/* @__PURE__ */ new Set()),
|
|
3654
3649
|
children: /* @__PURE__ */ z($, {
|
|
3655
3650
|
name: "x",
|
|
3656
3651
|
size: 15
|
|
@@ -3660,47 +3655,47 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3660
3655
|
})
|
|
3661
3656
|
]
|
|
3662
3657
|
}),
|
|
3663
|
-
q && /* @__PURE__ */ z(
|
|
3658
|
+
q && /* @__PURE__ */ z(rr, {
|
|
3664
3659
|
entry: q,
|
|
3665
3660
|
className: h.panel,
|
|
3666
|
-
onClose:
|
|
3667
|
-
onPrevious:
|
|
3668
|
-
onNext:
|
|
3661
|
+
onClose: we,
|
|
3662
|
+
onPrevious: xe > 0 ? () => I(G[xe - 1].file.path) : null,
|
|
3663
|
+
onNext: xe >= 0 && xe < G.length - 1 ? () => I(G[xe + 1].file.path) : null,
|
|
3669
3664
|
onDownload: () => ke([q]),
|
|
3670
3665
|
onDelete: () => Ne([q]),
|
|
3671
3666
|
deleteAction: je([q]),
|
|
3672
3667
|
onCopyPath: () => Ie(q.file.path)
|
|
3673
3668
|
}, "panel"),
|
|
3674
|
-
|
|
3675
|
-
entries:
|
|
3669
|
+
L && /* @__PURE__ */ z(hn, {
|
|
3670
|
+
entries: L,
|
|
3676
3671
|
rootPath: S,
|
|
3677
|
-
warning: v(
|
|
3678
|
-
deleteActionFor: (e) => Ae(X(
|
|
3672
|
+
warning: v(Ue),
|
|
3673
|
+
deleteActionFor: (e) => Ae(X(L, e)),
|
|
3679
3674
|
className: h.dialog,
|
|
3680
|
-
onCancel: () =>
|
|
3675
|
+
onCancel: () => pe(null),
|
|
3681
3676
|
onConfirm: (e) => {
|
|
3682
|
-
let t = X(
|
|
3683
|
-
|
|
3677
|
+
let t = X(L, e);
|
|
3678
|
+
pe(null), Me(t);
|
|
3684
3679
|
}
|
|
3685
3680
|
}),
|
|
3686
|
-
|
|
3687
|
-
folder:
|
|
3688
|
-
files:
|
|
3689
|
-
hiddenCount: T.filter((e) => e.path.startsWith(`${
|
|
3690
|
-
warning: v(
|
|
3691
|
-
action: Ae(
|
|
3692
|
-
busy:
|
|
3681
|
+
V && /* @__PURE__ */ z(gn, {
|
|
3682
|
+
folder: V,
|
|
3683
|
+
files: We,
|
|
3684
|
+
hiddenCount: T.filter((e) => e.path.startsWith(`${V.path}/`)).length - We.length,
|
|
3685
|
+
warning: v(We),
|
|
3686
|
+
action: Ae(We),
|
|
3687
|
+
busy: he,
|
|
3693
3688
|
className: h.dialog,
|
|
3694
|
-
onDownload: () => Oe(
|
|
3695
|
-
onCancel: () =>
|
|
3689
|
+
onDownload: () => Oe(We, V),
|
|
3690
|
+
onCancel: () => me(null),
|
|
3696
3691
|
onConfirm: () => {
|
|
3697
|
-
|
|
3692
|
+
me(null), Me(We, V);
|
|
3698
3693
|
}
|
|
3699
3694
|
}),
|
|
3700
3695
|
!x && /* @__PURE__ */ z("ul", {
|
|
3701
3696
|
className: "seed-fm-toasts",
|
|
3702
3697
|
"aria-live": "polite",
|
|
3703
|
-
children:
|
|
3698
|
+
children: U.map((e) => /* @__PURE__ */ B("li", {
|
|
3704
3699
|
className: w("toast", `seed-fm-toast${e.tone === "error" ? " seed-fm-toast--error" : ""}`),
|
|
3705
3700
|
children: [/* @__PURE__ */ z($, {
|
|
3706
3701
|
name: e.tone === "error" ? "triangleAlert" : "check",
|
|
@@ -3714,95 +3709,111 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3714
3709
|
}
|
|
3715
3710
|
//#endregion
|
|
3716
3711
|
//#region src/useEnsureLocalImage.ts
|
|
3717
|
-
var
|
|
3712
|
+
var kr = (e) => {
|
|
3718
3713
|
try {
|
|
3719
3714
|
return e.getService?.()?.getSnapshot?.()?.context?.storageTransactionId || void 0;
|
|
3720
3715
|
} catch {
|
|
3721
3716
|
return;
|
|
3722
3717
|
}
|
|
3723
3718
|
};
|
|
3724
|
-
function
|
|
3725
|
-
let { imageProperty: t, filename:
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
]),
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
]),
|
|
3735
|
-
if (
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3719
|
+
function Ar(e) {
|
|
3720
|
+
let { imageProperty: t, filename: r, width: a, enabled: s = !0 } = e, [l, d] = c(null), [f, p] = c("idle"), m = t?.refResolvedValue, h = t?.value, g = typeof h == "string" ? h : void 0, _ = kr(t), v = o(() => ae(_) ?? ae(r) ?? ae(m) ?? ae(g), [
|
|
3721
|
+
_,
|
|
3722
|
+
r,
|
|
3723
|
+
m,
|
|
3724
|
+
g
|
|
3725
|
+
]), y = o(() => (r ?? (typeof m == "string" ? m : void 0) ?? g)?.trim() || void 0, [
|
|
3726
|
+
r,
|
|
3727
|
+
m,
|
|
3728
|
+
g
|
|
3729
|
+
]), b = o(() => {
|
|
3730
|
+
if (!v) return [];
|
|
3731
|
+
let e = [];
|
|
3732
|
+
try {
|
|
3733
|
+
for (let t of D()) {
|
|
3734
|
+
let n = `${t.replace(/\/$/, "")}/raw/${v}`;
|
|
3735
|
+
e.includes(n) || e.push(n);
|
|
3736
|
+
}
|
|
3737
|
+
} catch {}
|
|
3738
|
+
try {
|
|
3739
|
+
let t = u.getRawUrl(v);
|
|
3740
|
+
t && !e.includes(t) && e.push(t);
|
|
3741
|
+
} catch {}
|
|
3742
|
+
return e;
|
|
3743
|
+
}, [v]), [x, S] = c(0);
|
|
3744
|
+
i(() => {
|
|
3745
|
+
S(0);
|
|
3746
|
+
}, [b]);
|
|
3747
|
+
let C = b[x], w = n(() => {
|
|
3748
|
+
S((e) => e < b.length ? e + 1 : e);
|
|
3749
|
+
}, [b]);
|
|
3741
3750
|
return i(() => {
|
|
3742
3751
|
let e = !1;
|
|
3743
3752
|
return (async () => {
|
|
3744
|
-
if (!
|
|
3745
|
-
else if (!
|
|
3753
|
+
if (!s) e || (d(null), p("idle"));
|
|
3754
|
+
else if (!v && !y) e || (d(null), p("idle"));
|
|
3746
3755
|
else {
|
|
3747
|
-
e ||
|
|
3756
|
+
e || p("loading");
|
|
3748
3757
|
try {
|
|
3749
3758
|
let t = await T({
|
|
3750
|
-
transactionId:
|
|
3751
|
-
fileName:
|
|
3752
|
-
widths:
|
|
3759
|
+
transactionId: v,
|
|
3760
|
+
fileName: y,
|
|
3761
|
+
widths: a == null ? void 0 : [a]
|
|
3753
3762
|
});
|
|
3754
3763
|
if (e) return;
|
|
3755
|
-
|
|
3764
|
+
d(t), p(t.status);
|
|
3756
3765
|
} catch {
|
|
3757
3766
|
if (e) return;
|
|
3758
|
-
|
|
3767
|
+
d({ status: "failed" }), p("failed");
|
|
3759
3768
|
}
|
|
3760
3769
|
}
|
|
3761
3770
|
})(), () => {
|
|
3762
3771
|
e = !0;
|
|
3763
3772
|
};
|
|
3764
3773
|
}, [
|
|
3765
|
-
|
|
3766
|
-
_,
|
|
3774
|
+
s,
|
|
3767
3775
|
v,
|
|
3768
|
-
|
|
3776
|
+
y,
|
|
3777
|
+
a
|
|
3769
3778
|
]), {
|
|
3770
|
-
status:
|
|
3771
|
-
gatewayHref:
|
|
3772
|
-
|
|
3779
|
+
status: f,
|
|
3780
|
+
gatewayHref: C,
|
|
3781
|
+
gatewayHrefs: b,
|
|
3782
|
+
onGatewayError: w,
|
|
3783
|
+
result: l
|
|
3773
3784
|
};
|
|
3774
3785
|
}
|
|
3775
3786
|
//#endregion
|
|
3776
3787
|
//#region src/SeedImage.tsx
|
|
3777
|
-
var
|
|
3788
|
+
var jr = L("seedSdk:react:SeedImage"), Mr = /* @__PURE__ */ new Map(), Nr = (e) => {
|
|
3778
3789
|
let t = e.match(/^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/);
|
|
3779
3790
|
return t && t[2] ? t[2] : e;
|
|
3780
3791
|
};
|
|
3781
|
-
function
|
|
3792
|
+
function Pr(e) {
|
|
3782
3793
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3783
3794
|
}
|
|
3784
|
-
function
|
|
3785
|
-
let n = RegExp(`^${
|
|
3795
|
+
function Fr(e, t) {
|
|
3796
|
+
let n = RegExp(`^${Pr(t)}$`), r = Nr(e);
|
|
3786
3797
|
return n.test(r);
|
|
3787
3798
|
}
|
|
3788
|
-
var
|
|
3789
|
-
let [s, l] = c(), [u, d] = c(), { property: p } =
|
|
3799
|
+
var Ir = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o }) => {
|
|
3800
|
+
let [s, l] = c(), [u, d] = c(), { property: p } = Ve({
|
|
3790
3801
|
propertyName: t.propertyName,
|
|
3791
3802
|
seedLocalId: t.seedLocalId,
|
|
3792
3803
|
seedUid: t.seedUid
|
|
3793
|
-
}), m = t ?? p, h = r ?? m?.refResolvedValue ?? m?.value, { status: g, gatewayHref: _ } =
|
|
3804
|
+
}), m = t ?? p, h = r ?? m?.refResolvedValue ?? m?.value, { status: g, gatewayHref: _, onGatewayError: v } = Ar({
|
|
3794
3805
|
imageProperty: m ?? t,
|
|
3795
3806
|
filename: r,
|
|
3796
3807
|
width: n,
|
|
3797
3808
|
enabled: a
|
|
3798
|
-
}),
|
|
3809
|
+
}), y = m?.value, b = typeof y == "string" ? y : h, x = y != null && (y instanceof File || y instanceof Blob), [S, C] = c(null), w = e.useRef(null);
|
|
3799
3810
|
i(() => {
|
|
3800
|
-
if (
|
|
3801
|
-
|
|
3811
|
+
if (x && (y instanceof File || y instanceof Blob)) return w.current || (w.current = URL.createObjectURL(y), C(w.current)), () => {
|
|
3812
|
+
w.current && (URL.revokeObjectURL(w.current), w.current = null), C(null);
|
|
3802
3813
|
};
|
|
3803
|
-
|
|
3804
|
-
}, [
|
|
3805
|
-
if (!h ||
|
|
3814
|
+
w.current = null, C(null);
|
|
3815
|
+
}, [x, y]), i(() => {
|
|
3816
|
+
if (!h || y && ((e) => typeof e == "string" && e.startsWith("blob:"))(y) || S) return;
|
|
3806
3817
|
let e = !1;
|
|
3807
3818
|
return (async () => {
|
|
3808
3819
|
try {
|
|
@@ -3812,15 +3823,15 @@ var Nr = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o
|
|
|
3812
3823
|
!e && n && d(n);
|
|
3813
3824
|
}
|
|
3814
3825
|
} catch (e) {
|
|
3815
|
-
|
|
3826
|
+
jr("_getOriginalContentUrl error", e);
|
|
3816
3827
|
}
|
|
3817
3828
|
})(), () => {
|
|
3818
3829
|
e = !0;
|
|
3819
3830
|
};
|
|
3820
3831
|
}, [
|
|
3821
3832
|
h,
|
|
3822
|
-
|
|
3823
|
-
|
|
3833
|
+
y,
|
|
3834
|
+
S,
|
|
3824
3835
|
m?.localStoragePath,
|
|
3825
3836
|
g
|
|
3826
3837
|
]), i(() => {
|
|
@@ -3828,46 +3839,49 @@ var Nr = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o
|
|
|
3828
3839
|
try {
|
|
3829
3840
|
let e = await f.getFs(), t = m?.localStoragePath ? m.localStoragePath.split("/").slice(0, -1).join("/") : f.getFilesPath("images"), r = e.readdirSync(t, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => parseInt(e.name)).filter((e) => !Number.isNaN(e));
|
|
3830
3841
|
if (r.length === 0) return;
|
|
3831
|
-
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a =
|
|
3832
|
-
if (
|
|
3833
|
-
let e =
|
|
3842
|
+
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a = Nr(h), o = `${a}-${i}`;
|
|
3843
|
+
if (Mr.has(o)) try {
|
|
3844
|
+
let e = Mr.get(o);
|
|
3834
3845
|
if (e && (await fetch(e)).ok) {
|
|
3835
3846
|
l(e);
|
|
3836
3847
|
return;
|
|
3837
3848
|
}
|
|
3838
3849
|
} catch (e) {
|
|
3839
|
-
|
|
3850
|
+
jr("error", e), Mr.delete(o);
|
|
3840
3851
|
}
|
|
3841
|
-
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ?
|
|
3852
|
+
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ? Fr(e.name, a) : !1);
|
|
3842
3853
|
if (!s) return;
|
|
3843
3854
|
let c = `${t}/${i}/${s?.name}`;
|
|
3844
3855
|
if (await f.pathExists(c)) {
|
|
3845
3856
|
let e = await f.getContentUrlFromPath(c);
|
|
3846
|
-
e && (
|
|
3857
|
+
e && (Mr.set(o, e), l(e));
|
|
3847
3858
|
}
|
|
3848
3859
|
} catch (e) {
|
|
3849
|
-
|
|
3860
|
+
jr("_getSizedContentUrl error", e);
|
|
3850
3861
|
}
|
|
3851
3862
|
})();
|
|
3852
3863
|
}, [
|
|
3853
3864
|
m,
|
|
3854
3865
|
n,
|
|
3855
|
-
|
|
3866
|
+
b,
|
|
3856
3867
|
h,
|
|
3857
3868
|
g
|
|
3858
3869
|
]);
|
|
3859
|
-
let
|
|
3860
|
-
if (!
|
|
3861
|
-
let
|
|
3870
|
+
let T = (e) => typeof e == "string" && e.startsWith("blob:"), E = !!s || !!u || !!S || !!b && T(b);
|
|
3871
|
+
if (!E && !h && !_) return null;
|
|
3872
|
+
let ee = s || u || S || (T(b) ? b : void 0) || (a && !E ? _ : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", { onError: D, ...te } = o, ne = (e) => {
|
|
3873
|
+
_ && ee === _ && v(), D?.(e);
|
|
3874
|
+
};
|
|
3862
3875
|
return /* @__PURE__ */ z("img", {
|
|
3863
|
-
src:
|
|
3876
|
+
src: ee,
|
|
3864
3877
|
alt: o.alt || t.propertyName || "Image",
|
|
3865
|
-
...
|
|
3878
|
+
...te,
|
|
3879
|
+
onError: ne
|
|
3866
3880
|
});
|
|
3867
3881
|
}, (e, t) => e.imageProperty === t.imageProperty && e.width === t.width && e.height === t.height && e.filename === t.filename && e.ensure === t.ensure);
|
|
3868
3882
|
//#endregion
|
|
3869
3883
|
//#region src/useResolvedMediaRef.ts
|
|
3870
|
-
function
|
|
3884
|
+
function Lr(e) {
|
|
3871
3885
|
let { value: t, enabled: r = !0, treatAs: a } = e, [o, s] = c(0), [l, u] = c(null), [d, f] = c(null), [p, m] = c("idle");
|
|
3872
3886
|
i(() => {
|
|
3873
3887
|
let e = !1;
|
|
@@ -3876,7 +3890,7 @@ function Pr(e) {
|
|
|
3876
3890
|
else {
|
|
3877
3891
|
e || (m("loading"), f(null));
|
|
3878
3892
|
try {
|
|
3879
|
-
let n = await
|
|
3893
|
+
let n = await M(String(t), { treatAs: a });
|
|
3880
3894
|
if (e) return;
|
|
3881
3895
|
u(n), n.status === "empty" ? m("empty") : n.status === "ready" ? m("ready") : m("unresolved");
|
|
3882
3896
|
} catch (t) {
|
|
@@ -3907,8 +3921,8 @@ function Pr(e) {
|
|
|
3907
3921
|
}
|
|
3908
3922
|
//#endregion
|
|
3909
3923
|
//#region src/SeedMediaImage.tsx
|
|
3910
|
-
function
|
|
3911
|
-
let { href: o } =
|
|
3924
|
+
function Rr({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
3925
|
+
let { href: o } = Lr({
|
|
3912
3926
|
value: e,
|
|
3913
3927
|
enabled: t,
|
|
3914
3928
|
treatAs: n
|
|
@@ -3923,14 +3937,14 @@ function Fr({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
|
3923
3937
|
}
|
|
3924
3938
|
//#endregion
|
|
3925
3939
|
//#region src/SeedMediaFile.tsx
|
|
3926
|
-
function
|
|
3940
|
+
function zr(e) {
|
|
3927
3941
|
try {
|
|
3928
3942
|
return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
|
|
3929
3943
|
} catch {
|
|
3930
3944
|
return "Open";
|
|
3931
3945
|
}
|
|
3932
3946
|
}
|
|
3933
|
-
function
|
|
3947
|
+
function Br(e) {
|
|
3934
3948
|
try {
|
|
3935
3949
|
let t = new URL(e).protocol;
|
|
3936
3950
|
return t === "http:" || t === "https:";
|
|
@@ -3938,27 +3952,27 @@ function Lr(e) {
|
|
|
3938
3952
|
return !1;
|
|
3939
3953
|
}
|
|
3940
3954
|
}
|
|
3941
|
-
function
|
|
3942
|
-
let { href: l } =
|
|
3955
|
+
function Vr({ value: e, enabled: t, treatAs: n, download: r, render: i, children: a, target: o, rel: s, ...c }) {
|
|
3956
|
+
let { href: l } = Lr({
|
|
3943
3957
|
value: e,
|
|
3944
3958
|
enabled: t,
|
|
3945
3959
|
treatAs: n
|
|
3946
3960
|
});
|
|
3947
3961
|
if (!l) return null;
|
|
3948
|
-
let u =
|
|
3962
|
+
let u = Br(l), d = o === void 0 ? u ? "_blank" : void 0 : o, f = {
|
|
3949
3963
|
...c,
|
|
3950
3964
|
href: l,
|
|
3951
3965
|
download: r,
|
|
3952
3966
|
target: d,
|
|
3953
3967
|
rel: s ?? (u && d === "_blank" ? "noopener noreferrer" : void 0),
|
|
3954
|
-
children: a ??
|
|
3968
|
+
children: a ?? zr(l)
|
|
3955
3969
|
};
|
|
3956
3970
|
return i ? /* @__PURE__ */ z(R, { children: i(f) }) : /* @__PURE__ */ z("a", { ...f });
|
|
3957
3971
|
}
|
|
3958
3972
|
//#endregion
|
|
3959
3973
|
//#region src/SeedMediaAudio.tsx
|
|
3960
|
-
function
|
|
3961
|
-
let { href: o } =
|
|
3974
|
+
function Hr({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
3975
|
+
let { href: o } = Lr({
|
|
3962
3976
|
value: e,
|
|
3963
3977
|
enabled: t,
|
|
3964
3978
|
treatAs: n
|
|
@@ -3973,8 +3987,8 @@ function zr({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
3973
3987
|
}
|
|
3974
3988
|
//#endregion
|
|
3975
3989
|
//#region src/SeedMediaVideo.tsx
|
|
3976
|
-
function
|
|
3977
|
-
let { href: o } =
|
|
3990
|
+
function Ur({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
3991
|
+
let { href: o } = Lr({
|
|
3978
3992
|
value: e,
|
|
3979
3993
|
enabled: t,
|
|
3980
3994
|
treatAs: n
|
|
@@ -3989,11 +4003,11 @@ function Br({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
3989
4003
|
}
|
|
3990
4004
|
//#endregion
|
|
3991
4005
|
//#region src/SeedHtml.tsx
|
|
3992
|
-
function
|
|
4006
|
+
function Wr(e) {
|
|
3993
4007
|
return typeof e == "string" && e.trim().length > 0;
|
|
3994
4008
|
}
|
|
3995
|
-
function
|
|
3996
|
-
if (!
|
|
4009
|
+
function Gr({ html: e, sanitize: t, render: n, ...r }) {
|
|
4010
|
+
if (!Wr(e)) return null;
|
|
3997
4011
|
let i = t(e);
|
|
3998
4012
|
return n ? /* @__PURE__ */ z(R, { children: n({ html: i }) }) : /* @__PURE__ */ z("div", {
|
|
3999
4013
|
...r,
|
|
@@ -4002,41 +4016,41 @@ function Hr({ html: e, sanitize: t, render: n, ...r }) {
|
|
|
4002
4016
|
}
|
|
4003
4017
|
//#endregion
|
|
4004
4018
|
//#region src/formatSeedJson.ts
|
|
4005
|
-
function
|
|
4019
|
+
function Kr(e, t) {
|
|
4006
4020
|
return e.length <= t ? e : `${e.slice(0, t)}…`;
|
|
4007
4021
|
}
|
|
4008
|
-
function
|
|
4022
|
+
function qr(e) {
|
|
4009
4023
|
let t = e.trim();
|
|
4010
4024
|
return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
|
|
4011
4025
|
}
|
|
4012
|
-
function
|
|
4026
|
+
function Jr(e, t, n, r, i) {
|
|
4013
4027
|
if (typeof e == "bigint") return String(e);
|
|
4014
4028
|
if (typeof e == "symbol") return e.toString();
|
|
4015
4029
|
if (typeof e == "function") return "[Function]";
|
|
4016
4030
|
if (e instanceof Date) return e.toISOString();
|
|
4017
|
-
if (typeof e == "string") return
|
|
4031
|
+
if (typeof e == "string") return Kr(e, n);
|
|
4018
4032
|
if (typeof e != "object" || !e) return e;
|
|
4019
4033
|
if (i.has(e)) return "[Circular]";
|
|
4020
4034
|
if (r >= t) return "[Max depth]";
|
|
4021
|
-
if (i.add(e), Array.isArray(e)) return e.map((e) =>
|
|
4035
|
+
if (i.add(e), Array.isArray(e)) return e.map((e) => Jr(e, t, n, r + 1, i));
|
|
4022
4036
|
let a = {};
|
|
4023
|
-
for (let [o, s] of Object.entries(e)) a[o] =
|
|
4037
|
+
for (let [o, s] of Object.entries(e)) a[o] = Jr(s, t, n, r + 1, i);
|
|
4024
4038
|
return a;
|
|
4025
4039
|
}
|
|
4026
|
-
function
|
|
4040
|
+
function Yr(e, t) {
|
|
4027
4041
|
let n = t?.maxDepth ?? 6, r = t?.maxStringLength ?? 5e4, i = t?.space ?? 2;
|
|
4028
4042
|
if (e === void 0) return "undefined";
|
|
4029
4043
|
if (e === null) return "null";
|
|
4030
4044
|
let a = e;
|
|
4031
4045
|
if (typeof e == "string") {
|
|
4032
|
-
if (
|
|
4046
|
+
if (qr(e)) try {
|
|
4033
4047
|
a = JSON.parse(e);
|
|
4034
4048
|
} catch {
|
|
4035
|
-
return
|
|
4049
|
+
return Kr(e, r);
|
|
4036
4050
|
}
|
|
4037
|
-
else return
|
|
4051
|
+
else return Kr(e, r);
|
|
4038
4052
|
}
|
|
4039
|
-
let o =
|
|
4053
|
+
let o = Jr(a, n, r, 0, /* @__PURE__ */ new WeakSet());
|
|
4040
4054
|
try {
|
|
4041
4055
|
return JSON.stringify(o, null, i);
|
|
4042
4056
|
} catch {
|
|
@@ -4045,8 +4059,8 @@ function Kr(e, t) {
|
|
|
4045
4059
|
}
|
|
4046
4060
|
//#endregion
|
|
4047
4061
|
//#region src/SeedJson.tsx
|
|
4048
|
-
function
|
|
4049
|
-
let a = t ? t(e) :
|
|
4062
|
+
function Xr({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
4063
|
+
let a = t ? t(e) : Yr(e, n);
|
|
4050
4064
|
return r ? /* @__PURE__ */ z(R, { children: r({ text: a }) }) : /* @__PURE__ */ z("pre", {
|
|
4051
4065
|
...i,
|
|
4052
4066
|
children: a
|
|
@@ -4054,10 +4068,10 @@ function qr({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
|
4054
4068
|
}
|
|
4055
4069
|
//#endregion
|
|
4056
4070
|
//#region src/useNormalizedFeedItemFields.ts
|
|
4057
|
-
function
|
|
4071
|
+
function Zr(e, t) {
|
|
4058
4072
|
return o(() => e ? oe(e, t) : {}, [e, t]);
|
|
4059
4073
|
}
|
|
4060
4074
|
//#endregion
|
|
4061
|
-
export {
|
|
4075
|
+
export { Se as ADDRESSES_PERSISTED_EVENT, At as FILES_QUERY_KEY_PREFIX, Ce as LOCAL_COPIES_REMOVED_EVENT, Or as OPFSFilesManager, cr as OPFS_FILES_MANAGER_CSS, Ht as SeedClientGate, Gr as SeedHtml, Ir as SeedImage, Xr as SeedJson, Hr as SeedMediaAudio, Vr as SeedMediaFile, Rr as SeedMediaImage, Ur as SeedMediaVideo, Bt as SeedProvider, X as createSeedQueryClient, Yr as formatSeedJson, Be as getItemPropertyQueryKey, Ne as getItemQueryKey, Oe as getSeedQueryDefaultOptions, Ye as getServiceName, Ze as getServiceUniqueKey, Xe as getServiceValue, Rt as invalidateItemPropertiesForItem, ke as mergeSeedQueryDefaults, dt as useAllSchemaVersions, Le as useCreateItem, Ge as useCreateItemProperty, _t as useCreateModel, Tt as useCreateModelProperty, lt as useCreateSchema, it as useDbsAreReady, He as useDebouncedItemProperty, Dt as useDeleteItem, Ke as useDestroyItemProperty, vt as useDestroyModel, Et as useDestroyModelProperty, ut as useDestroySchema, It as useEasSyncProcessById, Pt as useEasSyncProcesses, Ft as useEasSyncProcessesNonActiveCount, Nt as useEasSyncProcessesState, Ar as useEnsureLocalImage, jt as useFiles, rt as useGlobalServiceStatus, tt as useHasSavedSnapshots, kt as useImageFiles, $e as useIsDbReady, Pe as useItem, We as useItemProperties, Ve as useItemProperty, Ie as useItems, Y as useLiveQuery, gt as useModel, yt as useModelProperties, wt as useModelProperty, ht as useModels, Zr as useNormalizedFeedItemFields, rn as useOPFSFiles, et as usePersistedSnapshots, Re as usePublishItem, Lr as useResolvedMediaRef, ot as useSchema, ct as useSchemas, Te as useSeedAddressRevision, ft as useSeedProtocolSchema, Qe as useService, nt as useServices };
|
|
4062
4076
|
|
|
4063
4077
|
//# sourceMappingURL=index.js.map
|