@yuzhouu/canvas-kit 0.1.8 → 0.1.10

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 (271) hide show
  1. package/README.md +158 -102
  2. package/_vendor/canvas-core/bindings/bindingUtil.d.ts +8 -0
  3. package/_vendor/canvas-core/editor/cameraPanSession.d.ts +9 -0
  4. package/_vendor/canvas-core/editor/canvasPanInteraction.d.ts +2 -0
  5. package/_vendor/canvas-core/editor/commands.d.ts +15 -3
  6. package/_vendor/canvas-core/editor/createEditorWithPlugins.d.ts +6 -0
  7. package/_vendor/canvas-core/editor/editor.d.ts +24 -26
  8. package/_vendor/canvas-core/editor/editorComputedHelpers.d.ts +4 -2
  9. package/_vendor/canvas-core/editor/historyManager.d.ts +22 -1
  10. package/_vendor/canvas-core/editor/index.d.ts +2 -2
  11. package/_vendor/canvas-core/editor/interactions.d.ts +10 -1
  12. package/_vendor/canvas-core/editor/managers/bindingManager.d.ts +1 -0
  13. package/_vendor/canvas-core/editor/managers/inputsManager.d.ts +3 -0
  14. package/_vendor/canvas-core/editor/managers/interactionTransientManager.d.ts +0 -26
  15. package/_vendor/canvas-core/editor/managers/queryManager.d.ts +13 -1
  16. package/_vendor/canvas-core/editor/managers/selectionLayoutManager.d.ts +2 -0
  17. package/_vendor/canvas-core/editor/managers/shapeGeometryManager.d.ts +3 -2
  18. package/_vendor/canvas-core/editor/managers/shapeHierarchyManager.d.ts +6 -2
  19. package/_vendor/canvas-core/editor/managers/shapeReparenting.d.ts +3 -2
  20. package/_vendor/canvas-core/editor/managers/snapTypes.d.ts +1 -0
  21. package/_vendor/canvas-core/editor/managers/spatialIndexManager.d.ts +1 -0
  22. package/_vendor/canvas-core/editor/queries/shapeTransforms.d.ts +32 -12
  23. package/_vendor/canvas-core/editor/selection.d.ts +19 -5
  24. package/_vendor/canvas-core/editor/selectionOverlay.d.ts +4 -3
  25. package/_vendor/canvas-core/editor/selectionResizeCapabilities.d.ts +9 -0
  26. package/_vendor/canvas-core/editor/shapeTransformSpace.d.ts +6 -0
  27. package/_vendor/canvas-core/exports/svg.d.ts +1 -0
  28. package/_vendor/canvas-core/geometry/index.d.ts +1 -0
  29. package/_vendor/canvas-core/geometry/mat.d.ts +6 -2
  30. package/_vendor/canvas-core/geometry/polygon.d.ts +7 -0
  31. package/_vendor/canvas-core/geometry/vec.d.ts +0 -2
  32. package/_vendor/canvas-core/index.d.ts +14 -20
  33. package/_vendor/canvas-core/plugins/editorRuntimePlugin.d.ts +4 -10
  34. package/_vendor/canvas-core/plugins/editorRuntimeRegistry.d.ts +19 -0
  35. package/_vendor/canvas-core/plugins/index.d.ts +2 -1
  36. package/_vendor/canvas-core/schema/records.d.ts +2 -7
  37. package/_vendor/canvas-core/schema/snapshots.d.ts +10 -19
  38. package/_vendor/canvas-core/shapes/colors.d.ts +1 -2
  39. package/_vendor/canvas-core/shapes/shapeUtil.d.ts +52 -14
  40. package/_vendor/canvas-core/tools/select/selectToolHelpers.d.ts +9 -6
  41. package/_vendor/canvas-core/tools/select/states/draggingSelectionHandleInteractionState.d.ts +3 -3
  42. package/_vendor/canvas-core/tools/select/states/pointingSelectionHandleInteractionState.d.ts +2 -1
  43. package/_vendor/canvas-plugin-sdk/actionRegistry.d.ts +7 -0
  44. package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/actions.d.ts +2 -4
  45. package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/contextMenu.d.ts +25 -30
  46. package/_vendor/canvas-plugin-sdk/contextMenuRegistry.d.ts +11 -0
  47. package/_vendor/canvas-plugin-sdk/index.d.ts +7 -0
  48. package/_vendor/canvas-plugin-sdk/plugin.d.ts +39 -0
  49. package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/toolbar.d.ts +32 -1
  50. package/_vendor/canvas-plugin-sdk/toolbarRegistry.d.ts +19 -0
  51. package/_vendor/canvas-react/components/CanvasView.d.ts +2 -2
  52. package/_vendor/canvas-react/components/canvasKeyboardEvents.d.ts +13 -0
  53. package/_vendor/canvas-react/components/useCanvasDomEvents.d.ts +4 -3
  54. package/_vendor/canvas-react/contextMenuRequest.d.ts +19 -0
  55. package/_vendor/canvas-react/host/canvasRenderPlugin.d.ts +7 -1
  56. package/_vendor/canvas-react/host/canvasRenderRuntime.d.ts +13 -0
  57. package/_vendor/canvas-react/host/domEventGuards.d.ts +3 -3
  58. package/_vendor/canvas-react/host/index.d.ts +2 -8
  59. package/_vendor/canvas-react/host/overlayRegistry.d.ts +3 -3
  60. package/_vendor/canvas-react/host/rendererRegistry.d.ts +7 -4
  61. package/_vendor/canvas-react/index.d.ts +1 -0
  62. package/_vendor/plugin-arrow/arrowGeometry.d.ts +6 -4
  63. package/_vendor/plugin-arrow/arrowShapeUtil.d.ts +5 -3
  64. package/_vendor/plugin-arrow/arrowTerminalCommands.d.ts +2 -2
  65. package/_vendor/plugin-arrow/canvasRender.d.ts +2 -2
  66. package/_vendor/plugin-arrow/editorRuntime.d.ts +4 -2
  67. package/_vendor/plugin-arrow/feature.d.ts +2 -3
  68. package/_vendor/plugin-arrow/index.d.ts +2 -2
  69. package/_vendor/plugin-draw/canvasRender.d.ts +2 -2
  70. package/_vendor/plugin-draw/drawGeometry.d.ts +4 -7
  71. package/_vendor/plugin-draw/drawShapeUtil.d.ts +2 -2
  72. package/_vendor/plugin-draw/editorRuntime.d.ts +4 -2
  73. package/_vendor/plugin-draw/feature.d.ts +2 -3
  74. package/_vendor/plugin-draw/index.d.ts +3 -3
  75. package/_vendor/plugin-eraser/canvasRender.d.ts +2 -2
  76. package/_vendor/plugin-eraser/editorRuntime.d.ts +4 -2
  77. package/_vendor/plugin-eraser/eraserRuntime.d.ts +12 -0
  78. package/_vendor/plugin-eraser/feature.d.ts +2 -3
  79. package/_vendor/plugin-eraser/index.d.ts +3 -2
  80. package/_vendor/plugin-frame/canvasRender.d.ts +2 -2
  81. package/_vendor/plugin-frame/editorRuntime.d.ts +4 -2
  82. package/_vendor/plugin-frame/feature.d.ts +2 -3
  83. package/_vendor/plugin-frame/frameShapeUtil.d.ts +4 -2
  84. package/_vendor/plugin-frame/index.d.ts +2 -2
  85. package/_vendor/plugin-geo/canvasRender.d.ts +2 -2
  86. package/_vendor/plugin-geo/editorRuntime.d.ts +4 -2
  87. package/_vendor/plugin-geo/feature.d.ts +2 -3
  88. package/_vendor/plugin-geo/geoShapeUtil.d.ts +1 -1
  89. package/_vendor/plugin-geo/index.d.ts +2 -2
  90. package/_vendor/plugin-group/canvasRender.d.ts +2 -2
  91. package/_vendor/plugin-group/editorRuntime.d.ts +4 -2
  92. package/_vendor/plugin-group/feature.d.ts +2 -3
  93. package/_vendor/plugin-group/groupContributions.d.ts +7 -0
  94. package/_vendor/plugin-group/groupShapeUtil.d.ts +24 -5
  95. package/_vendor/plugin-group/index.d.ts +3 -2
  96. package/_vendor/plugin-image/canvasRender.d.ts +2 -2
  97. package/_vendor/plugin-image/cropRuntime.d.ts +1 -1
  98. package/_vendor/plugin-image/cropSession.d.ts +5 -3
  99. package/_vendor/plugin-image/editorRuntime.d.ts +4 -2
  100. package/_vendor/plugin-image/feature.d.ts +2 -3
  101. package/_vendor/plugin-image/imageHostActionContract.d.ts +1 -1
  102. package/_vendor/plugin-image/imageShapeUtil.d.ts +3 -3
  103. package/_vendor/plugin-image/index.d.ts +4 -4
  104. package/_vendor/plugin-image/runtimeShared.d.ts +1 -1
  105. package/_vendor/plugin-image/smudge.d.ts +13 -2
  106. package/_vendor/plugin-image/smudgeRuntime.d.ts +1 -1
  107. package/_vendor/plugin-image/styleRuntime.d.ts +1 -1
  108. package/_vendor/plugin-image/toolbarRuntime.d.ts +1 -1
  109. package/_vendor/plugin-laser/canvasRender.d.ts +2 -2
  110. package/_vendor/plugin-laser/editorRuntime.d.ts +4 -2
  111. package/_vendor/plugin-laser/feature.d.ts +2 -3
  112. package/_vendor/plugin-laser/index.d.ts +3 -2
  113. package/_vendor/plugin-laser/laserRuntime.d.ts +18 -0
  114. package/_vendor/plugin-packaging/canvasRender.d.ts +2 -0
  115. package/_vendor/plugin-packaging/editorRuntime.d.ts +2 -0
  116. package/_vendor/plugin-packaging/feature.d.ts +2 -0
  117. package/_vendor/plugin-packaging/index.d.ts +17 -0
  118. package/_vendor/plugin-packaging/packagingArtwork.d.ts +5 -0
  119. package/_vendor/plugin-packaging/packagingDxf.d.ts +9 -0
  120. package/_vendor/plugin-packaging/packagingGeometry.d.ts +74 -0
  121. package/_vendor/plugin-packaging/packagingInteractions.d.ts +2 -0
  122. package/_vendor/plugin-packaging/packagingPdfExporter.d.ts +25 -0
  123. package/_vendor/plugin-packaging/packagingRuntime.d.ts +11 -0
  124. package/_vendor/plugin-packaging/packagingShapeUtil.d.ts +34 -0
  125. package/_vendor/plugin-packaging/packagingStyle.d.ts +10 -0
  126. package/_vendor/plugin-packaging/packagingSvgExporter.d.ts +7 -0
  127. package/_vendor/plugin-packaging/productRuntime.d.ts +2 -0
  128. package/_vendor/plugin-packaging/types.d.ts +168 -0
  129. package/_vendor/plugin-packaging/validation.d.ts +3 -0
  130. package/_vendor/plugin-path/PathDraftOverlay.d.ts +1 -0
  131. package/_vendor/plugin-path/PathEditInsertPreviewOverlay.d.ts +1 -0
  132. package/_vendor/plugin-path/PathShapeRenderer.d.ts +12 -0
  133. package/_vendor/plugin-path/canvasRender.d.ts +2 -0
  134. package/_vendor/plugin-path/editorRuntime.d.ts +21 -0
  135. package/_vendor/plugin-path/feature.d.ts +2 -0
  136. package/_vendor/plugin-path/index.d.ts +7 -0
  137. package/_vendor/plugin-path/pathBoolean.d.ts +13 -0
  138. package/_vendor/plugin-path/pathDraft.d.ts +10 -0
  139. package/_vendor/plugin-path/pathEditPreview.d.ts +11 -0
  140. package/_vendor/plugin-path/pathEditSelection.d.ts +24 -0
  141. package/_vendor/plugin-path/pathEditSnap.d.ts +6 -0
  142. package/_vendor/plugin-path/pathGeometry.d.ts +74 -0
  143. package/_vendor/plugin-path/pathHandles.d.ts +18 -0
  144. package/_vendor/plugin-path/pathInteractions.d.ts +7 -0
  145. package/_vendor/plugin-path/pathShapeUtil.d.ts +28 -0
  146. package/_vendor/plugin-path/pathSvg.d.ts +3 -0
  147. package/_vendor/plugin-path/pathTool.d.ts +39 -0
  148. package/_vendor/plugin-path/types.d.ts +36 -0
  149. package/_vendor/plugin-text/arrowLabelBindingUtil.d.ts +6 -1
  150. package/_vendor/plugin-text/canvasRender.d.ts +6 -3
  151. package/_vendor/plugin-text/editorRuntime.d.ts +9 -3
  152. package/_vendor/plugin-text/feature.d.ts +4 -4
  153. package/_vendor/plugin-text/geoLabelBindingUtil.d.ts +6 -1
  154. package/_vendor/plugin-text/host/RichTextEditingBox.d.ts +4 -1
  155. package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +5 -2
  156. package/_vendor/plugin-text/host/richTextRendering.d.ts +0 -1
  157. package/_vendor/plugin-text/host/textFormattingApi.d.ts +16 -0
  158. package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +3 -1
  159. package/_vendor/plugin-text/host/tiptapTextEditorController.d.ts +4 -1
  160. package/_vendor/plugin-text/index.d.ts +7 -4
  161. package/_vendor/plugin-text/richTextUtils.d.ts +6 -0
  162. package/_vendor/plugin-text/shapeWideTextFormatting.d.ts +8 -0
  163. package/_vendor/plugin-text/textFonts.d.ts +6 -3
  164. package/_vendor/plugin-text/textFormatting.d.ts +45 -0
  165. package/_vendor/plugin-text/textFormattingSession.d.ts +6 -0
  166. package/_vendor/plugin-text/textLabelHelpers.d.ts +9 -4
  167. package/_vendor/plugin-text/textLinkPopoverPresentation.d.ts +18 -0
  168. package/_vendor/plugin-text/textShapeHelpers.d.ts +1 -0
  169. package/_vendor/plugin-text/textShapeUtil.d.ts +5 -4
  170. package/_vendor/signals/effect.d.ts +0 -4
  171. package/_vendor/signals/index.d.ts +1 -1
  172. package/_vendor/store/store.d.ts +4 -0
  173. package/browser/persistence.d.ts +5 -16
  174. package/builtins/controller/createBuiltInCanvasController.d.ts +2 -0
  175. package/builtins/controller/packagingController.d.ts +71 -0
  176. package/builtins/index.d.ts +4 -2
  177. package/builtins/plugins.d.ts +16 -0
  178. package/chrome/floating/CanvasKitFloatingPortal.d.ts +6 -0
  179. package/chrome/floating/useCanvasKitFloatingPosition.d.ts +11 -0
  180. package/chrome/toolbar/CanvasKitFloatingToolbarLayer.d.ts +1 -1
  181. package/chrome/toolbar/toolbarLabels.d.ts +1 -1
  182. package/chrome/toolbar/useToolbarSurfaces.d.ts +6 -10
  183. package/chrome/types.d.ts +5 -10
  184. package/chrome/useCanvasKitChromeContext.d.ts +13 -13
  185. package/chrome/useContextMenuSurface.d.ts +4 -4
  186. package/chrome/useHistoryControls.d.ts +3 -3
  187. package/chrome/usePageControls.d.ts +3 -3
  188. package/controller/canvasKitController.d.ts +5 -9
  189. package/core/index.d.ts +1 -2
  190. package/core/product-controller/canvasProductController.d.ts +2 -1
  191. package/core/runtime/productAssets.d.ts +4 -2
  192. package/core/runtime/productEditor.d.ts +1 -1
  193. package/core/runtime/productServices.d.ts +6 -2
  194. package/core/runtime/runtimeContracts.d.ts +17 -0
  195. package/es-DocrZgUh.mjs +2 -0
  196. package/features/actions/actionRuntime.d.ts +2 -7
  197. package/features/clipboard/clipboardContextMenuContributions.d.ts +1 -1
  198. package/features/clipboard/clipboardContribution.d.ts +2 -1
  199. package/features/clipboard/clipboardPlugin.d.ts +1 -0
  200. package/features/clipboard/clipboardService.d.ts +1 -1
  201. package/features/context-menu/contextMenuRuntime.d.ts +4 -4
  202. package/features/image/asset/imageAssetService.d.ts +1 -1
  203. package/features/image/asset/imageBlobStore.d.ts +6 -2
  204. package/features/image/controller/imageProductController.d.ts +1 -1
  205. package/features/image/imageProductPlugin.d.ts +1 -0
  206. package/features/image/smudge/imageSmudgeHostActions.d.ts +1 -1
  207. package/features/image/smudge/imageSmudgeTypes.d.ts +1 -0
  208. package/features/image/toolbar/imageHostActions.d.ts +13 -2
  209. package/features/image/toolbar/imageToolbarHostBridge.d.ts +1 -1
  210. package/features/keyboard/keyboardShortcutPlugin.d.ts +1 -0
  211. package/features/keyboard/useCanvasKitKeyboardShortcuts.d.ts +5 -3
  212. package/features/selection/selectionActions.d.ts +2 -3
  213. package/features/selection/selectionContextMenuContributions.d.ts +1 -1
  214. package/features/selection/selectionPlugin.d.ts +1 -0
  215. package/features/selection/selectionToolbarContributions.d.ts +1 -1
  216. package/features/text/link/TextLinkHoverPopover.d.ts +6 -0
  217. package/features/text/textProductPlugin.d.ts +5 -0
  218. package/features/tool/toolActions.d.ts +1 -1
  219. package/features/tool/toolContextMenuContributions.d.ts +1 -1
  220. package/features/tool/toolPlugin.d.ts +1 -0
  221. package/features/tool/toolToolbarContributions.d.ts +1 -1
  222. package/features/view/viewActions.d.ts +1 -1
  223. package/features/view/viewContextMenuContributions.d.ts +1 -1
  224. package/features/view/viewPlugin.d.ts +1 -0
  225. package/index.css +1 -1
  226. package/index.d.ts +23 -9
  227. package/index.mjs +84 -96
  228. package/package.json +12 -9
  229. package/product/standardCanvasKitPlugins.d.ts +4 -0
  230. package/react/CanvasKitRoot.d.ts +10 -5
  231. package/react/useCanvasKitControllerLifecycle.d.ts +8 -0
  232. package/react/useCanvasKitRuntime.d.ts +2 -4
  233. package/runtime/canvasKitCommandExecutor.d.ts +13 -0
  234. package/runtime/canvasKitPluginContracts.d.ts +79 -0
  235. package/runtime/canvasKitPlugins.d.ts +33 -0
  236. package/runtime/canvasKitRuntime.d.ts +46 -19
  237. package/runtime/canvasKitRuntimeContracts.d.ts +37 -0
  238. package/_vendor/canvas-core/editor/createEditorWithRuntimePlugins.d.ts +0 -6
  239. package/_vendor/canvas-core/editor/middleMousePanInteraction.d.ts +0 -2
  240. package/_vendor/canvas-core/schema/snapshotSupport.d.ts +0 -43
  241. package/_vendor/canvas-react/host/actionRegistry.d.ts +0 -15
  242. package/_vendor/canvas-react/host/canvasRenderPluginHost.d.ts +0 -2
  243. package/_vendor/canvas-react/host/canvasRenderPluginHostManifest.d.ts +0 -2
  244. package/_vendor/canvas-react/host/canvasRenderPluginHostRuntime.d.ts +0 -3
  245. package/_vendor/canvas-react/host/canvasRenderPluginHostTypes.d.ts +0 -104
  246. package/_vendor/canvas-react/host/canvasRenderPluginHostValidation.d.ts +0 -11
  247. package/_vendor/canvas-react/host/contextMenuRegistry.d.ts +0 -17
  248. package/_vendor/canvas-react/host/extension.d.ts +0 -37
  249. package/_vendor/canvas-react/host/toolbarRegistry.d.ts +0 -20
  250. package/_vendor/plugin-text/host/RichTextLinkPopover.d.ts +0 -14
  251. package/_vendor/plugin-text/host/RichTextToolbar.d.ts +0 -8
  252. package/_vendor/plugin-text/host/richTextBubbleMenuPositionSync.d.ts +0 -7
  253. package/browser/localSnapshotRestore.d.ts +0 -13
  254. package/builtins/extensions.d.ts +0 -18
  255. package/core/runtime/productDefinition.d.ts +0 -33
  256. package/core/runtime/productHost.d.ts +0 -20
  257. package/features/clipboard/clipboardHostExtension.d.ts +0 -2
  258. package/features/image/imageHostExtension.d.ts +0 -10
  259. package/features/keyboard/keyboardShortcutHostExtension.d.ts +0 -2
  260. package/features/persistence/CanvasKitPersistenceNotice.d.ts +0 -4
  261. package/features/persistence/persistenceHostExtension.d.ts +0 -2
  262. package/features/selection/selectionHostExtension.d.ts +0 -2
  263. package/features/tool/toolHostExtension.d.ts +0 -2
  264. package/features/view/viewHostExtension.d.ts +0 -2
  265. package/host/defaultHostExtensions.d.ts +0 -2
  266. package/product/canvasKitProduct.d.ts +0 -51
  267. package/react/useCanvasKitController.d.ts +0 -5
  268. package/react/useCanvasKitStartup.d.ts +0 -9
  269. package/runtime/canvasKitHostContracts.d.ts +0 -135
  270. package/runtime/canvasKitHostFeatureHooks.d.ts +0 -12
  271. package/runtime/canvasKitRuntimePlan.d.ts +0 -50
