@pairdraw/core 0.16.0 → 0.16.2

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 (145) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/providers.d.ts +6 -1
  3. package/dist/ai/providers.d.ts.map +1 -1
  4. package/dist/ai/providers.js +9 -0
  5. package/dist/ai/providers.js.map +1 -1
  6. package/dist/canvas/highlight-rect.d.ts +10 -1
  7. package/dist/canvas/highlight-rect.d.ts.map +1 -1
  8. package/dist/canvas/highlight-rect.js +16 -8
  9. package/dist/canvas/highlight-rect.js.map +1 -1
  10. package/dist/canvas/index.d.ts +2 -3
  11. package/dist/canvas/index.js +1 -2
  12. package/dist/canvas/issues/draw.d.ts +2 -6
  13. package/dist/canvas/issues/draw.d.ts.map +1 -1
  14. package/dist/canvas/issues/draw.js +2 -99
  15. package/dist/canvas/issues/draw.js.map +1 -1
  16. package/dist/canvas/issues/types.d.ts +2 -33
  17. package/dist/canvas/issues/types.d.ts.map +1 -1
  18. package/dist/canvas/overlays/{ai.d.ts → ai/draw.d.ts} +3 -3
  19. package/dist/canvas/overlays/ai/draw.d.ts.map +1 -0
  20. package/dist/canvas/overlays/ai/draw.js +102 -0
  21. package/dist/canvas/overlays/ai/draw.js.map +1 -0
  22. package/dist/canvas/overlays/ai/motion.d.ts +23 -0
  23. package/dist/canvas/overlays/ai/motion.d.ts.map +1 -0
  24. package/dist/canvas/overlays/ai/motion.js +32 -0
  25. package/dist/canvas/overlays/ai/motion.js.map +1 -0
  26. package/dist/canvas/renderer/methods.js +1 -1
  27. package/dist/canvas/renderer/methods.js.map +1 -1
  28. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  29. package/dist/canvas/renderer/overlay-pass.js +2 -47
  30. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  31. package/dist/canvas/renderer/pipeline.js +1 -1
  32. package/dist/canvas/renderer/pipeline.js.map +1 -1
  33. package/dist/canvas/renderer/state.d.ts +5 -3
  34. package/dist/canvas/renderer/state.d.ts.map +1 -1
  35. package/dist/canvas/renderer/state.js +18 -6
  36. package/dist/canvas/renderer/state.js.map +1 -1
  37. package/dist/canvas/renderer/types.d.ts +2 -2
  38. package/dist/canvas/renderer/types.d.ts.map +1 -1
  39. package/dist/canvas/renderer.d.ts +12 -8
  40. package/dist/canvas/renderer.d.ts.map +1 -1
  41. package/dist/canvas/renderer.js +9 -9
  42. package/dist/canvas/renderer.js.map +1 -1
  43. package/dist/canvas/text/preparation/cache.d.ts +5 -0
  44. package/dist/canvas/text/preparation/cache.d.ts.map +1 -1
  45. package/dist/canvas/text/preparation/cache.js +8 -1
  46. package/dist/canvas/text/preparation/cache.js.map +1 -1
  47. package/dist/constants.d.ts +13 -18
  48. package/dist/constants.d.ts.map +1 -1
  49. package/dist/constants.js +16 -21
  50. package/dist/constants.js.map +1 -1
  51. package/dist/design-jsx/index.d.ts +2 -2
  52. package/dist/design-jsx/index.js +2 -2
  53. package/dist/design-jsx/preview/picture.d.ts +12 -5
  54. package/dist/design-jsx/preview/picture.d.ts.map +1 -1
  55. package/dist/design-jsx/preview/picture.js +40 -15
  56. package/dist/design-jsx/preview/picture.js.map +1 -1
  57. package/dist/editor/bridges/undo.d.ts +1 -1
  58. package/dist/editor/create.d.ts +3 -6
  59. package/dist/editor/create.d.ts.map +1 -1
  60. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  61. package/dist/editor/history/atomic-tool.js +11 -8
  62. package/dist/editor/history/atomic-tool.js.map +1 -1
  63. package/dist/editor/history/document-change.d.ts +9 -1
  64. package/dist/editor/history/document-change.d.ts.map +1 -1
  65. package/dist/editor/history/document-change.js +100 -2
  66. package/dist/editor/history/document-change.js.map +1 -1
  67. package/dist/editor/history/snapshot/graph.d.ts +15 -3
  68. package/dist/editor/history/snapshot/graph.d.ts.map +1 -1
  69. package/dist/editor/history/snapshot/graph.js +29 -8
  70. package/dist/editor/history/snapshot/graph.js.map +1 -1
  71. package/dist/editor/index.d.ts +3 -3
  72. package/dist/editor/index.js +3 -3
  73. package/dist/editor/issues.d.ts +1 -4
  74. package/dist/editor/issues.d.ts.map +1 -1
  75. package/dist/editor/issues.js +5 -44
  76. package/dist/editor/issues.js.map +1 -1
  77. package/dist/editor/nudge.js +3 -2
  78. package/dist/editor/nudge.js.map +1 -1
  79. package/dist/editor/read-only/actions.js +0 -3
  80. package/dist/editor/read-only/actions.js.map +1 -1
  81. package/dist/editor/state/shared.js +1 -1
  82. package/dist/editor/state/shared.js.map +1 -1
  83. package/dist/editor/types.d.ts +7 -4
  84. package/dist/editor/types.d.ts.map +1 -1
  85. package/dist/index.d.ts +3 -3
  86. package/dist/index.js +3 -3
  87. package/dist/io/subgraph.d.ts +5 -2
  88. package/dist/io/subgraph.d.ts.map +1 -1
  89. package/dist/io/subgraph.js +6 -2
  90. package/dist/io/subgraph.js.map +1 -1
  91. package/dist/layout/mutations.d.ts +1 -1
  92. package/dist/layout/mutations.d.ts.map +1 -1
  93. package/dist/layout/mutations.js +1 -1
  94. package/dist/layout/mutations.js.map +1 -1
  95. package/dist/text/font/faces.js +1 -1
  96. package/dist/text/font/faces.js.map +1 -1
  97. package/dist/text/web-font/providers.d.ts +2 -11
  98. package/dist/text/web-font/providers.d.ts.map +1 -1
  99. package/dist/text/web-font/providers.js +8 -7
  100. package/dist/text/web-font/providers.js.map +1 -1
  101. package/dist/tools/analyze/diff/jsx.d.ts +2 -1
  102. package/dist/tools/analyze/diff/jsx.d.ts.map +1 -1
  103. package/dist/tools/analyze/diff/jsx.js +4 -2
  104. package/dist/tools/analyze/diff/jsx.js.map +1 -1
  105. package/package.json +24 -9
  106. package/src/ai/providers.ts +15 -1
  107. package/src/canvas/highlight-rect.ts +30 -9
  108. package/src/canvas/index.ts +1 -15
  109. package/src/canvas/issues/draw.ts +2 -165
  110. package/src/canvas/issues/types.ts +1 -36
  111. package/src/canvas/overlays/ai/draw.ts +129 -0
  112. package/src/canvas/overlays/ai/motion.ts +46 -0
  113. package/src/canvas/renderer/methods.ts +1 -1
  114. package/src/canvas/renderer/overlay-pass.ts +2 -49
  115. package/src/canvas/renderer/pipeline.ts +1 -1
  116. package/src/canvas/renderer/state.ts +20 -5
  117. package/src/canvas/renderer/types.ts +2 -2
  118. package/src/canvas/renderer.ts +9 -10
  119. package/src/canvas/text/preparation/cache.ts +9 -1
  120. package/src/constants.ts +12 -17
  121. package/src/design-jsx/index.ts +1 -1
  122. package/src/design-jsx/preview/picture.ts +55 -18
  123. package/src/editor/history/atomic-tool.ts +15 -8
  124. package/src/editor/history/document-change.ts +117 -1
  125. package/src/editor/history/snapshot/graph.ts +48 -8
  126. package/src/editor/index.ts +10 -2
  127. package/src/editor/issues.ts +6 -36
  128. package/src/editor/nudge.ts +4 -2
  129. package/src/editor/read-only/actions.ts +0 -3
  130. package/src/editor/state/shared.ts +1 -1
  131. package/src/editor/types.ts +6 -4
  132. package/src/io/subgraph.ts +10 -5
  133. package/src/layout/mutations.ts +2 -2
  134. package/src/text/font/faces.ts +1 -1
  135. package/src/text/web-font/providers.ts +19 -13
  136. package/src/tools/analyze/diff/jsx.ts +10 -5
  137. package/dist/canvas/issues/layout.d.ts +0 -37
  138. package/dist/canvas/issues/layout.d.ts.map +0 -1
  139. package/dist/canvas/issues/layout.js +0 -303
  140. package/dist/canvas/issues/layout.js.map +0 -1
  141. package/dist/canvas/overlays/ai.d.ts.map +0 -1
  142. package/dist/canvas/overlays/ai.js +0 -26
  143. package/dist/canvas/overlays/ai.js.map +0 -1
  144. package/src/canvas/issues/layout.ts +0 -376
  145. package/src/canvas/overlays/ai.ts +0 -34
