@pygmalionjs/pygmalion 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/{App-D_6vGXDa.js → App-XRuc9KYj.js} +6336 -5213
- package/dist-lib/pygmalion.js +223 -172
- package/dist-lib/style.css +1 -1
- package/dist-lib/testing.js +1 -1
- package/node/route-preview-artifact-v2.mjs +483 -0
- package/node/storyboard-canonical.mjs +410 -0
- package/node/storyboard-environment.mjs +1507 -0
- package/node/vite.mjs +55 -2
- package/package.json +4 -1
- package/types.d.ts +90 -3
- package/vite.d.ts +264 -0
package/dist-lib/pygmalion.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { i as
|
|
3
|
-
import { D as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return typeof r == "string" &&
|
|
1
|
+
import { jsx as Z } from "react/jsx-runtime";
|
|
2
|
+
import { i as le, g as ce, e as v, b as de, a as ue, c as fe, d as he, f as pe, h as me, j as ge, k as ye, l as we, m as be, n as ve, o as L, S as Se, A as Pe, p as K, q as Oe, r as Ie, t as Ee, u as Ne, v as Ae, w as Re, x as De, y as X } from "./App-XRuc9KYj.js";
|
|
3
|
+
import { D as Ye, z as We, B as Ze, C as Ke, E as Xe, G as er, H as rr, I as tr, J as nr, K as sr, L as ir, M as ar } from "./App-XRuc9KYj.js";
|
|
4
|
+
import { useMemo as ee, useState as Q, useRef as re, useCallback as j, useEffect as B } from "react";
|
|
5
|
+
const te = /^[a-f0-9]{64}$/, Te = /^\/__pygmalion-qa\/artifacts\/[A-Za-z0-9_-]{8,120}\.png$/, _e = /^p\d+$/;
|
|
6
|
+
function V(r) {
|
|
7
|
+
return typeof r == "string" && Te.test(r) ? r : void 0;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function ne(r, e) {
|
|
10
10
|
const s = new URL(r, e);
|
|
11
11
|
return s.search = "", s.hash = "", s.pathname.endsWith("/") || (s.pathname = `${s.pathname}/`), s.href;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function z(r) {
|
|
14
14
|
if (!r || typeof r != "object" || Array.isArray(r)) return null;
|
|
15
15
|
const e = r;
|
|
16
|
-
return typeof e.domStructureHash != "string" || !
|
|
16
|
+
return typeof e.domStructureHash != "string" || !te.test(e.domStructureHash) || typeof e.screenshotHash != "string" || !te.test(e.screenshotHash) ? null : {
|
|
17
17
|
domStructureHash: e.domStructureHash,
|
|
18
18
|
screenshotHash: e.screenshotHash,
|
|
19
|
-
...
|
|
19
|
+
...V(e.screenshotUrl) ? { screenshotUrl: V(e.screenshotUrl) } : {}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function se(r) {
|
|
23
23
|
if (!r || typeof r != "object" || Array.isArray(r)) return null;
|
|
24
24
|
const e = r;
|
|
25
25
|
return !Number.isSafeInteger(e.width) || !Number.isSafeInteger(e.height) || Number(e.width) < 1 || Number(e.height) < 1 || Number(e.width) > 65536 || Number(e.height) > 65536 ? null : { width: Number(e.width), height: Number(e.height) };
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function xe(r) {
|
|
28
28
|
if (!r || typeof r != "object" || Array.isArray(r)) return null;
|
|
29
|
-
const e = r, s =
|
|
29
|
+
const e = r, s = se(e.before), i = se(e.after);
|
|
30
30
|
if (!s || !i || !Number.isSafeInteger(e.changedPixels) || !Number.isSafeInteger(e.totalPixels) || Number(e.changedPixels) < 0 || Number(e.totalPixels) < 1 || Number(e.changedPixels) > Number(e.totalPixels) || typeof e.threshold != "number" || !Number.isFinite(e.threshold) || e.threshold < 0 || e.threshold > 1)
|
|
31
31
|
return null;
|
|
32
|
-
const t = e.heatmapUrl == null ? null :
|
|
32
|
+
const t = e.heatmapUrl == null ? null : V(e.heatmapUrl) ?? null;
|
|
33
33
|
return {
|
|
34
34
|
before: s,
|
|
35
35
|
after: i,
|
|
@@ -41,15 +41,15 @@ function Re(r) {
|
|
|
41
41
|
heatmapUrl: t
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Fe(r, e) {
|
|
45
45
|
if (!r || typeof r != "object" || Array.isArray(r)) return null;
|
|
46
46
|
const s = r;
|
|
47
47
|
if (typeof s.id != "string" || !s.id) return null;
|
|
48
|
-
const i =
|
|
48
|
+
const i = z(s), t = z(s.before) ?? i;
|
|
49
49
|
if (!t) return null;
|
|
50
|
-
const d =
|
|
50
|
+
const d = z(s.after);
|
|
51
51
|
if (e === "changed" && !d) return null;
|
|
52
|
-
const
|
|
52
|
+
const h = d ? xe(s.pixelDiff) : null;
|
|
53
53
|
return {
|
|
54
54
|
id: s.id,
|
|
55
55
|
before: t,
|
|
@@ -58,18 +58,18 @@ function xe(r, e) {
|
|
|
58
58
|
domChanged: t.domStructureHash !== d.domStructureHash,
|
|
59
59
|
screenshotChanged: t.screenshotHash !== d.screenshotHash
|
|
60
60
|
} : {},
|
|
61
|
-
...
|
|
61
|
+
...h ? { pixelDiff: h } : {}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ke(r, e = []) {
|
|
65
65
|
const s = new Set(e), i = s.size > 0, t = /* @__PURE__ */ new Set(), d = [
|
|
66
|
-
...r.styles.map((
|
|
67
|
-
...r.texts.map((
|
|
68
|
-
...r.operations.map((
|
|
66
|
+
...r.styles.map((h) => h.affectedFrames ?? []),
|
|
67
|
+
...r.texts.map((h) => h.affectedFrames ?? []),
|
|
68
|
+
...r.operations.map((h) => h.affectedFrames ?? [])
|
|
69
69
|
];
|
|
70
|
-
for (const
|
|
71
|
-
for (const u of
|
|
72
|
-
if (i &&
|
|
70
|
+
for (const h of d)
|
|
71
|
+
for (const u of h) {
|
|
72
|
+
if (i && _e.test(u.id) && !s.has(u.id))
|
|
73
73
|
throw new Error(
|
|
74
74
|
`"Impact Screen"${u.name}"This internal editor ID (${u.id}) is used. A canonical screen ID is required.`
|
|
75
75
|
);
|
|
@@ -77,7 +77,7 @@ function Fe(r, e = []) {
|
|
|
77
77
|
}
|
|
78
78
|
return [...t].sort();
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
80
|
+
async function ie(r, e, s) {
|
|
81
81
|
const i = await r(`${e.replace(/\/$/, "")}/capture`, {
|
|
82
82
|
method: "POST",
|
|
83
83
|
headers: { "content-type": "application/json" },
|
|
@@ -89,63 +89,63 @@ async function X(r, e, s) {
|
|
|
89
89
|
);
|
|
90
90
|
if (typeof t.baselineId != "string" || !t.baselineId)
|
|
91
91
|
throw new Error("Pygmalion visual QA response has no baselineId");
|
|
92
|
-
const d = Array.isArray(t.frames) ? t.frames.map((c) =>
|
|
92
|
+
const d = Array.isArray(t.frames) ? t.frames.map((c) => Fe(c, s.phase)).filter((c) => c != null) : [], h = Array.isArray(t.failures) ? t.failures.map((c) => {
|
|
93
93
|
if (!c || typeof c != "object" || Array.isArray(c)) return null;
|
|
94
|
-
const
|
|
95
|
-
return typeof
|
|
96
|
-
}).filter((c) => c != null) : [], u = new Set(s.frameIds),
|
|
94
|
+
const g = c;
|
|
95
|
+
return typeof g.id == "string" && typeof g.error == "string" ? { id: g.id, error: g.error } : null;
|
|
96
|
+
}).filter((c) => c != null) : [], u = new Set(s.frameIds), I = new Set(d.map((c) => c.id)).size === d.length && d.every((c) => u.has(c.id)) && h.every((c) => u.has(c.id));
|
|
97
97
|
return {
|
|
98
98
|
phase: s.phase,
|
|
99
99
|
baselineId: t.baselineId,
|
|
100
|
-
complete: t.complete !== !1 &&
|
|
100
|
+
complete: t.complete !== !1 && I && h.length === 0 && d.length === s.frameIds.length,
|
|
101
101
|
frames: d,
|
|
102
|
-
failures:
|
|
102
|
+
failures: h
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const G = {
|
|
106
106
|
mirror: "/__pygmalion-dev-control",
|
|
107
107
|
sessions: "/__pygmalion-design-session",
|
|
108
108
|
inspect: "/__pygmalion-inspect"
|
|
109
|
-
},
|
|
110
|
-
function
|
|
109
|
+
}, $e = "pygmalion.designSessionId", Ce = "/__pygmalion-qa", J = /* @__PURE__ */ new Map();
|
|
110
|
+
function ae() {
|
|
111
111
|
var r;
|
|
112
112
|
return typeof window < "u" && ((r = window.crypto) != null && r.randomUUID) ? window.crypto.randomUUID() : `pygmalion-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function je(r, e) {
|
|
115
115
|
if (r) return r;
|
|
116
|
-
const s =
|
|
116
|
+
const s = J.get(e);
|
|
117
117
|
if (s) return s;
|
|
118
118
|
try {
|
|
119
119
|
const i = window.localStorage.getItem(e);
|
|
120
120
|
if (i)
|
|
121
|
-
return
|
|
122
|
-
const t =
|
|
123
|
-
return window.localStorage.setItem(e, t),
|
|
121
|
+
return J.set(e, i), i;
|
|
122
|
+
const t = ae();
|
|
123
|
+
return window.localStorage.setItem(e, t), J.set(e, t), t;
|
|
124
124
|
} catch {
|
|
125
|
-
const i =
|
|
126
|
-
return
|
|
125
|
+
const i = ae();
|
|
126
|
+
return J.set(e, i), i;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
async function
|
|
129
|
+
async function O(r) {
|
|
130
130
|
const e = await r.json();
|
|
131
131
|
if (!r.ok) throw new Error(e.error ?? `Pygmalion request failed (${r.status})`);
|
|
132
132
|
return e;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
var
|
|
134
|
+
function Je(r = {}) {
|
|
135
|
+
var $, C, q, Y, W;
|
|
136
136
|
const {
|
|
137
137
|
sessionId: e,
|
|
138
|
-
sessionStorageKey: s =
|
|
138
|
+
sessionStorageKey: s = $e,
|
|
139
139
|
autoStart: i = !0,
|
|
140
140
|
fetcher: t = fetch,
|
|
141
141
|
formatApplyMessage: d
|
|
142
|
-
} = r,
|
|
143
|
-
() => JSON.parse(
|
|
144
|
-
[
|
|
145
|
-
),
|
|
146
|
-
() =>
|
|
142
|
+
} = r, h = (($ = r.endpoints) == null ? void 0 : $.mirror) ?? G.mirror, u = ((C = r.endpoints) == null ? void 0 : C.sessions) ?? G.sessions, A = ((q = r.endpoints) == null ? void 0 : q.inspect) ?? G.inspect, I = r.visualQa != null, c = ((Y = r.visualQa) == null ? void 0 : Y.endpoint) ?? Ce, g = JSON.stringify(((W = r.visualQa) == null ? void 0 : W.eligibleFrameIds) ?? []), x = ee(
|
|
143
|
+
() => JSON.parse(g),
|
|
144
|
+
[g]
|
|
145
|
+
), H = ee(
|
|
146
|
+
() => je(e, s),
|
|
147
147
|
[e, s]
|
|
148
|
-
), [
|
|
148
|
+
), [S, F] = Q({
|
|
149
149
|
state: "idle",
|
|
150
150
|
commit: null,
|
|
151
151
|
shortCommit: null,
|
|
@@ -154,32 +154,32 @@ function qe(r = {}) {
|
|
|
154
154
|
warning: null,
|
|
155
155
|
error: null,
|
|
156
156
|
appOrigin: null
|
|
157
|
-
}), [n,
|
|
157
|
+
}), [n, k] = Q(null), [R, D] = Q(null), E = re(null), y = re(null), T = j(
|
|
158
158
|
async (o = !0) => {
|
|
159
|
-
if (
|
|
159
|
+
if (E.current) return E.current;
|
|
160
160
|
const a = (async () => {
|
|
161
|
-
|
|
161
|
+
F((l) => ({ ...l, state: "syncing", error: null }));
|
|
162
162
|
try {
|
|
163
|
-
let l = await t(`${
|
|
163
|
+
let l = await t(`${h}/${o ? "refresh" : "status"}`, {
|
|
164
164
|
method: o ? "POST" : "GET"
|
|
165
|
-
}),
|
|
165
|
+
}), f = await O(l);
|
|
166
166
|
const w = Date.now();
|
|
167
|
-
for (; !o &&
|
|
168
|
-
await new Promise((P) => window.setTimeout(P, 500)), l = await t(`${
|
|
169
|
-
if (
|
|
170
|
-
throw new Error(
|
|
171
|
-
const
|
|
167
|
+
for (; !o && f.state === "syncing" && Date.now() - w < 12e4; )
|
|
168
|
+
await new Promise((P) => window.setTimeout(P, 500)), l = await t(`${h}/status`), f = await O(l);
|
|
169
|
+
if (f.state !== "ready" || !f.appOrigin || !f.commit)
|
|
170
|
+
throw new Error(f.error ?? "Pygmalion could not prepare the source preview");
|
|
171
|
+
const m = await O(
|
|
172
172
|
await t(`${u}/open`, {
|
|
173
173
|
method: "POST",
|
|
174
174
|
headers: { "content-type": "application/json" },
|
|
175
|
-
body: JSON.stringify({ sessionId:
|
|
175
|
+
body: JSON.stringify({ sessionId: H, baseDevSha: f.commit })
|
|
176
176
|
})
|
|
177
177
|
);
|
|
178
|
-
if (!
|
|
179
|
-
throw new Error(
|
|
180
|
-
let b =
|
|
178
|
+
if (!m.ok || !m.session)
|
|
179
|
+
throw new Error(m.error ?? "Pygmalion could not open the design session");
|
|
180
|
+
let b = m.session;
|
|
181
181
|
if (b.branchName) {
|
|
182
|
-
const P = await
|
|
182
|
+
const P = await O(
|
|
183
183
|
await t(`${u}/check`, {
|
|
184
184
|
method: "POST",
|
|
185
185
|
headers: { "content-type": "application/json" },
|
|
@@ -190,31 +190,31 @@ function qe(r = {}) {
|
|
|
190
190
|
throw new Error(P.error ?? "Pygmalion could not check the design session");
|
|
191
191
|
b = P.session;
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
F(f), k(b), D(b.appOrigin ?? f.appOrigin);
|
|
194
194
|
} catch (l) {
|
|
195
|
-
|
|
196
|
-
...
|
|
195
|
+
F((f) => ({
|
|
196
|
+
...f,
|
|
197
197
|
state: "error",
|
|
198
198
|
error: l instanceof Error ? l.message : String(l)
|
|
199
199
|
}));
|
|
200
200
|
}
|
|
201
201
|
})();
|
|
202
|
-
|
|
202
|
+
E.current = a;
|
|
203
203
|
try {
|
|
204
204
|
await a;
|
|
205
205
|
} finally {
|
|
206
|
-
|
|
206
|
+
E.current === a && (E.current = null);
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
|
-
[t,
|
|
210
|
-
),
|
|
209
|
+
[t, h, u, H]
|
|
210
|
+
), U = j(
|
|
211
211
|
async (o) => {
|
|
212
|
-
var
|
|
212
|
+
var m;
|
|
213
213
|
if (!n) throw new Error("Pygmalion design session is not ready");
|
|
214
|
-
const a =
|
|
214
|
+
const a = y.current;
|
|
215
215
|
if (a && (a.sessionId !== n.id || a.baseDevSha !== n.baseDevSha || a.revision !== n.revision || a.fingerprint !== JSON.stringify(o)))
|
|
216
216
|
throw new Error("The code diff you checked is out of date. Please check the diff for the current changes again.");
|
|
217
|
-
const l = await
|
|
217
|
+
const l = await O(
|
|
218
218
|
await t(`${u}/apply-visual`, {
|
|
219
219
|
method: "POST",
|
|
220
220
|
headers: { "content-type": "application/json" },
|
|
@@ -229,15 +229,15 @@ function qe(r = {}) {
|
|
|
229
229
|
);
|
|
230
230
|
if (!l.ok || !l.session)
|
|
231
231
|
throw new Error(l.error ?? "Pygmalion could not apply the visual changes");
|
|
232
|
-
|
|
233
|
-
const
|
|
232
|
+
k(l.session), l.session.appOrigin && D(l.session.appOrigin);
|
|
233
|
+
const f = l.applied ?? o.styles.length + o.texts.length + o.operations.length;
|
|
234
234
|
let w;
|
|
235
|
-
if (a != null && a.qaBaselineId && ((
|
|
235
|
+
if (a != null && a.qaBaselineId && ((m = a.qaFrameIds) != null && m.length) && l.session.appOrigin)
|
|
236
236
|
try {
|
|
237
|
-
w = await
|
|
237
|
+
w = await ie(t, c, {
|
|
238
238
|
phase: "changed",
|
|
239
239
|
baselineId: a.qaBaselineId,
|
|
240
|
-
basePath:
|
|
240
|
+
basePath: ne(l.session.appOrigin, window.location.origin),
|
|
241
241
|
frameIds: a.qaFrameIds
|
|
242
242
|
});
|
|
243
243
|
} catch (b) {
|
|
@@ -247,24 +247,24 @@ function qe(r = {}) {
|
|
|
247
247
|
baselineId: a.qaBaselineId,
|
|
248
248
|
complete: !1,
|
|
249
249
|
frames: [],
|
|
250
|
-
failures: a.qaFrameIds.map((
|
|
250
|
+
failures: a.qaFrameIds.map((oe) => ({ id: oe, error: P }))
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
|
-
return
|
|
254
|
-
applied:
|
|
253
|
+
return y.current = null, {
|
|
254
|
+
applied: f,
|
|
255
255
|
branch: l.session.branchName ?? void 0,
|
|
256
256
|
integration: l.session.integration.state,
|
|
257
|
-
message: d == null ? void 0 : d(l.session,
|
|
257
|
+
message: d == null ? void 0 : d(l.session, f),
|
|
258
258
|
...w ? { qa: w } : {}
|
|
259
259
|
};
|
|
260
260
|
},
|
|
261
261
|
[t, d, c, n, u]
|
|
262
|
-
),
|
|
262
|
+
), _ = j(
|
|
263
263
|
async (o) => {
|
|
264
|
-
var
|
|
264
|
+
var m;
|
|
265
265
|
if (!n) throw new Error("Pygmalion design session is not ready");
|
|
266
|
-
|
|
267
|
-
const a = await
|
|
266
|
+
y.current = null;
|
|
267
|
+
const a = await O(
|
|
268
268
|
await t(`${u}/preview-visual`, {
|
|
269
269
|
method: "POST",
|
|
270
270
|
headers: { "content-type": "application/json" },
|
|
@@ -278,48 +278,48 @@ function qe(r = {}) {
|
|
|
278
278
|
);
|
|
279
279
|
if (!a.ok || !Number.isSafeInteger(a.revision))
|
|
280
280
|
throw new Error(a.error ?? "Pygmalion could not preview the visual changes");
|
|
281
|
-
const l =
|
|
282
|
-
let
|
|
283
|
-
const w = n.appOrigin ??
|
|
281
|
+
const l = I ? ke(o, x) : [];
|
|
282
|
+
let f;
|
|
283
|
+
const w = n.appOrigin ?? S.appOrigin;
|
|
284
284
|
if (l.length > 0) {
|
|
285
285
|
if (!w)
|
|
286
286
|
throw new Error("Impact screen QA baseline preview not ready");
|
|
287
|
-
if (
|
|
287
|
+
if (f = await ie(t, c, {
|
|
288
288
|
phase: "baseline",
|
|
289
|
-
basePath:
|
|
289
|
+
basePath: ne(w, window.location.origin),
|
|
290
290
|
frameIds: l
|
|
291
|
-
}), !
|
|
291
|
+
}), !f.complete)
|
|
292
292
|
throw new Error(
|
|
293
|
-
((
|
|
293
|
+
((m = f.failures[0]) == null ? void 0 : m.error) ?? `Failed to capture ${l.length - f.frames.length} affected frames`
|
|
294
294
|
);
|
|
295
295
|
}
|
|
296
|
-
return
|
|
296
|
+
return y.current = {
|
|
297
297
|
sessionId: n.id,
|
|
298
298
|
baseDevSha: n.baseDevSha,
|
|
299
299
|
revision: a.revision,
|
|
300
300
|
fingerprint: JSON.stringify(o),
|
|
301
|
-
...
|
|
301
|
+
...f ? { qaBaselineId: f.baselineId, qaFrameIds: l } : {}
|
|
302
302
|
}, {
|
|
303
303
|
revision: a.revision,
|
|
304
304
|
files: Array.isArray(a.files) ? a.files : [],
|
|
305
305
|
affectedFiles: Array.isArray(a.affectedFiles) ? a.affectedFiles : [],
|
|
306
|
-
...
|
|
306
|
+
...f ? { qa: f } : {}
|
|
307
307
|
};
|
|
308
308
|
},
|
|
309
309
|
[
|
|
310
310
|
t,
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
S.appOrigin,
|
|
312
|
+
x,
|
|
313
313
|
c,
|
|
314
314
|
n,
|
|
315
315
|
u,
|
|
316
|
-
|
|
316
|
+
I
|
|
317
317
|
]
|
|
318
|
-
),
|
|
318
|
+
), p = j(
|
|
319
319
|
async (o) => {
|
|
320
320
|
if (o.length === 0) return { files: [] };
|
|
321
|
-
const a = await
|
|
322
|
-
await t(`${
|
|
321
|
+
const a = await O(
|
|
322
|
+
await t(`${A}/impact`, {
|
|
323
323
|
method: "POST",
|
|
324
324
|
headers: { "content-type": "application/json" },
|
|
325
325
|
body: JSON.stringify({ componentFiles: o })
|
|
@@ -329,11 +329,11 @@ function qe(r = {}) {
|
|
|
329
329
|
throw new Error(a.error ?? "Pygmalion could not calculate source impact");
|
|
330
330
|
return { files: Array.isArray(a.files) ? a.files : [] };
|
|
331
331
|
},
|
|
332
|
-
[t,
|
|
333
|
-
),
|
|
332
|
+
[t, A]
|
|
333
|
+
), N = j(async () => {
|
|
334
334
|
if (!(n != null && n.canRevert) || !n.headSha)
|
|
335
335
|
throw new Error("There are no reversible changes applied");
|
|
336
|
-
const o = await
|
|
336
|
+
const o = await O(
|
|
337
337
|
await t(`${u}/revert-visual`, {
|
|
338
338
|
method: "POST",
|
|
339
339
|
headers: { "content-type": "application/json" },
|
|
@@ -347,106 +347,157 @@ function qe(r = {}) {
|
|
|
347
347
|
);
|
|
348
348
|
if (!o.ok || o.reverted !== !0 || !o.operation || o.operation.kind !== "visual-revert" || !o.session)
|
|
349
349
|
throw new Error(o.error ?? "Pygmalion could not revert the last visual change");
|
|
350
|
-
return
|
|
350
|
+
return y.current = null, k(o.session), o.session.appOrigin && D(o.session.appOrigin), {
|
|
351
351
|
reverted: !0,
|
|
352
352
|
operation: o.operation,
|
|
353
353
|
session: o.session
|
|
354
354
|
};
|
|
355
355
|
}, [t, n, u]);
|
|
356
|
-
|
|
357
|
-
i &&
|
|
358
|
-
}, [i,
|
|
359
|
-
const
|
|
356
|
+
B(() => {
|
|
357
|
+
i && T(!1);
|
|
358
|
+
}, [i, T]);
|
|
359
|
+
const M = (n == null ? void 0 : n.appOrigin) ?? S.appOrigin ?? R;
|
|
360
360
|
return {
|
|
361
|
-
mirror:
|
|
361
|
+
mirror: S,
|
|
362
362
|
session: n,
|
|
363
363
|
ready: R != null,
|
|
364
|
-
appOrigin:
|
|
365
|
-
previewRevision: `${(n == null ? void 0 : n.headSha) ?? (n == null ? void 0 : n.baseDevSha) ??
|
|
366
|
-
refresh:
|
|
367
|
-
previewVisual:
|
|
368
|
-
inspectImpact:
|
|
369
|
-
applyVisual:
|
|
370
|
-
revertLastVisual:
|
|
364
|
+
appOrigin: M,
|
|
365
|
+
previewRevision: `${(n == null ? void 0 : n.headSha) ?? (n == null ? void 0 : n.baseDevSha) ?? S.commit ?? "pending"}:${(n == null ? void 0 : n.revision) ?? 0}`,
|
|
366
|
+
refresh: T,
|
|
367
|
+
previewVisual: _,
|
|
368
|
+
inspectImpact: p,
|
|
369
|
+
applyVisual: U,
|
|
370
|
+
revertLastVisual: N
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
|
-
const
|
|
374
|
-
function
|
|
375
|
-
|
|
373
|
+
const Qe = { editor: v, getObserverTree: ce, isObservableProp: le };
|
|
374
|
+
function Be(r) {
|
|
375
|
+
v.navigateToPageByName(r);
|
|
376
376
|
}
|
|
377
|
-
function
|
|
378
|
-
|
|
377
|
+
function Me() {
|
|
378
|
+
v.openPreview();
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
const r =
|
|
382
|
-
return r &&
|
|
380
|
+
function Le() {
|
|
381
|
+
const r = K.entries.length > 0;
|
|
382
|
+
return r && K.discardPending(), v.resetCurrentEdits() || r;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function ze({
|
|
385
385
|
registry: r,
|
|
386
386
|
tokens: e,
|
|
387
387
|
initialPages: s,
|
|
388
388
|
designImport: i,
|
|
389
389
|
onTokensChange: t,
|
|
390
390
|
appOrigin: d,
|
|
391
|
-
previewRevision:
|
|
391
|
+
previewRevision: h,
|
|
392
392
|
previewCacheNamespace: u,
|
|
393
|
-
previewArtifacts:
|
|
394
|
-
previewConcurrency:
|
|
393
|
+
previewArtifacts: A,
|
|
394
|
+
previewConcurrency: I,
|
|
395
395
|
previewOpen: c,
|
|
396
|
-
onPreviewOpenChange:
|
|
397
|
-
flowCanvas:
|
|
398
|
-
onApply:
|
|
399
|
-
onDesignChange:
|
|
400
|
-
onInspectApply:
|
|
396
|
+
onPreviewOpenChange: g,
|
|
397
|
+
flowCanvas: x,
|
|
398
|
+
onApply: H,
|
|
399
|
+
onDesignChange: S,
|
|
400
|
+
onInspectApply: F,
|
|
401
401
|
onInspectPreview: n,
|
|
402
|
-
onInspectImpact:
|
|
402
|
+
onInspectImpact: k,
|
|
403
|
+
storyboardDiscovery: R = !0,
|
|
404
|
+
storyboardDiscoveryEndpoint: D = Se
|
|
403
405
|
}) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
const [E, y] = Q(!R);
|
|
407
|
+
i && (i.assertComplete(), de(i));
|
|
408
|
+
const T = r ?? (i == null ? void 0 : i.getRegistry()), U = e ?? (i == null ? void 0 : i.getTokens()), _ = s ?? (i == null ? void 0 : i.getInitialPages());
|
|
409
|
+
return T && ue(T), U && fe(U), Oe(t ?? null), d != null && he(d), h != null && pe(h), me(u), A && _ && ge(A, {
|
|
407
410
|
namespace: u ?? "",
|
|
408
|
-
previewRevision:
|
|
409
|
-
appOrigin:
|
|
410
|
-
pages:
|
|
411
|
+
previewRevision: Ee(),
|
|
412
|
+
appOrigin: Ie(),
|
|
413
|
+
pages: _.flatMap(
|
|
411
414
|
(p) => p.route && p.importPageId ? [
|
|
412
415
|
{
|
|
413
416
|
canonicalId: p.importPageId,
|
|
414
417
|
route: p.route,
|
|
415
418
|
width: p.width,
|
|
416
419
|
height: p.height,
|
|
420
|
+
environment: p.environment,
|
|
417
421
|
preset: p.preset,
|
|
418
422
|
interactions: p.interactions,
|
|
419
423
|
assertions: p.assertions
|
|
420
424
|
}
|
|
421
425
|
] : []
|
|
422
426
|
)
|
|
423
|
-
}),
|
|
424
|
-
|
|
425
|
-
const p =
|
|
427
|
+
}), I != null && ye(I), Ne(g ?? null), x != null && we(x), Ae(H ?? null), Re(F ?? null), be(n ?? null), De(k ?? null), _ && v.initPagesFromComponents(_), B(() => {
|
|
428
|
+
X(S ?? null);
|
|
429
|
+
const p = ve(v);
|
|
426
430
|
return () => {
|
|
427
|
-
p(),
|
|
431
|
+
p(), X(null);
|
|
428
432
|
};
|
|
429
|
-
}, [
|
|
430
|
-
|
|
431
|
-
|
|
433
|
+
}, [S]), B(() => {
|
|
434
|
+
let p = !0;
|
|
435
|
+
return R ? (y(!1), fetch(D, {
|
|
436
|
+
headers: { accept: "application/json" },
|
|
437
|
+
cache: "no-store"
|
|
438
|
+
}).then(async (N) => {
|
|
439
|
+
if (!N.ok) throw new Error(`Storyboard discovery failed (${N.status})`);
|
|
440
|
+
return N.json();
|
|
441
|
+
}).then((N) => {
|
|
442
|
+
var $, C;
|
|
443
|
+
if (!p) return;
|
|
444
|
+
const M = (C = ($ = N.scenarios) == null ? void 0 : $.find(
|
|
445
|
+
(q) => q.id === "environment:baseline"
|
|
446
|
+
)) == null ? void 0 : C.environment;
|
|
447
|
+
L(M);
|
|
448
|
+
}).catch(() => {
|
|
449
|
+
p && L(void 0);
|
|
450
|
+
}).finally(() => {
|
|
451
|
+
p && y(!0);
|
|
452
|
+
}), () => {
|
|
453
|
+
p = !1;
|
|
454
|
+
}) : (L(void 0), y(!0), () => {
|
|
455
|
+
p = !1;
|
|
456
|
+
});
|
|
457
|
+
}, [R, D]), B(() => {
|
|
458
|
+
c == null || c === v.previewOpen || (c ? v.openPreview({ notifyHost: !1 }) : v.closePreview({ notifyHost: !1 }));
|
|
459
|
+
}, [c]), E ? /* @__PURE__ */ Z(Pe, {}) : /* @__PURE__ */ Z(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
"data-pygmalion-storyboard-loading": "",
|
|
463
|
+
role: "status",
|
|
464
|
+
style: {
|
|
465
|
+
display: "grid",
|
|
466
|
+
width: "100%",
|
|
467
|
+
height: "100%",
|
|
468
|
+
placeItems: "center",
|
|
469
|
+
color: "#777777",
|
|
470
|
+
background: "#f5f5f5",
|
|
471
|
+
font: "12px system-ui, sans-serif"
|
|
472
|
+
},
|
|
473
|
+
children: "Discovering storyboard branches"
|
|
474
|
+
}
|
|
475
|
+
);
|
|
432
476
|
}
|
|
433
477
|
export {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Xe as
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
478
|
+
Ye as DESIGN_IMPORT_KINDS,
|
|
479
|
+
ze as PygmalionEditor,
|
|
480
|
+
Se as STORYBOARD_ENVIRONMENT_CONTROL,
|
|
481
|
+
We as STORYBOARD_ENVIRONMENT_QUERY,
|
|
482
|
+
Qe as __debug,
|
|
483
|
+
Ze as applyTokenOverride,
|
|
484
|
+
Ke as clearPygmalionPreviewCache,
|
|
485
|
+
Xe as createDesignImportController,
|
|
486
|
+
er as createDesignScreenCollection,
|
|
487
|
+
rr as createStoryboardRouteUrl,
|
|
488
|
+
tr as getRecommendedPygmalionPreviewConcurrency,
|
|
489
|
+
nr as getStoryboardBaselineEnvironment,
|
|
490
|
+
sr as mergeScreenPresets,
|
|
491
|
+
ir as mergeStoryboardEnvironment,
|
|
492
|
+
Be as pygmalionNavigate,
|
|
493
|
+
Me as pygmalionOpenPreview,
|
|
494
|
+
Le as pygmalionResetCurrentEdits,
|
|
495
|
+
ar as resetTokenOverrides,
|
|
496
|
+
ue as setComponentRegistry,
|
|
447
497
|
he as setPygmalionAppOrigin,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
498
|
+
ye as setPygmalionPreviewConcurrency,
|
|
499
|
+
pe as setPygmalionPreviewRevision,
|
|
500
|
+
L as setStoryboardBaselineEnvironment,
|
|
501
|
+
fe as setTokens,
|
|
502
|
+
Je as usePygmalionProject
|
|
452
503
|
};
|