@yuzhouu/canvas-kit 0.1.10 → 0.1.12
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 +95 -40
- package/_vendor/canvas-core/bindings/bindingUtil.d.ts +15 -0
- package/_vendor/canvas-core/bindings/terminalPorts.d.ts +67 -0
- package/_vendor/canvas-core/editor/bindingReactionScope.d.ts +7 -0
- package/_vendor/canvas-core/editor/commands.d.ts +3 -3
- package/_vendor/canvas-core/editor/editor.d.ts +20 -5
- package/_vendor/canvas-core/editor/editorComputedHelpers.d.ts +1 -0
- package/_vendor/canvas-core/editor/historyManager.d.ts +2 -5
- package/_vendor/canvas-core/editor/interactions.d.ts +33 -9
- package/_vendor/canvas-core/editor/managers/bindingManager.d.ts +1 -6
- package/_vendor/canvas-core/editor/managers/queryManager.d.ts +13 -0
- package/_vendor/canvas-core/editor/managers/selectionLayoutManager.d.ts +3 -0
- package/_vendor/canvas-core/editor/managers/selectionOverlayManager.d.ts +1 -0
- package/_vendor/canvas-core/editor/managers/shapeEditingManager.d.ts +4 -0
- package/_vendor/canvas-core/editor/managers/shapeHierarchyManager.d.ts +1 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.d.ts +4 -1
- package/_vendor/canvas-core/editor/managers/snapGeometry.d.ts +2 -1
- package/_vendor/canvas-core/editor/operationManager.d.ts +74 -0
- package/_vendor/canvas-core/editor/selectionOverlay.d.ts +3 -1
- package/_vendor/canvas-core/exports/svg.d.ts +2 -3
- package/_vendor/canvas-core/geometry/contentCutout.d.ts +8 -0
- package/_vendor/canvas-core/index.d.ts +9 -5
- package/_vendor/canvas-core/shapes/colors.d.ts +2 -1
- package/_vendor/canvas-core/shapes/shapeUtil.d.ts +47 -1
- package/_vendor/canvas-core/tools/select/selectToolHelpers.d.ts +9 -2
- package/_vendor/canvas-core/tools/select/states/{draggingSelectionHandleInteractionState.d.ts → draggingPluginInteractionState.d.ts} +5 -4
- package/_vendor/canvas-core/tools/select/states/index.d.ts +1 -1
- package/_vendor/canvas-core/tools/select/states/pointingSelectionHandleInteractionState.d.ts +2 -2
- package/_vendor/canvas-core/tools/select/states/pointingShapeState.d.ts +1 -1
- package/_vendor/canvas-core/tools/select/states/resizingState.d.ts +1 -1
- package/_vendor/canvas-core/tools/select/states/rotatingState.d.ts +1 -1
- package/_vendor/canvas-core/tools/select/states/selectStateNode.d.ts +6 -2
- package/_vendor/canvas-core/tools/select/states/translatingState.d.ts +1 -1
- package/_vendor/canvas-plugin-sdk/capability.d.ts +10 -0
- package/_vendor/canvas-plugin-sdk/index.d.ts +2 -6
- package/_vendor/canvas-plugin-sdk/plugin.d.ts +18 -28
- package/_vendor/canvas-plugin-sdk/setupExtension.d.ts +5 -0
- package/_vendor/canvas-product-contracts/actionRegistry.d.ts +4 -0
- package/_vendor/{canvas-plugin-sdk → canvas-product-contracts}/actions.d.ts +14 -3
- package/_vendor/canvas-product-contracts/capability.d.ts +8 -0
- package/_vendor/canvas-product-contracts/chrome.d.ts +53 -0
- package/_vendor/canvas-product-contracts/chromeRegistry.d.ts +9 -0
- package/_vendor/{canvas-plugin-sdk → canvas-product-contracts}/contextMenu.d.ts +4 -0
- package/_vendor/canvas-product-contracts/contextMenuRegistry.d.ts +4 -0
- package/_vendor/canvas-product-contracts/exportRegistry.d.ts +6 -0
- package/_vendor/canvas-product-contracts/exports.d.ts +27 -0
- package/_vendor/canvas-product-contracts/importRegistry.d.ts +7 -0
- package/_vendor/canvas-product-contracts/imports.d.ts +39 -0
- package/_vendor/canvas-product-contracts/index.d.ts +15 -0
- package/_vendor/canvas-product-contracts/productApi.d.ts +29 -0
- package/_vendor/canvas-product-contracts/services.d.ts +21 -0
- package/_vendor/{canvas-plugin-sdk → canvas-product-contracts}/toolbar.d.ts +23 -4
- package/_vendor/canvas-product-contracts/toolbarRegistry.d.ts +9 -0
- package/_vendor/canvas-react/host/canvasRenderPlugin.d.ts +15 -4
- package/_vendor/canvas-react/host/index.d.ts +2 -2
- package/_vendor/plugin-arrow/api.d.ts +33 -0
- package/_vendor/plugin-arrow/arrowGeometry.d.ts +2 -1
- package/_vendor/plugin-arrow/arrowHeadGeometry.d.ts +8 -0
- package/_vendor/plugin-arrow/arrowShapeUtil.d.ts +2 -1
- package/_vendor/plugin-arrow/editorRuntime.d.ts +0 -2
- package/_vendor/plugin-arrow/feature.d.ts +2 -2
- package/_vendor/plugin-arrow/index.d.ts +4 -1
- package/_vendor/plugin-arrow/productRuntime.d.ts +2 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.d.ts +5 -2
- package/_vendor/plugin-draw/drawPath.d.ts +7 -1
- package/_vendor/plugin-draw/editorRuntime.d.ts +1 -3
- package/_vendor/plugin-draw/feature.d.ts +2 -2
- package/_vendor/plugin-draw/index.d.ts +2 -1
- package/_vendor/plugin-draw/productRuntime.d.ts +2 -0
- package/_vendor/plugin-eraser/editorRuntime.d.ts +1 -3
- package/_vendor/plugin-eraser/feature.d.ts +2 -2
- package/_vendor/plugin-eraser/index.d.ts +2 -1
- package/_vendor/plugin-eraser/productRuntime.d.ts +2 -0
- package/_vendor/plugin-frame/api.d.ts +19 -0
- package/_vendor/plugin-frame/canvasRender.d.ts +3 -3
- package/_vendor/plugin-frame/editorRuntime.d.ts +0 -2
- package/_vendor/plugin-frame/feature.d.ts +2 -2
- package/_vendor/plugin-frame/frameShapeUtil.d.ts +8 -0
- package/_vendor/plugin-frame/index.d.ts +4 -1
- package/_vendor/plugin-frame/productRuntime.d.ts +2 -0
- package/_vendor/plugin-geo/api.d.ts +27 -0
- package/_vendor/plugin-geo/canvasRender.d.ts +3 -3
- package/_vendor/plugin-geo/editorRuntime.d.ts +1 -3
- package/_vendor/plugin-geo/feature.d.ts +2 -2
- package/_vendor/plugin-geo/geoStrokeStyle.d.ts +2 -0
- package/_vendor/plugin-geo/geoTools.d.ts +1 -1
- package/_vendor/plugin-geo/index.d.ts +7 -4
- package/_vendor/plugin-geo/productRuntime.d.ts +2 -0
- package/_vendor/plugin-geo/types.d.ts +5 -1
- package/_vendor/plugin-group/canvasRender.d.ts +1 -2
- package/_vendor/plugin-group/editorRuntime.d.ts +0 -2
- package/_vendor/plugin-group/feature.d.ts +2 -2
- package/_vendor/plugin-group/groupContributions.d.ts +1 -1
- package/_vendor/plugin-group/index.d.ts +2 -1
- package/_vendor/plugin-group/productRuntime.d.ts +2 -0
- package/_vendor/plugin-image/cropRuntime.d.ts +1 -1
- package/_vendor/plugin-image/editorRuntime.d.ts +0 -4
- package/_vendor/plugin-image/feature.d.ts +2 -2
- package/_vendor/plugin-image/imageHostActionContract.d.ts +1 -1
- package/_vendor/plugin-image/index.d.ts +2 -1
- package/_vendor/plugin-image/productRuntime.d.ts +4 -0
- package/_vendor/plugin-image/runtimeShared.d.ts +1 -1
- package/_vendor/plugin-image/smudgeRuntime.d.ts +1 -1
- package/_vendor/plugin-image/styleRuntime.d.ts +6 -1
- package/_vendor/plugin-image/toolbarRuntime.d.ts +1 -1
- package/_vendor/plugin-laser/editorRuntime.d.ts +1 -3
- package/_vendor/plugin-laser/feature.d.ts +2 -2
- package/_vendor/plugin-laser/index.d.ts +2 -1
- package/_vendor/plugin-laser/productRuntime.d.ts +2 -0
- package/_vendor/plugin-path/PathShapeRenderer.d.ts +5 -2
- package/_vendor/plugin-path/editorRuntime.d.ts +1 -15
- package/_vendor/plugin-path/feature.d.ts +2 -2
- package/_vendor/plugin-path/index.d.ts +2 -1
- package/_vendor/plugin-path/pathHistory.d.ts +13 -0
- package/_vendor/plugin-path/pathShapeUtil.d.ts +3 -1
- package/_vendor/plugin-path/pathTool.d.ts +3 -0
- package/_vendor/plugin-path/productRuntime.d.ts +15 -0
- package/_vendor/plugin-runtime-clipboard/capability.d.ts +1 -0
- package/{features/clipboard/clipboardContribution.d.ts → _vendor/plugin-runtime-clipboard/clipboardActions.d.ts} +1 -7
- package/{features/clipboard → _vendor/plugin-runtime-clipboard}/clipboardService.d.ts +3 -3
- package/_vendor/plugin-runtime-clipboard/index.d.ts +4 -0
- package/_vendor/plugin-runtime-clipboard/plugin.d.ts +1 -0
- package/_vendor/plugin-runtime-export/blobDataUrl.d.ts +1 -0
- package/_vendor/plugin-runtime-export/canvasExportApi.d.ts +43 -0
- package/_vendor/plugin-runtime-export/index.d.ts +8 -0
- package/_vendor/plugin-runtime-export/plugin.d.ts +5 -0
- package/_vendor/plugin-runtime-export/pngExport.d.ts +15 -0
- package/{features/export → _vendor/plugin-runtime-export}/svgExport.d.ts +9 -2
- package/_vendor/plugin-text/api.d.ts +20 -0
- package/_vendor/plugin-text/capabilities.d.ts +2 -0
- package/_vendor/plugin-text/editorRuntime.d.ts +2 -8
- package/_vendor/plugin-text/feature.d.ts +1 -1
- package/_vendor/plugin-text/geoLabelBindingUtil.d.ts +0 -2
- package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +1 -1
- package/_vendor/plugin-text/host/initialTextBackground.d.ts +2 -0
- package/_vendor/plugin-text/host/richTextRendering.d.ts +1 -1
- package/_vendor/plugin-text/host/textEditingBoxStyle.d.ts +1 -1
- package/_vendor/plugin-text/host/textEntryFocus.d.ts +2 -1
- package/_vendor/plugin-text/host/textMeasurement.d.ts +10 -2
- package/_vendor/plugin-text/index.d.ts +7 -3
- package/_vendor/plugin-text/pathLabelBindingUtil.d.ts +55 -0
- package/_vendor/plugin-text/productRuntime.d.ts +6 -0
- package/_vendor/plugin-text/richTextUtils.d.ts +3 -2
- package/_vendor/plugin-text/shapeWideTextFormatting.d.ts +4 -0
- package/_vendor/plugin-text/textFormatting.d.ts +2 -0
- package/_vendor/plugin-text/textLabelHelpers.d.ts +23 -2
- package/_vendor/plugin-text/textShapeUtil.d.ts +5 -2
- package/_vendor/plugin-text/textTypes.d.ts +1 -0
- package/_vendor/signals/core.d.ts +1 -0
- package/_vendor/signals/index.d.ts +1 -1
- package/_vendor/store/history.d.ts +1 -1
- package/_vendor/store/store.d.ts +2 -0
- package/browser/indexedDb.d.ts +10 -10
- package/browser/persistence.d.ts +4 -25
- package/chrome/floating/useCanvasKitFloatingPosition.d.ts +1 -1
- package/chrome/toolbar/FloatingSelectionToolbarPageSpace.d.ts +5 -3
- package/chrome/toolbar/mergeToolbarGroups.d.ts +8 -0
- package/chrome/toolbar/toolbarLabels.d.ts +1 -1
- package/chrome/toolbar/useToolbarSurfaces.d.ts +9 -10
- package/chrome/types.d.ts +12 -9
- package/chrome/useCanvasKitChromeContext.d.ts +4 -7
- package/chrome/useChromeSurfaces.d.ts +12 -0
- package/chrome/useContextMenuSurface.d.ts +1 -1
- package/controller/canvasKitController.d.ts +4 -11
- package/core/index.d.ts +3 -4
- package/core/product-controller/canvasProductController.d.ts +40 -11
- package/core/product-controller/index.d.ts +1 -1
- package/core/runtime/productServices.d.ts +5 -19
- package/core/runtime/runtimeContracts.d.ts +3 -3
- package/features/context-menu/contextMenuRuntime.d.ts +1 -1
- package/features/image/asset/imageAssetService.d.ts +2 -3
- package/features/image/asset/imageBlobStore.d.ts +1 -0
- package/features/image/asset/imageFileHelpers.d.ts +0 -6
- package/features/image/asset/svgImageAssetInliner.d.ts +1 -1
- package/features/image/controller/imageProductController.d.ts +2 -2
- package/features/image/imageHostPlugin.d.ts +1 -0
- package/features/image/import/ImageImportController.d.ts +3 -1
- package/features/image/index.d.ts +1 -3
- package/features/image/smudge/imageSmudgeHostActions.d.ts +1 -1
- package/features/image/toolbar/imageHostActions.d.ts +8 -9
- package/features/image/toolbar/imageToolbarHostBridge.d.ts +1 -1
- package/features/text/{textProductPlugin.d.ts → textHostPlugin.d.ts} +1 -1
- package/features/text/textSvgAssetInliner.d.ts +3 -0
- package/features/text/textSvgAssetPlugin.d.ts +2 -0
- package/index.css +1 -1
- package/index.d.ts +31 -19
- package/index.mjs +88 -84
- package/package.json +2 -2
- package/plugins/runtime/import-host/CanvasImportHost.d.ts +4 -0
- package/plugins/runtime/import-host/capability.d.ts +1 -0
- package/plugins/runtime/import-host/index.d.ts +2 -0
- package/plugins/runtime/import-host/plugin.d.ts +1 -0
- package/plugins/runtime/keyboard-shortcuts/index.d.ts +1 -0
- package/plugins/runtime/keyboard-shortcuts/plugin.d.ts +1 -0
- package/plugins/runtime/keyboard-shortcuts/useCanvasKeyboardShortcuts.d.ts +8 -0
- package/plugins/runtime/tool-actions/capability.d.ts +1 -0
- package/plugins/runtime/tool-actions/index.d.ts +2 -0
- package/plugins/runtime/tool-actions/plugin.d.ts +1 -0
- package/plugins/runtime/tool-actions/toolActions.d.ts +2 -0
- package/plugins/standard/clipboard/chrome.d.ts +2 -0
- package/plugins/standard/clipboard/contextMenu.d.ts +2 -0
- package/plugins/standard/clipboard/plugin.d.ts +1 -0
- package/plugins/standard/clipboard/shortcuts.d.ts +5 -0
- package/plugins/standard/createStandardCanvasKitPlugins.d.ts +15 -0
- package/{features/selection/selectionActions.d.ts → plugins/standard/selection/actions.d.ts} +4 -2
- package/plugins/standard/selection/chrome.d.ts +2 -0
- package/plugins/standard/selection/contextMenu.d.ts +2 -0
- package/plugins/standard/selection/plugin.d.ts +1 -0
- package/plugins/standard/selection/toolbar.d.ts +2 -0
- package/plugins/standard/tool-ui/contextMenu.d.ts +2 -0
- package/plugins/standard/tool-ui/plugin.d.ts +1 -0
- package/plugins/standard/tool-ui/toolbar.d.ts +2 -0
- package/{features/view/viewActions.d.ts → plugins/standard/view/actions.d.ts} +1 -1
- package/plugins/standard/view/chrome.d.ts +2 -0
- package/plugins/standard/view/contextMenu.d.ts +2 -0
- package/plugins/standard/view/plugin.d.ts +1 -0
- package/{features/actions/actionRuntime.d.ts → runtime/canvasKitActionContext.d.ts} +3 -2
- package/runtime/canvasKitCommandExecutor.d.ts +1 -1
- package/runtime/canvasKitPluginContracts.d.ts +29 -76
- package/runtime/canvasKitPluginLifecycle.d.ts +32 -0
- package/runtime/canvasKitPluginSetup.d.ts +34 -0
- package/runtime/canvasKitPluginUi.d.ts +35 -0
- package/runtime/canvasKitResourceScope.d.ts +5 -0
- package/runtime/canvasKitRuntime.d.ts +9 -7
- package/runtime/canvasKitRuntimeContracts.d.ts +2 -5
- package/runtime/canvasPluginGraph.d.ts +15 -0
- package/runtime/persistenceCoordinator.d.ts +33 -0
- package/runtime/registries/actionRegistry.d.ts +5 -0
- package/runtime/registries/chromeRegistry.d.ts +2 -0
- package/runtime/registries/contextMenuRegistry.d.ts +5 -0
- package/runtime/registries/exportRegistry.d.ts +2 -0
- package/runtime/registries/importRegistry.d.ts +2 -0
- package/runtime/registries/index.d.ts +7 -0
- package/runtime/registries/productApiRegistry.d.ts +5 -0
- package/runtime/registries/toolbarRegistry.d.ts +5 -0
- package/_vendor/canvas-plugin-sdk/actionRegistry.d.ts +0 -7
- package/_vendor/canvas-plugin-sdk/contextMenuRegistry.d.ts +0 -11
- package/_vendor/canvas-plugin-sdk/toolbarRegistry.d.ts +0 -19
- package/_vendor/plugin-packaging/canvasRender.d.ts +0 -2
- package/_vendor/plugin-packaging/editorRuntime.d.ts +0 -2
- package/_vendor/plugin-packaging/feature.d.ts +0 -2
- package/_vendor/plugin-packaging/index.d.ts +0 -17
- package/_vendor/plugin-packaging/packagingArtwork.d.ts +0 -5
- package/_vendor/plugin-packaging/packagingDxf.d.ts +0 -9
- package/_vendor/plugin-packaging/packagingGeometry.d.ts +0 -74
- package/_vendor/plugin-packaging/packagingInteractions.d.ts +0 -2
- package/_vendor/plugin-packaging/packagingPdfExporter.d.ts +0 -25
- package/_vendor/plugin-packaging/packagingRuntime.d.ts +0 -11
- package/_vendor/plugin-packaging/packagingShapeUtil.d.ts +0 -34
- package/_vendor/plugin-packaging/packagingStyle.d.ts +0 -10
- package/_vendor/plugin-packaging/packagingSvgExporter.d.ts +0 -7
- package/_vendor/plugin-packaging/productRuntime.d.ts +0 -2
- package/_vendor/plugin-packaging/types.d.ts +0 -168
- package/_vendor/plugin-packaging/validation.d.ts +0 -3
- package/_vendor/plugin-text/arrowLabelBindingUtil.d.ts +0 -47
- package/builtins/controller/createBuiltInCanvasController.d.ts +0 -18
- package/builtins/controller/layerController.d.ts +0 -9
- package/builtins/controller/packagingController.d.ts +0 -71
- package/builtins/controller/shapeCreationController.d.ts +0 -83
- package/builtins/index.d.ts +0 -7
- package/builtins/plugins.d.ts +0 -16
- package/chrome/useSvgExport.d.ts +0 -15
- package/core/api/apiRegistry.d.ts +0 -12
- package/es-DocrZgUh.mjs +0 -2
- package/features/clipboard/clipboardContextMenuContributions.d.ts +0 -2
- package/features/clipboard/clipboardPlugin.d.ts +0 -1
- package/features/image/imageProductPlugin.d.ts +0 -1
- package/features/image/import/useImageImport.d.ts +0 -16
- package/features/keyboard/keyboardShortcutPlugin.d.ts +0 -1
- package/features/keyboard/useCanvasKitKeyboardShortcuts.d.ts +0 -8
- package/features/selection/selectionContextMenuContributions.d.ts +0 -2
- package/features/selection/selectionPlugin.d.ts +0 -1
- package/features/selection/selectionToolbarContributions.d.ts +0 -2
- package/features/tool/toolActions.d.ts +0 -2
- package/features/tool/toolContextMenuContributions.d.ts +0 -2
- package/features/tool/toolPlugin.d.ts +0 -1
- package/features/tool/toolToolbarContributions.d.ts +0 -2
- package/features/view/viewContextMenuContributions.d.ts +0 -2
- package/features/view/viewPlugin.d.ts +0 -1
- package/product/standardCanvasKitPlugins.d.ts +0 -4
- package/runtime/canvasKitPlugins.d.ts +0 -33
package/README.md
CHANGED
|
@@ -76,7 +76,23 @@ interface CanvasKitRuntimeOptions {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Controller callbacks, window exposure, and `windowKey` are mount concerns and
|
|
79
|
+
Controller callbacks, window exposure, and `windowKey` are mount concerns and
|
|
80
|
+
belong on `CanvasKitRoot`. Export appearance is supplied to each export request;
|
|
81
|
+
it is not stored on the Root or Runtime.
|
|
82
|
+
|
|
83
|
+
`plugins` is the complete caller-supplied plugin graph. Before compiling it,
|
|
84
|
+
CanvasKit adds Runtime default providers for clipboard behavior, import host,
|
|
85
|
+
generic tool actions, and the export API only when the graph does not already
|
|
86
|
+
provide the corresponding capability token. A plugin that provides
|
|
87
|
+
`canvasClipboardRuntimeCapability`, `canvasToolActionsCapability`, or
|
|
88
|
+
`canvasExportApiToken` therefore replaces that default implementation. Runtime
|
|
89
|
+
defaults and caller plugins use the same `CanvasPlugin` contract and compile
|
|
90
|
+
into one dependency graph.
|
|
91
|
+
|
|
92
|
+
CanvasKit-specific import, keyboard, and tool-action defaults live with the
|
|
93
|
+
composition root under `src/plugins/runtime`. Reusable clipboard and export
|
|
94
|
+
capabilities remain independent Runtime plugin packages. Physical ownership
|
|
95
|
+
does not change capability replacement semantics.
|
|
80
96
|
|
|
81
97
|
## Startup result
|
|
82
98
|
|
|
@@ -90,9 +106,9 @@ interface CanvasKitStartupResult {
|
|
|
90
106
|
}
|
|
91
107
|
```
|
|
92
108
|
|
|
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
|
|
109
|
+
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 Runtime-owned persistence coordination. Recoverable load/restore/asset/hook errors are returned in `warnings`. Synchronous assembly and seed failures are fatal.
|
|
94
110
|
|
|
95
|
-
Disposal aborts startup
|
|
111
|
+
Disposal aborts startup and unwinds one Runtime-owned disposer stack in reverse creation order. Persistence, plugin setup resources, Editor, and services all enter that stack. A disposed Runtime cannot restart.
|
|
96
112
|
|
|
97
113
|
## Persistence adapter
|
|
98
114
|
|
|
@@ -106,12 +122,16 @@ interface ProductPersistenceAdapter {
|
|
|
106
122
|
documentSnapshot: unknown | null;
|
|
107
123
|
sessionSnapshot: unknown | null;
|
|
108
124
|
}>;
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
saveDocument?(snapshot: DocumentSnapshot): Promise<void>;
|
|
126
|
+
saveSession?(snapshot: SessionSnapshot): Promise<void>;
|
|
111
127
|
}
|
|
112
128
|
```
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
Runtime captures document state from operation commits, captures session state
|
|
131
|
+
independently, applies trailing debounce, retries transient write failures, and
|
|
132
|
+
passes immutable snapshots to the adapter. When no document snapshot exists,
|
|
133
|
+
`seedDocument` runs once. Session restore happens after seed so persisted camera
|
|
134
|
+
and selection state win.
|
|
115
135
|
|
|
116
136
|
## Plugin authoring
|
|
117
137
|
|
|
@@ -131,33 +151,25 @@ const analyticsToken = createProductServiceToken<{ track(name: string): void }>(
|
|
|
131
151
|
|
|
132
152
|
const analyticsPlugin = defineCanvasPlugin({
|
|
133
153
|
id: "example.analytics",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
id: "example.track",
|
|
146
|
-
run: () => analytics?.track("canvas-action"),
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
},
|
|
150
|
-
}),
|
|
154
|
+
provides: [analyticsToken],
|
|
155
|
+
setup(context) {
|
|
156
|
+
const analytics = context.services.add({
|
|
157
|
+
token: analyticsToken,
|
|
158
|
+
create: () => ({ track: console.log }),
|
|
159
|
+
});
|
|
160
|
+
context.actions.add({
|
|
161
|
+
id: "example.track",
|
|
162
|
+
run: () => analytics.track("canvas-action"),
|
|
163
|
+
});
|
|
164
|
+
},
|
|
151
165
|
});
|
|
152
166
|
|
|
153
167
|
const reportingPlugin = defineCanvasPlugin({
|
|
154
168
|
id: "example.reporting",
|
|
155
|
-
requires: [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
}),
|
|
169
|
+
requires: [analyticsToken],
|
|
170
|
+
setup(context) {
|
|
171
|
+
context.services.get(analyticsToken)?.track("runtime-ready");
|
|
172
|
+
},
|
|
161
173
|
});
|
|
162
174
|
|
|
163
175
|
const options: CanvasKitRuntimeOptions = {
|
|
@@ -168,35 +180,78 @@ const options: CanvasKitRuntimeOptions = {
|
|
|
168
180
|
};
|
|
169
181
|
```
|
|
170
182
|
|
|
171
|
-
`CanvasPlugin`
|
|
183
|
+
`CanvasPlugin` has optional `editor`, `render`, and `setup` entries. `requires` lives at the plugin top level, so one dependency order applies to editor/render creation and setup installation. Depend on a plugin object when the whole extension must exist; depend on a typed API, service, or value capability token when only that cross-plugin contract matters. Providers declare those tokens in `provides` and register the matching implementation during setup. Raw `{ id }` dependency objects are rejected.
|
|
184
|
+
|
|
185
|
+
Nested arrays are groups only; they do not need IDs and are flattened in declaration order. Optional features are included or omitted explicitly.
|
|
186
|
+
|
|
187
|
+
Runtime creation compiles the graph, creates Editor and the Runtime resource owner, runs each setup once in dependency order, then seals all registries. Sealing validates duplicate IDs and action references, materializes registered APIs, and prevents later registration.
|
|
172
188
|
|
|
173
|
-
Packaging
|
|
174
|
-
|
|
189
|
+
Connector and Packaging are composed outside CanvasKit and are intentionally
|
|
190
|
+
absent from the standard plugin profile. Products that need them depend on their
|
|
191
|
+
plugin packages and add them explicitly:
|
|
175
192
|
|
|
176
193
|
```ts
|
|
177
194
|
import {
|
|
178
|
-
Packaging,
|
|
179
195
|
createStandardCanvasKitPlugins,
|
|
180
196
|
type CanvasKitRuntimeOptions,
|
|
181
197
|
} from "@land/canvas-kit";
|
|
198
|
+
import { Connector } from "@land/plugin-connector";
|
|
199
|
+
import { Packaging } from "@land/plugin-packaging";
|
|
182
200
|
|
|
183
201
|
const options: CanvasKitRuntimeOptions = {
|
|
184
|
-
plugins: [createStandardCanvasKitPlugins(), Packaging],
|
|
202
|
+
plugins: [Connector, createStandardCanvasKitPlugins(), Packaging],
|
|
185
203
|
};
|
|
186
204
|
```
|
|
187
205
|
|
|
188
|
-
|
|
206
|
+
`setup(context)` installs capabilities through focused registrars:
|
|
189
207
|
|
|
190
|
-
- `
|
|
191
|
-
- `
|
|
208
|
+
- `actions`, `toolbar`, `contextMenu`, and `apis`
|
|
209
|
+
- `services`
|
|
210
|
+
- `assets`
|
|
211
|
+
- `ui`
|
|
212
|
+
- `lifecycle.beforeReady()`, `lifecycle.beforeCommand()`, and `lifecycle.defer()`
|
|
192
213
|
|
|
193
|
-
`beforeCommand` is a repeatable interceptor executed by the Runtime-bound command executor
|
|
214
|
+
`setup` returns nothing. Every owned resource registers cleanup through `lifecycle.defer()`, which gives Runtime one cleanup protocol and reverse-order resource stack. `beforeReady` runs serially during `start()` after restore/seed and asset preparation. `beforeCommand` is a repeatable interceptor executed by the Runtime-bound command executor.
|
|
194
215
|
|
|
195
|
-
|
|
216
|
+
The set-active-tool and tool-lock actions are provided by the replaceable
|
|
217
|
+
Runtime default for `canvasToolActionsCapability`, so shape toolbar plugins do
|
|
218
|
+
not depend on the standard profile installing a Tool action provider.
|
|
219
|
+
Components share one props contract and render between Canvas and chrome; there
|
|
220
|
+
are no component slots.
|
|
196
221
|
|
|
197
222
|
## Public controller
|
|
198
223
|
|
|
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,
|
|
224
|
+
External code should work through `runtime.controller` or the controller supplied to `onControllerReady`. The controller exposes document, selection, page, tool, camera, layer, history, export, standard shape creation, and registered API operations without exposing the raw store.
|
|
225
|
+
|
|
226
|
+
### Export API
|
|
227
|
+
|
|
228
|
+
SVG and PNG export are async registered APIs so resource preparation and
|
|
229
|
+
embedding complete before a result is returned:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { canvasExportApiToken } from "@land/canvas-kit";
|
|
233
|
+
|
|
234
|
+
const exportApi = runtime.controller.apis.get(canvasExportApiToken);
|
|
235
|
+
if (!exportApi) throw new Error("Canvas export API is unavailable.");
|
|
236
|
+
|
|
237
|
+
const pagePng = await exportApi.exportPng({
|
|
238
|
+
appearance: {
|
|
239
|
+
resolveThemeColor(token, fallback) {
|
|
240
|
+
return currentTheme.tokens[token] ?? fallback;
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
scope: "page",
|
|
244
|
+
pixelRatio: 2,
|
|
245
|
+
});
|
|
246
|
+
const selectedSvg = await exportApi.exportSvg({ scope: "selection" });
|
|
247
|
+
const customSvg = await exportApi.exportSvg({ shapeIds: [shapeId] });
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`exportPng()` resolves with an `image/png` Blob and `exportSvg()` resolves with
|
|
251
|
+
a self-contained SVG string when export succeeds. The API deliberately exposes
|
|
252
|
+
no loading state; callers own pending-state presentation around the returned
|
|
253
|
+
Promise. SVG and PNG share one internal lock and reject a concurrent export.
|
|
254
|
+
When `appearance.resolveThemeColor` is omitted, core color fallbacks are used.
|
|
200
255
|
|
|
201
256
|
## Styles
|
|
202
257
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Editor } from "../editor/editor";
|
|
2
2
|
import type { SelectionOverlayFrameGeometryState } from "../editor/selection";
|
|
3
|
+
import type { Vec } from "../geometry/vec";
|
|
3
4
|
import type { BindingId, BindingRecord, BindingRecordBase, ShapeRecord } from "../schema/records";
|
|
4
5
|
export interface BindingUtilEffect {
|
|
5
6
|
shapes?: ShapeRecord[];
|
|
6
7
|
bindings?: BindingRecord[];
|
|
7
8
|
deleteShapeIds?: ShapeRecord["id"][];
|
|
8
9
|
deleteBindingIds?: BindingId[];
|
|
10
|
+
/** Suppress these bindings while applying this effect and its derived writes. */
|
|
11
|
+
suppressBindingIds?: BindingId[];
|
|
9
12
|
}
|
|
10
13
|
export interface BindingShapeChangeContext {
|
|
11
14
|
before: ShapeRecord;
|
|
@@ -28,6 +31,10 @@ export interface BindingShapeGeometryDependencyContext {
|
|
|
28
31
|
shape: ShapeRecord;
|
|
29
32
|
role: "from" | "to";
|
|
30
33
|
}
|
|
34
|
+
export interface BindingTargetShapeContentCutoutContext {
|
|
35
|
+
fromShape: ShapeRecord;
|
|
36
|
+
toShape: ShapeRecord;
|
|
37
|
+
}
|
|
31
38
|
export declare abstract class BindingUtil<B extends BindingRecordBase = BindingRecordBase> {
|
|
32
39
|
abstract readonly type: B["type"];
|
|
33
40
|
abstract getDefaultProps(): B["props"];
|
|
@@ -37,6 +44,7 @@ export declare abstract class BindingUtil<B extends BindingRecordBase = BindingR
|
|
|
37
44
|
onBindingCreate?(editor: Editor, binding: B): BindingUtilEffect | void;
|
|
38
45
|
onBindingUpdate?(editor: Editor, before: B, after: B): BindingUtilEffect | void;
|
|
39
46
|
onBindingLoad?(editor: Editor, binding: B): BindingUtilEffect | void;
|
|
47
|
+
onInvalidBindingLoad?(editor: Editor, binding: B): BindingUtilEffect | void;
|
|
40
48
|
onAfterShapeChange?(editor: Editor, binding: B, context: BindingShapeChangeContext): BindingUtilEffect | void;
|
|
41
49
|
onBeforeDeleteShape?(editor: Editor, binding: B, context: BindingShapeDeleteContext): BindingUtilEffect | void;
|
|
42
50
|
onBeforeDeleteBinding?(editor: Editor, binding: B): BindingUtilEffect | void;
|
|
@@ -48,6 +56,13 @@ export declare abstract class BindingUtil<B extends BindingRecordBase = BindingR
|
|
|
48
56
|
getShapeHierarchyRootId?(binding: B, shapeId: ShapeRecord["id"]): ShapeRecord["id"] | null;
|
|
49
57
|
canUseShapeHierarchy?(binding: B, context: BindingEndpointContext): boolean;
|
|
50
58
|
getGeometryDependentShapeIds?(editor: Editor, binding: B, context: BindingShapeGeometryDependencyContext): ShapeRecord["id"][];
|
|
59
|
+
/**
|
|
60
|
+
* Return polygons in the target shape's local space that should be removed
|
|
61
|
+
* from its rendered content. This lets a binding-owned companion such as a
|
|
62
|
+
* text label create a transparent gap without coupling the target plugin to
|
|
63
|
+
* the companion shape implementation.
|
|
64
|
+
*/
|
|
65
|
+
getTargetShapeContentCutoutLocalPolygons?(editor: Editor, binding: B, context: BindingTargetShapeContentCutoutContext): readonly (readonly Vec[])[];
|
|
51
66
|
getSelectionCompanionFrameGeometries?(editor: Editor, binding: B, context: BindingSelectionCompanionFrameContext): SelectionOverlayFrameGeometryState[];
|
|
52
67
|
}
|
|
53
68
|
export declare function resolveShapeHierarchyRootId(shapeId: ShapeRecord["id"], bindings: readonly BindingRecord[], getBindingUtil: (binding: BindingRecord) => BindingUtil): ShapeRecord["id"];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Editor } from "../editor/editor";
|
|
2
|
+
import { Vec } from "../geometry/vec";
|
|
3
|
+
import type { ShapeRecord } from "../schema/records";
|
|
4
|
+
export type TerminalBindingPortId = "top" | "right" | "bottom" | "left" | (string & {});
|
|
5
|
+
export interface ShapeTerminalBindingPort {
|
|
6
|
+
id: TerminalBindingPortId;
|
|
7
|
+
normalizedAnchor: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
outwardNormal: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface ResolvedShapeTerminalBindingPort {
|
|
17
|
+
id: TerminalBindingPortId;
|
|
18
|
+
normalizedAnchor: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
pagePoint: Vec;
|
|
23
|
+
pageOutwardNormal: Vec;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_TERMINAL_BINDING_PORTS: readonly [{
|
|
26
|
+
readonly id: "top";
|
|
27
|
+
readonly normalizedAnchor: {
|
|
28
|
+
readonly x: 0.5;
|
|
29
|
+
readonly y: 0;
|
|
30
|
+
};
|
|
31
|
+
readonly outwardNormal: {
|
|
32
|
+
readonly x: 0;
|
|
33
|
+
readonly y: -1;
|
|
34
|
+
};
|
|
35
|
+
}, {
|
|
36
|
+
readonly id: "right";
|
|
37
|
+
readonly normalizedAnchor: {
|
|
38
|
+
readonly x: 1;
|
|
39
|
+
readonly y: 0.5;
|
|
40
|
+
};
|
|
41
|
+
readonly outwardNormal: {
|
|
42
|
+
readonly x: 1;
|
|
43
|
+
readonly y: 0;
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
readonly id: "bottom";
|
|
47
|
+
readonly normalizedAnchor: {
|
|
48
|
+
readonly x: 0.5;
|
|
49
|
+
readonly y: 1;
|
|
50
|
+
};
|
|
51
|
+
readonly outwardNormal: {
|
|
52
|
+
readonly x: 0;
|
|
53
|
+
readonly y: 1;
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
readonly id: "left";
|
|
57
|
+
readonly normalizedAnchor: {
|
|
58
|
+
readonly x: 0;
|
|
59
|
+
readonly y: 0.5;
|
|
60
|
+
};
|
|
61
|
+
readonly outwardNormal: {
|
|
62
|
+
readonly x: -1;
|
|
63
|
+
readonly y: 0;
|
|
64
|
+
};
|
|
65
|
+
}];
|
|
66
|
+
export declare function getResolvedShapeTerminalBindingPorts(editor: Editor, shape: ShapeRecord): ResolvedShapeTerminalBindingPort[];
|
|
67
|
+
export declare function getResolvedShapeTerminalBindingPort(editor: Editor, shape: ShapeRecord, portId: TerminalBindingPortId): ResolvedShapeTerminalBindingPort | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BindingId } from "../schema/records";
|
|
2
|
+
import type { Editor } from "./editor";
|
|
3
|
+
declare const SYNCHRONOUS_CALLBACK_ERROR = "Binding reaction scope callbacks must be synchronous";
|
|
4
|
+
type SynchronousCallbackGuard<T> = T extends PromiseLike<unknown> ? [error: typeof SYNCHRONOUS_CALLBACK_ERROR] : [];
|
|
5
|
+
export declare function getSuppressedBindingReactionIds(editor: Editor): ReadonlySet<BindingId>;
|
|
6
|
+
export declare function runWithSuppressedBindingReactions<T>(editor: Editor, bindingIds: Iterable<BindingId>, callback: () => T, ..._synchronousCallbackGuard: SynchronousCallbackGuard<T>): T;
|
|
7
|
+
export {};
|
|
@@ -11,8 +11,8 @@ export interface CreateShapesOptions extends EditorCommandOptions {
|
|
|
11
11
|
deferMinimumChildRepair?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export interface UpdateShapesOptions extends EditorCommandOptions {
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/** Suppress these bindings while applying this update and its derived writes. */
|
|
15
|
+
suppressBindingIds?: ReadonlySet<BindingId>;
|
|
16
16
|
}
|
|
17
17
|
export interface CreateShapeInput {
|
|
18
18
|
type: ShapeRecordBase["type"];
|
|
@@ -69,7 +69,7 @@ export interface StartEditingShapeInput {
|
|
|
69
69
|
y: number;
|
|
70
70
|
};
|
|
71
71
|
markId?: string;
|
|
72
|
-
|
|
72
|
+
reuseActiveOperation?: boolean;
|
|
73
73
|
preserveInteraction?: boolean;
|
|
74
74
|
}
|
|
75
75
|
export interface CreateBindingInput {
|
|
@@ -17,6 +17,7 @@ import { Store, type ChangeSource, type StoreChange } from "../../store/index";
|
|
|
17
17
|
import { type CreateAssetInput, type CreateBindingInput, type CreatePageInput, type CreateShapeInput, type StartEditingShapeInput, type EditorCommands } from "./commands";
|
|
18
18
|
import type { CancelEditorEvent, EditorEvent } from "./events";
|
|
19
19
|
import { HistoryManager, type HistoryState } from "./historyManager";
|
|
20
|
+
import { EditorOperationManager } from "./operationManager";
|
|
20
21
|
import { BindingManager } from "./managers/bindingManager";
|
|
21
22
|
import { CameraManager } from "./managers/cameraManager";
|
|
22
23
|
import { ClipboardManager } from "./managers/clipboardManager";
|
|
@@ -121,6 +122,7 @@ export interface EditorSelectionState {
|
|
|
121
122
|
count: number;
|
|
122
123
|
singleShapeType: ShapeRecord["type"] | null;
|
|
123
124
|
commonShapeType: ShapeRecord["type"] | null;
|
|
125
|
+
canFlipSelection: boolean;
|
|
124
126
|
hasPointHandleSelection: boolean;
|
|
125
127
|
hasFrameSelection: boolean;
|
|
126
128
|
isMixedFrameAndPointHandleSelection: boolean;
|
|
@@ -172,6 +174,8 @@ export interface EditorOverlayDebugState {
|
|
|
172
174
|
interface ReadonlyStore {
|
|
173
175
|
readonly recordsSignal: Signal<Map<string, EditorRecord>>;
|
|
174
176
|
get(id: string): EditorRecord | undefined;
|
|
177
|
+
getActiveAtomicOperationRevision(): number | null;
|
|
178
|
+
getActiveAtomicOperationSnapshot(): EditorRecord[];
|
|
175
179
|
getRecordSignal(id: string): Signal<EditorRecord | undefined>;
|
|
176
180
|
getAll(): EditorRecord[];
|
|
177
181
|
getByScope(scope: RecordScope): EditorRecord[];
|
|
@@ -205,6 +209,7 @@ export declare class Editor {
|
|
|
205
209
|
readonly selectionOverlay: SelectionOverlayManager;
|
|
206
210
|
readonly transients: InteractionTransientManager;
|
|
207
211
|
readonly history: HistoryManager;
|
|
212
|
+
readonly operations: EditorOperationManager;
|
|
208
213
|
readonly sideEffects: SideEffectManager;
|
|
209
214
|
readonly commands: EditorCommands;
|
|
210
215
|
private readonly shapeCapabilityDefinitions;
|
|
@@ -256,6 +261,7 @@ export declare class Editor {
|
|
|
256
261
|
readonly selectionCountSignal: import("../../signals/index").Computed<number>;
|
|
257
262
|
readonly selectedShapeIdSetSignal: import("../../signals/index").Computed<Set<`shape:${string}`>>;
|
|
258
263
|
readonly selectedShapesSignal: import("../../signals/index").Computed<ShapeRecord[]>;
|
|
264
|
+
readonly selectionCanFlipSignal: import("../../signals/index").Computed<boolean>;
|
|
259
265
|
readonly selectedShapeOverlayItemsSignal: import("../../signals/index").Computed<SelectedShapeOverlayItem[]>;
|
|
260
266
|
readonly selectionStateSignal: import("../../signals/index").Computed<EditorSelectionState>;
|
|
261
267
|
readonly selectionMetadataSignal: import("../../signals/index").Computed<EditorSelectionMetadata>;
|
|
@@ -272,6 +278,7 @@ export declare class Editor {
|
|
|
272
278
|
readonly selectedShapeIdsOutsideCulledSetSignal: Signal<Set<ShapeId>>;
|
|
273
279
|
readonly renderVisibleShapeIdSetSignal: Signal<Set<ShapeId>>;
|
|
274
280
|
private readonly shapeSignals;
|
|
281
|
+
private readonly shapeContentCutoutLocalPolygonSignals;
|
|
275
282
|
private readonly shapeSelectedSignals;
|
|
276
283
|
private readonly shapeRenderOrderSignals;
|
|
277
284
|
private readonly shapeRenderVisibleSignals;
|
|
@@ -287,6 +294,7 @@ export declare class Editor {
|
|
|
287
294
|
readonly selectionOverlayFrameGeometrySignal: Signal<SelectionOverlayFrameGeometryState | null>;
|
|
288
295
|
readonly selectionOverlayCompanionFrameGeometriesSignal: Signal<SelectionOverlayFrameGeometryState[]>;
|
|
289
296
|
readonly selectionOverlayPathSignal: Signal<string | null>;
|
|
297
|
+
readonly selectionOverlayPageClipPathSignal: Signal<string | null>;
|
|
290
298
|
readonly selectionOverlayBindingSegmentsSignal: Signal<SelectionBindingSegment[]>;
|
|
291
299
|
readonly selectionOverlayFrameStyleSignal: Signal<SelectionOverlayFrameStyleState>;
|
|
292
300
|
readonly selectionOverlayFrameSignal: Signal<SelectionOverlayFrameState | null>;
|
|
@@ -358,15 +366,16 @@ export declare class Editor {
|
|
|
358
366
|
moveShapesInParentOrder(ids: readonly ShapeId[], direction: LayerOrderDirection, source?: ChangeSource): boolean;
|
|
359
367
|
moveShapesToParentOrderEdge(ids: readonly ShapeId[], edge: LayerOrderEdge, source?: ChangeSource): boolean;
|
|
360
368
|
moveSelectionWithinParent(direction: ShapeSiblingOrderDirection, source?: ChangeSource): boolean;
|
|
369
|
+
canAlignSelection(): boolean;
|
|
361
370
|
/**
|
|
362
|
-
* Align selected
|
|
363
|
-
* page bounds.
|
|
364
|
-
* the page-space delta maps directly onto `x`/`y`. Needs at least two shapes.
|
|
371
|
+
* Align selected, unlocked siblings along an edge or center of their combined
|
|
372
|
+
* page bounds. Needs at least two eligible shapes.
|
|
365
373
|
*/
|
|
366
374
|
alignSelection(mode: "left" | "horizontal-center" | "right" | "top" | "vertical-center" | "bottom", source?: ChangeSource): boolean;
|
|
375
|
+
canDistributeSelection(): boolean;
|
|
367
376
|
/**
|
|
368
|
-
* Distribute selected
|
|
369
|
-
* along the given axis. Needs at least three shapes.
|
|
377
|
+
* Distribute selected, unlocked siblings so the gaps between them are equal
|
|
378
|
+
* along the given axis. Needs at least three eligible shapes.
|
|
370
379
|
*/
|
|
371
380
|
distributeSelection(axis: "horizontal" | "vertical", source?: ChangeSource): boolean;
|
|
372
381
|
moveShapesToParentPlacementResult(input: ReparentShapePlacementInput, source?: ChangeSource): ReparentShapePlacementResult;
|
|
@@ -394,6 +403,7 @@ export declare class Editor {
|
|
|
394
403
|
resolveAssetUrl(assetId: AssetId): string | null;
|
|
395
404
|
getUnreferencedAssetIdsAfterShapeDelete(shapeIds: readonly ShapeId[]): AssetId[];
|
|
396
405
|
getShapeSignal(id: ShapeId): Signal<ShapeRecord | undefined>;
|
|
406
|
+
getShapeContentCutoutLocalPolygonsSignal(id: ShapeId): Signal<readonly (readonly Vec[])[]>;
|
|
397
407
|
getShapeLocalToPageTransformSignal(id: ShapeId): Signal<Mat | undefined>;
|
|
398
408
|
getShapeSelectedSignal(id: ShapeId): Signal<boolean>;
|
|
399
409
|
getShapeRenderOrderSignal(id: ShapeId): Signal<number>;
|
|
@@ -407,8 +417,11 @@ export declare class Editor {
|
|
|
407
417
|
getBinding(id: BindingId): BindingRecord | undefined;
|
|
408
418
|
getShapesForPage(pageId: PageId): ShapeRecord[];
|
|
409
419
|
getBindingsFromShape(shapeId: ShapeId): BindingRecord[];
|
|
420
|
+
getBindingsFromShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
410
421
|
getBindingsToShape(shapeId: ShapeId): BindingRecord[];
|
|
422
|
+
getBindingsToShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
411
423
|
getBindingsForShape(shapeId: ShapeId): BindingRecord[];
|
|
424
|
+
getBindingsForShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
412
425
|
getChildShapeIds(parentId: ShapeParentId): ShapeId[];
|
|
413
426
|
getChildShapes(parentId: ShapeParentId): ShapeRecord[];
|
|
414
427
|
getDescendantShapeIds(parentId: ShapeParentId): ShapeId[];
|
|
@@ -423,6 +436,7 @@ export declare class Editor {
|
|
|
423
436
|
getShapeIdsForSelectionRotation(shapeIds: Iterable<ShapeId>): ShapeId[];
|
|
424
437
|
getSelectionTransformTargetShapes(): ShapeRecord[];
|
|
425
438
|
canResizeSelection(): boolean;
|
|
439
|
+
canFlipSelection(): boolean;
|
|
426
440
|
canRotateSelection(): boolean;
|
|
427
441
|
getSelectionResizeTargetShapes(): ShapeRecord[];
|
|
428
442
|
getSelectionRotationTargetShapes(): ShapeRecord[];
|
|
@@ -517,6 +531,7 @@ export declare class Editor {
|
|
|
517
531
|
}): void;
|
|
518
532
|
removeShapeIdsFromSelection(ids: ShapeId[], source?: ChangeSource): void;
|
|
519
533
|
removeShapeIdsFromEditingSession(ids: ShapeId[], source?: ChangeSource): void;
|
|
534
|
+
prepareShapeIdsForRemoval(ids: readonly ShapeId[], source?: ChangeSource): void;
|
|
520
535
|
ensurePageSessionState(pageId: PageId, source?: ChangeSource): void;
|
|
521
536
|
removePageSessionState(pageId: PageId, nextCurrentPageId: PageId, source?: ChangeSource): void;
|
|
522
537
|
setCamera(partial: Partial<Camera>, options?: {
|
|
@@ -8,6 +8,7 @@ export declare function areEditorSelectionMetadataEqual(a: EditorSelectionMetada
|
|
|
8
8
|
export declare function areShapeIdArraysEqual(a: ShapeId[], b: ShapeId[]): boolean;
|
|
9
9
|
export declare function areVecsEqual(a: Vec | null, b: Vec | null): boolean;
|
|
10
10
|
export declare function areVecArraysEqual(a: readonly Vec[], b: readonly Vec[]): boolean;
|
|
11
|
+
export declare function areVecPolygonArraysEqual(a: readonly (readonly Vec[])[], b: readonly (readonly Vec[])[]): boolean;
|
|
11
12
|
export declare function areBoxesEqual(a: Box | null, b: Box | null): boolean;
|
|
12
13
|
export declare function isValidBox(box: Box): boolean;
|
|
13
14
|
export declare function areRenderHostDebugStatesEqual(a: EditorRenderHostDebugState, b: EditorRenderHostDebugState): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Signal } from "../../signals/index";
|
|
2
2
|
import { type StoreHistoryEntry, type StoreHistoryState } from "../../store/index";
|
|
3
|
-
import {
|
|
3
|
+
import type { DocumentRecord } from "../schema/records";
|
|
4
4
|
import type { Editor } from "./editor";
|
|
5
5
|
export interface HistoryScopeState {
|
|
6
6
|
canUndo: boolean;
|
|
@@ -24,16 +24,13 @@ export declare class HistoryManager {
|
|
|
24
24
|
readonly state: Signal<HistoryState>;
|
|
25
25
|
constructor(editor: Editor);
|
|
26
26
|
clear(): void;
|
|
27
|
-
mark(id: string): void;
|
|
28
|
-
bailToMark(id: string): void;
|
|
29
|
-
squashToMark(id: string, label?: string): void;
|
|
30
27
|
activateScope(scope: HistoryScope): () => void;
|
|
31
28
|
deactivateScope(scope: HistoryScope): boolean;
|
|
32
29
|
getActiveScope(): HistoryScope | null;
|
|
33
30
|
undo(): boolean;
|
|
34
31
|
redo(): boolean;
|
|
35
32
|
getEntries(): readonly StoreHistoryEntry<DocumentRecord>[];
|
|
36
|
-
private
|
|
33
|
+
private handleCommit;
|
|
37
34
|
private deactivateActivation;
|
|
38
35
|
private publishEffectiveState;
|
|
39
36
|
}
|
|
@@ -2,7 +2,7 @@ import type { ChangeSource } from "../../store/index";
|
|
|
2
2
|
import type { Vec } from "../geometry/vec";
|
|
3
3
|
import type { ShapeId, ShapeRecord } from "../schema/records";
|
|
4
4
|
import type { Editor } from "./editor";
|
|
5
|
-
import type { CancelEditorEvent, EditorEvent } from "./events";
|
|
5
|
+
import type { CancelEditorEvent, EditorEvent, PointerEditorEvent } from "./events";
|
|
6
6
|
import type { SelectionHandle } from "./selection";
|
|
7
7
|
import type { HandleSnapContext, HandleSnapMode } from "./managers/snapTypes";
|
|
8
8
|
export interface SelectionHandleInteractionInput {
|
|
@@ -10,36 +10,58 @@ export interface SelectionHandleInteractionInput {
|
|
|
10
10
|
shape: ShapeRecord;
|
|
11
11
|
originPagePoint: Vec;
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
13
|
+
export interface PointerDragInteractionSession {
|
|
14
14
|
readonly shapeId: ShapeId;
|
|
15
15
|
readonly historyMark: string;
|
|
16
|
-
readonly handleSnapMode?: HandleSnapMode;
|
|
17
|
-
readonly handleSnapContext?: HandleSnapContext;
|
|
18
|
-
readonly allowSelfSnap?: boolean;
|
|
19
|
-
readonly excludedSnapShapeIds?: readonly ShapeId[];
|
|
20
16
|
readonly shouldClearBindingPreviewOnExit?: boolean;
|
|
17
|
+
onDragStart?(input: {
|
|
18
|
+
editor: Editor;
|
|
19
|
+
}): void;
|
|
21
20
|
onClick?(input: {
|
|
22
21
|
editor: Editor;
|
|
23
22
|
source: ChangeSource;
|
|
24
23
|
}): void;
|
|
24
|
+
onDoubleClick?(input: {
|
|
25
|
+
editor: Editor;
|
|
26
|
+
source: ChangeSource;
|
|
27
|
+
}): void;
|
|
25
28
|
onCancel?(input: {
|
|
26
29
|
editor: Editor;
|
|
27
30
|
reason: CancelEditorEvent["reason"];
|
|
28
31
|
}): void;
|
|
32
|
+
onComplete?(input: {
|
|
33
|
+
editor: Editor;
|
|
34
|
+
}): void;
|
|
29
35
|
update(input: {
|
|
30
36
|
editor: Editor;
|
|
31
37
|
pagePoint: Vec;
|
|
32
38
|
accelKey: boolean;
|
|
33
39
|
source: ChangeSource;
|
|
34
|
-
}): "continue" | "stop" |
|
|
40
|
+
}): "continue" | "stop" | PointerDragInteractionUpdateResult;
|
|
35
41
|
}
|
|
36
|
-
export interface
|
|
42
|
+
export interface PointerDragInteractionUpdateResult {
|
|
37
43
|
status: "continue" | "stop";
|
|
38
44
|
finalPagePoint?: Vec | null;
|
|
39
45
|
}
|
|
46
|
+
export interface SelectionHandleInteractionSession extends PointerDragInteractionSession {
|
|
47
|
+
readonly handleSnapMode?: HandleSnapMode;
|
|
48
|
+
readonly handleSnapContext?: HandleSnapContext;
|
|
49
|
+
readonly allowSelfSnap?: boolean;
|
|
50
|
+
readonly excludedSnapShapeIds?: readonly ShapeId[];
|
|
51
|
+
}
|
|
52
|
+
export type SelectionHandleInteractionUpdateResult = PointerDragInteractionUpdateResult;
|
|
40
53
|
export interface SelectionHandleInteractionHandler {
|
|
41
54
|
createSession(editor: Editor, input: SelectionHandleInteractionInput): SelectionHandleInteractionSession | null;
|
|
42
55
|
}
|
|
56
|
+
export interface ShapePointerInteractionInput {
|
|
57
|
+
shape: ShapeRecord;
|
|
58
|
+
selectionTargetId: ShapeId;
|
|
59
|
+
originPagePoint: Vec;
|
|
60
|
+
event: PointerEditorEvent;
|
|
61
|
+
}
|
|
62
|
+
export interface ShapePointerInteractionHandler {
|
|
63
|
+
createSession(editor: Editor, input: ShapePointerInteractionInput): PointerDragInteractionSession | null;
|
|
64
|
+
}
|
|
43
65
|
export type EditorEventInteractionDecision = "continue" | "handled";
|
|
44
66
|
export interface EditorEventInteractionHandler {
|
|
45
67
|
handleEvent(editor: Editor, event: EditorEvent): EditorEventInteractionDecision;
|
|
@@ -48,6 +70,7 @@ export interface LandInteractionHandler {
|
|
|
48
70
|
id: string;
|
|
49
71
|
editorEvent?: EditorEventInteractionHandler;
|
|
50
72
|
selectionHandle?: SelectionHandleInteractionHandler;
|
|
73
|
+
shapePointer?: ShapePointerInteractionHandler;
|
|
51
74
|
}
|
|
52
75
|
export declare class InteractionHandlerRegistry {
|
|
53
76
|
private readonly handlers;
|
|
@@ -55,6 +78,7 @@ export declare class InteractionHandlerRegistry {
|
|
|
55
78
|
register(handler: LandInteractionHandler): void;
|
|
56
79
|
getHandlers(): readonly LandInteractionHandler[];
|
|
57
80
|
handleEvent(editor: Editor, event: EditorEvent): EditorEventInteractionDecision;
|
|
58
|
-
broadcastEvent(editor: Editor, event: EditorEvent):
|
|
81
|
+
broadcastEvent(editor: Editor, event: EditorEvent): EditorEventInteractionDecision;
|
|
59
82
|
createSelectionHandleSession(editor: Editor, input: SelectionHandleInteractionInput): SelectionHandleInteractionSession | null;
|
|
83
|
+
createShapePointerSession(editor: Editor, input: ShapePointerInteractionInput): PointerDragInteractionSession | null;
|
|
60
84
|
}
|
|
@@ -8,17 +8,12 @@ export interface ShapeChangeEntry {
|
|
|
8
8
|
export declare class BindingManager {
|
|
9
9
|
private readonly editor;
|
|
10
10
|
constructor(editor: Editor);
|
|
11
|
-
getBindingsFromShape(shapeId: ShapeId): BindingRecord[];
|
|
12
|
-
getBindingsToShape(shapeId: ShapeId): BindingRecord[];
|
|
13
|
-
getBindingsForShape(shapeId: ShapeId): BindingRecord[];
|
|
14
11
|
getConflictingBindings(binding: BindingRecord): BindingRecord[];
|
|
15
12
|
canBind(binding: BindingRecord): boolean;
|
|
16
13
|
syncCreatedBinding(binding: BindingRecord, source: ChangeSource): void;
|
|
17
14
|
syncUpdatedBinding(before: BindingRecord, after: BindingRecord, source: ChangeSource): void;
|
|
18
15
|
repairLoadedBindings(source: ChangeSource): void;
|
|
19
|
-
handleShapeChanges(changes: ShapeChangeEntry[], source: ChangeSource
|
|
20
|
-
skipBindingIds?: ReadonlySet<BindingId>;
|
|
21
|
-
}): void;
|
|
16
|
+
handleShapeChanges(changes: ShapeChangeEntry[], source: ChangeSource): void;
|
|
22
17
|
getShapeHierarchyRootId(shapeId: ShapeId): ShapeId;
|
|
23
18
|
cleanupBindingsForDeletedShapes(ids: ShapeId[], source: ChangeSource): void;
|
|
24
19
|
cleanupBindings(ids: BindingId[], source: ChangeSource): void;
|
|
@@ -30,6 +30,10 @@ export declare class QueryManager {
|
|
|
30
30
|
readonly selectionAnchorPagePointSignal: Signal<Vec | null>;
|
|
31
31
|
private readonly stateAtom;
|
|
32
32
|
private readonly shapeQuerySignals;
|
|
33
|
+
private readonly bindingsFromShapeSignals;
|
|
34
|
+
private readonly bindingsToShapeSignals;
|
|
35
|
+
private readonly bindingsForShapeSignals;
|
|
36
|
+
private draftBindingIndex;
|
|
33
37
|
constructor(editor: Editor);
|
|
34
38
|
getShapeIdsForPage(pageId: PageId): ShapeId[];
|
|
35
39
|
getShapesForPage(pageId: PageId): ShapeRecord[];
|
|
@@ -54,6 +58,7 @@ export declare class QueryManager {
|
|
|
54
58
|
private getShapeIdsForPageSnapshot;
|
|
55
59
|
private getChildShapeIdsSnapshot;
|
|
56
60
|
private handleStoreChange;
|
|
61
|
+
private updateCachedBindingSignals;
|
|
57
62
|
private getShapeLocalToPageTransformSnapshot;
|
|
58
63
|
private getShapeParentToPageTransformSnapshot;
|
|
59
64
|
private getShapeQuerySignals;
|
|
@@ -84,6 +89,14 @@ export declare class QueryManager {
|
|
|
84
89
|
getBindingIdsToShape(shapeId: ShapeId): BindingId[];
|
|
85
90
|
getBindingIdsForShape(shapeId: ShapeId): BindingId[];
|
|
86
91
|
getBindingsFromShape(shapeId: ShapeId): BindingRecord[];
|
|
92
|
+
getBindingsFromShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
87
93
|
getBindingsToShape(shapeId: ShapeId): BindingRecord[];
|
|
94
|
+
getBindingsToShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
88
95
|
getBindingsForShape(shapeId: ShapeId): BindingRecord[];
|
|
96
|
+
getBindingsForShapeSignal(shapeId: ShapeId): Signal<readonly BindingRecord[]>;
|
|
97
|
+
private getBindingsFromState;
|
|
98
|
+
private getBindingsToState;
|
|
99
|
+
private getBindingsForState;
|
|
100
|
+
private getBindingsForIds;
|
|
101
|
+
private getDraftBindingIndex;
|
|
89
102
|
}
|
|
@@ -18,13 +18,16 @@ export interface ZoomToBoundsOptions {
|
|
|
18
18
|
export declare class SelectionLayoutManager {
|
|
19
19
|
private readonly editor;
|
|
20
20
|
constructor(editor: Editor);
|
|
21
|
+
canAlign(): boolean;
|
|
21
22
|
align(mode: AlignMode, source?: ChangeSource): boolean;
|
|
23
|
+
canDistribute(): boolean;
|
|
22
24
|
distribute(axis: DistributeAxis, source?: ChangeSource): boolean;
|
|
23
25
|
getCurrentPageBounds(pageId?: PageId): Box | null;
|
|
24
26
|
zoomToBounds(bounds: Box, options?: ZoomToBoundsOptions): boolean;
|
|
25
27
|
zoomToFit(options?: ZoomToBoundsOptions): boolean;
|
|
26
28
|
zoomToSelection(options?: ZoomToBoundsOptions): boolean;
|
|
27
29
|
private boundsOfShapeIds;
|
|
30
|
+
private canLayoutSelection;
|
|
28
31
|
private getAlignableEntries;
|
|
29
32
|
private getPageToParentTransform;
|
|
30
33
|
private pageDeltaToParentDelta;
|