@pygmalionjs/pygmalion 0.7.4 → 0.8.0

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.
Files changed (133) hide show
  1. package/README.ko.md +17 -2
  2. package/README.md +18 -2
  3. package/dist-lib/CameraLayer-nkNrazn8.js +159 -0
  4. package/dist-lib/pygmalion.js +14628 -16995
  5. package/dist-lib/runtime-DdYnT6k4.js +19705 -0
  6. package/dist-lib/style.css +1 -1
  7. package/dist-lib/testing.js +20 -21
  8. package/dist-lib/types/EditorShell.d.ts +1 -1
  9. package/dist-lib/types/canvas/CameraLayer.d.ts +3 -3
  10. package/dist-lib/types/canvas/Canvas.d.ts +2 -2
  11. package/dist-lib/types/canvas/FrameLabelBanner.d.ts +1 -1
  12. package/dist-lib/types/canvas/FrameView.d.ts +8 -2
  13. package/dist-lib/types/canvas/FrozenRoutePreview.d.ts +1 -1
  14. package/dist-lib/types/canvas/InspectOverlay.d.ts +4 -2
  15. package/dist-lib/types/canvas/LightweightCanvas.d.ts +1 -1
  16. package/dist-lib/types/canvas/SectionBoxes.d.ts +1 -1
  17. package/dist-lib/types/canvas/ShadowRoutePreview.d.ts +2 -2
  18. package/dist-lib/types/canvas/useFlowSession.d.ts +1 -1
  19. package/dist-lib/types/canvas/useFrameLod.d.ts +1 -1
  20. package/dist-lib/types/contract/transport.d.ts +5 -5
  21. package/dist-lib/types/contract/types.d.ts +1 -1
  22. package/dist-lib/types/contract/validate.d.ts +3 -3
  23. package/dist-lib/types/core/context.d.ts +2 -2
  24. package/dist-lib/types/core/debug.d.ts +14 -14
  25. package/dist-lib/types/core/hostBindings.d.ts +2 -2
  26. package/dist-lib/types/core/runtime.d.ts +34 -3
  27. package/dist-lib/types/core/runtimeContext.d.ts +3 -3
  28. package/dist-lib/types/core/schedulers.d.ts +67 -0
  29. package/dist-lib/types/editor/assetEditing.d.ts +2 -2
  30. package/dist-lib/types/editor/automaticMotion.d.ts +0 -11
  31. package/dist-lib/types/editor/automaticPseudoStates.d.ts +8 -2
  32. package/dist-lib/types/editor/captureSupply.d.ts +16 -7
  33. package/dist-lib/types/editor/catalog.d.ts +2 -2
  34. package/dist-lib/types/editor/codegen.d.ts +6 -3
  35. package/dist-lib/types/editor/componentConnections.d.ts +13 -8
  36. package/dist-lib/types/editor/componentInstances.d.ts +2 -2
  37. package/dist-lib/types/editor/declarations.d.ts +107 -0
  38. package/dist-lib/types/editor/designCompiler.d.ts +9 -4
  39. package/dist-lib/types/editor/designImport.d.ts +48 -12
  40. package/dist-lib/types/editor/documentSync.d.ts +28 -25
  41. package/dist-lib/types/editor/domImport.d.ts +2 -2
  42. package/dist-lib/types/editor/fiberMap.d.ts +1 -1
  43. package/dist-lib/types/editor/flowSessionScheduler.d.ts +106 -159
  44. package/dist-lib/types/editor/flowSessions.d.ts +147 -84
  45. package/dist-lib/types/editor/frameInteraction.d.ts +22 -32
  46. package/dist-lib/types/editor/frameLabels.d.ts +11 -5
  47. package/dist-lib/types/editor/frameLanes.d.ts +14 -17
  48. package/dist-lib/types/editor/frameLod.d.ts +17 -0
  49. package/dist-lib/types/editor/frameLodRuntime.d.ts +38 -38
  50. package/dist-lib/types/editor/framePreviewKeys.d.ts +14 -5
  51. package/dist-lib/types/editor/frozenImport.d.ts +13 -14
  52. package/dist-lib/types/editor/heldPseudoStates.d.ts +1 -1
  53. package/dist-lib/types/editor/host.d.ts +10 -55
  54. package/dist-lib/types/editor/implementationSourceMap.d.ts +2 -2
  55. package/dist-lib/types/editor/importFidelity.d.ts +1 -1
  56. package/dist-lib/types/editor/inspect.d.ts +7 -2
  57. package/dist-lib/types/editor/interactiveSessionSurface.d.ts +26 -34
  58. package/dist-lib/types/editor/interactiveStates.d.ts +12 -10
  59. package/dist-lib/types/editor/livePreviewInstances.d.ts +13 -3
  60. package/dist-lib/types/editor/liveScreens.d.ts +25 -16
  61. package/dist-lib/types/editor/mountScheduler.d.ts +8 -11
  62. package/dist-lib/types/editor/nodeSelector.d.ts +1 -1
  63. package/dist-lib/types/editor/pendingSourceChanges.d.ts +19 -0
  64. package/dist-lib/types/editor/previewBootstrap.d.ts +12 -22
  65. package/dist-lib/types/editor/previewCaptureProgress.d.ts +10 -6
  66. package/dist-lib/types/editor/previewEnvironmentControls.d.ts +14 -17
  67. package/dist-lib/types/editor/previewIntent.d.ts +11 -16
  68. package/dist-lib/types/editor/previewSweep.d.ts +7 -3
  69. package/dist-lib/types/editor/previewWarmup.d.ts +19 -7
  70. package/dist-lib/types/editor/projectRuntime.d.ts +2 -2
  71. package/dist-lib/types/editor/registry.d.ts +6 -2
  72. package/dist-lib/types/editor/revisionCatalog.d.ts +19 -19
  73. package/dist-lib/types/editor/revisionCatalogInstall.d.ts +18 -17
  74. package/dist-lib/types/editor/routePreview.d.ts +85 -139
  75. package/dist-lib/types/editor/scenarioCoverage.d.ts +52 -20
  76. package/dist-lib/types/editor/screenCards.d.ts +10 -6
  77. package/dist-lib/types/editor/screenDimensions.d.ts +9 -5
  78. package/dist-lib/types/editor/screenFlows.d.ts +8 -5
  79. package/dist-lib/types/editor/screenInteractions.d.ts +9 -1
  80. package/dist-lib/types/editor/screenLists.d.ts +8 -4
  81. package/dist-lib/types/editor/screenStateGroups.d.ts +1 -1
  82. package/dist-lib/types/editor/sectionHeaders.d.ts +10 -6
  83. package/dist-lib/types/editor/sessionPresets.d.ts +12 -32
  84. package/dist-lib/types/editor/shadowPreview.d.ts +7 -10
  85. package/dist-lib/types/editor/sharedSource.d.ts +4 -2
  86. package/dist-lib/types/editor/sourceChangeSummary.d.ts +1 -1
  87. package/dist-lib/types/editor/sourceJournal.d.ts +2 -2
  88. package/dist-lib/types/editor/stateSwitchMetrics.d.ts +68 -82
  89. package/dist-lib/types/editor/store.d.ts +88 -22
  90. package/dist-lib/types/editor/storyboardAuthored.d.ts +2 -2
  91. package/dist-lib/types/editor/storyboardDiscovery.d.ts +4 -3
  92. package/dist-lib/types/editor/storyboardEnvironment.d.ts +9 -5
  93. package/dist-lib/types/editor/storyboardGraph.d.ts +1 -1
  94. package/dist-lib/types/editor/storyboardGraphRuntime.d.ts +8 -10
  95. package/dist-lib/types/editor/storyboardGraphView.d.ts +1 -1
  96. package/dist-lib/types/editor/storyboardJourney.d.ts +1 -1
  97. package/dist-lib/types/editor/surfaceDemands.d.ts +196 -31
  98. package/dist-lib/types/editor/tokens.d.ts +24 -25
  99. package/dist-lib/types/editor/variantAxes.d.ts +70 -0
  100. package/dist-lib/types/editor/variantPrefetch.d.ts +26 -43
  101. package/dist-lib/types/editor/viewportPresets.d.ts +6 -6
  102. package/dist-lib/types/editor/visualQa.d.ts +2 -2
  103. package/dist-lib/types/lib.d.ts +104 -108
  104. package/dist-lib/types/shell/CatalogAssetPanel.d.ts +1 -1
  105. package/dist-lib/types/shell/CodePanel.d.ts +1 -1
  106. package/dist-lib/types/shell/ComponentStateControls.d.ts +7 -53
  107. package/dist-lib/types/shell/FrameInspector.d.ts +17 -0
  108. package/dist-lib/types/shell/FrameReviewDetails.d.ts +28 -0
  109. package/dist-lib/types/shell/LayerTree.d.ts +1 -1
  110. package/dist-lib/types/shell/StoryboardGraphPanel.d.ts +2 -2
  111. package/dist-lib/types/shell/VariantPanel.d.ts +23 -0
  112. package/dist-lib/types/shell/inspectorControls.d.ts +34 -0
  113. package/dist-lib/types/shell/qaPresentation.d.ts +1 -1
  114. package/dist-lib/types/testing.d.ts +5 -6
  115. package/dist-lib/types/ui/SourceRefControl.d.ts +1 -1
  116. package/docs/coverage-contracts.md +431 -0
  117. package/docs/screen-state-contract.md +14 -16
  118. package/node/component-branches.mjs +7 -13
  119. package/node/design-session.mjs +3 -5
  120. package/node/dev-mirror.mjs +9 -6
  121. package/node/envelope.mjs +43 -0
  122. package/node/impact-frames.mjs +94 -0
  123. package/node/inspect-plugin.mjs +12 -6
  124. package/node/preview-artifact-plugin.mjs +3 -9
  125. package/node/qa-capture-plugin.mjs +3 -6
  126. package/node/source-graph.mjs +1 -0
  127. package/node/storyboard-environment.mjs +33 -6
  128. package/node/vite.mjs +1 -0
  129. package/package.json +7 -2
  130. package/dist-lib/CameraLayer-D2wrEPwG.js +0 -415
  131. package/dist-lib/frameLodRuntime-CU0IYaSu.js +0 -272
  132. package/dist-lib/runtime-DRkTU9eq.js +0 -16195
  133. package/dist-lib/types/core/defaultRuntime.d.ts +0 -3
