@seedprotocol/react 0.8.1-next.1726.g8c778c5 → 0.8.2-next.1774.gc97b5ba
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SeedClientGate.d.ts +2 -2
- package/dist/SeedProvider.d.ts +2 -1
- package/dist/SeedProvider.d.ts.map +1 -1
- package/dist/index.js +704 -690
- package/dist/index.js.map +1 -1
- package/dist/useAddressesProp.d.ts +7 -4
- package/dist/useAddressesProp.d.ts.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import e, { createContext as t, useCallback as n, useContext as r, useEffect as i, useInsertionEffect as a, useMemo as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
3
3
|
import { flushSync as u } from "react-dom";
|
|
4
|
-
import { BaseArweaveClient as d, BaseDb as f, BaseFileManager as p, ClientManagerState as m, ClientNotInitializedError as h, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as g, FILES_CHANGED_EVENT as _, Item as v, ItemProperty as y, ItemPropertySaveValidationError as b, MachineIds as x, Model as S, ModelProperty as C, SEED_PROTOCOL_SCHEMA_NAME as w, Schema as T, client as E, easName as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import
|
|
4
|
+
import { BaseArweaveClient as d, BaseDb as f, BaseFileManager as p, ClientManagerState as m, ClientNotInitializedError as h, EAS_SEED_DATA_SYNCED_TO_DB_EVENT as g, FILES_CHANGED_EVENT as _, Item as v, ItemProperty as y, ItemPropertySaveValidationError as b, MachineIds as x, Model as S, ModelProperty as C, SEED_PROTOCOL_SCHEMA_NAME as w, Schema as T, client as E, easName as ee, easSyncProcesses as D, ensureImageLocal as te, entityLoadError as ne, eventEmitter as O, getAddressesForItemsFilter as re, getArweaveReadBaseUrls as k, getClient as A, getPropertySchema as j, getVersionData as ie, isChangeFeedRunning as ae, isClientReadySnapshot as M, isValidEasAttestationUid as oe, loadAllSchemasFromDb as se, mapUrlAttribute as ce, metadata as N, modelSchemas as le, models as P, nextArweaveGatewayUrl as F, normalizeAddressConfig as ue, normalizeArweaveTxIdForEnsure as I, normalizeFeedItemFields as de, ownedSeedsSql as fe, pickLatestMetadataRowPerProperty as pe, placeholderUidSql as me, properties as L, publisherInAddressListSql as he, rehostArweaveLinksInHtml as ge, resolveMediaRef as _e, schemas as R, seeds as z, watchEntityRows as ve } from "@seedprotocol/sdk";
|
|
5
|
+
import { debounce as ye, orderBy as B, startCase as be } from "lodash-es";
|
|
6
|
+
import V from "debug";
|
|
7
7
|
import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
|
|
8
|
-
import { QueryClient as
|
|
9
|
-
import { and as
|
|
10
|
-
import
|
|
8
|
+
import { QueryClient as xe, QueryClientContext as Se, QueryClientProvider as G, useQuery as K, useQueryClient as Ce } from "@tanstack/react-query";
|
|
9
|
+
import { and as we, desc as Te, eq as q, gt as Ee, isNotNull as De, isNull as Oe, or as ke } from "drizzle-orm";
|
|
10
|
+
import Ae from "pluralize";
|
|
11
11
|
//#region src/client.ts
|
|
12
|
-
var
|
|
12
|
+
var je = (e) => A().subscribeService(e), Me = () => A().getService(), Ne = () => l(je, Me, Me);
|
|
13
13
|
function J(e) {
|
|
14
|
-
let t =
|
|
14
|
+
let t = Ne(), r = s(e);
|
|
15
15
|
r.current = e;
|
|
16
16
|
let i = n((e) => {
|
|
17
17
|
let n = t.subscribe({
|
|
18
18
|
next: e,
|
|
19
19
|
error: e,
|
|
20
20
|
complete: e
|
|
21
|
-
}), r =
|
|
21
|
+
}), r = A().subscribeService(e);
|
|
22
22
|
return () => {
|
|
23
23
|
n.unsubscribe(), r();
|
|
24
24
|
};
|
|
25
25
|
}, [t]), a = () => r.current(t.getSnapshot());
|
|
26
26
|
return l(i, a, a);
|
|
27
27
|
}
|
|
28
|
-
var Y = () => J(
|
|
28
|
+
var Y = () => J(M);
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/useHeldEntities.ts
|
|
31
31
|
function X(e, t, n) {
|
|
@@ -49,11 +49,11 @@ function X(e, t, n) {
|
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/addressesPersistedEventName.ts
|
|
52
|
-
var
|
|
53
|
-
function
|
|
54
|
-
return r(
|
|
52
|
+
var Pe = "addresses.persisted", Fe = "localCopies.removed", Ie = t(0);
|
|
53
|
+
function Le() {
|
|
54
|
+
return r(Ie);
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function Re({ queryClient: e, children: t }) {
|
|
57
57
|
let [r, a] = c(0), o = n(() => {
|
|
58
58
|
e.invalidateQueries({
|
|
59
59
|
queryKey: ["seed", "items"],
|
|
@@ -66,9 +66,9 @@ function Le({ queryClient: e, children: t }) {
|
|
|
66
66
|
exact: !1
|
|
67
67
|
}), a((e) => e + 1);
|
|
68
68
|
}, [e]);
|
|
69
|
-
return i(() => (
|
|
70
|
-
|
|
71
|
-
}), [o]), /* @__PURE__ */ U(
|
|
69
|
+
return i(() => (O.on(Pe, o), O.on(Fe, o), () => {
|
|
70
|
+
O.off(Pe, o), O.off(Fe, o);
|
|
71
|
+
}), [o]), /* @__PURE__ */ U(Ie.Provider, {
|
|
72
72
|
value: r,
|
|
73
73
|
children: t
|
|
74
74
|
});
|
|
@@ -76,9 +76,9 @@ function Le({ queryClient: e, children: t }) {
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/liveQuery.ts
|
|
78
78
|
function Z(e) {
|
|
79
|
-
return
|
|
79
|
+
return He(e).data;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function ze(e) {
|
|
82
82
|
if (e && typeof e == "object" && typeof e.toSQL == "function") try {
|
|
83
83
|
let { sql: t, params: n } = e.toSQL();
|
|
84
84
|
return `sql:${t}|${JSON.stringify(n)}`;
|
|
@@ -87,19 +87,19 @@ function Re(e) {
|
|
|
87
87
|
}
|
|
88
88
|
return e;
|
|
89
89
|
}
|
|
90
|
-
var
|
|
90
|
+
var Be = [
|
|
91
91
|
500,
|
|
92
92
|
1e3,
|
|
93
93
|
2e3,
|
|
94
94
|
5e3,
|
|
95
95
|
1e4,
|
|
96
96
|
3e4
|
|
97
|
-
],
|
|
98
|
-
function
|
|
97
|
+
], Ve = (e) => e instanceof Error ? e : Error(String(e));
|
|
98
|
+
function He(e) {
|
|
99
99
|
let [t, n] = c({
|
|
100
100
|
data: void 0,
|
|
101
101
|
error: null
|
|
102
|
-
}), [r, a] = c(0), o = Y(), l =
|
|
102
|
+
}), [r, a] = c(0), o = Y(), l = ze(e), u = s(e);
|
|
103
103
|
u.current = e;
|
|
104
104
|
let d = s(0), p = s(null);
|
|
105
105
|
return i(() => {
|
|
@@ -116,9 +116,9 @@ function Ve(e) {
|
|
|
116
116
|
let r, i = (e) => {
|
|
117
117
|
n((t) => ({
|
|
118
118
|
data: t.data,
|
|
119
|
-
error:
|
|
119
|
+
error: Ve(e)
|
|
120
120
|
}));
|
|
121
|
-
let t =
|
|
121
|
+
let t = Be[Math.min(d.current, Be.length - 1)];
|
|
122
122
|
d.current += 1, r = setTimeout(() => a((e) => e + 1), t);
|
|
123
123
|
}, s;
|
|
124
124
|
try {
|
|
@@ -145,16 +145,16 @@ function Ve(e) {
|
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region src/queryClient.ts
|
|
148
|
-
var
|
|
148
|
+
var Ue = { queries: {
|
|
149
149
|
networkMode: "offlineFirst",
|
|
150
150
|
gcTime: 864e5,
|
|
151
151
|
staleTime: 6e4
|
|
152
152
|
} };
|
|
153
|
-
function
|
|
154
|
-
return { ...
|
|
153
|
+
function We() {
|
|
154
|
+
return { ...Ue };
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
let t =
|
|
156
|
+
function Ge(e) {
|
|
157
|
+
let t = We();
|
|
158
158
|
return e ? {
|
|
159
159
|
queries: {
|
|
160
160
|
...t.queries,
|
|
@@ -166,33 +166,33 @@ function We(e) {
|
|
|
166
166
|
}
|
|
167
167
|
} : t;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
let t =
|
|
171
|
-
return new
|
|
169
|
+
function Ke(e) {
|
|
170
|
+
let t = We(), { defaultOptions: n, ...r } = e ?? {};
|
|
171
|
+
return new xe({
|
|
172
172
|
...r,
|
|
173
|
-
defaultOptions: n ?
|
|
173
|
+
defaultOptions: n ? Ge(n) : t
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
var
|
|
176
|
+
var qe, Je = !1, Ye = () => {
|
|
177
177
|
try {
|
|
178
178
|
return process.env.NODE_ENV !== "production";
|
|
179
179
|
} catch {
|
|
180
180
|
return !1;
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
184
|
-
return r(
|
|
183
|
+
function Xe() {
|
|
184
|
+
return r(Se) || (!Je && Ye() && (Je = !0, console.warn("[@seedprotocol/react] A Seed hook ran outside SeedProvider (no QueryClientProvider found), so it uses a shared fallback QueryClient. Wrap the app in <SeedProvider>: from 0.8 these hooks will throw without it.")), qe ?? (qe = Ke()), qe);
|
|
185
185
|
}
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/item.ts
|
|
188
|
-
var
|
|
188
|
+
var Ze = V("seedSdk:react:item"), Qe = (e) => [
|
|
189
189
|
"seed",
|
|
190
190
|
"item",
|
|
191
191
|
e ?? null
|
|
192
|
-
],
|
|
193
|
-
let a = t || r, [, l] = c(0), [, u] = c(0), [, d] = c(0), [f, p] = c(!1), [m, h] = c(null), _ = s(!1), y = Y(), b =
|
|
192
|
+
], $e = ({ modelName: e, seedLocalId: t, seedUid: r }) => {
|
|
193
|
+
let a = t || r, [, l] = c(0), [, u] = c(0), [, d] = c(0), [f, p] = c(!1), [m, h] = c(null), _ = s(!1), y = Y(), b = Xe(), x = o(() => Qe(a), [a]), S = s(x);
|
|
194
194
|
S.current = x;
|
|
195
|
-
let C =
|
|
195
|
+
let C = K({
|
|
196
196
|
queryKey: x,
|
|
197
197
|
queryFn: async () => {
|
|
198
198
|
let n = v.peekReady(a) ?? await v.find({
|
|
@@ -202,7 +202,7 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
202
202
|
hold: !1
|
|
203
203
|
});
|
|
204
204
|
if (n) return n;
|
|
205
|
-
|
|
205
|
+
Ze("[useItem] no item found", e, a);
|
|
206
206
|
let i = b.getQueryData(x);
|
|
207
207
|
return i && i.getService().getSnapshot().status === "active" ? i : null;
|
|
208
208
|
},
|
|
@@ -215,21 +215,21 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
215
215
|
}, b), w = C.data ?? void 0, T = n(() => {
|
|
216
216
|
b.invalidateQueries({ queryKey: S.current });
|
|
217
217
|
}, [b]);
|
|
218
|
-
return X(o(() => w ? [w] : [], [w]),
|
|
218
|
+
return X(o(() => w ? [w] : [], [w]), nt, T), i(() => {
|
|
219
219
|
let e = () => {
|
|
220
220
|
l((e) => e + 1), b.invalidateQueries({ queryKey: S.current });
|
|
221
221
|
};
|
|
222
|
-
return
|
|
223
|
-
|
|
222
|
+
return O.on(g, e), () => {
|
|
223
|
+
O.off(g, e);
|
|
224
224
|
};
|
|
225
225
|
}, [b]), i(() => {
|
|
226
226
|
if (_.current = !1, p(!1), h(null), !w) return;
|
|
227
|
-
let e = w.getService(), t =
|
|
227
|
+
let e = w.getService(), t = tt(e.getSnapshot()?.context), n = e.subscribe({
|
|
228
228
|
complete: T,
|
|
229
229
|
next: (e) => {
|
|
230
230
|
if (!e || typeof e != "object" || !("value" in e)) return;
|
|
231
|
-
let n =
|
|
232
|
-
|
|
231
|
+
let n = tt(e.context);
|
|
232
|
+
et.some((e, r) => !Object.is(n[r], t[r])) && (t = n, d((e) => e + 1)), w.status === "error" ? (h(/* @__PURE__ */ Error("Item service error")), p(!1)) : w.status === "ready" && e.value === "idle" ? (_.current = !0, p(!1), h(null)) : _.current && p(!0);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
return () => n.unsubscribe();
|
|
@@ -260,7 +260,7 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
260
260
|
isLoading: !!a && C.isPending || f,
|
|
261
261
|
error: m ?? C.error
|
|
262
262
|
};
|
|
263
|
-
},
|
|
263
|
+
}, et = [
|
|
264
264
|
"seedUid",
|
|
265
265
|
"latestVersionUid",
|
|
266
266
|
"latestVersionLocalId",
|
|
@@ -268,18 +268,18 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
268
268
|
"attestationCreatedAt",
|
|
269
269
|
"revokedAt",
|
|
270
270
|
"publisher"
|
|
271
|
-
],
|
|
271
|
+
], tt = (e) => et.map((t) => e?.[t]), nt = (e) => v.retain(e), rt = [], it = (e) => {
|
|
272
272
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
273
273
|
for (let r of e ?? []) {
|
|
274
274
|
if (!r.localId) continue;
|
|
275
|
-
let e =
|
|
275
|
+
let e = oe(r.uid) ? r.uid.toLowerCase() : "", i = r.lastVersionPublishedAt || r.attestationCreatedAt || r.createdAt;
|
|
276
276
|
i && t.set(r.localId, i), n.push(`${r.localId}:${e}:${i ?? ""}`);
|
|
277
277
|
}
|
|
278
278
|
return {
|
|
279
279
|
signature: n.sort().join(","),
|
|
280
280
|
sortTimes: t
|
|
281
281
|
};
|
|
282
|
-
},
|
|
282
|
+
}, at = (e, t, n, r, i, a, o) => [
|
|
283
283
|
"seed",
|
|
284
284
|
"items",
|
|
285
285
|
e ?? null,
|
|
@@ -291,14 +291,14 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
291
291
|
modelFileId: a ?? null,
|
|
292
292
|
schemaName: o ?? null
|
|
293
293
|
}] : []
|
|
294
|
-
],
|
|
295
|
-
let d = Y(), p =
|
|
294
|
+
], ot = ({ modelName: e, modelFileId: t, schemaName: r, deleted: a = !1, includeEas: l = !1, addressFilter: u }) => {
|
|
295
|
+
let d = Y(), p = Le(), m = Ce();
|
|
296
296
|
i(() => {
|
|
297
297
|
let e = () => {
|
|
298
298
|
m.invalidateQueries({ queryKey: ["seed", "items"] });
|
|
299
299
|
};
|
|
300
|
-
return
|
|
301
|
-
|
|
300
|
+
return O.on(g, e), () => {
|
|
301
|
+
O.off(g, e);
|
|
302
302
|
};
|
|
303
303
|
}, [m]);
|
|
304
304
|
let h = s([]), _ = s(/* @__PURE__ */ new Set()), y = s(0), b = s(0), [x, S] = c(null);
|
|
@@ -308,13 +308,13 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
let e = !1;
|
|
311
|
-
return
|
|
311
|
+
return re(u).then((t) => {
|
|
312
312
|
e || S(t);
|
|
313
313
|
}), () => {
|
|
314
314
|
e = !0;
|
|
315
315
|
};
|
|
316
316
|
}, [u, p]);
|
|
317
|
-
let C = o(() =>
|
|
317
|
+
let C = o(() => at(e, a, l, u, p, t, r), [
|
|
318
318
|
e,
|
|
319
319
|
a,
|
|
320
320
|
l,
|
|
@@ -326,7 +326,7 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
326
326
|
i(() => {
|
|
327
327
|
_.current = /* @__PURE__ */ new Set();
|
|
328
328
|
}, [C]);
|
|
329
|
-
let { data: w =
|
|
329
|
+
let { data: w = rt, isLoading: T, isFetching: E, dataUpdatedAt: D, error: te } = K({
|
|
330
330
|
queryKey: C,
|
|
331
331
|
queryFn: async ({ signal: n }) => (y.current++, await v.all(e, a, {
|
|
332
332
|
hold: !1,
|
|
@@ -342,40 +342,40 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
342
342
|
gcTime: 0
|
|
343
343
|
});
|
|
344
344
|
h.current = w;
|
|
345
|
-
let
|
|
346
|
-
|
|
347
|
-
m.invalidateQueries({ queryKey:
|
|
345
|
+
let ne = s(C);
|
|
346
|
+
ne.current = C, X(w, nt, n(() => {
|
|
347
|
+
m.invalidateQueries({ queryKey: ne.current });
|
|
348
348
|
}, [m]));
|
|
349
|
-
let
|
|
350
|
-
if (!
|
|
349
|
+
let k = d ? f.getAppDb() : null, A = Z(o(() => {
|
|
350
|
+
if (!k || (u === "owned" || u === "watched") && x === null) return null;
|
|
351
351
|
let t = [];
|
|
352
|
-
l || t.push(
|
|
353
|
-
let n =
|
|
354
|
-
return
|
|
355
|
-
localId:
|
|
356
|
-
uid:
|
|
357
|
-
type:
|
|
358
|
-
schemaUid:
|
|
359
|
-
createdAt:
|
|
360
|
-
attestationCreatedAt:
|
|
352
|
+
l || t.push(me(z.uid)), e && t.push(q(z.type, ee(e))), u === "owned" ? t.push(fe(x ?? [])) : u === "watched" && t.push(he(z.publisher, x ?? [])), a ? t.push(q(z._markedForDeletion, 1)) : (t.push(ke(Oe(z._markedForDeletion), q(z._markedForDeletion, 0))), t.push(ke(Oe(z.revokedAt), q(z.revokedAt, 0))));
|
|
353
|
+
let n = ie();
|
|
354
|
+
return k.with(n).select({
|
|
355
|
+
localId: z.localId,
|
|
356
|
+
uid: z.uid,
|
|
357
|
+
type: z.type,
|
|
358
|
+
schemaUid: z.schemaUid,
|
|
359
|
+
createdAt: z.createdAt,
|
|
360
|
+
attestationCreatedAt: z.attestationCreatedAt,
|
|
361
361
|
lastVersionPublishedAt: n.lastVersionPublishedAt,
|
|
362
|
-
_markedForDeletion:
|
|
363
|
-
}).from(
|
|
362
|
+
_markedForDeletion: z._markedForDeletion
|
|
363
|
+
}).from(z).leftJoin(n, q(z.localId, n.seedLocalId)).where(we(Ee(n.versionsCount, 0), ...t)).groupBy(z.localId);
|
|
364
364
|
}, [
|
|
365
|
-
|
|
365
|
+
k,
|
|
366
366
|
d,
|
|
367
367
|
e,
|
|
368
368
|
a,
|
|
369
369
|
l,
|
|
370
370
|
u,
|
|
371
371
|
x
|
|
372
|
-
])),
|
|
373
|
-
|
|
374
|
-
let
|
|
372
|
+
])), j = s(it(void 0)), ae = it(A);
|
|
373
|
+
ae.signature !== j.current.signature && (j.current = ae);
|
|
374
|
+
let M = j.current;
|
|
375
375
|
return i(() => {
|
|
376
|
-
if (!d || !
|
|
376
|
+
if (!d || !A) return;
|
|
377
377
|
let e = /* @__PURE__ */ new Set();
|
|
378
|
-
for (let t of
|
|
378
|
+
for (let t of A) {
|
|
379
379
|
let n = t.localId || t.uid;
|
|
380
380
|
n && e.add(n);
|
|
381
381
|
}
|
|
@@ -384,32 +384,32 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
384
384
|
let n = e.seedLocalId || e.seedUid;
|
|
385
385
|
n && t.add(n);
|
|
386
386
|
}
|
|
387
|
-
e.size === 0 && t.size > 0 || (
|
|
387
|
+
e.size === 0 && t.size > 0 || (ft(t, e) ? _.current = e : ft(_.current, e) && (y.current > b.current || E) || (_.current = e, b.current = y.current, m.invalidateQueries({ queryKey: C })));
|
|
388
388
|
}, [
|
|
389
389
|
d,
|
|
390
|
-
|
|
390
|
+
A,
|
|
391
391
|
m,
|
|
392
392
|
C,
|
|
393
|
-
|
|
393
|
+
D,
|
|
394
394
|
E
|
|
395
395
|
]), {
|
|
396
|
-
items: o(() =>
|
|
396
|
+
items: o(() => B(w, [(e) => e.seedLocalId && M.sortTimes.get(e.seedLocalId) || e.lastVersionPublishedAt || e.attestationCreatedAt || e.createdAt], ["desc"]), [w, M]),
|
|
397
397
|
isLoading: T || !d,
|
|
398
|
-
error:
|
|
398
|
+
error: te
|
|
399
399
|
};
|
|
400
|
-
},
|
|
400
|
+
}, st = (e) => {
|
|
401
401
|
if (typeof e != "object" || !e) return !1;
|
|
402
402
|
let t = Object.getPrototypeOf(e);
|
|
403
403
|
return t === Object.prototype || t === null;
|
|
404
|
-
},
|
|
404
|
+
}, ct = (e, t, n = 0) => Object.is(e, t) ? !0 : n > 20 ? !1 : Array.isArray(e) && Array.isArray(t) ? e.length === t.length && e.every((e, r) => ct(e, t[r], n + 1)) : st(e) && st(t) ? lt(e, t, n + 1) : !1, lt = (e, t, n = 0) => {
|
|
405
405
|
let r = Object.keys(e ?? {}), i = Object.keys(t ?? {});
|
|
406
|
-
return r.length === i.length && r.every((r) => Object.hasOwn(t ?? {}, r) &&
|
|
407
|
-
},
|
|
406
|
+
return r.length === i.length && r.every((r) => Object.hasOwn(t ?? {}, r) && ct(e?.[r], t?.[r], n));
|
|
407
|
+
}, ut = () => {
|
|
408
408
|
let [e, t] = c(!1), [r, i] = c(null), a = s([]), o = n(() => i(null), []);
|
|
409
409
|
return {
|
|
410
410
|
createItem: n((e, n, r) => {
|
|
411
|
-
let o = a.current.find((t) => t.modelName === e &&
|
|
412
|
-
if (o) return
|
|
411
|
+
let o = a.current.find((t) => t.modelName === e && lt(t.itemData, n) && lt(t.options, r));
|
|
412
|
+
if (o) return Ze("[useCreateItem] [createItem] the same create is running, returning it"), o.promise;
|
|
413
413
|
i(null), u(() => t(!0));
|
|
414
414
|
let s = async () => {
|
|
415
415
|
try {
|
|
@@ -422,7 +422,7 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
422
422
|
...r
|
|
423
423
|
}) ?? void 0;
|
|
424
424
|
} catch (e) {
|
|
425
|
-
|
|
425
|
+
Ze("[useCreateItem] Error creating item:", e), i(e instanceof Error ? e : Error(String(e)));
|
|
426
426
|
return;
|
|
427
427
|
} finally {
|
|
428
428
|
a.current = a.current.filter((e) => e !== c), a.current.length === 0 && queueMicrotask(() => t(!1));
|
|
@@ -439,7 +439,7 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
439
439
|
error: r,
|
|
440
440
|
resetError: o
|
|
441
441
|
};
|
|
442
|
-
},
|
|
442
|
+
}, dt = () => {
|
|
443
443
|
let [e, t] = c(null), [r, a] = c(!1), [o, l] = c(null), u = s(void 0), d = n(() => l(null), []), f = n((e, n) => {
|
|
444
444
|
e && (t(e), l(null), e.publish(n).catch((e) => {
|
|
445
445
|
l(e instanceof Error ? e : Error(String(e)));
|
|
@@ -464,16 +464,16 @@ var Xe = ye("seedSdk:react:item"), Ze = (e) => [
|
|
|
464
464
|
resetError: d
|
|
465
465
|
};
|
|
466
466
|
};
|
|
467
|
-
function
|
|
467
|
+
function ft(e, t) {
|
|
468
468
|
return e.size === t.size && [...e].every((e) => t.has(e));
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/entityRows.ts
|
|
472
|
-
function
|
|
473
|
-
let n = Y() &&
|
|
472
|
+
function pt(e, t) {
|
|
473
|
+
let n = Y() && ae(), r = He(n ? null : t), [a, o] = c({
|
|
474
474
|
data: void 0,
|
|
475
475
|
error: null
|
|
476
|
-
}), l = e && t ? `${JSON.stringify(e)}|${String(
|
|
476
|
+
}), l = e && t ? `${JSON.stringify(e)}|${String(ze(t))}` : null, u = s({
|
|
477
477
|
watch: e,
|
|
478
478
|
query: t
|
|
479
479
|
});
|
|
@@ -487,14 +487,14 @@ function ft(e, t) {
|
|
|
487
487
|
});
|
|
488
488
|
let { watch: e, query: t } = u.current;
|
|
489
489
|
if (!n || !l || !e || !t) return;
|
|
490
|
-
let r =
|
|
490
|
+
let r = ve(e, () => t.all(), (e) => o({
|
|
491
491
|
data: [...e],
|
|
492
492
|
error: null
|
|
493
493
|
}), {
|
|
494
494
|
immediate: !0,
|
|
495
495
|
onError: (e) => o((t) => ({
|
|
496
496
|
data: t.data,
|
|
497
|
-
error:
|
|
497
|
+
error: Ve(e)
|
|
498
498
|
}))
|
|
499
499
|
});
|
|
500
500
|
return () => r.unsubscribe();
|
|
@@ -502,15 +502,15 @@ function ft(e, t) {
|
|
|
502
502
|
}
|
|
503
503
|
//#endregion
|
|
504
504
|
//#region src/itemProperty.ts
|
|
505
|
-
var
|
|
505
|
+
var mt = V("seedSdk:react:property"), ht = V("seedSdk:react:itemProperties"), gt = (e, t, n) => [
|
|
506
506
|
"seed",
|
|
507
507
|
"itemProperty",
|
|
508
508
|
e ?? null,
|
|
509
509
|
t ?? null,
|
|
510
510
|
n
|
|
511
511
|
];
|
|
512
|
-
function
|
|
513
|
-
let n = Y(), r =
|
|
512
|
+
function _t(e, t) {
|
|
513
|
+
let n = Y(), r = Xe(), [, 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(() => {
|
|
514
514
|
let e = p !== void 0 && p !== "" ? p : u, t = p !== void 0 && p !== "" ? void 0 : d;
|
|
515
515
|
return (e || t) && m ? {
|
|
516
516
|
type: "identifiers",
|
|
@@ -524,7 +524,7 @@ function gt(e, t) {
|
|
|
524
524
|
m,
|
|
525
525
|
u,
|
|
526
526
|
d
|
|
527
|
-
]), g = o(() =>
|
|
527
|
+
]), g = o(() => gt(h?.seedLocalId, h?.seedUid, h?.propertyName ?? ""), [h]), _ = K({
|
|
528
528
|
queryKey: g,
|
|
529
529
|
queryFn: async () => {
|
|
530
530
|
if (!h) return null;
|
|
@@ -538,7 +538,7 @@ function gt(e, t) {
|
|
|
538
538
|
seedUid: h.itemId,
|
|
539
539
|
hold: !1
|
|
540
540
|
}) : void 0, n = e ?? t;
|
|
541
|
-
return n ||
|
|
541
|
+
return n || mt(`[useItemProperty] no property found for Item.${h.seedLocalId || h.seedUid}.${h.propertyName}`), n ?? null;
|
|
542
542
|
},
|
|
543
543
|
initialData: () => h ? y.peekReady(h) : void 0,
|
|
544
544
|
staleTime: 0,
|
|
@@ -547,7 +547,7 @@ function gt(e, t) {
|
|
|
547
547
|
retry: !1,
|
|
548
548
|
enabled: n && !!h
|
|
549
549
|
}, r), v = _.data ?? void 0;
|
|
550
|
-
return
|
|
550
|
+
return bt(o(() => v ? [v] : [], [v])), i(() => {
|
|
551
551
|
if (!v) return;
|
|
552
552
|
let e = () => a((e) => e + 1), t = v.getService().getSnapshot()?.context, n = t?.renderValue, r = t?.propertyValue, i = t?.conflict, o = t?.missingFile, s = !1, c = 0, l, u = v.getService().subscribe((t) => {
|
|
553
553
|
let a = t?.context ?? {};
|
|
@@ -575,8 +575,8 @@ function gt(e, t) {
|
|
|
575
575
|
valueStatus: v?.valueStatus
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
|
-
function
|
|
579
|
-
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 } =
|
|
578
|
+
function vt(e, t = 300) {
|
|
579
|
+
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 } = _t(o(() => r ? {
|
|
580
580
|
itemId: r,
|
|
581
581
|
propertyName: l
|
|
582
582
|
} : {
|
|
@@ -588,7 +588,7 @@ function _t(e, t = 300) {
|
|
|
588
588
|
a,
|
|
589
589
|
c,
|
|
590
590
|
l
|
|
591
|
-
])), p = s(""), m =
|
|
591
|
+
])), p = s(""), m = yt(u), h = o(() => ye((e) => {
|
|
592
592
|
e.setValue(p.current);
|
|
593
593
|
}, t), [t]);
|
|
594
594
|
i(() => () => h.flush(), [h]);
|
|
@@ -603,7 +603,7 @@ function _t(e, t = 300) {
|
|
|
603
603
|
error: f ?? m
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function yt(e) {
|
|
607
607
|
let [t, n] = c(null);
|
|
608
608
|
return i(() => {
|
|
609
609
|
if (!e) {
|
|
@@ -623,7 +623,7 @@ function vt(e) {
|
|
|
623
623
|
return () => a.unsubscribe();
|
|
624
624
|
}, [e]), t;
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function bt(e) {
|
|
627
627
|
i(() => {
|
|
628
628
|
let t = e.filter((e) => y.retain(e));
|
|
629
629
|
return () => {
|
|
@@ -633,7 +633,7 @@ function yt(e) {
|
|
|
633
633
|
};
|
|
634
634
|
}, [e]);
|
|
635
635
|
}
|
|
636
|
-
async function
|
|
636
|
+
async function xt(e, t) {
|
|
637
637
|
if (!e && !t) return [];
|
|
638
638
|
let n = f.getAppDb();
|
|
639
639
|
if (!n) return [];
|
|
@@ -648,19 +648,19 @@ async function bt(e, t) {
|
|
|
648
648
|
let o;
|
|
649
649
|
if (r.length > 0) {
|
|
650
650
|
let e = r[0];
|
|
651
|
-
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o =
|
|
651
|
+
o = e.modelName ?? e.modelType, o && typeof o == "string" && (o = be(o));
|
|
652
652
|
}
|
|
653
653
|
let s = await n.select({
|
|
654
|
-
type:
|
|
655
|
-
modelFileId:
|
|
656
|
-
}).from(
|
|
657
|
-
!o && s.length > 0 && s[0].type && (o =
|
|
654
|
+
type: z.type,
|
|
655
|
+
modelFileId: z.modelFileId
|
|
656
|
+
}).from(z).where(t ? q(z.uid, t) : q(z.localId, e)).limit(1), c = s[0]?.modelFileId ?? void 0;
|
|
657
|
+
!o && s.length > 0 && s[0].type && (o = be(s[0].type));
|
|
658
658
|
let l = [];
|
|
659
659
|
if (o) try {
|
|
660
660
|
let { Model: e } = await import("@seedprotocol/sdk"), t = await e.resolveAsync(o, { modelFileId: c });
|
|
661
661
|
if (t?.properties) for (let e of t.properties) e.name && l.push(e.name);
|
|
662
662
|
} catch (e) {
|
|
663
|
-
|
|
663
|
+
ht(`[useItemProperties] Error getting ModelProperties for ${o}:`, e);
|
|
664
664
|
}
|
|
665
665
|
if (o && l.length > 0) {
|
|
666
666
|
let n = r.length > 0 ? r[0].seedLocalId ?? e : e, s = r.length > 0 ? r[0].seedUid ?? t : t;
|
|
@@ -677,11 +677,11 @@ async function bt(e, t) {
|
|
|
677
677
|
});
|
|
678
678
|
t && i.push(t);
|
|
679
679
|
} catch (t) {
|
|
680
|
-
|
|
680
|
+
mt(`[useItemProperties] Error creating ItemProperty for missing property ${e}:`, t);
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
683
|
if (e || t) {
|
|
684
|
-
let a = await n.select({ createdAt:
|
|
684
|
+
let a = await n.select({ createdAt: z.createdAt }).from(z).where(t ? q(z.uid, t) : q(z.localId, e)).limit(1);
|
|
685
685
|
if (a.length > 0 && a[0].createdAt) {
|
|
686
686
|
let n = "createdAt";
|
|
687
687
|
if (!i.some((e) => e.propertyName === n) && o) try {
|
|
@@ -697,14 +697,14 @@ async function bt(e, t) {
|
|
|
697
697
|
});
|
|
698
698
|
l && i.push(l);
|
|
699
699
|
} catch (e) {
|
|
700
|
-
|
|
700
|
+
mt("[useItemProperties] Error creating createdAt ItemProperty:", e);
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
704
|
return i;
|
|
705
705
|
}
|
|
706
|
-
function
|
|
707
|
-
let t = Y(), n =
|
|
706
|
+
function St(e) {
|
|
707
|
+
let t = Y(), n = Ce(), r = s(void 0), a = o(() => typeof e == "string" ? {
|
|
708
708
|
type: "itemId",
|
|
709
709
|
itemId: e
|
|
710
710
|
} : typeof e == "object" ? {
|
|
@@ -719,54 +719,54 @@ function xt(e) {
|
|
|
719
719
|
"seed",
|
|
720
720
|
"itemProperties",
|
|
721
721
|
u
|
|
722
|
-
], [u]), { data: p = [], isLoading: m, error: h } =
|
|
722
|
+
], [u]), { data: p = [], isLoading: m, error: h } = K({
|
|
723
723
|
queryKey: d,
|
|
724
|
-
queryFn: () =>
|
|
724
|
+
queryFn: () => xt(c, l),
|
|
725
725
|
enabled: t && !!u,
|
|
726
726
|
gcTime: 0,
|
|
727
727
|
structuralSharing: !1
|
|
728
728
|
});
|
|
729
|
-
|
|
729
|
+
bt(p);
|
|
730
730
|
let g = o(() => {
|
|
731
|
-
if (!t || !c && !l) return
|
|
731
|
+
if (!t || !c && !l) return ht("[useItemProperties] Query: returning null (not ready or no identifiers)"), null;
|
|
732
732
|
let e = f.getAppDb();
|
|
733
|
-
if (!e) return
|
|
734
|
-
|
|
733
|
+
if (!e) return ht("[useItemProperties] Query: returning null (no db)"), null;
|
|
734
|
+
ht(`[useItemProperties] Query: creating query for seedLocalId=${c}, seedUid=${l}`);
|
|
735
735
|
let n = l ? e.select({
|
|
736
|
-
propertyName:
|
|
737
|
-
propertyValue:
|
|
738
|
-
seedLocalId:
|
|
739
|
-
seedUid:
|
|
740
|
-
modelType:
|
|
741
|
-
schemaUid:
|
|
742
|
-
createdAt:
|
|
743
|
-
attestationCreatedAt:
|
|
744
|
-
localId:
|
|
745
|
-
revokedAt:
|
|
746
|
-
}).from(
|
|
747
|
-
propertyName:
|
|
748
|
-
propertyValue:
|
|
749
|
-
seedLocalId:
|
|
750
|
-
seedUid:
|
|
751
|
-
modelType:
|
|
752
|
-
schemaUid:
|
|
753
|
-
createdAt:
|
|
754
|
-
attestationCreatedAt:
|
|
755
|
-
localId:
|
|
756
|
-
revokedAt:
|
|
757
|
-
}).from(
|
|
758
|
-
return
|
|
736
|
+
propertyName: N.propertyName,
|
|
737
|
+
propertyValue: N.propertyValue,
|
|
738
|
+
seedLocalId: N.seedLocalId,
|
|
739
|
+
seedUid: N.seedUid,
|
|
740
|
+
modelType: N.modelType,
|
|
741
|
+
schemaUid: N.schemaUid,
|
|
742
|
+
createdAt: N.createdAt,
|
|
743
|
+
attestationCreatedAt: N.attestationCreatedAt,
|
|
744
|
+
localId: N.localId,
|
|
745
|
+
revokedAt: N.revokedAt
|
|
746
|
+
}).from(N).where(we(q(N.seedUid, l), De(N.propertyName))) : c ? e.select({
|
|
747
|
+
propertyName: N.propertyName,
|
|
748
|
+
propertyValue: N.propertyValue,
|
|
749
|
+
seedLocalId: N.seedLocalId,
|
|
750
|
+
seedUid: N.seedUid,
|
|
751
|
+
modelType: N.modelType,
|
|
752
|
+
schemaUid: N.schemaUid,
|
|
753
|
+
createdAt: N.createdAt,
|
|
754
|
+
attestationCreatedAt: N.attestationCreatedAt,
|
|
755
|
+
localId: N.localId,
|
|
756
|
+
revokedAt: N.revokedAt
|
|
757
|
+
}).from(N).where(we(q(N.seedLocalId, c), De(N.propertyName))) : null;
|
|
758
|
+
return ht("[useItemProperties] Query: created query object", { queryType: l ? "seedUid" : "seedLocalId" }), n;
|
|
759
759
|
}, [
|
|
760
760
|
t,
|
|
761
761
|
c,
|
|
762
762
|
l
|
|
763
|
-
]), _ =
|
|
763
|
+
]), _ = pt(o(() => l ? {
|
|
764
764
|
seedUid: l,
|
|
765
765
|
tables: ["metadata"]
|
|
766
766
|
} : c ? {
|
|
767
767
|
seedLocalId: c,
|
|
768
768
|
tables: ["metadata"]
|
|
769
|
-
} : null, [c, l]), g).data, v = o(() => !_ || _.length === 0 ? [] :
|
|
769
|
+
} : null, [c, l]), g).data, v = o(() => !_ || _.length === 0 ? [] : pe(_), [_]);
|
|
770
770
|
return i(() => {
|
|
771
771
|
if (!t || !c && !l || v === void 0) return;
|
|
772
772
|
let e = JSON.stringify(v.map((e) => ({
|
|
@@ -792,7 +792,7 @@ function xt(e) {
|
|
|
792
792
|
error: h
|
|
793
793
|
};
|
|
794
794
|
}
|
|
795
|
-
var
|
|
795
|
+
var Ct = () => {
|
|
796
796
|
let e = s(void 0), [t, r] = c(!1), [a, o] = c(null), l = n(() => o(null), []), u = n((t) => {
|
|
797
797
|
if (!t.propertyName || !t.seedLocalId && !t.seedUid || !t.modelName) {
|
|
798
798
|
o(/* @__PURE__ */ Error("seedLocalId or seedUid, propertyName, and modelName are required"));
|
|
@@ -809,7 +809,7 @@ var St = () => {
|
|
|
809
809
|
}
|
|
810
810
|
let i = n.getService().subscribe(() => {
|
|
811
811
|
if (n.status === "error") {
|
|
812
|
-
let e =
|
|
812
|
+
let e = ne(n);
|
|
813
813
|
o(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to create item property")), r(!1);
|
|
814
814
|
}
|
|
815
815
|
n.status === "ready" && (o(null), r(!1));
|
|
@@ -824,7 +824,7 @@ var St = () => {
|
|
|
824
824
|
error: a,
|
|
825
825
|
resetError: l
|
|
826
826
|
};
|
|
827
|
-
},
|
|
827
|
+
}, wt = () => {
|
|
828
828
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
829
829
|
return {
|
|
830
830
|
destroy: n(async (e) => {
|
|
@@ -843,24 +843,24 @@ var St = () => {
|
|
|
843
843
|
error: r,
|
|
844
844
|
resetError: n(() => i(null), [])
|
|
845
845
|
};
|
|
846
|
-
},
|
|
846
|
+
}, Tt = /* @__PURE__ */ new Set([
|
|
847
847
|
m.SAVE_CONFIG,
|
|
848
848
|
m.PROCESS_SCHEMA_FILES,
|
|
849
849
|
m.ADD_MODELS_TO_DB,
|
|
850
850
|
m.IDLE
|
|
851
|
-
]),
|
|
851
|
+
]), Et = (e) => typeof e == "string" && Tt.has(e), Dt = () => ({ dbsAreReady: J((e) => e.status === "active" && Et(e.value)) }), Ot = V("seedSdk:react:services"), kt = [
|
|
852
852
|
"idle",
|
|
853
853
|
"ready",
|
|
854
854
|
"done",
|
|
855
855
|
"success",
|
|
856
856
|
"initialized"
|
|
857
|
-
],
|
|
857
|
+
], At = (e) => {
|
|
858
858
|
let t = "actor", n = e;
|
|
859
|
-
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t =
|
|
860
|
-
}, At = (e) => {
|
|
861
|
-
let t;
|
|
862
|
-
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), kt(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;
|
|
859
|
+
return e && n.uniqueKey && (t = n.uniqueKey), e && !n.uniqueKey && n.logic && n.logic.config && (t = Mt(e)), t;
|
|
863
860
|
}, jt = (e) => {
|
|
861
|
+
let t;
|
|
862
|
+
return e && e.getSnapshot() && e.getSnapshot().value && (t = e.getSnapshot().value), At(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;
|
|
863
|
+
}, Mt = (e) => {
|
|
864
864
|
let t = e;
|
|
865
865
|
if (!e || !t.logic || !t.logic.config || !t._snapshot) return;
|
|
866
866
|
let n = t.logic.config;
|
|
@@ -871,23 +871,23 @@ var St = () => {
|
|
|
871
871
|
try {
|
|
872
872
|
i = e.getSnapshot();
|
|
873
873
|
} catch (e) {
|
|
874
|
-
return
|
|
874
|
+
return Ot("Error:", e), r;
|
|
875
875
|
}
|
|
876
876
|
if (i) {
|
|
877
877
|
let e = i.context;
|
|
878
|
-
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r =
|
|
878
|
+
e && e.dbName && (r = e.dbName), e && e.modelNamePlural && (r = e.modelNamePlural), e && e.modelName && (r = Ae(e.modelName.toLowerCase()));
|
|
879
879
|
}
|
|
880
880
|
return r;
|
|
881
|
-
},
|
|
881
|
+
}, Nt = (e) => e?.logic?.config?.id === x.CLIENT_MANAGER, Pt = (e) => {
|
|
882
882
|
let t = e?.getSnapshot();
|
|
883
|
-
if (
|
|
884
|
-
let n =
|
|
885
|
-
if (n &&
|
|
883
|
+
if (Nt(e)) return t?.status === "active" ? zt(t.value) : 0;
|
|
884
|
+
let n = jt(e);
|
|
885
|
+
if (n && kt.includes(n)) return 100;
|
|
886
886
|
let r = e?.logic?.states;
|
|
887
887
|
if (!n || !r) return 0;
|
|
888
888
|
let i = Object.entries(r).filter(([, e]) => e.tags?.includes("loading")).map(([e]) => e), a = i.indexOf(n);
|
|
889
889
|
return a < 0 ? 0 : a / i.length * 100;
|
|
890
|
-
},
|
|
890
|
+
}, Ft = (e) => {
|
|
891
891
|
let [t, r] = c(0), a = n((t) => {
|
|
892
892
|
let n = e.subscribe({
|
|
893
893
|
next: t,
|
|
@@ -895,7 +895,7 @@ var St = () => {
|
|
|
895
895
|
complete: t
|
|
896
896
|
});
|
|
897
897
|
return () => n.unsubscribe();
|
|
898
|
-
}, [e]), o = () =>
|
|
898
|
+
}, [e]), o = () => jt(e), s = l(a, o, o), u = n((t) => {
|
|
899
899
|
let n = e.getSnapshot().value;
|
|
900
900
|
n === "done" || n === "success" || n === "idle" || n === "ready" ? clearInterval(t) : r((e) => e + 1);
|
|
901
901
|
}, [e]), d = n(() => {
|
|
@@ -908,16 +908,16 @@ var St = () => {
|
|
|
908
908
|
let e = d();
|
|
909
909
|
return () => clearInterval(e);
|
|
910
910
|
}, []), {
|
|
911
|
-
name:
|
|
911
|
+
name: At(e),
|
|
912
912
|
timeElapsed: t,
|
|
913
913
|
value: s,
|
|
914
|
-
percentComplete:
|
|
915
|
-
uniqueKey:
|
|
914
|
+
percentComplete: Pt(e),
|
|
915
|
+
uniqueKey: Mt(e)
|
|
916
916
|
};
|
|
917
|
-
},
|
|
918
|
-
let { internalStatus: e } =
|
|
917
|
+
}, It = () => {
|
|
918
|
+
let { internalStatus: e } = Vt();
|
|
919
919
|
return e === "ready";
|
|
920
|
-
},
|
|
920
|
+
}, Lt = () => {}, Rt = () => !1, zt = (e) => {
|
|
921
921
|
switch (e) {
|
|
922
922
|
case m.IDLE: return 100;
|
|
923
923
|
case m.ADD_MODELS_TO_DB: return 90;
|
|
@@ -928,28 +928,28 @@ var St = () => {
|
|
|
928
928
|
case m.PLATFORM_CLASSES_INIT: return 10;
|
|
929
929
|
default: return 0;
|
|
930
930
|
}
|
|
931
|
-
},
|
|
932
|
-
let e =
|
|
931
|
+
}, Bt = () => {
|
|
932
|
+
let e = Ne(), t = J((e) => e.status === "active" ? zt(e.value) : 0);
|
|
933
933
|
return {
|
|
934
934
|
services: o(() => (e.uniqueKey = "clientManager", [e]), [e]),
|
|
935
935
|
percentComplete: t
|
|
936
936
|
};
|
|
937
|
-
},
|
|
937
|
+
}, Vt = () => ({
|
|
938
938
|
status: J((e) => e.status === "active" ? e.value : "stopped"),
|
|
939
|
-
internalStatus: J((e) => e.status === "active" ?
|
|
939
|
+
internalStatus: J((e) => e.status === "active" ? Et(e.value) ? "ready" : e.value : "stopped"),
|
|
940
940
|
stopReason: J((e) => e.status === "active" ? void 0 : e.context.stopReason ?? "stop")
|
|
941
|
-
}),
|
|
942
|
-
function
|
|
941
|
+
}), Ht = (e) => e instanceof Error ? e : Error(String(e));
|
|
942
|
+
function Ut(e) {
|
|
943
943
|
let t = s(null), r = s(0), [a, o] = c(!1), [l, u] = c(null), d = n(() => u(null), []), f = n((n) => {
|
|
944
944
|
let r = (t) => {
|
|
945
945
|
if (n.status === "error") {
|
|
946
|
-
let r =
|
|
946
|
+
let r = ne(n) ?? t.context?._loadingError?.error;
|
|
947
947
|
u(r instanceof Error ? r : Error(e)), o(!1);
|
|
948
948
|
} else n.status === "ready" && (u(null), o(!1));
|
|
949
949
|
}, i = n.getService();
|
|
950
950
|
t.current = i.subscribe(r), r(i.getSnapshot());
|
|
951
951
|
}, [e]), p = n((e) => {
|
|
952
|
-
throw u(
|
|
952
|
+
throw u(Ht(e)), o(!1), e;
|
|
953
953
|
}, []), m = n(() => (t.current?.unsubscribe(), t.current = null, u(null), o(!0), ++r.current), []), h = n((e) => {
|
|
954
954
|
m();
|
|
955
955
|
let t;
|
|
@@ -989,11 +989,11 @@ function Ht(e) {
|
|
|
989
989
|
}
|
|
990
990
|
//#endregion
|
|
991
991
|
//#region src/schema.ts
|
|
992
|
-
var
|
|
992
|
+
var Wt = V("seedSdk:react:schema"), Gt = (e) => {
|
|
993
993
|
let [t, r] = c(null), [a, o] = c(!!e), [s, l] = c(null), d = Y(), f = n(async (e, t) => {
|
|
994
994
|
o(!0), l(null);
|
|
995
995
|
try {
|
|
996
|
-
if (!await
|
|
996
|
+
if (!await Kt(e)) {
|
|
997
997
|
if (!t.current) return;
|
|
998
998
|
r(null), o(!1);
|
|
999
999
|
return;
|
|
@@ -1013,7 +1013,7 @@ var Ut = ye("seedSdk:react:schema"), Wt = (e) => {
|
|
|
1013
1013
|
};
|
|
1014
1014
|
a(i.getSnapshot()), t.subscription = i.subscribe(a);
|
|
1015
1015
|
} catch (e) {
|
|
1016
|
-
if (
|
|
1016
|
+
if (Wt("[useSchema] Error creating schema:", e), !t.current) return;
|
|
1017
1017
|
l(e), r(null), o(!1);
|
|
1018
1018
|
}
|
|
1019
1019
|
}, []);
|
|
@@ -1040,25 +1040,25 @@ var Ut = ye("seedSdk:react:schema"), Wt = (e) => {
|
|
|
1040
1040
|
error: s
|
|
1041
1041
|
};
|
|
1042
1042
|
};
|
|
1043
|
-
async function
|
|
1043
|
+
async function Kt(e) {
|
|
1044
1044
|
if (e === w) return !0;
|
|
1045
1045
|
let t = f.getAppDb();
|
|
1046
|
-
return !t || (await t.select({ id:
|
|
1046
|
+
return !t || (await t.select({ id: R.id }).from(R).where(ke(q(R.name, e), q(R.schemaFileId, e))).limit(1)).length > 0;
|
|
1047
1047
|
}
|
|
1048
|
-
var
|
|
1049
|
-
let e = Y(), t =
|
|
1050
|
-
queryKey:
|
|
1048
|
+
var qt = ["seed", "schemas"], Jt = [], Yt = (e) => T.retain(e), Xt = () => {
|
|
1049
|
+
let e = Y(), t = Xe(), r = s(void 0), a = s([]), { data: c = Jt, isLoading: l, error: u } = K({
|
|
1050
|
+
queryKey: qt,
|
|
1051
1051
|
queryFn: () => T.all({ waitForReady: !0 }),
|
|
1052
1052
|
enabled: e
|
|
1053
1053
|
}, t);
|
|
1054
|
-
a.current = c, X(c,
|
|
1055
|
-
t.invalidateQueries({ queryKey:
|
|
1054
|
+
a.current = c, X(c, Yt, n(() => {
|
|
1055
|
+
t.invalidateQueries({ queryKey: qt });
|
|
1056
1056
|
}, [t]));
|
|
1057
|
-
let d = e ? f.getAppDb() : null, p = Z(o(() => d ? d.select().from(
|
|
1057
|
+
let d = e ? f.getAppDb() : null, p = Z(o(() => d ? d.select().from(R).orderBy(R.name, Te(R.version)) : null, [d, e]));
|
|
1058
1058
|
return i(() => {
|
|
1059
1059
|
if (typeof BroadcastChannel > "u") return;
|
|
1060
1060
|
let e = new BroadcastChannel("seed-schemas-invalidate"), n = () => {
|
|
1061
|
-
t.invalidateQueries({ queryKey:
|
|
1061
|
+
t.invalidateQueries({ queryKey: qt });
|
|
1062
1062
|
};
|
|
1063
1063
|
return e.addEventListener("message", n), () => {
|
|
1064
1064
|
e.removeEventListener("message", n), e.close();
|
|
@@ -1081,7 +1081,7 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1081
1081
|
let o = /* @__PURE__ */ new Set();
|
|
1082
1082
|
for (let e of p) e.name !== "Seed Protocol" && (e.schemaFileId ? o.add(e.schemaFileId) : e.name != null && e.version !== void 0 && o.add(`${e.name}:${e.version}`));
|
|
1083
1083
|
let s = i.size === o.size && [...i].every((e) => o.has(e)), c = i.size > 0 && o.size > 0 && [...o].some((e) => !i.has(e)), l = [...i].some((e) => !o.has(e));
|
|
1084
|
-
!s && (c || l) && t.invalidateQueries({ queryKey:
|
|
1084
|
+
!s && (c || l) && t.invalidateQueries({ queryKey: qt });
|
|
1085
1085
|
}, [
|
|
1086
1086
|
e,
|
|
1087
1087
|
p,
|
|
@@ -1091,15 +1091,15 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1091
1091
|
isLoading: l,
|
|
1092
1092
|
error: u
|
|
1093
1093
|
};
|
|
1094
|
-
},
|
|
1095
|
-
let { run: e, isLoading: t, error: r, resetError: i } =
|
|
1094
|
+
}, Zt = () => {
|
|
1095
|
+
let { run: e, isLoading: t, error: r, resetError: i } = Ut("Failed to create schema");
|
|
1096
1096
|
return {
|
|
1097
1097
|
createSchema: n((t) => e(() => T.create(t, { waitForReady: !1 })), [e]),
|
|
1098
1098
|
isLoading: t,
|
|
1099
1099
|
error: r,
|
|
1100
1100
|
resetError: i
|
|
1101
1101
|
};
|
|
1102
|
-
},
|
|
1102
|
+
}, Qt = () => {
|
|
1103
1103
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1104
1104
|
return {
|
|
1105
1105
|
destroy: n(async (e) => {
|
|
@@ -1118,10 +1118,10 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1118
1118
|
error: r,
|
|
1119
1119
|
resetError: n(() => i(null), [])
|
|
1120
1120
|
};
|
|
1121
|
-
},
|
|
1121
|
+
}, $t = () => {
|
|
1122
1122
|
let [e, t] = c(), r = s(/* @__PURE__ */ new Map()), a = Y(), o = n(async () => {
|
|
1123
1123
|
if (a) try {
|
|
1124
|
-
let e = await
|
|
1124
|
+
let e = await se(), n = /* @__PURE__ */ new Set();
|
|
1125
1125
|
for (let t of e) {
|
|
1126
1126
|
let e = t.schema.metadata?.name;
|
|
1127
1127
|
e && n.add(e);
|
|
@@ -1140,7 +1140,7 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1140
1140
|
for (let [e, t] of r.current.entries()) n.has(e) || t.unload();
|
|
1141
1141
|
r.current = i, t(Array.from(i.values()));
|
|
1142
1142
|
} catch (e) {
|
|
1143
|
-
|
|
1143
|
+
Wt("Error fetching all schema versions from database:", e), t(null);
|
|
1144
1144
|
}
|
|
1145
1145
|
}, [a]);
|
|
1146
1146
|
return i(() => {
|
|
@@ -1150,20 +1150,20 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1150
1150
|
e.unload();
|
|
1151
1151
|
}), r.current.clear();
|
|
1152
1152
|
}, []), e;
|
|
1153
|
-
},
|
|
1153
|
+
}, en = () => Gt(w), tn = (e) => [
|
|
1154
1154
|
"seed",
|
|
1155
1155
|
"models",
|
|
1156
1156
|
e
|
|
1157
|
-
],
|
|
1158
|
-
let t = Y(), r =
|
|
1157
|
+
], nn = [], rn = (e) => S.retain(e), an = (e) => e.getService().getSnapshot().status === "active", on = (e) => {
|
|
1158
|
+
let t = Y(), r = Xe(), a = s(null), c = o(() => tn(e), [e]), { data: l = nn, isLoading: u, error: d } = K({
|
|
1159
1159
|
queryKey: c,
|
|
1160
1160
|
queryFn: async () => {
|
|
1161
1161
|
let t = await S.all(e, { waitForReady: !1 }), n = r.getQueryData(c), i = a.current;
|
|
1162
|
-
return t.length === 0 && n && n.length > 0 && n.every(
|
|
1162
|
+
return t.length === 0 && n && n.length > 0 && n.every(an) && (!i || i.size > 0) ? n : t;
|
|
1163
1163
|
},
|
|
1164
1164
|
enabled: t && !!e
|
|
1165
|
-
}, r), p = e ? l :
|
|
1166
|
-
m.current = p, X(p,
|
|
1165
|
+
}, r), p = e ? l : nn, m = s(p);
|
|
1166
|
+
m.current = p, X(p, rn, n(() => {
|
|
1167
1167
|
r.invalidateQueries({ queryKey: c });
|
|
1168
1168
|
}, [r, c])), i(() => {
|
|
1169
1169
|
if (!e || typeof BroadcastChannel > "u") return;
|
|
@@ -1183,9 +1183,9 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1183
1183
|
function _() {
|
|
1184
1184
|
let t = f.getAppDb();
|
|
1185
1185
|
return !t || !e ? null : t.select({
|
|
1186
|
-
modelFileId:
|
|
1187
|
-
modelName:
|
|
1188
|
-
}).from(
|
|
1186
|
+
modelFileId: P.schemaFileId,
|
|
1187
|
+
modelName: P.name
|
|
1188
|
+
}).from(R).innerJoin(le, q(R.id, le.schemaId)).innerJoin(P, q(le.modelId, P.id)).where(ke(q(R.schemaFileId, e), q(R.name, e)));
|
|
1189
1189
|
}
|
|
1190
1190
|
let v = Z(o(() => {
|
|
1191
1191
|
if (!e || !t) return null;
|
|
@@ -1218,7 +1218,7 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1218
1218
|
isLoading: u,
|
|
1219
1219
|
error: d
|
|
1220
1220
|
};
|
|
1221
|
-
},
|
|
1221
|
+
}, sn = (e, t) => {
|
|
1222
1222
|
let r = Y(), [a, l] = c(void 0), [u, d] = c(!1), [f, p] = c(null), m = s(void 0), [, h] = c(0), [g, _] = c(0), v = t == null;
|
|
1223
1223
|
i(() => {
|
|
1224
1224
|
!r || !v || !e ? (l(void 0), d(!1), p(null)) : (async () => {
|
|
@@ -1237,8 +1237,8 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1237
1237
|
g
|
|
1238
1238
|
]);
|
|
1239
1239
|
let y = n(() => _((e) => e + 1), []);
|
|
1240
|
-
X(o(() => a ? [a] :
|
|
1241
|
-
let { models: b, isLoading: x, error: C } =
|
|
1240
|
+
X(o(() => a ? [a] : nn, [a]), rn, y);
|
|
1241
|
+
let { models: b, isLoading: x, error: C } = on(v ? null : e), w = o(() => {
|
|
1242
1242
|
if (!v && t) return b.find((e) => (e.modelName ?? e.name) === t);
|
|
1243
1243
|
}, [
|
|
1244
1244
|
v,
|
|
@@ -1260,8 +1260,8 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1260
1260
|
isLoading: x,
|
|
1261
1261
|
error: C
|
|
1262
1262
|
};
|
|
1263
|
-
},
|
|
1264
|
-
let { run: e, isLoading: t, error: r, resetError: i } =
|
|
1263
|
+
}, cn = () => {
|
|
1264
|
+
let { run: e, isLoading: t, error: r, resetError: i } = Ut("Failed to create model");
|
|
1265
1265
|
return {
|
|
1266
1266
|
create: n((t, n, r) => e(() => S.create(n, t, {
|
|
1267
1267
|
...r,
|
|
@@ -1271,7 +1271,7 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1271
1271
|
error: r,
|
|
1272
1272
|
resetError: i
|
|
1273
1273
|
};
|
|
1274
|
-
},
|
|
1274
|
+
}, ln = () => {
|
|
1275
1275
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1276
1276
|
return {
|
|
1277
1277
|
destroy: n(async (e) => {
|
|
@@ -1290,23 +1290,23 @@ var Kt = ["seed", "schemas"], qt = [], Jt = (e) => T.retain(e), Yt = () => {
|
|
|
1290
1290
|
error: r,
|
|
1291
1291
|
resetError: n(() => i(null), [])
|
|
1292
1292
|
};
|
|
1293
|
-
},
|
|
1294
|
-
async function
|
|
1293
|
+
}, un = [], dn = (e) => C.retain(e);
|
|
1294
|
+
async function fn(e) {
|
|
1295
1295
|
let t = f.getAppDb();
|
|
1296
1296
|
if (!t) throw new h();
|
|
1297
|
-
return (await t.select({ name:
|
|
1297
|
+
return (await t.select({ name: R.name }).from(R).where(ke(q(R.name, e), q(R.schemaFileId, e))).limit(1))[0]?.name ?? void 0;
|
|
1298
1298
|
}
|
|
1299
|
-
var
|
|
1300
|
-
let { model: r } =
|
|
1299
|
+
var pn = (e, t) => {
|
|
1300
|
+
let { model: r } = sn(e, t), a = Y(), c = Xe(), l = gn(r), u = r?.id, d = o(() => [
|
|
1301
1301
|
"seed",
|
|
1302
1302
|
"modelProperties",
|
|
1303
1303
|
u ?? ""
|
|
1304
|
-
], [u]), { data: p =
|
|
1304
|
+
], [u]), { data: p = un, isLoading: m, error: h } = K({
|
|
1305
1305
|
queryKey: d,
|
|
1306
1306
|
queryFn: () => C.all(u, { waitForReady: !0 }),
|
|
1307
1307
|
enabled: a && !!u
|
|
1308
1308
|
}, c);
|
|
1309
|
-
X(p,
|
|
1309
|
+
X(p, dn, n(() => {
|
|
1310
1310
|
c.invalidateQueries({ queryKey: d });
|
|
1311
1311
|
}, [c, d]));
|
|
1312
1312
|
let g = a ? f.getAppDb() : null, _ = Z(o(() => !g || !l ? null : g.select({
|
|
@@ -1355,33 +1355,33 @@ var fn = (e, t) => {
|
|
|
1355
1355
|
isLoading: m && p.length === 0,
|
|
1356
1356
|
error: h
|
|
1357
1357
|
};
|
|
1358
|
-
},
|
|
1358
|
+
}, mn = [
|
|
1359
1359
|
400,
|
|
1360
1360
|
1200,
|
|
1361
1361
|
2500
|
|
1362
|
-
],
|
|
1362
|
+
], hn = (e) => {
|
|
1363
1363
|
if (e) try {
|
|
1364
1364
|
return e._getSnapshotContext()._dbId;
|
|
1365
1365
|
} catch {
|
|
1366
1366
|
return;
|
|
1367
1367
|
}
|
|
1368
|
-
},
|
|
1369
|
-
let [t, n] = c(() =>
|
|
1368
|
+
}, gn = (e) => {
|
|
1369
|
+
let [t, n] = c(() => hn(e));
|
|
1370
1370
|
return i(() => {
|
|
1371
|
-
if (n(
|
|
1372
|
-
let t = e.getService().subscribe(() => n(
|
|
1371
|
+
if (n(hn(e)), !e) return;
|
|
1372
|
+
let t = e.getService().subscribe(() => n(hn(e)));
|
|
1373
1373
|
return () => t.unsubscribe();
|
|
1374
1374
|
}, [e]), t;
|
|
1375
|
-
},
|
|
1375
|
+
}, _n = async (e, t) => {
|
|
1376
1376
|
let n = await S.createById(e);
|
|
1377
1377
|
if (!n) return;
|
|
1378
1378
|
let r = n.modelName ?? n.name;
|
|
1379
|
-
if (r) return
|
|
1379
|
+
if (r) return j(r, t, {
|
|
1380
1380
|
modelFileId: e,
|
|
1381
1381
|
schemaName: n.schemaName
|
|
1382
1382
|
});
|
|
1383
1383
|
};
|
|
1384
|
-
function
|
|
1384
|
+
function vn(...e) {
|
|
1385
1385
|
let [t, r, a] = e, l = Math.min(e.length, 3), d = o(() => l === 3 ? !!(t && r && a) : l === 2 ? !!(t && r) : !!t, [
|
|
1386
1386
|
l,
|
|
1387
1387
|
t,
|
|
@@ -1425,7 +1425,7 @@ function _n(...e) {
|
|
|
1425
1425
|
p(void 0), h(!1), _(null);
|
|
1426
1426
|
return;
|
|
1427
1427
|
}
|
|
1428
|
-
t = await
|
|
1428
|
+
t = await _n(b.modelFileId, b.propertyName);
|
|
1429
1429
|
let e = await S.createById(b.modelFileId);
|
|
1430
1430
|
n = e?.modelName ?? e?.name;
|
|
1431
1431
|
} else {
|
|
@@ -1433,8 +1433,8 @@ function _n(...e) {
|
|
|
1433
1433
|
p(void 0), h(!1), _(null);
|
|
1434
1434
|
return;
|
|
1435
1435
|
}
|
|
1436
|
-
let e = await
|
|
1437
|
-
t = e ? await
|
|
1436
|
+
let e = await fn(b.schemaId);
|
|
1437
|
+
t = e ? await j(b.modelName, b.propertyName, { schemaName: e }) : void 0, n = b.modelName;
|
|
1438
1438
|
}
|
|
1439
1439
|
if (t && n) {
|
|
1440
1440
|
let e = C.create({
|
|
@@ -1461,11 +1461,11 @@ function _n(...e) {
|
|
|
1461
1461
|
x ? w() : (p(void 0), h(!1), _(null));
|
|
1462
1462
|
}, [x, w]);
|
|
1463
1463
|
let T = n(() => void w({ quiet: !0 }), [w]);
|
|
1464
|
-
X(o(() => f ? [f] :
|
|
1464
|
+
X(o(() => f ? [f] : un, [f]), dn, T);
|
|
1465
1465
|
let E = s(!1);
|
|
1466
1466
|
E.current = m || !!f || !!g, i(() => {
|
|
1467
1467
|
if (!x || b.type === "propertyFileId") return;
|
|
1468
|
-
let e =
|
|
1468
|
+
let e = mn.map((e) => setTimeout(() => {
|
|
1469
1469
|
E.current || w({ quiet: !0 });
|
|
1470
1470
|
}, e));
|
|
1471
1471
|
return () => e.forEach((e) => clearTimeout(e));
|
|
@@ -1474,11 +1474,11 @@ function _n(...e) {
|
|
|
1474
1474
|
b.type,
|
|
1475
1475
|
w
|
|
1476
1476
|
]);
|
|
1477
|
-
let
|
|
1477
|
+
let ee = b.type === "propertyFileId";
|
|
1478
1478
|
return i(() => {
|
|
1479
|
-
if (!f || !
|
|
1479
|
+
if (!f || !ee) return;
|
|
1480
1480
|
v.current?.unsubscribe();
|
|
1481
|
-
let e =
|
|
1481
|
+
let e = ye(w, 100), t = f.getService().subscribe(() => {
|
|
1482
1482
|
e();
|
|
1483
1483
|
});
|
|
1484
1484
|
return v.current = t, () => {
|
|
@@ -1487,19 +1487,19 @@ function _n(...e) {
|
|
|
1487
1487
|
}, [
|
|
1488
1488
|
f,
|
|
1489
1489
|
w,
|
|
1490
|
-
|
|
1490
|
+
ee
|
|
1491
1491
|
]), {
|
|
1492
1492
|
modelProperty: f,
|
|
1493
1493
|
isLoading: m,
|
|
1494
1494
|
error: g
|
|
1495
1495
|
};
|
|
1496
1496
|
}
|
|
1497
|
-
var
|
|
1498
|
-
let { runAsync: e, isLoading: t, error: r, resetError: i } =
|
|
1497
|
+
var yn = () => {
|
|
1498
|
+
let { runAsync: e, isLoading: t, error: r, resetError: i } = Ut("Failed to create model property");
|
|
1499
1499
|
return {
|
|
1500
1500
|
create: n((t, n, r) => e(async () => {
|
|
1501
1501
|
if (!n || !r.name || !r.dataType) throw Error("modelName, property name and dataType are required");
|
|
1502
|
-
let e = await
|
|
1502
|
+
let e = await fn(t);
|
|
1503
1503
|
if (!e) throw Error(`No stored schema has the name or schema file id "${t}"`);
|
|
1504
1504
|
return C.create({
|
|
1505
1505
|
...r,
|
|
@@ -1513,7 +1513,7 @@ var vn = () => {
|
|
|
1513
1513
|
error: r,
|
|
1514
1514
|
resetError: i
|
|
1515
1515
|
};
|
|
1516
|
-
},
|
|
1516
|
+
}, bn = () => {
|
|
1517
1517
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1518
1518
|
return {
|
|
1519
1519
|
destroy: n(async (e) => {
|
|
@@ -1532,7 +1532,7 @@ var vn = () => {
|
|
|
1532
1532
|
error: r,
|
|
1533
1533
|
resetError: n(() => i(null), [])
|
|
1534
1534
|
};
|
|
1535
|
-
},
|
|
1535
|
+
}, xn = () => {
|
|
1536
1536
|
let [e, t] = c(!1), [r, i] = c(null);
|
|
1537
1537
|
return {
|
|
1538
1538
|
deleteItem: n(async (e) => {
|
|
@@ -1551,21 +1551,21 @@ var vn = () => {
|
|
|
1551
1551
|
error: r,
|
|
1552
1552
|
resetError: n(() => i(null), [])
|
|
1553
1553
|
};
|
|
1554
|
-
},
|
|
1555
|
-
function
|
|
1556
|
-
let e = Y(), t =
|
|
1557
|
-
queryKey:
|
|
1554
|
+
}, Sn = ["seed", "imageFiles"];
|
|
1555
|
+
function Cn() {
|
|
1556
|
+
let e = Y(), t = Xe(), { data: n = [], isLoading: r, error: a, refetch: o } = K({
|
|
1557
|
+
queryKey: Sn,
|
|
1558
1558
|
queryFn: () => p.listImageFiles(),
|
|
1559
1559
|
enabled: e
|
|
1560
1560
|
}, t);
|
|
1561
1561
|
return i(() => {
|
|
1562
1562
|
let e = (e) => {
|
|
1563
|
-
e.includes("/images/") && t.invalidateQueries({ queryKey:
|
|
1563
|
+
e.includes("/images/") && t.invalidateQueries({ queryKey: Sn });
|
|
1564
1564
|
}, n = (e) => {
|
|
1565
|
-
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey:
|
|
1565
|
+
e.some((e) => e.includes("/images/")) && t.invalidateQueries({ queryKey: Sn });
|
|
1566
1566
|
};
|
|
1567
|
-
return
|
|
1568
|
-
|
|
1567
|
+
return O.on("file-saved", e), O.on(_, n), () => {
|
|
1568
|
+
O.off("file-saved", e), O.off(_, n);
|
|
1569
1569
|
};
|
|
1570
1570
|
}, [t]), {
|
|
1571
1571
|
imageFiles: n,
|
|
@@ -1576,9 +1576,9 @@ function Sn() {
|
|
|
1576
1576
|
}
|
|
1577
1577
|
//#endregion
|
|
1578
1578
|
//#region src/useFiles.ts
|
|
1579
|
-
var
|
|
1580
|
-
function
|
|
1581
|
-
let t = Y(), n =
|
|
1579
|
+
var wn = ["seed", "files"];
|
|
1580
|
+
function Tn(e = "files") {
|
|
1581
|
+
let t = Y(), n = Xe(), r = o(() => [...wn, e], [e]), { data: a = [], isLoading: s, error: c, refetch: l } = K({
|
|
1582
1582
|
queryKey: r,
|
|
1583
1583
|
queryFn: () => p.listFiles(e),
|
|
1584
1584
|
enabled: t
|
|
@@ -1589,8 +1589,8 @@ function wn(e = "files") {
|
|
|
1589
1589
|
}, i = (t) => {
|
|
1590
1590
|
t.some((t) => t.includes(`/${e}/`)) && n.invalidateQueries({ queryKey: r });
|
|
1591
1591
|
};
|
|
1592
|
-
return
|
|
1593
|
-
|
|
1592
|
+
return O.on("file-saved", t), O.on(_, i), () => {
|
|
1593
|
+
O.off("file-saved", t), O.off(_, i);
|
|
1594
1594
|
};
|
|
1595
1595
|
}, [
|
|
1596
1596
|
n,
|
|
@@ -1605,28 +1605,28 @@ function wn(e = "files") {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
//#endregion
|
|
1607
1607
|
//#region src/useEasSyncProcesses.ts
|
|
1608
|
-
function Tn() {
|
|
1609
|
-
return Y() ? f.getAppDb() : null;
|
|
1610
|
-
}
|
|
1611
1608
|
function En() {
|
|
1612
|
-
|
|
1613
|
-
return o(() => e ? e.select().from(O).orderBy(we(O.startedAt)) : null, [e]);
|
|
1609
|
+
return Y() ? f.getAppDb() : null;
|
|
1614
1610
|
}
|
|
1615
1611
|
function Dn() {
|
|
1616
|
-
let e =
|
|
1612
|
+
let e = En();
|
|
1613
|
+
return o(() => e ? e.select().from(D).orderBy(Te(D.startedAt)) : null, [e]);
|
|
1614
|
+
}
|
|
1615
|
+
function On() {
|
|
1616
|
+
let e = Z(Dn());
|
|
1617
1617
|
return {
|
|
1618
1618
|
records: e,
|
|
1619
1619
|
nonActiveCount: o(() => e === void 0 ? void 0 : e.filter((e) => e.status !== "in_progress").length, [e])
|
|
1620
1620
|
};
|
|
1621
1621
|
}
|
|
1622
|
-
function On() {
|
|
1623
|
-
return Z(En());
|
|
1624
|
-
}
|
|
1625
1622
|
function kn() {
|
|
1626
|
-
return Dn()
|
|
1623
|
+
return Z(Dn());
|
|
1624
|
+
}
|
|
1625
|
+
function An() {
|
|
1626
|
+
return On().nonActiveCount;
|
|
1627
1627
|
}
|
|
1628
|
-
function
|
|
1629
|
-
let t =
|
|
1628
|
+
function jn(e) {
|
|
1629
|
+
let t = En(), n = Z(o(() => e != null && t ? t.select().from(D).where(q(D.id, e)).limit(1) : null, [t, e])), r = e != null && (t == null || n === void 0);
|
|
1630
1630
|
return {
|
|
1631
1631
|
record: n && n.length > 0 ? n[0] : null,
|
|
1632
1632
|
isLoading: r
|
|
@@ -1634,37 +1634,51 @@ function An(e) {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
//#endregion
|
|
1636
1636
|
//#region src/useAddressesProp.ts
|
|
1637
|
-
function
|
|
1637
|
+
function Mn(e) {
|
|
1638
|
+
let { owned: t, watched: n } = ue(e);
|
|
1639
|
+
return t.length > 0 || n.length > 0;
|
|
1640
|
+
}
|
|
1641
|
+
async function Nn(e) {
|
|
1642
|
+
let t = ue(e), n = ue(await E.getAddresses()), r = (e, t) => e.length === t.length && [...e].sort().join() === [...t].sort().join();
|
|
1643
|
+
return r(t.owned, n.owned) && r(t.watched, n.watched);
|
|
1644
|
+
}
|
|
1645
|
+
function Pn(e, t, n) {
|
|
1638
1646
|
let r = s(e);
|
|
1639
1647
|
r.current = e;
|
|
1640
|
-
let a = JSON.stringify(e ?? null), o = s(a), c = s(Promise.resolve())
|
|
1641
|
-
|
|
1642
|
-
if (a === o.current) return;
|
|
1643
|
-
o.current = a;
|
|
1644
|
-
let e = r.current;
|
|
1645
|
-
e !== void 0 && (c.current = c.current.then(async () => {
|
|
1648
|
+
let a = JSON.stringify(e ?? null), o = s(a), c = s(Promise.resolve()), l = s((e, r) => {
|
|
1649
|
+
c.current = c.current.then(async () => {
|
|
1646
1650
|
try {
|
|
1647
1651
|
await t.current;
|
|
1648
1652
|
} catch {
|
|
1649
1653
|
return;
|
|
1650
1654
|
}
|
|
1651
1655
|
try {
|
|
1656
|
+
if (r && await Nn(e)) return;
|
|
1652
1657
|
await E.setAddresses(e);
|
|
1653
1658
|
} catch (e) {
|
|
1654
1659
|
console.error(`[${n}] setAddresses failed`, e);
|
|
1655
1660
|
}
|
|
1656
|
-
})
|
|
1661
|
+
});
|
|
1662
|
+
});
|
|
1663
|
+
i(() => {
|
|
1664
|
+
let e = r.current;
|
|
1665
|
+
e !== void 0 && Mn(e) && l.current(e, !0);
|
|
1666
|
+
}, []), i(() => {
|
|
1667
|
+
if (a === o.current) return;
|
|
1668
|
+
o.current = a;
|
|
1669
|
+
let e = r.current;
|
|
1670
|
+
e !== void 0 && l.current(e, !1);
|
|
1657
1671
|
}, [a]);
|
|
1658
1672
|
}
|
|
1659
1673
|
//#endregion
|
|
1660
1674
|
//#region src/SeedProvider.tsx
|
|
1661
|
-
var
|
|
1662
|
-
function
|
|
1663
|
-
return Promise.resolve(
|
|
1675
|
+
var Fn = null;
|
|
1676
|
+
function In(e) {
|
|
1677
|
+
return Promise.resolve(Fn?.(e));
|
|
1664
1678
|
}
|
|
1665
|
-
function
|
|
1679
|
+
function Ln({ queryClient: e }) {
|
|
1666
1680
|
return i(() => {
|
|
1667
|
-
|
|
1681
|
+
Fn = (t) => e.invalidateQueries({ queryKey: [
|
|
1668
1682
|
"seed",
|
|
1669
1683
|
"itemProperties",
|
|
1670
1684
|
t
|
|
@@ -1675,12 +1689,12 @@ function Pn({ queryClient: e }) {
|
|
|
1675
1689
|
exact: !1
|
|
1676
1690
|
});
|
|
1677
1691
|
};
|
|
1678
|
-
return
|
|
1679
|
-
|
|
1692
|
+
return O.on(g, t), () => {
|
|
1693
|
+
O.off(g, t), Fn = null;
|
|
1680
1694
|
};
|
|
1681
1695
|
}, [e]), null;
|
|
1682
1696
|
}
|
|
1683
|
-
function
|
|
1697
|
+
function Rn({ config: e, addresses: t, onInitError: n }) {
|
|
1684
1698
|
let r = s(n);
|
|
1685
1699
|
r.current = n;
|
|
1686
1700
|
let a = s(t);
|
|
@@ -1694,10 +1708,10 @@ function Fn({ config: e, addresses: t, onInitError: n }) {
|
|
|
1694
1708
|
o.current = E.init(t), o.current.catch((e) => {
|
|
1695
1709
|
r.current ? r.current(e) : console.error("[SeedProvider] client init failed", e);
|
|
1696
1710
|
});
|
|
1697
|
-
}, [e]),
|
|
1711
|
+
}, [e]), Pn(t, o, "SeedProvider"), null;
|
|
1698
1712
|
}
|
|
1699
|
-
function
|
|
1700
|
-
let s = o(() => i ??
|
|
1713
|
+
function zn({ children: e, config: t, addresses: n, onInitError: r, queryClient: i, queryClientRef: a }) {
|
|
1714
|
+
let s = o(() => i ?? Ke(), [i]);
|
|
1701
1715
|
if (a && (a.current = s, typeof window < "u")) {
|
|
1702
1716
|
let e = window;
|
|
1703
1717
|
e.__TEST_SEED_QUERY_CLIENT__ = s;
|
|
@@ -1705,13 +1719,13 @@ function In({ children: e, config: t, addresses: n, onInitError: r, queryClient:
|
|
|
1705
1719
|
window.parent && window.parent !== window && (window.parent.__TEST_SEED_QUERY_CLIENT__ = s);
|
|
1706
1720
|
} catch {}
|
|
1707
1721
|
}
|
|
1708
|
-
return /* @__PURE__ */ U(
|
|
1722
|
+
return /* @__PURE__ */ U(G, {
|
|
1709
1723
|
client: s,
|
|
1710
|
-
children: /* @__PURE__ */ W(
|
|
1724
|
+
children: /* @__PURE__ */ W(Re, {
|
|
1711
1725
|
queryClient: s,
|
|
1712
1726
|
children: [
|
|
1713
|
-
/* @__PURE__ */ U(
|
|
1714
|
-
t && /* @__PURE__ */ U(
|
|
1727
|
+
/* @__PURE__ */ U(Ln, { queryClient: s }),
|
|
1728
|
+
t && /* @__PURE__ */ U(Rn, {
|
|
1715
1729
|
config: t,
|
|
1716
1730
|
addresses: n,
|
|
1717
1731
|
onInitError: r
|
|
@@ -1723,7 +1737,7 @@ function In({ children: e, config: t, addresses: n, onInitError: r, queryClient:
|
|
|
1723
1737
|
}
|
|
1724
1738
|
//#endregion
|
|
1725
1739
|
//#region src/SeedClientGate.tsx
|
|
1726
|
-
function
|
|
1740
|
+
function Bn() {
|
|
1727
1741
|
return /* @__PURE__ */ U("div", {
|
|
1728
1742
|
style: {
|
|
1729
1743
|
display: "flex",
|
|
@@ -1735,24 +1749,24 @@ function Ln() {
|
|
|
1735
1749
|
children: "Loading..."
|
|
1736
1750
|
});
|
|
1737
1751
|
}
|
|
1738
|
-
function
|
|
1752
|
+
function Vn(e) {
|
|
1739
1753
|
try {
|
|
1740
1754
|
return JSON.stringify(e ?? null);
|
|
1741
1755
|
} catch {
|
|
1742
1756
|
return e;
|
|
1743
1757
|
}
|
|
1744
1758
|
}
|
|
1745
|
-
function
|
|
1759
|
+
function Hn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r, loadingClassName: a, onInitError: o, children: c }) {
|
|
1746
1760
|
let l = Y(), u = s(o);
|
|
1747
1761
|
u.current = o;
|
|
1748
1762
|
let d = s(e);
|
|
1749
1763
|
d.current = e;
|
|
1750
1764
|
let f = s(t);
|
|
1751
1765
|
f.current = t;
|
|
1752
|
-
let p = s(void 0), m =
|
|
1766
|
+
let p = s(void 0), m = Vn({
|
|
1753
1767
|
...e,
|
|
1754
1768
|
addresses: void 0
|
|
1755
|
-
}), h =
|
|
1769
|
+
}), h = Vn(t);
|
|
1756
1770
|
i(() => {
|
|
1757
1771
|
let e = d.current, t = f.current, n = t ? {
|
|
1758
1772
|
...e,
|
|
@@ -1764,8 +1778,8 @@ function zn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1764
1778
|
p.current = E.init(n), p.current.catch((e) => {
|
|
1765
1779
|
u.current ? u.current(e) : console.error("[SeedClientGate] client init failed", e);
|
|
1766
1780
|
});
|
|
1767
|
-
}, [m, h]),
|
|
1768
|
-
let g = n ?? /* @__PURE__ */ U(
|
|
1781
|
+
}, [m, h]), Pn(e.addresses, p, "SeedClientGate");
|
|
1782
|
+
let g = n ?? /* @__PURE__ */ U(Bn, {}), _ = r ? void 0 : {
|
|
1769
1783
|
position: "relative",
|
|
1770
1784
|
display: "flex",
|
|
1771
1785
|
height: "100vh",
|
|
@@ -1800,54 +1814,54 @@ function zn({ initConfig: e, schema: t, loadingComponent: n, wrapperClassName: r
|
|
|
1800
1814
|
}
|
|
1801
1815
|
//#endregion
|
|
1802
1816
|
//#region src/opfsPaths.ts
|
|
1803
|
-
function
|
|
1817
|
+
function Un(e) {
|
|
1804
1818
|
let t = e.split("/").filter(Boolean);
|
|
1805
1819
|
if (t.length === 0) throw Error(`Invalid OPFS path: "${e}"`);
|
|
1806
1820
|
return t;
|
|
1807
1821
|
}
|
|
1808
|
-
async function
|
|
1822
|
+
async function Wn(e, t) {
|
|
1809
1823
|
let n = t ?? await navigator.storage.getDirectory();
|
|
1810
1824
|
for (let t of e.split("/").filter(Boolean)) n = await n.getDirectoryHandle(t);
|
|
1811
1825
|
return n;
|
|
1812
1826
|
}
|
|
1813
|
-
async function
|
|
1814
|
-
let n =
|
|
1827
|
+
async function Gn(e, t) {
|
|
1828
|
+
let n = Un(e), r = n.pop();
|
|
1815
1829
|
return {
|
|
1816
|
-
dir: await
|
|
1830
|
+
dir: await Wn(n.join("/"), t),
|
|
1817
1831
|
name: r
|
|
1818
1832
|
};
|
|
1819
1833
|
}
|
|
1820
|
-
async function
|
|
1821
|
-
let { dir: n, name: r } = await
|
|
1834
|
+
async function Kn(e, t) {
|
|
1835
|
+
let { dir: n, name: r } = await Gn(e, t);
|
|
1822
1836
|
return n.getFileHandle(r);
|
|
1823
1837
|
}
|
|
1824
|
-
async function
|
|
1825
|
-
return (await
|
|
1838
|
+
async function qn(e, t) {
|
|
1839
|
+
return (await Kn(e, t)).getFile();
|
|
1826
1840
|
}
|
|
1827
|
-
async function
|
|
1828
|
-
let { dir: n, name: r } = await
|
|
1841
|
+
async function Jn(e, t) {
|
|
1842
|
+
let { dir: n, name: r } = await Gn(e, t);
|
|
1829
1843
|
await n.removeEntry(r);
|
|
1830
1844
|
}
|
|
1831
|
-
async function
|
|
1845
|
+
async function Yn(e, t) {
|
|
1832
1846
|
let n = await e.getDirectoryHandle(t), r = [];
|
|
1833
1847
|
for await (let e of n.entries()) r.push(e);
|
|
1834
1848
|
let i = !0;
|
|
1835
|
-
for (let [e, t] of r) (t.kind === "file" || !await
|
|
1849
|
+
for (let [e, t] of r) (t.kind === "file" || !await Yn(n, e)) && (i = !1);
|
|
1836
1850
|
return i && await e.removeEntry(t), i;
|
|
1837
1851
|
}
|
|
1838
|
-
async function
|
|
1852
|
+
async function Xn(e, t) {
|
|
1839
1853
|
try {
|
|
1840
|
-
let { dir: n, name: r } = await
|
|
1841
|
-
return await
|
|
1854
|
+
let { dir: n, name: r } = await Gn(e, t);
|
|
1855
|
+
return await Yn(n, r);
|
|
1842
1856
|
} catch (e) {
|
|
1843
1857
|
if (e instanceof DOMException && e.name === "NotFoundError") return !0;
|
|
1844
1858
|
throw e;
|
|
1845
1859
|
}
|
|
1846
1860
|
}
|
|
1847
|
-
function
|
|
1861
|
+
function Zn() {
|
|
1848
1862
|
return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
|
|
1849
1863
|
}
|
|
1850
|
-
var
|
|
1864
|
+
var Qn = [
|
|
1851
1865
|
{
|
|
1852
1866
|
type: "image/jpeg",
|
|
1853
1867
|
test: (e) => e[0] === 255 && e[1] === 216 && e[2] === 255
|
|
@@ -1858,43 +1872,43 @@ var Yn = [
|
|
|
1858
1872
|
},
|
|
1859
1873
|
{
|
|
1860
1874
|
type: "image/gif",
|
|
1861
|
-
test: (e) =>
|
|
1875
|
+
test: (e) => $n(e, 0, 4) === "GIF8"
|
|
1862
1876
|
},
|
|
1863
1877
|
{
|
|
1864
1878
|
type: "image/webp",
|
|
1865
|
-
test: (e) =>
|
|
1879
|
+
test: (e) => $n(e, 0, 4) === "RIFF" && $n(e, 8, 12) === "WEBP"
|
|
1866
1880
|
},
|
|
1867
1881
|
{
|
|
1868
1882
|
type: "image/avif",
|
|
1869
|
-
test: (e) =>
|
|
1883
|
+
test: (e) => $n(e, 4, 8) === "ftyp" && ["avif", "avis"].includes($n(e, 8, 12))
|
|
1870
1884
|
},
|
|
1871
1885
|
{
|
|
1872
1886
|
type: "application/vnd.sqlite3",
|
|
1873
|
-
test: (e) =>
|
|
1887
|
+
test: (e) => $n(e, 0, 15) === "SQLite format 3"
|
|
1874
1888
|
},
|
|
1875
1889
|
{
|
|
1876
1890
|
type: "application/pdf",
|
|
1877
|
-
test: (e) =>
|
|
1891
|
+
test: (e) => $n(e, 0, 5) === "%PDF-"
|
|
1878
1892
|
}
|
|
1879
1893
|
];
|
|
1880
|
-
function
|
|
1894
|
+
function $n(e, t, n) {
|
|
1881
1895
|
return String.fromCharCode(...e.subarray(t, n));
|
|
1882
1896
|
}
|
|
1883
|
-
function
|
|
1884
|
-
return
|
|
1897
|
+
function er(e) {
|
|
1898
|
+
return Qn.find((t) => t.test(e))?.type;
|
|
1885
1899
|
}
|
|
1886
|
-
async function
|
|
1887
|
-
if (e.size !== 0) return
|
|
1900
|
+
async function tr(e) {
|
|
1901
|
+
if (e.size !== 0) return er(new Uint8Array(await e.slice(0, 16).arrayBuffer()));
|
|
1888
1902
|
}
|
|
1889
1903
|
//#endregion
|
|
1890
1904
|
//#region src/useOPFSFiles.ts
|
|
1891
|
-
async function
|
|
1905
|
+
async function nr(e, t = "") {
|
|
1892
1906
|
let n = [];
|
|
1893
1907
|
try {
|
|
1894
1908
|
for await (let [r, i] of e.entries()) {
|
|
1895
1909
|
let e = t ? `${t}/${r}` : r;
|
|
1896
1910
|
if (i.kind === "file") try {
|
|
1897
|
-
let t = await i.getFile(), a = t.type ? void 0 : await
|
|
1911
|
+
let t = await i.getFile(), a = t.type ? void 0 : await tr(t).catch(() => void 0);
|
|
1898
1912
|
n.push({
|
|
1899
1913
|
name: r,
|
|
1900
1914
|
path: e,
|
|
@@ -1907,7 +1921,7 @@ async function $n(e, t = "") {
|
|
|
1907
1921
|
console.warn(`Failed to read file ${e}:`, t);
|
|
1908
1922
|
}
|
|
1909
1923
|
else if (i.kind === "directory") {
|
|
1910
|
-
let t = await
|
|
1924
|
+
let t = await nr(i, e);
|
|
1911
1925
|
n.push(...t);
|
|
1912
1926
|
}
|
|
1913
1927
|
}
|
|
@@ -1916,11 +1930,11 @@ async function $n(e, t = "") {
|
|
|
1916
1930
|
}
|
|
1917
1931
|
return n;
|
|
1918
1932
|
}
|
|
1919
|
-
function
|
|
1933
|
+
function rr(e = {}) {
|
|
1920
1934
|
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 () => {
|
|
1921
1935
|
s(!0), f(null), m(null);
|
|
1922
1936
|
try {
|
|
1923
|
-
let e = await
|
|
1937
|
+
let e = await nr(await Wn(t ?? ""), t || "");
|
|
1924
1938
|
a(e.sort((e, t) => e.path.localeCompare(t.path)));
|
|
1925
1939
|
} catch (e) {
|
|
1926
1940
|
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);
|
|
@@ -1941,7 +1955,7 @@ function er(e = {}) {
|
|
|
1941
1955
|
}
|
|
1942
1956
|
//#endregion
|
|
1943
1957
|
//#region src/OPFSFilesManager/format.ts
|
|
1944
|
-
var
|
|
1958
|
+
var ir = [
|
|
1945
1959
|
"B",
|
|
1946
1960
|
"KB",
|
|
1947
1961
|
"MB",
|
|
@@ -1950,32 +1964,32 @@ var tr = [
|
|
|
1950
1964
|
];
|
|
1951
1965
|
function Q(e) {
|
|
1952
1966
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
1953
|
-
let t = Math.min(
|
|
1954
|
-
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${
|
|
1967
|
+
let t = Math.min(ir.length - 1, Math.floor(Math.log(e) / Math.log(1024))), n = e / 1024 ** t;
|
|
1968
|
+
return `${t === 0 ? n : n < 10 ? Math.round(n * 10) / 10 : Math.round(n)} ${ir[t]}`;
|
|
1955
1969
|
}
|
|
1956
|
-
var
|
|
1957
|
-
function
|
|
1970
|
+
var ar = 6e4, or = 60 * ar, sr = 24 * or;
|
|
1971
|
+
function cr(e, t = Date.now()) {
|
|
1958
1972
|
let n = t - e;
|
|
1959
|
-
if (n <
|
|
1960
|
-
if (n <
|
|
1961
|
-
if (n <
|
|
1962
|
-
let r = Math.round(n /
|
|
1973
|
+
if (n < ar) return "just now";
|
|
1974
|
+
if (n < or) return `${Math.round(n / ar)} min ago`;
|
|
1975
|
+
if (n < sr) return `${Math.round(n / or)} h ago`;
|
|
1976
|
+
let r = Math.round(n / sr);
|
|
1963
1977
|
return r === 1 ? "yesterday" : r < 30 ? `${r} days ago` : new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" });
|
|
1964
1978
|
}
|
|
1965
|
-
function
|
|
1979
|
+
function lr(e) {
|
|
1966
1980
|
return new Date(e).toLocaleString(void 0, {
|
|
1967
1981
|
dateStyle: "medium",
|
|
1968
1982
|
timeStyle: "short"
|
|
1969
1983
|
});
|
|
1970
1984
|
}
|
|
1971
|
-
function
|
|
1985
|
+
function ur(e, t) {
|
|
1972
1986
|
if (e.length <= t) return e;
|
|
1973
1987
|
let n = Math.ceil((t - 1) / 2), r = Math.floor((t - 1) / 2);
|
|
1974
1988
|
return `${e.slice(0, n)}…${e.slice(e.length - r)}`;
|
|
1975
1989
|
}
|
|
1976
1990
|
//#endregion
|
|
1977
1991
|
//#region src/OPFSFilesManager/icons.tsx
|
|
1978
|
-
var
|
|
1992
|
+
var dr = {
|
|
1979
1993
|
check: /* @__PURE__ */ U("path", { d: "M20 6 9 17l-5-5" }),
|
|
1980
1994
|
chevronLeft: /* @__PURE__ */ U("path", { d: "m15 18-6-6 6-6" }),
|
|
1981
1995
|
chevronRight: /* @__PURE__ */ U("path", { d: "m9 18 6-6-6-6" }),
|
|
@@ -2160,13 +2174,13 @@ function $({ name: e, size: t = 16, strokeWidth: n = 2, className: r }) {
|
|
|
2160
2174
|
"aria-hidden": "true",
|
|
2161
2175
|
focusable: "false",
|
|
2162
2176
|
className: r,
|
|
2163
|
-
children:
|
|
2177
|
+
children: dr[e]
|
|
2164
2178
|
});
|
|
2165
2179
|
}
|
|
2166
2180
|
//#endregion
|
|
2167
2181
|
//#region src/OPFSFilesManager/DeleteDialog.tsx
|
|
2168
|
-
var
|
|
2169
|
-
function
|
|
2182
|
+
var fr = 6;
|
|
2183
|
+
function pr({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
2170
2184
|
let a = s(null);
|
|
2171
2185
|
return i(() => {
|
|
2172
2186
|
let e = a.current;
|
|
@@ -2192,9 +2206,9 @@ function ur({ className: e, onCancel: t, onSubmit: n, children: r }) {
|
|
|
2192
2206
|
})
|
|
2193
2207
|
});
|
|
2194
2208
|
}
|
|
2195
|
-
function
|
|
2196
|
-
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 ${
|
|
2197
|
-
return /* @__PURE__ */ W(
|
|
2209
|
+
function mr({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel: i, onConfirm: a, className: o }) {
|
|
2210
|
+
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 ${ur(e[0].file.name, 32)}?` : `Delete ${e.length} files?`;
|
|
2211
|
+
return /* @__PURE__ */ W(pr, {
|
|
2198
2212
|
className: o,
|
|
2199
2213
|
onCancel: i,
|
|
2200
2214
|
onSubmit: () => a(s),
|
|
@@ -2208,12 +2222,12 @@ function dr({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
2208
2222
|
e.length === 1 ? "it" : "them",
|
|
2209
2223
|
" from this browser’s private storage. Copies on Arweave or other devices aren’t affected. You can’t undo this."
|
|
2210
2224
|
] }),
|
|
2211
|
-
/* @__PURE__ */ W("ul", { children: [e.slice(0,
|
|
2225
|
+
/* @__PURE__ */ W("ul", { children: [e.slice(0, fr).map((e) => /* @__PURE__ */ W("li", { children: [/* @__PURE__ */ U("code", {
|
|
2212
2226
|
title: e.file.path,
|
|
2213
2227
|
children: e.file.path.startsWith(p) ? e.file.path.slice(p.length) : e.file.path
|
|
2214
|
-
}), /* @__PURE__ */ U("span", { children: Q(e.file.size) })] }, e.file.path)), e.length >
|
|
2228
|
+
}), /* @__PURE__ */ U("span", { children: Q(e.file.size) })] }, e.file.path)), e.length > fr && /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W("span", { children: [
|
|
2215
2229
|
"and ",
|
|
2216
|
-
e.length -
|
|
2230
|
+
e.length - fr,
|
|
2217
2231
|
" more"
|
|
2218
2232
|
] }) })] }),
|
|
2219
2233
|
u.length > 0 && /* @__PURE__ */ W("label", { children: [
|
|
@@ -2256,16 +2270,16 @@ function dr({ entries: e, rootPath: t, warning: n, deleteActionFor: r, onCancel:
|
|
|
2256
2270
|
]
|
|
2257
2271
|
});
|
|
2258
2272
|
}
|
|
2259
|
-
function
|
|
2273
|
+
function hr({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy: a, onDownload: o, onCancel: s, onConfirm: l, className: u }) {
|
|
2260
2274
|
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;
|
|
2261
|
-
return /* @__PURE__ */ W(
|
|
2275
|
+
return /* @__PURE__ */ W(pr, {
|
|
2262
2276
|
className: u,
|
|
2263
2277
|
onCancel: s,
|
|
2264
2278
|
onSubmit: l,
|
|
2265
2279
|
children: [
|
|
2266
2280
|
/* @__PURE__ */ U("h3", {
|
|
2267
2281
|
id: "seed-fm-delete-title",
|
|
2268
|
-
children: i.label ? `${i.label}?` : `Delete the “${
|
|
2282
|
+
children: i.label ? `${i.label}?` : `Delete the “${ur(e.name, 32)}” folder?`
|
|
2269
2283
|
}),
|
|
2270
2284
|
/* @__PURE__ */ W("p", { children: [
|
|
2271
2285
|
"This removes the folder and the ",
|
|
@@ -2282,12 +2296,12 @@ function fr({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2282
2296
|
size: 16
|
|
2283
2297
|
}), /* @__PURE__ */ W("span", { children: [/* @__PURE__ */ U("strong", { children: "This can’t be undone." }), " Once deleted, these files can’t be recovered from this browser."] })]
|
|
2284
2298
|
}),
|
|
2285
|
-
/* @__PURE__ */ W("ul", { children: [t.slice(0,
|
|
2299
|
+
/* @__PURE__ */ W("ul", { children: [t.slice(0, fr).map((e) => /* @__PURE__ */ W("li", { children: [/* @__PURE__ */ U("code", {
|
|
2286
2300
|
title: e.path,
|
|
2287
2301
|
children: e.path.slice(m.length)
|
|
2288
|
-
}), /* @__PURE__ */ U("span", { children: Q(e.size) })] }, e.path)), t.length >
|
|
2302
|
+
}), /* @__PURE__ */ U("span", { children: Q(e.size) })] }, e.path)), t.length > fr && /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W("span", { children: [
|
|
2289
2303
|
"and ",
|
|
2290
|
-
t.length -
|
|
2304
|
+
t.length - fr,
|
|
2291
2305
|
" more"
|
|
2292
2306
|
] }) })] }),
|
|
2293
2307
|
/* @__PURE__ */ W("div", {
|
|
@@ -2346,42 +2360,42 @@ function fr({ folder: e, files: t, hiddenCount: n, warning: r, action: i, busy:
|
|
|
2346
2360
|
}
|
|
2347
2361
|
//#endregion
|
|
2348
2362
|
//#region src/OPFSFilesManager/fileModel.ts
|
|
2349
|
-
function
|
|
2363
|
+
function gr(e) {
|
|
2350
2364
|
return e.detectedType ?? e.type;
|
|
2351
2365
|
}
|
|
2352
|
-
var
|
|
2353
|
-
function
|
|
2354
|
-
let t =
|
|
2355
|
-
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" ||
|
|
2366
|
+
var _r = /\.(db|sqlite|sqlite3)(-journal|-wal|-shm)?$/i;
|
|
2367
|
+
function vr(e) {
|
|
2368
|
+
let t = gr(e);
|
|
2369
|
+
return t.startsWith("image/") ? "image" : t === "application/vnd.sqlite3" || _r.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";
|
|
2356
2370
|
}
|
|
2357
|
-
function
|
|
2371
|
+
function yr(e) {
|
|
2358
2372
|
let t = /\.([a-z0-9-]{1,12})$/i.exec(e.name)?.[1];
|
|
2359
2373
|
if (t) return t.toLowerCase();
|
|
2360
|
-
let n =
|
|
2374
|
+
let n = gr(e);
|
|
2361
2375
|
return n === "application/octet-stream" ? "bin" : n.split("/")[1]?.replace(/^vnd\./, "") ?? "bin";
|
|
2362
2376
|
}
|
|
2363
|
-
var
|
|
2364
|
-
function
|
|
2365
|
-
let t =
|
|
2377
|
+
var br = /^(.*\/)?images\/(\d+)\/([^/]+)\.webp$/, xr = /^(.*\/)?images\/([^/]+)$/, Sr = (e) => e.replace(/\.[^/.]+$/, "");
|
|
2378
|
+
function Cr(e) {
|
|
2379
|
+
let t = br.exec(e);
|
|
2366
2380
|
return t ? {
|
|
2367
2381
|
key: `${t[1] ?? ""}images/${t[3]}`,
|
|
2368
2382
|
width: Number(t[2])
|
|
2369
2383
|
} : null;
|
|
2370
2384
|
}
|
|
2371
|
-
function
|
|
2372
|
-
let t =
|
|
2373
|
-
return t ? `${t[1] ?? ""}images/${
|
|
2385
|
+
function wr(e) {
|
|
2386
|
+
let t = xr.exec(e);
|
|
2387
|
+
return t ? `${t[1] ?? ""}images/${Sr(t[2])}` : null;
|
|
2374
2388
|
}
|
|
2375
|
-
var
|
|
2389
|
+
var Tr = (e) => ({
|
|
2376
2390
|
file: e,
|
|
2377
2391
|
variants: [],
|
|
2378
2392
|
totalSize: e.size
|
|
2379
2393
|
});
|
|
2380
|
-
function
|
|
2381
|
-
if (!t) return e.map(
|
|
2394
|
+
function Er(e, t) {
|
|
2395
|
+
if (!t) return e.map(Tr);
|
|
2382
2396
|
let n = /* @__PURE__ */ new Map(), r = [], i = [];
|
|
2383
2397
|
for (let t of e) {
|
|
2384
|
-
let e =
|
|
2398
|
+
let e = Cr(t.path);
|
|
2385
2399
|
if (e) {
|
|
2386
2400
|
i.push({
|
|
2387
2401
|
file: t,
|
|
@@ -2389,27 +2403,27 @@ function Cr(e, t) {
|
|
|
2389
2403
|
});
|
|
2390
2404
|
continue;
|
|
2391
2405
|
}
|
|
2392
|
-
let a =
|
|
2406
|
+
let a = Tr(t);
|
|
2393
2407
|
r.push(a);
|
|
2394
|
-
let o =
|
|
2395
|
-
o &&
|
|
2408
|
+
let o = wr(t.path);
|
|
2409
|
+
o && vr(t) === "image" && n.set(o, a);
|
|
2396
2410
|
}
|
|
2397
2411
|
for (let e of i) {
|
|
2398
2412
|
let t = n.get(e.key);
|
|
2399
2413
|
t ? (t.variants.push({
|
|
2400
2414
|
file: e.file,
|
|
2401
2415
|
width: e.width
|
|
2402
|
-
}), t.totalSize += e.file.size) : r.push(
|
|
2416
|
+
}), t.totalSize += e.file.size) : r.push(Tr(e.file));
|
|
2403
2417
|
}
|
|
2404
2418
|
for (let e of n.values()) e.variants.sort((e, t) => e.width - t.width);
|
|
2405
2419
|
return r;
|
|
2406
2420
|
}
|
|
2407
|
-
var
|
|
2408
|
-
function
|
|
2421
|
+
var Dr = (e, t) => e ? `${e}/${t}` : t;
|
|
2422
|
+
function Or(e, t, n = {}) {
|
|
2409
2423
|
let r = t ? `${t}/` : "", i = e.filter((e) => e.file.path.startsWith(r)), a = n.query?.trim().toLowerCase();
|
|
2410
2424
|
if (a) return {
|
|
2411
2425
|
folders: [],
|
|
2412
|
-
entries:
|
|
2426
|
+
entries: kr(i.filter((e) => e.file.path.slice(r.length).toLowerCase().includes(a)), n.sort)
|
|
2413
2427
|
};
|
|
2414
2428
|
let o = /* @__PURE__ */ new Map(), s = [];
|
|
2415
2429
|
for (let e of i) {
|
|
@@ -2420,7 +2434,7 @@ function Tr(e, t, n = {}) {
|
|
|
2420
2434
|
}
|
|
2421
2435
|
let a = n.slice(0, i), c = o.get(a) ?? {
|
|
2422
2436
|
name: a,
|
|
2423
|
-
path:
|
|
2437
|
+
path: Dr(t, a),
|
|
2424
2438
|
fileCount: 0,
|
|
2425
2439
|
size: 0
|
|
2426
2440
|
};
|
|
@@ -2428,10 +2442,10 @@ function Tr(e, t, n = {}) {
|
|
|
2428
2442
|
}
|
|
2429
2443
|
return {
|
|
2430
2444
|
folders: [...o.values()].sort((e, t) => e.name.localeCompare(t.name)),
|
|
2431
|
-
entries:
|
|
2445
|
+
entries: kr(s, n.sort)
|
|
2432
2446
|
};
|
|
2433
2447
|
}
|
|
2434
|
-
function
|
|
2448
|
+
function kr(e, t = "name") {
|
|
2435
2449
|
let n = {
|
|
2436
2450
|
name: (e, t) => e.file.name.localeCompare(t.file.name),
|
|
2437
2451
|
modified: (e, t) => t.file.lastModified - e.file.lastModified,
|
|
@@ -2439,7 +2453,7 @@ function Er(e, t = "name") {
|
|
|
2439
2453
|
};
|
|
2440
2454
|
return [...e].sort(n[t]);
|
|
2441
2455
|
}
|
|
2442
|
-
function
|
|
2456
|
+
function Ar(e) {
|
|
2443
2457
|
let t = {
|
|
2444
2458
|
image: 0,
|
|
2445
2459
|
database: 0,
|
|
@@ -2448,34 +2462,34 @@ function Dr(e) {
|
|
|
2448
2462
|
text: 0,
|
|
2449
2463
|
other: 0
|
|
2450
2464
|
};
|
|
2451
|
-
for (let n of e) t[
|
|
2465
|
+
for (let n of e) t[vr(n)] += n.size;
|
|
2452
2466
|
return t;
|
|
2453
2467
|
}
|
|
2454
|
-
function
|
|
2468
|
+
function jr(e) {
|
|
2455
2469
|
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;
|
|
2456
2470
|
}
|
|
2457
2471
|
//#endregion
|
|
2458
2472
|
//#region src/OPFSFilesManager/useThumbnail.ts
|
|
2459
|
-
var
|
|
2460
|
-
function
|
|
2473
|
+
var Mr = 400, Nr = 262144, Pr = 4, Fr = 3e4, Ir = 0, Lr = [];
|
|
2474
|
+
function Rr(e) {
|
|
2461
2475
|
return new Promise((t, n) => {
|
|
2462
2476
|
let r = () => {
|
|
2463
|
-
|
|
2464
|
-
|
|
2477
|
+
Ir++, e().then(t, n).finally(() => {
|
|
2478
|
+
Ir--, Lr.shift()?.();
|
|
2465
2479
|
});
|
|
2466
2480
|
};
|
|
2467
|
-
|
|
2481
|
+
Ir < Pr ? r() : Lr.push(r);
|
|
2468
2482
|
});
|
|
2469
2483
|
}
|
|
2470
|
-
var
|
|
2471
|
-
function
|
|
2472
|
-
let n =
|
|
2484
|
+
var zr = /* @__PURE__ */ new Map();
|
|
2485
|
+
function Br(e, t) {
|
|
2486
|
+
let n = zr.get(e);
|
|
2473
2487
|
if (!n) {
|
|
2474
2488
|
let r = {
|
|
2475
2489
|
refs: 0,
|
|
2476
2490
|
promise: Promise.resolve("")
|
|
2477
2491
|
};
|
|
2478
|
-
r.promise =
|
|
2492
|
+
r.promise = Rr(t).then((e) => (r.url = URL.createObjectURL(e), r.url)), zr.set(e, r), n = r;
|
|
2479
2493
|
}
|
|
2480
2494
|
n.timer && (clearTimeout(n.timer), n.timer = void 0), n.refs++;
|
|
2481
2495
|
let r = n, i = !1;
|
|
@@ -2483,15 +2497,15 @@ function Lr(e, t) {
|
|
|
2483
2497
|
promise: r.promise,
|
|
2484
2498
|
release: () => {
|
|
2485
2499
|
i || (i = !0, r.refs--, !(r.refs > 0) && (r.timer = setTimeout(() => {
|
|
2486
|
-
r.url && URL.revokeObjectURL(r.url),
|
|
2487
|
-
},
|
|
2500
|
+
r.url && URL.revokeObjectURL(r.url), zr.get(e) === r && zr.delete(e);
|
|
2501
|
+
}, Fr)));
|
|
2488
2502
|
}
|
|
2489
2503
|
};
|
|
2490
2504
|
}
|
|
2491
|
-
async function
|
|
2492
|
-
if (e.size <
|
|
2505
|
+
async function Vr(e) {
|
|
2506
|
+
if (e.size < Nr || typeof createImageBitmap != "function") return e;
|
|
2493
2507
|
let t = await createImageBitmap(e, {
|
|
2494
|
-
resizeWidth:
|
|
2508
|
+
resizeWidth: Mr,
|
|
2495
2509
|
resizeQuality: "medium"
|
|
2496
2510
|
});
|
|
2497
2511
|
try {
|
|
@@ -2508,22 +2522,22 @@ async function Rr(e) {
|
|
|
2508
2522
|
t.close();
|
|
2509
2523
|
}
|
|
2510
2524
|
}
|
|
2511
|
-
async function
|
|
2525
|
+
async function Hr(e) {
|
|
2512
2526
|
let t = e.variants[0];
|
|
2513
|
-
return t ?
|
|
2527
|
+
return t ? qn(t.file.path) : Vr(await qn(e.file.path));
|
|
2514
2528
|
}
|
|
2515
|
-
var
|
|
2516
|
-
function
|
|
2517
|
-
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (
|
|
2518
|
-
for (let t of e) t.isIntersecting && (
|
|
2519
|
-
}, { rootMargin: "300px" })),
|
|
2520
|
-
|
|
2529
|
+
var Ur = /* @__PURE__ */ new WeakMap(), Wr = null;
|
|
2530
|
+
function Gr(e, t) {
|
|
2531
|
+
return typeof IntersectionObserver > "u" ? (t(), () => {}) : (Wr ?? (Wr = new IntersectionObserver((e) => {
|
|
2532
|
+
for (let t of e) t.isIntersecting && (Wr.unobserve(t.target), Ur.get(t.target)?.(), Ur.delete(t.target));
|
|
2533
|
+
}, { rootMargin: "300px" })), Ur.set(e, t), Wr.observe(e), () => {
|
|
2534
|
+
Ur.delete(e), Wr?.unobserve(e);
|
|
2521
2535
|
});
|
|
2522
2536
|
}
|
|
2523
|
-
function
|
|
2524
|
-
let t =
|
|
2537
|
+
function Kr(e) {
|
|
2538
|
+
let t = vr(e.file) === "image", [r, a] = c(null), [o, s] = c(!1), [l, u] = c(null), [d, f] = c("idle"), p = n((e) => a(e), []);
|
|
2525
2539
|
i(() => {
|
|
2526
|
-
if (t && r && !o) return
|
|
2540
|
+
if (t && r && !o) return Gr(r, () => s(!0));
|
|
2527
2541
|
}, [
|
|
2528
2542
|
t,
|
|
2529
2543
|
r,
|
|
@@ -2534,7 +2548,7 @@ function Ur(e) {
|
|
|
2534
2548
|
if (!t || !o) return;
|
|
2535
2549
|
let n = !1;
|
|
2536
2550
|
f("loading");
|
|
2537
|
-
let r =
|
|
2551
|
+
let r = Br(_, () => Hr(e));
|
|
2538
2552
|
return r.promise.then((e) => {
|
|
2539
2553
|
n || (u(e), f("ready"));
|
|
2540
2554
|
}, () => {
|
|
@@ -2557,7 +2571,7 @@ function Ur(e) {
|
|
|
2557
2571
|
}
|
|
2558
2572
|
//#endregion
|
|
2559
2573
|
//#region src/OPFSFilesManager/FileThumbnail.tsx
|
|
2560
|
-
var
|
|
2574
|
+
var qr = {
|
|
2561
2575
|
image: {
|
|
2562
2576
|
icon: "image",
|
|
2563
2577
|
label: "Images",
|
|
@@ -2588,11 +2602,11 @@ var Wr = {
|
|
|
2588
2602
|
label: "Other",
|
|
2589
2603
|
color: "var(--seed-kind-other)"
|
|
2590
2604
|
}
|
|
2591
|
-
},
|
|
2592
|
-
function
|
|
2593
|
-
let r =
|
|
2605
|
+
}, Jr = (e) => ({ "--seed-kind": qr[e].color }), Yr = (e) => /png|webp|gif|avif|svg/.test(gr(e.file));
|
|
2606
|
+
function Xr({ entry: e, size: t, children: n }) {
|
|
2607
|
+
let r = vr(e.file), { ref: i, url: a, status: o, markError: s } = Kr(e), c = r === "image" && o === "error", l = r === "image" && a && !c, u = [
|
|
2594
2608
|
t === "tile" ? "seed-fm-thumb" : "seed-fm-mini",
|
|
2595
|
-
l &&
|
|
2609
|
+
l && Yr(e) ? "seed-fm-thumb--checker" : "",
|
|
2596
2610
|
r === "image" && o === "loading" ? "seed-fm-skeleton" : ""
|
|
2597
2611
|
].filter(Boolean).join(" "), d;
|
|
2598
2612
|
return d = l ? /* @__PURE__ */ U("img", {
|
|
@@ -2602,12 +2616,12 @@ function qr({ entry: e, size: t, children: n }) {
|
|
|
2602
2616
|
draggable: !1,
|
|
2603
2617
|
onError: s
|
|
2604
2618
|
}) : t === "mini" ? /* @__PURE__ */ U($, {
|
|
2605
|
-
name: c ? "imageOff" :
|
|
2619
|
+
name: c ? "imageOff" : qr[r].icon,
|
|
2606
2620
|
size: 16
|
|
2607
2621
|
}) : r === "image" && !c ? null : /* @__PURE__ */ W("span", {
|
|
2608
2622
|
className: "seed-fm-kind",
|
|
2609
2623
|
children: [/* @__PURE__ */ U($, {
|
|
2610
|
-
name: c ? "imageOff" :
|
|
2624
|
+
name: c ? "imageOff" : qr[r].icon,
|
|
2611
2625
|
size: 28,
|
|
2612
2626
|
strokeWidth: 1.6
|
|
2613
2627
|
}), c ? /* @__PURE__ */ U("span", {
|
|
@@ -2615,18 +2629,18 @@ function qr({ entry: e, size: t, children: n }) {
|
|
|
2615
2629
|
children: "Can’t decode image"
|
|
2616
2630
|
}) : /* @__PURE__ */ U("span", {
|
|
2617
2631
|
className: "seed-fm-ext",
|
|
2618
|
-
children:
|
|
2632
|
+
children: yr(e.file)
|
|
2619
2633
|
})]
|
|
2620
2634
|
}), /* @__PURE__ */ W("span", {
|
|
2621
2635
|
ref: i,
|
|
2622
2636
|
className: u,
|
|
2623
|
-
style:
|
|
2637
|
+
style: Jr(r),
|
|
2624
2638
|
children: [d, n]
|
|
2625
2639
|
});
|
|
2626
2640
|
}
|
|
2627
2641
|
//#endregion
|
|
2628
2642
|
//#region src/OPFSFilesManager/FileGrid.tsx
|
|
2629
|
-
function
|
|
2643
|
+
function Zr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i, tileClassName: a }) {
|
|
2630
2644
|
return /* @__PURE__ */ U("ul", {
|
|
2631
2645
|
className: ["seed-fm-grid", i].filter(Boolean).join(" "),
|
|
2632
2646
|
role: "listbox",
|
|
@@ -2646,7 +2660,7 @@ function Jr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2646
2660
|
onKeyDown: (t) => {
|
|
2647
2661
|
t.target === t.currentTarget && (t.key === "Enter" ? (t.preventDefault(), n(e, i, t)) : t.key === " " && (t.preventDefault(), r(e, i, t.shiftKey)));
|
|
2648
2662
|
},
|
|
2649
|
-
children: [/* @__PURE__ */ W(
|
|
2663
|
+
children: [/* @__PURE__ */ W(Xr, {
|
|
2650
2664
|
entry: e,
|
|
2651
2665
|
size: "tile",
|
|
2652
2666
|
children: [/* @__PURE__ */ U("button", {
|
|
@@ -2680,7 +2694,7 @@ function Jr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2680
2694
|
className: "seed-fm-tile-meta",
|
|
2681
2695
|
children: [/* @__PURE__ */ U("span", {
|
|
2682
2696
|
className: "seed-fm-tile-name",
|
|
2683
|
-
children:
|
|
2697
|
+
children: ur(o.name, 24)
|
|
2684
2698
|
}), /* @__PURE__ */ W("span", {
|
|
2685
2699
|
className: "seed-fm-tile-sub",
|
|
2686
2700
|
children: [
|
|
@@ -2689,8 +2703,8 @@ function Jr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2689
2703
|
" ",
|
|
2690
2704
|
/* @__PURE__ */ U("time", {
|
|
2691
2705
|
dateTime: new Date(o.lastModified).toISOString(),
|
|
2692
|
-
title:
|
|
2693
|
-
children:
|
|
2706
|
+
title: lr(o.lastModified),
|
|
2707
|
+
children: cr(o.lastModified)
|
|
2694
2708
|
})
|
|
2695
2709
|
]
|
|
2696
2710
|
})]
|
|
@@ -2701,7 +2715,7 @@ function Jr({ entries: e, selected: t, onActivate: n, onToggle: r, className: i,
|
|
|
2701
2715
|
}
|
|
2702
2716
|
//#endregion
|
|
2703
2717
|
//#region src/OPFSFilesManager/FileList.tsx
|
|
2704
|
-
function
|
|
2718
|
+
function Qr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onToggleAll: o, onDownload: c, onDelete: l, deleteActionFor: u, className: d, rowClassName: f }) {
|
|
2705
2719
|
let p = s(null), m = e.filter((e) => t.has(e.file.path)).length, h = e.length > 0 && m === e.length;
|
|
2706
2720
|
i(() => {
|
|
2707
2721
|
p.current && (p.current.indeterminate = m > 0 && !h);
|
|
@@ -2761,7 +2775,7 @@ function Yr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2761
2775
|
}),
|
|
2762
2776
|
/* @__PURE__ */ U("td", { children: /* @__PURE__ */ W("span", {
|
|
2763
2777
|
className: "seed-fm-namecell",
|
|
2764
|
-
children: [/* @__PURE__ */ U(
|
|
2778
|
+
children: [/* @__PURE__ */ U(Xr, {
|
|
2765
2779
|
entry: e,
|
|
2766
2780
|
size: "mini"
|
|
2767
2781
|
}), /* @__PURE__ */ W("span", { children: [/* @__PURE__ */ U("button", {
|
|
@@ -2780,8 +2794,8 @@ function Yr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2780
2794
|
className: "seed-fm-col-type",
|
|
2781
2795
|
children: /* @__PURE__ */ W("span", {
|
|
2782
2796
|
className: "seed-fm-type",
|
|
2783
|
-
style:
|
|
2784
|
-
children: [
|
|
2797
|
+
style: Jr(vr(i)),
|
|
2798
|
+
children: [gr(i), i.detectedType && /* @__PURE__ */ U("small", { children: "detected" })]
|
|
2785
2799
|
})
|
|
2786
2800
|
}),
|
|
2787
2801
|
/* @__PURE__ */ U("td", {
|
|
@@ -2791,8 +2805,8 @@ function Yr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2791
2805
|
}),
|
|
2792
2806
|
/* @__PURE__ */ U("td", {
|
|
2793
2807
|
className: "seed-fm-when seed-fm-col-modified",
|
|
2794
|
-
title:
|
|
2795
|
-
children:
|
|
2808
|
+
title: lr(i.lastModified),
|
|
2809
|
+
children: cr(i.lastModified)
|
|
2796
2810
|
}),
|
|
2797
2811
|
/* @__PURE__ */ W("td", {
|
|
2798
2812
|
className: "seed-fm-actions",
|
|
@@ -2827,22 +2841,22 @@ function Yr({ entries: e, selected: t, cwd: n, onActivate: r, onToggle: a, onTog
|
|
|
2827
2841
|
}
|
|
2828
2842
|
//#endregion
|
|
2829
2843
|
//#region src/OPFSFilesManager/PreviewPanel.tsx
|
|
2830
|
-
var
|
|
2831
|
-
function
|
|
2832
|
-
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o =
|
|
2844
|
+
var $r = 1048576, ei = 32768;
|
|
2845
|
+
function ti(e) {
|
|
2846
|
+
let [t, n] = c({ kind: "loading" }), { path: r, lastModified: a } = e.file, o = vr(e.file), s = e.file.size;
|
|
2833
2847
|
return i(() => {
|
|
2834
2848
|
let e = !1, t = null;
|
|
2835
2849
|
return n({ kind: "loading" }), (async () => {
|
|
2836
|
-
if (o === "image") return t = URL.createObjectURL(await
|
|
2850
|
+
if (o === "image") return t = URL.createObjectURL(await qn(r)), {
|
|
2837
2851
|
kind: "image",
|
|
2838
2852
|
url: t
|
|
2839
2853
|
};
|
|
2840
2854
|
if (o === "json" || o === "html" || o === "text") {
|
|
2841
|
-
if (s >
|
|
2855
|
+
if (s > $r) return {
|
|
2842
2856
|
kind: "none",
|
|
2843
2857
|
message: "This file is too large to preview."
|
|
2844
2858
|
};
|
|
2845
|
-
let e = await
|
|
2859
|
+
let e = await qn(r), t = e.size > ei, n = await e.slice(0, ei).text();
|
|
2846
2860
|
if (o === "json" && !t) try {
|
|
2847
2861
|
n = JSON.stringify(JSON.parse(n), null, 2);
|
|
2848
2862
|
} catch {}
|
|
@@ -2876,8 +2890,8 @@ function Qr(e) {
|
|
|
2876
2890
|
o
|
|
2877
2891
|
]), t;
|
|
2878
2892
|
}
|
|
2879
|
-
function
|
|
2880
|
-
let { file: f, variants: p } = e, m =
|
|
2893
|
+
function ni({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onDelete: o, deleteAction: l, onCopyPath: u, className: d }) {
|
|
2894
|
+
let { file: f, variants: p } = e, m = vr(f), h = ti(e), [g, _] = c(null), [v, y] = c(!1), b = s(null);
|
|
2881
2895
|
i(() => {
|
|
2882
2896
|
_(null), y(!1);
|
|
2883
2897
|
}, [f.path]), i(() => {
|
|
@@ -2900,13 +2914,13 @@ function $r({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2900
2914
|
C = /* @__PURE__ */ W("span", {
|
|
2901
2915
|
className: "seed-fm-preview-note",
|
|
2902
2916
|
children: [/* @__PURE__ */ U($, {
|
|
2903
|
-
name: v ? "imageOff" :
|
|
2917
|
+
name: v ? "imageOff" : qr[m].icon,
|
|
2904
2918
|
size: 32,
|
|
2905
2919
|
strokeWidth: 1.5
|
|
2906
2920
|
}), e]
|
|
2907
2921
|
});
|
|
2908
2922
|
}
|
|
2909
|
-
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(
|
|
2923
|
+
let w = h.kind === "image" && !v && /png|webp|gif|avif|svg/.test(gr(f));
|
|
2910
2924
|
return /* @__PURE__ */ W("aside", {
|
|
2911
2925
|
className: ["seed-fm-panel", d].filter(Boolean).join(" "),
|
|
2912
2926
|
role: "dialog",
|
|
@@ -2956,7 +2970,7 @@ function $r({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2956
2970
|
w ? "seed-fm-thumb--checker" : "",
|
|
2957
2971
|
h.kind === "loading" ? "seed-fm-skeleton" : ""
|
|
2958
2972
|
].filter(Boolean).join(" "),
|
|
2959
|
-
style:
|
|
2973
|
+
style: Jr(m),
|
|
2960
2974
|
children: C
|
|
2961
2975
|
}),
|
|
2962
2976
|
/* @__PURE__ */ W("dl", {
|
|
@@ -2984,7 +2998,7 @@ function $r({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2984
2998
|
/* @__PURE__ */ W("small", { children: [f.size.toLocaleString(), " bytes"] })
|
|
2985
2999
|
] }),
|
|
2986
3000
|
/* @__PURE__ */ U("dt", { children: "Type" }),
|
|
2987
|
-
/* @__PURE__ */ W("dd", { children: [
|
|
3001
|
+
/* @__PURE__ */ W("dd", { children: [gr(f), f.detectedType && /* @__PURE__ */ W("small", { children: [
|
|
2988
3002
|
" from file contents. File.type is “",
|
|
2989
3003
|
f.type,
|
|
2990
3004
|
"”"
|
|
@@ -2997,9 +3011,9 @@ function $r({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
2997
3011
|
] })] }),
|
|
2998
3012
|
/* @__PURE__ */ U("dt", { children: "Modified" }),
|
|
2999
3013
|
/* @__PURE__ */ W("dd", { children: [
|
|
3000
|
-
|
|
3014
|
+
lr(f.lastModified),
|
|
3001
3015
|
" ",
|
|
3002
|
-
/* @__PURE__ */ U("small", { children:
|
|
3016
|
+
/* @__PURE__ */ U("small", { children: cr(f.lastModified) })
|
|
3003
3017
|
] })
|
|
3004
3018
|
]
|
|
3005
3019
|
}),
|
|
@@ -3044,18 +3058,18 @@ function $r({ entry: e, onClose: t, onPrevious: n, onNext: r, onDownload: a, onD
|
|
|
3044
3058
|
}
|
|
3045
3059
|
//#endregion
|
|
3046
3060
|
//#region src/OPFSFilesManager/styles.ts
|
|
3047
|
-
var
|
|
3061
|
+
var ri = "seed-opfs-files-manager-styles", ii = "seed-opfs-files-manager", ai = "\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", oi = "\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", si = `@layer ${ii} {\n${`
|
|
3048
3062
|
.seed-fm {
|
|
3049
|
-
${
|
|
3063
|
+
${ai}
|
|
3050
3064
|
--seed-radius-sm: 6px;
|
|
3051
3065
|
--seed-radius-md: 8px;
|
|
3052
3066
|
--seed-radius-lg: 12px;
|
|
3053
3067
|
--seed-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
3054
3068
|
color-scheme: light;
|
|
3055
3069
|
}
|
|
3056
|
-
.seed-fm[data-seed-theme="dark"] { ${
|
|
3070
|
+
.seed-fm[data-seed-theme="dark"] { ${oi} }
|
|
3057
3071
|
@media (prefers-color-scheme: dark) {
|
|
3058
|
-
.seed-fm[data-seed-theme="system"] { ${
|
|
3072
|
+
.seed-fm[data-seed-theme="system"] { ${oi} }
|
|
3059
3073
|
}
|
|
3060
3074
|
|
|
3061
3075
|
.seed-fm { position: relative; color: var(--seed-fg); background: var(--seed-bg); font-family: inherit; font-size: 14px; line-height: 1.45; }
|
|
@@ -3263,14 +3277,14 @@ var ei = "seed-opfs-files-manager-styles", ti = "seed-opfs-files-manager", ni =
|
|
|
3263
3277
|
.seed-fm-thumb img { transition: none; }
|
|
3264
3278
|
}
|
|
3265
3279
|
`}\n}`;
|
|
3266
|
-
function
|
|
3280
|
+
function ci() {
|
|
3267
3281
|
if (typeof document > "u" || document.getElementById("seed-opfs-files-manager-styles")) return;
|
|
3268
3282
|
let e = document.createElement("style");
|
|
3269
|
-
e.id =
|
|
3283
|
+
e.id = ri, e.textContent = si, document.head.appendChild(e);
|
|
3270
3284
|
}
|
|
3271
3285
|
//#endregion
|
|
3272
3286
|
//#region src/OPFSFilesManager/useStorageEstimate.ts
|
|
3273
|
-
function
|
|
3287
|
+
function li(e) {
|
|
3274
3288
|
let [t, n] = c(null);
|
|
3275
3289
|
return i(() => {
|
|
3276
3290
|
if (typeof navigator > "u" || typeof navigator.storage?.estimate != "function") return;
|
|
@@ -3287,40 +3301,40 @@ function oi(e) {
|
|
|
3287
3301
|
}
|
|
3288
3302
|
//#endregion
|
|
3289
3303
|
//#region src/OPFSFilesManager/zip.ts
|
|
3290
|
-
var
|
|
3291
|
-
function
|
|
3292
|
-
if (
|
|
3293
|
-
|
|
3304
|
+
var ui = null;
|
|
3305
|
+
function di() {
|
|
3306
|
+
if (ui) return ui;
|
|
3307
|
+
ui = /* @__PURE__ */ new Uint32Array(256);
|
|
3294
3308
|
for (let e = 0; e < 256; e++) {
|
|
3295
3309
|
let t = e;
|
|
3296
3310
|
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
3297
|
-
|
|
3311
|
+
ui[e] = t >>> 0;
|
|
3298
3312
|
}
|
|
3299
|
-
return
|
|
3313
|
+
return ui;
|
|
3300
3314
|
}
|
|
3301
|
-
function
|
|
3302
|
-
let t =
|
|
3315
|
+
function fi(e) {
|
|
3316
|
+
let t = di(), n = 4294967295;
|
|
3303
3317
|
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
3304
3318
|
return (n ^ 4294967295) >>> 0;
|
|
3305
3319
|
}
|
|
3306
|
-
function
|
|
3320
|
+
function pi(e) {
|
|
3307
3321
|
let t = new Date(e), n = Math.max(1980, t.getFullYear());
|
|
3308
3322
|
return {
|
|
3309
3323
|
time: t.getHours() << 11 | t.getMinutes() << 5 | Math.floor(t.getSeconds() / 2),
|
|
3310
3324
|
date: n - 1980 << 9 | t.getMonth() + 1 << 5 | t.getDate()
|
|
3311
3325
|
};
|
|
3312
3326
|
}
|
|
3313
|
-
var
|
|
3314
|
-
async function
|
|
3327
|
+
var mi = 2048, hi = 4294967295;
|
|
3328
|
+
async function gi(e) {
|
|
3315
3329
|
if (e.length > 65535) throw Error("Too many files for a ZIP archive (max 65,535).");
|
|
3316
3330
|
let t = new TextEncoder(), n = [], r = [], i = 0;
|
|
3317
3331
|
for (let a of e) {
|
|
3318
|
-
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s =
|
|
3319
|
-
if (i + o.length + 30 + e.length >
|
|
3332
|
+
let e = t.encode(a.name), o = new Uint8Array(await a.data.arrayBuffer()), s = fi(o), { time: c, date: l } = pi(a.lastModified ?? Date.now());
|
|
3333
|
+
if (i + o.length + 30 + e.length > hi) throw Error("Selection is too large for a ZIP archive (max 4 GB).");
|
|
3320
3334
|
let u = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(30));
|
|
3321
|
-
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6,
|
|
3335
|
+
u.setUint32(0, 67324752, !0), u.setUint16(4, 20, !0), u.setUint16(6, mi, !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);
|
|
3322
3336
|
let d = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(46));
|
|
3323
|
-
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8,
|
|
3337
|
+
d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, mi, !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);
|
|
3324
3338
|
let f = new Uint8Array(46 + e.length);
|
|
3325
3339
|
f.set(new Uint8Array(d.buffer), 0), f.set(e, 46), r.push(f), i += 30 + e.length + o.length;
|
|
3326
3340
|
}
|
|
@@ -3333,12 +3347,12 @@ async function pi(e) {
|
|
|
3333
3347
|
}
|
|
3334
3348
|
//#endregion
|
|
3335
3349
|
//#region src/OPFSFilesManager/OPFSFilesManager.tsx
|
|
3336
|
-
var
|
|
3337
|
-
function
|
|
3350
|
+
var _i = "Everything this app stores in the browser’s private file system (OPFS).", vi = 4e3, yi = (e) => e instanceof Error ? e.message : String(e), bi = (e, t, n = `${t}s`) => `${e} ${e === 1 ? t : n}`, xi = (e) => (e ?? "").split("/").filter(Boolean).join("/");
|
|
3351
|
+
function Si(e, t) {
|
|
3338
3352
|
let n = URL.createObjectURL(t), r = document.createElement("a");
|
|
3339
3353
|
r.href = n, r.download = e, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
|
|
3340
3354
|
}
|
|
3341
|
-
function
|
|
3355
|
+
function Ci() {
|
|
3342
3356
|
let [e, t] = c([]), r = s(/* @__PURE__ */ new Set());
|
|
3343
3357
|
return i(() => {
|
|
3344
3358
|
let e = r.current;
|
|
@@ -3354,12 +3368,12 @@ function bi() {
|
|
|
3354
3368
|
}]);
|
|
3355
3369
|
let a = setTimeout(() => {
|
|
3356
3370
|
r.current.delete(a), t((e) => e.filter((e) => e.id !== i));
|
|
3357
|
-
},
|
|
3371
|
+
}, vi);
|
|
3358
3372
|
r.current.add(a);
|
|
3359
3373
|
}, [])
|
|
3360
3374
|
};
|
|
3361
3375
|
}
|
|
3362
|
-
var
|
|
3376
|
+
var wi = [
|
|
3363
3377
|
"image",
|
|
3364
3378
|
"database",
|
|
3365
3379
|
"json",
|
|
@@ -3367,11 +3381,11 @@ var xi = [
|
|
|
3367
3381
|
"text",
|
|
3368
3382
|
"other"
|
|
3369
3383
|
];
|
|
3370
|
-
function
|
|
3371
|
-
let n =
|
|
3372
|
-
label:
|
|
3384
|
+
function Ti({ files: e, estimate: t }) {
|
|
3385
|
+
let n = Ar(e), r = e.reduce((e, t) => e + t.size, 0), i = t ? Math.max(0, t.usage - r) : 0, a = r + i, o = [...wi.filter((e) => n[e] > 0).map((e) => ({
|
|
3386
|
+
label: qr[e].label,
|
|
3373
3387
|
size: n[e],
|
|
3374
|
-
color:
|
|
3388
|
+
color: qr[e].color
|
|
3375
3389
|
})), ...i > 0 ? [{
|
|
3376
3390
|
label: "Other site data",
|
|
3377
3391
|
size: i,
|
|
@@ -3385,7 +3399,7 @@ function Si({ files: e, estimate: t }) {
|
|
|
3385
3399
|
children: [/* @__PURE__ */ W("span", { children: [
|
|
3386
3400
|
/* @__PURE__ */ U("strong", { children: Q(t ? t.usage : r) }),
|
|
3387
3401
|
" ",
|
|
3388
|
-
t ? "used by this site" : `in ${
|
|
3402
|
+
t ? "used by this site" : `in ${bi(e.length, "file")}`
|
|
3389
3403
|
] }), t && /* @__PURE__ */ W("span", { children: [Q(t.quota), " available"] })]
|
|
3390
3404
|
}), a > 0 && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("div", {
|
|
3391
3405
|
className: "seed-fm-meter",
|
|
@@ -3408,7 +3422,7 @@ function Si({ files: e, estimate: t }) {
|
|
|
3408
3422
|
})] })]
|
|
3409
3423
|
});
|
|
3410
3424
|
}
|
|
3411
|
-
function
|
|
3425
|
+
function Ei({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
3412
3426
|
return /* @__PURE__ */ W("div", {
|
|
3413
3427
|
className: `seed-fm-state${r === "error" ? " seed-fm-state--error" : ""}`,
|
|
3414
3428
|
role: r === "error" ? "alert" : void 0,
|
|
@@ -3426,70 +3440,70 @@ function Ci({ icon: e, title: t, children: n, tone: r, action: i }) {
|
|
|
3426
3440
|
]
|
|
3427
3441
|
});
|
|
3428
3442
|
}
|
|
3429
|
-
function
|
|
3443
|
+
function Di({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDownload: l, title: u = "Files", description: d = _i, headingLevel: f = 2, theme: p = "system", className: m, classNames: h = {}, defaultView: g, groupImageVariants: _ = !0, deleteWarning: v = jr, confirmDelete: y, deleteAction: b, onNotify: x }) {
|
|
3430
3444
|
a(() => {
|
|
3431
|
-
p !== "none" &&
|
|
3445
|
+
p !== "none" && ci();
|
|
3432
3446
|
}, [p]);
|
|
3433
|
-
let S =
|
|
3434
|
-
i(() =>
|
|
3435
|
-
let
|
|
3436
|
-
i(() =>
|
|
3437
|
-
let [
|
|
3438
|
-
x ? x(e, t, n) :
|
|
3439
|
-
},
|
|
3440
|
-
query:
|
|
3441
|
-
sort:
|
|
3447
|
+
let S = xi(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 } = rr({ rootPath: e }), O = o(() => t ? T.filter(t) : T, [T, t]), re = li(T), [k, A] = c(_);
|
|
3448
|
+
i(() => A(_), [_]);
|
|
3449
|
+
let j = o(() => Er(O, k), [O, k]), [ie, ae] = c(S);
|
|
3450
|
+
i(() => ae(S), [S]);
|
|
3451
|
+
let [M, oe] = c(""), [se, ce] = c("name"), [N, le] = c(g), [P, F] = c(() => /* @__PURE__ */ new Set()), ue = s(null), [I, de] = c(null), fe = s(null), [pe, me] = c(null), [L, he] = c(null), [ge, _e] = c(!1), { toasts: R, showToast: z } = Ci(), ve = (e, t, n) => {
|
|
3452
|
+
x ? x(e, t, n) : z(e, t);
|
|
3453
|
+
}, ye = o(() => Or(j, ie, {
|
|
3454
|
+
query: M,
|
|
3455
|
+
sort: se
|
|
3442
3456
|
}), [
|
|
3457
|
+
j,
|
|
3458
|
+
ie,
|
|
3443
3459
|
M,
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
oe
|
|
3447
|
-
]), V = ve.entries, ye = V.length ? V.filter((e) => hr(e.file) === "image").length / V.length : 0, be = P ?? (ye >= .5 ? "grid" : "list"), xe = o(() => new Map(M.map((e) => [e.file.path, e])), [M]), Se = o(() => [...F].map((e) => xe.get(e)).filter((e) => !!e), [F, xe]), G = ue ? xe.get(ue) ?? null : null, K = G ? V.indexOf(G) : -1;
|
|
3460
|
+
se
|
|
3461
|
+
]), B = ye.entries, be = B.length ? B.filter((e) => vr(e.file) === "image").length / B.length : 0, V = N ?? (be >= .5 ? "grid" : "list"), xe = o(() => new Map(j.map((e) => [e.file.path, e])), [j]), Se = o(() => [...P].map((e) => xe.get(e)).filter((e) => !!e), [P, xe]), G = I ? xe.get(I) ?? null : null, K = G ? B.indexOf(G) : -1;
|
|
3448
3462
|
i(() => {
|
|
3449
|
-
|
|
3463
|
+
F((e) => {
|
|
3450
3464
|
let t = new Set([...e].filter((e) => xe.has(e)));
|
|
3451
3465
|
return t.size === e.size ? e : t;
|
|
3452
3466
|
});
|
|
3453
3467
|
}, [xe]);
|
|
3454
3468
|
let Ce = (e) => {
|
|
3455
|
-
|
|
3469
|
+
ae(e), oe(""), F(/* @__PURE__ */ new Set()), ue.current = null, de(null);
|
|
3456
3470
|
}, we = (e, t, n) => {
|
|
3457
|
-
let r =
|
|
3458
|
-
|
|
3471
|
+
let r = ue.current;
|
|
3472
|
+
F((i) => {
|
|
3459
3473
|
let a = new Set(i);
|
|
3460
3474
|
if (n && r != null) {
|
|
3461
3475
|
let [e, n] = r < t ? [r, t] : [t, r];
|
|
3462
|
-
for (let t of
|
|
3476
|
+
for (let t of B.slice(e, n + 1)) a.add(t.file.path);
|
|
3463
3477
|
} else a.has(e.file.path) ? a.delete(e.file.path) : a.add(e.file.path);
|
|
3464
3478
|
return a;
|
|
3465
|
-
}), (!n || r == null) && (
|
|
3466
|
-
},
|
|
3467
|
-
|
|
3468
|
-
},
|
|
3479
|
+
}), (!n || r == null) && (ue.current = t);
|
|
3480
|
+
}, Te = (e) => {
|
|
3481
|
+
I || (fe.current = document.activeElement), de(e);
|
|
3482
|
+
}, q = () => {
|
|
3469
3483
|
de(null), fe.current?.focus?.(), fe.current = null;
|
|
3470
3484
|
}, Ee = (e, t, n) => {
|
|
3471
3485
|
let r = n.shiftKey || n.metaKey || n.ctrlKey;
|
|
3472
|
-
|
|
3486
|
+
P.size > 0 || r ? we(e, t, n.shiftKey) : Te(e.file.path);
|
|
3473
3487
|
}, De = () => {
|
|
3474
|
-
let e =
|
|
3475
|
-
|
|
3488
|
+
let e = B.every((e) => P.has(e.file.path));
|
|
3489
|
+
F((t) => {
|
|
3476
3490
|
let n = new Set(t);
|
|
3477
|
-
for (let t of
|
|
3491
|
+
for (let t of B) e ? n.delete(t.file.path) : n.add(t.file.path);
|
|
3478
3492
|
return n;
|
|
3479
3493
|
});
|
|
3480
3494
|
}, Oe = (e) => S && e.startsWith(`${S}/`) ? e.slice(S.length + 1) : e, ke = async (e, t) => {
|
|
3481
|
-
l ? await l(e, t) :
|
|
3495
|
+
l ? await l(e, t) : Si(e.name, t);
|
|
3482
3496
|
}, Ae = async (e, t) => {
|
|
3483
3497
|
if (e.length === 0) return !1;
|
|
3484
|
-
|
|
3498
|
+
_e(!0);
|
|
3485
3499
|
try {
|
|
3486
3500
|
if (e.length === 1 && !t) {
|
|
3487
3501
|
let [t] = e;
|
|
3488
|
-
return await ke(t, await
|
|
3502
|
+
return await ke(t, await qn(t.path)), !0;
|
|
3489
3503
|
}
|
|
3490
|
-
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await
|
|
3504
|
+
let n = t ? t.path.slice(0, t.path.length - t.name.length) : "", r = await gi(await Promise.all(e.map(async (e) => ({
|
|
3491
3505
|
name: t ? e.path.slice(n.length) : Oe(e.path),
|
|
3492
|
-
data: await
|
|
3506
|
+
data: await qn(e.path),
|
|
3493
3507
|
lastModified: e.lastModified
|
|
3494
3508
|
})))), i = `${t ? t.name : C}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`;
|
|
3495
3509
|
return await ke({
|
|
@@ -3498,64 +3512,64 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3498
3512
|
size: r.size,
|
|
3499
3513
|
type: "application/zip",
|
|
3500
3514
|
lastModified: Date.now()
|
|
3501
|
-
}, r),
|
|
3515
|
+
}, r), ve(`Saved ${i} with ${bi(e.length, "file")}`, "success", {
|
|
3502
3516
|
kind: "download",
|
|
3503
3517
|
paths: e.map((e) => e.path),
|
|
3504
3518
|
fileName: i
|
|
3505
3519
|
}), !0;
|
|
3506
3520
|
} catch (t) {
|
|
3507
|
-
return
|
|
3521
|
+
return ve(`Couldn’t download: ${yi(t)}`, "error", {
|
|
3508
3522
|
kind: "download",
|
|
3509
3523
|
paths: e.map((e) => e.path),
|
|
3510
|
-
error:
|
|
3524
|
+
error: yi(t)
|
|
3511
3525
|
}), !1;
|
|
3512
3526
|
} finally {
|
|
3513
|
-
|
|
3527
|
+
_e(!1);
|
|
3514
3528
|
}
|
|
3515
|
-
}, je = (e) => Ae(e.map((e) => e.file)), Me = (e, t) => e.flatMap((e) => [e.file, ...t ? e.variants.map((e) => e.file) : []]),
|
|
3529
|
+
}, je = (e) => Ae(e.map((e) => e.file)), Me = (e, t) => e.flatMap((e) => [e.file, ...t ? e.variants.map((e) => e.file) : []]), Ne = (e) => {
|
|
3516
3530
|
let t = b?.(e);
|
|
3517
3531
|
return {
|
|
3518
3532
|
label: t?.label,
|
|
3519
3533
|
destructive: t?.destructive !== !1
|
|
3520
3534
|
};
|
|
3521
|
-
},
|
|
3522
|
-
|
|
3535
|
+
}, J = (e) => Ne(Me(e, !0)), Y = async (e, t) => {
|
|
3536
|
+
_e(!0);
|
|
3523
3537
|
let i = [], a = [], o = [], s = !1;
|
|
3524
3538
|
try {
|
|
3525
3539
|
let r = await navigator.storage.getDirectory();
|
|
3526
3540
|
for (let t of e) if (n && !await n(t)) o.push(t.path);
|
|
3527
3541
|
else try {
|
|
3528
|
-
await
|
|
3542
|
+
await Jn(t.path, r), i.push(t.path);
|
|
3529
3543
|
} catch (e) {
|
|
3530
3544
|
a.push({
|
|
3531
3545
|
path: t.path,
|
|
3532
|
-
error:
|
|
3546
|
+
error: yi(e)
|
|
3533
3547
|
});
|
|
3534
3548
|
}
|
|
3535
3549
|
if (t) try {
|
|
3536
|
-
s = await
|
|
3550
|
+
s = await Xn(t.path, r);
|
|
3537
3551
|
} catch (e) {
|
|
3538
3552
|
a.push({
|
|
3539
3553
|
path: t.path,
|
|
3540
|
-
error:
|
|
3554
|
+
error: yi(e)
|
|
3541
3555
|
});
|
|
3542
3556
|
}
|
|
3543
3557
|
} catch (e) {
|
|
3544
3558
|
a.push({
|
|
3545
3559
|
path: "",
|
|
3546
|
-
error:
|
|
3560
|
+
error: yi(e)
|
|
3547
3561
|
});
|
|
3548
3562
|
}
|
|
3549
|
-
|
|
3563
|
+
F((e) => {
|
|
3550
3564
|
let t = new Set(e);
|
|
3551
3565
|
return i.forEach((e) => t.delete(e)), t;
|
|
3552
|
-
}),
|
|
3553
|
-
let c = [s ? `Deleted the ${t.name} folder (${
|
|
3566
|
+
}), I && i.includes(I) && de(null), await ne(), _e(!1);
|
|
3567
|
+
let c = [s ? `Deleted the ${t.name} folder (${bi(i.length, "file")})` : i.length > 0 ? `Deleted ${bi(i.length, "file")}` : "Nothing deleted"];
|
|
3554
3568
|
if (o.length && c.push(`${o.length} kept by onBeforeDelete`), a.length) {
|
|
3555
3569
|
let e = a.map((e) => e.path ? `${e.path.split("/").pop()}: ${e.error}` : e.error);
|
|
3556
3570
|
c.push(`${a.length} failed (${e.join("; ")})`);
|
|
3557
3571
|
}
|
|
3558
|
-
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`),
|
|
3572
|
+
t && !s && !a.length && c.push(`The ${t.name} folder still has files, so it was kept`), ve(c.join(". "), a.length ? "error" : "success", {
|
|
3559
3573
|
kind: "delete",
|
|
3560
3574
|
deleted: i,
|
|
3561
3575
|
skipped: o,
|
|
@@ -3565,29 +3579,29 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3565
3579
|
folderRemoved: s
|
|
3566
3580
|
}
|
|
3567
3581
|
}), i.length > 0 && await r?.(i);
|
|
3568
|
-
},
|
|
3582
|
+
}, X = async (e) => {
|
|
3569
3583
|
if (e.length === 0) return;
|
|
3570
3584
|
if (!y) {
|
|
3571
|
-
|
|
3585
|
+
me(e);
|
|
3572
3586
|
return;
|
|
3573
3587
|
}
|
|
3574
3588
|
let t = Me(e, !0);
|
|
3575
|
-
await y(t) && await
|
|
3576
|
-
}, Pe = (e) =>
|
|
3589
|
+
await y(t) && await Y(t);
|
|
3590
|
+
}, Pe = (e) => O.filter((t) => t.path.startsWith(`${e.path}/`)), Fe = async (e) => {
|
|
3577
3591
|
if (!y) {
|
|
3578
|
-
|
|
3592
|
+
he(e);
|
|
3579
3593
|
return;
|
|
3580
3594
|
}
|
|
3581
3595
|
let t = Pe(e);
|
|
3582
|
-
await y(t) && await
|
|
3596
|
+
await y(t) && await Y(t, e);
|
|
3583
3597
|
}, Ie = (e) => {
|
|
3584
|
-
let t = () =>
|
|
3598
|
+
let t = () => ve("Path copied", "success", {
|
|
3585
3599
|
kind: "copy-path",
|
|
3586
3600
|
path: e
|
|
3587
|
-
}), n = (t) =>
|
|
3601
|
+
}), n = (t) => ve("Couldn’t copy. Select the path text instead.", "error", {
|
|
3588
3602
|
kind: "copy-path",
|
|
3589
3603
|
path: e,
|
|
3590
|
-
error: t === void 0 ? "Clipboard unavailable" :
|
|
3604
|
+
error: t === void 0 ? "Clipboard unavailable" : yi(t)
|
|
3591
3605
|
});
|
|
3592
3606
|
try {
|
|
3593
3607
|
navigator.clipboard.writeText(e).then(t, n);
|
|
@@ -3595,41 +3609,41 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3595
3609
|
n(e);
|
|
3596
3610
|
}
|
|
3597
3611
|
}, Le = (e) => {
|
|
3598
|
-
if (pe ||
|
|
3612
|
+
if (pe || L) return;
|
|
3599
3613
|
let t = e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement;
|
|
3600
3614
|
if (e.key === "Escape") {
|
|
3601
|
-
if (
|
|
3602
|
-
else if (
|
|
3615
|
+
if (I) q();
|
|
3616
|
+
else if (P.size > 0) F(/* @__PURE__ */ new Set());
|
|
3603
3617
|
else return;
|
|
3604
3618
|
e.preventDefault();
|
|
3605
3619
|
} else if (G && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
3606
|
-
let t =
|
|
3620
|
+
let t = B[K + (e.key === "ArrowRight" ? 1 : -1)];
|
|
3607
3621
|
t && de(t.file.path), e.preventDefault();
|
|
3608
3622
|
}
|
|
3609
|
-
},
|
|
3623
|
+
}, Re = o(() => O.some((e) => Cr(e.path)), [O]), Z = /(^|\/)images(\/\d+)?$/.test(ie), ze = [{
|
|
3610
3624
|
label: C,
|
|
3611
3625
|
path: S
|
|
3612
|
-
}, ...(
|
|
3626
|
+
}, ...(ie.length > S.length ? ie.slice(S ? S.length + 1 : 0).split("/") : []).map((e, t, n) => ({
|
|
3613
3627
|
label: e,
|
|
3614
3628
|
path: [S, ...n.slice(0, t + 1)].filter(Boolean).join("/")
|
|
3615
3629
|
}))], Be = `h${f}`, Ve = Se.reduce((e, t) => e + t.file.size, 0), He;
|
|
3616
|
-
if (!
|
|
3630
|
+
if (!Zn()) He = /* @__PURE__ */ U(Ei, {
|
|
3617
3631
|
icon: "triangleAlert",
|
|
3618
3632
|
tone: "error",
|
|
3619
3633
|
title: "This browser doesn’t support private file storage",
|
|
3620
3634
|
children: "OPFS isn’t available here. Some private browsing windows and older browsers turn it off. Try a current version of Chrome, Edge, Firefox, or Safari in a normal window."
|
|
3621
3635
|
});
|
|
3622
|
-
else if (
|
|
3636
|
+
else if (D) {
|
|
3623
3637
|
let e = /* @__PURE__ */ W("button", {
|
|
3624
3638
|
type: "button",
|
|
3625
3639
|
className: "seed-fm-btn",
|
|
3626
|
-
onClick: () =>
|
|
3640
|
+
onClick: () => ne(),
|
|
3627
3641
|
children: [/* @__PURE__ */ U($, {
|
|
3628
3642
|
name: "refresh",
|
|
3629
3643
|
size: 15
|
|
3630
3644
|
}), " Try again"]
|
|
3631
3645
|
});
|
|
3632
|
-
He =
|
|
3646
|
+
He = te === "NotFoundError" && S ? /* @__PURE__ */ W(Ei, {
|
|
3633
3647
|
icon: "triangleAlert",
|
|
3634
3648
|
tone: "error",
|
|
3635
3649
|
title: `Can’t open ${S}`,
|
|
@@ -3642,24 +3656,24 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3642
3656
|
/* @__PURE__ */ U("code", { children: "rootPath" }),
|
|
3643
3657
|
" prop, or open the app once so the SDK creates it."
|
|
3644
3658
|
]
|
|
3645
|
-
}) : /* @__PURE__ */ U(
|
|
3659
|
+
}) : /* @__PURE__ */ U(Ei, {
|
|
3646
3660
|
icon: "triangleAlert",
|
|
3647
3661
|
tone: "error",
|
|
3648
3662
|
title: "Can’t read private storage",
|
|
3649
3663
|
action: e,
|
|
3650
|
-
children:
|
|
3664
|
+
children: D
|
|
3651
3665
|
});
|
|
3652
|
-
} else He =
|
|
3666
|
+
} else He = ee ? j.length === 0 ? /* @__PURE__ */ U(Ei, {
|
|
3653
3667
|
icon: "folderOpen",
|
|
3654
3668
|
title: `No files in ${C} yet`,
|
|
3655
3669
|
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."
|
|
3656
|
-
}) :
|
|
3670
|
+
}) : ye.folders.length === 0 && B.length === 0 ? M ? /* @__PURE__ */ W(Ei, {
|
|
3657
3671
|
icon: "search",
|
|
3658
|
-
title: `No matches for “${
|
|
3672
|
+
title: `No matches for “${M}”`,
|
|
3659
3673
|
action: /* @__PURE__ */ U("button", {
|
|
3660
3674
|
type: "button",
|
|
3661
3675
|
className: "seed-fm-btn",
|
|
3662
|
-
onClick: () =>
|
|
3676
|
+
onClick: () => oe(""),
|
|
3663
3677
|
children: "Clear search"
|
|
3664
3678
|
}),
|
|
3665
3679
|
children: [
|
|
@@ -3667,16 +3681,16 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3667
3681
|
ze[ze.length - 1].label,
|
|
3668
3682
|
" and every folder inside it."
|
|
3669
3683
|
]
|
|
3670
|
-
}) : /* @__PURE__ */ U(
|
|
3684
|
+
}) : /* @__PURE__ */ U(Ei, {
|
|
3671
3685
|
icon: "folderOpen",
|
|
3672
3686
|
title: "This folder is empty",
|
|
3673
3687
|
children: "Everything in it has been deleted or filtered out."
|
|
3674
|
-
}) : /* @__PURE__ */ W(H, { children: [
|
|
3688
|
+
}) : /* @__PURE__ */ W(H, { children: [ye.folders.length > 0 && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("div", {
|
|
3675
3689
|
className: "seed-fm-section-label",
|
|
3676
3690
|
children: "Folders"
|
|
3677
3691
|
}), /* @__PURE__ */ U("ul", {
|
|
3678
3692
|
className: "seed-fm-folders",
|
|
3679
|
-
children:
|
|
3693
|
+
children: ye.folders.map((e) => /* @__PURE__ */ W("li", { children: [/* @__PURE__ */ W("button", {
|
|
3680
3694
|
type: "button",
|
|
3681
3695
|
className: w("folder", "seed-fm-folder"),
|
|
3682
3696
|
onClick: () => Ce(e.path),
|
|
@@ -3690,7 +3704,7 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3690
3704
|
}), /* @__PURE__ */ W("span", {
|
|
3691
3705
|
className: "seed-fm-folder-meta",
|
|
3692
3706
|
children: [
|
|
3693
|
-
|
|
3707
|
+
bi(e.fileCount, "file"),
|
|
3694
3708
|
" · ",
|
|
3695
3709
|
Q(e.size)
|
|
3696
3710
|
]
|
|
@@ -3700,33 +3714,33 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3700
3714
|
className: "seed-fm-btn seed-fm-btn--ghost seed-fm-btn--icon seed-fm-folder-delete",
|
|
3701
3715
|
"aria-label": `Delete folder ${e.name}`,
|
|
3702
3716
|
title: "Delete folder",
|
|
3703
|
-
disabled:
|
|
3717
|
+
disabled: ge,
|
|
3704
3718
|
onClick: () => Fe(e),
|
|
3705
3719
|
children: /* @__PURE__ */ U($, {
|
|
3706
3720
|
name: "trash",
|
|
3707
3721
|
size: 15
|
|
3708
3722
|
})
|
|
3709
3723
|
})] }, e.path))
|
|
3710
|
-
})] }),
|
|
3724
|
+
})] }), B.length > 0 && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("div", {
|
|
3711
3725
|
className: "seed-fm-section-label",
|
|
3712
|
-
children:
|
|
3713
|
-
}),
|
|
3714
|
-
entries:
|
|
3715
|
-
selected:
|
|
3726
|
+
children: M ? bi(B.length, "result") : "Files"
|
|
3727
|
+
}), V === "grid" ? /* @__PURE__ */ U(Zr, {
|
|
3728
|
+
entries: B,
|
|
3729
|
+
selected: P,
|
|
3716
3730
|
onActivate: Ee,
|
|
3717
3731
|
onToggle: we,
|
|
3718
3732
|
className: h.grid,
|
|
3719
3733
|
tileClassName: h.tile
|
|
3720
|
-
}) : /* @__PURE__ */ U(
|
|
3721
|
-
entries:
|
|
3722
|
-
selected:
|
|
3723
|
-
cwd:
|
|
3734
|
+
}) : /* @__PURE__ */ U(Qr, {
|
|
3735
|
+
entries: B,
|
|
3736
|
+
selected: P,
|
|
3737
|
+
cwd: ie,
|
|
3724
3738
|
onActivate: Ee,
|
|
3725
3739
|
onToggle: we,
|
|
3726
3740
|
onToggleAll: De,
|
|
3727
3741
|
onDownload: (e) => je([e]),
|
|
3728
|
-
onDelete: (e) =>
|
|
3729
|
-
deleteActionFor: (e) =>
|
|
3742
|
+
onDelete: (e) => X([e]),
|
|
3743
|
+
deleteActionFor: (e) => J([e]),
|
|
3730
3744
|
className: h.list,
|
|
3731
3745
|
rowClassName: h.row
|
|
3732
3746
|
})] })] }) : /* @__PURE__ */ U("ul", {
|
|
@@ -3738,11 +3752,11 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3738
3752
|
children: /* @__PURE__ */ U("span", { className: "seed-fm-thumb seed-fm-skeleton" })
|
|
3739
3753
|
}, t))
|
|
3740
3754
|
});
|
|
3741
|
-
let Ue = pe ? Me(pe, !0) : [], We =
|
|
3755
|
+
let Ue = pe ? Me(pe, !0) : [], We = L ? Pe(L) : [], Ge = P.size > 0 ? J(Se) : null;
|
|
3742
3756
|
return /* @__PURE__ */ W("div", {
|
|
3743
3757
|
className: [w("root", "seed-fm"), m].filter(Boolean).join(" "),
|
|
3744
3758
|
"data-seed-theme": p === "none" ? void 0 : p,
|
|
3745
|
-
"data-selecting":
|
|
3759
|
+
"data-selecting": P.size > 0 || void 0,
|
|
3746
3760
|
onKeyDown: Le,
|
|
3747
3761
|
children: [
|
|
3748
3762
|
/* @__PURE__ */ W("div", {
|
|
@@ -3761,17 +3775,17 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3761
3775
|
children: d
|
|
3762
3776
|
})]
|
|
3763
3777
|
}),
|
|
3764
|
-
|
|
3765
|
-
files:
|
|
3766
|
-
estimate:
|
|
3778
|
+
ee && !D && /* @__PURE__ */ U(Ti, {
|
|
3779
|
+
files: O,
|
|
3780
|
+
estimate: re
|
|
3767
3781
|
}),
|
|
3768
3782
|
/* @__PURE__ */ U("button", {
|
|
3769
3783
|
type: "button",
|
|
3770
3784
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3771
|
-
onClick: () =>
|
|
3785
|
+
onClick: () => ne(),
|
|
3772
3786
|
"aria-label": "Refresh",
|
|
3773
3787
|
title: "Refresh",
|
|
3774
|
-
"data-busy": E &&
|
|
3788
|
+
"data-busy": E && ee,
|
|
3775
3789
|
children: /* @__PURE__ */ U($, {
|
|
3776
3790
|
name: "refresh",
|
|
3777
3791
|
size: 15
|
|
@@ -3779,7 +3793,7 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3779
3793
|
})
|
|
3780
3794
|
]
|
|
3781
3795
|
}),
|
|
3782
|
-
|
|
3796
|
+
ee && !D && j.length > 0 && /* @__PURE__ */ W("div", {
|
|
3783
3797
|
className: w("toolbar", "seed-fm-toolbar"),
|
|
3784
3798
|
children: [
|
|
3785
3799
|
/* @__PURE__ */ U("nav", {
|
|
@@ -3804,16 +3818,16 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3804
3818
|
size: 14
|
|
3805
3819
|
}), /* @__PURE__ */ U("input", {
|
|
3806
3820
|
type: "search",
|
|
3807
|
-
value:
|
|
3808
|
-
onChange: (e) =>
|
|
3821
|
+
value: M,
|
|
3822
|
+
onChange: (e) => oe(e.target.value),
|
|
3809
3823
|
placeholder: "Search names and paths",
|
|
3810
3824
|
"aria-label": "Search files"
|
|
3811
3825
|
})]
|
|
3812
3826
|
}),
|
|
3813
3827
|
/* @__PURE__ */ W("select", {
|
|
3814
3828
|
className: "seed-fm-select",
|
|
3815
|
-
value:
|
|
3816
|
-
onChange: (e) =>
|
|
3829
|
+
value: se,
|
|
3830
|
+
onChange: (e) => ce(e.target.value),
|
|
3817
3831
|
"aria-label": "Sort by",
|
|
3818
3832
|
children: [
|
|
3819
3833
|
/* @__PURE__ */ U("option", {
|
|
@@ -3836,39 +3850,39 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3836
3850
|
"aria-label": "View",
|
|
3837
3851
|
children: [/* @__PURE__ */ U("button", {
|
|
3838
3852
|
type: "button",
|
|
3839
|
-
"aria-pressed":
|
|
3853
|
+
"aria-pressed": V === "grid",
|
|
3840
3854
|
"aria-label": "Grid view",
|
|
3841
|
-
onClick: () =>
|
|
3855
|
+
onClick: () => le("grid"),
|
|
3842
3856
|
children: /* @__PURE__ */ U($, {
|
|
3843
3857
|
name: "layoutGrid",
|
|
3844
3858
|
size: 15
|
|
3845
3859
|
})
|
|
3846
3860
|
}), /* @__PURE__ */ U("button", {
|
|
3847
3861
|
type: "button",
|
|
3848
|
-
"aria-pressed":
|
|
3862
|
+
"aria-pressed": V === "list",
|
|
3849
3863
|
"aria-label": "List view",
|
|
3850
|
-
onClick: () =>
|
|
3864
|
+
onClick: () => le("list"),
|
|
3851
3865
|
children: /* @__PURE__ */ U($, {
|
|
3852
3866
|
name: "list",
|
|
3853
3867
|
size: 15
|
|
3854
3868
|
})
|
|
3855
3869
|
})]
|
|
3856
3870
|
}),
|
|
3857
|
-
|
|
3871
|
+
Re && Z && /* @__PURE__ */ W("p", {
|
|
3858
3872
|
className: "seed-fm-hint",
|
|
3859
3873
|
children: [
|
|
3860
3874
|
/* @__PURE__ */ U($, {
|
|
3861
3875
|
name: "layers",
|
|
3862
3876
|
size: 13
|
|
3863
3877
|
}),
|
|
3864
|
-
|
|
3878
|
+
k ? "Resized copies are grouped with their original image." : "Resized copies are shown in their size folders.",
|
|
3865
3879
|
/* @__PURE__ */ U("button", {
|
|
3866
3880
|
type: "button",
|
|
3867
3881
|
className: "seed-fm-linkbtn",
|
|
3868
3882
|
onClick: () => {
|
|
3869
|
-
|
|
3883
|
+
A(!k), F(/* @__PURE__ */ new Set());
|
|
3870
3884
|
},
|
|
3871
|
-
children:
|
|
3885
|
+
children: k ? "Show as folders" : "Group with originals"
|
|
3872
3886
|
})
|
|
3873
3887
|
]
|
|
3874
3888
|
})
|
|
@@ -3887,7 +3901,7 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3887
3901
|
className: "seed-fm-batch-count",
|
|
3888
3902
|
"aria-live": "polite",
|
|
3889
3903
|
children: [
|
|
3890
|
-
|
|
3904
|
+
P.size,
|
|
3891
3905
|
" selected ",
|
|
3892
3906
|
/* @__PURE__ */ W("span", { children: ["· ", Q(Ve)] })
|
|
3893
3907
|
]
|
|
@@ -3895,7 +3909,7 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3895
3909
|
/* @__PURE__ */ W("button", {
|
|
3896
3910
|
type: "button",
|
|
3897
3911
|
className: "seed-fm-btn",
|
|
3898
|
-
disabled:
|
|
3912
|
+
disabled: ge,
|
|
3899
3913
|
onClick: () => je(Se),
|
|
3900
3914
|
children: [
|
|
3901
3915
|
/* @__PURE__ */ U($, {
|
|
@@ -3903,14 +3917,14 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3903
3917
|
size: 15
|
|
3904
3918
|
}),
|
|
3905
3919
|
" ",
|
|
3906
|
-
|
|
3920
|
+
P.size > 1 ? "Download .zip" : "Download"
|
|
3907
3921
|
]
|
|
3908
3922
|
}),
|
|
3909
3923
|
/* @__PURE__ */ W("button", {
|
|
3910
3924
|
type: "button",
|
|
3911
3925
|
className: `seed-fm-btn${Ge.destructive ? " seed-fm-btn--danger-text" : ""}`,
|
|
3912
|
-
disabled:
|
|
3913
|
-
onClick: () =>
|
|
3926
|
+
disabled: ge,
|
|
3927
|
+
onClick: () => X(Se),
|
|
3914
3928
|
children: [
|
|
3915
3929
|
/* @__PURE__ */ U($, {
|
|
3916
3930
|
name: "trash",
|
|
@@ -3924,7 +3938,7 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3924
3938
|
type: "button",
|
|
3925
3939
|
className: "seed-fm-btn seed-fm-btn--icon",
|
|
3926
3940
|
"aria-label": "Clear selection",
|
|
3927
|
-
onClick: () =>
|
|
3941
|
+
onClick: () => F(/* @__PURE__ */ new Set()),
|
|
3928
3942
|
children: /* @__PURE__ */ U($, {
|
|
3929
3943
|
name: "x",
|
|
3930
3944
|
size: 15
|
|
@@ -3934,47 +3948,47 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3934
3948
|
})
|
|
3935
3949
|
]
|
|
3936
3950
|
}),
|
|
3937
|
-
G && /* @__PURE__ */ U(
|
|
3951
|
+
G && /* @__PURE__ */ U(ni, {
|
|
3938
3952
|
entry: G,
|
|
3939
3953
|
className: h.panel,
|
|
3940
|
-
onClose:
|
|
3941
|
-
onPrevious: K > 0 ? () => de(
|
|
3942
|
-
onNext: K >= 0 && K <
|
|
3954
|
+
onClose: q,
|
|
3955
|
+
onPrevious: K > 0 ? () => de(B[K - 1].file.path) : null,
|
|
3956
|
+
onNext: K >= 0 && K < B.length - 1 ? () => de(B[K + 1].file.path) : null,
|
|
3943
3957
|
onDownload: () => je([G]),
|
|
3944
|
-
onDelete: () =>
|
|
3945
|
-
deleteAction:
|
|
3958
|
+
onDelete: () => X([G]),
|
|
3959
|
+
deleteAction: J([G]),
|
|
3946
3960
|
onCopyPath: () => Ie(G.file.path)
|
|
3947
3961
|
}, "panel"),
|
|
3948
|
-
pe && /* @__PURE__ */ U(
|
|
3962
|
+
pe && /* @__PURE__ */ U(mr, {
|
|
3949
3963
|
entries: pe,
|
|
3950
3964
|
rootPath: S,
|
|
3951
3965
|
warning: v(Ue),
|
|
3952
|
-
deleteActionFor: (e) =>
|
|
3966
|
+
deleteActionFor: (e) => Ne(Me(pe, e)),
|
|
3953
3967
|
className: h.dialog,
|
|
3954
|
-
onCancel: () =>
|
|
3968
|
+
onCancel: () => me(null),
|
|
3955
3969
|
onConfirm: (e) => {
|
|
3956
3970
|
let t = Me(pe, e);
|
|
3957
|
-
|
|
3971
|
+
me(null), Y(t);
|
|
3958
3972
|
}
|
|
3959
3973
|
}),
|
|
3960
|
-
|
|
3961
|
-
folder:
|
|
3974
|
+
L && /* @__PURE__ */ U(hr, {
|
|
3975
|
+
folder: L,
|
|
3962
3976
|
files: We,
|
|
3963
|
-
hiddenCount: T.filter((e) => e.path.startsWith(`${
|
|
3977
|
+
hiddenCount: T.filter((e) => e.path.startsWith(`${L.path}/`)).length - We.length,
|
|
3964
3978
|
warning: v(We),
|
|
3965
|
-
action:
|
|
3966
|
-
busy:
|
|
3979
|
+
action: Ne(We),
|
|
3980
|
+
busy: ge,
|
|
3967
3981
|
className: h.dialog,
|
|
3968
|
-
onDownload: () => Ae(We,
|
|
3969
|
-
onCancel: () =>
|
|
3982
|
+
onDownload: () => Ae(We, L),
|
|
3983
|
+
onCancel: () => he(null),
|
|
3970
3984
|
onConfirm: () => {
|
|
3971
|
-
|
|
3985
|
+
he(null), Y(We, L);
|
|
3972
3986
|
}
|
|
3973
3987
|
}),
|
|
3974
3988
|
!x && /* @__PURE__ */ U("ul", {
|
|
3975
3989
|
className: "seed-fm-toasts",
|
|
3976
3990
|
"aria-live": "polite",
|
|
3977
|
-
children:
|
|
3991
|
+
children: R.map((e) => /* @__PURE__ */ W("li", {
|
|
3978
3992
|
className: w("toast", `seed-fm-toast${e.tone === "error" ? " seed-fm-toast--error" : ""}`),
|
|
3979
3993
|
children: [/* @__PURE__ */ U($, {
|
|
3980
3994
|
name: e.tone === "error" ? "triangleAlert" : "check",
|
|
@@ -3988,15 +4002,15 @@ function wi({ rootPath: e, filter: t, onBeforeDelete: n, onAfterDelete: r, onDow
|
|
|
3988
4002
|
}
|
|
3989
4003
|
//#endregion
|
|
3990
4004
|
//#region src/useEnsureLocalImage.ts
|
|
3991
|
-
var
|
|
4005
|
+
var Oi = (e) => {
|
|
3992
4006
|
try {
|
|
3993
4007
|
return e.getService?.()?.getSnapshot?.()?.context?.storageTransactionId || void 0;
|
|
3994
4008
|
} catch {
|
|
3995
4009
|
return;
|
|
3996
4010
|
}
|
|
3997
4011
|
};
|
|
3998
|
-
function
|
|
3999
|
-
let { imageProperty: t, filename: r, width: a, enabled: s = !0 } = e, [l, u] = c(null), [f, p] = c("idle"), m = t?.refResolvedValue, h = t?.value, g = typeof h == "string" ? h : void 0, _ =
|
|
4012
|
+
function ki(e) {
|
|
4013
|
+
let { imageProperty: t, filename: r, width: a, enabled: s = !0 } = e, [l, u] = c(null), [f, p] = c("idle"), m = t?.refResolvedValue, h = t?.value, g = typeof h == "string" ? h : void 0, _ = Oi(t), v = o(() => I(_) ?? I(r) ?? I(m) ?? I(g), [
|
|
4000
4014
|
_,
|
|
4001
4015
|
r,
|
|
4002
4016
|
m,
|
|
@@ -4009,7 +4023,7 @@ function Ei(e) {
|
|
|
4009
4023
|
if (!v) return [];
|
|
4010
4024
|
let e = [];
|
|
4011
4025
|
try {
|
|
4012
|
-
for (let t of
|
|
4026
|
+
for (let t of k()) {
|
|
4013
4027
|
let n = `${t.replace(/\/$/, "")}/raw/${v}`;
|
|
4014
4028
|
e.includes(n) || e.push(n);
|
|
4015
4029
|
}
|
|
@@ -4034,7 +4048,7 @@ function Ei(e) {
|
|
|
4034
4048
|
else {
|
|
4035
4049
|
e || p("loading");
|
|
4036
4050
|
try {
|
|
4037
|
-
let t = await
|
|
4051
|
+
let t = await te({
|
|
4038
4052
|
transactionId: v,
|
|
4039
4053
|
fileName: y,
|
|
4040
4054
|
widths: a == null ? void 0 : [a]
|
|
@@ -4064,23 +4078,23 @@ function Ei(e) {
|
|
|
4064
4078
|
}
|
|
4065
4079
|
//#endregion
|
|
4066
4080
|
//#region src/SeedImage.tsx
|
|
4067
|
-
var
|
|
4081
|
+
var Ai = V("seedSdk:react:SeedImage"), ji = /* @__PURE__ */ new Map(), Mi = (e) => {
|
|
4068
4082
|
let t = e.match(/^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/);
|
|
4069
4083
|
return t && t[2] ? t[2] : e;
|
|
4070
4084
|
};
|
|
4071
|
-
function
|
|
4085
|
+
function Ni(e) {
|
|
4072
4086
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4073
4087
|
}
|
|
4074
|
-
function
|
|
4075
|
-
let n = RegExp(`^${
|
|
4088
|
+
function Pi(e, t) {
|
|
4089
|
+
let n = RegExp(`^${Ni(t)}$`), r = Mi(e);
|
|
4076
4090
|
return n.test(r);
|
|
4077
4091
|
}
|
|
4078
|
-
var
|
|
4079
|
-
let [l, u] = c(), [d, f] = c(), { property: m } =
|
|
4092
|
+
var Fi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure: a = !0, ...o }, s) => {
|
|
4093
|
+
let [l, u] = c(), [d, f] = c(), { property: m } = _t({
|
|
4080
4094
|
propertyName: t.propertyName,
|
|
4081
4095
|
seedLocalId: t.seedLocalId,
|
|
4082
4096
|
seedUid: t.seedUid
|
|
4083
|
-
}), h = t ?? m, g = r ?? h?.refResolvedValue ?? h?.value, { status: _, gatewayHref: v, onGatewayError: y } =
|
|
4097
|
+
}), h = t ?? m, g = r ?? h?.refResolvedValue ?? h?.value, { status: _, gatewayHref: v, onGatewayError: y } = ki({
|
|
4084
4098
|
imageProperty: h ?? t,
|
|
4085
4099
|
filename: r,
|
|
4086
4100
|
width: n,
|
|
@@ -4104,7 +4118,7 @@ var Mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4104
4118
|
!e && n && f(n);
|
|
4105
4119
|
}
|
|
4106
4120
|
} catch (e) {
|
|
4107
|
-
|
|
4121
|
+
Ai("_getOriginalContentUrl error", e);
|
|
4108
4122
|
}
|
|
4109
4123
|
})(), () => {
|
|
4110
4124
|
e = !0;
|
|
@@ -4120,25 +4134,25 @@ var Mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4120
4134
|
try {
|
|
4121
4135
|
let e = await p.getFs(), t = h?.localStoragePath ? h.localStoragePath.split("/").slice(0, -1).join("/") : p.getFilesPath("images"), r = e.readdirSync(t, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => parseInt(e.name)).filter((e) => !Number.isNaN(e));
|
|
4122
4136
|
if (r.length === 0) return;
|
|
4123
|
-
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a =
|
|
4124
|
-
if (
|
|
4125
|
-
let e =
|
|
4137
|
+
let i = r.reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e, r[0]), a = Mi(g), o = `${a}-${i}`;
|
|
4138
|
+
if (ji.has(o)) try {
|
|
4139
|
+
let e = ji.get(o);
|
|
4126
4140
|
if (e && (await fetch(e)).ok) {
|
|
4127
4141
|
u(e);
|
|
4128
4142
|
return;
|
|
4129
4143
|
}
|
|
4130
4144
|
} catch (e) {
|
|
4131
|
-
|
|
4145
|
+
Ai("error", e), ji.delete(o);
|
|
4132
4146
|
}
|
|
4133
|
-
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ?
|
|
4147
|
+
let s = e.readdirSync(`${t}/${i}`, { withFileTypes: !0 }).find((e) => e.name ? Pi(e.name, a) : !1);
|
|
4134
4148
|
if (!s) return;
|
|
4135
4149
|
let c = `${t}/${i}/${s?.name}`;
|
|
4136
4150
|
if (await p.pathExists(c)) {
|
|
4137
4151
|
let e = await p.getContentUrlFromPath(c);
|
|
4138
|
-
e && (
|
|
4152
|
+
e && (ji.set(o, e), u(e));
|
|
4139
4153
|
}
|
|
4140
4154
|
} catch (e) {
|
|
4141
|
-
|
|
4155
|
+
Ai("_getSizedContentUrl error", e);
|
|
4142
4156
|
}
|
|
4143
4157
|
})();
|
|
4144
4158
|
}, [
|
|
@@ -4148,23 +4162,23 @@ var Mi = e.memo(e.forwardRef(({ imageProperty: t, width: n, filename: r, ensure:
|
|
|
4148
4162
|
g,
|
|
4149
4163
|
_
|
|
4150
4164
|
]);
|
|
4151
|
-
let E = (e) => typeof e == "string" && e.startsWith("blob:"),
|
|
4152
|
-
if (!
|
|
4153
|
-
let
|
|
4154
|
-
v &&
|
|
4165
|
+
let E = (e) => typeof e == "string" && e.startsWith("blob:"), ee = !!l || !!d || !!C || !!x && E(x);
|
|
4166
|
+
if (!ee && !g && !v) return null;
|
|
4167
|
+
let D = l || d || C || (E(x) ? x : void 0) || (a && !ee ? v : void 0) || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", { onError: te, ...ne } = o, O = (e) => {
|
|
4168
|
+
v && D === v && y(), te?.(e);
|
|
4155
4169
|
};
|
|
4156
4170
|
return /* @__PURE__ */ U("img", {
|
|
4157
|
-
src:
|
|
4171
|
+
src: D,
|
|
4158
4172
|
alt: o.alt || t.propertyName || "Image",
|
|
4159
4173
|
width: n,
|
|
4160
|
-
...
|
|
4174
|
+
...ne,
|
|
4161
4175
|
ref: s,
|
|
4162
|
-
onError:
|
|
4176
|
+
onError: O
|
|
4163
4177
|
});
|
|
4164
4178
|
}));
|
|
4165
4179
|
//#endregion
|
|
4166
4180
|
//#region src/useResolvedMediaRef.ts
|
|
4167
|
-
function
|
|
4181
|
+
function Ii(e) {
|
|
4168
4182
|
let { value: t, enabled: r = !0, treatAs: a } = e, [o, s] = c(0), l = JSON.stringify([
|
|
4169
4183
|
r,
|
|
4170
4184
|
t ?? null,
|
|
@@ -4188,7 +4202,7 @@ function Ni(e) {
|
|
|
4188
4202
|
error: null
|
|
4189
4203
|
});
|
|
4190
4204
|
try {
|
|
4191
|
-
let r = await
|
|
4205
|
+
let r = await _e(String(t), { treatAs: a }), i = r.status === "ready" && r.source === "localBlob" ? r.href : void 0;
|
|
4192
4206
|
if (e) {
|
|
4193
4207
|
i && URL.revokeObjectURL(i);
|
|
4194
4208
|
return;
|
|
@@ -4234,8 +4248,8 @@ function Ni(e) {
|
|
|
4234
4248
|
}
|
|
4235
4249
|
//#endregion
|
|
4236
4250
|
//#region src/SeedMediaImage.tsx
|
|
4237
|
-
function
|
|
4238
|
-
let { href: o } =
|
|
4251
|
+
function Li({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
4252
|
+
let { href: o } = Ii({
|
|
4239
4253
|
value: e,
|
|
4240
4254
|
enabled: t,
|
|
4241
4255
|
treatAs: n
|
|
@@ -4250,14 +4264,14 @@ function Pi({ value: e, enabled: t, treatAs: n, render: r, alt: i, ...a }) {
|
|
|
4250
4264
|
}
|
|
4251
4265
|
//#endregion
|
|
4252
4266
|
//#region src/SeedMediaFile.tsx
|
|
4253
|
-
function
|
|
4267
|
+
function Ri(e) {
|
|
4254
4268
|
try {
|
|
4255
4269
|
return new URL(e).pathname.split("/").filter(Boolean).pop() || "Open";
|
|
4256
4270
|
} catch {
|
|
4257
4271
|
return "Open";
|
|
4258
4272
|
}
|
|
4259
4273
|
}
|
|
4260
|
-
function
|
|
4274
|
+
function zi(e) {
|
|
4261
4275
|
try {
|
|
4262
4276
|
let t = new URL(e).protocol;
|
|
4263
4277
|
return t === "http:" || t === "https:";
|
|
@@ -4265,27 +4279,27 @@ function Ii(e) {
|
|
|
4265
4279
|
return !1;
|
|
4266
4280
|
}
|
|
4267
4281
|
}
|
|
4268
|
-
function
|
|
4269
|
-
let { href: l } =
|
|
4282
|
+
function Bi({ value: e, enabled: t, treatAs: n, download: r, render: i, children: a, target: o, rel: s, ...c }) {
|
|
4283
|
+
let { href: l } = Ii({
|
|
4270
4284
|
value: e,
|
|
4271
4285
|
enabled: t,
|
|
4272
4286
|
treatAs: n
|
|
4273
4287
|
});
|
|
4274
4288
|
if (!l) return null;
|
|
4275
|
-
let u =
|
|
4289
|
+
let u = zi(l), d = o === void 0 ? u ? "_blank" : void 0 : o, f = {
|
|
4276
4290
|
...c,
|
|
4277
4291
|
href: l,
|
|
4278
4292
|
download: r,
|
|
4279
4293
|
target: d,
|
|
4280
4294
|
rel: s ?? (u && d === "_blank" ? "noopener noreferrer" : void 0),
|
|
4281
|
-
children: a ??
|
|
4295
|
+
children: a ?? Ri(l)
|
|
4282
4296
|
};
|
|
4283
4297
|
return i ? /* @__PURE__ */ U(H, { children: i(f) }) : /* @__PURE__ */ U("a", { ...f });
|
|
4284
4298
|
}
|
|
4285
4299
|
//#endregion
|
|
4286
4300
|
//#region src/SeedMediaAudio.tsx
|
|
4287
|
-
function
|
|
4288
|
-
let { href: o } =
|
|
4301
|
+
function Vi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
4302
|
+
let { href: o } = Ii({
|
|
4289
4303
|
value: e,
|
|
4290
4304
|
enabled: t,
|
|
4291
4305
|
treatAs: n
|
|
@@ -4300,8 +4314,8 @@ function Ri({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
4300
4314
|
}
|
|
4301
4315
|
//#endregion
|
|
4302
4316
|
//#region src/SeedMediaVideo.tsx
|
|
4303
|
-
function
|
|
4304
|
-
let { href: o } =
|
|
4317
|
+
function Hi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...a }) {
|
|
4318
|
+
let { href: o } = Ii({
|
|
4305
4319
|
value: e,
|
|
4306
4320
|
enabled: t,
|
|
4307
4321
|
treatAs: n
|
|
@@ -4316,39 +4330,39 @@ function zi({ value: e, enabled: t, treatAs: n, render: r, controls: i = !0, ...
|
|
|
4316
4330
|
}
|
|
4317
4331
|
//#endregion
|
|
4318
4332
|
//#region src/SeedHtml.tsx
|
|
4319
|
-
function
|
|
4333
|
+
function Ui(e) {
|
|
4320
4334
|
return typeof e == "string" && e.trim().length > 0;
|
|
4321
4335
|
}
|
|
4322
|
-
var
|
|
4336
|
+
var Wi = /* @__PURE__ */ new Set([
|
|
4323
4337
|
"img",
|
|
4324
4338
|
"video",
|
|
4325
4339
|
"audio",
|
|
4326
4340
|
"source"
|
|
4327
|
-
]),
|
|
4341
|
+
]), Gi = [
|
|
4328
4342
|
"src",
|
|
4329
4343
|
"srcset",
|
|
4330
4344
|
"poster"
|
|
4331
4345
|
];
|
|
4332
|
-
function
|
|
4346
|
+
function Ki(e) {
|
|
4333
4347
|
let t = (e) => {
|
|
4334
4348
|
let t = e.target;
|
|
4335
|
-
if (!(t instanceof Element) || !
|
|
4349
|
+
if (!(t instanceof Element) || !Wi.has(t.tagName.toLowerCase())) return;
|
|
4336
4350
|
let n = !1;
|
|
4337
|
-
for (let e of
|
|
4351
|
+
for (let e of Gi) {
|
|
4338
4352
|
let r = t.getAttribute(e);
|
|
4339
4353
|
if (!r) continue;
|
|
4340
|
-
let i =
|
|
4354
|
+
let i = ce(e, r, (e) => F(e));
|
|
4341
4355
|
i !== void 0 && (t.setAttribute(e, i), n = !0);
|
|
4342
4356
|
}
|
|
4343
4357
|
n && t.tagName.toLowerCase() === "source" && t.parentElement?.load?.();
|
|
4344
4358
|
};
|
|
4345
4359
|
return e.addEventListener("error", t, !0), () => e.removeEventListener("error", t, !0);
|
|
4346
4360
|
}
|
|
4347
|
-
function
|
|
4348
|
-
let a = e.useRef(null), o = e.useMemo(() =>
|
|
4361
|
+
function qi({ html: t, sanitize: n, render: r, ...i }) {
|
|
4362
|
+
let a = e.useRef(null), o = e.useMemo(() => Ui(t) ? n(ge(t)) : void 0, [t, n]);
|
|
4349
4363
|
return e.useEffect(() => {
|
|
4350
4364
|
let e = a.current;
|
|
4351
|
-
return e ?
|
|
4365
|
+
return e ? Ki(e) : void 0;
|
|
4352
4366
|
}, [o, r]), o === void 0 ? null : r ? /* @__PURE__ */ U(H, { children: r({ html: o }) }) : /* @__PURE__ */ U("div", {
|
|
4353
4367
|
...i,
|
|
4354
4368
|
ref: a,
|
|
@@ -4357,46 +4371,46 @@ function Wi({ html: t, sanitize: n, render: r, ...i }) {
|
|
|
4357
4371
|
}
|
|
4358
4372
|
//#endregion
|
|
4359
4373
|
//#region src/formatSeedJson.ts
|
|
4360
|
-
function
|
|
4374
|
+
function Ji(e, t) {
|
|
4361
4375
|
return e.length <= t ? e : `${e.slice(0, t)}…`;
|
|
4362
4376
|
}
|
|
4363
|
-
function
|
|
4377
|
+
function Yi(e) {
|
|
4364
4378
|
let t = e.trim();
|
|
4365
4379
|
return t.startsWith("{") && t.endsWith("}") || t.startsWith("[") && t.endsWith("]");
|
|
4366
4380
|
}
|
|
4367
|
-
function
|
|
4381
|
+
function Xi(e, t, n, r, i) {
|
|
4368
4382
|
if (typeof e == "bigint") return String(e);
|
|
4369
4383
|
if (typeof e == "symbol") return e.toString();
|
|
4370
4384
|
if (typeof e == "function") return "[Function]";
|
|
4371
4385
|
if (e instanceof Date) return e.toISOString();
|
|
4372
|
-
if (typeof e == "string") return
|
|
4386
|
+
if (typeof e == "string") return Ji(e, n);
|
|
4373
4387
|
if (typeof e != "object" || !e) return e;
|
|
4374
4388
|
if (i.has(e)) return "[Circular]";
|
|
4375
4389
|
if (r >= t) return "[Max depth]";
|
|
4376
4390
|
i.add(e);
|
|
4377
4391
|
try {
|
|
4378
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
4392
|
+
if (Array.isArray(e)) return e.map((e) => Xi(e, t, n, r + 1, i));
|
|
4379
4393
|
let a = {};
|
|
4380
|
-
for (let [o, s] of Object.entries(e)) a[o] =
|
|
4394
|
+
for (let [o, s] of Object.entries(e)) a[o] = Xi(s, t, n, r + 1, i);
|
|
4381
4395
|
return a;
|
|
4382
4396
|
} finally {
|
|
4383
4397
|
i.delete(e);
|
|
4384
4398
|
}
|
|
4385
4399
|
}
|
|
4386
|
-
function
|
|
4400
|
+
function Zi(e, t) {
|
|
4387
4401
|
let n = t?.maxDepth ?? 6, r = t?.maxStringLength ?? 5e4, i = t?.space ?? 2;
|
|
4388
4402
|
if (e === void 0) return "undefined";
|
|
4389
4403
|
if (e === null) return "null";
|
|
4390
4404
|
let a = e;
|
|
4391
4405
|
if (typeof e == "string") {
|
|
4392
|
-
if (
|
|
4406
|
+
if (Yi(e)) try {
|
|
4393
4407
|
a = JSON.parse(e);
|
|
4394
4408
|
} catch {
|
|
4395
|
-
return
|
|
4409
|
+
return Ji(e, r);
|
|
4396
4410
|
}
|
|
4397
|
-
else return
|
|
4411
|
+
else return Ji(e, r);
|
|
4398
4412
|
}
|
|
4399
|
-
let o =
|
|
4413
|
+
let o = Xi(a, n, r, 0, /* @__PURE__ */ new WeakSet());
|
|
4400
4414
|
try {
|
|
4401
4415
|
return JSON.stringify(o, null, i);
|
|
4402
4416
|
} catch {
|
|
@@ -4405,8 +4419,8 @@ function Ji(e, t) {
|
|
|
4405
4419
|
}
|
|
4406
4420
|
//#endregion
|
|
4407
4421
|
//#region src/SeedJson.tsx
|
|
4408
|
-
function
|
|
4409
|
-
let a = t ? t(e) :
|
|
4422
|
+
function Qi({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
4423
|
+
let a = t ? t(e) : Zi(e, n);
|
|
4410
4424
|
return r ? /* @__PURE__ */ U(H, { children: r({ text: a }) }) : /* @__PURE__ */ U("pre", {
|
|
4411
4425
|
...i,
|
|
4412
4426
|
children: a
|
|
@@ -4414,10 +4428,10 @@ function Yi({ value: e, format: t, formatOptions: n, render: r, ...i }) {
|
|
|
4414
4428
|
}
|
|
4415
4429
|
//#endregion
|
|
4416
4430
|
//#region src/useNormalizedFeedItemFields.ts
|
|
4417
|
-
function
|
|
4418
|
-
return o(() => e ?
|
|
4431
|
+
function $i(e, t) {
|
|
4432
|
+
return o(() => e ? de(e, t) : {}, [e, t]);
|
|
4419
4433
|
}
|
|
4420
4434
|
//#endregion
|
|
4421
|
-
export {
|
|
4435
|
+
export { Pe as ADDRESSES_PERSISTED_EVENT, wn as FILES_QUERY_KEY_PREFIX, Fe as LOCAL_COPIES_REMOVED_EVENT, Di as OPFSFilesManager, si as OPFS_FILES_MANAGER_CSS, Hn as SeedClientGate, qi as SeedHtml, Fi as SeedImage, Qi as SeedJson, Vi as SeedMediaAudio, Bi as SeedMediaFile, Li as SeedMediaImage, Hi as SeedMediaVideo, zn as SeedProvider, Ki as attachArweaveLoadFailover, Ke as createSeedQueryClient, Zi as formatSeedJson, gt as getItemPropertyQueryKey, Qe as getItemQueryKey, Pt as getPercentComplete, We as getSeedQueryDefaultOptions, At as getServiceName, Mt as getServiceUniqueKey, jt as getServiceValue, In as invalidateItemPropertiesForItem, M as isClientReadySnapshot, Et as isDbReadyState, Ge as mergeSeedQueryDefaults, $t as useAllSchemaVersions, J as useClientSelector, Ne as useClientService, ut as useCreateItem, Ct as useCreateItemProperty, cn as useCreateModel, yn as useCreateModelProperty, Zt as useCreateSchema, Dt as useDbsAreReady, vt as useDebouncedItemProperty, xn as useDeleteItem, wt as useDestroyItemProperty, ln as useDestroyModel, bn as useDestroyModelProperty, Qt as useDestroySchema, jn as useEasSyncProcessById, kn as useEasSyncProcesses, An as useEasSyncProcessesNonActiveCount, On as useEasSyncProcessesState, ki as useEnsureLocalImage, Tn as useFiles, Vt as useGlobalServiceStatus, Rt as useHasSavedSnapshots, Cn as useImageFiles, Y as useIsClientReady, It as useIsDbReady, $e as useItem, St as useItemProperties, _t as useItemProperty, ot as useItems, Z as useLiveQuery, He as useLiveQueryState, sn as useModel, pn as useModelProperties, vn as useModelProperty, on as useModels, $i as useNormalizedFeedItemFields, rr as useOPFSFiles, Lt as usePersistedSnapshots, dt as usePublishItem, Ii as useResolvedMediaRef, Gt as useSchema, Xt as useSchemas, Le as useSeedAddressRevision, en as useSeedProtocolSchema, Ft as useService, Bt as useServices, li as useStorageEstimate, Kr as useThumbnail };
|
|
4422
4436
|
|
|
4423
4437
|
//# sourceMappingURL=index.js.map
|