@seedprotocol/react 0.7.2 → 0.7.3-next.654.g52217f6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SeedImage.d.ts.map +1 -1
- package/dist/index.js +653 -634
- package/dist/index.js.map +1 -1
- 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,7 +303,7 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
303
303
|
error: r,
|
|
304
304
|
resetError: a
|
|
305
305
|
};
|
|
306
|
-
},
|
|
306
|
+
}, Re = () => {
|
|
307
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
308
|
e && (t(e), l(null), e.publish().catch(() => {}));
|
|
309
309
|
}, []);
|
|
@@ -332,15 +332,15 @@ var X = I("seedSdk:react:item"), Ae = (e) => [
|
|
|
332
332
|
error: o,
|
|
333
333
|
resetError: d
|
|
334
334
|
};
|
|
335
|
-
},
|
|
335
|
+
}, ze = L("seedSdk:react:property"), Z = L("seedSdk:react:itemProperties"), Be = (e, t, n) => [
|
|
336
336
|
"seed",
|
|
337
337
|
"itemProperty",
|
|
338
338
|
e ?? null,
|
|
339
339
|
t ?? null,
|
|
340
340
|
n
|
|
341
341
|
];
|
|
342
|
-
function
|
|
343
|
-
let n =
|
|
342
|
+
function Ve(e, t) {
|
|
343
|
+
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
344
|
let e = p !== void 0 && p !== "" ? p : u, t = p !== void 0 && p !== "" ? void 0 : d;
|
|
345
345
|
return (e || t) && m ? {
|
|
346
346
|
type: "identifiers",
|
|
@@ -353,7 +353,7 @@ function ze(e, t) {
|
|
|
353
353
|
m,
|
|
354
354
|
u,
|
|
355
355
|
d
|
|
356
|
-
]), g = o(() =>
|
|
356
|
+
]), g = o(() => Be(h?.seedLocalId, h?.seedUid, h?.propertyName ?? ""), [h]), v = H({
|
|
357
357
|
queryKey: g,
|
|
358
358
|
queryFn: async () => {
|
|
359
359
|
if (!h) return null;
|
|
@@ -362,7 +362,7 @@ function ze(e, t) {
|
|
|
362
362
|
seedLocalId: h.seedLocalId,
|
|
363
363
|
seedUid: h.seedUid
|
|
364
364
|
});
|
|
365
|
-
return e ||
|
|
365
|
+
return e || ze(`[useItemProperty] no property found for Item.${h.seedLocalId || h.seedUid}.${h.propertyName}`), e ?? null;
|
|
366
366
|
},
|
|
367
367
|
initialData: () => h ? _.peekReady(h) : void 0,
|
|
368
368
|
staleTime: 0,
|
|
@@ -390,8 +390,8 @@ function ze(e, t) {
|
|
|
390
390
|
error: v.error
|
|
391
391
|
};
|
|
392
392
|
}
|
|
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 } =
|
|
393
|
+
function He(e, t = 300) {
|
|
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 } = Ve(o(() => r ? {
|
|
395
395
|
seedLocalId: r,
|
|
396
396
|
propertyName: l
|
|
397
397
|
} : {
|
|
@@ -403,7 +403,7 @@ function Be(e, t = 300) {
|
|
|
403
403
|
a,
|
|
404
404
|
c,
|
|
405
405
|
l
|
|
406
|
-
])), p = s(""), m = o(() =>
|
|
406
|
+
])), p = s(""), m = o(() => F((e) => {
|
|
407
407
|
e.getService().send({
|
|
408
408
|
type: "save",
|
|
409
409
|
newValue: p.current
|
|
@@ -422,7 +422,7 @@ function Be(e, t = 300) {
|
|
|
422
422
|
error: f
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
|
-
async function
|
|
425
|
+
async function Ue(e, t) {
|
|
426
426
|
if (!e && !t) return [];
|
|
427
427
|
let n = d.getAppDb();
|
|
428
428
|
if (!n) return [];
|
|
@@ -434,19 +434,19 @@ async function Ve(e, t) {
|
|
|
434
434
|
let o;
|
|
435
435
|
if (r.length > 0) {
|
|
436
436
|
let e = r[0];
|
|
437
|
-
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o =
|
|
437
|
+
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o = fe(o));
|
|
438
438
|
}
|
|
439
439
|
let s = await n.select({
|
|
440
|
-
type:
|
|
441
|
-
modelFileId:
|
|
442
|
-
}).from(
|
|
443
|
-
!o && s.length > 0 && s[0].type && (o =
|
|
440
|
+
type: P.type,
|
|
441
|
+
modelFileId: P.modelFileId
|
|
442
|
+
}).from(P).where(t ? W(P.uid, t) : W(P.localId, e)).limit(1), c = s[0]?.modelFileId ?? void 0;
|
|
443
|
+
!o && s.length > 0 && s[0].type && (o = fe(s[0].type));
|
|
444
444
|
let l = [];
|
|
445
445
|
if (o) try {
|
|
446
446
|
let { Model: e } = await import("@seedprotocol/sdk"), t = await e.resolveAsync(o, { modelFileId: c });
|
|
447
447
|
if (t?.properties) for (let e of t.properties) e.name && l.push(e.name);
|
|
448
448
|
} catch (e) {
|
|
449
|
-
|
|
449
|
+
Z(`[useItemProperties] Error getting ModelProperties for ${o}:`, e);
|
|
450
450
|
}
|
|
451
451
|
if (o && l.length > 0) {
|
|
452
452
|
let n = r.length > 0 ? r[0].seedLocalId ?? e : e, s = r.length > 0 ? r[0].seedUid ?? t : t;
|
|
@@ -460,11 +460,11 @@ async function Ve(e, t) {
|
|
|
460
460
|
}, { waitForReady: !1 });
|
|
461
461
|
t && i.push(t);
|
|
462
462
|
} catch (t) {
|
|
463
|
-
|
|
463
|
+
ze(`[useItemProperties] Error creating ItemProperty for missing property ${e}:`, t);
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
if (e || t) {
|
|
467
|
-
let a = await n.select({ createdAt:
|
|
467
|
+
let a = await n.select({ createdAt: P.createdAt }).from(P).where(t ? W(P.uid, t) : W(P.localId, e)).limit(1);
|
|
468
468
|
if (a.length > 0 && a[0].createdAt) {
|
|
469
469
|
let n = "createdAt";
|
|
470
470
|
if (!i.some((e) => e.propertyName === n) && o) try {
|
|
@@ -477,14 +477,14 @@ async function Ve(e, t) {
|
|
|
477
477
|
}, { waitForReady: !1 });
|
|
478
478
|
l && i.push(l);
|
|
479
479
|
} catch (e) {
|
|
480
|
-
|
|
480
|
+
ze("[useItemProperties] Error creating createdAt ItemProperty:", e);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
return i;
|
|
485
485
|
}
|
|
486
|
-
function
|
|
487
|
-
let t =
|
|
486
|
+
function We(e) {
|
|
487
|
+
let t = J(), n = U(), r = s(void 0), a = o(() => typeof e == "string" ? {
|
|
488
488
|
type: "itemId",
|
|
489
489
|
itemId: e
|
|
490
490
|
} : typeof e == "object" ? {
|
|
@@ -501,42 +501,42 @@ function He(e) {
|
|
|
501
501
|
u
|
|
502
502
|
], [u]), { data: p = [], isLoading: m, error: h } = H({
|
|
503
503
|
queryKey: f,
|
|
504
|
-
queryFn: () =>
|
|
504
|
+
queryFn: () => Ue(c, l),
|
|
505
505
|
enabled: t && !!u
|
|
506
506
|
}), g = Y(o(() => {
|
|
507
|
-
if (!t || !c && !l) return
|
|
507
|
+
if (!t || !c && !l) return Z("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
508
508
|
let e = d.getAppDb();
|
|
509
|
-
if (!e) return
|
|
510
|
-
|
|
509
|
+
if (!e) return Z("[useItemProperties] Query: returning null (no db)"), null;
|
|
510
|
+
Z(`[useItemProperties] Query: creating query for seedLocalId=${c}, seedUid=${l}`);
|
|
511
511
|
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
|
|
512
|
+
propertyName: k.propertyName,
|
|
513
|
+
propertyValue: k.propertyValue,
|
|
514
|
+
seedLocalId: k.seedLocalId,
|
|
515
|
+
seedUid: k.seedUid,
|
|
516
|
+
modelType: k.modelType,
|
|
517
|
+
schemaUid: k.schemaUid,
|
|
518
|
+
createdAt: k.createdAt,
|
|
519
|
+
attestationCreatedAt: k.attestationCreatedAt,
|
|
520
|
+
localId: k.localId,
|
|
521
|
+
revokedAt: k.revokedAt
|
|
522
|
+
}).from(k).where(ge(W(k.seedUid, l), ve(k.propertyName))) : c ? e.select({
|
|
523
|
+
propertyName: k.propertyName,
|
|
524
|
+
propertyValue: k.propertyValue,
|
|
525
|
+
seedLocalId: k.seedLocalId,
|
|
526
|
+
seedUid: k.seedUid,
|
|
527
|
+
modelType: k.modelType,
|
|
528
|
+
schemaUid: k.schemaUid,
|
|
529
|
+
createdAt: k.createdAt,
|
|
530
|
+
attestationCreatedAt: k.attestationCreatedAt,
|
|
531
|
+
localId: k.localId,
|
|
532
|
+
revokedAt: k.revokedAt
|
|
533
|
+
}).from(k).where(ge(W(k.seedLocalId, c), ve(k.propertyName))) : null;
|
|
534
|
+
return Z("[useItemProperties] Query: created query object", { queryType: l ? "seedUid" : "seedLocalId" }), n;
|
|
535
535
|
}, [
|
|
536
536
|
t,
|
|
537
537
|
c,
|
|
538
538
|
l
|
|
539
|
-
])), _ = o(() => !g || g.length === 0 ? [] :
|
|
539
|
+
])), _ = o(() => !g || g.length === 0 ? [] : ce(g), [g]);
|
|
540
540
|
return i(() => {
|
|
541
541
|
if (!t || !c && !l || _ === void 0) return;
|
|
542
542
|
let e = JSON.stringify(_.map((e) => ({
|
|
@@ -562,7 +562,7 @@ function He(e) {
|
|
|
562
562
|
error: h
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
|
-
var
|
|
565
|
+
var Ge = () => {
|
|
566
566
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
567
567
|
if (!t.propertyName || !t.seedLocalId && !t.seedUid || !t.modelName) {
|
|
568
568
|
o(/* @__PURE__ */ Error("seedLocalId or seedUid, propertyName, and modelName are required"));
|
|
@@ -591,7 +591,7 @@ var Ue = () => {
|
|
|
591
591
|
error: a,
|
|
592
592
|
resetError: l
|
|
593
593
|
};
|
|
594
|
-
},
|
|
594
|
+
}, Ke = () => {
|
|
595
595
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
596
596
|
return {
|
|
597
597
|
destroy: n(async (e) => {
|
|
@@ -612,19 +612,19 @@ var Ue = () => {
|
|
|
612
612
|
error: r,
|
|
613
613
|
resetError: n(() => i(null), [])
|
|
614
614
|
};
|
|
615
|
-
},
|
|
615
|
+
}, qe = L("seedSdk:react:services"), Je = [
|
|
616
616
|
"idle",
|
|
617
617
|
"ready",
|
|
618
618
|
"done",
|
|
619
619
|
"success",
|
|
620
620
|
"initialized"
|
|
621
|
-
],
|
|
621
|
+
], Ye = (e) => {
|
|
622
622
|
let t = "actor", n = e;
|
|
623
|
-
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t =
|
|
624
|
-
},
|
|
623
|
+
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t = Ze(e)), t;
|
|
624
|
+
}, Xe = (e) => {
|
|
625
625
|
let t;
|
|
626
|
-
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value),
|
|
627
|
-
},
|
|
626
|
+
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;
|
|
627
|
+
}, Ze = (e) => {
|
|
628
628
|
let t = e;
|
|
629
629
|
if (!e || !t.logic || !t.logic.config || !t._snapshot) return;
|
|
630
630
|
let n = t.logic.config;
|
|
@@ -635,21 +635,21 @@ var Ue = () => {
|
|
|
635
635
|
try {
|
|
636
636
|
i = e.getSnapshot();
|
|
637
637
|
} catch (e) {
|
|
638
|
-
return
|
|
638
|
+
return qe("Error:", e), r;
|
|
639
639
|
}
|
|
640
640
|
if (i) {
|
|
641
641
|
let e = i.context;
|
|
642
|
-
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r =
|
|
642
|
+
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r = xe(e.modelName.toLowerCase()));
|
|
643
643
|
}
|
|
644
644
|
return r;
|
|
645
|
-
},
|
|
645
|
+
}, Qe = (e) => {
|
|
646
646
|
let [t, r] = c(0), a = (e) => {
|
|
647
647
|
let t = 0, n = e;
|
|
648
648
|
if (n.logic?.states) {
|
|
649
649
|
let r = [], i = [];
|
|
650
650
|
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 &&
|
|
651
|
+
let a = i.length, o = Xe(e);
|
|
652
|
+
if (o && Je.includes(o)) return 0;
|
|
653
653
|
o && (t = r.indexOf(o) / a * 100);
|
|
654
654
|
}
|
|
655
655
|
return t;
|
|
@@ -667,43 +667,43 @@ var Ue = () => {
|
|
|
667
667
|
let e = s();
|
|
668
668
|
return () => clearInterval(e);
|
|
669
669
|
}, []), {
|
|
670
|
-
name:
|
|
670
|
+
name: Ye(e),
|
|
671
671
|
timeElapsed: t,
|
|
672
|
-
value:
|
|
672
|
+
value: Xe(e),
|
|
673
673
|
percentComplete: a(e),
|
|
674
|
-
uniqueKey:
|
|
674
|
+
uniqueKey: Ze(e)
|
|
675
675
|
};
|
|
676
|
-
},
|
|
677
|
-
let [e, t] = c(!1), { internalStatus: n } =
|
|
676
|
+
}, $e = () => {
|
|
677
|
+
let [e, t] = c(!1), { internalStatus: n } = rt();
|
|
678
678
|
return i(() => {
|
|
679
679
|
n === "ready" && t(!0);
|
|
680
680
|
}, [n]), i(() => {
|
|
681
681
|
n === "ready" && t(!0);
|
|
682
682
|
}, []), e;
|
|
683
|
-
},
|
|
684
|
-
let [e, t] = c(!1), r =
|
|
685
|
-
for (let e of a)
|
|
683
|
+
}, et = () => {
|
|
684
|
+
let [e, t] = c(!1), r = tt(), { services: a, percentComplete: o } = nt(), s = n(async () => {
|
|
685
|
+
for (let e of a) qe(`would save to db with snapshot__${Ze(e)}:`, JSON.stringify(e.getPersistedSnapshot()));
|
|
686
686
|
}, [a]), l = n(async () => {
|
|
687
687
|
let e = d.getAppDb();
|
|
688
|
-
return e ? await e.select().from(S).where(
|
|
688
|
+
return e ? await e.select().from(S).where(be(S.key, "snapshot__%")) : [];
|
|
689
689
|
}, []);
|
|
690
690
|
i(() => !r || e ? void 0 : ((async () => {
|
|
691
|
-
|
|
691
|
+
qe("persistedSnapshots:", await l()), t(!0);
|
|
692
692
|
})(), () => {
|
|
693
693
|
s();
|
|
694
694
|
}), [r, e]);
|
|
695
|
-
},
|
|
696
|
-
let [e, t] = c(!1), n =
|
|
695
|
+
}, tt = () => {
|
|
696
|
+
let [e, t] = c(!1), n = $e();
|
|
697
697
|
return i(() => {
|
|
698
698
|
n && (async () => {
|
|
699
|
-
let e = await d.getAppDb().select().from(S).where(
|
|
699
|
+
let e = await d.getAppDb().select().from(S).where(be(S.key, "snapshot__%"));
|
|
700
700
|
e && e.length > 0 && t(!0);
|
|
701
701
|
})();
|
|
702
702
|
}, [n]), e;
|
|
703
|
-
},
|
|
703
|
+
}, nt = () => {
|
|
704
704
|
let [e, t] = c([]), [n, r] = c(5);
|
|
705
705
|
return i(() => {
|
|
706
|
-
let e =
|
|
706
|
+
let e = te().getService(), n = e;
|
|
707
707
|
n.uniqueKey = "clientManager", t([n]);
|
|
708
708
|
let i = e.subscribe((e) => {
|
|
709
709
|
let t = e.value, n = 0;
|
|
@@ -716,11 +716,11 @@ var Ue = () => {
|
|
|
716
716
|
services: e,
|
|
717
717
|
percentComplete: n
|
|
718
718
|
};
|
|
719
|
-
},
|
|
720
|
-
let e =
|
|
719
|
+
}, rt = () => {
|
|
720
|
+
let e = te().getService();
|
|
721
721
|
return {
|
|
722
|
-
status:
|
|
723
|
-
internalStatus:
|
|
722
|
+
status: pe(e, (e) => e.value),
|
|
723
|
+
internalStatus: pe(e, (e) => {
|
|
724
724
|
let t = e.value;
|
|
725
725
|
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
726
|
})
|
|
@@ -728,15 +728,15 @@ var Ue = () => {
|
|
|
728
728
|
};
|
|
729
729
|
//#endregion
|
|
730
730
|
//#region src/db.ts
|
|
731
|
-
|
|
732
|
-
var
|
|
731
|
+
L("seedSdk:react:db");
|
|
732
|
+
var it = () => {
|
|
733
733
|
let [e, t] = c(!1), r = n(() => {
|
|
734
734
|
e || t(!0);
|
|
735
735
|
}, []);
|
|
736
736
|
return i(() => {
|
|
737
737
|
let e;
|
|
738
738
|
return (async () => {
|
|
739
|
-
let t =
|
|
739
|
+
let t = te().getService(), n = t.getSnapshot().value;
|
|
740
740
|
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
741
|
let n = t.value;
|
|
742
742
|
(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 +745,8 @@ var tt = () => {
|
|
|
745
745
|
e && e.unsubscribe();
|
|
746
746
|
};
|
|
747
747
|
}, []), { dbsAreReady: e };
|
|
748
|
-
},
|
|
749
|
-
let [t, r] = c(null), [a, o] = c(!!e), [u, d] = c(null), f = s(null), p =
|
|
748
|
+
}, at = L("seedSdk:react:schema"), ot = (e) => {
|
|
749
|
+
let [t, r] = c(null), [a, o] = c(!!e), [u, d] = c(null), f = s(null), p = J(), m = n((e) => {
|
|
750
750
|
o(!0), d(null);
|
|
751
751
|
try {
|
|
752
752
|
let t = x.create(e, { waitForReady: !1 });
|
|
@@ -756,7 +756,7 @@ var tt = () => {
|
|
|
756
756
|
e.value === "idle" ? (l(() => o(!1)), d(null)) : o(!0);
|
|
757
757
|
});
|
|
758
758
|
} catch (e) {
|
|
759
|
-
return
|
|
759
|
+
return at("[useSchema] Error creating schema:", e), d(e), r(null), o(!1), null;
|
|
760
760
|
}
|
|
761
761
|
}, []);
|
|
762
762
|
return i(() => {
|
|
@@ -774,18 +774,18 @@ var tt = () => {
|
|
|
774
774
|
isLoading: a,
|
|
775
775
|
error: u
|
|
776
776
|
};
|
|
777
|
-
},
|
|
778
|
-
let e =
|
|
779
|
-
queryKey:
|
|
777
|
+
}, st = ["seed", "schemas"], ct = () => {
|
|
778
|
+
let e = J(), t = U(), n = s(void 0), r = s([]), { data: a = [], isLoading: c, error: l } = H({
|
|
779
|
+
queryKey: st,
|
|
780
780
|
queryFn: () => x.all({ waitForReady: !0 }),
|
|
781
781
|
enabled: e
|
|
782
782
|
});
|
|
783
783
|
r.current = a;
|
|
784
|
-
let u = e ? d.getAppDb() : null, f = Y(o(() => u ? u.select().from(
|
|
784
|
+
let u = e ? d.getAppDb() : null, f = Y(o(() => u ? u.select().from(N).orderBy(N.name, _e(N.version)) : null, [u, e]));
|
|
785
785
|
return i(() => {
|
|
786
786
|
if (typeof BroadcastChannel > "u") return;
|
|
787
787
|
let e = new BroadcastChannel("seed-schemas-invalidate"), n = () => {
|
|
788
|
-
t.invalidateQueries({ queryKey:
|
|
788
|
+
t.invalidateQueries({ queryKey: st });
|
|
789
789
|
};
|
|
790
790
|
return e.addEventListener("message", n), () => {
|
|
791
791
|
e.removeEventListener("message", n), e.close();
|
|
@@ -807,7 +807,7 @@ var tt = () => {
|
|
|
807
807
|
let o = /* @__PURE__ */ new Set();
|
|
808
808
|
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
809
|
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:
|
|
810
|
+
!s && c && t.invalidateQueries({ queryKey: st });
|
|
811
811
|
}, [
|
|
812
812
|
e,
|
|
813
813
|
f,
|
|
@@ -817,7 +817,7 @@ var tt = () => {
|
|
|
817
817
|
isLoading: c,
|
|
818
818
|
error: l
|
|
819
819
|
};
|
|
820
|
-
},
|
|
820
|
+
}, lt = () => {
|
|
821
821
|
let e = s(null), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
822
822
|
o(null), r(!0), e.current?.unsubscribe(), e.current = null;
|
|
823
823
|
let n = x.create(t, { waitForReady: !1 }), i = n.getService().subscribe((e) => {
|
|
@@ -837,7 +837,7 @@ var tt = () => {
|
|
|
837
837
|
error: a,
|
|
838
838
|
resetError: l
|
|
839
839
|
};
|
|
840
|
-
},
|
|
840
|
+
}, ut = () => {
|
|
841
841
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
842
842
|
return {
|
|
843
843
|
destroy: n(async (e) => {
|
|
@@ -858,8 +858,8 @@ var tt = () => {
|
|
|
858
858
|
error: r,
|
|
859
859
|
resetError: n(() => i(null), [])
|
|
860
860
|
};
|
|
861
|
-
},
|
|
862
|
-
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a =
|
|
861
|
+
}, dt = () => {
|
|
862
|
+
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a = J(), o = n(async () => {
|
|
863
863
|
if (a) try {
|
|
864
864
|
let e = await ie(), n = /* @__PURE__ */ new Set();
|
|
865
865
|
for (let t of e) {
|
|
@@ -877,7 +877,7 @@ var tt = () => {
|
|
|
877
877
|
for (let [e, t] of r.current.entries()) n.has(e) || t.unload();
|
|
878
878
|
r.current = i, t(Array.from(i.values()));
|
|
879
879
|
} catch (e) {
|
|
880
|
-
|
|
880
|
+
at("Error fetching all schema versions from database:", e), t(null);
|
|
881
881
|
}
|
|
882
882
|
}, [a]);
|
|
883
883
|
return i(() => {
|
|
@@ -887,12 +887,12 @@ var tt = () => {
|
|
|
887
887
|
e.unload();
|
|
888
888
|
}), r.current.clear();
|
|
889
889
|
}, []), e;
|
|
890
|
-
},
|
|
890
|
+
}, ft = () => ot(b), pt = (e) => [
|
|
891
891
|
"seed",
|
|
892
892
|
"models",
|
|
893
893
|
e
|
|
894
|
-
],
|
|
895
|
-
let t =
|
|
894
|
+
], mt = /* @__PURE__ */ new Map(), ht = (e) => {
|
|
895
|
+
let t = J(), n = U(), r = s([]), a = o(() => pt(e), [e]), { data: c = [], isLoading: l, error: u } = H({
|
|
896
896
|
queryKey: a,
|
|
897
897
|
queryFn: async () => {
|
|
898
898
|
let t = n.getQueryData(a), r = await v.all(e, { waitForReady: !1 });
|
|
@@ -905,8 +905,8 @@ var tt = () => {
|
|
|
905
905
|
},
|
|
906
906
|
enabled: t && !!e
|
|
907
907
|
}), f = e && typeof e == "string" ? e : "";
|
|
908
|
-
c.length > 0 &&
|
|
909
|
-
let p = r.current.length > 0 ? r.current :
|
|
908
|
+
c.length > 0 && mt.set(f, c);
|
|
909
|
+
let p = r.current.length > 0 ? r.current : mt.get(f), m = e ? c.length > 0 ? c : p?.length ? p : c : c;
|
|
910
910
|
r.current = m, i(() => {
|
|
911
911
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
912
912
|
let t = new BroadcastChannel("seed-models-invalidate"), r = (t) => {
|
|
@@ -925,9 +925,9 @@ var tt = () => {
|
|
|
925
925
|
function _() {
|
|
926
926
|
let t = d.getAppDb();
|
|
927
927
|
return !t || !e ? null : t.select({
|
|
928
|
-
modelFileId:
|
|
929
|
-
modelName:
|
|
930
|
-
}).from(
|
|
928
|
+
modelFileId: j.schemaFileId,
|
|
929
|
+
modelName: j.name
|
|
930
|
+
}).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
931
|
}
|
|
932
932
|
let y = Y(o(() => {
|
|
933
933
|
if (!e || !t) return null;
|
|
@@ -961,8 +961,8 @@ var tt = () => {
|
|
|
961
961
|
isLoading: l,
|
|
962
962
|
error: u
|
|
963
963
|
};
|
|
964
|
-
},
|
|
965
|
-
let n =
|
|
964
|
+
}, gt = (e, t) => {
|
|
965
|
+
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
966
|
if (o(() => n ? h ? !!e : !!(e && t) : !1, [
|
|
967
967
|
n,
|
|
968
968
|
h,
|
|
@@ -999,7 +999,7 @@ var tt = () => {
|
|
|
999
999
|
isLoading: l,
|
|
1000
1000
|
error: d
|
|
1001
1001
|
};
|
|
1002
|
-
let { models: g, isLoading: _, error: y } =
|
|
1002
|
+
let { models: g, isLoading: _, error: y } = ht(e), b = o(() => {
|
|
1003
1003
|
if (t) return g.find((e) => (e.modelName ?? e.name) === t);
|
|
1004
1004
|
}, [g, t]);
|
|
1005
1005
|
return i(() => {
|
|
@@ -1019,7 +1019,7 @@ var tt = () => {
|
|
|
1019
1019
|
isLoading: _,
|
|
1020
1020
|
error: y
|
|
1021
1021
|
};
|
|
1022
|
-
},
|
|
1022
|
+
}, _t = () => {
|
|
1023
1023
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t, n, i) => {
|
|
1024
1024
|
o(null), r(!0), e.current?.unsubscribe(), e.current = void 0;
|
|
1025
1025
|
let a = v.create(n, t, {
|
|
@@ -1038,7 +1038,7 @@ var tt = () => {
|
|
|
1038
1038
|
error: a,
|
|
1039
1039
|
resetError: l
|
|
1040
1040
|
};
|
|
1041
|
-
},
|
|
1041
|
+
}, vt = () => {
|
|
1042
1042
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1043
1043
|
return {
|
|
1044
1044
|
destroy: n(async (e) => {
|
|
@@ -1062,9 +1062,9 @@ var tt = () => {
|
|
|
1062
1062
|
};
|
|
1063
1063
|
//#endregion
|
|
1064
1064
|
//#region src/modelProperty.ts
|
|
1065
|
-
|
|
1066
|
-
var
|
|
1067
|
-
let { model: n } =
|
|
1065
|
+
L("seedSdk:browser:react:modelProperty");
|
|
1066
|
+
var yt = (e, t) => {
|
|
1067
|
+
let { model: n } = gt(e, t);
|
|
1068
1068
|
o(() => {
|
|
1069
1069
|
if (n) try {
|
|
1070
1070
|
return n.modelName ?? n.name;
|
|
@@ -1072,7 +1072,7 @@ var gt = (e, t) => {
|
|
|
1072
1072
|
return;
|
|
1073
1073
|
}
|
|
1074
1074
|
}, [n]);
|
|
1075
|
-
let r =
|
|
1075
|
+
let r = J(), a = U(), c = St(n), l = n?.id, u = o(() => [
|
|
1076
1076
|
"seed",
|
|
1077
1077
|
"modelProperties",
|
|
1078
1078
|
l ?? ""
|
|
@@ -1081,11 +1081,11 @@ var gt = (e, t) => {
|
|
|
1081
1081
|
queryFn: () => y.all(l, { waitForReady: !0 }),
|
|
1082
1082
|
enabled: r && !!l
|
|
1083
1083
|
}), h = r ? d.getAppDb() : null, g = Y(o(() => !h || !c ? null : h.select({
|
|
1084
|
-
id:
|
|
1085
|
-
name:
|
|
1086
|
-
dataType:
|
|
1087
|
-
schemaFileId:
|
|
1088
|
-
}).from(
|
|
1084
|
+
id: ue.id,
|
|
1085
|
+
name: ue.name,
|
|
1086
|
+
dataType: ue.dataType,
|
|
1087
|
+
schemaFileId: ue.schemaFileId
|
|
1088
|
+
}).from(ue).where(W(ue.modelId, c)), [
|
|
1089
1089
|
h,
|
|
1090
1090
|
r,
|
|
1091
1091
|
c
|
|
@@ -1126,38 +1126,38 @@ var gt = (e, t) => {
|
|
|
1126
1126
|
isLoading: p && f.length === 0,
|
|
1127
1127
|
error: m
|
|
1128
1128
|
};
|
|
1129
|
-
},
|
|
1129
|
+
}, bt = [
|
|
1130
1130
|
400,
|
|
1131
1131
|
1200,
|
|
1132
1132
|
2500
|
|
1133
|
-
],
|
|
1133
|
+
], xt = (e) => {
|
|
1134
1134
|
if (e) try {
|
|
1135
1135
|
return e._getSnapshotContext()._dbId;
|
|
1136
1136
|
} catch {
|
|
1137
1137
|
return;
|
|
1138
1138
|
}
|
|
1139
|
-
},
|
|
1140
|
-
let [t, n] = c(() =>
|
|
1139
|
+
}, St = (e) => {
|
|
1140
|
+
let [t, n] = c(() => xt(e));
|
|
1141
1141
|
return i(() => {
|
|
1142
|
-
if (n(
|
|
1143
|
-
let t = e.getService().subscribe(() => n(
|
|
1142
|
+
if (n(xt(e)), !e) return;
|
|
1143
|
+
let t = e.getService().subscribe(() => n(xt(e)));
|
|
1144
1144
|
return () => t.unsubscribe();
|
|
1145
1145
|
}, [e]), t;
|
|
1146
|
-
},
|
|
1146
|
+
}, Ct = async (e, t) => {
|
|
1147
1147
|
let n = await v.createById(e);
|
|
1148
1148
|
if (!n) return;
|
|
1149
1149
|
let r = n.modelName ?? n.name;
|
|
1150
|
-
if (r) return
|
|
1150
|
+
if (r) return ne(r, t, {
|
|
1151
1151
|
modelFileId: e,
|
|
1152
1152
|
schemaName: n.schemaName
|
|
1153
1153
|
});
|
|
1154
1154
|
};
|
|
1155
|
-
function
|
|
1155
|
+
function wt(e, t, r) {
|
|
1156
1156
|
let a = o(() => r == null ? t == null ? !!e : !!(e && t) : !!(e && t && r), [
|
|
1157
1157
|
e,
|
|
1158
1158
|
t,
|
|
1159
1159
|
r
|
|
1160
|
-
]), [u, d] = c(void 0), [f, p] = c(a), [m, h] = c(null), g = s(void 0), _ =
|
|
1160
|
+
]), [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
1161
|
type: "propertyFileId",
|
|
1162
1162
|
propertyFileId: e
|
|
1163
1163
|
} : {
|
|
@@ -1194,7 +1194,7 @@ function xt(e, t, r) {
|
|
|
1194
1194
|
d(void 0), p(!1), h(null);
|
|
1195
1195
|
return;
|
|
1196
1196
|
}
|
|
1197
|
-
t = await
|
|
1197
|
+
t = await Ct(b.modelFileId, b.propertyName);
|
|
1198
1198
|
let e = await v.createById(b.modelFileId);
|
|
1199
1199
|
n = e?.modelName ?? e?.name;
|
|
1200
1200
|
} else {
|
|
@@ -1202,8 +1202,8 @@ function xt(e, t, r) {
|
|
|
1202
1202
|
d(void 0), p(!1), h(null);
|
|
1203
1203
|
return;
|
|
1204
1204
|
}
|
|
1205
|
-
let e = await
|
|
1206
|
-
t = await
|
|
1205
|
+
let e = await O(b.schemaId) ?? b.schemaId;
|
|
1206
|
+
t = await ne(b.modelName, b.propertyName, { schemaName: e }), n = b.modelName;
|
|
1207
1207
|
}
|
|
1208
1208
|
if (t && n) {
|
|
1209
1209
|
let e = y.create({
|
|
@@ -1232,7 +1232,7 @@ function xt(e, t, r) {
|
|
|
1232
1232
|
let C = s(!1);
|
|
1233
1233
|
C.current = f || !!u || !!m, i(() => {
|
|
1234
1234
|
if (!x || b.type === "propertyFileId") return;
|
|
1235
|
-
let e =
|
|
1235
|
+
let e = bt.map((e) => setTimeout(() => {
|
|
1236
1236
|
C.current || S({ quiet: !0 });
|
|
1237
1237
|
}, e));
|
|
1238
1238
|
return () => e.forEach((e) => clearTimeout(e));
|
|
@@ -1245,7 +1245,7 @@ function xt(e, t, r) {
|
|
|
1245
1245
|
return i(() => {
|
|
1246
1246
|
if (!u || !w) return;
|
|
1247
1247
|
g.current?.unsubscribe();
|
|
1248
|
-
let e =
|
|
1248
|
+
let e = F(S, 100), t = u.getService().subscribe(() => {
|
|
1249
1249
|
e();
|
|
1250
1250
|
});
|
|
1251
1251
|
return g.current = t, () => {
|
|
@@ -1261,13 +1261,13 @@ function xt(e, t, r) {
|
|
|
1261
1261
|
error: m
|
|
1262
1262
|
};
|
|
1263
1263
|
}
|
|
1264
|
-
var
|
|
1264
|
+
var Tt = () => {
|
|
1265
1265
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t, n, i) => {
|
|
1266
1266
|
if (o(null), r(!0), e.current?.unsubscribe(), e.current = void 0, !n || !i.name || !i.dataType) {
|
|
1267
1267
|
let e = /* @__PURE__ */ Error("modelName, property name and dataType are required");
|
|
1268
1268
|
throw o(e), r(!1), e;
|
|
1269
1269
|
}
|
|
1270
|
-
let a =
|
|
1270
|
+
let a = O(t) ?? t, s = y.create({
|
|
1271
1271
|
...i,
|
|
1272
1272
|
modelName: n
|
|
1273
1273
|
}, {
|
|
@@ -1290,7 +1290,7 @@ var St = () => {
|
|
|
1290
1290
|
error: a,
|
|
1291
1291
|
resetError: l
|
|
1292
1292
|
};
|
|
1293
|
-
},
|
|
1293
|
+
}, Et = () => {
|
|
1294
1294
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1295
1295
|
return {
|
|
1296
1296
|
destroy: n(async (e) => {
|
|
@@ -1311,7 +1311,7 @@ var St = () => {
|
|
|
1311
1311
|
error: r,
|
|
1312
1312
|
resetError: n(() => i(null), [])
|
|
1313
1313
|
};
|
|
1314
|
-
},
|
|
1314
|
+
}, Dt = () => {
|
|
1315
1315
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1316
1316
|
return {
|
|
1317
1317
|
deleteItem: n(async (e) => {
|
|
@@ -1332,20 +1332,20 @@ var St = () => {
|
|
|
1332
1332
|
error: r,
|
|
1333
1333
|
resetError: n(() => i(null), [])
|
|
1334
1334
|
};
|
|
1335
|
-
},
|
|
1336
|
-
function
|
|
1337
|
-
let e =
|
|
1338
|
-
queryKey:
|
|
1335
|
+
}, Ot = ["seed", "imageFiles"];
|
|
1336
|
+
function kt() {
|
|
1337
|
+
let e = J(), t = U(), { data: n = [], isLoading: r, error: a, refetch: o } = H({
|
|
1338
|
+
queryKey: Ot,
|
|
1339
1339
|
queryFn: () => f.listImageFiles(),
|
|
1340
1340
|
enabled: e
|
|
1341
1341
|
});
|
|
1342
1342
|
return i(() => {
|
|
1343
1343
|
let e = (e) => {
|
|
1344
|
-
e.includes("/images/") && t.invalidateQueries({ queryKey:
|
|
1344
|
+
e.includes("/images/") && t.invalidateQueries({ queryKey: Ot });
|
|
1345
1345
|
}, n = () => {
|
|
1346
|
-
t.invalidateQueries({ queryKey:
|
|
1346
|
+
t.invalidateQueries({ queryKey: Ot });
|
|
1347
1347
|
}, r = (e) => {
|
|
1348
|
-
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey:
|
|
1348
|
+
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey: Ot });
|
|
1349
1349
|
};
|
|
1350
1350
|
return E.on("file-saved", e), E.on("fs.downloadAll.success", n), E.on(h, r), () => {
|
|
1351
1351
|
E.off("file-saved", e), E.off("fs.downloadAll.success", n), E.off(h, r);
|
|
@@ -1359,9 +1359,9 @@ function Et() {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
//#endregion
|
|
1361
1361
|
//#region src/useFiles.ts
|
|
1362
|
-
var
|
|
1363
|
-
function
|
|
1364
|
-
let t =
|
|
1362
|
+
var At = ["seed", "files"];
|
|
1363
|
+
function jt(e = "files") {
|
|
1364
|
+
let t = J(), n = U(), r = o(() => [...At, e], [e]), { data: a = [], isLoading: s, error: c, refetch: l } = H({
|
|
1365
1365
|
queryKey: r,
|
|
1366
1366
|
queryFn: () => f.listFiles(e),
|
|
1367
1367
|
enabled: t
|
|
@@ -1390,24 +1390,24 @@ function Ot(e = "files") {
|
|
|
1390
1390
|
}
|
|
1391
1391
|
//#endregion
|
|
1392
1392
|
//#region src/useEasSyncProcesses.ts
|
|
1393
|
-
function
|
|
1393
|
+
function Mt() {
|
|
1394
1394
|
let e = d.getAppDb();
|
|
1395
|
-
return o(() => e ? e.select().from(w).orderBy(
|
|
1395
|
+
return o(() => e ? e.select().from(w).orderBy(_e(w.startedAt)) : null, [e]);
|
|
1396
1396
|
}
|
|
1397
|
-
function
|
|
1398
|
-
let e = Y(
|
|
1397
|
+
function Nt() {
|
|
1398
|
+
let e = Y(Mt());
|
|
1399
1399
|
return {
|
|
1400
1400
|
records: e,
|
|
1401
1401
|
nonActiveCount: o(() => e === void 0 ? void 0 : e.filter((e) => e.status !== "in_progress").length, [e])
|
|
1402
1402
|
};
|
|
1403
1403
|
}
|
|
1404
|
-
function
|
|
1405
|
-
return Y(
|
|
1404
|
+
function Pt() {
|
|
1405
|
+
return Y(Mt());
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1408
|
-
return
|
|
1407
|
+
function Ft() {
|
|
1408
|
+
return Nt().nonActiveCount;
|
|
1409
1409
|
}
|
|
1410
|
-
function
|
|
1410
|
+
function It(e) {
|
|
1411
1411
|
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
1412
|
return {
|
|
1413
1413
|
record: n && n.length > 0 ? n[0] : null,
|
|
@@ -1416,12 +1416,12 @@ function Nt(e) {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
//#endregion
|
|
1418
1418
|
//#region src/SeedProvider.tsx
|
|
1419
|
-
var
|
|
1420
|
-
function
|
|
1421
|
-
let t =
|
|
1419
|
+
var Lt = null;
|
|
1420
|
+
function Rt(e) {
|
|
1421
|
+
let t = Lt?.(e);
|
|
1422
1422
|
return typeof window < "u" && window.__SEED_INVALIDATE_ITEM_PROPERTIES__ && window.__SEED_INVALIDATE_ITEM_PROPERTIES__(e), Promise.resolve(t).then(() => {});
|
|
1423
1423
|
}
|
|
1424
|
-
function
|
|
1424
|
+
function zt({ queryClient: e }) {
|
|
1425
1425
|
return i(() => {
|
|
1426
1426
|
let t = (t) => {
|
|
1427
1427
|
let n = [
|
|
@@ -1431,7 +1431,7 @@ function It({ queryClient: e }) {
|
|
|
1431
1431
|
];
|
|
1432
1432
|
return e.invalidateQueries({ queryKey: n }), e.refetchQueries({ queryKey: n });
|
|
1433
1433
|
};
|
|
1434
|
-
|
|
1434
|
+
Lt = t, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = t);
|
|
1435
1435
|
let n = (e) => {
|
|
1436
1436
|
let n = e?.seedLocalId ?? e?.seedUid;
|
|
1437
1437
|
n && t(n);
|
|
@@ -1442,12 +1442,12 @@ function It({ queryClient: e }) {
|
|
|
1442
1442
|
});
|
|
1443
1443
|
};
|
|
1444
1444
|
return E.on("itemProperty.saved", n), E.on(m, r), () => {
|
|
1445
|
-
E.off("itemProperty.saved", n), E.off(m, r),
|
|
1445
|
+
E.off("itemProperty.saved", n), E.off(m, r), Lt = null, typeof window < "u" && (window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null);
|
|
1446
1446
|
};
|
|
1447
1447
|
}, [e]), null;
|
|
1448
1448
|
}
|
|
1449
|
-
function
|
|
1450
|
-
let r = o(() => t ??
|
|
1449
|
+
function Bt({ children: e, queryClient: t, queryClientRef: n }) {
|
|
1450
|
+
let r = o(() => t ?? X(), [t]);
|
|
1451
1451
|
if (n && (n.current = r, typeof window < "u")) {
|
|
1452
1452
|
let e = window;
|
|
1453
1453
|
e.__TEST_SEED_QUERY_CLIENT__ = r;
|
|
@@ -1455,17 +1455,17 @@ function Lt({ children: e, queryClient: t, queryClientRef: n }) {
|
|
|
1455
1455
|
window.parent && window.parent !== window && (window.parent.__TEST_SEED_QUERY_CLIENT__ = r);
|
|
1456
1456
|
} catch {}
|
|
1457
1457
|
}
|
|
1458
|
-
return /* @__PURE__ */ z(
|
|
1458
|
+
return /* @__PURE__ */ z(he, {
|
|
1459
1459
|
client: r,
|
|
1460
|
-
children: /* @__PURE__ */ B(
|
|
1460
|
+
children: /* @__PURE__ */ B(Ee, {
|
|
1461
1461
|
queryClient: r,
|
|
1462
|
-
children: [/* @__PURE__ */ z(
|
|
1462
|
+
children: [/* @__PURE__ */ z(zt, { queryClient: r }), e]
|
|
1463
1463
|
})
|
|
1464
1464
|
});
|
|
1465
1465
|
}
|
|
1466
1466
|
//#endregion
|
|
1467
1467
|
//#region src/SeedClientGate.tsx
|
|
1468
|
-
function
|
|
1468
|
+
function Vt() {
|
|
1469
1469
|
return /* @__PURE__ */ z("div", {
|
|
1470
1470
|
style: {
|
|
1471
1471
|
display: "flex",
|
|
@@ -1477,8 +1477,8 @@ function Rt() {
|
|
|
1477
1477
|
children: "Loading..."
|
|
1478
1478
|
});
|
|
1479
1479
|
}
|
|
1480
|
-
function
|
|
1481
|
-
let l =
|
|
1480
|
+
function Ht({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r, loadingClassName: a, onInitError: o, children: c }) {
|
|
1481
|
+
let l = J(), u = s(o);
|
|
1482
1482
|
u.current = o, i(() => {
|
|
1483
1483
|
let n = t ? {
|
|
1484
1484
|
...e,
|
|
@@ -1491,7 +1491,7 @@ function zt({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1491
1491
|
u.current ? u.current(e) : console.error("[SeedClientGate] client init failed", e);
|
|
1492
1492
|
});
|
|
1493
1493
|
}, [e, t]);
|
|
1494
|
-
let d = n ?? /* @__PURE__ */ z(
|
|
1494
|
+
let d = n ?? /* @__PURE__ */ z(Vt, {}), f = r ? void 0 : {
|
|
1495
1495
|
position: "relative",
|
|
1496
1496
|
display: "flex",
|
|
1497
1497
|
height: "100vh",
|
|
@@ -1526,54 +1526,54 @@ function zt({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1526
1526
|
}
|
|
1527
1527
|
//#endregion
|
|
1528
1528
|
//#region src/opfsPaths.ts
|
|
1529
|
-
function
|
|
1529
|
+
function Ut(e) {
|
|
1530
1530
|
let t = e.split("/").filter(Boolean);
|
|
1531
1531
|
if (t.length === 0) throw Error(`Invalid OPFS path: "${e}"`);
|
|
1532
1532
|
return t;
|
|
1533
1533
|
}
|
|
1534
|
-
async function
|
|
1534
|
+
async function Wt(e, t) {
|
|
1535
1535
|
let n = t ?? await navigator.storage.getDirectory();
|
|
1536
1536
|
for (let t of e.split("/").filter(Boolean)) n = await n.getDirectoryHandle(t);
|
|
1537
1537
|
return n;
|
|
1538
1538
|
}
|
|
1539
|
-
async function
|
|
1540
|
-
let n =
|
|
1539
|
+
async function Gt(e, t) {
|
|
1540
|
+
let n = Ut(e), r = n.pop();
|
|
1541
1541
|
return {
|
|
1542
|
-
dir: await
|
|
1542
|
+
dir: await Wt(n.join("/"), t),
|
|
1543
1543
|
name: r
|
|
1544
1544
|
};
|
|
1545
1545
|
}
|
|
1546
|
-
async function
|
|
1547
|
-
let { dir: n, name: r } = await
|
|
1546
|
+
async function Kt(e, t) {
|
|
1547
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1548
1548
|
return n.getFileHandle(r);
|
|
1549
1549
|
}
|
|
1550
|
-
async function
|
|
1551
|
-
return (await
|
|
1550
|
+
async function qt(e, t) {
|
|
1551
|
+
return (await Kt(e, t)).getFile();
|
|
1552
1552
|
}
|
|
1553
|
-
async function
|
|
1554
|
-
let { dir: n, name: r } = await
|
|
1553
|
+
async function Jt(e, t) {
|
|
1554
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1555
1555
|
await n.removeEntry(r);
|
|
1556
1556
|
}
|
|
1557
|
-
async function
|
|
1557
|
+
async function Yt(e, t) {
|
|
1558
1558
|
let n = await e.getDirectoryHandle(t), r = [];
|
|
1559
1559
|
for await (let e of n.entries()) r.push(e);
|
|
1560
1560
|
let i = !0;
|
|
1561
|
-
for (let [e, t] of r) (t.kind === "file" || !await
|
|
1561
|
+
for (let [e, t] of r) (t.kind === "file" || !await Yt(n, e)) && (i = !1);
|
|
1562
1562
|
return i && await e.removeEntry(t), i;
|
|
1563
1563
|
}
|
|
1564
|
-
async function
|
|
1564
|
+
async function Xt(e, t) {
|
|
1565
1565
|
try {
|
|
1566
|
-
let { dir: n, name: r } = await
|
|
1567
|
-
return await
|
|
1566
|
+
let { dir: n, name: r } = await Gt(e, t);
|
|
1567
|
+
return await Yt(n, r);
|
|
1568
1568
|
} catch (e) {
|
|
1569
1569
|
if (e instanceof DOMException && e.name === "NotFoundError") return !0;
|
|
1570
1570
|
throw e;
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
|
-
function
|
|
1573
|
+
function Zt() {
|
|
1574
1574
|
return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
|
|
1575
1575
|
}
|
|
1576
|
-
var
|
|
1576
|
+
var Qt = [
|
|
1577
1577
|
{
|
|
1578
1578
|
type: "image/jpeg",
|
|
1579
1579
|
test: (e) => e[0] === 255 && e[1] === 216 && e[2] === 255
|
|
@@ -1584,43 +1584,43 @@ var Yt = [
|
|
|
1584
1584
|
},
|
|
1585
1585
|
{
|
|
1586
1586
|
type: "image/gif",
|
|
1587
|
-
test: (e) =>
|
|
1587
|
+
test: (e) => $t(e, 0, 4) === "GIF8"
|
|
1588
1588
|
},
|
|
1589
1589
|
{
|
|
1590
1590
|
type: "image/webp",
|
|
1591
|
-
test: (e) =>
|
|
1591
|
+
test: (e) => $t(e, 0, 4) === "RIFF" && $t(e, 8, 12) === "WEBP"
|
|
1592
1592
|
},
|
|
1593
1593
|
{
|
|
1594
1594
|
type: "image/avif",
|
|
1595
|
-
test: (e) =>
|
|
1595
|
+
test: (e) => $t(e, 4, 8) === "ftyp" && ["avif", "avis"].includes($t(e, 8, 12))
|
|
1596
1596
|
},
|
|
1597
1597
|
{
|
|
1598
1598
|
type: "application/vnd.sqlite3",
|
|
1599
|
-
test: (e) =>
|
|
1599
|
+
test: (e) => $t(e, 0, 15) === "SQLite format 3"
|
|
1600
1600
|
},
|
|
1601
1601
|
{
|
|
1602
1602
|
type: "application/pdf",
|
|
1603
|
-
test: (e) =>
|
|
1603
|
+
test: (e) => $t(e, 0, 5) === "%PDF-"
|
|
1604
1604
|
}
|
|
1605
1605
|
];
|
|
1606
|
-
function
|
|
1606
|
+
function $t(e, t, n) {
|
|
1607
1607
|
return String.fromCharCode(...e.subarray(t, n));
|
|
1608
1608
|
}
|
|
1609
|
-
function
|
|
1610
|
-
return
|
|
1609
|
+
function en(e) {
|
|
1610
|
+
return Qt.find((t) => t.test(e))?.type;
|
|
1611
1611
|
}
|
|
1612
|
-
async function
|
|
1613
|
-
if (e.size !== 0) return
|
|
1612
|
+
async function tn(e) {
|
|
1613
|
+
if (e.size !== 0) return en(new Uint8Array(await e.slice(0, 16).arrayBuffer()));
|
|
1614
1614
|
}
|
|
1615
1615
|
//#endregion
|
|
1616
1616
|
//#region src/useOPFSFiles.ts
|
|
1617
|
-
async function
|
|
1617
|
+
async function nn(e, t = "") {
|
|
1618
1618
|
let n = [];
|
|
1619
1619
|
try {
|
|
1620
1620
|
for await (let [r, i] of e.entries()) {
|
|
1621
1621
|
let e = t ? `${t}/${r}` : r;
|
|
1622
1622
|
if (i.kind === "file") try {
|
|
1623
|
-
let t = await i.getFile(), a = t.type ? void 0 : await
|
|
1623
|
+
let t = await i.getFile(), a = t.type ? void 0 : await tn(t).catch(() => void 0);
|
|
1624
1624
|
n.push({
|
|
1625
1625
|
name: r,
|
|
1626
1626
|
path: e,
|
|
@@ -1633,7 +1633,7 @@ async function $t(e, t = "") {
|
|
|
1633
1633
|
console.warn(`Failed to read file ${e}:`, t);
|
|
1634
1634
|
}
|
|
1635
1635
|
else if (i.kind === "directory") {
|
|
1636
|
-
let t = await
|
|
1636
|
+
let t = await nn(i, e);
|
|
1637
1637
|
n.push(...t);
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
@@ -1642,11 +1642,11 @@ async function $t(e, t = "") {
|
|
|
1642
1642
|
}
|
|
1643
1643
|
return n;
|
|
1644
1644
|
}
|
|
1645
|
-
function
|
|
1645
|
+
function rn(e = {}) {
|
|
1646
1646
|
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
1647
|
s(!0), f(null), m(null);
|
|
1648
1648
|
try {
|
|
1649
|
-
let e = await
|
|
1649
|
+
let e = await nn(await Wt(t ?? ""), t || "");
|
|
1650
1650
|
a(e.sort((e, t) => e.path.localeCompare(t.path)));
|
|
1651
1651
|
} catch (e) {
|
|
1652
1652
|
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 +1667,7 @@ function en(e = {}) {
|
|
|
1667
1667
|
}
|
|
1668
1668
|
//#endregion
|
|
1669
1669
|
//#region src/OPFSFilesManager/format.ts
|
|
1670
|
-
var
|
|
1670
|
+
var an = [
|
|
1671
1671
|
"B",
|
|
1672
1672
|
"KB",
|
|
1673
1673
|
"MB",
|
|
@@ -1676,32 +1676,32 @@ var tn = [
|
|
|
1676
1676
|
];
|
|
1677
1677
|
function Q(e) {
|
|
1678
1678
|
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)} ${
|
|
1679
|
+
let t = Math.min(an.length - 1, Math.floor(Math.log(e) / Math.log(1024))), n = e / 1024 ** t;
|
|
1680
|
+
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${an[t]}`;
|
|
1681
1681
|
}
|
|
1682
|
-
var
|
|
1683
|
-
function
|
|
1682
|
+
var on = 6e4, sn = 60 * on, cn = 24 * sn;
|
|
1683
|
+
function ln(e, t = Date.now()) {
|
|
1684
1684
|
let n = t - e;
|
|
1685
|
-
if (n <
|
|
1686
|
-
if (n <
|
|
1687
|
-
if (n <
|
|
1688
|
-
let r = Math.round(n /
|
|
1685
|
+
if (n < on) return "just now";
|
|
1686
|
+
if (n < sn) return `${Math.round(n / on)} min ago`;
|
|
1687
|
+
if (n < cn) return `${Math.round(n / sn)} h ago`;
|
|
1688
|
+
let r = Math.round(n / cn);
|
|
1689
1689
|
return r === 1 ? "yesterday" : r < 30 ? `${r} days ago` : new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" });
|
|
1690
1690
|
}
|
|
1691
|
-
function
|
|
1691
|
+
function un(e) {
|
|
1692
1692
|
return new Date(e).toLocaleString(void 0, {
|
|
1693
1693
|
dateStyle: "medium",
|
|
1694
1694
|
timeStyle: "short"
|
|
1695
1695
|
});
|
|
1696
1696
|
}
|
|
1697
|
-
function
|
|
1697
|
+
function dn(e, t) {
|
|
1698
1698
|
if (e.length <= t) return e;
|
|
1699
1699
|
let n = Math.ceil((t - 1) / 2), r = Math.floor((t - 1) / 2);
|
|
1700
1700
|
return `${e.slice(0, n)}…${e.slice(e.length - r)}`;
|
|
1701
1701
|
}
|
|
1702
1702
|
//#endregion
|
|
1703
1703
|
//#region src/OPFSFilesManager/icons.tsx
|
|
1704
|
-
var
|
|
1704
|
+
var fn = {
|
|
1705
1705
|
check: /* @__PURE__ */ z("path", { d: "M20 6 9 17l-5-5" }),
|
|
1706
1706
|
chevronLeft: /* @__PURE__ */ z("path", { d: "m15 18-6-6 6-6" }),
|
|
1707
1707
|
chevronRight: /* @__PURE__ */ z("path", { d: "m9 18 6-6-6-6" }),
|
|
@@ -1886,13 +1886,13 @@ function $({ name: e, size: t = 16, strokeWidth: n = 2, className: r }) {
|
|
|
1886
1886
|
"aria-hidden": "true",
|
|
1887
1887
|
focusable: "false",
|
|
1888
1888
|
className: r,
|
|
1889
|
-
children:
|
|
1889
|
+
children: fn[e]
|
|
1890
1890
|
});
|
|
1891
1891
|
}
|
|
1892
1892
|
//#endregion
|
|
1893
1893
|
//#region src/OPFSFilesManager/DeleteDialog.tsx
|
|
1894
|
-
var
|
|
1895
|
-
function
|
|
1894
|
+
var pn = 6;
|
|
1895
|
+
function mn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
1896
1896
|
let a = s(null);
|
|
1897
1897
|
return i(() => {
|
|
1898
1898
|
let e = a.current;
|
|
@@ -1918,9 +1918,9 @@ function dn({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
|
1918
1918
|
})
|
|
1919
1919
|
});
|
|
1920
1920
|
}
|
|
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(
|
|
1921
|
+
function hn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel: i, onConfirm: a, className: o }) {
|
|
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 ${dn(e[0].file.name, 32)}?` : `Delete ${e.length} files?`;
|
|
1923
|
+
return /* @__PURE__ */ B(mn, {
|
|
1924
1924
|
className: o,
|
|
1925
1925
|
onCancel: i,
|
|
1926
1926
|
onSubmit: () => a(s),
|
|
@@ -1934,12 +1934,12 @@ function fn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
1934
1934
|
e.length === 1 ? "it" : "them",
|
|
1935
1935
|
" from this browser’s private storage. Copies on Arweave or other devices aren’t affected. You can’t undo this."
|
|
1936
1936
|
] }),
|
|
1937
|
-
/* @__PURE__ */ B("ul", { children: [e.slice(0,
|
|
1937
|
+
/* @__PURE__ */ B("ul", { children: [e.slice(0, pn).map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ z("code", {
|
|
1938
1938
|
title: e.file.path,
|
|
1939
1939
|
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 >
|
|
1940
|
+
}), /* @__PURE__ */ z("span", { children: Q(e.file.size) })] }, e.file.path)), e.length > pn && /* @__PURE__ */ z("li", { children: /* @__PURE__ */ B("span", { children: [
|
|
1941
1941
|
"and ",
|
|
1942
|
-
e.length -
|
|
1942
|
+
e.length - pn,
|
|
1943
1943
|
" more"
|
|
1944
1944
|
] }) })] }),
|
|
1945
1945
|
u.length > 0 && /* @__PURE__ */ B("label", { children: [
|
|
@@ -1982,16 +1982,16 @@ function fn({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
1982
1982
|
]
|
|
1983
1983
|
});
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1985
|
+
function gn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy: a, onDownload: o, onCancel: s, onConfirm: l, className: u }) {
|
|
1986
1986
|
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(
|
|
1987
|
+
return /* @__PURE__ */ B(mn, {
|
|
1988
1988
|
className: u,
|
|
1989
1989
|
onCancel: s,
|
|
1990
1990
|
onSubmit: l,
|
|
1991
1991
|
children: [
|
|
1992
1992
|
/* @__PURE__ */ z("h3", {
|
|
1993
1993
|
id: "seed-fm-delete-title",
|
|
1994
|
-
children: i.label ? `${i.label}?` : `Delete the “${
|
|
1994
|
+
children: i.label ? `${i.label}?` : `Delete the “${dn(e.name, 32)}” folder?`
|
|
1995
1995
|
}),
|
|
1996
1996
|
/* @__PURE__ */ B("p", { children: [
|
|
1997
1997
|
"This removes the folder and the ",
|
|
@@ -2008,12 +2008,12 @@ function pn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2008
2008
|
size: 16
|
|
2009
2009
|
}), /* @__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
2010
|
}),
|
|
2011
|
-
/* @__PURE__ */ B("ul", { children: [t.slice(0,
|
|
2011
|
+
/* @__PURE__ */ B("ul", { children: [t.slice(0, pn).map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ z("code", {
|
|
2012
2012
|
title: e.path,
|
|
2013
2013
|
children: e.path.slice(m.length)
|
|
2014
|
-
}), /* @__PURE__ */ z("span", { children: Q(e.size) })] }, e.path)), t.length >
|
|
2014
|
+
}), /* @__PURE__ */ z("span", { children: Q(e.size) })] }, e.path)), t.length > pn && /* @__PURE__ */ z("li", { children: /* @__PURE__ */ B("span", { children: [
|
|
2015
2015
|
"and ",
|
|
2016
|
-
t.length -
|
|
2016
|
+
t.length - pn,
|
|
2017
2017
|
" more"
|
|
2018
2018
|
] }) })] }),
|
|
2019
2019
|
/* @__PURE__ */ B("div", {
|
|
@@ -2072,42 +2072,42 @@ function pn({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2072
2072
|
}
|
|
2073
2073
|
//#endregion
|
|
2074
2074
|
//#region src/OPFSFilesManager/fileModel.ts
|
|
2075
|
-
function
|
|
2075
|
+
function _n(e) {
|
|
2076
2076
|
return e.detectedType ?? e.type;
|
|
2077
2077
|
}
|
|
2078
|
-
var
|
|
2079
|
-
function
|
|
2080
|
-
let t =
|
|
2081
|
-
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" ||
|
|
2078
|
+
var vn = /\.(db|sqlite|sqlite3)(-journal|-wal|-shm)?$/i;
|
|
2079
|
+
function yn(e) {
|
|
2080
|
+
let t = _n(e);
|
|
2081
|
+
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
2082
|
}
|
|
2083
|
-
function
|
|
2083
|
+
function bn(e) {
|
|
2084
2084
|
let t = /\.([a-z0-9-]{1,12})$/i.exec(e.name)?.[1];
|
|
2085
2085
|
if (t) return t.toLowerCase();
|
|
2086
|
-
let n =
|
|
2086
|
+
let n = _n(e);
|
|
2087
2087
|
return n === "application/octet-stream" ? "bin" : n.split("/")[1]?.replace(/^vnd\./, "") ?? "bin";
|
|
2088
2088
|
}
|
|
2089
|
-
var
|
|
2090
|
-
function
|
|
2091
|
-
let t =
|
|
2089
|
+
var xn = /^(.*\/)?images\/(\d+)\/([^/]+)\.webp$/, Sn = /^(.*\/)?images\/([^/]+)$/, Cn = (e) => e.replace(/\.[^/.]+$/, "");
|
|
2090
|
+
function wn(e) {
|
|
2091
|
+
let t = xn.exec(e);
|
|
2092
2092
|
return t ? {
|
|
2093
2093
|
key: `${t[1] ?? ""}images/${t[3]}`,
|
|
2094
2094
|
width: Number(t[2])
|
|
2095
2095
|
} : null;
|
|
2096
2096
|
}
|
|
2097
|
-
function
|
|
2098
|
-
let t =
|
|
2099
|
-
return t ? `${t[1] ?? ""}images/${
|
|
2097
|
+
function Tn(e) {
|
|
2098
|
+
let t = Sn.exec(e);
|
|
2099
|
+
return t ? `${t[1] ?? ""}images/${Cn(t[2])}` : null;
|
|
2100
2100
|
}
|
|
2101
|
-
var
|
|
2101
|
+
var En = (e) => ({
|
|
2102
2102
|
file: e,
|
|
2103
2103
|
variants: [],
|
|
2104
2104
|
totalSize: e.size
|
|
2105
2105
|
});
|
|
2106
|
-
function
|
|
2107
|
-
if (!t) return e.map(
|
|
2106
|
+
function Dn(e, t) {
|
|
2107
|
+
if (!t) return e.map(En);
|
|
2108
2108
|
let n = /* @__PURE__ */ new Map(), r = [], i = [];
|
|
2109
2109
|
for (let t of e) {
|
|
2110
|
-
let e =
|
|
2110
|
+
let e = wn(t.path);
|
|
2111
2111
|
if (e) {
|
|
2112
2112
|
i.push({
|
|
2113
2113
|
file: t,
|
|
@@ -2115,27 +2115,27 @@ function wn(e, t) {
|
|
|
2115
2115
|
});
|
|
2116
2116
|
continue;
|
|
2117
2117
|
}
|
|
2118
|
-
let a =
|
|
2118
|
+
let a = En(t);
|
|
2119
2119
|
r.push(a);
|
|
2120
|
-
let o =
|
|
2121
|
-
o &&
|
|
2120
|
+
let o = Tn(t.path);
|
|
2121
|
+
o && yn(t) === "image" && n.set(o, a);
|
|
2122
2122
|
}
|
|
2123
2123
|
for (let e of i) {
|
|
2124
2124
|
let t = n.get(e.key);
|
|
2125
2125
|
t ? (t.variants.push({
|
|
2126
2126
|
file: e.file,
|
|
2127
2127
|
width: e.width
|
|
2128
|
-
}), t.totalSize += e.file.size) : r.push(
|
|
2128
|
+
}), t.totalSize += e.file.size) : r.push(En(e.file));
|
|
2129
2129
|
}
|
|
2130
2130
|
for (let e of n.values()) e.variants.sort((e, t) => e.width - t.width);
|
|
2131
2131
|
return r;
|
|
2132
2132
|
}
|
|
2133
|
-
var
|
|
2134
|
-
function
|
|
2133
|
+
var On = (e, t) => e ? `${e}/${t}` : t;
|
|
2134
|
+
function kn(e, t, n = {}) {
|
|
2135
2135
|
let r = t ? `${t}/` : "", i = e.filter((e) => e.file.path.startsWith(r)), a = n.query?.trim().toLowerCase();
|
|
2136
2136
|
if (a) return {
|
|
2137
2137
|
folders: [],
|
|
2138
|
-
entries:
|
|
2138
|
+
entries: An(i.filter((e) => e.file.path.slice(r.length).toLowerCase().includes(a)), n.sort)
|
|
2139
2139
|
};
|
|
2140
2140
|
let o = /* @__PURE__ */ new Map(), s = [];
|
|
2141
2141
|
for (let e of i) {
|
|
@@ -2146,7 +2146,7 @@ function En(e, t, n = {}) {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
let a = n.slice(0, i), c = o.get(a) ?? {
|
|
2148
2148
|
name: a,
|
|
2149
|
-
path:
|
|
2149
|
+
path: On(t, a),
|
|
2150
2150
|
fileCount: 0,
|
|
2151
2151
|
size: 0
|
|
2152
2152
|
};
|
|
@@ -2154,10 +2154,10 @@ function En(e, t, n = {}) {
|
|
|
2154
2154
|
}
|
|
2155
2155
|
return {
|
|
2156
2156
|
folders: [...o.values()].sort((e, t) => e.name.localeCompare(t.name)),
|
|
2157
|
-
entries:
|
|
2157
|
+
entries: An(s, n.sort)
|
|
2158
2158
|
};
|
|
2159
2159
|
}
|
|
2160
|
-
function
|
|
2160
|
+
function An(e, t = "name") {
|
|
2161
2161
|
let n = {
|
|
2162
2162
|
name: (e, t) => e.file.name.localeCompare(t.file.name),
|
|
2163
2163
|
modified: (e, t) => t.file.lastModified - e.file.lastModified,
|
|
@@ -2165,7 +2165,7 @@ function Dn(e, t = "name") {
|
|
|
2165
2165
|
};
|
|
2166
2166
|
return [...e].sort(n[t]);
|
|
2167
2167
|
}
|
|
2168
|
-
function
|
|
2168
|
+
function jn(e) {
|
|
2169
2169
|
let t = {
|
|
2170
2170
|
image: 0,
|
|
2171
2171
|
database: 0,
|
|
@@ -2174,34 +2174,34 @@ function On(e) {
|
|
|
2174
2174
|
text: 0,
|
|
2175
2175
|
other: 0
|
|
2176
2176
|
};
|
|
2177
|
-
for (let n of e) t[
|
|
2177
|
+
for (let n of e) t[yn(n)] += n.size;
|
|
2178
2178
|
return t;
|
|
2179
2179
|
}
|
|
2180
|
-
function
|
|
2180
|
+
function Mn(e) {
|
|
2181
2181
|
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
2182
|
}
|
|
2183
2183
|
//#endregion
|
|
2184
2184
|
//#region src/OPFSFilesManager/useThumbnail.ts
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2185
|
+
var Nn = 400, Pn = 262144, Fn = 4, In = 3e4, Ln = 0, Rn = [];
|
|
2186
|
+
function zn(e) {
|
|
2187
2187
|
return new Promise((t, n) => {
|
|
2188
2188
|
let r = () => {
|
|
2189
|
-
|
|
2190
|
-
|
|
2189
|
+
Ln++, e().then(t, n).finally(() => {
|
|
2190
|
+
Ln--, Rn.shift()?.();
|
|
2191
2191
|
});
|
|
2192
2192
|
};
|
|
2193
|
-
|
|
2193
|
+
Ln < Fn ? r() : Rn.push(r);
|
|
2194
2194
|
});
|
|
2195
2195
|
}
|
|
2196
|
-
var
|
|
2197
|
-
function
|
|
2198
|
-
let n =
|
|
2196
|
+
var Bn = /* @__PURE__ */ new Map();
|
|
2197
|
+
function Vn(e, t) {
|
|
2198
|
+
let n = Bn.get(e);
|
|
2199
2199
|
if (!n) {
|
|
2200
2200
|
let r = {
|
|
2201
2201
|
refs: 0,
|
|
2202
2202
|
promise: Promise.resolve("")
|
|
2203
2203
|
};
|
|
2204
|
-
r.promise =
|
|
2204
|
+
r.promise = zn(t).then((e) => (r.url = URL.createObjectURL(e), r.url)), Bn.set(e, r), n = r;
|
|
2205
2205
|
}
|
|
2206
2206
|
n.timer && (clearTimeout(n.timer), n.timer = void 0), n.refs++;
|
|
2207
2207
|
let r = n, i = !1;
|
|
@@ -2209,15 +2209,15 @@ function Rn(e, t) {
|
|
|
2209
2209
|
promise: r.promise,
|
|
2210
2210
|
release: () => {
|
|
2211
2211
|
i || (i = !0, r.refs--, !(r.refs > 0) && (r.timer = setTimeout(() => {
|
|
2212
|
-
r.url && URL.revokeObjectURL(r.url),
|
|
2213
|
-
},
|
|
2212
|
+
r.url && URL.revokeObjectURL(r.url), Bn.get(e) === r && Bn.delete(e);
|
|
2213
|
+
}, In)));
|
|
2214
2214
|
}
|
|
2215
2215
|
};
|
|
2216
2216
|
}
|
|
2217
|
-
async function
|
|
2218
|
-
if (e.size <
|
|
2217
|
+
async function Hn(e) {
|
|
2218
|
+
if (e.size < Pn || typeof createImageBitmap != "function") return e;
|
|
2219
2219
|
let t = await createImageBitmap(e, {
|
|
2220
|
-
resizeWidth:
|
|
2220
|
+
resizeWidth: Nn,
|
|
2221
2221
|
resizeQuality: "medium"
|
|
2222
2222
|
});
|
|
2223
2223
|
try {
|
|
@@ -2234,22 +2234,22 @@ async function zn(e) {
|
|
|
2234
2234
|
t.close();
|
|
2235
2235
|
}
|
|
2236
2236
|
}
|
|
2237
|
-
async function
|
|
2237
|
+
async function Un(e) {
|
|
2238
2238
|
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
|
-
|
|
2239
|
+
return t ? qt(t.file.path) : Hn(await qt(e.file.path));
|
|
2240
|
+
}
|
|
2241
|
+
var Wn = /* @__PURE__ */ new WeakMap(), Gn = null;
|
|
2242
|
+
function Kn(e, t) {
|
|
2243
|
+
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (Gn ?? (Gn = new IntersectionObserver((e) => {
|
|
2244
|
+
for (let t of e) t.isIntersecting && (Gn.unobserve(t.target), Wn.get(t.target)?.(), Wn.delete(t.target));
|
|
2245
|
+
}, { rootMargin: "300px" })), Wn.set(e, t), Gn.observe(e), () => {
|
|
2246
|
+
Wn.delete(e), Gn?.unobserve(e);
|
|
2247
2247
|
});
|
|
2248
2248
|
}
|
|
2249
|
-
function
|
|
2250
|
-
let t =
|
|
2249
|
+
function qn(e) {
|
|
2250
|
+
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
2251
|
i(() => {
|
|
2252
|
-
if (t && r && !o) return
|
|
2252
|
+
if (t && r && !o) return Kn(r, () => s(!0));
|
|
2253
2253
|
}, [
|
|
2254
2254
|
t,
|
|
2255
2255
|
r,
|
|
@@ -2260,7 +2260,7 @@ function Wn(e) {
|
|
|
2260
2260
|
if (!t || !o) return;
|
|
2261
2261
|
let n = !1;
|
|
2262
2262
|
f("loading");
|
|
2263
|
-
let r =
|
|
2263
|
+
let r = Vn(_, () => Un(e));
|
|
2264
2264
|
return r.promise.then((e) => {
|
|
2265
2265
|
n || (u(e), f("ready"));
|
|
2266
2266
|
}, () => {
|
|
@@ -2283,7 +2283,7 @@ function Wn(e) {
|
|
|
2283
2283
|
}
|
|
2284
2284
|
//#endregion
|
|
2285
2285
|
//#region src/OPFSFilesManager/FileThumbnail.tsx
|
|
2286
|
-
var
|
|
2286
|
+
var Jn = {
|
|
2287
2287
|
image: {
|
|
2288
2288
|
icon: "image",
|
|
2289
2289
|
label: "Images",
|
|
@@ -2314,11 +2314,11 @@ var Gn = {
|
|
|
2314
2314
|
label: "Other",
|
|
2315
2315
|
color: "var(--seed-kind-other)"
|
|
2316
2316
|
}
|
|
2317
|
-
},
|
|
2318
|
-
function
|
|
2319
|
-
let r =
|
|
2317
|
+
}, Yn = (e) => ({ "--seed-kind": Jn[e].color }), Xn = (e) => /png|webp|gif|avif|svg/.test(_n(e.file));
|
|
2318
|
+
function Zn({ entry: e, size: t, children: n }) {
|
|
2319
|
+
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
2320
|
t === "tile" ? "seed-fm-thumb" : "seed-fm-mini",
|
|
2321
|
-
l &&
|
|
2321
|
+
l && Xn(e) ? "seed-fm-thumb--checker" : "",
|
|
2322
2322
|
r === "image" && o === "loading" ? "seed-fm-skeleton" : ""
|
|
2323
2323
|
].filter(Boolean).join(" "), d;
|
|
2324
2324
|
return d = l ? /* @__PURE__ */ z("img", {
|
|
@@ -2328,12 +2328,12 @@ function Jn({ entry: e, size: t, children: n }) {
|
|
|
2328
2328
|
draggable: !1,
|
|
2329
2329
|
onError: s
|
|
2330
2330
|
}) : t === "mini" ? /* @__PURE__ */ z($, {
|
|
2331
|
-
name: c ? "imageOff" :
|
|
2331
|
+
name: c ? "imageOff" : Jn[r].icon,
|
|
2332
2332
|
size: 16
|
|
2333
2333
|
}) : r === "image" && !c ? null : /* @__PURE__ */ B("span", {
|
|
2334
2334
|
className: "seed-fm-kind",
|
|
2335
2335
|
children: [/* @__PURE__ */ z($, {
|
|
2336
|
-
name: c ? "imageOff" :
|
|
2336
|
+
name: c ? "imageOff" : Jn[r].icon,
|
|
2337
2337
|
size: 28,
|
|
2338
2338
|
strokeWidth: 1.6
|
|
2339
2339
|
}), c ? /* @__PURE__ */ z("span", {
|
|
@@ -2341,18 +2341,18 @@ function Jn({ entry: e, size: t, children: n }) {
|
|
|
2341
2341
|
children: "Can’t decode image"
|
|
2342
2342
|
}) : /* @__PURE__ */ z("span", {
|
|
2343
2343
|
className: "seed-fm-ext",
|
|
2344
|
-
children:
|
|
2344
|
+
children: bn(e.file)
|
|
2345
2345
|
})]
|
|
2346
2346
|
}), /* @__PURE__ */ B("span", {
|
|
2347
2347
|
ref: i,
|
|
2348
2348
|
className: u,
|
|
2349
|
-
style:
|
|
2349
|
+
style: Yn(r),
|
|
2350
2350
|
children: [d, n]
|
|
2351
2351
|
});
|
|
2352
2352
|
}
|
|
2353
2353
|
//#endregion
|
|
2354
2354
|
//#region src/OPFSFilesManager/FileGrid.tsx
|
|
2355
|
-
function
|
|
2355
|
+
function Qn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i, tileClassName: a }) {
|
|
2356
2356
|
return /* @__PURE__ */ z("ul", {
|
|
2357
2357
|
className: ["seed-fm-grid", i].filter(Boolean).join(" "),
|
|
2358
2358
|
role: "listbox",
|
|
@@ -2372,7 +2372,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2372
2372
|
onKeyDown: (t) => {
|
|
2373
2373
|
t.target === t.currentTarget && (t.key === "Enter" ? (t.preventDefault(), n(e, i, t)) : t.key === " " && (t.preventDefault(), r(e, i, t.shiftKey)));
|
|
2374
2374
|
},
|
|
2375
|
-
children: [/* @__PURE__ */ B(
|
|
2375
|
+
children: [/* @__PURE__ */ B(Zn, {
|
|
2376
2376
|
entry: e,
|
|
2377
2377
|
size: "tile",
|
|
2378
2378
|
children: [/* @__PURE__ */ z("button", {
|
|
@@ -2406,7 +2406,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2406
2406
|
className: "seed-fm-tile-meta",
|
|
2407
2407
|
children: [/* @__PURE__ */ z("span", {
|
|
2408
2408
|
className: "seed-fm-tile-name",
|
|
2409
|
-
children:
|
|
2409
|
+
children: dn(o.name, 24)
|
|
2410
2410
|
}), /* @__PURE__ */ B("span", {
|
|
2411
2411
|
className: "seed-fm-tile-sub",
|
|
2412
2412
|
children: [
|
|
@@ -2415,8 +2415,8 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2415
2415
|
" ",
|
|
2416
2416
|
/* @__PURE__ */ z("time", {
|
|
2417
2417
|
dateTime: new Date(o.lastModified).toISOString(),
|
|
2418
|
-
title:
|
|
2419
|
-
children:
|
|
2418
|
+
title: un(o.lastModified),
|
|
2419
|
+
children: ln(o.lastModified)
|
|
2420
2420
|
})
|
|
2421
2421
|
]
|
|
2422
2422
|
})]
|
|
@@ -2427,7 +2427,7 @@ function Yn({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2427
2427
|
}
|
|
2428
2428
|
//#endregion
|
|
2429
2429
|
//#region src/OPFSFilesManager/FileList.tsx
|
|
2430
|
-
function
|
|
2430
|
+
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
2431
|
let p = s(null), m = e.filter((e) => t.has(e.file.path)).length, h = e.length > 0 && m === e.length;
|
|
2432
2432
|
i(() => {
|
|
2433
2433
|
p.current && (p.current.indeterminate = m > 0 && !h);
|
|
@@ -2487,7 +2487,7 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2487
2487
|
}),
|
|
2488
2488
|
/* @__PURE__ */ z("td", { children: /* @__PURE__ */ B("span", {
|
|
2489
2489
|
className: "seed-fm-namecell",
|
|
2490
|
-
children: [/* @__PURE__ */ z(
|
|
2490
|
+
children: [/* @__PURE__ */ z(Zn, {
|
|
2491
2491
|
entry: e,
|
|
2492
2492
|
size: "mini"
|
|
2493
2493
|
}), /* @__PURE__ */ B("span", { children: [/* @__PURE__ */ z("button", {
|
|
@@ -2506,8 +2506,8 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2506
2506
|
className: "seed-fm-col-type",
|
|
2507
2507
|
children: /* @__PURE__ */ B("span", {
|
|
2508
2508
|
className: "seed-fm-type",
|
|
2509
|
-
style:
|
|
2510
|
-
children: [
|
|
2509
|
+
style: Yn(yn(i)),
|
|
2510
|
+
children: [_n(i), i.detectedType && /* @__PURE__ */ z("small", { children: "detected" })]
|
|
2511
2511
|
})
|
|
2512
2512
|
}),
|
|
2513
2513
|
/* @__PURE__ */ z("td", {
|
|
@@ -2517,8 +2517,8 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2517
2517
|
}),
|
|
2518
2518
|
/* @__PURE__ */ z("td", {
|
|
2519
2519
|
className: "seed-fm-when seed-fm-col-modified",
|
|
2520
|
-
title:
|
|
2521
|
-
children:
|
|
2520
|
+
title: un(i.lastModified),
|
|
2521
|
+
children: ln(i.lastModified)
|
|
2522
2522
|
}),
|
|
2523
2523
|
/* @__PURE__ */ B("td", {
|
|
2524
2524
|
className: "seed-fm-actions",
|
|
@@ -2553,22 +2553,22 @@ function Xn({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2553
2553
|
}
|
|
2554
2554
|
//#endregion
|
|
2555
2555
|
//#region src/OPFSFilesManager/PreviewPanel.tsx
|
|
2556
|
-
var
|
|
2557
|
-
function
|
|
2558
|
-
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o =
|
|
2556
|
+
var er = 1048576, tr = 32768;
|
|
2557
|
+
function nr(e) {
|
|
2558
|
+
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o = yn(e.file), s = e.file.size;
|
|
2559
2559
|
return i(() => {
|
|
2560
2560
|
let e = !1, t = null;
|
|
2561
2561
|
return n({ kind: "loading" }), (async () => {
|
|
2562
|
-
if (o === "image") return t = URL.createObjectURL(await
|
|
2562
|
+
if (o === "image") return t = URL.createObjectURL(await qt(r)), {
|
|
2563
2563
|
kind: "image",
|
|
2564
2564
|
url: t
|
|
2565
2565
|
};
|
|
2566
2566
|
if (o === "json" || o === "html" || o === "text") {
|
|
2567
|
-
if (s >
|
|
2567
|
+
if (s > er) return {
|
|
2568
2568
|
kind: "none",
|
|
2569
2569
|
message: "This file is too large to preview."
|
|
2570
2570
|
};
|
|
2571
|
-
let e = await
|
|
2571
|
+
let e = await qt(r), t = e.size > tr, n = await e.slice(0, tr).text();
|
|
2572
2572
|
if (o === "json" && !t) try {
|
|
2573
2573
|
n = JSON.stringify(JSON.parse(n), null, 2);
|
|
2574
2574
|
} catch {}
|
|
@@ -2602,8 +2602,8 @@ function $n(e) {
|
|
|
2602
2602
|
o
|
|
2603
2603
|
]), t;
|
|
2604
2604
|
}
|
|
2605
|
-
function
|
|
2606
|
-
let { file: f, variants: p } = e, m =
|
|
2605
|
+
function rr({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onDelete: o, deleteAction: l, onCopyPath: u, className: d }) {
|
|
2606
|
+
let { file: f, variants: p } = e, m = yn(f), h = nr(e), [g, _] = c(null), [v, y] = c(!1), b = s(null);
|
|
2607
2607
|
i(() => {
|
|
2608
2608
|
_(null), y(!1);
|
|
2609
2609
|
}, [f.path]), i(() => {
|
|
@@ -2626,13 +2626,13 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2626
2626
|
C = /* @__PURE__ */ B("span", {
|
|
2627
2627
|
className: "seed-fm-preview-note",
|
|
2628
2628
|
children: [/* @__PURE__ */ z($, {
|
|
2629
|
-
name: v ? "imageOff" :
|
|
2629
|
+
name: v ? "imageOff" : Jn[m].icon,
|
|
2630
2630
|
size: 32,
|
|
2631
2631
|
strokeWidth: 1.5
|
|
2632
2632
|
}), e]
|
|
2633
2633
|
});
|
|
2634
2634
|
}
|
|
2635
|
-
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(
|
|
2635
|
+
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(_n(f));
|
|
2636
2636
|
return /* @__PURE__ */ B("aside", {
|
|
2637
2637
|
className: ["seed-fm-panel", d].filter(Boolean).join(" "),
|
|
2638
2638
|
role: "dialog",
|
|
@@ -2682,7 +2682,7 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2682
2682
|
w ? "seed-fm-thumb--checker" : "",
|
|
2683
2683
|
h.kind === "loading" ? "seed-fm-skeleton" : ""
|
|
2684
2684
|
].filter(Boolean).join(" "),
|
|
2685
|
-
style:
|
|
2685
|
+
style: Yn(m),
|
|
2686
2686
|
children: C
|
|
2687
2687
|
}),
|
|
2688
2688
|
/* @__PURE__ */ B("dl", {
|
|
@@ -2710,7 +2710,7 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2710
2710
|
/* @__PURE__ */ B("small", { children: [f.size.toLocaleString(), " bytes"] })
|
|
2711
2711
|
] }),
|
|
2712
2712
|
/* @__PURE__ */ z("dt", { children: "Type" }),
|
|
2713
|
-
/* @__PURE__ */ B("dd", { children: [
|
|
2713
|
+
/* @__PURE__ */ B("dd", { children: [_n(f), f.detectedType && /* @__PURE__ */ B("small", { children: [
|
|
2714
2714
|
" from file contents. File.type is “",
|
|
2715
2715
|
f.type,
|
|
2716
2716
|
"”"
|
|
@@ -2723,9 +2723,9 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2723
2723
|
] })] }),
|
|
2724
2724
|
/* @__PURE__ */ z("dt", { children: "Modified" }),
|
|
2725
2725
|
/* @__PURE__ */ B("dd", { children: [
|
|
2726
|
-
|
|
2726
|
+
un(f.lastModified),
|
|
2727
2727
|
" ",
|
|
2728
|
-
/* @__PURE__ */ z("small", { children:
|
|
2728
|
+
/* @__PURE__ */ z("small", { children: ln(f.lastModified) })
|
|
2729
2729
|
] })
|
|
2730
2730
|
]
|
|
2731
2731
|
}),
|
|
@@ -2770,18 +2770,18 @@ function er({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2770
2770
|
}
|
|
2771
2771
|
//#endregion
|
|
2772
2772
|
//#region src/OPFSFilesManager/styles.ts
|
|
2773
|
-
var
|
|
2773
|
+
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
2774
|
.seed-fm {
|
|
2775
|
-
${
|
|
2775
|
+
${or}
|
|
2776
2776
|
--seed-radius-sm: 6px;
|
|
2777
2777
|
--seed-radius-md: 8px;
|
|
2778
2778
|
--seed-radius-lg: 12px;
|
|
2779
2779
|
--seed-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2780
2780
|
color-scheme: light;
|
|
2781
2781
|
}
|
|
2782
|
-
.seed-fm[data-seed-theme="dark"] { ${
|
|
2782
|
+
.seed-fm[data-seed-theme="dark"] { ${sr} }
|
|
2783
2783
|
@media (prefers-color-scheme: dark) {
|
|
2784
|
-
.seed-fm[data-seed-theme="system"] { ${
|
|
2784
|
+
.seed-fm[data-seed-theme="system"] { ${sr} }
|
|
2785
2785
|
}
|
|
2786
2786
|
|
|
2787
2787
|
.seed-fm { position: relative; color: var(--seed-fg); background: var(--seed-bg); font-family: inherit; font-size: 14px; line-height: 1.45; }
|
|
@@ -2989,14 +2989,14 @@ var tr = "seed-opfs-files-manager-styles", nr = "seed-opfs-files-manager", rr =
|
|
|
2989
2989
|
.seed-fm-thumb img { transition: none; }
|
|
2990
2990
|
}
|
|
2991
2991
|
`}\n}`;
|
|
2992
|
-
function
|
|
2992
|
+
function lr() {
|
|
2993
2993
|
if (typeof document > "u" || document.getElementById("seed-opfs-files-manager-styles")) return;
|
|
2994
2994
|
let e = document.createElement("style");
|
|
2995
|
-
e.id =
|
|
2995
|
+
e.id = ir, e.textContent = cr, document.head.appendChild(e);
|
|
2996
2996
|
}
|
|
2997
2997
|
//#endregion
|
|
2998
2998
|
//#region src/OPFSFilesManager/useStorageEstimate.ts
|
|
2999
|
-
function
|
|
2999
|
+
function ur(e) {
|
|
3000
3000
|
let [t, n] = c(null);
|
|
3001
3001
|
return i(() => {
|
|
3002
3002
|
if (typeof navigator > "u" || typeof navigator.storage?.estimate != "function") return;
|
|
@@ -3013,40 +3013,40 @@ function sr(e) {
|
|
|
3013
3013
|
}
|
|
3014
3014
|
//#endregion
|
|
3015
3015
|
//#region src/OPFSFilesManager/zip.ts
|
|
3016
|
-
var
|
|
3017
|
-
function
|
|
3018
|
-
if (
|
|
3019
|
-
|
|
3016
|
+
var dr = null;
|
|
3017
|
+
function fr() {
|
|
3018
|
+
if (dr) return dr;
|
|
3019
|
+
dr = /* @__PURE__ */ new Uint32Array(256);
|
|
3020
3020
|
for (let e = 0; e < 256; e++) {
|
|
3021
3021
|
let t = e;
|
|
3022
3022
|
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
3023
|
-
|
|
3023
|
+
dr[e] = t >>> 0;
|
|
3024
3024
|
}
|
|
3025
|
-
return
|
|
3025
|
+
return dr;
|
|
3026
3026
|
}
|
|
3027
|
-
function
|
|
3028
|
-
let t =
|
|
3027
|
+
function pr(e) {
|
|
3028
|
+
let t = fr(), n = 4294967295;
|
|
3029
3029
|
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
3030
3030
|
return (n ^ 4294967295) >>> 0;
|
|
3031
3031
|
}
|
|
3032
|
-
function
|
|
3032
|
+
function mr(e) {
|
|
3033
3033
|
let t = new Date(e), n = Math.max(1980, t.getFullYear());
|
|
3034
3034
|
return {
|
|
3035
3035
|
time: t.getHours() << 11 | t.getMinutes() << 5 | Math.floor(t.getSeconds() / 2),
|
|
3036
3036
|
date: n - 1980 << 9 | t.getMonth() + 1 << 5 | t.getDate()
|
|
3037
3037
|
};
|
|
3038
3038
|
}
|
|
3039
|
-
var
|
|
3040
|
-
async function
|
|
3039
|
+
var hr = 2048, gr = 4294967295;
|
|
3040
|
+
async function _r(e) {
|
|
3041
3041
|
if (e.length > 65535) throw Error("Too many files for a ZIP archive (max 65,535).");
|
|
3042
3042
|
let t = new TextEncoder(), n = [], r = [], i = 0;
|
|
3043
3043
|
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 >
|
|
3044
|
+
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());
|
|
3045
|
+
if (i + o.length + 30 + e.length > gr) throw Error("Selection is too large for a ZIP archive (max 4 GB).");
|
|
3046
3046
|
let u = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(30));
|
|
3047
|
-
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6,
|
|
3047
|
+
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
3048
|
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,
|
|
3049
|
+
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
3050
|
let f = new Uint8Array(46 + e.length);
|
|
3051
3051
|
f.set(new Uint8Array(d.buffer), 0), f.set(e, 46), r.push(f), i += 30 + e.length + o.length;
|
|
3052
3052
|
}
|
|
@@ -3059,12 +3059,12 @@ async function mr(e) {
|
|
|
3059
3059
|
}
|
|
3060
3060
|
//#endregion
|
|
3061
3061
|
//#region src/OPFSFilesManager/OPFSFilesManager.tsx
|
|
3062
|
-
var
|
|
3063
|
-
function
|
|
3062
|
+
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("/");
|
|
3063
|
+
function Cr(e, t) {
|
|
3064
3064
|
let n = URL.createObjectURL(t), r = document.createElement("a");
|
|
3065
3065
|
r.href = n, r.download = e, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
3066
3066
|
}
|
|
3067
|
-
function
|
|
3067
|
+
function wr() {
|
|
3068
3068
|
let [e, t] = c([]), r = s(/* @__PURE__ */ new Set());
|
|
3069
3069
|
return i(() => {
|
|
3070
3070
|
let e = r.current;
|
|
@@ -3080,12 +3080,12 @@ function xr() {
|
|
|
3080
3080
|
}]);
|
|
3081
3081
|
let a = setTimeout(() => {
|
|
3082
3082
|
r.current.delete(a), t((e) => e.filter((e) => e.id !== i));
|
|
3083
|
-
},
|
|
3083
|
+
}, yr);
|
|
3084
3084
|
r.current.add(a);
|
|
3085
3085
|
}, [])
|
|
3086
3086
|
};
|
|
3087
3087
|
}
|
|
3088
|
-
var
|
|
3088
|
+
var Tr = [
|
|
3089
3089
|
"image",
|
|
3090
3090
|
"database",
|
|
3091
3091
|
"json",
|
|
@@ -3093,11 +3093,11 @@ var Sr = [
|
|
|
3093
3093
|
"text",
|
|
3094
3094
|
"other"
|
|
3095
3095
|
];
|
|
3096
|
-
function
|
|
3097
|
-
let n =
|
|
3098
|
-
label:
|
|
3096
|
+
function Er({ files: e, estimate: t }) {
|
|
3097
|
+
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) => ({
|
|
3098
|
+
label: Jn[e].label,
|
|
3099
3099
|
size: n[e],
|
|
3100
|
-
color:
|
|
3100
|
+
color: Jn[e].color
|
|
3101
3101
|
})), ...i > 0 ? [{
|
|
3102
3102
|
label: "Other site data",
|
|
3103
3103
|
size: i,
|
|
@@ -3111,7 +3111,7 @@ function Cr({ files: e, estimate: t }) {
|
|
|
3111
3111
|
children: [/* @__PURE__ */ B("span", { children: [
|
|
3112
3112
|
/* @__PURE__ */ z("strong", { children: Q(t ? t.usage : r) }),
|
|
3113
3113
|
" ",
|
|
3114
|
-
t ? "used by this site" : `in ${
|
|
3114
|
+
t ? "used by this site" : `in ${xr(e.length, "file")}`
|
|
3115
3115
|
] }), t && /* @__PURE__ */ B("span", { children: [Q(t.quota), " available"] })]
|
|
3116
3116
|
}), a > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3117
3117
|
className: "seed-fm-meter",
|
|
@@ -3134,7 +3134,7 @@ function Cr({ files: e, estimate: t }) {
|
|
|
3134
3134
|
})] })]
|
|
3135
3135
|
});
|
|
3136
3136
|
}
|
|
3137
|
-
function
|
|
3137
|
+
function Dr({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
3138
3138
|
return /* @__PURE__ */ B("div", {
|
|
3139
3139
|
className: `seed-fm-state${r === "error" ? " seed-fm-state--error" : ""}`,
|
|
3140
3140
|
role: r === "error" ? "alert" : void 0,
|
|
@@ -3152,70 +3152,70 @@ function wr({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
|
3152
3152
|
]
|
|
3153
3153
|
});
|
|
3154
3154
|
}
|
|
3155
|
-
function
|
|
3155
|
+
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
3156
|
a(() => {
|
|
3157
|
-
p !== "none" &&
|
|
3157
|
+
p !== "none" && lr();
|
|
3158
3158
|
}, [p]);
|
|
3159
|
-
let S =
|
|
3160
|
-
i(() =>
|
|
3161
|
-
let
|
|
3162
|
-
i(() =>
|
|
3163
|
-
let [
|
|
3164
|
-
x ? x(e, t, n) :
|
|
3165
|
-
},
|
|
3166
|
-
query:
|
|
3159
|
+
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(_);
|
|
3160
|
+
i(() => k(_), [_]);
|
|
3161
|
+
let A = o(() => Dn(O, ie), [O, ie]), [j, ae] = c(S);
|
|
3162
|
+
i(() => ae(S), [S]);
|
|
3163
|
+
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) => {
|
|
3164
|
+
x ? x(e, t, n) : ge(e, t);
|
|
3165
|
+
}, W = o(() => kn(A, j, {
|
|
3166
|
+
query: oe,
|
|
3167
3167
|
sort: ce
|
|
3168
3168
|
}), [
|
|
3169
|
-
k,
|
|
3170
3169
|
A,
|
|
3171
|
-
|
|
3170
|
+
j,
|
|
3171
|
+
oe,
|
|
3172
3172
|
ce
|
|
3173
|
-
]), G =
|
|
3173
|
+
]), 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
3174
|
i(() => {
|
|
3175
|
-
|
|
3175
|
+
N((e) => {
|
|
3176
3176
|
let t = new Set([...e].filter((e) => be.has(e)));
|
|
3177
3177
|
return t.size === e.size ? e : t;
|
|
3178
3178
|
});
|
|
3179
3179
|
}, [be]);
|
|
3180
|
-
let
|
|
3181
|
-
|
|
3180
|
+
let J = (e) => {
|
|
3181
|
+
ae(e), se(""), N(/* @__PURE__ */ new Set()), P.current = null, I(null);
|
|
3182
3182
|
}, Se = (e, t, n) => {
|
|
3183
|
-
let r =
|
|
3184
|
-
|
|
3183
|
+
let r = P.current;
|
|
3184
|
+
N((i) => {
|
|
3185
3185
|
let a = new Set(i);
|
|
3186
3186
|
if (n && r != null) {
|
|
3187
3187
|
let [e, n] = r < t ? [r, t] : [t, r];
|
|
3188
3188
|
for (let t of G.slice(e, n + 1)) a.add(t.file.path);
|
|
3189
3189
|
} else a.has(e.file.path) ? a.delete(e.file.path) : a.add(e.file.path);
|
|
3190
3190
|
return a;
|
|
3191
|
-
}), (!n || r == null) && (
|
|
3191
|
+
}), (!n || r == null) && (P.current = t);
|
|
3192
3192
|
}, Ce = (e) => {
|
|
3193
|
-
|
|
3194
|
-
},
|
|
3195
|
-
|
|
3196
|
-
},
|
|
3193
|
+
F || (fe.current = document.activeElement), I(e);
|
|
3194
|
+
}, we = () => {
|
|
3195
|
+
I(null), fe.current?.focus?.(), fe.current = null;
|
|
3196
|
+
}, Te = (e, t, n) => {
|
|
3197
3197
|
let r = n.shiftKey || n.metaKey || n.ctrlKey;
|
|
3198
|
-
|
|
3199
|
-
},
|
|
3200
|
-
let e = G.every((e) =>
|
|
3201
|
-
|
|
3198
|
+
M.size > 0 || r ? Se(e, t, n.shiftKey) : Ce(e.file.path);
|
|
3199
|
+
}, Ee = () => {
|
|
3200
|
+
let e = G.every((e) => M.has(e.file.path));
|
|
3201
|
+
N((t) => {
|
|
3202
3202
|
let n = new Set(t);
|
|
3203
3203
|
for (let t of G) e ? n.delete(t.file.path) : n.add(t.file.path);
|
|
3204
3204
|
return n;
|
|
3205
3205
|
});
|
|
3206
|
-
},
|
|
3207
|
-
l ? await l(e, t) :
|
|
3206
|
+
}, Y = (e) => S && e.startsWith(`${S}/`) ? e.slice(S.length + 1) : e, De = async (e, t) => {
|
|
3207
|
+
l ? await l(e, t) : Cr(e.name, t);
|
|
3208
3208
|
}, Oe = async (e, t) => {
|
|
3209
3209
|
if (e.length === 0) return !1;
|
|
3210
|
-
|
|
3210
|
+
H(!0);
|
|
3211
3211
|
try {
|
|
3212
3212
|
if (e.length === 1 && !t) {
|
|
3213
3213
|
let [t] = e;
|
|
3214
|
-
return await De(t, await
|
|
3214
|
+
return await De(t, await qt(t.path)), !0;
|
|
3215
3215
|
}
|
|
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
|
|
3216
|
+
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await _r(await Promise.all(e.map(async (e) => ({
|
|
3217
|
+
name: t ? e.path.slice(n.length) : Y(e.path),
|
|
3218
|
+
data: await qt(e.path),
|
|
3219
3219
|
lastModified: e.lastModified
|
|
3220
3220
|
})))), i = `${t ? t.name : C}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`;
|
|
3221
3221
|
return await De({
|
|
@@ -3224,19 +3224,19 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3224
3224
|
size: r.size,
|
|
3225
3225
|
type: "application/zip",
|
|
3226
3226
|
lastModified: Date.now()
|
|
3227
|
-
}, r),
|
|
3227
|
+
}, r), _e(`Saved ${i} with ${xr(e.length, "file")}`, "success", {
|
|
3228
3228
|
kind: "download",
|
|
3229
3229
|
paths: e.map((e) => e.path),
|
|
3230
3230
|
fileName: i
|
|
3231
3231
|
}), !0;
|
|
3232
3232
|
} catch (t) {
|
|
3233
|
-
return
|
|
3233
|
+
return _e(`Couldn’t download: ${br(t)}`, "error", {
|
|
3234
3234
|
kind: "download",
|
|
3235
3235
|
paths: e.map((e) => e.path),
|
|
3236
|
-
error:
|
|
3236
|
+
error: br(t)
|
|
3237
3237
|
}), !1;
|
|
3238
3238
|
} finally {
|
|
3239
|
-
|
|
3239
|
+
H(!1);
|
|
3240
3240
|
}
|
|
3241
3241
|
}, 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
3242
|
let t = b?.(e);
|
|
@@ -3245,43 +3245,43 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3245
3245
|
destructive: t?.destructive !== !1
|
|
3246
3246
|
};
|
|
3247
3247
|
}, je = (e) => Ae(X(e, !0)), Me = async (e, t) => {
|
|
3248
|
-
|
|
3248
|
+
H(!0);
|
|
3249
3249
|
let i = [], a = [], o = [], s = !1;
|
|
3250
3250
|
try {
|
|
3251
3251
|
let r = await navigator.storage.getDirectory();
|
|
3252
3252
|
for (let t of e) if (n && !await n(t)) o.push(t.path);
|
|
3253
3253
|
else try {
|
|
3254
|
-
await
|
|
3254
|
+
await Jt(t.path, r), i.push(t.path);
|
|
3255
3255
|
} catch (e) {
|
|
3256
3256
|
a.push({
|
|
3257
3257
|
path: t.path,
|
|
3258
|
-
error:
|
|
3258
|
+
error: br(e)
|
|
3259
3259
|
});
|
|
3260
3260
|
}
|
|
3261
3261
|
if (t) try {
|
|
3262
|
-
s = await
|
|
3262
|
+
s = await Xt(t.path, r);
|
|
3263
3263
|
} catch (e) {
|
|
3264
3264
|
a.push({
|
|
3265
3265
|
path: t.path,
|
|
3266
|
-
error:
|
|
3266
|
+
error: br(e)
|
|
3267
3267
|
});
|
|
3268
3268
|
}
|
|
3269
3269
|
} catch (e) {
|
|
3270
3270
|
a.push({
|
|
3271
3271
|
path: "",
|
|
3272
|
-
error:
|
|
3272
|
+
error: br(e)
|
|
3273
3273
|
});
|
|
3274
3274
|
}
|
|
3275
|
-
|
|
3275
|
+
N((e) => {
|
|
3276
3276
|
let t = new Set(e);
|
|
3277
3277
|
return i.forEach((e) => t.delete(e)), t;
|
|
3278
|
-
}),
|
|
3279
|
-
let c = [s ? `Deleted the ${t.name} folder (${
|
|
3278
|
+
}), F && i.includes(F) && I(null), await ne(), H(!1);
|
|
3279
|
+
let c = [s ? `Deleted the ${t.name} folder (${xr(i.length, "file")})` : i.length > 0 ? `Deleted ${xr(i.length, "file")}` : "Nothing deleted"];
|
|
3280
3280
|
if (o.length && c.push(`${o.length} kept by onBeforeDelete`), a.length) {
|
|
3281
3281
|
let e = a.map((e) => e.path ? `${e.path.split("/").pop()}: ${e.error}` : e.error);
|
|
3282
3282
|
c.push(`${a.length} failed (${e.join("; ")})`);
|
|
3283
3283
|
}
|
|
3284
|
-
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`),
|
|
3284
|
+
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
3285
|
kind: "delete",
|
|
3286
3286
|
deleted: i,
|
|
3287
3287
|
skipped: o,
|
|
@@ -3294,26 +3294,26 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3294
3294
|
}, Ne = async (e) => {
|
|
3295
3295
|
if (e.length === 0) return;
|
|
3296
3296
|
if (!y) {
|
|
3297
|
-
|
|
3297
|
+
pe(e);
|
|
3298
3298
|
return;
|
|
3299
3299
|
}
|
|
3300
3300
|
let t = X(e, !0);
|
|
3301
3301
|
await y(t) && await Me(t);
|
|
3302
|
-
}, Pe = (e) =>
|
|
3302
|
+
}, Pe = (e) => O.filter((t) => t.path.startsWith(`${e.path}/`)), Fe = async (e) => {
|
|
3303
3303
|
if (!y) {
|
|
3304
|
-
|
|
3304
|
+
me(e);
|
|
3305
3305
|
return;
|
|
3306
3306
|
}
|
|
3307
3307
|
let t = Pe(e);
|
|
3308
3308
|
await y(t) && await Me(t, e);
|
|
3309
3309
|
}, Ie = (e) => {
|
|
3310
|
-
let t = () =>
|
|
3310
|
+
let t = () => _e("Path copied", "success", {
|
|
3311
3311
|
kind: "copy-path",
|
|
3312
3312
|
path: e
|
|
3313
|
-
}), n = (t) =>
|
|
3313
|
+
}), n = (t) => _e("Couldn’t copy. Select the path text instead.", "error", {
|
|
3314
3314
|
kind: "copy-path",
|
|
3315
3315
|
path: e,
|
|
3316
|
-
error: t === void 0 ? "Clipboard unavailable" :
|
|
3316
|
+
error: t === void 0 ? "Clipboard unavailable" : br(t)
|
|
3317
3317
|
});
|
|
3318
3318
|
try {
|
|
3319
3319
|
navigator.clipboard.writeText(e).then(t, n);
|
|
@@ -3321,25 +3321,25 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3321
3321
|
n(e);
|
|
3322
3322
|
}
|
|
3323
3323
|
}, Le = (e) => {
|
|
3324
|
-
if (
|
|
3324
|
+
if (L || V) return;
|
|
3325
3325
|
let t = e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement;
|
|
3326
3326
|
if (e.key === "Escape") {
|
|
3327
|
-
if (
|
|
3328
|
-
else if (
|
|
3327
|
+
if (F) we();
|
|
3328
|
+
else if (M.size > 0) N(/* @__PURE__ */ new Set());
|
|
3329
3329
|
else return;
|
|
3330
3330
|
e.preventDefault();
|
|
3331
3331
|
} else if (q && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
3332
|
-
let t = G[
|
|
3333
|
-
t &&
|
|
3332
|
+
let t = G[xe + (e.key === "ArrowRight" ? 1 : -1)];
|
|
3333
|
+
t && I(t.file.path), e.preventDefault();
|
|
3334
3334
|
}
|
|
3335
|
-
}, Re = o(() =>
|
|
3335
|
+
}, Re = o(() => O.some((e) => wn(e.path)), [O]), ze = /(^|\/)images(\/\d+)?$/.test(j), Z = [{
|
|
3336
3336
|
label: C,
|
|
3337
3337
|
path: S
|
|
3338
|
-
}, ...(
|
|
3338
|
+
}, ...(j.length > S.length ? j.slice(S ? S.length + 1 : 0).split("/") : []).map((e, t, n) => ({
|
|
3339
3339
|
label: e,
|
|
3340
3340
|
path: [S, ...n.slice(0, t + 1)].filter(Boolean).join("/")
|
|
3341
|
-
}))],
|
|
3342
|
-
if (!
|
|
3341
|
+
}))], Be = `h${f}`, Ve = K.reduce((e, t) => e + t.file.size, 0), He;
|
|
3342
|
+
if (!Zt()) He = /* @__PURE__ */ z(Dr, {
|
|
3343
3343
|
icon: "triangleAlert",
|
|
3344
3344
|
tone: "error",
|
|
3345
3345
|
title: "This browser doesn’t support private file storage",
|
|
@@ -3355,7 +3355,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3355
3355
|
size: 15
|
|
3356
3356
|
}), " Try again"]
|
|
3357
3357
|
});
|
|
3358
|
-
|
|
3358
|
+
He = te === "NotFoundError" && S ? /* @__PURE__ */ B(Dr, {
|
|
3359
3359
|
icon: "triangleAlert",
|
|
3360
3360
|
tone: "error",
|
|
3361
3361
|
title: `Can’t open ${S}`,
|
|
@@ -3368,44 +3368,44 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3368
3368
|
/* @__PURE__ */ z("code", { children: "rootPath" }),
|
|
3369
3369
|
" prop, or open the app once so the SDK creates it."
|
|
3370
3370
|
]
|
|
3371
|
-
}) : /* @__PURE__ */ z(
|
|
3371
|
+
}) : /* @__PURE__ */ z(Dr, {
|
|
3372
3372
|
icon: "triangleAlert",
|
|
3373
3373
|
tone: "error",
|
|
3374
3374
|
title: "Can’t read private storage",
|
|
3375
3375
|
action: e,
|
|
3376
3376
|
children: D
|
|
3377
3377
|
});
|
|
3378
|
-
} else
|
|
3378
|
+
} else He = ee ? A.length === 0 ? /* @__PURE__ */ z(Dr, {
|
|
3379
3379
|
icon: "folderOpen",
|
|
3380
3380
|
title: `No files in ${C} yet`,
|
|
3381
3381
|
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
|
-
}) :
|
|
3382
|
+
}) : W.folders.length === 0 && G.length === 0 ? oe ? /* @__PURE__ */ B(Dr, {
|
|
3383
3383
|
icon: "search",
|
|
3384
|
-
title: `No matches for “${
|
|
3384
|
+
title: `No matches for “${oe}”`,
|
|
3385
3385
|
action: /* @__PURE__ */ z("button", {
|
|
3386
3386
|
type: "button",
|
|
3387
3387
|
className: "seed-fm-btn",
|
|
3388
|
-
onClick: () =>
|
|
3388
|
+
onClick: () => se(""),
|
|
3389
3389
|
children: "Clear search"
|
|
3390
3390
|
}),
|
|
3391
3391
|
children: [
|
|
3392
3392
|
"Search covers file names and paths in ",
|
|
3393
|
-
|
|
3393
|
+
Z[Z.length - 1].label,
|
|
3394
3394
|
" and every folder inside it."
|
|
3395
3395
|
]
|
|
3396
|
-
}) : /* @__PURE__ */ z(
|
|
3396
|
+
}) : /* @__PURE__ */ z(Dr, {
|
|
3397
3397
|
icon: "folderOpen",
|
|
3398
3398
|
title: "This folder is empty",
|
|
3399
3399
|
children: "Everything in it has been deleted or filtered out."
|
|
3400
|
-
}) : /* @__PURE__ */ B(R, { children: [
|
|
3400
|
+
}) : /* @__PURE__ */ B(R, { children: [W.folders.length > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3401
3401
|
className: "seed-fm-section-label",
|
|
3402
3402
|
children: "Folders"
|
|
3403
3403
|
}), /* @__PURE__ */ z("ul", {
|
|
3404
3404
|
className: "seed-fm-folders",
|
|
3405
|
-
children:
|
|
3405
|
+
children: W.folders.map((e) => /* @__PURE__ */ B("li", { children: [/* @__PURE__ */ B("button", {
|
|
3406
3406
|
type: "button",
|
|
3407
3407
|
className: w("folder", "seed-fm-folder"),
|
|
3408
|
-
onClick: () =>
|
|
3408
|
+
onClick: () => J(e.path),
|
|
3409
3409
|
children: [/* @__PURE__ */ z($, {
|
|
3410
3410
|
name: "folder",
|
|
3411
3411
|
size: 20,
|
|
@@ -3416,7 +3416,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3416
3416
|
}), /* @__PURE__ */ B("span", {
|
|
3417
3417
|
className: "seed-fm-folder-meta",
|
|
3418
3418
|
children: [
|
|
3419
|
-
|
|
3419
|
+
xr(e.fileCount, "file"),
|
|
3420
3420
|
" · ",
|
|
3421
3421
|
Q(e.size)
|
|
3422
3422
|
]
|
|
@@ -3426,7 +3426,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3426
3426
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon seed-fm-folder-delete",
|
|
3427
3427
|
"aria-label": `Delete folder ${e.name}`,
|
|
3428
3428
|
title: "Delete folder",
|
|
3429
|
-
disabled:
|
|
3429
|
+
disabled: he,
|
|
3430
3430
|
onClick: () => Fe(e),
|
|
3431
3431
|
children: /* @__PURE__ */ z($, {
|
|
3432
3432
|
name: "trash",
|
|
@@ -3435,21 +3435,21 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3435
3435
|
})] }, e.path))
|
|
3436
3436
|
})] }), G.length > 0 && /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z("div", {
|
|
3437
3437
|
className: "seed-fm-section-label",
|
|
3438
|
-
children:
|
|
3439
|
-
}), ye === "grid" ? /* @__PURE__ */ z(
|
|
3438
|
+
children: oe ? xr(G.length, "result") : "Files"
|
|
3439
|
+
}), ye === "grid" ? /* @__PURE__ */ z(Qn, {
|
|
3440
3440
|
entries: G,
|
|
3441
|
-
selected:
|
|
3442
|
-
onActivate:
|
|
3441
|
+
selected: M,
|
|
3442
|
+
onActivate: Te,
|
|
3443
3443
|
onToggle: Se,
|
|
3444
3444
|
className: h.grid,
|
|
3445
3445
|
tileClassName: h.tile
|
|
3446
|
-
}) : /* @__PURE__ */ z(
|
|
3446
|
+
}) : /* @__PURE__ */ z($n, {
|
|
3447
3447
|
entries: G,
|
|
3448
|
-
selected:
|
|
3449
|
-
cwd:
|
|
3450
|
-
onActivate:
|
|
3448
|
+
selected: M,
|
|
3449
|
+
cwd: j,
|
|
3450
|
+
onActivate: Te,
|
|
3451
3451
|
onToggle: Se,
|
|
3452
|
-
onToggleAll:
|
|
3452
|
+
onToggleAll: Ee,
|
|
3453
3453
|
onDownload: (e) => ke([e]),
|
|
3454
3454
|
onDelete: (e) => Ne([e]),
|
|
3455
3455
|
deleteActionFor: (e) => je([e]),
|
|
@@ -3464,11 +3464,11 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3464
3464
|
children: /* @__PURE__ */ z("span", { className: "seed-fm-thumb seed-fm-skeleton" })
|
|
3465
3465
|
}, t))
|
|
3466
3466
|
});
|
|
3467
|
-
let
|
|
3467
|
+
let Ue = L ? X(L, !0) : [], We = V ? Pe(V) : [], Ge = M.size > 0 ? je(K) : null;
|
|
3468
3468
|
return /* @__PURE__ */ B("div", {
|
|
3469
3469
|
className: [w("root", "seed-fm"), m].filter(Boolean).join(" "),
|
|
3470
3470
|
"data-seed-theme": p === "none" ? void 0 : p,
|
|
3471
|
-
"data-selecting":
|
|
3471
|
+
"data-selecting": M.size > 0 || void 0,
|
|
3472
3472
|
onKeyDown: Le,
|
|
3473
3473
|
children: [
|
|
3474
3474
|
/* @__PURE__ */ B("div", {
|
|
@@ -3479,7 +3479,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3479
3479
|
children: [
|
|
3480
3480
|
/* @__PURE__ */ B("div", {
|
|
3481
3481
|
className: "seed-fm-titles",
|
|
3482
|
-
children: [/* @__PURE__ */ z(
|
|
3482
|
+
children: [/* @__PURE__ */ z(Be, {
|
|
3483
3483
|
className: "seed-fm-title",
|
|
3484
3484
|
children: u
|
|
3485
3485
|
}), d && /* @__PURE__ */ z("p", {
|
|
@@ -3487,9 +3487,9 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3487
3487
|
children: d
|
|
3488
3488
|
})]
|
|
3489
3489
|
}),
|
|
3490
|
-
ee && !D && /* @__PURE__ */ z(
|
|
3491
|
-
files:
|
|
3492
|
-
estimate:
|
|
3490
|
+
ee && !D && /* @__PURE__ */ z(Er, {
|
|
3491
|
+
files: O,
|
|
3492
|
+
estimate: re
|
|
3493
3493
|
}),
|
|
3494
3494
|
/* @__PURE__ */ z("button", {
|
|
3495
3495
|
type: "button",
|
|
@@ -3505,20 +3505,20 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3505
3505
|
})
|
|
3506
3506
|
]
|
|
3507
3507
|
}),
|
|
3508
|
-
ee && !D &&
|
|
3508
|
+
ee && !D && A.length > 0 && /* @__PURE__ */ B("div", {
|
|
3509
3509
|
className: w("toolbar", "seed-fm-toolbar"),
|
|
3510
3510
|
children: [
|
|
3511
3511
|
/* @__PURE__ */ z("nav", {
|
|
3512
3512
|
"aria-label": "Folder",
|
|
3513
3513
|
children: /* @__PURE__ */ z("ol", {
|
|
3514
3514
|
className: "seed-fm-crumbs",
|
|
3515
|
-
children:
|
|
3515
|
+
children: Z.map((e, t) => /* @__PURE__ */ B("li", { children: [t > 0 && /* @__PURE__ */ z($, {
|
|
3516
3516
|
name: "chevronRight",
|
|
3517
3517
|
size: 14
|
|
3518
3518
|
}), /* @__PURE__ */ z("button", {
|
|
3519
3519
|
type: "button",
|
|
3520
|
-
onClick: () =>
|
|
3521
|
-
"aria-current": t ===
|
|
3520
|
+
onClick: () => J(e.path),
|
|
3521
|
+
"aria-current": t === Z.length - 1 ? "page" : void 0,
|
|
3522
3522
|
children: e.label
|
|
3523
3523
|
})] }, e.path || "/"))
|
|
3524
3524
|
})
|
|
@@ -3530,8 +3530,8 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3530
3530
|
size: 14
|
|
3531
3531
|
}), /* @__PURE__ */ z("input", {
|
|
3532
3532
|
type: "search",
|
|
3533
|
-
value:
|
|
3534
|
-
onChange: (e) =>
|
|
3533
|
+
value: oe,
|
|
3534
|
+
onChange: (e) => se(e.target.value),
|
|
3535
3535
|
placeholder: "Search names and paths",
|
|
3536
3536
|
"aria-label": "Search files"
|
|
3537
3537
|
})]
|
|
@@ -3564,7 +3564,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3564
3564
|
type: "button",
|
|
3565
3565
|
"aria-pressed": ye === "grid",
|
|
3566
3566
|
"aria-label": "Grid view",
|
|
3567
|
-
onClick: () =>
|
|
3567
|
+
onClick: () => de("grid"),
|
|
3568
3568
|
children: /* @__PURE__ */ z($, {
|
|
3569
3569
|
name: "layoutGrid",
|
|
3570
3570
|
size: 15
|
|
@@ -3573,7 +3573,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3573
3573
|
type: "button",
|
|
3574
3574
|
"aria-pressed": ye === "list",
|
|
3575
3575
|
"aria-label": "List view",
|
|
3576
|
-
onClick: () =>
|
|
3576
|
+
onClick: () => de("list"),
|
|
3577
3577
|
children: /* @__PURE__ */ z($, {
|
|
3578
3578
|
name: "list",
|
|
3579
3579
|
size: 15
|
|
@@ -3587,14 +3587,14 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3587
3587
|
name: "layers",
|
|
3588
3588
|
size: 13
|
|
3589
3589
|
}),
|
|
3590
|
-
|
|
3590
|
+
ie ? "Resized copies are grouped with their original image." : "Resized copies are shown in their size folders.",
|
|
3591
3591
|
/* @__PURE__ */ z("button", {
|
|
3592
3592
|
type: "button",
|
|
3593
3593
|
className: "seed-fm-linkbtn",
|
|
3594
3594
|
onClick: () => {
|
|
3595
|
-
|
|
3595
|
+
k(!ie), N(/* @__PURE__ */ new Set());
|
|
3596
3596
|
},
|
|
3597
|
-
children:
|
|
3597
|
+
children: ie ? "Show as folders" : "Group with originals"
|
|
3598
3598
|
})
|
|
3599
3599
|
]
|
|
3600
3600
|
})
|
|
@@ -3602,7 +3602,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3602
3602
|
}),
|
|
3603
3603
|
/* @__PURE__ */ z("div", {
|
|
3604
3604
|
className: w("body", "seed-fm-body"),
|
|
3605
|
-
children:
|
|
3605
|
+
children: He
|
|
3606
3606
|
}),
|
|
3607
3607
|
Ge && /* @__PURE__ */ B("div", {
|
|
3608
3608
|
className: w("batchBar", "seed-fm-batch"),
|
|
@@ -3613,15 +3613,15 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3613
3613
|
className: "seed-fm-batch-count",
|
|
3614
3614
|
"aria-live": "polite",
|
|
3615
3615
|
children: [
|
|
3616
|
-
|
|
3616
|
+
M.size,
|
|
3617
3617
|
" selected ",
|
|
3618
|
-
/* @__PURE__ */ B("span", { children: ["· ", Q(
|
|
3618
|
+
/* @__PURE__ */ B("span", { children: ["· ", Q(Ve)] })
|
|
3619
3619
|
]
|
|
3620
3620
|
}),
|
|
3621
3621
|
/* @__PURE__ */ B("button", {
|
|
3622
3622
|
type: "button",
|
|
3623
3623
|
className: "seed-fm-btn",
|
|
3624
|
-
disabled:
|
|
3624
|
+
disabled: he,
|
|
3625
3625
|
onClick: () => ke(K),
|
|
3626
3626
|
children: [
|
|
3627
3627
|
/* @__PURE__ */ z($, {
|
|
@@ -3629,13 +3629,13 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3629
3629
|
size: 15
|
|
3630
3630
|
}),
|
|
3631
3631
|
" ",
|
|
3632
|
-
|
|
3632
|
+
M.size > 1 ? "Download .zip" : "Download"
|
|
3633
3633
|
]
|
|
3634
3634
|
}),
|
|
3635
3635
|
/* @__PURE__ */ B("button", {
|
|
3636
3636
|
type: "button",
|
|
3637
3637
|
className: `seed-fm-btn${Ge.destructive ? " seed-fm-btn--danger-text" : ""}`,
|
|
3638
|
-
disabled:
|
|
3638
|
+
disabled: he,
|
|
3639
3639
|
onClick: () => Ne(K),
|
|
3640
3640
|
children: [
|
|
3641
3641
|
/* @__PURE__ */ z($, {
|
|
@@ -3650,7 +3650,7 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3650
3650
|
type: "button",
|
|
3651
3651
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3652
3652
|
"aria-label": "Clear selection",
|
|
3653
|
-
onClick: () =>
|
|
3653
|
+
onClick: () => N(/* @__PURE__ */ new Set()),
|
|
3654
3654
|
children: /* @__PURE__ */ z($, {
|
|
3655
3655
|
name: "x",
|
|
3656
3656
|
size: 15
|
|
@@ -3660,47 +3660,47 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3660
3660
|
})
|
|
3661
3661
|
]
|
|
3662
3662
|
}),
|
|
3663
|
-
q && /* @__PURE__ */ z(
|
|
3663
|
+
q && /* @__PURE__ */ z(rr, {
|
|
3664
3664
|
entry: q,
|
|
3665
3665
|
className: h.panel,
|
|
3666
|
-
onClose:
|
|
3667
|
-
onPrevious:
|
|
3668
|
-
onNext:
|
|
3666
|
+
onClose: we,
|
|
3667
|
+
onPrevious: xe > 0 ? () => I(G[xe - 1].file.path) : null,
|
|
3668
|
+
onNext: xe >= 0 && xe < G.length - 1 ? () => I(G[xe + 1].file.path) : null,
|
|
3669
3669
|
onDownload: () => ke([q]),
|
|
3670
3670
|
onDelete: () => Ne([q]),
|
|
3671
3671
|
deleteAction: je([q]),
|
|
3672
3672
|
onCopyPath: () => Ie(q.file.path)
|
|
3673
3673
|
}, "panel"),
|
|
3674
|
-
|
|
3675
|
-
entries:
|
|
3674
|
+
L && /* @__PURE__ */ z(hn, {
|
|
3675
|
+
entries: L,
|
|
3676
3676
|
rootPath: S,
|
|
3677
|
-
warning: v(
|
|
3678
|
-
deleteActionFor: (e) => Ae(X(
|
|
3677
|
+
warning: v(Ue),
|
|
3678
|
+
deleteActionFor: (e) => Ae(X(L, e)),
|
|
3679
3679
|
className: h.dialog,
|
|
3680
|
-
onCancel: () =>
|
|
3680
|
+
onCancel: () => pe(null),
|
|
3681
3681
|
onConfirm: (e) => {
|
|
3682
|
-
let t = X(
|
|
3683
|
-
|
|
3682
|
+
let t = X(L, e);
|
|
3683
|
+
pe(null), Me(t);
|
|
3684
3684
|
}
|
|
3685
3685
|
}),
|
|
3686
|
-
|
|
3687
|
-
folder:
|
|
3688
|
-
files:
|
|
3689
|
-
hiddenCount: T.filter((e) => e.path.startsWith(`${
|
|
3690
|
-
warning: v(
|
|
3691
|
-
action: Ae(
|
|
3692
|
-
busy:
|
|
3686
|
+
V && /* @__PURE__ */ z(gn, {
|
|
3687
|
+
folder: V,
|
|
3688
|
+
files: We,
|
|
3689
|
+
hiddenCount: T.filter((e) => e.path.startsWith(`${V.path}/`)).length - We.length,
|
|
3690
|
+
warning: v(We),
|
|
3691
|
+
action: Ae(We),
|
|
3692
|
+
busy: he,
|
|
3693
3693
|
className: h.dialog,
|
|
3694
|
-
onDownload: () => Oe(
|
|
3695
|
-
onCancel: () =>
|
|
3694
|
+
onDownload: () => Oe(We, V),
|
|
3695
|
+
onCancel: () => me(null),
|
|
3696
3696
|
onConfirm: () => {
|
|
3697
|
-
|
|
3697
|
+
me(null), Me(We, V);
|
|
3698
3698
|
}
|
|
3699
3699
|
}),
|
|
3700
3700
|
!x && /* @__PURE__ */ z("ul", {
|
|
3701
3701
|
className: "seed-fm-toasts",
|
|
3702
3702
|
"aria-live": "polite",
|
|
3703
|
-
children:
|
|
3703
|
+
children: U.map((e) => /* @__PURE__ */ B("li", {
|
|
3704
3704
|
className: w("toast", `seed-fm-toast${e.tone === "error" ? " seed-fm-toast--error" : ""}`),
|
|
3705
3705
|
children: [/* @__PURE__ */ z($, {
|
|
3706
3706
|
name: e.tone === "error" ? "triangleAlert" : "check",
|
|
@@ -3714,95 +3714,111 @@ function Tr({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3714
3714
|
}
|
|
3715
3715
|
//#endregion
|
|
3716
3716
|
//#region src/useEnsureLocalImage.ts
|
|
3717
|
-
var
|
|
3717
|
+
var kr = (e) => {
|
|
3718
3718
|
try {
|
|
3719
3719
|
return e.getService?.()?.getSnapshot?.()?.context?.storageTransactionId || void 0;
|
|
3720
3720
|
} catch {
|
|
3721
3721
|
return;
|
|
3722
3722
|
}
|
|
3723
3723
|
};
|
|
3724
|
-
function
|
|
3725
|
-
let { imageProperty: t, filename:
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
]),
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
]),
|
|
3735
|
-
if (
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3724
|
+
function Ar(e) {
|
|
3725
|
+
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), [
|
|
3726
|
+
_,
|
|
3727
|
+
r,
|
|
3728
|
+
m,
|
|
3729
|
+
g
|
|
3730
|
+
]), y = o(() => (r ?? (typeof m == "string" ? m : void 0) ?? g)?.trim() || void 0, [
|
|
3731
|
+
r,
|
|
3732
|
+
m,
|
|
3733
|
+
g
|
|
3734
|
+
]), b = o(() => {
|
|
3735
|
+
if (!v) return [];
|
|
3736
|
+
let e = [];
|
|
3737
|
+
try {
|
|
3738
|
+
for (let t of D()) {
|
|
3739
|
+
let n = `${t.replace(/\/$/, "")}/raw/${v}`;
|
|
3740
|
+
e.includes(n) || e.push(n);
|
|
3741
|
+
}
|
|
3742
|
+
} catch {}
|
|
3743
|
+
try {
|
|
3744
|
+
let t = u.getRawUrl(v);
|
|
3745
|
+
t && !e.includes(t) && e.push(t);
|
|
3746
|
+
} catch {}
|
|
3747
|
+
return e;
|
|
3748
|
+
}, [v]), [x, S] = c(0);
|
|
3749
|
+
i(() => {
|
|
3750
|
+
S(0);
|
|
3751
|
+
}, [b]);
|
|
3752
|
+
let C = b[x], w = n(() => {
|
|
3753
|
+
S((e) => e < b.length ? e + 1 : e);
|
|
3754
|
+
}, [b]);
|
|
3741
3755
|
return i(() => {
|
|
3742
3756
|
let e = !1;
|
|
3743
3757
|
return (async () => {
|
|
3744
|
-
if (!
|
|
3745
|
-
else if (!
|
|
3758
|
+
if (!s) e || (d(null), p("idle"));
|
|
3759
|
+
else if (!v && !y) e || (d(null), p("idle"));
|
|
3746
3760
|
else {
|
|
3747
|
-
e ||
|
|
3761
|
+
e || p("loading");
|
|
3748
3762
|
try {
|
|
3749
3763
|
let t = await T({
|
|
3750
|
-
transactionId:
|
|
3751
|
-
fileName:
|
|
3752
|
-
widths:
|
|
3764
|
+
transactionId: v,
|
|
3765
|
+
fileName: y,
|
|
3766
|
+
widths: a == null ? void 0 : [a]
|
|
3753
3767
|
});
|
|
3754
3768
|
if (e) return;
|
|
3755
|
-
|
|
3769
|
+
d(t), p(t.status);
|
|
3756
3770
|
} catch {
|
|
3757
3771
|
if (e) return;
|
|
3758
|
-
|
|
3772
|
+
d({ status: "failed" }), p("failed");
|
|
3759
3773
|
}
|
|
3760
3774
|
}
|
|
3761
3775
|
})(), () => {
|
|
3762
3776
|
e = !0;
|
|
3763
3777
|
};
|
|
3764
3778
|
}, [
|
|
3765
|
-
|
|
3766
|
-
_,
|
|
3779
|
+
s,
|
|
3767
3780
|
v,
|
|
3768
|
-
|
|
3781
|
+
y,
|
|
3782
|
+
a
|
|
3769
3783
|
]), {
|
|
3770
|
-
status:
|
|
3771
|
-
gatewayHref:
|
|
3772
|
-
|
|
3784
|
+
status: f,
|
|
3785
|
+
gatewayHref: C,
|
|
3786
|
+
gatewayHrefs: b,
|
|
3787
|
+
onGatewayError: w,
|
|
3788
|
+
result: l
|
|
3773
3789
|
};
|
|
3774
3790
|
}
|
|
3775
3791
|
//#endregion
|
|
3776
3792
|
//#region src/SeedImage.tsx
|
|
3777
|
-
var
|
|
3793
|
+
var jr = L("seedSdk:react:SeedImage"), Mr = /* @__PURE__ */ new Map(), Nr = (e) => {
|
|
3778
3794
|
let t = e.match(/^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/);
|
|
3779
3795
|
return t && t[2] ? t[2] : e;
|
|
3780
3796
|
};
|
|
3781
|
-
function
|
|
3797
|
+
function Pr(e) {
|
|
3782
3798
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3783
3799
|
}
|
|
3784
|
-
function
|
|
3785
|
-
let n = RegExp(`^${
|
|
3800
|
+
function Fr(e, t) {
|
|
3801
|
+
let n = RegExp(`^${Pr(t)}$`), r = Nr(e);
|
|
3786
3802
|
return n.test(r);
|
|
3787
3803
|
}
|
|
3788
|
-
var
|
|
3789
|
-
let [s, l] = c(), [u, d] = c(), { property: p } =
|
|
3804
|
+
var Ir = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o }) => {
|
|
3805
|
+
let [s, l] = c(), [u, d] = c(), { property: p } = Ve({
|
|
3790
3806
|
propertyName: t.propertyName,
|
|
3791
3807
|
seedLocalId: t.seedLocalId,
|
|
3792
3808
|
seedUid: t.seedUid
|
|
3793
|
-
}), m = t ?? p, h = r ?? m?.refResolvedValue ?? m?.value, { status: g, gatewayHref: _ } =
|
|
3809
|
+
}), m = t ?? p, h = r ?? m?.refResolvedValue ?? m?.value, { status: g, gatewayHref: _, onGatewayError: v } = Ar({
|
|
3794
3810
|
imageProperty: m ?? t,
|
|
3795
3811
|
filename: r,
|
|
3796
3812
|
width: n,
|
|
3797
3813
|
enabled: a
|
|
3798
|
-
}),
|
|
3814
|
+
}), 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
3815
|
i(() => {
|
|
3800
|
-
if (
|
|
3801
|
-
|
|
3816
|
+
if (x && (y instanceof File || y instanceof Blob)) return w.current || (w.current = URL.createObjectURL(y), C(w.current)), () => {
|
|
3817
|
+
w.current && (URL.revokeObjectURL(w.current), w.current = null), C(null);
|
|
3802
3818
|
};
|
|
3803
|
-
|
|
3804
|
-
}, [
|
|
3805
|
-
if (!h ||
|
|
3819
|
+
w.current = null, C(null);
|
|
3820
|
+
}, [x, y]), i(() => {
|
|
3821
|
+
if (!h || y && ((e) => typeof e == "string" && e.startsWith("blob:"))(y) || S) return;
|
|
3806
3822
|
let e = !1;
|
|
3807
3823
|
return (async () => {
|
|
3808
3824
|
try {
|
|
@@ -3812,15 +3828,15 @@ var Nr = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o
|
|
|
3812
3828
|
!e && n && d(n);
|
|
3813
3829
|
}
|
|
3814
3830
|
} catch (e) {
|
|
3815
|
-
|
|
3831
|
+
jr("_getOriginalContentUrl error", e);
|
|
3816
3832
|
}
|
|
3817
3833
|
})(), () => {
|
|
3818
3834
|
e = !0;
|
|
3819
3835
|
};
|
|
3820
3836
|
}, [
|
|
3821
3837
|
h,
|
|
3822
|
-
|
|
3823
|
-
|
|
3838
|
+
y,
|
|
3839
|
+
S,
|
|
3824
3840
|
m?.localStoragePath,
|
|
3825
3841
|
g
|
|
3826
3842
|
]), i(() => {
|
|
@@ -3828,46 +3844,49 @@ var Nr = e.memo(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o
|
|
|
3828
3844
|
try {
|
|
3829
3845
|
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
3846
|
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 =
|
|
3847
|
+
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a = Nr(h), o = `${a}-${i}`;
|
|
3848
|
+
if (Mr.has(o)) try {
|
|
3849
|
+
let e = Mr.get(o);
|
|
3834
3850
|
if (e && (await fetch(e)).ok) {
|
|
3835
3851
|
l(e);
|
|
3836
3852
|
return;
|
|
3837
3853
|
}
|
|
3838
3854
|
} catch (e) {
|
|
3839
|
-
|
|
3855
|
+
jr("error", e), Mr.delete(o);
|
|
3840
3856
|
}
|
|
3841
|
-
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ?
|
|
3857
|
+
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ? Fr(e.name, a) : !1);
|
|
3842
3858
|
if (!s) return;
|
|
3843
3859
|
let c = `${t}/${i}/${s?.name}`;
|
|
3844
3860
|
if (await f.pathExists(c)) {
|
|
3845
3861
|
let e = await f.getContentUrlFromPath(c);
|
|
3846
|
-
e && (
|
|
3862
|
+
e && (Mr.set(o, e), l(e));
|
|
3847
3863
|
}
|
|
3848
3864
|
} catch (e) {
|
|
3849
|
-
|
|
3865
|
+
jr("_getSizedContentUrl error", e);
|
|
3850
3866
|
}
|
|
3851
3867
|
})();
|
|
3852
3868
|
}, [
|
|
3853
3869
|
m,
|
|
3854
3870
|
n,
|
|
3855
|
-
|
|
3871
|
+
b,
|
|
3856
3872
|
h,
|
|
3857
3873
|
g
|
|
3858
3874
|
]);
|
|
3859
|
-
let
|
|
3860
|
-
if (!
|
|
3861
|
-
let
|
|
3875
|
+
let T = (e) => typeof e == "string" && e.startsWith("blob:"), E = !!s || !!u || !!S || !!b && T(b);
|
|
3876
|
+
if (!E && !h && !_) return null;
|
|
3877
|
+
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) => {
|
|
3878
|
+
_ && ee === _ && v(), D?.(e);
|
|
3879
|
+
};
|
|
3862
3880
|
return /* @__PURE__ */ z("img", {
|
|
3863
|
-
src:
|
|
3881
|
+
src: ee,
|
|
3864
3882
|
alt: o.alt || t.propertyName || "Image",
|
|
3865
|
-
...
|
|
3883
|
+
...te,
|
|
3884
|
+
onError: ne
|
|
3866
3885
|
});
|
|
3867
3886
|
}, (e, t) => e.imageProperty === t.imageProperty && e.width === t.width && e.height === t.height && e.filename === t.filename && e.ensure === t.ensure);
|
|
3868
3887
|
//#endregion
|
|
3869
3888
|
//#region src/useResolvedMediaRef.ts
|
|
3870
|
-
function
|
|
3889
|
+
function Lr(e) {
|
|
3871
3890
|
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
3891
|
i(() => {
|
|
3873
3892
|
let e = !1;
|
|
@@ -3876,7 +3895,7 @@ function Pr(e) {
|
|
|
3876
3895
|
else {
|
|
3877
3896
|
e || (m("loading"), f(null));
|
|
3878
3897
|
try {
|
|
3879
|
-
let n = await
|
|
3898
|
+
let n = await M(String(t), { treatAs: a });
|
|
3880
3899
|
if (e) return;
|
|
3881
3900
|
u(n), n.status === "empty" ? m("empty") : n.status === "ready" ? m("ready") : m("unresolved");
|
|
3882
3901
|
} catch (t) {
|
|
@@ -3907,8 +3926,8 @@ function Pr(e) {
|
|
|
3907
3926
|
}
|
|
3908
3927
|
//#endregion
|
|
3909
3928
|
//#region src/SeedMediaImage.tsx
|
|
3910
|
-
function
|
|
3911
|
-
let { href: o } =
|
|
3929
|
+
function Rr({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
3930
|
+
let { href: o } = Lr({
|
|
3912
3931
|
value: e,
|
|
3913
3932
|
enabled: t,
|
|
3914
3933
|
treatAs: n
|
|
@@ -3923,14 +3942,14 @@ function Fr({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
|
3923
3942
|
}
|
|
3924
3943
|
//#endregion
|
|
3925
3944
|
//#region src/SeedMediaFile.tsx
|
|
3926
|
-
function
|
|
3945
|
+
function zr(e) {
|
|
3927
3946
|
try {
|
|
3928
3947
|
return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
|
|
3929
3948
|
} catch {
|
|
3930
3949
|
return "Open";
|
|
3931
3950
|
}
|
|
3932
3951
|
}
|
|
3933
|
-
function
|
|
3952
|
+
function Br(e) {
|
|
3934
3953
|
try {
|
|
3935
3954
|
let t = new URL(e).protocol;
|
|
3936
3955
|
return t === "http:" || t === "https:";
|
|
@@ -3938,27 +3957,27 @@ function Lr(e) {
|
|
|
3938
3957
|
return !1;
|
|
3939
3958
|
}
|
|
3940
3959
|
}
|
|
3941
|
-
function
|
|
3942
|
-
let { href: l } =
|
|
3960
|
+
function Vr({ value: e, enabled: t, treatAs: n, download: r, render: i, children: a, target: o, rel: s, ...c }) {
|
|
3961
|
+
let { href: l } = Lr({
|
|
3943
3962
|
value: e,
|
|
3944
3963
|
enabled: t,
|
|
3945
3964
|
treatAs: n
|
|
3946
3965
|
});
|
|
3947
3966
|
if (!l) return null;
|
|
3948
|
-
let u =
|
|
3967
|
+
let u = Br(l), d = o === void 0 ? u ? "_blank" : void 0 : o, f = {
|
|
3949
3968
|
...c,
|
|
3950
3969
|
href: l,
|
|
3951
3970
|
download: r,
|
|
3952
3971
|
target: d,
|
|
3953
3972
|
rel: s ?? (u && d === "_blank" ? "noopener noreferrer" : void 0),
|
|
3954
|
-
children: a ??
|
|
3973
|
+
children: a ?? zr(l)
|
|
3955
3974
|
};
|
|
3956
3975
|
return i ? /* @__PURE__ */ z(R, { children: i(f) }) : /* @__PURE__ */ z("a", { ...f });
|
|
3957
3976
|
}
|
|
3958
3977
|
//#endregion
|
|
3959
3978
|
//#region src/SeedMediaAudio.tsx
|
|
3960
|
-
function
|
|
3961
|
-
let { href: o } =
|
|
3979
|
+
function Hr({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
3980
|
+
let { href: o } = Lr({
|
|
3962
3981
|
value: e,
|
|
3963
3982
|
enabled: t,
|
|
3964
3983
|
treatAs: n
|
|
@@ -3973,8 +3992,8 @@ function zr({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
3973
3992
|
}
|
|
3974
3993
|
//#endregion
|
|
3975
3994
|
//#region src/SeedMediaVideo.tsx
|
|
3976
|
-
function
|
|
3977
|
-
let { href: o } =
|
|
3995
|
+
function Ur({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
3996
|
+
let { href: o } = Lr({
|
|
3978
3997
|
value: e,
|
|
3979
3998
|
enabled: t,
|
|
3980
3999
|
treatAs: n
|
|
@@ -3989,11 +4008,11 @@ function Br({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
3989
4008
|
}
|
|
3990
4009
|
//#endregion
|
|
3991
4010
|
//#region src/SeedHtml.tsx
|
|
3992
|
-
function
|
|
4011
|
+
function Wr(e) {
|
|
3993
4012
|
return typeof e == "string" && e.trim().length > 0;
|
|
3994
4013
|
}
|
|
3995
|
-
function
|
|
3996
|
-
if (!
|
|
4014
|
+
function Gr({ html: e, sanitize: t, render: n, ...r }) {
|
|
4015
|
+
if (!Wr(e)) return null;
|
|
3997
4016
|
let i = t(e);
|
|
3998
4017
|
return n ? /* @__PURE__ */ z(R, { children: n({ html: i }) }) : /* @__PURE__ */ z("div", {
|
|
3999
4018
|
...r,
|
|
@@ -4002,41 +4021,41 @@ function Hr({ html: e, sanitize: t, render: n, ...r }) {
|
|
|
4002
4021
|
}
|
|
4003
4022
|
//#endregion
|
|
4004
4023
|
//#region src/formatSeedJson.ts
|
|
4005
|
-
function
|
|
4024
|
+
function Kr(e, t) {
|
|
4006
4025
|
return e.length <= t ? e : `${e.slice(0, t)}…`;
|
|
4007
4026
|
}
|
|
4008
|
-
function
|
|
4027
|
+
function qr(e) {
|
|
4009
4028
|
let t = e.trim();
|
|
4010
4029
|
return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
|
|
4011
4030
|
}
|
|
4012
|
-
function
|
|
4031
|
+
function Jr(e, t, n, r, i) {
|
|
4013
4032
|
if (typeof e == "bigint") return String(e);
|
|
4014
4033
|
if (typeof e == "symbol") return e.toString();
|
|
4015
4034
|
if (typeof e == "function") return "[Function]";
|
|
4016
4035
|
if (e instanceof Date) return e.toISOString();
|
|
4017
|
-
if (typeof e == "string") return
|
|
4036
|
+
if (typeof e == "string") return Kr(e, n);
|
|
4018
4037
|
if (typeof e != "object" || !e) return e;
|
|
4019
4038
|
if (i.has(e)) return "[Circular]";
|
|
4020
4039
|
if (r >= t) return "[Max depth]";
|
|
4021
|
-
if (i.add(e), Array.isArray(e)) return e.map((e) =>
|
|
4040
|
+
if (i.add(e), Array.isArray(e)) return e.map((e) => Jr(e, t, n, r + 1, i));
|
|
4022
4041
|
let a = {};
|
|
4023
|
-
for (let [o, s] of Object.entries(e)) a[o] =
|
|
4042
|
+
for (let [o, s] of Object.entries(e)) a[o] = Jr(s, t, n, r + 1, i);
|
|
4024
4043
|
return a;
|
|
4025
4044
|
}
|
|
4026
|
-
function
|
|
4045
|
+
function Yr(e, t) {
|
|
4027
4046
|
let n = t?.maxDepth ?? 6, r = t?.maxStringLength ?? 5e4, i = t?.space ?? 2;
|
|
4028
4047
|
if (e === void 0) return "undefined";
|
|
4029
4048
|
if (e === null) return "null";
|
|
4030
4049
|
let a = e;
|
|
4031
4050
|
if (typeof e == "string") {
|
|
4032
|
-
if (
|
|
4051
|
+
if (qr(e)) try {
|
|
4033
4052
|
a = JSON.parse(e);
|
|
4034
4053
|
} catch {
|
|
4035
|
-
return
|
|
4054
|
+
return Kr(e, r);
|
|
4036
4055
|
}
|
|
4037
|
-
else return
|
|
4056
|
+
else return Kr(e, r);
|
|
4038
4057
|
}
|
|
4039
|
-
let o =
|
|
4058
|
+
let o = Jr(a, n, r, 0, /* @__PURE__ */ new WeakSet());
|
|
4040
4059
|
try {
|
|
4041
4060
|
return JSON.stringify(o, null, i);
|
|
4042
4061
|
} catch {
|
|
@@ -4045,8 +4064,8 @@ function Kr(e, t) {
|
|
|
4045
4064
|
}
|
|
4046
4065
|
//#endregion
|
|
4047
4066
|
//#region src/SeedJson.tsx
|
|
4048
|
-
function
|
|
4049
|
-
let a = t ? t(e) :
|
|
4067
|
+
function Xr({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
4068
|
+
let a = t ? t(e) : Yr(e, n);
|
|
4050
4069
|
return r ? /* @__PURE__ */ z(R, { children: r({ text: a }) }) : /* @__PURE__ */ z("pre", {
|
|
4051
4070
|
...i,
|
|
4052
4071
|
children: a
|
|
@@ -4054,10 +4073,10 @@ function qr({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
|
4054
4073
|
}
|
|
4055
4074
|
//#endregion
|
|
4056
4075
|
//#region src/useNormalizedFeedItemFields.ts
|
|
4057
|
-
function
|
|
4076
|
+
function Zr(e, t) {
|
|
4058
4077
|
return o(() => e ? oe(e, t) : {}, [e, t]);
|
|
4059
4078
|
}
|
|
4060
4079
|
//#endregion
|
|
4061
|
-
export {
|
|
4080
|
+
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
4081
|
|
|
4063
4082
|
//# sourceMappingURL=index.js.map
|