@pygmalionjs/pygmalion 0.8.1 → 0.10.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 (150) hide show
  1. package/README.md +34 -0
  2. package/binding-source.d.ts +25 -0
  3. package/dist-lib/{CameraLayer-B2D29VXQ.js → CameraLayer-BUOlJcUa.js} +17 -17
  4. package/dist-lib/pygmalion.js +24524 -12555
  5. package/dist-lib/{runtime-BAy8W1mJ.js → runtime-BOfDlGPR.js} +12438 -11118
  6. package/dist-lib/style.css +1 -1
  7. package/dist-lib/testing.js +19 -19
  8. package/dist-lib/types/binding/catalog.d.ts +10 -0
  9. package/dist-lib/types/binding/contracts.d.ts +202 -0
  10. package/dist-lib/types/binding/documentCommands.d.ts +38 -0
  11. package/dist-lib/types/binding/duplicateMetadata.d.ts +8 -0
  12. package/dist-lib/types/binding/index.d.ts +7 -0
  13. package/dist-lib/types/binding/preview.d.ts +37 -0
  14. package/dist-lib/types/binding/source.d.ts +109 -0
  15. package/dist-lib/types/binding/useDataProjection.d.ts +9 -0
  16. package/dist-lib/types/binding/validate.d.ts +8 -0
  17. package/dist-lib/types/core/runtime.d.ts +6 -0
  18. package/dist-lib/types/document/appearance.d.ts +112 -0
  19. package/dist-lib/types/document/assets.d.ts +204 -0
  20. package/dist-lib/types/document/components.d.ts +169 -0
  21. package/dist-lib/types/document/contracts.d.ts +171 -0
  22. package/dist-lib/types/document/engine.d.ts +20 -0
  23. package/dist-lib/types/document/exportSettings.d.ts +45 -0
  24. package/dist-lib/types/document/geometry.d.ts +11 -0
  25. package/dist-lib/types/document/layout.d.ts +53 -0
  26. package/dist-lib/types/document/prototype.d.ts +424 -0
  27. package/dist-lib/types/document/prototypeReferences.d.ts +3 -0
  28. package/dist-lib/types/document/richText.d.ts +185 -0
  29. package/dist-lib/types/document/styles.d.ts +216 -0
  30. package/dist-lib/types/document/svgImport.d.ts +17 -0
  31. package/dist-lib/types/document/vector.d.ts +222 -0
  32. package/dist-lib/types/editor/designCompiler.d.ts +7 -0
  33. package/dist-lib/types/editor/designImport.d.ts +7 -0
  34. package/dist-lib/types/editor/inspect.d.ts +8 -0
  35. package/dist-lib/types/editor/revisionCatalogInstall.d.ts +1 -1
  36. package/dist-lib/types/editor/screenInteractions.d.ts +3 -3
  37. package/dist-lib/types/editor/store.d.ts +1 -1
  38. package/dist-lib/types/host/project.d.ts +44 -0
  39. package/dist-lib/types/host/registryConnections.d.ts +11 -0
  40. package/dist-lib/types/host/sourceFilePlan.d.ts +15 -0
  41. package/dist-lib/types/host/sourceWriteback.d.ts +50 -0
  42. package/dist-lib/types/lib.d.ts +103 -3
  43. package/dist-lib/types/token-library/bindings.d.ts +62 -0
  44. package/dist-lib/types/token-library/contracts.d.ts +117 -0
  45. package/dist-lib/types/token-library/engine.d.ts +13 -0
  46. package/dist-lib/types/token-library/valueResolver.d.ts +19 -0
  47. package/dist-lib/types/workspace/WorkspaceShell.d.ts +9 -0
  48. package/dist-lib/types/workspace/application/ApplicationWorkspace.d.ts +3 -0
  49. package/dist-lib/types/workspace/configuration.d.ts +47 -0
  50. package/dist-lib/types/workspace/contracts.d.ts +64 -0
  51. package/dist-lib/types/workspace/controller.d.ts +35 -0
  52. package/dist-lib/types/workspace/documentSessions.d.ts +42 -0
  53. package/dist-lib/types/workspace/edit/AppearancePanel.d.ts +23 -0
  54. package/dist-lib/types/workspace/edit/ArrangeLayers.d.ts +10 -0
  55. package/dist-lib/types/workspace/edit/AssetsPanel.d.ts +16 -0
  56. package/dist-lib/types/workspace/edit/CanvasGuides.d.ts +19 -0
  57. package/dist-lib/types/workspace/edit/ComponentPanel.d.ts +11 -0
  58. package/dist-lib/types/workspace/edit/DataPanel.d.ts +16 -0
  59. package/dist-lib/types/workspace/edit/DesignWorkspace.d.ts +10 -0
  60. package/dist-lib/types/workspace/edit/LayerTree.d.ts +14 -0
  61. package/dist-lib/types/workspace/edit/LayoutPanel.d.ts +13 -0
  62. package/dist-lib/types/workspace/edit/PrototypePanel.d.ts +12 -0
  63. package/dist-lib/types/workspace/edit/ScopeTransferDialog.d.ts +40 -0
  64. package/dist-lib/types/workspace/edit/SelectionHandles.d.ts +52 -0
  65. package/dist-lib/types/workspace/edit/StylesPanel.d.ts +8 -0
  66. package/dist-lib/types/workspace/edit/TextEditor.d.ts +50 -0
  67. package/dist-lib/types/workspace/edit/VectorEditor.d.ts +89 -0
  68. package/dist-lib/types/workspace/edit/VectorToolbar.d.ts +5 -0
  69. package/dist-lib/types/workspace/edit/canvasGuideModel.d.ts +102 -0
  70. package/dist-lib/types/workspace/edit/clipboard.d.ts +35 -0
  71. package/dist-lib/types/workspace/edit/duplicateMetadata.d.ts +2 -0
  72. package/dist-lib/types/workspace/edit/geometryHandles.d.ts +224 -0
  73. package/dist-lib/types/workspace/edit/layerArrangement.d.ts +39 -0
  74. package/dist-lib/types/workspace/edit/layerMoves.d.ts +44 -0
  75. package/dist-lib/types/workspace/edit/projection.d.ts +12 -0
  76. package/dist-lib/types/workspace/edit/scopeTransfer.d.ts +96 -0
  77. package/dist-lib/types/workspace/edit/textStyles.d.ts +75 -0
  78. package/dist-lib/types/workspace/edit/vectorTools.d.ts +136 -0
  79. package/dist-lib/types/workspace/legacyModeAdapter.d.ts +13 -0
  80. package/dist-lib/types/workspace/source/ResponsiveLayoutPanel.d.ts +20 -0
  81. package/dist-lib/types/workspace/source/SourceReview.d.ts +11 -0
  82. package/dist-lib/types/workspace/source/appearanceSource.d.ts +19 -0
  83. package/dist-lib/types/workspace/source/compiler.d.ts +5 -0
  84. package/dist-lib/types/workspace/source/contracts.d.ts +156 -0
  85. package/dist-lib/types/workspace/source/controller.d.ts +50 -0
  86. package/dist-lib/types/workspace/source/documentRevision.d.ts +2 -0
  87. package/dist-lib/types/workspace/source/draftPreviewClient.d.ts +13 -0
  88. package/dist-lib/types/workspace/source/draftRecipe.d.ts +30 -0
  89. package/dist-lib/types/workspace/source/flowContracts.d.ts +72 -0
  90. package/dist-lib/types/workspace/source/prototypeSource.d.ts +4 -0
  91. package/dist-lib/types/workspace/source/responsive.d.ts +13 -0
  92. package/dist-lib/types/workspace/source/responsiveContracts.d.ts +78 -0
  93. package/dist-lib/types/workspace/source/structure.d.ts +21 -0
  94. package/dist-lib/types/workspace/source/textSource.d.ts +28 -0
  95. package/dist-lib/types/workspace/tokens/TokenLibraryContext.d.ts +11 -0
  96. package/dist-lib/types/workspace/tokens/TokenLibraryWorkspace.d.ts +14 -0
  97. package/dist-lib/types/workspace/tokens/contracts.d.ts +74 -0
  98. package/dist-lib/types/workspace/tokens/controller.d.ts +44 -0
  99. package/dist-lib/types/workspace/view/PrototypePlayer.d.ts +17 -0
  100. package/dist-lib/types/workspace/view/StoryboardWorkspace.d.ts +3 -0
  101. package/dist-lib/types/workspace/view/prototypePlayback.d.ts +46 -0
  102. package/draft-preview.d.ts +54 -0
  103. package/host-runtime.d.ts +73 -0
  104. package/inspect.d.ts +2 -0
  105. package/jsx-source-reconciler.d.ts +35 -0
  106. package/node/design-session.mjs +3 -0
  107. package/node/host-runtime.mjs +4 -0
  108. package/node/inspect-plugin.mjs +3 -1
  109. package/node/inspect-writeback.mjs +18 -2
  110. package/node/jsx-source-reconciler.mjs +155 -0
  111. package/node/preview-artifact-store.mjs +10 -7
  112. package/node/revision-catalog-resolver.mjs +159 -0
  113. package/node/source-archive-runtime.mjs +63 -0
  114. package/node/source-archive.mjs +88 -0
  115. package/node/source-bindings.mjs +65 -0
  116. package/node/source-file-lock.mjs +15 -0
  117. package/node/source-file-plan.mjs +162 -0
  118. package/node/source-file-proofs.mjs +44 -0
  119. package/node/source-module.mjs +17 -0
  120. package/node/source-responsive-codec.d.mts +17 -0
  121. package/node/source-responsive-codec.mjs +133 -0
  122. package/node/source-responsive.mjs +189 -0
  123. package/node/source-service-inputs.mjs +81 -0
  124. package/node/source-service-plugin.mjs +57 -0
  125. package/node/source-service.mjs +4 -0
  126. package/node/source-structure-reconcile.mjs +186 -0
  127. package/node/source-structure-wrapper-codec.d.mts +20 -0
  128. package/node/source-structure-wrapper-codec.mjs +205 -0
  129. package/node/source-structure.mjs +404 -0
  130. package/node/token-source-references.mjs +136 -0
  131. package/node/token-source-service.mjs +151 -0
  132. package/node/workspace-draft-entry.mjs +52 -0
  133. package/node/workspace-draft-preview-plugin.mjs +70 -0
  134. package/node/workspace-draft-preview.mjs +232 -0
  135. package/node/workspace-draft-process.mjs +129 -0
  136. package/node/workspace-draft-runtime.mjs +67 -0
  137. package/node/workspace-source-identity.d.mts +1 -0
  138. package/node/workspace-source-identity.mjs +21 -0
  139. package/node/workspace-source-plan.mjs +195 -0
  140. package/node/workspace-source-session.mjs +187 -0
  141. package/package.json +90 -6
  142. package/source-files.d.ts +35 -0
  143. package/source-module.d.ts +16 -0
  144. package/source-responsive.d.ts +10 -0
  145. package/source-service.d.ts +92 -0
  146. package/source-structure.d.ts +155 -0
  147. package/workspace-draft-entry.d.ts +15 -0
  148. package/workspace-source-plan.d.ts +44 -0
  149. package/docs/coverage-contracts.md +0 -444
  150. package/docs/screen-state-contract.md +0 -252
