@pygmalionjs/pygmalion 0.7.4 → 0.8.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.
Files changed (133) hide show
  1. package/README.ko.md +17 -2
  2. package/README.md +18 -2
  3. package/dist-lib/CameraLayer-B2D29VXQ.js +159 -0
  4. package/dist-lib/pygmalion.js +14628 -16995
  5. package/dist-lib/runtime-BAy8W1mJ.js +19716 -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 +198 -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 +444 -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
@@ -1,22 +1,24 @@
1
- import { type PreviewMotionState } from './automaticMotion';
2
- import { type InteractiveStateDef } from './interactiveStates';
3
- import { type ScreenDimensionDef } from './screenDimensions';
4
- import { type CardBadgeOption, type CardSlotDef, type ScreenCardDef } from './screenCards';
5
- import { type ScreenListDef } from './screenLists';
6
- import { type DesignImportAsset, type DesignImportInitialPage, type DesignImportKind, type DesignFrameSizeMode, type DesignScreenAssertion, type DesignScreenDesiredState, type DesignScreenInteraction, type DesignScreenPreset, type StoryboardEnvironment } from './designImport';
7
- import { type DomImportDiagnostic, type DomImportResult } from './domImport';
8
- import { type LayerImportFidelityReport, type MeasurableElement } from './importFidelity';
9
- import { type DesignFrameHeightMode } from './frameHeight';
10
- import { type RegistryPropValue } from './registry';
11
- import { type PrimitiveSourceValue } from './inspect';
12
- import { type SourceJournalSnapshot } from './sourceJournal';
13
- import { type SharedSourceEditScope, type SharedSourceImpact } from './sharedSource';
14
- import { type DesignAssetEditRequest } from './assetEditing';
1
+ import { type InteractiveStateDef } from './interactiveStates.js';
2
+ import { type ScreenDimensionDef } from './screenDimensions.js';
3
+ import { type CardBadgeOption, type CardSlotDef, type ScreenCardDef } from './screenCards.js';
4
+ import { type ScreenListDef } from './screenLists.js';
5
+ import { type DesignImportAsset, type DesignImportInitialPage, type DesignImportKind, type DesignFrameSizeMode, type DesignScreenAssertion, type DesignScreenDesiredState, type DesignScreenInteraction, type DesignScreenPreset, type StoryboardEnvironment } from './designImport.js';
6
+ import { type DomImportDiagnostic, type DomImportResult } from './domImport.js';
7
+ import { type LayerImportFidelityReport, type MeasurableElement } from './importFidelity.js';
8
+ import { type InteractiveSessionSurfaces } from './interactiveSessionSurface.js';
9
+ import { type EditorDeclarations } from './declarations.js';
10
+ import { type MountedShadowPreviews } from './frozenImport.js';
11
+ import { type DesignFrameHeightMode } from './frameHeight.js';
12
+ import type { RegistryPropValue } from './registry.js';
13
+ import { type PrimitiveSourceValue } from './inspect.js';
14
+ import { type SourceJournalSnapshot } from './sourceJournal.js';
15
+ import { type SharedSourceEditScope, type SharedSourceImpact } from './sharedSource.js';
16
+ import { type DesignAssetEditRequest } from './assetEditing.js';
15
17
  export type NodeType = 'rows' | 'columns' | 'text' | 'component';
16
18
  /** Autolayout container type (with direction, gap, and alignment). */
17
19
  export declare const isContainerType: (t: NodeType) => t is "rows" | "columns";
18
20
  /** Can contain child nodes — container + children:'nodes' components (Card, etc.). */
19
- export declare const canHaveChildren: (n: NodeModel) => boolean;
21
+ export declare const canHaveChildren: (declarations: Pick<EditorDeclarations, "getRegistry">, n: NodeModel) => boolean;
20
22
  export type SizeMode = 'fill' | 'fit' | 'fixed';
21
23
  export type TextAlign = 'left' | 'center' | 'right';
22
24
  export type JustifyMode = 'start' | 'center' | 'end' | 'between';
@@ -135,6 +137,11 @@ export interface DropHint {
135
137
  height: number;
136
138
  };
137
139
  }