@@ -43,20 +43,17 @@ export declare const UNDECLARED_LANE_ID = "";
43
43
  export declare function validateScreenLanes(lanes: readonly ScreenLaneDef[], context?: {
44
44
  sections?: readonly string[];
45
45
  }): ScreenLaneDiagnostic[];
46
- export declare function setScreenLanes(lanes: readonly ScreenLaneDef[] | undefined): void;
47
- export declare function getScreenLanes(): readonly ScreenLaneDef[];
48
- /** Declared lanes of one section, in declaration order. */
49
- export declare function lanesForSection(section: string): ScreenLaneDef[];
50
- export declare function laneCaptionFor(section: string, laneId: string): ScreenLaneDef | null;
51
- /**
52
- * Groups frames into lanes in declaration order, appending the implicit lane
53
- * last. A frame tagged with a lane the section did not declare counts as
54
- * undeclared rather than creating a lane of its own, so a typo shows up as a
55
- * frame that fell out of its situation instead of as a phantom row.
56
- */
57
- export declare function groupByLane<T extends {
58
- lane?: string;
59
- }>(section: string, frames: readonly T[]): {
60
- laneId: string;
61
- frames: T[];
62
- }[];
46
+ /** One editor's declared screen lanes. */
47
+ export declare function createFrameLanes(): {
48
+ setScreenLanes: (lanes: readonly ScreenLaneDef[] | undefined) => void;
49
+ getScreenLanes: () => readonly ScreenLaneDef[];
50
+ lanesForSection: (section: string) => ScreenLaneDef[];
51
+ laneCaptionFor: (section: string, laneId: string) => ScreenLaneDef | null;
52
+ groupByLane: <T extends {
53
+ lane?: string;
54
+ }>(section: string, frames: readonly T[]) => {
55
+ laneId: string;
56
+ frames: T[];
57
+ }[];
58
+ };
59
+ export type FrameLanes = ReturnType<typeof createFrameLanes>;
@@ -131,3 +131,20 @@ export declare function resolveFrameLodTiers({ frames, camera, viewport, previou
131
131
  config?: FrameLodConfig;
132
132
  budget: number;
133
133
  }): Map<string, FrameLifecycleTier>;