package/README.md CHANGED
@@ -1,151 +1,207 @@
1
1
  # @land/canvas-kit
2
2
 
3
- `@land/canvas-kit` is the public React SDK for the Land canvas kit. It includes the product runtime, built-in canvas extensions, image integration, persistence, chrome context, and typed controller surface behind one package root.
3
+ CanvasKit is the public composition root for the Land canvas. It compiles one graph of `CanvasPlugin` objects and nested plugin groups to assemble an isolated Runtime, then exposes a controller-oriented API without exposing Editor, services, registries, or private render data.
4
4
 
5
- ## Install
5
+ ## React usage
6
6
 
7
- ```bash
8
- pnpm add @land/canvas-kit react react-dom
9
- ```
10
-
11
- ## Basic Usage
7
+ Keep the options object stable. The hook uses reference identity to decide when to replace a Runtime.
12
8
 
13
9
  ```tsx
14
- import { useMemo } from "react";
15
10
  import {
16
11
  CanvasKitRoot,
17
- defineCanvasKit,
12
+ useCanvasKitRuntime,
13
+ type CanvasKitRuntimeOptions,
18
14
  } from "@land/canvas-kit";
19
- import "@land/canvas-kit/style.css";
15
+
16
+ const RUNTIME_OPTIONS: CanvasKitRuntimeOptions = {
17
+ id: "my-canvas",
18
+ storageNamespace: "my-app.canvas",
19
+ };
20
20
 
21
21
  export function App() {
22
- const product = useMemo(
23
- () =>
24
- defineCanvasKit({
25
- onControllerReady(controller) {
26
- console.log(controller.snapshot());
27
- },
28
- }),
29
- [],
30
- );
22
+ const state = useCanvasKitRuntime(RUNTIME_OPTIONS);
23
+
24
+ if (state.status === "error") throw state.error;
25
+ if (state.status !== "ready") return null;
31
26
 
32
27
  return (
33
- <div style={{ width: "100%", height: "100vh" }}>
34
- <CanvasKitRoot product={product} />
35
- </div>
28
+ <CanvasKitRoot
29
+ runtime={state.runtime}
30
+ onControllerReady={(controller) => {
31
+ controller.setTool("select");
32
+ }}
33
+ />
36
34
  );
37
35
  }
38
36
  ```