package/dist/constants.js CHANGED
@@ -238,35 +238,30 @@ const ISSUE_INFO_COLOR = {
238
238
  b: .55,
239
239
  a: 1
240
240
  };
241
- const ISSUE_MARKER_HEIGHT = 16;
242
- const ISSUE_MARKER_PADDING_X = 5;
243
- /** Gap between a layer's corner and its marker; clears the 8px selection handle. */
244
- const ISSUE_MARKER_OFFSET = 4;
245
- /** Markers closer than this merge into one. */
246
- const ISSUE_MARKER_GAP = 2;
247
- const ISSUE_MARKER_VIEWPORT_INSET = 4;
248
- /** Layers smaller than this on screen pass their marker to an ancestor. */
249
- const ISSUE_MARKER_MIN_TARGET = 24;
250
- const ISSUE_MARKER_MAX_COUNT = 99;
251
- /** Edge pins closer than this along the viewport edge merge into one. */
252
- const ISSUE_EDGE_MERGE_GAP = 24;
253
- /** Length of the chevron an edge pin points with, beyond its ring. */
254
- const ISSUE_EDGE_ARROW = 5;
255
- const ISSUE_MARKER_RING_WIDTH = 1.5;
256
241
  const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5;
257
242
  const ISSUE_HIGHLIGHT_FILL_ALPHA = .08;