134
+ /**
135
+ * Which frames should render live, best first: the active frame, then every
136
+ * frame by its screen-space gap to the viewport (intersecting frames first),
137
+ * ties broken by distance from the viewport centre. The live-screen budget
138
+ * takes the head of this list; the rest keep their frozen capture.
139
+ */
140
+ export declare function rankLiveScreenCandidates({ frames, camera, viewport, activeId, preferredIds, }: {
141
+ frames: readonly {
142
+ id: string;
143
+ rect: FrameLodRect;
144
+ }[];
145
+ camera: FrameLodCamera;
146
+ viewport: FrameLodViewport;
147
+ activeId: string | null;
148
+ /** Ids that outrank distance, in order: the active group's standby variants. */
149
+ preferredIds?: readonly string[];
150
+ }): string[];
@@ -1,42 +1,6 @@
1
- import { type FrameLifecycleTier, type FrameLodCamera, type FrameLodConfig, type FrameLodFrame, type FrameLodViewport } from './frameLod';
1
+ import { type FrameLifecycleTier, type FrameLodCamera, type FrameLodConfig, type FrameLodFrame, type FrameLodViewport } from './frameLod.js';
2
2
  /** Frames the controller has not classified render at full detail. */
3
3
  export declare const DEFAULT_FRAME_LOD_TIER: FrameLifecycleTier;