39
37
 
40
- The host element must provide a size. `CanvasKitRoot` fills the space provided by its parent and mounts the canvas runtime for the product.
38
+ Use a module-level constant or `useMemo` for `CanvasKitRuntimeOptions`. An inline object creates and disposes a Runtime after every render.
41
39
 
42
- ## Custom Chrome
40
+ ## Imperative usage
43
41
 
44
- Use the `chrome` option when you want to provide your own toolbar, panels, or menus while keeping the kit runtime and built-in extensions.
42
+ The creator owns the complete lifecycle:
45
43
 
46
44
  ```tsx
47
- import { useMemo } from "react";
45
+ import { createRoot } from "react-dom/client";
48
46
  import {
49
47
  CanvasKitRoot,
50
- defineCanvasKit,
51
- type CanvasKitController,
52
- type CanvasKitChromeContext,
48
+ createCanvasKitRuntime,
53
49
  } from "@land/canvas-kit";
54
- import "@land/canvas-kit/style.css";
55
50
 
56
- function MyChrome({
57
- context,
58
- }: {
59
- context: CanvasKitChromeContext<CanvasKitController>;
60
- }) {
61
- return (
62
- <>
63
- <button
64
- type="button"
65
- disabled={!context.history.canUndo}
66
- onClick={context.history.undo}
67
- >
68
- Undo
69
- </button>
70
- <button type="button" onClick={context.zoom.zoomIn}>
71
- Zoom in
72
- </button>
73
- <button
74
- type="button"
75
- disabled={context.selection.count === 0}
76
- onClick={() => context.controller.deleteShapes([...context.selectedShapeIds])}
77
- >
78
- Delete
79
- </button>
80
- </>
81
- );
82
- }
51
+ const runtime = createCanvasKitRuntime({ persistence: null });
52
+ const startup = await runtime.start();
83
53
 
84
- export function App() {
85
- const product = useMemo(
86
- () =>
87
- defineCanvasKit({
88
- chrome: (context) => <MyChrome context={context} />,
89
- }),
90
- [],
91
- );
54
+ const root = createRoot(document.getElementById("app")!);
55
+ root.render(<CanvasKitRoot runtime={runtime} />);
92
56
 
93
- return (
94
- <div style={{ width: "100%", height: "100vh" }}>
95
- <CanvasKitRoot product={product} />
96
- </div>
97
- );
57
+ // Later:
58
+ root.unmount();
59
+ runtime.dispose();
60
+ ```
61
+
62
+ One Runtime can be mounted by only one `CanvasKitRoot` at a time. `CanvasKitRoot` requires a ready Runtime and never calls `start()` or `dispose()`.
63
+
64
+ ## Runtime options
65
+
66
+ ```ts
67
+ interface CanvasKitRuntimeOptions {
68
+ id?: string;
69
+ chrome?: CanvasKitChromeRenderer;
70
+ documentMeta?: Record<string, unknown>;
71
+ persistence?: ProductPersistenceAdapter | null;
72
+ seedDocument?: CanvasKitDocumentSeed;
73
+ shouldSkipStoredSnapshots?: () => boolean;
74
+ plugins?: readonly CanvasPluginInput[];
75
+ storageNamespace?: string;
98
76
  }
99
77
  ```