package/README.md CHANGED
@@ -442,6 +442,40 @@ Shared edits update detailed active frames and lightweight inactive frames in
442
442
  the same render cycle. A frame does not need to be activated before it reflects
443
443
  a shared change.
444
444
 
445
+ ### Connect source adapters to SDK services
446
+
447
+ The host supplies screen declarations, source mappings, authentication or mock
448
+ setup, and build commands. Pygmalion owns reusable execution, revision caching,
449
+ source review, and cancellation. Keep SDK implementation and regression tests
450
+ in Pygmalion; host tests continue to cover the product's own behavior.
451
+
452
+ | Package subpath | Responsibility |
453
+ | --- | --- |
454
+ | `./host-runtime` | Process-group cleanup, revision catalog queues and caches, isolated source roots, and lockfile-matched dependencies. |
455
+ | `./source-service` | Source and token review receipts, apply validation, reconciliation sessions, and local JSON transport. |
456
+ | `./source-reconciler` | Reconcile draft structure with external source edits using host-supplied source identity mappings. |
457
+ | `./draft-entry` | Generate a browser entry that applies the declared draft recipe and reports readiness or failure. |
458
+ | `./source-module` | Evaluate a trusted declaration bundle using the host's bundler configuration. |
459
+
460
+ For example, declare a build command in the host and let the SDK wait for its
461
+ process group to stop before an archive can be removed:
462
+
463
+ ```js
464
+ import { executeWorkspaceDraftProcess } from '@pygmalionjs/pygmalion/host-runtime';
465
+
466
+ export function buildPreview({ cwd, signal }) {
467
+ return executeWorkspaceDraftProcess(process.execPath, ['scripts/build-preview.mjs'], {
468
+ cwd,
469
+ signal,
470
+ timeout: 120_000,
471
+ });
472
+ }
473
+ ```
474
+
475
+ Process-group cleanup supports macOS and Linux. Catalog generation callbacks
476
+ receive an isolated archive for the exact requested commit; cancelling one
477
+ catalog request does not cancel generation shared with another caller.
478
+
445
479
  ## Local development