4
- export declare function getFrameTier(frameId: string): FrameLifecycleTier;
5
- /**
6
- * True when the camera currently draws this frame beyond its screenshot's
7
- * pixel density. Published from the same recompute as the tiers, over the
8
- * same per-frame channels, so only frames whose flag flips re-render.
9
- */
10
- export declare function getFrameMagnification(frameId: string): boolean;
11
- /**
12
- * Whether screenshots should display at native capture resolution right now.
13
- * Camera-global: below one device pixel per CSS pixel every frame's
14
- * half-scale bitmap is indistinguishable and far cheaper to keep decoded.
15
- */
16
- export declare function getFrameBitmapFull(): boolean;
17
- export declare function subscribeFrameBitmapScale(listener: () => void): () => void;
18
- /** Diagnostic view of the published LOD state, for headless debugging. */
19
- export declare function __debugFrameLodState(): {
20
- tiers: [string, FrameLifecycleTier][];
21
- magnified: [string, boolean][];
22
- lastRecompute: {
23
- displayDensity?: number;
24
- overview?: boolean;
25
- frames?: {
26
- id: string;
27
- screenshotDensity: number | null | undefined;
28
- tier: string;
29
- }[];
30
- };
31
- };
32
- export declare function subscribeFrameLod(frameId: string, listener: () => void): () => void;
33
- /**
34
- * Total live tier listeners across all frames. A diagnostic seam for leak
35
- * tests: after any number of mount/unmount cycles the count must return to
36
- * what it was before them, because every subscribeFrameLod cleanup removes
37
- * its listener and drops the frame's empty set.
38
- */
39
- export declare function countFrameLodListeners(): number;
40
4
  export interface FrameLodCameraSample extends FrameLodCamera {
41
5
  /** Tracked so a canvas switch retriggers the reaction; unused by the math. */
42
6
  canvas?: string;
@@ -54,6 +18,13 @@ export interface FrameLodControllerOptions {
54
18
  resolveBudget?(frames: readonly FrameLodFrame[]): number;
55
19
  /** Screen device pixels per CSS pixel. Defaults to window.devicePixelRatio. */
56
20
  readDevicePixelRatio?(): number;
21
+ /** Called after every recompute with what it read and decided. */
22
+ onRecompute?(input: {
23
+ frames: readonly FrameLodFrame[];
24
+ camera: FrameLodCameraSample;
25
+ viewport: FrameLodViewport;
26
+ tiers: ReadonlyMap<string, FrameLifecycleTier>;
27
+ }): void;
57
28
  }
58
29
  export interface FrameLodController {
59
30
  start(): void;
@@ -61,4 +32,33 @@ export interface FrameLodController {
61
32
  /** Runs the tier computation immediately (initial mount and tests). */
62
33
  recompute(): void;
63
34
  }
64
- export declare function createFrameLodController(options: FrameLodControllerOptions): FrameLodController;
35
+ /**
36
+ * The per-runtime frame LOD state: the published tiers and magnification
37
+ * flags with their per-frame listeners, the camera-global bitmap-resolution
38
+ * signal, the last recompute diagnostic, and the controller factory that
39
+ * publishes into them. The bodies below are the former module-level
40
+ * functions, closed over instance state instead of module state.
41
+ */
42
+ export declare function createFrameLodRuntime(): {
43
+ getFrameTier: (frameId: string) => FrameLifecycleTier;
44
+ getFrameMagnification: (frameId: string) => boolean;
45
+ getFrameBitmapFull: () => boolean;
46
+ subscribeFrameBitmapScale: (listener: () => void) => () => void;
47
+ __debugFrameLodState: () => {
48
+ tiers: [string, FrameLifecycleTier][];
49
+ magnified: [string, boolean][];
50
+ lastRecompute: {
51
+ displayDensity?: number;
52
+ overview?: boolean;
53
+ frames?: {
54
+ id: string;
55
+ screenshotDensity: number | null | undefined;
56
+ tier: string;
57
+ }[];
58
+ };
59
+ };
60
+ subscribeFrameLod: (frameId: string, listener: () => void) => () => void;
61
+ countFrameLodListeners: () => number;
62
+ createFrameLodController: (options: FrameLodControllerOptions) => FrameLodController;
63
+ };
64
+ export type FrameLodRuntime = ReturnType<typeof createFrameLodRuntime>;
@@ -1,4 +1,6 @@
1
- import type { PageModel } from './store';
1
+ import type { RoutePreviewCache } from './routePreview.js';
2
+ import type { EditorDeclarations } from './declarations.js';
3
+ import type { PageModel } from './store.js';
2
4
  /**
3
5
  * The preview environment of one page: its own declared environment, plus the
4
6
  * host's preview-environment override when the page is the active one.
@@ -10,12 +12,19 @@ import type { PageModel } from './store';
10
12
  * is active (FrameView receives it as a prop; a store-side caller compares
11
13
  * ids), and passing it keeps the computation free of any store.
12
14
  */
13
- export declare function pagePreviewEnvironment(page: PageModel, active: boolean): import("./designImport").StoryboardEnvironment | undefined;
15
+ export declare function pagePreviewEnvironment(declarations: Pick<EditorDeclarations, 'getPreviewEnvironmentOverride'>, page: PageModel, active: boolean): import("./designImport.js").StoryboardEnvironment | undefined;
16
+ /** What a cache key needs from the preview cache: its namespace and its key format. */
17
+ export type RoutePreviewKeySource = Pick<RoutePreviewCache, 'createRoutePreviewRecipeKey' | 'getRoutePreviewCacheNamespace'>;
18
+ /** What a cache key needs from a runtime: its preview cache and its host declarations. */
19
+ export interface RoutePreviewKeyRuntime {
20
+ readonly previews: RoutePreviewKeySource;
21
+ readonly declarations: EditorDeclarations;
22
+ }
14
23
  /**
15
- * The recipe cache key of one page. `active` is forwarded to
16
- * pagePreviewEnvironment — see its note on selection reactivity.
24
+ * The recipe cache key of one page in one runtime's cache. `active` is
25
+ * forwarded to pagePreviewEnvironment — see its note on selection reactivity.
17
26
  */
18
- export declare function routePreviewCacheKey(page: PageModel, previewRevision: string, active: boolean, viewport?: {
27
+ export declare function routePreviewCacheKey(runtime: RoutePreviewKeyRuntime, page: PageModel, previewRevision: string, active: boolean, viewport?: {
19
28
  width: number;
20
29
  height: number;
21
30
  }): string;
@@ -1,6 +1,7 @@
1
- import type { DomImportOptions, DomImportResult } from './domImport';
2
- import type { InstanceResolver } from './fiberMap';
3
- import type { ShadowPreviewHandle } from './shadowPreview';
1
+ import type { DesignImportRegistry } from './designImport.js';
2
+ import type { DomImportOptions, DomImportResult } from './domImport.js';
3
+ import type { InstanceResolver } from './fiberMap.js';
4
+ import type { ShadowPreviewHandle } from './shadowPreview.js';
4
5
  /** Reads Track-D stamped attributes back into the fiberMap InstanceHit shape. */
5
6
  export declare function createStampedInstanceResolver(): InstanceResolver;
6
7
  /**
@@ -47,7 +48,7 @@ export declare function importCountFloor(sourceElements: number): number;
47
48
  * Counts opening tags; the floor only needs the order of magnitude.
48
49
  */
49
50
  export declare function countMarkupElements(markup: string | null | undefined, limit?: number): number;
50
- export declare function importDomFromShadowPreview(handle: ShadowPreviewHandle, options?: ShadowPreviewImportOptions): DomImportResult | null;
51
+ export declare function importDomFromShadowPreview(declarations: Pick<DesignImportRegistry, 'getDesignImportController'>, handle: ShadowPreviewHandle, options?: ShadowPreviewImportOptions): DomImportResult | null;
51
52
  export interface LiveImportSwapInput {
52
53
  /** True when the page tree changed after the provisional frozen import. */
53
54
  editedSinceImport: boolean;
@@ -58,13 +59,11 @@ export interface LiveImportSwapInput {
58
59
  * boot — the existing stale affordance covers manual refresh instead.
59
60
  */
60
61
  export declare function shouldSwapLiveImport(input: LiveImportSwapInput): boolean;
61
- /**
62
- * Registers the live mount handle for a page. The returned cleanup removes
63
- * exactly this registration, so a newer mount is never clobbered by a stale
64
- * teardown.
65
- */
66
- export declare function registerMountedShadowPreview(pageId: string, handle: ShadowPreviewHandle, options?: {
67
- stale?: boolean;
68
- }): () => void;
69
- /** The mounted handle for a page, or null when none is mounted or the mounted preview is stale. */
70
- export declare function getMountedShadowPreviewHandle(pageId: string): ShadowPreviewHandle | null;
62
+ /** The frozen previews one editor has mounted, by page id, so the store and the debug surface can reach a live handle. */
63
+ export declare function createMountedShadowPreviews(): {
64
+ registerMountedShadowPreview: (pageId: string, handle: ShadowPreviewHandle, options?: {
65
+ stale?: boolean;
66
+ }) => () => void;
67
+ getMountedShadowPreviewHandle: (pageId: string) => ShadowPreviewHandle | null;
68
+ };
69
+ export type MountedShadowPreviews = ReturnType<typeof createMountedShadowPreviews>;
@@ -1,4 +1,4 @@
1
- import type { DesignScreenInteraction } from './designImport';
1
+ import type { DesignScreenInteraction } from './designImport.js';
2
2
  export type HeldPseudoState = 'hover' | 'focus' | 'focus-visible' | 'active';
3
3
  /** The pseudo gestures still held after the complete recipe has run. */
4
4
  export declare function heldPseudoInteractionsFromRecipe(interactions: readonly DesignScreenInteraction[]): DesignScreenInteraction[];
@@ -1,6 +1,5 @@
1
- import type { InspectApplyPayload } from './inspect';
2
- import type { DesignImportKind } from './designImport';
3
- import type { InspectQaResult } from './visualQa';
1
+ import type { DesignImportKind } from './designImport.js';
2
+ import type { InspectQaResult } from './visualQa.js';
4
3
  export interface ApplyPayload {
5
4
  tokens: {
6
5
  name: string;
@@ -39,8 +38,16 @@ export interface InspectPreviewResult {
39
38
  /** Based on comparison of impact screens captured in current revision. */
40
39
  qa?: InspectQaResult;
41
40
  }
41
+ /** A frame the node side decided a source change reaches. */
42
+ export interface InspectImpactFrame {
43
+ /** The canonical frame id the editor and the capture worker share. */
44
+ id: string;
45
+ name?: string;
46
+ }
42
47
  export interface InspectImpactResult {
43
48
  files: string[];
49
+ /** Present when the service knows the revision catalog; the editor prefers it to its own matching. */
50
+ frames?: InspectImpactFrame[];
44
51
  }
45
52
  /**
46
53
  * Unit of code edited on the canvas.
@@ -93,55 +100,3 @@ export interface DesignChangeResult {
93
100
  files?: string[];
94
101
  message?: string;
95
102
  }
96
- /** @deprecated Use `runtime.host.setAppOrigin`. */
97
- export declare function setAppOrigin(origin: string): void;
98
- /** @deprecated Use `runtime.host.appOrigin`. */
99
- export declare function getAppOrigin(): string;
100
- /** @deprecated Use `runtime.host.subscribeAppOrigin`. */
101
- export declare function subscribeAppOrigin(listener: () => void): () => void;
102
- /** @deprecated Use `runtime.host.setArtifactOrigin`. */
103
- export declare function setArtifactOrigin(origin: string): void;
104
- /** @deprecated Use `runtime.host.artifactOrigin`; see its documentation for the fallback order. */
105
- export declare function getArtifactOrigin(): string;
106
- /** @deprecated Use `runtime.host.subscribeArtifactOrigin`. */
107
- export declare function subscribeArtifactOrigin(listener: () => void): () => void;
108
- /** @deprecated Use `runtime.host.setPreviewRevision`. */
109
- export declare function setPreviewRevision(revision: string): void;
110
- /** @deprecated Use `runtime.host.previewRevision`. */
111
- export declare function getPreviewRevision(): string;
112
- /** @deprecated Use `runtime.host.subscribePreviewRevision`. */
113
- export declare function subscribePreviewRevision(listener: () => void): () => void;
114
- /** @deprecated Use `runtime.host.setFlowCanvas`. */
115
- export declare function setFlowCanvas(canvas: string): void;
116
- /** @deprecated Use `runtime.host.flowCanvas`. */
117
- export declare function getFlowCanvas(): string;
118
- /** @deprecated Use `runtime.host.setStaticFrameSurface`. */
119
- export declare function setStaticFrameSurface(surface: 'bitmap' | 'dom'): void;
120
- /** @deprecated Use `runtime.host.staticFrameSurface`. */
121
- export declare function getStaticFrameSurface(): 'bitmap' | 'dom';
122
- /** @deprecated Use `runtime.host.setOnApply`. */
123
- export declare function setOnApply(cb: ((payload: ApplyPayload) => Promise<{
124
- branch: string;
125
- } | void>) | null): void;
126
- /** @deprecated Use `runtime.host.onApply`. */
127
- export declare function getOnApply(): import("../core/hostBindings").ApplyHandler | null;
128
- /** @deprecated Use `runtime.host.setOnInspectApply`. */
129
- export declare function setOnInspectApply(cb: ((payload: InspectApplyPayload) => Promise<InspectApplyResult | void>) | null): void;
130
- /** @deprecated Use `runtime.host.onInspectApply`. */
131
- export declare function getOnInspectApply(): import("../core/hostBindings").InspectApplyHandler | null;
132
- /** @deprecated Use `runtime.host.setOnInspectPreview`. */
133
- export declare function setOnInspectPreview(cb: ((payload: InspectApplyPayload) => Promise<InspectPreviewResult>) | null): void;
134
- /** @deprecated Use `runtime.host.onInspectPreview`. */
135
- export declare function getOnInspectPreview(): import("../core/hostBindings").InspectPreviewHandler | null;
136
- /** @deprecated Use `runtime.host.setOnInspectImpact`. */
137
- export declare function setOnInspectImpact(cb: ((componentFiles: string[]) => Promise<InspectImpactResult>) | null): void;
138
- /** @deprecated Use `runtime.host.onInspectImpact`. */
139
- export declare function getOnInspectImpact(): import("../core/hostBindings").InspectImpactHandler | null;
140
- /** @deprecated Use `runtime.host.setOnDesignChange`. */
141
- export declare function setOnDesignChange(cb: ((payload: DesignChangePayload) => Promise<DesignChangeResult | void>) | null): void;
142
- /** @deprecated Use `runtime.host.onDesignChange`. */
143
- export declare function getOnDesignChange(): import("../core/hostBindings").DesignChangeHandler | null;
144
- /** @deprecated Use `runtime.host.setOnPreviewOpenChange`. */
145
- export declare function setOnPreviewOpenChange(cb: ((open: boolean) => void) | null): void;
146
- /** @deprecated Use `runtime.host.onPreviewOpenChange`. */
147
- export declare function getOnPreviewOpenChange(): import("../core/hostBindings").PreviewOpenChangeHandler | null;
@@ -1,5 +1,5 @@
1
- import type { DesignIRComponent } from './designCompiler';
2
- import type { NodeJSON, NodeModel } from './store';
1
+ import type { DesignIRComponent } from './designCompiler.js';
2
+ import type { NodeJSON, NodeModel } from './store.js';
3
3
  type SourceNode = NodeModel | NodeJSON;
4
4
  export interface ImplementationComponentSource {
5
5
  name: string;
@@ -1,4 +1,4 @@
1
- import type { ImportedGeometryEntry } from './domImport';
1
+ import type { ImportedGeometryEntry } from './domImport.js';
2
2
  /** The shape of a mounted layer tree this check needs — NodeModel satisfies it. */
3
3
  export interface LayerImportFidelityNode {
4
4
  id: string;
@@ -1,3 +1,4 @@
1
+ import type { Registry } from './registry.js';
1
2
  /**
2
3
  * css module source mapping — host vite plugin (pygmalion-inspect-plugin)
3
4
  * window.__PYG_CSS_MODULES__ Derived from registration stacked in an array (scope class → scss file/local name).
@@ -97,7 +98,7 @@ export declare function canPreviewSourceProp(el: HTMLElement, prop: string): boo
97
98
  /** Relative paths whose meaning varies based on the target file are excluded. This slice supports only alias and bare package. */
98
99
  export declare function isSafeComponentImportPath(importPath: string): boolean;
99
100
  /** Normalize registry metadata only when it can be shared as is with AST payload and UI. */
100
- export declare function sourceInsertComponentFor(componentName: string): SourceInsertComponent | null;
101
+ export declare function sourceInsertComponentFor(registry: Pick<Registry, 'getRegistry'>, componentName: string): SourceInsertComponent | null;
101
102
  interface ComponentStructurePreview {
102
103
  wrapper: HTMLElement;
103
104
  mount: () => boolean;
@@ -163,10 +164,15 @@ export interface InspectApplyPayload {
163
164
  operations: SourceEditOperation[];
164
165
  }
165
166
  export declare class InspectSession {
167
+ /** The registry of the editor this session edits. */
168
+ private readonly registry;
169
+ constructor(registry: Pick<Registry, 'getRegistry'>);
166
170
  /** Final commit candidate. Only one combination of the same element, attribute, and breakpoint is always maintained. */
167
171
  entries: InspectEntry[];
168
172
  toastMsg: string;
169
173
  toastSeq: number;
174
+ /** Bumps on every change to the entries or the history; panels compare it. */
175
+ revision: number;
170
176
  private seq;
171
177
  /** Undo/Redo is a session memory cache separate from the final patch. */
172
178
  private undoHistory;
@@ -221,5 +227,4 @@ export declare class InspectSession {
221
227
  clearApplied(): void;
222
228
  }
223
229
  export declare function isSourceBackedEntry(entry: InspectEntry): boolean;
224
- export declare const inspectSession: InspectSession;
225
230
  export {};
@@ -6,7 +6,7 @@
6
6
  * published, while the active frame may mirror the running document
7
7
  * immediately so capture stability never becomes interaction latency.
8
8
  */
9
- import type { DesignScreenDesiredState } from './designImport';
9
+ import type { DesignScreenDesiredState } from './designImport.js';
10
10
  export interface InteractiveSessionSurface {
11
11
  iframe: HTMLIFrameElement;
12
12
  screenId: string;
@@ -14,37 +14,29 @@ export interface InteractiveSessionSurface {
14
14
  /** Stable presentation slot shared by sibling direct-state options. */
15
15
  export declare function directInteractiveSessionSurfaceId(pageId: string, stateId: string): string;
16
16
  /**
17
- * Connects the store's synchronous option selection to the session scheduler
18
- * without making the store import the scheduler that already depends on it.
17
+ * One editor's registry of live documents presenting a screen state, with the
18
+ * two direct-state handlers its flow-session scheduler installs. Every runtime
19
+ * owns one, so a store's option click reaches its own scheduler.
19
20
  */
20
- export declare function setDirectInteractiveStateRequestHandler(handler: ((pageId: string) => void) | null): void;
21
- /** Starts direct-state delivery in the same task as the right-panel click. */
22
- export declare function requestDirectInteractiveState(pageId: string): boolean;
23
- /** Installs the paint-first path used before the observable page recipe changes. */
24
- export declare function setDirectInteractiveStatePreviewHandler(handler: ((request: {
25
- pageId: string;
26
- stateId: string;
27
- desiredState: DesignScreenDesiredState;
28
- }) => boolean) | null): void;
29
- /** Applies a direct host state without invalidating the editor model yet. */
30
- export declare function requestDirectInteractiveStatePreview(request: {
31
- pageId: string;
32
- stateId: string;
33
- desiredState: DesignScreenDesiredState;
34
- }): boolean;
35
- /** Exposes a runner-owned iframe without transferring its ownership. */
36
- export declare function exposeInteractiveSessionSurface(screenId: string, iframe: HTMLIFrameElement): void;
37
- /**
38
- * Hands an in-flight prewarm slot to the frame that has just exposed its axis.
39
- * If preparation has not presented the iframe yet, its first exposure follows
40
- * the redirect instead of landing in the now-private staging slot.
41
- */
42
- export declare function redirectInteractiveSessionSurface(fromScreenId: string, toScreenId: string): boolean;
43
- /** Releases a surface only when the caller still owns the registered iframe. */
44
- export declare function releaseInteractiveSessionSurface(screenId: string, iframe: HTMLIFrameElement): void;
45
- /** Clears a presentation slot when its page returns to an authored state. */
46
- export declare function clearInteractiveSessionSurface(screenId: string): void;
47
- /** Active direct-state surfaces pin their warm React document against eviction. */
48
- export declare function hasInteractiveSessionSurfaceIframe(iframe: HTMLIFrameElement): boolean;
49
- export declare function getInteractiveSessionSurface(screenId: string): InteractiveSessionSurface | null;
50
- export declare function subscribeInteractiveSessionSurface(screenId: string, listener: () => void): () => void;
21
+ export declare function createInteractiveSessionSurfaces(): {
22
+ setDirectInteractiveStateRequestHandler: (handler: ((pageId: string) => void) | null) => void;
23
+ requestDirectInteractiveState: (pageId: string) => boolean;
24
+ setDirectInteractiveStatePreviewHandler: (handler: ((request: {
25
+ pageId: string;
26
+ stateId: string;
27
+ desiredState: DesignScreenDesiredState;
28
+ }) => boolean) | null) => void;
29
+ requestDirectInteractiveStatePreview: (request: {
30
+ pageId: string;
31
+ stateId: string;
32
+ desiredState: DesignScreenDesiredState;
33
+ }) => boolean;
34
+ exposeInteractiveSessionSurface: (screenId: string, iframe: HTMLIFrameElement) => void;
35
+ redirectInteractiveSessionSurface: (fromScreenId: string, toScreenId: string) => boolean;
36
+ releaseInteractiveSessionSurface: (screenId: string, iframe: HTMLIFrameElement) => void;
37
+ clearInteractiveSessionSurface: (screenId: string) => void;
38
+ hasInteractiveSessionSurfaceIframe: (iframe: HTMLIFrameElement) => boolean;
39
+ getInteractiveSessionSurface: (screenId: string) => InteractiveSessionSurface | null;
40
+ subscribeInteractiveSessionSurface: (screenId: string, listener: () => void) => () => void;
41
+ };
42
+ export type InteractiveSessionSurfaces = ReturnType<typeof createInteractiveSessionSurfaces>;
@@ -1,6 +1,6 @@
1
- import type { DesignScreenInteraction, DesignSerializable, StoryboardEnvironment } from './designImport';
2
- import type { PageModel } from './store';
3
- export { reachablePreviewTestIds } from './previewReachability';
1
+ import type { DesignScreenInteraction, DesignSerializable, StoryboardEnvironment } from './designImport.js';
2
+ import type { PageModel } from './store.js';
3
+ export { reachablePreviewTestIds } from './previewReachability.js';
4
4
  /**
5
5
  * Screen-state axes — same-frame variations reproduced by a gesture or a boot
6
6
  * condition.
@@ -145,8 +145,6 @@ export declare function previewMarkupTestIds(markup: string | null | undefined,
145
145
  * whole layer tree, while a frame without that control still hides the axis.
146
146
  */
147
147
  export declare function interactiveStatesForPage(page: PageModel, defs: readonly InteractiveStateDef[]): InteractiveStateDef[];
148
- /** The first axis whose options can render directly on a warm host document. */
149
- export declare function directInteractiveStateAxisForPage(page: PageModel, defs?: readonly InteractiveStateDef[]): InteractiveStateDef | undefined;
150
148
  /** Preferred public name for axes applicable to one frame. */
151
149
  export declare const screenStateAxesForPage: typeof interactiveStatesForPage;
152
150
  /**
@@ -161,8 +159,12 @@ export declare function capturedInteractiveOption(def: InteractiveStateDef, page
161
159
  * one option declared without steps.
162
160
  */
163
161
  export declare function baseInteractiveOption(def: InteractiveStateDef, page?: PageModel): InteractiveStateOption | undefined;
164
- export declare function setScreenStateAxes(defs: readonly InteractiveStateDef[] | undefined): void;
165
- /** @deprecated Use setScreenStateAxes. */
166
- export declare function setInteractiveStates(defs: readonly InteractiveStateDef[] | undefined): void;
167
- export declare function getInteractiveStates(): readonly InteractiveStateDef[];
168
- export declare const getScreenStateAxes: typeof getInteractiveStates;
162
+ /** One editor's declared screen state axes. */
163
+ export declare function createInteractiveStates(): {
164
+ directInteractiveStateAxisForPage: (page: PageModel, defs?: readonly InteractiveStateDef[]) => InteractiveStateDef | undefined;
165
+ setScreenStateAxes: (defs: readonly InteractiveStateDef[] | undefined) => void;
166
+ setInteractiveStates: (defs: readonly InteractiveStateDef[] | undefined) => void;
167
+ getInteractiveStates: () => readonly InteractiveStateDef[];
168
+ getScreenStateAxes: () => readonly InteractiveStateDef[];
169
+ };
170
+ export type InteractiveStates = ReturnType<typeof createInteractiveStates>;
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Shared live application instances for producing screen previews.
2
+ * Live application instances the frames of one editor share to produce
3
+ * screen previews.
3
4
  *
4
5
  * A frame that has no frozen snapshot yet has to run the real application once.
5
6
  * Doing that per frame means one boot per screen, which is what made opening a
@@ -9,6 +10,11 @@
9
10
  *
10
11
  * A lease is exclusive. Snapshot production reads the document while it freezes,
11
12
  * so two frames must never drive one instance at the same time.
13
+ *
14
+ * Every editor runtime owns one pool, `runtime.schedulers.livePreviews`, so two
15
+ * editors on one page never queue behind each other's screens. React
16
+ * components reach it through `useEditorRuntime()`; other code takes it as a
17
+ * parameter.
12
18
  */
13
19
  export interface LivePreviewInstanceOptions {
14
20
  /** Creates the offscreen frame. Injected so the pool can be tested without a browser. */
@@ -86,8 +92,12 @@ export declare function createLivePreviewInstances(options?: LivePreviewInstance
86
92
  /** Drops an instance whose document can no longer be trusted. */
87
93
  discard(key: string): void;
88
94
  size(): number;
95
+ /**
96
+ * Releases every instance: the offscreen frames are removed and waiting
97
+ * leases are resumed. The pool stays usable — the next lease boots fresh —
98
+ * which is what a change of origin or revision needs, since every booted
99
+ * document would otherwise keep showing old code.
100
+ */
89
101
  dispose(): void;
90
102
  };
91
103
  export type LivePreviewInstances = ReturnType<typeof createLivePreviewInstances>;
92
- export declare function getLivePreviewInstances(): LivePreviewInstances;
93
- export declare function resetLivePreviewInstances(): void;
@@ -1,20 +1,29 @@
1
- export declare function subscribeLiveScreens(listener: () => void): () => void;
2
1
  /**
3
- * Sets how many frames may render live at once. Lowering it releases the
4
- * least recently requested frames back to the frozen surface.
2
+ * One editor's live-screen holds: the budget, the page ids holding a slot in
3
+ * recency order, and the listeners frames subscribe through. The bodies below
4
+ * are the former module-level functions, closed over instance state instead
5
+ * of module state. Every runtime owns one.
5
6
  */
6
- export declare function setLiveScreenBudget(next: number): void;
7
- export declare function getLiveScreenBudget(): number;
7
+ /** How many frames render live unless the host says otherwise. */
8
+ export declare const DEFAULT_LIVE_SCREEN_BUDGET = 3;
8
9
  /**
9
- * Claims a live slot for a page, or refreshes its recency when it already
10
- * holds one. Returns whether the page holds a slot afterwards, so a caller
11
- * can fall back to the frozen surface without waiting for a re-render.
10
+ * The most instances a screen-state group may hold at once. The budget
11
+ * follows the active group's size up to here so every variant of a small
12
+ * group stays booted and a switch between them is instant; a larger group
13
+ * keeps its most recently used variants live.
12
14
  */
13
- export declare function requestLiveScreen(pageId: string): boolean;
14
- /** Releases a page's slot, if it holds one. */
15
- export declare function releaseLiveScreen(pageId: string): void;
16
- export declare function holdsLiveScreen(pageId: string): boolean;
17
- /** Page ids currently rendering live, least recently requested first. */
18
- export declare function liveScreenHolders(): readonly string[];
19
- /** Test seam drops every claim and the budget. */
20
- export declare function resetLiveScreens(): void;
15
+ export declare const LIVE_SCREEN_GROUP_BUDGET_CAP = 5;
16
+ export declare function createLiveScreens(): {
17
+ subscribeLiveScreens: (listener: () => void) => () => void;
18
+ setLiveScreenBudget: (next: number) => void;
19
+ setLiveScreenGroupSize: (next: number) => void;
20
+ getEffectiveLiveScreenBudget: () => number;
21
+ setLiveScreenCandidates: (next: readonly string[]) => void;
22
+ getLiveScreenBudget: () => number;
23
+ requestLiveScreen: (pageId: string) => boolean;
24
+ releaseLiveScreen: (pageId: string) => void;
25
+ holdsLiveScreen: (pageId: string) => boolean;
26
+ liveScreenHolders: () => readonly string[];
27
+ resetLiveScreens: () => void;
28
+ };
29
+ export type LiveScreens = ReturnType<typeof createLiveScreens>;
@@ -18,14 +18,11 @@ export declare const MOUNT_PRIORITY: Readonly<{
18
18
  background: 2;
19
19
  }>;
20
20
  export declare const DEFAULT_MOUNTS_PER_FRAME = 3;
21
- /** Test/tuning hook. */
22
- export declare function configureMountScheduler(options: MountSchedulerOptions): void;
23
- /** Drops queued mounts and counters; tests call it between cases. */
24
- export declare function resetMountScheduler(): void;
25
- export declare function pendingMountCount(): number;
26
- /**
27
- * Runs the mount now if this frame's budget allows, otherwise queues it.
28
- * The returned ticket withdraws a queued mount when the frame goes away
29
- * before its turn.
30
- */
31
- export declare function scheduleMount(run: () => void, priority?: number): MountTicket;
21
+ /** One editor's frame-mount budget: the queue of pending mounts and how many run per animation frame. */
22
+ export declare function createMountScheduler(): {
23
+ configureMountScheduler: (options: MountSchedulerOptions) => void;
24
+ resetMountScheduler: () => void;
25
+ pendingMountCount: () => number;
26
+ scheduleMount: (run: () => void, priority?: number) => MountTicket;
27
+ };
28
+ export type MountScheduler = ReturnType<typeof createMountScheduler>;
@@ -1,4 +1,4 @@
1
- import type { NodeModel } from './store';
1
+ import type { NodeModel } from './store.js';
2
2
  export interface NodeSelector {
3
3
  testId?: string;
4
4
  classIncludes?: string | readonly string[];
@@ -0,0 +1,19 @@
1
+ import type { InspectApplyPayload, InspectSession } from './inspect.js';
2
+ import type { EditorStore } from './store.js';
3
+ export interface PendingSourceChanges {
4
+ /** The store journal's revision, acknowledged with `ackPendingSourceChanges`. */
5
+ journalRevision: number;
6
+ /** The inspect session's revision, cleared with `clearApplied`. */
7
+ inspectRevision: number;
8
+ /** Both revisions in one comparable token. */
9
+ revision: string;
10
+ payload: InspectApplyPayload;
11
+ }
12
+ /**
13
+ * Folds two payloads into one. Style patches to the same file, class, and
14
+ * media query merge their declarations, the later one winning; texts and
15
+ * operations keep their order, first payload first.
16
+ */
17
+ export declare function mergeSourcePayloads(first: InspectApplyPayload, second: InspectApplyPayload): InspectApplyPayload;
18
+ /** Everything staged in this editor that the host has not written yet. */
19
+ export declare function collectPendingSourceChanges(store: Pick<EditorStore, 'getPendingSourceChanges'>, inspect: Pick<InspectSession, 'buildApplyPayload' | 'revision'>): PendingSourceChanges;