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