100
78
 
101
- Chrome should operate through `CanvasKitChromeContext` and `context.controller`. The product shell owns canvas mounting, so custom chrome should render controls and overlays rather than the canvas itself. It should not import `@land/canvas-core`, `@land/canvas-react`, built-in plugin packages, or kit internals.
79
+ Controller callbacks, window exposure, and `windowKey` are mount concerns and belong on `CanvasKitRoot`.
102
80
 
103
- The package no longer exposes a one-component direct render entry. Apps should define a product with `defineCanvasKit` and render it through `CanvasKitRoot`.
81
+ ## Startup result
104
82
 
105
- ## Local Persistence
83
+ `runtime.start()` is single-flight and idempotent. It returns:
106
84
 
107
- Default browser persistence restores supported records even when a saved
108
- snapshot also contains unsupported shape or binding types. Unsupported raw
109
- records are preserved outside the live editor and merged back into future saves.
110
- When this happens, `CanvasKitRoot` shows a persistence notice and custom
111
- chrome can inspect `context.persistence.status` or call
112
- `context.persistence.discardUnsupportedRecords?.()` after explicit user
113
- confirmation.
85
+ ```ts
86
+ interface CanvasKitStartupResult {
87
+ documentSource: "restored" | "seeded" | "empty";
88
+ sessionRestored: boolean;
89
+ warnings: readonly unknown[];
90
+ }
91
+ ```
114
92
 
115
- ## Internal Assembly
93
+ Startup loads snapshots, resets to a clean document/session, restores the document or seeds after a clean fallback, restores session state, clears history, prepares assets, runs `beforeReady`, and starts persistence. Recoverable load/restore/asset/hook/persistence errors are returned in `warnings`. Synchronous assembly and seed failures are fatal.
116
94
 
117
- The public product remains opaque. Internally, `defineCanvasKit()` resolves options into explicit product fields:
95
+ Disposal aborts startup, stops persistence, runs setup disposers in reverse order, then disposes Editor and services. A disposed Runtime cannot restart.
118
96
 
