@pygmalionjs/pygmalion 0.6.3 → 0.6.5

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.
@@ -1,4 +1,4 @@
1
- import { F as s, N as a, e as r, s as i, a as t } from "./FrozenRoutePreview-V9-gxIyv.js";
1
+ import { F as s, N as a, e as r, s as i, a as t } from "./FrozenRoutePreview-BVYL3dLT.js";
2
2
  export {
3
3
  s as FrozenRoutePreviewView,
4
4
  a as NodeModel,
@@ -6,12 +6,39 @@ export interface PygmalionPreviewCaptureProgress {
6
6
  completed: number;
7
7
  total: number;
8
8
  jobCount: number;
9
+ /** Stable worker-job identity used to join consecutive capture batches. */
10
+ jobId?: string;
11
+ /** Current worker batch, when the public counters represent the whole catalog. */
12
+ batchCompleted?: number;
13
+ /** Current worker batch size, when the public counters represent the whole catalog. */
14
+ batchTotal?: number;
9
15
  frameId?: string;
10
16
  captureStatus?: string;
11
17
  updatedAt?: number;
12
18
  }
19
+ export interface PygmalionPreviewCaptureCatalogProgress {
20
+ active: boolean;
21
+ completed: number;
22
+ total: number;
23
+ jobCount: number;
24
+ updatedAt?: number;
25
+ }
26
+ export declare function getPreviewCaptureCatalogProgress(): PygmalionPreviewCaptureCatalogProgress;
27
+ export declare function subscribePreviewCaptureCatalogProgress(listener: () => void): () => void;
28
+ export declare function publishPreviewCaptureCatalogProgress(value: PygmalionPreviewCaptureCatalogProgress): void;
29
+ export declare function resetPreviewCaptureCatalogProgress(): void;
13
30
  export declare function previewCaptureProgressEndpoint(artifactEndpoint: string): string;
14
31
  export declare function normalizePreviewCaptureProgress(value: unknown): PygmalionPreviewCaptureProgress | null;
32
+ export interface PreviewCaptureProgressMergeState {
33
+ jobId?: string;
34
+ baseline: number;
35
+ lastBatchCompleted: number;
36
+ lastBatchTotal: number;
37
+ }
38
+ export declare function mergePreviewCaptureProgress(worker: PygmalionPreviewCaptureProgress, catalog: PygmalionPreviewCaptureCatalogProgress, previous: PreviewCaptureProgressMergeState | null): {
39
+ progress: PygmalionPreviewCaptureProgress;
40
+ state: PreviewCaptureProgressMergeState | null;
41
+ };
15
42
  /**
16
43
  * Reads the local preview worker's current progress from the artifact plugin.
17
44
  * Idle polling is deliberately slower; an active capture tightens the interval
@@ -66,15 +66,18 @@ Pygmalion discovers visible CSS animation owners, animated pseudo elements,
66
66
  matching animation rules, and Web Animations API targets while it serializes a
67
67
  screen. It stamps every target into the inert preview and lists them under
68
68
  **Motion**. Reviewers can play all motion together, isolate one target, pause
69
- it, reset it to the deterministic capture point, or scrub through one cycle
69
+ it, reset it to the deterministic visual baseline, or scrub through one cycle
70
70
  with the Phase control.
71
71
 
72
72
  Motion discovery has no semantic or size threshold. Small progress dots,
73
73
  ordinary status indicators, shimmer bars, and full-surface animation receive
74
- the same control. The default preview remains frozen at the start of its
75
- animation timeline so screenshots and visual comparisons stay repeatable.
76
- Using a Motion control temporarily switches an imported frame back to its
77
- source DOM preview, including while the editor is in Editing mode.
74
+ the same control. The default preview holds finite animations at their terminal
75
+ state and repeating animations at the start of their cycle. This keeps entrance
76
+ motion from hiding the base UI while screenshots and visual comparisons remain
77
+ repeatable. Play, Pause, or Phase explicitly enters the motion timeline at the
78
+ selected phase; Reset restores the visual baseline. Using a Motion control
79
+ temporarily switches an imported frame back to its source DOM preview,
80
+ including while the editor is in Editing mode.
78
81
 
79
82
  An animation does not need duplicate frames merely to show several points in
80
83
  its cycle. Preserve a separate frame only when the motion ends in an independent
@@ -316,8 +316,8 @@ export function pygmalionPreviewArtifactPlugin({
316
316
  let captureJobCounter = 0;
317
317
 
318
318
  function readCaptureProgress() {
319
- const jobs = [...captureJobs.values()];
320
- if (jobs.length === 0) {
319
+ const entries = [...captureJobs.entries()];
320
+ if (entries.length === 0) {
321
321
  return {
322
322
  active: false,
323
323
  phase: 'idle',
@@ -326,6 +326,7 @@ export function pygmalionPreviewArtifactPlugin({
326
326
  jobCount: 0,
327
327
  };
328
328
  }
329
+ const jobs = entries.map(([, job]) => job);
329
330
  const phases = new Set(jobs.map((job) => job.phase));
330
331
  const phase = phases.has('capturing')
331
332
  ? 'capturing'
@@ -345,6 +346,10 @@ export function pygmalionPreviewArtifactPlugin({
345
346
  completed: jobs.reduce((sum, job) => sum + job.completed, 0),
346
347
  total: jobs.reduce((sum, job) => sum + job.total, 0),
347
348
  jobCount: jobs.length,
349
+ jobId: entries
350
+ .map(([id]) => id)
351
+ .sort()
352
+ .join(','),
348
353
  ...(latest.frameId ? { frameId: latest.frameId } : {}),
349
354
  ...(latest.captureStatus
350
355
  ? { captureStatus: latest.captureStatus }
@@ -94,11 +94,40 @@ function throwIfAborted(signal) {
94
94
  }
95
95
  }
96
96
 
97
- function resetStoryboardAnimations() {
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
- animation.currentTime = 0;
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(resetStoryboardAnimations);
144
+ await page.evaluate(settleStoryboardAnimations);
116
145
  }
117
146
 
118
147
  async function atCaptureStage(stage, task, details = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {