@declarion/react 0.32.0 → 0.34.0
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/{ActionRunner-CaSrGpBi.js → ActionRunner-UGGvGypS.js} +676 -543
- package/dist-lib/{DraggableChildrenTable-CAHg7paQ.js → DraggableChildrenTable-CljdYXd_.js} +30 -30
- package/dist-lib/DynamicIcon-BWO6QtNF.js +261 -0
- package/dist-lib/{Grid-DDbBhqcl.js → Grid-5Y_iPqNW.js} +2 -2
- package/dist-lib/{LayoutRenderer-CelsqsZ6.js → LayoutRenderer-CoTMmvNW.js} +712 -712
- package/dist-lib/{MarkdownRenderer-DThy2ixe.js → MarkdownRenderer-unbncYEV.js} +1 -1
- package/dist-lib/RefreshControl-oeKhCjEC.js +837 -0
- package/dist-lib/SmartDetailPage.impl-Caxd97q6.js +1771 -0
- package/dist-lib/{SmartRecordListPage.impl-BKIpTNK7.js → SmartRecordListPage.impl-BF_ieDc2.js} +258 -258
- package/dist-lib/components/pages/DocumentsMenu.d.ts +22 -0
- package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +42 -0
- package/dist-lib/components/pages/list/ListHeader.d.ts +1 -11
- package/dist-lib/components/primitives/Icons.d.ts +1 -0
- package/dist-lib/components/primitives/Tooltip.d.ts +30 -0
- package/dist-lib/components/primitives/index.d.ts +2 -0
- package/dist-lib/components/shared/ActionResultDialog.d.ts +4 -0
- package/dist-lib/components/shared/RecordHeader.d.ts +2 -1
- package/dist-lib/components/shared/ResponsiveActionBar.d.ts +9 -1
- package/dist-lib/icons.js +1 -1
- package/dist-lib/index.js +2288 -2334
- package/dist-lib/lib/document-templates.d.ts +12 -0
- package/dist-lib/lib/download.d.ts +20 -0
- package/dist-lib/lib/record-documents-key.d.ts +1 -0
- package/dist-lib/{registry-KQyyL5Gt.js → registry-DnPK3Msj.js} +826 -826
- package/dist-lib/testing.js +25 -25
- package/dist-lib/types/api.d.ts +1 -9
- package/dist-lib/types/schema.d.ts +17 -1
- package/dist-lib/{useProperties-D74hyWIa.js → useProperties-CgRhBh0k.js} +52 -52
- package/dist-lib/{value-BfXXl5EE.js → value-GmL5BVFm.js} +29 -29
- package/package.json +1 -1
- package/dist-lib/DynamicIcon-DCRdxxZ7.js +0 -260
- package/dist-lib/RefreshControl-CorluL6r.js +0 -582
- package/dist-lib/SmartDetailPage.impl-USIxbl-8.js +0 -1532
package/dist-lib/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { In as e, _t as t, at as n, ft as r, mt as i, pt as a, t as o } from "./ActionRunner-UGGvGypS.js";
|
|
2
2
|
import { useState as s } from "react";
|
|
3
3
|
import { MemoryRouter as c } from "react-router-dom";
|
|
4
4
|
import { QueryClient as l, QueryClientProvider as u } from "@tanstack/react-query";
|
|
@@ -59,7 +59,7 @@ function x() {
|
|
|
59
59
|
code: "test",
|
|
60
60
|
name: "Test",
|
|
61
61
|
role: "admin"
|
|
62
|
-
},
|
|
62
|
+
}, n = {
|
|
63
63
|
id: "test-user",
|
|
64
64
|
email: "test@example.com",
|
|
65
65
|
display_name: "Test User",
|
|
@@ -70,7 +70,7 @@ function x() {
|
|
|
70
70
|
created_at: "2026-01-01T00:00:00Z",
|
|
71
71
|
updated_at: "2026-01-01T00:00:00Z"
|
|
72
72
|
};
|
|
73
|
-
|
|
73
|
+
t.getState().setUser(n, e);
|
|
74
74
|
}
|
|
75
75
|
function S(e) {
|
|
76
76
|
if (e === void 0) return { rows: [] };
|
|
@@ -86,10 +86,10 @@ function S(e) {
|
|
|
86
86
|
return e;
|
|
87
87
|
}
|
|
88
88
|
function C(e) {
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
let
|
|
92
|
-
return
|
|
89
|
+
let t = e.entityData ?? {};
|
|
90
|
+
i((e, n) => {
|
|
91
|
+
let r = t[e], i = S(r), a = i.meta?.per_page ?? 50, o = i.meta?.total ?? i.rows.length;
|
|
92
|
+
return n.count === "only" ? {
|
|
93
93
|
data: [],
|
|
94
94
|
meta: {
|
|
95
95
|
page: 1,
|
|
@@ -108,24 +108,24 @@ function C(e) {
|
|
|
108
108
|
...i.refs === void 0 ? {} : { $refs: i.refs }
|
|
109
109
|
};
|
|
110
110
|
});
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
115
|
-
if (
|
|
116
|
-
let
|
|
117
|
-
if (
|
|
118
|
-
return { data:
|
|
111
|
+
let o = e.entityItems ?? {}, s = e.entityItemResponses ?? {};
|
|
112
|
+
a((e, t) => {
|
|
113
|
+
let r = typeof t == "string" ? t : n(t), i = s[e]?.[r];
|
|
114
|
+
if (i instanceof Error) throw i;
|
|
115
|
+
if (i !== void 0) return i;
|
|
116
|
+
let a = o[e]?.[r];
|
|
117
|
+
if (a instanceof Error) throw a;
|
|
118
|
+
return { data: a };
|
|
119
119
|
});
|
|
120
120
|
let c = e.actionResults ?? {};
|
|
121
|
-
|
|
121
|
+
r(async (e, t) => {
|
|
122
122
|
if (!(e in c)) throw Error(`renderWithDeclarion: no action result registered for "${e}" (seed it via actionResults)`);
|
|
123
123
|
let n = c[e];
|
|
124
124
|
return b(typeof n == "function" ? await n(t) : n);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
function w() {
|
|
128
|
-
|
|
128
|
+
i(null), a(null), r(null), t.setState({
|
|
129
129
|
user: null,
|
|
130
130
|
isAuthenticated: !1,
|
|
131
131
|
activeTenant: null,
|
|
@@ -142,32 +142,32 @@ function T(t, n = {}) {
|
|
|
142
142
|
client: r,
|
|
143
143
|
children: [/* @__PURE__ */ f(c, {
|
|
144
144
|
initialEntries: [n.route ?? "/"],
|
|
145
|
-
children: /* @__PURE__ */ f(
|
|
145
|
+
children: /* @__PURE__ */ f(o, { children: t })
|
|
146
146
|
}), /* @__PURE__ */ f(d, {})]
|
|
147
|
-
}),
|
|
147
|
+
}), a = m(n.viewport ? /* @__PURE__ */ f(e, {
|
|
148
148
|
viewportOverride: n.viewport,
|
|
149
149
|
children: i
|
|
150
150
|
}) : i);
|
|
151
|
-
return Object.assign(
|
|
151
|
+
return Object.assign(a, { queryClient: r });
|
|
152
152
|
}
|
|
153
|
-
function E({ children: e, authenticated:
|
|
153
|
+
function E({ children: e, authenticated: n = !0, ...r }) {
|
|
154
154
|
let [i] = s(() => {
|
|
155
155
|
let e = new l({ defaultOptions: { queries: {
|
|
156
156
|
retry: !1,
|
|
157
157
|
gcTime: Infinity
|
|
158
158
|
} } });
|
|
159
|
-
return
|
|
159
|
+
return n ? (x(), e.setQueryData(["schema", !0], r.schema ?? h())) : t.setState({
|
|
160
160
|
user: null,
|
|
161
161
|
isAuthenticated: !1,
|
|
162
162
|
activeTenant: null,
|
|
163
163
|
tenants: []
|
|
164
|
-
}), C(
|
|
164
|
+
}), C(r), e;
|
|
165
165
|
});
|
|
166
166
|
return /* @__PURE__ */ p(u, {
|
|
167
167
|
client: i,
|
|
168
168
|
children: [/* @__PURE__ */ f(c, {
|
|
169
|
-
initialEntries: [
|
|
170
|
-
children: /* @__PURE__ */ f(
|
|
169
|
+
initialEntries: [r.route ?? "/"],
|
|
170
|
+
children: /* @__PURE__ */ f(o, { children: e })
|
|
171
171
|
}), /* @__PURE__ */ f(d, {})]
|
|
172
172
|
});
|
|
173
173
|
}
|
package/dist-lib/types/api.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ export interface BrandingThemeColors {
|
|
|
182
182
|
accent_hover?: string;
|
|
183
183
|
accent_soft?: string;
|
|
184
184
|
primary?: string;
|
|
185
|
+
primary_hover?: string;
|
|
185
186
|
sidebar?: string;
|
|
186
187
|
rail?: string;
|
|
187
188
|
surface?: string;
|
|
@@ -191,14 +192,6 @@ export interface BrandingThemeColors {
|
|
|
191
192
|
text_muted?: string;
|
|
192
193
|
border?: string;
|
|
193
194
|
}
|
|
194
|
-
export interface BrandingThemeTypography {
|
|
195
|
-
font_display?: string;
|
|
196
|
-
body?: number;
|
|
197
|
-
page_title?: number;
|
|
198
|
-
table_cell?: number;
|
|
199
|
-
control?: number;
|
|
200
|
-
caption?: number;
|
|
201
|
-
}
|
|
202
195
|
export interface BrandingTheme {
|
|
203
196
|
css_url?: string;
|
|
204
197
|
font_sans?: string;
|
|
@@ -206,7 +199,6 @@ export interface BrandingTheme {
|
|
|
206
199
|
radius?: string;
|
|
207
200
|
density?: string;
|
|
208
201
|
colors?: BrandingThemeColors;
|
|
209
|
-
typography?: BrandingThemeTypography;
|
|
210
202
|
}
|
|
211
203
|
export interface BrandingSurfaceFlags {
|
|
212
204
|
show_title?: boolean;
|
|
@@ -29,7 +29,7 @@ export declare function getDisplayValue(row: Record<string, unknown> | null | un
|
|
|
29
29
|
display_field?: string;
|
|
30
30
|
};
|
|
31
31
|
} | null | undefined): string | undefined;
|
|
32
|
-
export declare function resolveRefRecordLabel(record: Record<string, unknown>,
|
|
32
|
+
export declare function resolveRefRecordLabel(record: Record<string, unknown>, displayKey: string | undefined, fallback: string): string;
|
|
33
33
|
export declare function screenTitleForPath(pathname: string, screens: Record<string, Screen> | undefined, entities?: Record<string, Entity>): {
|
|
34
34
|
title: string;
|
|
35
35
|
icon?: string;
|
|
@@ -413,6 +413,22 @@ export interface Entity {
|
|
|
413
413
|
* list UI on this. See docs/plans/2026-06-20-cross-store-list-cursor-pagination.md.
|
|
414
414
|
*/
|
|
415
415
|
list_pagination?: "offset" | "cursor";
|
|
416
|
+
/**
|
|
417
|
+
* Static, per-caller document-generation capability computed from the
|
|
418
|
+
* SYSTEM document template registry at schema projection (registry-only,
|
|
419
|
+
* no DB read, no ETag impact - system templates are boot-static and are
|
|
420
|
+
* covered by the schema fingerprint). Absent (or both flags falsy) means
|
|
421
|
+
* no system template applies for this caller/tenant/entity - the
|
|
422
|
+
* frontend's Generate affordance renders nothing UNLESS a tenant-uploaded
|
|
423
|
+
* template is found via the lazy `document.templates.available` runtime
|
|
424
|
+
* probe (tenant templates are runtime data and are never baked into the
|
|
425
|
+
* schema). `generate_one` gates the detail-scope toolbar; `generate_many`
|
|
426
|
+
* gates the list-scope toolbar. See docs/document-generation.md.
|
|
427
|
+
*/
|
|
428
|
+
documents?: {
|
|
429
|
+
generate_one?: boolean;
|
|
430
|
+
generate_many?: boolean;
|
|
431
|
+
};
|
|
416
432
|
}
|
|
417
433
|
export interface ExportConfig {
|
|
418
434
|
enabled?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { vt as c } from "./registry-
|
|
1
|
+
import { Mt as e, Qt as t, V as n, Z as r, jt as i, ln as a, ot as o, yn as s } from "./ActionRunner-UGGvGypS.js";
|
|
2
|
+
import { vt as c } from "./registry-DnPK3Msj.js";
|
|
3
3
|
import { useEffect as l, useMemo as u } from "react";
|
|
4
4
|
import { useSearchParams as d } from "react-router-dom";
|
|
5
5
|
import { useInfiniteQuery as f, useMutation as p, useQueryClient as m } from "@tanstack/react-query";
|
|
@@ -47,33 +47,33 @@ var b = class {
|
|
|
47
47
|
this.entity = e, this.refs = t ?? new v();
|
|
48
48
|
}
|
|
49
49
|
async get(e) {
|
|
50
|
-
let
|
|
51
|
-
return _((await
|
|
50
|
+
let t = new URLSearchParams(typeof e == "string" ? { id: e } : e);
|
|
51
|
+
return _((await i(`/api/data/${this.entity}?${t.toString()}`)).data);
|
|
52
52
|
}
|
|
53
53
|
async list(e = {}) {
|
|
54
|
-
let n,
|
|
54
|
+
let n, r = !1;
|
|
55
55
|
try {
|
|
56
|
-
n = await
|
|
56
|
+
n = await i(y(this.entity, e));
|
|
57
57
|
} catch (a) {
|
|
58
|
-
if (e.after &&
|
|
59
|
-
let { after:
|
|
60
|
-
n = await
|
|
58
|
+
if (e.after && t(a)) {
|
|
59
|
+
let { after: t, ...a } = e;
|
|
60
|
+
n = await i(y(this.entity, a)), r = !0;
|
|
61
61
|
} else throw a;
|
|
62
62
|
}
|
|
63
63
|
return this.refs.merge(n.$refs), {
|
|
64
64
|
data: n.data.map((e) => _(e)),
|
|
65
65
|
meta: n.meta,
|
|
66
66
|
$refs: this.refs.all(),
|
|
67
|
-
reset:
|
|
67
|
+
reset: r
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
async create(e) {
|
|
71
71
|
return (await this.createMany([e]))[0];
|
|
72
72
|
}
|
|
73
|
-
async createMany(
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
actions:
|
|
73
|
+
async createMany(t) {
|
|
74
|
+
if (t.length === 0) return [];
|
|
75
|
+
let n = await e("system.batch", {
|
|
76
|
+
actions: t.map((e) => ({
|
|
77
77
|
action: `${this.entity}.__create`,
|
|
78
78
|
params: {
|
|
79
79
|
entity: this.entity,
|
|
@@ -82,7 +82,7 @@ var b = class {
|
|
|
82
82
|
})),
|
|
83
83
|
atomic: !0
|
|
84
84
|
});
|
|
85
|
-
return x(
|
|
85
|
+
return x(n, `${this.entity}.__create`), n.results.map((e) => _(S(e)));
|
|
86
86
|
}
|
|
87
87
|
async update(e, t) {
|
|
88
88
|
return (await this.updateMany([{
|
|
@@ -90,10 +90,10 @@ var b = class {
|
|
|
90
90
|
...t
|
|
91
91
|
}]))[0];
|
|
92
92
|
}
|
|
93
|
-
async updateMany(
|
|
94
|
-
if (
|
|
95
|
-
let
|
|
96
|
-
actions:
|
|
93
|
+
async updateMany(t) {
|
|
94
|
+
if (t.length === 0) return [];
|
|
95
|
+
let n = await e("system.batch", {
|
|
96
|
+
actions: t.map(({ id: e, ...t }) => ({
|
|
97
97
|
action: `${this.entity}.__update`,
|
|
98
98
|
params: {
|
|
99
99
|
object_ids: [e],
|
|
@@ -103,13 +103,13 @@ var b = class {
|
|
|
103
103
|
})),
|
|
104
104
|
atomic: !0
|
|
105
105
|
});
|
|
106
|
-
return x(
|
|
106
|
+
return x(n, `${this.entity}.__update`), n.results.map((e) => _(S(e)));
|
|
107
107
|
}
|
|
108
108
|
async delete(e) {
|
|
109
109
|
await this.deleteMany([e]);
|
|
110
110
|
}
|
|
111
111
|
async deleteMany(e) {
|
|
112
|
-
return e.length === 0 ? { count: 0 } : { count: (await
|
|
112
|
+
return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__delete`, {
|
|
113
113
|
object_ids: e,
|
|
114
114
|
entity: this.entity
|
|
115
115
|
})).object_count ?? e.length };
|
|
@@ -118,7 +118,7 @@ var b = class {
|
|
|
118
118
|
await this.restoreMany([e]);
|
|
119
119
|
}
|
|
120
120
|
async restoreMany(e) {
|
|
121
|
-
return e.length === 0 ? { count: 0 } : { count: (await
|
|
121
|
+
return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__restore`, {
|
|
122
122
|
object_ids: e,
|
|
123
123
|
entity: this.entity
|
|
124
124
|
})).object_count ?? e.length };
|
|
@@ -126,20 +126,20 @@ var b = class {
|
|
|
126
126
|
async upsert(e, t) {
|
|
127
127
|
return (await this.upsertMany([e], t))[0];
|
|
128
128
|
}
|
|
129
|
-
async upsertMany(
|
|
130
|
-
if (
|
|
131
|
-
let
|
|
132
|
-
actions:
|
|
129
|
+
async upsertMany(t, n) {
|
|
130
|
+
if (t.length === 0) return [];
|
|
131
|
+
let r = await e("system.batch", {
|
|
132
|
+
actions: t.map((e) => ({
|
|
133
133
|
action: `${this.entity}.__upsert`,
|
|
134
134
|
params: {
|
|
135
135
|
entity: this.entity,
|
|
136
136
|
fields: e,
|
|
137
|
-
unique_by:
|
|
137
|
+
unique_by: n
|
|
138
138
|
}
|
|
139
139
|
})),
|
|
140
140
|
atomic: !0
|
|
141
141
|
});
|
|
142
|
-
return x(
|
|
142
|
+
return x(r, `${this.entity}.__upsert`), r.results.map((e) => _(C(e)));
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
function x(e, t) {
|
|
@@ -232,40 +232,40 @@ function O(e, t, n) {
|
|
|
232
232
|
}
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region src/hooks/useTabSearchMirror.ts
|
|
235
|
-
function k(
|
|
236
|
-
let
|
|
235
|
+
function k(e) {
|
|
236
|
+
let t = r(), [n] = d();
|
|
237
237
|
l(() => {
|
|
238
|
-
if (!
|
|
239
|
-
let
|
|
240
|
-
i &&
|
|
238
|
+
if (!e || t.enabled) return;
|
|
239
|
+
let r = c.getState(), i = r.findTabByPathname(e);
|
|
240
|
+
i && r.updateTabSearch(i.id, n.toString());
|
|
241
241
|
}, [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
n,
|
|
243
|
+
e,
|
|
244
|
+
t.enabled
|
|
245
245
|
]);
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/hooks/useRegisterScreenTab.ts
|
|
249
|
-
function A(t, n,
|
|
250
|
-
let a =
|
|
249
|
+
function A(e, t, n, i) {
|
|
250
|
+
let a = r();
|
|
251
251
|
l(() => {
|
|
252
|
-
!
|
|
253
|
-
pathname:
|
|
252
|
+
!e || a.enabled || c.getState().openTab({
|
|
253
|
+
pathname: e,
|
|
254
254
|
search: i,
|
|
255
|
-
title:
|
|
256
|
-
icon:
|
|
255
|
+
title: t,
|
|
256
|
+
icon: n,
|
|
257
257
|
closable: !0
|
|
258
258
|
});
|
|
259
259
|
}, [
|
|
260
|
+
e,
|
|
260
261
|
t,
|
|
261
262
|
n,
|
|
262
|
-
r,
|
|
263
263
|
a.enabled
|
|
264
264
|
]);
|
|
265
265
|
}
|
|
266
266
|
function j(e, t, n) {
|
|
267
|
-
let r = e?.route, i = t ?
|
|
268
|
-
A(t ? r : void 0, i,
|
|
267
|
+
let r = e?.route, i = t ? a(e?.display?.name) || a(t.display.name_plural) : "", o = e?.display?.icon || t?.display.icon;
|
|
268
|
+
A(t ? r : void 0, i, o, n);
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/lib/filters.ts
|
|
@@ -332,14 +332,14 @@ function z(e, t) {
|
|
|
332
332
|
if (!e.field || !e.op) return "";
|
|
333
333
|
let n = N[e.op] || e.op;
|
|
334
334
|
if (M.has(e.op)) return `${n}`;
|
|
335
|
-
let r = e.field,
|
|
335
|
+
let r = e.field, i = (e) => {
|
|
336
336
|
if (t) {
|
|
337
337
|
let n = t(r, e);
|
|
338
338
|
return n.label != null && (n.status === "special" || n.status === "resolved") ? n.label : n.raw;
|
|
339
339
|
}
|
|
340
|
-
return
|
|
340
|
+
return s(e);
|
|
341
341
|
};
|
|
342
|
-
return `${n} ${Array.isArray(e.value) ? e.value.map(
|
|
342
|
+
return `${n} ${Array.isArray(e.value) ? e.value.map(i).join(", ") : i(e.value)}`;
|
|
343
343
|
}
|
|
344
344
|
function B(e, t) {
|
|
345
345
|
return {
|
|
@@ -379,12 +379,12 @@ async function H(e, t, n, r, i) {
|
|
|
379
379
|
status_code: r
|
|
380
380
|
};
|
|
381
381
|
i != null && (a.note = i);
|
|
382
|
-
let
|
|
382
|
+
let s = (await o(`${e}.__update`, {
|
|
383
383
|
object_ids: [t],
|
|
384
384
|
entity: e,
|
|
385
385
|
fields: { $statuses: [a] }
|
|
386
386
|
})).result?.rows?.[0]?.$statuses ?? [];
|
|
387
|
-
return
|
|
387
|
+
return s.find((e) => e.group_code === n) ?? s[0];
|
|
388
388
|
}
|
|
389
389
|
//#endregion
|
|
390
390
|
//#region src/hooks/useObjectStatus.ts
|
|
@@ -403,7 +403,7 @@ function U(e, t) {
|
|
|
403
403
|
//#endregion
|
|
404
404
|
//#region src/api/properties.ts
|
|
405
405
|
async function W(e, t, n, r) {
|
|
406
|
-
let i = (await
|
|
406
|
+
let i = (await o(`${e}.__update`, {
|
|
407
407
|
object_ids: [t],
|
|
408
408
|
entity: e,
|
|
409
409
|
fields: { $properties: [{
|
|
@@ -414,7 +414,7 @@ async function W(e, t, n, r) {
|
|
|
414
414
|
return i.find((e) => e.property_code === n) ?? i[0];
|
|
415
415
|
}
|
|
416
416
|
async function G(e, t, n) {
|
|
417
|
-
await
|
|
417
|
+
await o(`${e}.__update`, {
|
|
418
418
|
object_ids: [t],
|
|
419
419
|
entity: e,
|
|
420
420
|
fields: { $properties: [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ht as e, Rt as t, zt as n } from "./ActionRunner-UGGvGypS.js";
|
|
2
2
|
import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
|
|
3
3
|
//#region src/components/file-widgets/helpers.ts
|
|
4
4
|
var s = ["thumb_200", "thumb_300"];
|
|
@@ -113,17 +113,17 @@ function T(e, t) {
|
|
|
113
113
|
function E(e) {
|
|
114
114
|
return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
|
|
115
115
|
}
|
|
116
|
-
async function D(
|
|
117
|
-
let i = await
|
|
116
|
+
async function D(e, r) {
|
|
117
|
+
let i = await t(), a = await fetch(e, T(i, r));
|
|
118
118
|
if (a.status !== 401) return a;
|
|
119
|
-
|
|
120
|
-
let o = await
|
|
121
|
-
return fetch(
|
|
122
|
-
}
|
|
123
|
-
async function O(
|
|
124
|
-
if (!
|
|
125
|
-
let i = await D(C(
|
|
126
|
-
if (i.status === 202 && typeof
|
|
119
|
+
n();
|
|
120
|
+
let o = await t();
|
|
121
|
+
return fetch(e, T(o, r));
|
|
122
|
+
}
|
|
123
|
+
async function O(t, n, r) {
|
|
124
|
+
if (!e()) throw Error("resolveEmbedFileSrc called outside embed token mode");
|
|
125
|
+
let i = await D(C(t, n), r);
|
|
126
|
+
if (i.status === 202 && typeof n == "object") throw new w(t, n.derivation);
|
|
127
127
|
if (!i.ok) throw Error(`embed file url request failed: ${i.status} ${i.statusText}`);
|
|
128
128
|
let a = await i.json();
|
|
129
129
|
if (!S(a)) throw Error("embed file url response is malformed");
|
|
@@ -132,7 +132,7 @@ async function O(e, t, r) {
|
|
|
132
132
|
kind: "direct"
|
|
133
133
|
};
|
|
134
134
|
if (!a.url.startsWith("/api/files/")) throw Error(`embed file proxy: refusing non-files-route URL ${JSON.stringify(a.url)}`);
|
|
135
|
-
let o = await D(
|
|
135
|
+
let o = await D(n === "download" ? E(a.url) : a.url, r);
|
|
136
136
|
if (!o.ok) throw Error(`embed file proxy fetch failed: ${o.status} ${o.statusText}`);
|
|
137
137
|
let s = await o.blob();
|
|
138
138
|
return {
|
|
@@ -148,23 +148,23 @@ function k(e) {
|
|
|
148
148
|
function A(e) {
|
|
149
149
|
return e.startsWith("derivation:") ? { derivation: e.slice(11) } : e === "download" ? "download" : "preview";
|
|
150
150
|
}
|
|
151
|
-
function j(
|
|
152
|
-
let a = k(
|
|
151
|
+
function j(t, n, r) {
|
|
152
|
+
let a = k(n), [s, c] = o(() => e() ? void 0 : r);
|
|
153
153
|
return i(() => {
|
|
154
|
-
|
|
154
|
+
e() || c(r);
|
|
155
155
|
}, [r]), i(() => {
|
|
156
|
-
if (!
|
|
157
|
-
if (!
|
|
156
|
+
if (!e()) return;
|
|
157
|
+
if (!t) {
|
|
158
158
|
c(void 0);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
let
|
|
162
|
-
return c(void 0), O(
|
|
161
|
+
let n = null, r = !1, i = new AbortController();
|
|
162
|
+
return c(void 0), O(t, A(a), i.signal).then((e) => {
|
|
163
163
|
if (r) {
|
|
164
164
|
e.kind === "blob" && URL.revokeObjectURL(e.url);
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
e.kind === "blob" && (
|
|
167
|
+
e.kind === "blob" && (n = e.url), c(e.url);
|
|
168
168
|
}).catch((e) => {
|
|
169
169
|
if (!r) {
|
|
170
170
|
if (e instanceof w) {
|
|
@@ -174,22 +174,22 @@ function j(e, t, r) {
|
|
|
174
174
|
e instanceof DOMException && e.name === "AbortError" || (console.error("[declarion-embed] file src resolution failed:", e), c(void 0));
|
|
175
175
|
}
|
|
176
176
|
}), () => {
|
|
177
|
-
r = !0, i.abort(),
|
|
177
|
+
r = !0, i.abort(), n && URL.revokeObjectURL(n);
|
|
178
178
|
};
|
|
179
|
-
}, [
|
|
179
|
+
}, [t, a]), s;
|
|
180
180
|
}
|
|
181
181
|
function M() {
|
|
182
|
-
let
|
|
182
|
+
let t = a([]);
|
|
183
183
|
return i(() => () => {
|
|
184
|
-
for (let
|
|
185
|
-
|
|
186
|
-
}, []), { open: r((
|
|
187
|
-
if (!
|
|
184
|
+
for (let e of t.current) URL.revokeObjectURL(e);
|
|
185
|
+
t.current = [];
|
|
186
|
+
}, []), { open: r((n, r, i) => {
|
|
187
|
+
if (!e()) {
|
|
188
188
|
i && window.open(i, "_blank", "noopener");
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
n && O(n, r).then((e) => {
|
|
192
|
+
e.kind === "blob" && t.current.push(e.url), window.open(e.url, "_blank", "noopener");
|
|
193
193
|
}).catch((e) => {
|
|
194
194
|
e instanceof w || console.error("[declarion-embed] file open failed:", e);
|
|
195
195
|
});
|