@widgetic/canvas 0.5.35 → 0.5.37
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 +105 -36
- package/dist/canvas/DomCanvas.svelte +449 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +221 -0
- package/dist/canvas/boardFrame.d.ts +13 -0
- package/dist/canvas/boardFrame.js +13 -0
- package/dist/canvas/boardSurface.d.ts +9 -0
- package/dist/canvas/boardSurface.js +9 -0
- package/dist/canvas/chromeLayout.d.ts +76 -0
- package/dist/canvas/chromeLayout.js +121 -0
- package/dist/canvas/emptyBoardHint.d.ts +17 -0
- package/dist/canvas/emptyBoardHint.js +12 -0
- package/dist/canvas/eventScope.d.ts +1 -1
- package/dist/canvas/eventScope.js +1 -1
- package/dist/canvas/host/CanvasHost.d.ts +348 -0
- package/dist/canvas/host/CanvasHost.js +1715 -0
- package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
- package/dist/canvas/host/CanvasHostApi.js +95 -0
- package/dist/canvas/host/browserServices.d.ts +46 -0
- package/dist/canvas/host/browserServices.js +167 -0
- package/dist/canvas/host/conversion.d.ts +53 -0
- package/dist/canvas/host/conversion.js +125 -0
- package/dist/canvas/host/hostObject.d.ts +40 -0
- package/dist/canvas/host/hostObject.js +93 -0
- package/dist/canvas/host/pageEvents.d.ts +24 -0
- package/dist/canvas/host/pageEvents.js +35 -0
- package/dist/canvas/host/screenRects.d.ts +66 -0
- package/dist/canvas/host/screenRects.js +102 -0
- package/dist/canvas/host/strokeSnap.d.ts +67 -0
- package/dist/canvas/host/strokeSnap.js +165 -0
- package/dist/canvas/index.d.ts +7 -7
- package/dist/canvas/index.js +8 -8
- package/dist/canvas/openMarks.d.ts +17 -0
- package/dist/canvas/openMarks.js +26 -0
- package/dist/canvas/panZoomPosition.d.ts +15 -0
- package/dist/canvas/panZoomPosition.js +16 -0
- package/dist/canvas/preferredTextFont.d.ts +12 -0
- package/dist/canvas/preferredTextFont.js +38 -0
- package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
- package/dist/canvas/shapes/ShapeLibrary.js +13 -1
- package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
- package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
- package/dist/canvas/toolbarPosition.d.ts +11 -11
- package/dist/canvas/toolbarPosition.js +11 -24
- package/dist/canvas/types.d.ts +14 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
- package/dist/canvas/ui/CanvasHint.svelte +21 -0
- package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
- package/dist/canvas/ui/ColorField.svelte +156 -0
- package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
- package/dist/canvas/ui/LoadNotice.svelte +39 -0
- package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
- package/dist/canvas/ui/SelectionPanel.svelte +300 -0
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
- package/dist/canvas/ui/SelectorBar.svelte +82 -0
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
- package/dist/canvas/ui/ShapesMenu.svelte +185 -0
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/ToolButton.svelte +78 -0
- package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
- package/dist/canvas/ui/WidgetActions.svelte +145 -0
- package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
- package/dist/canvas/ui/ZoomControl.svelte +89 -0
- package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
- package/dist/canvas/ui/colorModel.d.ts +18 -0
- package/dist/canvas/ui/colorModel.js +85 -0
- package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
- package/dist/canvas/ui/colorPickerMessages.js +15 -0
- package/dist/canvas/ui/floatingCard.d.ts +107 -0
- package/dist/canvas/ui/floatingCard.js +107 -0
- package/dist/canvas/ui/floatingLayer.d.ts +21 -0
- package/dist/canvas/ui/floatingLayer.js +52 -0
- package/dist/canvas/ui/icons.d.ts +12 -0
- package/dist/canvas/ui/icons.js +7 -0
- package/dist/canvas/ui/keyHints.d.ts +27 -0
- package/dist/canvas/ui/keyHints.js +43 -0
- package/dist/canvas/ui/popoverSide.d.ts +5 -0
- package/dist/canvas/ui/popoverSide.js +20 -0
- package/dist/canvas/ui/selectionTraits.d.ts +61 -0
- package/dist/canvas/ui/selectionTraits.js +99 -0
- package/dist/canvas/view/CanvasStage.svelte +132 -0
- package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
- package/dist/canvas/view/EraserTrail.svelte +50 -0
- package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
- package/dist/canvas/view/ObjectView.svelte +245 -0
- package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
- package/dist/canvas/view/SelectionOverlay.svelte +487 -0
- package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
- package/dist/canvas/view/TextEditor.svelte +76 -0
- package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.js +34 -0
- package/dist/canvas/view/geometry.d.ts +169 -0
- package/dist/canvas/view/geometry.js +272 -0
- package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +2 -2
- package/dist/engine/EngineCore.d.ts +273 -0
- package/dist/engine/EngineCore.js +1051 -0
- package/dist/engine/codec/canvasDocument.d.ts +57 -0
- package/dist/engine/codec/canvasDocument.js +471 -0
- package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
- package/dist/engine/codec/hostReadableKeys.js +25 -0
- package/dist/engine/core/arrange.d.ts +20 -0
- package/dist/engine/core/arrange.js +81 -0
- package/dist/engine/core/arrow.d.ts +91 -0
- package/dist/engine/core/arrow.js +182 -0
- package/dist/engine/core/brush.d.ts +68 -0
- package/dist/engine/core/brush.js +173 -0
- package/dist/engine/core/defaults.d.ts +70 -0
- package/dist/engine/core/defaults.js +158 -0
- package/dist/engine/core/freehand.d.ts +130 -0
- package/dist/engine/core/freehand.js +430 -0
- package/dist/engine/core/geometry.d.ts +44 -0
- package/dist/engine/core/geometry.js +216 -0
- package/dist/engine/core/history.d.ts +39 -0
- package/dist/engine/core/history.js +69 -0
- package/dist/engine/core/hitTest.d.ts +54 -0
- package/dist/engine/core/hitTest.js +298 -0
- package/dist/engine/core/matrix.d.ts +47 -0
- package/dist/engine/core/matrix.js +101 -0
- package/dist/engine/core/pathData.d.ts +50 -0
- package/dist/engine/core/pathData.js +550 -0
- package/dist/engine/core/rotationReset.d.ts +10 -0
- package/dist/engine/core/rotationReset.js +17 -0
- package/dist/engine/core/scene.d.ts +99 -0
- package/dist/engine/core/scene.js +450 -0
- package/dist/engine/core/scribble.d.ts +64 -0
- package/dist/engine/core/scribble.js +121 -0
- package/dist/engine/core/shapePaths.d.ts +34 -0
- package/dist/engine/core/shapePaths.js +69 -0
- package/dist/engine/core/shapeTools.d.ts +80 -0
- package/dist/engine/core/shapeTools.js +161 -0
- package/dist/engine/core/snapping.d.ts +64 -0
- package/dist/engine/core/snapping.js +164 -0
- package/dist/engine/core/style.d.ts +40 -0
- package/dist/engine/core/style.js +151 -0
- package/dist/engine/core/transform.d.ts +79 -0
- package/dist/engine/core/transform.js +258 -0
- package/dist/engine/core/types.d.ts +238 -0
- package/dist/engine/core/types.js +31 -0
- package/dist/engine/core/viewport.d.ts +32 -0
- package/dist/engine/core/viewport.js +84 -0
- package/dist/engine/input/PointerController.d.ts +38 -0
- package/dist/engine/input/PointerController.js +545 -0
- package/dist/engine/input/arrowHandles.d.ts +38 -0
- package/dist/engine/input/arrowHandles.js +60 -0
- package/dist/engine/input/gestures.d.ts +79 -0
- package/dist/engine/input/gestures.js +769 -0
- package/dist/engine/input/hoverCursor.d.ts +29 -0
- package/dist/engine/input/hoverCursor.js +23 -0
- package/dist/engine/input/keyboard.d.ts +75 -0
- package/dist/engine/input/keyboard.js +264 -0
- package/dist/engine/input/selectionHandles.d.ts +89 -0
- package/dist/engine/input/selectionHandles.js +169 -0
- package/dist/engine/input/types.d.ts +82 -0
- package/dist/engine/input/types.js +5 -0
- package/dist/engine/render/rasterize.d.ts +74 -0
- package/dist/engine/render/rasterize.js +273 -0
- package/dist/engine/state.d.ts +124 -0
- package/dist/engine/state.js +47 -0
- package/dist/engine/text/layoutText.d.ts +53 -0
- package/dist/engine/text/layoutText.js +170 -0
- package/dist/engine/widgets.d.ts +124 -0
- package/dist/engine/widgets.js +345 -0
- package/dist/i18n/labels.d.ts +4 -15
- package/dist/i18n/labels.js +33 -53
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +52 -124
- package/dist/i18n/messages.js +59 -133
- package/dist/i18n/shortcuts.d.ts +0 -1
- package/dist/i18n/shortcuts.js +2 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13363
- package/dist/canvas/Canvas.svelte.d.ts +0 -286
- package/dist/canvas/CanvasToolbar.svelte +0 -1498
- package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
- package/dist/canvas/ContextMenu.svelte +0 -305
- package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
- package/dist/canvas/PanZoomPanel.svelte +0 -478
- package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
- package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
- package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
- package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
- package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
- package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
- package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
- package/dist/canvas/shadowRootText.d.ts +0 -5
- package/dist/canvas/shadowRootText.js +0 -43
- package/dist/canvas/shapes/FrameShape.d.ts +0 -97
- package/dist/canvas/shapes/FrameShape.js +0 -953
- package/dist/canvas/shapes/ImageShape.d.ts +0 -47
- package/dist/canvas/shapes/ImageShape.js +0 -339
- package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
- package/dist/canvas/shapes/WidgetShape.js +0 -200
- package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
- package/dist/canvas/widgetPreviewGeometry.js +0 -66
- package/dist/i18n/shapeWords.d.ts +0 -30
- package/dist/i18n/shapeWords.js +0 -36
- package/dist/i18n/slots.d.ts +0 -20
- package/dist/i18n/slots.js +0 -40
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host of one canvas: the object the Svelte shell talks to, and the only place where the engine meets the page.
|
|
3
|
+
*
|
|
4
|
+
* It owns the engine, the pointer controller, the autosave buffer and the registry of conversions in flight, and it
|
|
5
|
+
* keeps every promise the canvas this one replaces made to the widget creator and the other modules that mount it:
|
|
6
|
+
* the props they set (read at the moment they are needed, so a change takes effect without a remount), the functions
|
|
7
|
+
* they call (the shell re-exports them one by one), the callbacks they are given, and the order in which these happen.
|
|
8
|
+
*
|
|
9
|
+
* Plain TypeScript with no Svelte and no DOM at construction, so a page that is rendered on the server can make one;
|
|
10
|
+
* the shell calls `attach` from `onMount` and `destroy` from `onDestroy`. The engine's state and the host's own UI state
|
|
11
|
+
* are offered as stores (`engineStore`, `uiStore`), so legacy and runes components read them the same way.
|
|
12
|
+
*/
|
|
13
|
+
import { createRectObject } from '../../engine/core/defaults.js';
|
|
14
|
+
import type { ObjectId, Point, TextObject, WidgetObject } from '../../engine/core/types.js';
|
|
15
|
+
import { EngineCore } from '../../engine/EngineCore.js';
|
|
16
|
+
import type { ToolShortcut } from '../../engine/input/keyboard.js';
|
|
17
|
+
import { PointerController } from '../../engine/input/PointerController.js';
|
|
18
|
+
import type { TextLayout } from '../../engine/text/layoutText.js';
|
|
19
|
+
import type { EngineState, ToolId } from '../../engine/state.js';
|
|
20
|
+
import { ConversionRegistry } from '../../engine/widgets.js';
|
|
21
|
+
import type { WidgetMetadata } from '../../engine/widgets.js';
|
|
22
|
+
import type { PanZoomPosition } from '../panZoomPosition.js';
|
|
23
|
+
import type { ToolbarPosition } from '../toolbarPosition.js';
|
|
24
|
+
import type { Translate as CatalogTranslate } from '@widgetic/design-system/i18n';
|
|
25
|
+
import type { CanvasMessageKey } from '../../i18n/messages.js';
|
|
26
|
+
import type { ObjectClickPayload, StrokeRecognizer } from '../types.js';
|
|
27
|
+
import type { LoadedImageFile } from './browserServices.js';
|
|
28
|
+
import type { HostObject } from './hostObject.js';
|
|
29
|
+
import type { ScreenRect, WidgetScreenRect } from './screenRects.js';
|
|
30
|
+
/** The words of the selector bar that replaces the drawing tools. */
|
|
31
|
+
export interface SelectorGuide {
|
|
32
|
+
click: string;
|
|
33
|
+
parentChild: string;
|
|
34
|
+
hold: string;
|
|
35
|
+
cmd: string;
|
|
36
|
+
interact: string;
|
|
37
|
+
esc: string;
|
|
38
|
+
done: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every prop of the canvas that the host reads. `class`, `style`, `locale` and `messages` belong to the shell (they
|
|
42
|
+
* are about the element and the words), the rest are here. Each is read when it is needed, never copied.
|
|
43
|
+
*/
|
|
44
|
+
export interface CanvasHostProps {
|
|
45
|
+
showContainerFrame: boolean;
|
|
46
|
+
widgetSelectionLayerTarget: string;
|
|
47
|
+
onObjectClick: ((data: ObjectClickPayload) => void) | null;
|
|
48
|
+
panZoomPosition: PanZoomPosition;
|
|
49
|
+
toolbarPosition: ToolbarPosition;
|
|
50
|
+
wireframeMode: boolean;
|
|
51
|
+
advancedFeatures: boolean;
|
|
52
|
+
showElementSelector: boolean;
|
|
53
|
+
showDrawingTools: boolean;
|
|
54
|
+
elementSelectorActive: boolean;
|
|
55
|
+
onToggleElementSelector: (() => void) | null;
|
|
56
|
+
selectorGuide: SelectorGuide | null;
|
|
57
|
+
showZoomPanel: boolean;
|
|
58
|
+
mediaBtsOnBar: boolean;
|
|
59
|
+
initialData: string | null;
|
|
60
|
+
onReady: (() => void) | null;
|
|
61
|
+
isExternalDataLoading: boolean;
|
|
62
|
+
onBeforeUnmount: ((json: string | null) => void) | null;
|
|
63
|
+
onAutoSave: ((json: string | null) => void | Promise<unknown>) | null;
|
|
64
|
+
autosaveDelayMs: number;
|
|
65
|
+
autosaveMaxWaitMs: number;
|
|
66
|
+
suspendAutosave: boolean;
|
|
67
|
+
showSaveButton: boolean;
|
|
68
|
+
onCanvasDirty: (() => void) | null;
|
|
69
|
+
onCanvasCleared: (() => void) | null;
|
|
70
|
+
onWidgetImageClick: ((widgetId: string) => void) | null;
|
|
71
|
+
onRecognizeStroke: StrokeRecognizer | null;
|
|
72
|
+
onNonWidgetSelected: (() => void) | null;
|
|
73
|
+
onWidgetShapeDuplicated: ((sourceWidgetId: string, clonedObject: any) => void) | null;
|
|
74
|
+
onWidgetShapeDeleting: ((widgetId: string) => Promise<boolean>) | null;
|
|
75
|
+
onWidgetRename: ((widgetId: string, newName: string) => void) | null;
|
|
76
|
+
onRefreshScreenshot: ((widgetId: string) => void) | null;
|
|
77
|
+
onSetPrimaryWidget: ((widgetId: string) => void) | null;
|
|
78
|
+
onAfterRender: (() => void) | null;
|
|
79
|
+
getWidgetName: ((widgetId: string) => string | null) | null;
|
|
80
|
+
widgetNameRevision: number;
|
|
81
|
+
isWidgetKnown: ((widgetId: string) => boolean) | null;
|
|
82
|
+
showLogs: boolean;
|
|
83
|
+
/** Whether a freehand stroke that is a clean shape becomes that shape. Off unless the page passes true. */
|
|
84
|
+
shapeSnap: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** What each prop is until the page sets it (the values the canvas this one replaces had, but for `panZoomPosition`). */
|
|
87
|
+
export declare const DEFAULT_HOST_PROPS: Readonly<CanvasHostProps>;
|
|
88
|
+
export type SaveState = 'saved' | 'dirty' | 'saving';
|
|
89
|
+
export type LoadPhase = 'initializing' | 'loading' | 'ready' | 'error';
|
|
90
|
+
export type LoadStatus = 'ok' | 'empty' | 'unsupported' | 'invalid';
|
|
91
|
+
/** What the host shows that is not the board: the open menus, the loading phase, the state of the save. */
|
|
92
|
+
export interface HostUiState {
|
|
93
|
+
loadPhase: LoadPhase;
|
|
94
|
+
/** How the last document read went (`unsupported` is an older canvas the board does not open). */
|
|
95
|
+
loadStatus: LoadStatus | null;
|
|
96
|
+
saveState: SaveState;
|
|
97
|
+
/** Where the context menu is open, in pixels of the board. */
|
|
98
|
+
/** The point of the board the menu opens at; `byTouch` when a long press opened it (the menu then stands clear of the finger). */
|
|
99
|
+
contextMenu: {
|
|
100
|
+
x: number;
|
|
101
|
+
y: number;
|
|
102
|
+
byTouch?: boolean;
|
|
103
|
+
} | null;
|
|
104
|
+
shapesMenuOpen: boolean;
|
|
105
|
+
shortcutsOpen: boolean;
|
|
106
|
+
/** The selection panel is collapsed to the settings control (true) or expanded (false). */
|
|
107
|
+
selectionPanelDismissed: boolean;
|
|
108
|
+
/** Space is held: a press pans. */
|
|
109
|
+
spacePan: boolean;
|
|
110
|
+
/** The gesture that is running (`draw`, `move`, `pinch` ...) or null. */
|
|
111
|
+
gestureKind: string | null;
|
|
112
|
+
/** Counts the times the host said that the names of the widgets changed. */
|
|
113
|
+
nameRevision: number;
|
|
114
|
+
/** False until onReady and the first load have had a turn, so the empty-board hint does not flash before saved shapes. */
|
|
115
|
+
emptyHintGateOpen: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface Readable<T> {
|
|
118
|
+
subscribe(run: (value: T) => void): () => void;
|
|
119
|
+
}
|
|
120
|
+
/** Text put on the system clipboard by a copy on the board, so that a picture copied earlier does not win the next paste. */
|
|
121
|
+
export declare const CLIPBOARD_MARKER = "widgetic-canvas-selection";
|
|
122
|
+
/** The longest side a picture gets when it is put on the board (the picture itself keeps its size). */
|
|
123
|
+
export declare const IMAGE_INSERT_MAX_SIDE = 480;
|
|
124
|
+
/** The smallest side of a picture put on the board. */
|
|
125
|
+
export declare const IMAGE_INSERT_MIN_SIDE = 24;
|
|
126
|
+
/**
|
|
127
|
+
* How long a finger rests on the board before the press is a long press (it opens the menu a right click opens), and how
|
|
128
|
+
* far the finger may wander meanwhile, in board pixels. The host times it itself: a browser that sends a `contextmenu`
|
|
129
|
+
* for a long press (Android) is not needed, and one that does not (an iPad) is served the same.
|
|
130
|
+
*/
|
|
131
|
+
export declare const TOUCH_LONG_PRESS_DELAY_MS = 500;
|
|
132
|
+
export declare const TOUCH_LONG_PRESS_SLOP = 8;
|
|
133
|
+
/** How long after the finger that opened the menu lifts its release is still told apart from a choice (see `isMenuHeldByItsFinger`). */
|
|
134
|
+
export declare const TOUCH_MENU_RELEASE_GRACE_MS = 400;
|
|
135
|
+
/** Says a message of the catalog in the language of the canvas (the host only ever asks for keys the catalog has). */
|
|
136
|
+
export type Translate = CatalogTranslate<CanvasMessageKey>;
|
|
137
|
+
/** A picture's size on the board: its own size, or the biggest one that fits `IMAGE_INSERT_MAX_SIDE`. */
|
|
138
|
+
export declare function fitImageSize(naturalWidth: number, naturalHeight: number): {
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
};
|
|
142
|
+
/** The tools the shell lets people pick, by the name the shortcuts and menus use. */
|
|
143
|
+
export type ShapeToolName = 'rect' | 'rounded-rect' | 'circle' | 'circle-true' | 'triangle' | 'arrow';
|
|
144
|
+
export declare class CanvasHost {
|
|
145
|
+
#private;
|
|
146
|
+
readonly engine: EngineCore;
|
|
147
|
+
readonly controller: PointerController;
|
|
148
|
+
readonly conversions: ConversionRegistry;
|
|
149
|
+
/** The engine's state as a store. */
|
|
150
|
+
readonly engineStore: Readable<EngineState>;
|
|
151
|
+
/** The host's own state as a store. */
|
|
152
|
+
readonly uiStore: Readable<HostUiState>;
|
|
153
|
+
props: CanvasHostProps;
|
|
154
|
+
/** The words the host draws or says (the shell gives it the language of the page). */
|
|
155
|
+
translate: Translate;
|
|
156
|
+
constructor(initialProps?: Partial<CanvasHostProps>);
|
|
157
|
+
/** The page changed some props. */
|
|
158
|
+
setProps(patch: Partial<CanvasHostProps>): void;
|
|
159
|
+
/** The shell gives the host the words of the page's language. */
|
|
160
|
+
setTranslator(translate: Translate): void;
|
|
161
|
+
get ui(): HostUiState;
|
|
162
|
+
updateUi(patch: Partial<HostUiState>): void;
|
|
163
|
+
/** True while the board is loading or the page says it is (the loader shows, input waits). */
|
|
164
|
+
get isLoading(): boolean;
|
|
165
|
+
/** The tools the page lets people use: the drawing group is the page's to hide, the shapes are always there. */
|
|
166
|
+
get tools(): {
|
|
167
|
+
drawing: boolean;
|
|
168
|
+
};
|
|
169
|
+
/** The shell mounted: the board element exists and has a size. Starts listening and loads the data the page gave. */
|
|
170
|
+
attach(root: HTMLElement, board: HTMLElement): void;
|
|
171
|
+
/** The shell is going away: hands the page its last chance to keep the board, then lets go of everything. */
|
|
172
|
+
destroy(): void;
|
|
173
|
+
/** The element the board's pointer events come from. */
|
|
174
|
+
get boardElement(): HTMLElement | null;
|
|
175
|
+
get rootElement(): HTMLElement | null;
|
|
176
|
+
/**
|
|
177
|
+
* Gives the board the keyboard.
|
|
178
|
+
*
|
|
179
|
+
* A press of the pointer passes `focusVisible: false`: the browser draws the focus ring for a focus that a script moves
|
|
180
|
+
* when the last thing the person did was a key, and a press on the board is not asking for a ring (the keyboard still
|
|
181
|
+
* has the focus, and a Tab or an arrow shows it). Browsers that do not know the option ignore it.
|
|
182
|
+
*/
|
|
183
|
+
focusBoard(options?: {
|
|
184
|
+
focusVisible?: boolean;
|
|
185
|
+
}): void;
|
|
186
|
+
handlePointerDown(event: PointerEvent): void;
|
|
187
|
+
/**
|
|
188
|
+
* Is the menu still held by the finger that opened it? True while that finger is down, and for a moment after it lifts:
|
|
189
|
+
* the browser sends the finger's `click` a moment after `pointerup`, to whatever is under it, and that is not a choice.
|
|
190
|
+
* The menu asks before it acts on an item, so a long press never picks the entry that opened under the finger.
|
|
191
|
+
*/
|
|
192
|
+
isMenuHeldByItsFinger(): boolean;
|
|
193
|
+
handlePointerMove(event: PointerEvent): void;
|
|
194
|
+
handlePointerUp(event: PointerEvent): void;
|
|
195
|
+
handlePointerCancel(event: PointerEvent): void;
|
|
196
|
+
handlePointerLeave(event: PointerEvent): void;
|
|
197
|
+
handleContextMenu(event: MouseEvent): void;
|
|
198
|
+
/** A picture is being dragged over the board: say that it can be dropped. */
|
|
199
|
+
handleDragOver(event: DragEvent): void;
|
|
200
|
+
/** Pictures were dropped on the board: they land where the pointer is. */
|
|
201
|
+
handleDrop(event: DragEvent): void;
|
|
202
|
+
/** Saves whatever the buffer still holds, now. Resolves once the page's save is done. */
|
|
203
|
+
flushAutosave(): Promise<void>;
|
|
204
|
+
/** An immediate save (Cmd+S, the save button, the page's own flushes). */
|
|
205
|
+
saveNow(): void;
|
|
206
|
+
/** The board as the text the page keeps. Null while the board is loading. */
|
|
207
|
+
saveCanvas(): string | null;
|
|
208
|
+
/**
|
|
209
|
+
* Shows saved data. Never throws: text the board cannot read (a canvas of the older engine, or something that is not
|
|
210
|
+
* a canvas) opens as an empty board, says so, and nothing is saved until the person changes something.
|
|
211
|
+
*/
|
|
212
|
+
loadCanvas(jsonString: string): Promise<void>;
|
|
213
|
+
/** Empties the board (an undo step) and tells the page. */
|
|
214
|
+
onClearAllObjects(): void;
|
|
215
|
+
setTool(tool: ToolId, options?: {
|
|
216
|
+
libraryShapeKey?: string | null;
|
|
217
|
+
}): void;
|
|
218
|
+
/** A letter of the keyboard chose a tool (or the menu did). */
|
|
219
|
+
chooseShortcutTool(tool: ToolShortcut): void;
|
|
220
|
+
/** The Select tool: the creator closes the element selector of its widgets when it hears of it. */
|
|
221
|
+
onSelectSelectTool(): void;
|
|
222
|
+
onSelectDrawTool(): void;
|
|
223
|
+
onSelectEraseTool(): void;
|
|
224
|
+
onSelectTextTool(): void;
|
|
225
|
+
onSelectArrowTool(): void;
|
|
226
|
+
onSelectPanTool(): void;
|
|
227
|
+
/** The names are the old ones: `circle` is the oval, `circle-true` the circle. */
|
|
228
|
+
onSelectShapeTool(shapeType: ShapeToolName): void;
|
|
229
|
+
/** The second argument of the old call (the path of the shape) is still accepted, and not needed: the library knows the shape by its key. */
|
|
230
|
+
onSelectLibraryShapeTool(shapeKey: string, _pathData?: string): void;
|
|
231
|
+
/** The image tool opens the file chooser (it needs the click that called it, which is how the toolbar and the key call it). */
|
|
232
|
+
onSelectImageTool(): void;
|
|
233
|
+
/** There are no frames on this board: kept so a page that still calls it keeps working. */
|
|
234
|
+
onSelectFrameTool(): void;
|
|
235
|
+
/** There is no video on this board: kept so a page that still calls it keeps working. */
|
|
236
|
+
onSelectVideoTool(): void;
|
|
237
|
+
zoomIn(): void;
|
|
238
|
+
zoomOut(): void;
|
|
239
|
+
zoomTo(percent: number): void;
|
|
240
|
+
zoomReset(): void;
|
|
241
|
+
zoomFit(): void;
|
|
242
|
+
deselectAll(): void;
|
|
243
|
+
onSelectAllObjects(): void;
|
|
244
|
+
onDeselectAllObjects(): void;
|
|
245
|
+
/** The same as the keys and the menu: copies the selection. Widget cards are made into new widgets by the page. */
|
|
246
|
+
duplicateSelectedObjects(): ObjectId[];
|
|
247
|
+
deleteSelectedObjects(): Promise<boolean>;
|
|
248
|
+
/** The same as the Copy key: remembers the selection for a paste and marks the system clipboard as the board's. */
|
|
249
|
+
copySelection(): boolean;
|
|
250
|
+
/** The same as the Cut key. */
|
|
251
|
+
cutSelection(): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Paste from the menu, centred on a point of the board (in pixels of the board). A copy made on the board wins; without
|
|
254
|
+
* one, a picture on the system clipboard is put on the board when the browser lets the page read it.
|
|
255
|
+
*/
|
|
256
|
+
pasteAt(boardPoint: Point | null): Promise<void>;
|
|
257
|
+
/** A colour for a new shape: a random hue, so that shapes drawn in a row can be told apart. */
|
|
258
|
+
shapeFillColor(): string;
|
|
259
|
+
onGroupSelection(): string | null;
|
|
260
|
+
onUngroupSelection(): void;
|
|
261
|
+
undo(): Promise<void>;
|
|
262
|
+
redo(): Promise<void>;
|
|
263
|
+
/** What the page reads of the selection: a view of the one object, or of the several. */
|
|
264
|
+
getSelectedObject(): HostObject | null;
|
|
265
|
+
addRect(): ObjectId | null;
|
|
266
|
+
addCircle(): ObjectId | null;
|
|
267
|
+
addTriangle(): ObjectId | null;
|
|
268
|
+
/** A label in the middle of the view, ready to be typed in. */
|
|
269
|
+
addText(): ObjectId;
|
|
270
|
+
/** There are no frames on this board: kept so a page that still calls it keeps working. */
|
|
271
|
+
addFrame(): null;
|
|
272
|
+
/** Opens the file chooser and puts the pictures that are chosen on the board. */
|
|
273
|
+
addImage(): Promise<void>;
|
|
274
|
+
/** The SVG entry of the shapes menu: the same as `addImage`, but the chooser only offers vector files. */
|
|
275
|
+
addSvg(): Promise<void>;
|
|
276
|
+
/** Reads picture files and puts them on the board, side by side from `at` (the middle of the view by default), as one step. */
|
|
277
|
+
insertImageFiles(files: readonly (File | Blob)[], at?: Point): Promise<ObjectId[]>;
|
|
278
|
+
insertLoadedImages(pictures: readonly LoadedImageFile[], at?: Point): ObjectId[];
|
|
279
|
+
/** A PNG of everything on the board, cropped to it; an empty string for an empty board. */
|
|
280
|
+
captureCanvasSketch(): Promise<string>;
|
|
281
|
+
/** The selection panel's "capture": hands the page a screenshot of the selection. */
|
|
282
|
+
captureSelection(): Promise<void>;
|
|
283
|
+
/** The whole board becomes one card of the widget. Resolves to the id of the card. */
|
|
284
|
+
absorbCanvasSketchIntoWidget(widgetId: string, screenshotDataUrl: string): Promise<string | null>;
|
|
285
|
+
/** Gives a card (or any object, which becomes one) the widget it stands for. */
|
|
286
|
+
linkObjectToWidget(target: ObjectId | {
|
|
287
|
+
id?: ObjectId;
|
|
288
|
+
_objectId?: ObjectId;
|
|
289
|
+
} | null | undefined, widgetId: string, widgetName?: string | null): void;
|
|
290
|
+
/** Gives the card with that id its widget (the page learned the id of the widget it made). */
|
|
291
|
+
linkFrameToWidget(objectId: string, widgetId: string): void;
|
|
292
|
+
/** Marks the selected cards as being copied: a loader shows over them until the page links them. */
|
|
293
|
+
markSelectedAsDuplicating(): void;
|
|
294
|
+
/** Replaces an object, or the selection a conversion remembered under that id, by a card of the widget. */
|
|
295
|
+
replaceObjectWithWidgetImage(objectId: string, widgetId: string, screenshotDataUrl: string): Promise<string | null>;
|
|
296
|
+
updateWidgetImage(widgetId: string, newScreenshotDataUrl: string): void;
|
|
297
|
+
selectWidgetShape(widgetId: string): boolean;
|
|
298
|
+
selectWidgetShapeById(widgetId: string): boolean;
|
|
299
|
+
getSelectedWidgetShapeId(): string | null;
|
|
300
|
+
getHoveredWidgetShapeId(): string | null;
|
|
301
|
+
/** The cards a live widget can be drawn over, with where each is on the page. */
|
|
302
|
+
listWidgetShapeScreenRects(): WidgetScreenRect[];
|
|
303
|
+
/** Where the card of a widget is on the page, with the board it is on. */
|
|
304
|
+
getWidgetShapeScreenRect(widgetId: string): ScreenRect | null;
|
|
305
|
+
/** Where any object is on the page: the id of an object, of a group, or of a selection a conversion remembered. */
|
|
306
|
+
getObjectScreenRect(objectId: string): ScreenRect | null;
|
|
307
|
+
/**
|
|
308
|
+
* The picture of a card as a data address, or null. A card shows its last screenshot; the answer is that one when it
|
|
309
|
+
* is inline (the page asks for it at a moment it cannot wait, so the board does not draw anything new here).
|
|
310
|
+
*/
|
|
311
|
+
getWidgetShapeDataUrl(widgetId: string): string | null;
|
|
312
|
+
/** Hides the screenshot of a card while a live widget covers it (so it does not show through the padding). */
|
|
313
|
+
setWidgetShapeLivePreviewHiddenImage(widgetId: string, hidden: boolean): void;
|
|
314
|
+
/** Puts a card for a widget in the middle of the view (rows of up to four for a batch). */
|
|
315
|
+
addWidgetShape(widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null): string | null;
|
|
316
|
+
getLinkedWidgetIds(): Set<string>;
|
|
317
|
+
keepOnlyWidgetShape(widgetId: string): number;
|
|
318
|
+
/** Takes everything but the card of one widget off the board. Returns how many objects went. */
|
|
319
|
+
removeSketchObjectsKeepingWidget(widgetId: string): number;
|
|
320
|
+
hydrateWidgetShapeMetadata(widgetsById: Map<string, WidgetMetadata>): number;
|
|
321
|
+
markOrphanedWidgetShapes(validWidgetIds: Set<string>): number;
|
|
322
|
+
setPrimaryWidgetShape(widgetId: string): boolean;
|
|
323
|
+
/** The selection chrome's "set as primary": marks the card, then tells the page so it can keep it. */
|
|
324
|
+
handleSetPrimaryFromPanel(widgetId: string): void;
|
|
325
|
+
getPrimaryWidgetId(): string | null;
|
|
326
|
+
/** A live widget covers the card: its own bar moves it, so the body does not. */
|
|
327
|
+
setWidgetShapeBodyDragAllowed(widgetId: string, allowed: boolean): void;
|
|
328
|
+
/** The page's bar drags a card by a distance in page pixels (the zoom, and a board the page scales, are accounted for). */
|
|
329
|
+
translateWidgetShapeByScreen(widgetId: string, dxScreen: number, dyScreen: number): boolean;
|
|
330
|
+
/** The page's bar let go: the move is one step and the board is marked as changed. */
|
|
331
|
+
/** The id the old call carries (the creator still passes it) is not needed: only one card is carried at a time, and the engine knows which. */
|
|
332
|
+
commitWidgetShapeTranslate(_widgetId?: string | null): void;
|
|
333
|
+
setWidgetShapeOverlayDragActive(active: boolean): void;
|
|
334
|
+
/**
|
|
335
|
+
* The lines a text is drawn on. The board draws exactly these (never letting the browser wrap), and the sketch handed to
|
|
336
|
+
* the AI is drawn from the same lines, so what is on the screen is what is sent. Kept per record: a text that did not
|
|
337
|
+
* change is not laid out again on the next frame, and all of them are when the fonts finished loading.
|
|
338
|
+
*/
|
|
339
|
+
textLayoutOf(text: TextObject): TextLayout;
|
|
340
|
+
/** The name drawn on a card: what the page calls the widget, what the card was saved with, or the generic word. */
|
|
341
|
+
widgetLabel(card: WidgetObject): string;
|
|
342
|
+
/** Whether the widget behind a card is gone (the card is kept, with a label that says so). */
|
|
343
|
+
isCardOrphaned(card: WidgetObject): boolean;
|
|
344
|
+
/** A new id for something the shell makes. */
|
|
345
|
+
createId(prefix?: string): ObjectId;
|
|
346
|
+
/** A plain rectangle in the middle of the view (used by the stress page). */
|
|
347
|
+
makeRect(fields?: Partial<Parameters<typeof createRectObject>[0]>): ObjectId;
|
|
348
|
+
}
|