@chocbite/ts-lib-ui 1.0.3 → 1.0.4
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 +0 -1
- package/canvas/index.d.mts +114 -59
- package/canvas/index.mjs +645 -575
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-_9dMpC-H.mjs → context-menu-Cz9rqUaM.mjs} +2 -2
- package/{context-menu-_9dMpC-H.mjs.map → context-menu-Cz9rqUaM.mjs.map} +1 -1
- package/form/index.d.mts +1 -1
- package/form/index.mjs +4 -4
- package/{index-CzpbJoAj.d.mts → index-DCn7acFY.d.mts} +13 -4
- package/keyboard/index.mjs +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-Bkm9Ailw.mjs → list-DXkEJKjx.mjs} +130 -20
- package/list-DXkEJKjx.mjs.map +1 -0
- package/package.json +2 -7
- package/spinner/index.mjs +1 -1
- package/style.css +409 -135
- package/theme/index.mjs +1 -1
- package/{theme-DlD5P5tY.mjs → theme-CFeGnUuF.mjs} +2 -2
- package/{theme-DlD5P5tY.mjs.map → theme-CFeGnUuF.mjs.map} +1 -1
- package/list-Bkm9Ailw.mjs.map +0 -1
- package/viewport/index.d.mts +0 -1
- package/viewport/index.mjs +0 -2
package/canvas/index.mjs
CHANGED
|
@@ -1,617 +1,687 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
2
|
import { Base, define_element } from "../base/index.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
sw.appendChild(svg.line(-8, 8, 8, -8).elem);
|
|
29
|
-
sw.appendChild(svg.isosceles_triangle(-7, 7, 8, 6).rotate(-135, -7, 7).elem);
|
|
30
|
-
sw.appendChild(svg.isosceles_triangle(7, -7, 8, 6).rotate(45, 7, -7).elem);
|
|
31
|
-
const move = svg.svg(32, 32, "0 0 32 32").cl("move").elem;
|
|
32
|
-
move.appendChild(svg.create("circle").elem);
|
|
33
|
-
move.appendChild(svg.line(0, 8, 0, -8).elem);
|
|
34
|
-
move.appendChild(svg.isosceles_triangle(0, 10, 8, 6).rotate(180, 0, 10).elem);
|
|
35
|
-
move.appendChild(svg.isosceles_triangle(0, -10, 8, 6).rotate(0, 0, -10).elem);
|
|
36
|
-
move.appendChild(svg.line(-10, 0, 10, 0).elem);
|
|
37
|
-
move.appendChild(svg.isosceles_triangle(-10, 0, 8, 6).rotate(270, -10, 0).elem);
|
|
38
|
-
move.appendChild(svg.isosceles_triangle(10, 0, 8, 6).rotate(90, 10, 0).elem);
|
|
39
|
-
const rotate_sym = svg.svg(32, 32, "0 0 32 32").a("y", "-30").cl("rotate").elem;
|
|
40
|
-
rotate_sym.appendChild(svg.create("circle").elem);
|
|
41
|
-
rotate_sym.appendChild(svg.attr(material_autorenew_rounded()).a("x", "-12").a("y", "-12").elem);
|
|
42
|
-
const rotation_center_indicator = svg.svg(16, 16, "0 0 16 16").cl("rotation-center").elem;
|
|
43
|
-
rotation_center_indicator.appendChild(svg.create("circle").elem);
|
|
44
|
-
rotation_center_indicator.appendChild(svg.line(-6, 0, 6, 0).elem);
|
|
45
|
-
rotation_center_indicator.appendChild(svg.line(0, -6, 0, 6).elem);
|
|
46
|
-
const DEG_TO_RAD = Math.PI / 180;
|
|
47
|
-
/**Rounds the value to the grid, a grid of 0 does not snap*/
|
|
48
|
-
const snap = (value, grid) => grid ? Math.round(value / grid) * grid : value;
|
|
49
|
-
/**Stops a handle following the pointer, for pointerup and pointercancel*/
|
|
50
|
-
const handle_release = (ev) => {
|
|
51
|
-
const handle = ev.currentTarget;
|
|
52
|
-
if (handle.hasPointerCapture(ev.pointerId)) handle.releasePointerCapture(ev.pointerId);
|
|
53
|
-
handle.onpointermove = null;
|
|
54
|
-
};
|
|
55
|
-
var ViewportMover = class {
|
|
56
|
-
#canvas = svg.create("svg").cl("viewport-mover").elem;
|
|
57
|
-
#outline = this.#canvas.appendChild(svg.rectangle_from_corner(-1, -1, 1, 1, 0).elem);
|
|
58
|
-
#nw_corner = this.#canvas.appendChild(node_clone(nw));
|
|
59
|
-
#ne_corner = this.#canvas.appendChild(node_clone(ne));
|
|
60
|
-
#sw_corner = this.#canvas.appendChild(node_clone(sw));
|
|
61
|
-
#se_corner = this.#canvas.appendChild(node_clone(se));
|
|
62
|
-
#move = this.#canvas.appendChild(node_clone(move));
|
|
63
|
-
#rotate = this.#canvas.appendChild(node_clone(rotate_sym));
|
|
64
|
-
#rc_indicator = this.#canvas.appendChild(node_clone(rotation_center_indicator));
|
|
65
|
-
#scale_buffer = 1;
|
|
66
|
-
#grid_x_buffer = 1;
|
|
67
|
-
#grid_y_buffer = 1;
|
|
68
|
-
#grid_rotate_buffer = 0;
|
|
69
|
-
constructor(scale, grid_x, grid_y, grid_rotate) {
|
|
70
|
-
scale.sub((val) => {
|
|
71
|
-
this.#scale_buffer = val.value;
|
|
72
|
-
const s = `scale(${1 / val.value})`;
|
|
73
|
-
this.#nw_corner.setAttribute("transform", s);
|
|
74
|
-
this.#ne_corner.setAttribute("transform", s);
|
|
75
|
-
this.#sw_corner.setAttribute("transform", s);
|
|
76
|
-
this.#se_corner.setAttribute("transform", s);
|
|
77
|
-
this.#move.setAttribute("transform", s);
|
|
78
|
-
this.#rotate.setAttribute("transform", s);
|
|
79
|
-
this.#rc_indicator.setAttribute("transform", s);
|
|
80
|
-
}, true);
|
|
81
|
-
grid_x.sub((val) => {
|
|
82
|
-
this.#grid_x_buffer = val.value;
|
|
83
|
-
}, true);
|
|
84
|
-
grid_y.sub((val) => {
|
|
85
|
-
this.#grid_y_buffer = val.value;
|
|
86
|
-
}, true);
|
|
87
|
-
grid_rotate.sub((val) => {
|
|
88
|
-
this.#grid_rotate_buffer = val.value;
|
|
89
|
-
}, true);
|
|
90
|
-
this.#setup_position();
|
|
91
|
-
this.#setup_corner(this.#nw_corner, -1, -1);
|
|
92
|
-
this.#setup_corner(this.#ne_corner, 1, -1);
|
|
93
|
-
this.#setup_corner(this.#sw_corner, -1, 1);
|
|
94
|
-
this.#setup_corner(this.#se_corner, 1, 1);
|
|
95
|
-
this.#setup_rotation();
|
|
96
|
-
}
|
|
97
|
-
#update_mover_transform() {
|
|
98
|
-
if (this.#rotation === 0) this.#canvas.removeAttribute("transform");
|
|
99
|
-
else {
|
|
100
|
-
const cx = this.#position_x + this.#rotation_center_x;
|
|
101
|
-
const cy = this.#position_y + this.#rotation_center_y;
|
|
102
|
-
this.#canvas.setAttribute("transform", `rotate(${this.#rotation} ${cx} ${cy})`);
|
|
103
|
-
}
|
|
3
|
+
import { i as theme_init_variable_root } from "../theme-CFeGnUuF.mjs";
|
|
4
|
+
import { $q as material_open_with_rounded, ha as material_arrow_range_rounded, r2 as material_rotate_right_rounded } from "../icons-e2J_Ojic.mjs";
|
|
5
|
+
import { BLUE, GREY } from "@chocbite/ts-lib/colors";
|
|
6
|
+
// src/canvas/shared.ts
|
|
7
|
+
const theme_root = theme_init_variable_root("canvas", "Canvas", "Theme variables for canvas viewports and pages");
|
|
8
|
+
const colors = theme_root.make_sub_group("colors", "Colors", "Colors used in viewports");
|
|
9
|
+
colors.make_variable("background", "Background Color", "Color of the viewport around the page", GREY["300"], GREY["900"], "Color", void 0);
|
|
10
|
+
colors.make_variable("pageBackground", "Page Background Color", "Color of the page behind the widgets", GREY["50"], GREY["800"], "Color", void 0);
|
|
11
|
+
const edit = theme_root.make_sub_group("edit", "Edit", "Settings for viewports in edit mode");
|
|
12
|
+
edit.make_variable("checker1", "Checkerboard First Color", "First color of the checkerboard shown behind the page in edit mode", GREY["300"], GREY["600"], "Color", void 0);
|
|
13
|
+
edit.make_variable("checker2", "Checkerboard Second Color", "Second color of the checkerboard shown behind the page in edit mode", GREY["200"], GREY["700"], "Color", void 0);
|
|
14
|
+
edit.make_variable("checkerSize", "Checkerboard Square Size", "Size of one square of the checkerboard shown behind the page in edit mode", "0.625rem", "0.625rem", "Length", {
|
|
15
|
+
min: .1,
|
|
16
|
+
max: 10
|
|
17
|
+
});
|
|
18
|
+
const transformer = theme_root.make_sub_group("transformer", "Transformer", "Settings for the transformer used to move, resize and rotate widgets in edit mode");
|
|
19
|
+
transformer.make_variable("color", "Transformer Color", "Color of the transformer outline and handle borders", BLUE["600"], BLUE["300"], "Color", void 0);
|
|
20
|
+
transformer.make_variable("handleBackground", "Handle Background Color", "Background color of the transformer handles", GREY["50"], GREY["900"], "Color", void 0);
|
|
21
|
+
// src/canvas/page.ts
|
|
22
|
+
/**Page of widgets with a fixed size
|
|
23
|
+
* Width and height are the size of the page in page units (px before any viewport scaling)*/
|
|
24
|
+
var Page = class extends Base {
|
|
25
|
+
/**Returns the name used to define the element */
|
|
26
|
+
static element_name() {
|
|
27
|
+
return "page";
|
|
104
28
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return this.#element;
|
|
109
|
-
}
|
|
110
|
-
attach_to_element(element, canvas) {
|
|
111
|
-
this.#element = void 0;
|
|
112
|
-
this.#canvas.setAttribute("x", element.position_x.toString());
|
|
113
|
-
this.#canvas.setAttribute("y", element.position_y.toString());
|
|
114
|
-
this.width = element.width;
|
|
115
|
-
this.height = element.height;
|
|
116
|
-
this.position_x = element.position_x;
|
|
117
|
-
this.position_y = element.position_y;
|
|
118
|
-
this.#rotation = element.rotation;
|
|
119
|
-
this.#rotation_center_x = element.rotation_center_x;
|
|
120
|
-
this.#rotation_center_y = element.rotation_center_y;
|
|
121
|
-
this.#update_rc_indicator();
|
|
122
|
-
this.#element = element;
|
|
123
|
-
this.#update_mover_transform();
|
|
124
|
-
canvas.appendChild(this.#canvas);
|
|
125
|
-
}
|
|
126
|
-
detach_from_element() {
|
|
127
|
-
this.#element = void 0;
|
|
128
|
-
this.#canvas.remove();
|
|
129
|
-
}
|
|
130
|
-
#setup_position() {
|
|
131
|
-
this.#move.onpointerdown = (e) => {
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
e.stopPropagation();
|
|
134
|
-
if (!this.#element) return;
|
|
135
|
-
this.#move.setPointerCapture(e.pointerId);
|
|
136
|
-
const x = this.#position_x;
|
|
137
|
-
const y = this.#position_y;
|
|
138
|
-
const offset_x = e.offsetX;
|
|
139
|
-
const offset_y = e.offsetY;
|
|
140
|
-
this.#move.onpointermove = (ev) => {
|
|
141
|
-
if (this.#element) {
|
|
142
|
-
const pos_x = (ev.offsetX - offset_x) / this.#scale_buffer + x;
|
|
143
|
-
this.position_x = ev.shiftKey ? pos_x : snap(pos_x, this.#grid_x_buffer);
|
|
144
|
-
const pos_y = (ev.offsetY - offset_y) / this.#scale_buffer + y;
|
|
145
|
-
this.position_y = ev.shiftKey ? pos_y : snap(pos_y, this.#grid_y_buffer);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
this.#move.onpointerup = handle_release;
|
|
150
|
-
this.#move.onpointercancel = handle_release;
|
|
151
|
-
}
|
|
152
|
-
#position_x = 0;
|
|
153
|
-
set position_x(value) {
|
|
154
|
-
this.#canvas.setAttribute("x", String(value));
|
|
155
|
-
this.#position_x = value;
|
|
156
|
-
if (this.#element) this.#element.position_x = value;
|
|
157
|
-
this.#update_mover_transform();
|
|
158
|
-
}
|
|
159
|
-
#position_y = 0;
|
|
160
|
-
set position_y(value) {
|
|
161
|
-
this.#canvas.setAttribute("y", String(value));
|
|
162
|
-
this.#position_y = value;
|
|
163
|
-
if (this.#element) this.#element.position_y = value;
|
|
164
|
-
this.#update_mover_transform();
|
|
165
|
-
}
|
|
166
|
-
#setup_rotation() {
|
|
167
|
-
this.#rotate.onpointerdown = (e) => {
|
|
168
|
-
e.preventDefault();
|
|
169
|
-
e.stopPropagation();
|
|
170
|
-
if (!this.#element) return;
|
|
171
|
-
this.#rotate.setPointerCapture(e.pointerId);
|
|
172
|
-
const ctm = this.#canvas.getScreenCTM();
|
|
173
|
-
if (!ctm) return;
|
|
174
|
-
const center = new DOMPoint(this.#rotation_center_x, this.#rotation_center_y).matrixTransform(ctm);
|
|
175
|
-
const initial_angle = Math.atan2(e.clientY - center.y, e.clientX - center.x);
|
|
176
|
-
const initial_rotation = this.#rotation;
|
|
177
|
-
this.#rotate.onpointermove = (ev) => {
|
|
178
|
-
if (!this.#element) return;
|
|
179
|
-
const current_angle = Math.atan2(ev.clientY - center.y, ev.clientX - center.x);
|
|
180
|
-
const raw_rotation = initial_rotation + (current_angle - initial_angle) / DEG_TO_RAD;
|
|
181
|
-
this.rotation = ev.shiftKey ? raw_rotation : snap(raw_rotation, this.#grid_rotate_buffer);
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
this.#rotate.onpointerup = handle_release;
|
|
185
|
-
this.#rotate.onpointercancel = handle_release;
|
|
29
|
+
/**Returns the namespace override for the element*/
|
|
30
|
+
static element_name_space() {
|
|
31
|
+
return "canvas";
|
|
186
32
|
}
|
|
187
|
-
#
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
33
|
+
#width = 1920;
|
|
34
|
+
#height = 1080;
|
|
35
|
+
#widgets = [];
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this.style.width = this.#width + "px";
|
|
39
|
+
this.style.height = this.#height + "px";
|
|
191
40
|
}
|
|
192
|
-
|
|
193
|
-
set
|
|
194
|
-
this.#
|
|
195
|
-
|
|
196
|
-
this.#update_mover_transform();
|
|
197
|
-
}
|
|
198
|
-
#rotation_center_x = 0;
|
|
199
|
-
#rotation_center_y = 0;
|
|
200
|
-
#setup_corner(handle, sx, sy) {
|
|
201
|
-
handle.onpointerdown = (e) => {
|
|
202
|
-
e.preventDefault();
|
|
203
|
-
e.stopPropagation();
|
|
204
|
-
if (!this.#element) return;
|
|
205
|
-
handle.setPointerCapture(e.pointerId);
|
|
206
|
-
const initial_x = e.clientX;
|
|
207
|
-
const initial_y = e.clientY;
|
|
208
|
-
const initial_w = this.#width;
|
|
209
|
-
const initial_h = this.#height;
|
|
210
|
-
const initial_px = this.#position_x;
|
|
211
|
-
const initial_py = this.#position_y;
|
|
212
|
-
const initial_rcx = this.#rotation_center_x;
|
|
213
|
-
const initial_rcy = this.#rotation_center_y;
|
|
214
|
-
const rad = this.#rotation * DEG_TO_RAD;
|
|
215
|
-
const cos_r = Math.cos(rad);
|
|
216
|
-
const sin_r = Math.sin(rad);
|
|
217
|
-
handle.onpointermove = (ev) => {
|
|
218
|
-
if (!this.#element) return;
|
|
219
|
-
const canvas_dx = (ev.clientX - initial_x) / this.#scale_buffer;
|
|
220
|
-
const canvas_dy = (ev.clientY - initial_y) / this.#scale_buffer;
|
|
221
|
-
const local_dx = cos_r * canvas_dx + sin_r * canvas_dy;
|
|
222
|
-
const local_dy = -sin_r * canvas_dx + cos_r * canvas_dy;
|
|
223
|
-
let new_w = Math.max(1, initial_w + sx * local_dx);
|
|
224
|
-
let new_h = Math.max(1, initial_h + sy * local_dy);
|
|
225
|
-
if (!ev.shiftKey) {
|
|
226
|
-
new_w = Math.round(new_w);
|
|
227
|
-
new_h = Math.round(new_h);
|
|
228
|
-
}
|
|
229
|
-
const new_rcx = initial_w > 0 ? initial_rcx * (new_w / initial_w) : initial_rcx;
|
|
230
|
-
const new_rcy = initial_h > 0 ? initial_rcy * (new_h / initial_h) : initial_rcy;
|
|
231
|
-
const drc_x = initial_rcx - new_rcx;
|
|
232
|
-
const drc_y = initial_rcy - new_rcy;
|
|
233
|
-
const delta_w = new_w - initial_w;
|
|
234
|
-
const delta_h = new_h - initial_h;
|
|
235
|
-
let new_px = initial_px;
|
|
236
|
-
let new_py = initial_py;
|
|
237
|
-
if (sx < 0) {
|
|
238
|
-
new_px -= delta_w * cos_r;
|
|
239
|
-
new_py -= delta_w * sin_r;
|
|
240
|
-
}
|
|
241
|
-
if (sy < 0) {
|
|
242
|
-
new_px += delta_h * sin_r;
|
|
243
|
-
new_py -= delta_h * cos_r;
|
|
244
|
-
}
|
|
245
|
-
new_px += drc_x * (1 - cos_r) + drc_y * sin_r;
|
|
246
|
-
new_py += -drc_x * sin_r + drc_y * (1 - cos_r);
|
|
247
|
-
this.#rotation_center_x = new_rcx;
|
|
248
|
-
this.#rotation_center_y = new_rcy;
|
|
249
|
-
if (this.#element) {
|
|
250
|
-
this.#element.rotation_center_x = new_rcx;
|
|
251
|
-
this.#element.rotation_center_y = new_rcy;
|
|
252
|
-
}
|
|
253
|
-
this.#update_rc_indicator();
|
|
254
|
-
this.width = new_w;
|
|
255
|
-
this.height = new_h;
|
|
256
|
-
this.position_x = new_px;
|
|
257
|
-
this.position_y = new_py;
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
handle.onpointerup = handle_release;
|
|
261
|
-
handle.onpointercancel = handle_release;
|
|
41
|
+
/**Sets the width of the page */
|
|
42
|
+
set width(width) {
|
|
43
|
+
this.#width = width;
|
|
44
|
+
this.style.width = width + "px";
|
|
262
45
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.#
|
|
266
|
-
this.#ne_corner.setAttribute("x", String(value));
|
|
267
|
-
this.#ne_corner.setAttribute("transform-origin", `${value} 0`);
|
|
268
|
-
this.#se_corner.setAttribute("x", String(value));
|
|
269
|
-
this.#se_corner.setAttribute("transform-origin", `${value} ${this.#height}`);
|
|
270
|
-
this.#move.setAttribute("x", String(value / 2));
|
|
271
|
-
this.#move.setAttribute("transform-origin", `${value / 2} ${this.#height / 2}`);
|
|
272
|
-
this.#rotate.setAttribute("x", String(value / 2));
|
|
273
|
-
this.#rotate.setAttribute("transform-origin", `${value / 2} 0`);
|
|
274
|
-
this.#width = value;
|
|
275
|
-
if (this.#element) this.#element.width = value;
|
|
46
|
+
/**Returns the width of the page */
|
|
47
|
+
get width() {
|
|
48
|
+
return this.#width;
|
|
276
49
|
}
|
|
277
|
-
|
|
278
|
-
set height(
|
|
279
|
-
this.#
|
|
280
|
-
this
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.#
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
50
|
+
/**Sets the height of the page */
|
|
51
|
+
set height(height) {
|
|
52
|
+
this.#height = height;
|
|
53
|
+
this.style.height = height + "px";
|
|
54
|
+
}
|
|
55
|
+
/**Returns the height of the page */
|
|
56
|
+
get height() {
|
|
57
|
+
return this.#height;
|
|
58
|
+
}
|
|
59
|
+
/**Sets the widgets on the page, the array order is the drawing order with the last widget on top
|
|
60
|
+
* Widgets already on the page are kept in place, so they are only reconnected if their order changes */
|
|
61
|
+
set widgets(widgets) {
|
|
62
|
+
const keep = new Set(widgets);
|
|
63
|
+
for (const widget of this.#widgets) if (!keep.has(widget) && widget.parentElement === this) widget.remove();
|
|
64
|
+
for (let i = 0; i < widgets.length; i++) {
|
|
65
|
+
const current = this.children[i];
|
|
66
|
+
if (current !== widgets[i]) this.insertBefore(widgets[i], current ?? null);
|
|
67
|
+
}
|
|
68
|
+
this.#widgets = widgets;
|
|
69
|
+
}
|
|
70
|
+
/**Returns the widgets on the page */
|
|
71
|
+
get widgets() {
|
|
72
|
+
return this.#widgets;
|
|
288
73
|
}
|
|
289
74
|
};
|
|
290
|
-
|
|
291
|
-
|
|
75
|
+
define_element(Page);
|
|
76
|
+
/**Creates a page of widgets with a fixed size */
|
|
77
|
+
const canvas_page = (options) => options ? new Page().opts(options) : new Page();
|
|
78
|
+
// src/canvas/widget.ts
|
|
79
|
+
/**Event dispatched on a widget when its position, size or rotation changes */
|
|
80
|
+
const WIDGET_TRANSFORM_EVENT = "widget_transform";
|
|
81
|
+
/**Shared class for widgets placed at a fixed position in a viewport
|
|
82
|
+
* Position and size are in viewport units (px before any viewport scaling)
|
|
83
|
+
* Rotation is in degrees clockwise around the center of the widget
|
|
84
|
+
*
|
|
85
|
+
* Width and height must always be set, they default to 0
|
|
86
|
+
*
|
|
87
|
+
* Widgets declare their original size, which is the size their content is laid out at
|
|
88
|
+
* The content is then scaled from the original size to the width and height of the widget
|
|
89
|
+
* Widgets that should not stretch, like text, return width and height as their original size
|
|
90
|
+
*
|
|
91
|
+
* WIDGET_TRANSFORM_EVENT is dispatched whenever position, size or rotation changes*/
|
|
92
|
+
var WidgetBase = class extends Base {
|
|
93
|
+
/**Returns the name used to define the element, Abstract classes should return @abstract@ */
|
|
292
94
|
static element_name() {
|
|
293
|
-
return "
|
|
95
|
+
return "@abstract@";
|
|
294
96
|
}
|
|
97
|
+
/**Returns the namespace override for the element*/
|
|
295
98
|
static element_name_space() {
|
|
296
|
-
return "
|
|
297
|
-
}
|
|
298
|
-
#
|
|
299
|
-
#
|
|
300
|
-
#
|
|
301
|
-
#
|
|
302
|
-
#
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this
|
|
306
|
-
this
|
|
307
|
-
this
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
#root = this.appendChild(svg.create("svg").elem);
|
|
311
|
-
#panner;
|
|
312
|
-
#zoomer;
|
|
313
|
-
/**Detaches the mover when clicking outside the viewport*/
|
|
314
|
-
#outside_pointerdown = (e) => {
|
|
315
|
-
if (!this.contains(e.target)) this.#detach_mover();
|
|
316
|
-
};
|
|
317
|
-
/**Detaches the mover when the browser window loses focus*/
|
|
318
|
-
#window_blur = () => this.#detach_mover();
|
|
319
|
-
/**Document the listeners are attached to, while connected*/
|
|
320
|
-
#listening_document;
|
|
99
|
+
return "canvas";
|
|
100
|
+
}
|
|
101
|
+
#x = 0;
|
|
102
|
+
#y = 0;
|
|
103
|
+
#width = 0;
|
|
104
|
+
#height = 0;
|
|
105
|
+
#rotation = 0;
|
|
106
|
+
constructor() {
|
|
107
|
+
super();
|
|
108
|
+
this.style.position = "absolute";
|
|
109
|
+
this.style.boxSizing = "border-box";
|
|
110
|
+
this.style.transformOrigin = "0 0";
|
|
111
|
+
}
|
|
321
112
|
connectedCallback() {
|
|
322
113
|
super.connectedCallback();
|
|
323
|
-
this.#
|
|
324
|
-
this.#listening_document.addEventListener("pointerdown", this.#outside_pointerdown);
|
|
325
|
-
this.#listening_document.defaultView?.addEventListener("blur", this.#window_blur);
|
|
114
|
+
this.#update();
|
|
326
115
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
this.#
|
|
330
|
-
this.#
|
|
331
|
-
this.#listening_document = void 0;
|
|
116
|
+
/**Sets the x position of the left edge of the widget */
|
|
117
|
+
set x(x) {
|
|
118
|
+
this.#x = x;
|
|
119
|
+
this.#update();
|
|
332
120
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this.#
|
|
336
|
-
this.#canvas_width = canvas_width;
|
|
337
|
-
this.#canvas_height = canvas_height;
|
|
338
|
-
this.#panner = this.#root.appendChild(svg.create("svg").a("width", canvas_width.toString()).a("height", canvas_height.toString()).elem);
|
|
339
|
-
this.#zoomer = this.#panner.appendChild(svg.create("svg").a("x", "-50%").a("y", "-50%").a("width", canvas_width.toString()).a("height", canvas_height.toString()).elem);
|
|
340
|
-
(infinite_canvas ? this.#root : this.#zoomer).prepend(svg.create("rect").attribute("x", "0").attribute("y", "0").attribute("width", "100%").attribute("height", "100%").fill("white").elem);
|
|
341
|
-
this.#canvas = this.#zoomer.appendChild(svg.svg(canvas_width, canvas_height, `0 0 ${canvas_width} ${canvas_height}`).elem);
|
|
342
|
-
this.#canvas_elements = this.#canvas.appendChild(svg.create("g").elem);
|
|
343
|
-
let count = 0;
|
|
344
|
-
let mover_x = 0;
|
|
345
|
-
let mover_y = 0;
|
|
346
|
-
let initial_x = 0;
|
|
347
|
-
let initial_y = 0;
|
|
348
|
-
let initial_id = 0;
|
|
349
|
-
let second_initial_id = 0;
|
|
350
|
-
let double_click = 0;
|
|
351
|
-
this.addEventListener("pointerdown", (e) => {
|
|
352
|
-
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
353
|
-
e.preventDefault();
|
|
354
|
-
e.stopPropagation();
|
|
355
|
-
const target = e.target;
|
|
356
|
-
if (target.closest(".viewport-mover")) return;
|
|
357
|
-
const elementCanvas = target.closest(".viewport-element");
|
|
358
|
-
if (elementCanvas) {
|
|
359
|
-
const element = this.#elements.find((el) => el.canvas === elementCanvas);
|
|
360
|
-
if (element) {
|
|
361
|
-
this.attach_mover(element);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
this.#detach_mover();
|
|
366
|
-
const now = performance.now();
|
|
367
|
-
if (now - double_click < 300) {
|
|
368
|
-
this.#pan_coordinates(0, 0);
|
|
369
|
-
this.#zoom_coordinates(Math.min(this.#viewport_height / this.#canvas_height, this.#viewport_width / this.#canvas_width), 0, 0);
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
double_click = now;
|
|
373
|
-
this.setPointerCapture(e.pointerId);
|
|
374
|
-
if (count === 0) {
|
|
375
|
-
mover_x = this.#pan_x.ok();
|
|
376
|
-
mover_y = this.#pan_y.ok();
|
|
377
|
-
initial_x = e.offsetX;
|
|
378
|
-
initial_y = e.offsetY;
|
|
379
|
-
initial_id = e.pointerId;
|
|
380
|
-
} else if (count === 1) second_initial_id = e.pointerId;
|
|
381
|
-
count++;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
this.onpointermove = (ev) => {
|
|
385
|
-
if (count === 0) return;
|
|
386
|
-
if (ev.pointerId === initial_id) this.#pan_coordinates(mover_x + (ev.offsetX - initial_x) / count, mover_y + (ev.offsetY - initial_y) / count);
|
|
387
|
-
else if (ev.pointerId === second_initial_id) {
|
|
388
|
-
if (count < 2) return;
|
|
389
|
-
this.#pan_coordinates(mover_x + (ev.offsetX - initial_x) / count, mover_y + (ev.offsetY - initial_y) / count);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
this.onpointerup = (ev) => {
|
|
393
|
-
if (this.hasPointerCapture(ev.pointerId)) {
|
|
394
|
-
this.releasePointerCapture(ev.pointerId);
|
|
395
|
-
count--;
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
this.onpointercancel = this.onpointerup;
|
|
399
|
-
this.addEventListener("wheel", (e) => {
|
|
400
|
-
e.preventDefault();
|
|
401
|
-
e.stopPropagation();
|
|
402
|
-
const move_scale = e.shiftKey ? e.altKey ? .01 : .05 : e.altKey ? 2 : .5;
|
|
403
|
-
if (e.ctrlKey) this.#pan_coordinates(void 0, this.#pan_y.ok() - e.deltaY * move_scale);
|
|
404
|
-
else {
|
|
405
|
-
const scale_scale = e.shiftKey ? e.altKey ? 5e-5 : 1e-4 : e.altKey ? .005 : .001;
|
|
406
|
-
const scale = this.#zoom.ok() * (1 - e.deltaY * scale_scale);
|
|
407
|
-
this.#zoom_coordinates(scale, e.offsetX - this.#viewport_width / 2, e.offsetY - this.#viewport_height / 2);
|
|
408
|
-
}
|
|
409
|
-
this.#pan_coordinates(this.#pan_x.ok() - e.deltaX * move_scale, void 0);
|
|
410
|
-
}, { capture: true });
|
|
121
|
+
/**Returns the x position of the left edge of the widget */
|
|
122
|
+
get x() {
|
|
123
|
+
return this.#x;
|
|
411
124
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
if (y !== void 0) {
|
|
418
|
-
this.#panner.setAttribute("y", (this.#viewport_height_half + y).toFixed(0));
|
|
419
|
-
this.#pan_y.set_ok(y);
|
|
420
|
-
}
|
|
125
|
+
/**Sets the y position of the top edge of the widget */
|
|
126
|
+
set y(y) {
|
|
127
|
+
this.#y = y;
|
|
128
|
+
this.#update();
|
|
421
129
|
}
|
|
422
|
-
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.#
|
|
429
|
-
this.#
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
this.#
|
|
438
|
-
this.#
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
get
|
|
442
|
-
return this.#
|
|
443
|
-
}
|
|
444
|
-
set canvas_height(value) {
|
|
445
|
-
this.#canvas.setAttribute("height", value.toString());
|
|
446
|
-
this.#canvas.setAttribute("viewBox", `0 0 ${this.#canvas_width} ${value}`);
|
|
447
|
-
this.#zoomer.setAttribute("height", value.toString());
|
|
448
|
-
this.#canvas_height = value;
|
|
449
|
-
}
|
|
450
|
-
get canvas_height() {
|
|
451
|
-
return this.#canvas_height;
|
|
452
|
-
}
|
|
453
|
-
#pan_x = state$1.rosw(ok(0), (value) => {
|
|
454
|
-
return sync_resolve(ok(this.#pan_coordinates(value, void 0)));
|
|
455
|
-
});
|
|
456
|
-
pan_x = this.#pan_x.read_write;
|
|
457
|
-
#pan_y = state$1.rosw(ok(0), (value) => {
|
|
458
|
-
return sync_resolve(ok(this.#pan_coordinates(void 0, value)));
|
|
459
|
-
});
|
|
460
|
-
pan_y = this.#pan_y.read_write;
|
|
461
|
-
#zoom = state$1.rosw(ok(1), (value) => sync_resolve(ok(this.#zoom_coordinates(value, 0, 0))));
|
|
462
|
-
zoom = this.#zoom.read_write;
|
|
463
|
-
#grid_x = state$1.rosw(ok(10), (value) => {
|
|
464
|
-
this.#grid_x.set_ok(value);
|
|
465
|
-
return sync_resolve(ok(void 0));
|
|
466
|
-
});
|
|
467
|
-
grid_x = this.#grid_x.read_write;
|
|
468
|
-
#grid_y = state$1.rosw(ok(10), (value) => {
|
|
469
|
-
this.#grid_y.set_ok(value);
|
|
470
|
-
return sync_resolve(ok(void 0));
|
|
471
|
-
});
|
|
472
|
-
grid_y = this.#grid_y.read_write;
|
|
473
|
-
#grid_rotate = state$1.rosw(ok(15), (value) => {
|
|
474
|
-
this.#grid_rotate.set_ok(value);
|
|
475
|
-
return sync_resolve(ok(void 0));
|
|
476
|
-
});
|
|
477
|
-
grid_rotate = this.#grid_rotate.read_write;
|
|
478
|
-
#elements = [];
|
|
479
|
-
#state_sub;
|
|
480
|
-
set elements(elements) {
|
|
481
|
-
if (this.#state_sub) {
|
|
482
|
-
this.detach_state(this.#state_sub);
|
|
483
|
-
this.#state_sub = void 0;
|
|
484
|
-
}
|
|
485
|
-
if (state$1.is.state(elements)) this.#state_sub = this.attach_state(elements, (r) => this.#update_rows(r.ok ? r.value : []));
|
|
486
|
-
else this.#update_rows(elements);
|
|
130
|
+
/**Returns the y position of the top edge of the widget */
|
|
131
|
+
get y() {
|
|
132
|
+
return this.#y;
|
|
133
|
+
}
|
|
134
|
+
/**Sets the width of the widget */
|
|
135
|
+
set width(width) {
|
|
136
|
+
this.#width = width;
|
|
137
|
+
this.#update();
|
|
138
|
+
}
|
|
139
|
+
/**Returns the width of the widget */
|
|
140
|
+
get width() {
|
|
141
|
+
return this.#width;
|
|
142
|
+
}
|
|
143
|
+
/**Sets the height of the widget */
|
|
144
|
+
set height(height) {
|
|
145
|
+
this.#height = height;
|
|
146
|
+
this.#update();
|
|
147
|
+
}
|
|
148
|
+
/**Returns the height of the widget */
|
|
149
|
+
get height() {
|
|
150
|
+
return this.#height;
|
|
487
151
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (moved && !rows.includes(moved)) this.#detach_mover();
|
|
152
|
+
/**Sets the rotation of the widget in degrees, rotating clockwise around the center of the widget */
|
|
153
|
+
set rotation(rotation) {
|
|
154
|
+
this.#rotation = rotation;
|
|
155
|
+
this.#update();
|
|
493
156
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
157
|
+
/**Returns the rotation of the widget in degrees */
|
|
158
|
+
get rotation() {
|
|
159
|
+
return this.#rotation;
|
|
497
160
|
}
|
|
498
|
-
#
|
|
499
|
-
this.#
|
|
161
|
+
#update() {
|
|
162
|
+
const width = this.#width;
|
|
163
|
+
const height = this.#height;
|
|
164
|
+
const layout_width = this.original_width;
|
|
165
|
+
const layout_height = this.original_height;
|
|
166
|
+
const scale_x = layout_width > 0 ? width / layout_width : 1;
|
|
167
|
+
const scale_y = layout_height > 0 ? height / layout_height : 1;
|
|
168
|
+
this.style.left = this.#x + "px";
|
|
169
|
+
this.style.top = this.#y + "px";
|
|
170
|
+
this.style.width = layout_width + "px";
|
|
171
|
+
this.style.height = layout_height + "px";
|
|
172
|
+
this.style.transform = `translate(${width / 2}px, ${height / 2}px) rotate(${this.#rotation}deg) translate(${-width / 2}px, ${-height / 2}px) scale(${scale_x}, ${scale_y})`;
|
|
173
|
+
this.dispatchEvent(new Event(WIDGET_TRANSFORM_EVENT));
|
|
500
174
|
}
|
|
501
175
|
};
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
176
|
+
// src/canvas/transformer.ts
|
|
177
|
+
/**Smallest width and height a widget can be resized to */
|
|
178
|
+
const MIN_SIZE = 1;
|
|
179
|
+
/**Grid positions and sizes snap to, and the finer grid used while alt is held */
|
|
180
|
+
const SNAP_GRID = 5;
|
|
181
|
+
const SNAP_GRID_FINE = 1;
|
|
182
|
+
/**Angle in degrees rotation snaps to, and the finer angle used while alt is held */
|
|
183
|
+
const SNAP_ANGLE = 15;
|
|
184
|
+
const SNAP_ANGLE_FINE = 5;
|
|
185
|
+
/**Rounds the value to the nearest multiple of step, a step of 0 returns the value unchanged
|
|
186
|
+
* Steps below 1 divide by the inverse, so steps like 0.1 do not give floating point errors like 0.30000000000000004 */
|
|
187
|
+
function snap(value, step) {
|
|
188
|
+
if (step <= 0) return value;
|
|
189
|
+
return step < 1 ? Math.round(value / step) / Math.round(1 / step) : Math.round(value / step) * step;
|
|
505
190
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
191
|
+
/**Resize handles, x and y is the edge they move, -1 is the left or top edge, 1 the right or bottom edge, 0 none */
|
|
192
|
+
const RESIZE_HANDLES = [
|
|
193
|
+
{
|
|
194
|
+
name: "nw",
|
|
195
|
+
x: -1,
|
|
196
|
+
y: -1
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "n",
|
|
200
|
+
x: 0,
|
|
201
|
+
y: -1
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "ne",
|
|
205
|
+
x: 1,
|
|
206
|
+
y: -1
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "e",
|
|
210
|
+
x: 1,
|
|
211
|
+
y: 0
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "se",
|
|
215
|
+
x: 1,
|
|
216
|
+
y: 1
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "s",
|
|
220
|
+
x: 0,
|
|
221
|
+
y: 1
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "sw",
|
|
225
|
+
x: -1,
|
|
226
|
+
y: 1
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "w",
|
|
230
|
+
x: -1,
|
|
231
|
+
y: 0
|
|
232
|
+
}
|
|
233
|
+
];
|
|
234
|
+
/**Dashed outline with handles, attached to a widget to move, resize and rotate it
|
|
235
|
+
* Corner handles resize both axes and side handles one axis, keeping the opposite corner or side in place
|
|
236
|
+
* The handle above the outline rotates the widget around its center
|
|
237
|
+
* The center handle and the outline itself move the widget, the inside of the outline is left to the widgets below
|
|
238
|
+
*
|
|
239
|
+
* Position and size snap to a 5px grid and rotation to 15 degrees
|
|
240
|
+
* Holding alt snaps to a 1px grid and 5 degrees instead, holding shift disables snapping
|
|
241
|
+
*
|
|
242
|
+
* Resize and rotate cursors follow the rotation of the widget in 45 degree steps
|
|
243
|
+
*
|
|
244
|
+
* The transformer is drawn in viewport pixels, so it keeps its size when the page is zoomed*/
|
|
245
|
+
var Transformer = class extends Base {
|
|
246
|
+
/**Returns the name used to define the element */
|
|
247
|
+
static element_name() {
|
|
248
|
+
return "transformer";
|
|
249
|
+
}
|
|
250
|
+
/**Returns the namespace override for the element*/
|
|
251
|
+
static element_name_space() {
|
|
252
|
+
return "canvas";
|
|
253
|
+
}
|
|
254
|
+
#widget;
|
|
255
|
+
#offset_x = 0;
|
|
256
|
+
#offset_y = 0;
|
|
257
|
+
#scale = 1;
|
|
258
|
+
#actions = /* @__PURE__ */ new Map();
|
|
259
|
+
#drag;
|
|
521
260
|
constructor() {
|
|
522
|
-
|
|
261
|
+
super();
|
|
262
|
+
this.hidden = true;
|
|
263
|
+
for (const side of [
|
|
264
|
+
"top",
|
|
265
|
+
"right",
|
|
266
|
+
"bottom",
|
|
267
|
+
"left"
|
|
268
|
+
]) this.#add("side " + side, { type: "move" });
|
|
269
|
+
this.#add("line", void 0);
|
|
270
|
+
for (const handle of RESIZE_HANDLES) this.#add("handle " + handle.name, {
|
|
271
|
+
type: "resize",
|
|
272
|
+
x: handle.x,
|
|
273
|
+
y: handle.y
|
|
274
|
+
}, material_arrow_range_rounded);
|
|
275
|
+
this.#add("handle rotate", { type: "rotate" }, material_rotate_right_rounded);
|
|
276
|
+
this.#add("handle move", { type: "move" }, material_open_with_rounded);
|
|
277
|
+
this.addEventListener("pointerdown", this.#on_pointer_down);
|
|
523
278
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
279
|
+
disconnectedCallback() {
|
|
280
|
+
super.disconnectedCallback();
|
|
281
|
+
this.#stop_drag();
|
|
282
|
+
}
|
|
283
|
+
/**Sets the widget the transformer is attached to, undefined hides the transformer */
|
|
284
|
+
set widget(widget) {
|
|
285
|
+
if (this.#widget === widget) return;
|
|
286
|
+
this.#stop_drag();
|
|
287
|
+
this.#widget?.removeEventListener(WIDGET_TRANSFORM_EVENT, this.#on_widget_transform);
|
|
288
|
+
this.#widget = widget;
|
|
289
|
+
widget?.addEventListener(WIDGET_TRANSFORM_EVENT, this.#on_widget_transform);
|
|
290
|
+
this.#update();
|
|
291
|
+
}
|
|
292
|
+
/**Returns the widget the transformer is attached to */
|
|
293
|
+
get widget() {
|
|
294
|
+
return this.#widget;
|
|
295
|
+
}
|
|
296
|
+
/**Returns whether a handle is being dragged */
|
|
297
|
+
get dragging() {
|
|
298
|
+
return this.#drag !== void 0;
|
|
299
|
+
}
|
|
300
|
+
/**Sets how page units map to viewport pixels, viewport = offset + page * scale */
|
|
301
|
+
view(offset_x, offset_y, scale) {
|
|
302
|
+
this.#offset_x = offset_x;
|
|
303
|
+
this.#offset_y = offset_y;
|
|
304
|
+
this.#scale = scale;
|
|
305
|
+
this.#update();
|
|
306
|
+
}
|
|
307
|
+
#add(class_name, action, icon) {
|
|
308
|
+
const element = this.appendChild(document.createElement("div"));
|
|
309
|
+
element.className = class_name;
|
|
310
|
+
if (icon) element.appendChild(icon());
|
|
311
|
+
if (action) this.#actions.set(element, action);
|
|
312
|
+
}
|
|
313
|
+
#update() {
|
|
314
|
+
const widget = this.#widget;
|
|
315
|
+
this.hidden = !widget;
|
|
316
|
+
if (!widget) return;
|
|
317
|
+
const scale = this.#scale;
|
|
318
|
+
this.style.left = this.#offset_x + widget.x * scale + "px";
|
|
319
|
+
this.style.top = this.#offset_y + widget.y * scale + "px";
|
|
320
|
+
this.style.width = widget.width * scale + "px";
|
|
321
|
+
this.style.height = widget.height * scale + "px";
|
|
322
|
+
this.style.transform = `rotate(${widget.rotation}deg)`;
|
|
323
|
+
const half_turn = (widget.rotation % 180 + 180) % 180;
|
|
324
|
+
this.setAttribute("cursor-step", String(Math.round(half_turn / 45) % 4));
|
|
325
|
+
}
|
|
326
|
+
#start(action, e) {
|
|
327
|
+
const widget = this.#widget;
|
|
328
|
+
if (!widget || this.#drag) return;
|
|
329
|
+
e.preventDefault();
|
|
330
|
+
e.stopPropagation();
|
|
331
|
+
const rect = this.getBoundingClientRect();
|
|
332
|
+
this.#drag = {
|
|
333
|
+
action,
|
|
334
|
+
pointer_id: e.pointerId,
|
|
335
|
+
client_x: e.clientX,
|
|
336
|
+
client_y: e.clientY,
|
|
337
|
+
center_x: rect.left + rect.width / 2,
|
|
338
|
+
center_y: rect.top + rect.height / 2,
|
|
339
|
+
x: widget.x,
|
|
340
|
+
y: widget.y,
|
|
341
|
+
width: widget.width,
|
|
342
|
+
height: widget.height,
|
|
343
|
+
rotation: widget.rotation
|
|
344
|
+
};
|
|
345
|
+
window.addEventListener("pointermove", this.#on_pointer_move);
|
|
346
|
+
window.addEventListener("pointerup", this.#on_pointer_up);
|
|
347
|
+
window.addEventListener("pointercancel", this.#on_pointer_up);
|
|
348
|
+
}
|
|
349
|
+
#stop_drag() {
|
|
350
|
+
if (!this.#drag) return;
|
|
351
|
+
this.#drag = void 0;
|
|
352
|
+
window.removeEventListener("pointermove", this.#on_pointer_move);
|
|
353
|
+
window.removeEventListener("pointerup", this.#on_pointer_up);
|
|
354
|
+
window.removeEventListener("pointercancel", this.#on_pointer_up);
|
|
355
|
+
}
|
|
356
|
+
#on_widget_transform = () => {
|
|
357
|
+
this.#update();
|
|
358
|
+
};
|
|
359
|
+
#on_pointer_down = (e) => {
|
|
360
|
+
const action = e.target instanceof Element ? this.#actions.get(e.target) : void 0;
|
|
361
|
+
if (!action || e.button !== 0) return;
|
|
362
|
+
this.#start(action, e);
|
|
363
|
+
};
|
|
364
|
+
#on_pointer_move = (e) => {
|
|
365
|
+
const drag = this.#drag;
|
|
366
|
+
const widget = this.#widget;
|
|
367
|
+
if (!drag || !widget || e.pointerId !== drag.pointer_id) return;
|
|
368
|
+
const delta_x = (e.clientX - drag.client_x) / this.#scale;
|
|
369
|
+
const delta_y = (e.clientY - drag.client_y) / this.#scale;
|
|
370
|
+
const grid = e.shiftKey ? 0 : e.altKey ? SNAP_GRID_FINE : SNAP_GRID;
|
|
371
|
+
const action = drag.action;
|
|
372
|
+
switch (action.type) {
|
|
373
|
+
case "move":
|
|
374
|
+
widget.x = snap(drag.x + delta_x, grid);
|
|
375
|
+
widget.y = snap(drag.y + delta_y, grid);
|
|
376
|
+
break;
|
|
377
|
+
case "resize": {
|
|
378
|
+
const radians = drag.rotation * Math.PI / 180;
|
|
379
|
+
const cos = Math.cos(radians);
|
|
380
|
+
const sin = Math.sin(radians);
|
|
381
|
+
const local_x = delta_x * cos + delta_y * sin;
|
|
382
|
+
const local_y = delta_y * cos - delta_x * sin;
|
|
383
|
+
const width = action.x ? Math.max(MIN_SIZE, snap(drag.width + action.x * local_x, grid)) : drag.width;
|
|
384
|
+
const height = action.y ? Math.max(MIN_SIZE, snap(drag.height + action.y * local_y, grid)) : drag.height;
|
|
385
|
+
const shift_x = action.x * (width - drag.width) / 2;
|
|
386
|
+
const shift_y = action.y * (height - drag.height) / 2;
|
|
387
|
+
const center_x = drag.x + drag.width / 2 + shift_x * cos - shift_y * sin;
|
|
388
|
+
const center_y = drag.y + drag.height / 2 + shift_x * sin + shift_y * cos;
|
|
389
|
+
widget.x = center_x - width / 2;
|
|
390
|
+
widget.y = center_y - height / 2;
|
|
391
|
+
widget.width = width;
|
|
392
|
+
widget.height = height;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
case "rotate": {
|
|
396
|
+
const start = Math.atan2(drag.client_y - drag.center_y, drag.client_x - drag.center_x);
|
|
397
|
+
const now = Math.atan2(e.clientY - drag.center_y, e.clientX - drag.center_x);
|
|
398
|
+
widget.rotation = (snap(drag.rotation + (now - start) * 180 / Math.PI, e.shiftKey ? 0 : e.altKey ? SNAP_ANGLE_FINE : SNAP_ANGLE) % 360 + 360) % 360;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
#on_pointer_up = (e) => {
|
|
404
|
+
if (e.pointerId === this.#drag?.pointer_id) this.#stop_drag();
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
define_element(Transformer);
|
|
408
|
+
// src/canvas/viewport.ts
|
|
409
|
+
const ZOOM_MIN = .1;
|
|
410
|
+
const ZOOM_MAX = 20;
|
|
411
|
+
/**Zoom factor per wheel pixel */
|
|
412
|
+
const WHEEL_ZOOM_SPEED = .002;
|
|
413
|
+
/**Zoom factor per wheel pixel for touchpad pinch, which reports much smaller deltas than a mouse wheel */
|
|
414
|
+
const PINCH_ZOOM_SPEED = .01;
|
|
415
|
+
/**Screen pixels panned per wheel pixel */
|
|
416
|
+
const WHEEL_PAN_SPEED = .5;
|
|
417
|
+
/**Pixels per line, for wheel events reported in lines */
|
|
418
|
+
const WHEEL_LINE_HEIGHT = 16;
|
|
419
|
+
/**Speed multiplier for wheel zoom and pan while alt is held */
|
|
420
|
+
const WHEEL_SLOW = .1;
|
|
421
|
+
/**Viewport showing a page of widgets
|
|
422
|
+
* The page is scaled to fit inside the viewport element while keeping its aspect ratio, and centered
|
|
423
|
+
*
|
|
424
|
+
* When edit is true the page can be zoomed and panned, and a checkerboard is shown behind it
|
|
425
|
+
* Wheel and touchpad two finger swipe pans, ctrl + wheel or swipe zooms toward the cursor
|
|
426
|
+
* Shift + vertical wheel pans horizontally
|
|
427
|
+
* Touchpad pinch zooms toward the cursor
|
|
428
|
+
* Holding alt makes wheel zoom and pan 10 times slower
|
|
429
|
+
* Two finger touch pinch zooms and pans, middle or right mouse drag pans
|
|
430
|
+
*
|
|
431
|
+
* Pressing a widget in edit mode selects it and attaches a transformer to move, resize and rotate it
|
|
432
|
+
* Pressing outside any widget clears the selection*/
|
|
433
|
+
var Viewport = class extends Base {
|
|
434
|
+
/**Returns the name used to define the element */
|
|
435
|
+
static element_name() {
|
|
436
|
+
return "viewport";
|
|
530
437
|
}
|
|
531
|
-
|
|
532
|
-
|
|
438
|
+
/**Returns the namespace override for the element*/
|
|
439
|
+
static element_name_space() {
|
|
440
|
+
return "canvas";
|
|
441
|
+
}
|
|
442
|
+
#background = this.appendChild(document.createElement("div"));
|
|
443
|
+
#container = this.appendChild(document.createElement("div"));
|
|
444
|
+
#transformer = this.appendChild(new Transformer());
|
|
445
|
+
#page;
|
|
446
|
+
#page_observer = new ResizeObserver(() => {
|
|
447
|
+
this.#update_view();
|
|
448
|
+
});
|
|
449
|
+
#scale = 1;
|
|
450
|
+
#fit_x = 0;
|
|
451
|
+
#fit_y = 0;
|
|
452
|
+
#edit = false;
|
|
453
|
+
#zoom = 1;
|
|
454
|
+
#pan_x = 0;
|
|
455
|
+
#pan_y = 0;
|
|
456
|
+
#touches = /* @__PURE__ */ new Map();
|
|
457
|
+
#pan_pointer_id;
|
|
458
|
+
#pan_pointer_last = {
|
|
459
|
+
x: 0,
|
|
460
|
+
y: 0
|
|
461
|
+
};
|
|
462
|
+
/**Whether the ctrl key is physically held, to tell touchpad pinch from ctrl + wheel */
|
|
463
|
+
#ctrl_held = false;
|
|
464
|
+
constructor() {
|
|
465
|
+
super();
|
|
466
|
+
this.#background.className = "checkerboard";
|
|
467
|
+
this.#container.className = "container";
|
|
468
|
+
this.attach_to_resize_observer();
|
|
469
|
+
}
|
|
470
|
+
/**Sets the page shown in the viewport */
|
|
471
|
+
set page(page) {
|
|
472
|
+
if (this.#page === page) return;
|
|
473
|
+
this.selected = void 0;
|
|
474
|
+
if (this.#page) {
|
|
475
|
+
this.#page_observer.unobserve(this.#page);
|
|
476
|
+
if (this.#page.parentElement === this.#container) this.#page.remove();
|
|
477
|
+
}
|
|
478
|
+
this.#page = page;
|
|
479
|
+
if (page) {
|
|
480
|
+
this.#container.appendChild(page);
|
|
481
|
+
this.#page_observer.observe(page);
|
|
482
|
+
}
|
|
483
|
+
this.#update_view();
|
|
484
|
+
}
|
|
485
|
+
/**Returns the page shown in the viewport */
|
|
486
|
+
get page() {
|
|
487
|
+
return this.#page;
|
|
488
|
+
}
|
|
489
|
+
/**Sets edit mode, which enables zooming and panning and shows a checkerboard background
|
|
490
|
+
* Leaving edit mode resets the view to fit the page */
|
|
491
|
+
set edit(edit) {
|
|
492
|
+
if (this.#edit === edit) return;
|
|
493
|
+
this.#edit = edit;
|
|
494
|
+
this.toggleAttribute("edit", edit);
|
|
495
|
+
this.#listen_keys(edit && this.isConnected);
|
|
496
|
+
if (edit) {
|
|
497
|
+
this.addEventListener("wheel", this.#on_wheel, { passive: false });
|
|
498
|
+
this.addEventListener("pointerdown", this.#on_pointer_down);
|
|
499
|
+
this.addEventListener("pointermove", this.#on_pointer_move);
|
|
500
|
+
this.addEventListener("pointerup", this.#on_pointer_up);
|
|
501
|
+
this.addEventListener("pointercancel", this.#on_pointer_up);
|
|
502
|
+
this.addEventListener("mousedown", this.#on_mouse_down);
|
|
503
|
+
this.addEventListener("contextmenu", this.#on_context_menu);
|
|
504
|
+
} else {
|
|
505
|
+
this.removeEventListener("wheel", this.#on_wheel);
|
|
506
|
+
this.removeEventListener("pointerdown", this.#on_pointer_down);
|
|
507
|
+
this.removeEventListener("pointermove", this.#on_pointer_move);
|
|
508
|
+
this.removeEventListener("pointerup", this.#on_pointer_up);
|
|
509
|
+
this.removeEventListener("pointercancel", this.#on_pointer_up);
|
|
510
|
+
this.removeEventListener("mousedown", this.#on_mouse_down);
|
|
511
|
+
this.removeEventListener("contextmenu", this.#on_context_menu);
|
|
512
|
+
this.#touches.clear();
|
|
513
|
+
this.#pan_pointer_id = void 0;
|
|
514
|
+
this.selected = void 0;
|
|
515
|
+
this.#zoom = 1;
|
|
516
|
+
this.#pan_x = 0;
|
|
517
|
+
this.#pan_y = 0;
|
|
518
|
+
this.#update_view();
|
|
519
|
+
}
|
|
533
520
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
this
|
|
537
|
-
this.#update_transform();
|
|
521
|
+
/**Returns whether edit mode is enabled */
|
|
522
|
+
get edit() {
|
|
523
|
+
return this.#edit;
|
|
538
524
|
}
|
|
539
|
-
|
|
540
|
-
|
|
525
|
+
/**Sets the selected widget, which the transformer is attached to, selection is cleared when leaving edit mode */
|
|
526
|
+
set selected(widget) {
|
|
527
|
+
this.#transformer.widget = widget;
|
|
541
528
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
set rotation(value) {
|
|
546
|
-
this.#rotation = value;
|
|
547
|
-
this.#update_transform();
|
|
529
|
+
/**Returns the selected widget */
|
|
530
|
+
get selected() {
|
|
531
|
+
return this.#transformer.widget;
|
|
548
532
|
}
|
|
549
|
-
|
|
550
|
-
|
|
533
|
+
/**Returns the current scale from page units to screen pixels */
|
|
534
|
+
get scale() {
|
|
535
|
+
return this.#scale;
|
|
551
536
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
set rotation_center_x(value) {
|
|
555
|
-
this.#rotation_center_x = value;
|
|
556
|
-
this.#update_transform();
|
|
557
|
-
}
|
|
558
|
-
get rotation_center_x() {
|
|
559
|
-
return this.#rotation_center_x;
|
|
560
|
-
}
|
|
561
|
-
/**Rotation center y coordinate, relative to the element's display area.
|
|
562
|
-
* Defaults to half of default_height (center of element). */
|
|
563
|
-
set rotation_center_y(value) {
|
|
564
|
-
this.#rotation_center_y = value;
|
|
565
|
-
this.#update_transform();
|
|
566
|
-
}
|
|
567
|
-
get rotation_center_y() {
|
|
568
|
-
return this.#rotation_center_y;
|
|
569
|
-
}
|
|
570
|
-
#update_transform() {
|
|
571
|
-
if (this.#rotation === 0) this.canvas.removeAttribute("transform");
|
|
572
|
-
else {
|
|
573
|
-
const cx = this.#position_x + this.#rotation_center_x;
|
|
574
|
-
const cy = this.#position_y + this.#rotation_center_y;
|
|
575
|
-
this.canvas.setAttribute("transform", `rotate(${this.#rotation} ${cx} ${cy})`);
|
|
576
|
-
}
|
|
537
|
+
on_resize() {
|
|
538
|
+
this.#update_view();
|
|
577
539
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
* - If the element has an optimal_ratio, the viewBox stays at default
|
|
582
|
-
* dimensions and the SVG content is stretched/scaled to fill the new size.
|
|
583
|
-
* - If the element has no optimal_ratio, the viewBox is updated to match
|
|
584
|
-
* the new dimensions and on_resize is called. */
|
|
585
|
-
set width(value) {
|
|
586
|
-
this.#width = value;
|
|
587
|
-
this.#apply_size();
|
|
540
|
+
connectedCallback() {
|
|
541
|
+
super.connectedCallback();
|
|
542
|
+
if (this.#edit) this.#listen_keys(true);
|
|
588
543
|
}
|
|
589
|
-
|
|
590
|
-
|
|
544
|
+
disconnectedCallback() {
|
|
545
|
+
super.disconnectedCallback();
|
|
546
|
+
this.#listen_keys(false);
|
|
547
|
+
}
|
|
548
|
+
/**Adds or removes the window listeners tracking the ctrl key */
|
|
549
|
+
#listen_keys(listen) {
|
|
550
|
+
if (listen) {
|
|
551
|
+
window.addEventListener("keydown", this.#on_key);
|
|
552
|
+
window.addEventListener("keyup", this.#on_key);
|
|
553
|
+
window.addEventListener("blur", this.#on_blur);
|
|
554
|
+
} else {
|
|
555
|
+
window.removeEventListener("keydown", this.#on_key);
|
|
556
|
+
window.removeEventListener("keyup", this.#on_key);
|
|
557
|
+
window.removeEventListener("blur", this.#on_blur);
|
|
558
|
+
this.#ctrl_held = false;
|
|
559
|
+
}
|
|
591
560
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
this.#
|
|
561
|
+
#update_view() {
|
|
562
|
+
if (!this.#page) return;
|
|
563
|
+
const width = this.#page.width;
|
|
564
|
+
const height = this.#page.height;
|
|
565
|
+
if (width <= 0 || height <= 0) return;
|
|
566
|
+
const rect = this.actual_size;
|
|
567
|
+
const fit = Math.min(rect.width / width, rect.height / height);
|
|
568
|
+
this.#fit_x = (rect.width - width * fit) / 2;
|
|
569
|
+
this.#fit_y = (rect.height - height * fit) / 2;
|
|
570
|
+
this.#scale = fit * this.#zoom;
|
|
571
|
+
this.#container.style.transform = `translate(${this.#fit_x + this.#pan_x}px, ${this.#fit_y + this.#pan_y}px) scale(${this.#scale})`;
|
|
572
|
+
this.#transformer.view(this.#fit_x + this.#pan_x, this.#fit_y + this.#pan_y, this.#scale);
|
|
573
|
+
}
|
|
574
|
+
/**Zooms by the factor, keeping the given point in viewport coordinates in place */
|
|
575
|
+
#zoom_at(x, y, factor) {
|
|
576
|
+
const zoom = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, this.#zoom * factor));
|
|
577
|
+
const ratio = zoom / this.#zoom;
|
|
578
|
+
this.#pan_x += (x - this.#fit_x - this.#pan_x) * (1 - ratio);
|
|
579
|
+
this.#pan_y += (y - this.#fit_y - this.#pan_y) * (1 - ratio);
|
|
580
|
+
this.#zoom = zoom;
|
|
581
|
+
}
|
|
582
|
+
/**Returns the position of the event in viewport coordinates */
|
|
583
|
+
#local(e) {
|
|
584
|
+
const rect = this.getBoundingClientRect();
|
|
585
|
+
return {
|
|
586
|
+
x: e.clientX - rect.left,
|
|
587
|
+
y: e.clientY - rect.top
|
|
588
|
+
};
|
|
600
589
|
}
|
|
601
|
-
|
|
602
|
-
|
|
590
|
+
/**Selects the widget under the pointer, or clears the selection if there is none */
|
|
591
|
+
#select_at(e) {
|
|
592
|
+
const page = this.#page;
|
|
593
|
+
let element = e.target instanceof Element ? e.target : null;
|
|
594
|
+
while (element && element.parentElement !== page) element = element.parentElement;
|
|
595
|
+
this.selected = page?.widgets.find((widget) => widget === element);
|
|
596
|
+
}
|
|
597
|
+
/**Returns center and distance of the first two touches */
|
|
598
|
+
#pinch() {
|
|
599
|
+
if (this.#touches.size < 2) return void 0;
|
|
600
|
+
const [a, b] = this.#touches.values();
|
|
601
|
+
return {
|
|
602
|
+
x: (a.x + b.x) / 2,
|
|
603
|
+
y: (a.y + b.y) / 2,
|
|
604
|
+
distance: Math.hypot(a.x - b.x, a.y - b.y)
|
|
605
|
+
};
|
|
603
606
|
}
|
|
604
|
-
#
|
|
605
|
-
|
|
606
|
-
this.
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
#on_wheel = (e) => {
|
|
608
|
+
e.preventDefault();
|
|
609
|
+
const unit = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? WHEEL_LINE_HEIGHT : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? this.actual_size.height : 1;
|
|
610
|
+
const delta_x = e.deltaX * unit;
|
|
611
|
+
const delta_y = e.deltaY * unit;
|
|
612
|
+
const speed = e.altKey ? WHEEL_SLOW : 1;
|
|
613
|
+
if (e.ctrlKey) {
|
|
614
|
+
const zoom_speed = this.#ctrl_held ? WHEEL_ZOOM_SPEED : PINCH_ZOOM_SPEED;
|
|
615
|
+
const point = this.#local(e);
|
|
616
|
+
this.#zoom_at(point.x, point.y, Math.exp(-delta_y * zoom_speed * speed));
|
|
617
|
+
} else {
|
|
618
|
+
const swap = e.shiftKey && delta_x === 0;
|
|
619
|
+
this.#pan_x -= (swap ? delta_y : delta_x) * speed * WHEEL_PAN_SPEED;
|
|
620
|
+
this.#pan_y -= (swap ? 0 : delta_y) * speed * WHEEL_PAN_SPEED;
|
|
610
621
|
}
|
|
611
|
-
|
|
622
|
+
this.#update_view();
|
|
623
|
+
};
|
|
624
|
+
#on_pointer_down = (e) => {
|
|
625
|
+
if (e.pointerType === "touch") {
|
|
626
|
+
if (this.#touches.size === 0 && !this.#transformer.dragging) this.#select_at(e);
|
|
627
|
+
this.#touches.set(e.pointerId, this.#local(e));
|
|
628
|
+
this.setPointerCapture(e.pointerId);
|
|
629
|
+
} else if (e.button === 0) this.#select_at(e);
|
|
630
|
+
else if (e.button === 1 || e.button === 2) {
|
|
631
|
+
e.preventDefault();
|
|
632
|
+
this.#pan_pointer_id = e.pointerId;
|
|
633
|
+
this.#pan_pointer_last = this.#local(e);
|
|
634
|
+
this.setPointerCapture(e.pointerId);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
#on_pointer_move = (e) => {
|
|
638
|
+
this.#ctrl_held = e.ctrlKey;
|
|
639
|
+
if (this.#touches.has(e.pointerId)) {
|
|
640
|
+
const before = this.#pinch();
|
|
641
|
+
this.#touches.set(e.pointerId, this.#local(e));
|
|
642
|
+
const after = this.#pinch();
|
|
643
|
+
if (!before || !after || before.distance <= 0) return;
|
|
644
|
+
this.#pan_x += after.x - before.x;
|
|
645
|
+
this.#pan_y += after.y - before.y;
|
|
646
|
+
this.#zoom_at(after.x, after.y, after.distance / before.distance);
|
|
647
|
+
this.#update_view();
|
|
648
|
+
} else if (e.pointerId === this.#pan_pointer_id) {
|
|
649
|
+
const point = this.#local(e);
|
|
650
|
+
this.#pan_x += point.x - this.#pan_pointer_last.x;
|
|
651
|
+
this.#pan_y += point.y - this.#pan_pointer_last.y;
|
|
652
|
+
this.#pan_pointer_last = point;
|
|
653
|
+
this.#update_view();
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
#on_pointer_up = (e) => {
|
|
657
|
+
this.#touches.delete(e.pointerId);
|
|
658
|
+
if (e.pointerId === this.#pan_pointer_id) this.#pan_pointer_id = void 0;
|
|
659
|
+
};
|
|
660
|
+
/**Prevents the browser autoscroll on middle mouse button */
|
|
661
|
+
#on_mouse_down = (e) => {
|
|
662
|
+
if (e.button === 1) e.preventDefault();
|
|
663
|
+
};
|
|
664
|
+
/**Prevents the context menu, as the right mouse button pans in edit mode */
|
|
665
|
+
#on_context_menu = (e) => {
|
|
666
|
+
e.preventDefault();
|
|
667
|
+
};
|
|
668
|
+
#on_key = (e) => {
|
|
669
|
+
this.#ctrl_held = e.ctrlKey;
|
|
670
|
+
};
|
|
671
|
+
#on_blur = () => {
|
|
672
|
+
this.#ctrl_held = false;
|
|
673
|
+
};
|
|
612
674
|
};
|
|
675
|
+
define_element(Viewport);
|
|
676
|
+
/**Creates a viewport showing a page of widgets */
|
|
677
|
+
const canvas_viewport = (options) => options ? new Viewport().opts(options) : new Viewport();
|
|
613
678
|
// src/canvas/index.ts
|
|
614
|
-
|
|
615
|
-
|
|
679
|
+
/**Displaying and editing graphics with a fixed position and size */
|
|
680
|
+
const canvas = {
|
|
681
|
+
page: canvas_page,
|
|
682
|
+
viewport: canvas_viewport,
|
|
683
|
+
WIDGET_TRANSFORM_EVENT
|
|
684
|
+
};
|
|
685
|
+
export { WIDGET_TRANSFORM_EVENT, WidgetBase, canvas, canvas as default };
|
|
616
686
|
|
|
617
687
|
//# sourceMappingURL=index.mjs.map
|