@widgetic/canvas 0.5.41 → 0.5.43
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 +1 -0
- package/dist/canvas/DomCanvas.svelte +49 -20
- package/dist/canvas/DomCanvas.svelte.d.ts +13 -7
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.d.ts +14 -3
- package/dist/canvas/chromeLayout.js +30 -20
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +47 -5
- package/dist/canvas/host/CanvasHost.js +1481 -1566
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/browserServices.js +65 -116
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.d.ts +33 -0
- package/dist/canvas/host/nearCards.js +78 -0
- package/dist/canvas/host/pageEvents.d.ts +16 -4
- package/dist/canvas/host/pageEvents.js +17 -8
- package/dist/canvas/host/pictureSaves.d.ts +33 -0
- package/dist/canvas/host/pictureSaves.js +42 -0
- package/dist/canvas/host/screenRects.d.ts +5 -0
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.d.ts +88 -0
- package/dist/canvas/host/storedPictures.js +288 -0
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.d.ts +45 -2
- package/dist/canvas/shapes/shapeImageStore.js +10 -3
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.d.ts +2 -2
- package/dist/canvas/toolbarPosition.js +4 -4
- package/dist/canvas/ui/SelectionPanel.svelte +28 -5
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/SelectorIndicator.svelte +81 -0
- package/dist/canvas/ui/SelectorIndicator.svelte.d.ts +11 -0
- package/dist/canvas/ui/ToolButton.svelte +8 -2
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +2 -2
- package/dist/canvas/ui/floatingCard.js +20 -20
- package/dist/canvas/ui/floatingLayer.d.ts +13 -2
- package/dist/canvas/ui/floatingLayer.js +18 -7
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.js +34 -40
- package/dist/canvas/view/CanvasStage.svelte +101 -67
- package/dist/canvas/view/LeftToRightScope.svelte +21 -0
- package/dist/canvas/view/LeftToRightScope.svelte.d.ts +7 -0
- package/dist/canvas/view/ObjectView.svelte +15 -10
- package/dist/canvas/view/ObjectView.svelte.d.ts +1 -1
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.js +71 -90
- package/dist/canvas/view/liftedScene.d.ts +31 -0
- package/dist/canvas/view/liftedScene.js +146 -0
- package/dist/canvas/view/mountedScene.d.ts +71 -0
- package/dist/canvas/view/mountedScene.js +363 -0
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +15 -1
- package/dist/engine/EngineCore.js +724 -797
- package/dist/engine/codec/canvasDocument.d.ts +5 -0
- package/dist/engine/codec/canvasDocument.js +212 -149
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +76 -89
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.js +67 -94
- package/dist/engine/core/defaults.js +90 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.d.ts +6 -0
- package/dist/engine/core/history.js +49 -50
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.d.ts +10 -0
- package/dist/engine/core/scene.js +153 -187
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.js +72 -63
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.js +31 -64
- package/dist/engine/core/transform.js +83 -94
- package/dist/engine/core/types.d.ts +8 -2
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +467 -474
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.js +265 -309
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +27 -30
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.d.ts +20 -0
- package/dist/engine/state.js +5 -15
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.d.ts +10 -1
- package/dist/fonts/interFont.js +47 -75
- package/dist/fonts/workspaceFonts.js +32 -90
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.d.ts +8 -1
- package/dist/i18n/messages.js +10 -2
- package/dist/i18n/shortcuts.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/settings/workspaceToolSettings.js +32 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +105 -141
- package/dist/tools/hostAdapter.js +11 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/types.js +1 -1
- package/package.json +1 -1
- package/dist/canvas/ui/SelectorBar.svelte +0 -84
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +0 -12
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
1
|
import { createPathObject, createRectObject, createTextObject } from '../../engine/core/defaults.js';
|
|
11
2
|
import { buildArrow } from '../../engine/core/arrow.js';
|
|
12
3
|
import { serializePathData } from '../../engine/core/pathData.js';
|
|
@@ -14,27 +5,27 @@ import { packGroup } from './grouping.js';
|
|
|
14
5
|
function snap(value) {
|
|
15
6
|
return Math.round(value / 8) * 8;
|
|
16
7
|
}
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const STROKE = '#9ca3af';
|
|
9
|
+
const STROKE_WIDTH = 2;
|
|
19
10
|
export function drawUiComponent(kind, x, y, width, height, label) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
const objects = [];
|
|
12
|
+
const px = snap(x);
|
|
13
|
+
const py = snap(y);
|
|
14
|
+
const w = snap(Math.max(160, width));
|
|
15
|
+
const h = snap(Math.max(120, height));
|
|
25
16
|
switch (kind) {
|
|
26
17
|
case 'video_player': {
|
|
27
|
-
|
|
18
|
+
const title = createTextObject({
|
|
28
19
|
x: px,
|
|
29
20
|
y: py - 28,
|
|
30
|
-
text:
|
|
21
|
+
text: label?.trim() || 'Video player',
|
|
31
22
|
fontSize: 14,
|
|
32
23
|
fontWeight: 'bold',
|
|
33
24
|
autoWidth: true
|
|
34
25
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
const thumbW = w;
|
|
27
|
+
const thumbH = snap(thumbW * (9 / 16));
|
|
28
|
+
const frame = createRectObject({
|
|
38
29
|
x: px,
|
|
39
30
|
y: py,
|
|
40
31
|
width: thumbW,
|
|
@@ -43,7 +34,7 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
43
34
|
stroke: STROKE,
|
|
44
35
|
strokeWidth: STROKE_WIDTH
|
|
45
36
|
});
|
|
46
|
-
|
|
37
|
+
const screen = createRectObject({
|
|
47
38
|
x: px + 12,
|
|
48
39
|
y: py + 12,
|
|
49
40
|
width: thumbW - 24,
|
|
@@ -53,15 +44,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
53
44
|
stroke: 'transparent',
|
|
54
45
|
strokeWidth: 0
|
|
55
46
|
});
|
|
56
|
-
|
|
47
|
+
const screenLabel = createTextObject({
|
|
57
48
|
x: px + 16,
|
|
58
49
|
y: py + 4,
|
|
59
50
|
text: 'Thumbnail',
|
|
60
51
|
fontSize: 11,
|
|
61
52
|
autoWidth: true
|
|
62
53
|
});
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
const playSize = 56;
|
|
55
|
+
const play = createRectObject({
|
|
65
56
|
x: px + thumbW / 2 - playSize / 2,
|
|
66
57
|
y: py + thumbH / 2 - playSize / 2,
|
|
67
58
|
width: playSize,
|
|
@@ -71,8 +62,8 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
71
62
|
stroke: '#d1d5db',
|
|
72
63
|
strokeWidth: 1
|
|
73
64
|
});
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
const screenGroup = packGroup([frame, screen, play, screenLabel], {});
|
|
66
|
+
const navBar = createRectObject({
|
|
76
67
|
x: px,
|
|
77
68
|
y: py + thumbH + 16,
|
|
78
69
|
width: thumbW,
|
|
@@ -82,8 +73,8 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
82
73
|
stroke: STROKE,
|
|
83
74
|
strokeWidth: STROKE_WIDTH
|
|
84
75
|
});
|
|
85
|
-
|
|
86
|
-
for (
|
|
76
|
+
const navThumbs = [];
|
|
77
|
+
for (let i = 0; i < 5; i++) {
|
|
87
78
|
navThumbs.push(createRectObject({
|
|
88
79
|
x: px + 16 + i * 56,
|
|
89
80
|
y: py + thumbH + 32,
|
|
@@ -95,7 +86,7 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
95
86
|
strokeWidth: 0
|
|
96
87
|
}));
|
|
97
88
|
}
|
|
98
|
-
|
|
89
|
+
const navTitle = createTextObject({
|
|
99
90
|
x: px,
|
|
100
91
|
y: py + thumbH + 4,
|
|
101
92
|
text: 'Navigation',
|
|
@@ -103,16 +94,16 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
103
94
|
fontWeight: 'bold',
|
|
104
95
|
autoWidth: true
|
|
105
96
|
});
|
|
106
|
-
|
|
107
|
-
objects.push
|
|
97
|
+
const navGroup = packGroup([navBar, navTitle, ...navThumbs], {});
|
|
98
|
+
objects.push(title, ...screenGroup.objects, ...navGroup.objects);
|
|
108
99
|
return {
|
|
109
|
-
objects
|
|
100
|
+
objects,
|
|
110
101
|
rootLabel: 'Video player',
|
|
111
102
|
highlightIds: [navGroup.groupId]
|
|
112
103
|
};
|
|
113
104
|
}
|
|
114
105
|
case 'navigation_bar': {
|
|
115
|
-
|
|
106
|
+
const bar = createRectObject({
|
|
116
107
|
x: px,
|
|
117
108
|
y: py + 20,
|
|
118
109
|
width: w,
|
|
@@ -122,32 +113,32 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
122
113
|
strokeWidth: STROKE_WIDTH,
|
|
123
114
|
fill: '#f9fafb'
|
|
124
115
|
});
|
|
125
|
-
|
|
116
|
+
const title = createTextObject({
|
|
126
117
|
x: px,
|
|
127
118
|
y: py,
|
|
128
|
-
text:
|
|
119
|
+
text: label?.trim() || 'Navigation bar',
|
|
129
120
|
fontSize: 12,
|
|
130
121
|
fontWeight: 'bold',
|
|
131
122
|
autoWidth: true
|
|
132
123
|
});
|
|
133
|
-
|
|
134
|
-
for (
|
|
124
|
+
const tabs = [];
|
|
125
|
+
for (let i = 0; i < 4; i++) {
|
|
135
126
|
tabs.push(createTextObject({
|
|
136
127
|
x: px + 16 + i * 96,
|
|
137
128
|
y: py + 36,
|
|
138
|
-
text:
|
|
129
|
+
text: `Nav ${i + 1}`,
|
|
139
130
|
fontSize: 14,
|
|
140
131
|
autoWidth: true
|
|
141
132
|
}));
|
|
142
133
|
}
|
|
143
|
-
|
|
144
|
-
objects.push
|
|
145
|
-
return { objects
|
|
134
|
+
const packed = packGroup([bar, ...tabs], {});
|
|
135
|
+
objects.push(title, ...packed.objects);
|
|
136
|
+
return { objects, rootLabel: label?.trim() || 'Navigation bar' };
|
|
146
137
|
}
|
|
147
138
|
case 'button': {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
const btnH = snap(Math.max(44, Math.min(48, h)));
|
|
140
|
+
const btnW = snap(Math.max(128, w));
|
|
141
|
+
const btn = createRectObject({
|
|
151
142
|
x: px,
|
|
152
143
|
y: py + 22,
|
|
153
144
|
width: btnW,
|
|
@@ -157,14 +148,14 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
157
148
|
stroke: STROKE,
|
|
158
149
|
strokeWidth: STROKE_WIDTH
|
|
159
150
|
});
|
|
160
|
-
|
|
151
|
+
const caption = createTextObject({
|
|
161
152
|
x: px + 16,
|
|
162
153
|
y: py + 34,
|
|
163
|
-
text: label
|
|
154
|
+
text: label ?? 'Button',
|
|
164
155
|
fontSize: 15,
|
|
165
156
|
autoWidth: true
|
|
166
157
|
});
|
|
167
|
-
|
|
158
|
+
const title = createTextObject({
|
|
168
159
|
x: px,
|
|
169
160
|
y: py,
|
|
170
161
|
text: 'Button',
|
|
@@ -172,13 +163,13 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
172
163
|
color: '#6b7280',
|
|
173
164
|
autoWidth: true
|
|
174
165
|
});
|
|
175
|
-
|
|
176
|
-
objects.push
|
|
177
|
-
return { objects
|
|
166
|
+
const packed = packGroup([btn, caption], {});
|
|
167
|
+
objects.push(title, ...packed.objects);
|
|
168
|
+
return { objects, rootLabel: label ?? 'Button' };
|
|
178
169
|
}
|
|
179
170
|
case 'card': {
|
|
180
|
-
|
|
181
|
-
|
|
171
|
+
const cardH = snap(Math.max(160, h));
|
|
172
|
+
const card = createRectObject({
|
|
182
173
|
x: px,
|
|
183
174
|
y: py + 24,
|
|
184
175
|
width: w,
|
|
@@ -188,15 +179,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
188
179
|
strokeWidth: STROKE_WIDTH,
|
|
189
180
|
fill: '#ffffff'
|
|
190
181
|
});
|
|
191
|
-
|
|
182
|
+
const heading = createTextObject({
|
|
192
183
|
x: px + 16,
|
|
193
184
|
y: py + 40,
|
|
194
|
-
text: label
|
|
185
|
+
text: label ?? 'Card title',
|
|
195
186
|
fontSize: 18,
|
|
196
187
|
fontWeight: 'bold',
|
|
197
188
|
autoWidth: true
|
|
198
189
|
});
|
|
199
|
-
|
|
190
|
+
const body = createRectObject({
|
|
200
191
|
x: px + 16,
|
|
201
192
|
y: py + 72,
|
|
202
193
|
width: w - 32,
|
|
@@ -206,15 +197,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
206
197
|
stroke: 'transparent',
|
|
207
198
|
strokeWidth: 0
|
|
208
199
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
objects.push
|
|
212
|
-
return { objects
|
|
200
|
+
const title = createTextObject({ x: px, y: py, text: 'Card', fontSize: 11, color: '#6b7280', autoWidth: true });
|
|
201
|
+
const packed = packGroup([card, heading, body], {});
|
|
202
|
+
objects.push(title, ...packed.objects);
|
|
203
|
+
return { objects, rootLabel: label ?? 'Card' };
|
|
213
204
|
}
|
|
214
205
|
case 'form': {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
for (
|
|
206
|
+
const title = createTextObject({ x: px, y: py, text: label ?? 'Form', fontSize: 12, fontWeight: 'bold', autoWidth: true });
|
|
207
|
+
const fields = [];
|
|
208
|
+
for (let i = 0; i < 3; i++) {
|
|
218
209
|
fields.push(createRectObject({
|
|
219
210
|
x: px,
|
|
220
211
|
y: py + 32 + i * 48,
|
|
@@ -226,12 +217,12 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
226
217
|
fill: '#fff'
|
|
227
218
|
}));
|
|
228
219
|
}
|
|
229
|
-
|
|
230
|
-
objects.push
|
|
231
|
-
return { objects
|
|
220
|
+
const packed = packGroup(fields, {});
|
|
221
|
+
objects.push(title, ...packed.objects);
|
|
222
|
+
return { objects, rootLabel: label ?? 'Form' };
|
|
232
223
|
}
|
|
233
224
|
default: {
|
|
234
|
-
|
|
225
|
+
const box = createRectObject({
|
|
235
226
|
x: px,
|
|
236
227
|
y: py + 20,
|
|
237
228
|
width: w,
|
|
@@ -240,21 +231,20 @@ export function drawUiComponent(kind, x, y, width, height, label) {
|
|
|
240
231
|
stroke: STROKE,
|
|
241
232
|
strokeWidth: STROKE_WIDTH
|
|
242
233
|
});
|
|
243
|
-
|
|
234
|
+
const title = createTextObject({
|
|
244
235
|
x: px,
|
|
245
236
|
y: py,
|
|
246
|
-
text: label
|
|
237
|
+
text: label ?? kind.replace(/_/g, ' '),
|
|
247
238
|
fontSize: 14,
|
|
248
239
|
autoWidth: true
|
|
249
240
|
});
|
|
250
241
|
objects.push(title, box);
|
|
251
|
-
return { objects
|
|
242
|
+
return { objects, rootLabel: label ?? kind };
|
|
252
243
|
}
|
|
253
244
|
}
|
|
254
245
|
}
|
|
255
|
-
export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth) {
|
|
256
|
-
|
|
257
|
-
var geometry = buildArrow({ x: fromX, y: fromY }, { x: toX, y: toY }, 0, strokeWidth);
|
|
246
|
+
export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth = 2) {
|
|
247
|
+
const geometry = buildArrow({ x: fromX, y: fromY }, { x: toX, y: toY }, 0, strokeWidth);
|
|
258
248
|
return createPathObject({
|
|
259
249
|
x: geometry.box.x,
|
|
260
250
|
y: geometry.box.y,
|
|
@@ -264,7 +254,7 @@ export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth) {
|
|
|
264
254
|
shape: 'arrow',
|
|
265
255
|
arrow: geometry.spec,
|
|
266
256
|
stroke: '#111827',
|
|
267
|
-
strokeWidth
|
|
257
|
+
strokeWidth,
|
|
268
258
|
fill: 'transparent'
|
|
269
259
|
});
|
|
270
260
|
}
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
1
|
import { createGroupObject, createObjectId } from '../../engine/core/defaults.js';
|
|
22
2
|
/** Insert a group and its members in list order (group before members). */
|
|
23
|
-
export function packGroup(members, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var parentId = (_b = options.parentId) !== null && _b !== void 0 ? _b : null;
|
|
28
|
-
var withParents = members.map(function (object) { return (__assign(__assign({}, object), { parentId: groupId })); });
|
|
3
|
+
export function packGroup(members, options = {}) {
|
|
4
|
+
const groupId = options.groupId ?? createObjectId('gp');
|
|
5
|
+
const parentId = options.parentId ?? null;
|
|
6
|
+
const withParents = members.map((object) => ({ ...object, parentId: groupId }));
|
|
29
7
|
return {
|
|
30
|
-
groupId
|
|
31
|
-
objects:
|
|
8
|
+
groupId,
|
|
9
|
+
objects: [createGroupObject({ id: groupId, parentId }), ...withParents]
|
|
32
10
|
};
|
|
33
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CANVAS_TOOL_NAMES } from './types.js';
|
|
2
|
-
export
|
|
2
|
+
export const CANVAS_TOOL_DEFINITIONS = [
|
|
3
3
|
{
|
|
4
4
|
name: 'get_canvas',
|
|
5
5
|
description: 'Read a compact summary of everything on the canvas: element ids, kinds, text labels, bounding boxes and z-order.',
|
|
@@ -128,20 +128,20 @@ export function isCanvasToolName(name) {
|
|
|
128
128
|
}
|
|
129
129
|
/** OpenAI / MCP-style tool list for the gateway LLM loop. */
|
|
130
130
|
export function toOpenAiTools() {
|
|
131
|
-
return CANVAS_TOOL_DEFINITIONS.map(
|
|
131
|
+
return CANVAS_TOOL_DEFINITIONS.map((tool) => ({
|
|
132
132
|
type: 'function',
|
|
133
133
|
function: {
|
|
134
134
|
name: tool.name,
|
|
135
135
|
description: tool.description,
|
|
136
136
|
parameters: tool.parameters
|
|
137
137
|
}
|
|
138
|
-
})
|
|
138
|
+
}));
|
|
139
139
|
}
|
|
140
140
|
/** MCP tool catalogue (names + inputSchema only). */
|
|
141
141
|
export function toMcpTools() {
|
|
142
|
-
return CANVAS_TOOL_DEFINITIONS.map(
|
|
142
|
+
return CANVAS_TOOL_DEFINITIONS.map((tool) => ({
|
|
143
143
|
name: tool.name,
|
|
144
144
|
description: tool.description,
|
|
145
145
|
inputSchema: tool.parameters
|
|
146
|
-
})
|
|
146
|
+
}));
|
|
147
147
|
}
|