@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.
- package/README.md +158 -102
- package/_vendor/canvas-core/bindings/bindingUtil.d.ts +8 -0
- package/_vendor/canvas-core/editor/cameraPanSession.d.ts +9 -0
- package/_vendor/canvas-core/editor/canvasPanInteraction.d.ts +2 -0
- package/_vendor/canvas-core/editor/commands.d.ts +15 -3
- package/_vendor/canvas-core/editor/createEditorWithPlugins.d.ts +6 -0
- package/_vendor/canvas-core/editor/editor.d.ts +24 -26
- package/_vendor/canvas-core/editor/editorComputedHelpers.d.ts +4 -2
- package/_vendor/canvas-core/editor/historyManager.d.ts +22 -1
- package/_vendor/canvas-core/editor/index.d.ts +2 -2
- package/_vendor/canvas-core/editor/interactions.d.ts +10 -1
- package/_vendor/canvas-core/editor/managers/bindingManager.d.ts +1 -0
- package/_vendor/canvas-core/editor/managers/inputsManager.d.ts +3 -0
- package/_vendor/canvas-core/editor/managers/interactionTransientManager.d.ts +0 -26
- package/_vendor/canvas-core/editor/managers/queryManager.d.ts +13 -1
- package/_vendor/canvas-core/editor/managers/selectionLayoutManager.d.ts +2 -0
- package/_vendor/canvas-core/editor/managers/shapeGeometryManager.d.ts +3 -2
- package/_vendor/canvas-core/editor/managers/shapeHierarchyManager.d.ts +6 -2
- package/_vendor/canvas-core/editor/managers/shapeReparenting.d.ts +3 -2
- package/_vendor/canvas-core/editor/managers/snapTypes.d.ts +1 -0
- package/_vendor/canvas-core/editor/managers/spatialIndexManager.d.ts +1 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.d.ts +32 -12
- package/_vendor/canvas-core/editor/selection.d.ts +19 -5
- package/_vendor/canvas-core/editor/selectionOverlay.d.ts +4 -3
- package/_vendor/canvas-core/editor/selectionResizeCapabilities.d.ts +9 -0
- package/_vendor/canvas-core/editor/shapeTransformSpace.d.ts +6 -0
- package/_vendor/canvas-core/exports/svg.d.ts +1 -0
- package/_vendor/canvas-core/geometry/index.d.ts +1 -0
- package/_vendor/canvas-core/geometry/mat.d.ts +6 -2
- package/_vendor/canvas-core/geometry/polygon.d.ts +7 -0
- package/_vendor/canvas-core/geometry/vec.d.ts +0 -2
- package/_vendor/canvas-core/index.d.ts +14 -20
- package/_vendor/canvas-core/plugins/editorRuntimePlugin.d.ts +4 -10
- package/_vendor/canvas-core/plugins/editorRuntimeRegistry.d.ts +19 -0
- package/_vendor/canvas-core/plugins/index.d.ts +2 -1
- package/_vendor/canvas-core/schema/records.d.ts +2 -7
- package/_vendor/canvas-core/schema/snapshots.d.ts +10 -19
- package/_vendor/canvas-core/shapes/colors.d.ts +1 -2
- package/_vendor/canvas-core/shapes/shapeUtil.d.ts +52 -14
- package/_vendor/canvas-core/tools/select/selectToolHelpers.d.ts +9 -6
- package/_vendor/canvas-core/tools/select/states/draggingSelectionHandleInteractionState.d.ts +3 -3
- package/_vendor/canvas-core/tools/select/states/pointingSelectionHandleInteractionState.d.ts +2 -1
- package/_vendor/canvas-plugin-sdk/actionRegistry.d.ts +7 -0
- package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/actions.d.ts +2 -4
- package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/contextMenu.d.ts +25 -30
- package/_vendor/canvas-plugin-sdk/contextMenuRegistry.d.ts +11 -0
- package/_vendor/canvas-plugin-sdk/index.d.ts +7 -0
- package/_vendor/canvas-plugin-sdk/plugin.d.ts +39 -0
- package/_vendor/{canvas-core/surfaces → canvas-plugin-sdk}/toolbar.d.ts +32 -1
- package/_vendor/canvas-plugin-sdk/toolbarRegistry.d.ts +19 -0
- package/_vendor/canvas-react/components/CanvasView.d.ts +2 -2
- package/_vendor/canvas-react/components/canvasKeyboardEvents.d.ts +13 -0
- package/_vendor/canvas-react/components/useCanvasDomEvents.d.ts +4 -3
- package/_vendor/canvas-react/contextMenuRequest.d.ts +19 -0
- package/_vendor/canvas-react/host/canvasRenderPlugin.d.ts +7 -1
- package/_vendor/canvas-react/host/canvasRenderRuntime.d.ts +13 -0
- package/_vendor/canvas-react/host/domEventGuards.d.ts +3 -3
- package/_vendor/canvas-react/host/index.d.ts +2 -8
- package/_vendor/canvas-react/host/overlayRegistry.d.ts +3 -3
- package/_vendor/canvas-react/host/rendererRegistry.d.ts +7 -4
- package/_vendor/canvas-react/index.d.ts +1 -0
- package/_vendor/plugin-arrow/arrowGeometry.d.ts +6 -4
- package/_vendor/plugin-arrow/arrowShapeUtil.d.ts +5 -3
- package/_vendor/plugin-arrow/arrowTerminalCommands.d.ts +2 -2
- package/_vendor/plugin-arrow/canvasRender.d.ts +2 -2
- package/_vendor/plugin-arrow/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-arrow/feature.d.ts +2 -3
- package/_vendor/plugin-arrow/index.d.ts +2 -2
- package/_vendor/plugin-draw/canvasRender.d.ts +2 -2
- package/_vendor/plugin-draw/drawGeometry.d.ts +4 -7
- package/_vendor/plugin-draw/drawShapeUtil.d.ts +2 -2
- package/_vendor/plugin-draw/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-draw/feature.d.ts +2 -3
- package/_vendor/plugin-draw/index.d.ts +3 -3
- package/_vendor/plugin-eraser/canvasRender.d.ts +2 -2
- package/_vendor/plugin-eraser/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-eraser/eraserRuntime.d.ts +12 -0
- package/_vendor/plugin-eraser/feature.d.ts +2 -3
- package/_vendor/plugin-eraser/index.d.ts +3 -2
- package/_vendor/plugin-frame/canvasRender.d.ts +2 -2
- package/_vendor/plugin-frame/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-frame/feature.d.ts +2 -3
- package/_vendor/plugin-frame/frameShapeUtil.d.ts +4 -2
- package/_vendor/plugin-frame/index.d.ts +2 -2
- package/_vendor/plugin-geo/canvasRender.d.ts +2 -2
- package/_vendor/plugin-geo/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-geo/feature.d.ts +2 -3
- package/_vendor/plugin-geo/geoShapeUtil.d.ts +1 -1
- package/_vendor/plugin-geo/index.d.ts +2 -2
- package/_vendor/plugin-group/canvasRender.d.ts +2 -2
- package/_vendor/plugin-group/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-group/feature.d.ts +2 -3
- package/_vendor/plugin-group/groupContributions.d.ts +7 -0
- package/_vendor/plugin-group/groupShapeUtil.d.ts +24 -5
- package/_vendor/plugin-group/index.d.ts +3 -2
- package/_vendor/plugin-image/canvasRender.d.ts +2 -2
- package/_vendor/plugin-image/cropRuntime.d.ts +1 -1
- package/_vendor/plugin-image/cropSession.d.ts +5 -3
- package/_vendor/plugin-image/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-image/feature.d.ts +2 -3
- package/_vendor/plugin-image/imageHostActionContract.d.ts +1 -1
- package/_vendor/plugin-image/imageShapeUtil.d.ts +3 -3
- package/_vendor/plugin-image/index.d.ts +4 -4
- package/_vendor/plugin-image/runtimeShared.d.ts +1 -1
- package/_vendor/plugin-image/smudge.d.ts +13 -2
- package/_vendor/plugin-image/smudgeRuntime.d.ts +1 -1
- package/_vendor/plugin-image/styleRuntime.d.ts +1 -1
- package/_vendor/plugin-image/toolbarRuntime.d.ts +1 -1
- package/_vendor/plugin-laser/canvasRender.d.ts +2 -2
- package/_vendor/plugin-laser/editorRuntime.d.ts +4 -2
- package/_vendor/plugin-laser/feature.d.ts +2 -3
- package/_vendor/plugin-laser/index.d.ts +3 -2
- package/_vendor/plugin-laser/laserRuntime.d.ts +18 -0
- package/_vendor/plugin-packaging/canvasRender.d.ts +2 -0
- package/_vendor/plugin-packaging/editorRuntime.d.ts +2 -0
- package/_vendor/plugin-packaging/feature.d.ts +2 -0
- package/_vendor/plugin-packaging/index.d.ts +17 -0
- package/_vendor/plugin-packaging/packagingArtwork.d.ts +5 -0
- package/_vendor/plugin-packaging/packagingDxf.d.ts +9 -0
- package/_vendor/plugin-packaging/packagingGeometry.d.ts +74 -0
- package/_vendor/plugin-packaging/packagingInteractions.d.ts +2 -0
- package/_vendor/plugin-packaging/packagingPdfExporter.d.ts +25 -0
- package/_vendor/plugin-packaging/packagingRuntime.d.ts +11 -0
- package/_vendor/plugin-packaging/packagingShapeUtil.d.ts +34 -0
- package/_vendor/plugin-packaging/packagingStyle.d.ts +10 -0
- package/_vendor/plugin-packaging/packagingSvgExporter.d.ts +7 -0
- package/_vendor/plugin-packaging/productRuntime.d.ts +2 -0
- package/_vendor/plugin-packaging/types.d.ts +168 -0
- package/_vendor/plugin-packaging/validation.d.ts +3 -0
- package/_vendor/plugin-path/PathDraftOverlay.d.ts +1 -0
- package/_vendor/plugin-path/PathEditInsertPreviewOverlay.d.ts +1 -0
- package/_vendor/plugin-path/PathShapeRenderer.d.ts +12 -0
- package/_vendor/plugin-path/canvasRender.d.ts +2 -0
- package/_vendor/plugin-path/editorRuntime.d.ts +21 -0
- package/_vendor/plugin-path/feature.d.ts +2 -0
- package/_vendor/plugin-path/index.d.ts +7 -0
- package/_vendor/plugin-path/pathBoolean.d.ts +13 -0
- package/_vendor/plugin-path/pathDraft.d.ts +10 -0
- package/_vendor/plugin-path/pathEditPreview.d.ts +11 -0
- package/_vendor/plugin-path/pathEditSelection.d.ts +24 -0
- package/_vendor/plugin-path/pathEditSnap.d.ts +6 -0
- package/_vendor/plugin-path/pathGeometry.d.ts +74 -0
- package/_vendor/plugin-path/pathHandles.d.ts +18 -0
- package/_vendor/plugin-path/pathInteractions.d.ts +7 -0
- package/_vendor/plugin-path/pathShapeUtil.d.ts +28 -0
- package/_vendor/plugin-path/pathSvg.d.ts +3 -0
- package/_vendor/plugin-path/pathTool.d.ts +39 -0
- package/_vendor/plugin-path/types.d.ts +36 -0
- package/_vendor/plugin-text/arrowLabelBindingUtil.d.ts +6 -1
- package/_vendor/plugin-text/canvasRender.d.ts +6 -3
- package/_vendor/plugin-text/editorRuntime.d.ts +9 -3
- package/_vendor/plugin-text/feature.d.ts +4 -4
- package/_vendor/plugin-text/geoLabelBindingUtil.d.ts +6 -1
- package/_vendor/plugin-text/host/RichTextEditingBox.d.ts +4 -1
- package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +5 -2
- package/_vendor/plugin-text/host/richTextRendering.d.ts +0 -1
- package/_vendor/plugin-text/host/textFormattingApi.d.ts +16 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +3 -1
- package/_vendor/plugin-text/host/tiptapTextEditorController.d.ts +4 -1
- package/_vendor/plugin-text/index.d.ts +7 -4
- package/_vendor/plugin-text/richTextUtils.d.ts +6 -0
- package/_vendor/plugin-text/shapeWideTextFormatting.d.ts +8 -0
- package/_vendor/plugin-text/textFonts.d.ts +6 -3
- package/_vendor/plugin-text/textFormatting.d.ts +45 -0
- package/_vendor/plugin-text/textFormattingSession.d.ts +6 -0
- package/_vendor/plugin-text/textLabelHelpers.d.ts +9 -4
- package/_vendor/plugin-text/textLinkPopoverPresentation.d.ts +18 -0
- package/_vendor/plugin-text/textShapeHelpers.d.ts +1 -0
- package/_vendor/plugin-text/textShapeUtil.d.ts +5 -4
- package/_vendor/signals/effect.d.ts +0 -4
- package/_vendor/signals/index.d.ts +1 -1
- package/_vendor/store/store.d.ts +4 -0
- package/browser/persistence.d.ts +5 -16
- package/builtins/controller/createBuiltInCanvasController.d.ts +2 -0
- package/builtins/controller/packagingController.d.ts +71 -0
- package/builtins/index.d.ts +4 -2
- package/builtins/plugins.d.ts +16 -0
- package/chrome/floating/CanvasKitFloatingPortal.d.ts +6 -0
- package/chrome/floating/useCanvasKitFloatingPosition.d.ts +11 -0
- package/chrome/toolbar/CanvasKitFloatingToolbarLayer.d.ts +1 -1
- package/chrome/toolbar/toolbarLabels.d.ts +1 -1
- package/chrome/toolbar/useToolbarSurfaces.d.ts +6 -10
- package/chrome/types.d.ts +5 -10
- package/chrome/useCanvasKitChromeContext.d.ts +13 -13
- package/chrome/useContextMenuSurface.d.ts +4 -4
- package/chrome/useHistoryControls.d.ts +3 -3
- package/chrome/usePageControls.d.ts +3 -3
- package/controller/canvasKitController.d.ts +5 -9
- package/core/index.d.ts +1 -2
- package/core/product-controller/canvasProductController.d.ts +2 -1
- package/core/runtime/productAssets.d.ts +4 -2
- package/core/runtime/productEditor.d.ts +1 -1
- package/core/runtime/productServices.d.ts +6 -2
- package/core/runtime/runtimeContracts.d.ts +17 -0
- package/es-DocrZgUh.mjs +2 -0
- package/features/actions/actionRuntime.d.ts +2 -7
- package/features/clipboard/clipboardContextMenuContributions.d.ts +1 -1
- package/features/clipboard/clipboardContribution.d.ts +2 -1
- package/features/clipboard/clipboardPlugin.d.ts +1 -0
- package/features/clipboard/clipboardService.d.ts +1 -1
- package/features/context-menu/contextMenuRuntime.d.ts +4 -4
- package/features/image/asset/imageAssetService.d.ts +1 -1
- package/features/image/asset/imageBlobStore.d.ts +6 -2
- package/features/image/controller/imageProductController.d.ts +1 -1
- package/features/image/imageProductPlugin.d.ts +1 -0
- package/features/image/smudge/imageSmudgeHostActions.d.ts +1 -1
- package/features/image/smudge/imageSmudgeTypes.d.ts +1 -0
- package/features/image/toolbar/imageHostActions.d.ts +13 -2
- package/features/image/toolbar/imageToolbarHostBridge.d.ts +1 -1
- package/features/keyboard/keyboardShortcutPlugin.d.ts +1 -0
- package/features/keyboard/useCanvasKitKeyboardShortcuts.d.ts +5 -3
- package/features/selection/selectionActions.d.ts +2 -3
- package/features/selection/selectionContextMenuContributions.d.ts +1 -1
- package/features/selection/selectionPlugin.d.ts +1 -0
- package/features/selection/selectionToolbarContributions.d.ts +1 -1
- package/features/text/link/TextLinkHoverPopover.d.ts +6 -0
- package/features/text/textProductPlugin.d.ts +5 -0
- package/features/tool/toolActions.d.ts +1 -1
- package/features/tool/toolContextMenuContributions.d.ts +1 -1
- package/features/tool/toolPlugin.d.ts +1 -0
- package/features/tool/toolToolbarContributions.d.ts +1 -1
- package/features/view/viewActions.d.ts +1 -1
- package/features/view/viewContextMenuContributions.d.ts +1 -1
- package/features/view/viewPlugin.d.ts +1 -0
- package/index.css +1 -1
- package/index.d.ts +23 -9
- package/index.mjs +84 -96
- package/package.json +12 -9
- package/product/standardCanvasKitPlugins.d.ts +4 -0
- package/react/CanvasKitRoot.d.ts +10 -5
- package/react/useCanvasKitControllerLifecycle.d.ts +8 -0
- package/react/useCanvasKitRuntime.d.ts +2 -4
- package/runtime/canvasKitCommandExecutor.d.ts +13 -0
- package/runtime/canvasKitPluginContracts.d.ts +79 -0
- package/runtime/canvasKitPlugins.d.ts +33 -0
- package/runtime/canvasKitRuntime.d.ts +46 -19
- package/runtime/canvasKitRuntimeContracts.d.ts +37 -0
- package/_vendor/canvas-core/editor/createEditorWithRuntimePlugins.d.ts +0 -6
- package/_vendor/canvas-core/editor/middleMousePanInteraction.d.ts +0 -2
- package/_vendor/canvas-core/schema/snapshotSupport.d.ts +0 -43
- package/_vendor/canvas-react/host/actionRegistry.d.ts +0 -15
- package/_vendor/canvas-react/host/canvasRenderPluginHost.d.ts +0 -2
- package/_vendor/canvas-react/host/canvasRenderPluginHostManifest.d.ts +0 -2
- package/_vendor/canvas-react/host/canvasRenderPluginHostRuntime.d.ts +0 -3
- package/_vendor/canvas-react/host/canvasRenderPluginHostTypes.d.ts +0 -104
- package/_vendor/canvas-react/host/canvasRenderPluginHostValidation.d.ts +0 -11
- package/_vendor/canvas-react/host/contextMenuRegistry.d.ts +0 -17
- package/_vendor/canvas-react/host/extension.d.ts +0 -37
- package/_vendor/canvas-react/host/toolbarRegistry.d.ts +0 -20
- package/_vendor/plugin-text/host/RichTextLinkPopover.d.ts +0 -14
- package/_vendor/plugin-text/host/RichTextToolbar.d.ts +0 -8
- package/_vendor/plugin-text/host/richTextBubbleMenuPositionSync.d.ts +0 -7
- package/browser/localSnapshotRestore.d.ts +0 -13
- package/builtins/extensions.d.ts +0 -18
- package/core/runtime/productDefinition.d.ts +0 -33
- package/core/runtime/productHost.d.ts +0 -20
- package/features/clipboard/clipboardHostExtension.d.ts +0 -2
- package/features/image/imageHostExtension.d.ts +0 -10
- package/features/keyboard/keyboardShortcutHostExtension.d.ts +0 -2
- package/features/persistence/CanvasKitPersistenceNotice.d.ts +0 -4
- package/features/persistence/persistenceHostExtension.d.ts +0 -2
- package/features/selection/selectionHostExtension.d.ts +0 -2
- package/features/tool/toolHostExtension.d.ts +0 -2
- package/features/view/viewHostExtension.d.ts +0 -2
- package/host/defaultHostExtensions.d.ts +0 -2
- package/product/canvasKitProduct.d.ts +0 -51
- package/react/useCanvasKitController.d.ts +0 -5
- package/react/useCanvasKitStartup.d.ts +0 -9
- package/runtime/canvasKitHostContracts.d.ts +0 -135
- package/runtime/canvasKitHostFeatureHooks.d.ts +0 -12
- package/runtime/canvasKitRuntimePlan.d.ts +0 -50
package/README.md
CHANGED
|
@@ -1,151 +1,207 @@
|
|
|
1
1
|
# @land/canvas-kit
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## React usage
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
12
|
+
useCanvasKitRuntime,
|
|
13
|
+
type CanvasKitRuntimeOptions,
|
|
18
14
|
} from "@land/canvas-kit";
|
|
19
|
-
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
<CanvasKitRoot
|
|
29
|
+
runtime={state.runtime}
|
|
30
|
+
onControllerReady={(controller) => {
|
|
31
|
+
controller.setTool("select");
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
36
34
|
);
|
|
37
35
|
}
|
|
38
36
|
```
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
Use a module-level constant or `useMemo` for `CanvasKitRuntimeOptions`. An inline object creates and disposes a Runtime after every render.
|
|
41
39
|
|
|
42
|
-
##
|
|
40
|
+
## Imperative usage
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
The creator owns the complete lifecycle:
|
|
45
43
|
|
|
46
44
|
```tsx
|
|
47
|
-
import {
|
|
45
|
+
import { createRoot } from "react-dom/client";
|
|
48
46
|
import {
|
|
49
47
|
CanvasKitRoot,
|
|
50
|
-
|
|
51
|
-
type CanvasKitController,
|
|
52
|
-
type CanvasKitChromeContext,
|
|
48
|
+
createCanvasKitRuntime,
|
|
53
49
|
} from "@land/canvas-kit";
|
|
54
|
-
import "@land/canvas-kit/style.css";
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
79
|
+
Controller callbacks, window exposure, and `windowKey` are mount concerns and belong on `CanvasKitRoot`.
|
|
102
80
|
|
|
103
|
-
|
|
81
|
+
## Startup result
|
|
104
82
|
|
|
105
|
-
|
|
83
|
+
`runtime.start()` is single-flight and idempotent. It returns:
|
|
106
84
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
```ts
|
|
86
|
+
interface CanvasKitStartupResult {
|
|
87
|
+
documentSource: "restored" | "seeded" | "empty";
|
|
88
|
+
sessionRestored: boolean;
|
|
89
|
+
warnings: readonly unknown[];
|
|
90
|
+
}
|
|
91
|
+
```
|
|
114
92
|
|
|
115
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
114
|
+
When no document snapshot exists, `seedDocument` runs once. Session restore happens after seed so persisted camera and selection state win.
|
|
131
115
|
|
|
132
|
-
|
|
116
|
+
## Plugin authoring
|
|
133
117
|
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
173
|
+
Packaging is intentionally outside the standard plugin profile. Products that
|
|
174
|
+
need it add the public plugin explicitly:
|
|
142
175
|
|
|
143
|
-
```
|
|
144
|
-
|
|
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
|
|
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
|
-
|
|
150
|
-
|
|
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;
|
|
@@ -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?:
|
|
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?:
|
|
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):
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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"]
|
|
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
|
|
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
|
}
|