@declarion/react 0.4.1 → 0.4.2
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-lib/{DraggableChildrenTable---ODhvpn.js → DraggableChildrenTable-DjSEK6XF.js} +2 -2
- package/dist-lib/{DraggableChildrenTable---ODhvpn.js.map → DraggableChildrenTable-DjSEK6XF.js.map} +1 -1
- package/dist-lib/{Grid-BEEwkvX8.js → Grid-D8gOvkf3.js} +2 -2
- package/dist-lib/{Grid-BEEwkvX8.js.map → Grid-D8gOvkf3.js.map} +1 -1
- package/dist-lib/api/entities.d.ts +10 -1
- package/dist-lib/{dataTableStyles-BrYVdg1O.js → dataTableStyles-eleWR-pg.js} +3 -3
- package/dist-lib/{dataTableStyles-BrYVdg1O.js.map → dataTableStyles-eleWR-pg.js.map} +1 -1
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.js +1580 -1572
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/types/api.d.ts +22 -0
- package/dist-lib/{value-DaEUgsnK.js → value-CiwnEAde.js} +163 -157
- package/dist-lib/value-CiwnEAde.js.map +1 -0
- package/package.json +1 -1
- package/dist-lib/value-DaEUgsnK.js.map +0 -1
|
@@ -9,36 +9,42 @@ var c = class extends Error {
|
|
|
9
9
|
constructor(e, t, n, r, i) {
|
|
10
10
|
super(t), this.name = "ApiError", this.status = e, this.code = n, this.index = r, this.raw = i;
|
|
11
11
|
}
|
|
12
|
-
}, l = "
|
|
12
|
+
}, l = "cursor_semantics_mismatch", u = "cursor_locale_changed";
|
|
13
|
+
function d(e) {
|
|
14
|
+
return e instanceof c && (e.code === "cursor_semantics_mismatch" || e.code === "cursor_locale_changed");
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/api/auth-redirect.ts
|
|
18
|
+
var f = "/", p = "/login", m = "/signup", h = "https://declarion.local";
|
|
13
19
|
function ee(e) {
|
|
14
20
|
let t = e.split(/[?#]/, 1)[0];
|
|
15
|
-
return t ===
|
|
21
|
+
return t === p || t.startsWith(`${p}/`) || t === m || t.startsWith(`${m}/`);
|
|
16
22
|
}
|
|
17
|
-
function
|
|
18
|
-
if (!e) return
|
|
23
|
+
function te(e) {
|
|
24
|
+
if (!e) return f;
|
|
19
25
|
let t = e.toLowerCase();
|
|
20
|
-
if (!e.startsWith("/") || e.startsWith("//") || e.includes("\\") || t.includes("%5c")) return
|
|
26
|
+
if (!e.startsWith("/") || e.startsWith("//") || e.includes("\\") || t.includes("%5c")) return f;
|
|
21
27
|
try {
|
|
22
|
-
let t = new URL(e,
|
|
23
|
-
if (t.origin !==
|
|
28
|
+
let t = new URL(e, h);
|
|
29
|
+
if (t.origin !== h) return f;
|
|
24
30
|
let n = `${t.pathname}${t.search}${t.hash}`;
|
|
25
|
-
return !n.startsWith("/") || n.startsWith("//") || n.includes("\\") ?
|
|
31
|
+
return !n.startsWith("/") || n.startsWith("//") || n.includes("\\") ? f : n || f;
|
|
26
32
|
} catch {
|
|
27
|
-
return
|
|
33
|
+
return f;
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
|
-
function
|
|
31
|
-
let t =
|
|
32
|
-
return t ===
|
|
36
|
+
function ne(e) {
|
|
37
|
+
let t = te(e);
|
|
38
|
+
return t === f || ee(t) ? p : `${p}?next=${encodeURIComponent(t)}`;
|
|
33
39
|
}
|
|
34
|
-
function
|
|
35
|
-
if (typeof window > "u") return
|
|
40
|
+
function re() {
|
|
41
|
+
if (typeof window > "u") return p;
|
|
36
42
|
let { pathname: e, search: t, hash: n } = window.location;
|
|
37
|
-
return
|
|
43
|
+
return ne(`${e}${t}${n}`);
|
|
38
44
|
}
|
|
39
45
|
//#endregion
|
|
40
46
|
//#region src/embed/protocol.ts
|
|
41
|
-
var
|
|
47
|
+
var g = "declarion-embed", _ = {
|
|
42
48
|
ready: "ready",
|
|
43
49
|
setToken: "set-token",
|
|
44
50
|
tokenExpired: "token-expired",
|
|
@@ -50,10 +56,10 @@ var h = "declarion-embed", g = {
|
|
|
50
56
|
navigate: "navigate",
|
|
51
57
|
setTheme: "set-theme"
|
|
52
58
|
};
|
|
53
|
-
function
|
|
59
|
+
function v(e, t, n) {
|
|
54
60
|
if (!e || typeof window > "u" || window.parent === window) return !1;
|
|
55
61
|
let r = {
|
|
56
|
-
source:
|
|
62
|
+
source: g,
|
|
57
63
|
protocol: 1,
|
|
58
64
|
type: t,
|
|
59
65
|
payload: n
|
|
@@ -62,28 +68,28 @@ function _(e, t, n) {
|
|
|
62
68
|
}
|
|
63
69
|
//#endregion
|
|
64
70
|
//#region src/embed/token.ts
|
|
65
|
-
var
|
|
71
|
+
var ie = 15e3, ae = 5e3, y = {
|
|
66
72
|
active: !1,
|
|
67
73
|
parentOrigin: null,
|
|
68
74
|
current: null,
|
|
69
75
|
pending: null
|
|
70
76
|
};
|
|
71
|
-
function
|
|
77
|
+
function oe(e) {
|
|
72
78
|
y.active = !0, y.parentOrigin = e;
|
|
73
79
|
}
|
|
74
80
|
function b() {
|
|
75
81
|
return y.active;
|
|
76
82
|
}
|
|
77
|
-
function
|
|
83
|
+
function se() {
|
|
78
84
|
return y.current?.token ?? null;
|
|
79
85
|
}
|
|
80
|
-
function
|
|
86
|
+
function ce() {
|
|
81
87
|
return y.parentOrigin;
|
|
82
88
|
}
|
|
83
|
-
function
|
|
84
|
-
return y.current ? Date.now() >= y.current.expiresAt -
|
|
89
|
+
function le() {
|
|
90
|
+
return y.current ? Date.now() >= y.current.expiresAt - ae : !0;
|
|
85
91
|
}
|
|
86
|
-
function
|
|
92
|
+
function ue(e) {
|
|
87
93
|
if (!e.token || typeof e.token != "string") return;
|
|
88
94
|
let t = Date.parse(e.expires_at);
|
|
89
95
|
if (!Number.isNaN(t) && (y.current = {
|
|
@@ -94,73 +100,73 @@ function oe(e) {
|
|
|
94
100
|
y.pending = null, clearTimeout(t.timer), t.resolve(e.token);
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
function
|
|
103
|
+
function x() {
|
|
98
104
|
y.current = null;
|
|
99
105
|
}
|
|
100
|
-
function
|
|
101
|
-
if (!
|
|
106
|
+
function S() {
|
|
107
|
+
if (!le() && y.current) return Promise.resolve(y.current.token);
|
|
102
108
|
if (y.pending) return y.pending.promise;
|
|
103
109
|
let e, t, n = new Promise((n, r) => {
|
|
104
110
|
e = n, t = r;
|
|
105
111
|
}), r = setTimeout(() => {
|
|
106
|
-
y.pending && y.pending.promise === n && (y.pending = null), t(/* @__PURE__ */ Error(`embed token wait timed out after ${
|
|
107
|
-
},
|
|
112
|
+
y.pending && y.pending.promise === n && (y.pending = null), t(/* @__PURE__ */ Error(`embed token wait timed out after ${ie}ms`));
|
|
113
|
+
}, ie);
|
|
108
114
|
return y.pending = {
|
|
109
115
|
promise: n,
|
|
110
116
|
resolve: e,
|
|
111
117
|
reject: t,
|
|
112
118
|
timer: r
|
|
113
|
-
},
|
|
119
|
+
}, v(y.parentOrigin, _.tokenExpired, {}), n;
|
|
114
120
|
}
|
|
115
121
|
//#endregion
|
|
116
122
|
//#region src/lib/versionTracker.ts
|
|
117
|
-
var
|
|
118
|
-
function
|
|
123
|
+
var de = "X-Declarion-Version", fe = "declarion-version";
|
|
124
|
+
function pe() {
|
|
119
125
|
if (typeof BroadcastChannel > "u") return null;
|
|
120
126
|
try {
|
|
121
|
-
return new BroadcastChannel(
|
|
127
|
+
return new BroadcastChannel(fe);
|
|
122
128
|
} catch {
|
|
123
129
|
return null;
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
|
-
var
|
|
132
|
+
var C = {
|
|
127
133
|
firstSeen: null,
|
|
128
134
|
firstComponents: null,
|
|
129
135
|
hasReportedDrift: !1,
|
|
130
136
|
listeners: /* @__PURE__ */ new Set(),
|
|
131
137
|
channel: null
|
|
132
138
|
};
|
|
133
|
-
function
|
|
134
|
-
|
|
139
|
+
function w() {
|
|
140
|
+
C.channel || typeof BroadcastChannel > "u" || (C.channel = pe(), C.channel && C.channel.addEventListener("message", (e) => {
|
|
135
141
|
let t = e.data;
|
|
136
|
-
if (!(!t || t.type !== "drift" || !t.delta) && !
|
|
137
|
-
|
|
138
|
-
for (let e of
|
|
142
|
+
if (!(!t || t.type !== "drift" || !t.delta) && !C.hasReportedDrift) {
|
|
143
|
+
C.hasReportedDrift = !0;
|
|
144
|
+
for (let e of C.listeners) e(t.delta);
|
|
139
145
|
}
|
|
140
146
|
}));
|
|
141
147
|
}
|
|
142
|
-
function
|
|
143
|
-
if (
|
|
144
|
-
let t = e.get(
|
|
148
|
+
function me(e) {
|
|
149
|
+
if (w(), !e) return;
|
|
150
|
+
let t = e.get(de);
|
|
145
151
|
if (t) {
|
|
146
|
-
if (!
|
|
147
|
-
|
|
152
|
+
if (!C.firstSeen) {
|
|
153
|
+
C.firstSeen = t;
|
|
148
154
|
return;
|
|
149
155
|
}
|
|
150
|
-
t !==
|
|
151
|
-
|
|
156
|
+
t !== C.firstSeen && (C.hasReportedDrift || T().catch(() => {
|
|
157
|
+
E({
|
|
152
158
|
kind: "unknown",
|
|
153
159
|
observed: t
|
|
154
160
|
});
|
|
155
161
|
}));
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
|
-
async function
|
|
159
|
-
|
|
164
|
+
async function T() {
|
|
165
|
+
w();
|
|
160
166
|
let e;
|
|
161
167
|
try {
|
|
162
168
|
let t = {};
|
|
163
|
-
|
|
169
|
+
C.firstSeen && (t["If-None-Match"] = `"${C.firstSeen}"`), e = await fetch("/api/version", {
|
|
164
170
|
method: "GET",
|
|
165
171
|
credentials: b() ? "omit" : "include",
|
|
166
172
|
headers: t
|
|
@@ -183,63 +189,63 @@ async function E() {
|
|
|
183
189
|
asset: t.asset_fingerprint,
|
|
184
190
|
binary: t.binary_fingerprint
|
|
185
191
|
} : void 0;
|
|
186
|
-
|
|
187
|
-
kind:
|
|
192
|
+
C.firstSeen ||= n, !C.firstComponents && r && n === C.firstSeen && (C.firstComponents = r), n !== C.firstSeen && E({
|
|
193
|
+
kind: he(C.firstComponents, r),
|
|
188
194
|
observed: n,
|
|
189
195
|
components: r
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
|
-
function
|
|
198
|
+
function he(e, t) {
|
|
193
199
|
if (!e || !t) return "unknown";
|
|
194
200
|
let n = e.schema !== t.schema, r = e.asset !== t.asset, i = e.binary !== t.binary;
|
|
195
201
|
return n && !r && !i ? "schema-only" : r || i ? "asset-or-binary" : "unknown";
|
|
196
202
|
}
|
|
197
|
-
function
|
|
198
|
-
if (!
|
|
199
|
-
|
|
200
|
-
for (let t of
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
+
function E(e) {
|
|
204
|
+
if (!C.hasReportedDrift) {
|
|
205
|
+
C.hasReportedDrift = !0;
|
|
206
|
+
for (let t of C.listeners) t(e);
|
|
207
|
+
if (C.channel) try {
|
|
208
|
+
C.channel.postMessage({
|
|
203
209
|
type: "drift",
|
|
204
210
|
delta: e
|
|
205
211
|
});
|
|
206
212
|
} catch {}
|
|
207
|
-
b() && e.kind !== "schema-only" &&
|
|
213
|
+
b() && e.kind !== "schema-only" && v(ce(), _.reloadRequired, { reason: `version drift: ${e.kind}` });
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
|
-
function
|
|
211
|
-
return
|
|
212
|
-
|
|
216
|
+
function ge(e) {
|
|
217
|
+
return C.listeners.add(e), () => {
|
|
218
|
+
C.listeners.delete(e);
|
|
213
219
|
};
|
|
214
220
|
}
|
|
215
221
|
//#endregion
|
|
216
222
|
//#region src/api/client.ts
|
|
217
|
-
var
|
|
223
|
+
var _e = (e) => JSON.stringify(e ?? {}), D = null, O = class extends Error {
|
|
218
224
|
status;
|
|
219
225
|
constructor(e) {
|
|
220
226
|
super(`refresh failed terminally (${e})`), this.status = e, this.name = "RefreshDeadError";
|
|
221
227
|
}
|
|
222
|
-
},
|
|
223
|
-
function
|
|
228
|
+
}, k = null, A = null, j = 3e4, ve = 5e3;
|
|
229
|
+
function M() {
|
|
224
230
|
F().catch((e) => {
|
|
225
|
-
e instanceof
|
|
231
|
+
e instanceof O && I();
|
|
226
232
|
});
|
|
227
233
|
}
|
|
228
234
|
function N(e) {
|
|
229
|
-
if (
|
|
235
|
+
if (k &&= (clearTimeout(k), null), A = null, !e || typeof window > "u") return;
|
|
230
236
|
let t = Date.parse(e);
|
|
231
237
|
if (Number.isNaN(t)) return;
|
|
232
|
-
|
|
233
|
-
let n = Math.max(t - Date.now() -
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
A = t;
|
|
239
|
+
let n = Math.max(t - Date.now() - j, ve);
|
|
240
|
+
k = setTimeout(() => {
|
|
241
|
+
k = null, M();
|
|
236
242
|
}, n);
|
|
237
243
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
244
|
+
function ye() {
|
|
245
|
+
k &&= (clearTimeout(k), null), A = null;
|
|
240
246
|
}
|
|
241
247
|
typeof document < "u" && document.addEventListener("visibilitychange", () => {
|
|
242
|
-
document.visibilityState === "visible" &&
|
|
248
|
+
document.visibilityState === "visible" && A !== null && Date.now() >= A - j && M();
|
|
243
249
|
});
|
|
244
250
|
async function P(e) {
|
|
245
251
|
try {
|
|
@@ -247,42 +253,42 @@ async function P(e) {
|
|
|
247
253
|
N(t?.result?.expires_at ?? t?.expires_at);
|
|
248
254
|
} catch {}
|
|
249
255
|
}
|
|
250
|
-
async function
|
|
256
|
+
async function be() {
|
|
251
257
|
let e = {
|
|
252
258
|
method: "POST",
|
|
253
259
|
credentials: "include",
|
|
254
260
|
headers: { "Content-Type": "application/json" },
|
|
255
|
-
body:
|
|
261
|
+
body: _e({})
|
|
256
262
|
}, t = await fetch("/api/actions/auth.refresh", e);
|
|
257
263
|
if (t.status === 429) {
|
|
258
264
|
let n = parseInt(t.headers.get("Retry-After") || "1", 10);
|
|
259
265
|
await new Promise((e) => setTimeout(e, n * 1e3));
|
|
260
266
|
let r = await fetch("/api/actions/auth.refresh", e);
|
|
261
|
-
if (!r.ok) throw new
|
|
267
|
+
if (!r.ok) throw new O(r.status);
|
|
262
268
|
await P(r);
|
|
263
269
|
return;
|
|
264
270
|
}
|
|
265
|
-
if (!t.ok) throw new
|
|
271
|
+
if (!t.ok) throw new O(t.status);
|
|
266
272
|
await P(t);
|
|
267
273
|
}
|
|
268
274
|
async function F() {
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
}),
|
|
275
|
+
return D || (D = be().finally(() => {
|
|
276
|
+
D = null;
|
|
277
|
+
}), D);
|
|
272
278
|
}
|
|
273
279
|
var I = () => {
|
|
274
280
|
if (typeof window > "u") return;
|
|
275
281
|
let { pathname: e } = window.location;
|
|
276
|
-
e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || (window.location.href =
|
|
282
|
+
e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || (window.location.href = re());
|
|
277
283
|
};
|
|
278
|
-
function
|
|
284
|
+
function xe(e) {
|
|
279
285
|
let t = I;
|
|
280
286
|
return I = e, t;
|
|
281
287
|
}
|
|
282
288
|
function L() {
|
|
283
289
|
return I;
|
|
284
290
|
}
|
|
285
|
-
var
|
|
291
|
+
var Se = ({ status: e, code: t, message: n }) => {
|
|
286
292
|
console.error(`[API ${e}] ${t}: ${n}`);
|
|
287
293
|
};
|
|
288
294
|
function R(e, t, n, r) {
|
|
@@ -290,12 +296,12 @@ function R(e, t, n, r) {
|
|
|
290
296
|
return !i.has("Content-Type") && t && i.set("Content-Type", "application/json"), n.setAccept && !i.has("Accept") && i.set("Accept", "*/*"), r && i.set("Authorization", `Bearer ${r}`), i;
|
|
291
297
|
}
|
|
292
298
|
async function z(e, t, n, r) {
|
|
293
|
-
let i = b(), a = i ? "omit" : "include", o = R(t.headers, !!t.body, n, i ?
|
|
299
|
+
let i = b(), a = i ? "omit" : "include", o = R(t.headers, !!t.body, n, i ? se() : null), s = await fetch(e, {
|
|
294
300
|
...t,
|
|
295
301
|
headers: o,
|
|
296
302
|
credentials: a
|
|
297
303
|
});
|
|
298
|
-
if (
|
|
304
|
+
if (me(s.headers), !s.ok) {
|
|
299
305
|
let o = "Request failed", l = "UNKNOWN", u, d;
|
|
300
306
|
try {
|
|
301
307
|
d = await s.json();
|
|
@@ -304,7 +310,7 @@ async function z(e, t, n, r) {
|
|
|
304
310
|
} catch {}
|
|
305
311
|
if (s.status === 401 && (l === "TOKEN_REFRESH_NEEDED" || l === "UNAUTHORIZED")) try {
|
|
306
312
|
let o = null;
|
|
307
|
-
i ? (
|
|
313
|
+
i ? (x(), o = await S()) : await F();
|
|
308
314
|
let s = R(t.headers, !!t.body, n, o), l = await fetch(e, {
|
|
309
315
|
...t,
|
|
310
316
|
headers: s,
|
|
@@ -322,7 +328,7 @@ async function z(e, t, n, r) {
|
|
|
322
328
|
} catch (e) {
|
|
323
329
|
throw e instanceof c ? e : (I(), new c(401, o, l, u));
|
|
324
330
|
}
|
|
325
|
-
throw s.status === 401 && I(),
|
|
331
|
+
throw s.status === 401 && I(), Se({
|
|
326
332
|
status: s.status,
|
|
327
333
|
code: l,
|
|
328
334
|
message: o
|
|
@@ -330,23 +336,23 @@ async function z(e, t, n, r) {
|
|
|
330
336
|
}
|
|
331
337
|
return r(s);
|
|
332
338
|
}
|
|
333
|
-
function
|
|
339
|
+
function Ce(e) {
|
|
334
340
|
return e.status === 204 ? Promise.resolve(void 0) : e.json();
|
|
335
341
|
}
|
|
336
342
|
async function B(e, t = {}) {
|
|
337
|
-
return z(e, t, { setAccept: !1 },
|
|
343
|
+
return z(e, t, { setAccept: !1 }, Ce);
|
|
338
344
|
}
|
|
339
|
-
async function
|
|
345
|
+
async function we(e) {
|
|
340
346
|
return {
|
|
341
347
|
blob: await e.blob(),
|
|
342
|
-
filename:
|
|
348
|
+
filename: Ee(e.headers),
|
|
343
349
|
headers: e.headers
|
|
344
350
|
};
|
|
345
351
|
}
|
|
346
|
-
async function
|
|
347
|
-
return z(e, t, { setAccept: !0 },
|
|
352
|
+
async function Te(e, t = {}) {
|
|
353
|
+
return z(e, t, { setAccept: !0 }, we);
|
|
348
354
|
}
|
|
349
|
-
function
|
|
355
|
+
function Ee(e) {
|
|
350
356
|
let t = e.get("Content-Disposition");
|
|
351
357
|
if (!t) return "";
|
|
352
358
|
let n = t.match(/filename\*\s*=\s*([^']*)'([^']*)'([^;]+)/i);
|
|
@@ -359,18 +365,18 @@ function Ce(e) {
|
|
|
359
365
|
async function V(e, t = {}) {
|
|
360
366
|
return (await B(`/api/actions/${encodeURIComponent(e)}`, {
|
|
361
367
|
method: "POST",
|
|
362
|
-
body:
|
|
368
|
+
body: _e(t)
|
|
363
369
|
})).result;
|
|
364
370
|
}
|
|
365
371
|
//#endregion
|
|
366
372
|
//#region src/embed/file-src.ts
|
|
367
373
|
var H = "/api/files";
|
|
368
|
-
function
|
|
374
|
+
function De(e) {
|
|
369
375
|
if (typeof e != "object" || !e) return !1;
|
|
370
376
|
let t = e;
|
|
371
377
|
return typeof t.url == "string" && typeof t.proxy == "boolean";
|
|
372
378
|
}
|
|
373
|
-
function
|
|
379
|
+
function Oe(e, t) {
|
|
374
380
|
let n = encodeURIComponent(e);
|
|
375
381
|
return typeof t == "object" ? `${H}/${n}/derived/${encodeURIComponent(t.derivation)}/url` : `${H}/${n}/url`;
|
|
376
382
|
}
|
|
@@ -389,29 +395,29 @@ function W(e, t) {
|
|
|
389
395
|
signal: t
|
|
390
396
|
};
|
|
391
397
|
}
|
|
392
|
-
function
|
|
398
|
+
function ke(e) {
|
|
393
399
|
return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
|
|
394
400
|
}
|
|
395
401
|
async function G(e, t) {
|
|
396
|
-
let n = await
|
|
402
|
+
let n = await S(), r = await fetch(e, W(n, t));
|
|
397
403
|
if (r.status !== 401) return r;
|
|
398
|
-
|
|
399
|
-
let i = await
|
|
404
|
+
x();
|
|
405
|
+
let i = await S();
|
|
400
406
|
return fetch(e, W(i, t));
|
|
401
407
|
}
|
|
402
408
|
async function K(e, t, n) {
|
|
403
409
|
if (!b()) throw Error("resolveEmbedFileSrc called outside embed token mode");
|
|
404
|
-
let r = await G(
|
|
410
|
+
let r = await G(Oe(e, t), n);
|
|
405
411
|
if (r.status === 202 && typeof t == "object") throw new U(e, t.derivation);
|
|
406
412
|
if (!r.ok) throw Error(`embed file url request failed: ${r.status} ${r.statusText}`);
|
|
407
413
|
let i = await r.json();
|
|
408
|
-
if (!
|
|
414
|
+
if (!De(i)) throw Error("embed file url response is malformed");
|
|
409
415
|
if (!i.proxy) return {
|
|
410
416
|
url: i.url,
|
|
411
417
|
kind: "direct"
|
|
412
418
|
};
|
|
413
419
|
if (!i.url.startsWith("/api/files/")) throw Error(`embed file proxy: refusing non-files-route URL ${JSON.stringify(i.url)}`);
|
|
414
|
-
let a = await G(t === "download" ?
|
|
420
|
+
let a = await G(t === "download" ? ke(i.url) : i.url, n);
|
|
415
421
|
if (!a.ok) throw Error(`embed file proxy fetch failed: ${a.status} ${a.statusText}`);
|
|
416
422
|
let o = await a.blob();
|
|
417
423
|
return {
|
|
@@ -428,15 +434,15 @@ var q = class extends Error {
|
|
|
428
434
|
super(n), this.code = t, this.status = e;
|
|
429
435
|
}
|
|
430
436
|
};
|
|
431
|
-
async function
|
|
437
|
+
async function Ae(e) {
|
|
432
438
|
let t = b();
|
|
433
439
|
try {
|
|
434
|
-
return await J(e, t ? await
|
|
440
|
+
return await J(e, t ? await S() : null);
|
|
435
441
|
} catch (n) {
|
|
436
442
|
if (!(n instanceof q && n.status === 401 && (n.code === "TOKEN_REFRESH_NEEDED" || n.code === "UNAUTHORIZED"))) throw n;
|
|
437
443
|
let r = null;
|
|
438
444
|
try {
|
|
439
|
-
t ? (
|
|
445
|
+
t ? (x(), r = await S()) : await F();
|
|
440
446
|
} catch {
|
|
441
447
|
throw L()(), n;
|
|
442
448
|
}
|
|
@@ -451,7 +457,7 @@ function J(e, t) {
|
|
|
451
457
|
let { file: n, entityCode: r, fieldCode: i, slotCode: a, onProgress: o, signal: s } = e;
|
|
452
458
|
return new Promise((e, c) => {
|
|
453
459
|
let l = new XMLHttpRequest();
|
|
454
|
-
if (l.open("POST",
|
|
460
|
+
if (l.open("POST", je(r, i, a)), l.withCredentials = t === null, t && l.setRequestHeader("Authorization", `Bearer ${t}`), l.upload.onprogress = (e) => {
|
|
455
461
|
if (!o) return;
|
|
456
462
|
let t = e.lengthComputable ? e.total : n.size, r = t > 0 ? Math.min(100, Math.round(e.loaded / t * 100)) : 0;
|
|
457
463
|
o({
|
|
@@ -490,24 +496,24 @@ function J(e, t) {
|
|
|
490
496
|
u.append("file", n, n.name), l.send(u);
|
|
491
497
|
});
|
|
492
498
|
}
|
|
493
|
-
function
|
|
499
|
+
function je(e, t, n) {
|
|
494
500
|
let r = new URLSearchParams();
|
|
495
501
|
e && t && (r.set("entity_code", e), r.set("field_code", t), n && r.set("slot_code", n));
|
|
496
502
|
let i = r.toString();
|
|
497
503
|
return i ? `/api/files/upload?${i}` : "/api/files/upload";
|
|
498
504
|
}
|
|
499
505
|
function Y(e) {
|
|
500
|
-
return X(e) ? X(e.result) ? Y(e.result) : X(e.file) ?
|
|
506
|
+
return X(e) ? X(e.result) ? Y(e.result) : X(e.file) ? Me(e.file) : typeof e.id == "string" ? e : null : null;
|
|
501
507
|
}
|
|
502
|
-
function
|
|
508
|
+
function Me(e) {
|
|
503
509
|
let t = Z(e.file_id);
|
|
504
510
|
return t ? {
|
|
505
511
|
id: t,
|
|
506
512
|
filename: Z(e.filename_original) ?? Z(e.filename_normalized) ?? t,
|
|
507
513
|
content_type: Z(e.content_type) ?? "application/octet-stream",
|
|
508
|
-
size_bytes:
|
|
514
|
+
size_bytes: Ne(e.size_bytes) ?? 0,
|
|
509
515
|
sha256: Z(e.sha256) ?? "",
|
|
510
|
-
dedup:
|
|
516
|
+
dedup: Pe(e.dedup)
|
|
511
517
|
} : null;
|
|
512
518
|
}
|
|
513
519
|
function X(e) {
|
|
@@ -516,30 +522,30 @@ function X(e) {
|
|
|
516
522
|
function Z(e) {
|
|
517
523
|
return typeof e == "string" ? e : void 0;
|
|
518
524
|
}
|
|
519
|
-
function
|
|
525
|
+
function Ne(e) {
|
|
520
526
|
return typeof e == "number" ? e : void 0;
|
|
521
527
|
}
|
|
522
|
-
function
|
|
528
|
+
function Pe(e) {
|
|
523
529
|
return typeof e == "boolean" ? e : void 0;
|
|
524
530
|
}
|
|
525
|
-
async function
|
|
531
|
+
async function Fe(e) {
|
|
526
532
|
await V("files.discard", { file_id: e });
|
|
527
533
|
}
|
|
528
|
-
function
|
|
534
|
+
function Ie(e, t, n) {
|
|
529
535
|
if (n && e.size > n) return {
|
|
530
536
|
code: "FILE_TOO_LARGE",
|
|
531
537
|
message: `File is ${Q(e.size)}, max ${Q(n)}`
|
|
532
538
|
};
|
|
533
539
|
if (t && t.length > 0) {
|
|
534
540
|
let n = e.type || "application/octet-stream";
|
|
535
|
-
if (!t.some((e) =>
|
|
541
|
+
if (!t.some((e) => Le(e, n))) return {
|
|
536
542
|
code: "MIME_NOT_ACCEPTED",
|
|
537
543
|
message: `File type ${n} is not accepted`
|
|
538
544
|
};
|
|
539
545
|
}
|
|
540
546
|
return null;
|
|
541
547
|
}
|
|
542
|
-
function
|
|
548
|
+
function Le(e, t) {
|
|
543
549
|
if (e === "*/*" || e === "*") return !0;
|
|
544
550
|
if (e.endsWith("/*")) {
|
|
545
551
|
let n = e.slice(0, e.length - 1);
|
|
@@ -559,11 +565,11 @@ function Q(e) {
|
|
|
559
565
|
}
|
|
560
566
|
//#endregion
|
|
561
567
|
//#region src/components/file-widgets/helpers.ts
|
|
562
|
-
var
|
|
563
|
-
function
|
|
568
|
+
var Re = ["thumb_200", "thumb_300"];
|
|
569
|
+
function ze() {
|
|
564
570
|
return typeof navigator > "u" ? ["en"] : (navigator.languages?.length ? navigator.languages : [navigator.language]).filter((e) => typeof e == "string" && e.length > 0);
|
|
565
571
|
}
|
|
566
|
-
function
|
|
572
|
+
function Be(e, t) {
|
|
567
573
|
for (let n of t) {
|
|
568
574
|
if (e[n]) return e[n];
|
|
569
575
|
let t = n.split("-")[0];
|
|
@@ -571,17 +577,17 @@ function Le(e, t) {
|
|
|
571
577
|
}
|
|
572
578
|
for (let t of Object.values(e)) if (typeof t == "string" && t.length > 0) return t;
|
|
573
579
|
}
|
|
574
|
-
function
|
|
580
|
+
function Ve(e, t, n) {
|
|
575
581
|
if (t) return t;
|
|
576
582
|
let r = e?.metadata?.alt_text;
|
|
577
583
|
if (typeof r == "string" && r.length > 0) return r;
|
|
578
584
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
579
|
-
let e =
|
|
585
|
+
let e = Be(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), ze());
|
|
580
586
|
if (e) return e;
|
|
581
587
|
}
|
|
582
588
|
return n;
|
|
583
589
|
}
|
|
584
|
-
var
|
|
590
|
+
var He = new Set([
|
|
585
591
|
"image/png",
|
|
586
592
|
"image/jpeg",
|
|
587
593
|
"image/webp",
|
|
@@ -589,30 +595,30 @@ var ze = new Set([
|
|
|
589
595
|
"image/avif",
|
|
590
596
|
"application/pdf"
|
|
591
597
|
]);
|
|
592
|
-
function
|
|
598
|
+
function Ue(e) {
|
|
593
599
|
let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
594
|
-
return
|
|
600
|
+
return He.has(t);
|
|
595
601
|
}
|
|
596
|
-
function
|
|
602
|
+
function We(e) {
|
|
597
603
|
return e.url ?? e.presigned_url;
|
|
598
604
|
}
|
|
599
|
-
function
|
|
600
|
-
return e.url ?
|
|
605
|
+
function Ge(e) {
|
|
606
|
+
return e.url ? Je(e.url, "attachment") : e.presigned_url;
|
|
601
607
|
}
|
|
602
|
-
function
|
|
608
|
+
function Ke(e, t) {
|
|
603
609
|
if (!e) return;
|
|
604
610
|
let n = e.derivations ?? {};
|
|
605
611
|
if (t && n[t]) return n[t];
|
|
606
|
-
for (let e of
|
|
612
|
+
for (let e of Re) if (n[e]) return n[e];
|
|
607
613
|
return e.url ?? e.presigned_url;
|
|
608
614
|
}
|
|
609
|
-
function
|
|
615
|
+
function qe(e, t) {
|
|
610
616
|
let n = e?.derivations ?? {};
|
|
611
617
|
if (t && n[t]) return { derivation: t };
|
|
612
|
-
for (let e of
|
|
618
|
+
for (let e of Re) if (n[e]) return { derivation: e };
|
|
613
619
|
return "preview";
|
|
614
620
|
}
|
|
615
|
-
function
|
|
621
|
+
function Je(e, t) {
|
|
616
622
|
try {
|
|
617
623
|
let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
|
|
618
624
|
return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
|
|
@@ -620,7 +626,7 @@ function Ge(e, t) {
|
|
|
620
626
|
return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
|
|
621
627
|
}
|
|
622
628
|
}
|
|
623
|
-
function
|
|
629
|
+
function Ye(e) {
|
|
624
630
|
let t = e?.metadata?.focal_point;
|
|
625
631
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
626
632
|
let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
|
|
@@ -629,10 +635,10 @@ function Ke(e) {
|
|
|
629
635
|
y: i
|
|
630
636
|
};
|
|
631
637
|
}
|
|
632
|
-
function
|
|
638
|
+
function Xe(e) {
|
|
633
639
|
if (e) return `${e.x * 100}% ${e.y * 100}%`;
|
|
634
640
|
}
|
|
635
|
-
function
|
|
641
|
+
function Ze(e, t) {
|
|
636
642
|
return {
|
|
637
643
|
...e,
|
|
638
644
|
metadata: {
|
|
@@ -643,7 +649,7 @@ function Je(e, t) {
|
|
|
643
649
|
}
|
|
644
650
|
//#endregion
|
|
645
651
|
//#region src/components/file-widgets/draft-scope.tsx
|
|
646
|
-
var
|
|
652
|
+
var Qe = e({
|
|
647
653
|
registerDraft() {},
|
|
648
654
|
unregisterDraft() {},
|
|
649
655
|
hasDraft() {
|
|
@@ -652,7 +658,7 @@ var Ye = e({
|
|
|
652
658
|
flushAllDrafts: async () => {},
|
|
653
659
|
markCommitted() {}
|
|
654
660
|
});
|
|
655
|
-
function
|
|
661
|
+
function $e({ children: e }) {
|
|
656
662
|
let t = a(/* @__PURE__ */ new Map()), n = i(() => ({
|
|
657
663
|
registerDraft(e) {
|
|
658
664
|
t.current.set(e.fileId, e);
|
|
@@ -671,16 +677,16 @@ function Xe({ children: e }) {
|
|
|
671
677
|
t.current.clear(), await Promise.allSettled(e.map((e) => Promise.resolve(e.discard())));
|
|
672
678
|
}
|
|
673
679
|
}), []);
|
|
674
|
-
return /* @__PURE__ */ s(
|
|
680
|
+
return /* @__PURE__ */ s(Qe.Provider, {
|
|
675
681
|
value: n,
|
|
676
682
|
children: e
|
|
677
683
|
});
|
|
678
684
|
}
|
|
679
|
-
function
|
|
680
|
-
return n(
|
|
685
|
+
function et() {
|
|
686
|
+
return n(Qe);
|
|
681
687
|
}
|
|
682
|
-
function
|
|
683
|
-
let e =
|
|
688
|
+
function tt() {
|
|
689
|
+
let e = et();
|
|
684
690
|
return {
|
|
685
691
|
register: t((t, n) => {
|
|
686
692
|
e.registerDraft({
|
|
@@ -699,14 +705,14 @@ function Qe() {
|
|
|
699
705
|
}
|
|
700
706
|
//#endregion
|
|
701
707
|
//#region src/components/file-widgets/useEmbedFileSrc.ts
|
|
702
|
-
function
|
|
708
|
+
function nt(e) {
|
|
703
709
|
return typeof e == "object" ? `derivation:${e.derivation}` : e;
|
|
704
710
|
}
|
|
705
|
-
function
|
|
711
|
+
function rt(e) {
|
|
706
712
|
return e.startsWith("derivation:") ? { derivation: e.slice(11) } : e === "download" ? "download" : "preview";
|
|
707
713
|
}
|
|
708
|
-
function
|
|
709
|
-
let i =
|
|
714
|
+
function it(e, t, n) {
|
|
715
|
+
let i = nt(t), [a, s] = o(() => b() ? void 0 : n);
|
|
710
716
|
return r(() => {
|
|
711
717
|
b() || s(n);
|
|
712
718
|
}, [n]), r(() => {
|
|
@@ -716,7 +722,7 @@ function tt(e, t, n) {
|
|
|
716
722
|
return;
|
|
717
723
|
}
|
|
718
724
|
let t = null, n = !1, r = new AbortController();
|
|
719
|
-
return s(void 0), K(e,
|
|
725
|
+
return s(void 0), K(e, rt(i), r.signal).then((e) => {
|
|
720
726
|
if (n) {
|
|
721
727
|
e.kind === "blob" && URL.revokeObjectURL(e.url);
|
|
722
728
|
return;
|
|
@@ -735,7 +741,7 @@ function tt(e, t, n) {
|
|
|
735
741
|
};
|
|
736
742
|
}, [e, i]), a;
|
|
737
743
|
}
|
|
738
|
-
function
|
|
744
|
+
function at() {
|
|
739
745
|
let e = a([]);
|
|
740
746
|
return r(() => () => {
|
|
741
747
|
for (let t of e.current) URL.revokeObjectURL(t);
|
|
@@ -757,13 +763,13 @@ function nt() {
|
|
|
757
763
|
function $(e) {
|
|
758
764
|
return typeof e == "object" && !!e && typeof e.id == "string";
|
|
759
765
|
}
|
|
760
|
-
function
|
|
766
|
+
function ot(e) {
|
|
761
767
|
return e ? Array.isArray(e) ? e.find($) ?? null : $(e) ? e : null : null;
|
|
762
768
|
}
|
|
763
|
-
function
|
|
769
|
+
function st(e) {
|
|
764
770
|
return e ? Array.isArray(e) ? e.filter($) : $(e) ? [e] : [] : [];
|
|
765
771
|
}
|
|
766
772
|
//#endregion
|
|
767
|
-
export {
|
|
773
|
+
export { xe as A, _ as B, B as C, F as D, ye as E, se as F, u as G, ne as H, oe as I, l as K, b as L, ge as M, S as N, L as O, x as P, ue as R, O as S, V as T, te as U, v as V, c as W, q as _, $e as a, Ae as b, Ue as c, Ke as d, qe as f, Ze as g, Ve as h, it as i, T as j, N as k, Ge as l, Ye as m, ot as n, tt as o, We as p, d as q, at as r, et as s, st as t, Xe as u, Fe as v, Te as w, Ie as x, Q as y, g as z };
|
|
768
774
|
|
|
769
|
-
//# sourceMappingURL=value-
|
|
775
|
+
//# sourceMappingURL=value-CiwnEAde.js.map
|