@netless/appliance-plugin 1.0.0-beta.10 → 1.0.0-beta.12
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/cdn/cdn.js +1 -1
- package/cdn/fullWorker-kDR8Un.js +453 -0
- package/cdn/subWorker-fkG5Nn.js +453 -0
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +13 -13
- package/dist/core/enum.d.ts +8 -1
- package/dist/core/mainEngine.d.ts +3 -0
- package/dist/core/mainThread/base.d.ts +2 -2
- package/dist/core/mainThread/index.d.ts +2 -2
- package/dist/core/mainThread/snapshotThread.d.ts +3 -3
- package/dist/core/mainThread/subLocalThread.d.ts +16 -12
- package/dist/core/mainThread/subTopThread.d.ts +7 -7
- package/dist/core/mainThread/vNodeManager.d.ts +1 -0
- package/dist/core/msgEvent/base.d.ts +6 -2
- package/dist/core/msgEvent/copyNode/forMain.d.ts +1 -0
- package/dist/core/msgEvent/deleteNode/forMain.d.ts +1 -0
- package/dist/core/msgEvent/deleteNode/forMainThread.d.ts +1 -4
- package/dist/core/msgEvent/deleteNode/forWorker.d.ts +1 -4
- package/dist/core/msgEvent/index.d.ts +4 -0
- package/dist/core/msgEvent/rotateNode/forMain.d.ts +2 -1
- package/dist/core/msgEvent/scaleNode/forMain.d.ts +2 -1
- package/dist/core/msgEvent/setColor/forMain.d.ts +1 -0
- package/dist/core/msgEvent/setFont/forMain.d.ts +1 -0
- package/dist/core/msgEvent/setLock/forMain.d.ts +1 -0
- package/dist/core/msgEvent/setPoint/forMain.d.ts +1 -0
- package/dist/core/msgEvent/setShape/forMain.d.ts +1 -0
- package/dist/core/msgEvent/setZIndex/forMain.d.ts +1 -0
- package/dist/core/msgEvent/translateNode/forMain.d.ts +2 -1
- package/dist/core/tools/base.d.ts +1 -1
- package/dist/core/tools/text.d.ts +1 -8
- package/dist/core/types.d.ts +1 -1
- package/dist/core/worker/base.d.ts +20 -12
- package/dist/core/worker/fullWorkerLocal.d.ts +1 -0
- package/dist/core/worker/subWorkerLocal.d.ts +3 -0
- package/dist/core/worker/subWorkerTopLayer.d.ts +6 -6
- package/dist/core/worker/vNodeManager.d.ts +1 -0
- package/dist/core/worker/workerManager.d.ts +2 -1
- package/dist/fullWorker.js +566 -468
- package/dist/index-BHpx5UNa.js +1 -0
- package/dist/{index-CP5_CnSG.mjs → index-CW6jtvNM.mjs} +975 -944
- package/dist/index-GViHv6Ev.mjs +9088 -0
- package/dist/index-rH7eipCG.js +1 -0
- package/dist/plugin/single/applianceDisplayer.d.ts +0 -1
- package/dist/plugin/types.d.ts +6 -14
- package/dist/subWorker.js +566 -468
- package/package.json +1 -1
- package/cdn/fullWorker-DkNRgu.js +0 -468
- package/cdn/subWorker-BvxT1L.js +0 -468
- package/dist/index-B3tcgIQd.js +0 -1
- package/dist/index-BFpq0pIU.mjs +0 -8844
- package/dist/index-ChX1QimR.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var Bt = Object.defineProperty;
|
|
2
|
-
var zt = (
|
|
3
|
-
var m = (
|
|
4
|
-
import { i as
|
|
5
|
-
import { Group as _, Path as it, Rect as
|
|
2
|
+
var zt = (C, n, e) => n in C ? Bt(C, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : C[n] = e;
|
|
3
|
+
var m = (C, n, e) => (zt(C, typeof n != "symbol" ? n + "" : n, e), e);
|
|
4
|
+
import { i as q, c as B, a as tt, P as O, g as z, s as Ft, b as pt, d as Tt, r as Ut, p as rt, e as nt, E as U, f as P, h as y, j as R, k as D, l as X, t as K, V as k, m as ht, S as Y, n as ct, o as gt, q as ot, u as vt, v as Xt, w as Yt, x as $t, y as It, z as dt, A as Vt, B as Ht, C as E, D as Pt, F as Gt } from "./index-GViHv6Ev.mjs";
|
|
5
|
+
import { Group as _, Path as it, Rect as kt, Polyline as st, Ellipse as qt, Sprite as jt, Label as Zt, Scene as Nt } from "spritejs";
|
|
6
6
|
import Kt from "lineclip";
|
|
7
7
|
import "lz-string";
|
|
8
8
|
import "white-web-sdk";
|
|
9
9
|
import "react-dom";
|
|
10
10
|
import "react";
|
|
11
11
|
import "lodash";
|
|
12
|
-
const
|
|
12
|
+
const H = class H {
|
|
13
13
|
constructor(n) {
|
|
14
14
|
m(this, "syncUnitTime", 1e3);
|
|
15
15
|
m(this, "vNodes");
|
|
@@ -47,13 +47,13 @@ const j = class j {
|
|
|
47
47
|
if (i.length !== 1)
|
|
48
48
|
return;
|
|
49
49
|
const r = i[0], { pos: a, zIndex: c, scale: l, angle: h, translate: p } = n, f = {};
|
|
50
|
-
|
|
50
|
+
q(c) && (f.zIndex = c), a && (f.pos = [a[0], a[1]]), l && (f.scale = l), h && (f.rotate = h), p && (f.translate = p), r.attr(f);
|
|
51
51
|
const d = r == null ? void 0 : r.getBoundingClientRect();
|
|
52
52
|
return d && (e = B(e, {
|
|
53
|
-
x: Math.floor(d.x -
|
|
54
|
-
y: Math.floor(d.y -
|
|
55
|
-
w: Math.floor(d.width +
|
|
56
|
-
h: Math.floor(d.height +
|
|
53
|
+
x: Math.floor(d.x - H.SafeBorderPadding),
|
|
54
|
+
y: Math.floor(d.y - H.SafeBorderPadding),
|
|
55
|
+
w: Math.floor(d.width + H.SafeBorderPadding * 2),
|
|
56
|
+
h: Math.floor(d.height + H.SafeBorderPadding * 2)
|
|
57
57
|
})), (s = this.vNodes) == null || s.setInfo(t, {
|
|
58
58
|
rect: e,
|
|
59
59
|
centerPos: a
|
|
@@ -82,43 +82,53 @@ const j = class j {
|
|
|
82
82
|
const u = i && tt(i) || o.get(e.name);
|
|
83
83
|
if (!u)
|
|
84
84
|
return;
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
85
|
+
q(r) && (e.setAttribute("zIndex", r), u.opt.zIndex = r);
|
|
86
|
+
const w = e.parent;
|
|
87
|
+
if (w) {
|
|
88
88
|
if (l && p && h) {
|
|
89
|
-
const { rect:
|
|
89
|
+
const { rect: S } = u, b = [];
|
|
90
90
|
for (let M = 0; M < u.op.length; M += 3)
|
|
91
91
|
b.push(new O(u.op[M], u.op[M + 1], u.op[M + 2]));
|
|
92
|
-
const
|
|
92
|
+
const T = z(b), g = [T.w * w.worldScaling[0], T.h * w.worldScaling[0]], I = [S.w - g[0], S.h - g[1]], N = [(S.w * h[0] - I[0]) / g[0], (S.h * h[1] - I[1]) / g[1]], W = [p[0] / w.worldScaling[0], p[1] / w.worldScaling[1]], A = u.op.map((M, $) => {
|
|
93
93
|
const F = $ % 3;
|
|
94
|
-
return F === 0 ? M +
|
|
95
|
-
}),
|
|
96
|
-
Ft(A,
|
|
94
|
+
return F === 0 ? M + W[0] : F === 1 ? M + W[1] : M;
|
|
95
|
+
}), v = [u.centerPos[0] + W[0], u.centerPos[1] + W[1]];
|
|
96
|
+
Ft(A, v, N);
|
|
97
97
|
const x = [];
|
|
98
98
|
for (let M = 0; M < A.length; M += 3)
|
|
99
99
|
x.push(new O(A[M], A[M + 1], A[M + 2]));
|
|
100
|
-
u.op = A, u.centerPos =
|
|
101
|
-
} else if (a)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
u.op = A, u.centerPos = v;
|
|
101
|
+
} else if (a)
|
|
102
|
+
if (e.setAttribute("translate", a), u.opt.translate = a, i) {
|
|
103
|
+
const S = [a[0] * w.worldScaling[0], a[1] * w.worldScaling[1]];
|
|
104
|
+
d = pt(u.rect, S), u.rect = d;
|
|
105
|
+
} else {
|
|
106
|
+
const S = H.getRectFromLayer(w, e.name);
|
|
107
|
+
u.rect = S || u.rect;
|
|
108
|
+
}
|
|
109
|
+
else if (q(c))
|
|
110
|
+
if (e.setAttribute("rotate", c), u.opt.rotate = c, i)
|
|
111
|
+
d = Tt(u.rect, c), u.rect = d;
|
|
112
|
+
else {
|
|
113
|
+
const S = H.getRectFromLayer(w, e.name);
|
|
114
|
+
u.rect = S || u.rect;
|
|
115
|
+
}
|
|
106
116
|
if (f) {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
for (let b = 0,
|
|
110
|
-
u.op[b] =
|
|
117
|
+
const S = f.get(e.name);
|
|
118
|
+
if (S)
|
|
119
|
+
for (let b = 0, T = 0; b < u.op.length; b += 3, T++)
|
|
120
|
+
u.op[b] = S[T][0], u.op[b + 1] = S[T][1];
|
|
111
121
|
}
|
|
112
122
|
if (s) {
|
|
113
123
|
if (a) {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
return
|
|
124
|
+
const S = [a[0], a[1]], b = u.op.map((T, g) => {
|
|
125
|
+
const I = g % 3;
|
|
126
|
+
return I === 0 ? T + S[0] : I === 1 ? T + S[1] : T;
|
|
117
127
|
});
|
|
118
|
-
u.op = b, u.centerPos = [u.centerPos[0] +
|
|
119
|
-
} else if (
|
|
120
|
-
const
|
|
121
|
-
Ut(
|
|
128
|
+
u.op = b, u.centerPos = [u.centerPos[0] + S[0], u.centerPos[1] + S[1]], u != null && u.opt && (u.opt.translate = void 0);
|
|
129
|
+
} else if (q(c)) {
|
|
130
|
+
const S = u.op;
|
|
131
|
+
Ut(S, u.centerPos, c), u.op = S, u != null && u.opt && (u.opt.rotate = void 0);
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
u && o.setInfo(e.name, u);
|
|
@@ -136,32 +146,32 @@ const j = class j {
|
|
|
136
146
|
if (t) {
|
|
137
147
|
const o = t.getBoundingClientRect();
|
|
138
148
|
return {
|
|
139
|
-
x: Math.floor(o.x -
|
|
140
|
-
y: Math.floor(o.y -
|
|
141
|
-
w: Math.floor(o.width +
|
|
142
|
-
h: Math.floor(o.height +
|
|
149
|
+
x: Math.floor(o.x - H.SafeBorderPadding),
|
|
150
|
+
y: Math.floor(o.y - H.SafeBorderPadding),
|
|
151
|
+
w: Math.floor(o.width + H.SafeBorderPadding * 2),
|
|
152
|
+
h: Math.floor(o.height + H.SafeBorderPadding * 2)
|
|
143
153
|
};
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
};
|
|
147
|
-
m(
|
|
148
|
-
let
|
|
149
|
-
function lt(
|
|
150
|
-
const e =
|
|
157
|
+
m(H, "SafeBorderPadding", 10);
|
|
158
|
+
let L = H;
|
|
159
|
+
function lt(C, n = !0) {
|
|
160
|
+
const e = C.length;
|
|
151
161
|
if (e < 2)
|
|
152
162
|
return "";
|
|
153
|
-
let t =
|
|
163
|
+
let t = C[0], o = C[1];
|
|
154
164
|
if (e === 2)
|
|
155
165
|
return `M${rt(t)}L${rt(o)}`;
|
|
156
166
|
let s = "";
|
|
157
167
|
for (let i = 2, r = e - 1; i < r; i++)
|
|
158
|
-
t =
|
|
159
|
-
return n ? `M${nt(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)}T${s}${nt(
|
|
168
|
+
t = C[i], o = C[i + 1], s += nt(t, o);
|
|
169
|
+
return n ? `M${nt(C[0], C[1])}Q${rt(C[1])}${nt(
|
|
170
|
+
C[1],
|
|
171
|
+
C[2]
|
|
172
|
+
)}T${s}${nt(C[e - 1], C[0])}${nt(C[0], C[1])}Z` : `M${rt(C[0])}Q${rt(C[1])}${nt(C[1], C[2])}${C.length > 3 ? "T" : ""}${s}L${rt(C[e - 1])}`;
|
|
163
173
|
}
|
|
164
|
-
class Wt extends
|
|
174
|
+
class Wt extends L {
|
|
165
175
|
constructor(e) {
|
|
166
176
|
super(e);
|
|
167
177
|
m(this, "canRotate", !0);
|
|
@@ -187,8 +197,8 @@ class Wt extends W {
|
|
|
187
197
|
const i = this.drawLayer || this.fullLayer;
|
|
188
198
|
return t.length && (s = this.draw({ attrs: o, tasks: t, replaceId: e, layer: i })), {
|
|
189
199
|
rect: s,
|
|
190
|
-
type:
|
|
191
|
-
dataType:
|
|
200
|
+
type: y.DrawWork,
|
|
201
|
+
dataType: R.Local
|
|
192
202
|
};
|
|
193
203
|
}
|
|
194
204
|
setWorkOptions(e) {
|
|
@@ -198,7 +208,7 @@ class Wt extends W {
|
|
|
198
208
|
var b;
|
|
199
209
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i, drawCount: r, replaceId: a } = e;
|
|
200
210
|
if (((b = t.op) == null ? void 0 : b.length) === 0)
|
|
201
|
-
return { type:
|
|
211
|
+
return { type: y.None };
|
|
202
212
|
const { workId: c } = t, { tasks: l, effects: h, consumeIndex: p } = this.transformData(t, !1);
|
|
203
213
|
this.syncIndex = Math.min(this.syncIndex, p, Math.max(0, this.tmpPoints.length - 2));
|
|
204
214
|
const f = {
|
|
@@ -206,27 +216,27 @@ class Wt extends W {
|
|
|
206
216
|
id: r == null ? void 0 : r.toString()
|
|
207
217
|
};
|
|
208
218
|
let d, u = !1;
|
|
209
|
-
const
|
|
219
|
+
const w = this.syncIndex;
|
|
210
220
|
if (this.syncTimestamp === 0 && (this.syncTimestamp = Date.now()), l.length && (l[0].taskId - this.syncTimestamp > this.syncUnitTime && (u = !0, this.syncTimestamp = l[0].taskId, this.syncIndex = this.tmpPoints.length), s || i)) {
|
|
211
|
-
const
|
|
212
|
-
d = this.draw({ attrs: f, tasks: l, effects: h, layer:
|
|
221
|
+
const T = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
222
|
+
d = this.draw({ attrs: f, tasks: l, effects: h, layer: T, replaceId: a });
|
|
213
223
|
}
|
|
214
224
|
if (s)
|
|
215
225
|
return p > 10 && this.tmpPoints.splice(0, p - 10), {
|
|
216
226
|
rect: d,
|
|
217
|
-
type:
|
|
218
|
-
dataType:
|
|
227
|
+
type: y.DrawWork,
|
|
228
|
+
dataType: R.Local
|
|
219
229
|
};
|
|
220
|
-
const
|
|
221
|
-
return this.tmpPoints.slice(
|
|
222
|
-
|
|
230
|
+
const S = [];
|
|
231
|
+
return this.tmpPoints.slice(w).forEach((T) => {
|
|
232
|
+
S.push(T.x, T.y, this.computRadius(T.z, this.workOptions.thickness));
|
|
223
233
|
}), {
|
|
224
234
|
rect: d,
|
|
225
|
-
type:
|
|
226
|
-
dataType:
|
|
235
|
+
type: y.DrawWork,
|
|
236
|
+
dataType: R.Local,
|
|
227
237
|
workId: u ? c : void 0,
|
|
228
|
-
op: u ?
|
|
229
|
-
index: u ?
|
|
238
|
+
op: u ? S : void 0,
|
|
239
|
+
index: u ? w * 3 : void 0
|
|
230
240
|
};
|
|
231
241
|
}
|
|
232
242
|
consumeAll(e) {
|
|
@@ -237,7 +247,7 @@ class Wt extends W {
|
|
|
237
247
|
}
|
|
238
248
|
const t = (l = this.workId) == null ? void 0 : l.toString();
|
|
239
249
|
if (!t)
|
|
240
|
-
return { type:
|
|
250
|
+
return { type: y.None };
|
|
241
251
|
const o = this.transformDataAll(!0), s = {
|
|
242
252
|
name: t
|
|
243
253
|
};
|
|
@@ -256,11 +266,11 @@ class Wt extends W {
|
|
|
256
266
|
toolsType: this.toolsType,
|
|
257
267
|
scaleType: this.scaleType,
|
|
258
268
|
canRotate: this.canRotate,
|
|
259
|
-
centerPos: i &&
|
|
269
|
+
centerPos: i && L.getCenterPos(i, r)
|
|
260
270
|
}), {
|
|
261
271
|
rect: i,
|
|
262
|
-
type:
|
|
263
|
-
dataType:
|
|
272
|
+
type: y.FullWork,
|
|
273
|
+
dataType: R.Local,
|
|
264
274
|
workId: t,
|
|
265
275
|
ops: c,
|
|
266
276
|
updateNodeOpt: {
|
|
@@ -280,7 +290,7 @@ class Wt extends W {
|
|
|
280
290
|
for (let p = 0; p < t.length; p += 3) {
|
|
281
291
|
const f = new O(t[p], t[p + 1], t[p + 2]);
|
|
282
292
|
if (this.tmpPoints.length > 0) {
|
|
283
|
-
const d = this.tmpPoints[this.tmpPoints.length - 1], u =
|
|
293
|
+
const d = this.tmpPoints[this.tmpPoints.length - 1], u = k.Sub(f, d).uni();
|
|
284
294
|
f.setv(u);
|
|
285
295
|
}
|
|
286
296
|
this.tmpPoints.push(f);
|
|
@@ -298,7 +308,7 @@ class Wt extends W {
|
|
|
298
308
|
toolsType: this.toolsType,
|
|
299
309
|
scaleType: this.scaleType,
|
|
300
310
|
canRotate: this.canRotate,
|
|
301
|
-
centerPos: c &&
|
|
311
|
+
centerPos: c && L.getCenterPos(c, p)
|
|
302
312
|
});
|
|
303
313
|
}
|
|
304
314
|
return c;
|
|
@@ -309,19 +319,19 @@ class Wt extends W {
|
|
|
309
319
|
draw(e) {
|
|
310
320
|
const { attrs: t, tasks: o, replaceId: s, effects: i, layer: r } = e, { strokeColor: a, strokeType: c, thickness: l, zIndex: h, scale: p, rotate: f, translate: d } = this.workOptions;
|
|
311
321
|
i != null && i.size && (i.forEach((g) => {
|
|
312
|
-
var
|
|
313
|
-
(
|
|
322
|
+
var I;
|
|
323
|
+
(I = r.getElementById(g + "")) == null || I.remove();
|
|
314
324
|
}), i.clear());
|
|
315
325
|
let u;
|
|
316
|
-
const
|
|
326
|
+
const w = [], S = r.worldPosition, b = r.worldScaling;
|
|
317
327
|
for (let g = 0; g < o.length; g++) {
|
|
318
|
-
const { pos:
|
|
319
|
-
let
|
|
328
|
+
const { pos: I, points: N } = o[g], { ps: W, rect: A } = this.computDrawPoints(N);
|
|
329
|
+
let v;
|
|
320
330
|
const x = N.length === 1;
|
|
321
|
-
c === X.Stroke || x ?
|
|
331
|
+
c === X.Stroke || x ? v = lt(W, !0) : v = lt(W, !1);
|
|
322
332
|
const M = {
|
|
323
|
-
pos:
|
|
324
|
-
d:
|
|
333
|
+
pos: I,
|
|
334
|
+
d: v,
|
|
325
335
|
fillColor: c === X.Stroke || x ? a : void 0,
|
|
326
336
|
lineDash: c === X.Dotted && !x ? [1, l * 2] : c === X.LongDotted && !x ? [l, l * 2] : void 0,
|
|
327
337
|
strokeColor: a,
|
|
@@ -329,35 +339,35 @@ class Wt extends W {
|
|
|
329
339
|
lineWidth: c === X.Stroke || x ? 0 : l
|
|
330
340
|
};
|
|
331
341
|
u = B(u, {
|
|
332
|
-
x: Math.floor((A.x +
|
|
333
|
-
y: Math.floor((A.y +
|
|
334
|
-
w: Math.floor(A.w * b[0] + 2 *
|
|
335
|
-
h: Math.floor(A.h * b[1] + 2 *
|
|
336
|
-
}),
|
|
342
|
+
x: Math.floor((A.x + I[0]) * b[0] + S[0] - L.SafeBorderPadding),
|
|
343
|
+
y: Math.floor((A.y + I[1]) * b[1] + S[1] - L.SafeBorderPadding),
|
|
344
|
+
w: Math.floor(A.w * b[0] + 2 * L.SafeBorderPadding),
|
|
345
|
+
h: Math.floor(A.h * b[1] + 2 * L.SafeBorderPadding)
|
|
346
|
+
}), w.push(M);
|
|
337
347
|
}
|
|
338
348
|
p && (t.scale = p), f && (t.rotate = f), d && (t.translate = d);
|
|
339
|
-
const
|
|
349
|
+
const T = new _();
|
|
340
350
|
if (u) {
|
|
341
|
-
this.centerPos =
|
|
351
|
+
this.centerPos = L.getCenterPos(u, r), T.attr({
|
|
342
352
|
...t,
|
|
343
353
|
normalize: !0,
|
|
344
354
|
anchor: [0.5, 0.5],
|
|
345
355
|
bgcolor: c === X.Stroke ? a : void 0,
|
|
346
356
|
pos: this.centerPos,
|
|
347
|
-
size: [(u.w - 2 *
|
|
357
|
+
size: [(u.w - 2 * L.SafeBorderPadding) / b[0], (u.h - 2 * L.SafeBorderPadding) / b[1]],
|
|
348
358
|
zIndex: h
|
|
349
359
|
});
|
|
350
|
-
const g =
|
|
351
|
-
|
|
360
|
+
const g = w.map((I) => (I.pos = [I.pos[0] - this.centerPos[0], I.pos[1] - this.centerPos[1]], new it(I)));
|
|
361
|
+
T.append(...g), c === X.Stroke && T.seal(), this.replace(r, s || t.workId, T);
|
|
352
362
|
}
|
|
353
363
|
if (p || f || d) {
|
|
354
|
-
const g =
|
|
364
|
+
const g = T == null ? void 0 : T.getBoundingClientRect();
|
|
355
365
|
if (g)
|
|
356
366
|
return {
|
|
357
|
-
x: Math.floor(g.x -
|
|
358
|
-
y: Math.floor(g.y -
|
|
359
|
-
w: Math.floor(g.width +
|
|
360
|
-
h: Math.floor(g.height +
|
|
367
|
+
x: Math.floor(g.x - L.SafeBorderPadding),
|
|
368
|
+
y: Math.floor(g.y - L.SafeBorderPadding),
|
|
369
|
+
w: Math.floor(g.width + L.SafeBorderPadding * 2),
|
|
370
|
+
h: Math.floor(g.height + L.SafeBorderPadding * 2)
|
|
361
371
|
};
|
|
362
372
|
}
|
|
363
373
|
return u;
|
|
@@ -379,7 +389,7 @@ class Wt extends W {
|
|
|
379
389
|
const { point: l, radius: h } = e[c];
|
|
380
390
|
let p = l.v;
|
|
381
391
|
c === 0 && e.length > 1 && (p = e[c + 1].point.v);
|
|
382
|
-
const f =
|
|
392
|
+
const f = k.Per(p).mul(h);
|
|
383
393
|
t.push(O.Sub(l, f)), o.push(O.Add(l, f));
|
|
384
394
|
}
|
|
385
395
|
const s = e[e.length - 1], i = O.GetSemicircleStroke(s.point, t[t.length - 1], -1, 8), r = O.GetSemicircleStroke(e[0].point, o[0], -1, 8), a = t.concat(i, o.reverse(), r);
|
|
@@ -414,26 +424,26 @@ class Wt extends W {
|
|
|
414
424
|
return [];
|
|
415
425
|
let s = 0, i = e[0].x, r = e[0].y, a = [i, r], c = [], l = e[0].t;
|
|
416
426
|
for (; s < e.length; ) {
|
|
417
|
-
const p = e[s], f = p.x - i, d = p.y - r, u = p.z,
|
|
427
|
+
const p = e[s], f = p.x - i, d = p.y - r, u = p.z, w = t ? this.computRadius(u, t) : u;
|
|
418
428
|
if (c.push({
|
|
419
429
|
point: new O(f, d, u, e[s].v),
|
|
420
|
-
radius:
|
|
430
|
+
radius: w
|
|
421
431
|
}), s > 0 && s < e.length - 1) {
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
432
|
+
const S = e[s].getAngleByPoints(e[s - 1], e[s + 1]);
|
|
433
|
+
if (S < 90 || S > 270) {
|
|
424
434
|
const b = (h = c.pop()) == null ? void 0 : h.point.clone();
|
|
425
435
|
b && o.push({
|
|
426
436
|
taskId: l,
|
|
427
437
|
pos: a,
|
|
428
438
|
points: [...c, {
|
|
429
439
|
point: b,
|
|
430
|
-
radius:
|
|
440
|
+
radius: w
|
|
431
441
|
}]
|
|
432
442
|
}), i = e[s].x, r = e[s].y, a = [i, r];
|
|
433
|
-
const
|
|
443
|
+
const T = p.x - i, g = p.y - r;
|
|
434
444
|
c = [{
|
|
435
|
-
point: new O(
|
|
436
|
-
radius:
|
|
445
|
+
point: new O(T, g, u),
|
|
446
|
+
radius: w
|
|
437
447
|
}], l = Date.now();
|
|
438
448
|
}
|
|
439
449
|
}
|
|
@@ -455,16 +465,16 @@ class Wt extends W {
|
|
|
455
465
|
this.tmpPoints.push(h);
|
|
456
466
|
continue;
|
|
457
467
|
}
|
|
458
|
-
const p = l - 1, f = this.tmpPoints[p], d =
|
|
468
|
+
const p = l - 1, f = this.tmpPoints[p], d = k.Sub(h, f).uni();
|
|
459
469
|
if (h.isNear(f, t)) {
|
|
460
470
|
if (f.z < this.MAX_REPEAR) {
|
|
461
471
|
if (f.setz(Math.min(f.z + 1, this.MAX_REPEAR)), r = Math.min(r, p), l > 1) {
|
|
462
|
-
let
|
|
463
|
-
for (;
|
|
464
|
-
const b = this.tmpPoints[
|
|
465
|
-
if (this.tmpPoints[
|
|
472
|
+
let S = l - 1;
|
|
473
|
+
for (; S > 0; ) {
|
|
474
|
+
const b = this.tmpPoints[S].distance(this.tmpPoints[S - 1]), T = Math.max(this.tmpPoints[S].z - this.uniThickness * b, 0);
|
|
475
|
+
if (this.tmpPoints[S - 1].z >= T)
|
|
466
476
|
break;
|
|
467
|
-
this.tmpPoints[
|
|
477
|
+
this.tmpPoints[S - 1].setz(T), r = Math.min(r, S - 1), S--;
|
|
468
478
|
}
|
|
469
479
|
}
|
|
470
480
|
} else
|
|
@@ -472,8 +482,8 @@ class Wt extends W {
|
|
|
472
482
|
continue;
|
|
473
483
|
}
|
|
474
484
|
h.setv(d);
|
|
475
|
-
const u = h.distance(f),
|
|
476
|
-
l > 1 &&
|
|
485
|
+
const u = h.distance(f), w = Math.max(f.z - this.uniThickness * u, 0);
|
|
486
|
+
l > 1 && k.Equals(d, f.v, 0.02) && (w > 0 || f.z <= 0) && (o && f.t && o.add(f.t), this.tmpPoints.pop(), r = Math.min(p, r)), h.setz(w), this.tmpPoints.push(h);
|
|
477
487
|
}
|
|
478
488
|
if (r === 1 / 0)
|
|
479
489
|
return this.tmpPoints.length;
|
|
@@ -505,12 +515,12 @@ class Wt extends W {
|
|
|
505
515
|
this.tmpPoints.push(p);
|
|
506
516
|
continue;
|
|
507
517
|
}
|
|
508
|
-
const f = h - 1, d = this.tmpPoints[f], u =
|
|
518
|
+
const f = h - 1, d = this.tmpPoints[f], u = k.Sub(p, d).uni();
|
|
509
519
|
if (p.isNear(d, t / 2)) {
|
|
510
520
|
r = Math.min(f, r);
|
|
511
521
|
continue;
|
|
512
522
|
}
|
|
513
|
-
|
|
523
|
+
k.Equals(u, d.v, 0.02) && (o && d.t && o.add(d.t), this.tmpPoints.pop(), r = Math.min(f, r)), p.setv(u), this.tmpPoints.push(p);
|
|
514
524
|
}
|
|
515
525
|
let a = i;
|
|
516
526
|
if (r === i) {
|
|
@@ -538,24 +548,24 @@ class Wt extends W {
|
|
|
538
548
|
this.tmpPoints.push(a);
|
|
539
549
|
continue;
|
|
540
550
|
}
|
|
541
|
-
const c = r - 1, l = this.tmpPoints[c], h =
|
|
551
|
+
const c = r - 1, l = this.tmpPoints[c], h = k.Sub(a, l).uni(), p = a.distance(l);
|
|
542
552
|
if (r > 1 && l.z === s)
|
|
543
553
|
break;
|
|
544
554
|
if (a.isNear(l, t / 2)) {
|
|
545
555
|
if (o < 3 && l.z < this.MAX_REPEAR && (l.setz(Math.min(l.z + 1, this.MAX_REPEAR)), r > 1)) {
|
|
546
556
|
let d = r - 1;
|
|
547
557
|
for (; d > 0; ) {
|
|
548
|
-
const u = this.tmpPoints[d].distance(this.tmpPoints[d - 1]),
|
|
549
|
-
if (this.tmpPoints[d - 1].z >=
|
|
558
|
+
const u = this.tmpPoints[d].distance(this.tmpPoints[d - 1]), w = Math.max(this.tmpPoints[d].z - this.uniThickness * u, -t / 4);
|
|
559
|
+
if (this.tmpPoints[d - 1].z >= w)
|
|
550
560
|
break;
|
|
551
|
-
this.tmpPoints[d - 1].setz(
|
|
561
|
+
this.tmpPoints[d - 1].setz(w), d--;
|
|
552
562
|
}
|
|
553
563
|
}
|
|
554
564
|
continue;
|
|
555
565
|
}
|
|
556
566
|
a.setv(h);
|
|
557
567
|
const f = Math.max(l.z - this.uniThickness * p, s);
|
|
558
|
-
r > 1 &&
|
|
568
|
+
r > 1 && k.Equals(h, l.v, 0.02) && l.z <= 0 && this.tmpPoints.pop(), a.setz(f), this.tmpPoints.push(a);
|
|
559
569
|
}
|
|
560
570
|
}
|
|
561
571
|
static updateNodeOpt(e) {
|
|
@@ -563,24 +573,10 @@ class Wt extends W {
|
|
|
563
573
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
|
|
564
574
|
return i && (t.tagName === "GROUP" ? Jt(t) ? t.setAttribute("bgcolor", i) : t.children.forEach((c) => {
|
|
565
575
|
c.setAttribute("strokeColor", i), c.getAttribute("fillColor") && c.setAttribute("fillColor", i);
|
|
566
|
-
}) : (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i)), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r),
|
|
567
|
-
}
|
|
568
|
-
// static getRectFromLayer(layer: Group, name:string): IRectType|undefined {
|
|
569
|
-
// const node = layer.getElementsByName(name)[0] as ShapeNodes;
|
|
570
|
-
// if (node) {
|
|
571
|
-
// const r = node.getBoundingClientRect();
|
|
572
|
-
// console.log('r', r.x, r.y, r.width, r.height)
|
|
573
|
-
// return {
|
|
574
|
-
// x: Math.floor(r.x - BaseShapeTool.SafeBorderPadding),
|
|
575
|
-
// y: Math.floor(r.y - BaseShapeTool.SafeBorderPadding),
|
|
576
|
-
// w: Math.floor(r.width + BaseShapeTool.SafeBorderPadding * 2),
|
|
577
|
-
// h: Math.floor(r.height + BaseShapeTool.SafeBorderPadding * 2)
|
|
578
|
-
// }
|
|
579
|
-
// }
|
|
580
|
-
// return undefined
|
|
581
|
-
// }
|
|
576
|
+
}) : (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i)), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), L.updateNodeOpt(e);
|
|
577
|
+
}
|
|
582
578
|
}
|
|
583
|
-
class Lt extends
|
|
579
|
+
class Lt extends L {
|
|
584
580
|
constructor(e) {
|
|
585
581
|
super(e);
|
|
586
582
|
m(this, "toolsType", P.LaserPen);
|
|
@@ -601,9 +597,9 @@ class Lt extends W {
|
|
|
601
597
|
consume(e) {
|
|
602
598
|
const { data: t, isSubWorker: o } = e, { workId: s, op: i } = t;
|
|
603
599
|
if ((i == null ? void 0 : i.length) === 0)
|
|
604
|
-
return { type:
|
|
600
|
+
return { type: y.None };
|
|
605
601
|
if (this.updateTempPoints(i || []), this.consumeIndex > this.tmpPoints.length - 4)
|
|
606
|
-
return { type:
|
|
602
|
+
return { type: y.None };
|
|
607
603
|
const { strokeColor: r, thickness: a, strokeType: c } = this.workOptions, l = z(this.tmpPoints, a);
|
|
608
604
|
let h = !1;
|
|
609
605
|
const p = this.syncIndex, f = this.tmpPoints.slice(this.consumeIndex);
|
|
@@ -618,12 +614,12 @@ class Lt extends W {
|
|
|
618
614
|
anchor: [0.5, 0.5]
|
|
619
615
|
}, u = this.getTaskPoints(f);
|
|
620
616
|
if (u.length) {
|
|
621
|
-
const
|
|
622
|
-
|
|
617
|
+
const S = Date.now();
|
|
618
|
+
S - this.syncTimestamp > this.syncUnitTime && (h = !0, this.syncTimestamp = S, this.syncIndex = this.tmpPoints.length), o && this.draw({ attrs: d, tasks: u, isDot: !1, layer: this.drawLayer || this.fullLayer });
|
|
623
619
|
}
|
|
624
|
-
const
|
|
625
|
-
return this.tmpPoints.slice(p).forEach((
|
|
626
|
-
|
|
620
|
+
const w = [];
|
|
621
|
+
return this.tmpPoints.slice(p).forEach((S) => {
|
|
622
|
+
w.push(S.x, S.y);
|
|
627
623
|
}), {
|
|
628
624
|
rect: {
|
|
629
625
|
x: l.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
|
|
@@ -631,10 +627,10 @@ class Lt extends W {
|
|
|
631
627
|
w: l.w * this.fullLayer.worldScaling[0],
|
|
632
628
|
h: l.h * this.fullLayer.worldScaling[1]
|
|
633
629
|
},
|
|
634
|
-
type:
|
|
635
|
-
dataType:
|
|
630
|
+
type: y.DrawWork,
|
|
631
|
+
dataType: R.Local,
|
|
636
632
|
workId: h ? s : void 0,
|
|
637
|
-
op: h ?
|
|
633
|
+
op: h ? w : void 0,
|
|
638
634
|
index: h ? p * 2 : void 0
|
|
639
635
|
};
|
|
640
636
|
}
|
|
@@ -677,8 +673,8 @@ class Lt extends W {
|
|
|
677
673
|
w: t.w * this.fullLayer.worldScaling[0],
|
|
678
674
|
h: t.h * this.fullLayer.worldScaling[1]
|
|
679
675
|
},
|
|
680
|
-
type:
|
|
681
|
-
dataType:
|
|
676
|
+
type: y.FullWork,
|
|
677
|
+
dataType: R.Local,
|
|
682
678
|
workId: e,
|
|
683
679
|
ops: s,
|
|
684
680
|
index: this.syncIndex * 2
|
|
@@ -691,12 +687,12 @@ class Lt extends W {
|
|
|
691
687
|
var u;
|
|
692
688
|
const { op: t, replaceId: o, isFullWork: s } = e, { strokeColor: i, thickness: r, strokeType: a } = this.workOptions;
|
|
693
689
|
if (!t.length) {
|
|
694
|
-
const
|
|
690
|
+
const w = z(this.tmpPoints, r);
|
|
695
691
|
return {
|
|
696
|
-
x:
|
|
697
|
-
y:
|
|
698
|
-
w:
|
|
699
|
-
h:
|
|
692
|
+
x: w.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
|
|
693
|
+
y: w.y * this.fullLayer.worldScaling[1] + this.fullLayer.worldPosition[1],
|
|
694
|
+
w: w.w * this.fullLayer.worldScaling[0],
|
|
695
|
+
h: w.h * this.fullLayer.worldScaling[1]
|
|
700
696
|
};
|
|
701
697
|
}
|
|
702
698
|
const c = Math.max(0, this.tmpPoints.length - 1);
|
|
@@ -704,11 +700,11 @@ class Lt extends W {
|
|
|
704
700
|
let l, h = this.tmpPoints.slice(c);
|
|
705
701
|
const p = h.length === 1;
|
|
706
702
|
if (p) {
|
|
707
|
-
const
|
|
703
|
+
const w = this.computDotStroke({
|
|
708
704
|
point: h[0],
|
|
709
705
|
radius: r / 2
|
|
710
706
|
});
|
|
711
|
-
h =
|
|
707
|
+
h = w.ps, l = w.rect;
|
|
712
708
|
} else
|
|
713
709
|
l = z(this.tmpPoints, r);
|
|
714
710
|
const f = {
|
|
@@ -722,8 +718,8 @@ class Lt extends W {
|
|
|
722
718
|
anchor: [0.5, 0.5]
|
|
723
719
|
}, d = this.getTaskPoints(h);
|
|
724
720
|
if (d.length) {
|
|
725
|
-
const
|
|
726
|
-
this.draw({ attrs: f, tasks: d, isDot: p, replaceId: o, layer:
|
|
721
|
+
const w = s ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
722
|
+
this.draw({ attrs: f, tasks: d, isDot: p, replaceId: o, layer: w });
|
|
727
723
|
}
|
|
728
724
|
return {
|
|
729
725
|
x: l.x * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0],
|
|
@@ -758,10 +754,10 @@ class Lt extends W {
|
|
|
758
754
|
});
|
|
759
755
|
const { vertex: f, fragment: d } = this.workOptions;
|
|
760
756
|
if (f && d) {
|
|
761
|
-
const u = i.renderer.createProgram({ vertex: f, fragment: d }), { width:
|
|
757
|
+
const u = i.renderer.createProgram({ vertex: f, fragment: d }), { width: w, height: S } = i.getResolution();
|
|
762
758
|
c.setUniforms({
|
|
763
759
|
u_time: 0,
|
|
764
|
-
u_resolution: [
|
|
760
|
+
u_resolution: [w, S]
|
|
765
761
|
}), c.setProgram(u);
|
|
766
762
|
}
|
|
767
763
|
i.appendChild(c), c.transition(r).attr({
|
|
@@ -788,8 +784,8 @@ class Lt extends W {
|
|
|
788
784
|
pos: r,
|
|
789
785
|
points: [...a, d]
|
|
790
786
|
}), s = e[o].x, i = e[o].y, r = [s, i];
|
|
791
|
-
const u = l.x - s,
|
|
792
|
-
a = [new O(u,
|
|
787
|
+
const u = l.x - s, w = l.y - i;
|
|
788
|
+
a = [new O(u, w)];
|
|
793
789
|
}
|
|
794
790
|
}
|
|
795
791
|
o++;
|
|
@@ -817,7 +813,7 @@ class Lt extends W {
|
|
|
817
813
|
}), o.length && o.forEach((s) => s.remove()), t;
|
|
818
814
|
}
|
|
819
815
|
}
|
|
820
|
-
const at = class at extends
|
|
816
|
+
const at = class at extends L {
|
|
821
817
|
constructor(e, t) {
|
|
822
818
|
super(e);
|
|
823
819
|
m(this, "canRotate", !1);
|
|
@@ -851,11 +847,11 @@ const at = class at extends W {
|
|
|
851
847
|
computRectCenterPoints() {
|
|
852
848
|
const e = this.tmpPoints.slice(-2);
|
|
853
849
|
if (this.tmpPoints.length === 4) {
|
|
854
|
-
const t = new
|
|
850
|
+
const t = new k(this.tmpPoints[0], this.tmpPoints[1]), o = new k(this.tmpPoints[2], this.tmpPoints[3]), s = k.Sub(o, t).uni(), i = k.Dist(t, o), { width: r, height: a } = at.eraserSizes[this.workOptions.thickness], c = Math.min(r, a), l = Math.round(i / c);
|
|
855
851
|
if (l > 1) {
|
|
856
852
|
const h = [];
|
|
857
853
|
for (let p = 0; p < l; p++) {
|
|
858
|
-
const f =
|
|
854
|
+
const f = k.Mul(s, p * c);
|
|
859
855
|
h.push(this.tmpPoints[0] + f.x, this.tmpPoints[1] + f.y);
|
|
860
856
|
}
|
|
861
857
|
return h.concat(e);
|
|
@@ -864,8 +860,8 @@ const at = class at extends W {
|
|
|
864
860
|
return e;
|
|
865
861
|
}
|
|
866
862
|
isNear(e, t) {
|
|
867
|
-
const o = new
|
|
868
|
-
return
|
|
863
|
+
const o = new k(e[0], e[1]), s = new k(t[0], t[1]), { width: i, height: r } = at.eraserSizes[this.workOptions.thickness];
|
|
864
|
+
return k.Dist(o, s) < Math.hypot(i, r) * 0.5;
|
|
869
865
|
}
|
|
870
866
|
cutPolyline(e, t) {
|
|
871
867
|
let o = [t], s = 0;
|
|
@@ -882,9 +878,9 @@ const at = class at extends W {
|
|
|
882
878
|
const p = a[h], f = p.findIndex((d, u) => u < p.length - 1 ? r([d, p[u + 1]], [c[0], c[1]]) : !1);
|
|
883
879
|
if (f !== -1 && f > -1) {
|
|
884
880
|
const d = [], u = p.slice(0, f + 1);
|
|
885
|
-
if (
|
|
886
|
-
const
|
|
887
|
-
|
|
881
|
+
if (k.Equals(p[f], c[0]) || u.push(c[0].clone().setz(p[f].z)), u.length > 1 && d.push(u), f + c.length - 1 < p.length - 1) {
|
|
882
|
+
const w = f + c.length - 1, S = p.slice(w), b = c[c.length - 1];
|
|
883
|
+
k.Equals(p[w], b) || S.unshift(b.clone().setz(p[w].z)), S.length > 1 && d.push(S);
|
|
888
884
|
}
|
|
889
885
|
return l.splice(h, 1, ...d), l;
|
|
890
886
|
}
|
|
@@ -892,8 +888,8 @@ const at = class at extends W {
|
|
|
892
888
|
return l;
|
|
893
889
|
}
|
|
894
890
|
function r(a, c) {
|
|
895
|
-
const l =
|
|
896
|
-
return Math.abs(
|
|
891
|
+
const l = k.Sub(a[1], a[0]), h = k.Sub(c[1], c[0]), p = k.Sub(c[0], a[0]);
|
|
892
|
+
return Math.abs(k.Cpr(l, h)) < 0.1 && Math.abs(k.Cpr(l, p)) < 0.1;
|
|
897
893
|
}
|
|
898
894
|
}
|
|
899
895
|
isSamePoint(e, t) {
|
|
@@ -905,7 +901,7 @@ const at = class at extends W {
|
|
|
905
901
|
const s = e[o].filter((a, c, l) => !(c > 0 && this.isSamePoint(a, l[c - 1]))), i = [];
|
|
906
902
|
let r = 0;
|
|
907
903
|
for (; r < s.length; ) {
|
|
908
|
-
const a = s[r], c = new
|
|
904
|
+
const a = s[r], c = new k(a[0], a[1]);
|
|
909
905
|
i.push(c), r++;
|
|
910
906
|
}
|
|
911
907
|
t.push(i);
|
|
@@ -921,30 +917,30 @@ const at = class at extends W {
|
|
|
921
917
|
for (const [a, c] of t.entries())
|
|
922
918
|
if (c.rect && this.eraserRect && this.eraserPolyline && ht(this.eraserRect, c.rect)) {
|
|
923
919
|
const { op: l, toolsType: h } = c, p = this.isLineEraser(h, i), f = [], d = [];
|
|
924
|
-
for (let
|
|
925
|
-
const
|
|
926
|
-
d.push(
|
|
920
|
+
for (let w = 0; w < l.length; w += 3) {
|
|
921
|
+
const S = new k(l[w] * this.worldScaling[0] + this.worldPosition[0], l[w + 1] * this.worldScaling[1] + this.worldPosition[1], l[w + 2]);
|
|
922
|
+
d.push(S), f.push(new O(S.x, S.y));
|
|
927
923
|
}
|
|
928
924
|
const u = f.length && z(f) || c.rect;
|
|
929
925
|
if (ht(u, this.eraserRect)) {
|
|
930
926
|
if (d.length > 1) {
|
|
931
|
-
const
|
|
932
|
-
if (
|
|
933
|
-
const
|
|
934
|
-
for (let
|
|
935
|
-
const g = `${a}_s_${
|
|
936
|
-
b[
|
|
937
|
-
|
|
927
|
+
const w = Kt.polyline(d.map((S) => S.XY), this.eraserPolyline);
|
|
928
|
+
if (w.length && (o.add(c.name), !p)) {
|
|
929
|
+
const S = this.translateIntersect(w), b = this.cutPolyline(S, d);
|
|
930
|
+
for (let T = 0; T < b.length; T++) {
|
|
931
|
+
const g = `${a}_s_${T}`, I = [];
|
|
932
|
+
b[T].forEach((N) => {
|
|
933
|
+
I.push((N.x - this.worldPosition[0]) / this.worldScaling[0], (N.y - this.worldPosition[1]) / this.worldScaling[1], N.z);
|
|
938
934
|
}), c.opt && c.toolsType && this.vNodes && (this.vNodes.setInfo(g, {
|
|
939
935
|
rect: u,
|
|
940
|
-
op:
|
|
936
|
+
op: I,
|
|
941
937
|
opt: c.opt,
|
|
942
938
|
canRotate: c.canRotate,
|
|
943
939
|
scaleType: c.scaleType,
|
|
944
940
|
toolsType: c.toolsType
|
|
945
941
|
}), s.set(g, {
|
|
946
942
|
workId: g,
|
|
947
|
-
op:
|
|
943
|
+
op: I,
|
|
948
944
|
opt: c.opt,
|
|
949
945
|
toolsType: c.toolsType
|
|
950
946
|
}));
|
|
@@ -958,18 +954,18 @@ const at = class at extends W {
|
|
|
958
954
|
return o.forEach((a) => {
|
|
959
955
|
var c;
|
|
960
956
|
return (c = this.vNodes) == null ? void 0 : c.delete(a);
|
|
961
|
-
}), r && (r.x -=
|
|
957
|
+
}), r && (r.x -= L.SafeBorderPadding, r.y -= L.SafeBorderPadding, r.w += L.SafeBorderPadding * 2, r.h += L.SafeBorderPadding * 2), r;
|
|
962
958
|
}
|
|
963
959
|
consume(e) {
|
|
964
960
|
const { op: t } = e.data;
|
|
965
961
|
if (!t || t.length === 0)
|
|
966
962
|
return {
|
|
967
|
-
type:
|
|
963
|
+
type: y.None
|
|
968
964
|
};
|
|
969
965
|
const o = this.tmpPoints.length;
|
|
970
966
|
if (o > 1 && this.isNear([t[0], t[1]], [this.tmpPoints[o - 2], this.tmpPoints[o - 1]]))
|
|
971
967
|
return {
|
|
972
|
-
type:
|
|
968
|
+
type: y.None
|
|
973
969
|
};
|
|
974
970
|
o === 4 && (this.tmpPoints.shift(), this.tmpPoints.shift()), this.tmpPoints.push(t[0], t[1]);
|
|
975
971
|
const s = this.computRectCenterPoints();
|
|
@@ -977,7 +973,7 @@ const at = class at extends W {
|
|
|
977
973
|
const r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
|
|
978
974
|
if (!this.vNodes)
|
|
979
975
|
return {
|
|
980
|
-
type:
|
|
976
|
+
type: y.None
|
|
981
977
|
};
|
|
982
978
|
this.vNodes.setTarget();
|
|
983
979
|
const c = this.getUnLockNodeMap(this.vNodes.getLastTarget());
|
|
@@ -990,15 +986,15 @@ const at = class at extends W {
|
|
|
990
986
|
for (const l of a.keys())
|
|
991
987
|
r.has(l) && a.delete(l);
|
|
992
988
|
return {
|
|
993
|
-
type:
|
|
994
|
-
dataType:
|
|
989
|
+
type: y.RemoveNode,
|
|
990
|
+
dataType: R.Local,
|
|
995
991
|
rect: i,
|
|
996
992
|
removeIds: [...r],
|
|
997
993
|
newWorkDatas: a
|
|
998
994
|
};
|
|
999
995
|
}
|
|
1000
996
|
return {
|
|
1001
|
-
type:
|
|
997
|
+
type: y.None
|
|
1002
998
|
};
|
|
1003
999
|
}
|
|
1004
1000
|
consumeAll(e) {
|
|
@@ -1027,8 +1023,8 @@ m(at, "eraserSizes", Object.freeze([
|
|
|
1027
1023
|
Object.freeze({ width: 26, height: 34 }),
|
|
1028
1024
|
Object.freeze({ width: 34, height: 50 })
|
|
1029
1025
|
]));
|
|
1030
|
-
let
|
|
1031
|
-
const Q = class Q extends
|
|
1026
|
+
let ft = at;
|
|
1027
|
+
const Q = class Q extends L {
|
|
1032
1028
|
constructor(e) {
|
|
1033
1029
|
super(e);
|
|
1034
1030
|
m(this, "toolsType", P.Selector);
|
|
@@ -1082,7 +1078,7 @@ const Q = class Q extends W {
|
|
|
1082
1078
|
zIndex: 1e3
|
|
1083
1079
|
}), c = [];
|
|
1084
1080
|
if (r) {
|
|
1085
|
-
const l = new
|
|
1081
|
+
const l = new kt({
|
|
1086
1082
|
normalize: !0,
|
|
1087
1083
|
pos: [t.w / 2, t.h / 2],
|
|
1088
1084
|
lineWidth: 1,
|
|
@@ -1097,7 +1093,7 @@ const Q = class Q extends W {
|
|
|
1097
1093
|
const p = [
|
|
1098
1094
|
l.rect.x + l.rect.w / 2 - t.x,
|
|
1099
1095
|
l.rect.y + l.rect.h / 2 - t.y
|
|
1100
|
-
], f = new
|
|
1096
|
+
], f = new kt({
|
|
1101
1097
|
normalize: !0,
|
|
1102
1098
|
pos: p,
|
|
1103
1099
|
lineWidth: 1,
|
|
@@ -1147,18 +1143,18 @@ const Q = class Q extends W {
|
|
|
1147
1143
|
const { op: t, workState: o } = e.data;
|
|
1148
1144
|
let s = this.oldSelectRect;
|
|
1149
1145
|
if (o === D.Start && (s = this.unSelectedAllIds()), !(t != null && t.length) || !this.vNodes.curNodeMap.size)
|
|
1150
|
-
return { type:
|
|
1146
|
+
return { type: y.None };
|
|
1151
1147
|
this.updateTempPoints(t);
|
|
1152
1148
|
const i = this.computSelector();
|
|
1153
1149
|
if (this.selectIds && ct(this.selectIds, i.selectIds))
|
|
1154
|
-
return { type:
|
|
1150
|
+
return { type: y.None };
|
|
1155
1151
|
this.selectIds = i.selectIds;
|
|
1156
1152
|
const r = i.intersectRect;
|
|
1157
1153
|
this.getSelecteorInfo(i.subNodeMap), this.draw(Q.selectorId, this.fullLayer, i), this.oldSelectRect = r;
|
|
1158
1154
|
const a = this.getChildrenPoints();
|
|
1159
1155
|
return {
|
|
1160
|
-
type:
|
|
1161
|
-
dataType:
|
|
1156
|
+
type: y.Select,
|
|
1157
|
+
dataType: R.Local,
|
|
1162
1158
|
rect: B(r, s),
|
|
1163
1159
|
selectIds: i.selectIds,
|
|
1164
1160
|
opt: this.workOptions,
|
|
@@ -1184,8 +1180,8 @@ const Q = class Q extends W {
|
|
|
1184
1180
|
if (!((t = this.selectIds) != null && t.length) && this.tmpPoints[0] && this.selectSingleTool(this.tmpPoints[0].XY, Q.selectorId, !1), (o = this.selectIds) != null && o.length && (e = this.selectedByIds(this.selectIds)), e) {
|
|
1185
1181
|
const s = this.getChildrenPoints();
|
|
1186
1182
|
return {
|
|
1187
|
-
type:
|
|
1188
|
-
dataType:
|
|
1183
|
+
type: y.Select,
|
|
1184
|
+
dataType: R.Local,
|
|
1189
1185
|
rect: this.oldSelectRect,
|
|
1190
1186
|
selectIds: this.selectIds,
|
|
1191
1187
|
opt: this.workOptions,
|
|
@@ -1206,7 +1202,7 @@ const Q = class Q extends W {
|
|
|
1206
1202
|
};
|
|
1207
1203
|
}
|
|
1208
1204
|
return {
|
|
1209
|
-
type:
|
|
1205
|
+
type: y.None
|
|
1210
1206
|
};
|
|
1211
1207
|
}
|
|
1212
1208
|
consumeService() {
|
|
@@ -1284,135 +1280,136 @@ const Q = class Q extends W {
|
|
|
1284
1280
|
if (!h)
|
|
1285
1281
|
return;
|
|
1286
1282
|
let p;
|
|
1287
|
-
const f = /* @__PURE__ */ new Map(), { box: d, workState: u, angle:
|
|
1288
|
-
let b = [0, 0],
|
|
1289
|
-
if (d ||
|
|
1283
|
+
const f = /* @__PURE__ */ new Map(), { box: d, workState: u, angle: w, translate: S } = t;
|
|
1284
|
+
let b = [0, 0], T = [1, 1], g = [0, 0], I, N;
|
|
1285
|
+
if (d || S || q(w)) {
|
|
1290
1286
|
if (u === D.Start)
|
|
1291
1287
|
return s.setTarget(), {
|
|
1292
|
-
type:
|
|
1293
|
-
dataType:
|
|
1288
|
+
type: y.Select,
|
|
1289
|
+
dataType: R.Local,
|
|
1294
1290
|
selectRect: this.oldSelectRect,
|
|
1295
1291
|
rect: this.oldSelectRect
|
|
1296
1292
|
};
|
|
1297
|
-
if (
|
|
1298
|
-
let
|
|
1293
|
+
if (I = s.getLastTarget(), I && d) {
|
|
1294
|
+
let v;
|
|
1299
1295
|
o == null || o.forEach((x) => {
|
|
1300
|
-
const M =
|
|
1301
|
-
|
|
1302
|
-
}),
|
|
1296
|
+
const M = I == null ? void 0 : I.get(x);
|
|
1297
|
+
v = B(v, M == null ? void 0 : M.rect);
|
|
1298
|
+
}), v && (T = [d.w / v.w, d.h / v.h], b = [d.x + d.w / 2 - (v.x + v.w / 2), d.y + d.h / 2 - (v.y + v.h / 2)], g = [v.x + v.w / 2, v.y + v.h / 2]), N = v;
|
|
1303
1299
|
}
|
|
1304
1300
|
}
|
|
1305
1301
|
if (o)
|
|
1306
|
-
for (const
|
|
1307
|
-
const x = s.get(
|
|
1302
|
+
for (const v of o) {
|
|
1303
|
+
const x = s.get(v);
|
|
1308
1304
|
if (x) {
|
|
1309
1305
|
const { toolsType: M } = x;
|
|
1310
|
-
let $ = (h == null ? void 0 : h.getElementsByName(
|
|
1306
|
+
let $ = (h == null ? void 0 : h.getElementsByName(v))[0];
|
|
1311
1307
|
if ($) {
|
|
1312
1308
|
const F = { ...t };
|
|
1313
|
-
let
|
|
1309
|
+
let V;
|
|
1314
1310
|
if (M) {
|
|
1315
|
-
if (
|
|
1316
|
-
F.boxScale =
|
|
1317
|
-
const
|
|
1318
|
-
F.boxTranslate = [et[0] * (
|
|
1311
|
+
if (V = I == null ? void 0 : I.get(v), V && d) {
|
|
1312
|
+
F.boxScale = T;
|
|
1313
|
+
const j = [V.rect.x + V.rect.w / 2, V.rect.y + V.rect.h / 2], et = [j[0] - g[0], j[1] - g[1]];
|
|
1314
|
+
F.boxTranslate = [et[0] * (T[0] - 1) + b[0] + (a && a[0] || 0), et[1] * (T[1] - 1) + b[1] + (a && a[1] || 0)];
|
|
1319
1315
|
}
|
|
1320
|
-
const
|
|
1321
|
-
if (
|
|
1316
|
+
const St = At(M);
|
|
1317
|
+
if (St == null || St.updateNodeOpt({
|
|
1322
1318
|
node: $,
|
|
1323
1319
|
opt: F,
|
|
1324
1320
|
vNodes: s,
|
|
1325
1321
|
willSerializeData: i,
|
|
1326
|
-
targetNode:
|
|
1327
|
-
}), x && r &&
|
|
1328
|
-
|
|
1322
|
+
targetNode: V
|
|
1323
|
+
}), x && r && // itemOpt.angle || itemOpt.translate || itemOpt.boxScale ||
|
|
1324
|
+
(i && (F.angle || F.translate) || F.box && F.workState !== D.Start || F.pointMap && F.pointMap.has(v) || M === P.Text && (F.fontSize || F.translate || F.textInfos && F.textInfos.get(v)) || M === P.Image && (F.angle || F.translate || F.boxScale) || M === F.toolsType && F.willRefresh)) {
|
|
1325
|
+
const j = r.createWorkShapeNode({
|
|
1329
1326
|
toolsType: M,
|
|
1330
1327
|
toolsOpt: x.opt
|
|
1331
1328
|
});
|
|
1332
|
-
|
|
1329
|
+
j == null || j.setWorkId(v);
|
|
1333
1330
|
let et;
|
|
1334
|
-
M === P.Image && c ? et = await
|
|
1331
|
+
M === P.Image && c ? et = await j.consumeServiceAsync({
|
|
1335
1332
|
isFullWork: !0,
|
|
1336
|
-
replaceId:
|
|
1333
|
+
replaceId: v,
|
|
1337
1334
|
scene: c,
|
|
1338
1335
|
isMainThread: l
|
|
1339
|
-
}) : M === P.Text ? et = await
|
|
1336
|
+
}) : M === P.Text ? et = await j.consumeServiceAsync({
|
|
1340
1337
|
isFullWork: !0,
|
|
1341
|
-
replaceId:
|
|
1342
|
-
}) : et =
|
|
1338
|
+
replaceId: v
|
|
1339
|
+
}) : et = j == null ? void 0 : j.consumeService({
|
|
1343
1340
|
op: x.op,
|
|
1344
1341
|
isFullWork: !0,
|
|
1345
|
-
replaceId:
|
|
1346
|
-
}), et && (x.rect = et), $ = (h == null ? void 0 : h.getElementsByName(
|
|
1342
|
+
replaceId: v
|
|
1343
|
+
}), et && (x.rect = et), $ = (h == null ? void 0 : h.getElementsByName(v))[0];
|
|
1347
1344
|
}
|
|
1348
|
-
x && (f.set(
|
|
1345
|
+
x && (f.set(v, x), p = B(p, x.rect));
|
|
1349
1346
|
}
|
|
1350
1347
|
}
|
|
1351
1348
|
}
|
|
1352
1349
|
}
|
|
1353
|
-
|
|
1354
|
-
const
|
|
1355
|
-
if (N && t.dir &&
|
|
1356
|
-
const
|
|
1350
|
+
I && u === D.Done && (s.deleteLastTarget(), I = void 0);
|
|
1351
|
+
const W = p;
|
|
1352
|
+
if (N && t.dir && W && !a) {
|
|
1353
|
+
const v = [0, 0];
|
|
1357
1354
|
switch (t.dir) {
|
|
1358
1355
|
case "top": {
|
|
1359
1356
|
const x = [N.x, N.y + N.h];
|
|
1360
|
-
t.reverseY ?
|
|
1357
|
+
t.reverseY ? v[1] = x[1] - W.y : v[1] = x[1] - (W.y + W.h);
|
|
1361
1358
|
break;
|
|
1362
1359
|
}
|
|
1363
1360
|
case "topLeft": {
|
|
1364
1361
|
const x = [N.x + N.w, N.y + N.h];
|
|
1365
|
-
t.reverseY ?
|
|
1362
|
+
t.reverseY ? v[1] = x[1] - W.y : v[1] = x[1] - (W.y + W.h), t.reverseX ? v[0] = x[0] - W.x : v[0] = x[0] - (W.x + W.w);
|
|
1366
1363
|
break;
|
|
1367
1364
|
}
|
|
1368
1365
|
case "topRight": {
|
|
1369
1366
|
const x = [N.x, N.y + N.h];
|
|
1370
|
-
t.reverseY ?
|
|
1367
|
+
t.reverseY ? v[1] = x[1] - W.y : v[1] = x[1] - (W.y + W.h), t.reverseX ? v[0] = x[0] - (W.x + W.w) : v[0] = x[0] - W.x;
|
|
1371
1368
|
break;
|
|
1372
1369
|
}
|
|
1373
1370
|
case "bottom": {
|
|
1374
1371
|
const x = [N.x, N.y];
|
|
1375
|
-
t.reverseY ?
|
|
1372
|
+
t.reverseY ? v[1] = x[1] - (W.y + W.h) : v[1] = x[1] - W.y;
|
|
1376
1373
|
break;
|
|
1377
1374
|
}
|
|
1378
1375
|
case "bottomLeft": {
|
|
1379
1376
|
const x = [N.x + N.w, N.y];
|
|
1380
|
-
t.reverseY ?
|
|
1377
|
+
t.reverseY ? v[1] = x[1] - (W.y + W.h) : v[1] = x[1] - W.y, t.reverseX ? v[0] = x[0] - W.x : v[0] = x[0] - (W.x + W.w);
|
|
1381
1378
|
break;
|
|
1382
1379
|
}
|
|
1383
1380
|
case "bottomRight": {
|
|
1384
1381
|
const x = [N.x, N.y];
|
|
1385
|
-
t.reverseY ?
|
|
1382
|
+
t.reverseY ? v[1] = x[1] - (W.y + W.h) : v[1] = x[1] - W.y, t.reverseX ? v[0] = x[0] - (W.x + W.w) : v[0] = x[0] - W.x;
|
|
1386
1383
|
break;
|
|
1387
1384
|
}
|
|
1388
1385
|
case "right": {
|
|
1389
1386
|
const x = [N.x, N.y];
|
|
1390
|
-
t.reverseX ?
|
|
1387
|
+
t.reverseX ? v[0] = x[0] - (W.x + W.w) : v[0] = x[0] - W.x;
|
|
1391
1388
|
break;
|
|
1392
1389
|
}
|
|
1393
1390
|
}
|
|
1394
|
-
if (
|
|
1395
|
-
return
|
|
1391
|
+
if (v[0] || v[1])
|
|
1392
|
+
return W.x = W.x + v[0], W.y = W.y + v[1], await this.updateSelector({ ...e, offset: v });
|
|
1396
1393
|
}
|
|
1397
1394
|
this.getSelecteorInfo(f), this.draw(Q.selectorId, h, {
|
|
1398
1395
|
selectIds: o || [],
|
|
1399
1396
|
subNodeMap: f,
|
|
1400
|
-
intersectRect:
|
|
1397
|
+
intersectRect: W
|
|
1401
1398
|
});
|
|
1402
|
-
const A = B(this.oldSelectRect,
|
|
1403
|
-
return this.oldSelectRect =
|
|
1404
|
-
type:
|
|
1405
|
-
dataType:
|
|
1406
|
-
selectRect:
|
|
1399
|
+
const A = B(this.oldSelectRect, W);
|
|
1400
|
+
return this.oldSelectRect = W, {
|
|
1401
|
+
type: y.Select,
|
|
1402
|
+
dataType: R.Local,
|
|
1403
|
+
selectRect: W,
|
|
1407
1404
|
renderRect: p,
|
|
1408
|
-
rect: B(A,
|
|
1405
|
+
rect: B(A, W)
|
|
1409
1406
|
};
|
|
1410
1407
|
}
|
|
1411
1408
|
blurSelector() {
|
|
1412
1409
|
const e = this.unSelectedAllIds();
|
|
1413
1410
|
return {
|
|
1414
|
-
type:
|
|
1415
|
-
dataType:
|
|
1411
|
+
type: y.Select,
|
|
1412
|
+
dataType: R.Local,
|
|
1416
1413
|
rect: e,
|
|
1417
1414
|
selectIds: [],
|
|
1418
1415
|
willSyncService: !0
|
|
@@ -1469,16 +1466,16 @@ const Q = class Q extends W {
|
|
|
1469
1466
|
const o = (i = this.workId) == null ? void 0 : i.toString(), s = [e[0] * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[0], e[1] * this.fullLayer.worldScaling[0] + this.fullLayer.worldPosition[1]];
|
|
1470
1467
|
if (this.selectSingleTool(s, o, !0), this.oldSelectRect && !ct(t, this.oldSelectRect))
|
|
1471
1468
|
return {
|
|
1472
|
-
type:
|
|
1473
|
-
dataType:
|
|
1469
|
+
type: y.CursorHover,
|
|
1470
|
+
dataType: R.Local,
|
|
1474
1471
|
rect: B(t, this.oldSelectRect),
|
|
1475
1472
|
selectorColor: this.selectorColor,
|
|
1476
1473
|
willSyncService: !1
|
|
1477
1474
|
};
|
|
1478
1475
|
if ((r = this.selectIds) != null && r.length || (this.oldSelectRect = void 0), t && !this.oldSelectRect)
|
|
1479
1476
|
return this.cursorBlur(), {
|
|
1480
|
-
type:
|
|
1481
|
-
dataType:
|
|
1477
|
+
type: y.CursorHover,
|
|
1478
|
+
dataType: R.Local,
|
|
1482
1479
|
rect: t,
|
|
1483
1480
|
selectorColor: this.selectorColor,
|
|
1484
1481
|
willSyncService: !1
|
|
@@ -1494,8 +1491,8 @@ const Q = class Q extends W {
|
|
|
1494
1491
|
}
|
|
1495
1492
|
};
|
|
1496
1493
|
m(Q, "selectorId", Y), m(Q, "selectorBorderId", "selector-border");
|
|
1497
|
-
let
|
|
1498
|
-
class xt extends
|
|
1494
|
+
let G = Q;
|
|
1495
|
+
class xt extends L {
|
|
1499
1496
|
constructor(e) {
|
|
1500
1497
|
super(e);
|
|
1501
1498
|
m(this, "canRotate", !1);
|
|
@@ -1512,13 +1509,13 @@ class xt extends W {
|
|
|
1512
1509
|
var d;
|
|
1513
1510
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
1514
1511
|
if (!r)
|
|
1515
|
-
return { type:
|
|
1512
|
+
return { type: y.None };
|
|
1516
1513
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
1517
1514
|
if (!l || l < 2)
|
|
1518
|
-
return { type:
|
|
1515
|
+
return { type: y.None };
|
|
1519
1516
|
let h;
|
|
1520
1517
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
1521
|
-
return { type:
|
|
1518
|
+
return { type: y.None };
|
|
1522
1519
|
let p;
|
|
1523
1520
|
if (s || i) {
|
|
1524
1521
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -1527,19 +1524,19 @@ class xt extends W {
|
|
|
1527
1524
|
if (!s) {
|
|
1528
1525
|
const u = Date.now();
|
|
1529
1526
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
1530
|
-
type:
|
|
1531
|
-
dataType:
|
|
1527
|
+
type: y.DrawWork,
|
|
1528
|
+
dataType: R.Local,
|
|
1532
1529
|
workId: r,
|
|
1533
|
-
op: this.tmpPoints.map((
|
|
1530
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
1534
1531
|
isSync: !0,
|
|
1535
1532
|
index: 0
|
|
1536
|
-
}) : { type:
|
|
1533
|
+
}) : { type: y.None };
|
|
1537
1534
|
}
|
|
1538
1535
|
const f = B(p, this.oldRect);
|
|
1539
1536
|
return this.oldRect = p, {
|
|
1540
1537
|
rect: f,
|
|
1541
|
-
type:
|
|
1542
|
-
dataType:
|
|
1538
|
+
type: y.DrawWork,
|
|
1539
|
+
dataType: R.Local,
|
|
1543
1540
|
workId: r
|
|
1544
1541
|
};
|
|
1545
1542
|
}
|
|
@@ -1547,10 +1544,10 @@ class xt extends W {
|
|
|
1547
1544
|
var c, l;
|
|
1548
1545
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
1549
1546
|
if (!o)
|
|
1550
|
-
return { type:
|
|
1547
|
+
return { type: y.None };
|
|
1551
1548
|
if (this.tmpPoints.length < 2)
|
|
1552
1549
|
return {
|
|
1553
|
-
type:
|
|
1550
|
+
type: y.RemoveNode,
|
|
1554
1551
|
removeIds: [o]
|
|
1555
1552
|
};
|
|
1556
1553
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s });
|
|
@@ -1563,11 +1560,11 @@ class xt extends W {
|
|
|
1563
1560
|
toolsType: this.toolsType,
|
|
1564
1561
|
canRotate: this.canRotate,
|
|
1565
1562
|
scaleType: this.scaleType,
|
|
1566
|
-
centerPos:
|
|
1563
|
+
centerPos: L.getCenterPos(i, s)
|
|
1567
1564
|
}), {
|
|
1568
1565
|
rect: i,
|
|
1569
|
-
type:
|
|
1570
|
-
dataType:
|
|
1566
|
+
type: y.FullWork,
|
|
1567
|
+
dataType: R.Local,
|
|
1571
1568
|
workId: o,
|
|
1572
1569
|
ops: a,
|
|
1573
1570
|
isSync: !0,
|
|
@@ -1575,7 +1572,7 @@ class xt extends W {
|
|
|
1575
1572
|
};
|
|
1576
1573
|
}
|
|
1577
1574
|
draw(e) {
|
|
1578
|
-
const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { points: f, rect: d } = this.computDrawPoints(i),
|
|
1575
|
+
const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { points: f, rect: d } = this.computDrawPoints(i), w = {
|
|
1579
1576
|
pos: [
|
|
1580
1577
|
d.x + d.w / 2,
|
|
1581
1578
|
d.y + d.h / 2
|
|
@@ -1590,29 +1587,29 @@ class xt extends W {
|
|
|
1590
1587
|
normalize: !0,
|
|
1591
1588
|
zIndex: r
|
|
1592
1589
|
};
|
|
1593
|
-
a && (
|
|
1594
|
-
const
|
|
1595
|
-
if (this.replace(o, t,
|
|
1596
|
-
const b =
|
|
1590
|
+
a && (w.scale = a), c && (w.rotate = c), l && (w.translate = l);
|
|
1591
|
+
const S = new st(w);
|
|
1592
|
+
if (this.replace(o, t, S), a || c || l) {
|
|
1593
|
+
const b = S.getBoundingClientRect();
|
|
1597
1594
|
return {
|
|
1598
|
-
x: Math.floor(b.x -
|
|
1599
|
-
y: Math.floor(b.y -
|
|
1600
|
-
w: Math.floor(b.width +
|
|
1601
|
-
h: Math.floor(b.height +
|
|
1595
|
+
x: Math.floor(b.x - L.SafeBorderPadding),
|
|
1596
|
+
y: Math.floor(b.y - L.SafeBorderPadding),
|
|
1597
|
+
w: Math.floor(b.width + L.SafeBorderPadding * 2),
|
|
1598
|
+
h: Math.floor(b.height + L.SafeBorderPadding * 2)
|
|
1602
1599
|
};
|
|
1603
1600
|
}
|
|
1604
1601
|
return {
|
|
1605
|
-
x: Math.floor(d.x * p[0] + h[0] -
|
|
1606
|
-
y: Math.floor(d.y * p[1] + h[1] -
|
|
1607
|
-
w: Math.floor(d.w * p[0] + 2 *
|
|
1608
|
-
h: Math.floor(d.h * p[1] + 2 *
|
|
1602
|
+
x: Math.floor(d.x * p[0] + h[0] - L.SafeBorderPadding),
|
|
1603
|
+
y: Math.floor(d.y * p[1] + h[1] - L.SafeBorderPadding),
|
|
1604
|
+
w: Math.floor(d.w * p[0] + 2 * L.SafeBorderPadding),
|
|
1605
|
+
h: Math.floor(d.h * p[1] + 2 * L.SafeBorderPadding)
|
|
1609
1606
|
};
|
|
1610
1607
|
}
|
|
1611
1608
|
computDrawPoints(e) {
|
|
1612
1609
|
return this.tmpPoints[1].distance(this.tmpPoints[0]) > this.arrowTipWidth ? this.computFullArrowPoints(e) : this.computTrianglePoints();
|
|
1613
1610
|
}
|
|
1614
1611
|
computFullArrowPoints(e) {
|
|
1615
|
-
const t =
|
|
1612
|
+
const t = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = k.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = k.Mul(t, this.arrowTipWidth), a = k.Sub(this.tmpPoints[1], r), c = O.Sub(a, o), l = O.Add(a, o), h = k.Per(t).mul(e * 1.5), p = O.Sub(a, h), f = O.Add(a, h), d = [
|
|
1616
1613
|
s,
|
|
1617
1614
|
c,
|
|
1618
1615
|
p,
|
|
@@ -1629,7 +1626,7 @@ class xt extends W {
|
|
|
1629
1626
|
};
|
|
1630
1627
|
}
|
|
1631
1628
|
computTrianglePoints() {
|
|
1632
|
-
const e =
|
|
1629
|
+
const e = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), t = this.tmpPoints[1].distance(this.tmpPoints[0]), o = k.Per(e).mul(Math.floor(t * 3 / 8)), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = [s, this.tmpPoints[1], i];
|
|
1633
1630
|
return {
|
|
1634
1631
|
points: r.map((a) => O.Sub(a, this.tmpPoints[0]).XY).flat(1),
|
|
1635
1632
|
rect: z(r),
|
|
@@ -1665,7 +1662,7 @@ class xt extends W {
|
|
|
1665
1662
|
toolsType: this.toolsType,
|
|
1666
1663
|
canRotate: this.canRotate,
|
|
1667
1664
|
scaleType: this.scaleType,
|
|
1668
|
-
centerPos:
|
|
1665
|
+
centerPos: L.getCenterPos(r, i)
|
|
1669
1666
|
}), r;
|
|
1670
1667
|
}
|
|
1671
1668
|
clearTmpPoints() {
|
|
@@ -1674,10 +1671,10 @@ class xt extends W {
|
|
|
1674
1671
|
static updateNodeOpt(e) {
|
|
1675
1672
|
var a;
|
|
1676
1673
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
|
|
1677
|
-
return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i), r && s.setInfo(t.name, r)),
|
|
1674
|
+
return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i), r && s.setInfo(t.name, r)), L.updateNodeOpt(e);
|
|
1678
1675
|
}
|
|
1679
1676
|
}
|
|
1680
|
-
class bt extends
|
|
1677
|
+
class bt extends L {
|
|
1681
1678
|
constructor(e) {
|
|
1682
1679
|
super(e);
|
|
1683
1680
|
m(this, "canRotate", !1);
|
|
@@ -1693,13 +1690,13 @@ class bt extends W {
|
|
|
1693
1690
|
var d;
|
|
1694
1691
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
1695
1692
|
if (!r)
|
|
1696
|
-
return { type:
|
|
1693
|
+
return { type: y.None };
|
|
1697
1694
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
1698
1695
|
if (!l || l < 2)
|
|
1699
|
-
return { type:
|
|
1696
|
+
return { type: y.None };
|
|
1700
1697
|
let h;
|
|
1701
1698
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
1702
|
-
return { type:
|
|
1699
|
+
return { type: y.None };
|
|
1703
1700
|
let p;
|
|
1704
1701
|
if (s || i) {
|
|
1705
1702
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -1708,19 +1705,19 @@ class bt extends W {
|
|
|
1708
1705
|
if (!s) {
|
|
1709
1706
|
const u = Date.now();
|
|
1710
1707
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
1711
|
-
type:
|
|
1712
|
-
dataType:
|
|
1708
|
+
type: y.DrawWork,
|
|
1709
|
+
dataType: R.Local,
|
|
1713
1710
|
workId: r,
|
|
1714
|
-
op: this.tmpPoints.map((
|
|
1711
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
1715
1712
|
isSync: !0,
|
|
1716
1713
|
index: 0
|
|
1717
|
-
}) : { type:
|
|
1714
|
+
}) : { type: y.None };
|
|
1718
1715
|
}
|
|
1719
1716
|
const f = B(p, this.oldRect);
|
|
1720
1717
|
return this.oldRect = p, {
|
|
1721
1718
|
rect: f,
|
|
1722
|
-
type:
|
|
1723
|
-
dataType:
|
|
1719
|
+
type: y.DrawWork,
|
|
1720
|
+
dataType: R.Local,
|
|
1724
1721
|
workId: r
|
|
1725
1722
|
};
|
|
1726
1723
|
}
|
|
@@ -1728,10 +1725,10 @@ class bt extends W {
|
|
|
1728
1725
|
var c, l;
|
|
1729
1726
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
1730
1727
|
if (!o)
|
|
1731
|
-
return { type:
|
|
1728
|
+
return { type: y.None };
|
|
1732
1729
|
if (this.tmpPoints.length < 2)
|
|
1733
1730
|
return {
|
|
1734
|
-
type:
|
|
1731
|
+
type: y.RemoveNode,
|
|
1735
1732
|
removeIds: [o]
|
|
1736
1733
|
};
|
|
1737
1734
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
|
|
@@ -1744,11 +1741,11 @@ class bt extends W {
|
|
|
1744
1741
|
toolsType: this.toolsType,
|
|
1745
1742
|
canRotate: this.canRotate,
|
|
1746
1743
|
scaleType: this.scaleType,
|
|
1747
|
-
centerPos: i &&
|
|
1744
|
+
centerPos: i && L.getCenterPos(i, s)
|
|
1748
1745
|
}), {
|
|
1749
1746
|
rect: i,
|
|
1750
|
-
type:
|
|
1751
|
-
dataType:
|
|
1747
|
+
type: y.FullWork,
|
|
1748
|
+
dataType: R.Local,
|
|
1752
1749
|
workId: o,
|
|
1753
1750
|
ops: a,
|
|
1754
1751
|
isSync: !0,
|
|
@@ -1756,8 +1753,8 @@ class bt extends W {
|
|
|
1756
1753
|
};
|
|
1757
1754
|
}
|
|
1758
1755
|
draw(e) {
|
|
1759
|
-
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, scale: l, rotate: h, translate: p } = this.workOptions, f = o.worldScaling, { radius: d, rect: u, pos:
|
|
1760
|
-
pos:
|
|
1756
|
+
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, scale: l, rotate: h, translate: p } = this.workOptions, f = o.worldScaling, { radius: d, rect: u, pos: w } = this.computDrawPoints(a), S = {
|
|
1757
|
+
pos: w,
|
|
1761
1758
|
name: t,
|
|
1762
1759
|
id: t,
|
|
1763
1760
|
radius: d,
|
|
@@ -1769,12 +1766,12 @@ class bt extends W {
|
|
|
1769
1766
|
name: t,
|
|
1770
1767
|
id: t,
|
|
1771
1768
|
zIndex: c,
|
|
1772
|
-
pos:
|
|
1769
|
+
pos: w,
|
|
1773
1770
|
anchor: [0.5, 0.5],
|
|
1774
1771
|
size: [u.w, u.h]
|
|
1775
1772
|
};
|
|
1776
1773
|
l && (b.scale = l), h && (b.rotate = h), p && (b.translate = p);
|
|
1777
|
-
const
|
|
1774
|
+
const T = new _(b);
|
|
1778
1775
|
if (s) {
|
|
1779
1776
|
const N = new it({
|
|
1780
1777
|
d: "M-4,0H4M0,-4V4",
|
|
@@ -1784,19 +1781,19 @@ class bt extends W {
|
|
|
1784
1781
|
lineWidth: 1,
|
|
1785
1782
|
scale: [1 / f[0], 1 / f[1]]
|
|
1786
1783
|
});
|
|
1787
|
-
|
|
1784
|
+
T.append(N);
|
|
1788
1785
|
}
|
|
1789
|
-
const g = new
|
|
1790
|
-
...
|
|
1786
|
+
const g = new qt({
|
|
1787
|
+
...S,
|
|
1791
1788
|
pos: [0, 0]
|
|
1792
1789
|
});
|
|
1793
|
-
|
|
1794
|
-
const
|
|
1790
|
+
T.append(g), this.replace(o, t, T);
|
|
1791
|
+
const I = T.getBoundingClientRect();
|
|
1795
1792
|
return {
|
|
1796
|
-
x: Math.floor(
|
|
1797
|
-
y: Math.floor(
|
|
1798
|
-
w: Math.floor(
|
|
1799
|
-
h: Math.floor(
|
|
1793
|
+
x: Math.floor(I.x - L.SafeBorderPadding),
|
|
1794
|
+
y: Math.floor(I.y - L.SafeBorderPadding),
|
|
1795
|
+
w: Math.floor(I.width + L.SafeBorderPadding * 2),
|
|
1796
|
+
h: Math.floor(I.height + L.SafeBorderPadding * 2)
|
|
1800
1797
|
};
|
|
1801
1798
|
}
|
|
1802
1799
|
computDrawPoints(e) {
|
|
@@ -1835,7 +1832,7 @@ class bt extends W {
|
|
|
1835
1832
|
toolsType: this.toolsType,
|
|
1836
1833
|
canRotate: this.canRotate,
|
|
1837
1834
|
scaleType: this.scaleType,
|
|
1838
|
-
centerPos:
|
|
1835
|
+
centerPos: L.getCenterPos(r, i)
|
|
1839
1836
|
}), r;
|
|
1840
1837
|
}
|
|
1841
1838
|
clearTmpPoints() {
|
|
@@ -1845,10 +1842,10 @@ class bt extends W {
|
|
|
1845
1842
|
var l, h;
|
|
1846
1843
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r } = o, a = s.get(t.name);
|
|
1847
1844
|
let c = t;
|
|
1848
|
-
return t.tagName === "GROUP" && (c = t.children[0]), i && (c.setAttribute("strokeColor", i), (l = a == null ? void 0 : a.opt) != null && l.strokeColor && (a.opt.strokeColor = i)), r && (r === "transparent" ? c.setAttribute("fillColor", "rgba(0,0,0,0)") : c.setAttribute("fillColor", r), (h = a == null ? void 0 : a.opt) != null && h.fillColor && (a.opt.fillColor = r)), a && s.setInfo(t.name, a),
|
|
1845
|
+
return t.tagName === "GROUP" && (c = t.children[0]), i && (c.setAttribute("strokeColor", i), (l = a == null ? void 0 : a.opt) != null && l.strokeColor && (a.opt.strokeColor = i)), r && (r === "transparent" ? c.setAttribute("fillColor", "rgba(0,0,0,0)") : c.setAttribute("fillColor", r), (h = a == null ? void 0 : a.opt) != null && h.fillColor && (a.opt.fillColor = r)), a && s.setInfo(t.name, a), L.updateNodeOpt(e);
|
|
1849
1846
|
}
|
|
1850
1847
|
}
|
|
1851
|
-
class Rt extends
|
|
1848
|
+
class Rt extends L {
|
|
1852
1849
|
constructor(e) {
|
|
1853
1850
|
super(e);
|
|
1854
1851
|
m(this, "canRotate", !0);
|
|
@@ -1872,7 +1869,7 @@ class Rt extends W {
|
|
|
1872
1869
|
computDrawPoints(e) {
|
|
1873
1870
|
const { thickness: t } = this.workOptions, o = [];
|
|
1874
1871
|
for (const r of e)
|
|
1875
|
-
o.push(new
|
|
1872
|
+
o.push(new k(...r));
|
|
1876
1873
|
const s = z(o, t), i = [s.x + s.w / 2, s.y + s.h / 2];
|
|
1877
1874
|
return {
|
|
1878
1875
|
rect: s,
|
|
@@ -1884,35 +1881,35 @@ class Rt extends W {
|
|
|
1884
1881
|
var u;
|
|
1885
1882
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (u = t == null ? void 0 : t.workId) == null ? void 0 : u.toString();
|
|
1886
1883
|
if (!r)
|
|
1887
|
-
return { type:
|
|
1884
|
+
return { type: y.None };
|
|
1888
1885
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
1889
1886
|
if (!l || l < 2)
|
|
1890
|
-
return { type:
|
|
1887
|
+
return { type: y.None };
|
|
1891
1888
|
let h;
|
|
1892
1889
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
1893
|
-
return { type:
|
|
1890
|
+
return { type: y.None };
|
|
1894
1891
|
const p = this.transformData();
|
|
1895
1892
|
let f;
|
|
1896
1893
|
if (s || i) {
|
|
1897
|
-
const
|
|
1898
|
-
f = this.draw({ ps: p, workId: r, layer:
|
|
1894
|
+
const w = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
1895
|
+
f = this.draw({ ps: p, workId: r, layer: w, isDrawing: !0 });
|
|
1899
1896
|
}
|
|
1900
1897
|
if (!s) {
|
|
1901
|
-
const
|
|
1902
|
-
return
|
|
1903
|
-
type:
|
|
1904
|
-
dataType:
|
|
1898
|
+
const w = Date.now();
|
|
1899
|
+
return w - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = w, {
|
|
1900
|
+
type: y.DrawWork,
|
|
1901
|
+
dataType: R.Local,
|
|
1905
1902
|
workId: r,
|
|
1906
1903
|
op: p.flat(1),
|
|
1907
1904
|
isSync: !0,
|
|
1908
1905
|
index: 0
|
|
1909
|
-
}) : { type:
|
|
1906
|
+
}) : { type: y.None };
|
|
1910
1907
|
}
|
|
1911
1908
|
const d = B(f, this.oldRect);
|
|
1912
1909
|
return this.oldRect = f, {
|
|
1913
1910
|
rect: d,
|
|
1914
|
-
type:
|
|
1915
|
-
dataType:
|
|
1911
|
+
type: y.DrawWork,
|
|
1912
|
+
dataType: R.Local,
|
|
1916
1913
|
workId: r
|
|
1917
1914
|
};
|
|
1918
1915
|
}
|
|
@@ -1920,10 +1917,10 @@ class Rt extends W {
|
|
|
1920
1917
|
var l, h;
|
|
1921
1918
|
const { data: t } = e, o = (l = t == null ? void 0 : t.workId) == null ? void 0 : l.toString();
|
|
1922
1919
|
if (!o)
|
|
1923
|
-
return { type:
|
|
1920
|
+
return { type: y.None };
|
|
1924
1921
|
if (this.tmpPoints.length < 2)
|
|
1925
1922
|
return {
|
|
1926
|
-
type:
|
|
1923
|
+
type: y.RemoveNode,
|
|
1927
1924
|
removeIds: [o]
|
|
1928
1925
|
};
|
|
1929
1926
|
const s = this.transformData(), i = this.fullLayer, r = this.draw({ ps: s, workId: o, layer: i, isDrawing: !1 });
|
|
@@ -1936,11 +1933,11 @@ class Rt extends W {
|
|
|
1936
1933
|
toolsType: this.toolsType,
|
|
1937
1934
|
scaleType: this.scaleType,
|
|
1938
1935
|
canRotate: this.canRotate,
|
|
1939
|
-
centerPos: r &&
|
|
1936
|
+
centerPos: r && L.getCenterPos(r, i)
|
|
1940
1937
|
}), {
|
|
1941
1938
|
rect: r,
|
|
1942
|
-
type:
|
|
1943
|
-
dataType:
|
|
1939
|
+
type: y.FullWork,
|
|
1940
|
+
dataType: R.Local,
|
|
1944
1941
|
workId: o,
|
|
1945
1942
|
ops: c,
|
|
1946
1943
|
opt: this.workOptions,
|
|
@@ -1948,7 +1945,7 @@ class Rt extends W {
|
|
|
1948
1945
|
};
|
|
1949
1946
|
}
|
|
1950
1947
|
draw(e) {
|
|
1951
|
-
const { workId: t, layer: o, isDrawing: s, ps: i, replaceId: r } = e, { strokeColor: a, fillColor: c, thickness: l, zIndex: h, scale: p, rotate: f, translate: d, textOpt: u } = this.workOptions,
|
|
1948
|
+
const { workId: t, layer: o, isDrawing: s, ps: i, replaceId: r } = e, { strokeColor: a, fillColor: c, thickness: l, zIndex: h, scale: p, rotate: f, translate: d, textOpt: u } = this.workOptions, w = o.worldPosition, S = o.worldScaling, { points: b, rect: T, pos: g } = this.computDrawPoints(i), I = {
|
|
1952
1949
|
close: !0,
|
|
1953
1950
|
normalize: !0,
|
|
1954
1951
|
points: b,
|
|
@@ -1957,45 +1954,45 @@ class Rt extends W {
|
|
|
1957
1954
|
strokeColor: a,
|
|
1958
1955
|
lineJoin: "round"
|
|
1959
1956
|
}, N = {
|
|
1960
|
-
x: Math.floor(
|
|
1961
|
-
y: Math.floor(
|
|
1962
|
-
w: Math.floor(
|
|
1963
|
-
h: Math.floor(
|
|
1964
|
-
},
|
|
1957
|
+
x: Math.floor(T.x * S[0] + w[0] - L.SafeBorderPadding),
|
|
1958
|
+
y: Math.floor(T.y * S[1] + w[1] - L.SafeBorderPadding),
|
|
1959
|
+
w: Math.floor(T.w * S[0] + 2 * L.SafeBorderPadding),
|
|
1960
|
+
h: Math.floor(T.h * S[0] + 2 * L.SafeBorderPadding)
|
|
1961
|
+
}, W = new _({
|
|
1965
1962
|
name: t,
|
|
1966
1963
|
id: t,
|
|
1967
1964
|
zIndex: h,
|
|
1968
1965
|
pos: g,
|
|
1969
1966
|
anchor: [0.5, 0.5],
|
|
1970
1967
|
size: [
|
|
1971
|
-
|
|
1972
|
-
|
|
1968
|
+
T.w,
|
|
1969
|
+
T.h
|
|
1973
1970
|
],
|
|
1974
1971
|
scale: p,
|
|
1975
1972
|
rotate: f,
|
|
1976
1973
|
translate: d
|
|
1977
1974
|
}), A = new st({
|
|
1978
|
-
...
|
|
1975
|
+
...I,
|
|
1979
1976
|
pos: [0, 0]
|
|
1980
1977
|
});
|
|
1981
|
-
if (
|
|
1982
|
-
const
|
|
1978
|
+
if (W.appendChild(A), s) {
|
|
1979
|
+
const v = new it({
|
|
1983
1980
|
d: "M-4,0H4M0,-4V4",
|
|
1984
1981
|
normalize: !0,
|
|
1985
1982
|
pos: [0, 0],
|
|
1986
1983
|
strokeColor: a,
|
|
1987
1984
|
lineWidth: 1,
|
|
1988
|
-
scale: [1 /
|
|
1985
|
+
scale: [1 / S[0], 1 / S[1]]
|
|
1989
1986
|
});
|
|
1990
|
-
|
|
1987
|
+
W.appendChild(v);
|
|
1991
1988
|
}
|
|
1992
|
-
if (this.replace(o, r || t,
|
|
1993
|
-
const
|
|
1989
|
+
if (this.replace(o, r || t, W), p || f || d) {
|
|
1990
|
+
const v = W.getBoundingClientRect();
|
|
1994
1991
|
return {
|
|
1995
|
-
x: Math.floor(
|
|
1996
|
-
y: Math.floor(
|
|
1997
|
-
w: Math.floor(
|
|
1998
|
-
h: Math.floor(
|
|
1992
|
+
x: Math.floor(v.x - L.SafeBorderPadding),
|
|
1993
|
+
y: Math.floor(v.y - L.SafeBorderPadding),
|
|
1994
|
+
w: Math.floor(v.width + 2 * L.SafeBorderPadding),
|
|
1995
|
+
h: Math.floor(v.height + 2 * L.SafeBorderPadding)
|
|
1999
1996
|
};
|
|
2000
1997
|
}
|
|
2001
1998
|
return N;
|
|
@@ -2028,14 +2025,14 @@ class Rt extends W {
|
|
|
2028
2025
|
toolsType: this.toolsType,
|
|
2029
2026
|
scaleType: this.scaleType,
|
|
2030
2027
|
canRotate: this.canRotate,
|
|
2031
|
-
centerPos: c &&
|
|
2028
|
+
centerPos: c && L.getCenterPos(c, a)
|
|
2032
2029
|
}), c;
|
|
2033
2030
|
}
|
|
2034
2031
|
clearTmpPoints() {
|
|
2035
2032
|
this.tmpPoints.length = 0;
|
|
2036
2033
|
}
|
|
2037
2034
|
static updateNodeOpt(e) {
|
|
2038
|
-
var
|
|
2035
|
+
var S, b;
|
|
2039
2036
|
const { node: t, opt: o, vNodes: s } = e, {
|
|
2040
2037
|
strokeColor: i,
|
|
2041
2038
|
fillColor: r,
|
|
@@ -2047,15 +2044,15 @@ class Rt extends W {
|
|
|
2047
2044
|
underline: f,
|
|
2048
2045
|
fontSize: d
|
|
2049
2046
|
} = o, u = s.get(t.name);
|
|
2050
|
-
let
|
|
2051
|
-
if (t.tagName === "GROUP" && (
|
|
2052
|
-
const
|
|
2053
|
-
a &&
|
|
2047
|
+
let w = t;
|
|
2048
|
+
if (t.tagName === "GROUP" && (w = t.children[0]), i && (w.setAttribute("strokeColor", i), (S = u == null ? void 0 : u.opt) != null && S.strokeColor && (u.opt.strokeColor = i)), r && (r === "transparent" ? w.setAttribute("fillColor", "rgba(0,0,0,0)") : w.setAttribute("fillColor", r), (b = u == null ? void 0 : u.opt) != null && b.fillColor && (u.opt.fillColor = r)), u != null && u.opt.textOpt) {
|
|
2049
|
+
const T = u.opt.textOpt;
|
|
2050
|
+
a && T.fontColor && (T.fontColor = a), c && T.fontBgColor && (T.fontBgColor = c), l && (T.bold = l), h && (T.italic = h), ot(p) && (T.lineThrough = p), ot(f) && (T.underline = f), d && (T.fontSize = d);
|
|
2054
2051
|
}
|
|
2055
|
-
return u && s.setInfo(t.name, u),
|
|
2052
|
+
return u && s.setInfo(t.name, u), L.updateNodeOpt(e);
|
|
2056
2053
|
}
|
|
2057
2054
|
}
|
|
2058
|
-
class Ct extends
|
|
2055
|
+
class Ct extends L {
|
|
2059
2056
|
constructor(e) {
|
|
2060
2057
|
super(e);
|
|
2061
2058
|
m(this, "canRotate", !1);
|
|
@@ -2071,13 +2068,13 @@ class Ct extends W {
|
|
|
2071
2068
|
var d;
|
|
2072
2069
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
2073
2070
|
if (!r)
|
|
2074
|
-
return { type:
|
|
2071
|
+
return { type: y.None };
|
|
2075
2072
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
2076
2073
|
if (!l || l < 2)
|
|
2077
|
-
return { type:
|
|
2074
|
+
return { type: y.None };
|
|
2078
2075
|
let h;
|
|
2079
2076
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
2080
|
-
return { type:
|
|
2077
|
+
return { type: y.None };
|
|
2081
2078
|
let p;
|
|
2082
2079
|
if (s || i) {
|
|
2083
2080
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -2086,19 +2083,19 @@ class Ct extends W {
|
|
|
2086
2083
|
if (!s) {
|
|
2087
2084
|
const u = Date.now();
|
|
2088
2085
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
2089
|
-
type:
|
|
2090
|
-
dataType:
|
|
2086
|
+
type: y.DrawWork,
|
|
2087
|
+
dataType: R.Local,
|
|
2091
2088
|
workId: r,
|
|
2092
|
-
op: this.tmpPoints.map((
|
|
2089
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
2093
2090
|
isSync: !0,
|
|
2094
2091
|
index: 0
|
|
2095
|
-
}) : { type:
|
|
2092
|
+
}) : { type: y.None };
|
|
2096
2093
|
}
|
|
2097
2094
|
const f = B(p, this.oldRect);
|
|
2098
2095
|
return this.oldRect = p, {
|
|
2099
2096
|
rect: f,
|
|
2100
|
-
type:
|
|
2101
|
-
dataType:
|
|
2097
|
+
type: y.DrawWork,
|
|
2098
|
+
dataType: R.Local,
|
|
2102
2099
|
workId: r
|
|
2103
2100
|
// op: this.tmpPoints.map(c=>[...c.XY,0]).flat(1)
|
|
2104
2101
|
};
|
|
@@ -2107,10 +2104,10 @@ class Ct extends W {
|
|
|
2107
2104
|
var c, l;
|
|
2108
2105
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
2109
2106
|
if (!o)
|
|
2110
|
-
return { type:
|
|
2107
|
+
return { type: y.None };
|
|
2111
2108
|
if (this.tmpPoints.length < 2)
|
|
2112
2109
|
return {
|
|
2113
|
-
type:
|
|
2110
|
+
type: y.RemoveNode,
|
|
2114
2111
|
removeIds: [o]
|
|
2115
2112
|
};
|
|
2116
2113
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
|
|
@@ -2123,11 +2120,11 @@ class Ct extends W {
|
|
|
2123
2120
|
toolsType: this.toolsType,
|
|
2124
2121
|
scaleType: this.scaleType,
|
|
2125
2122
|
canRotate: this.canRotate,
|
|
2126
|
-
centerPos: i &&
|
|
2123
|
+
centerPos: i && L.getCenterPos(i, s)
|
|
2127
2124
|
}), {
|
|
2128
2125
|
rect: i,
|
|
2129
|
-
type:
|
|
2130
|
-
dataType:
|
|
2126
|
+
type: y.FullWork,
|
|
2127
|
+
dataType: R.Local,
|
|
2131
2128
|
workId: o,
|
|
2132
2129
|
ops: a,
|
|
2133
2130
|
isSync: !0,
|
|
@@ -2135,55 +2132,55 @@ class Ct extends W {
|
|
|
2135
2132
|
};
|
|
2136
2133
|
}
|
|
2137
2134
|
draw(e) {
|
|
2138
|
-
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, innerVerticeStep: h, innerRatio: p, scale: f, rotate: d, translate: u } = this.workOptions,
|
|
2135
|
+
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, innerVerticeStep: h, innerRatio: p, scale: f, rotate: d, translate: u } = this.workOptions, w = o.worldScaling, { rect: S, pos: b, points: T } = this.computDrawPoints(a, l, h, p), g = {
|
|
2139
2136
|
close: !0,
|
|
2140
|
-
points:
|
|
2137
|
+
points: T,
|
|
2141
2138
|
lineWidth: a,
|
|
2142
2139
|
fillColor: r !== "transparent" && r || void 0,
|
|
2143
2140
|
strokeColor: i,
|
|
2144
2141
|
normalize: !0,
|
|
2145
2142
|
lineJoin: "round"
|
|
2146
|
-
},
|
|
2143
|
+
}, I = {
|
|
2147
2144
|
name: t,
|
|
2148
2145
|
id: t,
|
|
2149
2146
|
zIndex: c,
|
|
2150
2147
|
pos: b,
|
|
2151
2148
|
anchor: [0.5, 0.5],
|
|
2152
|
-
size: [
|
|
2149
|
+
size: [S.w, S.h],
|
|
2153
2150
|
className: `${b[0]},${b[1]}`
|
|
2154
2151
|
};
|
|
2155
|
-
f && (
|
|
2156
|
-
const N = new _(
|
|
2152
|
+
f && (I.scale = f), d && (I.rotate = d), u && (I.translate = u);
|
|
2153
|
+
const N = new _(I);
|
|
2157
2154
|
if (s) {
|
|
2158
|
-
const
|
|
2155
|
+
const v = new it({
|
|
2159
2156
|
d: "M-4,0H4M0,-4V4",
|
|
2160
2157
|
normalize: !0,
|
|
2161
2158
|
pos: [0, 0],
|
|
2162
2159
|
strokeColor: i,
|
|
2163
2160
|
lineWidth: 1,
|
|
2164
|
-
scale: [1 /
|
|
2161
|
+
scale: [1 / w[0], 1 / w[1]]
|
|
2165
2162
|
});
|
|
2166
|
-
N.append(
|
|
2163
|
+
N.append(v);
|
|
2167
2164
|
}
|
|
2168
|
-
const
|
|
2165
|
+
const W = new st({
|
|
2169
2166
|
...g,
|
|
2170
2167
|
pos: [0, 0]
|
|
2171
2168
|
});
|
|
2172
|
-
N.append(
|
|
2169
|
+
N.append(W), this.replace(o, t, N);
|
|
2173
2170
|
const A = N.getBoundingClientRect();
|
|
2174
2171
|
return {
|
|
2175
|
-
x: Math.floor(A.x -
|
|
2176
|
-
y: Math.floor(A.y -
|
|
2177
|
-
w: Math.floor(A.width +
|
|
2178
|
-
h: Math.floor(A.height +
|
|
2172
|
+
x: Math.floor(A.x - L.SafeBorderPadding),
|
|
2173
|
+
y: Math.floor(A.y - L.SafeBorderPadding),
|
|
2174
|
+
w: Math.floor(A.width + L.SafeBorderPadding * 2),
|
|
2175
|
+
h: Math.floor(A.height + L.SafeBorderPadding * 2)
|
|
2179
2176
|
};
|
|
2180
2177
|
}
|
|
2181
2178
|
computDrawPoints(e, t, o, s) {
|
|
2182
2179
|
const i = z(this.tmpPoints), r = [Math.floor(i.x + i.w / 2), Math.floor(i.y + i.h / 2)], a = vt(i.w, i.h), c = Math.floor(Math.min(i.w, i.h) / 2), l = s * c, h = [], p = 2 * Math.PI / t;
|
|
2183
2180
|
for (let d = 0; d < t; d++) {
|
|
2184
2181
|
const u = d * p - 0.5 * Math.PI;
|
|
2185
|
-
let
|
|
2186
|
-
d % o === 1 ? (
|
|
2182
|
+
let w, S;
|
|
2183
|
+
d % o === 1 ? (w = l * a[0] * Math.cos(u), S = l * a[1] * Math.sin(u)) : (w = c * a[0] * Math.cos(u), S = c * a[1] * Math.sin(u), h.push(w, S)), h.push(w, S);
|
|
2187
2184
|
}
|
|
2188
2185
|
return {
|
|
2189
2186
|
rect: z(this.tmpPoints, e),
|
|
@@ -2219,7 +2216,7 @@ class Ct extends W {
|
|
|
2219
2216
|
toolsType: this.toolsType,
|
|
2220
2217
|
scaleType: this.scaleType,
|
|
2221
2218
|
canRotate: this.canRotate,
|
|
2222
|
-
centerPos: r &&
|
|
2219
|
+
centerPos: r && L.getCenterPos(r, i)
|
|
2223
2220
|
}), r;
|
|
2224
2221
|
}
|
|
2225
2222
|
clearTmpPoints() {
|
|
@@ -2228,10 +2225,10 @@ class Ct extends W {
|
|
|
2228
2225
|
static updateNodeOpt(e) {
|
|
2229
2226
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, vertices: c, innerVerticeStep: l, innerRatio: h } = o, p = s.get(t.name), f = p == null ? void 0 : p.opt;
|
|
2230
2227
|
let d = t;
|
|
2231
|
-
return t.tagName === "GROUP" && (d = t.children[0]), i && (d.setAttribute("strokeColor", i), f != null && f.strokeColor && (f.strokeColor = i)), r && (r === "transparent" ? d.setAttribute("fillColor", "rgba(0,0,0,0)") : d.setAttribute("fillColor", r), f != null && f.fillColor && (f.fillColor = r)), a === P.Star && (c && (f.vertices = c), l && (f.innerVerticeStep = l), h && (f.innerRatio = h)), p && s.setInfo(t.name, { ...p, opt: f }),
|
|
2228
|
+
return t.tagName === "GROUP" && (d = t.children[0]), i && (d.setAttribute("strokeColor", i), f != null && f.strokeColor && (f.strokeColor = i)), r && (r === "transparent" ? d.setAttribute("fillColor", "rgba(0,0,0,0)") : d.setAttribute("fillColor", r), f != null && f.fillColor && (f.fillColor = r)), a === P.Star && (c && (f.vertices = c), l && (f.innerVerticeStep = l), h && (f.innerRatio = h)), p && s.setInfo(t.name, { ...p, opt: f }), L.updateNodeOpt(e);
|
|
2232
2229
|
}
|
|
2233
2230
|
}
|
|
2234
|
-
class Mt extends
|
|
2231
|
+
class Mt extends L {
|
|
2235
2232
|
constructor(e) {
|
|
2236
2233
|
super(e);
|
|
2237
2234
|
m(this, "canRotate", !1);
|
|
@@ -2247,13 +2244,13 @@ class Mt extends W {
|
|
|
2247
2244
|
var d;
|
|
2248
2245
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
2249
2246
|
if (!r)
|
|
2250
|
-
return { type:
|
|
2247
|
+
return { type: y.None };
|
|
2251
2248
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
2252
2249
|
if (!l || l < 2)
|
|
2253
|
-
return { type:
|
|
2250
|
+
return { type: y.None };
|
|
2254
2251
|
let h;
|
|
2255
2252
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
2256
|
-
return { type:
|
|
2253
|
+
return { type: y.None };
|
|
2257
2254
|
let p;
|
|
2258
2255
|
if (s || i) {
|
|
2259
2256
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -2262,19 +2259,19 @@ class Mt extends W {
|
|
|
2262
2259
|
if (!s) {
|
|
2263
2260
|
const u = Date.now();
|
|
2264
2261
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
2265
|
-
type:
|
|
2266
|
-
dataType:
|
|
2262
|
+
type: y.DrawWork,
|
|
2263
|
+
dataType: R.Local,
|
|
2267
2264
|
workId: r,
|
|
2268
|
-
op: this.tmpPoints.map((
|
|
2265
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
2269
2266
|
isSync: !0,
|
|
2270
2267
|
index: 0
|
|
2271
|
-
}) : { type:
|
|
2268
|
+
}) : { type: y.None };
|
|
2272
2269
|
}
|
|
2273
2270
|
const f = B(p, this.oldRect);
|
|
2274
2271
|
return this.oldRect = p, {
|
|
2275
2272
|
rect: f,
|
|
2276
|
-
type:
|
|
2277
|
-
dataType:
|
|
2273
|
+
type: y.DrawWork,
|
|
2274
|
+
dataType: R.Local,
|
|
2278
2275
|
workId: r
|
|
2279
2276
|
};
|
|
2280
2277
|
}
|
|
@@ -2282,10 +2279,10 @@ class Mt extends W {
|
|
|
2282
2279
|
var c, l;
|
|
2283
2280
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
2284
2281
|
if (!o)
|
|
2285
|
-
return { type:
|
|
2282
|
+
return { type: y.None };
|
|
2286
2283
|
if (this.tmpPoints.length < 2)
|
|
2287
2284
|
return {
|
|
2288
|
-
type:
|
|
2285
|
+
type: y.RemoveNode,
|
|
2289
2286
|
removeIds: [o]
|
|
2290
2287
|
};
|
|
2291
2288
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
|
|
@@ -2298,11 +2295,11 @@ class Mt extends W {
|
|
|
2298
2295
|
toolsType: this.toolsType,
|
|
2299
2296
|
scaleType: this.scaleType,
|
|
2300
2297
|
canRotate: this.canRotate,
|
|
2301
|
-
centerPos: i &&
|
|
2298
|
+
centerPos: i && L.getCenterPos(i, s)
|
|
2302
2299
|
}), {
|
|
2303
2300
|
rect: i,
|
|
2304
|
-
type:
|
|
2305
|
-
dataType:
|
|
2301
|
+
type: y.FullWork,
|
|
2302
|
+
dataType: R.Local,
|
|
2306
2303
|
workId: o,
|
|
2307
2304
|
ops: a,
|
|
2308
2305
|
isSync: !0,
|
|
@@ -2310,26 +2307,26 @@ class Mt extends W {
|
|
|
2310
2307
|
};
|
|
2311
2308
|
}
|
|
2312
2309
|
draw(e) {
|
|
2313
|
-
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, scale: h, rotate: p, translate: f } = this.workOptions, d = o.worldScaling, { rect: u, pos:
|
|
2310
|
+
const { workId: t, layer: o, isDrawing: s } = e, { strokeColor: i, fillColor: r, thickness: a, zIndex: c, vertices: l, scale: h, rotate: p, translate: f } = this.workOptions, d = o.worldScaling, { rect: u, pos: w, points: S } = this.computDrawPoints(a, l), b = {
|
|
2314
2311
|
close: !0,
|
|
2315
|
-
points:
|
|
2312
|
+
points: S,
|
|
2316
2313
|
lineWidth: a,
|
|
2317
2314
|
fillColor: r !== "transparent" && r || void 0,
|
|
2318
2315
|
strokeColor: i,
|
|
2319
2316
|
normalize: !0,
|
|
2320
2317
|
lineJoin: "round"
|
|
2321
|
-
},
|
|
2318
|
+
}, T = {
|
|
2322
2319
|
name: t,
|
|
2323
2320
|
id: t,
|
|
2324
2321
|
zIndex: c,
|
|
2325
|
-
pos:
|
|
2322
|
+
pos: w,
|
|
2326
2323
|
anchor: [0.5, 0.5],
|
|
2327
2324
|
size: [u.w, u.h]
|
|
2328
2325
|
};
|
|
2329
|
-
h && (
|
|
2330
|
-
const g = new _(
|
|
2326
|
+
h && (T.scale = h), p && (T.rotate = p), f && (T.translate = f);
|
|
2327
|
+
const g = new _(T);
|
|
2331
2328
|
if (s) {
|
|
2332
|
-
const
|
|
2329
|
+
const W = new it({
|
|
2333
2330
|
d: "M-4,0H4M0,-4V4",
|
|
2334
2331
|
normalize: !0,
|
|
2335
2332
|
pos: [0, 0],
|
|
@@ -2337,19 +2334,19 @@ class Mt extends W {
|
|
|
2337
2334
|
lineWidth: 1,
|
|
2338
2335
|
scale: [1 / d[0], 1 / d[1]]
|
|
2339
2336
|
});
|
|
2340
|
-
g.append(
|
|
2337
|
+
g.append(W);
|
|
2341
2338
|
}
|
|
2342
|
-
const
|
|
2339
|
+
const I = new st({
|
|
2343
2340
|
...b,
|
|
2344
2341
|
pos: [0, 0]
|
|
2345
2342
|
});
|
|
2346
|
-
g.append(
|
|
2343
|
+
g.append(I), this.replace(o, t, g);
|
|
2347
2344
|
const N = g.getBoundingClientRect();
|
|
2348
2345
|
return {
|
|
2349
|
-
x: Math.floor(N.x -
|
|
2350
|
-
y: Math.floor(N.y -
|
|
2351
|
-
w: Math.floor(N.width +
|
|
2352
|
-
h: Math.floor(N.height +
|
|
2346
|
+
x: Math.floor(N.x - L.SafeBorderPadding),
|
|
2347
|
+
y: Math.floor(N.y - L.SafeBorderPadding),
|
|
2348
|
+
w: Math.floor(N.width + L.SafeBorderPadding * 2),
|
|
2349
|
+
h: Math.floor(N.height + L.SafeBorderPadding * 2)
|
|
2353
2350
|
};
|
|
2354
2351
|
}
|
|
2355
2352
|
computDrawPoints(e, t) {
|
|
@@ -2392,7 +2389,7 @@ class Mt extends W {
|
|
|
2392
2389
|
toolsType: this.toolsType,
|
|
2393
2390
|
scaleType: this.scaleType,
|
|
2394
2391
|
canRotate: this.canRotate,
|
|
2395
|
-
centerPos: r &&
|
|
2392
|
+
centerPos: r && L.getCenterPos(r, i)
|
|
2396
2393
|
}), r;
|
|
2397
2394
|
}
|
|
2398
2395
|
clearTmpPoints() {
|
|
@@ -2401,7 +2398,7 @@ class Mt extends W {
|
|
|
2401
2398
|
static updateNodeOpt(e) {
|
|
2402
2399
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, vertices: c } = o, l = s.get(t.name), h = l == null ? void 0 : l.opt;
|
|
2403
2400
|
let p = t;
|
|
2404
|
-
return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.Polygon && c && (h.vertices = c), l && s.setInfo(t.name, { ...l, opt: h }),
|
|
2401
|
+
return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.Polygon && c && (h.vertices = c), l && s.setInfo(t.name, { ...l, opt: h }), L.updateNodeOpt(e);
|
|
2405
2402
|
}
|
|
2406
2403
|
}
|
|
2407
2404
|
class Z {
|
|
@@ -2440,7 +2437,7 @@ class Z {
|
|
|
2440
2437
|
*/
|
|
2441
2438
|
static oneBezier(n, e, t) {
|
|
2442
2439
|
const o = e.x + (t.x - e.x) * n, s = e.y + (t.y - e.y) * n;
|
|
2443
|
-
return new
|
|
2440
|
+
return new k(o, s);
|
|
2444
2441
|
}
|
|
2445
2442
|
/**
|
|
2446
2443
|
* @desc 二阶贝塞尔
|
|
@@ -2451,7 +2448,7 @@ class Z {
|
|
|
2451
2448
|
*/
|
|
2452
2449
|
static twoBezier(n, e, t, o) {
|
|
2453
2450
|
const s = (1 - n) * (1 - n) * e.x + 2 * n * (1 - n) * t.x + n * n * o.x, i = (1 - n) * (1 - n) * e.y + 2 * n * (1 - n) * t.y + n * n * o.y;
|
|
2454
|
-
return new
|
|
2451
|
+
return new k(s, i);
|
|
2455
2452
|
}
|
|
2456
2453
|
/**
|
|
2457
2454
|
* @desc 三阶贝塞尔
|
|
@@ -2463,10 +2460,10 @@ class Z {
|
|
|
2463
2460
|
*/
|
|
2464
2461
|
static threeBezier(n, e, t, o, s) {
|
|
2465
2462
|
const i = e.x * (1 - n) * (1 - n) * (1 - n) + 3 * t.x * n * (1 - n) * (1 - n) + 3 * o.x * n * n * (1 - n) + s.x * n * n * n, r = e.y * (1 - n) * (1 - n) * (1 - n) + 3 * t.y * n * (1 - n) * (1 - n) + 3 * o.y * n * n * (1 - n) + s.y * n * n * n;
|
|
2466
|
-
return new
|
|
2463
|
+
return new k(i, r);
|
|
2467
2464
|
}
|
|
2468
2465
|
}
|
|
2469
|
-
class Ot extends
|
|
2466
|
+
class Ot extends L {
|
|
2470
2467
|
constructor(e) {
|
|
2471
2468
|
super(e);
|
|
2472
2469
|
m(this, "canRotate", !1);
|
|
@@ -2483,13 +2480,13 @@ class Ot extends W {
|
|
|
2483
2480
|
var d;
|
|
2484
2481
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
2485
2482
|
if (!r)
|
|
2486
|
-
return { type:
|
|
2483
|
+
return { type: y.None };
|
|
2487
2484
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
2488
2485
|
if (!l || l < 2)
|
|
2489
|
-
return { type:
|
|
2486
|
+
return { type: y.None };
|
|
2490
2487
|
let h;
|
|
2491
2488
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
2492
|
-
return { type:
|
|
2489
|
+
return { type: y.None };
|
|
2493
2490
|
let p;
|
|
2494
2491
|
if (s || i) {
|
|
2495
2492
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -2498,19 +2495,19 @@ class Ot extends W {
|
|
|
2498
2495
|
if (!s) {
|
|
2499
2496
|
const u = Date.now();
|
|
2500
2497
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
2501
|
-
type:
|
|
2502
|
-
dataType:
|
|
2498
|
+
type: y.DrawWork,
|
|
2499
|
+
dataType: R.Local,
|
|
2503
2500
|
workId: r,
|
|
2504
|
-
op: this.tmpPoints.map((
|
|
2501
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
2505
2502
|
isSync: !0,
|
|
2506
2503
|
index: 0
|
|
2507
|
-
}) : { type:
|
|
2504
|
+
}) : { type: y.None };
|
|
2508
2505
|
}
|
|
2509
2506
|
const f = B(p, this.oldRect);
|
|
2510
2507
|
return this.oldRect = p, {
|
|
2511
2508
|
rect: f,
|
|
2512
|
-
type:
|
|
2513
|
-
dataType:
|
|
2509
|
+
type: y.DrawWork,
|
|
2510
|
+
dataType: R.Local,
|
|
2514
2511
|
workId: r
|
|
2515
2512
|
};
|
|
2516
2513
|
}
|
|
@@ -2518,10 +2515,10 @@ class Ot extends W {
|
|
|
2518
2515
|
var c, l;
|
|
2519
2516
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
2520
2517
|
if (!o)
|
|
2521
|
-
return { type:
|
|
2518
|
+
return { type: y.None };
|
|
2522
2519
|
if (this.tmpPoints.length < 2)
|
|
2523
2520
|
return {
|
|
2524
|
-
type:
|
|
2521
|
+
type: y.RemoveNode,
|
|
2525
2522
|
removeIds: [o]
|
|
2526
2523
|
};
|
|
2527
2524
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s, isDrawing: !1 });
|
|
@@ -2534,11 +2531,11 @@ class Ot extends W {
|
|
|
2534
2531
|
toolsType: this.toolsType,
|
|
2535
2532
|
scaleType: this.scaleType,
|
|
2536
2533
|
canRotate: this.canRotate,
|
|
2537
|
-
centerPos: i &&
|
|
2534
|
+
centerPos: i && L.getCenterPos(i, s)
|
|
2538
2535
|
}), {
|
|
2539
2536
|
rect: i,
|
|
2540
|
-
type:
|
|
2541
|
-
dataType:
|
|
2537
|
+
type: y.FullWork,
|
|
2538
|
+
dataType: R.Local,
|
|
2542
2539
|
workId: o,
|
|
2543
2540
|
ops: a,
|
|
2544
2541
|
isSync: !0,
|
|
@@ -2546,8 +2543,8 @@ class Ot extends W {
|
|
|
2546
2543
|
};
|
|
2547
2544
|
}
|
|
2548
2545
|
draw(e) {
|
|
2549
|
-
const { workId: t, layer: o } = e, { strokeColor: s, fillColor: i, thickness: r, zIndex: a, placement: c, scale: l, rotate: h, translate: p } = this.workOptions, { rect: f, pos: d, points: u } = this.computDrawPoints(r, c),
|
|
2550
|
-
points: u.map((
|
|
2546
|
+
const { workId: t, layer: o } = e, { strokeColor: s, fillColor: i, thickness: r, zIndex: a, placement: c, scale: l, rotate: h, translate: p } = this.workOptions, { rect: f, pos: d, points: u } = this.computDrawPoints(r, c), w = {
|
|
2547
|
+
points: u.map((I) => I.XY),
|
|
2551
2548
|
lineWidth: r,
|
|
2552
2549
|
fillColor: i !== "transparent" && i || void 0,
|
|
2553
2550
|
strokeColor: s,
|
|
@@ -2555,7 +2552,7 @@ class Ot extends W {
|
|
|
2555
2552
|
className: `${d[0]},${d[1]}`,
|
|
2556
2553
|
lineJoin: "round",
|
|
2557
2554
|
close: !0
|
|
2558
|
-
},
|
|
2555
|
+
}, S = {
|
|
2559
2556
|
name: t,
|
|
2560
2557
|
id: t,
|
|
2561
2558
|
zIndex: a,
|
|
@@ -2563,18 +2560,18 @@ class Ot extends W {
|
|
|
2563
2560
|
anchor: [0.5, 0.5],
|
|
2564
2561
|
size: [f.w, f.h]
|
|
2565
2562
|
};
|
|
2566
|
-
l && (
|
|
2567
|
-
const b = new _(
|
|
2568
|
-
...
|
|
2563
|
+
l && (S.scale = l), h && (S.rotate = h), p && (S.translate = p);
|
|
2564
|
+
const b = new _(S), T = new st({
|
|
2565
|
+
...w,
|
|
2569
2566
|
pos: [0, 0]
|
|
2570
2567
|
});
|
|
2571
|
-
b.append(
|
|
2568
|
+
b.append(T), this.replace(o, t, b);
|
|
2572
2569
|
const g = b.getBoundingClientRect();
|
|
2573
2570
|
return {
|
|
2574
|
-
x: Math.floor(g.x -
|
|
2575
|
-
y: Math.floor(g.y -
|
|
2576
|
-
w: Math.floor(g.width +
|
|
2577
|
-
h: Math.floor(g.height +
|
|
2571
|
+
x: Math.floor(g.x - L.SafeBorderPadding),
|
|
2572
|
+
y: Math.floor(g.y - L.SafeBorderPadding),
|
|
2573
|
+
w: Math.floor(g.width + L.SafeBorderPadding * 2),
|
|
2574
|
+
h: Math.floor(g.height + L.SafeBorderPadding * 2)
|
|
2578
2575
|
};
|
|
2579
2576
|
}
|
|
2580
2577
|
transformControlPoints(e) {
|
|
@@ -2585,10 +2582,10 @@ class Ot extends W {
|
|
|
2585
2582
|
case "bottomRight": {
|
|
2586
2583
|
const o = t.y + t.h * this.ratio;
|
|
2587
2584
|
return [
|
|
2588
|
-
new
|
|
2589
|
-
new
|
|
2590
|
-
new
|
|
2591
|
-
new
|
|
2585
|
+
new k(t.x, t.y, 0),
|
|
2586
|
+
new k(t.x + t.w, t.y, 0),
|
|
2587
|
+
new k(t.x + t.w, o, 0),
|
|
2588
|
+
new k(t.x, o, 0)
|
|
2592
2589
|
];
|
|
2593
2590
|
}
|
|
2594
2591
|
case "top":
|
|
@@ -2596,10 +2593,10 @@ class Ot extends W {
|
|
|
2596
2593
|
case "topRight": {
|
|
2597
2594
|
const o = t.y + t.h * (1 - this.ratio);
|
|
2598
2595
|
return [
|
|
2599
|
-
new
|
|
2600
|
-
new
|
|
2601
|
-
new
|
|
2602
|
-
new
|
|
2596
|
+
new k(t.x, o, 0),
|
|
2597
|
+
new k(t.x + t.w, o, 0),
|
|
2598
|
+
new k(t.x + t.w, t.y + t.h, 0),
|
|
2599
|
+
new k(t.x, t.y + t.h, 0)
|
|
2603
2600
|
];
|
|
2604
2601
|
}
|
|
2605
2602
|
case "left":
|
|
@@ -2607,10 +2604,10 @@ class Ot extends W {
|
|
|
2607
2604
|
case "leftTop": {
|
|
2608
2605
|
const o = t.x + t.w * (1 - this.ratio);
|
|
2609
2606
|
return [
|
|
2610
|
-
new
|
|
2611
|
-
new
|
|
2612
|
-
new
|
|
2613
|
-
new
|
|
2607
|
+
new k(o, t.y, 0),
|
|
2608
|
+
new k(t.x + t.w, t.y, 0),
|
|
2609
|
+
new k(t.x + t.w, t.y + t.h, 0),
|
|
2610
|
+
new k(o, t.y + t.h, 0)
|
|
2614
2611
|
];
|
|
2615
2612
|
}
|
|
2616
2613
|
case "right":
|
|
@@ -2618,81 +2615,81 @@ class Ot extends W {
|
|
|
2618
2615
|
case "rightTop": {
|
|
2619
2616
|
const o = t.x + t.w * this.ratio;
|
|
2620
2617
|
return [
|
|
2621
|
-
new
|
|
2622
|
-
new
|
|
2623
|
-
new
|
|
2624
|
-
new
|
|
2618
|
+
new k(t.x, t.y, 0),
|
|
2619
|
+
new k(o, t.y, 0),
|
|
2620
|
+
new k(o, t.y + t.h, 0),
|
|
2621
|
+
new k(t.x, t.y + t.h, 0)
|
|
2625
2622
|
];
|
|
2626
2623
|
}
|
|
2627
2624
|
}
|
|
2628
2625
|
}
|
|
2629
2626
|
computDrawPoints(e, t) {
|
|
2630
|
-
const o = z(this.tmpPoints), s = this.transformControlPoints(t), i = Math.floor(o.w * 0.1), r = Math.floor(o.h * 0.1), a = [], c =
|
|
2627
|
+
const o = z(this.tmpPoints), s = this.transformControlPoints(t), i = Math.floor(o.w * 0.1), r = Math.floor(o.h * 0.1), a = [], c = k.Add(s[0], new k(0, r, 0)), l = k.Add(s[0], new k(i, 0, 0)), h = Z.getBezierPoints(10, c, s[0], l), p = k.Sub(s[1], new k(i, 0, 0)), f = k.Add(s[1], new k(0, r, 0)), d = Z.getBezierPoints(10, p, s[1], f), u = k.Sub(s[2], new k(0, r, 0)), w = k.Sub(s[2], new k(i, 0, 0)), S = Z.getBezierPoints(10, u, s[2], w), b = k.Add(s[3], new k(i, 0, 0)), T = k.Sub(s[3], new k(0, r, 0)), g = Z.getBezierPoints(10, b, s[3], T), I = i * (1 - this.ratio) * 10, N = r * (1 - this.ratio) * 10;
|
|
2631
2628
|
switch (t) {
|
|
2632
2629
|
case "bottom": {
|
|
2633
|
-
const
|
|
2634
|
-
a.push(x, M, ...g, ...h, ...d, ...
|
|
2630
|
+
const v = k.Sub(s[2], new k(i * 5 - I / 2, 0, 0)), x = k.Sub(s[2], new k(i * 5, -N, 0)), M = k.Sub(s[2], new k(i * 5 + I / 2, 0, 0));
|
|
2631
|
+
a.push(x, M, ...g, ...h, ...d, ...S, v);
|
|
2635
2632
|
break;
|
|
2636
2633
|
}
|
|
2637
2634
|
case "bottomRight": {
|
|
2638
|
-
const
|
|
2639
|
-
a.push(x, M, ...g, ...h, ...d, ...
|
|
2635
|
+
const v = k.Sub(s[2], new k(i * 1.1, 0, 0)), x = k.Sub(s[2], new k(i * 1.1 + I / 2, -N, 0)), M = k.Sub(s[2], new k(i * 1.1 + I, 0, 0));
|
|
2636
|
+
a.push(x, M, ...g, ...h, ...d, ...S, v);
|
|
2640
2637
|
break;
|
|
2641
2638
|
}
|
|
2642
2639
|
case "bottomLeft": {
|
|
2643
|
-
const
|
|
2644
|
-
a.push(x, M, ...g, ...h, ...d, ...
|
|
2640
|
+
const v = k.Add(s[3], new k(i * 1.1 + I, 0, 0)), x = k.Add(s[3], new k(i * 1.1 + I / 2, N, 0)), M = k.Add(s[3], new k(i * 1.1, 0, 0));
|
|
2641
|
+
a.push(x, M, ...g, ...h, ...d, ...S, v);
|
|
2645
2642
|
break;
|
|
2646
2643
|
}
|
|
2647
2644
|
case "top": {
|
|
2648
|
-
const
|
|
2649
|
-
a.push(x,
|
|
2645
|
+
const v = k.Sub(s[1], new k(i * 5 - I / 2, 0, 0)), x = k.Sub(s[1], new k(i * 5, N, 0)), M = k.Sub(s[1], new k(i * 5 + I / 2, 0, 0));
|
|
2646
|
+
a.push(x, v, ...d, ...S, ...g, ...h, M);
|
|
2650
2647
|
break;
|
|
2651
2648
|
}
|
|
2652
2649
|
case "topRight": {
|
|
2653
|
-
const
|
|
2654
|
-
a.push(x,
|
|
2650
|
+
const v = k.Sub(s[1], new k(i * 1.1, 0, 0)), x = k.Sub(s[1], new k(i * 1.1 + I / 2, N, 0)), M = k.Sub(s[1], new k(i * 1.1 + I, 0, 0));
|
|
2651
|
+
a.push(x, v, ...d, ...S, ...g, ...h, M);
|
|
2655
2652
|
break;
|
|
2656
2653
|
}
|
|
2657
2654
|
case "topLeft": {
|
|
2658
|
-
const
|
|
2659
|
-
a.push(x,
|
|
2655
|
+
const v = k.Add(s[0], new k(i * 1.1 + I, 0, 0)), x = k.Add(s[0], new k(i * 1.1 + I / 2, -N, 0)), M = k.Add(s[0], new k(i * 1.1, 0, 0));
|
|
2656
|
+
a.push(x, v, ...d, ...S, ...g, ...h, M);
|
|
2660
2657
|
break;
|
|
2661
2658
|
}
|
|
2662
2659
|
case "left": {
|
|
2663
|
-
const
|
|
2664
|
-
a.push(x,
|
|
2660
|
+
const v = k.Add(s[0], new k(0, r * 5 - N / 2, 0)), x = k.Add(s[0], new k(-I, r * 5, 0)), M = k.Add(s[0], new k(0, r * 5 + N / 2, 0));
|
|
2661
|
+
a.push(x, v, ...h, ...d, ...S, ...g, M);
|
|
2665
2662
|
break;
|
|
2666
2663
|
}
|
|
2667
2664
|
case "leftTop": {
|
|
2668
|
-
const
|
|
2669
|
-
a.push(x,
|
|
2665
|
+
const v = k.Add(s[0], new k(0, r * 1.1, 0)), x = k.Add(s[0], new k(-I, r * 1.1 + N / 2, 0)), M = k.Add(s[0], new k(0, r * 1.1 + N, 0));
|
|
2666
|
+
a.push(x, v, ...h, ...d, ...S, ...g, M);
|
|
2670
2667
|
break;
|
|
2671
2668
|
}
|
|
2672
2669
|
case "leftBottom": {
|
|
2673
|
-
const
|
|
2674
|
-
a.push(x,
|
|
2670
|
+
const v = k.Sub(s[3], new k(0, r * 1.1 + N, 0)), x = k.Sub(s[3], new k(I, r * 1.1 + N / 2, 0)), M = k.Sub(s[3], new k(0, r * 1.1, 0));
|
|
2671
|
+
a.push(x, v, ...h, ...d, ...S, ...g, M);
|
|
2675
2672
|
break;
|
|
2676
2673
|
}
|
|
2677
2674
|
case "right": {
|
|
2678
|
-
const
|
|
2679
|
-
a.push(x, M, ...
|
|
2675
|
+
const v = k.Add(s[1], new k(0, r * 5 - N / 2, 0)), x = k.Add(s[1], new k(I, r * 5, 0)), M = k.Add(s[1], new k(0, r * 5 + N / 2, 0));
|
|
2676
|
+
a.push(x, M, ...S, ...g, ...h, ...d, v);
|
|
2680
2677
|
break;
|
|
2681
2678
|
}
|
|
2682
2679
|
case "rightTop": {
|
|
2683
|
-
const
|
|
2684
|
-
a.push(x, M, ...
|
|
2680
|
+
const v = k.Add(s[1], new k(0, r * 1.1, 0)), x = k.Add(s[1], new k(I, r * 1.1 + N / 2, 0)), M = k.Add(s[1], new k(0, r * 1.1 + N, 0));
|
|
2681
|
+
a.push(x, M, ...S, ...g, ...h, ...d, v);
|
|
2685
2682
|
break;
|
|
2686
2683
|
}
|
|
2687
2684
|
case "rightBottom": {
|
|
2688
|
-
const
|
|
2689
|
-
a.push(x, M, ...
|
|
2685
|
+
const v = k.Sub(s[2], new k(0, r * 1.1 + N, 0)), x = k.Sub(s[2], new k(-I, r * 1.1 + N / 2, 0)), M = k.Sub(s[2], new k(0, r * 1.1, 0));
|
|
2686
|
+
a.push(x, M, ...S, ...g, ...h, ...d, v);
|
|
2690
2687
|
break;
|
|
2691
2688
|
}
|
|
2692
2689
|
}
|
|
2693
|
-
const
|
|
2690
|
+
const W = z(this.tmpPoints, e), A = [Math.floor(W.x + W.w / 2), Math.floor(W.y + W.h / 2)];
|
|
2694
2691
|
return {
|
|
2695
|
-
rect:
|
|
2692
|
+
rect: W,
|
|
2696
2693
|
pos: A,
|
|
2697
2694
|
points: a
|
|
2698
2695
|
};
|
|
@@ -2725,7 +2722,7 @@ class Ot extends W {
|
|
|
2725
2722
|
toolsType: this.toolsType,
|
|
2726
2723
|
scaleType: this.scaleType,
|
|
2727
2724
|
canRotate: this.canRotate,
|
|
2728
|
-
centerPos: r &&
|
|
2725
|
+
centerPos: r && L.getCenterPos(r, i)
|
|
2729
2726
|
}), r;
|
|
2730
2727
|
}
|
|
2731
2728
|
clearTmpPoints() {
|
|
@@ -2734,10 +2731,10 @@ class Ot extends W {
|
|
|
2734
2731
|
static updateNodeOpt(e) {
|
|
2735
2732
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i, fillColor: r, toolsType: a, placement: c } = o, l = s.get(t.name), h = l == null ? void 0 : l.opt;
|
|
2736
2733
|
let p = t;
|
|
2737
|
-
return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.SpeechBalloon && c && (h.placement = c), l && s.setInfo(t.name, { ...l, opt: h }),
|
|
2734
|
+
return t.tagName === "GROUP" && (p = t.children[0]), i && (p.setAttribute("strokeColor", i), h != null && h.strokeColor && (h.strokeColor = i)), r && (r === "transparent" ? p.setAttribute("fillColor", "rgba(0,0,0,0)") : p.setAttribute("fillColor", r), h != null && h.fillColor && (h.fillColor = r)), a === P.SpeechBalloon && c && (h.placement = c), l && s.setInfo(t.name, { ...l, opt: h }), L.updateNodeOpt(e);
|
|
2738
2735
|
}
|
|
2739
2736
|
}
|
|
2740
|
-
class ut extends
|
|
2737
|
+
class ut extends L {
|
|
2741
2738
|
constructor(e) {
|
|
2742
2739
|
super(e);
|
|
2743
2740
|
m(this, "canRotate", !0);
|
|
@@ -2749,29 +2746,30 @@ class ut extends W {
|
|
|
2749
2746
|
this.workOptions = e.toolsOpt, this.scaleType = ut.getScaleType(this.workOptions);
|
|
2750
2747
|
}
|
|
2751
2748
|
consume() {
|
|
2752
|
-
return { type:
|
|
2749
|
+
return { type: y.None };
|
|
2753
2750
|
}
|
|
2754
2751
|
consumeAll() {
|
|
2755
|
-
return { type:
|
|
2752
|
+
return { type: y.None };
|
|
2756
2753
|
}
|
|
2757
2754
|
draw(e) {
|
|
2758
|
-
const { layer: t, workId: o, replaceId: s, imageBitmap: i, isMainThread: r } = e, { centerX: a, centerY: c, width: l, height: h, rotate: p, zIndex: f } = this.workOptions, d = {
|
|
2755
|
+
const { layer: t, workId: o, replaceId: s, imageBitmap: i, isMainThread: r } = e, { centerX: a, centerY: c, width: l, height: h, rotate: p, zIndex: f } = this.workOptions, d = !!t.parent.gl, u = {
|
|
2759
2756
|
anchor: [0.5, 0.5],
|
|
2760
2757
|
pos: [a, c],
|
|
2761
2758
|
name: o,
|
|
2762
2759
|
size: [l, h],
|
|
2763
2760
|
zIndex: f,
|
|
2764
|
-
rotate: !r && 180 + (p || 0) || p,
|
|
2761
|
+
rotate: !r && !d && 180 + (p || 0) || p,
|
|
2762
|
+
// rotate,
|
|
2765
2763
|
texture: i
|
|
2766
|
-
},
|
|
2767
|
-
this.replace(t, s || o,
|
|
2768
|
-
const
|
|
2769
|
-
if (
|
|
2764
|
+
}, w = new jt(u);
|
|
2765
|
+
this.replace(t, s || o, w);
|
|
2766
|
+
const S = w.getBoundingClientRect();
|
|
2767
|
+
if (S)
|
|
2770
2768
|
return {
|
|
2771
|
-
x: Math.floor(
|
|
2772
|
-
y: Math.floor(
|
|
2773
|
-
w: Math.floor(
|
|
2774
|
-
h: Math.floor(
|
|
2769
|
+
x: Math.floor(S.x - L.SafeBorderPadding),
|
|
2770
|
+
y: Math.floor(S.y - L.SafeBorderPadding),
|
|
2771
|
+
w: Math.floor(S.width + L.SafeBorderPadding * 2),
|
|
2772
|
+
h: Math.floor(S.height + L.SafeBorderPadding * 2)
|
|
2775
2773
|
};
|
|
2776
2774
|
}
|
|
2777
2775
|
consumeService() {
|
|
@@ -2783,16 +2781,16 @@ class ut extends W {
|
|
|
2783
2781
|
const u = await s.preload({
|
|
2784
2782
|
id: a,
|
|
2785
2783
|
src: this.workOptions.src
|
|
2786
|
-
}),
|
|
2784
|
+
}), w = this.draw({ workId: c, layer: l, replaceId: o, imageBitmap: u[0], isMainThread: i });
|
|
2787
2785
|
return this.oldRect = c && ((f = (p = this.vNodes) == null ? void 0 : p.get(c)) == null ? void 0 : f.rect) || void 0, (d = this.vNodes) == null || d.setInfo(c, {
|
|
2788
|
-
rect:
|
|
2786
|
+
rect: w,
|
|
2789
2787
|
op: [],
|
|
2790
2788
|
opt: this.workOptions,
|
|
2791
2789
|
toolsType: this.toolsType,
|
|
2792
2790
|
scaleType: this.scaleType,
|
|
2793
2791
|
canRotate: this.canRotate,
|
|
2794
|
-
centerPos:
|
|
2795
|
-
}),
|
|
2792
|
+
centerPos: w && L.getCenterPos(w, l)
|
|
2793
|
+
}), w;
|
|
2796
2794
|
}
|
|
2797
2795
|
}
|
|
2798
2796
|
clearTmpPoints() {
|
|
@@ -2808,36 +2806,45 @@ class ut extends W {
|
|
|
2808
2806
|
return;
|
|
2809
2807
|
const u = t.parent;
|
|
2810
2808
|
if (u) {
|
|
2811
|
-
if (
|
|
2812
|
-
const { centerX:
|
|
2813
|
-
x:
|
|
2814
|
-
y:
|
|
2809
|
+
if (q(f) && (t.setAttribute("zIndex", f), d.opt.zIndex = f), ot(p) && (d.opt.locked = p), a && l && c) {
|
|
2810
|
+
const { centerX: w, centerY: S, width: b, height: T, uniformScale: g, rotate: I } = d.opt, N = Math.min(c[0], c[1]), W = g !== !1 ? [N, N] : c, A = Xt({
|
|
2811
|
+
x: w - b / 2,
|
|
2812
|
+
y: S - T / 2,
|
|
2815
2813
|
w: b,
|
|
2816
|
-
h:
|
|
2817
|
-
},
|
|
2814
|
+
h: T
|
|
2815
|
+
}, I || 0), v = Yt(A, new k(w, S), W), x = $t(v, new k(w, S), -(I || 0)), M = z(x);
|
|
2818
2816
|
d.opt.width = Math.round(M.w), d.opt.height = Math.round(M.h);
|
|
2819
2817
|
const $ = [l[0] / u.worldScaling[0], l[1] / u.worldScaling[1]];
|
|
2820
|
-
d.opt.centerX =
|
|
2818
|
+
d.opt.centerX = w + $[0], d.opt.centerY = S + $[1];
|
|
2821
2819
|
const F = [d.centerPos[0] + $[0], d.centerPos[1] + $[1]];
|
|
2822
2820
|
if (d.centerPos = F, i) {
|
|
2823
|
-
let
|
|
2824
|
-
|
|
2821
|
+
let V = It(d.rect, c);
|
|
2822
|
+
V = pt(V, $), d.rect = V;
|
|
2823
|
+
} else {
|
|
2824
|
+
const V = L.getRectFromLayer(u, t.name);
|
|
2825
|
+
d.rect = V || d.rect;
|
|
2825
2826
|
}
|
|
2826
|
-
} else if (r)
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2827
|
+
} else if (r)
|
|
2828
|
+
if (d.opt.centerX = d.opt.centerX + r[0], d.opt.centerY = d.opt.centerY + r[1], d.centerPos = [d.centerPos[0] + r[0], d.centerPos[1] + r[1]], i) {
|
|
2829
|
+
const w = [r[0] * u.worldScaling[0], r[1] * u.worldScaling[1]], S = pt(d.rect, w);
|
|
2830
|
+
d.rect = S;
|
|
2831
|
+
} else {
|
|
2832
|
+
const w = L.getRectFromLayer(u, t.name);
|
|
2833
|
+
d.rect = w || d.rect;
|
|
2834
|
+
}
|
|
2835
|
+
else if (q(h))
|
|
2836
|
+
if (d.opt.rotate = h, d.scaleType = ut.getScaleType(d.opt), i) {
|
|
2837
|
+
const w = Tt(d.rect, h);
|
|
2838
|
+
d.rect = w;
|
|
2839
|
+
} else {
|
|
2840
|
+
const w = L.getRectFromLayer(u, t.name);
|
|
2841
|
+
d.rect = w || d.rect;
|
|
2831
2842
|
}
|
|
2832
|
-
} else if (V(h) && (d.opt.rotate = h, d.scaleType = ut.getScaleType(d.opt), i)) {
|
|
2833
|
-
const y = Tt(d.rect, h);
|
|
2834
|
-
d.rect = y;
|
|
2835
|
-
}
|
|
2836
2843
|
return d && s.setInfo(t.name, d), d == null ? void 0 : d.rect;
|
|
2837
2844
|
}
|
|
2838
2845
|
}
|
|
2839
2846
|
}
|
|
2840
|
-
class Dt extends
|
|
2847
|
+
class Dt extends L {
|
|
2841
2848
|
constructor(e) {
|
|
2842
2849
|
super(e);
|
|
2843
2850
|
m(this, "canRotate", !1);
|
|
@@ -2854,13 +2861,13 @@ class Dt extends W {
|
|
|
2854
2861
|
var d;
|
|
2855
2862
|
const { data: t, isFullWork: o, isSubWorker: s, isMainThread: i } = e, r = (d = t == null ? void 0 : t.workId) == null ? void 0 : d.toString();
|
|
2856
2863
|
if (!r)
|
|
2857
|
-
return { type:
|
|
2864
|
+
return { type: y.None };
|
|
2858
2865
|
const { op: a, workState: c } = t, l = a == null ? void 0 : a.length;
|
|
2859
2866
|
if (!l || l < 2)
|
|
2860
|
-
return { type:
|
|
2867
|
+
return { type: y.None };
|
|
2861
2868
|
let h;
|
|
2862
2869
|
if (c === D.Start ? (this.tmpPoints = [new O(a[0], a[1])], h = !1) : h = this.updateTempPoints(a), !h)
|
|
2863
|
-
return { type:
|
|
2870
|
+
return { type: y.None };
|
|
2864
2871
|
let p;
|
|
2865
2872
|
if (s || i) {
|
|
2866
2873
|
const u = o ? this.fullLayer : this.drawLayer || this.fullLayer;
|
|
@@ -2869,19 +2876,19 @@ class Dt extends W {
|
|
|
2869
2876
|
if (!s) {
|
|
2870
2877
|
const u = Date.now();
|
|
2871
2878
|
return u - this.syncTimestamp > this.syncUnitTime ? (this.syncTimestamp = u, {
|
|
2872
|
-
type:
|
|
2873
|
-
dataType:
|
|
2879
|
+
type: y.DrawWork,
|
|
2880
|
+
dataType: R.Local,
|
|
2874
2881
|
workId: r,
|
|
2875
|
-
op: this.tmpPoints.map((
|
|
2882
|
+
op: this.tmpPoints.map((w) => [...w.XY, 0]).flat(1),
|
|
2876
2883
|
isSync: !0,
|
|
2877
2884
|
index: 0
|
|
2878
|
-
}) : { type:
|
|
2885
|
+
}) : { type: y.None };
|
|
2879
2886
|
}
|
|
2880
2887
|
const f = B(p, this.oldRect);
|
|
2881
2888
|
return this.oldRect = p, {
|
|
2882
2889
|
rect: f,
|
|
2883
|
-
type:
|
|
2884
|
-
dataType:
|
|
2890
|
+
type: y.DrawWork,
|
|
2891
|
+
dataType: R.Local,
|
|
2885
2892
|
workId: r
|
|
2886
2893
|
};
|
|
2887
2894
|
}
|
|
@@ -2889,10 +2896,10 @@ class Dt extends W {
|
|
|
2889
2896
|
var c, l;
|
|
2890
2897
|
const { data: t } = e, o = (c = t == null ? void 0 : t.workId) == null ? void 0 : c.toString();
|
|
2891
2898
|
if (!o)
|
|
2892
|
-
return { type:
|
|
2899
|
+
return { type: y.None };
|
|
2893
2900
|
if (this.tmpPoints.length < 2)
|
|
2894
2901
|
return {
|
|
2895
|
-
type:
|
|
2902
|
+
type: y.RemoveNode,
|
|
2896
2903
|
removeIds: [o]
|
|
2897
2904
|
};
|
|
2898
2905
|
const s = this.fullLayer, i = this.draw({ workId: o, layer: s });
|
|
@@ -2905,11 +2912,11 @@ class Dt extends W {
|
|
|
2905
2912
|
toolsType: this.toolsType,
|
|
2906
2913
|
scaleType: this.scaleType,
|
|
2907
2914
|
canRotate: this.canRotate,
|
|
2908
|
-
centerPos: i &&
|
|
2915
|
+
centerPos: i && L.getCenterPos(i, s)
|
|
2909
2916
|
}), {
|
|
2910
2917
|
rect: i,
|
|
2911
|
-
type:
|
|
2912
|
-
dataType:
|
|
2918
|
+
type: y.FullWork,
|
|
2919
|
+
dataType: R.Local,
|
|
2913
2920
|
workId: o,
|
|
2914
2921
|
ops: a,
|
|
2915
2922
|
isSync: !0,
|
|
@@ -2920,7 +2927,7 @@ class Dt extends W {
|
|
|
2920
2927
|
const { workId: t, layer: o } = e, { strokeColor: s, thickness: i, zIndex: r, scale: a, rotate: c, translate: l } = this.workOptions, h = o.worldPosition, p = o.worldScaling, { d: f, rect: d } = this.computDrawPoints(i), u = [
|
|
2921
2928
|
d.x + d.w / 2,
|
|
2922
2929
|
d.y + d.h / 2
|
|
2923
|
-
],
|
|
2930
|
+
], w = {
|
|
2924
2931
|
pos: u,
|
|
2925
2932
|
name: t,
|
|
2926
2933
|
id: t,
|
|
@@ -2932,29 +2939,29 @@ class Dt extends W {
|
|
|
2932
2939
|
normalize: !0,
|
|
2933
2940
|
zIndex: r
|
|
2934
2941
|
};
|
|
2935
|
-
a && (
|
|
2936
|
-
const
|
|
2937
|
-
if (this.replace(o, t,
|
|
2938
|
-
const
|
|
2942
|
+
a && (w.scale = a), c && (w.rotate = c), l && (w.translate = l);
|
|
2943
|
+
const S = new it(w);
|
|
2944
|
+
if (this.replace(o, t, S), c || a || l) {
|
|
2945
|
+
const T = S.getBoundingClientRect();
|
|
2939
2946
|
return {
|
|
2940
|
-
x: Math.floor(
|
|
2941
|
-
y: Math.floor(
|
|
2942
|
-
w: Math.floor(
|
|
2943
|
-
h: Math.floor(
|
|
2947
|
+
x: Math.floor(T.x - L.SafeBorderPadding),
|
|
2948
|
+
y: Math.floor(T.y - L.SafeBorderPadding),
|
|
2949
|
+
w: Math.floor(T.width + L.SafeBorderPadding * 2),
|
|
2950
|
+
h: Math.floor(T.height + L.SafeBorderPadding * 2)
|
|
2944
2951
|
};
|
|
2945
2952
|
}
|
|
2946
2953
|
return {
|
|
2947
|
-
x: Math.floor(d.x * p[0] + h[0] -
|
|
2948
|
-
y: Math.floor(d.y * p[1] + h[1] -
|
|
2949
|
-
w: Math.floor(d.w * p[0] + 2 *
|
|
2950
|
-
h: Math.floor(d.h * p[1] + 2 *
|
|
2954
|
+
x: Math.floor(d.x * p[0] + h[0] - L.SafeBorderPadding),
|
|
2955
|
+
y: Math.floor(d.y * p[1] + h[1] - L.SafeBorderPadding),
|
|
2956
|
+
w: Math.floor(d.w * p[0] + 2 * L.SafeBorderPadding),
|
|
2957
|
+
h: Math.floor(d.h * p[1] + 2 * L.SafeBorderPadding)
|
|
2951
2958
|
};
|
|
2952
2959
|
}
|
|
2953
2960
|
computDrawPoints(e) {
|
|
2954
2961
|
return this.tmpPoints[1].distance(this.tmpPoints[0]) > this.straightTipWidth ? this.computFullPoints(e) : this.computDotPoints(e);
|
|
2955
2962
|
}
|
|
2956
2963
|
computFullPoints(e) {
|
|
2957
|
-
const t =
|
|
2964
|
+
const t = k.Sub(this.tmpPoints[1], this.tmpPoints[0]).uni(), o = k.Per(t).mul(e / 2), s = O.Sub(this.tmpPoints[0], o), i = O.Add(this.tmpPoints[0], o), r = O.Sub(this.tmpPoints[1], o), a = O.Add(this.tmpPoints[1], o), c = O.GetSemicircleStroke(this.tmpPoints[1], r, -1, 8), l = O.GetSemicircleStroke(this.tmpPoints[0], i, -1, 8), h = [s, r, ...c, a, i, ...l];
|
|
2958
2965
|
return {
|
|
2959
2966
|
d: lt(h, !0),
|
|
2960
2967
|
rect: z(h),
|
|
@@ -2999,7 +3006,7 @@ class Dt extends W {
|
|
|
2999
3006
|
toolsType: this.toolsType,
|
|
3000
3007
|
scaleType: this.scaleType,
|
|
3001
3008
|
canRotate: this.canRotate,
|
|
3002
|
-
centerPos: r &&
|
|
3009
|
+
centerPos: r && L.getCenterPos(r, i)
|
|
3003
3010
|
}), r;
|
|
3004
3011
|
}
|
|
3005
3012
|
clearTmpPoints() {
|
|
@@ -3008,10 +3015,10 @@ class Dt extends W {
|
|
|
3008
3015
|
static updateNodeOpt(e) {
|
|
3009
3016
|
var a;
|
|
3010
3017
|
const { node: t, opt: o, vNodes: s } = e, { strokeColor: i } = o, r = s.get(t.name);
|
|
3011
|
-
return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r),
|
|
3018
|
+
return i && (t.setAttribute("strokeColor", i), t.setAttribute("fillColor", i), (a = r == null ? void 0 : r.opt) != null && a.strokeColor && (r.opt.strokeColor = i)), r && s.setInfo(t.name, r), L.updateNodeOpt(e);
|
|
3012
3019
|
}
|
|
3013
3020
|
}
|
|
3014
|
-
class
|
|
3021
|
+
class yt extends L {
|
|
3015
3022
|
constructor(e) {
|
|
3016
3023
|
super(e);
|
|
3017
3024
|
m(this, "canRotate", !1);
|
|
@@ -3024,12 +3031,12 @@ class ft extends W {
|
|
|
3024
3031
|
}
|
|
3025
3032
|
consume() {
|
|
3026
3033
|
return {
|
|
3027
|
-
type:
|
|
3034
|
+
type: y.None
|
|
3028
3035
|
};
|
|
3029
3036
|
}
|
|
3030
3037
|
consumeAll() {
|
|
3031
3038
|
return {
|
|
3032
|
-
type:
|
|
3039
|
+
type: y.None
|
|
3033
3040
|
};
|
|
3034
3041
|
}
|
|
3035
3042
|
consumeService() {
|
|
@@ -3051,14 +3058,16 @@ class ft extends W {
|
|
|
3051
3058
|
y: r[1],
|
|
3052
3059
|
w: i[0],
|
|
3053
3060
|
h: i[1]
|
|
3054
|
-
}, d = new
|
|
3061
|
+
}, d = new kt({
|
|
3055
3062
|
normalize: !0,
|
|
3056
3063
|
pos: [0, 0],
|
|
3057
3064
|
size: i
|
|
3058
|
-
})
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3065
|
+
});
|
|
3066
|
+
if (p.append(d), s) {
|
|
3067
|
+
const u = s && await yt.createLabels(this.workOptions, p) || [];
|
|
3068
|
+
p.append(...u);
|
|
3069
|
+
}
|
|
3070
|
+
return this.replace(o, t, p), {
|
|
3062
3071
|
x: Math.floor(f.x * l[0] + c[0]),
|
|
3063
3072
|
y: Math.floor(f.y * l[1] + c[1]),
|
|
3064
3073
|
w: Math.floor(f.w * l[0]),
|
|
@@ -3080,21 +3089,9 @@ class ft extends W {
|
|
|
3080
3089
|
toolsType: this.toolsType,
|
|
3081
3090
|
scaleType: this.scaleType,
|
|
3082
3091
|
canRotate: this.canRotate,
|
|
3083
|
-
centerPos: a &&
|
|
3092
|
+
centerPos: a && L.getCenterPos(a, r)
|
|
3084
3093
|
}), a;
|
|
3085
3094
|
}
|
|
3086
|
-
updateLabelsWidth(e) {
|
|
3087
|
-
e.children.forEach((t) => {
|
|
3088
|
-
if (t.tagName === "LABEL") {
|
|
3089
|
-
const o = t.name, { width: s } = t.getBoundingClientRect(), [i] = e.worldScaling, { underline: r, lineThrough: a } = this.getWorkOptions();
|
|
3090
|
-
r && e.getElementsByName(`${o}_underline`)[0].attr({
|
|
3091
|
-
points: [0, 0, s / i, 0]
|
|
3092
|
-
}), a && e.getElementsByName(`${o}_lineThrough`)[0].attr({
|
|
3093
|
-
points: [0, 0, s / i, 0]
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
|
-
});
|
|
3097
|
-
}
|
|
3098
3095
|
updataOptService() {
|
|
3099
3096
|
}
|
|
3100
3097
|
async updataOptServiceAsync(e) {
|
|
@@ -3104,7 +3101,7 @@ class ft extends W {
|
|
|
3104
3101
|
const t = this.workId.toString(), { fontColor: o, fontBgColor: s, bold: i, italic: r, lineThrough: a, underline: c, zIndex: l } = e, h = (f = this.vNodes) == null ? void 0 : f.get(t);
|
|
3105
3102
|
if (!h)
|
|
3106
3103
|
return;
|
|
3107
|
-
o && (h.opt.fontColor = o), s && (h.opt.fontBgColor = s), i && (h.opt.bold = i), r && (h.opt.italic = r), ot(a) && (h.opt.lineThrough = a), ot(c) && (h.opt.underline = c),
|
|
3104
|
+
o && (h.opt.fontColor = o), s && (h.opt.fontBgColor = s), i && (h.opt.bold = i), r && (h.opt.italic = r), ot(a) && (h.opt.lineThrough = a), ot(c) && (h.opt.underline = c), q(l) && (h.opt.zIndex = l), this.oldRect = h.rect;
|
|
3108
3105
|
const p = await this.draw({
|
|
3109
3106
|
workId: t,
|
|
3110
3107
|
layer: this.fullLayer,
|
|
@@ -3117,69 +3114,79 @@ class ft extends W {
|
|
|
3117
3114
|
toolsType: this.toolsType,
|
|
3118
3115
|
scaleType: this.scaleType,
|
|
3119
3116
|
canRotate: this.canRotate,
|
|
3120
|
-
centerPos: p &&
|
|
3117
|
+
centerPos: p && L.getCenterPos(p, this.fullLayer)
|
|
3121
3118
|
}), p;
|
|
3122
3119
|
}
|
|
3123
3120
|
clearTmpPoints() {
|
|
3124
3121
|
this.tmpPoints.length = 0;
|
|
3125
3122
|
}
|
|
3126
|
-
static
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
for (let r = 0; r < i; r++) {
|
|
3133
|
-
const a = s[r], { fontSize: c, lineHeight: l, bold: h, textAlign: p, italic: f, boxSize: d, fontFamily: u, verticalAlign: y, fontColor: k, underline: b, lineThrough: v } = e, g = l || c * 1.2, L = t && t.parent.canvas.getContext("2d"), N = L && ft.getFontWidth({ text: a, opt: e, ctx: L, worldScaling: t.worldScaling });
|
|
3134
|
-
if (N) {
|
|
3135
|
-
const I = {
|
|
3123
|
+
static async createLabels(e, t) {
|
|
3124
|
+
const o = [], s = e.text.split(","), i = s.length, { fontSize: r, lineHeight: a, bold: c, textAlign: l, italic: h, boxSize: p, fontFamily: f, verticalAlign: d, fontColor: u, fontBgColor: w, underline: S, lineThrough: b } = e;
|
|
3125
|
+
for (let T = 0; T < i; T++) {
|
|
3126
|
+
const g = s[T], I = a || r * 1.2;
|
|
3127
|
+
if (g) {
|
|
3128
|
+
const N = {
|
|
3136
3129
|
anchor: [0, 0.5],
|
|
3137
|
-
text:
|
|
3138
|
-
fontSize:
|
|
3139
|
-
lineHeight:
|
|
3140
|
-
fontFamily:
|
|
3141
|
-
fontWeight:
|
|
3142
|
-
fillColor:
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3130
|
+
text: g,
|
|
3131
|
+
fontSize: r,
|
|
3132
|
+
lineHeight: I,
|
|
3133
|
+
fontFamily: f,
|
|
3134
|
+
fontWeight: c,
|
|
3135
|
+
fillColor: u,
|
|
3136
|
+
bgcolor: w,
|
|
3137
|
+
textAlign: l,
|
|
3138
|
+
fontStyle: h,
|
|
3139
|
+
name: T.toString(),
|
|
3146
3140
|
className: "label"
|
|
3147
|
-
},
|
|
3148
|
-
if (
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3151
|
-
}
|
|
3152
|
-
if (p === "left") {
|
|
3153
|
-
const x = d && -d[0] / 2 || 0;
|
|
3154
|
-
A[0] = f === "italic" && x || x + 5, console.log("text-left", A);
|
|
3141
|
+
}, W = [0, 0];
|
|
3142
|
+
if (d === "middle") {
|
|
3143
|
+
const v = (i - 1) / 2;
|
|
3144
|
+
W[1] = (T - v) * I;
|
|
3155
3145
|
}
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
const x = {
|
|
3160
|
-
normalize: !1,
|
|
3161
|
-
pos: [I.pos[0], I.pos[1] + c / 2],
|
|
3162
|
-
lineWidth: Math.floor(c / 10),
|
|
3163
|
-
points: [0, 0, N, 0],
|
|
3164
|
-
strokeColor: k,
|
|
3165
|
-
name: `${r}_underline`,
|
|
3166
|
-
className: "underline"
|
|
3167
|
-
}, M = new st(x);
|
|
3168
|
-
o.push(M);
|
|
3146
|
+
if (l === "left") {
|
|
3147
|
+
const v = p && -p[0] / 2 || 0;
|
|
3148
|
+
W[0] = h === "italic" && v || v + 5;
|
|
3169
3149
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3150
|
+
N.pos = W;
|
|
3151
|
+
const A = new Zt(N);
|
|
3152
|
+
o.push(A);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
if (await new Promise((T) => {
|
|
3156
|
+
setTimeout(T, 0);
|
|
3157
|
+
}), S || b) {
|
|
3158
|
+
const T = [], [g] = t.worldScaling;
|
|
3159
|
+
for (let I = 0; I < o.length; I++) {
|
|
3160
|
+
const { width: N } = o[I].getBoundingClientRect();
|
|
3161
|
+
if (N) {
|
|
3162
|
+
const W = o[I].getAttribute("pos");
|
|
3163
|
+
if (S) {
|
|
3164
|
+
const A = {
|
|
3165
|
+
normalize: !1,
|
|
3166
|
+
pos: [W[0], W[1] + r / 2],
|
|
3167
|
+
lineWidth: Math.floor(r / 10),
|
|
3168
|
+
points: [0, 0, N / g, 0],
|
|
3169
|
+
strokeColor: u,
|
|
3170
|
+
name: `${I}_underline`,
|
|
3171
|
+
className: "underline"
|
|
3172
|
+
}, v = new st(A);
|
|
3173
|
+
T.push(v);
|
|
3174
|
+
}
|
|
3175
|
+
if (b) {
|
|
3176
|
+
const A = {
|
|
3177
|
+
normalize: !1,
|
|
3178
|
+
pos: W,
|
|
3179
|
+
lineWidth: Math.floor(r / 10),
|
|
3180
|
+
points: [0, 0, N / g, 0],
|
|
3181
|
+
strokeColor: u,
|
|
3182
|
+
name: `${I}_lineThrough`,
|
|
3183
|
+
className: "lineThrough"
|
|
3184
|
+
}, v = new st(A);
|
|
3185
|
+
T.push(v);
|
|
3186
|
+
}
|
|
3181
3187
|
}
|
|
3182
3188
|
}
|
|
3189
|
+
return o.concat(T);
|
|
3183
3190
|
}
|
|
3184
3191
|
return o;
|
|
3185
3192
|
}
|
|
@@ -3194,30 +3201,32 @@ class ft extends W {
|
|
|
3194
3201
|
bold: f,
|
|
3195
3202
|
italic: d,
|
|
3196
3203
|
lineThrough: u,
|
|
3197
|
-
underline:
|
|
3198
|
-
fontSize:
|
|
3204
|
+
underline: w,
|
|
3205
|
+
fontSize: S,
|
|
3199
3206
|
textInfos: b,
|
|
3200
|
-
zIndex:
|
|
3207
|
+
zIndex: T
|
|
3201
3208
|
} = o, g = i && tt(i) || s.get(t.name);
|
|
3202
3209
|
if (!g)
|
|
3203
3210
|
return;
|
|
3204
|
-
const
|
|
3205
|
-
if (!
|
|
3211
|
+
const I = t.parent;
|
|
3212
|
+
if (!I)
|
|
3206
3213
|
return;
|
|
3207
3214
|
const N = g.opt;
|
|
3208
|
-
if (
|
|
3209
|
-
|
|
3210
|
-
})), r && N.fontBgColor && (N.fontBgColor = r
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3215
|
+
if (q(T) && (t.setAttribute("zIndex", T), g.opt.zIndex = T), a && N.fontColor && (N.fontColor = a, t.children.forEach((W) => {
|
|
3216
|
+
W.tagName === "LABEL" ? W.setAttribute("fillColor", a) : W.tagName === "POLYLINE" && W.setAttribute("strokeColor", a);
|
|
3217
|
+
})), r && N.fontBgColor && (N.fontBgColor = r, t.children.forEach((W) => {
|
|
3218
|
+
W.tagName === "LABEL" && W.setAttribute("bgcolor", r);
|
|
3219
|
+
})), f && (N.bold = f), d && (N.italic = d), ot(u) && (N.lineThrough = u), ot(w) && (N.underline = w), S && (N.fontSize = S), l && p && h) {
|
|
3220
|
+
const W = b == null ? void 0 : b.get(t.name);
|
|
3221
|
+
if (W) {
|
|
3222
|
+
const { fontSize: x, boxSize: M } = W;
|
|
3214
3223
|
N.boxSize = M || N.boxSize, N.fontSize = x || N.fontSize;
|
|
3215
3224
|
}
|
|
3216
|
-
const A = g.rect,
|
|
3217
|
-
N.boxPoint =
|
|
3218
|
-
} else if (c && N.boxPoint) {
|
|
3219
|
-
const
|
|
3220
|
-
|
|
3225
|
+
const A = g.rect, v = pt(It(A, h), p);
|
|
3226
|
+
N.boxPoint = v && [(v.x - I.worldPosition[0]) / I.worldScaling[0], (v.y - I.worldPosition[1]) / I.worldScaling[1]];
|
|
3227
|
+
} else if (c && N.boxPoint && (N.boxPoint = [N.boxPoint[0] + c[0], N.boxPoint[1] + c[1]], g.centerPos = [g.centerPos[0] + c[0], g.centerPos[1] + c[1]], i)) {
|
|
3228
|
+
const W = [c[0] / I.worldScaling[0], c[1] / I.worldScaling[1]];
|
|
3229
|
+
g.rect = pt(g.rect, W);
|
|
3221
3230
|
}
|
|
3222
3231
|
return g && s.setInfo(t.name, g), g == null ? void 0 : g.rect;
|
|
3223
3232
|
}
|
|
@@ -3234,8 +3243,8 @@ class ft extends W {
|
|
|
3234
3243
|
}
|
|
3235
3244
|
}
|
|
3236
3245
|
}
|
|
3237
|
-
function At(
|
|
3238
|
-
switch (
|
|
3246
|
+
function At(C) {
|
|
3247
|
+
switch (C) {
|
|
3239
3248
|
case P.Arrow:
|
|
3240
3249
|
return xt;
|
|
3241
3250
|
case P.Pencil:
|
|
@@ -3255,19 +3264,19 @@ function At(R) {
|
|
|
3255
3264
|
case P.SpeechBalloon:
|
|
3256
3265
|
return Ot;
|
|
3257
3266
|
case P.Text:
|
|
3258
|
-
return
|
|
3267
|
+
return yt;
|
|
3259
3268
|
case P.LaserPen:
|
|
3260
3269
|
return Lt;
|
|
3261
3270
|
case P.Eraser:
|
|
3262
|
-
return
|
|
3271
|
+
return ft;
|
|
3263
3272
|
case P.Selector:
|
|
3264
|
-
return
|
|
3273
|
+
return G;
|
|
3265
3274
|
case P.Image:
|
|
3266
3275
|
return ut;
|
|
3267
3276
|
}
|
|
3268
3277
|
}
|
|
3269
|
-
function
|
|
3270
|
-
const { toolsType: e, ...t } =
|
|
3278
|
+
function wt(C, n) {
|
|
3279
|
+
const { toolsType: e, ...t } = C;
|
|
3271
3280
|
switch (e) {
|
|
3272
3281
|
case P.Arrow:
|
|
3273
3282
|
return new xt(t);
|
|
@@ -3288,36 +3297,36 @@ function yt(R, n) {
|
|
|
3288
3297
|
case P.SpeechBalloon:
|
|
3289
3298
|
return new Ot(t);
|
|
3290
3299
|
case P.Text:
|
|
3291
|
-
return new
|
|
3300
|
+
return new yt(t);
|
|
3292
3301
|
case P.LaserPen:
|
|
3293
3302
|
return new Lt(t);
|
|
3294
3303
|
case P.Eraser:
|
|
3295
|
-
return new
|
|
3304
|
+
return new ft(t, n);
|
|
3296
3305
|
case P.Selector:
|
|
3297
|
-
return t.vNodes ? new
|
|
3306
|
+
return t.vNodes ? new G({ ...t, vNodes: t.vNodes, drawLayer: t.fullLayer }) : void 0;
|
|
3298
3307
|
case P.Image:
|
|
3299
3308
|
return new ut(t);
|
|
3300
3309
|
default:
|
|
3301
3310
|
return;
|
|
3302
3311
|
}
|
|
3303
3312
|
}
|
|
3304
|
-
function Et(
|
|
3313
|
+
function Et(C) {
|
|
3305
3314
|
const n = [], e = ["PATH", "SPRITE", "POLYLINE", "RECT", "ELLIPSE"];
|
|
3306
|
-
for (const t of
|
|
3315
|
+
for (const t of C) {
|
|
3307
3316
|
if (t.tagName === "GROUP" && t.children.length)
|
|
3308
3317
|
return Et(t.children);
|
|
3309
3318
|
t.tagName && e.includes(t.tagName) && n.push(t);
|
|
3310
3319
|
}
|
|
3311
3320
|
return n;
|
|
3312
3321
|
}
|
|
3313
|
-
const Jt = (
|
|
3314
|
-
if (
|
|
3315
|
-
const n = Object.getOwnPropertySymbols(
|
|
3316
|
-
if (n &&
|
|
3322
|
+
const Jt = (C) => {
|
|
3323
|
+
if (C.tagName === "GROUP") {
|
|
3324
|
+
const n = Object.getOwnPropertySymbols(C).find((e) => e.toString() === "Symbol(sealed)");
|
|
3325
|
+
if (n && C[n])
|
|
3317
3326
|
return !0;
|
|
3318
3327
|
}
|
|
3319
3328
|
return !1;
|
|
3320
|
-
}, Qt = (
|
|
3329
|
+
}, Qt = (C) => !C.isHid, mt = "cursorhover";
|
|
3321
3330
|
class _t {
|
|
3322
3331
|
constructor(n, e) {
|
|
3323
3332
|
m(this, "viewId");
|
|
@@ -3389,10 +3398,10 @@ class _t {
|
|
|
3389
3398
|
return this.fullLayer && (t == null ? void 0 : t.getRectFromLayer(this.fullLayer, n));
|
|
3390
3399
|
}
|
|
3391
3400
|
updateNodesRect() {
|
|
3392
|
-
this.curNodeMap.
|
|
3393
|
-
const t = this.getNodeRectFormShape(
|
|
3394
|
-
t ? (
|
|
3395
|
-
}
|
|
3401
|
+
for (const [n, e] of this.curNodeMap.entries()) {
|
|
3402
|
+
const t = this.getNodeRectFormShape(n, e);
|
|
3403
|
+
t ? (e.rect = t, this.curNodeMap.set(n, e)) : this.curNodeMap.delete(n);
|
|
3404
|
+
}
|
|
3396
3405
|
}
|
|
3397
3406
|
combineIntersectRect(n) {
|
|
3398
3407
|
let e = n;
|
|
@@ -3415,6 +3424,9 @@ class _t {
|
|
|
3415
3424
|
deleteTarget(n) {
|
|
3416
3425
|
this.targetNodeMap.length = n;
|
|
3417
3426
|
}
|
|
3427
|
+
clearTarget() {
|
|
3428
|
+
this.targetNodeMap.length = 0;
|
|
3429
|
+
}
|
|
3418
3430
|
}
|
|
3419
3431
|
class te {
|
|
3420
3432
|
constructor(n) {
|
|
@@ -3441,14 +3453,14 @@ class te {
|
|
|
3441
3453
|
}
|
|
3442
3454
|
consumeDraw(n) {
|
|
3443
3455
|
const { workId: e, dataType: t } = n;
|
|
3444
|
-
if (t ===
|
|
3456
|
+
if (t === R.Service)
|
|
3445
3457
|
this.activeServiceWorkShape(n);
|
|
3446
3458
|
else {
|
|
3447
|
-
const o = this.localWorkShapes.get(
|
|
3448
|
-
if (!
|
|
3459
|
+
const o = e == null ? void 0 : e.toString(), s = o && this.localWorkShapes.get(o);
|
|
3460
|
+
if (!s)
|
|
3449
3461
|
return;
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3462
|
+
const i = s.node.consume({ data: n, isFullWork: !1, isSubWorker: !0 });
|
|
3463
|
+
i.rect && (s.result = i, s.workState = D.Doing, o && this.localWorkShapes.set(o, s));
|
|
3452
3464
|
}
|
|
3453
3465
|
this.runAnimation();
|
|
3454
3466
|
}
|
|
@@ -3458,7 +3470,7 @@ class te {
|
|
|
3458
3470
|
createWorkShapeNode(n) {
|
|
3459
3471
|
const { toolsType: e } = n;
|
|
3460
3472
|
if (e === P.LaserPen)
|
|
3461
|
-
return
|
|
3473
|
+
return wt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.topLayer, drawLayer: this.thread.topLayer });
|
|
3462
3474
|
}
|
|
3463
3475
|
getTmpWorkShapeNode() {
|
|
3464
3476
|
return this.tmpWorkShapeNode;
|
|
@@ -3532,7 +3544,7 @@ class te {
|
|
|
3532
3544
|
if (p) {
|
|
3533
3545
|
c.node.clearTmpPoints(), this.localWorkShapes.delete(a), t.push({
|
|
3534
3546
|
removeIds: [a.toString()],
|
|
3535
|
-
type:
|
|
3547
|
+
type: y.RemoveNode
|
|
3536
3548
|
});
|
|
3537
3549
|
break;
|
|
3538
3550
|
}
|
|
@@ -3543,7 +3555,7 @@ class te {
|
|
|
3543
3555
|
}
|
|
3544
3556
|
n && this.runAnimation(), e.size && e.forEach((a, c) => {
|
|
3545
3557
|
t.push({
|
|
3546
|
-
type:
|
|
3558
|
+
type: y.Cursor,
|
|
3547
3559
|
uid: c.split(gt)[0],
|
|
3548
3560
|
op: a.op,
|
|
3549
3561
|
workState: a.workState,
|
|
@@ -3560,14 +3572,14 @@ class te {
|
|
|
3560
3572
|
}
|
|
3561
3573
|
consumeDrawAll(n) {
|
|
3562
3574
|
const { workId: e, dataType: t } = n;
|
|
3563
|
-
if (t ===
|
|
3575
|
+
if (t === R.Service)
|
|
3564
3576
|
this.activeServiceWorkShape(n);
|
|
3565
3577
|
else {
|
|
3566
|
-
const o = this.localWorkShapes.get(
|
|
3567
|
-
if (!
|
|
3578
|
+
const o = e == null ? void 0 : e.toString(), s = o && this.localWorkShapes.get(o);
|
|
3579
|
+
if (!s)
|
|
3568
3580
|
return;
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3581
|
+
const i = s.node.consumeAll({ data: n });
|
|
3582
|
+
s.result = i, s.workState = D.Done, o && this.localWorkShapes.set(o, s);
|
|
3571
3583
|
}
|
|
3572
3584
|
this.runAnimation();
|
|
3573
3585
|
}
|
|
@@ -3577,7 +3589,6 @@ class ee {
|
|
|
3577
3589
|
m(this, "vNodes");
|
|
3578
3590
|
m(this, "thread");
|
|
3579
3591
|
m(this, "workShapes", /* @__PURE__ */ new Map());
|
|
3580
|
-
// workShapeState: Map<IworkId, ShapeStateInfo> = new Map();
|
|
3581
3592
|
m(this, "effectSelectNodeData", /* @__PURE__ */ new Set());
|
|
3582
3593
|
m(this, "batchEraserRemoveNodes", /* @__PURE__ */ new Set());
|
|
3583
3594
|
m(this, "batchEraserWorks", /* @__PURE__ */ new Set());
|
|
@@ -3589,6 +3600,16 @@ class ee {
|
|
|
3589
3600
|
}, 100, { leading: !1 }));
|
|
3590
3601
|
this.vNodes = n.vNodes, this.thread = n.thread;
|
|
3591
3602
|
}
|
|
3603
|
+
workShapesDone(n, e) {
|
|
3604
|
+
for (const t of this.workShapes.keys())
|
|
3605
|
+
this.consumeDrawAll({
|
|
3606
|
+
workId: t,
|
|
3607
|
+
scenePath: n,
|
|
3608
|
+
viewId: this.thread.viewId,
|
|
3609
|
+
msgType: y.DrawWork,
|
|
3610
|
+
dataType: R.Local
|
|
3611
|
+
}, e);
|
|
3612
|
+
}
|
|
3592
3613
|
async updateSelector(n) {
|
|
3593
3614
|
var p;
|
|
3594
3615
|
const e = this.workShapes.get(Y);
|
|
@@ -3606,11 +3627,11 @@ class ee {
|
|
|
3606
3627
|
e.selectIds.forEach((f) => {
|
|
3607
3628
|
const d = this.vNodes.get(f);
|
|
3608
3629
|
if (d) {
|
|
3609
|
-
const { toolsType: u, op:
|
|
3630
|
+
const { toolsType: u, op: w, opt: S } = d;
|
|
3610
3631
|
c.set(f, {
|
|
3611
|
-
opt:
|
|
3632
|
+
opt: S,
|
|
3612
3633
|
toolsType: u,
|
|
3613
|
-
ops: (
|
|
3634
|
+
ops: (w == null ? void 0 : w.length) && K(w) || void 0
|
|
3614
3635
|
});
|
|
3615
3636
|
}
|
|
3616
3637
|
});
|
|
@@ -3635,8 +3656,8 @@ class ee {
|
|
|
3635
3656
|
}), this.thread.localLayer.removeAllChildren()), this.workShapes.get(Y)) {
|
|
3636
3657
|
const e = [];
|
|
3637
3658
|
e.push({
|
|
3638
|
-
type:
|
|
3639
|
-
dataType:
|
|
3659
|
+
type: y.Select,
|
|
3660
|
+
dataType: R.Local,
|
|
3640
3661
|
selectIds: [],
|
|
3641
3662
|
willSyncService: !1
|
|
3642
3663
|
}), this.thread.post({ sp: e });
|
|
@@ -3656,12 +3677,12 @@ class ee {
|
|
|
3656
3677
|
}
|
|
3657
3678
|
s && (await this.blurSelector({
|
|
3658
3679
|
viewId: t,
|
|
3659
|
-
msgType:
|
|
3680
|
+
msgType: y.Select,
|
|
3660
3681
|
dataType: o,
|
|
3661
3682
|
isSync: !0
|
|
3662
3683
|
}), this.thread.post({
|
|
3663
3684
|
sp: [{
|
|
3664
|
-
type:
|
|
3685
|
+
type: y.GetTextActive,
|
|
3665
3686
|
toolsType: P.Text,
|
|
3666
3687
|
workId: s
|
|
3667
3688
|
}]
|
|
@@ -3670,7 +3691,7 @@ class ee {
|
|
|
3670
3691
|
}
|
|
3671
3692
|
cursorHover(n) {
|
|
3672
3693
|
const { opt: e, toolsType: t, point: o } = n, s = this.setFullWork({
|
|
3673
|
-
workId:
|
|
3694
|
+
workId: mt,
|
|
3674
3695
|
toolsType: t,
|
|
3675
3696
|
opt: e
|
|
3676
3697
|
});
|
|
@@ -3684,7 +3705,7 @@ class ee {
|
|
|
3684
3705
|
return;
|
|
3685
3706
|
}
|
|
3686
3707
|
if (!e) {
|
|
3687
|
-
!this.setFullWork(n) && n.workId && ((o = this.tmpWorkShapeNode) == null ? void 0 : o.toolsType) === P.Selector && this.setTmpWorkId(n.workId), this.updateFullSelectWork(n);
|
|
3708
|
+
!this.setFullWork(n) && n.workId && ((o = this.tmpWorkShapeNode) == null ? void 0 : o.toolsType) === P.Selector && this.setTmpWorkId(n.workId.toString()), this.updateFullSelectWork(n);
|
|
3688
3709
|
return;
|
|
3689
3710
|
}
|
|
3690
3711
|
if (e && (t != null && t.length)) {
|
|
@@ -3697,7 +3718,7 @@ class ee {
|
|
|
3697
3718
|
canTextEdit: e.canTextEdit,
|
|
3698
3719
|
canRotate: e.canRotate,
|
|
3699
3720
|
scaleType: e.scaleType,
|
|
3700
|
-
type:
|
|
3721
|
+
type: y.Select,
|
|
3701
3722
|
selectRect: c,
|
|
3702
3723
|
points: e.getChildrenPoints(),
|
|
3703
3724
|
willSyncService: (n == null ? void 0 : n.willSyncService) || !1,
|
|
@@ -3715,20 +3736,22 @@ class ee {
|
|
|
3715
3736
|
t && this.removeNode(t);
|
|
3716
3737
|
}
|
|
3717
3738
|
removeNode(n) {
|
|
3718
|
-
var
|
|
3719
|
-
this.
|
|
3720
|
-
|
|
3721
|
-
}), this.vNodes.delete(n))
|
|
3739
|
+
var o;
|
|
3740
|
+
this.vNodes.get(n) && ((o = this.thread.fullLayer) == null || o.getElementsByName(n).forEach((s) => {
|
|
3741
|
+
s.remove();
|
|
3742
|
+
}), this.vNodes.delete(n)), this.workShapes.has(n) && (this.thread.localLayer.getElementsByName(n).forEach((s) => {
|
|
3743
|
+
s.remove();
|
|
3744
|
+
}), this.clearWorkShapeNodeCache(n));
|
|
3722
3745
|
}
|
|
3723
3746
|
setFullWork(n) {
|
|
3724
3747
|
const { workId: e, opt: t, toolsType: o } = n;
|
|
3725
3748
|
if (e && t && o) {
|
|
3726
|
-
const s = e
|
|
3749
|
+
const s = e.toString(), i = this.workShapes.get(s) || this.createWorkShapeNode({
|
|
3727
3750
|
toolsOpt: t,
|
|
3728
3751
|
toolsType: o,
|
|
3729
|
-
workId:
|
|
3752
|
+
workId: s
|
|
3730
3753
|
});
|
|
3731
|
-
return
|
|
3754
|
+
return i ? (i.setWorkId(s), this.workShapes.set(s, i), i) : void 0;
|
|
3732
3755
|
}
|
|
3733
3756
|
}
|
|
3734
3757
|
async consumeFull(n, e) {
|
|
@@ -3750,14 +3773,13 @@ class ee {
|
|
|
3750
3773
|
replaceId: i
|
|
3751
3774
|
}), n != null && n.updateNodeOpt && t.updataOptService(n.updateNodeOpt);
|
|
3752
3775
|
const r = [];
|
|
3753
|
-
n.workId && this.workShapes.delete(n.workId), n.willSyncService && r.push({
|
|
3776
|
+
n.workId && this.workShapes.delete(n.workId.toString()), n.willSyncService && r.push({
|
|
3754
3777
|
opt: n.opt,
|
|
3755
3778
|
toolsType: n.toolsType,
|
|
3756
|
-
type:
|
|
3779
|
+
type: y.FullWork,
|
|
3757
3780
|
workId: n.workId,
|
|
3758
3781
|
ops: n.ops,
|
|
3759
3782
|
updateNodeOpt: n.updateNodeOpt,
|
|
3760
|
-
// undoTickerId: data.undoTickerId,
|
|
3761
3783
|
viewId: this.thread.viewId
|
|
3762
3784
|
}), r.length && this.thread.post({ sp: r });
|
|
3763
3785
|
}
|
|
@@ -3765,7 +3787,7 @@ class ee {
|
|
|
3765
3787
|
async colloctEffectSelectWork(n) {
|
|
3766
3788
|
const e = this.workShapes.get(Y), { workId: t, msgType: o } = n;
|
|
3767
3789
|
if (e && t && e.selectIds && e.selectIds.includes(t.toString())) {
|
|
3768
|
-
o ===
|
|
3790
|
+
o === y.RemoveNode ? e.selectIds = e.selectIds.filter((s) => s !== t.toString()) : this.effectSelectNodeData.add(n), await new Promise((s) => {
|
|
3769
3791
|
setTimeout(() => {
|
|
3770
3792
|
s(!0);
|
|
3771
3793
|
}, 0);
|
|
@@ -3803,7 +3825,7 @@ class ee {
|
|
|
3803
3825
|
replaceId: r
|
|
3804
3826
|
}), s != null && s.updateNodeOpt && i.updataOptService(s.updateNodeOpt);
|
|
3805
3827
|
}
|
|
3806
|
-
s.workId && this.workShapes.delete(s.workId);
|
|
3828
|
+
s.workId && this.workShapes.delete(s.workId.toString());
|
|
3807
3829
|
}
|
|
3808
3830
|
}
|
|
3809
3831
|
this.reRenderSelector(n);
|
|
@@ -3818,7 +3840,7 @@ class ee {
|
|
|
3818
3840
|
const t = e.reRenderSelector();
|
|
3819
3841
|
t && this.thread.post({
|
|
3820
3842
|
sp: [{
|
|
3821
|
-
type:
|
|
3843
|
+
type: y.Select,
|
|
3822
3844
|
selectIds: e.selectIds,
|
|
3823
3845
|
selectRect: t,
|
|
3824
3846
|
willSyncService: n,
|
|
@@ -3854,8 +3876,8 @@ class ee {
|
|
|
3854
3876
|
}
|
|
3855
3877
|
}
|
|
3856
3878
|
clearWorkShapeNodeCache(n) {
|
|
3857
|
-
var e;
|
|
3858
|
-
(e = this.getWorkShape(n)) == null || e.clearTmpPoints(), this.workShapes.delete(n);
|
|
3879
|
+
var e, t;
|
|
3880
|
+
(e = this.getWorkShape(n)) == null || e.clearTmpPoints(), this.workShapes.delete(n), ((t = this.tmpWorkShapeNode) == null ? void 0 : t.getWorkId()) === n && this.setTmpWorkId(void 0);
|
|
3859
3881
|
}
|
|
3860
3882
|
drawEraser(n) {
|
|
3861
3883
|
var t, o;
|
|
@@ -3864,7 +3886,7 @@ class ee {
|
|
|
3864
3886
|
for (const s of n.newWorkDatas.values()) {
|
|
3865
3887
|
const i = s.workId.toString();
|
|
3866
3888
|
this.batchEraserWorks.add(i), e.push({
|
|
3867
|
-
type:
|
|
3889
|
+
type: y.FullWork,
|
|
3868
3890
|
workId: i,
|
|
3869
3891
|
ops: K(s.op),
|
|
3870
3892
|
opt: s.opt,
|
|
@@ -3878,7 +3900,7 @@ class ee {
|
|
|
3878
3900
|
}
|
|
3879
3901
|
(o = n.removeIds) == null || o.forEach((s) => {
|
|
3880
3902
|
this.batchEraserRemoveNodes.add(s);
|
|
3881
|
-
}),
|
|
3903
|
+
}), e.push(n), this.thread.post({ sp: e }), this.batchEraserCombine();
|
|
3882
3904
|
}
|
|
3883
3905
|
updateBatchEraserCombineNode(n, e) {
|
|
3884
3906
|
for (const t of e.keys())
|
|
@@ -3899,10 +3921,13 @@ class ee {
|
|
|
3899
3921
|
getWorkShape(n) {
|
|
3900
3922
|
return this.workShapes.get(n);
|
|
3901
3923
|
}
|
|
3924
|
+
getWorkShapes() {
|
|
3925
|
+
return this.workShapes;
|
|
3926
|
+
}
|
|
3902
3927
|
consumeDraw(n, e) {
|
|
3903
3928
|
const { op: t, workId: o, scenePath: s } = n;
|
|
3904
3929
|
if (t != null && t.length && o) {
|
|
3905
|
-
const i = this.workShapes.get(o);
|
|
3930
|
+
const i = this.workShapes.get(o.toString());
|
|
3906
3931
|
if (!i)
|
|
3907
3932
|
return;
|
|
3908
3933
|
const r = i.toolsType;
|
|
@@ -3915,7 +3940,7 @@ class ee {
|
|
|
3915
3940
|
data: n,
|
|
3916
3941
|
isFullWork: !0
|
|
3917
3942
|
});
|
|
3918
|
-
a.type ===
|
|
3943
|
+
a.type === y.Select && (a.selectIds && e.runReverseSelectWork(a.selectIds), this.thread.post({ sp: [a] }));
|
|
3919
3944
|
}
|
|
3920
3945
|
break;
|
|
3921
3946
|
case P.Eraser:
|
|
@@ -3954,19 +3979,19 @@ class ee {
|
|
|
3954
3979
|
var s, i, r;
|
|
3955
3980
|
const { workId: t, scenePath: o } = n;
|
|
3956
3981
|
if (t) {
|
|
3957
|
-
const a = this.workShapes.get(
|
|
3958
|
-
if (!
|
|
3982
|
+
const a = t.toString(), c = this.workShapes.get(a);
|
|
3983
|
+
if (!c)
|
|
3959
3984
|
return;
|
|
3960
|
-
const
|
|
3961
|
-
if (
|
|
3985
|
+
const l = c.toolsType;
|
|
3986
|
+
if (l === P.LaserPen)
|
|
3962
3987
|
return;
|
|
3963
|
-
const
|
|
3964
|
-
switch (
|
|
3988
|
+
const h = this.workShapes.get(mt), p = (s = h == null ? void 0 : h.selectIds) == null ? void 0 : s[0], f = c.consumeAll({ data: n });
|
|
3989
|
+
switch (l) {
|
|
3965
3990
|
case P.Selector:
|
|
3966
|
-
|
|
3991
|
+
f.selectIds && p && ((i = f.selectIds) != null && i.includes(p)) && h.cursorBlur(), f.type === y.Select && (f.selectIds && e.runReverseSelectWork(f.selectIds), this.thread.post({ sp: [{ ...f, scenePath: o }] })), (r = c.selectIds) != null && r.length ? c.clearTmpPoints() : this.clearWorkShapeNodeCache(a);
|
|
3967
3992
|
break;
|
|
3968
3993
|
case P.Eraser:
|
|
3969
|
-
|
|
3994
|
+
f != null && f.rect && this.drawEraser({ ...f, scenePath: o }), c.clearTmpPoints();
|
|
3970
3995
|
break;
|
|
3971
3996
|
case P.Arrow:
|
|
3972
3997
|
case P.Straight:
|
|
@@ -3976,10 +4001,10 @@ class ee {
|
|
|
3976
4001
|
case P.Polygon:
|
|
3977
4002
|
case P.SpeechBalloon:
|
|
3978
4003
|
case P.Pencil:
|
|
3979
|
-
|
|
4004
|
+
f && (this.drawCount = 0, this.thread.post({
|
|
3980
4005
|
drawCount: this.drawCount,
|
|
3981
|
-
sp: [
|
|
3982
|
-
})), this.clearWorkShapeNodeCache(
|
|
4006
|
+
sp: [f]
|
|
4007
|
+
})), this.clearWorkShapeNodeCache(a);
|
|
3983
4008
|
break;
|
|
3984
4009
|
}
|
|
3985
4010
|
}
|
|
@@ -4003,7 +4028,7 @@ class ee {
|
|
|
4003
4028
|
this.workShapes.get(n) || this.setTmpWorkId(n), (o = this.workShapes.get(n)) == null || o.setWorkOptions(e);
|
|
4004
4029
|
}
|
|
4005
4030
|
createWorkShapeNode(n) {
|
|
4006
|
-
return
|
|
4031
|
+
return wt({ ...n, vNodes: this.vNodes, fullLayer: this.thread.fullLayer, drawLayer: this.thread.localLayer }, this.thread.serviceWork);
|
|
4007
4032
|
}
|
|
4008
4033
|
}
|
|
4009
4034
|
class oe {
|
|
@@ -4076,31 +4101,31 @@ class oe {
|
|
|
4076
4101
|
return Math.min((n.animationIndex || 0) + (t || e), (n.animationWorkData || []).length);
|
|
4077
4102
|
}
|
|
4078
4103
|
async animationDraw() {
|
|
4079
|
-
var t, o, s, i, r, a, c, l, h, p, f, d, u,
|
|
4104
|
+
var t, o, s, i, r, a, c, l, h, p, f, d, u, w, S, b;
|
|
4080
4105
|
this.animationId = void 0;
|
|
4081
4106
|
let n = !1;
|
|
4082
4107
|
const e = /* @__PURE__ */ new Map();
|
|
4083
|
-
for (const [
|
|
4108
|
+
for (const [T, g] of this.workShapes.entries())
|
|
4084
4109
|
switch (g.toolsType) {
|
|
4085
4110
|
case P.Image: {
|
|
4086
4111
|
await ((o = g.node) == null ? void 0 : o.consumeServiceAsync({
|
|
4087
4112
|
isFullWork: !0,
|
|
4088
4113
|
scene: (t = this.thread.fullLayer.parent) == null ? void 0 : t.parent,
|
|
4089
4114
|
isMainThread: !0
|
|
4090
|
-
})), this.selectorWorkShapes.forEach((
|
|
4091
|
-
var
|
|
4092
|
-
(
|
|
4093
|
-
}), this.workShapes.delete(
|
|
4115
|
+
})), this.selectorWorkShapes.forEach((I, N) => {
|
|
4116
|
+
var W;
|
|
4117
|
+
(W = I.selectIds) != null && W.includes(T) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
|
|
4118
|
+
}), this.workShapes.delete(T);
|
|
4094
4119
|
break;
|
|
4095
4120
|
}
|
|
4096
4121
|
case P.Text: {
|
|
4097
4122
|
g.node && (await ((s = g.node) == null ? void 0 : s.consumeServiceAsync({
|
|
4098
4123
|
isFullWork: !0,
|
|
4099
|
-
replaceId:
|
|
4100
|
-
})), this.selectorWorkShapes.forEach((
|
|
4101
|
-
var
|
|
4102
|
-
(
|
|
4103
|
-
}), (i = g.node) == null || i.clearTmpPoints(), this.workShapes.delete(
|
|
4124
|
+
replaceId: T
|
|
4125
|
+
})), this.selectorWorkShapes.forEach((I, N) => {
|
|
4126
|
+
var W;
|
|
4127
|
+
(W = I.selectIds) != null && W.includes(T) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
|
|
4128
|
+
}), (i = g.node) == null || i.clearTmpPoints(), this.workShapes.delete(T));
|
|
4104
4129
|
break;
|
|
4105
4130
|
}
|
|
4106
4131
|
case P.Arrow:
|
|
@@ -4110,18 +4135,18 @@ class oe {
|
|
|
4110
4135
|
case P.Star:
|
|
4111
4136
|
case P.Polygon:
|
|
4112
4137
|
case P.SpeechBalloon: {
|
|
4113
|
-
const
|
|
4138
|
+
const I = !!g.ops;
|
|
4114
4139
|
if ((r = g.animationWorkData) != null && r.length) {
|
|
4115
4140
|
const N = g.oldRect;
|
|
4116
4141
|
(a = g.node) == null || a.consumeService({
|
|
4117
4142
|
op: g.animationWorkData,
|
|
4118
|
-
isFullWork:
|
|
4119
|
-
}),
|
|
4120
|
-
var
|
|
4121
|
-
(
|
|
4122
|
-
}), (c = g.node) == null || c.clearTmpPoints(), this.workShapes.delete(
|
|
4143
|
+
isFullWork: I
|
|
4144
|
+
}), I && (this.selectorWorkShapes.forEach((W, A) => {
|
|
4145
|
+
var v;
|
|
4146
|
+
(v = W.selectIds) != null && v.includes(T) && (this.willRunEffectSelectorIds.add(A), this.runEffect());
|
|
4147
|
+
}), (c = g.node) == null || c.clearTmpPoints(), this.workShapes.delete(T)), e.set(T, {
|
|
4123
4148
|
workState: N ? g.ops ? D.Done : D.Doing : D.Start,
|
|
4124
|
-
op: g.animationWorkData.filter((
|
|
4149
|
+
op: g.animationWorkData.filter((W, A) => {
|
|
4125
4150
|
if (A % 3 !== 2)
|
|
4126
4151
|
return !0;
|
|
4127
4152
|
}).slice(-2)
|
|
@@ -4134,28 +4159,28 @@ class oe {
|
|
|
4134
4159
|
(l = g.node) == null || l.consumeService({
|
|
4135
4160
|
op: g.animationWorkData || [],
|
|
4136
4161
|
isFullWork: !0,
|
|
4137
|
-
replaceId:
|
|
4138
|
-
}), (h = g.node) == null || h.updataOptService(g.updateNodeOpt), this.selectorWorkShapes.forEach((
|
|
4139
|
-
var
|
|
4140
|
-
(
|
|
4141
|
-
}), (p = g.node) == null || p.clearTmpPoints(), this.workShapes.delete(
|
|
4162
|
+
replaceId: T
|
|
4163
|
+
}), (h = g.node) == null || h.updataOptService(g.updateNodeOpt), this.selectorWorkShapes.forEach((I, N) => {
|
|
4164
|
+
var W;
|
|
4165
|
+
(W = I.selectIds) != null && W.includes(T) && (this.willRunEffectSelectorIds.add(N), this.runEffect());
|
|
4166
|
+
}), (p = g.node) == null || p.clearTmpPoints(), this.workShapes.delete(T);
|
|
4142
4167
|
else if (g.useAnimation) {
|
|
4143
4168
|
if (g.isDel) {
|
|
4144
|
-
(f = g.node) == null || f.clearTmpPoints(), this.workShapes.delete(
|
|
4169
|
+
(f = g.node) == null || f.clearTmpPoints(), this.workShapes.delete(T);
|
|
4145
4170
|
break;
|
|
4146
4171
|
}
|
|
4147
|
-
const
|
|
4172
|
+
const I = 3, N = this.computNextAnimationIndex(g, I), W = g.isDiff ? 0 : Math.max(0, (g.animationIndex || 0) - I), A = (g.animationWorkData || []).slice(W, N), v = (u = (d = g.node) == null ? void 0 : d.getWorkId()) == null ? void 0 : u.toString();
|
|
4148
4173
|
if ((g.animationIndex || 0) < N || g.isDiff) {
|
|
4149
|
-
if ((
|
|
4174
|
+
if ((w = g.node) == null || w.consumeService({
|
|
4150
4175
|
op: A,
|
|
4151
4176
|
isFullWork: !1
|
|
4152
4177
|
}), g.animationIndex = N, g.isDiff && (g.isDiff = !1), A.length) {
|
|
4153
4178
|
const x = A.filter((M, $) => {
|
|
4154
|
-
if ($ %
|
|
4179
|
+
if ($ % I !== I - 1)
|
|
4155
4180
|
return !0;
|
|
4156
4181
|
}).slice(-2);
|
|
4157
|
-
e.set(
|
|
4158
|
-
workState:
|
|
4182
|
+
e.set(T, {
|
|
4183
|
+
workState: W === 0 ? D.Start : N === ((S = g.animationWorkData) == null ? void 0 : S.length) ? D.Done : D.Doing,
|
|
4159
4184
|
op: x
|
|
4160
4185
|
});
|
|
4161
4186
|
}
|
|
@@ -4163,11 +4188,11 @@ class oe {
|
|
|
4163
4188
|
g.ops && ((b = g.node) == null || b.consumeService({
|
|
4164
4189
|
op: g.animationWorkData || [],
|
|
4165
4190
|
isFullWork: !0,
|
|
4166
|
-
replaceId:
|
|
4167
|
-
}), g.isDel = !0, e.set(
|
|
4191
|
+
replaceId: v
|
|
4192
|
+
}), g.isDel = !0, e.set(T, {
|
|
4168
4193
|
workState: D.Done,
|
|
4169
4194
|
op: A.filter((x, M) => {
|
|
4170
|
-
if (M %
|
|
4195
|
+
if (M % I !== I - 1)
|
|
4171
4196
|
return !0;
|
|
4172
4197
|
}).slice(-2)
|
|
4173
4198
|
}));
|
|
@@ -4178,16 +4203,16 @@ class oe {
|
|
|
4178
4203
|
}
|
|
4179
4204
|
}
|
|
4180
4205
|
if (n && this.runAnimation(), e.size) {
|
|
4181
|
-
const
|
|
4182
|
-
e.forEach((g,
|
|
4183
|
-
|
|
4184
|
-
type:
|
|
4185
|
-
uid:
|
|
4206
|
+
const T = [];
|
|
4207
|
+
e.forEach((g, I) => {
|
|
4208
|
+
T.push({
|
|
4209
|
+
type: y.Cursor,
|
|
4210
|
+
uid: I.split(gt)[0],
|
|
4186
4211
|
op: g.op,
|
|
4187
4212
|
workState: g.workState,
|
|
4188
4213
|
viewId: this.thread.viewId
|
|
4189
4214
|
});
|
|
4190
|
-
}), this.thread.post({ sp:
|
|
4215
|
+
}), this.thread.post({ sp: T });
|
|
4191
4216
|
}
|
|
4192
4217
|
}
|
|
4193
4218
|
runAnimation() {
|
|
@@ -4214,13 +4239,13 @@ class oe {
|
|
|
4214
4239
|
return !1;
|
|
4215
4240
|
}
|
|
4216
4241
|
activeWorkShape(n) {
|
|
4217
|
-
var f, d, u,
|
|
4242
|
+
var f, d, u, w;
|
|
4218
4243
|
const { workId: e, opt: t, toolsType: o, type: s, updateNodeOpt: i, ops: r, op: a, useAnimation: c } = n;
|
|
4219
4244
|
if (!e)
|
|
4220
4245
|
return;
|
|
4221
4246
|
const l = e.toString(), h = (f = this.vNodes.get(l)) == null ? void 0 : f.rect;
|
|
4222
4247
|
if (!((d = this.workShapes) != null && d.has(l))) {
|
|
4223
|
-
let
|
|
4248
|
+
let S = {
|
|
4224
4249
|
toolsType: o,
|
|
4225
4250
|
animationWorkData: a || [],
|
|
4226
4251
|
animationIndex: 0,
|
|
@@ -4231,9 +4256,9 @@ class oe {
|
|
|
4231
4256
|
oldRect: h,
|
|
4232
4257
|
isDiff: !1
|
|
4233
4258
|
};
|
|
4234
|
-
o && t && (
|
|
4259
|
+
o && t && (S = this.setNodeKey(S, o, t)), (u = this.workShapes) == null || u.set(l, S);
|
|
4235
4260
|
}
|
|
4236
|
-
const p = (
|
|
4261
|
+
const p = (w = this.workShapes) == null ? void 0 : w.get(l);
|
|
4237
4262
|
s && (p.type = s), r && (p.animationWorkData = dt(r), p.ops = r), i && (p.updateNodeOpt = i), a && (p.isDiff = this.hasDiffData(p.animationWorkData || [], a, p.toolsType), p.animationWorkData = a), p.node && p.node.getWorkId() !== l && p.node.setWorkId(l), h && (p.oldRect = h), o && t && (p.toolsType !== o && o && t && this.setNodeKey(p, o, t), p.node && p.node.setWorkOptions(t));
|
|
4238
4263
|
}
|
|
4239
4264
|
removeNode(n, e) {
|
|
@@ -4266,7 +4291,7 @@ class oe {
|
|
|
4266
4291
|
s && (a.type = s), a.node && a.node.getWorkId() !== r && a.node.setWorkId(r), a.selectIds = i || [];
|
|
4267
4292
|
}
|
|
4268
4293
|
setNodeKey(n, e, t) {
|
|
4269
|
-
return n.toolsType = e, n.node =
|
|
4294
|
+
return n.toolsType = e, n.node = wt({
|
|
4270
4295
|
toolsType: e,
|
|
4271
4296
|
toolsOpt: t,
|
|
4272
4297
|
vNodes: this.vNodes,
|
|
@@ -4292,7 +4317,7 @@ class se extends J {
|
|
|
4292
4317
|
}
|
|
4293
4318
|
async consume(e) {
|
|
4294
4319
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4295
|
-
if (t ===
|
|
4320
|
+
if (t === y.FullWork && o === R.Local && s === this.emitEventType)
|
|
4296
4321
|
return this.consumeForLocalWorker(e), !0;
|
|
4297
4322
|
}
|
|
4298
4323
|
async consumeForLocalWorker(e) {
|
|
@@ -4308,13 +4333,13 @@ class ie extends J {
|
|
|
4308
4333
|
}
|
|
4309
4334
|
async consume(e) {
|
|
4310
4335
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4311
|
-
if (t ===
|
|
4336
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4312
4337
|
return this.consumeForLocalWorker(e), !0;
|
|
4313
4338
|
}
|
|
4314
4339
|
async consumeForLocalWorker(e) {
|
|
4315
4340
|
var c;
|
|
4316
4341
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
|
|
4317
|
-
t ===
|
|
4342
|
+
t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
|
|
4318
4343
|
updateSelectorOpt: o,
|
|
4319
4344
|
willRefreshSelector: s,
|
|
4320
4345
|
willSyncService: i,
|
|
@@ -4330,14 +4355,14 @@ class ie extends J {
|
|
|
4330
4355
|
a && h.toolsType === P.Text ? c.push({
|
|
4331
4356
|
...h,
|
|
4332
4357
|
workId: l,
|
|
4333
|
-
type:
|
|
4334
|
-
dataType:
|
|
4358
|
+
type: y.TextUpdate,
|
|
4359
|
+
dataType: R.Local,
|
|
4335
4360
|
willSyncService: !0
|
|
4336
4361
|
}) : c.push(
|
|
4337
4362
|
{
|
|
4338
4363
|
...h,
|
|
4339
4364
|
workId: l,
|
|
4340
|
-
type:
|
|
4365
|
+
type: y.UpdateNode,
|
|
4341
4366
|
updateNodeOpt: {
|
|
4342
4367
|
useAnimation: !1
|
|
4343
4368
|
},
|
|
@@ -4356,13 +4381,13 @@ class re extends J {
|
|
|
4356
4381
|
}
|
|
4357
4382
|
async consume(e) {
|
|
4358
4383
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4359
|
-
if (t ===
|
|
4384
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4360
4385
|
return this.consumeForLocalWorker(e), !0;
|
|
4361
4386
|
}
|
|
4362
4387
|
async consumeForLocalWorker(e) {
|
|
4363
4388
|
var a;
|
|
4364
4389
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
|
|
4365
|
-
t ===
|
|
4390
|
+
t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
|
|
4366
4391
|
updateSelectorOpt: o,
|
|
4367
4392
|
willRefreshSelector: s,
|
|
4368
4393
|
willSyncService: i,
|
|
@@ -4378,7 +4403,7 @@ class re extends J {
|
|
|
4378
4403
|
{
|
|
4379
4404
|
...l,
|
|
4380
4405
|
workId: c,
|
|
4381
|
-
type:
|
|
4406
|
+
type: y.UpdateNode,
|
|
4382
4407
|
updateNodeOpt: {
|
|
4383
4408
|
useAnimation: !1
|
|
4384
4409
|
},
|
|
@@ -4397,13 +4422,13 @@ class ne extends J {
|
|
|
4397
4422
|
}
|
|
4398
4423
|
async consume(e) {
|
|
4399
4424
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4400
|
-
if (t ===
|
|
4425
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4401
4426
|
return await this.consumeForLocalWorker(e), !0;
|
|
4402
4427
|
}
|
|
4403
4428
|
async consumeForLocalWorker(e) {
|
|
4404
4429
|
var l, h;
|
|
4405
4430
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a, emitEventType: c } = e;
|
|
4406
|
-
t ===
|
|
4431
|
+
t === G.selectorId && o && (o.workState === D.Done && (o != null && o.translate) && (o.translate[0] || o.translate[1]) || o.workState !== D.Done ? await ((l = this.localWork) == null ? void 0 : l.updateSelector({
|
|
4407
4432
|
updateSelectorOpt: o,
|
|
4408
4433
|
willRefreshSelector: s,
|
|
4409
4434
|
willSyncService: i,
|
|
@@ -4425,7 +4450,7 @@ class ne extends J {
|
|
|
4425
4450
|
const d = r == null ? void 0 : r.selectRect;
|
|
4426
4451
|
if (a) {
|
|
4427
4452
|
p === D.Doing && f.push({
|
|
4428
|
-
type:
|
|
4453
|
+
type: y.Select,
|
|
4429
4454
|
selectIds: i.selectIds,
|
|
4430
4455
|
selectRect: d,
|
|
4431
4456
|
willSyncService: !0,
|
|
@@ -4433,18 +4458,18 @@ class ne extends J {
|
|
|
4433
4458
|
points: i.getChildrenPoints(),
|
|
4434
4459
|
textOpt: i.textOpt
|
|
4435
4460
|
});
|
|
4436
|
-
for (const [u,
|
|
4437
|
-
h &&
|
|
4438
|
-
...
|
|
4461
|
+
for (const [u, w] of s.entries())
|
|
4462
|
+
h && w.toolsType === P.Text ? f.push({
|
|
4463
|
+
...w,
|
|
4439
4464
|
workId: u,
|
|
4440
|
-
type:
|
|
4441
|
-
dataType:
|
|
4465
|
+
type: y.TextUpdate,
|
|
4466
|
+
dataType: R.Local,
|
|
4442
4467
|
willSyncService: !0
|
|
4443
4468
|
}) : f.push(
|
|
4444
4469
|
{
|
|
4445
|
-
...
|
|
4470
|
+
...w,
|
|
4446
4471
|
workId: u,
|
|
4447
|
-
type:
|
|
4472
|
+
type: y.UpdateNode,
|
|
4448
4473
|
updateNodeOpt: {
|
|
4449
4474
|
useAnimation: !1
|
|
4450
4475
|
},
|
|
@@ -4464,10 +4489,10 @@ class ae extends J {
|
|
|
4464
4489
|
}
|
|
4465
4490
|
async consume(e) {
|
|
4466
4491
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4467
|
-
if (t ===
|
|
4468
|
-
if (o ===
|
|
4492
|
+
if (t === y.RemoveNode) {
|
|
4493
|
+
if (o === R.Local && s === this.emitEventType)
|
|
4469
4494
|
return this.consumeForLocalWorker(e), !0;
|
|
4470
|
-
if (o ===
|
|
4495
|
+
if (o === R.Service && s === this.emitEventType)
|
|
4471
4496
|
return this.consumeForServiceWorker(e), !0;
|
|
4472
4497
|
}
|
|
4473
4498
|
}
|
|
@@ -4498,7 +4523,7 @@ class ae extends J {
|
|
|
4498
4523
|
a && s.push(a), this.localWork.removeNode(r), i.push(r);
|
|
4499
4524
|
}
|
|
4500
4525
|
o && s.push({
|
|
4501
|
-
type:
|
|
4526
|
+
type: y.RemoveNode,
|
|
4502
4527
|
removeIds: i
|
|
4503
4528
|
}), s.length && this.localWork.thread.post({ sp: s });
|
|
4504
4529
|
}
|
|
@@ -4510,10 +4535,10 @@ class ae extends J {
|
|
|
4510
4535
|
const t = (o = this.localWork) == null ? void 0 : o.vNodes.get(e);
|
|
4511
4536
|
if (t && t.toolsType === P.Text)
|
|
4512
4537
|
return {
|
|
4513
|
-
type:
|
|
4538
|
+
type: y.TextUpdate,
|
|
4514
4539
|
toolsType: P.Text,
|
|
4515
4540
|
workId: e,
|
|
4516
|
-
dataType:
|
|
4541
|
+
dataType: R.Local
|
|
4517
4542
|
};
|
|
4518
4543
|
}
|
|
4519
4544
|
}
|
|
@@ -4524,13 +4549,13 @@ class ce extends J {
|
|
|
4524
4549
|
}
|
|
4525
4550
|
async consume(e) {
|
|
4526
4551
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4527
|
-
if (t ===
|
|
4552
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4528
4553
|
return await this.consumeForLocalWorker(e), !0;
|
|
4529
4554
|
}
|
|
4530
4555
|
async consumeForLocalWorker(e) {
|
|
4531
4556
|
var r;
|
|
4532
4557
|
const { workId: t, updateNodeOpt: o, willSyncService: s, willSerializeData: i } = e;
|
|
4533
|
-
t ===
|
|
4558
|
+
t === G.selectorId && o && await ((r = this.localWork) == null ? void 0 : r.updateSelector({
|
|
4534
4559
|
updateSelectorOpt: o,
|
|
4535
4560
|
willSyncService: s,
|
|
4536
4561
|
willSerializeData: i,
|
|
@@ -4548,7 +4573,7 @@ class ce extends J {
|
|
|
4548
4573
|
};
|
|
4549
4574
|
if (c) {
|
|
4550
4575
|
h === D.Doing && p.push({
|
|
4551
|
-
type:
|
|
4576
|
+
type: y.Select,
|
|
4552
4577
|
selectIds: s.selectIds,
|
|
4553
4578
|
selectRect: f,
|
|
4554
4579
|
willSyncService: !0,
|
|
@@ -4556,7 +4581,7 @@ class ce extends J {
|
|
|
4556
4581
|
points: s.getChildrenPoints(),
|
|
4557
4582
|
textOpt: s.textOpt
|
|
4558
4583
|
}), l && h === D.Done && p.push({
|
|
4559
|
-
type:
|
|
4584
|
+
type: y.Select,
|
|
4560
4585
|
selectIds: s.selectIds,
|
|
4561
4586
|
selectRect: f,
|
|
4562
4587
|
willSyncService: !1,
|
|
@@ -4568,14 +4593,14 @@ class ce extends J {
|
|
|
4568
4593
|
u.toolsType === P.Text ? p.push({
|
|
4569
4594
|
...u,
|
|
4570
4595
|
workId: d,
|
|
4571
|
-
type:
|
|
4572
|
-
dataType:
|
|
4596
|
+
type: y.TextUpdate,
|
|
4597
|
+
dataType: R.Local,
|
|
4573
4598
|
willSyncService: !0
|
|
4574
4599
|
}) : p.push(
|
|
4575
4600
|
{
|
|
4576
4601
|
...u,
|
|
4577
4602
|
workId: d,
|
|
4578
|
-
type:
|
|
4603
|
+
type: y.UpdateNode,
|
|
4579
4604
|
updateNodeOpt: {
|
|
4580
4605
|
useAnimation: !1
|
|
4581
4606
|
},
|
|
@@ -4595,13 +4620,13 @@ class le extends J {
|
|
|
4595
4620
|
}
|
|
4596
4621
|
async consume(e) {
|
|
4597
4622
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4598
|
-
if (t ===
|
|
4623
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4599
4624
|
return await this.consumeForLocalWorker(e), !0;
|
|
4600
4625
|
}
|
|
4601
4626
|
async consumeForLocalWorker(e) {
|
|
4602
4627
|
var c;
|
|
4603
4628
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, emitEventType: a } = e;
|
|
4604
|
-
t ===
|
|
4629
|
+
t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
|
|
4605
4630
|
updateSelectorOpt: o,
|
|
4606
4631
|
willRefreshSelector: s,
|
|
4607
4632
|
willSyncService: i,
|
|
@@ -4616,19 +4641,19 @@ class le extends J {
|
|
|
4616
4641
|
const { param: t, postData: o, workShapeNode: s, res: i, newServiceStore: r } = e, { updateSelectorOpt: a, willSyncService: c, willSerializeData: l, isSync: h } = t, p = a.workState, f = o.sp || [], d = i == null ? void 0 : i.selectRect;
|
|
4617
4642
|
if (c) {
|
|
4618
4643
|
l && p === D.Done && f.push({
|
|
4619
|
-
type:
|
|
4644
|
+
type: y.Select,
|
|
4620
4645
|
selectIds: s.selectIds,
|
|
4621
4646
|
selectRect: d,
|
|
4622
4647
|
willSyncService: !0,
|
|
4623
4648
|
isSync: h,
|
|
4624
4649
|
points: s.getChildrenPoints()
|
|
4625
4650
|
});
|
|
4626
|
-
for (const [u,
|
|
4651
|
+
for (const [u, w] of r.entries())
|
|
4627
4652
|
f.push(
|
|
4628
4653
|
{
|
|
4629
|
-
...
|
|
4654
|
+
...w,
|
|
4630
4655
|
workId: u,
|
|
4631
|
-
type:
|
|
4656
|
+
type: y.UpdateNode,
|
|
4632
4657
|
updateNodeOpt: {
|
|
4633
4658
|
useAnimation: !1
|
|
4634
4659
|
},
|
|
@@ -4648,13 +4673,13 @@ class he extends J {
|
|
|
4648
4673
|
}
|
|
4649
4674
|
async consume(e) {
|
|
4650
4675
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4651
|
-
if (t ===
|
|
4676
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4652
4677
|
return await this.consumeForLocalWorker(e), !0;
|
|
4653
4678
|
}
|
|
4654
4679
|
async consumeForLocalWorker(e) {
|
|
4655
4680
|
var c;
|
|
4656
4681
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
|
|
4657
|
-
t ===
|
|
4682
|
+
t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
|
|
4658
4683
|
updateSelectorOpt: o,
|
|
4659
4684
|
willRefreshSelector: s,
|
|
4660
4685
|
willSyncService: i,
|
|
@@ -4667,7 +4692,7 @@ class he extends J {
|
|
|
4667
4692
|
const { param: t, postData: o, newServiceStore: s, workShapeNode: i, res: r } = e, { willSyncService: a, isSync: c, updateSelectorOpt: l, textUpdateForWoker: h } = t, p = o.sp || [], f = r == null ? void 0 : r.selectRect;
|
|
4668
4693
|
if (a && p) {
|
|
4669
4694
|
l.fontSize && p.push({
|
|
4670
|
-
type:
|
|
4695
|
+
type: y.Select,
|
|
4671
4696
|
selectIds: i.selectIds,
|
|
4672
4697
|
selectRect: f,
|
|
4673
4698
|
willSyncService: a,
|
|
@@ -4678,14 +4703,14 @@ class he extends J {
|
|
|
4678
4703
|
h && u.toolsType === P.Text ? p.push({
|
|
4679
4704
|
...u,
|
|
4680
4705
|
workId: d,
|
|
4681
|
-
type:
|
|
4682
|
-
dataType:
|
|
4706
|
+
type: y.TextUpdate,
|
|
4707
|
+
dataType: R.Local,
|
|
4683
4708
|
willSyncService: !0
|
|
4684
4709
|
}) : p.push(
|
|
4685
4710
|
{
|
|
4686
4711
|
...u,
|
|
4687
4712
|
workId: d,
|
|
4688
|
-
type:
|
|
4713
|
+
type: y.UpdateNode,
|
|
4689
4714
|
updateNodeOpt: {
|
|
4690
4715
|
useAnimation: !1
|
|
4691
4716
|
},
|
|
@@ -4705,13 +4730,13 @@ class pe extends J {
|
|
|
4705
4730
|
}
|
|
4706
4731
|
async consume(e) {
|
|
4707
4732
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4708
|
-
if (t ===
|
|
4733
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4709
4734
|
return this.consumeForLocalWorker(e), !0;
|
|
4710
4735
|
}
|
|
4711
4736
|
async consumeForLocalWorker(e) {
|
|
4712
4737
|
var c;
|
|
4713
4738
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r, textUpdateForWoker: a } = e;
|
|
4714
|
-
t ===
|
|
4739
|
+
t === G.selectorId && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
|
|
4715
4740
|
updateSelectorOpt: o,
|
|
4716
4741
|
willRefreshSelector: s,
|
|
4717
4742
|
willSyncService: i,
|
|
@@ -4730,7 +4755,7 @@ class pe extends J {
|
|
|
4730
4755
|
{
|
|
4731
4756
|
...f,
|
|
4732
4757
|
workId: p,
|
|
4733
|
-
type:
|
|
4758
|
+
type: y.UpdateNode,
|
|
4734
4759
|
updateNodeOpt: {
|
|
4735
4760
|
useAnimation: !1
|
|
4736
4761
|
},
|
|
@@ -4738,7 +4763,7 @@ class pe extends J {
|
|
|
4738
4763
|
}
|
|
4739
4764
|
);
|
|
4740
4765
|
l.push({
|
|
4741
|
-
type:
|
|
4766
|
+
type: y.Select,
|
|
4742
4767
|
selectIds: i.selectIds,
|
|
4743
4768
|
selectRect: h,
|
|
4744
4769
|
willSyncService: a,
|
|
@@ -4758,13 +4783,13 @@ class de extends J {
|
|
|
4758
4783
|
}
|
|
4759
4784
|
async consume(e) {
|
|
4760
4785
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4761
|
-
if (t ===
|
|
4786
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4762
4787
|
return this.consumeForLocalWorker(e), !0;
|
|
4763
4788
|
}
|
|
4764
4789
|
async consumeForLocalWorker(e) {
|
|
4765
4790
|
var a;
|
|
4766
4791
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
|
|
4767
|
-
t ===
|
|
4792
|
+
t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
|
|
4768
4793
|
updateSelectorOpt: o,
|
|
4769
4794
|
willRefreshSelector: s,
|
|
4770
4795
|
willSyncService: i,
|
|
@@ -4780,7 +4805,7 @@ class de extends J {
|
|
|
4780
4805
|
{
|
|
4781
4806
|
...d,
|
|
4782
4807
|
workId: f,
|
|
4783
|
-
type:
|
|
4808
|
+
type: y.UpdateNode,
|
|
4784
4809
|
updateNodeOpt: {
|
|
4785
4810
|
useAnimation: !1
|
|
4786
4811
|
},
|
|
@@ -4792,7 +4817,7 @@ class de extends J {
|
|
|
4792
4817
|
selectorColor: i.selectorColor,
|
|
4793
4818
|
scaleType: i.scaleType,
|
|
4794
4819
|
canRotate: i.canRotate,
|
|
4795
|
-
type:
|
|
4820
|
+
type: y.Select,
|
|
4796
4821
|
selectIds: i.selectIds,
|
|
4797
4822
|
selectRect: p,
|
|
4798
4823
|
willSyncService: a,
|
|
@@ -4811,13 +4836,13 @@ class ue extends J {
|
|
|
4811
4836
|
}
|
|
4812
4837
|
async consume(e) {
|
|
4813
4838
|
const { msgType: t, dataType: o, emitEventType: s } = e;
|
|
4814
|
-
if (t ===
|
|
4839
|
+
if (t === y.UpdateNode && o === R.Local && s === this.emitEventType)
|
|
4815
4840
|
return this.consumeForLocalWorker(e), !0;
|
|
4816
4841
|
}
|
|
4817
4842
|
async consumeForLocalWorker(e) {
|
|
4818
4843
|
var a;
|
|
4819
4844
|
const { workId: t, updateNodeOpt: o, willRefreshSelector: s, willSyncService: i, willSerializeData: r } = e;
|
|
4820
|
-
t ===
|
|
4845
|
+
t === G.selectorId && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
|
|
4821
4846
|
updateSelectorOpt: o,
|
|
4822
4847
|
willRefreshSelector: s,
|
|
4823
4848
|
willSyncService: i,
|
|
@@ -4833,7 +4858,7 @@ class ue extends J {
|
|
|
4833
4858
|
{
|
|
4834
4859
|
...l,
|
|
4835
4860
|
workId: c,
|
|
4836
|
-
type:
|
|
4861
|
+
type: y.UpdateNode,
|
|
4837
4862
|
updateNodeOpt: {
|
|
4838
4863
|
useAnimation: !1
|
|
4839
4864
|
},
|
|
@@ -4929,65 +4954,65 @@ class me {
|
|
|
4929
4954
|
post(n) {
|
|
4930
4955
|
this.combinePostMsg.add(n), this.runBatchPostData();
|
|
4931
4956
|
}
|
|
4932
|
-
async on(n
|
|
4957
|
+
async on(n) {
|
|
4933
4958
|
if (!await this.methodBuilder.consumeForMainThread(n)) {
|
|
4934
|
-
const { msgType:
|
|
4935
|
-
switch (
|
|
4936
|
-
case
|
|
4959
|
+
const { msgType: e, toolsType: t, opt: o, dataType: s, workId: i, workState: r } = n, a = i == null ? void 0 : i.toString();
|
|
4960
|
+
switch (e) {
|
|
4961
|
+
case y.Destroy:
|
|
4937
4962
|
this.destroy();
|
|
4938
4963
|
break;
|
|
4939
|
-
case
|
|
4964
|
+
case y.Clear:
|
|
4940
4965
|
this.clearAll();
|
|
4941
4966
|
break;
|
|
4942
|
-
case
|
|
4943
|
-
this.updateCamera(n)
|
|
4967
|
+
case y.UpdateCamera:
|
|
4968
|
+
this.updateCamera(n);
|
|
4944
4969
|
break;
|
|
4945
|
-
case
|
|
4946
|
-
if (
|
|
4970
|
+
case y.UpdateTools:
|
|
4971
|
+
if (s === R.Local && t && o) {
|
|
4947
4972
|
const c = {
|
|
4948
|
-
toolsType:
|
|
4949
|
-
toolsOpt:
|
|
4973
|
+
toolsType: t,
|
|
4974
|
+
toolsOpt: o
|
|
4950
4975
|
};
|
|
4951
4976
|
this.localWork.setToolsOpt(c);
|
|
4952
4977
|
}
|
|
4953
4978
|
break;
|
|
4954
|
-
case
|
|
4955
|
-
if (
|
|
4956
|
-
if (
|
|
4979
|
+
case y.CreateWork:
|
|
4980
|
+
if (i && o && t) {
|
|
4981
|
+
if (t === P.LaserPen) {
|
|
4957
4982
|
this.topWork.getTmpWorkShapeNode() || this.topWork.setToolsOpt({
|
|
4958
|
-
toolsType:
|
|
4959
|
-
toolsOpt:
|
|
4960
|
-
}), this.topWork.setWorkOptions(
|
|
4983
|
+
toolsType: t,
|
|
4984
|
+
toolsOpt: o
|
|
4985
|
+
}), a && this.topWork.setWorkOptions(a, o);
|
|
4961
4986
|
break;
|
|
4962
4987
|
}
|
|
4963
4988
|
this.localWork.getTmpWorkShapeNode() || this.localWork.setToolsOpt({
|
|
4964
|
-
toolsType:
|
|
4965
|
-
toolsOpt:
|
|
4966
|
-
}), this.localWork.setWorkOptions(
|
|
4989
|
+
toolsType: t,
|
|
4990
|
+
toolsOpt: o
|
|
4991
|
+
}), a && this.localWork.setWorkOptions(a, o);
|
|
4967
4992
|
}
|
|
4968
4993
|
break;
|
|
4969
|
-
case
|
|
4970
|
-
|
|
4994
|
+
case y.DrawWork:
|
|
4995
|
+
r === D.Done && s === R.Local ? this.consumeDrawAll(s, n) : this.consumeDraw(s, n);
|
|
4971
4996
|
break;
|
|
4972
|
-
case
|
|
4973
|
-
case
|
|
4974
|
-
if (
|
|
4975
|
-
this.consumeDrawAll(
|
|
4997
|
+
case y.UpdateNode:
|
|
4998
|
+
case y.FullWork:
|
|
4999
|
+
if (t === P.LaserPen) {
|
|
5000
|
+
this.consumeDrawAll(s, n);
|
|
4976
5001
|
break;
|
|
4977
5002
|
}
|
|
4978
|
-
this.consumeFull(
|
|
5003
|
+
this.consumeFull(s, n);
|
|
4979
5004
|
break;
|
|
4980
|
-
case
|
|
5005
|
+
case y.RemoveNode:
|
|
4981
5006
|
this.removeNode(n);
|
|
4982
5007
|
return;
|
|
4983
|
-
case
|
|
4984
|
-
|
|
5008
|
+
case y.Select:
|
|
5009
|
+
s === R.Service && (i === Y ? this.localWork.updateFullSelectWork(n) : this.serviceWork.runSelectWork(n));
|
|
4985
5010
|
break;
|
|
4986
|
-
case
|
|
5011
|
+
case y.CursorHover:
|
|
4987
5012
|
this.localWork.cursorHover(n);
|
|
4988
5013
|
break;
|
|
4989
|
-
case
|
|
4990
|
-
|
|
5014
|
+
case y.GetTextActive:
|
|
5015
|
+
s === R.Local && this.localWork.checkTextActive(n);
|
|
4991
5016
|
break;
|
|
4992
5017
|
}
|
|
4993
5018
|
}
|
|
@@ -4998,11 +5023,11 @@ class me {
|
|
|
4998
5023
|
this.localWork.blurSelector(n);
|
|
4999
5024
|
return;
|
|
5000
5025
|
}
|
|
5001
|
-
e ===
|
|
5026
|
+
e === R.Local && (this.localWork.removeWork(n), await this.localWork.colloctEffectSelectWork(n)), e === R.Service && (this.serviceWork.removeWork(n), await this.localWork.colloctEffectSelectWork(n));
|
|
5002
5027
|
}
|
|
5003
5028
|
async consumeFull(n, e) {
|
|
5004
5029
|
const t = await this.localWork.colloctEffectSelectWork(e);
|
|
5005
|
-
t && n ===
|
|
5030
|
+
t && n === R.Local && await this.localWork.consumeFull(t, this.scene), t && n === R.Service && this.serviceWork.consumeFull(t);
|
|
5006
5031
|
}
|
|
5007
5032
|
setCameraOpt(n) {
|
|
5008
5033
|
this.cameraOpt = n;
|
|
@@ -5013,47 +5038,51 @@ class me {
|
|
|
5013
5038
|
this.mainThreadPostId || (this.mainThreadPostId = requestAnimationFrame(this.combinePost.bind(this)));
|
|
5014
5039
|
}
|
|
5015
5040
|
combinePostData() {
|
|
5016
|
-
var
|
|
5041
|
+
var t;
|
|
5017
5042
|
this.mainThreadPostId = void 0;
|
|
5018
5043
|
const n = [];
|
|
5019
|
-
let e
|
|
5020
|
-
for (const
|
|
5021
|
-
if ((
|
|
5022
|
-
for (const
|
|
5023
|
-
let
|
|
5024
|
-
for (const
|
|
5025
|
-
if (ct(
|
|
5026
|
-
|
|
5044
|
+
let e;
|
|
5045
|
+
for (const o of this.combinePostMsg.values()) {
|
|
5046
|
+
if ((t = o.sp) != null && t.length)
|
|
5047
|
+
for (const s of o.sp) {
|
|
5048
|
+
let i = !1;
|
|
5049
|
+
for (const r of n)
|
|
5050
|
+
if (ct(s, r)) {
|
|
5051
|
+
i = !0;
|
|
5027
5052
|
break;
|
|
5028
5053
|
}
|
|
5029
|
-
|
|
5054
|
+
i || n.push(s);
|
|
5030
5055
|
}
|
|
5031
|
-
|
|
5056
|
+
q(o.drawCount) && (e = o.drawCount);
|
|
5032
5057
|
}
|
|
5033
5058
|
return this.combinePostMsg.clear(), {
|
|
5034
5059
|
sp: n,
|
|
5035
|
-
drawCount: e
|
|
5036
|
-
workerTasksqueueCount: t
|
|
5060
|
+
drawCount: e
|
|
5037
5061
|
};
|
|
5038
5062
|
}
|
|
5039
5063
|
combinePost() {
|
|
5040
5064
|
var t, o, s;
|
|
5041
|
-
const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !==
|
|
5042
|
-
e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, n.drawCount === void 0 && delete n.drawCount,
|
|
5065
|
+
const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== y.None || Object.keys(i).filter((r) => r === "type").length);
|
|
5066
|
+
e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, n.drawCount === void 0 && delete n.drawCount, (n != null && n.drawCount || (s = n.sp) != null && s.length) && this.opt.post(n);
|
|
5043
5067
|
}
|
|
5044
5068
|
clearAll() {
|
|
5045
5069
|
this.fullLayer.children.length && (this.fullLayer.parent.children.forEach((n) => {
|
|
5046
5070
|
n.name !== "viewport" && n.remove();
|
|
5047
|
-
}), this.fullLayer.removeAllChildren()), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear()
|
|
5071
|
+
}), this.fullLayer.removeAllChildren()), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
|
|
5072
|
+
sp: [{
|
|
5073
|
+
type: y.Clear
|
|
5074
|
+
}]
|
|
5075
|
+
});
|
|
5048
5076
|
}
|
|
5049
5077
|
consumeDrawAll(n, e) {
|
|
5050
5078
|
const { ops: t, op: o, workId: s } = e;
|
|
5051
5079
|
if ((t || o != null && o.length) && s) {
|
|
5052
|
-
|
|
5080
|
+
const i = s.toString();
|
|
5081
|
+
if (this.topWork.localWorkShapes.get(i)) {
|
|
5053
5082
|
this.topWork.consumeDrawAll(e);
|
|
5054
5083
|
return;
|
|
5055
5084
|
}
|
|
5056
|
-
if (this.localWork.workShapes.get(
|
|
5085
|
+
if (this.localWork.workShapes.get(i)) {
|
|
5057
5086
|
this.localWork.consumeDrawAll(e, this.serviceWork);
|
|
5058
5087
|
return;
|
|
5059
5088
|
}
|
|
@@ -5062,29 +5091,30 @@ class me {
|
|
|
5062
5091
|
consumeDraw(n, e) {
|
|
5063
5092
|
const { op: t, workId: o } = e;
|
|
5064
5093
|
if (t != null && t.length && o) {
|
|
5065
|
-
|
|
5094
|
+
const s = o.toString();
|
|
5095
|
+
if (this.topWork.localWorkShapes.get(s)) {
|
|
5066
5096
|
this.topWork.consumeDraw(e);
|
|
5067
5097
|
return;
|
|
5068
5098
|
}
|
|
5069
|
-
if (this.localWork.workShapes.get(
|
|
5099
|
+
if (this.localWork.workShapes.get(s)) {
|
|
5070
5100
|
this.localWork.consumeDraw(e, this.serviceWork);
|
|
5071
5101
|
return;
|
|
5072
5102
|
}
|
|
5073
|
-
n ===
|
|
5103
|
+
n === R.Service && this.serviceWork.consumeDraw(e);
|
|
5074
5104
|
}
|
|
5075
5105
|
}
|
|
5076
5106
|
updateCamera(n) {
|
|
5077
|
-
var
|
|
5078
|
-
const { cameraOpt: e } = n;
|
|
5107
|
+
var o;
|
|
5108
|
+
const { cameraOpt: e, scenePath: t } = n;
|
|
5079
5109
|
if (e && !ct(this.cameraOpt, e)) {
|
|
5080
|
-
const
|
|
5081
|
-
if (
|
|
5082
|
-
for (const [
|
|
5110
|
+
const s = this.localWork.getWorkShape(mt);
|
|
5111
|
+
if (s && ((o = s.selectIds) != null && o.length) && s.cursorBlur(), t && [...this.localWork.getWorkShapes().keys()].filter((r) => r !== mt).length && this.localWork.workShapesDone(t, this.serviceWork), this.setCameraOpt(e), this.vNodes.curNodeMap.size && (this.vNodes.clearTarget(), this.vNodes.updateNodesRect(), this.localWork.reRenderSelector(), this.serviceWork.selectorWorkShapes.size))
|
|
5112
|
+
for (const [i, r] of this.serviceWork.selectorWorkShapes.entries())
|
|
5083
5113
|
this.serviceWork.runSelectWork({
|
|
5084
|
-
workId:
|
|
5085
|
-
selectIds:
|
|
5086
|
-
msgType:
|
|
5087
|
-
dataType:
|
|
5114
|
+
workId: i,
|
|
5115
|
+
selectIds: r.selectIds,
|
|
5116
|
+
msgType: y.Select,
|
|
5117
|
+
dataType: R.Service,
|
|
5088
5118
|
viewId: this.viewId
|
|
5089
5119
|
});
|
|
5090
5120
|
}
|
|
@@ -5095,7 +5125,8 @@ class me {
|
|
|
5095
5125
|
depth: !1,
|
|
5096
5126
|
desynchronized: !0,
|
|
5097
5127
|
...n,
|
|
5098
|
-
autoRender: !0
|
|
5128
|
+
autoRender: !0,
|
|
5129
|
+
id: this.viewId
|
|
5099
5130
|
});
|
|
5100
5131
|
}
|
|
5101
5132
|
createLayer(n, e, t) {
|
|
@@ -5139,26 +5170,26 @@ class ye {
|
|
|
5139
5170
|
async on(n) {
|
|
5140
5171
|
const { msgType: e } = n;
|
|
5141
5172
|
switch (e) {
|
|
5142
|
-
case
|
|
5173
|
+
case y.Snapshot:
|
|
5143
5174
|
await this.getSnapshot(n), this.destroy();
|
|
5144
5175
|
return;
|
|
5145
|
-
case
|
|
5176
|
+
case y.BoundingBox:
|
|
5146
5177
|
await this.getBoundingRect(n), this.destroy();
|
|
5147
5178
|
return;
|
|
5148
5179
|
}
|
|
5149
5180
|
}
|
|
5150
5181
|
createWorkShapeNode(n) {
|
|
5151
|
-
return
|
|
5182
|
+
return wt({ ...n, fullLayer: this.fullLayer, drawLayer: void 0 });
|
|
5152
5183
|
}
|
|
5153
5184
|
setFullWork(n) {
|
|
5154
5185
|
const { workId: e, opt: t, toolsType: o } = n;
|
|
5155
5186
|
if (e && t && o) {
|
|
5156
|
-
const s = e
|
|
5187
|
+
const s = e.toString(), i = this.workShapes.get(s) || this.createWorkShapeNode({
|
|
5157
5188
|
toolsOpt: t,
|
|
5158
5189
|
toolsType: o,
|
|
5159
|
-
workId:
|
|
5190
|
+
workId: s
|
|
5160
5191
|
});
|
|
5161
|
-
return
|
|
5192
|
+
return i ? (i.setWorkId(e.toString()), this.workShapes.set(s, i), i) : void 0;
|
|
5162
5193
|
}
|
|
5163
5194
|
}
|
|
5164
5195
|
async runFullWork(n) {
|
|
@@ -5190,14 +5221,14 @@ class ye {
|
|
|
5190
5221
|
for (const [c, l] of Object.entries(t))
|
|
5191
5222
|
if (l != null && l.type)
|
|
5192
5223
|
switch (l == null ? void 0 : l.type) {
|
|
5193
|
-
case
|
|
5194
|
-
case
|
|
5224
|
+
case y.UpdateNode:
|
|
5225
|
+
case y.FullWork: {
|
|
5195
5226
|
const { opt: h } = l, p = await this.runFullWork({
|
|
5196
5227
|
...l,
|
|
5197
5228
|
opt: h,
|
|
5198
5229
|
workId: c,
|
|
5199
|
-
msgType:
|
|
5200
|
-
dataType:
|
|
5230
|
+
msgType: y.FullWork,
|
|
5231
|
+
dataType: R.Service,
|
|
5201
5232
|
viewId: this.viewId
|
|
5202
5233
|
});
|
|
5203
5234
|
r = B(r, p);
|
|
@@ -5221,7 +5252,7 @@ class ye {
|
|
|
5221
5252
|
};
|
|
5222
5253
|
}
|
|
5223
5254
|
getRectImageBitmap(n, e) {
|
|
5224
|
-
const t = n.x * this.opt.displayer.dpr, o = n.y * this.opt.displayer.dpr, s = n.w * this.opt.displayer.dpr, i = n.h * this.opt.displayer.dpr;
|
|
5255
|
+
const t = n.x * this.opt.displayer.dpr, o = n.y * this.opt.displayer.dpr, s = n.w > 0 && n.w * this.opt.displayer.dpr || 1, i = n.h > 0 && n.h * this.opt.displayer.dpr || 1;
|
|
5225
5256
|
return createImageBitmap(this.fullLayer.parent.canvas, t, o, s, i, e);
|
|
5226
5257
|
}
|
|
5227
5258
|
async getSnapshotRender(n) {
|
|
@@ -5231,7 +5262,7 @@ class ye {
|
|
|
5231
5262
|
const o = await this.getRectImageBitmap(this.getSceneRect(), t);
|
|
5232
5263
|
o && (this.post({
|
|
5233
5264
|
sp: [{
|
|
5234
|
-
type:
|
|
5265
|
+
type: y.Snapshot,
|
|
5235
5266
|
scenePath: e,
|
|
5236
5267
|
imageBitmap: o,
|
|
5237
5268
|
viewId: this.viewId
|
|
@@ -5246,13 +5277,13 @@ class ye {
|
|
|
5246
5277
|
for (const [i, r] of Object.entries(t))
|
|
5247
5278
|
if (r != null && r.type)
|
|
5248
5279
|
switch (r == null ? void 0 : r.type) {
|
|
5249
|
-
case
|
|
5250
|
-
case
|
|
5280
|
+
case y.UpdateNode:
|
|
5281
|
+
case y.FullWork: {
|
|
5251
5282
|
const a = await this.runFullWork({
|
|
5252
5283
|
...r,
|
|
5253
5284
|
workId: i,
|
|
5254
|
-
msgType:
|
|
5255
|
-
dataType:
|
|
5285
|
+
msgType: y.FullWork,
|
|
5286
|
+
dataType: R.Service,
|
|
5256
5287
|
viewId: this.viewId
|
|
5257
5288
|
});
|
|
5258
5289
|
s = B(s, a);
|
|
@@ -5261,7 +5292,7 @@ class ye {
|
|
|
5261
5292
|
}
|
|
5262
5293
|
s && this.post({
|
|
5263
5294
|
sp: [{
|
|
5264
|
-
type:
|
|
5295
|
+
type: y.BoundingBox,
|
|
5265
5296
|
scenePath: e,
|
|
5266
5297
|
rect: s
|
|
5267
5298
|
}]
|
|
@@ -5296,8 +5327,8 @@ class ye {
|
|
|
5296
5327
|
}
|
|
5297
5328
|
combinePost() {
|
|
5298
5329
|
var t, o, s;
|
|
5299
|
-
const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !==
|
|
5300
|
-
e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, (n != null && n.drawCount ||
|
|
5330
|
+
const n = this.combinePostData(), e = (t = n.sp) == null ? void 0 : t.filter((i) => i.type !== y.None || Object.keys(i).filter((r) => r === "type").length);
|
|
5331
|
+
e != null && e.length && (n.sp = e.map((i) => i.viewId ? i : { ...i, viewId: this.viewId })), ((o = n.sp) == null ? void 0 : o.length) === 0 && delete n.sp, (n != null && n.drawCount || (s = n.sp) != null && s.length) && this.opt.post(n);
|
|
5301
5332
|
}
|
|
5302
5333
|
createScene(n) {
|
|
5303
5334
|
return new Nt({
|
|
@@ -5340,7 +5371,7 @@ class We {
|
|
|
5340
5371
|
}
|
|
5341
5372
|
post(n) {
|
|
5342
5373
|
const { drawCount: e, sp: t, workerTasksqueueCount: o } = n;
|
|
5343
|
-
|
|
5374
|
+
this.master.isBusy && q(o) && this.master.setWorkerTasksqueueCount(o), q(e) && this.master.setMaxDrawCount(e), t && this.master.collectorSyncData(t);
|
|
5344
5375
|
}
|
|
5345
5376
|
destroy() {
|
|
5346
5377
|
this.mainThreadMap.clear();
|
|
@@ -5351,30 +5382,30 @@ class We {
|
|
|
5351
5382
|
createSnapshotThread(n, e) {
|
|
5352
5383
|
return new ye(n, e);
|
|
5353
5384
|
}
|
|
5354
|
-
consume(n) {
|
|
5385
|
+
async consume(n) {
|
|
5355
5386
|
var e, t, o, s;
|
|
5356
5387
|
for (const i of n.values()) {
|
|
5357
5388
|
const { msgType: r, viewId: a, tasksqueue: c, mainTasksqueueCount: l, layerOpt: h, offscreenCanvasOpt: p, cameraOpt: f } = i;
|
|
5358
|
-
if (r ===
|
|
5359
|
-
const u = (e = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : e.displayer,
|
|
5360
|
-
if (u &&
|
|
5361
|
-
const
|
|
5389
|
+
if (r === y.Init) {
|
|
5390
|
+
const u = (e = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : e.displayer, w = u == null ? void 0 : u.canvasContainerRef.current;
|
|
5391
|
+
if (u && w && h && p) {
|
|
5392
|
+
const S = this.createMainThread(a, {
|
|
5362
5393
|
displayer: u,
|
|
5363
|
-
container:
|
|
5394
|
+
container: w,
|
|
5364
5395
|
layerOpt: h,
|
|
5365
5396
|
master: this.master,
|
|
5366
5397
|
canvasOpt: p,
|
|
5367
5398
|
post: this.post.bind(this)
|
|
5368
5399
|
});
|
|
5369
|
-
this.mainThreadMap.set(a,
|
|
5400
|
+
this.mainThreadMap.set(a, S), S && f && S.setCameraOpt(f);
|
|
5370
5401
|
}
|
|
5371
5402
|
continue;
|
|
5372
5403
|
}
|
|
5373
|
-
if ((r ===
|
|
5374
|
-
const u = (o = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : o.displayer,
|
|
5375
|
-
if (u &&
|
|
5376
|
-
|
|
5377
|
-
const
|
|
5404
|
+
if ((r === y.Snapshot || r === y.BoundingBox) && a === ((t = this.master.control.viewContainerManager.mainView) == null ? void 0 : t.id)) {
|
|
5405
|
+
const u = (o = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : o.displayer, w = (s = u.snapshotContainerRef) == null ? void 0 : s.current;
|
|
5406
|
+
if (u && w && f) {
|
|
5407
|
+
w.style.width = `${f.width}px`, w.style.height = `${f.height}px`;
|
|
5408
|
+
const S = {
|
|
5378
5409
|
...Pt.defaultLayerOpt,
|
|
5379
5410
|
offscreen: !1,
|
|
5380
5411
|
width: f.width,
|
|
@@ -5386,31 +5417,31 @@ class We {
|
|
|
5386
5417
|
};
|
|
5387
5418
|
this.snapshotThread = this.createSnapshotThread(a, {
|
|
5388
5419
|
displayer: u,
|
|
5389
|
-
container:
|
|
5390
|
-
layerOpt:
|
|
5420
|
+
container: w,
|
|
5421
|
+
layerOpt: S,
|
|
5391
5422
|
master: this.master,
|
|
5392
5423
|
canvasOpt: b,
|
|
5393
5424
|
post: this.post.bind(this)
|
|
5394
5425
|
}), this.snapshotThread.on(i).then(() => {
|
|
5395
|
-
this.snapshotThread = void 0,
|
|
5426
|
+
this.snapshotThread = void 0, w.innerHTML = "", w.style.width = "", w.style.height = "";
|
|
5396
5427
|
});
|
|
5397
5428
|
continue;
|
|
5398
5429
|
}
|
|
5399
5430
|
}
|
|
5400
|
-
if (r ===
|
|
5401
|
-
for (const [u,
|
|
5402
|
-
const
|
|
5403
|
-
|
|
5431
|
+
if (r === y.TasksQueue && (c != null && c.size)) {
|
|
5432
|
+
for (const [u, w] of this.mainThreadMap.entries()) {
|
|
5433
|
+
const S = c.get(u);
|
|
5434
|
+
S && (await w.on(S), l && this.post({ workerTasksqueueCount: l }));
|
|
5404
5435
|
}
|
|
5405
5436
|
continue;
|
|
5406
5437
|
}
|
|
5407
|
-
if (a ===
|
|
5438
|
+
if (a === Gt) {
|
|
5408
5439
|
for (const u of this.mainThreadMap.values())
|
|
5409
|
-
u.on(i), r ===
|
|
5440
|
+
u.on(i), r === y.Destroy && this.mainThreadMap.delete(a);
|
|
5410
5441
|
continue;
|
|
5411
5442
|
}
|
|
5412
5443
|
const d = this.mainThreadMap.get(a);
|
|
5413
|
-
d && (d.on(i), r ===
|
|
5444
|
+
d && (d.on(i), r === y.Destroy && this.mainThreadMap.delete(a));
|
|
5414
5445
|
}
|
|
5415
5446
|
}
|
|
5416
5447
|
}
|