@gtsx/studio 0.0.1 → 0.0.3
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/boundary-tree.d.ts +4 -0
- package/dist/boundary-tree.d.ts.map +1 -0
- package/dist/case-grid-layout.d.ts +10 -1
- package/dist/case-grid-layout.d.ts.map +1 -1
- package/dist/chunks/client-entry-ByeOr0nI.js +5863 -0
- package/dist/client.d.ts +42 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/components/BufferedPreviewIframe.g.d.ts +1 -0
- package/dist/components/BufferedPreviewIframe.g.d.ts.map +1 -1
- package/dist/components/ComponentCard.g.d.ts +4 -1
- package/dist/components/ComponentCard.g.d.ts.map +1 -1
- package/dist/components/FileGroupLink.g.d.ts.map +1 -1
- package/dist/components/LazyPreviewFrame.g.d.ts +33 -0
- package/dist/components/LazyPreviewFrame.g.d.ts.map +1 -1
- package/dist/components/PreviewError.g.d.ts.map +1 -1
- package/dist/components/SelectedBoundaryOutline.g.d.ts.map +1 -1
- package/dist/components/SidebarComponentPreview.g.d.ts.map +1 -1
- package/dist/components/StudioComponentCardSlot.d.ts +3 -1
- package/dist/components/StudioComponentCardSlot.d.ts.map +1 -1
- package/dist/components/StudioDesignWorkspace.g.d.ts +11 -0
- package/dist/components/StudioDesignWorkspace.g.d.ts.map +1 -0
- package/dist/components/StudioEmptyState.g.d.ts.map +1 -1
- package/dist/components/StudioPreviewIframe.d.ts +1 -0
- package/dist/components/StudioPreviewIframe.d.ts.map +1 -1
- package/dist/components/StudioShell.d.ts +9 -1
- package/dist/components/StudioShell.d.ts.map +1 -1
- package/dist/components/StudioWorkspaceView.g.d.ts +136 -4
- package/dist/components/StudioWorkspaceView.g.d.ts.map +1 -1
- package/dist/components/ViewportPresetTabs.g.d.ts +5 -16
- package/dist/components/ViewportPresetTabs.g.d.ts.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/manifest-server.d.ts +2 -1
- package/dist/manifest-server.d.ts.map +1 -1
- package/dist/manifest-server.js +39 -15
- package/dist/manifest.d.ts +14 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +8 -5
- package/dist/preview-frame-layout.d.ts +1 -1
- package/dist/preview-frame-layout.d.ts.map +1 -1
- package/dist/preview-iframe-pool.d.ts +9 -0
- package/dist/preview-iframe-pool.d.ts.map +1 -1
- package/dist/preview-render-queue.d.ts +1 -0
- package/dist/preview-render-queue.d.ts.map +1 -1
- package/dist/studio-canvas-geometry.d.ts +67 -3
- package/dist/studio-canvas-geometry.d.ts.map +1 -1
- package/dist/studio-canvas-screen-stable-chrome.d.ts +28 -0
- package/dist/studio-canvas-screen-stable-chrome.d.ts.map +1 -0
- package/dist/studio-preview-render-plan.d.ts +3 -0
- package/dist/studio-preview-render-plan.d.ts.map +1 -1
- package/dist/studio-theme.d.ts +86 -0
- package/dist/studio-theme.d.ts.map +1 -0
- package/dist/studio-workspace-view-helpers.d.ts +11 -0
- package/dist/studio-workspace-view-helpers.d.ts.map +1 -0
- package/dist/use-studio-canvas-controller.d.ts.map +1 -1
- package/dist/use-studio-canvas-layout.d.ts +1 -0
- package/dist/use-studio-canvas-layout.d.ts.map +1 -1
- package/dist/use-studio-preview-render-scheduler.d.ts +6 -0
- package/dist/use-studio-preview-render-scheduler.d.ts.map +1 -1
- package/package.json +13 -9
- package/dist/chunks/client-entry-6rzfPqgF.js +0 -3973
|
@@ -1,3973 +0,0 @@
|
|
|
1
|
-
import { G_PREVIEW_PROTOCOL_VERSION as e, createGPreviewRenderMessage as t, createGPreviewRequestValuesMessage as n, createGScopeHook as r, defineGComponent as i } from "@gtsx/core";
|
|
2
|
-
import a from "react";
|
|
3
|
-
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
-
import { flushSync as l } from "react-dom";
|
|
5
|
-
//#region src/preview-frame-layout.ts
|
|
6
|
-
var u = 16;
|
|
7
|
-
function d(e, t) {
|
|
8
|
-
if (!t) return e.height;
|
|
9
|
-
let n = h(e, t);
|
|
10
|
-
return Math.max(1, Math.ceil(t.height + n.top + n.bottom));
|
|
11
|
-
}
|
|
12
|
-
function f(e, t) {
|
|
13
|
-
if (!t) return e.width;
|
|
14
|
-
let n = h(e, t);
|
|
15
|
-
return Math.max(1, Math.ceil(t.width + n.left + n.right));
|
|
16
|
-
}
|
|
17
|
-
function p(e, t) {
|
|
18
|
-
return {
|
|
19
|
-
x: Math.max(0, Math.floor(e?.x ?? 0) - t.left),
|
|
20
|
-
y: Math.max(0, Math.floor(e?.y ?? 0) - t.top)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function m(e, t) {
|
|
24
|
-
if (e) return {
|
|
25
|
-
x: t.left,
|
|
26
|
-
y: t.top,
|
|
27
|
-
width: e.width,
|
|
28
|
-
height: e.height
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function h(e, t) {
|
|
32
|
-
if (!t) return {
|
|
33
|
-
bottom: 0,
|
|
34
|
-
left: 0,
|
|
35
|
-
right: 0,
|
|
36
|
-
top: 0
|
|
37
|
-
};
|
|
38
|
-
let n = typeof e.width == "number" ? e.width : Infinity;
|
|
39
|
-
return {
|
|
40
|
-
bottom: Math.min(u, Math.max(0, (e.height ?? Infinity) - t.y - t.height)),
|
|
41
|
-
left: Math.min(u, Math.max(0, t.x)),
|
|
42
|
-
right: Math.min(u, Math.max(0, n - t.x - t.width)),
|
|
43
|
-
top: Math.min(u, Math.max(0, t.y))
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/client.tsx
|
|
48
|
-
var g = "roots";
|
|
49
|
-
function _(t, n) {
|
|
50
|
-
if (n.protocolVersion !== e || n.sessionId !== t.expectedSessionId) return t;
|
|
51
|
-
if (n.type === "gtsx:ready") {
|
|
52
|
-
if (t.ready && !t.error) return t;
|
|
53
|
-
let e = {
|
|
54
|
-
...t,
|
|
55
|
-
ready: !0
|
|
56
|
-
};
|
|
57
|
-
return delete e.error, e;
|
|
58
|
-
}
|
|
59
|
-
return n.type === "gtsx:tree" ? y(t.tree, n.tree) ? t : {
|
|
60
|
-
...t,
|
|
61
|
-
tree: n.tree
|
|
62
|
-
} : n.type === "gtsx:resize" ? t.size?.width === n.size.width && t.size.height === n.size.height ? t : {
|
|
63
|
-
...t,
|
|
64
|
-
size: n.size
|
|
65
|
-
} : n.type === "gtsx:error" ? t.error?.message === n.error.message && t.error.stack === n.error.stack ? t : {
|
|
66
|
-
...t,
|
|
67
|
-
error: n.error
|
|
68
|
-
} : n.type === "gtsx:values" ? {
|
|
69
|
-
...t,
|
|
70
|
-
valuesByBoundaryId: {
|
|
71
|
-
...t.valuesByBoundaryId,
|
|
72
|
-
[n.values.boundaryId]: n.values
|
|
73
|
-
}
|
|
74
|
-
} : t;
|
|
75
|
-
}
|
|
76
|
-
function v(e, t, n) {
|
|
77
|
-
if (!n.has(t.sessionId)) return e;
|
|
78
|
-
let r = e[t.sessionId] ?? {
|
|
79
|
-
expectedSessionId: t.sessionId,
|
|
80
|
-
ready: !1
|
|
81
|
-
}, i = _(r, t);
|
|
82
|
-
return i === r ? e : {
|
|
83
|
-
...e,
|
|
84
|
-
[t.sessionId]: i
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function y(e, t) {
|
|
88
|
-
return e === t ? !0 : !e || !t || e.length !== t.length ? !1 : e.every((e, n) => b(e, t[n]));
|
|
89
|
-
}
|
|
90
|
-
function b(e, t) {
|
|
91
|
-
return t ? e.id === t.id && e.coordinate === t.coordinate && x(e.rect, t.rect) && y(e.children, t.children) : !1;
|
|
92
|
-
}
|
|
93
|
-
function x(e, t) {
|
|
94
|
-
return e === t || e?.x === t?.x && e?.y === t?.y && e?.width === t?.width && e?.height === t?.height;
|
|
95
|
-
}
|
|
96
|
-
function S(e, t) {
|
|
97
|
-
return {
|
|
98
|
-
canvasViewportPreset: "tablet",
|
|
99
|
-
columns: [{ components: U(e, t).components }],
|
|
100
|
-
selectedCaseByCoordinate: {},
|
|
101
|
-
selectedCoordinatePath: [],
|
|
102
|
-
selectedRuntimeInstanceByCoordinate: {},
|
|
103
|
-
selectedViewportPresetByCoordinate: {}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function C() {
|
|
107
|
-
return {
|
|
108
|
-
x: 40,
|
|
109
|
-
y: 40,
|
|
110
|
-
scale: 1
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function w(e, t, n, r, i = {}) {
|
|
114
|
-
let a = T(e, n, i.columnIndex);
|
|
115
|
-
if (a < 0) return e;
|
|
116
|
-
let o = e.columns.slice(0, a + 1), s = [...e.selectedCoordinatePath.slice(0, a), n], c = le(t, ue(r), n);
|
|
117
|
-
return c.length > 0 && o.push({
|
|
118
|
-
components: c,
|
|
119
|
-
parentCoordinate: n
|
|
120
|
-
}), {
|
|
121
|
-
canvasViewportPreset: I(e),
|
|
122
|
-
columns: o,
|
|
123
|
-
selectedCaseByCoordinate: de(e.selectedCaseByCoordinate, s),
|
|
124
|
-
selectedCoordinatePath: s,
|
|
125
|
-
selectedRuntimeInstanceByCoordinate: e.selectedRuntimeInstanceByCoordinate,
|
|
126
|
-
selectedViewportPresetByCoordinate: e.selectedViewportPresetByCoordinate
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function T(e, t, n) {
|
|
130
|
-
return n !== void 0 && e.columns[n]?.components.some((e) => e.coordinate === t) ? n : e.columns.findIndex((e) => e.components.some((e) => e.coordinate === t));
|
|
131
|
-
}
|
|
132
|
-
function E(e, t) {
|
|
133
|
-
return e.selectedCaseByCoordinate[t.coordinate] ?? t.cases[0]?.name ?? "No cases";
|
|
134
|
-
}
|
|
135
|
-
function D(e, t, n, r = {}) {
|
|
136
|
-
let i = e.columns.findIndex((e) => e.components.some((e) => e.coordinate === t)), a = r.keepDrilldown || i < 0 ? e.columns : e.columns.slice(0, i + 1);
|
|
137
|
-
return {
|
|
138
|
-
canvasViewportPreset: I(e),
|
|
139
|
-
columns: a,
|
|
140
|
-
selectedCaseByCoordinate: {
|
|
141
|
-
...e.selectedCaseByCoordinate,
|
|
142
|
-
[t]: n
|
|
143
|
-
},
|
|
144
|
-
selectedCoordinatePath: r.keepDrilldown || i < 0 ? e.selectedCoordinatePath : [...e.selectedCoordinatePath.slice(0, i), t],
|
|
145
|
-
selectedRuntimeInstanceByCoordinate: {},
|
|
146
|
-
selectedViewportPresetByCoordinate: e.selectedViewportPresetByCoordinate
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function O(e, t, n) {
|
|
150
|
-
return {
|
|
151
|
-
...e,
|
|
152
|
-
selectedRuntimeInstanceByCoordinate: {
|
|
153
|
-
...e.selectedRuntimeInstanceByCoordinate,
|
|
154
|
-
[t]: n
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function ee(e, t, n) {
|
|
159
|
-
return {
|
|
160
|
-
...e,
|
|
161
|
-
canvasViewportPreset: n,
|
|
162
|
-
selectedViewportPresetByCoordinate: {
|
|
163
|
-
...e.selectedViewportPresetByCoordinate,
|
|
164
|
-
[t]: n
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function k(e, t) {
|
|
169
|
-
return {
|
|
170
|
-
...e,
|
|
171
|
-
canvasViewportPreset: t,
|
|
172
|
-
selectedViewportPresetByCoordinate: {}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function A(e, t, n) {
|
|
176
|
-
let r = new URLSearchParams();
|
|
177
|
-
e && e !== g && r.set("selection", e);
|
|
178
|
-
let i = I(t);
|
|
179
|
-
i !== "tablet" && r.set("canvasViewport", i), we(r, n);
|
|
180
|
-
for (let e of t.selectedCoordinatePath) r.append("path", e);
|
|
181
|
-
for (let e of t.selectedCoordinatePath) {
|
|
182
|
-
let n = t.selectedCaseByCoordinate[e];
|
|
183
|
-
n && r.append("case", `${e}:${n}`);
|
|
184
|
-
let i = t.selectedRuntimeInstanceByCoordinate[e];
|
|
185
|
-
i && r.append("instance", `${e}:${i}`);
|
|
186
|
-
let a = t.selectedViewportPresetByCoordinate[e];
|
|
187
|
-
a !== void 0 && r.append("viewport", `${e}:${a}`);
|
|
188
|
-
}
|
|
189
|
-
return r;
|
|
190
|
-
}
|
|
191
|
-
function j(e, t) {
|
|
192
|
-
let n = t.get("selection") ?? void 0, r = me(t), i = U(e, n), a = t.getAll("path"), o = a.filter((t) => !!L(e, t)), s = new Set(o), c = ne(e, t, s), l = M(e, t, s), u = re(e, t, s), d = ie(t, u, o), f = n && n !== i.id || a.length !== o.length || se(e, t, s) || ce(e, t, s) || oe(t) ? "Invalid Studio URL state was ignored." : void 0;
|
|
193
|
-
return o.length === 0 ? {
|
|
194
|
-
canvas: r,
|
|
195
|
-
selection: i.id,
|
|
196
|
-
workspace: {
|
|
197
|
-
canvasViewportPreset: d,
|
|
198
|
-
columns: [{ components: i.components }],
|
|
199
|
-
selectedCaseByCoordinate: c,
|
|
200
|
-
selectedCoordinatePath: [],
|
|
201
|
-
selectedRuntimeInstanceByCoordinate: l,
|
|
202
|
-
selectedViewportPresetByCoordinate: u
|
|
203
|
-
},
|
|
204
|
-
...f ? { warning: f } : {}
|
|
205
|
-
} : {
|
|
206
|
-
canvas: r,
|
|
207
|
-
selection: i.id,
|
|
208
|
-
workspace: {
|
|
209
|
-
canvasViewportPreset: d,
|
|
210
|
-
columns: [{ components: i.components }, ...o.slice(1).map((t) => {
|
|
211
|
-
let n = L(e, t), r = o.indexOf(t);
|
|
212
|
-
return {
|
|
213
|
-
components: n ? [n] : [],
|
|
214
|
-
parentCoordinate: r > 0 ? o[r - 1] : void 0
|
|
215
|
-
};
|
|
216
|
-
})],
|
|
217
|
-
selectedCaseByCoordinate: c,
|
|
218
|
-
selectedCoordinatePath: o,
|
|
219
|
-
selectedRuntimeInstanceByCoordinate: l,
|
|
220
|
-
selectedViewportPresetByCoordinate: u
|
|
221
|
-
},
|
|
222
|
-
...f ? { warning: f } : {}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function te(e, t, r) {
|
|
226
|
-
let i = t.selectedCoordinatePath.at(-1);
|
|
227
|
-
if (!i) return;
|
|
228
|
-
let a = L(e, t.selectedCoordinatePath.at(-2) ?? i);
|
|
229
|
-
if (!a) return;
|
|
230
|
-
let o = z(a, E(t, a), I(t));
|
|
231
|
-
return {
|
|
232
|
-
sessionId: o,
|
|
233
|
-
message: n(o, r)
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function ne(e, t, n) {
|
|
237
|
-
let r = {};
|
|
238
|
-
for (let i of t.getAll("case")) {
|
|
239
|
-
let t = N(e, i);
|
|
240
|
-
if (!t) continue;
|
|
241
|
-
let a = L(e, t.coordinate);
|
|
242
|
-
n.has(t.coordinate) && a?.cases.some((e) => e.name === t.value) && (r[t.coordinate] = t.value);
|
|
243
|
-
}
|
|
244
|
-
return r;
|
|
245
|
-
}
|
|
246
|
-
function M(e, t, n) {
|
|
247
|
-
let r = {};
|
|
248
|
-
for (let i of t.getAll("instance")) {
|
|
249
|
-
let t = N(e, i);
|
|
250
|
-
t && n.has(t.coordinate) && L(e, t.coordinate) && (r[t.coordinate] = t.value);
|
|
251
|
-
}
|
|
252
|
-
return r;
|
|
253
|
-
}
|
|
254
|
-
function re(e, t, n) {
|
|
255
|
-
let r = {};
|
|
256
|
-
for (let i of t.getAll("viewport")) {
|
|
257
|
-
let t = N(e, i);
|
|
258
|
-
t && n.has(t.coordinate) && ae(t.value) && (r[t.coordinate] = t.value);
|
|
259
|
-
}
|
|
260
|
-
return r;
|
|
261
|
-
}
|
|
262
|
-
function ie(e, t, n) {
|
|
263
|
-
let r = e.get("canvasViewport");
|
|
264
|
-
if (r && ae(r)) return r;
|
|
265
|
-
let i = [...n].reverse().find((e) => t[e]);
|
|
266
|
-
return i ? t[i] : "tablet";
|
|
267
|
-
}
|
|
268
|
-
function ae(e) {
|
|
269
|
-
return e === "phone" || e === "tablet" || e === "desktop";
|
|
270
|
-
}
|
|
271
|
-
function oe(e) {
|
|
272
|
-
let t = e.get("canvasViewport");
|
|
273
|
-
return !!(t && !ae(t));
|
|
274
|
-
}
|
|
275
|
-
function se(e, t, n) {
|
|
276
|
-
return t.getAll("case").some((t) => {
|
|
277
|
-
let r = N(e, t);
|
|
278
|
-
return !r || !n.has(r.coordinate) ? !0 : !L(e, r.coordinate)?.cases.some((e) => e.name === r.value);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
function ce(e, t, n) {
|
|
282
|
-
return t.getAll("instance").some((t) => {
|
|
283
|
-
let r = N(e, t);
|
|
284
|
-
return !r || !n.has(r.coordinate);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
function N(e, t) {
|
|
288
|
-
let n = e.files.flatMap((e) => e.components).map((e) => e.coordinate).sort((e, t) => t.length - e.length).find((e) => t.startsWith(`${e}:`));
|
|
289
|
-
if (n) return {
|
|
290
|
-
coordinate: n,
|
|
291
|
-
value: t.slice(n.length + 1)
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
function le(e, t, n) {
|
|
295
|
-
let r = new Map(e.files.flatMap((e) => e.components).map((e) => [e.coordinate, e])), i = /* @__PURE__ */ new Set(), a = [];
|
|
296
|
-
for (let e of t) {
|
|
297
|
-
let t = fe(e, n);
|
|
298
|
-
if (t) for (let e of t.children) {
|
|
299
|
-
if (i.has(e.coordinate)) continue;
|
|
300
|
-
let t = r.get(e.coordinate);
|
|
301
|
-
t && (i.add(e.coordinate), a.push(t));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return a;
|
|
305
|
-
}
|
|
306
|
-
function ue(e) {
|
|
307
|
-
return e.length === 0 ? [] : Array.isArray(e[0]) ? e : [e];
|
|
308
|
-
}
|
|
309
|
-
function de(e, t) {
|
|
310
|
-
let n = new Set(t);
|
|
311
|
-
return Object.fromEntries(Object.entries(e).filter(([e]) => !n.has(e)));
|
|
312
|
-
}
|
|
313
|
-
function fe(e, t) {
|
|
314
|
-
for (let n of e) {
|
|
315
|
-
if (n.coordinate === t) return n;
|
|
316
|
-
let e = fe(n.children, t);
|
|
317
|
-
if (e) return e;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function pe(e, t) {
|
|
321
|
-
if (t !== void 0) return new URLSearchParams(t);
|
|
322
|
-
if (typeof window < "u" && window.location.search) return new URLSearchParams(window.location.search);
|
|
323
|
-
let n = new URLSearchParams();
|
|
324
|
-
return e && n.set("selection", e), n;
|
|
325
|
-
}
|
|
326
|
-
function me(e) {
|
|
327
|
-
let t = C();
|
|
328
|
-
return {
|
|
329
|
-
x: Te(e, "canvasX", t.x),
|
|
330
|
-
y: Te(e, "canvasY", t.y),
|
|
331
|
-
scale: P(Te(e, "canvasScale", t.scale), Se, Ce)
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
function he(e) {
|
|
335
|
-
if (typeof window > "u") return;
|
|
336
|
-
let t = new URLSearchParams(window.location.search);
|
|
337
|
-
we(t, e);
|
|
338
|
-
let n = t.toString(), r = `${window.location.pathname}${n ? `?${n}` : ""}`;
|
|
339
|
-
r !== `${window.location.pathname}${window.location.search}` && window.history.replaceState({ gtsxStudio: !0 }, "", r);
|
|
340
|
-
}
|
|
341
|
-
function ge(e, t, n = {}) {
|
|
342
|
-
if (typeof window > "u") return;
|
|
343
|
-
let r = A(e, t, n.canvas ?? me(new URLSearchParams(window.location.search)));
|
|
344
|
-
xe(r, new URLSearchParams(window.location.search));
|
|
345
|
-
let i = r.toString(), a = `${window.location.pathname}${i ? `?${i}` : ""}`;
|
|
346
|
-
a !== `${window.location.pathname}${window.location.search}` && window.history.pushState({ gtsxStudio: !0 }, "", a);
|
|
347
|
-
}
|
|
348
|
-
function _e(e) {
|
|
349
|
-
let t = be(e);
|
|
350
|
-
return t.includes("pool") || t.includes("preview-pool") || t.includes("no-pool") || t.includes("disable-pool") || e.get("debugPool") === "1" || ye(e);
|
|
351
|
-
}
|
|
352
|
-
function ve(e) {
|
|
353
|
-
let t = be(e);
|
|
354
|
-
return t.includes("queue") || t.includes("preview-queue");
|
|
355
|
-
}
|
|
356
|
-
function ye(e) {
|
|
357
|
-
let t = be(e), n = e.get("debugPool")?.trim().toLowerCase();
|
|
358
|
-
return t.includes("no-pool") || t.includes("disable-pool") || t.includes("without-pool") || n === "0" || n === "false" || n === "off";
|
|
359
|
-
}
|
|
360
|
-
function be(e) {
|
|
361
|
-
return e.getAll("debug").join(",").split(",").map((e) => e.trim()).filter(Boolean);
|
|
362
|
-
}
|
|
363
|
-
function xe(e, t) {
|
|
364
|
-
for (let n of /* @__PURE__ */ "debug.debugPool.debounce.maximumConcurrentRenderTasks.maximumConcurrentRenderTasksDuringCanvasMovement.maximumRenderTaskCount.minimumVisibleRenderTasksDuringCanvasMovement.previewQueueActiveRenderTimeout.previewQueueActiveRenderTimeoutMilliseconds.previewQueueActive.previewQueueActiveTimeout.previewQueueBufferRenderDelay.previewQueueBufferRenderDelayMilliseconds.previewQueueBuffer.previewQueueDebounce.previewQueueLength.previewQueueMaximumConcurrentRenderTasks.previewQueueMaximumConcurrentRenderTasksDuringCanvasMovement.previewQueueMaximumMountedPreviewSessions.previewQueueMaximumRenderTaskCount.previewQueueMinimumVisibleRenderTasksDuringCanvasMovement.previewQueueVisibleRenderFloor.previewQueueRenderBufferMargin.previewQueueRenderDebounce.previewQueueRenderDebounceMilliseconds.previewQueueRenderThrottle.previewQueueRenderThrottleMilliseconds.previewQueueSafety.previewQueueThrottle.queueActiveRenderTimeout.queueActive.queueActiveTimeout.queueBufferRenderDelay.queueBuffer.queueDebounce.queueLength.queueMaximumConcurrentRenderTasks.queueMaximumConcurrentRenderTasksDuringCanvasMovement.queueMaximumMountedPreviewSessions.queueMaximumRenderTaskCount.queueMinimumVisibleRenderTasksDuringCanvasMovement.queueRenderBufferMargin.queueRenderDebounce.queueRenderThrottle.queueSafety.queueThrottle.queueVisibleRenderFloor.previewBuffer.previewDebounce.previewRenderBufferMargin.previewRenderDebounce.previewRenderThrottle.previewThrottle.throttle".split(".")) {
|
|
365
|
-
e.delete(n);
|
|
366
|
-
for (let r of t.getAll(n)) e.append(n, r);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
function P(e, t, n) {
|
|
370
|
-
return Math.min(n, Math.max(t, e));
|
|
371
|
-
}
|
|
372
|
-
var Se = .2, Ce = 2.5;
|
|
373
|
-
function we(e, t) {
|
|
374
|
-
if (e.delete("canvasX"), e.delete("canvasY"), e.delete("canvasScale"), !t) return;
|
|
375
|
-
let n = C();
|
|
376
|
-
t.x !== n.x && e.set("canvasX", Ee(t.x)), t.y !== n.y && e.set("canvasY", Ee(t.y)), t.scale !== n.scale && e.set("canvasScale", Ee(t.scale));
|
|
377
|
-
}
|
|
378
|
-
function Te(e, t, n) {
|
|
379
|
-
let r = e.get(t);
|
|
380
|
-
if (!r) return n;
|
|
381
|
-
let i = Number(r);
|
|
382
|
-
return Number.isFinite(i) ? i : n;
|
|
383
|
-
}
|
|
384
|
-
function Ee(e) {
|
|
385
|
-
let t = Math.round(e * 1e3) / 1e3;
|
|
386
|
-
return String(Object.is(t, -0) ? 0 : t);
|
|
387
|
-
}
|
|
388
|
-
function De(e, t) {
|
|
389
|
-
if (!t.ctrlKey && !t.metaKey) return {
|
|
390
|
-
...e,
|
|
391
|
-
x: e.x - t.deltaX,
|
|
392
|
-
y: e.y - t.deltaY
|
|
393
|
-
};
|
|
394
|
-
let n = t.focalViewportX ?? t.clientX - t.viewportLeft, r = t.focalViewportY ?? t.clientY - t.viewportTop, i = (n - e.x) / e.scale, a = (r - e.y) / e.scale, o = -t.deltaY * je(t.deltaMode) * 10, s = P(e.scale * 2 ** o, Se, Ce);
|
|
395
|
-
return {
|
|
396
|
-
scale: s,
|
|
397
|
-
x: n - i * s,
|
|
398
|
-
y: r - a * s
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
function Oe(e, t) {
|
|
402
|
-
let n = t.margin ?? 24, r = Me(t.viewportRect, t.blockerRects ?? [], n), i = Ne(t.rect.left, t.rect.right, r.left, r.right), a = Ne(t.rect.top, t.rect.bottom, r.top, r.bottom);
|
|
403
|
-
return i === 0 && a === 0 ? e : {
|
|
404
|
-
...e,
|
|
405
|
-
x: e.x + i,
|
|
406
|
-
y: e.y + a
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function ke(e) {
|
|
410
|
-
let t = e.margin ?? 40, n = {}, r = {};
|
|
411
|
-
return e.columns.forEach((i, a) => {
|
|
412
|
-
if (a === 0 || !i.parentCoordinate) n[a] = {
|
|
413
|
-
x: 0,
|
|
414
|
-
y: 0
|
|
415
|
-
};
|
|
416
|
-
else {
|
|
417
|
-
let o = Fe(r, a, i.parentCoordinate);
|
|
418
|
-
if (!o) n[a] = {
|
|
419
|
-
x: a * t,
|
|
420
|
-
y: 0
|
|
421
|
-
};
|
|
422
|
-
else {
|
|
423
|
-
let i = e.measurementsByIndex[a]?.height ?? 0, s = o.top;
|
|
424
|
-
n[a] = {
|
|
425
|
-
x: (Ie(r, a, s, s + i) ?? o.right) + t,
|
|
426
|
-
y: o.top
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
r[a] = Pe(e.measurementsByIndex[a]?.cardRectsByCoordinate ?? {}, n[a] ?? {
|
|
431
|
-
x: 0,
|
|
432
|
-
y: 0
|
|
433
|
-
}, i.componentCoordinates);
|
|
434
|
-
}), n;
|
|
435
|
-
}
|
|
436
|
-
function F(e) {
|
|
437
|
-
let t = e.gap ?? 14, n = e.caseChromeHeight ?? 20, r = e.maxSide ?? 760, i = e.minScale ?? .24, a = e.items.length > 0 ? e.items : [{
|
|
438
|
-
height: 160,
|
|
439
|
-
width: 280
|
|
440
|
-
}], o = a.length, s = Math.max(1, ...a.map((e) => e.width)), c = Math.max(1, ...a.map((e) => e.height)), l, u = Infinity;
|
|
441
|
-
for (let a = 1; a <= o; a += 1) {
|
|
442
|
-
let d = Math.ceil(o / a), f = a * s + (a - 1) * t, p = d * c, m = d * n + (d - 1) * t, h = Math.max(r * i, r - m), g = P(Math.min(1, r / f, h / p), i, 1), _ = e.previewScale === void 0 ? g : P(e.previewScale, i, 1), v = Math.ceil(s * _), y = Math.ceil(n + c * _), b = Math.ceil(a * v + (a - 1) * t), x = Math.ceil(d * y + (d - 1) * t), S = Math.abs(Math.log(b / x)), C = e.previewScale === void 0 ? (1 - _) * .35 : 0, w = (a * d - o) * .08, T = e.previewScale === void 0 ? 0 : Math.max(0, b - r, x - r) / r, E = S + C + w + T * 4;
|
|
443
|
-
E < u && (u = E, l = {
|
|
444
|
-
caseChromeHeight: n,
|
|
445
|
-
cellHeight: y,
|
|
446
|
-
cellWidth: v,
|
|
447
|
-
columns: a,
|
|
448
|
-
gap: t,
|
|
449
|
-
height: x,
|
|
450
|
-
previewScale: _,
|
|
451
|
-
rows: d,
|
|
452
|
-
width: b
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
return l ?? {
|
|
456
|
-
caseChromeHeight: n,
|
|
457
|
-
cellHeight: n + 160,
|
|
458
|
-
cellWidth: 280,
|
|
459
|
-
columns: 1,
|
|
460
|
-
gap: t,
|
|
461
|
-
height: n + 160,
|
|
462
|
-
previewScale: 1,
|
|
463
|
-
rows: 1,
|
|
464
|
-
width: 280
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function Ae(e, t) {
|
|
468
|
-
if (t.type !== "clear" && t.source !== "keyboard") return t.coordinate === e ? e : t.coordinate;
|
|
469
|
-
}
|
|
470
|
-
function je(e) {
|
|
471
|
-
return e === 1 ? .05 : e === 2 ? 1 : .002;
|
|
472
|
-
}
|
|
473
|
-
function Me(e, t, n) {
|
|
474
|
-
let r = e.left + n, i = e.right - n, a = e.top + n, o = e.bottom - n;
|
|
475
|
-
for (let s of t) {
|
|
476
|
-
let t = s.bottom > a && s.top < o, c = s.right > r && s.left < i;
|
|
477
|
-
if (!t || !c) continue;
|
|
478
|
-
let l = s.right >= e.right - 1, u = s.left <= e.left + 1, d = s.bottom >= e.bottom - 1, f = s.top <= e.top + 1;
|
|
479
|
-
if (l || u) {
|
|
480
|
-
l && (i = Math.min(i, s.left - n)), u && (r = Math.max(r, s.right + n));
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
d && (o = Math.min(o, s.top - n)), f && (a = Math.max(a, s.bottom + n));
|
|
484
|
-
}
|
|
485
|
-
return {
|
|
486
|
-
bottom: Math.max(a, o),
|
|
487
|
-
left: r,
|
|
488
|
-
right: Math.max(r, i),
|
|
489
|
-
top: a
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
function Ne(e, t, n, r) {
|
|
493
|
-
return t - e > r - n ? t < n ? n - e : e > r ? r - t : 0 : e < n ? n - e : t > r ? r - t : 0;
|
|
494
|
-
}
|
|
495
|
-
function Pe(e, t, n) {
|
|
496
|
-
let r = {};
|
|
497
|
-
for (let i of n) {
|
|
498
|
-
let n = e[i];
|
|
499
|
-
n && (r[i] = {
|
|
500
|
-
bottom: n.bottom + t.y,
|
|
501
|
-
left: n.left + t.x,
|
|
502
|
-
right: n.right + t.x,
|
|
503
|
-
top: n.top + t.y
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
return r;
|
|
507
|
-
}
|
|
508
|
-
function Fe(e, t, n) {
|
|
509
|
-
for (let r = t - 1; r >= 0; --r) {
|
|
510
|
-
let t = e[r]?.[n];
|
|
511
|
-
if (t) return t;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
function Ie(e, t, n, r) {
|
|
515
|
-
let i;
|
|
516
|
-
for (let a = 0; a < t; a += 1) for (let t of Object.values(e[a] ?? {})) t.bottom <= n || t.top >= r || (i = i === void 0 ? t.right : Math.max(i, t.right));
|
|
517
|
-
return i;
|
|
518
|
-
}
|
|
519
|
-
function Le(e, t, n) {
|
|
520
|
-
let r = t ? fe(t, n)?.rect : void 0;
|
|
521
|
-
return r ? Math.max(280, Math.ceil(Number(f(e, r)))) : typeof e.width == "number" ? e.width + 28 : 520;
|
|
522
|
-
}
|
|
523
|
-
function Re(e, t) {
|
|
524
|
-
if (!e) return;
|
|
525
|
-
let n = typeof t.width == "number" ? t.width : Infinity, r = P(e.x, 0, n), i = P(e.y, 0, t.height), a = P(e.x + e.width, 0, n), o = P(e.y + e.height, 0, t.height);
|
|
526
|
-
if (!(a <= r || o <= i)) return {
|
|
527
|
-
x: r,
|
|
528
|
-
y: i,
|
|
529
|
-
width: a - r,
|
|
530
|
-
height: o - i
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
function I(e) {
|
|
534
|
-
if (e.canvasViewportPreset) return e.canvasViewportPreset;
|
|
535
|
-
let t = e.selectedCoordinatePath.at(-1);
|
|
536
|
-
return t ? e.selectedViewportPresetByCoordinate[t] ?? "tablet" : Object.values(e.selectedViewportPresetByCoordinate)[0] ?? "tablet";
|
|
537
|
-
}
|
|
538
|
-
function ze(e) {
|
|
539
|
-
let t = /* @__PURE__ */ new Set(), n = [];
|
|
540
|
-
for (let r of e.columns.flatMap((e) => e.components)) t.has(r.coordinate) || (t.add(r.coordinate), n.push(r));
|
|
541
|
-
return n;
|
|
542
|
-
}
|
|
543
|
-
function L(e, t) {
|
|
544
|
-
return e.files.flatMap((e) => e.components).find((e) => e.coordinate === t);
|
|
545
|
-
}
|
|
546
|
-
function R(e, t, n, r = z(t, n), i = {}) {
|
|
547
|
-
let a = new URLSearchParams({
|
|
548
|
-
entry: t.coordinate,
|
|
549
|
-
case: n,
|
|
550
|
-
chrome: "0",
|
|
551
|
-
sessionId: r
|
|
552
|
-
});
|
|
553
|
-
return i.static && a.set("static", "1"), `${e.routes.preview}?${a.toString()}`;
|
|
554
|
-
}
|
|
555
|
-
function Be(e) {
|
|
556
|
-
return He(e.routes.preview, new URLSearchParams({
|
|
557
|
-
chrome: "0",
|
|
558
|
-
pool: "1"
|
|
559
|
-
}));
|
|
560
|
-
}
|
|
561
|
-
function Ve(e, t) {
|
|
562
|
-
let n = new URL(e, "http://gtsx.local"), r = n.searchParams.getAll("gcase").flatMap((e) => {
|
|
563
|
-
let t = e.lastIndexOf(":");
|
|
564
|
-
return t > 0 ? [[e.slice(0, t), e.slice(t + 1)]] : [];
|
|
565
|
-
});
|
|
566
|
-
return {
|
|
567
|
-
caseName: n.searchParams.get("case"),
|
|
568
|
-
...r.length > 0 ? { caseOverrides: r } : {},
|
|
569
|
-
chrome: n.searchParams.get("chrome"),
|
|
570
|
-
entry: n.searchParams.get("entry"),
|
|
571
|
-
sessionId: n.searchParams.get("sessionId") ?? t,
|
|
572
|
-
staticMode: n.searchParams.get("static") === "1"
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
function He(e, t) {
|
|
576
|
-
let n = t.toString();
|
|
577
|
-
return n ? `${e}${e.includes("?") ? "&" : "?"}${n}` : e;
|
|
578
|
-
}
|
|
579
|
-
function z(e, t, n) {
|
|
580
|
-
return `${e.coordinate}:${t}${n && n !== "tablet" ? `@${n}` : ""}`;
|
|
581
|
-
}
|
|
582
|
-
function B(e, t, n) {
|
|
583
|
-
return `${n}\n${e.sourceHash ?? "no-source-hash"}\n${e.coordinate}\n${t}`;
|
|
584
|
-
}
|
|
585
|
-
function V(e, t) {
|
|
586
|
-
return e === "phone" ? {
|
|
587
|
-
width: 390,
|
|
588
|
-
height: 844
|
|
589
|
-
} : e === "tablet" ? {
|
|
590
|
-
width: 768,
|
|
591
|
-
height: 1024
|
|
592
|
-
} : e === "desktop" ? {
|
|
593
|
-
width: 1280,
|
|
594
|
-
height: 900
|
|
595
|
-
} : {
|
|
596
|
-
width: 768,
|
|
597
|
-
height: P(t?.height ?? 1024, 160, 1200)
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
function H(e, t, n) {
|
|
601
|
-
if (!(!t && !n)) return {
|
|
602
|
-
expectedSessionId: e,
|
|
603
|
-
ready: t?.ready ?? !1,
|
|
604
|
-
...t?.tree ?? n?.tree ? { tree: t?.tree ?? n?.tree } : {},
|
|
605
|
-
...t?.size ?? n?.size ? { size: t?.size ?? n?.size } : {},
|
|
606
|
-
...t?.error ? { error: t.error } : {},
|
|
607
|
-
...t?.valuesByBoundaryId ? { valuesByBoundaryId: t.valuesByBoundaryId } : {}
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
function Ue(e) {
|
|
611
|
-
let t = I(e);
|
|
612
|
-
return new Set(e.columns.flatMap((e) => e.components.flatMap((e) => e.cases.map((n) => z(e, n.name, t)))));
|
|
613
|
-
}
|
|
614
|
-
function We(e, t) {
|
|
615
|
-
let n = I(t);
|
|
616
|
-
return ze(t).flatMap((t) => t.cases.map((r) => Ge(e, t, r.name, n, z(t, r.name, n))));
|
|
617
|
-
}
|
|
618
|
-
function Ge(e, t, n, r, i) {
|
|
619
|
-
return {
|
|
620
|
-
cacheKey: B(t, n, r),
|
|
621
|
-
previewUrl: R(e, t, n, i, { static: !0 }),
|
|
622
|
-
sessionId: i,
|
|
623
|
-
size: V(r, void 0),
|
|
624
|
-
title: `${t.componentName} ${n} preview`
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
function Ke(t) {
|
|
628
|
-
let n = t.type;
|
|
629
|
-
return typeof t == "object" && !!t && typeof n == "string" && qe(n) && t.protocolVersion === e && typeof t.sessionId == "string";
|
|
630
|
-
}
|
|
631
|
-
function qe(e) {
|
|
632
|
-
return e === "gtsx:ready" || e === "gtsx:tree" || e === "gtsx:resize" || e === "gtsx:error" || e === "gtsx:request-values" || e === "gtsx:values" || e === "gtsx:render";
|
|
633
|
-
}
|
|
634
|
-
function U(e, t) {
|
|
635
|
-
if (!t || t === g) return {
|
|
636
|
-
id: g,
|
|
637
|
-
components: Je(e)
|
|
638
|
-
};
|
|
639
|
-
if (t?.startsWith("component:")) {
|
|
640
|
-
let n = t.slice(10), r = e.files.flatMap((e) => e.components).find((e) => e.coordinate === n);
|
|
641
|
-
if (r) return {
|
|
642
|
-
id: t,
|
|
643
|
-
components: [r]
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
if (t?.startsWith("file:")) {
|
|
647
|
-
let n = t.slice(5), r = e.files.find((e) => e.path === n);
|
|
648
|
-
if (r) return {
|
|
649
|
-
id: t,
|
|
650
|
-
components: r.components
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
return {
|
|
654
|
-
id: g,
|
|
655
|
-
components: Je(e)
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
function Je(e) {
|
|
659
|
-
let t = e.files.flatMap((e) => e.components), n = new Set(t.flatMap((e) => e.dependencies ?? [])), r = t.filter((e) => !n.has(e.coordinate));
|
|
660
|
-
return r.length > 0 ? r : t;
|
|
661
|
-
}
|
|
662
|
-
//#endregion
|
|
663
|
-
//#region src/preview-cache-indexeddb.ts
|
|
664
|
-
var Ye = "gtsx-studio-preview-cache-v1", W = "previewFrames", Xe = 1;
|
|
665
|
-
function Ze(e) {
|
|
666
|
-
let t = e.cache?.namespace?.trim();
|
|
667
|
-
return t ? `project:${t}` : `manifest:${ot(JSON.stringify({
|
|
668
|
-
files: e.files.map((e) => ({
|
|
669
|
-
path: e.path,
|
|
670
|
-
components: e.components.map((e) => ({
|
|
671
|
-
coordinate: e.coordinate,
|
|
672
|
-
exportName: e.exportName,
|
|
673
|
-
cases: e.cases.map((e) => e.name)
|
|
674
|
-
}))
|
|
675
|
-
})),
|
|
676
|
-
routes: e.routes,
|
|
677
|
-
version: e.version
|
|
678
|
-
}))}`;
|
|
679
|
-
}
|
|
680
|
-
async function Qe(e, t) {
|
|
681
|
-
if (!it() || t.length === 0) return {};
|
|
682
|
-
try {
|
|
683
|
-
let n = await tt(), r = n.transaction(W, "readonly"), i = r.objectStore(W), a = await Promise.all(t.map((t) => nt(i.get(at(e, t)))));
|
|
684
|
-
return await rt(r), n.close(), Object.fromEntries(a.flatMap((t) => t && t.namespace === e ? [[t.cacheKey, {
|
|
685
|
-
frameState: t.frameState,
|
|
686
|
-
lastUsedAt: t.updatedAt
|
|
687
|
-
}]] : []));
|
|
688
|
-
} catch {
|
|
689
|
-
return {};
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
async function $e(e, t) {
|
|
693
|
-
let n = Object.entries(t).flatMap(([t, n]) => {
|
|
694
|
-
let r = n ? et(n.frameState) : void 0;
|
|
695
|
-
return r ? [{
|
|
696
|
-
cacheKey: t,
|
|
697
|
-
frameState: r,
|
|
698
|
-
id: at(e, t),
|
|
699
|
-
namespace: e,
|
|
700
|
-
updatedAt: Date.now()
|
|
701
|
-
}] : [];
|
|
702
|
-
});
|
|
703
|
-
if (!(!it() || n.length === 0)) try {
|
|
704
|
-
let e = await tt(), t = e.transaction(W, "readwrite"), r = t.objectStore(W);
|
|
705
|
-
for (let e of n) r.put(e);
|
|
706
|
-
await rt(t), e.close();
|
|
707
|
-
} catch {}
|
|
708
|
-
}
|
|
709
|
-
function et(e) {
|
|
710
|
-
if (!(!e.tree && !e.size)) return {
|
|
711
|
-
expectedSessionId: e.expectedSessionId,
|
|
712
|
-
ready: e.ready,
|
|
713
|
-
...e.size ? { size: e.size } : {},
|
|
714
|
-
...e.tree ? { tree: e.tree } : {}
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
function tt() {
|
|
718
|
-
return new Promise((e, t) => {
|
|
719
|
-
let n = indexedDB.open(Ye, Xe);
|
|
720
|
-
n.onupgradeneeded = () => {
|
|
721
|
-
let e = n.result;
|
|
722
|
-
e.objectStoreNames.contains(W) || e.createObjectStore(W, { keyPath: "id" }).createIndex("namespace", "namespace", { unique: !1 });
|
|
723
|
-
}, n.onerror = () => t(n.error), n.onsuccess = () => e(n.result);
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
function nt(e) {
|
|
727
|
-
return new Promise((t, n) => {
|
|
728
|
-
e.onerror = () => n(e.error), e.onsuccess = () => t(e.result);
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
function rt(e) {
|
|
732
|
-
return new Promise((t, n) => {
|
|
733
|
-
e.onerror = () => n(e.error), e.onabort = () => n(e.error), e.oncomplete = () => t();
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
function it() {
|
|
737
|
-
return typeof indexedDB < "u";
|
|
738
|
-
}
|
|
739
|
-
function at(e, t) {
|
|
740
|
-
return `${e}\n${t}`;
|
|
741
|
-
}
|
|
742
|
-
function ot(e) {
|
|
743
|
-
let t = 2166136261;
|
|
744
|
-
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
745
|
-
return (t >>> 0).toString(36);
|
|
746
|
-
}
|
|
747
|
-
//#endregion
|
|
748
|
-
//#region src/preview-geometry-cache-store.ts
|
|
749
|
-
var st = [
|
|
750
|
-
"phone",
|
|
751
|
-
"tablet",
|
|
752
|
-
"desktop"
|
|
753
|
-
];
|
|
754
|
-
function ct(e) {
|
|
755
|
-
return ht(e.files.flatMap((e) => e.components.flatMap((e) => e.cases.flatMap((t) => st.map((n) => B(e, t.name, n))))));
|
|
756
|
-
}
|
|
757
|
-
function lt(e) {
|
|
758
|
-
let t = ht(e.cacheKeys), n = {}, r = {}, i = {}, a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (e) => {
|
|
759
|
-
if (e.size === 0) return;
|
|
760
|
-
let t = /* @__PURE__ */ new Set();
|
|
761
|
-
for (let n of e) {
|
|
762
|
-
o.set(n, (o.get(n) ?? 0) + 1);
|
|
763
|
-
for (let e of a.get(n) ?? []) t.add(e);
|
|
764
|
-
}
|
|
765
|
-
for (let e of t) e();
|
|
766
|
-
};
|
|
767
|
-
return {
|
|
768
|
-
cacheKeys: t,
|
|
769
|
-
getFrameState(e) {
|
|
770
|
-
return r[e];
|
|
771
|
-
},
|
|
772
|
-
getLayoutFrameState(e, t) {
|
|
773
|
-
let n = i[t]?.frameState;
|
|
774
|
-
return n ? H(e, void 0, n) : r[e];
|
|
775
|
-
},
|
|
776
|
-
getMergedFrameState(e, t) {
|
|
777
|
-
return H(e, r[e], n[t]?.frameState);
|
|
778
|
-
},
|
|
779
|
-
namespace: e.namespace,
|
|
780
|
-
getSnapshot() {
|
|
781
|
-
return n;
|
|
782
|
-
},
|
|
783
|
-
getVersionForKeys(e) {
|
|
784
|
-
return e.map((e) => `${e}:${o.get(e) ?? 0}`).join("|");
|
|
785
|
-
},
|
|
786
|
-
async hydrate() {
|
|
787
|
-
let r = {
|
|
788
|
-
...await Qe(e.namespace, t),
|
|
789
|
-
...n
|
|
790
|
-
}, a = gt(n, r);
|
|
791
|
-
return n = r, i = r, s(a), n;
|
|
792
|
-
},
|
|
793
|
-
markSessionRenderStarted(e) {
|
|
794
|
-
let t = r[e], n = {
|
|
795
|
-
expectedSessionId: e,
|
|
796
|
-
ready: !1
|
|
797
|
-
};
|
|
798
|
-
return t && vt(t, n) ? !1 : (r = {
|
|
799
|
-
...r,
|
|
800
|
-
[e]: n
|
|
801
|
-
}, s(new Set([e])), !0);
|
|
802
|
-
},
|
|
803
|
-
putMessages(e, t = /* @__PURE__ */ new Set()) {
|
|
804
|
-
let a = /* @__PURE__ */ new Set(), o = dt(r, e, t, a), c = ft(n, e, a), l = pt(i, e, a);
|
|
805
|
-
return o === r && c === n && l === i ? {
|
|
806
|
-
changed: !1,
|
|
807
|
-
entriesToWrite: {},
|
|
808
|
-
snapshot: n
|
|
809
|
-
} : (r = o, n = c, i = l, s(a), {
|
|
810
|
-
changed: !0,
|
|
811
|
-
entriesToWrite: mt(n, e),
|
|
812
|
-
snapshot: n
|
|
813
|
-
});
|
|
814
|
-
},
|
|
815
|
-
reset(e = {}) {
|
|
816
|
-
let t = new Set([
|
|
817
|
-
...Object.keys(r),
|
|
818
|
-
...gt(n, e),
|
|
819
|
-
...gt(i, e)
|
|
820
|
-
]);
|
|
821
|
-
r = {}, n = e, i = e, s(t);
|
|
822
|
-
},
|
|
823
|
-
subscribe(e, t) {
|
|
824
|
-
for (let n of e) {
|
|
825
|
-
let e = a.get(n);
|
|
826
|
-
e || (e = /* @__PURE__ */ new Set(), a.set(n, e)), e.add(t);
|
|
827
|
-
}
|
|
828
|
-
return () => {
|
|
829
|
-
for (let n of e) {
|
|
830
|
-
let e = a.get(n);
|
|
831
|
-
e && (e.delete(t), e.size === 0 && a.delete(n));
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
},
|
|
835
|
-
writeEntries(t) {
|
|
836
|
-
return $e(e.namespace, t);
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
function ut(e) {
|
|
841
|
-
return e.component.cases.flatMap((t) => [z(e.component, t.name, e.viewportPreset), B(e.component, t.name, e.viewportPreset)]);
|
|
842
|
-
}
|
|
843
|
-
function dt(e, t, n, r) {
|
|
844
|
-
let i = e;
|
|
845
|
-
for (let { message: a } of t) {
|
|
846
|
-
if (!n.has(a.sessionId)) continue;
|
|
847
|
-
let t = i[a.sessionId] ?? {
|
|
848
|
-
expectedSessionId: a.sessionId,
|
|
849
|
-
ready: !1
|
|
850
|
-
}, o = _(t, a);
|
|
851
|
-
o !== t && (i === e && (i = { ...e }), i[a.sessionId] = o, r.add(a.sessionId));
|
|
852
|
-
}
|
|
853
|
-
return i;
|
|
854
|
-
}
|
|
855
|
-
function ft(e, t, n) {
|
|
856
|
-
let r = Date.now(), i = e;
|
|
857
|
-
for (let { message: a, target: o } of t) {
|
|
858
|
-
let t = i[o.cacheKey]?.frameState ?? {
|
|
859
|
-
expectedSessionId: a.sessionId,
|
|
860
|
-
ready: !1
|
|
861
|
-
}, s = _(t, a);
|
|
862
|
-
s !== t && (i === e && (i = { ...e }), i[o.cacheKey] = {
|
|
863
|
-
frameState: s,
|
|
864
|
-
lastUsedAt: r
|
|
865
|
-
}, n.add(o.cacheKey));
|
|
866
|
-
}
|
|
867
|
-
return i;
|
|
868
|
-
}
|
|
869
|
-
function pt(e, t, n) {
|
|
870
|
-
let r = Date.now(), i = e;
|
|
871
|
-
for (let { message: a, target: o } of t) {
|
|
872
|
-
let t = i[o.cacheKey];
|
|
873
|
-
if (!_t(t)) continue;
|
|
874
|
-
let s = t?.frameState ?? {
|
|
875
|
-
expectedSessionId: a.sessionId,
|
|
876
|
-
ready: !1
|
|
877
|
-
}, c = _(s, a);
|
|
878
|
-
c !== s && (i === e && (i = { ...e }), i[o.cacheKey] = {
|
|
879
|
-
frameState: c,
|
|
880
|
-
lastUsedAt: r
|
|
881
|
-
}, n.add(o.cacheKey));
|
|
882
|
-
}
|
|
883
|
-
return i;
|
|
884
|
-
}
|
|
885
|
-
function mt(e, t) {
|
|
886
|
-
let n = {};
|
|
887
|
-
for (let { target: r } of t) n[r.cacheKey] = e[r.cacheKey];
|
|
888
|
-
return n;
|
|
889
|
-
}
|
|
890
|
-
function ht(e) {
|
|
891
|
-
return [...new Set(e)];
|
|
892
|
-
}
|
|
893
|
-
function gt(e, t) {
|
|
894
|
-
let n = new Set([...Object.keys(e), ...Object.keys(t)]), r = /* @__PURE__ */ new Set();
|
|
895
|
-
for (let i of n) e[i] !== t[i] && r.add(i);
|
|
896
|
-
return r;
|
|
897
|
-
}
|
|
898
|
-
function _t(e) {
|
|
899
|
-
return !e?.frameState.tree && !e?.frameState.error;
|
|
900
|
-
}
|
|
901
|
-
function vt(e, t) {
|
|
902
|
-
return e.expectedSessionId === t.expectedSessionId && e.ready === t.ready && e.tree === t.tree && e.size === t.size && e.error === t.error && e.valuesByBoundaryId === t.valuesByBoundaryId;
|
|
903
|
-
}
|
|
904
|
-
//#endregion
|
|
905
|
-
//#region src/preview-lazy-loading.ts
|
|
906
|
-
var yt = 3200;
|
|
907
|
-
function bt(e, t) {
|
|
908
|
-
return {
|
|
909
|
-
bottom: e.y + t.bottom * e.scale,
|
|
910
|
-
left: e.x + t.left * e.scale,
|
|
911
|
-
right: e.x + t.right * e.scale,
|
|
912
|
-
top: e.y + t.top * e.scale
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
function xt(e, t, n) {
|
|
916
|
-
return e.bottom >= t.top - n && e.right >= t.left - n && e.top <= t.bottom + n && e.left <= t.right + n;
|
|
917
|
-
}
|
|
918
|
-
//#endregion
|
|
919
|
-
//#region src/preview-render-queue.ts
|
|
920
|
-
var St = 24, Ct = 4, wt = 4, Tt = 8192, Et = 5e3, Dt = 100, Ot = 120, kt = 1e3;
|
|
921
|
-
function At(e) {
|
|
922
|
-
let t = /* @__PURE__ */ new Set(), n = 0, r = 0, i = 0, a = Gt(e.maximumRenderTaskCount, Tt), o = Math.min(Gt(e.maximumConcurrentRenderTasks, 24), a), s = Gt(e.maximumMountedPreviewSessions, 32), c = Math.min(Kt(e.minimumVisibleRenderTasks, 0), o);
|
|
923
|
-
for (let l of Ft(e)) if (!t.has(l.sessionId)) {
|
|
924
|
-
if (l.currentlyMounted && !l.active) {
|
|
925
|
-
if (t.size >= s) continue;
|
|
926
|
-
t.add(l.sessionId);
|
|
927
|
-
continue;
|
|
928
|
-
}
|
|
929
|
-
if (!(l.needsRenderTask && (r += 1, r > a))) {
|
|
930
|
-
if (jt(l)) {
|
|
931
|
-
if (!Mt(l, {
|
|
932
|
-
concurrentRenderTasks: n,
|
|
933
|
-
maximumConcurrentRenderTasks: o,
|
|
934
|
-
minimumVisibleRenderTasks: c,
|
|
935
|
-
visibleRenderTasks: i
|
|
936
|
-
})) continue;
|
|
937
|
-
n += 1, l.visible && (i += 1);
|
|
938
|
-
}
|
|
939
|
-
!l.visible && t.size >= s || t.add(l.sessionId);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
return t;
|
|
943
|
-
}
|
|
944
|
-
function jt(e) {
|
|
945
|
-
return e.active || e.needsRenderTask;
|
|
946
|
-
}
|
|
947
|
-
function Mt(e, t) {
|
|
948
|
-
return !jt(e) || e.visible && e.active || e.visible && t.visibleRenderTasks < t.minimumVisibleRenderTasks ? !0 : t.concurrentRenderTasks < t.maximumConcurrentRenderTasks;
|
|
949
|
-
}
|
|
950
|
-
function Nt(e, t = At(e)) {
|
|
951
|
-
let n = /* @__PURE__ */ new Set();
|
|
952
|
-
for (let r of Ft(e)) r.visible && t.has(r.sessionId) && n.add(r.sessionId);
|
|
953
|
-
return n;
|
|
954
|
-
}
|
|
955
|
-
function Pt(e) {
|
|
956
|
-
return {
|
|
957
|
-
activeRenderTimeoutMilliseconds: G(e, [
|
|
958
|
-
"previewQueueActiveRenderTimeoutMilliseconds",
|
|
959
|
-
"previewQueueActiveRenderTimeout",
|
|
960
|
-
"queueActiveRenderTimeout",
|
|
961
|
-
"previewQueueActiveTimeout",
|
|
962
|
-
"queueActiveTimeout"
|
|
963
|
-
]),
|
|
964
|
-
bufferRenderDelayMilliseconds: K(e, [
|
|
965
|
-
"previewQueueBufferRenderDelayMilliseconds",
|
|
966
|
-
"previewQueueBufferRenderDelay",
|
|
967
|
-
"queueBufferRenderDelay",
|
|
968
|
-
"previewQueueBufferDelay",
|
|
969
|
-
"previewRenderBufferDelay",
|
|
970
|
-
"previewBufferDelay",
|
|
971
|
-
"queueBufferDelay",
|
|
972
|
-
"bufferDelay"
|
|
973
|
-
]),
|
|
974
|
-
renderDebounceMilliseconds: K(e, [
|
|
975
|
-
"previewQueueRenderDebounceMilliseconds",
|
|
976
|
-
"previewQueueRenderDebounce",
|
|
977
|
-
"queueRenderDebounce",
|
|
978
|
-
"previewQueueDebounce",
|
|
979
|
-
"previewRenderDebounce",
|
|
980
|
-
"previewDebounce",
|
|
981
|
-
"queueDebounce",
|
|
982
|
-
"debounce"
|
|
983
|
-
]),
|
|
984
|
-
maximumConcurrentRenderTasks: G(e, [
|
|
985
|
-
"previewQueueMaximumConcurrentRenderTasks",
|
|
986
|
-
"queueMaximumConcurrentRenderTasks",
|
|
987
|
-
"maximumConcurrentRenderTasks",
|
|
988
|
-
"previewQueueActive",
|
|
989
|
-
"queueActive"
|
|
990
|
-
]),
|
|
991
|
-
maximumConcurrentRenderTasksDuringCanvasMovement: G(e, [
|
|
992
|
-
"previewQueueMaximumConcurrentRenderTasksDuringCanvasMovement",
|
|
993
|
-
"queueMaximumConcurrentRenderTasksDuringCanvasMovement",
|
|
994
|
-
"maximumConcurrentRenderTasksDuringCanvasMovement"
|
|
995
|
-
]),
|
|
996
|
-
minimumVisibleRenderTasksDuringCanvasMovement: K(e, [
|
|
997
|
-
"previewQueueMinimumVisibleRenderTasksDuringCanvasMovement",
|
|
998
|
-
"queueMinimumVisibleRenderTasksDuringCanvasMovement",
|
|
999
|
-
"minimumVisibleRenderTasksDuringCanvasMovement",
|
|
1000
|
-
"previewQueueVisibleRenderFloor",
|
|
1001
|
-
"queueVisibleRenderFloor"
|
|
1002
|
-
]),
|
|
1003
|
-
renderBufferMargin: K(e, [
|
|
1004
|
-
"previewQueueRenderBufferMargin",
|
|
1005
|
-
"queueRenderBufferMargin",
|
|
1006
|
-
"previewRenderBufferMargin",
|
|
1007
|
-
"previewQueueBuffer",
|
|
1008
|
-
"queueBuffer",
|
|
1009
|
-
"previewBuffer"
|
|
1010
|
-
]),
|
|
1011
|
-
maximumRenderTaskCount: G(e, [
|
|
1012
|
-
"previewQueueMaximumRenderTaskCount",
|
|
1013
|
-
"queueMaximumRenderTaskCount",
|
|
1014
|
-
"maximumRenderTaskCount",
|
|
1015
|
-
"previewQueueSafety",
|
|
1016
|
-
"queueSafety",
|
|
1017
|
-
"previewQueueLength",
|
|
1018
|
-
"queueLength"
|
|
1019
|
-
]),
|
|
1020
|
-
maximumMountedPreviewSessions: G(e, [
|
|
1021
|
-
"previewQueueMaximumMountedPreviewSessions",
|
|
1022
|
-
"queueMaximumMountedPreviewSessions",
|
|
1023
|
-
"maximumMountedPreviewSessions",
|
|
1024
|
-
"previewQueueMounted",
|
|
1025
|
-
"queueMounted"
|
|
1026
|
-
]),
|
|
1027
|
-
renderThrottleMilliseconds: K(e, [
|
|
1028
|
-
"previewQueueRenderThrottleMilliseconds",
|
|
1029
|
-
"previewQueueRenderThrottle",
|
|
1030
|
-
"queueRenderThrottle",
|
|
1031
|
-
"previewQueueThrottle",
|
|
1032
|
-
"previewRenderThrottle",
|
|
1033
|
-
"previewThrottle",
|
|
1034
|
-
"queueThrottle",
|
|
1035
|
-
"throttle"
|
|
1036
|
-
])
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
function Ft(e) {
|
|
1040
|
-
let t = e.currentSessionIds ?? /* @__PURE__ */ new Set(), n = e.completedSessionIds ?? /* @__PURE__ */ new Set(), r = e.activeSessionIds ?? /* @__PURE__ */ new Set(), i = Kt(e.renderBufferMargin, yt), a = e.includeBufferedRenderTasks !== !1, o = Bt(e.canvasMovement), s = [], c = [];
|
|
1041
|
-
return e.items.forEach((l, u) => {
|
|
1042
|
-
let d = l.sessionIds.some((e) => t.has(e)), f = bt(e.canvas, l.rect), p = d || a ? i : 0;
|
|
1043
|
-
if (!xt(f, e.viewport, p)) return;
|
|
1044
|
-
let m = Wt(f, e.viewport), h = m > 0 ? Ut(f, e.viewport) : zt(f, e.viewport), g = l.sessionIds.map((i, a) => {
|
|
1045
|
-
let s = t.has(i), c = n.has(i);
|
|
1046
|
-
return {
|
|
1047
|
-
active: r.has(i),
|
|
1048
|
-
cardIndex: u,
|
|
1049
|
-
completed: c,
|
|
1050
|
-
currentlyMounted: s,
|
|
1051
|
-
...Vt(f, e.viewport, o),
|
|
1052
|
-
distance: h,
|
|
1053
|
-
intersectionArea: m,
|
|
1054
|
-
needsRenderTask: !s,
|
|
1055
|
-
sessionId: i,
|
|
1056
|
-
sessionIndex: a,
|
|
1057
|
-
visible: m > 0
|
|
1058
|
-
};
|
|
1059
|
-
});
|
|
1060
|
-
g.length !== 0 && (m > 0 ? s.push(g) : c.push(g));
|
|
1061
|
-
}), [...Rt(s, It), ...Rt(c, Lt)];
|
|
1062
|
-
}
|
|
1063
|
-
function It(e, t) {
|
|
1064
|
-
return e.distance - t.distance || t.intersectionArea - e.intersectionArea || Number(t.currentlyMounted) - Number(e.currentlyMounted) || Number(t.completed) - Number(e.completed) || e.cardIndex - t.cardIndex || e.sessionIndex - t.sessionIndex;
|
|
1065
|
-
}
|
|
1066
|
-
function Lt(e, t) {
|
|
1067
|
-
return e.directionRank - t.directionRank || e.distance - t.distance || e.directionOffset - t.directionOffset || Number(t.currentlyMounted) - Number(e.currentlyMounted) || Number(t.completed) - Number(e.completed) || e.cardIndex - t.cardIndex || e.sessionIndex - t.sessionIndex;
|
|
1068
|
-
}
|
|
1069
|
-
function Rt(e, t) {
|
|
1070
|
-
let n = e.sort((e, n) => t(e[0], n[0])), r = [], i = Math.max(0, ...n.map((e) => e.length));
|
|
1071
|
-
for (let e = 0; e < i; e += 1) for (let t of n) {
|
|
1072
|
-
let n = t[e];
|
|
1073
|
-
n && r.push(n);
|
|
1074
|
-
}
|
|
1075
|
-
return r;
|
|
1076
|
-
}
|
|
1077
|
-
function zt(e, t) {
|
|
1078
|
-
let n = e.right < t.left ? t.left - e.right : e.left > t.right ? e.left - t.right : 0, r = e.bottom < t.top ? t.top - e.bottom : e.top > t.bottom ? e.top - t.bottom : 0;
|
|
1079
|
-
return Math.hypot(n, r);
|
|
1080
|
-
}
|
|
1081
|
-
function Bt(e) {
|
|
1082
|
-
if (!e) return;
|
|
1083
|
-
let t = Math.hypot(e.x, e.y);
|
|
1084
|
-
if (!(t < .001)) return {
|
|
1085
|
-
x: -e.x / t,
|
|
1086
|
-
y: -e.y / t
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
function Vt(e, t, n) {
|
|
1090
|
-
if (!n) return {
|
|
1091
|
-
directionOffset: 0,
|
|
1092
|
-
directionRank: 0
|
|
1093
|
-
};
|
|
1094
|
-
let r = Ht(e, t), i = r.x * n.x + r.y * n.y;
|
|
1095
|
-
return {
|
|
1096
|
-
directionOffset: Math.abs(r.x * n.y - r.y * n.x),
|
|
1097
|
-
directionRank: i > 0 ? 0 : 1
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
function Ht(e, t) {
|
|
1101
|
-
let n = (e.left + e.right) / 2, r = (e.top + e.bottom) / 2, i = (t.left + t.right) / 2, a = (t.top + t.bottom) / 2;
|
|
1102
|
-
return {
|
|
1103
|
-
x: n - i,
|
|
1104
|
-
y: r - a
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
function Ut(e, t) {
|
|
1108
|
-
let n = Ht(e, t);
|
|
1109
|
-
return Math.hypot(n.x, n.y);
|
|
1110
|
-
}
|
|
1111
|
-
function Wt(e, t) {
|
|
1112
|
-
return Math.max(0, Math.min(e.right, t.right) - Math.max(e.left, t.left)) * Math.max(0, Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top));
|
|
1113
|
-
}
|
|
1114
|
-
function Gt(e, t) {
|
|
1115
|
-
return typeof e == "number" && Number.isFinite(e) && e > 0 ? Math.floor(e) : t;
|
|
1116
|
-
}
|
|
1117
|
-
function Kt(e, t) {
|
|
1118
|
-
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : t;
|
|
1119
|
-
}
|
|
1120
|
-
function G(e, t) {
|
|
1121
|
-
for (let n of t) {
|
|
1122
|
-
let t = e.get(n);
|
|
1123
|
-
if (!t) continue;
|
|
1124
|
-
let r = Number(t);
|
|
1125
|
-
if (Number.isFinite(r) && r > 0) return Math.floor(r);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
function K(e, t) {
|
|
1129
|
-
for (let n of t) {
|
|
1130
|
-
let t = e.get(n);
|
|
1131
|
-
if (!t) continue;
|
|
1132
|
-
let r = Number(t);
|
|
1133
|
-
if (Number.isFinite(r) && r >= 0) return Math.floor(r);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region src/studio-canvas-transform-event.ts
|
|
1138
|
-
var qt = "gtsx:studio-canvas-transform-changed";
|
|
1139
|
-
function Jt(e) {
|
|
1140
|
-
typeof window > "u" || window.dispatchEvent(new CustomEvent(qt, { detail: e }));
|
|
1141
|
-
}
|
|
1142
|
-
//#endregion
|
|
1143
|
-
//#region src/preview-iframe-pool.tsx
|
|
1144
|
-
var Yt = a.createContext(null), Xt = 48, Zt = 48, Qt = 0, $t = 250, en = 12, tn = typeof window > "u" ? a.useEffect : a.useLayoutEffect;
|
|
1145
|
-
function nn(e) {
|
|
1146
|
-
let t = a.useRef(null), n = a.useRef([]), r = a.useRef(0), i = a.useRef(0), o = a.useRef(0), l = a.useRef(0), u = a.useRef(0), d = a.useRef(0), f = a.useRef(0), p = a.useRef(0), m = a.useRef(0), h = a.useRef(0), g = a.useRef(0), _ = a.useRef(0), v = a.useRef(0), y = a.useRef(0), [b, x] = a.useState({
|
|
1147
|
-
active: 0,
|
|
1148
|
-
borrows: 0,
|
|
1149
|
-
created: 0,
|
|
1150
|
-
directRenderPosts: 0,
|
|
1151
|
-
idle: 0,
|
|
1152
|
-
newBorrows: 0,
|
|
1153
|
-
acceptedRenderPosts: 0,
|
|
1154
|
-
postMessageRenderPosts: 0,
|
|
1155
|
-
readyIdle: 0,
|
|
1156
|
-
renderEndpointWaits: 0,
|
|
1157
|
-
redeliveredRenderPosts: 0,
|
|
1158
|
-
renderPosts: 0,
|
|
1159
|
-
reusedBorrows: 0,
|
|
1160
|
-
total: 0
|
|
1161
|
-
}), S = e.maximumIdleFrames ?? Xt, C = e.minimumIdleReserveFrames ?? Qt, w = e.maximumRetainedFrames ?? Zt, T = a.useCallback(() => {
|
|
1162
|
-
e.debug && (d.current ||= window.requestAnimationFrame(() => {
|
|
1163
|
-
d.current = 0, x(jn(n.current, {
|
|
1164
|
-
acceptedRenderPosts: p.current,
|
|
1165
|
-
borrows: r.current,
|
|
1166
|
-
created: i.current,
|
|
1167
|
-
directRenderPosts: m.current,
|
|
1168
|
-
newBorrows: o.current,
|
|
1169
|
-
postMessageRenderPosts: h.current,
|
|
1170
|
-
redeliveredRenderPosts: g.current,
|
|
1171
|
-
renderEndpointWaits: _.current,
|
|
1172
|
-
renderPosts: v.current,
|
|
1173
|
-
reusedBorrows: y.current
|
|
1174
|
-
}));
|
|
1175
|
-
}));
|
|
1176
|
-
}, [e.debug]), E = a.useCallback((e, t = {}) => {
|
|
1177
|
-
if (!e.pendingInput) return;
|
|
1178
|
-
let n = bn(e.pendingInput);
|
|
1179
|
-
if (!xn(e, n, t)) return;
|
|
1180
|
-
let r = Ve(e.pendingInput.slot.previewUrl, e.pendingInput.slot.sessionId), i = yn(e.frame);
|
|
1181
|
-
if (!i) {
|
|
1182
|
-
_.current += 1, wn(e, n, E), T();
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
i.render(r), e.pendingRenderDeliveryAttemptCount = Sn(e, n), e.lastPostedRenderKey = n, e.lastRenderedSessionId = r.sessionId ?? e.pendingInput.slot.sessionId, e.frame.dataset.gtsxPreviewPoolLastRenderSessionId = r.sessionId ?? "", e.frame.dataset.gtsxPreviewPoolRenderDeliveryAttemptCount = String(e.pendingRenderDeliveryAttemptCount), i.transport === "direct" ? m.current += 1 : h.current += 1, v.current += 1, t.redelivery && (g.current += 1), Cn(e, n, E), T();
|
|
1186
|
-
}, [T]), D = a.useCallback((e) => {
|
|
1187
|
-
e.ready && E(e);
|
|
1188
|
-
}, [E]), O = a.useCallback(() => {
|
|
1189
|
-
let t = document.createElement("iframe"), r = {
|
|
1190
|
-
frame: t,
|
|
1191
|
-
id: l.current++,
|
|
1192
|
-
poolUrl: e.poolUrl,
|
|
1193
|
-
ready: !1
|
|
1194
|
-
};
|
|
1195
|
-
return i.current += 1, t.setAttribute("aria-hidden", "true"), t.dataset.gtsxPooledPreviewFrame = "true", t.dataset.gtsxPreviewPoolReady = "false", t.loading = "eager", t.tabIndex = -1, Object.assign(t.style, {
|
|
1196
|
-
background: "transparent",
|
|
1197
|
-
border: "0",
|
|
1198
|
-
height: "0",
|
|
1199
|
-
left: "0",
|
|
1200
|
-
pointerEvents: "none",
|
|
1201
|
-
position: "fixed",
|
|
1202
|
-
top: "0",
|
|
1203
|
-
transformOrigin: "0 0",
|
|
1204
|
-
visibility: "hidden",
|
|
1205
|
-
width: "0",
|
|
1206
|
-
zIndex: "1"
|
|
1207
|
-
}), t.src = e.poolUrl, n.current.push(r), T(), r;
|
|
1208
|
-
}, [e.poolUrl, T]), ee = a.useCallback(() => {
|
|
1209
|
-
let e = t.current;
|
|
1210
|
-
if (!e) return;
|
|
1211
|
-
let n = O();
|
|
1212
|
-
e.appendChild(n.frame);
|
|
1213
|
-
}, [O]), k = a.useCallback(() => {
|
|
1214
|
-
C <= 0 || t.current && (n.current.length >= w || Nn(n.current) >= C || ee());
|
|
1215
|
-
}, [
|
|
1216
|
-
ee,
|
|
1217
|
-
w,
|
|
1218
|
-
C
|
|
1219
|
-
]), A = a.useCallback(() => {
|
|
1220
|
-
typeof window > "u" || (f.current ||= window.requestAnimationFrame(() => {
|
|
1221
|
-
f.current = 0, k();
|
|
1222
|
-
}));
|
|
1223
|
-
}, [k]), j = a.useCallback((t) => {
|
|
1224
|
-
let r = sn(n.current, {
|
|
1225
|
-
maximumRetainedFrames: w,
|
|
1226
|
-
poolUrl: e.poolUrl,
|
|
1227
|
-
sessionId: t.slot.sessionId
|
|
1228
|
-
});
|
|
1229
|
-
return r ? {
|
|
1230
|
-
entry: r,
|
|
1231
|
-
origin: "pool"
|
|
1232
|
-
} : {
|
|
1233
|
-
entry: O(),
|
|
1234
|
-
origin: "new"
|
|
1235
|
-
};
|
|
1236
|
-
}, [
|
|
1237
|
-
O,
|
|
1238
|
-
w,
|
|
1239
|
-
e.poolUrl
|
|
1240
|
-
]), te = a.useCallback(() => {
|
|
1241
|
-
let e = n.current.filter((e) => !e.owner), t = Math.max(0, e.length - S, n.current.length - w);
|
|
1242
|
-
if (t <= 0) return;
|
|
1243
|
-
let r = new Set(e.slice(0, t).map((e) => e.id));
|
|
1244
|
-
n.current = n.current.filter((e) => r.has(e.id) ? (Y(e), e.frame.remove(), !1) : !0);
|
|
1245
|
-
}, [S, w]), ne = a.useCallback(() => {
|
|
1246
|
-
for (let e of n.current) e.owner && ln(e);
|
|
1247
|
-
}, []), M = a.useCallback(() => {
|
|
1248
|
-
u.current ||= window.requestAnimationFrame(() => {
|
|
1249
|
-
u.current = 0, ne();
|
|
1250
|
-
});
|
|
1251
|
-
}, [ne]), re = a.useCallback((e, n) => {
|
|
1252
|
-
let { entry: i, origin: a } = j(n), s = Symbol(n.slot.sessionId), c = t.current;
|
|
1253
|
-
return r.current += 1, a === "new" ? o.current += 1 : y.current += 1, i.owner = s, i.container = e, c && i.frame.parentElement !== c && c.appendChild(i.frame), mn(i, n, D), T(), A(), M(), {
|
|
1254
|
-
origin: a,
|
|
1255
|
-
update(t) {
|
|
1256
|
-
i.owner === s && (i.container = e, mn(i, t, D), M());
|
|
1257
|
-
},
|
|
1258
|
-
release() {
|
|
1259
|
-
i.owner === s && (i.pendingInput?.onPreviewFrameMount?.(i.pendingInput.slot.sessionId, null), gn(i), i.owner = void 0, i.container = void 0, i.currentSessionId = void 0, i.pendingInput = void 0, Y(i), un(i), te(), T(), A());
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
}, [
|
|
1263
|
-
j,
|
|
1264
|
-
D,
|
|
1265
|
-
te,
|
|
1266
|
-
T,
|
|
1267
|
-
M,
|
|
1268
|
-
A
|
|
1269
|
-
]);
|
|
1270
|
-
a.useEffect(() => {
|
|
1271
|
-
e.debug && x(jn(n.current, {
|
|
1272
|
-
acceptedRenderPosts: p.current,
|
|
1273
|
-
borrows: r.current,
|
|
1274
|
-
created: i.current,
|
|
1275
|
-
directRenderPosts: m.current,
|
|
1276
|
-
newBorrows: o.current,
|
|
1277
|
-
postMessageRenderPosts: h.current,
|
|
1278
|
-
redeliveredRenderPosts: g.current,
|
|
1279
|
-
renderEndpointWaits: _.current,
|
|
1280
|
-
renderPosts: v.current,
|
|
1281
|
-
reusedBorrows: y.current
|
|
1282
|
-
}));
|
|
1283
|
-
}, [e.debug]), a.useEffect(() => {
|
|
1284
|
-
let e = () => M();
|
|
1285
|
-
return window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), window.addEventListener(qt, e), () => {
|
|
1286
|
-
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0), window.removeEventListener(qt, e);
|
|
1287
|
-
};
|
|
1288
|
-
}, [M]), a.useEffect(() => {
|
|
1289
|
-
let e = (e) => {
|
|
1290
|
-
if (On(e.data)) {
|
|
1291
|
-
let t = n.current.find((t) => t.frame.contentWindow === e.source);
|
|
1292
|
-
if (!t) return;
|
|
1293
|
-
t.ready = !0, t.frame.dataset.gtsxPreviewPoolReady = "true", T(), A(), Y(t), E(t);
|
|
1294
|
-
return;
|
|
1295
|
-
}
|
|
1296
|
-
if (kn(e.data)) {
|
|
1297
|
-
let t = n.current.find((t) => t.frame.contentWindow === e.source);
|
|
1298
|
-
if (!t || t.pendingInput?.slot.sessionId !== e.data.sessionId) return;
|
|
1299
|
-
t.lastAcceptedRenderSessionId = e.data.sessionId, t.frame.dataset.gtsxPreviewPoolLastAcceptedRenderSessionId = e.data.sessionId, En(t), p.current += 1, T();
|
|
1300
|
-
return;
|
|
1301
|
-
}
|
|
1302
|
-
if (An(e.data)) {
|
|
1303
|
-
let t = n.current.find((t) => t.frame.contentWindow === e.source);
|
|
1304
|
-
if (!t || t.pendingInput?.slot.sessionId !== e.data.sessionId) return;
|
|
1305
|
-
t.lastCompletedSessionId = e.data.sessionId, t.lastCompletedPreviewUrl = t.pendingInput.slot.previewUrl, t.lastCompletedSize = t.pendingInput.size, Y(t), t.frame.style.opacity = "1";
|
|
1306
|
-
}
|
|
1307
|
-
};
|
|
1308
|
-
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
1309
|
-
}, [
|
|
1310
|
-
E,
|
|
1311
|
-
T,
|
|
1312
|
-
A
|
|
1313
|
-
]), a.useEffect(() => {
|
|
1314
|
-
A();
|
|
1315
|
-
}, [A]), a.useEffect(() => () => {
|
|
1316
|
-
for (let e of n.current) Y(e), e.frame.remove();
|
|
1317
|
-
d.current && window.cancelAnimationFrame(d.current), u.current && window.cancelAnimationFrame(u.current), f.current && window.cancelAnimationFrame(f.current), n.current = [];
|
|
1318
|
-
}, []);
|
|
1319
|
-
let ie = a.useMemo(() => ({ borrow: re }), [re]);
|
|
1320
|
-
return /* @__PURE__ */ c(Yt.Provider, {
|
|
1321
|
-
value: ie,
|
|
1322
|
-
children: [
|
|
1323
|
-
e.children,
|
|
1324
|
-
/* @__PURE__ */ s("div", {
|
|
1325
|
-
"aria-hidden": "true",
|
|
1326
|
-
"data-gtsx-preview-iframe-pool": "true",
|
|
1327
|
-
ref: t,
|
|
1328
|
-
style: {
|
|
1329
|
-
inset: 0,
|
|
1330
|
-
overflow: "visible",
|
|
1331
|
-
pointerEvents: "none",
|
|
1332
|
-
position: "fixed",
|
|
1333
|
-
zIndex: 2
|
|
1334
|
-
}
|
|
1335
|
-
}),
|
|
1336
|
-
e.debug ? /* @__PURE__ */ s(Pn, { stats: b }) : null
|
|
1337
|
-
]
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
function rn(e) {
|
|
1341
|
-
let t = on(), n = a.useRef(null), r = a.useRef(null), i = a.useRef(null), o = a.useRef(e.onPreviewFrameMount), c = a.useRef(e.onBorrowOriginChange);
|
|
1342
|
-
o.current = e.onPreviewFrameMount, c.current = e.onBorrowOriginChange;
|
|
1343
|
-
let l = a.useMemo(() => ({
|
|
1344
|
-
size: e.size,
|
|
1345
|
-
slot: e.slot,
|
|
1346
|
-
onPreviewFrameMount(e, t, n) {
|
|
1347
|
-
o.current?.(e, t, n);
|
|
1348
|
-
}
|
|
1349
|
-
}), [
|
|
1350
|
-
e.size.height,
|
|
1351
|
-
e.size.width,
|
|
1352
|
-
e.slot.previewUrl,
|
|
1353
|
-
e.slot.sessionId,
|
|
1354
|
-
e.slot.title
|
|
1355
|
-
]);
|
|
1356
|
-
return r.current = l, tn(() => {
|
|
1357
|
-
if (!t || !n.current) return;
|
|
1358
|
-
let e = r.current;
|
|
1359
|
-
if (!e) return;
|
|
1360
|
-
let a = t.borrow(n.current, e);
|
|
1361
|
-
return i.current = a, c.current?.(a.origin), () => an(i, c);
|
|
1362
|
-
}, [t]), tn(() => {
|
|
1363
|
-
i.current?.update(l), i.current && c.current?.(i.current.origin);
|
|
1364
|
-
}, [l]), t ? /* @__PURE__ */ s("div", {
|
|
1365
|
-
"data-gtsx-pooled-preview-slot": e.slot.sessionId,
|
|
1366
|
-
ref: n,
|
|
1367
|
-
style: {
|
|
1368
|
-
height: e.size.height,
|
|
1369
|
-
left: 0,
|
|
1370
|
-
pointerEvents: "none",
|
|
1371
|
-
position: "absolute",
|
|
1372
|
-
top: 0,
|
|
1373
|
-
width: e.size.width,
|
|
1374
|
-
zIndex: 1
|
|
1375
|
-
}
|
|
1376
|
-
}) : null;
|
|
1377
|
-
}
|
|
1378
|
-
function an(e, t) {
|
|
1379
|
-
t.current?.(null), e.current?.release(), e.current = null;
|
|
1380
|
-
}
|
|
1381
|
-
function on() {
|
|
1382
|
-
return a.useContext(Yt);
|
|
1383
|
-
}
|
|
1384
|
-
function sn(e, t) {
|
|
1385
|
-
let n = e.filter((e) => !e.owner && e.poolUrl === t.poolUrl), r = n.find((e) => e.ready && e.lastRenderedSessionId === t.sessionId);
|
|
1386
|
-
if (r) return r;
|
|
1387
|
-
let i = n.find((e) => e.ready && !e.lastRenderedSessionId);
|
|
1388
|
-
if (i) return i;
|
|
1389
|
-
let a = n.find((e) => e.ready);
|
|
1390
|
-
if (a) return a;
|
|
1391
|
-
}
|
|
1392
|
-
function q(e) {
|
|
1393
|
-
return typeof e == "number" ? `${e}px` : e;
|
|
1394
|
-
}
|
|
1395
|
-
function cn(e) {
|
|
1396
|
-
if (e.anchorRect.width <= 0 || e.anchorRect.height <= 0) return dn(e.layoutSize);
|
|
1397
|
-
let t = fn(e.layoutSize.width, e.anchorRect.width), n = fn(e.layoutSize.height, e.anchorRect.height), r = t > 0 ? e.anchorRect.width / t : 1, i = n > 0 ? e.anchorRect.height / n : 1, a = Math.max(0, e.clipRect.top - e.anchorRect.top) / i, o = Math.max(0, e.anchorRect.right - e.clipRect.right) / r, s = Math.max(0, e.anchorRect.bottom - e.clipRect.bottom) / i, c = Math.max(0, e.clipRect.left - e.anchorRect.left) / r;
|
|
1398
|
-
return {
|
|
1399
|
-
clipPath: `inset(${J(a)}px ${J(o)}px ${J(s)}px ${J(c)}px)`,
|
|
1400
|
-
height: `${J(n)}px`,
|
|
1401
|
-
transform: `translate3d(${J(e.anchorRect.left)}px, ${J(e.anchorRect.top)}px, 0) scale(${pn(r)}, ${pn(i)})`,
|
|
1402
|
-
visibility: "visible",
|
|
1403
|
-
width: `${J(t)}px`
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
function ln(e) {
|
|
1407
|
-
let t = e.pendingInput, n = e.container;
|
|
1408
|
-
if (!t || !n?.isConnected) {
|
|
1409
|
-
un(e);
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
let r = n.getBoundingClientRect(), i = n.closest("[data-gtsx-preview-clip]"), a = i instanceof HTMLElement ? i.getBoundingClientRect() : r;
|
|
1413
|
-
Object.assign(e.frame.style, cn({
|
|
1414
|
-
anchorRect: r,
|
|
1415
|
-
clipRect: a,
|
|
1416
|
-
layoutSize: t.size
|
|
1417
|
-
}));
|
|
1418
|
-
}
|
|
1419
|
-
function un(e) {
|
|
1420
|
-
Object.assign(e.frame.style, dn(e.pendingInput?.size ?? {
|
|
1421
|
-
width: 0,
|
|
1422
|
-
height: 0
|
|
1423
|
-
}));
|
|
1424
|
-
}
|
|
1425
|
-
function dn(e) {
|
|
1426
|
-
return {
|
|
1427
|
-
clipPath: "inset(0px)",
|
|
1428
|
-
height: q(e.height),
|
|
1429
|
-
transform: "translate3d(-100000px, -100000px, 0)",
|
|
1430
|
-
visibility: "hidden",
|
|
1431
|
-
width: q(e.width)
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
function fn(e, t) {
|
|
1435
|
-
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
1436
|
-
if (typeof e == "string" && e.endsWith("px")) {
|
|
1437
|
-
let t = Number(e.slice(0, -2));
|
|
1438
|
-
if (Number.isFinite(t) && t > 0) return t;
|
|
1439
|
-
}
|
|
1440
|
-
return Math.max(0, t);
|
|
1441
|
-
}
|
|
1442
|
-
function J(e) {
|
|
1443
|
-
return Math.round(e * 100) / 100;
|
|
1444
|
-
}
|
|
1445
|
-
function pn(e) {
|
|
1446
|
-
return Math.round(e * 1e4) / 1e4;
|
|
1447
|
-
}
|
|
1448
|
-
function mn(e, t, n) {
|
|
1449
|
-
let r = e.pendingInput, i = r?.slot.sessionId, a = t.slot.sessionId, o = _n(e, t), s = Dn(r, t);
|
|
1450
|
-
e.currentSessionId = a, e.pendingInput = t, hn(e, t), e.frame.title = t.slot.title, e.frame.style.height = q(t.size.height), e.frame.style.width = q(t.size.width), ln(e), o && (e.frame.style.opacity = "1"), i !== a && (o ? e.frame.dataset.gtsxPreviewPoolLastRenderSessionId = a : delete e.frame.dataset.gtsxPreviewPoolLastRenderSessionId, i && r?.onPreviewFrameMount?.(i, null), t.onPreviewFrameMount?.(a, e.frame, { retainedRender: o })), s && !o && (vn(e), Y(e), e.frame.style.opacity = "0", n(e));
|
|
1451
|
-
}
|
|
1452
|
-
function hn(e, t) {
|
|
1453
|
-
e.frame.dataset.gtsxPreviewPoolEntryId = String(e.id), e.frame.dataset.gtsxPreviewPoolLeaseSessionId = t.slot.sessionId, e.frame.dataset.gtsxPreviewPoolReady = e.ready ? "true" : "false";
|
|
1454
|
-
}
|
|
1455
|
-
function gn(e) {
|
|
1456
|
-
delete e.frame.dataset.gtsxPreviewPoolLeaseSessionId, delete e.frame.dataset.gtsxPreviewPoolLastAcceptedRenderSessionId, delete e.frame.dataset.gtsxPreviewPoolLastRenderSessionId, delete e.frame.dataset.gtsxPreviewPoolRenderDeliveryAttemptCount;
|
|
1457
|
-
}
|
|
1458
|
-
function _n(e, t) {
|
|
1459
|
-
return e.lastCompletedSessionId === t.slot.sessionId && e.lastCompletedPreviewUrl === t.slot.previewUrl && e.lastCompletedSize?.height === t.size.height && e.lastCompletedSize.width === t.size.width;
|
|
1460
|
-
}
|
|
1461
|
-
function vn(e) {
|
|
1462
|
-
delete e.lastCompletedSessionId, delete e.lastCompletedPreviewUrl, delete e.lastCompletedSize;
|
|
1463
|
-
}
|
|
1464
|
-
function yn(e) {
|
|
1465
|
-
let n = e.contentWindow;
|
|
1466
|
-
if (n) try {
|
|
1467
|
-
let e = n.__gtsxPreviewRenderTargetMailbox;
|
|
1468
|
-
return e ? {
|
|
1469
|
-
render: e.render,
|
|
1470
|
-
transport: "direct"
|
|
1471
|
-
} : void 0;
|
|
1472
|
-
} catch {
|
|
1473
|
-
return {
|
|
1474
|
-
render(e) {
|
|
1475
|
-
n.postMessage(t(e), "*");
|
|
1476
|
-
},
|
|
1477
|
-
transport: "postMessage"
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
function bn(e) {
|
|
1482
|
-
return JSON.stringify({
|
|
1483
|
-
height: e.size.height,
|
|
1484
|
-
previewUrl: e.slot.previewUrl,
|
|
1485
|
-
sessionId: e.slot.sessionId,
|
|
1486
|
-
width: e.size.width
|
|
1487
|
-
});
|
|
1488
|
-
}
|
|
1489
|
-
function xn(e, t, n = {}) {
|
|
1490
|
-
return n.force ? !0 : e.lastPostedRenderKey !== t;
|
|
1491
|
-
}
|
|
1492
|
-
function Sn(e, t) {
|
|
1493
|
-
return e.lastPostedRenderKey === t ? (e.pendingRenderDeliveryAttemptCount ?? 0) + 1 : 1;
|
|
1494
|
-
}
|
|
1495
|
-
function Cn(e, t, n) {
|
|
1496
|
-
En(e), !((e.pendingRenderDeliveryAttemptCount ?? 0) >= en) && (e.pendingRenderRedeliveryTimeout = window.setTimeout(() => {
|
|
1497
|
-
e.pendingRenderRedeliveryTimeout = void 0, e.pendingInput && bn(e.pendingInput) === t && (_n(e, e.pendingInput) || n(e, {
|
|
1498
|
-
force: !0,
|
|
1499
|
-
redelivery: !0
|
|
1500
|
-
}));
|
|
1501
|
-
}, $t));
|
|
1502
|
-
}
|
|
1503
|
-
function wn(e, t, n) {
|
|
1504
|
-
Tn(e), e.pendingRenderEndpointRetryTimeout = window.setTimeout(() => {
|
|
1505
|
-
e.pendingRenderEndpointRetryTimeout = void 0, e.pendingInput && bn(e.pendingInput) === t && (_n(e, e.pendingInput) || n(e, { force: !0 }));
|
|
1506
|
-
}, 50);
|
|
1507
|
-
}
|
|
1508
|
-
function Tn(e) {
|
|
1509
|
-
e.pendingRenderEndpointRetryTimeout &&= (window.clearTimeout(e.pendingRenderEndpointRetryTimeout), void 0);
|
|
1510
|
-
}
|
|
1511
|
-
function En(e) {
|
|
1512
|
-
e.pendingRenderRedeliveryTimeout &&= (window.clearTimeout(e.pendingRenderRedeliveryTimeout), void 0);
|
|
1513
|
-
}
|
|
1514
|
-
function Y(e) {
|
|
1515
|
-
Tn(e), En(e), delete e.lastPostedRenderKey, delete e.pendingRenderDeliveryAttemptCount, delete e.frame.dataset.gtsxPreviewPoolRenderDeliveryAttemptCount;
|
|
1516
|
-
}
|
|
1517
|
-
function Dn(e, t) {
|
|
1518
|
-
return !e || e.slot.sessionId !== t.slot.sessionId || e.slot.previewUrl !== t.slot.previewUrl || e.size.height !== t.size.height || e.size.width !== t.size.width;
|
|
1519
|
-
}
|
|
1520
|
-
function On(e) {
|
|
1521
|
-
return typeof e == "object" && !!e && e.type === "gtsx:pool-ready" && e.protocolVersion === 1;
|
|
1522
|
-
}
|
|
1523
|
-
function kn(e) {
|
|
1524
|
-
return typeof e == "object" && !!e && e.type === "gtsx:render-accepted" && e.protocolVersion === 1 && typeof e.sessionId == "string";
|
|
1525
|
-
}
|
|
1526
|
-
function An(e) {
|
|
1527
|
-
return typeof e == "object" && !!e && (e.type === "gtsx:ready" || e.type === "gtsx:error") && typeof e.sessionId == "string";
|
|
1528
|
-
}
|
|
1529
|
-
function jn(e, t) {
|
|
1530
|
-
let n = e.filter((e) => e.owner).length;
|
|
1531
|
-
return {
|
|
1532
|
-
active: n,
|
|
1533
|
-
acceptedRenderPosts: t.acceptedRenderPosts,
|
|
1534
|
-
borrows: t.borrows,
|
|
1535
|
-
created: t.created,
|
|
1536
|
-
directRenderPosts: t.directRenderPosts,
|
|
1537
|
-
idle: e.length - n,
|
|
1538
|
-
newBorrows: t.newBorrows,
|
|
1539
|
-
postMessageRenderPosts: t.postMessageRenderPosts,
|
|
1540
|
-
readyIdle: Mn(e),
|
|
1541
|
-
redeliveredRenderPosts: t.redeliveredRenderPosts,
|
|
1542
|
-
renderEndpointWaits: t.renderEndpointWaits,
|
|
1543
|
-
renderPosts: t.renderPosts,
|
|
1544
|
-
reusedBorrows: t.reusedBorrows,
|
|
1545
|
-
total: e.length
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
function Mn(e) {
|
|
1549
|
-
return e.filter((e) => !e.owner && e.ready).length;
|
|
1550
|
-
}
|
|
1551
|
-
function Nn(e) {
|
|
1552
|
-
return e.filter((e) => !e.owner).length;
|
|
1553
|
-
}
|
|
1554
|
-
function Pn(e) {
|
|
1555
|
-
return /* @__PURE__ */ c("div", {
|
|
1556
|
-
"aria-label": "Preview iframe pool stats",
|
|
1557
|
-
"data-gtsx-preview-iframe-pool-stats": "true",
|
|
1558
|
-
"data-gtsx-preview-iframe-pool-active": e.stats.active,
|
|
1559
|
-
"data-gtsx-preview-iframe-pool-borrows": e.stats.borrows,
|
|
1560
|
-
"data-gtsx-preview-iframe-pool-created": e.stats.created,
|
|
1561
|
-
"data-gtsx-preview-iframe-pool-direct-render-posts": e.stats.directRenderPosts,
|
|
1562
|
-
"data-gtsx-preview-iframe-pool-idle": e.stats.idle,
|
|
1563
|
-
"data-gtsx-preview-iframe-pool-new-borrows": e.stats.newBorrows,
|
|
1564
|
-
"data-gtsx-preview-iframe-pool-post-message-render-posts": e.stats.postMessageRenderPosts,
|
|
1565
|
-
"data-gtsx-preview-iframe-pool-accepted-render-posts": e.stats.acceptedRenderPosts,
|
|
1566
|
-
"data-gtsx-preview-iframe-pool-ready-idle": e.stats.readyIdle,
|
|
1567
|
-
"data-gtsx-preview-iframe-pool-render-endpoint-waits": e.stats.renderEndpointWaits,
|
|
1568
|
-
"data-gtsx-preview-iframe-pool-redelivered-render-posts": e.stats.redeliveredRenderPosts,
|
|
1569
|
-
"data-gtsx-preview-iframe-pool-render-posts": e.stats.renderPosts,
|
|
1570
|
-
"data-gtsx-preview-iframe-pool-reused-borrows": e.stats.reusedBorrows,
|
|
1571
|
-
"data-gtsx-preview-iframe-pool-total": e.stats.total,
|
|
1572
|
-
style: {
|
|
1573
|
-
background: "rgba(255,255,255,0.9)",
|
|
1574
|
-
border: "1px solid rgba(216,222,232,0.95)",
|
|
1575
|
-
borderRadius: 6,
|
|
1576
|
-
bottom: 12,
|
|
1577
|
-
boxShadow: "0 6px 20px rgba(31,35,40,0.12)",
|
|
1578
|
-
color: "#1f2328",
|
|
1579
|
-
display: "flex",
|
|
1580
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1581
|
-
fontSize: 11,
|
|
1582
|
-
gap: 8,
|
|
1583
|
-
left: 12,
|
|
1584
|
-
lineHeight: 1.3,
|
|
1585
|
-
padding: "6px 8px",
|
|
1586
|
-
pointerEvents: "none",
|
|
1587
|
-
position: "fixed",
|
|
1588
|
-
zIndex: 10
|
|
1589
|
-
},
|
|
1590
|
-
children: [
|
|
1591
|
-
/* @__PURE__ */ c("span", { children: ["pool ", e.stats.total] }),
|
|
1592
|
-
/* @__PURE__ */ c("span", { children: ["active ", e.stats.active] }),
|
|
1593
|
-
/* @__PURE__ */ c("span", { children: ["idle ", e.stats.idle] }),
|
|
1594
|
-
/* @__PURE__ */ c("span", { children: ["ready idle ", e.stats.readyIdle] }),
|
|
1595
|
-
/* @__PURE__ */ c("span", { children: ["created ", e.stats.created] }),
|
|
1596
|
-
/* @__PURE__ */ c("span", { children: ["borrow ", e.stats.borrows] }),
|
|
1597
|
-
/* @__PURE__ */ c("span", { children: ["new ", e.stats.newBorrows] }),
|
|
1598
|
-
/* @__PURE__ */ c("span", { children: ["reuse ", e.stats.reusedBorrows] }),
|
|
1599
|
-
/* @__PURE__ */ c("span", { children: ["render ", e.stats.renderPosts] }),
|
|
1600
|
-
/* @__PURE__ */ c("span", { children: ["direct ", e.stats.directRenderPosts] }),
|
|
1601
|
-
/* @__PURE__ */ c("span", { children: ["postMessage ", e.stats.postMessageRenderPosts] }),
|
|
1602
|
-
/* @__PURE__ */ c("span", { children: ["wait endpoint ", e.stats.renderEndpointWaits] }),
|
|
1603
|
-
/* @__PURE__ */ c("span", { children: ["accepted ", e.stats.acceptedRenderPosts] }),
|
|
1604
|
-
/* @__PURE__ */ c("span", { children: ["redelivered ", e.stats.redeliveredRenderPosts] })
|
|
1605
|
-
]
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
//#endregion
|
|
1609
|
-
//#region src/studio-preview-message-flush.ts
|
|
1610
|
-
function Fn(e) {
|
|
1611
|
-
let t = /* @__PURE__ */ new Set(), n = [], r = [];
|
|
1612
|
-
for (let i of e.messages) {
|
|
1613
|
-
if (!In(i.message)) {
|
|
1614
|
-
r.push(i);
|
|
1615
|
-
continue;
|
|
1616
|
-
}
|
|
1617
|
-
let a = Rn(i.message);
|
|
1618
|
-
t.has(a) || (t.add(a), !Ln(e.getFrameState(i.message.sessionId), i.message) && (r.push(i), n.push(i)));
|
|
1619
|
-
}
|
|
1620
|
-
return {
|
|
1621
|
-
completionMessages: n,
|
|
1622
|
-
messagesToApply: r
|
|
1623
|
-
};
|
|
1624
|
-
}
|
|
1625
|
-
function In(e) {
|
|
1626
|
-
return e.type === "gtsx:ready" || e.type === "gtsx:error";
|
|
1627
|
-
}
|
|
1628
|
-
function Ln(e, t) {
|
|
1629
|
-
return e ? t.type === "gtsx:ready" ? e.ready === !0 && !e.error : e.error?.message === t.error.message && e.error.stack === t.error.stack : !1;
|
|
1630
|
-
}
|
|
1631
|
-
function Rn(e) {
|
|
1632
|
-
return e.type === "gtsx:ready" ? `${e.sessionId}\n${e.type}` : `${e.sessionId}\n${e.type}\n${e.error.message}\n${e.error.stack ?? ""}`;
|
|
1633
|
-
}
|
|
1634
|
-
//#endregion
|
|
1635
|
-
//#region src/preview-render-session-store.tsx
|
|
1636
|
-
var zn = a.createContext(null);
|
|
1637
|
-
function Bn(e = /* @__PURE__ */ new Set()) {
|
|
1638
|
-
let t = new Set(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = (e, t) => {
|
|
1639
|
-
let n = e.get(t);
|
|
1640
|
-
if (n) for (let e of n) e();
|
|
1641
|
-
};
|
|
1642
|
-
return {
|
|
1643
|
-
getSessionIds() {
|
|
1644
|
-
return t;
|
|
1645
|
-
},
|
|
1646
|
-
hasSessionId(e) {
|
|
1647
|
-
return t.has(e);
|
|
1648
|
-
},
|
|
1649
|
-
isVisibleSessionId(e) {
|
|
1650
|
-
return n.has(e);
|
|
1651
|
-
},
|
|
1652
|
-
setSessionIds(e, o = /* @__PURE__ */ new Set()) {
|
|
1653
|
-
if (Gn(t, e) && Gn(n, o)) return !1;
|
|
1654
|
-
let s = t, c = n;
|
|
1655
|
-
t = new Set(e), n = new Set(o);
|
|
1656
|
-
let l = /* @__PURE__ */ new Set();
|
|
1657
|
-
for (let e of s) t.has(e) || l.add(e);
|
|
1658
|
-
for (let e of t) s.has(e) || l.add(e);
|
|
1659
|
-
let u = /* @__PURE__ */ new Set();
|
|
1660
|
-
for (let e of c) n.has(e) || u.add(e);
|
|
1661
|
-
for (let e of n) c.has(e) || u.add(e);
|
|
1662
|
-
for (let e of l) a(r, e);
|
|
1663
|
-
for (let e of u) a(i, e);
|
|
1664
|
-
return !0;
|
|
1665
|
-
},
|
|
1666
|
-
subscribeToRenderSession(e, t) {
|
|
1667
|
-
return Vn(r, e, t);
|
|
1668
|
-
},
|
|
1669
|
-
subscribeToVisibleSession(e, t) {
|
|
1670
|
-
return Vn(i, e, t);
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
function Vn(e, t, n) {
|
|
1675
|
-
let r = e.get(t);
|
|
1676
|
-
return r || (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n), () => {
|
|
1677
|
-
let r = e.get(t);
|
|
1678
|
-
r && (r.delete(n), r.size === 0 && e.delete(t));
|
|
1679
|
-
};
|
|
1680
|
-
}
|
|
1681
|
-
function Hn(e) {
|
|
1682
|
-
return /* @__PURE__ */ s(zn.Provider, {
|
|
1683
|
-
value: e.store,
|
|
1684
|
-
children: e.children
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
function Un(e, t = !0) {
|
|
1688
|
-
let n = a.useContext(zn);
|
|
1689
|
-
return a.useSyncExternalStore(a.useCallback((r) => t ? n?.subscribeToVisibleSession(e, r) ?? (() => {}) : () => {}, [
|
|
1690
|
-
t,
|
|
1691
|
-
e,
|
|
1692
|
-
n
|
|
1693
|
-
]), a.useCallback(() => t ? n?.isVisibleSessionId(e) ?? !1 : !1, [
|
|
1694
|
-
t,
|
|
1695
|
-
e,
|
|
1696
|
-
n
|
|
1697
|
-
]), () => !1);
|
|
1698
|
-
}
|
|
1699
|
-
function Wn(e) {
|
|
1700
|
-
let t = a.useContext(zn);
|
|
1701
|
-
return a.useSyncExternalStore(a.useCallback((n) => t?.subscribeToRenderSession(e, n) ?? (() => {}), [e, t]), a.useCallback(() => t?.hasSessionId(e) ?? !1, [e, t]), () => !1);
|
|
1702
|
-
}
|
|
1703
|
-
function Gn(e, t) {
|
|
1704
|
-
if (e.size !== t.size) return !1;
|
|
1705
|
-
for (let n of e) if (!t.has(n)) return !1;
|
|
1706
|
-
return !0;
|
|
1707
|
-
}
|
|
1708
|
-
//#endregion
|
|
1709
|
-
//#region src/case-grid-layout.ts
|
|
1710
|
-
var Kn = .18;
|
|
1711
|
-
function qn(e, t) {
|
|
1712
|
-
let n = e === "desktop" ? 860 : e === "phone" ? 680 : 760;
|
|
1713
|
-
return t <= 1 ? Math.min(n, 720) : n;
|
|
1714
|
-
}
|
|
1715
|
-
//#endregion
|
|
1716
|
-
//#region src/studio-component-preview-frame-states.ts
|
|
1717
|
-
function Jn(e, t, n, r, i) {
|
|
1718
|
-
return Object.fromEntries(e.cases.map((a) => {
|
|
1719
|
-
let o = z(e, a.name, t), s = B(e, a.name, t);
|
|
1720
|
-
return [a.name, i ? i.getLayoutFrameState(o, s) : H(o, n?.[o], r?.[s]?.frameState)];
|
|
1721
|
-
}));
|
|
1722
|
-
}
|
|
1723
|
-
function Yn(e, t, n, r, i) {
|
|
1724
|
-
return Object.fromEntries(e.cases.map((a) => {
|
|
1725
|
-
let o = z(e, a.name, t), s = B(e, a.name, t);
|
|
1726
|
-
return [a.name, i ? i.getMergedFrameState(o, s) : H(o, n?.[o], r?.[s]?.frameState)];
|
|
1727
|
-
}));
|
|
1728
|
-
}
|
|
1729
|
-
//#endregion
|
|
1730
|
-
//#region src/studio-canvas-geometry.ts
|
|
1731
|
-
function Xn(e) {
|
|
1732
|
-
return {
|
|
1733
|
-
bottom: e.bottom,
|
|
1734
|
-
left: e.left,
|
|
1735
|
-
right: e.right,
|
|
1736
|
-
top: e.top
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
function Zn(e, t, n) {
|
|
1740
|
-
return {
|
|
1741
|
-
bottom: (e.bottom - t.top) / n,
|
|
1742
|
-
left: (e.left - t.left) / n,
|
|
1743
|
-
right: (e.right - t.left) / n,
|
|
1744
|
-
top: (e.top - t.top) / n
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
function Qn(e) {
|
|
1748
|
-
return `translate(${e.x}px, ${e.y}px) scale(${e.scale})`;
|
|
1749
|
-
}
|
|
1750
|
-
function $n(e, t, n) {
|
|
1751
|
-
return [...e.selectedCoordinatePath.slice(0, t), n];
|
|
1752
|
-
}
|
|
1753
|
-
function er(e) {
|
|
1754
|
-
return e.join("\n");
|
|
1755
|
-
}
|
|
1756
|
-
function tr(e, t) {
|
|
1757
|
-
return `${e}\n${t}`;
|
|
1758
|
-
}
|
|
1759
|
-
function nr(e, t, n, r) {
|
|
1760
|
-
return e.columns.map((e) => e.components.map((e) => e.cases.map((i) => {
|
|
1761
|
-
let a = z(e, i.name, t), o = B(e, i.name, t), s = H(a, n?.[a], r?.[o]?.frameState);
|
|
1762
|
-
return `${e.coordinate}:${i.name}:${dr(s)}`;
|
|
1763
|
-
}).join(";")).join(",")).join("|");
|
|
1764
|
-
}
|
|
1765
|
-
function rr(e, t, n, r, i) {
|
|
1766
|
-
let a = ze(e).map((e) => F({
|
|
1767
|
-
caseChromeHeight: 21,
|
|
1768
|
-
gap: 14,
|
|
1769
|
-
items: sr(e, Jn(e, t, n, r, i), t),
|
|
1770
|
-
maxSide: qn(t, e.cases.length),
|
|
1771
|
-
minScale: Kn
|
|
1772
|
-
}).previewScale);
|
|
1773
|
-
return a.length > 0 ? Math.min(1, ...a) : 1;
|
|
1774
|
-
}
|
|
1775
|
-
function ir(e, t, n, r, i = {}) {
|
|
1776
|
-
let a = [], o;
|
|
1777
|
-
return e.columns.forEach((s, c) => {
|
|
1778
|
-
let l = n[c] ?? {
|
|
1779
|
-
x: 0,
|
|
1780
|
-
y: 0
|
|
1781
|
-
}, u = r[c]?.cardRectsByCoordinate ?? {}, d = r[c]?.previewFrameRectsBySessionId ?? {};
|
|
1782
|
-
for (let n of s.components) {
|
|
1783
|
-
let r = u[n.coordinate];
|
|
1784
|
-
if (!r) continue;
|
|
1785
|
-
let s = /* @__PURE__ */ new Set();
|
|
1786
|
-
for (let e of n.cases) {
|
|
1787
|
-
let r = z(n, e.name, t), i = d[r];
|
|
1788
|
-
i && (s.add(r), a.push({
|
|
1789
|
-
rect: {
|
|
1790
|
-
bottom: l.y + i.bottom,
|
|
1791
|
-
left: l.x + i.left,
|
|
1792
|
-
right: l.x + i.right,
|
|
1793
|
-
top: l.y + i.top
|
|
1794
|
-
},
|
|
1795
|
-
sessionIds: [r]
|
|
1796
|
-
}));
|
|
1797
|
-
}
|
|
1798
|
-
s.size !== n.cases.length && (o ??= rr(e, t, i.frameStates, i.previewCache, i.previewGeometryStore), a.push(...cr({
|
|
1799
|
-
cardRect: r,
|
|
1800
|
-
casePreviewScale: o,
|
|
1801
|
-
columnLayout: l,
|
|
1802
|
-
component: n,
|
|
1803
|
-
measuredSessionIds: s,
|
|
1804
|
-
previewCache: i.previewCache,
|
|
1805
|
-
previewGeometryStore: i.previewGeometryStore,
|
|
1806
|
-
frameStates: i.frameStates,
|
|
1807
|
-
viewportPreset: t
|
|
1808
|
-
})));
|
|
1809
|
-
}
|
|
1810
|
-
}), a;
|
|
1811
|
-
}
|
|
1812
|
-
function ar(e, t) {
|
|
1813
|
-
let n = Object.keys(e), r = Object.keys(t);
|
|
1814
|
-
return n.length === r.length ? n.every((n) => {
|
|
1815
|
-
let r = e[Number(n)], i = t[Number(n)];
|
|
1816
|
-
return r?.x === i?.x && r?.y === i?.y;
|
|
1817
|
-
}) : !1;
|
|
1818
|
-
}
|
|
1819
|
-
function or(e, t) {
|
|
1820
|
-
let n = Object.keys(e), r = Object.keys(t);
|
|
1821
|
-
return n.length === r.length ? n.every((n) => {
|
|
1822
|
-
let r = Number(n), i = e[r], a = t[r];
|
|
1823
|
-
return !i || !a || i.height !== a.height ? !1 : pr(i.cardRectsByCoordinate, a.cardRectsByCoordinate) && pr(i.previewFrameRectsBySessionId ?? {}, a.previewFrameRectsBySessionId ?? {});
|
|
1824
|
-
}) : !1;
|
|
1825
|
-
}
|
|
1826
|
-
function sr(e, t, n) {
|
|
1827
|
-
return e.cases.map((r) => {
|
|
1828
|
-
let i = t[r.name], a = V(n, i?.size), o = Re(lr(i?.tree, e.coordinate), a);
|
|
1829
|
-
return {
|
|
1830
|
-
height: d(a, o),
|
|
1831
|
-
width: Number(f(a, o))
|
|
1832
|
-
};
|
|
1833
|
-
});
|
|
1834
|
-
}
|
|
1835
|
-
function cr(e) {
|
|
1836
|
-
let t = Jn(e.component, e.viewportPreset, e.frameStates, e.previewCache, e.previewGeometryStore), n = sr(e.component, t, e.viewportPreset), r = F({
|
|
1837
|
-
caseChromeHeight: 21,
|
|
1838
|
-
gap: 14,
|
|
1839
|
-
items: n,
|
|
1840
|
-
maxSide: qn(e.viewportPreset, e.component.cases.length),
|
|
1841
|
-
minScale: Kn,
|
|
1842
|
-
previewScale: e.casePreviewScale
|
|
1843
|
-
}), i = e.cardRect.left, a = e.cardRect.bottom - r.height, o = [];
|
|
1844
|
-
return e.component.cases.forEach((t, s) => {
|
|
1845
|
-
let c = z(e.component, t.name, e.viewportPreset);
|
|
1846
|
-
if (e.measuredSessionIds.has(c)) return;
|
|
1847
|
-
let l = n[s];
|
|
1848
|
-
if (!l) return;
|
|
1849
|
-
let u = s % r.columns, d = Math.floor(s / r.columns), f = i + u * (r.cellWidth + r.gap), p = a + d * (r.cellHeight + r.gap), m = Math.ceil(l.width * r.previewScale), h = Math.ceil(l.height * r.previewScale), g = f + (r.cellWidth - m) / 2, _ = p + 21;
|
|
1850
|
-
o.push({
|
|
1851
|
-
rect: {
|
|
1852
|
-
bottom: e.columnLayout.y + _ + h,
|
|
1853
|
-
left: e.columnLayout.x + g,
|
|
1854
|
-
right: e.columnLayout.x + g + m,
|
|
1855
|
-
top: e.columnLayout.y + _
|
|
1856
|
-
},
|
|
1857
|
-
sessionIds: [c]
|
|
1858
|
-
});
|
|
1859
|
-
}), o;
|
|
1860
|
-
}
|
|
1861
|
-
function lr(e, t) {
|
|
1862
|
-
return e ? ur(e, t)?.rect : void 0;
|
|
1863
|
-
}
|
|
1864
|
-
function ur(e, t) {
|
|
1865
|
-
for (let n of e) {
|
|
1866
|
-
if (n.coordinate === t) return n;
|
|
1867
|
-
let e = ur(n.children, t);
|
|
1868
|
-
if (e) return e;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
function dr(e) {
|
|
1872
|
-
return e ? `${e.size ? `${e.size.width}x${e.size.height}` : "-"}:${fr(e.tree)}` : "pending";
|
|
1873
|
-
}
|
|
1874
|
-
function fr(e) {
|
|
1875
|
-
if (!e) return "-";
|
|
1876
|
-
let t = [], n = (e) => {
|
|
1877
|
-
let r = e.rect ? `${e.rect.x},${e.rect.y},${e.rect.width},${e.rect.height}` : "-";
|
|
1878
|
-
t.push(`${e.coordinate}@${r}`);
|
|
1879
|
-
for (let t of e.children) n(t);
|
|
1880
|
-
};
|
|
1881
|
-
for (let t of e) n(t);
|
|
1882
|
-
return t.join(";");
|
|
1883
|
-
}
|
|
1884
|
-
function pr(e, t) {
|
|
1885
|
-
let n = Object.keys(e), r = Object.keys(t);
|
|
1886
|
-
return n.length === r.length ? n.every((n) => mr(e[n], t[n])) : !1;
|
|
1887
|
-
}
|
|
1888
|
-
function mr(e, t) {
|
|
1889
|
-
return e?.bottom === t?.bottom && e?.left === t?.left && e?.right === t?.right && e?.top === t?.top;
|
|
1890
|
-
}
|
|
1891
|
-
//#endregion
|
|
1892
|
-
//#region src/studio-preview-render-observation.ts
|
|
1893
|
-
function hr(e) {
|
|
1894
|
-
let t, n, r = 0, i = () => ({
|
|
1895
|
-
fullRender: t ? yr(t) : void 0,
|
|
1896
|
-
scrollResponse: n ? vr(n) : void 0,
|
|
1897
|
-
sequence: r
|
|
1898
|
-
});
|
|
1899
|
-
return {
|
|
1900
|
-
observePreviewTiming(a) {
|
|
1901
|
-
let o = e.now(), s = !1;
|
|
1902
|
-
return n && n.sessionIds.has(a.sessionId) && (s = _r(n, a.sessionId, o) || s), t && t.sessionIds.has(a.sessionId) && (s = _r(t, a.sessionId, o) || s), s && (r += 1), i();
|
|
1903
|
-
},
|
|
1904
|
-
observeQueueRun(a) {
|
|
1905
|
-
let o = e.now();
|
|
1906
|
-
if (a.renderBudget === "canvas-movement") {
|
|
1907
|
-
let e = a.newVisibleSessionIds === void 0 ? a.visibleSessionIds ?? [] : a.newVisibleSessionIds;
|
|
1908
|
-
(e.length > 0 || a.newVisibleSessionIds === void 0 && !n) && (n = gr(e, o));
|
|
1909
|
-
}
|
|
1910
|
-
if (a.renderBudget === "normal" && a.renderScope === "buffer") {
|
|
1911
|
-
let e = a.newSessionIds === void 0 ? a.nextSessionIds ?? [] : a.newSessionIds;
|
|
1912
|
-
(e.length > 0 || a.newSessionIds === void 0 && !t) && (t = gr(e, o));
|
|
1913
|
-
}
|
|
1914
|
-
return r += 1, i();
|
|
1915
|
-
},
|
|
1916
|
-
snapshot: i
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
function gr(e, t) {
|
|
1920
|
-
return {
|
|
1921
|
-
completedSessionIds: /* @__PURE__ */ new Set(),
|
|
1922
|
-
sessionIds: new Set(e),
|
|
1923
|
-
startedAtMilliseconds: t
|
|
1924
|
-
};
|
|
1925
|
-
}
|
|
1926
|
-
function _r(e, t, n) {
|
|
1927
|
-
if (e.completedSessionIds.has(t)) return !1;
|
|
1928
|
-
e.completedSessionIds.add(t);
|
|
1929
|
-
let r = Math.max(0, n - e.startedAtMilliseconds);
|
|
1930
|
-
return e.firstCompletionMilliseconds ??= r, e.latestCompletionMilliseconds = r, !0;
|
|
1931
|
-
}
|
|
1932
|
-
function vr(e) {
|
|
1933
|
-
return {
|
|
1934
|
-
completedVisibleSessionCount: e.completedSessionIds.size,
|
|
1935
|
-
firstVisibleCompletionMilliseconds: X(e.firstCompletionMilliseconds),
|
|
1936
|
-
latestVisibleCompletionMilliseconds: X(e.latestCompletionMilliseconds),
|
|
1937
|
-
pendingVisibleSessionCount: Math.max(0, e.sessionIds.size - e.completedSessionIds.size),
|
|
1938
|
-
startedAtMilliseconds: X(e.startedAtMilliseconds) ?? 0,
|
|
1939
|
-
visibleSessionCount: e.sessionIds.size
|
|
1940
|
-
};
|
|
1941
|
-
}
|
|
1942
|
-
function yr(e) {
|
|
1943
|
-
let t = X(e.latestCompletionMilliseconds);
|
|
1944
|
-
return {
|
|
1945
|
-
completedSessionCount: e.completedSessionIds.size,
|
|
1946
|
-
firstCompletionMilliseconds: X(e.firstCompletionMilliseconds),
|
|
1947
|
-
latestCompletionMilliseconds: t,
|
|
1948
|
-
pendingSessionCount: Math.max(0, e.sessionIds.size - e.completedSessionIds.size),
|
|
1949
|
-
renderCompletionsPerSecond: t && t > 0 ? br(e.completedSessionIds.size / (t / 1e3)) : void 0,
|
|
1950
|
-
sessionCount: e.sessionIds.size,
|
|
1951
|
-
startedAtMilliseconds: X(e.startedAtMilliseconds) ?? 0
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
function X(e) {
|
|
1955
|
-
return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 10) / 10 : void 0;
|
|
1956
|
-
}
|
|
1957
|
-
function br(e) {
|
|
1958
|
-
return Math.round(e * 10) / 10;
|
|
1959
|
-
}
|
|
1960
|
-
//#endregion
|
|
1961
|
-
//#region src/use-studio-canvas-controller.ts
|
|
1962
|
-
var xr = typeof window > "u" ? a.useEffect : a.useLayoutEffect, Sr = 1500;
|
|
1963
|
-
function Cr(e) {
|
|
1964
|
-
let [t, n] = a.useState(() => C()), [r, i] = a.useState(null), [o, s] = a.useState(null), c = e.canvas ?? t, l = a.useRef(c), u = a.useRef(null), d = a.useRef(null), f = a.useRef(null), p = a.useRef(e.onCanvasChange), m = a.useRef(e.onCanvasMove), h = a.useRef(e.onCanvasPanEnd), g = a.useRef(e.shouldHandleWheelTarget);
|
|
1965
|
-
p.current = e.onCanvasChange, m.current = e.onCanvasMove, h.current = e.onCanvasPanEnd, g.current = e.shouldHandleWheelTarget;
|
|
1966
|
-
let _ = a.useCallback((e) => {
|
|
1967
|
-
let t = u.current;
|
|
1968
|
-
t && (t.style.transform = Qn(e)), Jt(e);
|
|
1969
|
-
}, []), v = a.useCallback((e) => {
|
|
1970
|
-
let t = e(l.current);
|
|
1971
|
-
Dr(l.current, t) || (l.current = t, _(t), m.current(t), p.current ? p.current(t) : n(t));
|
|
1972
|
-
}, [_]), y = a.useCallback((e, t) => {
|
|
1973
|
-
if (!o) return;
|
|
1974
|
-
let n = o.getBoundingClientRect(), r = {
|
|
1975
|
-
x: e - n.left,
|
|
1976
|
-
y: t - n.top
|
|
1977
|
-
};
|
|
1978
|
-
Er(r, n) && (d.current = {
|
|
1979
|
-
...r,
|
|
1980
|
-
observedAtMilliseconds: Or()
|
|
1981
|
-
});
|
|
1982
|
-
}, [o]);
|
|
1983
|
-
xr(() => {
|
|
1984
|
-
Dr(l.current, c) || (l.current = c, _(c), m.current(c));
|
|
1985
|
-
}, [c, _]);
|
|
1986
|
-
let b = a.useCallback((e) => {
|
|
1987
|
-
u.current = e, e && (e.style.transform = Qn(l.current)), i(e);
|
|
1988
|
-
}, []), x = a.useCallback((e) => {
|
|
1989
|
-
s(e);
|
|
1990
|
-
}, []), S = a.useCallback((e) => {
|
|
1991
|
-
f.current?.pointerId === e.pointerId && (f.current = null, h.current());
|
|
1992
|
-
}, []), w = a.useCallback((e) => {
|
|
1993
|
-
if (y(e.clientX, e.clientY), !e.target.closest("a,button,iframe")) {
|
|
1994
|
-
f.current = {
|
|
1995
|
-
pointerId: e.pointerId,
|
|
1996
|
-
startX: e.clientX,
|
|
1997
|
-
startY: e.clientY,
|
|
1998
|
-
originX: l.current.x,
|
|
1999
|
-
originY: l.current.y
|
|
2000
|
-
};
|
|
2001
|
-
try {
|
|
2002
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2003
|
-
} catch {}
|
|
2004
|
-
}
|
|
2005
|
-
}, [y]), T = a.useCallback((e) => {
|
|
2006
|
-
y(e.clientX, e.clientY);
|
|
2007
|
-
let t = f.current;
|
|
2008
|
-
!t || t.pointerId !== e.pointerId || v((n) => ({
|
|
2009
|
-
...n,
|
|
2010
|
-
x: t.originX + e.clientX - t.startX,
|
|
2011
|
-
y: t.originY + e.clientY - t.startY
|
|
2012
|
-
}));
|
|
2013
|
-
}, [v, y]), E = a.useCallback((e) => {
|
|
2014
|
-
y(e.clientX, e.clientY), f.current?.pointerId === e.pointerId && (f.current = null, h.current());
|
|
2015
|
-
}, [y]);
|
|
2016
|
-
return a.useEffect(() => {
|
|
2017
|
-
if (!o) return;
|
|
2018
|
-
let e = (e) => {
|
|
2019
|
-
if (!g.current(e.target)) return;
|
|
2020
|
-
e.preventDefault();
|
|
2021
|
-
let t = o.getBoundingClientRect(), n = Tr(e, t), r = Or(), i = d.current, a = e.ctrlKey || e.metaKey ? wr({
|
|
2022
|
-
eventViewportPoint: n,
|
|
2023
|
-
lastKnownPointerAgeMilliseconds: i ? r - i.observedAtMilliseconds : void 0,
|
|
2024
|
-
lastKnownPointerViewportPoint: i,
|
|
2025
|
-
viewportSize: {
|
|
2026
|
-
height: t.height,
|
|
2027
|
-
width: t.width
|
|
2028
|
-
}
|
|
2029
|
-
}) : void 0;
|
|
2030
|
-
n && Er(n, t) && (d.current = {
|
|
2031
|
-
...n,
|
|
2032
|
-
observedAtMilliseconds: r
|
|
2033
|
-
}), v((n) => De(n, {
|
|
2034
|
-
clientX: e.clientX,
|
|
2035
|
-
clientY: e.clientY,
|
|
2036
|
-
ctrlKey: e.ctrlKey,
|
|
2037
|
-
deltaMode: e.deltaMode,
|
|
2038
|
-
deltaX: e.deltaX,
|
|
2039
|
-
deltaY: e.deltaY,
|
|
2040
|
-
focalViewportX: a?.x,
|
|
2041
|
-
focalViewportY: a?.y,
|
|
2042
|
-
metaKey: e.metaKey,
|
|
2043
|
-
viewportLeft: t.left,
|
|
2044
|
-
viewportTop: t.top
|
|
2045
|
-
}));
|
|
2046
|
-
};
|
|
2047
|
-
return o.addEventListener("wheel", e, { passive: !1 }), () => o.removeEventListener("wheel", e);
|
|
2048
|
-
}, [o, v]), a.useMemo(() => ({
|
|
2049
|
-
canvas: c,
|
|
2050
|
-
canvasRef: l,
|
|
2051
|
-
canvasSurfaceElement: r,
|
|
2052
|
-
canvasViewportElement: o,
|
|
2053
|
-
moveCanvas: v,
|
|
2054
|
-
onCanvasPointerCancel: S,
|
|
2055
|
-
onCanvasPointerDown: w,
|
|
2056
|
-
onCanvasPointerMove: T,
|
|
2057
|
-
onCanvasPointerUp: E,
|
|
2058
|
-
setCanvasSurfaceElement: b,
|
|
2059
|
-
setCanvasViewportElement: x
|
|
2060
|
-
}), [
|
|
2061
|
-
c,
|
|
2062
|
-
r,
|
|
2063
|
-
o,
|
|
2064
|
-
v,
|
|
2065
|
-
S,
|
|
2066
|
-
w,
|
|
2067
|
-
T,
|
|
2068
|
-
E,
|
|
2069
|
-
b,
|
|
2070
|
-
x
|
|
2071
|
-
]);
|
|
2072
|
-
}
|
|
2073
|
-
function wr(e) {
|
|
2074
|
-
let t = e.lastKnownPointerViewportPoint, n = t !== null && Er(t, e.viewportSize), r = typeof e.lastKnownPointerAgeMilliseconds == "number" && e.lastKnownPointerAgeMilliseconds <= Sr;
|
|
2075
|
-
return n && r ? t : e.eventViewportPoint && Er(e.eventViewportPoint, e.viewportSize) ? e.eventViewportPoint : n ? t : {
|
|
2076
|
-
x: e.viewportSize.width / 2,
|
|
2077
|
-
y: e.viewportSize.height / 2
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
function Tr(e, t) {
|
|
2081
|
-
if (!(e.clientX === 0 && e.clientY === 0)) return {
|
|
2082
|
-
x: e.clientX - t.left,
|
|
2083
|
-
y: e.clientY - t.top
|
|
2084
|
-
};
|
|
2085
|
-
}
|
|
2086
|
-
function Er(e, t) {
|
|
2087
|
-
return e.x >= 0 && e.y >= 0 && e.x <= t.width && e.y <= t.height;
|
|
2088
|
-
}
|
|
2089
|
-
function Dr(e, t) {
|
|
2090
|
-
return e.x === t.x && e.y === t.y && e.scale === t.scale;
|
|
2091
|
-
}
|
|
2092
|
-
function Or() {
|
|
2093
|
-
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2094
|
-
}
|
|
2095
|
-
//#endregion
|
|
2096
|
-
//#region src/use-studio-canvas-layout.ts
|
|
2097
|
-
var kr = typeof window > "u" ? a.useEffect : a.useLayoutEffect, Ar = 40;
|
|
2098
|
-
function jr(e) {
|
|
2099
|
-
let [t, n] = a.useState({}), [r, i] = a.useState({}), [o, s] = a.useState(() => rr(e.workspace, e.canvasViewportPreset, e.frameStates, e.previewCache, e.previewGeometryStore)), c = a.useRef(/* @__PURE__ */ new Map()), l = a.useRef(/* @__PURE__ */ new Map()), u = a.useRef(/* @__PURE__ */ new Map()), d = a.useRef(t), f = a.useRef(r), p = a.useRef(0), m = a.useRef(e.onLayoutMeasured), h = a.useMemo(() => e.previewGeometryStore ? void 0 : nr(e.workspace, e.canvasViewportPreset, e.frameStates, e.previewCache), [
|
|
2100
|
-
e.canvasViewportPreset,
|
|
2101
|
-
e.frameStates,
|
|
2102
|
-
e.previewCache,
|
|
2103
|
-
e.previewGeometryStore,
|
|
2104
|
-
e.workspace
|
|
2105
|
-
]);
|
|
2106
|
-
m.current = e.onLayoutMeasured;
|
|
2107
|
-
let g = a.useCallback((e, t, n) => {
|
|
2108
|
-
let r = tr(e, t);
|
|
2109
|
-
n ? (c.current.set(t, n), l.current.set(r, n)) : (c.current.get(t) === l.current.get(r) && c.current.delete(t), l.current.delete(r));
|
|
2110
|
-
}, []), _ = a.useCallback((e, t) => {
|
|
2111
|
-
t ? u.current.set(e, t) : u.current.delete(e);
|
|
2112
|
-
}, []), v = a.useCallback((e, t) => l.current.get(tr(e, t)) ?? c.current.get(t), []), y = a.useCallback(() => {
|
|
2113
|
-
let t = rr(e.workspace, e.canvasViewportPreset, e.frameStates, e.previewCache, e.previewGeometryStore);
|
|
2114
|
-
s((e) => e === t ? e : t);
|
|
2115
|
-
}, [
|
|
2116
|
-
e.canvasViewportPreset,
|
|
2117
|
-
e.frameStates,
|
|
2118
|
-
e.previewCache,
|
|
2119
|
-
e.previewGeometryStore,
|
|
2120
|
-
e.workspace
|
|
2121
|
-
]), b = a.useCallback(() => {
|
|
2122
|
-
if (!e.canvasSurfaceElement) return;
|
|
2123
|
-
let t = {};
|
|
2124
|
-
e.workspace.columns.forEach((n, r) => {
|
|
2125
|
-
let i = u.current.get(r);
|
|
2126
|
-
if (!i) return;
|
|
2127
|
-
let a = i.getBoundingClientRect(), o = {}, s = {};
|
|
2128
|
-
for (let t of n.components) {
|
|
2129
|
-
let n = l.current.get(tr(r, t.coordinate));
|
|
2130
|
-
if (n) {
|
|
2131
|
-
o[t.coordinate] = Zn(n.getBoundingClientRect(), a, e.canvasRef.current.scale);
|
|
2132
|
-
for (let t of n.querySelectorAll("[data-gtsx-preview-session-id]")) {
|
|
2133
|
-
let n = t.dataset.gtsxPreviewSessionId;
|
|
2134
|
-
n && (s[n] = Zn(t.getBoundingClientRect(), a, e.canvasRef.current.scale));
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
t[r] = {
|
|
2139
|
-
cardRectsByCoordinate: o,
|
|
2140
|
-
height: a.height / e.canvasRef.current.scale,
|
|
2141
|
-
previewFrameRectsBySessionId: s
|
|
2142
|
-
};
|
|
2143
|
-
});
|
|
2144
|
-
let r = ke({
|
|
2145
|
-
columns: e.workspace.columns.map((e) => ({
|
|
2146
|
-
componentCoordinates: e.components.map((e) => e.coordinate),
|
|
2147
|
-
parentCoordinate: e.parentCoordinate
|
|
2148
|
-
})),
|
|
2149
|
-
margin: Ar,
|
|
2150
|
-
measurementsByIndex: t
|
|
2151
|
-
}), a = !or(f.current, t), o = !ar(d.current, r);
|
|
2152
|
-
f.current = t, d.current = r, i((e) => or(e, t) ? e : t), n((e) => ar(e, r) ? e : r), (a || o) && m.current();
|
|
2153
|
-
}, [
|
|
2154
|
-
e.canvasRef,
|
|
2155
|
-
e.canvasSurfaceElement,
|
|
2156
|
-
e.workspace.columns
|
|
2157
|
-
]), x = a.useCallback(() => {
|
|
2158
|
-
if (y(), typeof window > "u") {
|
|
2159
|
-
b();
|
|
2160
|
-
return;
|
|
2161
|
-
}
|
|
2162
|
-
p.current ||= window.requestAnimationFrame(() => {
|
|
2163
|
-
p.current = 0, b();
|
|
2164
|
-
});
|
|
2165
|
-
}, [b, y]);
|
|
2166
|
-
return kr(() => {
|
|
2167
|
-
y(), b();
|
|
2168
|
-
}, [
|
|
2169
|
-
e.canvasSurfaceElement,
|
|
2170
|
-
h,
|
|
2171
|
-
b,
|
|
2172
|
-
y
|
|
2173
|
-
]), a.useEffect(() => () => {
|
|
2174
|
-
p.current && window.cancelAnimationFrame(p.current);
|
|
2175
|
-
}, []), {
|
|
2176
|
-
casePreviewScale: o,
|
|
2177
|
-
columnLayoutByIndex: t,
|
|
2178
|
-
columnLayoutByIndexRef: d,
|
|
2179
|
-
columnMeasurementsByIndexRef: f,
|
|
2180
|
-
getCardElement: v,
|
|
2181
|
-
layoutMeasurementKey: h,
|
|
2182
|
-
scheduleMeasurement: x,
|
|
2183
|
-
setCardElement: g,
|
|
2184
|
-
setColumnElement: _
|
|
2185
|
-
};
|
|
2186
|
-
}
|
|
2187
|
-
//#endregion
|
|
2188
|
-
//#region src/studio-preview-render-request-policy.ts
|
|
2189
|
-
var Z = {
|
|
2190
|
-
renderBudget: "normal",
|
|
2191
|
-
renderScope: "buffer"
|
|
2192
|
-
}, Mr = {
|
|
2193
|
-
renderBudget: "normal",
|
|
2194
|
-
renderScope: "visible"
|
|
2195
|
-
}, Nr = {
|
|
2196
|
-
renderBudget: "canvas-movement",
|
|
2197
|
-
renderScope: "buffer"
|
|
2198
|
-
};
|
|
2199
|
-
function Pr(e, t) {
|
|
2200
|
-
return Fr(e, Q(t));
|
|
2201
|
-
}
|
|
2202
|
-
function Fr(e, t) {
|
|
2203
|
-
if (t.renderScope === Z.renderScope && t.renderBudget === Z.renderBudget) return e;
|
|
2204
|
-
let n = { ...e };
|
|
2205
|
-
return t.renderScope === "visible" && (n.includeBufferedRenderTasks = !1), t.renderBudget === "canvas-movement" && (n.maximumConcurrentRenderTasks = e?.maximumConcurrentRenderTasksDuringCanvasMovement ?? 4, n.minimumVisibleRenderTasks = e?.minimumVisibleRenderTasksDuringCanvasMovement ?? 4), n;
|
|
2206
|
-
}
|
|
2207
|
-
function Ir(e, t) {
|
|
2208
|
-
return Rr(Lr(e ? Q(e) : null, Q(t)));
|
|
2209
|
-
}
|
|
2210
|
-
function Lr(e, t) {
|
|
2211
|
-
return e ? {
|
|
2212
|
-
renderBudget: e.renderBudget === "canvas-movement" && t.renderBudget === "canvas-movement" ? "canvas-movement" : "normal",
|
|
2213
|
-
renderScope: e.renderScope === "buffer" || t.renderScope === "buffer" ? "buffer" : "visible"
|
|
2214
|
-
} : t;
|
|
2215
|
-
}
|
|
2216
|
-
function Q(e) {
|
|
2217
|
-
return {
|
|
2218
|
-
renderBudget: e.useCanvasMovementRenderTaskLimit === !0 ? "canvas-movement" : "normal",
|
|
2219
|
-
renderScope: e.includeBuffer === !1 ? "visible" : "buffer"
|
|
2220
|
-
};
|
|
2221
|
-
}
|
|
2222
|
-
function Rr(e) {
|
|
2223
|
-
return {
|
|
2224
|
-
includeBuffer: e.renderScope === "buffer",
|
|
2225
|
-
useCanvasMovementRenderTaskLimit: e.renderBudget === "canvas-movement"
|
|
2226
|
-
};
|
|
2227
|
-
}
|
|
2228
|
-
//#endregion
|
|
2229
|
-
//#region src/studio-preview-render-request-clock.ts
|
|
2230
|
-
function zr(e) {
|
|
2231
|
-
let t = e.scheduler ?? Ur(), n = 0, r = 0, i = 0, a = 0, o = 0, s, c, l = null, u = (e) => {
|
|
2232
|
-
t && (e === "active" && n && (t.clearTimeout(n), n = 0), e === "bufferRenderDelay" && i && (t.clearTimeout(i), i = 0), e === "canvasThrottle" && a && (t.clearTimeout(a), a = 0), e === "idle" && o && (t.clearTimeout(o), o = 0));
|
|
2233
|
-
}, d = () => Br(s, e.getRenderQueueOptions(), t), f = () => d() ? Nr : i ? Mr : Z, p = (t, n) => {
|
|
2234
|
-
e.runRenderRequest(t, n) && g();
|
|
2235
|
-
}, m = (n) => {
|
|
2236
|
-
l = Lr(l, n), t && (r ||= t.requestAnimationFrame(() => {
|
|
2237
|
-
r = 0;
|
|
2238
|
-
let t = l ?? Z;
|
|
2239
|
-
l = null, p(e.getCanvas(), t);
|
|
2240
|
-
}));
|
|
2241
|
-
}, h = () => {
|
|
2242
|
-
m(f());
|
|
2243
|
-
}, g = () => {
|
|
2244
|
-
if (!t) return;
|
|
2245
|
-
u("active");
|
|
2246
|
-
let r = Vr(e.getRenderQueueOptions()?.activeRenderTimeoutMilliseconds ?? 5e3);
|
|
2247
|
-
r !== void 0 && (n = t.setTimeout(() => {
|
|
2248
|
-
n = 0, h();
|
|
2249
|
-
}, r + 16));
|
|
2250
|
-
}, _ = () => {
|
|
2251
|
-
if (!t) return;
|
|
2252
|
-
let n = $(e.getRenderQueueOptions()?.renderDebounceMilliseconds, 120), r = $(e.getRenderQueueOptions()?.bufferRenderDelayMilliseconds, kt);
|
|
2253
|
-
if (n <= 0) {
|
|
2254
|
-
u("idle"), u("bufferRenderDelay"), m(Z);
|
|
2255
|
-
return;
|
|
2256
|
-
}
|
|
2257
|
-
u("idle"), u("bufferRenderDelay"), o = t.setTimeout(() => {
|
|
2258
|
-
if (o = 0, m(Mr), r <= 0) {
|
|
2259
|
-
m(Z);
|
|
2260
|
-
return;
|
|
2261
|
-
}
|
|
2262
|
-
i = t.setTimeout(() => {
|
|
2263
|
-
i = 0, m(Z);
|
|
2264
|
-
}, r);
|
|
2265
|
-
}, n);
|
|
2266
|
-
}, v = () => {
|
|
2267
|
-
if (!t) {
|
|
2268
|
-
p(e.getCanvas(), Z);
|
|
2269
|
-
return;
|
|
2270
|
-
}
|
|
2271
|
-
let n = $(e.getRenderQueueOptions()?.bufferRenderDelayMilliseconds, kt);
|
|
2272
|
-
if (u("bufferRenderDelay"), m(Mr), n <= 0) {
|
|
2273
|
-
m(Z);
|
|
2274
|
-
return;
|
|
2275
|
-
}
|
|
2276
|
-
i = t.setTimeout(() => {
|
|
2277
|
-
i = 0, m(Z);
|
|
2278
|
-
}, n);
|
|
2279
|
-
}, y = (e) => {
|
|
2280
|
-
c = Hr(t), p(e, Nr);
|
|
2281
|
-
}, b = (n) => {
|
|
2282
|
-
if (!t) {
|
|
2283
|
-
y(n);
|
|
2284
|
-
return;
|
|
2285
|
-
}
|
|
2286
|
-
let r = $(e.getRenderQueueOptions()?.renderThrottleMilliseconds, 100);
|
|
2287
|
-
if (r <= 0) {
|
|
2288
|
-
u("canvasThrottle"), y(n);
|
|
2289
|
-
return;
|
|
2290
|
-
}
|
|
2291
|
-
let i = t.now(), o = c === void 0 ? r : i - c;
|
|
2292
|
-
if (o >= r) {
|
|
2293
|
-
u("canvasThrottle"), y(n);
|
|
2294
|
-
return;
|
|
2295
|
-
}
|
|
2296
|
-
a ||= t.setTimeout(() => {
|
|
2297
|
-
a = 0, y(e.getCanvas());
|
|
2298
|
-
}, Math.max(0, r - o));
|
|
2299
|
-
};
|
|
2300
|
-
return {
|
|
2301
|
-
dispose() {
|
|
2302
|
-
t && r && t.cancelAnimationFrame(r), r = 0, l = null, u("active"), u("bufferRenderDelay"), u("canvasThrottle"), u("idle");
|
|
2303
|
-
},
|
|
2304
|
-
flushRenderRequest(n = e.getCanvas(), i = {}) {
|
|
2305
|
-
t && r && t.cancelAnimationFrame(r), r = 0, l = null, u("bufferRenderDelay"), p(n, Q(i));
|
|
2306
|
-
},
|
|
2307
|
-
requestBufferedRender() {
|
|
2308
|
-
v();
|
|
2309
|
-
},
|
|
2310
|
-
requestCanvasMovementRender(n = e.getCanvas()) {
|
|
2311
|
-
s = Hr(t), b(n), _();
|
|
2312
|
-
},
|
|
2313
|
-
requestRenderAfterPreviewCompletion() {
|
|
2314
|
-
h();
|
|
2315
|
-
}
|
|
2316
|
-
};
|
|
2317
|
-
}
|
|
2318
|
-
function Br(e, t, n) {
|
|
2319
|
-
if (e === void 0) return !1;
|
|
2320
|
-
let r = $(t?.renderDebounceMilliseconds, 120);
|
|
2321
|
-
return r > 0 && Hr(n) - e < r;
|
|
2322
|
-
}
|
|
2323
|
-
function Vr(e) {
|
|
2324
|
-
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0;
|
|
2325
|
-
}
|
|
2326
|
-
function $(e, t) {
|
|
2327
|
-
return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : t;
|
|
2328
|
-
}
|
|
2329
|
-
function Hr(e) {
|
|
2330
|
-
return e ? e.now() : typeof performance < "u" ? performance.now() : Date.now();
|
|
2331
|
-
}
|
|
2332
|
-
function Ur() {
|
|
2333
|
-
if (!(typeof window > "u")) return {
|
|
2334
|
-
cancelAnimationFrame(e) {
|
|
2335
|
-
window.cancelAnimationFrame(e);
|
|
2336
|
-
},
|
|
2337
|
-
clearTimeout(e) {
|
|
2338
|
-
window.clearTimeout(e);
|
|
2339
|
-
},
|
|
2340
|
-
now() {
|
|
2341
|
-
return Hr(void 0);
|
|
2342
|
-
},
|
|
2343
|
-
requestAnimationFrame(e) {
|
|
2344
|
-
return window.requestAnimationFrame(e);
|
|
2345
|
-
},
|
|
2346
|
-
setTimeout(e, t) {
|
|
2347
|
-
return window.setTimeout(e, t);
|
|
2348
|
-
}
|
|
2349
|
-
};
|
|
2350
|
-
}
|
|
2351
|
-
//#endregion
|
|
2352
|
-
//#region src/studio-preview-render-completion-source.ts
|
|
2353
|
-
function Wr(e) {
|
|
2354
|
-
return e.previewGeometryStore ? Kr(e.previewGeometryStore) : Gr(e.frameStates);
|
|
2355
|
-
}
|
|
2356
|
-
function Gr(e) {
|
|
2357
|
-
let t = qr(e);
|
|
2358
|
-
return { completedSessionIdsFor() {
|
|
2359
|
-
return new Set(t);
|
|
2360
|
-
} };
|
|
2361
|
-
}
|
|
2362
|
-
function Kr(e) {
|
|
2363
|
-
return { completedSessionIdsFor(t) {
|
|
2364
|
-
return Jr(e, t);
|
|
2365
|
-
} };
|
|
2366
|
-
}
|
|
2367
|
-
function qr(e) {
|
|
2368
|
-
let t = /* @__PURE__ */ new Set();
|
|
2369
|
-
if (!e) return t;
|
|
2370
|
-
for (let [n, r] of Object.entries(e)) (r.ready || r.error) && t.add(n);
|
|
2371
|
-
return t;
|
|
2372
|
-
}
|
|
2373
|
-
function Jr(e, t) {
|
|
2374
|
-
let n = /* @__PURE__ */ new Set();
|
|
2375
|
-
for (let r of t) {
|
|
2376
|
-
let t = e.getFrameState(r);
|
|
2377
|
-
(t?.ready || t?.error) && n.add(r);
|
|
2378
|
-
}
|
|
2379
|
-
return n;
|
|
2380
|
-
}
|
|
2381
|
-
//#endregion
|
|
2382
|
-
//#region src/studio-preview-render-plan.ts
|
|
2383
|
-
function Yr(e) {
|
|
2384
|
-
let t = ir(e.workspace, e.canvasViewportPreset, e.columnLayoutByIndex, e.columnMeasurementsByIndex, {
|
|
2385
|
-
frameStates: e.frameStates,
|
|
2386
|
-
previewCache: e.previewCache,
|
|
2387
|
-
previewGeometryStore: e.previewGeometryStore
|
|
2388
|
-
}), n = Qr(e.currentSessionIds, e.completedSessionIds, e.mountedAtBySessionId, e.activeRenderTimeoutMilliseconds ?? 5e3), r = {
|
|
2389
|
-
activeSessionIds: n,
|
|
2390
|
-
canvas: e.canvas,
|
|
2391
|
-
canvasMovement: e.canvasMovement,
|
|
2392
|
-
completedSessionIds: e.completedSessionIds,
|
|
2393
|
-
currentSessionIds: e.currentSessionIds,
|
|
2394
|
-
items: t,
|
|
2395
|
-
viewport: e.viewport,
|
|
2396
|
-
...e.queueOptions
|
|
2397
|
-
}, i = At(r), a = Nt(r, i), o = Xr(t, e.canvas, e.viewport);
|
|
2398
|
-
return {
|
|
2399
|
-
activeSessionIds: n,
|
|
2400
|
-
allVisibleSessionIds: o,
|
|
2401
|
-
completedSessionIds: e.completedSessionIds,
|
|
2402
|
-
hasIncompleteVisibleRenderTasks: Zr(o, e.completedSessionIds),
|
|
2403
|
-
nextSessionIds: i,
|
|
2404
|
-
viewport: e.viewport,
|
|
2405
|
-
visibleSessionIds: a,
|
|
2406
|
-
visibilityItems: t,
|
|
2407
|
-
visibleRects: $r(t, a, e.canvas)
|
|
2408
|
-
};
|
|
2409
|
-
}
|
|
2410
|
-
function Xr(e, t, n) {
|
|
2411
|
-
let r = /* @__PURE__ */ new Set();
|
|
2412
|
-
for (let i of e) if (!(ei(bt(t, i.rect), n) <= 0)) for (let e of i.sessionIds) r.add(e);
|
|
2413
|
-
return r;
|
|
2414
|
-
}
|
|
2415
|
-
function Zr(e, t) {
|
|
2416
|
-
if (e.size === 0) return !1;
|
|
2417
|
-
for (let n of e) if (!t.has(n)) return !0;
|
|
2418
|
-
return !1;
|
|
2419
|
-
}
|
|
2420
|
-
function Qr(e, t, n, r) {
|
|
2421
|
-
let i = /* @__PURE__ */ new Set(), a = ti();
|
|
2422
|
-
for (let o of e) {
|
|
2423
|
-
if (t.has(o)) continue;
|
|
2424
|
-
let e = n.get(o) ?? a;
|
|
2425
|
-
(r === void 0 || a - e < r) && i.add(o);
|
|
2426
|
-
}
|
|
2427
|
-
return i;
|
|
2428
|
-
}
|
|
2429
|
-
function $r(e, t, n) {
|
|
2430
|
-
let r = [];
|
|
2431
|
-
for (let i of e) for (let e of i.sessionIds) t.has(e) && r.push({
|
|
2432
|
-
canvasRect: i.rect,
|
|
2433
|
-
sessionId: e,
|
|
2434
|
-
viewportRect: bt(n, i.rect)
|
|
2435
|
-
});
|
|
2436
|
-
return r;
|
|
2437
|
-
}
|
|
2438
|
-
function ei(e, t) {
|
|
2439
|
-
return Math.max(0, Math.min(e.right, t.right) - Math.max(e.left, t.left)) * Math.max(0, Math.min(e.bottom, t.bottom) - Math.max(e.top, t.top));
|
|
2440
|
-
}
|
|
2441
|
-
function ti() {
|
|
2442
|
-
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2443
|
-
}
|
|
2444
|
-
//#endregion
|
|
2445
|
-
//#region src/use-studio-preview-render-scheduler.ts
|
|
2446
|
-
function ni(e) {
|
|
2447
|
-
let t = a.useRef(void 0), n = a.useRef(e.canvasRef.current), r = a.useRef(/* @__PURE__ */ new Map()), i = a.useRef(e.previewRenderSessionStore.getSessionIds()), o = a.useCallback((a = e.canvasRef.current, o = Z) => {
|
|
2448
|
-
if (!e.canvasViewportElement) return !1;
|
|
2449
|
-
let s = Fr(e.previewRenderQueueRef.current, o), c = Wr({
|
|
2450
|
-
frameStates: e.frameStatesRef.current,
|
|
2451
|
-
previewGeometryStore: e.previewGeometryStore
|
|
2452
|
-
}), l = li(n.current, a);
|
|
2453
|
-
ui(l) && (t.current = l), n.current = a;
|
|
2454
|
-
let u = ri({
|
|
2455
|
-
activeRenderTimeoutMilliseconds: s?.activeRenderTimeoutMilliseconds ?? 5e3,
|
|
2456
|
-
canvas: a,
|
|
2457
|
-
canvasMovement: t.current,
|
|
2458
|
-
canvasViewportElement: e.canvasViewportElement,
|
|
2459
|
-
canvasViewportPreset: e.canvasViewportPresetRef.current,
|
|
2460
|
-
columnLayoutByIndex: e.columnLayoutByIndexRef.current,
|
|
2461
|
-
columnMeasurementsByIndex: e.columnMeasurementsByIndexRef.current,
|
|
2462
|
-
completionSource: c,
|
|
2463
|
-
frameStates: e.frameStatesRef.current,
|
|
2464
|
-
mountedAtBySessionId: r.current,
|
|
2465
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
2466
|
-
queueOptions: s,
|
|
2467
|
-
sessionIds: i.current,
|
|
2468
|
-
workspace: e.workspaceRef.current
|
|
2469
|
-
});
|
|
2470
|
-
if (!u) return !1;
|
|
2471
|
-
let d = i.current, f = ci(u.nextSessionIds, d), p = ci(u.visibleSessionIds, d);
|
|
2472
|
-
return mi({
|
|
2473
|
-
canvas: a,
|
|
2474
|
-
canvasMovement: t.current,
|
|
2475
|
-
completedCount: u.completedSessionIds.size,
|
|
2476
|
-
currentCount: i.current.size,
|
|
2477
|
-
includeBuffer: o.renderScope === "buffer",
|
|
2478
|
-
itemCount: u.visibilityItems.length,
|
|
2479
|
-
maximumConcurrentRenderTasks: s?.maximumConcurrentRenderTasks ?? 24,
|
|
2480
|
-
minimumVisibleRenderTasks: s?.minimumVisibleRenderTasks ?? 0,
|
|
2481
|
-
nextCount: u.nextSessionIds.size,
|
|
2482
|
-
nextSessionIds: [...u.nextSessionIds],
|
|
2483
|
-
newSessionIds: f,
|
|
2484
|
-
newVisibleSessionIds: p,
|
|
2485
|
-
renderExpansionCenterViewportPoint: ai(u.viewport),
|
|
2486
|
-
renderBudget: o.renderBudget,
|
|
2487
|
-
renderScope: o.renderScope,
|
|
2488
|
-
showRenderExpansionCenterPulse: oi(o),
|
|
2489
|
-
visibleRects: u.visibleRects,
|
|
2490
|
-
visibleCount: u.visibleSessionIds.size,
|
|
2491
|
-
visibleSessionIds: [...u.visibleSessionIds],
|
|
2492
|
-
viewportHeight: u.viewport.bottom,
|
|
2493
|
-
viewportWidth: u.viewport.right,
|
|
2494
|
-
useCanvasMovementRenderTaskLimit: o.renderBudget === "canvas-movement"
|
|
2495
|
-
}), di(r.current, d, u.nextSessionIds), i.current = u.nextSessionIds, fi(e.previewRenderSessionStore, u.nextSessionIds, u.visibleSessionIds, { urgent: o.renderBudget === "canvas-movement" });
|
|
2496
|
-
}, [
|
|
2497
|
-
e.canvasRef,
|
|
2498
|
-
e.canvasViewportElement,
|
|
2499
|
-
e.canvasViewportPresetRef,
|
|
2500
|
-
e.columnLayoutByIndexRef,
|
|
2501
|
-
e.columnMeasurementsByIndexRef,
|
|
2502
|
-
e.frameStatesRef,
|
|
2503
|
-
e.previewGeometryStore,
|
|
2504
|
-
e.previewRenderQueueRef,
|
|
2505
|
-
e.previewRenderSessionStore,
|
|
2506
|
-
e.workspaceRef
|
|
2507
|
-
]), s = a.useCallback((t = e.canvasRef.current, n = Z) => o(t, n), [e.canvasRef, o]), c = a.useMemo(() => zr({
|
|
2508
|
-
getCanvas: () => e.canvasRef.current,
|
|
2509
|
-
getRenderQueueOptions: () => e.previewRenderQueueRef.current,
|
|
2510
|
-
runRenderRequest: s
|
|
2511
|
-
}), [
|
|
2512
|
-
e.canvasRef,
|
|
2513
|
-
e.previewRenderQueueRef,
|
|
2514
|
-
s
|
|
2515
|
-
]), l = a.useCallback((t = e.canvasRef.current) => {
|
|
2516
|
-
c.requestBufferedRender(t);
|
|
2517
|
-
}, [e.canvasRef, c]), u = a.useCallback((t = e.canvasRef.current, n = {}) => {
|
|
2518
|
-
c.flushRenderRequest(t, n);
|
|
2519
|
-
}, [e.canvasRef, c]), d = a.useCallback((t = e.canvasRef.current) => {
|
|
2520
|
-
c.requestCanvasMovementRender(t);
|
|
2521
|
-
}, [e.canvasRef, c]);
|
|
2522
|
-
return a.useEffect(() => {
|
|
2523
|
-
if (typeof window > "u") return;
|
|
2524
|
-
let e = () => {
|
|
2525
|
-
c.requestRenderAfterPreviewCompletion();
|
|
2526
|
-
};
|
|
2527
|
-
return window.addEventListener("gtsx:preview-timing", e), () => window.removeEventListener("gtsx:preview-timing", e);
|
|
2528
|
-
}, [c]), a.useEffect(() => () => c.dispose(), [c]), {
|
|
2529
|
-
flushPreviewRender: u,
|
|
2530
|
-
requestCanvasPreviewRender: d,
|
|
2531
|
-
requestPreviewRender: l
|
|
2532
|
-
};
|
|
2533
|
-
}
|
|
2534
|
-
function ri(e) {
|
|
2535
|
-
if (!e.canvasViewportElement) return;
|
|
2536
|
-
let t = e.completionSource.completedSessionIdsFor(e.sessionIds), n = {
|
|
2537
|
-
activeRenderTimeoutMilliseconds: e.activeRenderTimeoutMilliseconds,
|
|
2538
|
-
canvas: e.canvas,
|
|
2539
|
-
canvasMovement: e.canvasMovement,
|
|
2540
|
-
canvasViewportPreset: e.canvasViewportPreset,
|
|
2541
|
-
columnLayoutByIndex: e.columnLayoutByIndex,
|
|
2542
|
-
columnMeasurementsByIndex: e.columnMeasurementsByIndex,
|
|
2543
|
-
completedSessionIds: t,
|
|
2544
|
-
currentSessionIds: e.sessionIds,
|
|
2545
|
-
frameStates: e.frameStates,
|
|
2546
|
-
mountedAtBySessionId: e.mountedAtBySessionId,
|
|
2547
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
2548
|
-
queueOptions: e.queueOptions,
|
|
2549
|
-
viewport: ii(e.canvasViewportElement),
|
|
2550
|
-
workspace: e.workspace
|
|
2551
|
-
}, r = Yr(n), i = new Set([...e.sessionIds, ...r.allVisibleSessionIds]), a = e.completionSource.completedSessionIdsFor(i);
|
|
2552
|
-
return si(t, a) ? r : Yr({
|
|
2553
|
-
...n,
|
|
2554
|
-
completedSessionIds: a
|
|
2555
|
-
});
|
|
2556
|
-
}
|
|
2557
|
-
function ii(e) {
|
|
2558
|
-
let t = e.getBoundingClientRect();
|
|
2559
|
-
return {
|
|
2560
|
-
bottom: t.height,
|
|
2561
|
-
left: 0,
|
|
2562
|
-
right: t.width,
|
|
2563
|
-
top: 0
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
function ai(e) {
|
|
2567
|
-
return {
|
|
2568
|
-
x: (e.left + e.right) / 2,
|
|
2569
|
-
y: (e.top + e.bottom) / 2
|
|
2570
|
-
};
|
|
2571
|
-
}
|
|
2572
|
-
function oi(e) {
|
|
2573
|
-
return e.renderBudget === "normal" && e.renderScope === "buffer";
|
|
2574
|
-
}
|
|
2575
|
-
function si(e, t) {
|
|
2576
|
-
if (e.size !== t.size) return !1;
|
|
2577
|
-
for (let n of e) if (!t.has(n)) return !1;
|
|
2578
|
-
return !0;
|
|
2579
|
-
}
|
|
2580
|
-
function ci(e, t) {
|
|
2581
|
-
let n = [];
|
|
2582
|
-
for (let r of e) t.has(r) || n.push(r);
|
|
2583
|
-
return n;
|
|
2584
|
-
}
|
|
2585
|
-
function li(e, t) {
|
|
2586
|
-
return {
|
|
2587
|
-
x: t.x - e.x,
|
|
2588
|
-
y: t.y - e.y
|
|
2589
|
-
};
|
|
2590
|
-
}
|
|
2591
|
-
function ui(e) {
|
|
2592
|
-
return Math.hypot(e.x, e.y) >= .001;
|
|
2593
|
-
}
|
|
2594
|
-
function di(e, t, n) {
|
|
2595
|
-
let r = pi();
|
|
2596
|
-
for (let i of n) !t.has(i) && !e.has(i) && e.set(i, r);
|
|
2597
|
-
for (let t of e.keys()) n.has(t) || e.delete(t);
|
|
2598
|
-
}
|
|
2599
|
-
function fi(e, t, n, r) {
|
|
2600
|
-
if (!r.urgent || typeof window > "u") return e.setSessionIds(t, n);
|
|
2601
|
-
let i = !1;
|
|
2602
|
-
return l(() => {
|
|
2603
|
-
i = e.setSessionIds(t, n);
|
|
2604
|
-
}), i;
|
|
2605
|
-
}
|
|
2606
|
-
function pi() {
|
|
2607
|
-
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2608
|
-
}
|
|
2609
|
-
function mi(e) {
|
|
2610
|
-
if (typeof window > "u") return;
|
|
2611
|
-
let t = new URLSearchParams(window.location.search).getAll("debug").join(",").split(",").map((e) => e.trim());
|
|
2612
|
-
!t.includes("queue") && !t.includes("preview-queue") || (document.documentElement.setAttribute("data-gtsx-preview-queue-debug", JSON.stringify(e)), window.dispatchEvent(new CustomEvent("gtsx:preview-queue-debug", { detail: e })));
|
|
2613
|
-
}
|
|
2614
|
-
//#endregion
|
|
2615
|
-
//#region src/components/ComponentBoundsHitTarget.g.tsx
|
|
2616
|
-
function hi(e) {
|
|
2617
|
-
return /* @__PURE__ */ s("div", {
|
|
2618
|
-
"aria-hidden": "true",
|
|
2619
|
-
"data-gtsx-card-select-coordinate": e.coordinate,
|
|
2620
|
-
"data-gtsx-card-select-target": "component-bounds",
|
|
2621
|
-
onClick: (t) => {
|
|
2622
|
-
t.stopPropagation(), e.onSelect?.();
|
|
2623
|
-
},
|
|
2624
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
2625
|
-
style: {
|
|
2626
|
-
height: e.rect.height,
|
|
2627
|
-
left: e.rect.x,
|
|
2628
|
-
pointerEvents: "auto",
|
|
2629
|
-
position: "absolute",
|
|
2630
|
-
top: e.rect.y,
|
|
2631
|
-
width: e.rect.width,
|
|
2632
|
-
zIndex: 2
|
|
2633
|
-
}
|
|
2634
|
-
});
|
|
2635
|
-
}
|
|
2636
|
-
var gi = i("src/components/ComponentBoundsHitTarget.g.tsx#default", hi);
|
|
2637
|
-
gi.cases = { userCardBounds: { props: {
|
|
2638
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
2639
|
-
rect: {
|
|
2640
|
-
x: 12,
|
|
2641
|
-
y: 20,
|
|
2642
|
-
width: 320,
|
|
2643
|
-
height: 88
|
|
2644
|
-
}
|
|
2645
|
-
} } };
|
|
2646
|
-
//#endregion
|
|
2647
|
-
//#region src/components/SelectedBoundaryOutline.g.tsx
|
|
2648
|
-
function _i(e) {
|
|
2649
|
-
return /* @__PURE__ */ s("div", {
|
|
2650
|
-
"aria-hidden": "true",
|
|
2651
|
-
"data-gtsx-selection-outline": "true",
|
|
2652
|
-
style: {
|
|
2653
|
-
height: e.rect.height,
|
|
2654
|
-
left: e.rect.x,
|
|
2655
|
-
outline: "1px solid #0d99ff",
|
|
2656
|
-
pointerEvents: "none",
|
|
2657
|
-
position: "absolute",
|
|
2658
|
-
top: e.rect.y,
|
|
2659
|
-
width: e.rect.width,
|
|
2660
|
-
zIndex: 1
|
|
2661
|
-
}
|
|
2662
|
-
});
|
|
2663
|
-
}
|
|
2664
|
-
var vi = i("src/components/SelectedBoundaryOutline.g.tsx#default", _i);
|
|
2665
|
-
vi.cases = { userCardSelected: { props: { rect: {
|
|
2666
|
-
x: 12,
|
|
2667
|
-
y: 20,
|
|
2668
|
-
width: 320,
|
|
2669
|
-
height: 88
|
|
2670
|
-
} } } };
|
|
2671
|
-
//#endregion
|
|
2672
|
-
//#region src/components/BufferedPreviewIframe.g.tsx
|
|
2673
|
-
function yi(e) {
|
|
2674
|
-
return /* @__PURE__ */ s("iframe", {
|
|
2675
|
-
"aria-hidden": "true",
|
|
2676
|
-
loading: "eager",
|
|
2677
|
-
ref: (t) => e.onPreviewFrameMount?.(e.slot.sessionId, t),
|
|
2678
|
-
src: e.slot.previewUrl,
|
|
2679
|
-
style: {
|
|
2680
|
-
background: "transparent",
|
|
2681
|
-
border: 0,
|
|
2682
|
-
height: e.size.height,
|
|
2683
|
-
left: 0,
|
|
2684
|
-
pointerEvents: "none",
|
|
2685
|
-
position: "absolute",
|
|
2686
|
-
top: 0,
|
|
2687
|
-
width: e.size.width,
|
|
2688
|
-
zIndex: 1
|
|
2689
|
-
},
|
|
2690
|
-
tabIndex: -1,
|
|
2691
|
-
title: e.slot.title
|
|
2692
|
-
});
|
|
2693
|
-
}
|
|
2694
|
-
var bi = i("src/components/BufferedPreviewIframe.g.tsx#default", yi);
|
|
2695
|
-
bi.cases = { active: { props: {
|
|
2696
|
-
size: {
|
|
2697
|
-
width: 390,
|
|
2698
|
-
height: 844
|
|
2699
|
-
},
|
|
2700
|
-
slot: {
|
|
2701
|
-
previewUrl: "/gtsx?entry=src%2FUserCard.g.tsx%23default&case=ready&chrome=0",
|
|
2702
|
-
sessionId: "src/UserCard.g.tsx#default:ready",
|
|
2703
|
-
title: "UserCard preview"
|
|
2704
|
-
}
|
|
2705
|
-
} } };
|
|
2706
|
-
//#endregion
|
|
2707
|
-
//#region src/components/StudioPreviewIframe.tsx
|
|
2708
|
-
function xi(e) {
|
|
2709
|
-
let t = on();
|
|
2710
|
-
return a.useEffect(() => {
|
|
2711
|
-
if (!t) return e.onBorrowOriginChange?.("new"), () => e.onBorrowOriginChange?.(null);
|
|
2712
|
-
}, [t, e.onBorrowOriginChange]), s(t ? rn : bi, { ...e });
|
|
2713
|
-
}
|
|
2714
|
-
//#endregion
|
|
2715
|
-
//#region src/components/LazyPreviewFrame.g.tsx
|
|
2716
|
-
function Si(e) {
|
|
2717
|
-
return {
|
|
2718
|
-
isVisibleRenderSession: Un(e.sessionId, e.debugPreviewQueue === !0),
|
|
2719
|
-
shouldLoadFromRenderQueue: Wn(e.sessionId)
|
|
2720
|
-
};
|
|
2721
|
-
}
|
|
2722
|
-
var Ci = r(Si);
|
|
2723
|
-
function wi(e) {
|
|
2724
|
-
let [t, n] = a.useState(null), r = Ci(e), i = e.shouldLoad ?? r.shouldLoadFromRenderQueue, o = d(e.size, e.boundaryRect), l = f(e.size, e.boundaryRect), u = h(e.size, e.boundaryRect), g = p(e.boundaryRect, u), _ = m(e.boundaryRect, u), v = m(e.selectedBoundaryRect, u), y = 1 / Math.max(e.debugIndicatorScale ?? 1, .01), b = Di(e.frameState, i), x = t ?? "pending", S = Ei({
|
|
2725
|
-
iframeOrigin: x,
|
|
2726
|
-
isVisibleRenderSession: r.isVisibleRenderSession,
|
|
2727
|
-
renderLifecycleState: b,
|
|
2728
|
-
shouldLoad: i
|
|
2729
|
-
});
|
|
2730
|
-
return a.useEffect(() => {
|
|
2731
|
-
i || n(null);
|
|
2732
|
-
}, [i]), /* @__PURE__ */ c("div", {
|
|
2733
|
-
"data-gtsx-preview-session-id": e["data-gtsx-preview-session-id"],
|
|
2734
|
-
"data-gtsx-preview-src": e.previewUrl,
|
|
2735
|
-
"data-gtsx-viewport-preset": e.viewportPreset,
|
|
2736
|
-
style: {
|
|
2737
|
-
height: o,
|
|
2738
|
-
overflow: "visible",
|
|
2739
|
-
position: "relative",
|
|
2740
|
-
width: l
|
|
2741
|
-
},
|
|
2742
|
-
children: [
|
|
2743
|
-
i ? /* @__PURE__ */ s("div", {
|
|
2744
|
-
"data-gtsx-preview-clip": "true",
|
|
2745
|
-
style: {
|
|
2746
|
-
contain: "layout paint style",
|
|
2747
|
-
height: o,
|
|
2748
|
-
left: 0,
|
|
2749
|
-
overflow: "hidden",
|
|
2750
|
-
pointerEvents: "none",
|
|
2751
|
-
position: "absolute",
|
|
2752
|
-
top: 0,
|
|
2753
|
-
width: l,
|
|
2754
|
-
zIndex: 1
|
|
2755
|
-
},
|
|
2756
|
-
children: /* @__PURE__ */ s("div", {
|
|
2757
|
-
style: {
|
|
2758
|
-
height: e.size.height,
|
|
2759
|
-
left: -g.x,
|
|
2760
|
-
position: "absolute",
|
|
2761
|
-
top: -g.y,
|
|
2762
|
-
width: e.size.width
|
|
2763
|
-
},
|
|
2764
|
-
children: /* @__PURE__ */ s(xi, {
|
|
2765
|
-
onBorrowOriginChange: e.debugPreviewPool || e.debugPreviewQueue ? n : void 0,
|
|
2766
|
-
onPreviewFrameMount: e.onPreviewFrameMount,
|
|
2767
|
-
size: e.size,
|
|
2768
|
-
slot: {
|
|
2769
|
-
previewUrl: e.previewUrl,
|
|
2770
|
-
sessionId: e.sessionId,
|
|
2771
|
-
title: e.title
|
|
2772
|
-
}
|
|
2773
|
-
})
|
|
2774
|
-
})
|
|
2775
|
-
}) : null,
|
|
2776
|
-
e.debugPreviewQueue ? /* @__PURE__ */ c("span", {
|
|
2777
|
-
"aria-label": "Preview render lifecycle",
|
|
2778
|
-
"data-gtsx-preview-render-flow": S,
|
|
2779
|
-
"data-gtsx-preview-render-iframe-origin": x,
|
|
2780
|
-
"data-gtsx-preview-render-lifecycle": b,
|
|
2781
|
-
"data-gtsx-preview-render-queued": i ? "true" : "false",
|
|
2782
|
-
"data-gtsx-preview-render-visible": r.isVisibleRenderSession ? "true" : "false",
|
|
2783
|
-
style: {
|
|
2784
|
-
alignItems: "center",
|
|
2785
|
-
background: "rgba(255,255,255,0.92)",
|
|
2786
|
-
border: "1px solid rgba(216,222,232,0.96)",
|
|
2787
|
-
borderRadius: 999,
|
|
2788
|
-
bottom: 5,
|
|
2789
|
-
boxShadow: "0 1px 5px rgba(31,35,40,0.16)",
|
|
2790
|
-
display: "grid",
|
|
2791
|
-
gap: 3,
|
|
2792
|
-
gridTemplateColumns: "repeat(4, 6px)",
|
|
2793
|
-
height: 12,
|
|
2794
|
-
justifyContent: "center",
|
|
2795
|
-
padding: "0 4px",
|
|
2796
|
-
pointerEvents: "none",
|
|
2797
|
-
position: "absolute",
|
|
2798
|
-
right: 5,
|
|
2799
|
-
transform: `scale(${y})`,
|
|
2800
|
-
transformOrigin: "bottom right",
|
|
2801
|
-
zIndex: 5
|
|
2802
|
-
},
|
|
2803
|
-
title: S,
|
|
2804
|
-
children: [
|
|
2805
|
-
/* @__PURE__ */ s(ki, {
|
|
2806
|
-
active: i,
|
|
2807
|
-
color: "#57606a"
|
|
2808
|
-
}),
|
|
2809
|
-
/* @__PURE__ */ s(ki, {
|
|
2810
|
-
active: r.isVisibleRenderSession,
|
|
2811
|
-
color: "#0d99ff"
|
|
2812
|
-
}),
|
|
2813
|
-
/* @__PURE__ */ s(ki, {
|
|
2814
|
-
active: t !== null,
|
|
2815
|
-
color: t === "new" ? "#fb8f2d" : "#2da44e"
|
|
2816
|
-
}),
|
|
2817
|
-
/* @__PURE__ */ s(ki, {
|
|
2818
|
-
active: !0,
|
|
2819
|
-
color: Oi(b)
|
|
2820
|
-
})
|
|
2821
|
-
]
|
|
2822
|
-
}) : null,
|
|
2823
|
-
e.debugPreviewQueue && i && r.isVisibleRenderSession ? /* @__PURE__ */ s("span", {
|
|
2824
|
-
"aria-label": "Preview task dispatched from visible viewport",
|
|
2825
|
-
"data-gtsx-preview-queue-origin": "visible",
|
|
2826
|
-
style: {
|
|
2827
|
-
background: "#0d99ff",
|
|
2828
|
-
border: "1px solid rgba(255,255,255,0.92)",
|
|
2829
|
-
borderRadius: 999,
|
|
2830
|
-
boxShadow: "0 1px 5px rgba(31,35,40,0.25)",
|
|
2831
|
-
height: 9,
|
|
2832
|
-
pointerEvents: "none",
|
|
2833
|
-
position: "absolute",
|
|
2834
|
-
right: e.debugPreviewPool ? 18 : 5,
|
|
2835
|
-
top: 5,
|
|
2836
|
-
transform: `scale(${y})`,
|
|
2837
|
-
transformOrigin: "top right",
|
|
2838
|
-
width: 9,
|
|
2839
|
-
zIndex: 4
|
|
2840
|
-
},
|
|
2841
|
-
title: "visible queue task"
|
|
2842
|
-
}) : null,
|
|
2843
|
-
e.debugPreviewPool && i && t ? /* @__PURE__ */ s("span", {
|
|
2844
|
-
"aria-label": t === "pool" ? "Preview iframe reused from pool" : "Preview iframe created",
|
|
2845
|
-
"data-gtsx-preview-pool-origin": t,
|
|
2846
|
-
style: {
|
|
2847
|
-
background: t === "pool" ? "#2da44e" : "#fb8f2d",
|
|
2848
|
-
border: "1px solid rgba(255,255,255,0.92)",
|
|
2849
|
-
borderRadius: 999,
|
|
2850
|
-
boxShadow: "0 1px 5px rgba(31,35,40,0.25)",
|
|
2851
|
-
height: 9,
|
|
2852
|
-
pointerEvents: "none",
|
|
2853
|
-
position: "absolute",
|
|
2854
|
-
right: 5,
|
|
2855
|
-
top: 5,
|
|
2856
|
-
transform: `scale(${y})`,
|
|
2857
|
-
transformOrigin: "top right",
|
|
2858
|
-
width: 9,
|
|
2859
|
-
zIndex: 4
|
|
2860
|
-
},
|
|
2861
|
-
title: t === "pool" ? "from pool" : "new iframe"
|
|
2862
|
-
}) : null,
|
|
2863
|
-
_ ? /* @__PURE__ */ s(gi, {
|
|
2864
|
-
coordinate: e.coordinate,
|
|
2865
|
-
onSelect: e.onSelect,
|
|
2866
|
-
rect: _
|
|
2867
|
-
}) : null,
|
|
2868
|
-
v ? /* @__PURE__ */ s(vi, { rect: v }) : null
|
|
2869
|
-
]
|
|
2870
|
-
});
|
|
2871
|
-
}
|
|
2872
|
-
var Ti = i("src/components/LazyPreviewFrame.g.tsx#default", wi);
|
|
2873
|
-
Ti.cases = { loadedPhone: { props: {
|
|
2874
|
-
"data-gtsx-preview-session-id": "src/UserCard.g.tsx#default:ready",
|
|
2875
|
-
boundaryRect: {
|
|
2876
|
-
x: 10,
|
|
2877
|
-
y: 20,
|
|
2878
|
-
width: 320,
|
|
2879
|
-
height: 88
|
|
2880
|
-
},
|
|
2881
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
2882
|
-
previewUrl: "/gtsx?entry=src%2FUserCard.g.tsx%23default&case=ready&chrome=0",
|
|
2883
|
-
selectedBoundaryRect: {
|
|
2884
|
-
x: 10,
|
|
2885
|
-
y: 20,
|
|
2886
|
-
width: 320,
|
|
2887
|
-
height: 88
|
|
2888
|
-
},
|
|
2889
|
-
shouldLoad: !0,
|
|
2890
|
-
size: {
|
|
2891
|
-
width: 390,
|
|
2892
|
-
height: 844
|
|
2893
|
-
},
|
|
2894
|
-
sessionId: "src/UserCard.g.tsx#default:ready",
|
|
2895
|
-
title: "UserCard preview",
|
|
2896
|
-
viewportPreset: "phone"
|
|
2897
|
-
} } };
|
|
2898
|
-
function Ei(e) {
|
|
2899
|
-
return [
|
|
2900
|
-
e.shouldLoad ? "queued" : "not-queued",
|
|
2901
|
-
e.isVisibleRenderSession ? "visible" : "buffer",
|
|
2902
|
-
`iframe-${e.iframeOrigin}`,
|
|
2903
|
-
e.renderLifecycleState
|
|
2904
|
-
].join(" -> ");
|
|
2905
|
-
}
|
|
2906
|
-
function Di(e, t) {
|
|
2907
|
-
return e?.error ? "error" : e?.ready ? "ready" : t && e ? "rendering" : t ? "queued" : "idle";
|
|
2908
|
-
}
|
|
2909
|
-
function Oi(e) {
|
|
2910
|
-
return e === "error" ? "#cf222e" : e === "ready" ? "#2da44e" : e === "rendering" ? "#bf8700" : e === "queued" ? "#0d99ff" : "#8c959f";
|
|
2911
|
-
}
|
|
2912
|
-
function ki(e) {
|
|
2913
|
-
return /* @__PURE__ */ s("span", {
|
|
2914
|
-
"aria-hidden": "true",
|
|
2915
|
-
style: {
|
|
2916
|
-
background: e.active ? e.color : "rgba(140,149,159,0.22)",
|
|
2917
|
-
borderRadius: 999,
|
|
2918
|
-
display: "block",
|
|
2919
|
-
height: 6,
|
|
2920
|
-
width: 6
|
|
2921
|
-
}
|
|
2922
|
-
});
|
|
2923
|
-
}
|
|
2924
|
-
//#endregion
|
|
2925
|
-
//#region src/components/PreviewError.g.tsx
|
|
2926
|
-
function Ai(e) {
|
|
2927
|
-
return /* @__PURE__ */ c("div", {
|
|
2928
|
-
role: "status",
|
|
2929
|
-
style: {
|
|
2930
|
-
background: "#fff8c5",
|
|
2931
|
-
border: "1px solid #d4a72c",
|
|
2932
|
-
borderRadius: 8,
|
|
2933
|
-
color: "#5a1e02",
|
|
2934
|
-
padding: 12
|
|
2935
|
-
},
|
|
2936
|
-
children: [
|
|
2937
|
-
/* @__PURE__ */ s("strong", { children: "Preview unavailable" }),
|
|
2938
|
-
/* @__PURE__ */ s("p", {
|
|
2939
|
-
style: { margin: "6px 0 0" },
|
|
2940
|
-
children: e.error.message
|
|
2941
|
-
}),
|
|
2942
|
-
e.error.stack ? /* @__PURE__ */ s("pre", {
|
|
2943
|
-
style: { whiteSpace: "pre-wrap" },
|
|
2944
|
-
children: e.error.stack
|
|
2945
|
-
}) : null,
|
|
2946
|
-
/* @__PURE__ */ c("dl", {
|
|
2947
|
-
style: {
|
|
2948
|
-
display: "grid",
|
|
2949
|
-
gap: 4,
|
|
2950
|
-
margin: "8px 0 0"
|
|
2951
|
-
},
|
|
2952
|
-
children: [
|
|
2953
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", { children: "Entry" }), /* @__PURE__ */ s("dd", {
|
|
2954
|
-
style: { margin: 0 },
|
|
2955
|
-
children: e.coordinate
|
|
2956
|
-
})] }),
|
|
2957
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", { children: "Case" }), /* @__PURE__ */ s("dd", {
|
|
2958
|
-
style: { margin: 0 },
|
|
2959
|
-
children: e.caseName
|
|
2960
|
-
})] }),
|
|
2961
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", { children: "Preview URL" }), /* @__PURE__ */ s("dd", {
|
|
2962
|
-
style: { margin: 0 },
|
|
2963
|
-
children: /* @__PURE__ */ s("code", { children: e.previewUrl })
|
|
2964
|
-
})] })
|
|
2965
|
-
]
|
|
2966
|
-
})
|
|
2967
|
-
]
|
|
2968
|
-
});
|
|
2969
|
-
}
|
|
2970
|
-
var ji = i("src/components/PreviewError.g.tsx#default", Ai);
|
|
2971
|
-
ji.cases = { renderFailure: { props: {
|
|
2972
|
-
caseName: "ready",
|
|
2973
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
2974
|
-
error: {
|
|
2975
|
-
message: "Cannot read properties of undefined",
|
|
2976
|
-
stack: "TypeError: Cannot read properties of undefined\n at UserCard"
|
|
2977
|
-
},
|
|
2978
|
-
previewUrl: "/gtsx?entry=src%2FUserCard.g.tsx%23default&case=ready&chrome=0"
|
|
2979
|
-
} } };
|
|
2980
|
-
//#endregion
|
|
2981
|
-
//#region src/components/ComponentCard.g.tsx
|
|
2982
|
-
function Mi(e) {
|
|
2983
|
-
let t = Ri(e.component), n = Object.fromEntries(e.component.cases.map((t) => [t.name, e.caseFrameStates?.[t.name] ?? (t.name === e.selectedCaseName ? e.frameState : void 0)])), r = Object.fromEntries(e.component.cases.map((t) => [t.name, e.caseLayoutFrameStates?.[t.name] ?? n[t.name]])), i = e.component.cases.map((t) => {
|
|
2984
|
-
let i = n[t.name], a = r[t.name], o = z(e.component, t.name, e.viewportPreset), s = V(e.viewportPreset, a?.size), c = R(e.manifest, e.component, t.name, o, { static: !0 }), l = Re(Li(a?.tree, e.component.coordinate), s), u = Number(f(s, l));
|
|
2985
|
-
return {
|
|
2986
|
-
displaySize: s,
|
|
2987
|
-
frameState: i,
|
|
2988
|
-
layoutHeight: d(s, l),
|
|
2989
|
-
layoutWidth: u,
|
|
2990
|
-
name: t.name,
|
|
2991
|
-
previewUrl: c,
|
|
2992
|
-
sessionId: o,
|
|
2993
|
-
visibleBoundaryRect: l
|
|
2994
|
-
};
|
|
2995
|
-
}), a = F({
|
|
2996
|
-
caseChromeHeight: 21,
|
|
2997
|
-
gap: 14,
|
|
2998
|
-
items: i.map((e) => ({
|
|
2999
|
-
height: e.layoutHeight,
|
|
3000
|
-
width: e.layoutWidth
|
|
3001
|
-
})),
|
|
3002
|
-
maxSide: qn(e.viewportPreset, i.length),
|
|
3003
|
-
minScale: Kn,
|
|
3004
|
-
previewScale: e.casePreviewScale
|
|
3005
|
-
}), o = Math.max(280, a.width), l = e.columnIndex ?? 0, u = e.component.cases[0]?.name ?? e.selectedCaseName;
|
|
3006
|
-
return /* @__PURE__ */ c("article", {
|
|
3007
|
-
"aria-label": e.component.componentName,
|
|
3008
|
-
"data-gtsx-card-coordinate": e.component.coordinate,
|
|
3009
|
-
"data-gtsx-card-selected": e.selected ? "true" : void 0,
|
|
3010
|
-
style: {
|
|
3011
|
-
display: "grid",
|
|
3012
|
-
gap: 8,
|
|
3013
|
-
width: o
|
|
3014
|
-
},
|
|
3015
|
-
children: [/* @__PURE__ */ s("strong", {
|
|
3016
|
-
style: {
|
|
3017
|
-
color: "inherit",
|
|
3018
|
-
fontSize: 13,
|
|
3019
|
-
letterSpacing: 0,
|
|
3020
|
-
lineHeight: 1.2,
|
|
3021
|
-
overflow: "hidden",
|
|
3022
|
-
textOverflow: "ellipsis",
|
|
3023
|
-
whiteSpace: "nowrap"
|
|
3024
|
-
},
|
|
3025
|
-
children: e.component.componentName
|
|
3026
|
-
}), t ? /* @__PURE__ */ s(ji, {
|
|
3027
|
-
caseName: u,
|
|
3028
|
-
coordinate: e.component.coordinate,
|
|
3029
|
-
error: { message: t },
|
|
3030
|
-
previewUrl: R(e.manifest, e.component, u, void 0, { static: !0 })
|
|
3031
|
-
}) : /* @__PURE__ */ s("div", {
|
|
3032
|
-
"data-gtsx-case-grid": e.component.coordinate,
|
|
3033
|
-
"data-gtsx-case-grid-columns": a.columns,
|
|
3034
|
-
"data-gtsx-case-grid-preview-scale": a.previewScale,
|
|
3035
|
-
"data-gtsx-case-grid-selected": e.selected ? "true" : void 0,
|
|
3036
|
-
style: {
|
|
3037
|
-
display: "grid",
|
|
3038
|
-
gap: a.gap,
|
|
3039
|
-
gridTemplateColumns: `repeat(${a.columns}, ${a.cellWidth}px)`,
|
|
3040
|
-
outline: e.selected ? "1px solid #0d99ff" : void 0,
|
|
3041
|
-
position: "relative",
|
|
3042
|
-
width: a.width
|
|
3043
|
-
},
|
|
3044
|
-
children: i.map((t) => /* @__PURE__ */ c("div", {
|
|
3045
|
-
"data-gtsx-case-tile": t.name,
|
|
3046
|
-
onClick: () => e.onSelect?.(e.component, n, l, "pointer"),
|
|
3047
|
-
onKeyDown: (t) => {
|
|
3048
|
-
t.key !== "Enter" && t.key !== " " || (t.preventDefault(), e.onSelect?.(e.component, n, l, "keyboard"));
|
|
3049
|
-
},
|
|
3050
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
3051
|
-
role: "button",
|
|
3052
|
-
style: {
|
|
3053
|
-
alignContent: "start",
|
|
3054
|
-
cursor: e.onSelect ? "pointer" : "default",
|
|
3055
|
-
display: "grid",
|
|
3056
|
-
gap: 5,
|
|
3057
|
-
minWidth: 0,
|
|
3058
|
-
width: a.cellWidth
|
|
3059
|
-
},
|
|
3060
|
-
tabIndex: 0,
|
|
3061
|
-
children: [/* @__PURE__ */ s("strong", {
|
|
3062
|
-
style: {
|
|
3063
|
-
color: "#57606a",
|
|
3064
|
-
fontSize: 11,
|
|
3065
|
-
lineHeight: "16px",
|
|
3066
|
-
overflow: "hidden",
|
|
3067
|
-
textOverflow: "ellipsis",
|
|
3068
|
-
whiteSpace: "nowrap"
|
|
3069
|
-
},
|
|
3070
|
-
children: t.name
|
|
3071
|
-
}), /* @__PURE__ */ s("div", {
|
|
3072
|
-
"data-gtsx-case-preview-frame": t.name,
|
|
3073
|
-
"data-gtsx-case-preview-frame-state": Ii(t.frameState),
|
|
3074
|
-
style: {
|
|
3075
|
-
height: Math.ceil(t.layoutHeight * a.previewScale),
|
|
3076
|
-
justifySelf: "center",
|
|
3077
|
-
overflow: "visible",
|
|
3078
|
-
position: "relative",
|
|
3079
|
-
width: Math.ceil(t.layoutWidth * a.previewScale)
|
|
3080
|
-
},
|
|
3081
|
-
children: /* @__PURE__ */ c("div", {
|
|
3082
|
-
style: {
|
|
3083
|
-
height: t.layoutHeight,
|
|
3084
|
-
left: 0,
|
|
3085
|
-
position: "absolute",
|
|
3086
|
-
top: 0,
|
|
3087
|
-
transform: `scale(${a.previewScale})`,
|
|
3088
|
-
transformOrigin: "0 0",
|
|
3089
|
-
width: t.layoutWidth
|
|
3090
|
-
},
|
|
3091
|
-
children: [/* @__PURE__ */ s(Ti, {
|
|
3092
|
-
"data-gtsx-preview-session-id": t.sessionId,
|
|
3093
|
-
boundaryRect: t.visibleBoundaryRect,
|
|
3094
|
-
coordinate: e.component.coordinate,
|
|
3095
|
-
debugIndicatorScale: a.previewScale,
|
|
3096
|
-
debugPreviewPool: e.debugPreviewPool,
|
|
3097
|
-
debugPreviewQueue: e.debugPreviewQueue,
|
|
3098
|
-
frameState: t.frameState,
|
|
3099
|
-
onSelect: () => e.onSelect?.(e.component, n, l, "pointer"),
|
|
3100
|
-
onPreviewFrameMount: e.onPreviewFrameMount,
|
|
3101
|
-
previewUrl: t.previewUrl,
|
|
3102
|
-
size: t.displaySize,
|
|
3103
|
-
sessionId: t.sessionId,
|
|
3104
|
-
title: `${e.component.componentName} ${t.name} preview`,
|
|
3105
|
-
viewportPreset: e.viewportPreset
|
|
3106
|
-
}), t.frameState?.error ? /* @__PURE__ */ s("div", {
|
|
3107
|
-
style: {
|
|
3108
|
-
inset: 0,
|
|
3109
|
-
overflow: "auto",
|
|
3110
|
-
position: "absolute",
|
|
3111
|
-
zIndex: 2
|
|
3112
|
-
},
|
|
3113
|
-
children: /* @__PURE__ */ s(ji, {
|
|
3114
|
-
caseName: t.name,
|
|
3115
|
-
coordinate: e.component.coordinate,
|
|
3116
|
-
error: t.frameState.error,
|
|
3117
|
-
previewUrl: t.previewUrl
|
|
3118
|
-
})
|
|
3119
|
-
}) : null]
|
|
3120
|
-
})
|
|
3121
|
-
})]
|
|
3122
|
-
}, t.name))
|
|
3123
|
-
})]
|
|
3124
|
-
});
|
|
3125
|
-
}
|
|
3126
|
-
var Ni = a.memo(Mi, Pi);
|
|
3127
|
-
Ni.cases = { selectedReady: { props: {
|
|
3128
|
-
component: {
|
|
3129
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
3130
|
-
filePath: "src/UserCard.g.tsx",
|
|
3131
|
-
exportName: "default",
|
|
3132
|
-
componentName: "UserCard",
|
|
3133
|
-
mode: "scope",
|
|
3134
|
-
cases: [{
|
|
3135
|
-
kind: "scope",
|
|
3136
|
-
name: "ready"
|
|
3137
|
-
}],
|
|
3138
|
-
providers: {},
|
|
3139
|
-
diagnostics: []
|
|
3140
|
-
},
|
|
3141
|
-
frameState: {
|
|
3142
|
-
expectedSessionId: "src/UserCard.g.tsx#default:ready",
|
|
3143
|
-
ready: !0,
|
|
3144
|
-
tree: [{
|
|
3145
|
-
id: "root",
|
|
3146
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
3147
|
-
rect: {
|
|
3148
|
-
x: 10,
|
|
3149
|
-
y: 20,
|
|
3150
|
-
width: 320,
|
|
3151
|
-
height: 88
|
|
3152
|
-
},
|
|
3153
|
-
children: []
|
|
3154
|
-
}]
|
|
3155
|
-
},
|
|
3156
|
-
caseFrameStates: { ready: {
|
|
3157
|
-
expectedSessionId: "src/UserCard.g.tsx#default:ready",
|
|
3158
|
-
ready: !0,
|
|
3159
|
-
tree: [{
|
|
3160
|
-
id: "root",
|
|
3161
|
-
coordinate: "src/UserCard.g.tsx#default",
|
|
3162
|
-
rect: {
|
|
3163
|
-
x: 10,
|
|
3164
|
-
y: 20,
|
|
3165
|
-
width: 320,
|
|
3166
|
-
height: 88
|
|
3167
|
-
},
|
|
3168
|
-
children: []
|
|
3169
|
-
}]
|
|
3170
|
-
} },
|
|
3171
|
-
manifest: {
|
|
3172
|
-
version: 1,
|
|
3173
|
-
routes: {
|
|
3174
|
-
preview: "/gtsx",
|
|
3175
|
-
studio: "/gtsx/studio",
|
|
3176
|
-
manifest: "/gtsx/studio/manifest"
|
|
3177
|
-
},
|
|
3178
|
-
preview: {
|
|
3179
|
-
urlTemplate: "/gtsx?entry={entry}&case={case}{gcase}",
|
|
3180
|
-
allUrlTemplate: "/gtsx?entry={entry}{gcase}"
|
|
3181
|
-
},
|
|
3182
|
-
files: [],
|
|
3183
|
-
diagnostics: []
|
|
3184
|
-
},
|
|
3185
|
-
selected: !0,
|
|
3186
|
-
selectedCaseName: "ready",
|
|
3187
|
-
viewportPreset: "phone"
|
|
3188
|
-
} } };
|
|
3189
|
-
function Pi(e, t) {
|
|
3190
|
-
if (e.casePreviewScale !== t.casePreviewScale || e.columnIndex !== t.columnIndex || e.component !== t.component || e.debugPreviewPool !== t.debugPreviewPool || e.debugPreviewQueue !== t.debugPreviewQueue || e.frameState !== t.frameState || e.manifest !== t.manifest || e.onPreviewFrameMount !== t.onPreviewFrameMount || e.onSelect !== t.onSelect || e.selected !== t.selected || e.selectedCaseName !== t.selectedCaseName || e.viewportPreset !== t.viewportPreset) return !1;
|
|
3191
|
-
for (let n of t.component.cases) if (!Fi(e.caseFrameStates?.[n.name], t.caseFrameStates?.[n.name]) || !Fi(e.caseLayoutFrameStates?.[n.name], t.caseLayoutFrameStates?.[n.name])) return !1;
|
|
3192
|
-
return !0;
|
|
3193
|
-
}
|
|
3194
|
-
function Fi(e, t) {
|
|
3195
|
-
return e === t || e?.expectedSessionId === t?.expectedSessionId && e?.ready === t?.ready && e?.tree === t?.tree && e?.size?.height === t?.size?.height && e?.size?.width === t?.size?.width && e?.error?.message === t?.error?.message && e?.error?.stack === t?.error?.stack && e?.valuesByBoundaryId === t?.valuesByBoundaryId;
|
|
3196
|
-
}
|
|
3197
|
-
function Ii(e) {
|
|
3198
|
-
return e?.error ? "error" : e?.ready ? "ready" : "loading";
|
|
3199
|
-
}
|
|
3200
|
-
function Li(e, t) {
|
|
3201
|
-
return e ? zi(e, t)?.rect : void 0;
|
|
3202
|
-
}
|
|
3203
|
-
function Ri(e) {
|
|
3204
|
-
if (e.diagnostics.length > 0) return e.diagnostics.map((e) => e.code).join(", ");
|
|
3205
|
-
if (!e.cases[0]) return "missing-case";
|
|
3206
|
-
}
|
|
3207
|
-
function zi(e, t) {
|
|
3208
|
-
for (let n of e) {
|
|
3209
|
-
if (n.coordinate === t) return n;
|
|
3210
|
-
let e = zi(n.children, t);
|
|
3211
|
-
if (e) return e;
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
//#endregion
|
|
3215
|
-
//#region src/components/StudioComponentCardSlot.tsx
|
|
3216
|
-
var Bi = typeof window > "u" ? a.useEffect : a.useLayoutEffect;
|
|
3217
|
-
function Vi(e) {
|
|
3218
|
-
let t = a.useRef(e.onPreviewGeometryChange), n = a.useRef(e.onSelect);
|
|
3219
|
-
t.current = e.onPreviewGeometryChange, n.current = e.onSelect;
|
|
3220
|
-
let r = Wi({
|
|
3221
|
-
component: e.component,
|
|
3222
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
3223
|
-
viewportPreset: e.viewportPreset
|
|
3224
|
-
}), i = a.useMemo(() => Yn(e.component, e.viewportPreset, e.fallbackFrameStates, e.fallbackPreviewCache, e.previewGeometryStore), [
|
|
3225
|
-
e.component,
|
|
3226
|
-
e.fallbackFrameStates,
|
|
3227
|
-
e.fallbackPreviewCache,
|
|
3228
|
-
e.previewGeometryStore,
|
|
3229
|
-
e.viewportPreset,
|
|
3230
|
-
r
|
|
3231
|
-
]), o = a.useMemo(() => Jn(e.component, e.viewportPreset, e.fallbackFrameStates, e.fallbackPreviewCache, e.previewGeometryStore), [
|
|
3232
|
-
e.component,
|
|
3233
|
-
e.fallbackFrameStates,
|
|
3234
|
-
e.fallbackPreviewCache,
|
|
3235
|
-
e.previewGeometryStore,
|
|
3236
|
-
e.viewportPreset,
|
|
3237
|
-
r
|
|
3238
|
-
]), c = Gi(e.component, o), l = a.useCallback((e, t, r, i) => {
|
|
3239
|
-
n.current(e, t, r, i);
|
|
3240
|
-
}, []);
|
|
3241
|
-
return Bi(() => {
|
|
3242
|
-
t.current?.();
|
|
3243
|
-
}, [c]), /* @__PURE__ */ s(Ni, {
|
|
3244
|
-
caseFrameStates: i,
|
|
3245
|
-
caseLayoutFrameStates: o,
|
|
3246
|
-
casePreviewScale: e.casePreviewScale,
|
|
3247
|
-
columnIndex: e.columnIndex,
|
|
3248
|
-
component: e.component,
|
|
3249
|
-
debugPreviewPool: e.debugPreviewPool,
|
|
3250
|
-
debugPreviewQueue: e.debugPreviewQueue,
|
|
3251
|
-
manifest: e.manifest,
|
|
3252
|
-
onPreviewFrameMount: e.onPreviewFrameMount,
|
|
3253
|
-
onSelect: l,
|
|
3254
|
-
selected: e.selected,
|
|
3255
|
-
selectedCaseName: e.selectedCaseName,
|
|
3256
|
-
viewportPreset: e.viewportPreset
|
|
3257
|
-
});
|
|
3258
|
-
}
|
|
3259
|
-
var Hi = a.memo(Vi, Ui);
|
|
3260
|
-
function Ui(e, t) {
|
|
3261
|
-
return e.casePreviewScale === t.casePreviewScale && e.columnIndex === t.columnIndex && e.component === t.component && e.debugPreviewPool === t.debugPreviewPool && e.debugPreviewQueue === t.debugPreviewQueue && e.fallbackFrameStates === t.fallbackFrameStates && e.fallbackPreviewCache === t.fallbackPreviewCache && e.manifest === t.manifest && e.onPreviewGeometryChange === t.onPreviewGeometryChange && e.onPreviewFrameMount === t.onPreviewFrameMount && e.onSelect === t.onSelect && e.previewGeometryStore === t.previewGeometryStore && e.selected === t.selected && e.selectedCaseName === t.selectedCaseName && e.viewportPreset === t.viewportPreset;
|
|
3262
|
-
}
|
|
3263
|
-
function Wi(e) {
|
|
3264
|
-
let t = a.useMemo(() => e.previewGeometryStore ? ut({
|
|
3265
|
-
component: e.component,
|
|
3266
|
-
viewportPreset: e.viewportPreset
|
|
3267
|
-
}) : [], [
|
|
3268
|
-
e.component,
|
|
3269
|
-
e.previewGeometryStore,
|
|
3270
|
-
e.viewportPreset
|
|
3271
|
-
]);
|
|
3272
|
-
return a.useSyncExternalStore(a.useCallback((n) => e.previewGeometryStore?.subscribe(t, n) ?? (() => {}), [e.previewGeometryStore, t]), a.useCallback(() => e.previewGeometryStore?.getVersionForKeys(t) ?? "", [e.previewGeometryStore, t]), () => "");
|
|
3273
|
-
}
|
|
3274
|
-
function Gi(e, t) {
|
|
3275
|
-
return e.cases.map((e) => `${e.name}:${Ki(t[e.name])}`).join("|");
|
|
3276
|
-
}
|
|
3277
|
-
function Ki(e) {
|
|
3278
|
-
return e ? `${e.size ? `${e.size.width}x${e.size.height}` : "-"}:${qi(e.tree)}` : "pending";
|
|
3279
|
-
}
|
|
3280
|
-
function qi(e) {
|
|
3281
|
-
if (!e) return "-";
|
|
3282
|
-
let t = [], n = (e) => {
|
|
3283
|
-
let r = e.rect ? `${e.rect.x},${e.rect.y},${e.rect.width},${e.rect.height}` : "-";
|
|
3284
|
-
t.push(`${e.coordinate}@${r}`);
|
|
3285
|
-
for (let t of e.children) n(t);
|
|
3286
|
-
};
|
|
3287
|
-
for (let t of e) n(t);
|
|
3288
|
-
return t.join(";");
|
|
3289
|
-
}
|
|
3290
|
-
//#endregion
|
|
3291
|
-
//#region src/components/ViewportPresetTabs.g.tsx
|
|
3292
|
-
var Ji = [
|
|
3293
|
-
"phone",
|
|
3294
|
-
"tablet",
|
|
3295
|
-
"desktop"
|
|
3296
|
-
];
|
|
3297
|
-
function Yi(e) {
|
|
3298
|
-
let t = Math.max(0, Ji.indexOf(e.selectedPreset));
|
|
3299
|
-
return /* @__PURE__ */ c("div", {
|
|
3300
|
-
"aria-label": "Viewport",
|
|
3301
|
-
"data-gtsx-floating-viewport-controls": e.floating ? !0 : void 0,
|
|
3302
|
-
style: {
|
|
3303
|
-
background: "rgba(255,255,255,0.82)",
|
|
3304
|
-
border: "1px solid rgba(216,222,232,0.92)",
|
|
3305
|
-
borderRadius: 999,
|
|
3306
|
-
boxShadow: "0 10px 30px rgba(31,35,40,0.12)",
|
|
3307
|
-
display: "grid",
|
|
3308
|
-
gridTemplateColumns: `repeat(${Ji.length}, 34px)`,
|
|
3309
|
-
...e.floating ? {
|
|
3310
|
-
left: "50%",
|
|
3311
|
-
position: "absolute",
|
|
3312
|
-
top: 16,
|
|
3313
|
-
transform: "translateX(-50%)",
|
|
3314
|
-
zIndex: 3
|
|
3315
|
-
} : {},
|
|
3316
|
-
padding: 3,
|
|
3317
|
-
position: e.floating ? "absolute" : "relative",
|
|
3318
|
-
width: "max-content"
|
|
3319
|
-
},
|
|
3320
|
-
children: [/* @__PURE__ */ s("span", {
|
|
3321
|
-
"aria-hidden": "true",
|
|
3322
|
-
"data-gtsx-viewport-tab-highlight": e.floating ? !0 : void 0,
|
|
3323
|
-
style: {
|
|
3324
|
-
background: "#ffffff",
|
|
3325
|
-
border: "1px solid #d8dee8",
|
|
3326
|
-
borderRadius: 999,
|
|
3327
|
-
boxShadow: "0 3px 10px rgba(31,35,40,0.12)",
|
|
3328
|
-
height: 28,
|
|
3329
|
-
left: 3,
|
|
3330
|
-
position: "absolute",
|
|
3331
|
-
top: 3,
|
|
3332
|
-
transform: `translateX(${t * 34}px)`,
|
|
3333
|
-
transition: "transform 120ms ease",
|
|
3334
|
-
width: 32
|
|
3335
|
-
}
|
|
3336
|
-
}), Ji.map((t) => /* @__PURE__ */ s("button", {
|
|
3337
|
-
"aria-label": `Viewport ${t}`,
|
|
3338
|
-
"data-gtsx-viewport-control": t,
|
|
3339
|
-
onClick: () => e.onChange?.(t),
|
|
3340
|
-
style: {
|
|
3341
|
-
alignItems: "center",
|
|
3342
|
-
background: "transparent",
|
|
3343
|
-
border: 0,
|
|
3344
|
-
color: e.selectedPreset === t ? "#0969da" : "#57606a",
|
|
3345
|
-
cursor: e.onChange ? "pointer" : "default",
|
|
3346
|
-
display: "grid",
|
|
3347
|
-
height: 28,
|
|
3348
|
-
justifyItems: "center",
|
|
3349
|
-
padding: 0,
|
|
3350
|
-
position: "relative",
|
|
3351
|
-
width: 32,
|
|
3352
|
-
zIndex: 1
|
|
3353
|
-
},
|
|
3354
|
-
title: t,
|
|
3355
|
-
type: "button",
|
|
3356
|
-
children: /* @__PURE__ */ s(Zi, { preset: t })
|
|
3357
|
-
}, t))]
|
|
3358
|
-
});
|
|
3359
|
-
}
|
|
3360
|
-
var Xi = i("src/components/ViewportPresetTabs.g.tsx#default", Yi);
|
|
3361
|
-
Xi.cases = {
|
|
3362
|
-
tabletSelected: { props: { selectedPreset: "tablet" } },
|
|
3363
|
-
floatingPhoneSelected: { props: {
|
|
3364
|
-
floating: !0,
|
|
3365
|
-
selectedPreset: "phone"
|
|
3366
|
-
} }
|
|
3367
|
-
};
|
|
3368
|
-
function Zi(e) {
|
|
3369
|
-
return e.preset === "phone" ? /* @__PURE__ */ s("span", {
|
|
3370
|
-
"aria-hidden": "true",
|
|
3371
|
-
style: {
|
|
3372
|
-
border: "1.5px solid currentColor",
|
|
3373
|
-
borderRadius: 3,
|
|
3374
|
-
height: 16,
|
|
3375
|
-
width: 9
|
|
3376
|
-
}
|
|
3377
|
-
}) : e.preset === "tablet" ? /* @__PURE__ */ s("span", {
|
|
3378
|
-
"aria-hidden": "true",
|
|
3379
|
-
style: {
|
|
3380
|
-
border: "1.5px solid currentColor",
|
|
3381
|
-
borderRadius: 3,
|
|
3382
|
-
height: 15,
|
|
3383
|
-
width: 12
|
|
3384
|
-
}
|
|
3385
|
-
}) : /* @__PURE__ */ s("span", {
|
|
3386
|
-
"aria-hidden": "true",
|
|
3387
|
-
style: {
|
|
3388
|
-
border: "1.5px solid currentColor",
|
|
3389
|
-
borderRadius: 2,
|
|
3390
|
-
height: 11,
|
|
3391
|
-
width: 18
|
|
3392
|
-
}
|
|
3393
|
-
});
|
|
3394
|
-
}
|
|
3395
|
-
//#endregion
|
|
3396
|
-
//#region src/components/StudioWorkspaceView.g.tsx
|
|
3397
|
-
var Qi = typeof window > "u" ? a.useEffect : a.useLayoutEffect, $i = "[data-gtsx-canvas-wheel-exempt]", ea = 24;
|
|
3398
|
-
function ta(e) {
|
|
3399
|
-
return !(typeof Element < "u" && e instanceof Element && e.closest($i));
|
|
3400
|
-
}
|
|
3401
|
-
function na(e) {
|
|
3402
|
-
return typeof Element > "u" || !(e instanceof Element) || !e.closest("a,button,iframe");
|
|
3403
|
-
}
|
|
3404
|
-
function ra(e) {
|
|
3405
|
-
let t = U(e.manifest, e.selection), [n, r] = a.useState(), i = I(e.workspace), o = a.useMemo(() => Bn(), []), s = a.useRef(i), c = a.useRef(e.frameStates), l = a.useRef(() => {}), u = a.useRef(() => {}), [d, f] = a.useState(), [p, m] = a.useState(), h = a.useRef(e.onSelectComponent), g = a.useRef(hr({ now: () => typeof performance < "u" ? performance.now() : Date.now() })), _ = a.useRef(e.previewRenderQueue), v = a.useRef(() => {}), y = a.useRef(e.workspace);
|
|
3406
|
-
s.current = i, c.current = e.frameStates, h.current = e.onSelectComponent, _.current = e.previewRenderQueue, y.current = e.workspace;
|
|
3407
|
-
let b = Cr({
|
|
3408
|
-
canvas: e.canvas,
|
|
3409
|
-
onCanvasChange: e.onChangeCanvas,
|
|
3410
|
-
onCanvasMove(e) {
|
|
3411
|
-
v.current(e);
|
|
3412
|
-
},
|
|
3413
|
-
onCanvasPanEnd() {
|
|
3414
|
-
l.current(void 0, { includeBuffer: !0 });
|
|
3415
|
-
},
|
|
3416
|
-
shouldHandleWheelTarget: ta
|
|
3417
|
-
}), x = a.useCallback(() => {
|
|
3418
|
-
u.current(b.canvasRef.current);
|
|
3419
|
-
}, [b.canvasRef]), S = jr({
|
|
3420
|
-
canvasRef: b.canvasRef,
|
|
3421
|
-
canvasSurfaceElement: b.canvasSurfaceElement,
|
|
3422
|
-
canvasViewportPreset: i,
|
|
3423
|
-
frameStates: e.frameStates,
|
|
3424
|
-
onLayoutMeasured: x,
|
|
3425
|
-
previewCache: e.previewCache,
|
|
3426
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
3427
|
-
workspace: e.workspace
|
|
3428
|
-
}), { flushPreviewRender: C, requestCanvasPreviewRender: w, requestPreviewRender: T } = ni({
|
|
3429
|
-
canvasRef: b.canvasRef,
|
|
3430
|
-
canvasViewportElement: b.canvasViewportElement,
|
|
3431
|
-
canvasViewportPresetRef: s,
|
|
3432
|
-
columnLayoutByIndexRef: S.columnLayoutByIndexRef,
|
|
3433
|
-
columnMeasurementsByIndexRef: S.columnMeasurementsByIndexRef,
|
|
3434
|
-
frameStatesRef: c,
|
|
3435
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
3436
|
-
previewRenderQueueRef: _,
|
|
3437
|
-
previewRenderSessionStore: o,
|
|
3438
|
-
workspaceRef: y
|
|
3439
|
-
});
|
|
3440
|
-
l.current = C, u.current = T, v.current = w, Qi(() => {
|
|
3441
|
-
T(b.canvasRef.current);
|
|
3442
|
-
}, [b.canvasViewportElement, T]), a.useEffect(() => {
|
|
3443
|
-
T(b.canvasRef.current);
|
|
3444
|
-
}, [
|
|
3445
|
-
i,
|
|
3446
|
-
S.layoutMeasurementKey,
|
|
3447
|
-
T
|
|
3448
|
-
]), a.useEffect(() => {
|
|
3449
|
-
e.previewGeometryStore || T(b.canvasRef.current);
|
|
3450
|
-
}, [
|
|
3451
|
-
e.frameStates,
|
|
3452
|
-
e.previewGeometryStore,
|
|
3453
|
-
T
|
|
3454
|
-
]), a.useEffect(() => {
|
|
3455
|
-
if (!e.debugPreviewQueue || typeof window > "u") return;
|
|
3456
|
-
let t = g.current, n = 0, r = (e) => {
|
|
3457
|
-
m(e), document.documentElement.setAttribute("data-gtsx-preview-render-observation", JSON.stringify(e)), window.dispatchEvent(new CustomEvent("gtsx:preview-render-observation", { detail: e }));
|
|
3458
|
-
}, i = () => {
|
|
3459
|
-
n = 0, f(void 0);
|
|
3460
|
-
}, a = (e) => {
|
|
3461
|
-
let a = e.detail;
|
|
3462
|
-
r(t.observeQueueRun(a)), !(!a?.showRenderExpansionCenterPulse || !a.renderExpansionCenterViewportPoint) && (n && window.clearTimeout(n), f({
|
|
3463
|
-
id: Date.now(),
|
|
3464
|
-
x: a.renderExpansionCenterViewportPoint.x,
|
|
3465
|
-
y: a.renderExpansionCenterViewportPoint.y
|
|
3466
|
-
}), n = window.setTimeout(i, 650));
|
|
3467
|
-
}, o = (e) => {
|
|
3468
|
-
let n = e.detail;
|
|
3469
|
-
!n?.sessionId || n.type !== "gtsx:ready" && n.type !== "gtsx:error" || r(t.observePreviewTiming({
|
|
3470
|
-
sessionId: n.sessionId,
|
|
3471
|
-
type: n.type
|
|
3472
|
-
}));
|
|
3473
|
-
};
|
|
3474
|
-
return window.addEventListener("gtsx:preview-queue-debug", a), window.addEventListener("gtsx:preview-timing", o), () => {
|
|
3475
|
-
window.removeEventListener("gtsx:preview-queue-debug", a), window.removeEventListener("gtsx:preview-timing", o), document.documentElement.removeAttribute("data-gtsx-preview-render-observation"), n && window.clearTimeout(n);
|
|
3476
|
-
};
|
|
3477
|
-
}, [e.debugPreviewQueue]), a.useEffect(() => {
|
|
3478
|
-
r(void 0);
|
|
3479
|
-
}, [e.selection]);
|
|
3480
|
-
let E = a.useCallback((e, t, n = {}) => {
|
|
3481
|
-
if (!b.canvasViewportElement) return;
|
|
3482
|
-
let r = S.getCardElement(e, t);
|
|
3483
|
-
if (!r) return;
|
|
3484
|
-
let i = b.canvasRef.current, a = Oe(i, {
|
|
3485
|
-
margin: ea,
|
|
3486
|
-
rect: Xn(r.getBoundingClientRect()),
|
|
3487
|
-
viewportRect: Xn(b.canvasViewportElement.getBoundingClientRect())
|
|
3488
|
-
}), o = n.preserveVerticalCanvasPosition ? {
|
|
3489
|
-
...a,
|
|
3490
|
-
y: i.y
|
|
3491
|
-
} : a;
|
|
3492
|
-
o !== i && b.moveCanvas(() => o);
|
|
3493
|
-
}, [b, S.getCardElement]), D = a.useCallback((e, t, n = {}) => {
|
|
3494
|
-
E(e, t, n), !(typeof window > "u") && window.requestAnimationFrame(() => E(e, t, n));
|
|
3495
|
-
}, [E]), O = a.useCallback((e, t, n, i) => {
|
|
3496
|
-
let a = er($n(y.current, n, e.coordinate));
|
|
3497
|
-
r((t) => Ae(t === a ? e.coordinate : void 0, {
|
|
3498
|
-
type: "activate-card",
|
|
3499
|
-
coordinate: e.coordinate,
|
|
3500
|
-
source: i
|
|
3501
|
-
}) ? a : void 0), h.current?.(e, t, { columnIndex: n }), D(n, e.coordinate, { preserveVerticalCanvasPosition: i === "pointer" });
|
|
3502
|
-
}, [D]);
|
|
3503
|
-
return {
|
|
3504
|
-
canvas: b.canvas,
|
|
3505
|
-
canvasViewportPreset: i,
|
|
3506
|
-
columnLayoutByIndex: S.columnLayoutByIndex,
|
|
3507
|
-
onCanvasPointerCancel: b.onCanvasPointerCancel,
|
|
3508
|
-
onCanvasPointerDown(e) {
|
|
3509
|
-
na(e.target) && r(void 0), b.onCanvasPointerDown(e);
|
|
3510
|
-
},
|
|
3511
|
-
onCanvasPointerMove: b.onCanvasPointerMove,
|
|
3512
|
-
onCanvasPointerUp: b.onCanvasPointerUp,
|
|
3513
|
-
onChangeSelection: e.onChangeSelection ? (t) => {
|
|
3514
|
-
r(void 0), e.onChangeSelection?.(t);
|
|
3515
|
-
} : void 0,
|
|
3516
|
-
onSelectCard: O,
|
|
3517
|
-
onPreviewGeometryChange: S.scheduleMeasurement,
|
|
3518
|
-
onViewportPresetChange(t) {
|
|
3519
|
-
if (e.onChangeCanvasViewportPreset) e.onChangeCanvasViewportPreset(t);
|
|
3520
|
-
else for (let n of ze(e.workspace)) e.onChangeViewportPreset?.(n, t);
|
|
3521
|
-
},
|
|
3522
|
-
casePreviewScale: S.casePreviewScale,
|
|
3523
|
-
renderObservationSnapshot: p,
|
|
3524
|
-
renderExpansionCenterPulse: d,
|
|
3525
|
-
previewRenderSessionStore: o,
|
|
3526
|
-
selected: t,
|
|
3527
|
-
selectedCardPathKey: n,
|
|
3528
|
-
setCanvasSurfaceElement: b.setCanvasSurfaceElement,
|
|
3529
|
-
setCanvasViewportElement: b.setCanvasViewportElement,
|
|
3530
|
-
setCardElement: S.setCardElement,
|
|
3531
|
-
setColumnElement: S.setColumnElement
|
|
3532
|
-
};
|
|
3533
|
-
}
|
|
3534
|
-
var ia = r(ra);
|
|
3535
|
-
function aa(e) {
|
|
3536
|
-
let t = ia(e), n = e.previewCacheReady ?? !0, r = typeof window > "u" ? Qn(t.canvas) : void 0;
|
|
3537
|
-
return /* @__PURE__ */ s(Hn, {
|
|
3538
|
-
store: t.previewRenderSessionStore,
|
|
3539
|
-
children: /* @__PURE__ */ s("main", {
|
|
3540
|
-
style: {
|
|
3541
|
-
display: "grid",
|
|
3542
|
-
height: "100vh",
|
|
3543
|
-
overflow: "hidden",
|
|
3544
|
-
background: "#f5f6f8",
|
|
3545
|
-
color: "#1f2328",
|
|
3546
|
-
fontFamily: "ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif"
|
|
3547
|
-
},
|
|
3548
|
-
children: /* @__PURE__ */ s("section", {
|
|
3549
|
-
style: {
|
|
3550
|
-
display: "grid",
|
|
3551
|
-
minHeight: 0,
|
|
3552
|
-
minWidth: 0
|
|
3553
|
-
},
|
|
3554
|
-
children: /* @__PURE__ */ c("div", {
|
|
3555
|
-
"aria-label": "GTSX Studio canvas viewport",
|
|
3556
|
-
"data-gtsx-canvas-viewport": !0,
|
|
3557
|
-
onPointerDown: t.onCanvasPointerDown,
|
|
3558
|
-
onPointerMove: t.onCanvasPointerMove,
|
|
3559
|
-
onPointerUp: t.onCanvasPointerUp,
|
|
3560
|
-
onPointerCancel: t.onCanvasPointerCancel,
|
|
3561
|
-
ref: t.setCanvasViewportElement,
|
|
3562
|
-
"aria-busy": n ? void 0 : !0,
|
|
3563
|
-
style: {
|
|
3564
|
-
backgroundColor: "#f5f6f8",
|
|
3565
|
-
backgroundImage: "radial-gradient(circle at 1px 1px, rgba(31,35,40,0.10) 1px, transparent 0)",
|
|
3566
|
-
backgroundSize: "24px 24px",
|
|
3567
|
-
cursor: "grab",
|
|
3568
|
-
height: "100%",
|
|
3569
|
-
minHeight: 0,
|
|
3570
|
-
overscrollBehavior: "none",
|
|
3571
|
-
overflow: "hidden",
|
|
3572
|
-
position: "relative",
|
|
3573
|
-
touchAction: "none"
|
|
3574
|
-
},
|
|
3575
|
-
role: "application",
|
|
3576
|
-
tabIndex: 0,
|
|
3577
|
-
children: [
|
|
3578
|
-
/* @__PURE__ */ s(Xi, {
|
|
3579
|
-
floating: !0,
|
|
3580
|
-
onChange: t.onViewportPresetChange,
|
|
3581
|
-
selectedPreset: t.canvasViewportPreset
|
|
3582
|
-
}),
|
|
3583
|
-
t.renderExpansionCenterPulse ? /* @__PURE__ */ s("span", {
|
|
3584
|
-
"aria-label": "Preview render expansion center",
|
|
3585
|
-
"data-gtsx-preview-render-expansion-center-pulse": "true",
|
|
3586
|
-
style: {
|
|
3587
|
-
background: "rgba(13,153,255,0.24)",
|
|
3588
|
-
border: "2px solid #0d99ff",
|
|
3589
|
-
borderRadius: 999,
|
|
3590
|
-
boxShadow: "0 0 0 6px rgba(13,153,255,0.14)",
|
|
3591
|
-
height: 18,
|
|
3592
|
-
left: t.renderExpansionCenterPulse.x,
|
|
3593
|
-
pointerEvents: "none",
|
|
3594
|
-
position: "absolute",
|
|
3595
|
-
top: t.renderExpansionCenterPulse.y,
|
|
3596
|
-
transform: "translate(-50%, -50%)",
|
|
3597
|
-
width: 18,
|
|
3598
|
-
zIndex: 4
|
|
3599
|
-
}
|
|
3600
|
-
}, t.renderExpansionCenterPulse.id) : null,
|
|
3601
|
-
e.urlWarning ? /* @__PURE__ */ s("p", {
|
|
3602
|
-
role: "status",
|
|
3603
|
-
style: {
|
|
3604
|
-
background: "#fff8c5",
|
|
3605
|
-
border: "1px solid #d4a72c",
|
|
3606
|
-
borderRadius: 8,
|
|
3607
|
-
color: "#5a1e02",
|
|
3608
|
-
fontSize: 12,
|
|
3609
|
-
left: 16,
|
|
3610
|
-
lineHeight: 1.45,
|
|
3611
|
-
margin: 0,
|
|
3612
|
-
maxWidth: 280,
|
|
3613
|
-
padding: "8px 10px",
|
|
3614
|
-
position: "absolute",
|
|
3615
|
-
top: 16,
|
|
3616
|
-
zIndex: 3
|
|
3617
|
-
},
|
|
3618
|
-
children: e.urlWarning
|
|
3619
|
-
}) : null,
|
|
3620
|
-
e.debugPreviewQueue && t.renderObservationSnapshot ? /* @__PURE__ */ s(sa, { snapshot: t.renderObservationSnapshot }) : null,
|
|
3621
|
-
n ? /* @__PURE__ */ s("div", {
|
|
3622
|
-
"data-gtsx-canvas-surface": !0,
|
|
3623
|
-
ref: t.setCanvasSurfaceElement,
|
|
3624
|
-
style: {
|
|
3625
|
-
display: "block",
|
|
3626
|
-
left: 0,
|
|
3627
|
-
padding: "0 80px 80px 0",
|
|
3628
|
-
position: "absolute",
|
|
3629
|
-
top: 0,
|
|
3630
|
-
...r ? { transform: r } : {},
|
|
3631
|
-
transformOrigin: "0 0"
|
|
3632
|
-
},
|
|
3633
|
-
children: e.workspace.columns.map((n, r) => /* @__PURE__ */ s("section", {
|
|
3634
|
-
"data-gtsx-column-index": r,
|
|
3635
|
-
"data-gtsx-column-layout-x": t.columnLayoutByIndex[r]?.x ?? 0,
|
|
3636
|
-
"data-gtsx-column-layout-y": t.columnLayoutByIndex[r]?.y ?? 0,
|
|
3637
|
-
"data-gtsx-column-parent-coordinate": n.parentCoordinate,
|
|
3638
|
-
ref: (e) => t.setColumnElement(r, e),
|
|
3639
|
-
style: {
|
|
3640
|
-
display: "grid",
|
|
3641
|
-
gap: 10,
|
|
3642
|
-
left: t.columnLayoutByIndex[r]?.x ?? 0,
|
|
3643
|
-
position: "absolute",
|
|
3644
|
-
top: t.columnLayoutByIndex[r]?.y ?? 0,
|
|
3645
|
-
width: "max-content"
|
|
3646
|
-
},
|
|
3647
|
-
children: n.components.map((n) => {
|
|
3648
|
-
let i = er($n(e.workspace, r, n.coordinate));
|
|
3649
|
-
return /* @__PURE__ */ s("div", {
|
|
3650
|
-
ref: (e) => t.setCardElement(r, n.coordinate, e),
|
|
3651
|
-
style: {
|
|
3652
|
-
display: "grid",
|
|
3653
|
-
justifySelf: "start",
|
|
3654
|
-
width: "max-content"
|
|
3655
|
-
},
|
|
3656
|
-
children: /* @__PURE__ */ s(Hi, {
|
|
3657
|
-
casePreviewScale: t.casePreviewScale,
|
|
3658
|
-
columnIndex: r,
|
|
3659
|
-
component: n,
|
|
3660
|
-
debugPreviewPool: e.debugPreviewPool,
|
|
3661
|
-
debugPreviewQueue: e.debugPreviewQueue,
|
|
3662
|
-
fallbackFrameStates: e.frameStates,
|
|
3663
|
-
fallbackPreviewCache: e.previewCache,
|
|
3664
|
-
manifest: e.manifest,
|
|
3665
|
-
onPreviewFrameMount: e.onPreviewFrameMount,
|
|
3666
|
-
onPreviewGeometryChange: t.onPreviewGeometryChange,
|
|
3667
|
-
onSelect: t.onSelectCard,
|
|
3668
|
-
previewGeometryStore: e.previewGeometryStore,
|
|
3669
|
-
selected: t.selectedCardPathKey === i,
|
|
3670
|
-
selectedCaseName: E(e.workspace, n),
|
|
3671
|
-
viewportPreset: t.canvasViewportPreset
|
|
3672
|
-
})
|
|
3673
|
-
}, n.coordinate);
|
|
3674
|
-
})
|
|
3675
|
-
}, r))
|
|
3676
|
-
}) : null
|
|
3677
|
-
]
|
|
3678
|
-
})
|
|
3679
|
-
})
|
|
3680
|
-
})
|
|
3681
|
-
});
|
|
3682
|
-
}
|
|
3683
|
-
var oa = i("src/components/StudioWorkspaceView.g.tsx#default", aa);
|
|
3684
|
-
function sa(e) {
|
|
3685
|
-
let t = e.snapshot.scrollResponse, n = e.snapshot.fullRender;
|
|
3686
|
-
return /* @__PURE__ */ c("aside", {
|
|
3687
|
-
"aria-label": "Preview render observation",
|
|
3688
|
-
"data-gtsx-preview-render-observation-panel": "true",
|
|
3689
|
-
style: {
|
|
3690
|
-
background: "rgba(255,255,255,0.92)",
|
|
3691
|
-
border: "1px solid rgba(216,222,228,0.95)",
|
|
3692
|
-
borderRadius: 6,
|
|
3693
|
-
bottom: 12,
|
|
3694
|
-
boxShadow: "0 3px 12px rgba(31,35,40,0.14)",
|
|
3695
|
-
color: "#1f2328",
|
|
3696
|
-
display: "grid",
|
|
3697
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
3698
|
-
fontSize: 11,
|
|
3699
|
-
gap: 3,
|
|
3700
|
-
left: 12,
|
|
3701
|
-
lineHeight: 1.35,
|
|
3702
|
-
padding: "7px 9px",
|
|
3703
|
-
pointerEvents: "none",
|
|
3704
|
-
position: "absolute",
|
|
3705
|
-
zIndex: 5
|
|
3706
|
-
},
|
|
3707
|
-
children: [/* @__PURE__ */ c("span", {
|
|
3708
|
-
"data-gtsx-preview-render-observation-scroll": "true",
|
|
3709
|
-
children: [
|
|
3710
|
-
"scroll",
|
|
3711
|
-
" ",
|
|
3712
|
-
t ? `${ca(t.firstVisibleCompletionMilliseconds)} ${t.completedVisibleSessionCount}/${t.visibleSessionCount}` : "idle"
|
|
3713
|
-
]
|
|
3714
|
-
}), /* @__PURE__ */ c("span", {
|
|
3715
|
-
"data-gtsx-preview-render-observation-full": "true",
|
|
3716
|
-
children: [
|
|
3717
|
-
"full",
|
|
3718
|
-
" ",
|
|
3719
|
-
n ? `${ca(n.latestCompletionMilliseconds)} ${n.completedSessionCount}/${n.sessionCount} ${la(n.renderCompletionsPerSecond)}` : "idle"
|
|
3720
|
-
]
|
|
3721
|
-
})]
|
|
3722
|
-
});
|
|
3723
|
-
}
|
|
3724
|
-
function ca(e) {
|
|
3725
|
-
return typeof e == "number" ? `${e}ms` : "...";
|
|
3726
|
-
}
|
|
3727
|
-
function la(e) {
|
|
3728
|
-
return typeof e == "number" ? `${e}/s` : ".../s";
|
|
3729
|
-
}
|
|
3730
|
-
oa.cases = { multiExportFile: {
|
|
3731
|
-
props: {
|
|
3732
|
-
manifest: {
|
|
3733
|
-
version: 1,
|
|
3734
|
-
routes: {
|
|
3735
|
-
preview: "/gtsx",
|
|
3736
|
-
studio: "/gtsx/studio",
|
|
3737
|
-
manifest: "/gtsx/studio/manifest"
|
|
3738
|
-
},
|
|
3739
|
-
preview: {
|
|
3740
|
-
urlTemplate: "/gtsx?entry={entry}&case={case}{gcase}",
|
|
3741
|
-
allUrlTemplate: "/gtsx?entry={entry}{gcase}"
|
|
3742
|
-
},
|
|
3743
|
-
files: [{
|
|
3744
|
-
path: "src/MultiExport.g.tsx",
|
|
3745
|
-
groupId: "file:src/MultiExport.g.tsx",
|
|
3746
|
-
components: [{
|
|
3747
|
-
coordinate: "src/MultiExport.g.tsx#NamedBadge",
|
|
3748
|
-
filePath: "src/MultiExport.g.tsx",
|
|
3749
|
-
exportName: "NamedBadge",
|
|
3750
|
-
componentName: "NamedBadge",
|
|
3751
|
-
mode: "pure",
|
|
3752
|
-
cases: [{
|
|
3753
|
-
kind: "pure",
|
|
3754
|
-
name: "ready"
|
|
3755
|
-
}],
|
|
3756
|
-
providers: {},
|
|
3757
|
-
diagnostics: []
|
|
3758
|
-
}],
|
|
3759
|
-
diagnostics: []
|
|
3760
|
-
}],
|
|
3761
|
-
diagnostics: []
|
|
3762
|
-
},
|
|
3763
|
-
workspace: {
|
|
3764
|
-
canvasViewportPreset: "tablet",
|
|
3765
|
-
columns: [{ components: [{
|
|
3766
|
-
coordinate: "src/MultiExport.g.tsx#NamedBadge",
|
|
3767
|
-
filePath: "src/MultiExport.g.tsx",
|
|
3768
|
-
exportName: "NamedBadge",
|
|
3769
|
-
componentName: "NamedBadge",
|
|
3770
|
-
mode: "pure",
|
|
3771
|
-
cases: [{
|
|
3772
|
-
kind: "pure",
|
|
3773
|
-
name: "ready"
|
|
3774
|
-
}],
|
|
3775
|
-
providers: {},
|
|
3776
|
-
diagnostics: []
|
|
3777
|
-
}] }],
|
|
3778
|
-
selectedCaseByCoordinate: {},
|
|
3779
|
-
selectedCoordinatePath: [],
|
|
3780
|
-
selectedRuntimeInstanceByCoordinate: {},
|
|
3781
|
-
selectedViewportPresetByCoordinate: {}
|
|
3782
|
-
}
|
|
3783
|
-
},
|
|
3784
|
-
scope: {
|
|
3785
|
-
canvas: {
|
|
3786
|
-
x: 40,
|
|
3787
|
-
y: 40,
|
|
3788
|
-
scale: 1
|
|
3789
|
-
},
|
|
3790
|
-
canvasViewportPreset: "tablet",
|
|
3791
|
-
casePreviewScale: 1,
|
|
3792
|
-
columnLayoutByIndex: {},
|
|
3793
|
-
onCanvasPointerCancel() {},
|
|
3794
|
-
onCanvasPointerDown() {},
|
|
3795
|
-
onCanvasPointerMove() {},
|
|
3796
|
-
onCanvasPointerUp() {},
|
|
3797
|
-
onPreviewGeometryChange() {},
|
|
3798
|
-
onSelectCard() {},
|
|
3799
|
-
onViewportPresetChange() {},
|
|
3800
|
-
previewRenderSessionStore: Bn(),
|
|
3801
|
-
selected: {
|
|
3802
|
-
id: "file:src/MultiExport.g.tsx",
|
|
3803
|
-
components: []
|
|
3804
|
-
},
|
|
3805
|
-
setCanvasSurfaceElement() {},
|
|
3806
|
-
setCanvasViewportElement() {},
|
|
3807
|
-
setCardElement() {},
|
|
3808
|
-
setColumnElement() {}
|
|
3809
|
-
}
|
|
3810
|
-
} };
|
|
3811
|
-
//#endregion
|
|
3812
|
-
//#region src/components/StudioShell.tsx
|
|
3813
|
-
var ua = 120, da = typeof window > "u" ? a.useEffect : a.useLayoutEffect;
|
|
3814
|
-
function fa(e) {
|
|
3815
|
-
let t = a.useMemo(() => pe(e.selection, e.urlSearch), [e.selection, e.urlSearch]), n = a.useMemo(() => j(e.manifest, t), [t, e.manifest]), r = a.useMemo(() => _e(t), [t]), i = a.useMemo(() => ve(t), [t]), o = a.useMemo(() => ye(t), [t]), s = a.useMemo(() => ({
|
|
3816
|
-
...Pt(t),
|
|
3817
|
-
...e.previewRenderQueue
|
|
3818
|
-
}), [t, e.previewRenderQueue]), [c, l] = a.useState(n.selection), u = pa(n.canvas), [d, f] = a.useState(n.warning), [p, m] = a.useState(n.workspace), h = a.useRef(/* @__PURE__ */ new Map()), g = a.useRef(/* @__PURE__ */ new Map()), _ = a.useMemo(() => Ue(p), [p]), v = a.useMemo(() => We(e.manifest, p), [e.manifest, p]), y = a.useMemo(() => Ze(e.manifest), [e.manifest]), b = a.useMemo(() => ct(e.manifest), [e.manifest]), x = a.useMemo(() => lt({
|
|
3819
|
-
cacheKeys: b,
|
|
3820
|
-
namespace: y
|
|
3821
|
-
}), [y, b]), S = ha(e.manifest), [C, T] = a.useState(!0), E = a.useMemo(() => new Map(v.map((e) => [e.sessionId, e])), [v]), D = a.useRef(c);
|
|
3822
|
-
a.useEffect(() => {
|
|
3823
|
-
D.current = c;
|
|
3824
|
-
}, [c]), a.useEffect(() => {
|
|
3825
|
-
x.reset();
|
|
3826
|
-
}, [x]), da(() => {
|
|
3827
|
-
let e = !1;
|
|
3828
|
-
return T(S ? x.cacheKeys.length === 0 : !0), x.hydrate().then(() => {
|
|
3829
|
-
e || S && T(!0);
|
|
3830
|
-
}), () => {
|
|
3831
|
-
e = !0;
|
|
3832
|
-
};
|
|
3833
|
-
}, [x, S]), a.useEffect(() => {
|
|
3834
|
-
let e = [], t = 0, n = () => {
|
|
3835
|
-
t = 0;
|
|
3836
|
-
let n = e;
|
|
3837
|
-
e = [], n.length !== 0 && a.startTransition(() => {
|
|
3838
|
-
let e = Fn({
|
|
3839
|
-
getFrameState: x.getFrameState,
|
|
3840
|
-
messages: n
|
|
3841
|
-
});
|
|
3842
|
-
if (e.messagesToApply.length === 0) return;
|
|
3843
|
-
let t = x.putMessages(e.messagesToApply, _);
|
|
3844
|
-
for (let t of e.completionMessages) ga(t.target, t.message, t.mountedAt);
|
|
3845
|
-
t.changed && x.writeEntries(t.entriesToWrite);
|
|
3846
|
-
});
|
|
3847
|
-
}, r = () => {
|
|
3848
|
-
t ||= window.requestAnimationFrame(n);
|
|
3849
|
-
}, i = (t) => {
|
|
3850
|
-
let n = t.data;
|
|
3851
|
-
if (!Ke(n)) return;
|
|
3852
|
-
let i = E.get(n.sessionId);
|
|
3853
|
-
i && (e.push({
|
|
3854
|
-
message: n,
|
|
3855
|
-
mountedAt: g.current.get(n.sessionId),
|
|
3856
|
-
target: i
|
|
3857
|
-
}), r());
|
|
3858
|
-
};
|
|
3859
|
-
return window.addEventListener("message", i), () => {
|
|
3860
|
-
window.removeEventListener("message", i), t && window.cancelAnimationFrame(t);
|
|
3861
|
-
};
|
|
3862
|
-
}, [
|
|
3863
|
-
x,
|
|
3864
|
-
_,
|
|
3865
|
-
E
|
|
3866
|
-
]), a.useEffect(() => {
|
|
3867
|
-
let t = () => {
|
|
3868
|
-
let t = j(e.manifest, new URLSearchParams(window.location.search));
|
|
3869
|
-
u.restoreCanvasFromUrl(t.canvas), l(t.selection), f(t.warning), m(t.workspace);
|
|
3870
|
-
};
|
|
3871
|
-
return window.addEventListener("popstate", t), () => window.removeEventListener("popstate", t);
|
|
3872
|
-
}, [u, e.manifest]);
|
|
3873
|
-
let O = a.useCallback((e) => {
|
|
3874
|
-
m((t) => {
|
|
3875
|
-
let n = e(t);
|
|
3876
|
-
return ge(D.current, n, { canvas: u.liveCanvasRef.current }), n;
|
|
3877
|
-
});
|
|
3878
|
-
}, [u.liveCanvasRef]), A = a.useCallback((e, t, n) => {
|
|
3879
|
-
t ? (h.current.set(e, t), g.current.set(e, performance.now()), n?.retainedRender || x.markSessionRenderStarted(e)) : (h.current.delete(e), g.current.delete(e));
|
|
3880
|
-
}, [x]);
|
|
3881
|
-
return {
|
|
3882
|
-
canvas: u.restoredCanvas,
|
|
3883
|
-
debugPreviewPool: r,
|
|
3884
|
-
debugPreviewQueue: i,
|
|
3885
|
-
disablePreviewPool: o,
|
|
3886
|
-
onChangeCanvas: u.commitLiveCanvasChange,
|
|
3887
|
-
onChangeCanvasViewportPreset(e) {
|
|
3888
|
-
O((t) => k(t, e));
|
|
3889
|
-
},
|
|
3890
|
-
onChangeSelection(t) {
|
|
3891
|
-
let n = new URLSearchParams();
|
|
3892
|
-
n.set("selection", t);
|
|
3893
|
-
let r = I(p);
|
|
3894
|
-
r !== "tablet" && n.set("canvasViewport", r);
|
|
3895
|
-
let i = j(e.manifest, n);
|
|
3896
|
-
D.current = i.selection, l(i.selection), f(i.warning), m(i.workspace), ge(i.selection, i.workspace, { canvas: u.liveCanvasRef.current });
|
|
3897
|
-
},
|
|
3898
|
-
onChangeViewportPreset(e, t) {
|
|
3899
|
-
O((n) => ee(n, e.coordinate, t));
|
|
3900
|
-
},
|
|
3901
|
-
onPreviewFrameMount: A,
|
|
3902
|
-
onSelectComponent(t, n, r) {
|
|
3903
|
-
O((i) => w(i, e.manifest, t.coordinate, Object.values(n).flatMap((e) => e?.tree ? [e.tree] : []), r));
|
|
3904
|
-
},
|
|
3905
|
-
previewCacheReady: C,
|
|
3906
|
-
previewGeometryStore: x,
|
|
3907
|
-
previewRenderQueue: s,
|
|
3908
|
-
selection: c,
|
|
3909
|
-
urlWarning: d,
|
|
3910
|
-
workspace: p
|
|
3911
|
-
};
|
|
3912
|
-
}
|
|
3913
|
-
function pa(e) {
|
|
3914
|
-
let [t, n] = a.useState(e), r = a.useRef(t), i = a.useRef(null), o = a.useRef(0), s = a.useCallback(() => {
|
|
3915
|
-
i.current = null, o.current &&= (window.clearTimeout(o.current), 0);
|
|
3916
|
-
}, []), c = a.useCallback(() => {
|
|
3917
|
-
o.current = 0;
|
|
3918
|
-
let e = i.current;
|
|
3919
|
-
e && (i.current = null, he(e));
|
|
3920
|
-
}, []), l = a.useCallback((e) => {
|
|
3921
|
-
r.current = e, i.current = e, o.current && window.clearTimeout(o.current), o.current = window.setTimeout(c, ua);
|
|
3922
|
-
}, [c]), u = a.useCallback((e) => {
|
|
3923
|
-
s(), r.current = e, n(e);
|
|
3924
|
-
}, [s]);
|
|
3925
|
-
return a.useEffect(() => () => s(), [s]), a.useMemo(() => ({
|
|
3926
|
-
commitLiveCanvasChange: l,
|
|
3927
|
-
liveCanvasRef: r,
|
|
3928
|
-
restoreCanvasFromUrl: u,
|
|
3929
|
-
restoredCanvas: t
|
|
3930
|
-
}), [
|
|
3931
|
-
l,
|
|
3932
|
-
u,
|
|
3933
|
-
t
|
|
3934
|
-
]);
|
|
3935
|
-
}
|
|
3936
|
-
function ma(e) {
|
|
3937
|
-
let t = fa(e), n = /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s(oa, {
|
|
3938
|
-
canvas: t.canvas,
|
|
3939
|
-
debugPreviewPool: t.debugPreviewPool,
|
|
3940
|
-
debugPreviewQueue: t.debugPreviewQueue,
|
|
3941
|
-
manifest: e.manifest,
|
|
3942
|
-
onChangeCanvas: t.onChangeCanvas,
|
|
3943
|
-
onSelectComponent: t.onSelectComponent,
|
|
3944
|
-
onChangeCanvasViewportPreset: t.onChangeCanvasViewportPreset,
|
|
3945
|
-
onChangeSelection: t.onChangeSelection,
|
|
3946
|
-
onChangeViewportPreset: t.onChangeViewportPreset,
|
|
3947
|
-
onPreviewFrameMount: t.onPreviewFrameMount,
|
|
3948
|
-
previewCacheReady: t.previewCacheReady,
|
|
3949
|
-
previewGeometryStore: t.previewGeometryStore,
|
|
3950
|
-
previewRenderQueue: t.previewRenderQueue,
|
|
3951
|
-
selection: t.selection,
|
|
3952
|
-
urlWarning: t.urlWarning,
|
|
3953
|
-
workspace: t.workspace
|
|
3954
|
-
}) });
|
|
3955
|
-
return t.disablePreviewPool ? n : /* @__PURE__ */ s(nn, {
|
|
3956
|
-
debug: t.debugPreviewPool,
|
|
3957
|
-
poolUrl: Be(e.manifest),
|
|
3958
|
-
children: n
|
|
3959
|
-
});
|
|
3960
|
-
}
|
|
3961
|
-
function ha(e) {
|
|
3962
|
-
return !!e.cache?.namespace || typeof window < "u";
|
|
3963
|
-
}
|
|
3964
|
-
function ga(e, t, n) {
|
|
3965
|
-
t.type !== "gtsx:ready" && t.type !== "gtsx:error" || window.dispatchEvent(new CustomEvent("gtsx:preview-timing", { detail: {
|
|
3966
|
-
cacheKey: e.cacheKey,
|
|
3967
|
-
sessionId: t.sessionId,
|
|
3968
|
-
type: t.type,
|
|
3969
|
-
...typeof n == "number" ? { elapsedMs: Math.round((performance.now() - n) * 10) / 10 } : {}
|
|
3970
|
-
} }));
|
|
3971
|
-
}
|
|
3972
|
-
//#endregion
|
|
3973
|
-
export { j as $, Dt as A, v as B, Et as C, Tt as D, Ct as E, ct as F, Le as G, D as H, ut as I, me as J, F as K, De as L, Pt as M, Nt as N, wt as O, lt as P, S as Q, Ae as R, Fn as S, St as T, ee as U, k as V, Re as W, R as X, Be as Y, te as Z, Q as _, V as _t, Zr as a, ye as at, ir as b, Kr as c, z as ct, Ir as d, Oe as dt, A as et, Nr as f, Je as ft, Pr as g, B as gt, Fr as h, E as ht, Yr as i, _e as it, At as j, Ot as k, zr as l, he as lt, Mr as m, O as mt, oa as n, C as nt, Wr as o, ve as ot, Z as p, w as pt, ke as q, Xr as r, Ke as rt, Gr as s, H as st, ma as t, We as tt, Lr as u, U as ut, Rr as v, Ve as vt, kt as w, Bn as x, hr as y, _ as z };
|