119
- - `LandExtension[]` installs editor/canvas render plugins through `@land/canvas-react/host`.
120
- - `CanvasKitHostExtension[]` installs product-host behavior such as clipboard, toolbar, context menu, image import, asset URL resolution, SVG asset inlining, and controller components.
121
- - Service factories and asset resolver tokens wire product-level services into runtime.
122
- - `CanvasKitRuntime` creates services, the plugin host runtime, the editor, controller registry, and then runs product runtime setup.
97
+ ## Persistence adapter
123
98
 
124
- Advanced products can pass additional `hostExtensions` to `defineCanvasKit()`
125
- for product-host behavior that should compose with the built-in runtime instead
126
- of being hard-coded in chrome or canvas runtime modules.
99
+ Persistence is IO-only; Runtime owns restore and seed ordering.
127
100
 
128
- This keeps app chrome on the root package controller while keeping browser-specific host behavior out of concrete shape plugins and out of `canvas-core`.
101
+ ```ts
102
+ interface ProductPersistenceAdapter {
103
+ load?(options: {
104
+ signal: AbortSignal;
105
+ }): Promise<{
106
+ documentSnapshot: unknown | null;
107
+ sessionSnapshot: unknown | null;
108
+ }>;
109
+ start?(editor: Editor): () => void;
110
+ flushSnapshot?(editor: Editor): Promise<void>;
111
+ }
112
+ ```
129
113
 
130
- ## Public Exports
114
+ When no document snapshot exists, `seedDocument` runs once. Session restore happens after seed so persisted camera and selection state win.
131
115
 
132
- The published package intentionally exposes only:
116
+ ## Plugin authoring
133
117
 
134
- - `@land/canvas-kit`
135
- - `@land/canvas-kit/style.css`
118
+ Use `defineCanvasPlugin()` and pass plugins or nested plugin groups through Runtime options:
119
+
120
+ ```ts
121
+ import {
122
+ createProductServiceToken,
123
+ createStandardCanvasKitPlugins,
124
+ defineCanvasPlugin,
125
+ type CanvasKitRuntimeOptions,
126
+ } from "@land/canvas-kit";
136
127
 
137
- Package subpaths are internal implementation details.
128
+ const analyticsToken = createProductServiceToken<{ track(name: string): void }>(
129
+ "example.analytics",
130
+ );
131
+
132
+ const analyticsPlugin = defineCanvasPlugin({
133
+ id: "example.analytics",
134
+ product: () => ({
135
+ services: [
136
+ {
137
+ token: analyticsToken,
138
+ create: () => ({ track: console.log }),
139
+ },
140
+ ],
141
+ createActions({ services }) {
142
+ const analytics = services.get(analyticsToken);
143
+ return [
144
+ {
145
+ id: "example.track",
146
+ run: () => analytics?.track("canvas-action"),
147
+ },
148
+ ];
149
+ },
150
+ }),
151
+ });
152
+
153
+ const reportingPlugin = defineCanvasPlugin({
154
+ id: "example.reporting",
155
+ requires: [analyticsPlugin],
156
+ product: () => ({
157
+ setup({ services }) {
158
+ services.get(analyticsToken)?.track("runtime-ready");
159
+ },
160
+ }),
161
+ });
162
+
163
+ const options: CanvasKitRuntimeOptions = {
164
+ plugins: [
165
+ createStandardCanvasKitPlugins(),
166
+ [analyticsPlugin, reportingPlugin],
167
+ ],
168
+ };
169
+ ```
138
170
 
139
- ## Local Build
171
+ `CanvasPlugin` keeps its optional `editor`, `render`, and `product` facets. `requires` lives at the plugin top level, so one dependency order applies to every facet. Nested arrays are groups only; they do not need IDs and are flattened in declaration order. Optional features are included or omitted explicitly in these arrays; product factories always return a contribution. Runtime creation validates missing or circular dependencies, duplicate IDs, and action references before creating Editor state.
140
172
 
141
- Run from the workspace root:
173
+ Packaging is intentionally outside the standard plugin profile. Products that
174
+ need it add the public plugin explicitly:
142
175
 
143
- ```bash
144
- pnpm build:canvas-kit:bundle
176
+ ```ts
177
+ import {
178
+ Packaging,
179
+ createStandardCanvasKitPlugins,
180
+ type CanvasKitRuntimeOptions,
181
+ } from "@land/canvas-kit";
182
+
183
+ const options: CanvasKitRuntimeOptions = {
184
+ plugins: [createStandardCanvasKitPlugins(), Packaging],
185
+ };
145
186
  ```
146
187
 
147
- The publish-ready output is written to:
188
+ The flat product contribution has two assembly/startup hooks:
189
+
190
+ - `setup(context)` runs during synchronous Runtime creation and may return a disposer.
191
+ - `beforeReady({ startup, signal, ...context })` runs serially during `start()` after restore/seed and asset preparation.
192
+
193
+ `beforeCommand` is a repeatable interceptor executed by the Runtime-bound command executor; it is not a lifecycle stage.
194
+
195
+ Services, `createActions`, APIs, hooks, providers, components, and asset integration all live directly on the product contribution. API contributions use only `token.id` for identity. Components share one props contract and render between Canvas and chrome; there are no component slots.
196
+
197
+ ## Public controller
148
198
 
149
- ```text
150
- packages/canvas-kit/dist-component/
199
+ External code should work through `runtime.controller` or the controller supplied to `onControllerReady`. The controller exposes document, selection, page, tool, camera, layer, history, export, built-in shape creation, and registered API operations without exposing the raw store.
200
+
201
+ ## Styles
202
+
203
+ The package root imports its base styles. Published consumers may also use the explicit stylesheet export when their bundler requires it:
204
+
205
+ ```ts
206
+ import "@land/canvas-kit/style.css";
151
207
  ```
@@ -11,6 +11,7 @@ export interface BindingShapeChangeContext {
11
11
  before: ShapeRecord;
12
12
  after: ShapeRecord;
13
13
  role: "from" | "to";
14
+ reason: "self" | "ancestry";
14
15
  }
15
16
  export interface BindingShapeDeleteContext {
16
17
  shape: ShapeRecord;
@@ -40,6 +41,13 @@ export declare abstract class BindingUtil<B extends BindingRecordBase = BindingR
40
41
  onBeforeDeleteShape?(editor: Editor, binding: B, context: BindingShapeDeleteContext): BindingUtilEffect | void;
41
42
  onBeforeDeleteBinding?(editor: Editor, binding: B): BindingUtilEffect | void;
42
43
  getExportShapeIds?(editor: Editor, binding: B): ShapeRecord["id"][];
44
+ /**
45
+ * Map a hierarchy companion (for example, a bound label) to the shape that
46
+ * owns its group lifecycle and selection semantics.
47
+ */
48
+ getShapeHierarchyRootId?(binding: B, shapeId: ShapeRecord["id"]): ShapeRecord["id"] | null;
49
+ canUseShapeHierarchy?(binding: B, context: BindingEndpointContext): boolean;
43
50
  getGeometryDependentShapeIds?(editor: Editor, binding: B, context: BindingShapeGeometryDependencyContext): ShapeRecord["id"][];
44
51
  getSelectionCompanionFrameGeometries?(editor: Editor, binding: B, context: BindingSelectionCompanionFrameContext): SelectionOverlayFrameGeometryState[];
45
52
  }