446
480
 
447
481
  ```bash
@@ -0,0 +1,25 @@
1
+ import type { BindingSourcePlan } from './dist-lib/types/binding/source.js';
2
+
3
+ export interface SourceBindingProofOptions {
4
+ sourceRevision: string;
5
+ files: ReadonlyMap<string, string> | Readonly<Record<string, string>>;
6
+ /** Explicit files the host permits this design operation to change. */
7
+ allowedFiles: readonly string[];
8
+ /** DTO/schema and other host-owned exclusions take precedence over allowed files. */
9
+ excludedSourcePrefixes?: readonly string[];
10
+ }
11
+
12
+ export interface SourceBindingProofDiagnostic {
13
+ severity: 'error';
14
+ code: 'binding-source-plan-invalid' | 'binding-source-policy-invalid' | 'binding-source-empty'
15
+ | 'binding-source-proof-invalid' | 'binding-source-file-excluded' | 'binding-source-file-missing'
16
+ | 'binding-source-stale' | 'binding-source-overlap' | 'binding-source-anchor-invalid';
17
+ message: string;
18
+ file?: string;
19
+ }
20
+
21
+ /** Verify evidence without writing source or accepting a literal-prop inspection payload. */
22
+ export declare function validateSourceBindingProofs(plan: BindingSourcePlan, options: SourceBindingProofOptions): {
23
+ valid: boolean;
24
+ diagnostics: SourceBindingProofDiagnostic[];
25
+ };
@@ -1,13 +1,13 @@
1
1
  import { jsx as p } from "react/jsx-runtime";
2
- import { a as C, R as P, at as g, bB as R, bC as b, C as E, bD as k, P as m, K as I } from "./runtime-BAy8W1mJ.js";
2
+ import { j as g, R as C, aI as P, cf as R, cg as E, U as I, ch as k, a3 as m, a0 as b } from "./runtime-BOfDlGPR.js";
3
3
  import { useRef as L, useLayoutEffect as h } from "react";
4
- function v(n) {
4
+ function f(n) {
5
5
  return `translate(${n.panX}px, ${n.panY}px) scale(${n.zoom})`;
6
6
  }
7
7
  function x(n, e, i, r = !1) {
8
8
  return r || k(n, e, i) ? void 0 : "none";
9
9
  }
10
- function f(n, e) {
10
+ function v(n, e) {
11
11
  return x(
12
12
  n.editMode,
13
13
  n.tool,
@@ -18,7 +18,7 @@ function f(n, e) {
18
18
  const l = /* @__PURE__ */ new WeakMap();
19
19
  function z(n, e, i, r) {
20
20
  if (e.route == null) return 0;
21
- const t = I(e) ?? e.route, a = e.width ?? 390, o = e.height ?? 600, c = n.declarations.getPreviewIdentityEpoch();
21
+ const t = b(e) ?? e.route, a = e.width ?? 390, o = e.height ?? 600, c = n.declarations.getPreviewIdentityEpoch();
22
22
  let s = l.get(e);
23
23
  (!s || s.revision !== i || s.epoch !== c || s.route !== t || s.width !== a || s.height !== o) && (s = {
24
24
  revision: i,
@@ -41,7 +41,7 @@ function F(n, e, i, r) {
41
41
  const c = e.width ?? 390;
42
42
  return c > 0 ? o.width / c : null;
43
43
  }
44
- function W(n) {
44
+ function B(n) {
45
45
  return w(n).map((i) => {
46
46
  var t;
47
47
  const r = n.store.pages.find((a) => a.id === i.id);
@@ -61,13 +61,13 @@ function w(n) {
61
61
  x: t.x ?? 0,
62
62
  y: t.y ?? 0,
63
63
  width: t.width ?? 390,
64
- height: E(t)
64
+ height: I(t)
65
65
  },
66
66
  pinned: t.id === e.activePageId || (r == null ? void 0 : r.kind) === "frame" && r.id === t.id || // A standby variant renders its full surface hidden at the group's
67
67
  // slot, so the switch to it has nothing left to mount.
68
68
  e.isScreenStateStandby(t) || // Catalog sheets need a full first render to replace their 1x1 seed.
69
69
  // Their live DOM remains mounted afterwards; offscreen paint may be skipped.
70
- b(t) || n.schedulers.previewIntent.hasPreviewIntent(t.id),
70
+ E(t) || n.schedulers.previewIntent.hasPreviewIntent(t.id),
71
71
  weightBytes: z(n, t, i, t.id === e.activePageId),
72
72
  screenshotDensity: F(
73
73
  n,
@@ -77,20 +77,20 @@ function w(n) {
77
77
  )
78
78
  }));
79
79
  }
80
- let B = 0;
81
- function $({
80
+ let O = 0;
81
+ function D({
82
82
  children: n,
83
83
  interactionFrameId: e = null
84
84
  }) {
85
- const i = C(), r = i.store, t = L(null);
85
+ const i = g(), r = i.store, t = L(null);
86
86
  return h(() => {
87
87
  const a = t.current;
88
88
  if (!a) return;
89
- const o = new P(`CameraLayer#${++B}`, () => {
89
+ const o = new C(`CameraLayer#${++O}`, () => {
90
90
  o.isDisposed || c();
91
91
  }), c = () => {
92
92
  o.track(() => {
93
- a.style.transform = v(r), a.style.pointerEvents = f(r, e) ?? "";
93
+ a.style.transform = f(r), a.style.pointerEvents = v(r, e) ?? "";
94
94
  });
95
95
  };
