@pygmalionjs/pygmalion 0.6.35 → 0.7.1
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/LICENSE +190 -0
- package/README.ko.md +309 -28
- package/README.md +37 -16
- package/dist-lib/CameraLayer-D2wrEPwG.js +415 -0
- package/dist-lib/frameLodRuntime-CU0IYaSu.js +272 -0
- package/dist-lib/pygmalion.js +11665 -16023
- package/dist-lib/routePreviewStatus-DTr-UJhV.js +64 -0
- package/dist-lib/{FrozenRoutePreview-BbF5Ov5K.js → runtime-DRkTU9eq.js} +9515 -5306
- package/dist-lib/testing.js +46 -6
- package/dist-lib/types/{App.d.ts → EditorShell.d.ts} +1 -1
- package/dist-lib/types/canvas/CameraLayer.d.ts +2 -1
- package/dist-lib/types/canvas/FrameLabelBanner.d.ts +1 -1
- package/dist-lib/types/canvas/FrameView.d.ts +1 -1
- package/dist-lib/types/canvas/FrozenRoutePreview.d.ts +1 -1
- package/dist-lib/types/canvas/SectionBoxes.d.ts +2 -1
- package/dist-lib/types/canvas/ShadowRoutePreview.d.ts +1 -1
- package/dist-lib/types/contract/errors.d.ts +30 -0
- package/dist-lib/types/contract/index.d.ts +5 -0
- package/dist-lib/types/contract/memoryTransport.d.ts +19 -0
- package/dist-lib/types/contract/paths.d.ts +57 -0
- package/dist-lib/types/contract/transport.d.ts +69 -0
- package/dist-lib/types/contract/types.d.ts +150 -0
- package/dist-lib/types/contract/validate.d.ts +15 -0
- package/dist-lib/types/contract/viteTransport.d.ts +10 -0
- package/dist-lib/types/core/context.d.ts +12 -0
- package/dist-lib/types/core/debug.d.ts +187 -0
- package/dist-lib/types/core/defaultRuntime.d.ts +3 -0
- package/dist-lib/types/core/hostBindings.d.ts +90 -0
- package/dist-lib/types/core/runtime.d.ts +36 -0
- package/dist-lib/types/core/runtimeContext.d.ts +13 -0
- package/dist-lib/types/editor/flowSessionScheduler.d.ts +21 -7
- package/dist-lib/types/editor/framePreviewKeys.d.ts +10 -10
- package/dist-lib/types/editor/host.d.ts +31 -26
- package/dist-lib/types/editor/previewBootstrap.d.ts +5 -15
- package/dist-lib/types/editor/previewCaptureProgress.d.ts +7 -2
- package/dist-lib/types/editor/projectRuntime.d.ts +11 -98
- package/dist-lib/types/editor/revisionCatalog.d.ts +8 -9
- package/dist-lib/types/editor/scenarioCoverage.d.ts +2 -1
- package/dist-lib/types/editor/store.d.ts +17 -2
- package/dist-lib/types/editor/storyboardComposition.d.ts +1 -5
- package/dist-lib/types/editor/storyboardDiscovery.d.ts +6 -16
- package/dist-lib/types/editor/storyboardEnvironment.d.ts +2 -2
- package/dist-lib/types/editor/variantPrefetch.d.ts +3 -2
- package/dist-lib/types/editor/visualQa.d.ts +7 -2
- package/dist-lib/types/lib.d.ts +25 -204
- package/dist-lib/types/shell/ComponentStateControls.d.ts +1 -1
- package/dist-lib/types/testing.d.ts +5 -1
- package/node/component-branches.mjs +3 -3
- package/node/contract.d.mts +63 -0
- package/node/contract.mjs +175 -0
- package/node/design-session.mjs +4 -2
- package/node/dev-mirror.mjs +6 -3
- package/node/inspect-plugin.mjs +3 -2
- package/node/preview-artifact-plugin.mjs +13 -16
- package/node/preview-artifact-store.mjs +4 -2
- package/node/qa-capture-plugin.mjs +3 -2
- package/node/storyboard-canonical.mjs +2 -2
- package/node/storyboard-capture-runtime.mjs +2 -2
- package/node/storyboard-environment.mjs +9 -6
- package/node/vite.mjs +2 -13
- package/package.json +24 -4
- package/storyboard.d.ts +11 -0
package/README.md
CHANGED
|
@@ -174,22 +174,32 @@ defaults, adoption, and code-generation metadata revision-bound without putting
|
|
|
174
174
|
functions in JSON.
|
|
175
175
|
Repository-owned generated-code intent belongs in `codegenProject` so its
|
|
176
176
|
frame contracts and prompt provenance switch with the same catalog.
|
|
177
|
-
Then opt the editor into the
|
|
177
|
+
Then opt the editor into the exact-preview services through its transport:
|
|
178
178
|
|
|
179
179
|
```tsx
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
// Once, for the editor's lifetime. The catalog endpoint derives from the
|
|
181
|
+
// artifact endpoint; pass `previewCatalog: null` to run artifacts alone.
|
|
182
|
+
const transport = createViteTransport({ endpoints: { previewArtifact: true } });
|
|
183
|
+
const runtime = createEditorRuntime({ transport });
|
|
184
|
+
|
|
185
|
+
function Editor() {
|
|
186
|
+
const { appOrigin, previewRevision } = usePygmalionProject({ transport });
|
|
187
|
+
return (
|
|
188
|
+
<PygmalionEditor
|
|
189
|
+
runtime={runtime}
|
|
190
|
+
previewCacheNamespace="my-product"
|
|
191
|
+
previewRevision={previewRevision}
|
|
192
|
+
appOrigin={appOrigin ?? undefined}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
188
196
|
```
|
|
189
197
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
Every request the editor and the project hook make goes through that
|
|
199
|
+
transport, so the two talk to one service; [The editor transport](./docs/transport.md)
|
|
200
|
+
lists its operations, paths, and errors. Pass the hook's full
|
|
201
|
+
`previewRevision`; the editor derives its source SHA for the catalog request
|
|
202
|
+
while retaining the session mutation counter for screen cache invalidation.
|
|
193
203
|
|
|
194
204
|
The editor validates both namespace and source revision before installation.
|
|
195
205
|
While another checkout is preparing, it keeps the last complete catalog,
|
|
@@ -395,9 +405,9 @@ Artifact v3 preserves every registered frame with one explicit outcome:
|
|
|
395
405
|
their last stable DOM and screenshot while CI remains red. A failed strict
|
|
396
406
|
capture therefore cannot silently leave an older artifact active.
|
|
397
407
|
|
|
398
|
-
When
|
|
399
|
-
namespace or source revision is treated only as a
|
|
400
|
-
preview. It does not count toward `data-preview-warm`. Each frame exposes its
|
|
408
|
+
When the transport configures a preview artifact endpoint, an embedded
|
|
409
|
+
artifact with another namespace or source revision is treated only as a
|
|
410
|
+
visibly outdated, last-known preview. It does not count toward `data-preview-warm`. Each frame exposes its
|
|
401
411
|
exact-resolution lifecycle through `data-artifact-resolution`: `checking`,
|
|
402
412
|
`outdated`, `generating`, `error`, or `exact`. Transport, validation, and
|
|
403
413
|
generation failures stay visible on the frame with a retry action. A current
|
|
@@ -447,4 +457,15 @@ npm run lint:language
|
|
|
447
457
|
- [Editor usability](./EDITOR-USABILITY.md) defines interaction coverage.
|
|
448
458
|
- [Product readiness](./PRODUCTIZATION.md) defines quality gates and remaining
|
|
449
459
|
work.
|
|
450
|
-
- [
|
|
460
|
+
- [The editor transport](./docs/transport.md) defines the one object every
|
|
461
|
+
request goes through, its endpoint table, and its error model.
|
|
462
|
+
- [Upgrading to 0.7](./docs/migration-0.7.md) maps the removed module-level
|
|
463
|
+
exports to the editor runtime and the removed endpoint props to the
|
|
464
|
+
transport.
|
|
465
|
+
- [Contributing](./CONTRIBUTING.md) defines the required commit format and the
|
|
466
|
+
release flow.
|
|
467
|
+
- [Changelog](./CHANGELOG.md) lists what each published version changed.
|
|
468
|
+
|
|
469
|
+
## License
|
|
470
|
+
|
|
471
|
+
Pygmalion is released under the [Apache License 2.0](./LICENSE).
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { jsx as G } from "react/jsx-runtime";
|
|
2
|
+
import { a6 as U, R as A, Y as q, ab as O, ad as J, a7 as Q, af as Z, ac as ee, bB as te } from "./runtime-DRkTU9eq.js";
|
|
3
|
+
import { useRef as ne, useLayoutEffect as N } from "react";
|
|
4
|
+
import { d as re, e as oe } from "./frameLodRuntime-CU0IYaSu.js";
|
|
5
|
+
function Ee({
|
|
6
|
+
editMode: e,
|
|
7
|
+
tool: t,
|
|
8
|
+
hasRoute: r,
|
|
9
|
+
liveOriginReady: n,
|
|
10
|
+
backgroundOnly: o = !1
|
|
11
|
+
}) {
|
|
12
|
+
return !e && t === "select" && r && n && !o;
|
|
13
|
+
}
|
|
14
|
+
function ie(e, t, r) {
|
|
15
|
+
return t !== "select" ? !1 : e || r;
|
|
16
|
+
}
|
|
17
|
+
const Y = Object.freeze({
|
|
18
|
+
frameId: null,
|
|
19
|
+
phase: "idle",
|
|
20
|
+
scroll: null
|
|
21
|
+
}), P = /* @__PURE__ */ new Set();
|
|
22
|
+
let u = Y, v = null;
|
|
23
|
+
function L(e) {
|
|
24
|
+
u = e;
|
|
25
|
+
for (const t of P) t();
|
|
26
|
+
}
|
|
27
|
+
function y(e) {
|
|
28
|
+
return Number.isFinite(e) ? e : 0;
|
|
29
|
+
}
|
|
30
|
+
function X(e) {
|
|
31
|
+
const t = Math.max(0, y(e.viewportWidth)), r = Math.max(0, y(e.viewportHeight)), n = Math.max(t, y(e.contentWidth)), o = Math.max(r, y(e.contentHeight)), s = Math.max(0, y(e.maxX)), a = Math.max(0, y(e.maxY));
|
|
32
|
+
return {
|
|
33
|
+
x: Math.min(s, Math.max(0, y(e.x))),
|
|
34
|
+
y: Math.min(a, Math.max(0, y(e.y))),
|
|
35
|
+
maxX: s,
|
|
36
|
+
maxY: a,
|
|
37
|
+
viewportWidth: t,
|
|
38
|
+
viewportHeight: r,
|
|
39
|
+
contentWidth: n,
|
|
40
|
+
contentHeight: o
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function se(e, t) {
|
|
44
|
+
return e ? e.x === t.x && e.y === t.y && e.maxX === t.maxX && e.maxY === t.maxY && e.viewportWidth === t.viewportWidth && e.viewportHeight === t.viewportHeight && e.contentWidth === t.contentWidth && e.contentHeight === t.contentHeight : !1;
|
|
45
|
+
}
|
|
46
|
+
function x(e) {
|
|
47
|
+
const t = v;
|
|
48
|
+
t && (v = null, t.unsubscribe(), e && u.frameId === t.frameId && (u.phase === "preview" || u.phase === "interacting") && L({ frameId: t.frameId, phase: "starting", scroll: null }));
|
|
49
|
+
}
|
|
50
|
+
function Le(e) {
|
|
51
|
+
var t, r;
|
|
52
|
+
if (e) {
|
|
53
|
+
if (u.frameId === e) {
|
|
54
|
+
(r = v == null ? void 0 : (t = v.adapter).focus) == null || r.call(t);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
x(!1), L({ frameId: e, phase: "starting", scroll: null });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function F(e) {
|
|
61
|
+
return u.frameId == null || e != null && u.frameId !== e ? !1 : (x(!1), L(Y), !0);
|
|
62
|
+
}
|
|
63
|
+
function xe(e, t) {
|
|
64
|
+
return u.frameId == null || t && u.frameId === e ? !1 : F();
|
|
65
|
+
}
|
|
66
|
+
function ke() {
|
|
67
|
+
return u;
|
|
68
|
+
}
|
|
69
|
+
function Ie(e) {
|
|
70
|
+
return P.add(e), () => P.delete(e);
|
|
71
|
+
}
|
|
72
|
+
function ae(e, t) {
|
|
73
|
+
return B(e, t, "interacting");
|
|
74
|
+
}
|
|
75
|
+
function B(e, t, r) {
|
|
76
|
+
var o, s;
|
|
77
|
+
if (u.frameId !== e) return () => {
|
|
78
|
+
};
|
|
79
|
+
x(!1);
|
|
80
|
+
const n = () => {
|
|
81
|
+
if (u.frameId !== e || (v == null ? void 0 : v.adapter) !== t) return;
|
|
82
|
+
const a = X(t.readScroll());
|
|
83
|
+
u.phase === r && se(u.scroll, a) || L({ frameId: e, phase: r, scroll: a });
|
|
84
|
+
};
|
|
85
|
+
return v = {
|
|
86
|
+
frameId: e,
|
|
87
|
+
adapter: t,
|
|
88
|
+
phase: r,
|
|
89
|
+
unsubscribe: ((o = t.subscribe) == null ? void 0 : o.call(t, n)) ?? (() => {
|
|
90
|
+
})
|
|
91
|
+
}, n(), (s = t.focus) == null || s.call(t), () => {
|
|
92
|
+
(v == null ? void 0 : v.adapter) === t && x(!0);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function Pe(e, t, r) {
|
|
96
|
+
const n = t.host.ownerDocument.defaultView;
|
|
97
|
+
if (!n) return () => {
|
|
98
|
+
};
|
|
99
|
+
let o = r;
|
|
100
|
+
return B(e, {
|
|
101
|
+
readScroll: () => j(o),
|
|
102
|
+
scrollTo: ({ x: a, y: i }) => {
|
|
103
|
+
try {
|
|
104
|
+
o.scrollTo({ left: a, top: i, behavior: "auto" });
|
|
105
|
+
} catch {
|
|
106
|
+
o.scrollLeft = a, o.scrollTop = i;
|
|
107
|
+
}
|
|
108
|
+
o.scrollLeft !== a && (o.scrollLeft = a), o.scrollTop !== i && (o.scrollTop = i);
|
|
109
|
+
},
|
|
110
|
+
subscribe: (a) => {
|
|
111
|
+
const i = (l) => {
|
|
112
|
+
const c = l.target;
|
|
113
|
+
c instanceof n.HTMLElement && (c.scrollHeight > c.clientHeight || c.scrollWidth > c.clientWidth) && (o = c), a();
|
|
114
|
+
}, f = (l) => {
|
|
115
|
+
!(l instanceof n.KeyboardEvent) || l.key !== "Escape" || (l.preventDefault(), l.stopImmediatePropagation(), F(e));
|
|
116
|
+
}, w = (l) => {
|
|
117
|
+
var S;
|
|
118
|
+
const c = l.target;
|
|
119
|
+
(S = c == null ? void 0 : c.closest) != null && S.call(c, "a[href]") && l.preventDefault();
|
|
120
|
+
}, g = (l) => l.preventDefault();
|
|
121
|
+
return t.addEventListener("scroll", i, !0), t.addEventListener("keydown", f, !0), t.addEventListener("click", w, !0), t.addEventListener("submit", g, !0), () => {
|
|
122
|
+
t.removeEventListener("scroll", i, !0), t.removeEventListener("keydown", f, !0), t.removeEventListener("click", w, !0), t.removeEventListener("submit", g, !0);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}, "preview");
|
|
126
|
+
}
|
|
127
|
+
function Fe(e) {
|
|
128
|
+
const t = v;
|
|
129
|
+
if (!t || u.phase !== "preview" && u.phase !== "interacting" || !u.scroll)
|
|
130
|
+
return !1;
|
|
131
|
+
t.adapter.scrollTo({
|
|
132
|
+
x: e.x ?? u.scroll.x,
|
|
133
|
+
y: e.y ?? u.scroll.y
|
|
134
|
+
});
|
|
135
|
+
const r = X(t.adapter.readScroll());
|
|
136
|
+
return L({
|
|
137
|
+
frameId: t.frameId,
|
|
138
|
+
phase: t.phase,
|
|
139
|
+
scroll: r
|
|
140
|
+
}), !0;
|
|
141
|
+
}
|
|
142
|
+
function j(e) {
|
|
143
|
+
return {
|
|
144
|
+
x: e.scrollLeft,
|
|
145
|
+
y: e.scrollTop,
|
|
146
|
+
maxX: Math.max(0, e.scrollWidth - e.clientWidth),
|
|
147
|
+
maxY: Math.max(0, e.scrollHeight - e.clientHeight),
|
|
148
|
+
viewportWidth: e.clientWidth,
|
|
149
|
+
viewportHeight: e.clientHeight,
|
|
150
|
+
contentWidth: e.scrollWidth,
|
|
151
|
+
contentHeight: e.scrollHeight
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function I(e, t) {
|
|
155
|
+
try {
|
|
156
|
+
const r = new URL(e), n = new URL(t, r);
|
|
157
|
+
return r.origin === n.origin && r.pathname === n.pathname;
|
|
158
|
+
} catch {
|
|
159
|
+
return !1;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function ce(e, t) {
|
|
163
|
+
const r = e.location.href, n = e.history, o = n.pushState, s = n.replaceState, a = n.back, i = n.forward, f = n.go, w = e.open, g = (d) => d == null || I(
|
|
164
|
+
r,
|
|
165
|
+
new URL(String(d), e.location.href).href
|
|
166
|
+
), l = (d, p, m) => {
|
|
167
|
+
g(m) && o.call(n, d, p, m);
|
|
168
|
+
}, c = (d, p, m) => {
|
|
169
|
+
g(m) && s.call(n, d, p, m);
|
|
170
|
+
}, S = () => {
|
|
171
|
+
}, H = () => {
|
|
172
|
+
}, W = () => {
|
|
173
|
+
}, M = (() => null);
|
|
174
|
+
n.pushState = l, n.replaceState = c, n.back = S, n.forward = H, n.go = W, e.open = M;
|
|
175
|
+
const R = (d) => {
|
|
176
|
+
var D;
|
|
177
|
+
const p = d.target, m = (D = p == null ? void 0 : p.closest) == null ? void 0 : D.call(p, "a[href]");
|
|
178
|
+
if (!m) return;
|
|
179
|
+
(m.target && m.target.toLowerCase() !== "_self" || !I(
|
|
180
|
+
r,
|
|
181
|
+
m.href
|
|
182
|
+
)) && d.preventDefault();
|
|
183
|
+
}, T = (d) => d.preventDefault(), b = e.navigation, C = (d) => {
|
|
184
|
+
var m;
|
|
185
|
+
const p = (m = d.destination) == null ? void 0 : m.url;
|
|
186
|
+
p && !I(r, p) && d.cancelable && d.preventDefault();
|
|
187
|
+
};
|
|
188
|
+
return t.addEventListener("click", R, !0), t.addEventListener("submit", T, !0), b == null || b.addEventListener("navigate", C), () => {
|
|
189
|
+
t.removeEventListener("click", R, !0), t.removeEventListener("submit", T, !0), b == null || b.removeEventListener("navigate", C), n.pushState === l && (n.pushState = o), n.replaceState === c && (n.replaceState = s), n.back === S && (n.back = a), n.forward === H && (n.forward = i), n.go === W && (n.go = f), e.open === M && (e.open = w);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function He(e, t) {
|
|
193
|
+
const r = t.contentWindow, n = t.contentDocument, o = n == null ? void 0 : n.scrollingElement;
|
|
194
|
+
if (!r || !n || !o)
|
|
195
|
+
return () => {
|
|
196
|
+
};
|
|
197
|
+
let s = o;
|
|
198
|
+
return ae(e, {
|
|
199
|
+
readScroll: () => j(s),
|
|
200
|
+
scrollTo: ({ x: i, y: f }) => s.scrollTo({ left: i, top: f }),
|
|
201
|
+
focus: () => {
|
|
202
|
+
t.focus(), r.focus();
|
|
203
|
+
},
|
|
204
|
+
subscribe: (i) => {
|
|
205
|
+
const f = ce(
|
|
206
|
+
r,
|
|
207
|
+
n
|
|
208
|
+
), w = (l) => {
|
|
209
|
+
const c = l.target;
|
|
210
|
+
c != null && c.nodeType === 1 && (c.scrollHeight > c.clientHeight || c.scrollWidth > c.clientWidth) && (s = c), i();
|
|
211
|
+
}, g = (l) => {
|
|
212
|
+
l.key === "Escape" && (l.preventDefault(), l.stopImmediatePropagation(), F(e));
|
|
213
|
+
};
|
|
214
|
+
return n.addEventListener("scroll", w, !0), r.addEventListener("resize", i), r.addEventListener("keydown", g, !0), () => {
|
|
215
|
+
f(), n.removeEventListener("scroll", w, !0), r.removeEventListener("resize", i), r.removeEventListener("keydown", g, !0);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const le = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map();
|
|
221
|
+
let h = [];
|
|
222
|
+
const ue = 2;
|
|
223
|
+
function K(e, t) {
|
|
224
|
+
for (const n of [...le]) n();
|
|
225
|
+
const r = /* @__PURE__ */ new Set();
|
|
226
|
+
for (const n of e) t.includes(n) || r.add(n);
|
|
227
|
+
for (const n of t) e.includes(n) || r.add(n);
|
|
228
|
+
for (const n of r) {
|
|
229
|
+
const o = E.get(n);
|
|
230
|
+
if (o)
|
|
231
|
+
for (const s of [...o]) s();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function We(e, t = ue) {
|
|
235
|
+
if (!e) return !1;
|
|
236
|
+
const r = Math.max(1, t);
|
|
237
|
+
if (h[0] === e && h.length <= r) return !1;
|
|
238
|
+
const n = [e, ...h.filter((s) => s !== e)].slice(0, r);
|
|
239
|
+
if (n.length === h.length && n.every((s, a) => s === h[a]))
|
|
240
|
+
return !1;
|
|
241
|
+
const o = h;
|
|
242
|
+
return h = n, K(o, n), !0;
|
|
243
|
+
}
|
|
244
|
+
function Me(e) {
|
|
245
|
+
if (!h.includes(e)) return;
|
|
246
|
+
const t = h;
|
|
247
|
+
h = h.filter((r) => r !== e), K(t, h);
|
|
248
|
+
}
|
|
249
|
+
function fe(e) {
|
|
250
|
+
return h.includes(e);
|
|
251
|
+
}
|
|
252
|
+
function Re() {
|
|
253
|
+
return h;
|
|
254
|
+
}
|
|
255
|
+
function Te(e, t) {
|
|
256
|
+
let r = E.get(e);
|
|
257
|
+
return r || (r = /* @__PURE__ */ new Set(), E.set(e, r)), r.add(t), () => {
|
|
258
|
+
r.delete(t), r.size === 0 && E.get(e) === r && E.delete(e);
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function _(e) {
|
|
262
|
+
return `translate(${e.panX}px, ${e.panY}px) scale(${e.zoom})`;
|
|
263
|
+
}
|
|
264
|
+
function $(e, t, r) {
|
|
265
|
+
return ie(e, t, r) ? void 0 : "none";
|
|
266
|
+
}
|
|
267
|
+
function z(e, t) {
|
|
268
|
+
return $(
|
|
269
|
+
e.editMode,
|
|
270
|
+
e.tool,
|
|
271
|
+
t != null
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
const k = /* @__PURE__ */ new WeakMap();
|
|
275
|
+
function de(e, t, r) {
|
|
276
|
+
if (e.route == null) return 0;
|
|
277
|
+
const n = Q(e) ?? e.route, o = e.width ?? 390, s = e.height ?? 600, a = te();
|
|
278
|
+
let i = k.get(e);
|
|
279
|
+
(!i || i.revision !== t || i.epoch !== a || i.route !== n || i.width !== o || i.height !== s) && (i = {
|
|
280
|
+
revision: t,
|
|
281
|
+
epoch: a,
|
|
282
|
+
route: n,
|
|
283
|
+
width: o,
|
|
284
|
+
height: s,
|
|
285
|
+
key: O(e, t, r)
|
|
286
|
+
}, k.set(e, i));
|
|
287
|
+
const f = Z(i.key);
|
|
288
|
+
if (f != null) return f.length * 2;
|
|
289
|
+
const w = ee(i.key);
|
|
290
|
+
return w ? w.bodyHtml.length * 2 : 0;
|
|
291
|
+
}
|
|
292
|
+
function he(e, t, r) {
|
|
293
|
+
var i;
|
|
294
|
+
if (e.route == null) return null;
|
|
295
|
+
const n = k.get(e), o = (n == null ? void 0 : n.key) ?? O(e, t, r), s = (i = J(o)) == null ? void 0 : i.screenshot;
|
|
296
|
+
if (!s) return null;
|
|
297
|
+
const a = e.width ?? 390;
|
|
298
|
+
return a > 0 ? s.width / a : null;
|
|
299
|
+
}
|
|
300
|
+
function me(e) {
|
|
301
|
+
return V(e).map((r) => {
|
|
302
|
+
var o;
|
|
303
|
+
const n = e.store.pages.find((s) => s.id === r.id);
|
|
304
|
+
return {
|
|
305
|
+
...r,
|
|
306
|
+
memoKey: n ? (o = k.get(n)) == null ? void 0 : o.key : void 0
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function V(e) {
|
|
311
|
+
const t = e.store, r = e.host.previewRevision, n = t.selectedCanvasObject;
|
|
312
|
+
return t.pages.filter(
|
|
313
|
+
(o) => (o.canvas ?? "default") === t.activeCanvas && t.isScreenStateShown(o)
|
|
314
|
+
).map((o) => ({
|
|
315
|
+
id: o.id,
|
|
316
|
+
rect: {
|
|
317
|
+
x: o.x ?? 0,
|
|
318
|
+
y: o.y ?? 0,
|
|
319
|
+
width: o.width ?? 390,
|
|
320
|
+
height: q(o)
|
|
321
|
+
},
|
|
322
|
+
pinned: o.id === t.activePageId || (n == null ? void 0 : n.kind) === "frame" && n.id === o.id || // Catalog sheets need a full first render to replace their 1x1 seed.
|
|
323
|
+
// Their live DOM remains mounted afterwards; offscreen paint may be skipped.
|
|
324
|
+
oe(o) || fe(o.id),
|
|
325
|
+
weightBytes: de(o, r, o.id === t.activePageId),
|
|
326
|
+
screenshotDensity: he(
|
|
327
|
+
o,
|
|
328
|
+
r,
|
|
329
|
+
o.id === t.activePageId
|
|
330
|
+
)
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
let ve = 0;
|
|
334
|
+
function pe({
|
|
335
|
+
children: e,
|
|
336
|
+
interactionFrameId: t = null
|
|
337
|
+
}) {
|
|
338
|
+
const r = U(), n = r.store, o = ne(null);
|
|
339
|
+
return N(() => {
|
|
340
|
+
const s = o.current;
|
|
341
|
+
if (!s) return;
|
|
342
|
+
const a = new A(`CameraLayer#${++ve}`, () => {
|
|
343
|
+
a.isDisposed || i();
|
|
344
|
+
}), i = () => {
|
|
345
|
+
a.track(() => {
|
|
346
|
+
s.style.transform = _(n), s.style.pointerEvents = z(n, t) ?? "";
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
return i(), () => a.dispose();
|
|
350
|
+
}, [n, t]), N(() => {
|
|
351
|
+
const s = re({
|
|
352
|
+
readCamera: () => ({
|
|
353
|
+
panX: n.panX,
|
|
354
|
+
panY: n.panY,
|
|
355
|
+
zoom: n.zoom,
|
|
356
|
+
canvas: n.activeCanvas
|
|
357
|
+
}),
|
|
358
|
+
readFrames: () => V(r),
|
|
359
|
+
readViewport: () => {
|
|
360
|
+
var i;
|
|
361
|
+
const a = (i = o.current) == null ? void 0 : i.parentElement;
|
|
362
|
+
if (a) {
|
|
363
|
+
const f = a.getBoundingClientRect();
|
|
364
|
+
if (f.width > 0 && f.height > 0)
|
|
365
|
+
return { width: f.width, height: f.height };
|
|
366
|
+
}
|
|
367
|
+
return { width: window.innerWidth, height: window.innerHeight };
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return s.start(), () => s.stop();
|
|
371
|
+
}, [n, r]), /* @__PURE__ */ G(
|
|
372
|
+
"div",
|
|
373
|
+
{
|
|
374
|
+
ref: o,
|
|
375
|
+
"data-canvas-camera": !0,
|
|
376
|
+
style: {
|
|
377
|
+
position: "absolute",
|
|
378
|
+
left: 0,
|
|
379
|
+
top: 0,
|
|
380
|
+
transform: _(n),
|
|
381
|
+
transformOrigin: "0 0",
|
|
382
|
+
transition: "none",
|
|
383
|
+
willChange: "transform",
|
|
384
|
+
pointerEvents: z(n, t)
|
|
385
|
+
},
|
|
386
|
+
children: e
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
const Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
391
|
+
__proto__: null,
|
|
392
|
+
CameraLayer: pe,
|
|
393
|
+
__debugReadEditorFrames: me,
|
|
394
|
+
resolveCameraPointerEvents: $
|
|
395
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
396
|
+
export {
|
|
397
|
+
pe as C,
|
|
398
|
+
ue as P,
|
|
399
|
+
He as a,
|
|
400
|
+
Ie as b,
|
|
401
|
+
Pe as c,
|
|
402
|
+
xe as d,
|
|
403
|
+
F as e,
|
|
404
|
+
I as f,
|
|
405
|
+
ke as g,
|
|
406
|
+
fe as h,
|
|
407
|
+
Ee as i,
|
|
408
|
+
Le as j,
|
|
409
|
+
Re as k,
|
|
410
|
+
Fe as l,
|
|
411
|
+
Ce as m,
|
|
412
|
+
We as n,
|
|
413
|
+
Me as r,
|
|
414
|
+
Te as s
|
|
415
|
+
};
|