258
- const AI_ACTIVE_COLOR = {
259
- r: .26,
260
- g: .52,
261
- b: .96
243
+ /** The violet AI agents show in everywhere, the app's `--color-agent`. */
244
+ const AI_AGENT_COLOR = {
245
+ r: .486,
246
+ g: .361,
247
+ b: 1
262
248
  };
263
249
  const AI_DONE_COLOR = {
264
250
  r: .16,
265
251
  g: .73,
266
252
  b: .36
267
253
  };
268
- const AI_PULSE_PERIOD_MS = 1500;
269
254
  const AI_DONE_DURATION_MS = 800;
255
+ /** How long a layer an agent adds takes to trace in, once its turn comes. */
256
+ const AI_ENTER_DURATION_MS = 480;
257
+ /** The pause between the layers of one edit, so they appear one after another. */
258
+ const AI_ENTER_STAGGER_MS = 45;
259
+ /** The last layer of an edit starts within this, however many layers the edit adds. */
260
+ const AI_ENTER_MAX_DELAY_MS = 900;
261
+ /** One sweep of the light over an area an agent is working in. */
262
+ const AI_SHIMMER_PERIOD_MS = 1600;
263
+ /** Width of the sweeping light, in screen pixels. */
264
+ const AI_SHIMMER_BAND = 120;
270
265
  /** Opacity of the selection color behind selected text while editing. */
271
266
  const TEXT_SELECTION_ALPHA = .3;
272
267
  /** The caret's colour where the text's fill gives it none, as Figma's. */
@@ -417,6 +412,6 @@ const DEFAULT_TEXT_HEIGHT = 24;
417
412
  /** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
418
413
  const DUPLICATE_FRAME_GAP = 40;
419
414
  //#endregion
420
- export { ACP_AGENTS, AI_ACTIVE_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_PROVIDERS, AI_PULSE_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, ISSUE_EDGE_ARROW, ISSUE_EDGE_MERGE_GAP, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_MARKER_GAP, ISSUE_MARKER_HEIGHT, ISSUE_MARKER_MAX_COUNT, ISSUE_MARKER_MIN_TARGET, ISSUE_MARKER_OFFSET, ISSUE_MARKER_PADDING_X, ISSUE_MARKER_RING_WIDTH, ISSUE_MARKER_VIEWPORT_INSET, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PARENT_OUTLINE_DASH, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
415
+ export { ACP_AGENTS, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PARENT_OUTLINE_DASH, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
421
416
 
422
417
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const PARENT_OUTLINE_DASH = 4\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_MARKER_HEIGHT = 16\nexport const ISSUE_MARKER_PADDING_X = 5\n/** Gap between a layer's corner and its marker; clears the 8px selection handle. */\nexport const ISSUE_MARKER_OFFSET = 4\n/** Markers closer than this merge into one. */\nexport const ISSUE_MARKER_GAP = 2\nexport const ISSUE_MARKER_VIEWPORT_INSET = 4\n/** Layers smaller than this on screen pass their marker to an ancestor. */\nexport const ISSUE_MARKER_MIN_TARGET = 24\nexport const ISSUE_MARKER_MAX_COUNT = 99\n/** Edge pins closer than this along the viewport edge merge into one. */\nexport const ISSUE_EDGE_MERGE_GAP = 24\n/** Length of the chevron an edge pin points with, beyond its ring. */\nexport const ISSUE_EDGE_ARROW = 5\nexport const ISSUE_MARKER_RING_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\nexport const AI_ACTIVE_COLOR = { r: 0.26, g: 0.52, b: 0.96 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_PULSE_PERIOD_MS = 1500\nexport const AI_DONE_DURATION_MS = 800\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAAa,OAAO,WAAW;AAC5C,MAAa,WAAW,cAAc,yBAAyB;AAE/D,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,uBAA8B;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAK;AACvE,MAAa,kBAAkB;CAAE,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;AAAE;;AAEjE,MAAa,0BAAoD;CAC/D,OAAO;CACP,YAAY;AACd;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,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;;;;AAKnC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const PARENT_OUTLINE_DASH = 4\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\n/** The violet AI agents show in everywhere, the app's `--color-agent`. */\nexport const AI_AGENT_COLOR = { r: 0.486, g: 0.361, b: 1 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_DONE_DURATION_MS = 800\n/** How long a layer an agent adds takes to trace in, once its turn comes. */\nexport const AI_ENTER_DURATION_MS = 480\n/** The pause between the layers of one edit, so they appear one after another. */\nexport const AI_ENTER_STAGGER_MS = 45\n/** The last layer of an edit starts within this, however many layers the edit adds. */\nexport const AI_ENTER_MAX_DELAY_MS = 900\n/** One sweep of the light over an area an agent is working in. */\nexport const AI_SHIMMER_PERIOD_MS = 1600\n/** Width of the sweeping light, in screen pixels. */\nexport const AI_SHIMMER_BAND = 120\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAA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AG,KAAO;GAAK,GAAG,KAAO;GAAK,GAAG;EAAE;EAC3D,SAAS;EACT,SAAS;CACX;AACF;AAEA,MAAa,yBAAiC;CAC5C,MAAM;CACN,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAa,wBAAwB;AAErC,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;;;;AAKnC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
@@ -1,5 +1,5 @@
1
1
  import { designJSXRenderer, renderJSX, renderTree } from "./renderer.js";
2
2
  import { RenderPlacement, RenderPlacementInput, finishRenderPlacement, resolveRenderPlacement } from "./placement.js";
3
3
  import { StagedJSXPreview, stageJSXPreview } from "./preview/stage.js";
4
- import { recordJSXPreview } from "./preview/picture.js";
5
- export { type RenderPlacement, type RenderPlacementInput, type StagedJSXPreview, designJSXRenderer, finishRenderPlacement, recordJSXPreview, renderJSX, renderTree, resolveRenderPlacement, stageJSXPreview };
4
+ import { JSXPreviewRecorder, createJSXPreviewRecorder } from "./preview/picture.js";
5
+ export { type JSXPreviewRecorder, type RenderPlacement, type RenderPlacementInput, type StagedJSXPreview, createJSXPreviewRecorder, designJSXRenderer, finishRenderPlacement, renderJSX, renderTree, resolveRenderPlacement, stageJSXPreview };
@@ -1,5 +1,5 @@
1
1
  import { designJSXRenderer, renderJSX, renderTree } from "./renderer.js";
2
2
  import { finishRenderPlacement, resolveRenderPlacement } from "./placement.js";
3
- import { recordJSXPreview } from "./preview/picture.js";
3
+ import { createJSXPreviewRecorder } from "./preview/picture.js";
4
4
  import { stageJSXPreview } from "./preview/stage.js";
5
- export { designJSXRenderer, finishRenderPlacement, recordJSXPreview, renderJSX, renderTree, resolveRenderPlacement, stageJSXPreview };
5
+ export { createJSXPreviewRecorder, designJSXRenderer, finishRenderPlacement, renderJSX, renderTree, resolveRenderPlacement, stageJSXPreview };
@@ -1,12 +1,19 @@
1
1
  import { StagedJSXPreview } from "./stage.js";
2
2
  import { CanvasKit, SkPicture } from "canvaskit-wasm";
3
3
  //#region src/design-jsx/preview/picture.d.ts
4
+ interface JSXPreviewRecorder {
5
+ /** Record `staged` as a picture the caller owns, even when its request becomes stale. */
6
+ record(staged: StagedJSXPreview, signal: AbortSignal): Promise<SkPicture | null>;
7
+ /** Free the private renderer once the records already asked for finish. */
8
+ destroy(): void;
9
+ }
4
10
  /**
5
- * Record a disposable vector picture using a private graph and renderer.
6
- * Neither speculative nodes nor renderer caches enter the live document.
7
- * The caller owns the returned picture, even when its request becomes stale.
11
+ * A private renderer that records preview pictures one at a time, for previews of JSX that is
12
+ * still streaming. Each record draws a new graph, so only what identical text shaped to carries
13
+ * over: a preview that grows measures just its new text instead of all of it again. Neither
14
+ * speculative nodes nor renderer caches enter the live document.
8
15
  */
9
- declare function recordJSXPreview(ck: CanvasKit, staged: StagedJSXPreview, signal: AbortSignal): Promise<SkPicture | null>;
16
+ declare function createJSXPreviewRecorder(ck: CanvasKit): JSXPreviewRecorder;
10
17
  //#endregion
11
- export { recordJSXPreview };
18
+ export { JSXPreviewRecorder, createJSXPreviewRecorder };
12
19
  //# sourceMappingURL=picture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"picture.d.ts","names":[],"sources":["../../../src/design-jsx/preview/picture.ts"],"mappings":";;;;;;;;iBAiDsB,iBACpB,IAAI,WACJ,QAAQ,kBACR,QAAQ,cACP,QAAQ"}
1
+ {"version":3,"file":"picture.d.ts","names":[],"sources":["../../../src/design-jsx/preview/picture.ts"],"mappings":";;;UA0CiB;;EAEf,OAAO,QAAQ,kBAAkB,QAAQ,cAAc,QAAQ;;EAE/D;;;;;;;;iBASc,yBAAyB,IAAI,YAAY"}
@@ -10,8 +10,6 @@ function fitsPreview({ minX, minY, maxX, maxY }) {
10
10
  }
11
11
  async function recordStaged(renderer, { graph, pageId, nodeIds }, signal) {
12
12
  renderer.pageId = pageId;
13
- await renderer.loadFonts();
14
- signal.throwIfAborted();
15
13
  await renderer.prepareForExport(graph, pageId, nodeIds);
16
14
  signal.throwIfAborted();
17
15
  const bounds = computeDescendantVisualBounds(nodeIds, (id) => graph.getNode(id), (id) => graph.getAbsolutePosition(id));
@@ -21,22 +19,49 @@ async function recordStaged(renderer, { graph, pageId, nodeIds }, signal) {
21
19
  });
22
20
  }
23
21
  /**
24
- * Record a disposable vector picture using a private graph and renderer.
25
- * Neither speculative nodes nor renderer caches enter the live document.
26
- * The caller owns the returned picture, even when its request becomes stale.
22
+ * A private renderer that records preview pictures one at a time, for previews of JSX that is
23
+ * still streaming. Each record draws a new graph, so only what identical text shaped to carries
24
+ * over: a preview that grows measures just its new text instead of all of it again. Neither
25
+ * speculative nodes nor renderer caches enter the live document.
27
26
  */
28
- async function recordJSXPreview(ck, staged, signal) {
29
- signal.throwIfAborted();
30
- const surface = ck.MakeSurface(1, 1);
31
- if (!surface) return null;
32
- const renderer = new SkiaRenderer(ck, surface);
33
- try {
34
- return await recordStaged(renderer, staged, signal);
35
- } finally {
36
- renderer.destroy();
27
+ function createJSXPreviewRecorder(ck) {
28
+ let renderer = null;
29
+ let destroyed = false;
30
+ let queue = Promise.resolve();
31
+ async function rendererFor() {
32
+ if (renderer) return renderer;
33
+ const surface = ck.MakeSurface(1, 1);
34
+ if (!surface) return null;
35
+ const created = new SkiaRenderer(ck, surface);
36
+ renderer = created;
37
+ await created.loadFonts();
38
+ return created;
39
+ }
40
+ async function recordNext(staged, signal) {
41
+ signal.throwIfAborted();
42
+ const current = destroyed ? null : await rendererFor();
43
+ if (!current) return null;
44
+ signal.throwIfAborted();
45
+ current.invalidateAllPictures({ keepShapedText: true });
46
+ return recordStaged(current, staged, signal);
37
47
  }
48
+ return {
49
+ record(staged, signal) {
50
+ const result = queue.then(() => recordNext(staged, signal));
51
+ queue = result.catch(() => void 0);
52
+ return result;
53
+ },
54
+ destroy() {
55
+ destroyed = true;
56
+ const release = () => {
57
+ renderer?.destroy();
58
+ renderer = null;
59
+ };
60
+ queue = queue.then(release);
61
+ }
62
+ };
38
63
  }
39
64
  //#endregion
40
- export { recordJSXPreview };
65
+ export { createJSXPreviewRecorder };
41
66
 
42
67
  //# sourceMappingURL=picture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"picture.js","names":[],"sources":["../../../src/design-jsx/preview/picture.ts"],"sourcesContent":["import type { CanvasKit, SkPicture } from 'canvaskit-wasm'\n\nimport { computeDescendantVisualBounds, type VisualBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { SkiaRenderer } from '#core/canvas/renderer'\nimport { recordWorldPicture } from '#core/canvas/renderer/picture'\n\nimport type { StagedJSXPreview } from './stage'\n\nconst MAX_PREVIEW_DIMENSION = 8192\n\nfunction fitsPreview({ minX, minY, maxX, maxY }: VisualBounds): boolean {\n const width = maxX - minX\n const height = maxY - minY\n return (\n Number.isFinite(width + height) &&\n width > 0 &&\n height > 0 &&\n width <= MAX_PREVIEW_DIMENSION &&\n height <= MAX_PREVIEW_DIMENSION\n )\n}\n\nasync function recordStaged(\n renderer: SkiaRenderer,\n { graph, pageId, nodeIds }: StagedJSXPreview,\n signal: AbortSignal\n): Promise<SkPicture | null> {\n renderer.pageId = pageId\n await renderer.loadFonts()\n signal.throwIfAborted()\n await renderer.prepareForExport(graph, pageId, nodeIds)\n signal.throwIfAborted()\n const bounds = computeDescendantVisualBounds(\n nodeIds,\n (id) => graph.getNode(id),\n (id) => graph.getAbsolutePosition(id)\n )\n if (!bounds || !fitsPreview(bounds)) return null\n return recordWorldPicture(renderer, bounds, (canvas) => {\n for (const id of nodeIds) renderer.renderNode(canvas, graph, id, {})\n })\n}\n\n/**\n * Record a disposable vector picture using a private graph and renderer.\n * Neither speculative nodes nor renderer caches enter the live document.\n * The caller owns the returned picture, even when its request becomes stale.\n */\nexport async function recordJSXPreview(\n ck: CanvasKit,\n staged: StagedJSXPreview,\n signal: AbortSignal\n): Promise<SkPicture | null> {\n signal.throwIfAborted()\n const surface = ck.MakeSurface(1, 1)\n if (!surface) return null\n const renderer = new SkiaRenderer(ck, surface)\n try {\n return await recordStaged(renderer, staged, signal)\n } finally {\n renderer.destroy()\n }\n}\n"],"mappings":";;;;AASA,MAAM,wBAAwB;AAE9B,SAAS,YAAY,EAAE,MAAM,MAAM,MAAM,QAA+B;CACtE,MAAM,QAAQ,OAAO;CACrB,MAAM,SAAS,OAAO;CACtB,OACE,OAAO,SAAS,QAAQ,MAAM,KAC9B,QAAQ,KACR,SAAS,KACT,SAAS,yBACT,UAAU;AAEd;AAEA,eAAe,aACb,UACA,EAAE,OAAO,QAAQ,WACjB,QAC2B;CAC3B,SAAS,SAAS;CAClB,MAAM,SAAS,UAAU;CACzB,OAAO,eAAe;CACtB,MAAM,SAAS,iBAAiB,OAAO,QAAQ,OAAO;CACtD,OAAO,eAAe;CACtB,MAAM,SAAS,8BACb,UACC,OAAO,MAAM,QAAQ,EAAE,IACvB,OAAO,MAAM,oBAAoB,EAAE,CACtC;CACA,IAAI,CAAC,UAAU,CAAC,YAAY,MAAM,GAAG,OAAO;CAC5C,OAAO,mBAAmB,UAAU,SAAS,WAAW;EACtD,KAAK,MAAM,MAAM,SAAS,SAAS,WAAW,QAAQ,OAAO,IAAI,CAAC,CAAC;CACrE,CAAC;AACH;;;;;;AAOA,eAAsB,iBACpB,IACA,QACA,QAC2B;CAC3B,OAAO,eAAe;CACtB,MAAM,UAAU,GAAG,YAAY,GAAG,CAAC;CACnC,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,WAAW,IAAI,aAAa,IAAI,OAAO;CAC7C,IAAI;EACF,OAAO,MAAM,aAAa,UAAU,QAAQ,MAAM;CACpD,UAAU;EACR,SAAS,QAAQ;CACnB;AACF"}
1
+ {"version":3,"file":"picture.js","names":[],"sources":["../../../src/design-jsx/preview/picture.ts"],"sourcesContent":["import type { CanvasKit, SkPicture } from 'canvaskit-wasm'\n\nimport { computeDescendantVisualBounds, type VisualBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { SkiaRenderer } from '#core/canvas/renderer'\nimport { recordWorldPicture } from '#core/canvas/renderer/picture'\n\nimport type { StagedJSXPreview } from './stage'\n\nconst MAX_PREVIEW_DIMENSION = 8192\n\nfunction fitsPreview({ minX, minY, maxX, maxY }: VisualBounds): boolean {\n const width = maxX - minX\n const height = maxY - minY\n return (\n Number.isFinite(width + height) &&\n width > 0 &&\n height > 0 &&\n width <= MAX_PREVIEW_DIMENSION &&\n height <= MAX_PREVIEW_DIMENSION\n )\n}\n\nasync function recordStaged(\n renderer: SkiaRenderer,\n { graph, pageId, nodeIds }: StagedJSXPreview,\n signal: AbortSignal\n): Promise<SkPicture | null> {\n renderer.pageId = pageId\n await renderer.prepareForExport(graph, pageId, nodeIds)\n signal.throwIfAborted()\n const bounds = computeDescendantVisualBounds(\n nodeIds,\n (id) => graph.getNode(id),\n (id) => graph.getAbsolutePosition(id)\n )\n if (!bounds || !fitsPreview(bounds)) return null\n return recordWorldPicture(renderer, bounds, (canvas) => {\n for (const id of nodeIds) renderer.renderNode(canvas, graph, id, {})\n })\n}\n\nexport interface JSXPreviewRecorder {\n /** Record `staged` as a picture the caller owns, even when its request becomes stale. */\n record(staged: StagedJSXPreview, signal: AbortSignal): Promise<SkPicture | null>\n /** Free the private renderer once the records already asked for finish. */\n destroy(): void\n}\n\n/**\n * A private renderer that records preview pictures one at a time, for previews of JSX that is\n * still streaming. Each record draws a new graph, so only what identical text shaped to carries\n * over: a preview that grows measures just its new text instead of all of it again. Neither\n * speculative nodes nor renderer caches enter the live document.\n */\nexport function createJSXPreviewRecorder(ck: CanvasKit): JSXPreviewRecorder {\n let renderer: SkiaRenderer | null = null\n let destroyed = false\n // Records share one renderer, whose caches and page one record at a time may use.\n let queue: Promise<unknown> = Promise.resolve()\n\n async function rendererFor(): Promise<SkiaRenderer | null> {\n if (renderer) return renderer\n const surface = ck.MakeSurface(1, 1)\n if (!surface) return null\n const created = new SkiaRenderer(ck, surface)\n renderer = created\n // Loading fonts drops every cache, so it happens once rather than before each record.\n await created.loadFonts()\n return created\n }\n\n async function recordNext(\n staged: StagedJSXPreview,\n signal: AbortSignal\n ): Promise<SkPicture | null> {\n signal.throwIfAborted()\n const current = destroyed ? null : await rendererFor()\n if (!current) return null\n signal.throwIfAborted()\n // Layer IDs repeat between staged graphs with different content, so nothing keyed by them stays.\n current.invalidateAllPictures({ keepShapedText: true })\n return recordStaged(current, staged, signal)\n }\n\n return {\n record(staged, signal) {\n const result = queue.then(() => recordNext(staged, signal))\n queue = result.catch(() => undefined)\n return result\n },\n destroy() {\n destroyed = true\n const release = () => {\n renderer?.destroy()\n renderer = null\n }\n queue = queue.then(release)\n }\n }\n}\n"],"mappings":";;;;AASA,MAAM,wBAAwB;AAE9B,SAAS,YAAY,EAAE,MAAM,MAAM,MAAM,QAA+B;CACtE,MAAM,QAAQ,OAAO;CACrB,MAAM,SAAS,OAAO;CACtB,OACE,OAAO,SAAS,QAAQ,MAAM,KAC9B,QAAQ,KACR,SAAS,KACT,SAAS,yBACT,UAAU;AAEd;AAEA,eAAe,aACb,UACA,EAAE,OAAO,QAAQ,WACjB,QAC2B;CAC3B,SAAS,SAAS;CAClB,MAAM,SAAS,iBAAiB,OAAO,QAAQ,OAAO;CACtD,OAAO,eAAe;CACtB,MAAM,SAAS,8BACb,UACC,OAAO,MAAM,QAAQ,EAAE,IACvB,OAAO,MAAM,oBAAoB,EAAE,CACtC;CACA,IAAI,CAAC,UAAU,CAAC,YAAY,MAAM,GAAG,OAAO;CAC5C,OAAO,mBAAmB,UAAU,SAAS,WAAW;EACtD,KAAK,MAAM,MAAM,SAAS,SAAS,WAAW,QAAQ,OAAO,IAAI,CAAC,CAAC;CACrE,CAAC;AACH;;;;;;;AAeA,SAAgB,yBAAyB,IAAmC;CAC1E,IAAI,WAAgC;CACpC,IAAI,YAAY;CAEhB,IAAI,QAA0B,QAAQ,QAAQ;CAE9C,eAAe,cAA4C;EACzD,IAAI,UAAU,OAAO;EACrB,MAAM,UAAU,GAAG,YAAY,GAAG,CAAC;EACnC,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,UAAU,IAAI,aAAa,IAAI,OAAO;EAC5C,WAAW;EAEX,MAAM,QAAQ,UAAU;EACxB,OAAO;CACT;CAEA,eAAe,WACb,QACA,QAC2B;EAC3B,OAAO,eAAe;EACtB,MAAM,UAAU,YAAY,OAAO,MAAM,YAAY;EACrD,IAAI,CAAC,SAAS,OAAO;EACrB,OAAO,eAAe;EAEtB,QAAQ,sBAAsB,EAAE,gBAAgB,KAAK,CAAC;EACtD,OAAO,aAAa,SAAS,QAAQ,MAAM;CAC7C;CAEA,OAAO;EACL,OAAO,QAAQ,QAAQ;GACrB,MAAM,SAAS,MAAM,WAAW,WAAW,QAAQ,MAAM,CAAC;GAC1D,QAAQ,OAAO,YAAY,KAAA,CAAS;GACpC,OAAO;EACT;EACA,UAAU;GACR,YAAY;GACZ,MAAM,gBAAgB;IACpB,UAAU,QAAQ;IAClB,WAAW;GACb;GACA,QAAQ,MAAM,KAAK,OAAO;EAC5B;CACF;AACF"}
@@ -15,7 +15,7 @@ declare function createUndoBridge(undoActions: UndoActions, selection: Selection
15
15
  commitMove: (originals: Map<string, import("@pairdraw/scene-graph/primitives").Vector>) => void;
16
16
  commitMoveWithReparent: (originals: Map<string, MovePlace>) => void;
17
17
  commitDuplicateMove: (rootIds: string[], previousSelection: Set<string>) => void;
18
- commitResize: (nodeId: string, original: import("@pairdraw/scene-graph/primitives").Rect & Partial<Pick<import("@pairdraw/scene-graph").SceneNode, "vectorNetwork" | "fillGeometry" | "strokeGeometry" | "derivedTextGlyphs" | "strokes" | "textPathData" | "textPathBox">>) => void;
18
+ commitResize: (nodeId: string, original: import("@pairdraw/scene-graph/primitives").Rect & Partial<Pick<import("@pairdraw/scene-graph").SceneNode, "strokes" | "vectorNetwork" | "fillGeometry" | "strokeGeometry" | "derivedTextGlyphs" | "textPathData" | "textPathBox">>) => void;
19
19
  commitGroupResize: (nodeId: string, origRect: import("@pairdraw/scene-graph/primitives").Rect, origChildren: Map<string, import("@pairdraw/scene-graph/resize").ResizeSnapshot>) => void;
20
20
  commitRotation: (nodeId: string, origRotation: number) => void;
21
21
  commitNodeUpdate: (nodeId: string, previous: Partial<import("@pairdraw/scene-graph").SceneNode>, label?: string) => void;
@@ -1,5 +1,5 @@
1
1
  import { GuidePreview, GuideRedline, GuideSelection } from "../canvas/guides/types.js";
2
- import { DesignIssueHighlight, DesignIssueMarker } from "../canvas/issues/types.js";
2
+ import { DesignIssueHighlight } from "../canvas/issues/types.js";
3
3
  import { AttachModifiers, ConnectorTarget } from "./connectors/attach.js";
4
4
  import { RotationPreview } from "../geometry/types.js";
5
5
  import { LineEnd } from "../geometry/line-ends.js";
@@ -183,7 +183,7 @@ declare function createEditor(options?: EditorOptions): {
183
183
  commitMove: (originals: Map<string, import("@pairdraw/scene-graph/primitives").Vector>) => void;
184
184
  commitMoveWithReparent: (originals: Map<string, MovePlace>) => void;
185
185
  commitDuplicateMove: (rootIds: string[], previousSelection: Set<string>) => void;
186
- commitResize: (nodeId: string, original: import("@pairdraw/scene-graph/primitives").Rect & Partial<Pick<SceneNode, "vectorNetwork" | "fillGeometry" | "strokeGeometry" | "derivedTextGlyphs" | "strokes" | "textPathData" | "textPathBox">>) => void;
186
+ commitResize: (nodeId: string, original: import("@pairdraw/scene-graph/primitives").Rect & Partial<Pick<SceneNode, "strokes" | "vectorNetwork" | "fillGeometry" | "strokeGeometry" | "derivedTextGlyphs" | "textPathData" | "textPathBox">>) => void;
187
187
  commitGroupResize: (nodeId: string, origRect: import("@pairdraw/scene-graph/primitives").Rect, origChildren: Map<string, import("@pairdraw/scene-graph/resize").ResizeSnapshot>) => void;
188
188
  commitRotation: (nodeId: string, origRotation: number) => void;
189
189
  snapshotPage: (pageId?: string) => PageSnapshot;
@@ -399,10 +399,7 @@ declare function createEditor(options?: EditorOptions): {
399
399
  penCommit: (closed: boolean) => void;
400
400
  penCancel: () => void;
401
401
  createShape: (type: import("@pairdraw/scene-graph").NodeType, x: number, y: number, w: number, h: number, parentId?: string, name?: string) => string;
402
- setDesignIssueMarkers: (markers: readonly DesignIssueMarker[]) => void;
403
402
  setDesignIssueHighlight: (highlight: DesignIssueHighlight | null) => void;
404
- setHoveredIssueMarker: (key: string | null) => void;
405
- clearDesignIssues: () => void;
406
403
  addGuide: (ownerId: string, axis: import("@pairdraw/scene-graph/guides").CanvasGuide["axis"], position: number) => string | null;
407
404
  moveGuide: (ownerId: string, guideId: string, position: number) => boolean;
408
405
  removeGuide: (ownerId: string, guideId: string) => boolean;
@@ -836,7 +833,7 @@ declare function createEditor(options?: EditorOptions): {
836
833
  undo: UndoManager;
837
834
  state: EditorState;
838
835
  runLayoutForNode: (id: string) => void;
839
- runMutationWithLayout: <T>(operation: () => T | Promise<T>, fallbackId?: string, beforeLayout?: (result: T) => Promise<void> | void) => Promise<T>;
836
+ runMutationWithLayout: <T>(operation: () => T | Promise<T>, fallbackId?: string, beforeLayout?: (result: T, impact: import("@pairdraw/scene-graph/mutation-impact").SceneMutationImpact) => Promise<void> | void) => Promise<T>;
840
837
  };
841
838
  /**
842
839
  * The editor `createEditor` returns. An interface rather than an alias, so declarations that
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","names":[],"sources":["../../src/editor/create.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoFgB,aAAa,UAAU;;IAvCvB;;sCAuCuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwcZ,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UAAY;EA9LZ,qBAAA,OAAA,oCAAkC;EAiN7B,uBAAA,UAAA;EAQR,eAAA,UAAA;;;;;;;;;;;;;;;;;;;;;;UA8LjB,eAAe,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-tool.d.ts","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"mappings":";;;;;;KAcK,iBAAiB,KACpB;EAGA,OAAO;;;;;;;iBAuBO,kBACd,QAAQ,gBACR,OAAO,UACP,KAAK,SACL,MAAM,yBACN;EAAW,SAAS;EAAa;EAAwB"}
1
+ {"version":3,"file":"atomic-tool.d.ts","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"mappings":";;;;;;KAcK,iBAAiB,KACpB;EAGA,OAAO;;;;;;;iBAyBO,kBACd,QAAQ,gBACR,OAAO,UACP,KAAK,SACL,MAAM,yBACN;EAAW,SAAS;EAAa;EAAwB"}
@@ -2,10 +2,10 @@ import { resolveEditorProfile } from "../views/profile.js";
2
2
  import { ReadOnlyDocumentError } from "../read-only/index.js";
3
3
  import { diffFields } from "./diff.js";
4
4
  import { isAtomicTool } from "../../tools/schema.js";
5
- import { captureGraphCheckpoint } from "@pairdraw/scene-graph/checkpoint";
5
+ import { captureEditCheckpoint } from "@pairdraw/scene-graph/checkpoint";
6
6
  //#region src/editor/history/atomic-tool.ts
7
7
  const MAX_TRANSACTION_NODES = 1e4;
8
- function changes(before, after) {
8
+ function changes(before, after, expectedSize = before.size) {
9
9
  const result = [];
10
10
  for (const [id, previous] of before) {
11
11
  const current = after.get(id);
@@ -13,7 +13,7 @@ function changes(before, after) {
13
13
  const change = diffFields(id, previous, current);
14
14
  if (change) result.push(change);
15
15
  }
16
- if (before.size !== after.size) throw new Error("Atomic tools must not create nodes or variables");
16
+ if (after.size !== expectedSize) throw new Error("Atomic tools must not create nodes or variables");
17
17
  return result;
18
18
  }
19
19
  /**
@@ -28,8 +28,9 @@ function executeAtomicTool(editor, figma, def, args, options = {}) {
28
28
  if (editor.graph !== figma.graph || options.isLive?.() === false) throw new Error("The target document is no longer open");
29
29
  const graph = figma.graph;
30
30
  if (graph.nodes.size + graph.variables.size > MAX_TRANSACTION_NODES) throw new Error("Document too large for atomic agent editing (maximum 10000 nodes)");
31
- const checkpoint = captureGraphCheckpoint(graph);
32
- const { nodes, variables } = checkpoint;
31
+ const checkpoint = captureEditCheckpoint(graph);
32
+ const { variables } = checkpoint;
33
+ const nodeCount = graph.nodes.size;
33
34
  const pageId = figma.currentPageId;
34
35
  const replay = (nodeChanges, variableChanges, direction) => {
35
36
  if (editor.graph !== graph) throw new Error("The target document has been replaced");
@@ -50,10 +51,10 @@ function executeAtomicTool(editor, figma, def, args, options = {}) {
50
51
  const result = def.execute(figma, args);
51
52
  if (result instanceof Promise) throw new Error("Atomic tools must execute synchronously");
52
53
  if (result && typeof result === "object" && "error" in result) throw new Error(String(result.error));
53
- checkpoint.assertPropertiesOnly();
54
+ const touched = checkpoint.assertPropertiesOnly();
54
55
  const variableChanges = changes(variables, graph.variables);
55
- layout(graph, editor, pageId, variableChanges.length > 0, changes(nodes, graph.nodes).map((change) => change.id));
56
- const nodeChanges = changes(nodes, graph.nodes);
56
+ layout(graph, editor, pageId, variableChanges.length > 0, changes(touched, graph.nodes, nodeCount).map((change) => change.id));
57
+ const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount);
57
58
  const contentChanged = variableChanges.length > 0 || nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== "source"));
58
59
  if (!contentChanged && nodeChanges.length) replay(nodeChanges, [], "before");
59
60
  if (contentChanged) {
@@ -69,6 +70,8 @@ function executeAtomicTool(editor, figma, def, args, options = {}) {
69
70
  checkpoint.restore();
70
71
  editor.requestRender();
71
72
  throw error;
73
+ } finally {
74
+ checkpoint.release();
72
75
  }
73
76
  }
74
77
  function layout(graph, editor, pageId, allPages, changedIds) {
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-tool.js","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport { captureGraphCheckpoint } from '@pairdraw/scene-graph/checkpoint'\n\nimport type { Editor } from '#core/editor/create'\nimport { ReadOnlyDocumentError } from '#core/editor/read-only'\nimport { resolveEditorProfile, type EditorProfileInputs } from '#core/editor/views'\nimport type { FigmaAPI } from '#core/figma-api'\nimport { isAtomicTool, type ToolDef } from '#core/tools/schema'\n\nimport { diffFields, type FieldChanges } from './diff'\n\n// Capture property changes across pages. Component synchronization remains editor-owned.\nconst MAX_TRANSACTION_NODES = 10_000\n\ntype MutationEditor = Pick<\n Editor,\n 'graph' | 'runLayoutForNode' | 'requestRender' | 'pushUndoStep'\n> & {\n state: EditorProfileInputs\n}\n\nfunction changes<T extends object>(\n before: Map<string, T>,\n after: Map<string, T>\n): FieldChanges<T>[] {\n const result: FieldChanges<T>[] = []\n for (const [id, previous] of before) {\n const current = after.get(id)\n if (!current) throw new Error('Atomic tools must not remove nodes or variables')\n const change = diffFields(id, previous, current)\n if (change) result.push(change)\n }\n if (before.size !== after.size) throw new Error('Atomic tools must not create nodes or variables')\n return result\n}\n\n/**\n * No await is permitted between snapshot and commit. Browser events, other agents and\n * cancellation cannot interleave with this bounded transaction. Async tools use their\n * existing execution path and are not exposed through WebMCP.\n */\nexport function executeAtomicTool(\n editor: MutationEditor,\n figma: FigmaAPI,\n def: ToolDef,\n args: Record<string, unknown>,\n options: { signal?: AbortSignal; isLive?: () => boolean; label?: string } = {}\n): unknown {\n if (!isAtomicTool(def)) throw new Error(`Not an atomic tool: ${def.name}`)\n if (!resolveEditorProfile(editor.state).edits) throw new ReadOnlyDocumentError()\n options.signal?.throwIfAborted()\n if (editor.graph !== figma.graph || options.isLive?.() === false) {\n throw new Error('The target document is no longer open')\n }\n const graph = figma.graph\n if (graph.nodes.size + graph.variables.size > MAX_TRANSACTION_NODES) {\n throw new Error('Document too large for atomic agent editing (maximum 10000 nodes)')\n }\n const checkpoint = captureGraphCheckpoint(graph)\n const { nodes, variables } = checkpoint\n const pageId = figma.currentPageId\n\n const replay = (\n nodeChanges: FieldChanges<SceneNode>[],\n variableChanges: FieldChanges<Variable>[],\n direction: 'before' | 'after'\n ) => {\n if (editor.graph !== graph) throw new Error('The target document has been replaced')\n for (const change of variableChanges) {\n const variable = graph.variables.get(change.id)\n if (variable) {\n Object.assign(variable, structuredClone(change[direction]))\n for (const key of change.absent[direction]) Reflect.deleteProperty(variable, key)\n }\n }\n graph.preserveSourceMetadataDuring(() => {\n for (const change of nodeChanges)\n graph.restoreNodeProperties(\n change.id,\n structuredClone(change[direction]),\n change.absent[direction]\n )\n })\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n nodeChanges.map((change) => change.id)\n )\n editor.requestRender()\n }\n\n try {\n const result = def.execute(figma, args)\n if (result instanceof Promise) throw new Error('Atomic tools must execute synchronously')\n if (result && typeof result === 'object' && 'error' in result) {\n throw new Error(String(result.error))\n }\n checkpoint.assertPropertiesOnly()\n const variableChanges = changes(variables, graph.variables)\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n changes(nodes, graph.nodes).map((change) => change.id)\n )\n const nodeChanges = changes(nodes, graph.nodes)\n const contentChanged =\n variableChanges.length > 0 ||\n nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== 'source'))\n if (!contentChanged && nodeChanges.length) replay(nodeChanges, [], 'before')\n if (contentChanged) {\n editor.pushUndoStep({\n label: `${options.label ?? 'Agent'}: ${def.name}`,\n inverse: () => replay(nodeChanges, variableChanges, 'before'),\n forward: () => replay(nodeChanges, variableChanges, 'after')\n })\n editor.requestRender()\n }\n return result\n } catch (error) {\n checkpoint.restore()\n editor.requestRender()\n throw error\n }\n}\n\nfunction layout(\n graph: SceneGraph,\n editor: MutationEditor,\n pageId: string,\n allPages: boolean,\n changedIds: string[]\n): void {\n const scopes = new Set(allPages ? graph.getPages().map((page) => page.id) : [pageId])\n for (const id of changedIds) {\n let node = graph.getNode(id)\n while (node && node.type !== 'CANVAS')\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n if (node) scopes.add(node.id)\n }\n for (const id of scopes) editor.runLayoutForNode(id)\n}\n"],"mappings":";;;;;;AAYA,MAAM,wBAAwB;AAS9B,SAAS,QACP,QACA,OACmB;CACnB,MAAM,SAA4B,CAAC;CACnC,KAAK,MAAM,CAAC,IAAI,aAAa,QAAQ;EACnC,MAAM,UAAU,MAAM,IAAI,EAAE;EAC5B,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,iDAAiD;EAC/E,MAAM,SAAS,WAAW,IAAI,UAAU,OAAO;EAC/C,IAAI,QAAQ,OAAO,KAAK,MAAM;CAChC;CACA,IAAI,OAAO,SAAS,MAAM,MAAM,MAAM,IAAI,MAAM,iDAAiD;CACjG,OAAO;AACT;;;;;;AAOA,SAAgB,kBACd,QACA,OACA,KACA,MACA,UAA4E,CAAC,GACpE;CACT,IAAI,CAAC,aAAa,GAAG,GAAG,MAAM,IAAI,MAAM,uBAAuB,IAAI,MAAM;CACzE,IAAI,CAAC,qBAAqB,OAAO,KAAK,CAAC,CAAC,OAAO,MAAM,IAAI,sBAAsB;CAC/E,QAAQ,QAAQ,eAAe;CAC/B,IAAI,OAAO,UAAU,MAAM,SAAS,QAAQ,SAAS,MAAM,OACzD,MAAM,IAAI,MAAM,uCAAuC;CAEzD,MAAM,QAAQ,MAAM;CACpB,IAAI,MAAM,MAAM,OAAO,MAAM,UAAU,OAAO,uBAC5C,MAAM,IAAI,MAAM,mEAAmE;CAErF,MAAM,aAAa,uBAAuB,KAAK;CAC/C,MAAM,EAAE,OAAO,cAAc;CAC7B,MAAM,SAAS,MAAM;CAErB,MAAM,UACJ,aACA,iBACA,cACG;EACH,IAAI,OAAO,UAAU,OAAO,MAAM,IAAI,MAAM,uCAAuC;EACnF,KAAK,MAAM,UAAU,iBAAiB;GACpC,MAAM,WAAW,MAAM,UAAU,IAAI,OAAO,EAAE;GAC9C,IAAI,UAAU;IACZ,OAAO,OAAO,UA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c;EACrB,MAAM;CACR;AACF;AAEA,SAAS,OACP,OACA,QACA,QACA,UACA,YACM;CACN,MAAM,SAAS,IAAI,IAAI,WAAW,MAAM,SAAS,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;CACpF,KAAK,MAAM,MAAM,YAAY;EAC3B,IAAI,OAAO,MAAM,QAAQ,EAAE;EAC3B,OAAO,QAAQ,KAAK,SAAS,UAC3B,OAAO,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAA;EACxD,IAAI,MAAM,OAAO,IAAI,KAAK,EAAE;CAC9B;CACA,KAAK,MAAM,MAAM,QAAQ,OAAO,iBAAiB,EAAE;AACrD"}
1
+ {"version":3,"file":"atomic-tool.js","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport { captureEditCheckpoint } from '@pairdraw/scene-graph/checkpoint'\n\nimport type { Editor } from '#core/editor/create'\nimport { ReadOnlyDocumentError } from '#core/editor/read-only'\nimport { resolveEditorProfile, type EditorProfileInputs } from '#core/editor/views'\nimport type { FigmaAPI } from '#core/figma-api'\nimport { isAtomicTool, type ToolDef } from '#core/tools/schema'\n\nimport { diffFields, type FieldChanges } from './diff'\n\n// Capture property changes across pages. Component synchronization remains editor-owned.\nconst MAX_TRANSACTION_NODES = 10_000\n\ntype MutationEditor = Pick<\n Editor,\n 'graph' | 'runLayoutForNode' | 'requestRender' | 'pushUndoStep'\n> & {\n state: EditorProfileInputs\n}\n\nfunction changes<T extends object>(\n before: Map<string, T>,\n after: Map<string, T>,\n expectedSize = before.size\n): FieldChanges<T>[] {\n const result: FieldChanges<T>[] = []\n for (const [id, previous] of before) {\n const current = after.get(id)\n if (!current) throw new Error('Atomic tools must not remove nodes or variables')\n const change = diffFields(id, previous, current)\n if (change) result.push(change)\n }\n if (after.size !== expectedSize)\n throw new Error('Atomic tools must not create nodes or variables')\n return result\n}\n\n/**\n * No await is permitted between snapshot and commit. Browser events, other agents and\n * cancellation cannot interleave with this bounded transaction. Async tools use their\n * existing execution path and are not exposed through WebMCP.\n */\nexport function executeAtomicTool(\n editor: MutationEditor,\n figma: FigmaAPI,\n def: ToolDef,\n args: Record<string, unknown>,\n options: { signal?: AbortSignal; isLive?: () => boolean; label?: string } = {}\n): unknown {\n if (!isAtomicTool(def)) throw new Error(`Not an atomic tool: ${def.name}`)\n if (!resolveEditorProfile(editor.state).edits) throw new ReadOnlyDocumentError()\n options.signal?.throwIfAborted()\n if (editor.graph !== figma.graph || options.isLive?.() === false) {\n throw new Error('The target document is no longer open')\n }\n const graph = figma.graph\n if (graph.nodes.size + graph.variables.size > MAX_TRANSACTION_NODES) {\n throw new Error('Document too large for atomic agent editing (maximum 10000 nodes)')\n }\n // Rollback state costs what the call touches, not a copy of the document.\n const checkpoint = captureEditCheckpoint(graph)\n const { variables } = checkpoint\n const nodeCount = graph.nodes.size\n const pageId = figma.currentPageId\n\n const replay = (\n nodeChanges: FieldChanges<SceneNode>[],\n variableChanges: FieldChanges<Variable>[],\n direction: 'before' | 'after'\n ) => {\n if (editor.graph !== graph) throw new Error('The target document has been replaced')\n for (const change of variableChanges) {\n const variable = graph.variables.get(change.id)\n if (variable) {\n Object.assign(variable, structuredClone(change[direction]))\n for (const key of change.absent[direction]) Reflect.deleteProperty(variable, key)\n }\n }\n graph.preserveSourceMetadataDuring(() => {\n for (const change of nodeChanges)\n graph.restoreNodeProperties(\n change.id,\n structuredClone(change[direction]),\n change.absent[direction]\n )\n })\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n nodeChanges.map((change) => change.id)\n )\n editor.requestRender()\n }\n\n try {\n const result = def.execute(figma, args)\n if (result instanceof Promise) throw new Error('Atomic tools must execute synchronously')\n if (result && typeof result === 'object' && 'error' in result) {\n throw new Error(String(result.error))\n }\n const touched = checkpoint.assertPropertiesOnly()\n const variableChanges = changes(variables, graph.variables)\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n changes(touched, graph.nodes, nodeCount).map((change) => change.id)\n )\n // Layout may change other layers too.\n const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount)\n const contentChanged =\n variableChanges.length > 0 ||\n nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== 'source'))\n if (!contentChanged && nodeChanges.length) replay(nodeChanges, [], 'before')\n if (contentChanged) {\n editor.pushUndoStep({\n label: `${options.label ?? 'Agent'}: ${def.name}`,\n inverse: () => replay(nodeChanges, variableChanges, 'before'),\n forward: () => replay(nodeChanges, variableChanges, 'after')\n })\n editor.requestRender()\n }\n return result\n } catch (error) {\n checkpoint.restore()\n editor.requestRender()\n throw error\n } finally {\n checkpoint.release()\n }\n}\n\nfunction layout(\n graph: SceneGraph,\n editor: MutationEditor,\n pageId: string,\n allPages: boolean,\n changedIds: string[]\n): void {\n const scopes = new Set(allPages ? graph.getPages().map((page) => page.id) : [pageId])\n for (const id of changedIds) {\n let node = graph.getNode(id)\n while (node && node.type !== 'CANVAS')\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n if (node) scopes.add(node.id)\n }\n for (const id of scopes) editor.runLayoutForNode(id)\n}\n"],"mappings":";;;;;;AAYA,MAAM,wBAAwB;AAS9B,SAAS,QACP,QACA,OACA,eAAe,OAAO,MACH;CACnB,MAAM,SAA4B,CAAC;CACnC,KAAK,MAAM,CAAC,IAAI,aAAa,QAAQ;EACnC,MAAM,UAAU,MAAM,IAAI,EAAE;EAC5B,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,iDAAiD;EAC/E,MAAM,SAAS,WAAW,IAAI,UAAU,OAAO;EAC/C,IAAI,QAAQ,OAAO,KAAK,MAAM;CAChC;CACA,IAAI,MAAM,SAAS,cACjB,MAAM,IAAI,MAAM,iDAAiD;CACnE,OAAO;AACT;;;;;;AAOA,SAAgB,kBACd,QACA,OACA,KACA,MACA,UAA4E,CAAC,GACpE;CACT,IAAI,CAAC,aAAa,GAAG,G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id: strin
58
58
  * page, or the document node, is copied the first time the edit is about to change it.
59
59
  */
60
60
  declare function captureDocumentChange(graph: SceneGraph, pageId: string): () => DocumentChange;
61
+ /**
62
+ * The page children holding what an edit touched, on either side of it, for diffing and drawing
63
+ * just those instead of whole pages (`graphsFromDocumentChange`). A layer whose connector draws
64
+ * to a layer elsewhere brings that layer too, as JSX writes the end by it. `null` when part of
65
+ * the page cannot be told apart this way: the edit changed variables, which any layer may show,
66
+ * moved a layer to another page, or left a layer whose parents cannot be followed.
67
+ */
68
+ declare function touchedTopLevelIds(graph: SceneGraph, change: DocumentChange): string[] | null;
61
69
  declare function isEmptyDocumentChange(change: DocumentChange): boolean;
62
70
  /**
63
71
  * Puts what an edit touched back as it was on one side of it. The graph must be as the other
@@ -75,5 +83,5 @@ declare function restoreDocumentChange(ctx: EditorContext, change: DocumentChang
75
83
  keepSelection?: boolean;
76
84
  }): void;
77
85
  //#endregion
78
- export { DocumentChange, applyDocumentChange, captureDocumentChange, isEmptyDocumentChange, restoreDocumentChange, writeRecord };
86
+ export { DocumentChange, applyDocumentChange, captureDocumentChange, isEmptyDocumentChange, restoreDocumentChange, touchedTopLevelIds, writeRecord };
79
87
  //# sourceMappingURL=document-change.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-change.d.ts","names":[],"sources":["../../../src/editor/history/document-change.ts"],"mappings":";;;;KAsBK;;;;;;UAOK;EACR;EACA,QAAQ,aAAa;EACrB,QAAQ,aAAa;EACrB,KAAK,aAAa;;;UAIV;EACR;EACA;;;UAIQ,aAAa;EACrB;EACA,QAAQ;EACR,OAAO;;;;;;;;UASQ;;EAEf;;EAEA;;EAEA,SAAS;;EAET,SAAS;;EAET,SAAS;;EAET,UAAU,OAAO,MAAM;EACvB,WAAW,aAAa;EACxB,aAAa,aAAa;;;;iBAsJZ,YAAY,kBAC1B,QAAQ,YAAY,IACpB,YACA,OAAO;;;;;;;;iBA8BO,sBAAsB,OAAO,YAAY,uBAAuB;iBAgEhE,sBAAsB,QAAQ;;;;;;;iBAkB9B,oBAAoB,OAAO,YAAY,QAAQ,gBAAgB,MAAM;;;;;;iBAqCrE,sBACd,KAAK,eACL,QAAQ,gBACR,MAAM,MACN;EAAW"}
1
+ {"version":3,"file":"document-change.d.ts","names":[],"sources":["../../../src/editor/history/document-change.ts"],"mappings":";;;;KAsBK;;;;;;UAOK;EACR;EACA,QAAQ,aAAa;EACrB,QAAQ,aAAa;EACrB,KAAK,aAAa;;;UAIV;EACR;EACA;;;UAIQ,aAAa;EACrB;EACA,QAAQ;EACR,OAAO;;;;;;;;UASQ;;EAEf;;EAEA;;EAEA,SAAS;;EAET,SAAS;;EAET,SAAS;;EAET,UAAU,OAAO,MAAM;EACvB,WAAW,aAAa;EACxB,aAAa,aAAa;;;;iBAsJZ,YAAY,kBAC1B,QAAQ,YAAY,IACpB,YACA,OAAO;;;;;;;;iBA8BO,sBAAsB,OAAO,YAAY,uBAAuB;;;;;;;;iBAqJhE,mBAAmB,OAAO,YAAY,QAAQ;iBA+B9C,sBAAsB,QAAQ;;;;;;;iBAkB9B,oBAAoB,OAAO,YAAY,QAAQ,gBAAgB,MAAM;;;;;;iBAqCrE,sBACd,KAAK,eACL,QAAQ,gBACR,MAAM,MACN;EAAW"}