96
96
  return c(), () => o.dispose();
@@ -106,7 +106,7 @@ function $({
106
106
  // The live-screen budget follows the camera: the active frame first,
107
107
  // then the frames nearest the viewport take the remaining slots.
108
108
  onRecompute: ({ frames: o, camera: c, viewport: s }) => {
109
- const { liveScreens: d } = i.schedulers, { activeId: u, siblingIds: y, groupSize: S } = g(() => ({
109
+ const { liveScreens: d } = i.schedulers, { activeId: u, siblingIds: y, groupSize: S } = P(() => ({
110
110
  activeId: r.activePageId,
111
111
  siblingIds: r.activeScreenStateSiblingIds,
112
112
  groupSize: r.activeScreenStateGroup.length
@@ -142,18 +142,18 @@ function $({
142
142
  position: "absolute",
143
143
  left: 0,
144
144
  top: 0,
145
- transform: v(r),
145
+ transform: f(r),
146
146
  transformOrigin: "0 0",
147
147
  transition: "none",
148
148
  willChange: "transform",
149
- pointerEvents: f(r, e)
149
+ pointerEvents: v(r, e)
150
150
  },
151
151
  children: n
152
152
  }
153
153
  );
154
154
  }
155
155
  export {
156
- $ as CameraLayer,
157
- W as __debugReadEditorFrames,
156
+ D as CameraLayer,
157
+ B as __debugReadEditorFrames,
158
158
  x as resolveCameraPointerEvents
159
159
  };