@pygmalionjs/pygmalion 0.6.4 → 0.6.6
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/README.md +1 -1
- package/dist-lib/{FrozenRoutePreview-V9-gxIyv.js → FrozenRoutePreview-CBsH9Pei.js} +1577 -1494
- package/dist-lib/pygmalion.js +9262 -7515
- package/dist-lib/style.css +1 -1
- package/dist-lib/testing.js +1 -1
- package/dist-lib/types/canvas/CameraLayer.d.ts +3 -1
- package/dist-lib/types/canvas/FrameView.d.ts +2 -0
- package/dist-lib/types/editor/designImport.d.ts +7 -1
- package/dist-lib/types/editor/frameInteraction.d.ts +66 -0
- package/dist-lib/types/editor/frameScrollControls.d.ts +40 -0
- package/dist-lib/types/editor/previewBootstrap.d.ts +17 -1
- package/dist-lib/types/editor/shadowPreview.d.ts +2 -0
- package/dist-lib/types/editor/store.d.ts +27 -0
- package/dist-lib/types/editor/storyboardGraph.d.ts +17 -1
- package/dist-lib/types/editor/storyboardGraphView.d.ts +7 -0
- package/dist-lib/types/editor/storyboardJourney.d.ts +4 -0
- package/dist-lib/types/lib.d.ts +3 -1
- package/dist-lib/types/shell/ComponentStateControls.d.ts +14 -1
- package/dist-lib/types/shell/StoryboardGraphPanel.d.ts +5 -1
- package/docs/screen-state-contract.md +35 -5
- package/node/storyboard-capture-runtime.mjs +65 -3
- package/package.json +1 -1
|
@@ -37,6 +37,19 @@ Use a same-frame axis when all of these are true:
|
|
|
37
37
|
Pseudo states such as hover, keyboard focus, and pointer active are always
|
|
38
38
|
interaction states. They must not become duplicate frames.
|
|
39
39
|
|
|
40
|
+
## Frame size
|
|
41
|
+
|
|
42
|
+
The W and H controls in the frame inspector change the frame viewport, not the
|
|
43
|
+
canvas camera. A committed size is part of the frame fingerprint and its exact
|
|
44
|
+
capture recipe. The request carries the route, width, height, conditions, and
|
|
45
|
+
interactions that produced that fingerprint, and a returned artifact is seeded
|
|
46
|
+
under that requested recipe instead of the authored catalog key.
|
|
47
|
+
|
|
48
|
+
This distinction is observable: resizing a frame may change responsive layout,
|
|
49
|
+
while changing canvas zoom only changes how large the same frame appears in the
|
|
50
|
+
editor. Hosts that implement an on-demand capture adapter must apply the
|
|
51
|
+
requested `route`, `width`, and `height` overrides before launching the capture.
|
|
52
|
+
|
|
40
53
|
## Automatic pseudo-state coverage
|
|
41
54
|
|
|
42
55
|
Pygmalion discovers pseudo-state surfaces while it serializes a screen. Every
|
|
@@ -66,15 +79,18 @@ Pygmalion discovers visible CSS animation owners, animated pseudo elements,
|
|
|
66
79
|
matching animation rules, and Web Animations API targets while it serializes a
|
|
67
80
|
screen. It stamps every target into the inert preview and lists them under
|
|
68
81
|
**Motion**. Reviewers can play all motion together, isolate one target, pause
|
|
69
|
-
it, reset it to the deterministic
|
|
82
|
+
it, reset it to the deterministic visual baseline, or scrub through one cycle
|
|
70
83
|
with the Phase control.
|
|
71
84
|
|
|
72
85
|
Motion discovery has no semantic or size threshold. Small progress dots,
|
|
73
86
|
ordinary status indicators, shimmer bars, and full-surface animation receive
|
|
74
|
-
the same control. The default preview
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
the same control. The default preview holds finite animations at their terminal
|
|
88
|
+
state and repeating animations at the start of their cycle. This keeps entrance
|
|
89
|
+
motion from hiding the base UI while screenshots and visual comparisons remain
|
|
90
|
+
repeatable. Play, Pause, or Phase explicitly enters the motion timeline at the
|
|
91
|
+
selected phase; Reset restores the visual baseline. Using a Motion control
|
|
92
|
+
temporarily switches an imported frame back to its source DOM preview,
|
|
93
|
+
including while the editor is in Editing mode.
|
|
78
94
|
|
|
79
95
|
An animation does not need duplicate frames merely to show several points in
|
|
80
96
|
its cycle. Preserve a separate frame only when the motion ends in an independent
|
|
@@ -157,6 +173,20 @@ result. This keeps empty strings and maximum-length samples out of the state
|
|
|
157
173
|
panel while still allowing a search input to reproduce a real empty-result
|
|
158
174
|
state.
|
|
159
175
|
|
|
176
|
+
## Scroll positions
|
|
177
|
+
|
|
178
|
+
A stable scroll endpoint is an interaction state. Use a `scroll` recipe step
|
|
179
|
+
with absolute `scrollX` and/or `scrollY` coordinates. With no selector the step
|
|
180
|
+
restores the document viewport; a selector targets a specific overflow
|
|
181
|
+
container. An omitted axis keeps its current position.
|
|
182
|
+
|
|
183
|
+
Absolute coordinates make the endpoint repeatable in both the in-editor replay
|
|
184
|
+
and the capture worker. A free wheel gesture remains transient until the host
|
|
185
|
+
preserves its endpoint as a recipe. The frame inspector enumerates the document
|
|
186
|
+
viewport and independently scrollable nested surfaces. Preserving one records
|
|
187
|
+
both its stable selector and coordinates; the target picker keeps nested list
|
|
188
|
+
or panel scroll distinct from the document viewport.
|
|
189
|
+
|
|
160
190
|
## Held pseudo states
|
|
161
191
|
|
|
162
192
|
Recipes support `hover`, `focus-visible`, and `active` in addition to `focus`.
|
|
@@ -94,11 +94,40 @@ function throwIfAborted(signal) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Holds one-shot motion at its terminal visual state while keeping repeating
|
|
99
|
+
* motion at a deterministic cycle origin. A frozen screen is the review
|
|
100
|
+
* baseline, so an entrance animation must not make its own content disappear.
|
|
101
|
+
*
|
|
102
|
+
* This function runs through page.evaluate and must remain self-contained.
|
|
103
|
+
*/
|
|
104
|
+
export function settleStoryboardAnimations() {
|
|
98
105
|
for (const animation of document.getAnimations?.({ subtree: true }) ?? []) {
|
|
99
106
|
try {
|
|
100
107
|
animation.pause();
|
|
101
|
-
|
|
108
|
+
const timing = animation.effect?.getComputedTiming?.();
|
|
109
|
+
const computedEndTime = Number(timing?.endTime);
|
|
110
|
+
if (Number.isFinite(computedEndTime)) {
|
|
111
|
+
animation.currentTime = Math.max(0, computedEndTime);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (computedEndTime === Number.POSITIVE_INFINITY) {
|
|
115
|
+
animation.currentTime = 0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Browser timing objects expose endTime, but the fallback keeps custom
|
|
120
|
+
// Animation implementations and older engines deterministic as well.
|
|
121
|
+
const duration = Number(timing?.duration);
|
|
122
|
+
const iterations =
|
|
123
|
+
timing?.iterations == null ? 1 : Number(timing.iterations);
|
|
124
|
+
const delay = Number(timing?.delay ?? 0);
|
|
125
|
+
const endDelay = Number(timing?.endDelay ?? 0);
|
|
126
|
+
const fallbackEndTime =
|
|
127
|
+
delay + duration * Math.max(0, iterations) + endDelay;
|
|
128
|
+
animation.currentTime = Number.isFinite(fallbackEndTime)
|
|
129
|
+
? Math.max(0, fallbackEndTime)
|
|
130
|
+
: 0;
|
|
102
131
|
} catch {
|
|
103
132
|
// An animation owned by an unavailable timeline remains CSS-paused.
|
|
104
133
|
}
|
|
@@ -112,7 +141,7 @@ async function freezeStoryboardMotion(page, addStyle = true) {
|
|
|
112
141
|
element.setAttribute('data-pygmalion-preview', 'frozen');
|
|
113
142
|
});
|
|
114
143
|
}
|
|
115
|
-
await page.evaluate(
|
|
144
|
+
await page.evaluate(settleStoryboardAnimations);
|
|
116
145
|
}
|
|
117
146
|
|
|
118
147
|
async function atCaptureStage(stage, task, details = {}) {
|
|
@@ -394,6 +423,39 @@ export async function runStoryboardInteraction(page, interaction) {
|
|
|
394
423
|
return;
|
|
395
424
|
}
|
|
396
425
|
|
|
426
|
+
if (interaction.action === 'scroll') {
|
|
427
|
+
const position = {
|
|
428
|
+
x: Number.isFinite(interaction.scrollX) ? Math.max(0, interaction.scrollX) : null,
|
|
429
|
+
y: Number.isFinite(interaction.scrollY) ? Math.max(0, interaction.scrollY) : null,
|
|
430
|
+
};
|
|
431
|
+
if (interaction.selector || interaction.text) {
|
|
432
|
+
const timeoutMs = interaction.timeoutMs ?? 5_000;
|
|
433
|
+
const target = await waitForCandidateLocator(
|
|
434
|
+
page,
|
|
435
|
+
interaction,
|
|
436
|
+
timeoutMs,
|
|
437
|
+
);
|
|
438
|
+
if (!(await targetExists(target, Math.min(timeoutMs, 500)))) {
|
|
439
|
+
throw new Error(`"${interaction.label}" scroll target was not found.`);
|
|
440
|
+
}
|
|
441
|
+
await target.evaluate((element, next) => {
|
|
442
|
+
const left = next.x ?? element.scrollLeft;
|
|
443
|
+
const top = next.y ?? element.scrollTop;
|
|
444
|
+
if (typeof element.scrollTo === 'function') element.scrollTo(left, top);
|
|
445
|
+
else {
|
|
446
|
+
element.scrollLeft = left;
|
|
447
|
+
element.scrollTop = top;
|
|
448
|
+
}
|
|
449
|
+
}, position);
|
|
450
|
+
} else {
|
|
451
|
+
await page.evaluate((next) => {
|
|
452
|
+
window.scrollTo(next.x ?? window.scrollX, next.y ?? window.scrollY);
|
|
453
|
+
}, position);
|
|
454
|
+
}
|
|
455
|
+
await page.waitForTimeout(interaction.settleMs ?? 100);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
397
459
|
const timeoutMs = interaction.timeoutMs ?? 5_000;
|
|
398
460
|
const target = await waitForCandidateLocator(page, interaction, timeoutMs);
|
|
399
461
|
if (!(await targetExists(target, Math.min(timeoutMs, 500)))) {
|