53
+ export declare function resolveShapeHierarchyRootId(shapeId: ShapeRecord["id"], bindings: readonly BindingRecord[], getBindingUtil: (binding: BindingRecord) => BindingUtil): ShapeRecord["id"];
@@ -0,0 +1,9 @@
1
+ import type { Vec } from "../geometry/vec";
2
+ import type { Camera } from "../schema/records";
3
+ import type { Editor } from "./editor";
4
+ export interface CameraPanSession {
5
+ originScreenPoint: Vec;
6
+ originCamera: Camera;
7
+ }
8
+ export declare function createCameraPanSession(editor: Editor, originScreenPoint: Vec): CameraPanSession;
9
+ export declare function updateCameraPanSession(editor: Editor, session: CameraPanSession, screenPoint: Vec): void;
@@ -0,0 +1,2 @@
1
+ import type { LandInteractionHandler } from "./interactions";
2
+ export declare function createCanvasPanInteractionHandler(): LandInteractionHandler;
@@ -4,6 +4,16 @@ import type { AssetId, AssetRecord, AssetRecordBase, BindingId, BindingRecordBas
4
4
  export interface EditorCommandOptions {
5
5
  source?: ChangeSource;
6
6
  }
7
+ export interface CreateShapesOptions extends EditorCommandOptions {
8
+ /** Defer spatial containment until an interactive creation gesture completes. */
9
+ autoReparent?: boolean;
10
+ /** Internal: allow a container to receive children later in the same atomic command. */
11
+ deferMinimumChildRepair?: boolean;
12
+ }
13
+ export interface UpdateShapesOptions extends EditorCommandOptions {
14
+ /** Internal recursion guard for binding-driven shape updates. */
15
+ skipBindingIds?: ReadonlySet<BindingId>;
16
+ }
7
17
  export interface CreateShapeInput {
8
18
  type: ShapeRecordBase["type"];
9
19
  x: number;
@@ -14,6 +24,7 @@ export interface CreateShapeInput {
14
24
  opacity?: number;
15
25
  isHidden?: boolean;
16
26
  rotation?: number;
27
+ skewX?: number;
17
28
  scaleX?: number;
18
29
  scaleY?: number;
19
30
  isLocked?: boolean;
@@ -35,6 +46,7 @@ export interface ShapeUpdate {
35
46
  x?: number;
36
47
  y?: number;
37
48
  rotation?: number;
49
+ skewX?: number;
38
50
  scaleX?: number;
39
51
  scaleY?: number;
40
52
  opacity?: number;
@@ -106,19 +118,19 @@ export interface EditorCommands {
106
118
  updateDocumentMeta(input: UpdateDocumentMetaInput, options?: EditorCommandOptions): DocumentMetadataRecord;
107
119
  updatePageMeta(input: UpdatePageMetaInput, options?: EditorCommandOptions): PageRecord | null;
108
120
  movePage(input: MovePageInput, options?: EditorCommandOptions): void;
109
- createShapes(inputs: CreateShapeInput[], options?: EditorCommandOptions): ShapeRecord[];
121
+ createShapes(inputs: CreateShapeInput[], options?: CreateShapesOptions): ShapeRecord[];
110
122
  /**
111
123
  * Persist already-built shape records (with their existing ids) through the
112
124
  * command pipeline. Used by paste/duplicate where ids must be assigned before
113
125
  * parent/binding remapping. Prefer `createShapes` for fresh shapes.
114
126
  */
115
127
  createShapesFromRecords(records: ShapeRecord[], options?: EditorCommandOptions): ShapeRecord[];
116
- updateShapes(updates: ShapeUpdate[], options?: EditorCommandOptions): void;
128
+ updateShapes(updates: ShapeUpdate[], options?: UpdateShapesOptions): void;
117
129
  /**
118
130
  * Move shapes to a new parent, appending shapes that are entering that parent
119
131
  * to the end of its child order in the order provided by `ids`.
120
132
  */
121
- reparentShapes(input: ReparentShapesInput, options?: EditorCommandOptions): void;
133
+ reparentShapes(input: ReparentShapesInput, options?: EditorCommandOptions): boolean;
122
134
  deleteShapes(ids: ShapeId[], options?: EditorCommandOptions): void;
123
135
  createAsset(input: CreateAssetInput, options?: EditorCommandOptions): AssetRecord;
124
136
  /**
@@ -0,0 +1,6 @@
1
+ import { type EditorPlugin } from "../plugins";
2
+ import { Editor, type EditorOptions } from "./editor";
3
+ export interface CreateEditorWithPluginsOptions extends Omit<EditorOptions, "shapeUtils" | "shapeSvgExporters" | "bindingUtils" | "shapeCapabilities"> {
4
+ plugins?: readonly EditorPlugin[];
5
+ }
6
+ export declare function createEditorWithPlugins(options?: CreateEditorWithPluginsOptions): Editor;
@@ -5,6 +5,7 @@ import { BindingUtilRegistry } from "../bindings/bindingUtilRegistry";
5
5
  import { Box } from "../geometry/box";
6
6
  import { Mat } from "../geometry/mat";
7
7
  import { Vec } from "../geometry/vec";
8
+ import { EditorRuntimeRegistry } from "../plugins/editorRuntimeRegistry";
8
9
  import { type BindingId, type BindingRecord, type AssetId, type AssetRecord, type Camera, type DocumentMetadataRecord, type PageId, type PageRecord, type EditorRecord, type RecordScope, type SessionRecord, type ShapeId, type ShapeParentId, type ShapeRecord, type ShapeEditingEntryRequest, type ShapeEditingSession } from "../schema/records";
9
10
  import { type DocumentSnapshot, type SessionSnapshot } from "../schema/snapshots";
10
11
  import type { ShapeSelectionFlipAxis, ShapeUtil } from "../shapes/shapeUtil";
@@ -21,8 +22,8 @@ import { CameraManager } from "./managers/cameraManager";
21
22
  import { ClipboardManager } from "./managers/clipboardManager";
22
23
  import { DocumentSnapshotManager } from "./managers/documentSnapshotManager";
23
24
  import { InputsManager } from "./managers/inputsManager";
24
- import { InteractionTransientManager, type LaserTrailState } from "./managers/interactionTransientManager";
25
- import { QueryManager, type ShapeContainment } from "./managers/queryManager";
25
+ import { InteractionTransientManager } from "./managers/interactionTransientManager";
26
+ import { QueryManager, type ShapeHierarchySnapshotEntry, type ShapeContainment } from "./managers/queryManager";
26
27
  import { SpatialIndexManager, type ShapeAtPointOptions, type ShapeLineSegmentHitTestOptions, type SpatialQueryOptions } from "./managers/spatialIndexManager";
27
28
  import { SnapManager } from "./managers/snapManager";
28
29
  import { SideEffectManager } from "./managers/sideEffectManager";
@@ -87,7 +88,7 @@ export interface ShapeSelectionSiblingOrderState {
87
88
  canMoveBackward: boolean;
88
89
  canMoveForward: boolean;
89
90
  }
90
- export type ReparentShapePlacementFailureReason = "notFound" | "locked" | "hidden" | "invalidParent" | "cycle" | "invalidBeforeId";
91
+ export type ReparentShapePlacementFailureReason = "notFound" | "locked" | "hidden" | "invalidParent" | "cycle" | "invalidBeforeId" | "unsupportedTransform";
91
92
  export type ReparentShapePlacementResult = {
92
93
  ok: true;
93
94
  movedIds: ShapeId[];
@@ -103,7 +104,8 @@ export interface ReparentShapePlacementInput {
103
104
  export interface ShapeGroupState {
104
105
  parentId: ShapeParentId;
105
106
  shapeIds: ShapeId[];
106
- bounds: Box;
107
+ /** Axis-aligned bounds of the grouped roots in their common parent's local space. */
108
+ parentLocalBounds: Box;
107
109
  }
108
110
  export type LayerOrderDirection = "backward" | "forward";
109
111
  export type LayerOrderEdge = "back" | "front";
@@ -131,6 +133,7 @@ export interface EditorSelectionState {
131
133
  frameRotationCenter: Vec | null;
132
134
  selectionAnchorPagePoint: Vec | null;
133
135
  }
136
+ export type EditorSelectionMetadata = Omit<EditorSelectionState, "frameBounds" | "frameRotation" | "frameRotationCenter" | "selectionAnchorPagePoint">;
134
137
  export interface EditorRenderHostDebugState {
135
138
  culledCount: number;
136
139
  visibleCount: number;
@@ -193,6 +196,7 @@ export declare class Editor {
193
196
  readonly bindingUtils: BindingUtilRegistry;
194
197
  readonly interactions: InteractionHandlerRegistry;
195
198
  readonly selectionHandleInteractions: SelectionHandleInteractionRegistry;
199
+ readonly runtime: EditorRuntimeRegistry;
196
200
  readonly queries: QueryManager;
197
201
  readonly bindings: BindingManager;
198
202
  readonly spatialIndex: SpatialIndexManager;
@@ -206,12 +210,6 @@ export declare class Editor {
206
210
  private readonly shapeCapabilityDefinitions;
207
211
  readonly brushBoxSignal: Signal<Box | null>;
208
212
  readonly brushBoxActiveSignal: Signal<boolean>;
209
- readonly erasingShapeIdsSignal: Signal<ShapeId[]>;
210
- readonly erasingShapeIdsActiveSignal: Signal<boolean>;
211
- readonly eraserTrailSignal: Signal<Vec[]>;
212
- readonly eraserTrailActiveSignal: Signal<boolean>;
213
- readonly laserTrailSignal: Signal<LaserTrailState | null>;
214
- readonly laserTrailActiveSignal: Signal<boolean>;
215
213
  readonly bindingPreviewSignal: Signal<BindingPreviewState | null>;
216
214
  readonly bindingPreviewActiveSignal: Signal<boolean>;
217
215
  readonly terminalBindingGuidesSignal: Signal<TerminalBindingGuideState[]>;
@@ -234,9 +232,12 @@ export declare class Editor {
234
232
  private assetUrlResolver;
235
233
  private get _internalStore();
236
234
  readonly sessionSignal: import("../../signals/index").Computed<SessionRecord>;
235
+ /** Read the latest session draft, including writes made inside store.atomic. */
236
+ getSessionRecord(): SessionRecord;
237
237
  readonly currentPageIdSignal: import("../../signals/index").Computed<`page:${string}`>;
238
238
  readonly currentPageShapeIdsSignal: Signal<ShapeId[]>;
239
239
  readonly currentPageShapesSignal: Signal<ShapeRecord[]>;
240
+ readonly currentPageShapeHierarchySignal: Signal<ShapeHierarchySnapshotEntry[]>;
240
241
  readonly culledShapeIdsSignal: Signal<ShapeId[]>;
241
242
  readonly renderVisibleShapeIdsSignal: Signal<ShapeId[]>;
242
243
  readonly retainedShapeIdsSignal: Signal<ShapeId[]>;
@@ -257,6 +258,7 @@ export declare class Editor {
257
258
  readonly selectedShapesSignal: import("../../signals/index").Computed<ShapeRecord[]>;
258
259
  readonly selectedShapeOverlayItemsSignal: import("../../signals/index").Computed<SelectedShapeOverlayItem[]>;
259
260
  readonly selectionStateSignal: import("../../signals/index").Computed<EditorSelectionState>;
261
+ readonly selectionMetadataSignal: import("../../signals/index").Computed<EditorSelectionMetadata>;
260
262
  readonly pageTransformSignal: import("../../signals/index").Computed<Mat>;
261
263
  readonly cameraZoomSignal: import("../../signals/index").Computed<number>;
262
264
  readonly viewportPageBoundsSignal: import("../../signals/index").Computed<Box | null>;
@@ -274,10 +276,10 @@ export declare class Editor {
274
276
  private readonly shapeRenderOrderSignals;
275
277
  private readonly shapeRenderVisibleSignals;
276
278
  private readonly shapeDocumentVisibleSignals;
279
+ private readonly shapeEffectiveOpacitySignals;
277
280
  private readonly shapeEditingSessionSignals;
278
281
  private readonly shapeDropTargetSignals;
279
282
  private readonly shapeHoveredSignals;
280
- private readonly shapeErasingSignals;
281
283
  private readonly shapeSelectedDescendantTransformAncestorSignals;
282
284
  private lastPointerDownForClickCount;
283
285
  private lastPointerUpForClickCount;
@@ -367,7 +369,6 @@ export declare class Editor {
367
369
  * along the given axis. Needs at least three shapes.
368
370
  */
369
371
  distributeSelection(axis: "horizontal" | "vertical", source?: ChangeSource): boolean;
370
- moveShapesToParentPlacement(input: ReparentShapePlacementInput, source?: ChangeSource): boolean;
371
372
  moveShapesToParentPlacementResult(input: ReparentShapePlacementInput, source?: ChangeSource): ReparentShapePlacementResult;
372
373
  moveSelectionInParentOrder(direction: ShapeSiblingOrderDirection, source?: ChangeSource): boolean;
373
374
  moveSelectionToParentOrderEdge(edge: ShapeSiblingOrderEdge, source?: ChangeSource): boolean;
@@ -393,14 +394,15 @@ export declare class Editor {
393
394
  resolveAssetUrl(assetId: AssetId): string | null;
394
395
  getUnreferencedAssetIdsAfterShapeDelete(shapeIds: readonly ShapeId[]): AssetId[];
395
396
  getShapeSignal(id: ShapeId): Signal<ShapeRecord | undefined>;
397
+ getShapeLocalToPageTransformSignal(id: ShapeId): Signal<Mat | undefined>;
396
398
  getShapeSelectedSignal(id: ShapeId): Signal<boolean>;
397
399
  getShapeRenderOrderSignal(id: ShapeId): Signal<number>;
398
400
  getShapeRenderVisibleSignal(id: ShapeId): Signal<boolean>;
399
401
  getShapeDocumentVisibleSignal(id: ShapeId): Signal<boolean>;
402
+ getShapeEffectiveOpacitySignal(id: ShapeId): Signal<number>;
400
403
  getShapeEditingSessionForShapeSignal(id: ShapeId): Signal<ShapeEditingSession | null>;
401
404
  getShapeDropTargetSignal(id: ShapeId): Signal<boolean>;
402
405
  getShapeHoveredSignal(id: ShapeId): Signal<boolean>;
403
- getShapeErasingSignal(id: ShapeId): Signal<boolean>;
404
406
  getShapeSelectedDescendantTransformAncestorSignal(id: ShapeId): Signal<boolean>;
405
407
  getBinding(id: BindingId): BindingRecord | undefined;
406
408
  getShapesForPage(pageId: PageId): ShapeRecord[];
@@ -420,6 +422,9 @@ export declare class Editor {
420
422
  getShapeIdsForSelectionTransform(shapeIds: Iterable<ShapeId>): ShapeId[];
421
423
  getShapeIdsForSelectionRotation(shapeIds: Iterable<ShapeId>): ShapeId[];
422
424
  getSelectionTransformTargetShapes(): ShapeRecord[];
425
+ canResizeSelection(): boolean;
426
+ canRotateSelection(): boolean;
427
+ getSelectionResizeTargetShapes(): ShapeRecord[];
423
428
  getSelectionRotationTargetShapes(): ShapeRecord[];
424
429
  getShapeExportTraversalIds(shapeIds: Iterable<ShapeId>): ShapeId[];
425
430
  getShapeContainment(containerId: ShapeId, shapeId: ShapeId): ShapeContainment | null;
@@ -434,7 +439,7 @@ export declare class Editor {
434
439
  canUseShapeParent(parentId: ShapeParentId, childId?: ShapeId): boolean;
435
440
  getShapeUtil<S extends ShapeRecord>(shape: S): ShapeUtil<S>;
436
441
  getBindingUtil<B extends BindingRecord>(binding: B): BindingUtil<B>;
437
- computeShapeBounds(shape: ShapeRecord): Box;
442
+ computeShapePositionedBounds(shape: ShapeRecord): Box;
438
443
  computeShapeLocalBounds(shape: ShapeRecord): Box;
439
444
  computeShapeRenderBounds(shape: ShapeRecord): Box;
440
445
  computeShapeExportBounds(shape: ShapeRecord): Box;
@@ -448,7 +453,7 @@ export declare class Editor {
448
453
  computeShapePageCenter(shape: ShapeRecord): Vec;
449
454
  computeShapePageCorners(shape: ShapeRecord): Vec[];
450
455
  computeShapePageOutlineVertices(shape: ShapeRecord): Vec[];
451
- getShapeBounds(shapeId: ShapeId): Box | null;
456
+ getShapePositionedBounds(shapeId: ShapeId): Box | null;
452
457
  getShapePageBounds(shapeId: ShapeId): Box | null;
453
458
  getShapeGeometry(shapeId: ShapeId): ShapeGeometry | null;
454
459
  getShapePositionedToPageTransform(shapeId: ShapeId): Mat | null;
@@ -463,16 +468,6 @@ export declare class Editor {
463
468
  getSelectionAnchorPagePoint(): Vec | null;
464
469
  hitTestSelectionHandle(point: Vec): SelectionHandle | null;
465
470
  setBrushBox(brushBox: Box | null): void;
466
- getErasingShapeIds(): ShapeId[];
467
- setErasingShapeIds(shapeIds: readonly ShapeId[]): void;
468
- clearErasingShapeIds(): void;
469
- getEraserTrail(): Vec[];
470
- setEraserTrail(points: readonly Vec[]): void;
471
- clearEraserTrail(): void;
472
- startLaserTrail(): number;
473
- setLaserTrail(sessionId: number, points: readonly Vec[]): void;
474
- finishLaserTrail(sessionId: number): void;
475
- clearLaserTrail(sessionId: number): void;
476
471
  setBindingPreview(preview: BindingPreviewState | null): void;
477
472
  setTerminalBindingGuides(guides: readonly TerminalBindingGuideState[] | null): void;
478
473
  setDropTargetShapeId(shapeId: ShapeId | null): void;
@@ -507,7 +502,9 @@ export declare class Editor {
507
502
  }): void;
508
503
  syncAfterDocumentRestore(): void;
509
504
  cancelInteractionForCommand(): void;
510
- cancelInteractionAndClearTransients(reason: CancelEditorEvent["reason"]): void;
505
+ cancelInteractionAndClearTransients(reason: CancelEditorEvent["reason"], options?: {
506
+ notifyInteractionHandlers?: boolean;
507
+ }): void;
511
508
  syncToolStateFromSession(source: ChangeSource): void;
512
509
  createShapeRecord(input: CreateShapeInput): ShapeRecord;
513
510
  createBindingRecord(input: CreateBindingInput): BindingRecord;
@@ -564,6 +561,7 @@ export declare class Editor {
564
561
  syncPageCounter(): void;
565
562
  syncBindingCounter(): void;
566
563
  syncAssetCounter(): void;
564
+ dispose(): void;
567
565
  private createPageId;
568
566
  private createPageIndex;
569
567
  private handleWheelEvent;
@@ -1,8 +1,10 @@
1
1
  import type { Box } from "../geometry/box";
2
2
  import type { Vec } from "../geometry/vec";
3
- import type { AssetId, PageId, ShapeId, ShapeRecord } from "../schema/records";
3
+ import type { AssetId, PageId, PageRecord, ShapeId, ShapeRecord } from "../schema/records";
4
4
  import type { BindingPreviewState } from "./selection";
5
- import type { EditorOverlayDebugState, EditorRenderHostDebugState, RenderItem } from "./editor";
5
+ import type { EditorOverlayDebugState, EditorRenderHostDebugState, EditorSelectionMetadata, RenderItem } from "./editor";
6
+ export declare function arePageRecordArraysEqual(a: readonly PageRecord[], b: readonly PageRecord[]): boolean;
7
+ export declare function areEditorSelectionMetadataEqual(a: EditorSelectionMetadata, b: EditorSelectionMetadata): boolean;
6
8
  export declare function areShapeIdArraysEqual(a: ShapeId[], b: ShapeId[]): boolean;
7
9
  export declare function areVecsEqual(a: Vec | null, b: Vec | null): boolean;
8
10
  export declare function areVecArraysEqual(a: readonly Vec[], b: readonly Vec[]): boolean;
@@ -1,18 +1,39 @@
1
+ import { type Signal } from "../../signals/index";
1
2
  import { type StoreHistoryEntry, type StoreHistoryState } from "../../store/index";
2
3
  import { type DocumentRecord } from "../schema/records";
3
4
  import type { Editor } from "./editor";
5
+ export interface HistoryScopeState {
6
+ canUndo: boolean;
7
+ canRedo: boolean;
8
+ undoDepth?: number;
9
+ redoDepth?: number;
10
+ }
11
+ export interface HistoryScope {
12
+ readonly id: string;
13
+ getState(): HistoryScopeState;
14
+ subscribe(listener: () => void): () => void;
15
+ undo(): boolean;
16
+ redo(): boolean;
17
+ }
4
18
  export type HistoryState = StoreHistoryState;
5
19
  export declare class HistoryManager {
6
20
  private readonly editor;
7
21
  private readonly buffer;
8
- readonly state: import("../../signals/index").Signal<StoreHistoryState>;
22
+ private readonly scopeActivations;
23
+ private readonly _state;
24
+ readonly state: Signal<HistoryState>;
9
25
  constructor(editor: Editor);
10
26
  clear(): void;
11
27
  mark(id: string): void;
12
28
  bailToMark(id: string): void;
13
29
  squashToMark(id: string, label?: string): void;
30
+ activateScope(scope: HistoryScope): () => void;
31
+ deactivateScope(scope: HistoryScope): boolean;
32
+ getActiveScope(): HistoryScope | null;
14
33
  undo(): boolean;
15
34
  redo(): boolean;
16
35
  getEntries(): readonly StoreHistoryEntry<DocumentRecord>[];
17
36
  private handleStoreChange;
37
+ private deactivateActivation;
38
+ private publishEffectiveState;
18
39
  }