@yuzhouu/canvas-kit 0.1.2 → 0.1.3
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/_vendor/canvas-core/bindings/BindingUtil.d.ts +45 -0
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.d.ts +8 -0
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.d.ts +28 -0
- package/_vendor/canvas-core/contextMenu.d.ts +62 -0
- package/_vendor/canvas-core/editor/Editor.d.ts +564 -0
- package/_vendor/canvas-core/editor/HistoryManager.d.ts +18 -0
- package/_vendor/canvas-core/editor/StateNode.d.ts +31 -0
- package/_vendor/canvas-core/editor/camera.d.ts +3 -0
- package/_vendor/canvas-core/editor/clipboard.d.ts +43 -0
- package/_vendor/canvas-core/editor/commands.d.ts +126 -0
- package/_vendor/canvas-core/editor/edgeScroll.d.ts +5 -0
- package/_vendor/canvas-core/editor/editorComputedHelpers.d.ts +21 -0
- package/_vendor/canvas-core/editor/editorSelectionTransforms.d.ts +6 -0
- package/_vendor/canvas-core/editor/events.d.ts +71 -0
- package/_vendor/canvas-core/editor/{index.ts → index.d.ts} +1 -5
- package/_vendor/canvas-core/editor/interactions.d.ts +51 -0
- package/_vendor/canvas-core/editor/internal.d.ts +7 -0
- package/_vendor/canvas-core/editor/managers/BindingManager.d.ts +27 -0
- package/_vendor/canvas-core/editor/managers/CameraManager.d.ts +39 -0
- package/_vendor/canvas-core/editor/managers/ClipboardManager.d.ts +14 -0
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.d.ts +28 -0
- package/_vendor/canvas-core/editor/managers/InputsManager.d.ts +44 -0
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.d.ts +52 -0
- package/_vendor/canvas-core/editor/managers/QueryManager.d.ts +76 -0
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.d.ts +25 -0
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/SelectionManager.d.ts +21 -0
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.d.ts +23 -0
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.d.ts +42 -0
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.d.ts +58 -0
- package/_vendor/canvas-core/editor/managers/SideEffectManager.d.ts +23 -0
- package/_vendor/canvas-core/editor/managers/SnapManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.d.ts +22 -0
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.d.ts +30 -0
- package/_vendor/canvas-core/editor/managers/ToolManager.d.ts +25 -0
- package/_vendor/canvas-core/editor/managers/queryState.d.ts +18 -0
- package/_vendor/canvas-core/editor/managers/selectionGeometry.d.ts +28 -0
- package/_vendor/canvas-core/editor/managers/shapeOrder.d.ts +14 -0
- package/_vendor/canvas-core/editor/managers/shapeReparenting.d.ts +6 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.d.ts +40 -0
- package/_vendor/canvas-core/editor/managers/snapGeometry.d.ts +26 -0
- package/_vendor/canvas-core/editor/managers/snapIndicators.d.ts +22 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.d.ts +98 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.d.ts +27 -0
- package/_vendor/canvas-core/editor/renderWindow.d.ts +30 -0
- package/_vendor/canvas-core/editor/resizeGeometry.d.ts +97 -0
- package/_vendor/canvas-core/editor/selection.d.ts +224 -0
- package/_vendor/canvas-core/editor/selectionHandleInteractions.d.ts +11 -0
- package/_vendor/canvas-core/editor/selectionOverlay.d.ts +31 -0
- package/_vendor/canvas-core/exports/integrity.d.ts +32 -0
- package/_vendor/canvas-core/exports/svg.d.ts +48 -0
- package/_vendor/canvas-core/geometry/Box.d.ts +19 -0
- package/_vendor/canvas-core/geometry/Ellipse2d.d.ts +16 -0
- package/_vendor/canvas-core/geometry/Geometry2d.d.ts +15 -0
- package/_vendor/canvas-core/geometry/Mat.d.ts +28 -0
- package/_vendor/canvas-core/geometry/Polyline2d.d.ts +14 -0
- package/_vendor/canvas-core/geometry/Rectangle2d.d.ts +16 -0
- package/_vendor/canvas-core/geometry/Vec.d.ts +37 -0
- package/_vendor/canvas-core/geometry/{index.ts → index.d.ts} +1 -6
- package/_vendor/canvas-core/geometry/segments.d.ts +5 -0
- package/_vendor/canvas-core/index.d.ts +57 -0
- package/_vendor/canvas-core/plugins/index.d.ts +1 -0
- package/_vendor/canvas-core/plugins/types.d.ts +27 -0
- package/_vendor/canvas-core/reactivity.d.ts +4 -0
- package/_vendor/canvas-core/schema/records.d.ts +112 -0
- package/_vendor/canvas-core/schema/snapshots.d.ts +27 -0
- package/_vendor/canvas-core/shapes/ShapeUtil.d.ts +133 -0
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.d.ts +9 -0
- package/_vendor/canvas-core/shapes/capabilities.d.ts +25 -0
- package/_vendor/canvas-core/shapes/types.d.ts +2 -0
- package/_vendor/canvas-core/toolbar.d.ts +117 -0
- package/_vendor/canvas-core/tools/hand/HandTool.d.ts +5 -0
- package/_vendor/canvas-core/tools/select/SelectTool.d.ts +5 -0
- package/_vendor/canvas-core/tools/select/selectContainment.d.ts +11 -0
- package/_vendor/canvas-core/tools/select/selectToolHelpers.d.ts +161 -0
- package/_vendor/canvas-core/tools/select/states/BrushingState.d.ts +19 -0
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.d.ts +15 -0
- package/_vendor/canvas-core/tools/select/states/IdleState.d.ts +8 -0
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.d.ts +11 -0
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.d.ts +12 -0
- package/_vendor/canvas-core/tools/select/states/ResizingState.d.ts +16 -0
- package/_vendor/canvas-core/tools/select/states/RotatingState.d.ts +14 -0
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.d.ts +60 -0
- package/_vendor/canvas-core/tools/select/states/TranslatingState.d.ts +16 -0
- package/_vendor/canvas-plugin-api/feature.d.ts +37 -0
- package/_vendor/canvas-plugin-api/index.d.ts +57 -0
- package/_vendor/canvas-product-react/api/apiRegistry.d.ts +12 -0
- package/_vendor/canvas-product-react/api/canvasProductApi.d.ts +124 -0
- package/_vendor/canvas-product-react/api/index.d.ts +4 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.d.ts +9 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.d.ts +16 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.d.ts +17 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.d.ts +12 -0
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.d.ts +29 -0
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.d.ts +8 -0
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.d.ts +12 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.d.ts +32 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.d.ts +19 -0
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.d.ts +9 -0
- package/_vendor/canvas-product-react/index.d.ts +24 -0
- package/_vendor/canvas-product-react/persistence/index.d.ts +2 -0
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.d.ts +40 -0
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.d.ts +4 -0
- package/_vendor/canvas-product-react/runtime/productDefinition.d.ts +45 -0
- package/_vendor/canvas-product-react/runtime/productServices.d.ts +31 -0
- package/_vendor/canvas-react/components/CanvasView.d.ts +11 -0
- package/_vendor/canvas-react/components/OverlayLayer.d.ts +1 -0
- package/_vendor/canvas-react/components/PageSpace.d.ts +6 -0
- package/_vendor/canvas-react/components/ShapeLayer.d.ts +1 -0
- package/_vendor/canvas-react/hooks/useEditor.d.ts +3 -0
- package/_vendor/canvas-react/hooks/useValue.d.ts +2 -0
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.d.ts +3 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.d.ts +12 -0
- package/_vendor/canvas-react/host/domEventGuards.d.ts +11 -0
- package/_vendor/canvas-react/host/index.d.ts +8 -0
- package/_vendor/canvas-react/host/pluginHost.d.ts +93 -0
- package/_vendor/canvas-react/host/rendererRegistry.d.ts +12 -0
- package/_vendor/canvas-react/host/toolbarRegistry.d.ts +24 -0
- package/_vendor/plugin-arrow/ArrowBindingUtil.d.ts +27 -0
- package/_vendor/plugin-arrow/ArrowShapeUtil.d.ts +20 -0
- package/_vendor/plugin-arrow/ArrowTool.d.ts +4 -0
- package/_vendor/plugin-arrow/arrowGeometry.d.ts +50 -0
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.d.ts +21 -0
- package/_vendor/plugin-arrow/arrowTerminalCommands.d.ts +12 -0
- package/_vendor/plugin-arrow/canvas.d.ts +2 -0
- package/_vendor/plugin-arrow/core.d.ts +7 -0
- package/_vendor/plugin-arrow/feature.d.ts +3 -0
- package/_vendor/plugin-arrow/index.d.ts +11 -0
- package/_vendor/plugin-arrow/selectionHandleInteractions.d.ts +3 -0
- package/_vendor/plugin-arrow/types.d.ts +31 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.d.ts +8 -0
- package/_vendor/plugin-draw/DrawShapeUtil.d.ts +21 -0
- package/_vendor/plugin-draw/DrawTool.d.ts +6 -0
- package/_vendor/plugin-draw/canvas.d.ts +2 -0
- package/_vendor/plugin-draw/core.d.ts +7 -0
- package/_vendor/plugin-draw/drawGeometry.d.ts +45 -0
- package/_vendor/plugin-draw/drawHitTest.d.ts +11 -0
- package/_vendor/plugin-draw/drawInterpolation.d.ts +5 -0
- package/_vendor/plugin-draw/drawPath.d.ts +37 -0
- package/_vendor/plugin-draw/drawSegments.d.ts +11 -0
- package/_vendor/plugin-draw/drawSelectionTransform.d.ts +18 -0
- package/_vendor/plugin-draw/drawShapeGeometry.d.ts +33 -0
- package/_vendor/plugin-draw/drawStrokeGeometry.d.ts +17 -0
- package/_vendor/plugin-draw/feature.d.ts +3 -0
- package/_vendor/plugin-draw/index.d.ts +13 -0
- package/_vendor/plugin-draw/types.d.ts +23 -0
- package/_vendor/plugin-eraser/EraserTool.d.ts +5 -0
- package/_vendor/plugin-eraser/canvas.d.ts +2 -0
- package/_vendor/plugin-eraser/core.d.ts +2 -0
- package/_vendor/plugin-eraser/feature.d.ts +3 -0
- package/_vendor/plugin-frame/FrameShapeUtil.d.ts +22 -0
- package/_vendor/plugin-frame/FrameTool.d.ts +6 -0
- package/_vendor/plugin-frame/canvas.d.ts +8 -0
- package/_vendor/plugin-frame/core.d.ts +7 -0
- package/_vendor/plugin-frame/feature.d.ts +3 -0
- package/_vendor/plugin-geo/GeoShapeUtil.d.ts +13 -0
- package/_vendor/plugin-geo/GeoTools.d.ts +17 -0
- package/_vendor/plugin-geo/canvas.d.ts +11 -0
- package/_vendor/plugin-geo/core.d.ts +7 -0
- package/_vendor/plugin-geo/feature.d.ts +3 -0
- package/_vendor/plugin-geo/types.d.ts +15 -0
- package/_vendor/plugin-group/GroupShapeUtil.d.ts +15 -0
- package/_vendor/plugin-group/canvas.d.ts +10 -0
- package/_vendor/plugin-group/core.d.ts +7 -0
- package/_vendor/plugin-group/feature.d.ts +3 -0
- package/_vendor/plugin-image/ImageShapeUtil.d.ts +10 -0
- package/_vendor/plugin-image/canvas.d.ts +2 -0
- package/_vendor/plugin-image/core.d.ts +16 -0
- package/_vendor/plugin-image/crop.d.ts +112 -0
- package/_vendor/plugin-image/cropInteractions.d.ts +3 -0
- package/_vendor/plugin-image/cropSession.d.ts +4 -0
- package/_vendor/plugin-image/feature.d.ts +3 -0
- package/_vendor/plugin-image/index.d.ts +8 -0
- package/_vendor/plugin-image/types.d.ts +37 -0
- package/_vendor/plugin-image-product-react/ImageImportController.d.ts +9 -0
- package/_vendor/plugin-image-product-react/imageAssetService.d.ts +7 -0
- package/_vendor/plugin-image-product-react/imageBlobStore.d.ts +25 -0
- package/_vendor/plugin-image-product-react/imageHostActions.d.ts +35 -0
- package/_vendor/plugin-image-product-react/imageProductApi.d.ts +21 -0
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.d.ts +14 -0
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.d.ts +2 -0
- package/_vendor/plugin-image-product-react/index.d.ts +16 -0
- package/_vendor/plugin-image-product-react/snapshotGuards.d.ts +1 -0
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.d.ts +3 -0
- package/_vendor/plugin-image-product-react/useImageImport.d.ts +16 -0
- package/_vendor/plugin-laser/LaserTool.d.ts +4 -0
- package/_vendor/plugin-laser/canvas.d.ts +2 -0
- package/_vendor/plugin-laser/core.d.ts +2 -0
- package/_vendor/plugin-laser/feature.d.ts +3 -0
- package/_vendor/plugin-text/ArrowLabelBindingUtil.d.ts +42 -0
- package/_vendor/plugin-text/GeoLabelBindingUtil.d.ts +45 -0
- package/_vendor/plugin-text/TextShapeSvgExporter.d.ts +6 -0
- package/_vendor/plugin-text/TextShapeUtil.d.ts +19 -0
- package/_vendor/plugin-text/TextTool.d.ts +4 -0
- package/_vendor/plugin-text/canvas.d.ts +2 -0
- package/_vendor/plugin-text/core.d.ts +2 -0
- package/_vendor/plugin-text/feature.d.ts +3 -0
- package/_vendor/plugin-text/host/RichTextEditingBox.d.ts +5 -0
- package/_vendor/plugin-text/host/RichTextToolbar.d.ts +6 -0
- package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +24 -0
- package/_vendor/plugin-text/host/richTextRendering.d.ts +3 -0
- package/_vendor/plugin-text/host/textDomSelection.d.ts +7 -0
- package/_vendor/plugin-text/host/textEditingBoxStyle.d.ts +3 -0
- package/_vendor/plugin-text/host/textEntryFocus.d.ts +22 -0
- package/_vendor/plugin-text/host/textFontLoader.d.ts +2 -0
- package/_vendor/plugin-text/host/textMeasurement.d.ts +12 -0
- package/_vendor/plugin-text/host/textMeasurementSync.d.ts +10 -0
- package/_vendor/plugin-text/host/textRangeSelection.d.ts +14 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +8 -0
- package/_vendor/plugin-text/host/textShapeSync.d.ts +17 -0
- package/_vendor/plugin-text/host/tiptapTextEditorController.d.ts +33 -0
- package/_vendor/plugin-text/index.d.ts +4 -0
- package/_vendor/plugin-text/richTextUtils.d.ts +18 -0
- package/_vendor/plugin-text/textInteractions.d.ts +2 -0
- package/_vendor/plugin-text/textLabelHelpers.d.ts +44 -0
- package/_vendor/plugin-text/textShapeHelpers.d.ts +21 -0
- package/_vendor/plugin-text/textStyle.d.ts +9 -0
- package/_vendor/plugin-text/textTypes.d.ts +28 -0
- package/_vendor/signals/atom.d.ts +9 -0
- package/_vendor/signals/computed.d.ts +11 -0
- package/_vendor/signals/core.d.ts +17 -0
- package/_vendor/signals/effect.d.ts +29 -0
- package/_vendor/signals/types.d.ts +15 -0
- package/_vendor/store/Store.d.ts +26 -0
- package/_vendor/store/diff.d.ts +9 -0
- package/_vendor/store/history.d.ts +37 -0
- package/_vendor/store/index.d.ts +5 -0
- package/_vendor/store/types.d.ts +27 -0
- package/api/canvasKitApi.d.ts +2 -2
- package/index.css +1 -1
- package/index.d.ts +0 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/product/Shell.d.ts +2 -2
- package/product/chromeContext.d.ts +8 -8
- package/product/createCanvasKitEditor.d.ts +1 -1
- package/product/persistence.d.ts +1 -1
- package/product/product.d.ts +1 -1
- package/product/useCanvasClipboardShortcuts.d.ts +2 -2
- package/product-CxN5NN6u.mjs +4 -0
- package/product.mjs +1 -1
- package/standard/extensions.d.ts +1 -1
- package/standard/standardApi.d.ts +5 -5
- package/standard-R17_x8HU.mjs +44 -0
- package/standard.mjs +1 -1
- package/_vendor/canvas-core/bindings/BindingUtil.ts +0 -92
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.ts +0 -22
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.ts +0 -52
- package/_vendor/canvas-core/contextMenu.ts +0 -85
- package/_vendor/canvas-core/editor/Editor.ts +0 -2614
- package/_vendor/canvas-core/editor/HistoryManager.ts +0 -83
- package/_vendor/canvas-core/editor/StateNode.ts +0 -162
- package/_vendor/canvas-core/editor/camera.ts +0 -6
- package/_vendor/canvas-core/editor/clipboard.ts +0 -478
- package/_vendor/canvas-core/editor/commands.ts +0 -833
- package/_vendor/canvas-core/editor/edgeScroll.ts +0 -37
- package/_vendor/canvas-core/editor/editorComputedHelpers.ts +0 -257
- package/_vendor/canvas-core/editor/editorSelectionTransforms.ts +0 -116
- package/_vendor/canvas-core/editor/events.ts +0 -93
- package/_vendor/canvas-core/editor/interactions.ts +0 -101
- package/_vendor/canvas-core/editor/internal.ts +0 -22
- package/_vendor/canvas-core/editor/managers/BindingManager.ts +0 -262
- package/_vendor/canvas-core/editor/managers/CameraManager.ts +0 -147
- package/_vendor/canvas-core/editor/managers/ClipboardManager.ts +0 -32
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.ts +0 -256
- package/_vendor/canvas-core/editor/managers/InputsManager.ts +0 -319
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.ts +0 -218
- package/_vendor/canvas-core/editor/managers/QueryManager.ts +0 -837
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.ts +0 -347
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.ts +0 -196
- package/_vendor/canvas-core/editor/managers/SelectionManager.ts +0 -98
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.ts +0 -308
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.ts +0 -226
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.ts +0 -162
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.ts +0 -797
- package/_vendor/canvas-core/editor/managers/SideEffectManager.ts +0 -83
- package/_vendor/canvas-core/editor/managers/SnapManager.ts +0 -433
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.ts +0 -430
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.ts +0 -354
- package/_vendor/canvas-core/editor/managers/ToolManager.ts +0 -81
- package/_vendor/canvas-core/editor/managers/queryState.ts +0 -583
- package/_vendor/canvas-core/editor/managers/selectionGeometry.ts +0 -287
- package/_vendor/canvas-core/editor/managers/shapeOrder.ts +0 -350
- package/_vendor/canvas-core/editor/managers/shapeReparenting.ts +0 -160
- package/_vendor/canvas-core/editor/managers/snapCalculations.ts +0 -412
- package/_vendor/canvas-core/editor/managers/snapGeometry.ts +0 -202
- package/_vendor/canvas-core/editor/managers/snapIndicators.ts +0 -403
- package/_vendor/canvas-core/editor/managers/snapTypes.ts +0 -122
- package/_vendor/canvas-core/editor/queries/shapeTransforms.ts +0 -171
- package/_vendor/canvas-core/editor/renderWindow.ts +0 -439
- package/_vendor/canvas-core/editor/resizeGeometry.ts +0 -654
- package/_vendor/canvas-core/editor/selection.ts +0 -489
- package/_vendor/canvas-core/editor/selectionHandleInteractions.ts +0 -43
- package/_vendor/canvas-core/editor/selectionOverlay.ts +0 -567
- package/_vendor/canvas-core/exports/integrity.ts +0 -174
- package/_vendor/canvas-core/exports/svg.ts +0 -494
- package/_vendor/canvas-core/geometry/Box.ts +0 -80
- package/_vendor/canvas-core/geometry/Ellipse2d.ts +0 -67
- package/_vendor/canvas-core/geometry/Geometry2d.ts +0 -52
- package/_vendor/canvas-core/geometry/Mat.ts +0 -92
- package/_vendor/canvas-core/geometry/Polyline2d.ts +0 -63
- package/_vendor/canvas-core/geometry/Rectangle2d.ts +0 -64
- package/_vendor/canvas-core/geometry/Vec.ts +0 -123
- package/_vendor/canvas-core/geometry/segments.ts +0 -65
- package/_vendor/canvas-core/index.ts +0 -391
- package/_vendor/canvas-core/plugins/index.ts +0 -5
- package/_vendor/canvas-core/plugins/types.ts +0 -53
- package/_vendor/canvas-core/reactivity.ts +0 -16
- package/_vendor/canvas-core/schema/records.ts +0 -221
- package/_vendor/canvas-core/schema/snapshots.ts +0 -527
- package/_vendor/canvas-core/shapes/ShapeUtil.ts +0 -516
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.ts +0 -26
- package/_vendor/canvas-core/shapes/capabilities.ts +0 -67
- package/_vendor/canvas-core/shapes/types.ts +0 -20
- package/_vendor/canvas-core/toolbar.ts +0 -148
- package/_vendor/canvas-core/tools/hand/HandTool.ts +0 -75
- package/_vendor/canvas-core/tools/select/SelectTool.ts +0 -33
- package/_vendor/canvas-core/tools/select/selectContainment.ts +0 -104
- package/_vendor/canvas-core/tools/select/selectToolHelpers.ts +0 -801
- package/_vendor/canvas-core/tools/select/states/BrushingState.ts +0 -145
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.ts +0 -116
- package/_vendor/canvas-core/tools/select/states/IdleState.ts +0 -159
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.ts +0 -41
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.ts +0 -78
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.ts +0 -64
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.ts +0 -34
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.ts +0 -140
- package/_vendor/canvas-core/tools/select/states/ResizingState.ts +0 -171
- package/_vendor/canvas-core/tools/select/states/RotatingState.ts +0 -124
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.ts +0 -128
- package/_vendor/canvas-core/tools/select/states/TranslatingState.ts +0 -139
- package/_vendor/canvas-plugin-api/feature.ts +0 -204
- package/_vendor/canvas-plugin-api/index.ts +0 -142
- package/_vendor/canvas-product-react/api/apiRegistry.ts +0 -35
- package/_vendor/canvas-product-react/api/canvasProductApi.ts +0 -422
- package/_vendor/canvas-product-react/api/index.ts +0 -31
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.ts +0 -36
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.ts +0 -245
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.ts +0 -396
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.ts +0 -59
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.ts +0 -156
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.ts +0 -23
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.ts +0 -41
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.ts +0 -490
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.ts +0 -92
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.ts +0 -27
- package/_vendor/canvas-product-react/index.ts +0 -84
- package/_vendor/canvas-product-react/persistence/index.ts +0 -18
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.ts +0 -294
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.tsx +0 -250
- package/_vendor/canvas-product-react/runtime/productDefinition.ts +0 -72
- package/_vendor/canvas-product-react/runtime/productServices.ts +0 -96
- package/_vendor/canvas-react/components/CanvasView.tsx +0 -796
- package/_vendor/canvas-react/components/OverlayLayer.tsx +0 -879
- package/_vendor/canvas-react/components/PageSpace.tsx +0 -34
- package/_vendor/canvas-react/components/ShapeLayer.tsx +0 -428
- package/_vendor/canvas-react/hooks/useEditor.ts +0 -11
- package/_vendor/canvas-react/hooks/useValue.ts +0 -14
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.tsx +0 -14
- package/_vendor/canvas-react/host/contextMenuRegistry.ts +0 -61
- package/_vendor/canvas-react/host/domEventGuards.ts +0 -61
- package/_vendor/canvas-react/host/index.ts +0 -38
- package/_vendor/canvas-react/host/pluginHost.ts +0 -635
- package/_vendor/canvas-react/host/rendererRegistry.tsx +0 -58
- package/_vendor/canvas-react/host/toolbarRegistry.ts +0 -100
- package/_vendor/plugin-arrow/ArrowBindingUtil.ts +0 -239
- package/_vendor/plugin-arrow/ArrowShapeUtil.ts +0 -311
- package/_vendor/plugin-arrow/ArrowTool.ts +0 -208
- package/_vendor/plugin-arrow/arrowGeometry.ts +0 -441
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.ts +0 -253
- package/_vendor/plugin-arrow/arrowTerminalCommands.ts +0 -230
- package/_vendor/plugin-arrow/canvas.tsx +0 -92
- package/_vendor/plugin-arrow/core.ts +0 -409
- package/_vendor/plugin-arrow/feature.ts +0 -20
- package/_vendor/plugin-arrow/index.ts +0 -28
- package/_vendor/plugin-arrow/selectionHandleInteractions.ts +0 -154
- package/_vendor/plugin-arrow/types.ts +0 -63
- package/_vendor/plugin-draw/DrawShapeRenderer.tsx +0 -60
- package/_vendor/plugin-draw/DrawShapeUtil.ts +0 -372
- package/_vendor/plugin-draw/DrawTool.ts +0 -444
- package/_vendor/plugin-draw/canvas.tsx +0 -24
- package/_vendor/plugin-draw/core.ts +0 -515
- package/_vendor/plugin-draw/drawGeometry.ts +0 -491
- package/_vendor/plugin-draw/drawHitTest.ts +0 -271
- package/_vendor/plugin-draw/drawInterpolation.ts +0 -250
- package/_vendor/plugin-draw/drawPath.ts +0 -550
- package/_vendor/plugin-draw/drawSegments.ts +0 -106
- package/_vendor/plugin-draw/drawSelectionTransform.ts +0 -67
- package/_vendor/plugin-draw/drawShapeGeometry.ts +0 -307
- package/_vendor/plugin-draw/drawStrokeGeometry.ts +0 -454
- package/_vendor/plugin-draw/feature.ts +0 -20
- package/_vendor/plugin-draw/index.ts +0 -31
- package/_vendor/plugin-draw/types.ts +0 -36
- package/_vendor/plugin-eraser/EraserTool.ts +0 -297
- package/_vendor/plugin-eraser/canvas.tsx +0 -616
- package/_vendor/plugin-eraser/core.ts +0 -49
- package/_vendor/plugin-eraser/feature.ts +0 -20
- package/_vendor/plugin-frame/FrameShapeUtil.ts +0 -173
- package/_vendor/plugin-frame/FrameTool.ts +0 -225
- package/_vendor/plugin-frame/canvas.tsx +0 -75
- package/_vendor/plugin-frame/core.ts +0 -534
- package/_vendor/plugin-frame/feature.ts +0 -20
- package/_vendor/plugin-geo/GeoShapeUtil.ts +0 -463
- package/_vendor/plugin-geo/GeoTools.ts +0 -247
- package/_vendor/plugin-geo/canvas.tsx +0 -90
- package/_vendor/plugin-geo/core.ts +0 -495
- package/_vendor/plugin-geo/feature.ts +0 -20
- package/_vendor/plugin-geo/types.ts +0 -27
- package/_vendor/plugin-group/GroupShapeUtil.ts +0 -59
- package/_vendor/plugin-group/canvas.tsx +0 -59
- package/_vendor/plugin-group/core.ts +0 -40
- package/_vendor/plugin-group/feature.ts +0 -20
- package/_vendor/plugin-image/ImageShapeUtil.ts +0 -95
- package/_vendor/plugin-image/canvas.tsx +0 -212
- package/_vendor/plugin-image/core.ts +0 -542
- package/_vendor/plugin-image/crop.ts +0 -770
- package/_vendor/plugin-image/cropInteractions.ts +0 -350
- package/_vendor/plugin-image/cropSession.ts +0 -38
- package/_vendor/plugin-image/feature.ts +0 -20
- package/_vendor/plugin-image/index.ts +0 -29
- package/_vendor/plugin-image/types.ts +0 -55
- package/_vendor/plugin-image-product-react/ImageImportController.tsx +0 -143
- package/_vendor/plugin-image-product-react/imageAssetService.ts +0 -52
- package/_vendor/plugin-image-product-react/imageBlobStore.ts +0 -315
- package/_vendor/plugin-image-product-react/imageHostActions.ts +0 -438
- package/_vendor/plugin-image-product-react/imageProductApi.ts +0 -88
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.ts +0 -48
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.ts +0 -21
- package/_vendor/plugin-image-product-react/index.ts +0 -60
- package/_vendor/plugin-image-product-react/snapshotGuards.ts +0 -33
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.ts +0 -54
- package/_vendor/plugin-image-product-react/useImageImport.ts +0 -64
- package/_vendor/plugin-laser/LaserTool.ts +0 -154
- package/_vendor/plugin-laser/canvas.tsx +0 -645
- package/_vendor/plugin-laser/core.ts +0 -49
- package/_vendor/plugin-laser/feature.ts +0 -20
- package/_vendor/plugin-text/ArrowLabelBindingUtil.ts +0 -336
- package/_vendor/plugin-text/GeoLabelBindingUtil.ts +0 -391
- package/_vendor/plugin-text/TextShapeSvgExporter.ts +0 -101
- package/_vendor/plugin-text/TextShapeUtil.ts +0 -284
- package/_vendor/plugin-text/TextTool.ts +0 -228
- package/_vendor/plugin-text/canvas.tsx +0 -115
- package/_vendor/plugin-text/core.ts +0 -422
- package/_vendor/plugin-text/feature.ts +0 -20
- package/_vendor/plugin-text/host/RichTextEditingBox.tsx +0 -144
- package/_vendor/plugin-text/host/RichTextToolbar.tsx +0 -266
- package/_vendor/plugin-text/host/TiptapTextEditor.tsx +0 -191
- package/_vendor/plugin-text/host/richTextRendering.tsx +0 -49
- package/_vendor/plugin-text/host/textDomSelection.ts +0 -93
- package/_vendor/plugin-text/host/textEditingBoxStyle.ts +0 -36
- package/_vendor/plugin-text/host/textEntryFocus.ts +0 -307
- package/_vendor/plugin-text/host/textFontLoader.ts +0 -149
- package/_vendor/plugin-text/host/textMeasurement.ts +0 -258
- package/_vendor/plugin-text/host/textMeasurementSync.ts +0 -77
- package/_vendor/plugin-text/host/textRangeSelection.ts +0 -134
- package/_vendor/plugin-text/host/textShapeRendererRuntime.tsx +0 -89
- package/_vendor/plugin-text/host/textShapeSync.ts +0 -173
- package/_vendor/plugin-text/host/tiptapTextEditorController.ts +0 -148
- package/_vendor/plugin-text/index.ts +0 -18
- package/_vendor/plugin-text/richTextUtils.ts +0 -259
- package/_vendor/plugin-text/textInteractions.ts +0 -366
- package/_vendor/plugin-text/textLabelHelpers.ts +0 -235
- package/_vendor/plugin-text/textShapeHelpers.ts +0 -123
- package/_vendor/plugin-text/textStyle.ts +0 -96
- package/_vendor/plugin-text/textTypes.ts +0 -48
- package/_vendor/signals/atom.ts +0 -74
- package/_vendor/signals/computed.ts +0 -132
- package/_vendor/signals/core.ts +0 -130
- package/_vendor/signals/effect.ts +0 -117
- package/_vendor/signals/types.ts +0 -17
- package/_vendor/store/Store.ts +0 -171
- package/_vendor/store/diff.ts +0 -229
- package/_vendor/store/history.ts +0 -177
- package/_vendor/store/index.ts +0 -32
- package/_vendor/store/types.ts +0 -37
- package/internal-modules.d.ts +0 -187
- package/product-iyBbEPIs.mjs +0 -4
- package/standard-BmrxwqpJ.mjs +0 -44
- /package/_vendor/canvas-core/tools/{index.ts → index.d.ts} +0 -0
- /package/_vendor/canvas-core/tools/select/states/{index.ts → index.d.ts} +0 -0
- /package/_vendor/canvas-react/components/{index.ts → index.d.ts} +0 -0
- /package/_vendor/canvas-react/{index.ts → index.d.ts} +0 -0
- /package/_vendor/plugin-eraser/{index.ts → index.d.ts} +0 -0
- /package/_vendor/plugin-frame/{index.ts → index.d.ts} +0 -0
- /package/_vendor/plugin-geo/{index.ts → index.d.ts} +0 -0
- /package/_vendor/plugin-group/{index.ts → index.d.ts} +0 -0
- /package/_vendor/plugin-laser/{index.ts → index.d.ts} +0 -0
- /package/_vendor/signals/{index.ts → index.d.ts} +0 -0
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
import { memo, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { type LandCanvasPlugin } from "@land/canvas-plugin-api";
|
|
3
|
-
import { type Vec } from "@land/canvas-core";
|
|
4
|
-
import { PageSpace, useEditor, useValue } from "@land/canvas-react";
|
|
5
|
-
|
|
6
|
-
export function createEraserCanvasPlugin(): LandCanvasPlugin {
|
|
7
|
-
return {
|
|
8
|
-
id: "land.eraser.react",
|
|
9
|
-
canvasComponents: [
|
|
10
|
-
{
|
|
11
|
-
id: "land.eraser.trail-overlay",
|
|
12
|
-
component: EraserTrailOverlay,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
setup() {
|
|
16
|
-
// Eraser does not render shape records.
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const EraserTrailOverlay = memo(function EraserTrailOverlay() {
|
|
22
|
-
const editor = useEditor();
|
|
23
|
-
const isTrailActive = useValue(editor.eraserTrailActiveSignal);
|
|
24
|
-
|
|
25
|
-
if (!isTrailActive) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<PageSpace
|
|
31
|
-
dataUi="eraser-trail-page-space"
|
|
32
|
-
className="pointer-events-none absolute inset-0"
|
|
33
|
-
>
|
|
34
|
-
<svg
|
|
35
|
-
width="100%"
|
|
36
|
-
height="100%"
|
|
37
|
-
style={{
|
|
38
|
-
display: "block",
|
|
39
|
-
width: "100%",
|
|
40
|
-
height: "100%",
|
|
41
|
-
overflow: "visible",
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
<EraserTrailContent />
|
|
45
|
-
</svg>
|
|
46
|
-
</PageSpace>
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const EraserTrailContent = memo(function EraserTrailContent() {
|
|
51
|
-
const editor = useEditor();
|
|
52
|
-
const trail = useValue(editor.eraserTrailSignal);
|
|
53
|
-
const zoom = useValue(editor.cameraZoomSignal);
|
|
54
|
-
const safeZoom = Math.max(zoom, 0.0001);
|
|
55
|
-
const clockTime = useAnimationClock();
|
|
56
|
-
const sampleState = useRef<EraserTrailSampleState>({
|
|
57
|
-
samples: [],
|
|
58
|
-
sourceLength: 0,
|
|
59
|
-
});
|
|
60
|
-
const renderTime = Math.max(clockTime, getNowMs());
|
|
61
|
-
syncEraserTrailSampleState(
|
|
62
|
-
sampleState.current,
|
|
63
|
-
trail,
|
|
64
|
-
safeZoom,
|
|
65
|
-
renderTime,
|
|
66
|
-
);
|
|
67
|
-
const trailPoints = getRenderableEraserTrailPoints(
|
|
68
|
-
sampleState.current.samples,
|
|
69
|
-
renderTime,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (trailPoints.length === 0) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const path = getEraserScribblePath(
|
|
77
|
-
trailPoints,
|
|
78
|
-
ERASER_SCRIBBLE_SIZE / safeZoom,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
if (!path) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<g data-ui="eraser-trail-overlay">
|
|
87
|
-
<path
|
|
88
|
-
data-ui="eraser-trail-scribble"
|
|
89
|
-
d={path}
|
|
90
|
-
fill={ERASER_SCRIBBLE_FILL}
|
|
91
|
-
/>
|
|
92
|
-
</g>
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
interface TrailRenderPoint {
|
|
97
|
-
x: number;
|
|
98
|
-
y: number;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
interface EraserTrailTimedPoint extends TrailRenderPoint {
|
|
102
|
-
time: number;
|
|
103
|
-
velocity: number;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface EraserTrailSampleState {
|
|
107
|
-
samples: EraserTrailTimedPoint[];
|
|
108
|
-
sourceLength: number;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
interface EraserScribbleSample {
|
|
112
|
-
point: TrailRenderPoint;
|
|
113
|
-
direction: TrailRenderPoint;
|
|
114
|
-
radius: number;
|
|
115
|
-
runningLength: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const ERASER_SCRIBBLE_FILL = "rgba(142, 142, 142, 0.16)";
|
|
119
|
-
const ERASER_SCRIBBLE_MAX_POINTS = 48;
|
|
120
|
-
const ERASER_SCRIBBLE_MIN_POINT_DISTANCE = 1;
|
|
121
|
-
const ERASER_SCRIBBLE_SIZE = 12;
|
|
122
|
-
const ERASER_SCRIBBLE_STREAMLINE = 0.32;
|
|
123
|
-
const ERASER_SCRIBBLE_CAP_STEPS = 8;
|
|
124
|
-
const ERASER_SCRIBBLE_DOT_STEPS = 13;
|
|
125
|
-
const ERASER_SCRIBBLE_INITIAL_SAMPLE_INTERVAL = 16;
|
|
126
|
-
const ERASER_SCRIBBLE_MIN_SAMPLE_INTERVAL = 8;
|
|
127
|
-
const ERASER_SCRIBBLE_BASE_LIFETIME = 180;
|
|
128
|
-
const ERASER_SCRIBBLE_SPEED_LIFETIME = 180;
|
|
129
|
-
const ERASER_SCRIBBLE_MAX_LIFETIME = 680;
|
|
130
|
-
|
|
131
|
-
function useAnimationClock(): number {
|
|
132
|
-
const [time, setTime] = useState(() => getNowMs());
|
|
133
|
-
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
if (typeof window === "undefined") {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
let frame = 0;
|
|
140
|
-
const tick = (nextTime: number) => {
|
|
141
|
-
setTime(nextTime);
|
|
142
|
-
frame = window.requestAnimationFrame(tick);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
frame = window.requestAnimationFrame(tick);
|
|
146
|
-
return () => {
|
|
147
|
-
window.cancelAnimationFrame(frame);
|
|
148
|
-
};
|
|
149
|
-
}, []);
|
|
150
|
-
|
|
151
|
-
return time;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function getNowMs(): number {
|
|
155
|
-
return typeof performance === "undefined" ? Date.now() : performance.now();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function syncEraserTrailSampleState(
|
|
159
|
-
state: EraserTrailSampleState,
|
|
160
|
-
points: readonly Vec[],
|
|
161
|
-
zoom: number,
|
|
162
|
-
now: number,
|
|
163
|
-
): void {
|
|
164
|
-
pruneEraserTrailSamples(state, now);
|
|
165
|
-
if (points.length < state.sourceLength) {
|
|
166
|
-
state.samples = [];
|
|
167
|
-
state.sourceLength = 0;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (points.length === state.sourceLength) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const firstNewIndex = state.sourceLength;
|
|
175
|
-
const newPointCount = points.length - firstNewIndex;
|
|
176
|
-
const previousTime =
|
|
177
|
-
state.samples[state.samples.length - 1]?.time ??
|
|
178
|
-
now - ERASER_SCRIBBLE_INITIAL_SAMPLE_INTERVAL * newPointCount;
|
|
179
|
-
for (let i = firstNewIndex; i < points.length; i++) {
|
|
180
|
-
const point = points[i];
|
|
181
|
-
const progress = (i - firstNewIndex + 1) / newPointCount;
|
|
182
|
-
appendEraserTrailSample(
|
|
183
|
-
state,
|
|
184
|
-
{ x: point.x, y: point.y },
|
|
185
|
-
zoom,
|
|
186
|
-
lerpNumber(previousTime, now, progress),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
state.sourceLength = points.length;
|
|
191
|
-
pruneEraserTrailSamples(state, now);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function appendEraserTrailSample(
|
|
195
|
-
state: EraserTrailSampleState,
|
|
196
|
-
point: TrailRenderPoint,
|
|
197
|
-
zoom: number,
|
|
198
|
-
time: number,
|
|
199
|
-
): void {
|
|
200
|
-
const previous = state.samples[state.samples.length - 1];
|
|
201
|
-
if (!previous) {
|
|
202
|
-
state.samples.push({ ...point, time, velocity: 0 });
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const minDistance = ERASER_SCRIBBLE_MIN_POINT_DISTANCE / zoom;
|
|
207
|
-
const distance = getTrailPointDistance(previous, point);
|
|
208
|
-
if (distance < minDistance) {
|
|
209
|
-
state.samples[state.samples.length - 1] = {
|
|
210
|
-
...previous,
|
|
211
|
-
...point,
|
|
212
|
-
time,
|
|
213
|
-
};
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const elapsed = Math.max(
|
|
218
|
-
ERASER_SCRIBBLE_MIN_SAMPLE_INTERVAL,
|
|
219
|
-
time - previous.time,
|
|
220
|
-
);
|
|
221
|
-
const screenVelocity = (distance * zoom) / elapsed;
|
|
222
|
-
state.samples.push({
|
|
223
|
-
...point,
|
|
224
|
-
time,
|
|
225
|
-
velocity: lerpNumber(previous.velocity, screenVelocity, 0.68),
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function pruneEraserTrailSamples(
|
|
230
|
-
state: EraserTrailSampleState,
|
|
231
|
-
now: number,
|
|
232
|
-
): void {
|
|
233
|
-
state.samples = getActiveEraserTrailSamples(state.samples, now);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function getRenderableEraserTrailPoints(
|
|
237
|
-
samples: readonly EraserTrailTimedPoint[],
|
|
238
|
-
now: number,
|
|
239
|
-
): TrailRenderPoint[] {
|
|
240
|
-
const activeSamples = getActiveEraserTrailSamples(samples, now);
|
|
241
|
-
const activePoints =
|
|
242
|
-
activeSamples.length > ERASER_SCRIBBLE_MAX_POINTS
|
|
243
|
-
? activeSamples.slice(-ERASER_SCRIBBLE_MAX_POINTS)
|
|
244
|
-
: activeSamples;
|
|
245
|
-
return getStreamlinedTrailPoints(activePoints, ERASER_SCRIBBLE_STREAMLINE);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function getActiveEraserTrailSamples(
|
|
249
|
-
samples: readonly EraserTrailTimedPoint[],
|
|
250
|
-
now: number,
|
|
251
|
-
): EraserTrailTimedPoint[] {
|
|
252
|
-
const head = samples[samples.length - 1];
|
|
253
|
-
if (!head) {
|
|
254
|
-
return [];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const cutoffTime = now - getEraserTrailSampleLifetime(head);
|
|
258
|
-
if (head.time < cutoffTime) {
|
|
259
|
-
return [];
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const firstActiveIndex = samples.findIndex(
|
|
263
|
-
(sample) => sample.time >= cutoffTime,
|
|
264
|
-
);
|
|
265
|
-
if (firstActiveIndex === -1) {
|
|
266
|
-
return [];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const activeSamples = samples.slice(firstActiveIndex);
|
|
270
|
-
const previous = samples[firstActiveIndex - 1];
|
|
271
|
-
const first = activeSamples[0];
|
|
272
|
-
if (previous && first.time > cutoffTime) {
|
|
273
|
-
const t = clamp(
|
|
274
|
-
(cutoffTime - previous.time) / (first.time - previous.time),
|
|
275
|
-
0,
|
|
276
|
-
1,
|
|
277
|
-
);
|
|
278
|
-
return [lerpEraserTrailSample(previous, first, t), ...activeSamples];
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return activeSamples;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function lerpEraserTrailSample(
|
|
285
|
-
a: EraserTrailTimedPoint,
|
|
286
|
-
b: EraserTrailTimedPoint,
|
|
287
|
-
t: number,
|
|
288
|
-
): EraserTrailTimedPoint {
|
|
289
|
-
return {
|
|
290
|
-
...lerpTrailPoint(a, b, t),
|
|
291
|
-
time: lerpNumber(a.time, b.time, t),
|
|
292
|
-
velocity: lerpNumber(a.velocity, b.velocity, t),
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function getEraserTrailSampleLifetime(sample: EraserTrailTimedPoint): number {
|
|
297
|
-
return clamp(
|
|
298
|
-
ERASER_SCRIBBLE_BASE_LIFETIME +
|
|
299
|
-
sample.velocity * ERASER_SCRIBBLE_SPEED_LIFETIME,
|
|
300
|
-
ERASER_SCRIBBLE_BASE_LIFETIME,
|
|
301
|
-
ERASER_SCRIBBLE_MAX_LIFETIME,
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function getStreamlinedTrailPoints(
|
|
306
|
-
points: readonly TrailRenderPoint[],
|
|
307
|
-
streamline: number,
|
|
308
|
-
): TrailRenderPoint[] {
|
|
309
|
-
if (points.length <= 1) {
|
|
310
|
-
return [...points];
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const t = 0.15 + (1 - streamline) * 0.85;
|
|
314
|
-
const result: TrailRenderPoint[] = [points[0]];
|
|
315
|
-
for (let i = 1; i < points.length; i++) {
|
|
316
|
-
result.push(lerpTrailPoint(result[result.length - 1], points[i], t));
|
|
317
|
-
}
|
|
318
|
-
return result;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function getEraserScribblePath(
|
|
322
|
-
points: readonly TrailRenderPoint[],
|
|
323
|
-
size: number,
|
|
324
|
-
): string | null {
|
|
325
|
-
if (points.length === 0 || size <= 0) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (points.length === 1) {
|
|
330
|
-
return getCircleTrailPath(points[0], size / 2);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const samples = getEraserScribbleSamples(points, size);
|
|
334
|
-
const outline = getEraserScribbleOutline(samples);
|
|
335
|
-
return getSmoothClosedTrailPathFromPoints(outline);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function getEraserScribbleSamples(
|
|
339
|
-
points: readonly TrailRenderPoint[],
|
|
340
|
-
size: number,
|
|
341
|
-
): EraserScribbleSample[] {
|
|
342
|
-
const runningLengths = getTrailRunningLengths(points);
|
|
343
|
-
const totalLength = runningLengths[runningLengths.length - 1] ?? 0;
|
|
344
|
-
const taperLength = Math.max(size, totalLength);
|
|
345
|
-
|
|
346
|
-
return points.map((point, index) => {
|
|
347
|
-
const runningLength = runningLengths[index] ?? 0;
|
|
348
|
-
const taper = clamp(runningLength / taperLength, 0, 1);
|
|
349
|
-
return {
|
|
350
|
-
point,
|
|
351
|
-
direction: getTrailPointDirection(points, index),
|
|
352
|
-
radius: (size / 2) * taper,
|
|
353
|
-
runningLength,
|
|
354
|
-
};
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function getEraserScribbleOutline(
|
|
359
|
-
samples: readonly EraserScribbleSample[],
|
|
360
|
-
): TrailRenderPoint[] {
|
|
361
|
-
if (samples.length === 0) {
|
|
362
|
-
return [];
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (samples.length === 1) {
|
|
366
|
-
return getCircleTrailPoints(
|
|
367
|
-
samples[0].point,
|
|
368
|
-
Math.max(samples[0].radius, 0.01),
|
|
369
|
-
ERASER_SCRIBBLE_DOT_STEPS,
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const leftPoints: TrailRenderPoint[] = [];
|
|
374
|
-
const rightPoints: TrailRenderPoint[] = [];
|
|
375
|
-
|
|
376
|
-
for (const sample of samples) {
|
|
377
|
-
const normal = getTrailPointPerpendicular(sample.direction);
|
|
378
|
-
appendDistinctTrailPoint(
|
|
379
|
-
leftPoints,
|
|
380
|
-
subtractTrailPoints(sample.point, multiplyTrailPoint(normal, sample.radius)),
|
|
381
|
-
);
|
|
382
|
-
appendDistinctTrailPoint(
|
|
383
|
-
rightPoints,
|
|
384
|
-
addTrailPoints(sample.point, multiplyTrailPoint(normal, sample.radius)),
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const outline: TrailRenderPoint[] = [];
|
|
389
|
-
for (const point of leftPoints) {
|
|
390
|
-
appendDistinctTrailPoint(outline, point);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const lastSample = samples[samples.length - 1];
|
|
394
|
-
const lastNormal = getTrailPointPerpendicular(lastSample.direction);
|
|
395
|
-
const endCap = getRoundEndCapTrailPoints({
|
|
396
|
-
center: lastSample.point,
|
|
397
|
-
direction: lastSample.direction,
|
|
398
|
-
normal: lastNormal,
|
|
399
|
-
radius: lastSample.radius,
|
|
400
|
-
});
|
|
401
|
-
for (const point of endCap) {
|
|
402
|
-
appendDistinctTrailPoint(outline, point);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
for (let i = rightPoints.length - 1; i >= 0; i--) {
|
|
406
|
-
appendDistinctTrailPoint(outline, rightPoints[i]);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return outline;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
function getTrailRunningLengths(
|
|
413
|
-
points: readonly TrailRenderPoint[],
|
|
414
|
-
): number[] {
|
|
415
|
-
const runningLengths = [0];
|
|
416
|
-
for (let i = 1; i < points.length; i++) {
|
|
417
|
-
runningLengths.push(
|
|
418
|
-
runningLengths[i - 1] + getTrailPointDistance(points[i - 1], points[i]),
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
return runningLengths;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function getTrailPointDirection(
|
|
425
|
-
points: readonly TrailRenderPoint[],
|
|
426
|
-
index: number,
|
|
427
|
-
): TrailRenderPoint {
|
|
428
|
-
if (points.length <= 1) {
|
|
429
|
-
return { x: 1, y: 0 };
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const previous = points[index - 1] ?? points[index];
|
|
433
|
-
const next = points[index + 1] ?? points[index];
|
|
434
|
-
const direction =
|
|
435
|
-
index === 0
|
|
436
|
-
? subtractTrailPoints(next, points[index])
|
|
437
|
-
: index === points.length - 1
|
|
438
|
-
? subtractTrailPoints(points[index], previous)
|
|
439
|
-
: subtractTrailPoints(next, previous);
|
|
440
|
-
|
|
441
|
-
return normalizeTrailPoint(direction);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function getRoundEndCapTrailPoints({
|
|
445
|
-
center,
|
|
446
|
-
direction,
|
|
447
|
-
normal,
|
|
448
|
-
radius,
|
|
449
|
-
}: {
|
|
450
|
-
center: TrailRenderPoint;
|
|
451
|
-
direction: TrailRenderPoint;
|
|
452
|
-
normal: TrailRenderPoint;
|
|
453
|
-
radius: number;
|
|
454
|
-
}): TrailRenderPoint[] {
|
|
455
|
-
if (radius <= 0) {
|
|
456
|
-
return [];
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const points: TrailRenderPoint[] = [];
|
|
460
|
-
for (let step = 1; step < ERASER_SCRIBBLE_CAP_STEPS; step++) {
|
|
461
|
-
const t = step / ERASER_SCRIBBLE_CAP_STEPS;
|
|
462
|
-
points.push(
|
|
463
|
-
addTrailPoints(
|
|
464
|
-
center,
|
|
465
|
-
addTrailPoints(
|
|
466
|
-
multiplyTrailPoint(direction, Math.sin(Math.PI * t) * radius),
|
|
467
|
-
multiplyTrailPoint(normal, -Math.cos(Math.PI * t) * radius),
|
|
468
|
-
),
|
|
469
|
-
),
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
return points;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function getCircleTrailPath(center: TrailRenderPoint, radius: number): string {
|
|
476
|
-
const points = getCircleTrailPoints(
|
|
477
|
-
center,
|
|
478
|
-
radius,
|
|
479
|
-
ERASER_SCRIBBLE_DOT_STEPS,
|
|
480
|
-
);
|
|
481
|
-
return getSmoothClosedTrailPathFromPoints(points) ?? "";
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function getCircleTrailPoints(
|
|
485
|
-
center: TrailRenderPoint,
|
|
486
|
-
radius: number,
|
|
487
|
-
steps: number,
|
|
488
|
-
): TrailRenderPoint[] {
|
|
489
|
-
const points: TrailRenderPoint[] = [];
|
|
490
|
-
for (let step = 0; step < steps; step++) {
|
|
491
|
-
const angle = (Math.PI * 2 * step) / steps;
|
|
492
|
-
points.push({
|
|
493
|
-
x: center.x + Math.cos(angle) * radius,
|
|
494
|
-
y: center.y + Math.sin(angle) * radius,
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
return points;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function getTrailPointDistance(a: TrailRenderPoint, b: TrailRenderPoint): number {
|
|
501
|
-
return Math.sqrt(getTrailPointDistanceSquared(a, b));
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function getTrailPointDistanceSquared(
|
|
505
|
-
a: TrailRenderPoint,
|
|
506
|
-
b: TrailRenderPoint,
|
|
507
|
-
): number {
|
|
508
|
-
const dx = a.x - b.x;
|
|
509
|
-
const dy = a.y - b.y;
|
|
510
|
-
return dx * dx + dy * dy;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
function getTrailPointPerpendicular(point: TrailRenderPoint): TrailRenderPoint {
|
|
514
|
-
return { x: -point.y, y: point.x };
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
function normalizeTrailPoint(point: TrailRenderPoint): TrailRenderPoint {
|
|
518
|
-
const length = Math.sqrt(point.x * point.x + point.y * point.y);
|
|
519
|
-
if (length <= 0) {
|
|
520
|
-
return { x: 1, y: 0 };
|
|
521
|
-
}
|
|
522
|
-
return { x: point.x / length, y: point.y / length };
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
function addTrailPoints(
|
|
526
|
-
a: TrailRenderPoint,
|
|
527
|
-
b: TrailRenderPoint,
|
|
528
|
-
): TrailRenderPoint {
|
|
529
|
-
return { x: a.x + b.x, y: a.y + b.y };
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function subtractTrailPoints(
|
|
533
|
-
a: TrailRenderPoint,
|
|
534
|
-
b: TrailRenderPoint,
|
|
535
|
-
): TrailRenderPoint {
|
|
536
|
-
return { x: a.x - b.x, y: a.y - b.y };
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
function multiplyTrailPoint(
|
|
540
|
-
point: TrailRenderPoint,
|
|
541
|
-
scale: number,
|
|
542
|
-
): TrailRenderPoint {
|
|
543
|
-
return { x: point.x * scale, y: point.y * scale };
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function lerpTrailPoint(
|
|
547
|
-
a: TrailRenderPoint,
|
|
548
|
-
b: TrailRenderPoint,
|
|
549
|
-
t: number,
|
|
550
|
-
): TrailRenderPoint {
|
|
551
|
-
return {
|
|
552
|
-
x: lerpNumber(a.x, b.x, t),
|
|
553
|
-
y: lerpNumber(a.y, b.y, t),
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
function lerpNumber(a: number, b: number, t: number): number {
|
|
558
|
-
return a + (b - a) * t;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function clamp(value: number, min: number, max: number): number {
|
|
562
|
-
return Math.max(min, Math.min(max, value));
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
function appendDistinctTrailPoint(
|
|
566
|
-
points: TrailRenderPoint[],
|
|
567
|
-
point: TrailRenderPoint,
|
|
568
|
-
): void {
|
|
569
|
-
const previous = points[points.length - 1];
|
|
570
|
-
if (!previous || getTrailPointDistanceSquared(previous, point) > 0.04) {
|
|
571
|
-
points.push(point);
|
|
572
|
-
} else {
|
|
573
|
-
points[points.length - 1] = point;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
function getSmoothClosedTrailPathFromPoints(
|
|
578
|
-
points: readonly TrailRenderPoint[],
|
|
579
|
-
): string | null {
|
|
580
|
-
if (points.length < 2) {
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
if (points.length === 2) {
|
|
585
|
-
return `M ${formatTrailSvgPoint(points[0])} L ${formatTrailSvgPoint(points[1])} Z`;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
const commands = [
|
|
589
|
-
`M ${formatTrailSvgPoint(getTrailMidpoint(points[0], points[1]))}`,
|
|
590
|
-
];
|
|
591
|
-
for (let i = 1; i < points.length; i++) {
|
|
592
|
-
const current = points[i];
|
|
593
|
-
const next = points[(i + 1) % points.length];
|
|
594
|
-
commands.push(
|
|
595
|
-
`Q ${formatTrailSvgPoint(current)} ${formatTrailSvgPoint(getTrailMidpoint(current, next))}`,
|
|
596
|
-
);
|
|
597
|
-
}
|
|
598
|
-
commands.push("Z");
|
|
599
|
-
|
|
600
|
-
return commands.join(" ");
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function getTrailMidpoint(
|
|
604
|
-
a: TrailRenderPoint,
|
|
605
|
-
b: TrailRenderPoint,
|
|
606
|
-
): TrailRenderPoint {
|
|
607
|
-
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
function formatTrailSvgPoint(point: TrailRenderPoint): string {
|
|
611
|
-
return `${formatTrailSvgNumber(point.x)},${formatTrailSvgNumber(point.y)}`;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
function formatTrailSvgNumber(value: number): string {
|
|
615
|
-
return Number.isInteger(value) ? `${value}` : value.toFixed(3);
|
|
616
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SET_ACTIVE_TOOL_TOOLBAR_ACTION_ID,
|
|
3
|
-
type LandCorePlugin,
|
|
4
|
-
type ToolbarContribution,
|
|
5
|
-
} from "@land/canvas-core";
|
|
6
|
-
import { EraserTool } from "./EraserTool";
|
|
7
|
-
|
|
8
|
-
export function createEraserCorePlugin(): LandCorePlugin {
|
|
9
|
-
return {
|
|
10
|
-
id: "land.eraser",
|
|
11
|
-
toolbarContributions: [createEraserToolToolbarContribution()],
|
|
12
|
-
setup(editor) {
|
|
13
|
-
editor.tools.register(
|
|
14
|
-
"eraser",
|
|
15
|
-
(currentEditor) => new EraserTool(currentEditor),
|
|
16
|
-
{ shortcut: "e" },
|
|
17
|
-
);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function createEraserToolToolbarContribution(): ToolbarContribution {
|
|
23
|
-
return {
|
|
24
|
-
id: "eraser.tool-toolbar",
|
|
25
|
-
surface: "tool",
|
|
26
|
-
placement: "chrome",
|
|
27
|
-
order: 50,
|
|
28
|
-
actionIds: [SET_ACTIVE_TOOL_TOOLBAR_ACTION_ID],
|
|
29
|
-
getGroups() {
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
id: "eraser.tools",
|
|
33
|
-
items: [
|
|
34
|
-
{
|
|
35
|
-
kind: "button",
|
|
36
|
-
id: "eraser.tool.eraser",
|
|
37
|
-
actionId: SET_ACTIVE_TOOL_TOOLBAR_ACTION_ID,
|
|
38
|
-
value: "eraser",
|
|
39
|
-
label: "Eraser",
|
|
40
|
-
shortcut: "E",
|
|
41
|
-
icon: "eraser",
|
|
42
|
-
dataUi: "eraser-tool-button",
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineLandExtension,
|
|
3
|
-
type LandFeatureBundle,
|
|
4
|
-
} from "@land/canvas-plugin-api";
|
|
5
|
-
import { createEraserCanvasPlugin } from "./canvas";
|
|
6
|
-
import { createEraserCorePlugin } from "./core";
|
|
7
|
-
|
|
8
|
-
export function createEraserFeatureBundle(): LandFeatureBundle {
|
|
9
|
-
return {
|
|
10
|
-
id: "land.eraser.bundle",
|
|
11
|
-
corePlugins: [createEraserCorePlugin()],
|
|
12
|
-
canvasPlugins: [createEraserCanvasPlugin()],
|
|
13
|
-
shapeTypes: [],
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Eraser = defineLandExtension({
|
|
18
|
-
name: "eraser",
|
|
19
|
-
createFeature: createEraserFeatureBundle,
|
|
20
|
-
});
|