@pygmalionjs/pygmalion 0.8.1 → 0.9.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 (129) hide show
  1. package/binding-source.d.ts +25 -0
  2. package/dist-lib/{CameraLayer-B2D29VXQ.js → CameraLayer-BdOko8XE.js} +17 -17
  3. package/dist-lib/pygmalion.js +24599 -12746
  4. package/dist-lib/{runtime-BAy8W1mJ.js → runtime-Dxb-IaLN.js} +12414 -11114
  5. package/dist-lib/style.css +1 -1
  6. package/dist-lib/testing.js +10 -10
  7. package/dist-lib/types/binding/catalog.d.ts +10 -0
  8. package/dist-lib/types/binding/contracts.d.ts +202 -0
  9. package/dist-lib/types/binding/documentCommands.d.ts +38 -0
  10. package/dist-lib/types/binding/index.d.ts +6 -0
  11. package/dist-lib/types/binding/preview.d.ts +37 -0
  12. package/dist-lib/types/binding/source.d.ts +109 -0
  13. package/dist-lib/types/binding/useDataProjection.d.ts +9 -0
  14. package/dist-lib/types/binding/validate.d.ts +8 -0
  15. package/dist-lib/types/core/runtime.d.ts +6 -0
  16. package/dist-lib/types/document/appearance.d.ts +112 -0
  17. package/dist-lib/types/document/assets.d.ts +204 -0
  18. package/dist-lib/types/document/components.d.ts +169 -0
  19. package/dist-lib/types/document/contracts.d.ts +171 -0
  20. package/dist-lib/types/document/engine.d.ts +20 -0
  21. package/dist-lib/types/document/exportSettings.d.ts +45 -0
  22. package/dist-lib/types/document/geometry.d.ts +11 -0
  23. package/dist-lib/types/document/layout.d.ts +53 -0
  24. package/dist-lib/types/document/prototype.d.ts +424 -0
  25. package/dist-lib/types/document/prototypeReferences.d.ts +3 -0
  26. package/dist-lib/types/document/richText.d.ts +185 -0
  27. package/dist-lib/types/document/styles.d.ts +216 -0
  28. package/dist-lib/types/document/svgImport.d.ts +17 -0
  29. package/dist-lib/types/document/vector.d.ts +222 -0
  30. package/dist-lib/types/editor/designCompiler.d.ts +7 -0
  31. package/dist-lib/types/editor/designImport.d.ts +7 -0
  32. package/dist-lib/types/editor/inspect.d.ts +8 -0
  33. package/dist-lib/types/editor/revisionCatalogInstall.d.ts +1 -1
  34. package/dist-lib/types/editor/screenInteractions.d.ts +3 -3
  35. package/dist-lib/types/editor/store.d.ts +1 -1
  36. package/dist-lib/types/host/project.d.ts +44 -0
  37. package/dist-lib/types/host/registryConnections.d.ts +11 -0
  38. package/dist-lib/types/host/sourceFilePlan.d.ts +15 -0
  39. package/dist-lib/types/host/sourceWriteback.d.ts +50 -0
  40. package/dist-lib/types/lib.d.ts +101 -3
  41. package/dist-lib/types/token-library/bindings.d.ts +62 -0
  42. package/dist-lib/types/token-library/contracts.d.ts +117 -0
  43. package/dist-lib/types/token-library/engine.d.ts +13 -0
  44. package/dist-lib/types/workspace/WorkspaceShell.d.ts +9 -0
  45. package/dist-lib/types/workspace/application/ApplicationWorkspace.d.ts +3 -0
  46. package/dist-lib/types/workspace/configuration.d.ts +39 -0
  47. package/dist-lib/types/workspace/contracts.d.ts +64 -0
  48. package/dist-lib/types/workspace/controller.d.ts +35 -0
  49. package/dist-lib/types/workspace/documentSessions.d.ts +42 -0
  50. package/dist-lib/types/workspace/edit/AppearancePanel.d.ts +23 -0
  51. package/dist-lib/types/workspace/edit/ArrangeLayers.d.ts +10 -0
  52. package/dist-lib/types/workspace/edit/AssetsPanel.d.ts +16 -0
  53. package/dist-lib/types/workspace/edit/CanvasGuides.d.ts +19 -0
  54. package/dist-lib/types/workspace/edit/ComponentPanel.d.ts +11 -0
  55. package/dist-lib/types/workspace/edit/DataPanel.d.ts +16 -0
  56. package/dist-lib/types/workspace/edit/DesignWorkspace.d.ts +10 -0
  57. package/dist-lib/types/workspace/edit/LayerTree.d.ts +14 -0
  58. package/dist-lib/types/workspace/edit/LayoutPanel.d.ts +13 -0
  59. package/dist-lib/types/workspace/edit/PrototypePanel.d.ts +12 -0
  60. package/dist-lib/types/workspace/edit/ScopeTransferDialog.d.ts +40 -0
  61. package/dist-lib/types/workspace/edit/SelectionHandles.d.ts +52 -0
  62. package/dist-lib/types/workspace/edit/StylesPanel.d.ts +8 -0
  63. package/dist-lib/types/workspace/edit/TextEditor.d.ts +50 -0
  64. package/dist-lib/types/workspace/edit/VectorEditor.d.ts +89 -0
  65. package/dist-lib/types/workspace/edit/VectorToolbar.d.ts +5 -0
  66. package/dist-lib/types/workspace/edit/canvasGuideModel.d.ts +102 -0
  67. package/dist-lib/types/workspace/edit/clipboard.d.ts +35 -0
  68. package/dist-lib/types/workspace/edit/duplicateMetadata.d.ts +2 -0
  69. package/dist-lib/types/workspace/edit/geometryHandles.d.ts +224 -0
  70. package/dist-lib/types/workspace/edit/layerArrangement.d.ts +39 -0
  71. package/dist-lib/types/workspace/edit/layerMoves.d.ts +44 -0
  72. package/dist-lib/types/workspace/edit/projection.d.ts +12 -0
  73. package/dist-lib/types/workspace/edit/scopeTransfer.d.ts +96 -0
  74. package/dist-lib/types/workspace/edit/textStyles.d.ts +75 -0
  75. package/dist-lib/types/workspace/edit/vectorTools.d.ts +136 -0
  76. package/dist-lib/types/workspace/legacyModeAdapter.d.ts +13 -0
  77. package/dist-lib/types/workspace/source/ResponsiveLayoutPanel.d.ts +20 -0
  78. package/dist-lib/types/workspace/source/SourceReview.d.ts +11 -0
  79. package/dist-lib/types/workspace/source/appearanceSource.d.ts +19 -0
  80. package/dist-lib/types/workspace/source/compiler.d.ts +5 -0
  81. package/dist-lib/types/workspace/source/contracts.d.ts +156 -0
  82. package/dist-lib/types/workspace/source/controller.d.ts +50 -0
  83. package/dist-lib/types/workspace/source/documentRevision.d.ts +2 -0
  84. package/dist-lib/types/workspace/source/draftPreviewClient.d.ts +13 -0
  85. package/dist-lib/types/workspace/source/draftRecipe.d.ts +30 -0
  86. package/dist-lib/types/workspace/source/flowContracts.d.ts +72 -0
  87. package/dist-lib/types/workspace/source/prototypeSource.d.ts +4 -0
  88. package/dist-lib/types/workspace/source/responsive.d.ts +13 -0
  89. package/dist-lib/types/workspace/source/responsiveContracts.d.ts +78 -0
  90. package/dist-lib/types/workspace/source/structure.d.ts +21 -0
  91. package/dist-lib/types/workspace/source/textSource.d.ts +28 -0
  92. package/dist-lib/types/workspace/tokens/TokenLibraryContext.d.ts +11 -0
  93. package/dist-lib/types/workspace/tokens/TokenLibraryWorkspace.d.ts +14 -0
  94. package/dist-lib/types/workspace/tokens/contracts.d.ts +74 -0
  95. package/dist-lib/types/workspace/tokens/controller.d.ts +44 -0
  96. package/dist-lib/types/workspace/view/PrototypePlayer.d.ts +17 -0
  97. package/dist-lib/types/workspace/view/StoryboardWorkspace.d.ts +3 -0
  98. package/dist-lib/types/workspace/view/prototypePlayback.d.ts +46 -0
  99. package/draft-preview.d.ts +54 -0
  100. package/inspect.d.ts +2 -0
  101. package/node/design-session.mjs +3 -0
  102. package/node/inspect-plugin.mjs +3 -1
  103. package/node/inspect-writeback.mjs +18 -2
  104. package/node/preview-artifact-store.mjs +10 -7
  105. package/node/source-archive.mjs +88 -0
  106. package/node/source-bindings.mjs +65 -0
  107. package/node/source-file-lock.mjs +15 -0
  108. package/node/source-file-plan.mjs +162 -0
  109. package/node/source-file-proofs.mjs +44 -0
  110. package/node/source-responsive-codec.d.mts +17 -0
  111. package/node/source-responsive-codec.mjs +133 -0
  112. package/node/source-responsive.mjs +189 -0
  113. package/node/source-structure-reconcile.mjs +186 -0
  114. package/node/source-structure-wrapper-codec.d.mts +20 -0
  115. package/node/source-structure-wrapper-codec.mjs +205 -0
  116. package/node/source-structure.mjs +404 -0
  117. package/node/token-source-references.mjs +136 -0
  118. package/node/workspace-draft-preview-plugin.mjs +70 -0
  119. package/node/workspace-draft-preview.mjs +231 -0
  120. package/node/workspace-source-identity.d.mts +1 -0
  121. package/node/workspace-source-identity.mjs +21 -0
  122. package/node/workspace-source-plan.mjs +195 -0
  123. package/package.json +52 -6
  124. package/source-files.d.ts +35 -0
  125. package/source-responsive.d.ts +10 -0
  126. package/source-structure.d.ts +155 -0
  127. package/workspace-source-plan.d.ts +44 -0
  128. package/docs/coverage-contracts.md +0 -444
  129. package/docs/screen-state-contract.md +0 -252