140
+ /**
141
+ * A live boot that has reported nothing for this long no longer blocks the
142
+ * standby queue: a document that failed to load must not stall every sibling.
143
+ */
144
+ export declare const LIVE_ROUTE_BOOT_STALE_MS = 20000;
138
145
  export interface PageModel {
139
146
  /** Frame size (px). Default 390×600 (mobile). */
140
147
  width?: number;
@@ -349,9 +356,30 @@ export interface EditorStoreHost {
349
356
  readonly flowCanvas: string;
350
357
  readonly onPreviewOpenChange: ((open: boolean) => void) | null;
351
358
  }
359
+ /**
360
+ * What the store needs from its runtime's interactive-session surfaces: the
361
+ * direct-state requests an option click starts, and the release of a slot a
362
+ * state no longer presents. A store created on its own gets a detached
363
+ * registry whose requests answer false.
364
+ */
365
+ export type DirectStateSurfaces = Pick<InteractiveSessionSurfaces, 'requestDirectInteractiveState' | 'requestDirectInteractiveStatePreview' | 'clearInteractiveSessionSurface'>;
366
+ /** What a store is built from; a runtime supplies all three, a test what it needs. */
367
+ export interface EditorStoreOptions {
368
+ host?: EditorStoreHost;
369
+ surfaces?: DirectStateSurfaces;
370
+ declarations?: EditorDeclarations;
371
+ /** The frozen previews mounted for this editor's pages. */
372
+ shadowMounts?: Pick<MountedShadowPreviews, 'getMountedShadowPreviewHandle'>;
373
+ }
352
374
  export declare class EditorStore {
353
375
  /** Host bindings this store reads; excluded from MobX so the bindings object stays plain. */
354
376
  readonly host: EditorStoreHost;
377
+ /** The runtime's session surfaces the store's option clicks reach; excluded from MobX. */
378
+ readonly surfaces: DirectStateSurfaces;
379
+ /** The runtime's host declarations the store reads; excluded from MobX. */
380
+ readonly declarations: EditorDeclarations;
381
+ /** The frozen previews mounted for this editor's pages; excluded from MobX. */
382
+ readonly shadowMounts: Pick<MountedShadowPreviews, 'getMountedShadowPreviewHandle'>;
355
383
  /** Multi-page — each page has an independent tree. */
356
384
  pages: PageModel[];
357
385
  activePageId: string;
@@ -420,6 +448,40 @@ export declare class EditorStore {
420
448
  */
421
449
  isInSelectedRuntime(page: PageModel): boolean;
422
450
  isScreenStateShown(page: PageModel): boolean;
451
+ /** The declared state variants of the active frame's group, base first; empty outside a group. */
452
+ get activeScreenStateGroup(): PageModel[];
453
+ /**
454
+ * A folded variant of the active frame's group. Standby frames stay
455
+ * mounted at the group's slot, hidden, so switching to one is a visibility
456
+ * change rather than a mount, and their live instances boot ahead of the
457
+ * switch. Variants of other groups stay folded away entirely.
458
+ */
459
+ isScreenStateStandby(page: PageModel): boolean;
460
+ /**
461
+ * Live routes booting or preparing right now, by page id, with the time
462
+ * each began. Standby variants boot one at a time and only while nothing
463
+ * else is booting, so the frame the designer is looking at settles first.
464
+ */
465
+ liveRouteLoadingSince: Map<string, number>;
466
+ setLiveRouteLoading(pageId: string, loading: boolean): void;
467
+ /** True when no live route has been booting for less than the stale limit. */
468
+ liveRouteBootFree(now?: number): boolean;
469
+ /** Takes the one boot slot for a standby variant; false while another boot runs. */
470
+ claimLiveRouteBoot(pageId: string, now?: number): boolean;
471
+ /**
472
+ * Live reproductions that failed, by page id, with the step or reason. A
473
+ * frame records its own failure so the panel can name it and offer a
474
+ * retry; the frame keeps its capture on screen meanwhile.
475
+ */
476
+ liveRouteFailures: Map<string, string>;
477
+ /** Retry counts by page id; a frame reloads its live document when its count changes. */
478
+ liveRouteRetries: Map<string, number>;
479
+ setLiveRouteFailure(pageId: string, message: string | null): void;
480
+ liveRouteFailure(pageId: string): string | undefined;
481
+ retryLiveRoute(pageId: string): void;
482
+ liveRouteRetryCount(pageId: string): number;
483
+ /** Standby page ids of the active group, in declaration order. */
484
+ get activeScreenStateSiblingIds(): string[];
423
485
  /** Swaps a folded variant into its group's canvas slot; the camera stays. */
424
486
  private revealScreenState;
425
487
  /** Switch canvases, restore their view, and activate the first frame. */
@@ -503,10 +565,9 @@ export declare class EditorStore {
503
565
  /** pageId → source geometry awaiting its post-mount fidelity measurement. */
504
566
  private pendingLayerImportGeometry;
505
567
  /** View-only motion playback never becomes part of a frame recipe or undo history. */
506
- private previewMotionStates;
507
568
  private contentLayoutScheduled;
508
569
  private contentLayoutCanvases;
509
- constructor(host?: EditorStoreHost);
570
+ constructor(options?: EditorStoreOptions);
510
571
  /** Releases the reactions this store owns. A runtime calls it when its editor unmounts. */
511
572
  dispose(): void;
512
573
  get activePage(): PageModel;
@@ -801,11 +862,6 @@ export declare class EditorStore {
801
862
  selector?: string;
802
863
  targetLabel?: string;
803
864
  } | null): boolean;
804
- previewMotionState(pageId: string): Readonly<PreviewMotionState>;
805
- playPreviewMotion(pageId: string, targetId?: string): void;
806
- pausePreviewMotion(pageId: string, targetId?: string): void;
807
- seekPreviewMotion(pageId: string, targetId: string | undefined, progress: number): void;
808
- resetPreviewMotion(pageId: string): void;
809
865
  /** Pages whose mounted frozen preview was refused at the import boundary. */
810
866
  private frozenPromotionRefusals;
811
867
  /** True when the page's frozen capture was refused and activation should boot live instead. */
@@ -875,6 +931,16 @@ export declare class EditorStore {
875
931
  /** Section name whose name is entered immediately after creation/double-clicking — SectionBoxes are rendered as input. */
876
932
  sectionRenameTarget: string | null;
877
933
  setTool(tool: 'select' | 'hand' | 'zoom' | 'section'): void;
934
+ /** Inspecting picks DOM elements inside live frames and records source edits. */
935
+ inspectOn: boolean;
936
+ /**
937
+ * Which discovered element the variant panel's Elements row is about, per
938
+ * page. A held pseudo-state outranks it; the canvas inspector writes it.
939
+ */
940
+ pseudoTargets: Map<string, string>;
941
+ setPseudoTarget(pageId: string, targetId: string | null): void;
942
+ pseudoTargetFor(pageId: string): string | undefined;
943
+ setInspectOn(on: boolean): void;
878
944
  setSectionRenameTarget(name: string | null): void;
879
945
  /**
880
946
  * Completing a section drag creates the rectangle immediately and includes intersecting frames.
@@ -1,5 +1,5 @@
1
- import { type StoryboardDefinition, type StoryboardGraph } from './storyboardGraph';
2
- import type { DesignImportAsset, DesignImportInitialPage, DesignScenarioSource } from './designImport';
1
+ import { type StoryboardDefinition, type StoryboardGraph } from './storyboardGraph.js';
2
+ import type { DesignImportAsset, DesignImportInitialPage, DesignScenarioSource } from './designImport.js';
3
3
  export type AuthoredStoryboardGraphOptions = {
4
4
  pages: readonly DesignImportInitialPage[];
5
5
  assets?: readonly DesignImportAsset[];
@@ -1,6 +1,7 @@
1
- import type { DesignImportAsset, DesignImportKind, DesignScreenCase, StoryboardEnvironment } from './designImport';
1
+ import type { DesignImportAsset, DesignImportKind, DesignScreenCase, StoryboardEnvironment } from './designImport.js';
2
2
  import type { EditorTransport } from '../contract/transport.js';
3
- import { type StoryboardGraph, type StoryboardDefinition } from './storyboardGraph';
3
+ import { type StoryboardGraph, type StoryboardDefinition } from './storyboardGraph.js';
4
+ import type { StoryboardGraphRuntime } from './storyboardGraphRuntime.js';
4
5
  export interface StoryboardDiscoveryScenario {
5
6
  id?: string;
6
7
  name?: string;
@@ -94,4 +95,4 @@ export declare function loadStoryboardDiscovery(transport: EditorTransport, opti
94
95
  * Replaces the editor graph atomically from source discovery. A stale graph is
95
96
  * cleared both before the request and after any transport or parsing failure.
96
97
  */
97
- export declare function publishStoryboardDiscovery(transport: EditorTransport, options: LoadStoryboardDiscoveryOptions): Promise<StoryboardDiscoveryResult>;
98
+ export declare function publishStoryboardDiscovery(transport: EditorTransport, graph: Pick<StoryboardGraphRuntime, 'setStoryboardGraph'>, options: LoadStoryboardDiscoveryOptions): Promise<StoryboardDiscoveryResult>;
@@ -1,10 +1,6 @@
1
- import type { StoryboardEnvironment } from './designImport';
2
- export declare function bumpPreviewIdentityEpoch(): void;
3
- export declare function getPreviewIdentityEpoch(): number;
1
+ import type { StoryboardEnvironment } from './designImport.js';
4
2
  export declare const STORYBOARD_ENVIRONMENT_QUERY: "__pygmalion_environment";
5
3
  export declare const STORYBOARD_ENVIRONMENT_CONTROL: "/__pygmalion-storyboard/environment";
6
- export declare function setStoryboardBaselineEnvironment(environment?: StoryboardEnvironment): void;
7
- export declare function getStoryboardBaselineEnvironment(): StoryboardEnvironment | undefined;
8
4
  export declare function mergeStoryboardEnvironment(base?: StoryboardEnvironment, override?: StoryboardEnvironment): StoryboardEnvironment | undefined;
9
5
  /**
10
6
  * Boot-time environment derived from a screen preset — parity with the Node
@@ -29,3 +25,11 @@ export declare function resolveStoryboardBootEnvironment(preset: Readonly<Record
29
25
  * application modules execute, so routers continue to see the original URL.
30
26
  */
31
27
  export declare function createStoryboardRouteUrl(appOrigin: string, route: string, environment?: StoryboardEnvironment): string;
28
+ /** One editor's storyboard baseline environment and preview identity epoch. */
29
+ export declare function createStoryboardEnvironmentState(): {
30
+ bumpPreviewIdentityEpoch: () => void;
31
+ getPreviewIdentityEpoch: () => number;
32
+ setStoryboardBaselineEnvironment: (environment?: StoryboardEnvironment) => void;
33
+ getStoryboardBaselineEnvironment: () => StoryboardEnvironment | undefined;
34
+ };
35
+ export type StoryboardEnvironmentState = ReturnType<typeof createStoryboardEnvironmentState>;
@@ -1,4 +1,4 @@
1
- import type { DesignImportAsset, DesignScenarioSource, DesignScreenCase } from './designImport';
1
+ import type { DesignImportAsset, DesignScenarioSource, DesignScreenCase } from './designImport.js';
2
2
  export type StoryboardGraphEdgeOrigin = 'explicit' | 'inferred';
3
3
  export type StoryboardGraphEdgeLabelScope = 'edge' | 'path';
4
4
  export interface StoryboardGraphEdgeInput {
@@ -1,12 +1,10 @@
1
- import type { StoryboardGraph } from './storyboardGraph';
1
+ import type { StoryboardGraph } from './storyboardGraph.js';
2
2
  type StoryboardGraphListener = () => void;
3
- /**
4
- * Publishes a project-owned storyboard graph to the editor shell.
5
- *
6
- * The runtime only stores the generic graph contract. Projects remain
7
- * responsible for creating their manifest, meanings, presets, and assertions.
8
- */
9
- export declare function setStoryboardGraph(graph: StoryboardGraph | null): void;
10
- export declare function getStoryboardGraph(): StoryboardGraph | null;
11
- export declare function subscribeStoryboardGraph(listener: StoryboardGraphListener): () => void;
3
+ /** One editor's published storyboard graph and its subscribers. */
4
+ export declare function createStoryboardGraphRuntime(): {
5
+ setStoryboardGraph: (graph: StoryboardGraph | null) => void;
6
+ getStoryboardGraph: () => StoryboardGraph | null;
7
+ subscribeStoryboardGraph: (listener: StoryboardGraphListener) => () => void;
8
+ };
9
+ export type StoryboardGraphRuntime = ReturnType<typeof createStoryboardGraphRuntime>;
12
10
  export {};
@@ -1,4 +1,4 @@
1
- import type { StoryboardGraph, StoryboardGraphEdgeOrigin, StoryboardGraphWarning } from './storyboardGraph';
1
+ import type { StoryboardGraph, StoryboardGraphEdgeOrigin, StoryboardGraphWarning } from './storyboardGraph.js';
2
2
  export interface StoryboardFrameReference {
3
3
  frameId: string;
4
4
  screenId: string;
@@ -1,4 +1,4 @@
1
- import type { StoryboardGraphFrameView, StoryboardGraphViewModel } from './storyboardGraphView';
1
+ import type { StoryboardGraphFrameView, StoryboardGraphViewModel } from './storyboardGraphView.js';
2
2
  /**
3
3
  * The journey a catalog actually tells, and everything that hangs off it.
4
4
  *
@@ -3,6 +3,13 @@ export interface SurfaceCandidate {
3
3
  kind: SurfaceDemandKind;
4
4
  /** Stable identity — the same surface must produce the same id across runs. */
5
5
  id: string;
6
+ /**
7
+ * The host's own identity for the surface, carried through untouched: the
8
+ * route id discovery reported, for a route candidate. A diagnostic repeats
9
+ * it so the host joins back to a route name or a source path by key rather
10
+ * than by parsing the candidate id.
11
+ */
12
+ sourceId?: string;
6
13
  /** Frame the candidate was found in. Absent for route candidates. */
7
14
  frameId?: string;
8
15
  /**
@@ -33,14 +40,67 @@ export type SurfaceVerdict = {
33
40
  export type SurfaceClassification = SurfaceVerdict & {
34
41
  id: string;
35
42
  };
43
+ /**
44
+ * What went wrong, as a value a gate can branch on.
45
+ *
46
+ * - `duplicate-candidate` — an enumerator reported one surface twice.
47
+ * - `stale-verdict` — a verdict names a surface no enumerator reports.
48
+ * - `duplicate-verdict` — two verdicts answer one surface.
49
+ * - `exclusion-reason` — an exclusion's reason is below the floor.
50
+ * - `empty-target` — a covered verdict names nothing.
51
+ * - `unknown-target` — a covered verdict names a declaration that does not
52
+ * exist among the known targets the caller supplied.
53
+ * - `unclassified` — a surface has no verdict at all.
54
+ */
55
+ export type SurfaceDemandDiagnosticCode = 'duplicate-candidate' | 'stale-verdict' | 'duplicate-verdict' | 'exclusion-reason' | 'empty-target' | 'unknown-target' | 'unclassified';
36
56
  export interface SurfaceDemandDiagnostic {
37
57
  severity: 'error' | 'warning';
58
+ code: SurfaceDemandDiagnosticCode;
38
59
  kind: SurfaceDemandKind | 'unknown';
39
60
  candidateId: string;
61
+ /** The candidate's host-side identity, when the enumerator carried one. */
62
+ sourceId?: string;
63
+ /** Frame the candidate was found in, when it was found in one. */
64
+ frameId?: string;
65
+ /** The coverage target the verdict named, for target diagnostics. */
66
+ target?: string;
40
67
  message: string;
41
68
  }
69
+ export interface SurfaceDemandOptions {
70
+ /**
71
+ * Every declaration a `covered` verdict may name.
72
+ *
73
+ * Without it a verdict passes as long as it names something, so a screen
74
+ * that was deleted keeps covering its route through the verdict that named
75
+ * it. With it, `by` must be one of these ids; `declaredCoverageTargets`
76
+ * builds the set from the host's declarations.
77
+ */
78
+ knownTargets?: readonly string[] | ReadonlySet<string>;
79
+ }
42
80
  /** Reasons must say something; the scenario ledger uses the same floor. */
43
81
  export declare const MIN_SURFACE_REASON_LENGTH = 10;
82
+ /**
83
+ * The ids a `covered` verdict may name, built from what the host declared.
84
+ *
85
+ * A screen is named by its own id — the same string a coverage claim's
86
+ * `screenId` uses, prefix and all. A registered component is named
87
+ * `component:<name>`, since a bare component name and a screen id could
88
+ * collide. Anything else the host counts as a coverage target (an
89
+ * interactive axis, a card slot) is passed through `targets` as written. A
90
+ * host with its own vocabulary builds the set itself and hands it to
91
+ * `knownTargets` directly.
92
+ */
93
+ export interface CoverageTargetDeclarations {
94
+ /** Declared screens — the cases handed to `createDesignScreenCollection` qualify. */
95
+ screens?: readonly {
96
+ id: string;
97
+ }[];
98
+ /** Registered component names, or the registry object itself. */
99
+ components?: readonly string[] | ReadonlySet<string> | Readonly<Record<string, unknown>>;
100
+ /** Further target ids, verbatim. */
101
+ targets?: readonly string[];
102
+ }
103
+ export declare function declaredCoverageTargets(declarations: CoverageTargetDeclarations): Set<string>;
44
104
  /**
45
105
  * Compares what the editor found against what the host answered.
46
106
  *
@@ -48,28 +108,145 @@ export declare const MIN_SURFACE_REASON_LENGTH = 10;
48
108
  * green while a surface goes unreviewed, which is the state this module exists
49
109
  * to end. Callers that need a migration window hold a baseline of known ids
50
110
  * rather than downgrading the severity.
111
+ *
112
+ * Pass `knownTargets` to also require that every `covered` verdict names a
113
+ * declaration that exists. Without it the target is only required to be
114
+ * nonempty, which is what let a deleted screen keep covering its route.
51
115
  */
52
- export declare function validateSurfaceDemands(candidates: readonly SurfaceCandidate[], classifications: readonly SurfaceClassification[]): SurfaceDemandDiagnostic[];
116
+ export declare function validateSurfaceDemands(candidates: readonly SurfaceCandidate[], classifications: readonly SurfaceClassification[], options?: SurfaceDemandOptions): SurfaceDemandDiagnostic[];
117
+ /**
118
+ * Counts by outcome. Four buckets and nothing moves between them: a surface is
119
+ * covered only when a valid verdict names a valid target, an exclusion is
120
+ * visible in its own count rather than folded into coverage, and a verdict
121
+ * that failed validation counts as invalid — never as covered.
122
+ */
123
+ export interface SurfaceCoverageSummary {
124
+ total: number;
125
+ covered: number;
126
+ excluded: number;
127
+ /** Surfaces whose verdict failed validation. */
128
+ invalid: number;
129
+ unclassified: number;
130
+ excludedIds: string[];
131
+ invalidIds: string[];
132
+ unclassifiedIds: string[];
133
+ }
134
+ export declare function summarizeSurfaceDemands(candidates: readonly SurfaceCandidate[], classifications: readonly SurfaceClassification[], options?: SurfaceDemandOptions): SurfaceCoverageSummary;
53
135
  /** Candidates with no verdict yet — what the panel shows on a frame. */
54
136
  export declare function unclassifiedSurfaces(candidates: readonly SurfaceCandidate[], classifications: readonly SurfaceClassification[]): SurfaceCandidate[];
137
+ /**
138
+ * A route as the host's discovery reported it.
139
+ *
140
+ * `path` is the canonical pattern in whatever syntax the host normalized to
141
+ * (`/items/:id`, or `/items/[id]` left as the framework wrote it); `id` is the
142
+ * host's stable identity for it, which the candidate carries as `sourceId`.
143
+ * Either alone is enough: a route with only an id is treated as a path.
144
+ */
145
+ export interface DiscoveredRoute {
146
+ path?: string;
147
+ id?: string;
148
+ }
149
+ /**
150
+ * What a declared screen says about source routes.
151
+ *
152
+ * `route` is the concrete address the screen boots; it represents a
153
+ * discovered pattern when it satisfies that pattern segment for segment.
154
+ * `coverageRoutes` is the explicit form: the source routes this screen stands
155
+ * for, matched by the discovered route's `id` or by its normalized path,
156
+ * exactly. It is how a screen that renders a registered component
157
+ * (`componentName`) covers a route without inventing a navigation URL, and
158
+ * how a screen booted at one concrete address claims a dynamic pattern
159
+ * without the core guessing at parameters. A `DesignScreenCase` satisfies
160
+ * this shape as written.
161
+ */
162
+ export interface DeclaredScreenRoute {
163
+ id: string;
164
+ route?: string;
165
+ componentName?: string;
166
+ coverageRoutes?: readonly string[];
167
+ }
55
168
  export interface RouteEnumerationInput {
56
169
  /** Routes discovered in the codebase. */
57
- routes: readonly {
58
- path?: string;
59
- id?: string;
60
- }[];
61
- /** Screen cases the host declared, with the route each one boots. */
62
- declaredScreens: readonly {
63
- id: string;
64
- route?: string;
65
- }[];
170
+ routes: readonly DiscoveredRoute[];
171
+ /** Screen cases the host declared, with the route or component each one renders. */
172
+ declaredScreens: readonly DeclaredScreenRoute[];
173
+ /**
174
+ * Registered component names, or the registry itself. When given, a screen
175
+ * whose `componentName` is not among them represents nothing: the fixture
176
+ * it names is gone, and the routes it mapped stay unrepresented.
177
+ */
178
+ registeredComponents?: readonly string[] | ReadonlySet<string> | Readonly<Record<string, unknown>>;
179
+ }
180
+ /** How a declared screen came to represent a discovered route. */
181
+ export type RouteRepresentationKind =
182
+ /** The screen's concrete `route` satisfies the discovered pattern. */
183
+ 'preview'
184
+ /** The screen lists the route in `coverageRoutes` and boots a route of its own. */
185
+ | 'mapping'
186
+ /** The screen lists the route in `coverageRoutes` and renders a registered component. */
187
+ | 'fixture';
188
+ export interface RouteRepresentation {
189
+ /** The candidate id the route would have had, `route:<path>`. */
190
+ candidateId: string;
191
+ path: string;
192
+ sourceId?: string;
193
+ screenId: string;
194
+ via: RouteRepresentationKind;
195
+ componentName?: string;
196
+ }
197
+ /**
198
+ * - `unknown-route` — a `coverageRoutes` entry matches no discovered route:
199
+ * the source route was removed or renamed, and the mapping is stale.
200
+ * - `unregistered-component` — the screen's `componentName` is not among
201
+ * `registeredComponents`: its fixture registration is gone.
202
+ * - `empty-mapping` — a `coverageRoutes` entry is blank.
203
+ * - `missing-render-source` — a mapped screen has neither a nonempty preview
204
+ * route nor a component fixture to render.
205
+ */
206
+ export type RouteCoverageDiagnosticCode = 'unknown-route' | 'unregistered-component' | 'empty-mapping' | 'missing-render-source';
207
+ export interface RouteCoverageDiagnostic {
208
+ severity: 'error';
209
+ code: RouteCoverageDiagnosticCode;
210
+ screenId: string;
211
+ /** The `coverageRoutes` entry as the host wrote it. */
212
+ route?: string;
213
+ componentName?: string;
214
+ message: string;
215
+ }
216
+ export interface RouteCoverageAudit {
217
+ /** Discovered routes nothing represents — each still owes a verdict. */
218
+ candidates: SurfaceCandidate[];
219
+ /** Every (route, screen) pair that holds, so a host can join routes to screens. */
220
+ represented: RouteRepresentation[];
221
+ /** Mappings that name something missing. Separate from the candidates on purpose. */
222
+ diagnostics: RouteCoverageDiagnostic[];
66
223
  }
67
224
  /**
225
+ * Which declared screens represent each discovered route, and which routes
226
+ * nothing represents.
227
+ *
68
228
  * A discovered route with no screen case is the plainest hole there is: the
69
229
  * codebase can render it and the storyboard never shows it. Resolution today
70
230
  * is silent — `resolveStoryboardScreenCases` maps declared pages and never
71
231
  * looks at the discovered route list.
232
+ *
233
+ * Two ways a screen represents a route, checked in this order:
234
+ *
235
+ * 1. Explicitly, by listing the route in `coverageRoutes`. The entry must
236
+ * equal the discovered route's `id` or normalize to its path — no
237
+ * parameter substitution, no prefix. A screen that renders a registered
238
+ * component covers the route this way without a navigation URL; a screen
239
+ * booted at `/items/fixture-1` covers `/items/[id]` this way without the
240
+ * core parsing bracket syntax.
241
+ * 2. Implicitly, by booting a concrete `route` that satisfies the pattern
242
+ * segment for segment (`:param` and `*` accept any nonempty segment).
243
+ *
244
+ * A mapping that names a missing route or an unregistered component is a
245
+ * diagnostic, not a representation: a stale mapping must not keep covering,
246
+ * and the route it named is reported among the candidates as well.
72
247
  */
248
+ export declare function auditRouteCoverage(input: RouteEnumerationInput): RouteCoverageAudit;
249
+ /** The unrepresented routes of `auditRouteCoverage`, for callers that only need the holes. */
73
250
  export declare function enumerateRouteCandidates(input: RouteEnumerationInput): SurfaceCandidate[];
74
251
  export interface ControlNodeLike {
75
252
  id: string;
@@ -111,28 +288,18 @@ export declare function requestEndpointShape(url: string): string;
111
288
  * (`StoryboardEnvironment.network`), which is what makes asking fair.
112
289
  */
113
290
  export declare function enumerateRequestCandidates(frameId: string, requests: readonly ObservedRequest[]): SurfaceCandidate[];
114
- export declare function setSurfaceClassifications(classifications: readonly SurfaceClassification[] | undefined): void;
115
- export declare function getSurfaceClassifications(): readonly SurfaceClassification[];
116
- /**
117
- * Records what a frame asked for while booting.
118
- *
119
- * Replaces rather than appends: a re-supplied frame boots again, and appending
120
- * would keep questions alive for endpoints the current recipe no longer calls.
121
- */
122
- export declare function setObservedRequests(frameId: string, requests: readonly ObservedRequest[]): void;
123
- export declare function getObservedRequests(frameId: string): readonly ObservedRequest[];
124
291
  export interface FrameSurfaceDemands {
125
292
  candidates: SurfaceCandidate[];
126
293
  unclassified: SurfaceCandidate[];
127
294
  }
128
- /**
129
- * The questions one frame owes an answer to.
130
- *
131
- * Controls come from the tree the editor already imported for editing, requests
132
- * from what the frame asked for while booting. Both are facts about this frame,
133
- * so the panel can show them next to the axes the host did declare — which is
134
- * where a missing axis becomes visible instead of merely absent.
135
- */
136
- export declare function frameSurfaceDemands(frameId: string, root?: (ControlNodeLike & {
137
- children?: readonly ControlNodeLike[];
138
- }) | null, classifications?: readonly SurfaceClassification[]): FrameSurfaceDemands;
295
+ /** One editor's declared surface classifications and the requests its frames observed. */
296
+ export declare function createSurfaceDemands(): {
297
+ setSurfaceClassifications: (classifications: readonly SurfaceClassification[] | undefined) => void;
298
+ getSurfaceClassifications: () => readonly SurfaceClassification[];
299
+ setObservedRequests: (frameId: string, requests: readonly ObservedRequest[]) => void;
300
+ getObservedRequests: (frameId: string) => readonly ObservedRequest[];
301
+ frameSurfaceDemands: (frameId: string, root?: (ControlNodeLike & {
302
+ children?: readonly ControlNodeLike[];
303
+ }) | null, classifications?: readonly SurfaceClassification[]) => FrameSurfaceDemands;
304
+ };
305
+ export type SurfaceDemands = ReturnType<typeof createSurfaceDemands>;
@@ -1,3 +1,4 @@
1
+ import type { DocumentSync } from './documentSync.js';
1
2
  export interface TokenDef {
2
3
  /** CSS variable name — e.g. `--app-color-surface-brand`. */
3
4
  name: string;
@@ -8,28 +9,26 @@ export interface TokenDef {
8
9
  /** Optional group label. */
9
10
  group?: string;
10
11
  }
11
- export declare function setTokens(t: TokenDef[]): void;
12
- export declare function getTokens(): TokenDef[];
13
- export declare function setOnTokensChange(cb: ((changed: {
14
- name: string;
15
- value: string;
16
- }[]) => void) | null): void;
17
- /** Value being edited (overridden) — if not present, injected raw value. */
18
- export declare function getTokenValue(name: string): string;
19
- export declare function getTokenOverrides(): {
20
- name: string;
21
- value: string;
22
- }[];
23
- /**
24
- * Replaces revision-local token edits without reporting them as new user edits.
25
- * Catalog installation uses this to retire one checkout's CSS overrides and to
26
- * restore them if the surrounding atomic install fails.
27
- */
28
- export declare function replaceTokenOverrides(next: readonly {
29
- name: string;
30
- value: string;
31
- }[]): void;
32
- /** Edit token value — Immediately override document root (live) + notify cumulative changes to host callback. */
33
- export declare function applyTokenOverride(name: string, value: string): void;
34
- /** Disable all overrides (return to original value). */
35
- export declare function resetTokenOverrides(): void;
12
+ /** The part of a runtime's document sync a token edit queues into. */
13
+ export type TokenSyncQueue = Pick<DocumentSync, 'queueTokenDesignChange'>;
14
+ /** One editor's design tokens and the overrides the designer applied. */
15
+ export declare function createTokens(): {
16
+ setTokens: (t: TokenDef[]) => void;
17
+ getTokens: () => TokenDef[];
18
+ setOnTokensChange: (cb: ((changed: {
19
+ name: string;
20
+ value: string;
21
+ }[]) => void) | null) => void;
22
+ getTokenValue: (name: string) => string;
23
+ getTokenOverrides: () => {
24
+ name: string;
25
+ value: string;
26
+ }[];
27
+ replaceTokenOverrides: (next: readonly {
28
+ name: string;
29
+ value: string;
30
+ }[]) => void;
31
+ applyTokenOverride: (sync: TokenSyncQueue, name: string, value: string) => void;
32
+ resetTokenOverrides: (sync: TokenSyncQueue) => void;
33
+ };
34
+ export type Tokens = ReturnType<typeof createTokens>;