@yuzhouu/canvas-kit 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/_vendor/canvas-core/bindings/BindingUtil.ts +92 -0
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.ts +22 -0
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.ts +52 -0
- package/_vendor/canvas-core/contextMenu.ts +85 -0
- package/_vendor/canvas-core/editor/Editor.ts +2614 -0
- package/_vendor/canvas-core/editor/HistoryManager.ts +83 -0
- package/_vendor/canvas-core/editor/StateNode.ts +162 -0
- package/_vendor/canvas-core/editor/camera.ts +6 -0
- package/_vendor/canvas-core/editor/clipboard.ts +478 -0
- package/_vendor/canvas-core/editor/commands.ts +833 -0
- package/_vendor/canvas-core/editor/edgeScroll.ts +37 -0
- package/_vendor/canvas-core/editor/editorComputedHelpers.ts +257 -0
- package/_vendor/canvas-core/editor/editorSelectionTransforms.ts +116 -0
- package/_vendor/canvas-core/editor/events.ts +93 -0
- package/_vendor/canvas-core/editor/index.ts +12 -0
- package/_vendor/canvas-core/editor/interactions.ts +101 -0
- package/_vendor/canvas-core/editor/internal.ts +22 -0
- package/_vendor/canvas-core/editor/managers/BindingManager.ts +262 -0
- package/_vendor/canvas-core/editor/managers/CameraManager.ts +147 -0
- package/_vendor/canvas-core/editor/managers/ClipboardManager.ts +32 -0
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.ts +256 -0
- package/_vendor/canvas-core/editor/managers/InputsManager.ts +319 -0
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.ts +218 -0
- package/_vendor/canvas-core/editor/managers/QueryManager.ts +837 -0
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.ts +347 -0
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.ts +196 -0
- package/_vendor/canvas-core/editor/managers/SelectionManager.ts +98 -0
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.ts +308 -0
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.ts +226 -0
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.ts +162 -0
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.ts +797 -0
- package/_vendor/canvas-core/editor/managers/SideEffectManager.ts +83 -0
- package/_vendor/canvas-core/editor/managers/SnapManager.ts +433 -0
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.ts +430 -0
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.ts +354 -0
- package/_vendor/canvas-core/editor/managers/ToolManager.ts +81 -0
- package/_vendor/canvas-core/editor/managers/queryState.ts +583 -0
- package/_vendor/canvas-core/editor/managers/selectionGeometry.ts +287 -0
- package/_vendor/canvas-core/editor/managers/shapeOrder.ts +350 -0
- package/_vendor/canvas-core/editor/managers/shapeReparenting.ts +160 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.ts +412 -0
- package/_vendor/canvas-core/editor/managers/snapGeometry.ts +202 -0
- package/_vendor/canvas-core/editor/managers/snapIndicators.ts +403 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.ts +122 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.ts +171 -0
- package/_vendor/canvas-core/editor/renderWindow.ts +439 -0
- package/_vendor/canvas-core/editor/resizeGeometry.ts +654 -0
- package/_vendor/canvas-core/editor/selection.ts +489 -0
- package/_vendor/canvas-core/editor/selectionHandleInteractions.ts +43 -0
- package/_vendor/canvas-core/editor/selectionOverlay.ts +567 -0
- package/_vendor/canvas-core/exports/integrity.ts +174 -0
- package/_vendor/canvas-core/exports/svg.ts +494 -0
- package/_vendor/canvas-core/geometry/Box.ts +80 -0
- package/_vendor/canvas-core/geometry/Ellipse2d.ts +67 -0
- package/_vendor/canvas-core/geometry/Geometry2d.ts +52 -0
- package/_vendor/canvas-core/geometry/Mat.ts +92 -0
- package/_vendor/canvas-core/geometry/Polyline2d.ts +63 -0
- package/_vendor/canvas-core/geometry/Rectangle2d.ts +64 -0
- package/_vendor/canvas-core/geometry/Vec.ts +123 -0
- package/_vendor/canvas-core/geometry/index.ts +13 -0
- package/_vendor/canvas-core/geometry/segments.ts +65 -0
- package/_vendor/canvas-core/index.ts +391 -0
- package/_vendor/canvas-core/plugins/index.ts +5 -0
- package/_vendor/canvas-core/plugins/types.ts +53 -0
- package/_vendor/canvas-core/reactivity.ts +16 -0
- package/_vendor/canvas-core/schema/records.ts +221 -0
- package/_vendor/canvas-core/schema/snapshots.ts +527 -0
- package/_vendor/canvas-core/shapes/ShapeUtil.ts +516 -0
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.ts +26 -0
- package/_vendor/canvas-core/shapes/capabilities.ts +67 -0
- package/_vendor/canvas-core/shapes/types.ts +20 -0
- package/_vendor/canvas-core/toolbar.ts +148 -0
- package/_vendor/canvas-core/tools/hand/HandTool.ts +75 -0
- package/_vendor/canvas-core/tools/index.ts +2 -0
- package/_vendor/canvas-core/tools/select/SelectTool.ts +33 -0
- package/_vendor/canvas-core/tools/select/selectContainment.ts +104 -0
- package/_vendor/canvas-core/tools/select/selectToolHelpers.ts +801 -0
- package/_vendor/canvas-core/tools/select/states/BrushingState.ts +145 -0
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.ts +116 -0
- package/_vendor/canvas-core/tools/select/states/IdleState.ts +159 -0
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.ts +41 -0
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.ts +78 -0
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.ts +64 -0
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.ts +34 -0
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.ts +140 -0
- package/_vendor/canvas-core/tools/select/states/ResizingState.ts +171 -0
- package/_vendor/canvas-core/tools/select/states/RotatingState.ts +124 -0
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.ts +128 -0
- package/_vendor/canvas-core/tools/select/states/TranslatingState.ts +139 -0
- package/_vendor/canvas-core/tools/select/states/index.ts +11 -0
- package/_vendor/canvas-plugin-api/feature.ts +204 -0
- package/_vendor/canvas-plugin-api/index.ts +142 -0
- package/_vendor/canvas-product-react/api/apiRegistry.ts +35 -0
- package/_vendor/canvas-product-react/api/canvasProductApi.ts +422 -0
- package/_vendor/canvas-product-react/api/index.ts +31 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.ts +36 -0
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.ts +245 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.ts +396 -0
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.ts +59 -0
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.ts +156 -0
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.ts +23 -0
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.ts +41 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.ts +490 -0
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.ts +92 -0
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.ts +27 -0
- package/_vendor/canvas-product-react/index.ts +84 -0
- package/_vendor/canvas-product-react/persistence/index.ts +18 -0
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.ts +294 -0
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.tsx +250 -0
- package/_vendor/canvas-product-react/runtime/productDefinition.ts +72 -0
- package/_vendor/canvas-product-react/runtime/productServices.ts +96 -0
- package/_vendor/canvas-react/components/CanvasView.tsx +796 -0
- package/_vendor/canvas-react/components/OverlayLayer.tsx +879 -0
- package/_vendor/canvas-react/components/PageSpace.tsx +34 -0
- package/_vendor/canvas-react/components/ShapeLayer.tsx +428 -0
- package/_vendor/canvas-react/components/index.ts +4 -0
- package/_vendor/canvas-react/hooks/useEditor.ts +11 -0
- package/_vendor/canvas-react/hooks/useValue.ts +14 -0
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.tsx +14 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.ts +61 -0
- package/_vendor/canvas-react/host/domEventGuards.ts +61 -0
- package/_vendor/canvas-react/host/index.ts +38 -0
- package/_vendor/canvas-react/host/pluginHost.ts +635 -0
- package/_vendor/canvas-react/host/rendererRegistry.tsx +58 -0
- package/_vendor/canvas-react/host/toolbarRegistry.ts +100 -0
- package/_vendor/canvas-react/index.ts +3 -0
- package/_vendor/plugin-arrow/ArrowBindingUtil.ts +239 -0
- package/_vendor/plugin-arrow/ArrowShapeUtil.ts +311 -0
- package/_vendor/plugin-arrow/ArrowTool.ts +208 -0
- package/_vendor/plugin-arrow/arrowGeometry.ts +441 -0
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.ts +253 -0
- package/_vendor/plugin-arrow/arrowTerminalCommands.ts +230 -0
- package/_vendor/plugin-arrow/canvas.tsx +92 -0
- package/_vendor/plugin-arrow/core.ts +409 -0
- package/_vendor/plugin-arrow/feature.ts +20 -0
- package/_vendor/plugin-arrow/index.ts +28 -0
- package/_vendor/plugin-arrow/selectionHandleInteractions.ts +154 -0
- package/_vendor/plugin-arrow/types.ts +63 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.tsx +60 -0
- package/_vendor/plugin-draw/DrawShapeUtil.ts +372 -0
- package/_vendor/plugin-draw/DrawTool.ts +444 -0
- package/_vendor/plugin-draw/canvas.tsx +24 -0
- package/_vendor/plugin-draw/core.ts +515 -0
- package/_vendor/plugin-draw/drawGeometry.ts +491 -0
- package/_vendor/plugin-draw/drawHitTest.ts +271 -0
- package/_vendor/plugin-draw/drawInterpolation.ts +250 -0
- package/_vendor/plugin-draw/drawPath.ts +550 -0
- package/_vendor/plugin-draw/drawSegments.ts +106 -0
- package/_vendor/plugin-draw/drawSelectionTransform.ts +67 -0
- package/_vendor/plugin-draw/drawShapeGeometry.ts +307 -0
- package/_vendor/plugin-draw/drawStrokeGeometry.ts +454 -0
- package/_vendor/plugin-draw/feature.ts +20 -0
- package/_vendor/plugin-draw/index.ts +31 -0
- package/_vendor/plugin-draw/types.ts +36 -0
- package/_vendor/plugin-eraser/EraserTool.ts +297 -0
- package/_vendor/plugin-eraser/canvas.tsx +616 -0
- package/_vendor/plugin-eraser/core.ts +49 -0
- package/_vendor/plugin-eraser/feature.ts +20 -0
- package/_vendor/plugin-eraser/index.ts +4 -0
- package/_vendor/plugin-frame/FrameShapeUtil.ts +173 -0
- package/_vendor/plugin-frame/FrameTool.ts +225 -0
- package/_vendor/plugin-frame/canvas.tsx +75 -0
- package/_vendor/plugin-frame/core.ts +534 -0
- package/_vendor/plugin-frame/feature.ts +20 -0
- package/_vendor/plugin-frame/index.ts +6 -0
- package/_vendor/plugin-geo/GeoShapeUtil.ts +463 -0
- package/_vendor/plugin-geo/GeoTools.ts +247 -0
- package/_vendor/plugin-geo/canvas.tsx +90 -0
- package/_vendor/plugin-geo/core.ts +495 -0
- package/_vendor/plugin-geo/feature.ts +20 -0
- package/_vendor/plugin-geo/index.ts +7 -0
- package/_vendor/plugin-geo/types.ts +27 -0
- package/_vendor/plugin-group/GroupShapeUtil.ts +59 -0
- package/_vendor/plugin-group/canvas.tsx +59 -0
- package/_vendor/plugin-group/core.ts +40 -0
- package/_vendor/plugin-group/feature.ts +20 -0
- package/_vendor/plugin-group/index.ts +5 -0
- package/_vendor/plugin-image/ImageShapeUtil.ts +95 -0
- package/_vendor/plugin-image/canvas.tsx +212 -0
- package/_vendor/plugin-image/core.ts +542 -0
- package/_vendor/plugin-image/crop.ts +770 -0
- package/_vendor/plugin-image/cropInteractions.ts +350 -0
- package/_vendor/plugin-image/cropSession.ts +38 -0
- package/_vendor/plugin-image/feature.ts +20 -0
- package/_vendor/plugin-image/index.ts +29 -0
- package/_vendor/plugin-image/types.ts +55 -0
- package/_vendor/plugin-image-product-react/ImageImportController.tsx +143 -0
- package/_vendor/plugin-image-product-react/imageAssetService.ts +52 -0
- package/_vendor/plugin-image-product-react/imageBlobStore.ts +315 -0
- package/_vendor/plugin-image-product-react/imageHostActions.ts +438 -0
- package/_vendor/plugin-image-product-react/imageProductApi.ts +88 -0
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.ts +48 -0
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.ts +21 -0
- package/_vendor/plugin-image-product-react/index.ts +60 -0
- package/_vendor/plugin-image-product-react/snapshotGuards.ts +33 -0
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.ts +54 -0
- package/_vendor/plugin-image-product-react/useImageImport.ts +64 -0
- package/_vendor/plugin-laser/LaserTool.ts +154 -0
- package/_vendor/plugin-laser/canvas.tsx +645 -0
- package/_vendor/plugin-laser/core.ts +49 -0
- package/_vendor/plugin-laser/feature.ts +20 -0
- package/_vendor/plugin-laser/index.ts +4 -0
- package/_vendor/plugin-text/ArrowLabelBindingUtil.ts +336 -0
- package/_vendor/plugin-text/GeoLabelBindingUtil.ts +391 -0
- package/_vendor/plugin-text/TextShapeSvgExporter.ts +101 -0
- package/_vendor/plugin-text/TextShapeUtil.ts +284 -0
- package/_vendor/plugin-text/TextTool.ts +228 -0
- package/_vendor/plugin-text/canvas.tsx +115 -0
- package/_vendor/plugin-text/core.ts +422 -0
- package/_vendor/plugin-text/feature.ts +20 -0
- package/_vendor/plugin-text/host/RichTextEditingBox.tsx +144 -0
- package/_vendor/plugin-text/host/RichTextToolbar.tsx +266 -0
- package/_vendor/plugin-text/host/TiptapTextEditor.tsx +191 -0
- package/_vendor/plugin-text/host/richTextRendering.tsx +49 -0
- package/_vendor/plugin-text/host/textDomSelection.ts +93 -0
- package/_vendor/plugin-text/host/textEditingBoxStyle.ts +36 -0
- package/_vendor/plugin-text/host/textEntryFocus.ts +307 -0
- package/_vendor/plugin-text/host/textFontLoader.ts +149 -0
- package/_vendor/plugin-text/host/textMeasurement.ts +258 -0
- package/_vendor/plugin-text/host/textMeasurementSync.ts +77 -0
- package/_vendor/plugin-text/host/textRangeSelection.ts +134 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.tsx +89 -0
- package/_vendor/plugin-text/host/textShapeSync.ts +173 -0
- package/_vendor/plugin-text/host/tiptapTextEditorController.ts +148 -0
- package/_vendor/plugin-text/index.ts +18 -0
- package/_vendor/plugin-text/richTextUtils.ts +259 -0
- package/_vendor/plugin-text/textInteractions.ts +366 -0
- package/_vendor/plugin-text/textLabelHelpers.ts +235 -0
- package/_vendor/plugin-text/textShapeHelpers.ts +123 -0
- package/_vendor/plugin-text/textStyle.ts +96 -0
- package/_vendor/plugin-text/textTypes.ts +48 -0
- package/_vendor/signals/atom.ts +74 -0
- package/_vendor/signals/computed.ts +132 -0
- package/_vendor/signals/core.ts +130 -0
- package/_vendor/signals/effect.ts +117 -0
- package/_vendor/signals/index.ts +9 -0
- package/_vendor/signals/types.ts +17 -0
- package/_vendor/store/Store.ts +171 -0
- package/_vendor/store/diff.ts +229 -0
- package/_vendor/store/history.ts +177 -0
- package/_vendor/store/index.ts +32 -0
- package/_vendor/store/types.ts +37 -0
- package/api/canvasKitApi.d.ts +29 -0
- package/index.css +3 -0
- package/index.d.ts +16 -0
- package/index.mjs +1 -0
- package/internal-modules.d.ts +187 -0
- package/package.json +48 -0
- package/product/Shell.d.ts +19 -0
- package/product/chromeContext.d.ts +70 -0
- package/product/createCanvasKitEditor.d.ts +6 -0
- package/product/index.d.ts +7 -0
- package/product/persistence.d.ts +3 -0
- package/product/product.d.ts +22 -0
- package/product/useCanvasClipboardShortcuts.d.ts +6 -0
- package/product-iyBbEPIs.mjs +4 -0
- package/product.mjs +1 -0
- package/standard/extensions.d.ts +1 -0
- package/standard/index.d.ts +3 -0
- package/standard/standardApi.d.ts +91 -0
- package/standard-BmrxwqpJ.mjs +44 -0
- package/standard.mjs +1 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { Box } from "../geometry/Box";
|
|
2
|
+
import { Mat } from "../geometry/Mat";
|
|
3
|
+
import { Vec } from "../geometry/Vec";
|
|
4
|
+
import type { Editor } from "../editor/Editor";
|
|
5
|
+
import type { ShapeUpdate } from "../editor/commands";
|
|
6
|
+
import {
|
|
7
|
+
mirrorSelectionLocalPoint,
|
|
8
|
+
selectionLocalPointToPagePoint,
|
|
9
|
+
type SelectionMirrorAxis,
|
|
10
|
+
} from "../editor/selection";
|
|
11
|
+
import {
|
|
12
|
+
getAnchoredSelectionResizeLocalBounds,
|
|
13
|
+
} from "../editor/resizeGeometry";
|
|
14
|
+
import type {
|
|
15
|
+
SelectionArrowMiddleHandleAnchor,
|
|
16
|
+
SelectionArrowTerminalHandleAnchor,
|
|
17
|
+
SelectionCustomHandleAnchor,
|
|
18
|
+
SelectionHandle,
|
|
19
|
+
SelectionResizeHandleId,
|
|
20
|
+
} from "../editor/selection";
|
|
21
|
+
import type { ShapeId, ShapeRecordBase } from "../schema/records";
|
|
22
|
+
|
|
23
|
+
export interface ShapeEditEndResult {
|
|
24
|
+
deleteShapeIds?: ShapeId[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ShapeBindingPointInput {
|
|
28
|
+
rawPagePoint: Vec;
|
|
29
|
+
oppositePagePoint: Vec;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ShapeSelectionResizeInput {
|
|
33
|
+
handleId: SelectionResizeHandleId;
|
|
34
|
+
pageCenter: Vec;
|
|
35
|
+
selectionLocalBounds: Box;
|
|
36
|
+
scaleX: number;
|
|
37
|
+
scaleY: number;
|
|
38
|
+
isResizingFromCenter: boolean;
|
|
39
|
+
selectionRotation: number;
|
|
40
|
+
selectionRotationCenter: Vec;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ShapeSelectionResizeAspectRatioLockInput {
|
|
44
|
+
editor: Editor;
|
|
45
|
+
handleId: SelectionResizeHandleId;
|
|
46
|
+
isOnlySelected: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ShapeSelectionFlipAxis = SelectionMirrorAxis;
|
|
50
|
+
|
|
51
|
+
export interface ShapeSelectionFlipInput {
|
|
52
|
+
axis: ShapeSelectionFlipAxis;
|
|
53
|
+
selectionBounds: Box;
|
|
54
|
+
selectionLocalBounds: Box;
|
|
55
|
+
selectionRotation: number;
|
|
56
|
+
selectionRotationCenter: Vec;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type ShapeSelectionPagePoints = readonly [Vec, Vec];
|
|
60
|
+
|
|
61
|
+
export interface ShapeSelectionPagePointsInput {
|
|
62
|
+
pagePoints: ShapeSelectionPagePoints;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ShapeBrushWrapInput {
|
|
66
|
+
brushBounds: Box;
|
|
67
|
+
pageOutlineVertices: readonly Vec[];
|
|
68
|
+
pageBounds: Box | null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ShapeBrushSelectInput extends ShapeBrushWrapInput {
|
|
72
|
+
isWrapping: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ShapeLineSegmentHitTestInput {
|
|
76
|
+
pageStart: Vec;
|
|
77
|
+
pageEnd: Vec;
|
|
78
|
+
positionedStart: Vec;
|
|
79
|
+
positionedEnd: Vec;
|
|
80
|
+
margin: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ShapeBoundsSnapGeometry {
|
|
84
|
+
// Returned points live in local shape space and are mapped by core.
|
|
85
|
+
points?: readonly Vec[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ShapeHandleSnapContext {
|
|
89
|
+
shapeId: ShapeId;
|
|
90
|
+
handle: SelectionHandle;
|
|
91
|
+
currentPagePoint: Vec;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ShapeHandleSnapGeometry {
|
|
95
|
+
// Returned points/outlines live in local shape space and are mapped by core.
|
|
96
|
+
points?: readonly Vec[];
|
|
97
|
+
outline?: readonly Vec[] | null;
|
|
98
|
+
getSelfSnapPoints?(context: ShapeHandleSnapContext): readonly Vec[];
|
|
99
|
+
getSelfSnapOutline?(context: ShapeHandleSnapContext): readonly Vec[] | null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ShapeSelectionHandleAnchorInput {
|
|
103
|
+
isOnlySelected: boolean;
|
|
104
|
+
editor: Editor;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ShapeSelectionFrameInput {
|
|
108
|
+
editor: Editor;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ShapeSelectionTranslateInput {
|
|
112
|
+
editor: Editor;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ShapeSelectionHandleAnchors {
|
|
116
|
+
terminalHandleAnchors: readonly SelectionArrowTerminalHandleAnchor[];
|
|
117
|
+
middleHandleAnchors: readonly SelectionArrowMiddleHandleAnchor[];
|
|
118
|
+
customHandleAnchors?: readonly SelectionCustomHandleAnchor[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ShapeSelectionOverlayInfo {
|
|
122
|
+
usesSelectionPathOverlay: boolean;
|
|
123
|
+
startPagePoint: Vec | null;
|
|
124
|
+
endPagePoint: Vec | null;
|
|
125
|
+
middlePagePoint: Vec | null;
|
|
126
|
+
path: string | null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getBoxCorners(bounds: Box): Vec[] {
|
|
130
|
+
return [
|
|
131
|
+
new Vec(bounds.minX, bounds.minY),
|
|
132
|
+
new Vec(bounds.maxX, bounds.minY),
|
|
133
|
+
new Vec(bounds.maxX, bounds.maxY),
|
|
134
|
+
new Vec(bounds.minX, bounds.maxY),
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getSegmentIntersectionParameter(
|
|
139
|
+
start: Vec,
|
|
140
|
+
end: Vec,
|
|
141
|
+
edgeStart: Vec,
|
|
142
|
+
edgeEnd: Vec,
|
|
143
|
+
): number | null {
|
|
144
|
+
const segment = end.sub(start);
|
|
145
|
+
const edge = edgeEnd.sub(edgeStart);
|
|
146
|
+
const denominator = segment.x * edge.y - segment.y * edge.x;
|
|
147
|
+
if (Math.abs(denominator) < 1e-8) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const delta = edgeStart.sub(start);
|
|
152
|
+
const t = (delta.x * edge.y - delta.y * edge.x) / denominator;
|
|
153
|
+
const u = (delta.x * segment.y - delta.y * segment.x) / denominator;
|
|
154
|
+
|
|
155
|
+
return t >= 0 && t <= 1 && u >= 0 && u <= 1 ? t : null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function doesLineSegmentIntersectBox(start: Vec, end: Vec, bounds: Box): boolean {
|
|
159
|
+
if (bounds.containsPoint(start) || bounds.containsPoint(end)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const corners = getBoxCorners(bounds);
|
|
164
|
+
for (let index = 0; index < corners.length; index += 1) {
|
|
165
|
+
const edgeStart = corners[index];
|
|
166
|
+
const edgeEnd = corners[(index + 1) % corners.length];
|
|
167
|
+
if (
|
|
168
|
+
edgeStart &&
|
|
169
|
+
edgeEnd &&
|
|
170
|
+
getSegmentIntersectionParameter(start, end, edgeStart, edgeEnd) !== null
|
|
171
|
+
) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function getValidatedDimension(
|
|
180
|
+
props: object,
|
|
181
|
+
key: "w" | "h",
|
|
182
|
+
fallback: number,
|
|
183
|
+
): number {
|
|
184
|
+
const value = (props as Record<string, unknown>)[key];
|
|
185
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
186
|
+
? value
|
|
187
|
+
: fallback;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export abstract class ShapeUtil<S extends ShapeRecordBase = ShapeRecordBase> {
|
|
191
|
+
// Coordinate spaces:
|
|
192
|
+
// - local: shape-owned document truth, without shape.x / shape.y
|
|
193
|
+
// - positioned: local space translated by shape.x / shape.y, before rotation / scale
|
|
194
|
+
// - page: final rendered page space after rotation / scale
|
|
195
|
+
abstract readonly type: S["type"];
|
|
196
|
+
|
|
197
|
+
abstract getDefaultProps(): S["props"];
|
|
198
|
+
|
|
199
|
+
abstract validateProps(props: unknown): S["props"];
|
|
200
|
+
|
|
201
|
+
// Positioned bounds: local geometry translated by shape.x / shape.y.
|
|
202
|
+
abstract getBounds(shape: S): Box;
|
|
203
|
+
|
|
204
|
+
getLocalBounds(shape: S): Box {
|
|
205
|
+
const bounds = this.getBounds(shape);
|
|
206
|
+
return new Box(bounds.x - shape.x, bounds.y - shape.y, bounds.w, bounds.h);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Render/export bounds stay in local space and are transformed by core later.
|
|
210
|
+
getRenderBounds(shape: S): Box {
|
|
211
|
+
return this.getLocalBounds(shape);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getExportBounds(shape: S): Box {
|
|
215
|
+
return this.getRenderBounds(shape);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
getChildClipLocalBounds(_shape: S): Box | null {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getChildExportClipLocalBounds(shape: S): Box | null {
|
|
223
|
+
return this.getChildClipLocalBounds(shape);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
getSelectionResizeLocalBounds(shape: S): Box {
|
|
227
|
+
return this.getLocalBounds(shape);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
resizeSelectionBounds(
|
|
231
|
+
shape: S,
|
|
232
|
+
input: ShapeSelectionResizeInput,
|
|
233
|
+
): ShapeUpdate {
|
|
234
|
+
const localBounds = this.getSelectionResizeLocalBounds(shape);
|
|
235
|
+
if (localBounds.x !== 0 || localBounds.y !== 0) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`Shape util "${this.type}" must implement resizeSelectionBounds for non-origin local bounds`,
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const flipsSingleAxis =
|
|
242
|
+
(input.scaleX < 0) !== (input.scaleY < 0);
|
|
243
|
+
const nextRotation =
|
|
244
|
+
flipsSingleAxis
|
|
245
|
+
? input.selectionRotation * 2 - shape.rotation
|
|
246
|
+
: shape.rotation;
|
|
247
|
+
const nextProps = this.validateProps({
|
|
248
|
+
...shape.props,
|
|
249
|
+
w: input.selectionLocalBounds.w,
|
|
250
|
+
h: input.selectionLocalBounds.h,
|
|
251
|
+
});
|
|
252
|
+
const actualWidth = getValidatedDimension(
|
|
253
|
+
nextProps,
|
|
254
|
+
"w",
|
|
255
|
+
input.selectionLocalBounds.w,
|
|
256
|
+
);
|
|
257
|
+
const actualHeight = getValidatedDimension(
|
|
258
|
+
nextProps,
|
|
259
|
+
"h",
|
|
260
|
+
input.selectionLocalBounds.h,
|
|
261
|
+
);
|
|
262
|
+
const actualSelectionLocalBounds = getAnchoredSelectionResizeLocalBounds({
|
|
263
|
+
requestedBounds: input.selectionLocalBounds,
|
|
264
|
+
handleId: input.handleId,
|
|
265
|
+
actualWidth,
|
|
266
|
+
actualHeight,
|
|
267
|
+
scaleX: input.scaleX,
|
|
268
|
+
scaleY: input.scaleY,
|
|
269
|
+
isResizingFromCenter: input.isResizingFromCenter,
|
|
270
|
+
});
|
|
271
|
+
const pageCenter = selectionLocalPointToPagePoint(
|
|
272
|
+
actualSelectionLocalBounds.center,
|
|
273
|
+
{
|
|
274
|
+
rotation: input.selectionRotation,
|
|
275
|
+
rotationCenter: input.selectionRotationCenter,
|
|
276
|
+
},
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
id: shape.id,
|
|
281
|
+
x: pageCenter.x - actualWidth / 2,
|
|
282
|
+
y: pageCenter.y - actualHeight / 2,
|
|
283
|
+
rotation: nextRotation,
|
|
284
|
+
scaleX: input.scaleX < 0 ? -shape.scaleX : shape.scaleX,
|
|
285
|
+
scaleY: input.scaleY < 0 ? -shape.scaleY : shape.scaleY,
|
|
286
|
+
props: nextProps as Record<string, unknown>,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
getSelectionResizeAspectRatioLock(
|
|
291
|
+
_shape: S,
|
|
292
|
+
_input: ShapeSelectionResizeAspectRatioLockInput,
|
|
293
|
+
): boolean | null {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
flipSelectionBounds(
|
|
298
|
+
shape: S,
|
|
299
|
+
input: ShapeSelectionFlipInput,
|
|
300
|
+
): ShapeUpdate {
|
|
301
|
+
const selectionPagePoints = this.getSelectionPagePoints(shape);
|
|
302
|
+
if (selectionPagePoints) {
|
|
303
|
+
const nextPagePoints = selectionPagePoints.map((point) => {
|
|
304
|
+
const localPoint =
|
|
305
|
+
input.selectionRotation === 0
|
|
306
|
+
? point.clone()
|
|
307
|
+
: Vec.RotWith(
|
|
308
|
+
point,
|
|
309
|
+
input.selectionRotationCenter,
|
|
310
|
+
-input.selectionRotation,
|
|
311
|
+
);
|
|
312
|
+
const mirrored = mirrorSelectionLocalPoint({
|
|
313
|
+
axis: input.axis,
|
|
314
|
+
bounds: input.selectionBounds,
|
|
315
|
+
point: localPoint,
|
|
316
|
+
});
|
|
317
|
+
return input.selectionRotation === 0
|
|
318
|
+
? mirrored
|
|
319
|
+
: Vec.RotWith(
|
|
320
|
+
mirrored,
|
|
321
|
+
input.selectionRotationCenter,
|
|
322
|
+
input.selectionRotation,
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return this.updateSelectionPagePoints(shape, {
|
|
327
|
+
pagePoints: [nextPagePoints[0]!, nextPagePoints[1]!],
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const localBounds = this.getSelectionResizeLocalBounds(shape);
|
|
332
|
+
const pageCenter =
|
|
333
|
+
input.selectionRotation === 0
|
|
334
|
+
? input.selectionLocalBounds.center
|
|
335
|
+
: Vec.RotWith(
|
|
336
|
+
input.selectionLocalBounds.center,
|
|
337
|
+
input.selectionRotationCenter,
|
|
338
|
+
input.selectionRotation,
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
return {
|
|
342
|
+
id: shape.id,
|
|
343
|
+
x: pageCenter.x - localBounds.center.x,
|
|
344
|
+
y: pageCenter.y - localBounds.center.y,
|
|
345
|
+
rotation: input.selectionRotation * 2 - shape.rotation,
|
|
346
|
+
scaleX:
|
|
347
|
+
input.axis === "horizontal" ? -shape.scaleX : shape.scaleX,
|
|
348
|
+
scaleY: input.axis === "vertical" ? -shape.scaleY : shape.scaleY,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
updateSelectionPagePoints(
|
|
353
|
+
shape: S,
|
|
354
|
+
_input: ShapeSelectionPagePointsInput,
|
|
355
|
+
): ShapeUpdate {
|
|
356
|
+
throw new Error(
|
|
357
|
+
`Shape util "${this.type}" must implement updateSelectionPagePoints before selection can transform point-defined geometry`,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
getSelectionPagePoints(_shape: S): ShapeSelectionPagePoints | null {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
contributesToSelectionFrame(
|
|
366
|
+
_shape: S,
|
|
367
|
+
_input: ShapeSelectionFrameInput,
|
|
368
|
+
): boolean {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
canUseSelectionFrameHandles(
|
|
373
|
+
_shape: S,
|
|
374
|
+
_input: ShapeSelectionFrameInput,
|
|
375
|
+
): boolean {
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
getSelectionTargetId(
|
|
380
|
+
shape: S,
|
|
381
|
+
_input: ShapeSelectionFrameInput,
|
|
382
|
+
): ShapeId {
|
|
383
|
+
return shape.id;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
getTranslateTargetId(
|
|
387
|
+
shape: S,
|
|
388
|
+
_input: ShapeSelectionTranslateInput,
|
|
389
|
+
): ShapeId {
|
|
390
|
+
return shape.id;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
shouldTransformDescendants(_shape: S): boolean {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
shouldRotateDescendants(shape: S): boolean {
|
|
398
|
+
return this.shouldTransformDescendants(shape);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
canStartTranslateFromSelectionBounds(_shape: S): boolean {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
canSnap(_shape: S): boolean {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
getBoundsSnapGeometry(_shape: S): ShapeBoundsSnapGeometry {
|
|
410
|
+
return {};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
getHandleSnapGeometry(shape: S): ShapeHandleSnapGeometry {
|
|
414
|
+
return {
|
|
415
|
+
outline: getBoxCorners(this.getLocalBounds(shape)),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
getPositionedOutlineVertices(shape: S): Vec[] {
|
|
420
|
+
const bounds = this.getBounds(shape);
|
|
421
|
+
return [
|
|
422
|
+
new Vec(bounds.minX, bounds.minY),
|
|
423
|
+
new Vec(bounds.maxX, bounds.minY),
|
|
424
|
+
new Vec(bounds.maxX, bounds.maxY),
|
|
425
|
+
new Vec(bounds.minX, bounds.maxY),
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
getSelectionHandleAnchors(
|
|
430
|
+
_shape: S,
|
|
431
|
+
_input: ShapeSelectionHandleAnchorInput,
|
|
432
|
+
): ShapeSelectionHandleAnchors {
|
|
433
|
+
return {
|
|
434
|
+
terminalHandleAnchors: [],
|
|
435
|
+
middleHandleAnchors: [],
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
getSelectionOverlayInfo(_shape: S): ShapeSelectionOverlayInfo {
|
|
440
|
+
return {
|
|
441
|
+
usesSelectionPathOverlay: false,
|
|
442
|
+
startPagePoint: null,
|
|
443
|
+
endPagePoint: null,
|
|
444
|
+
middlePagePoint: null,
|
|
445
|
+
path: null,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
isWrappedByBrush(
|
|
450
|
+
_shape: S,
|
|
451
|
+
input: ShapeBrushWrapInput,
|
|
452
|
+
): boolean {
|
|
453
|
+
if (input.pageOutlineVertices.length === 0) {
|
|
454
|
+
return input.pageBounds
|
|
455
|
+
? input.brushBounds.containsBox(input.pageBounds)
|
|
456
|
+
: false;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return input.pageOutlineVertices.every((point) =>
|
|
460
|
+
input.brushBounds.containsPoint(point),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
canSelectByBrush(
|
|
465
|
+
shape: S,
|
|
466
|
+
input: ShapeBrushSelectInput,
|
|
467
|
+
): boolean {
|
|
468
|
+
return input.isWrapping ? this.isWrappedByBrush(shape, input) : true;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
getLocalToPageTransform(shape: S): Mat {
|
|
472
|
+
const localBounds = this.getLocalBounds(shape);
|
|
473
|
+
const localCenter = localBounds.center;
|
|
474
|
+
return Mat.Translate(shape.x + localCenter.x, shape.y + localCenter.y)
|
|
475
|
+
.compose(Mat.Rotate(shape.rotation))
|
|
476
|
+
.compose(Mat.Scale(shape.scaleX, shape.scaleY))
|
|
477
|
+
.compose(Mat.Translate(-localCenter.x, -localCenter.y));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
canEdit(_shape: S): boolean {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
canReceiveChildren(_shape: S): boolean {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
repairLoadedShape(_shape: S): S | null {
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
onEditEnd(_shape: S): ShapeEditEndResult | void {}
|
|
493
|
+
|
|
494
|
+
// Hit tests receive a positioned-space point (page space with rotation / scale removed).
|
|
495
|
+
hitTest(shape: S, positionedPoint: Vec): boolean {
|
|
496
|
+
return this.getBounds(shape).containsPoint(positionedPoint);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
hitTestLineSegment(
|
|
500
|
+
shape: S,
|
|
501
|
+
input: ShapeLineSegmentHitTestInput,
|
|
502
|
+
): boolean {
|
|
503
|
+
return doesLineSegmentIntersectBox(
|
|
504
|
+
input.positionedStart,
|
|
505
|
+
input.positionedEnd,
|
|
506
|
+
this.getBounds(shape).expand(input.margin),
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
resolveBindingPoint(
|
|
511
|
+
_shape: S,
|
|
512
|
+
input: ShapeBindingPointInput,
|
|
513
|
+
): Vec {
|
|
514
|
+
return input.rawPagePoint;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ShapeRecordBase } from "../schema/records";
|
|
2
|
+
import { ShapeUtil } from "./ShapeUtil";
|
|
3
|
+
|
|
4
|
+
export class ShapeUtilRegistry {
|
|
5
|
+
private readonly registry = new Map<string, ShapeUtil>();
|
|
6
|
+
|
|
7
|
+
register<S extends ShapeRecordBase>(util: ShapeUtil<S>): void {
|
|
8
|
+
this.registry.set(util.type, util as ShapeUtil);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
has(type: ShapeRecordBase["type"]): boolean {
|
|
12
|
+
return this.registry.has(type);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
values(): IterableIterator<ShapeUtil> {
|
|
16
|
+
return this.registry.values();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get<S extends ShapeRecordBase>(type: S["type"]): ShapeUtil<S> {
|
|
20
|
+
const util = this.registry.get(type);
|
|
21
|
+
if (!util) {
|
|
22
|
+
throw new Error(`Missing shape util for type \"${type}\"`);
|
|
23
|
+
}
|
|
24
|
+
return util as ShapeUtil<S>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ShapeSvgExporterRegistry } from "../exports/svg";
|
|
2
|
+
import type { ShapeRecordBase } from "../schema/records";
|
|
3
|
+
import type { ShapeUtilRegistry } from "./ShapeUtilRegistry";
|
|
4
|
+
|
|
5
|
+
export type ShapeCapabilitySupport = "supported" | "partial" | "missing";
|
|
6
|
+
|
|
7
|
+
export interface ShapeCapabilityManifestEntry {
|
|
8
|
+
type: ShapeRecordBase["type"];
|
|
9
|
+
schemaProps: string[];
|
|
10
|
+
shapeUtil: ShapeCapabilitySupport;
|
|
11
|
+
reactRenderer: ShapeCapabilitySupport;
|
|
12
|
+
svgExporter: ShapeCapabilitySupport;
|
|
13
|
+
toolbarEntry: ShapeCapabilitySupport;
|
|
14
|
+
exportSupport: ShapeCapabilitySupport;
|
|
15
|
+
notes: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ShapeCapabilityManifest {
|
|
19
|
+
entries: ShapeCapabilityManifestEntry[];
|
|
20
|
+
supportedExportTypes: ShapeRecordBase["type"][];
|
|
21
|
+
missingExporterTypes: ShapeRecordBase["type"][];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ShapeCapabilityDefinition = Omit<
|
|
25
|
+
ShapeCapabilityManifestEntry,
|
|
26
|
+
"shapeUtil" | "svgExporter" | "exportSupport"
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
export function getShapeCapabilityManifest({
|
|
30
|
+
definitions,
|
|
31
|
+
exporters,
|
|
32
|
+
shapeUtils,
|
|
33
|
+
}: {
|
|
34
|
+
definitions: readonly ShapeCapabilityDefinition[];
|
|
35
|
+
exporters: ShapeSvgExporterRegistry;
|
|
36
|
+
shapeUtils: ShapeUtilRegistry;
|
|
37
|
+
}): ShapeCapabilityManifest {
|
|
38
|
+
const entries = definitions.map((entry) => {
|
|
39
|
+
const shapeUtil: ShapeCapabilitySupport = shapeUtils.has(entry.type)
|
|
40
|
+
? "supported"
|
|
41
|
+
: "missing";
|
|
42
|
+
const svgExporter: ShapeCapabilitySupport = exporters.has(entry.type)
|
|
43
|
+
? "supported"
|
|
44
|
+
: "missing";
|
|
45
|
+
const exportSupport: ShapeCapabilitySupport =
|
|
46
|
+
shapeUtil === "supported" && svgExporter === "supported"
|
|
47
|
+
? "supported"
|
|
48
|
+
: "missing";
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
...entry,
|
|
52
|
+
shapeUtil,
|
|
53
|
+
svgExporter,
|
|
54
|
+
exportSupport,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
entries,
|
|
60
|
+
supportedExportTypes: entries
|
|
61
|
+
.filter((entry) => entry.exportSupport === "supported")
|
|
62
|
+
.map((entry) => entry.type),
|
|
63
|
+
missingExporterTypes: entries
|
|
64
|
+
.filter((entry) => entry.svgExporter !== "supported")
|
|
65
|
+
.map((entry) => entry.type),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
BindingId,
|
|
3
|
+
BindingRecord,
|
|
4
|
+
PageRecord,
|
|
5
|
+
PageId,
|
|
6
|
+
EditorRecord,
|
|
7
|
+
ShapeRecord,
|
|
8
|
+
ShapeId,
|
|
9
|
+
SessionRecord,
|
|
10
|
+
} from "../schema/records";
|
|
11
|
+
export {
|
|
12
|
+
DEFAULT_PAGE_ID,
|
|
13
|
+
DEFAULT_SESSION_ID,
|
|
14
|
+
createDefaultPage,
|
|
15
|
+
createDefaultSession,
|
|
16
|
+
isBindingRecord,
|
|
17
|
+
isPageRecord,
|
|
18
|
+
isShapeRecord,
|
|
19
|
+
isSessionRecord,
|
|
20
|
+
} from "../schema/records";
|