@@ -0,0 +1,16 @@
1
+ import type { DocumentEngine } from '../../document/contracts.js';
2
+ import { type DesignExportArtifact, type RasterExportRenderer } from '../../document/exportSettings.js';
3
+
4
+ export interface AssetsPanelProps {
5
+ engine: DocumentEngine;
6
+ parentId?: string;
7
+ selectedNodeId?: string;
8
+ allocateId: (sourceId: string) => string;
9
+ onSelect?: (nodeId: string) => void;
10
+ onExport?: (artifact: DesignExportArtifact) => void | Promise<void>;
11
+ rasterRenderer?: RasterExportRenderer;
12
+ disabled?: boolean;
13
+ }
14
+ export declare function AssetsPanel({ engine, parentId, selectedNodeId, allocateId, onSelect, onExport, rasterRenderer, disabled }: AssetsPanelProps): import("react").JSX.Element;
15
+ /** Explicit local download callback for the panel; raster output still needs a separate host renderer. */
16
+ export declare function downloadDesignArtifact(artifact: DesignExportArtifact): void;
@@ -0,0 +1,19 @@
1
+ import type { DataProjection } from '../../binding/preview.js';
2
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
3
+
4
+ type Act = (label: string, apply: (transaction: DocumentTransaction) => void) => unknown;
5
+ /** Rulers and persisted guide/grid overlays use canvas units inside the scaled stage. */
6
+ export declare function CanvasGuides({ document, selected, projection, zoom, act, width, height }: {
7
+ document: DesignDocument;
8
+ selected?: readonly string[];
9
+ projection?: DataProjection | null;
10
+ zoom: number;
11
+ act: Act;
12
+ width?: number;
13
+ height?: number;
14
+ }): import("react").JSX.Element;
15
+ export declare function CanvasGuidesPanel({ node, act }: {
16
+ node: DocumentNode;
17
+ act: Act;
18
+ }): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { DesignDocument, DocumentDuplicateMetadataRemapper, DocumentTransaction } from '../../document/contracts.js';
2
+
3
+ export interface ComponentPanelProps {
4
+ document: DesignDocument;
5
+ selected: readonly string[];
6
+ act(label: string, apply: (transaction: DocumentTransaction) => void): boolean;
7
+ onSelect(id: string): void;
8
+ allocateId?(sourceId: string): string;
9
+ remapMetadata?: DocumentDuplicateMetadataRemapper;
10
+ }
11
+ export declare function ComponentPanel({ document, selected, act, onSelect, allocateId, remapMetadata }: ComponentPanelProps): import("react").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import type { DocumentEngine } from '../../document/contracts.js';
2
+ import type { HostDataCapabilities } from '../../binding/contracts.js';
3
+ import type { DataProjection } from '../../binding/preview.js';
4
+ export interface DataPanelProps {
5
+ engine: DocumentEngine;
6
+ selectedNodeId: string | null;
7
+ capabilities: HostDataCapabilities;
8
+ screenId: string;
9
+ onProjection?(projection: DataProjection | null): void;
10
+ onRequestData?(request: {
11
+ screenId: string;
12
+ description: string;
13
+ }): void;
14
+ }
15
+ /** Data is read-only host knowledge; this panel changes only placement and presentation. */
16
+ export declare function DataPanel({ engine, selectedNodeId, capabilities, screenId, onProjection, onRequestData }: DataPanelProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { EditorRuntime } from '../../core/runtime.js';
2
+ import { type WorkspaceConfiguration } from '../configuration.js';
3
+ import { type WorkspaceDocumentSessions } from '../documentSessions.js';
4
+
5
+ export interface DesignWorkspaceProps {
6
+ runtime: EditorRuntime;
7
+ configuration: WorkspaceConfiguration;
8
+ sessions: WorkspaceDocumentSessions;
9
+ }
10
+ export declare function DesignWorkspace(props: DesignWorkspaceProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { DesignDocument, DocumentEngineOptions, DocumentTransaction } from '../../document/contracts.js';
2
+ import type { HostDataCapabilities } from '../../binding/contracts.js';
3
+
4
+ export interface LayerTreeProps {
5
+ document: DesignDocument;
6
+ selected: readonly string[];
7
+ onSelectionChange(ids: readonly string[]): void;
8
+ act(label: string, apply: (transaction: DocumentTransaction) => void): boolean;
9
+ preflight?: DocumentEngineOptions['preflight'];
10
+ /** With host declarations, a drop blocked only by a data-scope escape asks for explicit binding decisions. */
11
+ capabilities?: HostDataCapabilities;
12
+ }
13
+ /** A document-owned tree gesture always commits through the existing document transaction. */
14
+ export declare function LayerTree({ document, selected, onSelectionChange, act, preflight, capabilities }: LayerTreeProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
2
+
3
+ type Act = (label: string, apply: (transaction: DocumentTransaction) => void) => unknown;
4
+ export interface LayoutPanelProps {
5
+ document: DesignDocument;
6
+ node: DocumentNode;
7
+ act: Act;
8
+ sourceGroup?: boolean;
9
+ intrinsic?: boolean;
10
+ }
11
+ /** Authored layout controls. Source wrappers retain host-declared spacing spellings on review. */
12
+ export declare function LayoutPanel({ document, node, act, sourceGroup, intrinsic }: LayoutPanelProps): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { DocumentEngine } from '../../document/contracts.js';
2
+
3
+ export declare function PrototypeField({ label, value, onCommit, numeric }: {
4
+ label: string;
5
+ value: string | number;
6
+ onCommit(value: string): void;
7
+ numeric?: boolean;
8
+ }): import("react").JSX.Element;
9
+ export declare function PrototypePanel({ engine, nodeId }: {
10
+ engine: DocumentEngine;
11
+ nodeId: string | null;
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { HostDataCapabilities } from '../../binding/contracts.js';
3
+ import type { DesignDocument, DocumentEngineOptions, DocumentTransaction } from '../../document/contracts.js';
4
+ import { type DocumentLayerMoveRequest, type ReadyDocumentLayerMove } from './layerMoves.js';
5
+ import { type ScopeTransferDecision, type ScopeTransferDecisionPlan, type ScopeTransferPlan } from './scopeTransfer.js';
6
+
7
+ export interface ScopeTransferDialogProps {
8
+ plan: ScopeTransferDecisionPlan;
9
+ /** A rejected decision set stays open with its diagnostics; the document is untouched. */
10
+ error?: string;
11
+ onCancel(): void;
12
+ onApply(decisions: readonly ScopeTransferDecision[]): void;
13
+ }
14
+ /**
15
+ * Presents every connection a move would carry out of its data scope, with declaration evidence,
16
+ * and collects one explicit decision per connection. Cancel is the default; nothing is committed
17
+ * until the caller applies the complete decision set in one document transaction.
18
+ */
19
+ export declare function ScopeTransferDialog({ plan, error, onCancel, onApply }: ScopeTransferDialogProps): import("react").JSX.Element;
20
+ export interface ScopeTransferHandlers {
21
+ label: string;
22
+ onCommitted?(move: ReadyDocumentLayerMove): void;
23
+ /** The move was planned but not applied: the live transaction failed or the document changed. */
24
+ onRejected?(message: string): void;
25
+ onCancelled?(): void;
26
+ }
27
+ export interface ScopeTransferController {
28
+ /** Commits a plain move immediately; a scope-only rejection opens the decision dialog instead. */
29
+ move(request: DocumentLayerMoveRequest, handlers: ScopeTransferHandlers): ScopeTransferPlan;
30
+ pending: ScopeTransferDecisionPlan | null;
31
+ cancel(): void;
32
+ dialog: ReactNode;
33
+ }
34
+ /** Shared by the layer tree and any inspector control that reparents layers through the live transaction. */
35
+ export declare function useScopeTransfer({ document, capabilities, preflight, act }: {
36
+ document: DesignDocument;
37
+ capabilities?: HostDataCapabilities;
38
+ preflight?: DocumentEngineOptions['preflight'];
39
+ act(label: string, apply: (transaction: DocumentTransaction) => void): boolean;
40
+ }): ScopeTransferController;
@@ -0,0 +1,52 @@
1
+ import type { DataProjection } from '../../binding/preview.js';
2
+ import type { DesignDocument, DocumentTransaction } from '../../document/contracts.js';
3
+ import { type LayerPlacement, type SnapGuide } from './geometryHandles.js';
4
+
5
+ type Act = (label: string, apply: (transaction: DocumentTransaction) => void) => boolean;
6
+ export interface LayerGeometryPreview extends LayerPlacement {
7
+ readonly nodeId: string;
8
+ }
9
+ export interface SelectionHandlesProps {
10
+ document: DesignDocument;
11
+ selected: readonly string[];
12
+ projection: DataProjection | null;
13
+ /** Canvas scale; handles keep a constant screen size and snapping a constant screen tolerance. */
14
+ zoom: number;
15
+ act: Act;
16
+ /** A move the canvas is previewing itself: the box follows it and its guides are drawn here. */
17
+ movePreview?: {
18
+ readonly nodeId: string;
19
+ readonly x: number;
20
+ readonly y: number;
21
+ readonly guides?: readonly SnapGuide[];
22
+ } | null;
23
+ /** Lets the canvas render the layer with in-gesture geometry; `null` ends the preview. */
24
+ onPreview?(preview: LayerGeometryPreview | null): void;
25
+ /** Same for a selection box gesture, which previews several layers at once; `null` ends the preview. */
26
+ onPreviewMany?(previews: readonly LayerGeometryPreview[] | null): void;
27
+ }
28
+ /** Key of the shared box in `data-selection-box` when several layers are selected. */
29
+ export declare const SELECTION_BOX_ID = "selection";
30
+ /**
31
+ * Canvas overlay for free-placement layers: eight resize handles, a rotation handle, and snap
32
+ * guides. One selected layer gets its own box; several selected layers share one selection box
33
+ * that resizes and rotates every independent member together. It is mounted inside the scaled
34
+ * stage so its coordinates are canvas units, while handle sizes divide by the zoom to stay
35
+ * constant on screen. Every gesture becomes one document transaction on release; Escape cancels
36
+ * it with the document untouched. Layers the geometry policy refuses (auto layout children,
37
+ * source layout, repeated rows) get no handles; the inspector section reports the diagnostic,
38
+ * mirroring layer arrangement, so the canvas DOM carries no text beyond the transient gesture
39
+ * feedback.
40
+ */
41
+ export declare function SelectionHandles({ document, selected, projection, zoom, act, movePreview, onPreview, onPreviewMany }: SelectionHandlesProps): import("react").JSX.Element;
42
+ /**
43
+ * Inspector section: the geometry policy for the whole selection, plus parent-relative rotation
44
+ * in degrees and resize constraints when exactly one layer is selected.
45
+ */
46
+ export declare function LayerGeometryInspector({ document, selected, projection, act }: {
47
+ document: DesignDocument;
48
+ selected: readonly string[];
49
+ projection: DataProjection | null;
50
+ act: Act;
51
+ }): import("react").JSX.Element | null;
52
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
2
+
3
+ export interface StylesPanelProps {
4
+ document: DesignDocument;
5
+ node: DocumentNode | null;
6
+ act(label: string, apply: (tx: DocumentTransaction) => void): boolean;
7
+ }
8
+ export declare function StylesPanel({ document, node, act }: StylesPanelProps): import("react").JSX.Element | null;
@@ -0,0 +1,50 @@
1
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
2
+ import { type TextFontLoader, type TextFontLoadReport } from '../../document/richText.js';
3
+
4
+ type Act = (label: string, apply: (transaction: DocumentTransaction) => void) => boolean;
5
+ /**
6
+ * Renders a text node's paragraphs and runs with inline styles. Lists are real `<ul>`/`<ol>` elements and
7
+ * links are `<a>` elements that never navigate inside the editor. `content` is projected bound data,
8
+ * rendered plain with the node-level style only.
9
+ */
10
+ export declare function TextNodeSurface({ node, content }: {
11
+ node: DocumentNode;
12
+ content?: string;
13
+ }): import("react").JSX.Element;
14
+ /**
15
+ * Loads the faces a text node needs through the injected loader (the browser font set when none is given) and
16
+ * reports what stayed unavailable. `null` while nothing is required, no loader exists, or the load is pending.
17
+ * Nothing here reaches the network on its own; the host declares its faces.
18
+ */
19
+ export declare function useTextFontStatus(node: DocumentNode, loader?: TextFontLoader | null): TextFontLoadReport | null;
20
+ export interface TextInlineEditorProps {
21
+ document: DesignDocument;
22
+ node: DocumentNode;
23
+ act: Act;
24
+ /** Called once the edit is committed or discarded; the canvas then shows the surface again. */
25
+ onDone(): void;
26
+ /** Whether a binding targets the node; derived from the document when omitted. */
27
+ connected?: boolean;
28
+ }
29
+ /**
30
+ * Edits the written text in place on the canvas. Mounted by the canvas instead of the surface after a
31
+ * double-click; blur or Ctrl/Cmd+Enter commits one transaction, Escape discards the draft. Connected text
32
+ * is refused because its content comes from data.
33
+ */
34
+ export declare function TextInlineEditor({ document, node, act, onDone, connected }: TextInlineEditorProps): import("react").JSX.Element;
35
+ export interface TextEditorProps {
36
+ document: DesignDocument;
37
+ node: DocumentNode;
38
+ act: Act;
39
+ /** Whether a binding targets the node; derived from the document when omitted. */
40
+ connected?: boolean;
41
+ /** Resolves required faces; the browser font set when omitted, no loading when null. */
42
+ fontLoader?: TextFontLoader | null;
43
+ }
44
+ /**
45
+ * Inspector section for a text node. The written text is edited in a textarea whose selection decides
46
+ * whether a style applies to a character range or to the whole layer. Every committed edit is one
47
+ * document transaction; Escape discards the uncommitted draft.
48
+ */
49
+ export declare function TextEditor({ document, node, act, connected, fontLoader }: TextEditorProps): import("react").JSX.Element;
50
+ export {};
@@ -0,0 +1,89 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DataProjection } from '../../binding/preview.js';
3
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
4
+ import { type VectorAnchor, type VectorAnchorAddress, type VectorBooleanOperation, type VectorProperties, type VectorShape } from '../../document/vector.js';
5
+ import { type VectorAnchorAction, type VectorAnchorActions, type VectorBooleanPlan, type VectorEditPlan, type VectorStyle, type VectorTool } from './vectorTools.js';
6
+
7
+ type Act = (label: string, apply: (transaction: DocumentTransaction) => void) => boolean;
8
+ /** Box geometry a canvas gesture is previewing for one layer; the surface draws it instead of the stored path. */
9
+ export interface VectorGeometryPreview {
10
+ readonly nodeId: string;
11
+ readonly vector: VectorProperties;
12
+ }
13
+ export interface VectorEditingSession {
14
+ readonly document: DesignDocument;
15
+ readonly projection: DataProjection | null;
16
+ readonly selection: readonly string[];
17
+ readonly tool: VectorTool;
18
+ setTool(tool: VectorTool): void;
19
+ readonly plan: VectorEditPlan;
20
+ /** Selected anchors of the edit target; addresses that no longer exist are dropped. */
21
+ readonly anchors: readonly VectorAnchorAddress[];
22
+ setAnchors(anchors: readonly VectorAnchorAddress[]): void;
23
+ readonly actions: VectorAnchorActions;
24
+ readonly boolean: VectorBooleanPlan;
25
+ readonly feedback: string;
26
+ report(text: string): void;
27
+ insertShape(shape: VectorShape): void;
28
+ /** Commits a pen path; points are canvas coordinates of the stage. */
29
+ drawPath(points: readonly VectorAnchor[], closed: boolean): boolean;
30
+ /** Stores box geometry on the edit target as one transaction, refitting the layer box. */
31
+ commitGeometry(label: string, next: VectorProperties, anchors?: readonly VectorAnchorAddress[]): boolean;
32
+ changeArc(key: 'start' | 'sweep' | 'innerRadius', value: number): void;
33
+ restyle(label: string, style: Partial<VectorStyle>): boolean;
34
+ runAnchorAction(action: VectorAnchorAction): void;
35
+ combine(operation: VectorBooleanOperation): void;
36
+ }
37
+ export interface VectorEditing extends VectorEditingSession {
38
+ readonly toolbar: ReactNode;
39
+ readonly inspector: ReactNode;
40
+ }
41
+ export interface VectorEditingInput {
42
+ document: DesignDocument;
43
+ selection: readonly string[];
44
+ projection: DataProjection | null;
45
+ act: Act;
46
+ select(id: string): void;
47
+ }
48
+ export interface VectorEditorProps {
49
+ session: VectorEditingSession;
50
+ zoom: number;
51
+ onPreview?(preview: VectorGeometryPreview | null): void;
52
+ }
53
+ /**
54
+ * Renders a vector layer: one `<svg>` filling the layer box with the stored path, fitted to
55
+ * the box, honouring fill, fill rule, stroke, and corner radius. A mask layer shows no paint
56
+ * of its own; the canvas clips the siblings above it with the mask's outline.
57
+ */
58
+ export declare function VectorNodeSurface({ node, width, height, vector }: {
59
+ node: DocumentNode;
60
+ width?: number;
61
+ height?: number;
62
+ vector?: VectorProperties;
63
+ }): import("react").JSX.Element;
64
+ /**
65
+ * Owns the vector editing state for a design workspace: the active tool, the anchor selection,
66
+ * gesture feedback, and every command the toolbar, the canvas overlay, and the inspector issue.
67
+ * The returned `toolbar` and `inspector` are ready to mount; the canvas mounts `VectorEditor`
68
+ * with the same session inside the stage.
69
+ */
70
+ export declare function useVectorEditing({ document, selection, projection, act, select }: VectorEditingInput): VectorEditing;
71
+ /**
72
+ * Canvas overlay inside the scaled stage. With the pen tool it covers the stage and turns
73
+ * clicks into anchors (a click on the first anchor closes the path, Enter finishes an open
74
+ * one, Escape discards the draft). With the select tool it draws the selected path's
75
+ * anchors and handles: drag moves them with a live preview and commits one transaction on
76
+ * release, Escape cancels with the document untouched, double-clicking a segment adds an
77
+ * anchor, Delete removes the selected anchors. Handle and anchor sizes divide by the zoom.
78
+ */
79
+ export declare function VectorEditor({ session, zoom, onPreview }: VectorEditorProps): import("react").JSX.Element;
80
+ /**
81
+ * Inspector section for vector layers: paint, stroke, corner radius, and mask for one selected
82
+ * layer; anchor actions for the anchors selected on the canvas; boolean operations when two
83
+ * vector layers sharing a parent are selected. Policy and gesture feedback show here, never
84
+ * inside the canvas.
85
+ */
86
+ export declare function VectorInspector({ session }: {
87
+ session: VectorEditingSession;
88
+ }): import("react").JSX.Element | null;
89
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { VectorEditingSession } from './VectorEditor.js';
2
+ /** Toolbar group: the select and pen tools plus one button per shape. */
3
+ export declare function VectorToolbar({ session }: {
4
+ session: VectorEditingSession;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,102 @@
1
+ import type { DocumentNode, DocumentNodeKind, DocumentNodePatch } from '../../document/contracts.js';
2
+ /**
3
+ * Pure model for the canvas furniture that Figma keeps next to the layers: persisted
4
+ * guides, layout grids on frames, and the rulers that measure the stage.
5
+ *
6
+ * Guides live on the node they belong to as `node.properties.guides`: the document root
7
+ * carries the canvas guides (canvas units, the space root children are placed in) and a
8
+ * frame carries its own guides in its local space. Layout grids live on frames and
9
+ * component definitions as `node.properties.layoutGrids`, in the local space of the box
10
+ * they describe. Both are plain document values, so they save, reopen, and undo with the
11
+ * document like any other property; nothing here reaches the DOM.
12
+ */
13
+ export type GuideAxis = 'x' | 'y';
14
+ /** A guide is one straight line across its owner: `axis: 'x'` is a vertical line at `position`. */
15
+ export interface CanvasGuide {
16
+ axis: GuideAxis;
17
+ position: number;
18
+ }
19
+ export type LayoutGridPattern = 'columns' | 'rows' | 'grid';
20
+ export type LayoutGridAlign = 'stretch' | 'start' | 'center' | 'end';
21
+ export interface LayoutGridTracks {
22
+ pattern: 'columns' | 'rows';
23
+ count: number;
24
+ gutter: number;
25
+ align: LayoutGridAlign;
26
+ /** Track width or height; ignored (derived) for `stretch`. */
27
+ size?: number;
28
+ /** Margin from both edges for `stretch`, from the leading edge for `start`, from the trailing edge for `end`. */
29
+ offset?: number;
30
+ visible?: boolean;
31
+ color?: string;
32
+ }
33
+ export interface LayoutGridPixels {
34
+ pattern: 'grid';
35
+ size: number;
36
+ visible?: boolean;
37
+ color?: string;
38
+ }
39
+ export type LayoutGrid = LayoutGridTracks | LayoutGridPixels;
40
+ export interface LayoutGridTrack {
41
+ readonly start: number;
42
+ readonly end: number;
43
+ }
44
+ export interface LayoutGridGeometry {
45
+ readonly axis: GuideAxis;
46
+ readonly tracks: readonly LayoutGridTrack[];
47
+ }
48
+ export interface RulerTick {
49
+ readonly position: number;
50
+ readonly major: boolean;
51
+ readonly label?: string;
52
+ }
53
+ export interface RulerScale {
54
+ readonly major: number;
55
+ readonly minor: number;
56
+ }
57
+ export declare const GUIDES_PROPERTY = "guides";
58
+ export declare const LAYOUT_GRIDS_PROPERTY = "layoutGrids";
59
+ /** Node kinds that may carry layout grids; the document root carries canvas guides only. */
60
+ export declare const LAYOUT_GRID_KINDS: readonly DocumentNodeKind[];
61
+ export declare const LAYOUT_GRID_PATTERNS: readonly LayoutGridPattern[];
62
+ export declare const LAYOUT_GRID_ALIGNMENTS: readonly LayoutGridAlign[];
63
+ export declare const LAYOUT_GRID_DEFAULT_COLOR = "#ff4d4d1a";
64
+ export declare const PIXEL_GRID_DEFAULT_COLOR = "#0000000f";
65
+ /** Screen pixels between two labelled ruler ticks, at least. */
66
+ export declare const RULER_LABEL_SPACING = 60;
67
+ export declare function isCanvasGuide(value: unknown): value is CanvasGuide;
68
+ /** Strict structural check of a stored layout grid; unknown keys and non-finite numbers are rejected. */
69
+ export declare function isLayoutGrid(value: unknown): value is LayoutGrid;
70
+ /** Valid guides stored on a node, detached; invalid entries are dropped so one bad value never hides the rest. */
71
+ export declare function nodeGuides(node: Pick<DocumentNode, 'properties'>): CanvasGuide[];
72
+ /** Valid layout grids stored on a node, detached. */
73
+ export declare function nodeLayoutGrids(node: Pick<DocumentNode, 'properties'>): LayoutGrid[];
74
+ export declare function canCarryLayoutGrids(node: Pick<DocumentNode, 'kind'>): boolean;
75
+ /** Stores guides on a node in canonical form; an empty list removes the key. */
76
+ export declare function guidesPatch(node: Pick<DocumentNode, 'properties'>, guides: readonly CanvasGuide[]): DocumentNodePatch;
77
+ /** Stores layout grids on a node in canonical form; an empty list removes the key. */
78
+ export declare function layoutGridsPatch(node: Pick<DocumentNode, 'kind' | 'properties'>, grids: readonly LayoutGrid[]): DocumentNodePatch;
79
+ /** Guides sorted by axis then position, without duplicates closer than `EPSILON`. */
80
+ export declare function normalizeGuides(guides: readonly CanvasGuide[]): CanvasGuide[];
81
+ export declare function addGuide(guides: readonly CanvasGuide[], guide: CanvasGuide): CanvasGuide[];
82
+ export declare function moveGuide(guides: readonly CanvasGuide[], index: number, position: number): CanvasGuide[];
83
+ export declare function removeGuide(guides: readonly CanvasGuide[], index: number): CanvasGuide[];
84
+ /** A grid with the defaults Figma offers: five stretched columns with a 20 gutter, or an eight-unit pixel grid. */
85
+ export declare function defaultLayoutGrid(pattern: LayoutGridPattern): LayoutGrid;
86
+ /**
87
+ * Track extents of a column or row grid along its axis inside a box of the given length.
88
+ * Stretch divides the room left by the margins; the other alignments lay fixed-size tracks
89
+ * from the leading edge, the trailing edge, or the center. Tracks that do not fit are dropped
90
+ * rather than drawn outside the box.
91
+ */
92
+ export declare function layoutGridTracks(grid: LayoutGridTracks, length: number): LayoutGridTrack[];
93
+ /** Column tracks run along x, row tracks along y; a pixel grid has no tracks (it is drawn as a lattice). */
94
+ export declare function layoutGridGeometry(grid: LayoutGrid, width: number, height: number): LayoutGridGeometry | null;
95
+ /** Distinct track edges of every visible column and row grid on a node, by axis, for snapping. */
96
+ export declare function layoutGridSnapLines(grids: readonly LayoutGrid[], width: number, height: number): CanvasGuide[];
97
+ /** Labelled step and tick step for a ruler at a zoom: labels stay at least `RULER_LABEL_SPACING` screen pixels apart. */
98
+ export declare function rulerScale(zoom: number, labelSpacing?: number): RulerScale;
99
+ /** Ticks covering `[from, to]` canvas units; every `major` multiple carries its value as the label. */
100
+ export declare function rulerTicks(zoom: number, from: number, to: number, labelSpacing?: number): RulerTick[];
101
+ /** Canvas position under a ruler pointer: `screen` is measured from the ruler's zero corner, `origin` is where canvas 0 sits on that ruler. */
102
+ export declare function rulerPointToCanvas(screen: number, origin: number, zoom: number): number;
@@ -0,0 +1,35 @@
1
+ import type { DesignDocument, DocumentMatrix, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
2
+ import { type AssetStore } from '../../document/assets.js';
3
+ export declare const DESIGN_CLIPBOARD_FORMAT = "pygmalion/design-clipboard";
4
+ export declare const DESIGN_INTERCHANGE_FORMAT = "pygmalion/design-document";
5
+ export interface DesignClipboard {
6
+ format: typeof DESIGN_CLIPBOARD_FORMAT;
7
+ version: 1;
8
+ sourceDocumentId: string;
9
+ roots: string[];
10
+ nodes: DocumentNode[];
11
+ definitions: DocumentNode[];
12
+ assets: AssetStore;
13
+ worldTransforms: Record<string, DocumentMatrix>;
14
+ }
15
+ /** Copies owned subtrees and the transitive component definitions they reference. */
16
+ export declare function copyDesignSubtrees(document: DesignDocument, selection: readonly string[]): DesignClipboard;
17
+ export declare function serializeDesignClipboard(payload: DesignClipboard): string;
18
+ export declare function parseDesignClipboard(serialized: string): DesignClipboard;
19
+ export interface PasteDesignResult {
20
+ document: DesignDocument;
21
+ roots: string[];
22
+ nodeIds: Record<string, string>;
23
+ }
24
+ /** Pure paste plan; commit the returned same-identity snapshot as one undoable transaction. */
25
+ export declare function pasteDesignSubtrees(target: DesignDocument, payload: DesignClipboard, options: {
26
+ parentId: string;
27
+ allocateId: (sourceId: string) => string;
28
+ offset?: {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ }): PasteDesignResult;
33
+ export declare function applyDesignPaste(transaction: Pick<DocumentTransaction, 'replaceDocument'>, plan: PasteDesignResult): void;
34
+ export declare function exportDesignInterchange(document: DesignDocument): string;
35
+ export declare function importDesignInterchange(text: string): DesignDocument;
@@ -0,0 +1,2 @@
1
+ import type { DesignDocument, DocumentDuplicateMetadataRemapper } from '../../document/contracts.js';
2
+ export declare function designDuplicateMetadata(document: DesignDocument, host?: DocumentDuplicateMetadataRemapper): DocumentDuplicateMetadataRemapper | undefined;