@netless/appliance-plugin 1.0.8 → 1.0.10

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.
Files changed (44) hide show
  1. package/cdn/cdn.js +1 -1
  2. package/cdn/fullWorker-CjGKnN.js +439 -0
  3. package/cdn/subWorker-DUJqv_.js +439 -0
  4. package/dist/appliance-plugin.js +1 -1
  5. package/dist/appliance-plugin.mjs +1 -1
  6. package/dist/core/enum.d.ts +20 -16
  7. package/dist/core/mainEngine.d.ts +1 -0
  8. package/dist/core/mainThread/base.d.ts +6 -0
  9. package/dist/core/mainThread/snapshotThread.d.ts +7 -1
  10. package/dist/core/mainThread/subLocalThread.d.ts +7 -4
  11. package/dist/core/mainThread/subServiceThread.d.ts +1 -0
  12. package/dist/core/mainThread/subTopThread.d.ts +2 -2
  13. package/dist/core/mainThread/workerMainThread.d.ts +1 -1
  14. package/dist/core/msgEvent/baseForMainThread.d.ts +3 -3
  15. package/dist/core/msgEvent/baseForWorker.d.ts +3 -3
  16. package/dist/core/msgEvent/forMainThread.d.ts +2 -4
  17. package/dist/core/msgEvent/forWorker.d.ts +2 -4
  18. package/dist/core/tools/base.d.ts +12 -0
  19. package/dist/core/tools/image.d.ts +6 -3
  20. package/dist/core/tools/pencilEraser.d.ts +0 -2
  21. package/dist/core/tools/pencilEraserBitMap.d.ts +83 -0
  22. package/dist/core/tools/selector.d.ts +2 -5
  23. package/dist/core/tools/utils.d.ts +6 -5
  24. package/dist/core/types.d.ts +3 -2
  25. package/dist/core/utils/image.d.ts +5 -0
  26. package/dist/core/utils/math.d.ts +3 -0
  27. package/dist/core/worker/base.d.ts +11 -2
  28. package/dist/core/worker/fullWorkerLocal.d.ts +4 -2
  29. package/dist/core/worker/subWorkerTopLayer.d.ts +2 -2
  30. package/dist/core/worker/workerManager.d.ts +1 -0
  31. package/dist/fullWorker.js +153 -152
  32. package/dist/index-C29o_HLi.js +1 -0
  33. package/dist/{index-DBzmxM2f.mjs → index-C4KNxHht.mjs} +708 -547
  34. package/dist/{index-CWXxYSm5.mjs → index-CIJP6_Qj.mjs} +5880 -5414
  35. package/dist/index-DmfRoAiB.js +1 -0
  36. package/dist/plugin/baseApplianceManager.d.ts +5 -4
  37. package/dist/plugin/const.d.ts +3 -0
  38. package/dist/plugin/types.d.ts +28 -1
  39. package/dist/subWorker.js +153 -152
  40. package/package.json +2 -2
  41. package/cdn/fullWorker-8AH6yz.js +0 -438
  42. package/cdn/subWorker-B-aVKt.js +0 -438
  43. package/dist/index-B42Mnde_.js +0 -1
  44. package/dist/index-CBeudPfv.js +0 -1
@@ -1,14 +1,14 @@
1
- var se = Object.defineProperty;
2
- var oe = (I, t, e) => t in I ? se(I, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : I[t] = e;
3
- var d = (I, t, e) => oe(I, typeof t != "symbol" ? t + "" : t, e);
4
- import { E as f, a as T, i as re, c as C, b as ie, d as ae, e as z, f as x, g as ne, D as F, h as w, j as B, t as P, k as p, S as Y, l as N, m as V, n as ce, C as H, o as le, p as v, M as A, T as $, q as _, r as Z, s as he, u as j, V as G, v as pe } from "./index-CWXxYSm5.mjs";
5
- import { Scene as Q, Group as J } from "spritejs";
6
- import { cloneDeep as ee, xor as de, isEqual as X, isNumber as ue } from "lodash";
1
+ var te = Object.defineProperty;
2
+ var se = (N, t, e) => t in N ? te(N, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : N[t] = e;
3
+ var d = (N, t, e) => se(N, typeof t != "symbol" ? t + "" : t, e);
4
+ import { E as f, a as I, i as oe, c as R, b as re, d as ie, e as B, f as A, g as ae, D as x, h as w, j as U, t as F, k as p, S as X, l as L, m as K, n as ce, C as _, o as ne, p as T, M as C, T as G, q as z, r as V, s as le, u as $, V as Z, v as he } from "./index-CIJP6_Qj.mjs";
5
+ import { Scene as Y, Group as Q } from "spritejs";
6
+ import { cloneDeep as J, xor as pe, isEqual as j, isNumber as de } from "lodash";
7
7
  import "lineclip";
8
8
  import "white-web-sdk";
9
9
  import "react-dom";
10
10
  import "react";
11
- class fe {
11
+ class ue {
12
12
  constructor(t, e) {
13
13
  d(this, "viewId");
14
14
  d(this, "scene");
@@ -27,7 +27,7 @@ class fe {
27
27
  getUnLockNodes() {
28
28
  const t = /* @__PURE__ */ new Map();
29
29
  for (const [e, s] of this.curNodeMap.entries())
30
- s.toolsType === f.Image && s.opt.locked || s.toolsType === f.Text && (s.opt.workState === T.Doing || s.opt.workState === T.Start) || t.set(e, s);
30
+ s.toolsType === f.Image && s.opt.locked || s.toolsType === f.Text && (s.opt.workState === I.Doing || s.opt.workState === I.Start) || t.set(e, s);
31
31
  return t;
32
32
  }
33
33
  getNodesByType(t) {
@@ -39,7 +39,7 @@ class fe {
39
39
  hasRenderNodes() {
40
40
  let t = !1;
41
41
  for (const e of this.curNodeMap.values())
42
- re(e) && (t = !0);
42
+ oe(e) && (t = !0);
43
43
  return t;
44
44
  }
45
45
  has(t) {
@@ -50,7 +50,7 @@ class fe {
50
50
  name: t,
51
51
  rect: e.rect
52
52
  };
53
- e.rect && (s.rect = C(e.rect)), e.op && ie(e.op) && (s.op = C(e.op)), e.canRotate && (s.canRotate = e.canRotate), e.scaleType && (s.scaleType = e.scaleType), e.opt && (s.opt = C(e.opt)), e.toolsType && (s.toolsType = e.toolsType), e.centerPos && (s.centerPos = C(e.centerPos)), ae(e.isSelected) && (s.isSelected = e.isSelected), s.rect ? this.curNodeMap.set(t, s) : this.curNodeMap.delete(t);
53
+ e.rect && (s.rect = R(e.rect)), e.op && re(e.op) && (s.op = R(e.op)), e.canRotate && (s.canRotate = e.canRotate), e.scaleType && (s.scaleType = e.scaleType), e.opt && (s.opt = R(e.opt)), e.toolsType && (s.toolsType = e.toolsType), e.centerPos && (s.centerPos = R(e.centerPos)), ie(e.isSelected) && (s.isSelected = e.isSelected), s.rect ? this.curNodeMap.set(t, s) : this.curNodeMap.delete(t);
54
54
  }
55
55
  selected(t) {
56
56
  this.setInfo(t, { isSelected: !0 });
@@ -66,8 +66,8 @@ class fe {
66
66
  }
67
67
  hasRectIntersectRange(t, e = !0) {
68
68
  for (const s of this.curNodeMap.values())
69
- if (z(t, s.rect)) {
70
- if (e && s.toolsType === f.Image && s.opt.locked || e && s.toolsType === f.Text && (s.opt.workState === T.Doing || s.opt.workState === T.Start))
69
+ if (B(t, s.rect)) {
70
+ if (e && s.toolsType === f.Image && s.opt.locked || e && s.toolsType === f.Text && (s.opt.workState === I.Doing || s.opt.workState === I.Start))
71
71
  continue;
72
72
  return !0;
73
73
  }
@@ -76,11 +76,11 @@ class fe {
76
76
  getRectIntersectRange(t, e = !0, s = !0) {
77
77
  let o;
78
78
  const r = /* @__PURE__ */ new Map();
79
- for (const [i, n] of this.curNodeMap.entries())
80
- if (z(t, n.rect)) {
81
- if (e && n.toolsType === f.Image && n.opt.locked || s && n.toolsType === f.Text && (n.opt.workState === T.Doing || n.opt.workState === T.Start))
79
+ for (const [i, a] of this.curNodeMap.entries())
80
+ if (B(t, a.rect)) {
81
+ if (e && a.toolsType === f.Image && a.opt.locked || s && a.toolsType === f.Text && (a.opt.workState === I.Doing || a.opt.workState === I.Start))
82
82
  continue;
83
- o = x(o, n.rect), r.set(i, n);
83
+ o = A(o, a.rect), r.set(i, a);
84
84
  }
85
85
  return {
86
86
  rectRange: o,
@@ -88,7 +88,7 @@ class fe {
88
88
  };
89
89
  }
90
90
  getNodeRectFormShape(t, e) {
91
- const s = ne(e.toolsType);
91
+ const s = ae(e.toolsType);
92
92
  return this.fullLayer && (s == null ? void 0 : s.getRectFromLayer(this.fullLayer, t));
93
93
  }
94
94
  updateNodeRect(t) {
@@ -118,19 +118,19 @@ class fe {
118
118
  combineIntersectRect(t) {
119
119
  let e = t;
120
120
  return this.curNodeMap.forEach((s) => {
121
- z(e, s.rect) && (e = x(e, s.rect));
121
+ B(e, s.rect) && (e = A(e, s.rect));
122
122
  }), e;
123
123
  }
124
124
  setTargetAssignKeys(t) {
125
125
  const e = /* @__PURE__ */ new Map();
126
126
  for (const s of t) {
127
127
  const o = this.curNodeMap.get(s);
128
- o && e.set(s, C(o));
128
+ o && e.set(s, R(o));
129
129
  }
130
- return this.targetNodeMap.push(C(e)), this.targetNodeMap.length - 1;
130
+ return this.targetNodeMap.push(R(e)), this.targetNodeMap.length - 1;
131
131
  }
132
132
  setTarget() {
133
- return this.targetNodeMap.push(C(this.curNodeMap)), this.targetNodeMap.length - 1;
133
+ return this.targetNodeMap.push(R(this.curNodeMap)), this.targetNodeMap.length - 1;
134
134
  }
135
135
  getLastTarget() {
136
136
  return this.targetNodeMap[this.targetNodeMap.length - 1];
@@ -148,7 +148,7 @@ class fe {
148
148
  this.targetNodeMap.length = 0;
149
149
  }
150
150
  }
151
- class Se {
151
+ class fe {
152
152
  constructor(t) {
153
153
  d(this, "vNodes");
154
154
  d(this, "thread");
@@ -156,7 +156,7 @@ class Se {
156
156
  d(this, "localWorkShapes", /* @__PURE__ */ new Map());
157
157
  d(this, "tmpOpt");
158
158
  d(this, "animationId");
159
- d(this, "syncUnitTime", F.syncOpt.interval);
159
+ d(this, "syncUnitTime", x.syncOpt.interval);
160
160
  this.vNodes = t.vNodes, this.thread = t.thread;
161
161
  }
162
162
  createLocalWork(t) {
@@ -181,7 +181,7 @@ class Se {
181
181
  return o && this.localWorkShapes.set(t, {
182
182
  node: o,
183
183
  toolsType: o.toolsType,
184
- workState: T.Start
184
+ workState: I.Start
185
185
  }), o;
186
186
  }
187
187
  }
@@ -205,7 +205,7 @@ class Se {
205
205
  if (!r)
206
206
  return;
207
207
  const i = r.node.consume({ data: t, isFullWork: !1, isSubWorker: !0 });
208
- i.rect && (r.result = i, r.workState = T.Doing, o && this.localWorkShapes.set(o, r));
208
+ i.rect && (r.result = i, r.workState = I.Doing, o && this.localWorkShapes.set(o, r));
209
209
  }
210
210
  this.runAnimation();
211
211
  }
@@ -219,31 +219,31 @@ class Se {
219
219
  createWorkShapeNode(t) {
220
220
  const { toolsType: e } = t;
221
221
  if (e === f.LaserPen)
222
- return B({ ...t, vNodes: this.vNodes, fullLayer: this.thread.topLayer, drawLayer: this.thread.topLayer });
222
+ return U({ ...t, vNodes: this.vNodes, fullLayer: this.thread.topLayer, drawLayer: this.thread.topLayer });
223
223
  }
224
224
  setNodeKey(t, e, s, o) {
225
225
  return e.toolsType = s, e.node = this.createWorkShapeNode({ workId: t, toolsType: s, toolsOpt: o }), e;
226
226
  }
227
227
  activeServiceWorkShape(t) {
228
228
  var S, u;
229
- const { workId: e, opt: s, toolsType: o, type: r, updateNodeOpt: i, ops: n, op: c } = t;
229
+ const { workId: e, opt: s, toolsType: o, type: r, updateNodeOpt: i, ops: a, op: n } = t;
230
230
  if (!e)
231
231
  return;
232
- const a = e.toString(), h = (S = this.vNodes.get(a)) == null ? void 0 : S.rect;
233
- if (!((u = this.serviceWorkShapes) != null && u.has(a))) {
232
+ const c = e.toString(), h = (S = this.vNodes.get(c)) == null ? void 0 : S.rect;
233
+ if (!((u = this.serviceWorkShapes) != null && u.has(c))) {
234
234
  let y = {
235
235
  toolsType: o,
236
- animationWorkData: c || [],
236
+ animationWorkData: n || [],
237
237
  animationIndex: 0,
238
238
  type: r,
239
239
  updateNodeOpt: i,
240
- ops: n,
240
+ ops: a,
241
241
  oldRect: h
242
242
  };
243
- o && s && (y = this.setNodeKey(a, y, o, s)), this.serviceWorkShapes.set(a, y);
243
+ o && s && (y = this.setNodeKey(c, y, o, s)), this.serviceWorkShapes.set(c, y);
244
244
  }
245
- const l = this.serviceWorkShapes.get(a);
246
- r && (l.type = r), n && (l.animationWorkData = P(n), l.ops = n), i && (l.updateNodeOpt = i), c && (l.animationWorkData = c), l.node && l.node.getWorkId() !== a && l.node.setWorkId(a), h && (l.oldRect = h), o && s && (l.toolsType !== o && o && s && this.setNodeKey(a, l, o, s), l.node && l.node.setWorkOptions(s));
245
+ const l = this.serviceWorkShapes.get(c);
246
+ r && (l.type = r), a && (l.animationWorkData = F(a), l.ops = a), i && (l.updateNodeOpt = i), n && (l.animationWorkData = n), l.node && l.node.getWorkId() !== c && l.node.setWorkId(c), h && (l.oldRect = h), o && s && (l.toolsType !== o && o && s && this.setNodeKey(c, l, o, s), l.node && l.node.setWorkOptions(s));
247
247
  }
248
248
  computNextAnimationIndex(t, e) {
249
249
  var r;
@@ -251,50 +251,50 @@ class Se {
251
251
  return Math.min((t.animationIndex || 0) + (o || e), (t.animationWorkData || []).length);
252
252
  }
253
253
  animationDraw() {
254
- var o, r, i, n;
254
+ var o, r, i, a;
255
255
  this.animationId = void 0;
256
256
  let t = !1;
257
257
  const e = /* @__PURE__ */ new Map(), s = [];
258
- for (const [c, a] of this.serviceWorkShapes.entries())
259
- switch (a.toolsType) {
258
+ for (const [n, c] of this.serviceWorkShapes.entries())
259
+ switch (c.toolsType) {
260
260
  case f.LaserPen: {
261
- const l = this.computNextAnimationIndex(a, 8), S = Math.max(0, a.animationIndex || 0), u = (a.animationWorkData || []).slice(S, l);
262
- if ((a.animationIndex || 0) < l && ((o = a.node) == null || o.consumeService({
261
+ const l = this.computNextAnimationIndex(c, 8), S = Math.max(0, c.animationIndex || 0), u = (c.animationWorkData || []).slice(S, l);
262
+ if ((c.animationIndex || 0) < l && ((o = c.node) == null || o.consumeService({
263
263
  op: u,
264
264
  isFullWork: !1
265
- }), a.animationIndex = l, u.length && e.set(c, {
266
- workState: S === 0 ? T.Start : l === ((r = a.animationWorkData) == null ? void 0 : r.length) ? T.Done : T.Doing,
265
+ }), c.animationIndex = l, u.length && e.set(n, {
266
+ workState: S === 0 ? I.Start : l === ((r = c.animationWorkData) == null ? void 0 : r.length) ? I.Done : I.Doing,
267
267
  op: u.slice(-2)
268
- })), a.isDel) {
269
- (i = a.node) == null || i.clearTmpPoints(), this.serviceWorkShapes.delete(c);
268
+ })), c.isDel) {
269
+ (i = c.node) == null || i.clearTmpPoints(), this.serviceWorkShapes.delete(n);
270
270
  break;
271
271
  }
272
- a.ops && a.animationIndex === ((n = a.animationWorkData) == null ? void 0 : n.length) && !a.isDel && (this.thread.topLayer.getElementsByName(c.toString())[0] || (a.isDel = !0, this.serviceWorkShapes.set(c, a))), t = !0;
272
+ c.ops && c.animationIndex === ((a = c.animationWorkData) == null ? void 0 : a.length) && !c.isDel && (this.thread.topLayer.getElementsByName(n.toString())[0] || (c.isDel = !0, this.serviceWorkShapes.set(n, c))), t = !0;
273
273
  break;
274
274
  }
275
275
  }
276
- for (const [c, a] of this.localWorkShapes.entries()) {
277
- const { result: h, toolsType: l, isDel: S, workState: u } = a;
276
+ for (const [n, c] of this.localWorkShapes.entries()) {
277
+ const { result: h, toolsType: l, isDel: S, workState: u } = c;
278
278
  switch (l) {
279
279
  case f.LaserPen: {
280
280
  if (S) {
281
- a.node.clearTmpPoints(), this.localWorkShapes.delete(c), s.push({
282
- removeIds: [c.toString()],
281
+ c.node.clearTmpPoints(), this.localWorkShapes.delete(n), s.push({
282
+ removeIds: [n.toString()],
283
283
  type: p.RemoveNode
284
284
  });
285
285
  break;
286
286
  }
287
- h && ((h.op || h.ops) && s.push(h), a.result = void 0), !this.thread.topLayer.getElementsByName(c.toString())[0] && u === T.Done && (a.isDel = !0, this.localWorkShapes.set(c, a)), t = !0;
287
+ h && ((h.op || h.ops) && s.push(h), c.result = void 0), !this.thread.topLayer.getElementsByName(n.toString())[0] && u === I.Done && (c.isDel = !0, this.localWorkShapes.set(n, c)), t = !0;
288
288
  break;
289
289
  }
290
290
  }
291
291
  }
292
- t && this.runAnimation(), e.size && e.forEach((c, a) => {
292
+ t && this.runAnimation(), e.size && e.forEach((n, c) => {
293
293
  s.push({
294
294
  type: p.Cursor,
295
- uid: a.split(Y)[0],
296
- op: c.op,
297
- workState: c.workState,
295
+ uid: c.split(X)[0],
296
+ op: n.op,
297
+ workState: n.workState,
298
298
  viewId: this.thread.viewId
299
299
  });
300
300
  }), s.length && this.thread.post({ sp: s });
@@ -310,7 +310,7 @@ class Se {
310
310
  this.tmpOpt.toolsOpt = e, s = this.createWorkShapeNode({ workId: t, toolsType: r, toolsOpt: e }), s && this.localWorkShapes.set(t, {
311
311
  node: s,
312
312
  toolsType: r,
313
- workState: T.Start
313
+ workState: I.Start
314
314
  }), this.setToolsOpt(this.tmpOpt);
315
315
  }
316
316
  e != null && e.syncUnitTime || (e.syncUnitTime = this.syncUnitTime), s && s.setWorkOptions(e);
@@ -324,12 +324,12 @@ class Se {
324
324
  if (!r)
325
325
  return;
326
326
  const i = r.node.consumeAll({ data: t });
327
- r.result = i, r.workState = T.Done, o && this.localWorkShapes.set(o, r);
327
+ r.result = i, r.workState = I.Done, o && this.localWorkShapes.set(o, r);
328
328
  }
329
329
  this.runAnimation();
330
330
  }
331
331
  }
332
- class ke {
332
+ class Se {
333
333
  constructor(t) {
334
334
  d(this, "vNodes");
335
335
  d(this, "thread");
@@ -338,14 +338,17 @@ class ke {
338
338
  d(this, "batchEraserRemoveNodes", /* @__PURE__ */ new Set());
339
339
  d(this, "batchEraserWorks", /* @__PURE__ */ new Set());
340
340
  d(this, "tmpOpt");
341
- d(this, "syncUnitTime", F.syncOpt.interval);
341
+ d(this, "syncUnitTime", x.syncOpt.interval);
342
342
  d(this, "drawCount", 0);
343
343
  d(this, "drawWorkActiveId");
344
- d(this, "batchEraserCombine", le(() => {
344
+ d(this, "batchEraserCombine", ne(() => {
345
345
  this.updateBatchEraserCombineNode(this.batchEraserWorks, this.batchEraserRemoveNodes), this.batchEraserWorks.clear(), this.batchEraserRemoveNodes.clear();
346
346
  }, 100, { leading: !1 }));
347
347
  this.vNodes = t.vNodes, this.thread = t.thread;
348
348
  }
349
+ async loadImageBitMap(t) {
350
+ return this.thread.loadImageBitMap(t);
351
+ }
349
352
  createLocalWork(t) {
350
353
  const { workId: e, opt: s, toolsType: o } = t;
351
354
  if (e && s) {
@@ -367,42 +370,40 @@ class ke {
367
370
  }, e);
368
371
  }
369
372
  async updateSelector(t) {
370
- var u;
371
- const e = this.workShapes.get(N);
372
- if (!((u = e == null ? void 0 : e.selectIds) != null && u.length)) return;
373
- const { callback: s, ...o } = t, { updateSelectorOpt: r, willSerializeData: i, scene: n } = o, c = await (e == null ? void 0 : e.updateSelector({
373
+ var S;
374
+ const e = this.workShapes.get(L);
375
+ if (!((S = e == null ? void 0 : e.selectIds) != null && S.length)) return;
376
+ const { callback: s, ...o } = t, { updateSelectorOpt: r, willSerializeData: i } = o, a = await (e == null ? void 0 : e.updateSelector({
374
377
  updateSelectorOpt: r,
375
- selectIds: ee(e.selectIds),
378
+ selectIds: J(e.selectIds),
376
379
  vNodes: this.vNodes,
377
380
  willSerializeData: i,
378
- worker: this,
379
- scene: n,
380
- isMainThread: !0
381
- })), a = /* @__PURE__ */ new Map();
382
- let h;
383
- c != null && c.selectIds && (h = de(e.selectIds, c.selectIds), c.selectIds.forEach((y) => {
384
- const m = this.vNodes.get(y);
385
- if (m) {
386
- const { toolsType: g, op: W, opt: M } = m;
387
- a.set(y, {
388
- opt: M,
389
- toolsType: g,
390
- ops: (W == null ? void 0 : W.length) && V(W) || void 0
381
+ worker: this
382
+ })), n = /* @__PURE__ */ new Map();
383
+ let c;
384
+ a != null && a.selectIds && (c = pe(e.selectIds, a.selectIds), a.selectIds.forEach((u) => {
385
+ const y = this.vNodes.get(u);
386
+ if (y) {
387
+ const { toolsType: m, op: v, opt: W } = y;
388
+ n.set(u, {
389
+ opt: W,
390
+ toolsType: m,
391
+ ops: (v == null ? void 0 : v.length) && K(v) || void 0
391
392
  });
392
393
  }
393
- }), e.selectIds = c.selectIds);
394
- const l = [], S = s && s({
395
- res: c,
394
+ }), e.selectIds = a.selectIds);
395
+ const h = [], l = s && s({
396
+ res: a,
396
397
  workShapeNode: e,
397
398
  param: o,
398
- postData: { sp: l },
399
- newServiceStore: a
400
- }) || { sp: l };
401
- h && S.sp.push({
399
+ postData: { sp: h },
400
+ newServiceStore: n
401
+ }) || { sp: h };
402
+ c && l.sp.push({
402
403
  type: p.RemoveNode,
403
- removeIds: h,
404
+ removeIds: c,
404
405
  viewId: this.thread.viewId
405
- }), S.sp.length && this.thread.post(S);
406
+ }), l.sp.length && this.thread.post(l);
406
407
  }
407
408
  destroy() {
408
409
  this.clearAll();
@@ -410,7 +411,7 @@ class ke {
410
411
  clearAll() {
411
412
  if (this.thread.localLayer.children.length && (this.thread.topLayer.parent.children.forEach((e) => {
412
413
  e.name !== "viewport" && e.remove();
413
- }), this.thread.localLayer.removeAllChildren()), this.workShapes.get(N)) {
414
+ }), this.thread.localLayer.removeAllChildren()), this.workShapes.get(L)) {
414
415
  const e = [];
415
416
  e.push({
416
417
  type: p.Select,
@@ -426,9 +427,9 @@ class ke {
426
427
  if (e != null && e.length) {
427
428
  let r;
428
429
  for (const i of this.vNodes.curNodeMap.values()) {
429
- const { rect: n, name: c, toolsType: a, opt: h } = i, l = e[0] * this.thread.fullLayer.worldScaling[0] + this.thread.fullLayer.worldPosition[0], S = e[1] * this.thread.fullLayer.worldScaling[1] + this.thread.fullLayer.worldPosition[1];
430
- if (a === f.Text && ce([l, S], n) && h.workState === T.Done) {
431
- r = c;
430
+ const { rect: a, name: n, toolsType: c, opt: h } = i, l = e[0] * this.thread.fullLayer.worldScaling[0] + this.thread.fullLayer.worldPosition[0], S = e[1] * this.thread.fullLayer.worldScaling[1] + this.thread.fullLayer.worldPosition[1];
431
+ if (c === f.Text && ce([l, S], a) && h.workState === I.Done) {
432
+ r = n;
432
433
  break;
433
434
  }
434
435
  }
@@ -448,36 +449,36 @@ class ke {
448
449
  }
449
450
  cursorHover(t) {
450
451
  const { opt: e, toolsType: s, point: o } = t, r = this.setFullWork({
451
- workId: H,
452
+ workId: _,
452
453
  toolsType: s,
453
454
  opt: e
454
455
  });
455
456
  r && o && r.cursorHover(o);
456
457
  }
457
458
  updateFullSelectWork(t) {
458
- var o, r, i, n, c;
459
- const e = this.workShapes.get(N), { selectIds: s } = t;
459
+ var o, r, i, a, n;
460
+ const e = this.workShapes.get(L), { selectIds: s } = t;
460
461
  if (!(s != null && s.length)) {
461
462
  this.blurSelector(t);
462
463
  return;
463
464
  }
464
465
  if (!e) {
465
- const a = this.setFullWork(t);
466
- !a && t.workId && this.tmpOpt && ((o = this.tmpOpt) == null ? void 0 : o.toolsType) === f.Selector && this.setWorkOptions(t.workId.toString(), t.opt || this.tmpOpt.toolsOpt), a && this.updateFullSelectWork(t);
466
+ const c = this.setFullWork(t);
467
+ !c && t.workId && this.tmpOpt && ((o = this.tmpOpt) == null ? void 0 : o.toolsType) === f.Selector && this.setWorkOptions(t.workId.toString(), t.opt || this.tmpOpt.toolsOpt), c && this.updateFullSelectWork(t);
467
468
  return;
468
469
  }
469
470
  if (e && (s != null && s.length)) {
470
- const { selectRect: a } = e.updateSelectIds(s), h = [{
471
+ const { selectRect: c } = e.updateSelectIds(s), h = [{
471
472
  ...t,
472
473
  selectorColor: ((r = t.opt) == null ? void 0 : r.strokeColor) || e.selectorColor,
473
474
  strokeColor: ((i = t.opt) == null ? void 0 : i.strokeColor) || e.strokeColor,
474
- fillColor: ((n = t.opt) == null ? void 0 : n.fillColor) || e.fillColor,
475
- textOpt: ((c = t.opt) == null ? void 0 : c.textOpt) || e.textOpt,
475
+ fillColor: ((a = t.opt) == null ? void 0 : a.fillColor) || e.fillColor,
476
+ textOpt: ((n = t.opt) == null ? void 0 : n.textOpt) || e.textOpt,
476
477
  canTextEdit: e.canTextEdit,
477
478
  canRotate: e.canRotate,
478
479
  scaleType: e.scaleType,
479
480
  type: p.Select,
480
- selectRect: a,
481
+ selectRect: c,
481
482
  points: e.getChildrenPoints(),
482
483
  willSyncService: (t == null ? void 0 : t.willSyncService) || !1,
483
484
  opt: (t == null ? void 0 : t.willSyncService) && e.getWorkOptions() || void 0,
@@ -503,16 +504,16 @@ class ke {
503
504
  };
504
505
  }
505
506
  async removeSelector(t) {
506
- const { willSyncService: e } = t, s = [], o = [], r = this.workShapes.get(N);
507
+ const { willSyncService: e } = t, s = [], o = [], r = this.workShapes.get(L);
507
508
  if (!r)
508
509
  return;
509
510
  const i = r.selectIds && [...r.selectIds] || [];
510
- for (const n of i) {
511
- if (this.vNodes.get(n)) {
512
- const a = this.commandDeleteText(n);
513
- a && s.push(a);
511
+ for (const a of i) {
512
+ if (this.vNodes.get(a)) {
513
+ const c = this.commandDeleteText(a);
514
+ c && s.push(c);
514
515
  }
515
- this.removeNode(n), o.push(n);
516
+ this.removeNode(a), o.push(a);
516
517
  }
517
518
  o.length && s.push({
518
519
  type: p.RemoveNode,
@@ -547,26 +548,25 @@ class ke {
547
548
  }), i ? (this.workShapes.set(r, i), i) : void 0;
548
549
  }
549
550
  }
550
- async consumeFull(t, e) {
551
- var r;
552
- const s = this.setFullWork(t), o = t.ops && P(t.ops);
553
- if (s) {
554
- const i = (r = t.workId) == null ? void 0 : r.toString();
555
- s.toolsType === f.Image && e ? await s.consumeServiceAsync({
556
- scene: e,
551
+ async consumeFull(t) {
552
+ var o;
553
+ const e = this.setFullWork(t), s = t.ops && F(t.ops);
554
+ if (e) {
555
+ const r = (o = t.workId) == null ? void 0 : o.toString();
556
+ e.toolsType === f.Image ? await e.consumeServiceAsync({
557
557
  isFullWork: !0,
558
- replaceId: i,
559
- isMainThread: !0
560
- }) : s.toolsType === f.Text ? await s.consumeServiceAsync({
558
+ replaceId: r,
559
+ worker: this
560
+ }) : e.toolsType === f.Text ? await e.consumeServiceAsync({
561
561
  isFullWork: !0,
562
- replaceId: i
563
- }) : s.consumeService({
564
- op: o,
562
+ replaceId: r
563
+ }) : e.consumeService({
564
+ op: s,
565
565
  isFullWork: !0,
566
- replaceId: i
567
- }), t != null && t.updateNodeOpt && s.updataOptService(t.updateNodeOpt);
568
- const n = [];
569
- t.workId && this.workShapes.delete(t.workId.toString()), t.willSyncService && n.push({
566
+ replaceId: r
567
+ }), t != null && t.updateNodeOpt && e.updataOptService(t.updateNodeOpt);
568
+ const i = [];
569
+ t.workId && this.workShapes.delete(t.workId.toString()), t.willSyncService && i.push({
570
570
  opt: t.opt,
571
571
  toolsType: t.toolsType,
572
572
  type: p.FullWork,
@@ -574,11 +574,11 @@ class ke {
574
574
  ops: t.ops,
575
575
  updateNodeOpt: t.updateNodeOpt,
576
576
  viewId: this.thread.viewId
577
- }), n.length && this.thread.post({ sp: n });
577
+ }), i.length && this.thread.post({ sp: i });
578
578
  }
579
579
  }
580
580
  async colloctEffectSelectWork(t) {
581
- const e = this.workShapes.get(N), { workId: s, msgType: o } = t;
581
+ const e = this.workShapes.get(L), { workId: s, msgType: o } = t;
582
582
  if (e && s && e.selectIds && e.selectIds.includes(s.toString())) {
583
583
  o === p.RemoveNode ? e.selectIds = e.selectIds.filter((r) => r !== s.toString()) : this.effectSelectNodeData.add(t), await new Promise((r) => {
584
584
  setTimeout(() => {
@@ -593,45 +593,44 @@ class ke {
593
593
  return t;
594
594
  }
595
595
  async runEffectSelectWork(t) {
596
- var e, s, o;
597
- for (const r of this.effectSelectNodeData.values()) {
598
- const i = this.setFullWork(r);
599
- if (i) {
600
- const n = (e = r.workId) == null ? void 0 : e.toString();
601
- if (i.toolsType === f.Image)
602
- await i.consumeServiceAsync({
603
- scene: (o = (s = this.thread.localLayer) == null ? void 0 : s.parent) == null ? void 0 : o.parent,
596
+ var e;
597
+ for (const s of this.effectSelectNodeData.values()) {
598
+ const o = this.setFullWork(s);
599
+ if (o) {
600
+ const r = (e = s.workId) == null ? void 0 : e.toString();
601
+ if (o.toolsType === f.Image)
602
+ await o.consumeServiceAsync({
604
603
  isFullWork: !0,
605
- replaceId: n,
606
- isMainThread: !0
604
+ replaceId: r,
605
+ worker: this
607
606
  });
608
- else if (i.toolsType === f.Text)
609
- await i.consumeServiceAsync({
607
+ else if (o.toolsType === f.Text)
608
+ await o.consumeServiceAsync({
610
609
  isFullWork: !0,
611
- replaceId: n
610
+ replaceId: r
612
611
  });
613
612
  else {
614
- const c = r.ops && P(r.ops);
615
- i.consumeService({
616
- op: c,
613
+ const i = s.ops && F(s.ops);
614
+ o.consumeService({
615
+ op: i,
617
616
  isFullWork: !0,
618
- replaceId: n
619
- }), r != null && r.updateNodeOpt && i.updataOptService(r.updateNodeOpt);
617
+ replaceId: r
618
+ }), s != null && s.updateNodeOpt && o.updataOptService(s.updateNodeOpt);
620
619
  }
621
- r.workId && this.workShapes.delete(r.workId.toString());
620
+ s.workId && this.workShapes.delete(s.workId.toString());
622
621
  }
623
622
  }
624
623
  this.reRenderSelector(t);
625
624
  }
626
625
  hasSelector() {
627
- return this.workShapes.has(N);
626
+ return this.workShapes.has(L);
628
627
  }
629
628
  getSelector() {
630
- return this.workShapes.get(N);
629
+ return this.workShapes.get(L);
631
630
  }
632
631
  reRenderSelector(t = !1) {
633
632
  var o;
634
- const e = this.workShapes.get(N);
633
+ const e = this.workShapes.get(L);
635
634
  if (!e) return;
636
635
  if (e && !((o = e.selectIds) != null && o.length))
637
636
  return this.blurSelector();
@@ -664,9 +663,9 @@ class ke {
664
663
  }
665
664
  async blurSelector(t) {
666
665
  var o;
667
- const e = this.workShapes.get(N), s = e == null ? void 0 : e.blurSelector();
668
- if (this.clearWorkShapeNodeCache(N), ((o = this.thread.fullLayer) == null ? void 0 : o.parent).children.forEach((r) => {
669
- r.name === N && r.remove();
666
+ const e = this.workShapes.get(L), s = e == null ? void 0 : e.blurSelector();
667
+ if (this.clearWorkShapeNodeCache(L), ((o = this.thread.fullLayer) == null ? void 0 : o.parent).children.forEach((r) => {
668
+ r.name === L && r.remove();
670
669
  }), s) {
671
670
  const r = [];
672
671
  r.push({
@@ -679,6 +678,48 @@ class ke {
679
678
  var e;
680
679
  (e = this.getWorkShape(t)) == null || e.clearTmpPoints(), this.workShapes.delete(t);
681
680
  }
681
+ drawBitMapEraser(t) {
682
+ const e = [];
683
+ t.op && e.push(t), e.length && this.thread.post({ sp: e });
684
+ }
685
+ async drawBitMapEraserFull(t, e) {
686
+ const { willUpdateNodes: s, isLockSentEventCursor: o, scenePath: r, ...i } = e, a = t.getWorkId(), n = [
687
+ {
688
+ ...i,
689
+ workId: a,
690
+ isLockSentEventCursor: o,
691
+ scenePath: r,
692
+ updateNodeOpt: {
693
+ useAnimation: !1
694
+ },
695
+ isSync: !0,
696
+ nextTasks: [
697
+ {
698
+ type: p.RemoveNode,
699
+ removeIds: [a],
700
+ viewId: this.thread.viewId
701
+ }
702
+ ]
703
+ }
704
+ ];
705
+ if (s != null && s.size) {
706
+ await (t == null ? void 0 : t.reRenderEffectNodes({
707
+ willUpdateNodes: s,
708
+ worker: this
709
+ }));
710
+ for (const [c, h] of s)
711
+ n.push({
712
+ type: p.UpdateNode,
713
+ dataType: w.Local,
714
+ opt: h.opt,
715
+ workId: c,
716
+ updateNodeOpt: {
717
+ useAnimation: !1
718
+ }
719
+ });
720
+ }
721
+ n.length && this.thread.post({ sp: n });
722
+ }
682
723
  drawPencilEraser(t) {
683
724
  var s, o;
684
725
  const e = [];
@@ -688,7 +729,7 @@ class ke {
688
729
  this.batchEraserWorks.add(i), e.push({
689
730
  type: p.FullWork,
690
731
  workId: i,
691
- ops: V(r.op),
732
+ ops: K(r.op),
692
733
  opt: r.opt,
693
734
  toolsType: r.toolsType,
694
735
  updateNodeOpt: {
@@ -731,11 +772,11 @@ class ke {
731
772
  consumeDraw(t, e) {
732
773
  const { op: s, workId: o, scenePath: r } = t;
733
774
  if (s != null && s.length && o) {
734
- const i = o.toString(), n = this.workShapes.get(i);
735
- if (!n)
775
+ const i = o.toString(), a = this.workShapes.get(i);
776
+ if (!a)
736
777
  return;
737
- const c = n.toolsType;
738
- if (c === f.LaserPen)
778
+ const n = a.toolsType;
779
+ if (n === f.LaserPen)
739
780
  return;
740
781
  switch (this.drawWorkActiveId && this.drawWorkActiveId !== i && (this.consumeDrawAll({
741
782
  workId: this.drawWorkActiveId,
@@ -743,32 +784,40 @@ class ke {
743
784
  viewId: this.thread.viewId,
744
785
  msgType: p.DrawWork,
745
786
  dataType: w.Local
746
- }, e), this.drawWorkActiveId = void 0), !this.drawWorkActiveId && i !== N && (this.drawWorkActiveId = i), c) {
787
+ }, e), this.drawWorkActiveId = void 0), !this.drawWorkActiveId && i !== L && (this.drawWorkActiveId = i), n) {
747
788
  case f.Selector:
748
789
  {
749
- const a = n.consume({
790
+ const c = a.consume({
750
791
  data: t,
751
792
  isFullWork: !0
752
793
  });
753
- a.type === p.Select && (a.selectIds && e.runReverseSelectWork(a.selectIds), this.thread.post({ sp: [a] }));
794
+ c.type === p.Select && (c.selectIds && e.runReverseSelectWork(c.selectIds), this.thread.post({ sp: [c] }));
754
795
  }
755
796
  break;
756
797
  case f.PencilEraser:
757
798
  {
758
- const a = n.consume({
799
+ const c = a.consume({
759
800
  data: t,
760
801
  isFullWork: !0
761
802
  });
762
- a != null && a.rect && this.drawPencilEraser(a);
803
+ c != null && c.rect && this.drawPencilEraser(c);
763
804
  }
764
805
  break;
806
+ case f.BitMapEraser: {
807
+ const c = a.consume({
808
+ data: t,
809
+ isFullWork: !0
810
+ });
811
+ c != null && c.rect && this.drawBitMapEraser(c);
812
+ break;
813
+ }
765
814
  case f.Eraser:
766
815
  {
767
- const a = n.consume({
816
+ const c = a.consume({
768
817
  data: t,
769
818
  isFullWork: !0
770
819
  });
771
- a != null && a.rect && this.drawEraser(a);
820
+ c != null && c.rect && this.drawEraser(c);
772
821
  }
773
822
  break;
774
823
  case f.Arrow:
@@ -780,14 +829,14 @@ class ke {
780
829
  case f.SpeechBalloon:
781
830
  case f.Pencil:
782
831
  {
783
- const a = n.consume({
832
+ const c = a.consume({
784
833
  data: t,
785
834
  isFullWork: !1,
786
835
  isMainThread: !0
787
836
  });
788
- a && (this.drawCount++, this.thread.post({
837
+ c && (this.drawCount++, this.thread.post({
789
838
  drawCount: this.drawCount,
790
- sp: a.op && [{ ...a, scenePath: r }] || void 0
839
+ sp: c.op && [{ ...c, scenePath: r }] || void 0
791
840
  }));
792
841
  }
793
842
  break;
@@ -795,27 +844,30 @@ class ke {
795
844
  }
796
845
  }
797
846
  consumeDrawAll(t, e) {
798
- var r, i, n;
799
- const { workId: s, scenePath: o } = t;
847
+ var i, a, n, c;
848
+ const { workId: s, scenePath: o, isLockSentEventCursor: r } = t;
800
849
  if (s) {
801
- const c = s.toString();
802
- this.drawWorkActiveId === c && (this.drawWorkActiveId = void 0);
803
- const a = this.workShapes.get(c);
804
- if (!a)
850
+ const h = s.toString();
851
+ this.drawWorkActiveId === h && (this.drawWorkActiveId = void 0);
852
+ const l = this.workShapes.get(h);
853
+ if (!l)
805
854
  return;
806
- const h = a.toolsType;
807
- if (h === f.LaserPen)
855
+ const S = l.toolsType;
856
+ if (S === f.LaserPen)
808
857
  return;
809
- const l = this.workShapes.get(H), S = (r = l == null ? void 0 : l.selectIds) == null ? void 0 : r[0], u = a.consumeAll({ data: t });
810
- switch (h) {
858
+ const u = this.workShapes.get(_), y = (i = u == null ? void 0 : u.selectIds) == null ? void 0 : i[0], m = l.consumeAll({ data: t });
859
+ switch (S) {
811
860
  case f.Selector:
812
- u.selectIds && S && ((i = u.selectIds) != null && i.includes(S)) && l.cursorBlur(), u.type === p.Select && (u.selectIds && e.runReverseSelectWork(u.selectIds), this.thread.post({ sp: [{ ...u, scenePath: o }] })), (n = a.selectIds) != null && n.length ? a.clearTmpPoints() : this.clearWorkShapeNodeCache(c);
861
+ m.selectIds && y && ((a = m.selectIds) != null && a.includes(y)) && u.cursorBlur(), m.type === p.Select && (m.selectIds && e.runReverseSelectWork(m.selectIds), this.thread.post({ sp: [{ ...m, scenePath: o }] })), (n = l.selectIds) != null && n.length ? l.clearTmpPoints() : this.clearWorkShapeNodeCache(h);
813
862
  break;
814
863
  case f.PencilEraser:
815
- u != null && u.rect && this.drawPencilEraser({ ...u, scenePath: o }), a.clearTmpPoints();
864
+ m != null && m.rect && this.drawPencilEraser({ ...m, scenePath: o }), l.clearTmpPoints();
865
+ break;
866
+ case f.BitMapEraser:
867
+ (m.rect || (c = m.newWorkDatas) != null && c.size) && this.drawBitMapEraserFull(l, { ...m, isLockSentEventCursor: r });
816
868
  break;
817
869
  case f.Eraser:
818
- u != null && u.rect && this.drawEraser({ ...u, scenePath: o }), a.clearTmpPoints();
870
+ m != null && m.rect && this.drawEraser({ ...m, scenePath: o }), l.clearTmpPoints();
819
871
  break;
820
872
  case f.Arrow:
821
873
  case f.Straight:
@@ -825,10 +877,10 @@ class ke {
825
877
  case f.Polygon:
826
878
  case f.SpeechBalloon:
827
879
  case f.Pencil:
828
- u && (this.drawCount = 0, this.thread.post({
880
+ m && (this.drawCount = 0, this.thread.post({
829
881
  drawCount: this.drawCount,
830
- sp: [u]
831
- })), this.clearWorkShapeNodeCache(c);
882
+ sp: [m]
883
+ })), this.clearWorkShapeNodeCache(h);
832
884
  break;
833
885
  }
834
886
  }
@@ -849,10 +901,10 @@ class ke {
849
901
  e.syncUnitTime || (e.syncUnitTime = this.syncUnitTime), s == null || s.setWorkOptions(e);
850
902
  }
851
903
  createWorkShapeNode(t) {
852
- return B({ ...t, vNodes: this.vNodes, fullLayer: this.thread.fullLayer, drawLayer: this.thread.localLayer }, this.thread.serviceWork);
904
+ return U({ ...t, vNodes: this.vNodes, fullLayer: this.thread.fullLayer, drawLayer: this.thread.localLayer }, this.thread.serviceWork);
853
905
  }
854
906
  }
855
- class ye {
907
+ class ke {
856
908
  constructor(t) {
857
909
  d(this, "vNodes");
858
910
  d(this, "thread");
@@ -861,9 +913,12 @@ class ye {
861
913
  d(this, "willRunEffectSelectorIds", /* @__PURE__ */ new Set());
862
914
  d(this, "runEffectId");
863
915
  d(this, "animationId");
864
- d(this, "syncUnitTime", F.syncOpt.interval);
916
+ d(this, "syncUnitTime", x.syncOpt.interval);
865
917
  this.vNodes = t.vNodes, this.thread = t.thread;
866
918
  }
919
+ async loadImageBitMap(t) {
920
+ return this.thread.loadImageBitMap(t);
921
+ }
867
922
  destroy() {
868
923
  this.clearAll();
869
924
  }
@@ -919,31 +974,30 @@ class ye {
919
974
  return Math.min((t.animationIndex || 0) + (s || e), (t.animationWorkData || []).length);
920
975
  }
921
976
  async animationDraw() {
922
- var s, o, r, i, n, c, a, h, l, S, u, y, m, g, W, M;
977
+ var s, o, r, i, a, n, c, h, l, S, u, y, m, v, W;
923
978
  this.animationId = void 0;
924
979
  let t = !1;
925
980
  const e = /* @__PURE__ */ new Map();
926
- for (const [L, k] of this.workShapes.entries())
981
+ for (const [g, k] of this.workShapes.entries())
927
982
  switch (k.toolsType) {
928
983
  case f.Image: {
929
- await ((o = k.node) == null ? void 0 : o.consumeServiceAsync({
984
+ await ((s = k.node) == null ? void 0 : s.consumeServiceAsync({
930
985
  isFullWork: !0,
931
- scene: (s = this.thread.fullLayer.parent) == null ? void 0 : s.parent,
932
- isMainThread: !0
933
- })), this.selectorWorkShapes.forEach((b, D) => {
934
- var O;
935
- (O = b.selectIds) != null && O.includes(L) && (this.willRunEffectSelectorIds.add(D), this.runEffect());
936
- }), this.workShapes.delete(L);
986
+ worker: this
987
+ })), this.selectorWorkShapes.forEach((b, O) => {
988
+ var M;
989
+ (M = b.selectIds) != null && M.includes(g) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
990
+ }), this.workShapes.delete(g);
937
991
  break;
938
992
  }
939
993
  case f.Text: {
940
- k.node && (await ((r = k.node) == null ? void 0 : r.consumeServiceAsync({
994
+ k.node && (await ((o = k.node) == null ? void 0 : o.consumeServiceAsync({
941
995
  isFullWork: !0,
942
- replaceId: L
943
- })), this.selectorWorkShapes.forEach((b, D) => {
944
- var O;
945
- (O = b.selectIds) != null && O.includes(L) && (this.willRunEffectSelectorIds.add(D), this.runEffect());
946
- }), (i = k.node) == null || i.clearTmpPoints(), this.workShapes.delete(L));
996
+ replaceId: g
997
+ })), this.selectorWorkShapes.forEach((b, O) => {
998
+ var M;
999
+ (M = b.selectIds) != null && M.includes(g) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
1000
+ }), (r = k.node) == null || r.clearTmpPoints(), this.workShapes.delete(g));
947
1001
  break;
948
1002
  }
949
1003
  case f.Arrow:
@@ -954,18 +1008,18 @@ class ye {
954
1008
  case f.Polygon:
955
1009
  case f.SpeechBalloon: {
956
1010
  const b = !!k.ops;
957
- if ((n = k.animationWorkData) != null && n.length) {
958
- const D = k.oldRect;
959
- (c = k.node) == null || c.consumeService({
1011
+ if ((i = k.animationWorkData) != null && i.length) {
1012
+ const O = k.oldRect;
1013
+ (a = k.node) == null || a.consumeService({
960
1014
  op: k.animationWorkData,
961
1015
  isFullWork: b
962
- }), b && (this.selectorWorkShapes.forEach((O, R) => {
963
- var U;
964
- (U = O.selectIds) != null && U.includes(L) && (this.willRunEffectSelectorIds.add(R), this.runEffect());
965
- }), (a = k.node) == null || a.clearTmpPoints(), this.workShapes.delete(L)), e.set(L, {
966
- workState: D ? k.ops ? T.Done : T.Doing : T.Start,
967
- op: k.animationWorkData.filter((O, R) => {
968
- if (R % 3 !== 2)
1016
+ }), b && (this.selectorWorkShapes.forEach((M, D) => {
1017
+ var P;
1018
+ (P = M.selectIds) != null && P.includes(g) && (this.willRunEffectSelectorIds.add(D), this.runEffect());
1019
+ }), (n = k.node) == null || n.clearTmpPoints(), this.workShapes.delete(g)), e.set(g, {
1020
+ workState: O ? k.ops ? I.Done : I.Doing : I.Start,
1021
+ op: k.animationWorkData.filter((M, D) => {
1022
+ if (D % 3 !== 2)
969
1023
  return !0;
970
1024
  }).slice(-2)
971
1025
  }), k.animationWorkData.length = 0;
@@ -974,42 +1028,42 @@ class ye {
974
1028
  }
975
1029
  case f.Pencil: {
976
1030
  if (!k.useAnimation && k.ops)
977
- (h = k.node) == null || h.consumeService({
1031
+ (c = k.node) == null || c.consumeService({
978
1032
  op: k.animationWorkData || [],
979
1033
  isFullWork: !0,
980
- replaceId: L
981
- }), (l = k.node) == null || l.updataOptService(k.updateNodeOpt), this.selectorWorkShapes.forEach((b, D) => {
982
- var O;
983
- (O = b.selectIds) != null && O.includes(L) && (this.willRunEffectSelectorIds.add(D), this.runEffect());
984
- }), (S = k.node) == null || S.clearTmpPoints(), this.workShapes.delete(L);
1034
+ replaceId: g
1035
+ }), (h = k.node) == null || h.updataOptService(k.updateNodeOpt), this.selectorWorkShapes.forEach((b, O) => {
1036
+ var M;
1037
+ (M = b.selectIds) != null && M.includes(g) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
1038
+ }), (l = k.node) == null || l.clearTmpPoints(), this.workShapes.delete(g);
985
1039
  else if (k.useAnimation) {
986
1040
  if (k.isDel) {
987
- (u = k.node) == null || u.clearTmpPoints(), this.workShapes.delete(L);
1041
+ (S = k.node) == null || S.clearTmpPoints(), this.workShapes.delete(g);
988
1042
  break;
989
1043
  }
990
- const b = 3, D = this.computNextAnimationIndex(k, b), O = k.isDiff ? 0 : Math.max(0, (k.animationIndex || 0) - b), R = (k.animationWorkData || []).slice(O, D), U = (m = (y = k.node) == null ? void 0 : y.getWorkId()) == null ? void 0 : m.toString();
991
- if ((k.animationIndex || 0) < D || k.isDiff) {
992
- if ((g = k.node) == null || g.consumeService({
993
- op: R,
1044
+ const b = 3, O = this.computNextAnimationIndex(k, b), M = k.isDiff ? 0 : Math.max(0, (k.animationIndex || 0) - b), D = (k.animationWorkData || []).slice(M, O), P = (y = (u = k.node) == null ? void 0 : u.getWorkId()) == null ? void 0 : y.toString();
1045
+ if ((k.animationIndex || 0) < O || k.isDiff) {
1046
+ if ((m = k.node) == null || m.consumeService({
1047
+ op: D,
994
1048
  isFullWork: !1
995
- }), k.animationIndex = D, k.isDiff && (k.isDiff = !1), R.length) {
996
- const q = R.filter((K, te) => {
997
- if (te % b !== b - 1)
1049
+ }), k.animationIndex = O, k.isDiff && (k.isDiff = !1), D.length) {
1050
+ const H = D.filter((q, ee) => {
1051
+ if (ee % b !== b - 1)
998
1052
  return !0;
999
1053
  }).slice(-2);
1000
- e.set(L, {
1001
- workState: O === 0 ? T.Start : D === ((W = k.animationWorkData) == null ? void 0 : W.length) ? T.Done : T.Doing,
1002
- op: q
1054
+ e.set(g, {
1055
+ workState: M === 0 ? I.Start : O === ((v = k.animationWorkData) == null ? void 0 : v.length) ? I.Done : I.Doing,
1056
+ op: H
1003
1057
  });
1004
1058
  }
1005
- } else k.ops && ((M = k.node) == null || M.consumeService({
1059
+ } else k.ops && ((W = k.node) == null || W.consumeService({
1006
1060
  op: k.animationWorkData || [],
1007
1061
  isFullWork: !0,
1008
- replaceId: U
1009
- }), k.isDel = !0, e.set(L, {
1010
- workState: T.Done,
1011
- op: R.filter((q, K) => {
1012
- if (K % b !== b - 1)
1062
+ replaceId: P
1063
+ }), k.isDel = !0, e.set(g, {
1064
+ workState: I.Done,
1065
+ op: D.filter((H, q) => {
1066
+ if (q % b !== b - 1)
1013
1067
  return !0;
1014
1068
  }).slice(-2)
1015
1069
  }));
@@ -1020,16 +1074,16 @@ class ye {
1020
1074
  }
1021
1075
  }
1022
1076
  if (t && this.runAnimation(), e.size) {
1023
- const L = [];
1077
+ const g = [];
1024
1078
  e.forEach((k, b) => {
1025
- L.push({
1079
+ g.push({
1026
1080
  type: p.Cursor,
1027
- uid: b.split(Y)[0],
1081
+ uid: b.split(X)[0],
1028
1082
  op: k.op,
1029
1083
  workState: k.workState,
1030
1084
  viewId: this.thread.viewId
1031
1085
  });
1032
- }), this.thread.post({ sp: L });
1086
+ }), this.thread.post({ sp: g });
1033
1087
  }
1034
1088
  }
1035
1089
  runAnimation() {
@@ -1056,30 +1110,31 @@ class ye {
1056
1110
  return !1;
1057
1111
  }
1058
1112
  activeWorkShape(t) {
1059
- var u, y, m, g;
1060
- const { workId: e, opt: s, toolsType: o, type: r, updateNodeOpt: i, ops: n, op: c, useAnimation: a } = t;
1113
+ var y, m, v, W;
1114
+ const { workId: e, opt: s, toolsType: o, type: r, updateNodeOpt: i, ops: a, op: n, useAnimation: c, imageBitmap: h } = t;
1061
1115
  if (!e)
1062
1116
  return;
1063
- const h = e.toString(), l = (u = this.vNodes.get(h)) == null ? void 0 : u.rect;
1064
- if (!((y = this.workShapes) != null && y.has(h))) {
1065
- let W = {
1117
+ const l = e.toString(), S = (y = this.vNodes.get(l)) == null ? void 0 : y.rect;
1118
+ if (!((m = this.workShapes) != null && m.has(l))) {
1119
+ let g = {
1066
1120
  toolsType: o,
1067
- animationWorkData: c || [],
1121
+ animationWorkData: n || [],
1068
1122
  animationIndex: 0,
1069
1123
  type: r,
1070
1124
  updateNodeOpt: i,
1071
- ops: n,
1072
- useAnimation: typeof a < "u" ? a : typeof (i == null ? void 0 : i.useAnimation) < "u" ? i == null ? void 0 : i.useAnimation : !0,
1073
- oldRect: l,
1074
- isDiff: !1
1125
+ ops: a,
1126
+ useAnimation: typeof c < "u" ? c : typeof (i == null ? void 0 : i.useAnimation) < "u" ? i == null ? void 0 : i.useAnimation : !0,
1127
+ oldRect: S,
1128
+ isDiff: !1,
1129
+ imageBitmap: h
1075
1130
  };
1076
- o && s && (W = this.setNodeKey(h, W, o, s)), (m = this.workShapes) == null || m.set(h, W);
1131
+ o && s && (g = this.setNodeKey(l, g, o, s)), (v = this.workShapes) == null || v.set(l, g);
1077
1132
  }
1078
- const S = (g = this.workShapes) == null ? void 0 : g.get(h);
1079
- r && (S.type = r), n && (S.animationWorkData = P(n), S.ops = n), i && (S.updateNodeOpt = i), c && (S.isDiff = this.hasDiffData(S.animationWorkData || [], c, S.toolsType), S.animationWorkData = c), S.node && S.node.getWorkId() !== h && S.node.setWorkId(h), l && (S.oldRect = l), o && s && (s.syncUnitTime && (this.syncUnitTime = s.syncUnitTime), S.toolsType !== o && o && s && this.setNodeKey(h, S, o, s), S.node && S.node.setWorkOptions(s));
1133
+ const u = (W = this.workShapes) == null ? void 0 : W.get(l);
1134
+ r && (u.type = r), a && (u.animationWorkData = F(a), u.ops = a), i && (u.updateNodeOpt = i), n && (u.isDiff = this.hasDiffData(u.animationWorkData || [], n, u.toolsType), u.animationWorkData = n), u.node && u.node.getWorkId() !== l && u.node.setWorkId(l), S && (u.oldRect = S), o && s && (s.syncUnitTime && (this.syncUnitTime = s.syncUnitTime), u.toolsType !== o && o && s && this.setNodeKey(l, u, o, s), u.node && u.node.setWorkOptions(s)), h && (u.imageBitmap = h);
1080
1135
  }
1081
1136
  removeNode(t, e) {
1082
- t.indexOf(N) > -1 && this.removeSelectWork(e), this.thread.fullLayer.getElementsByName(t).forEach((s) => {
1137
+ t.indexOf(L) > -1 && this.removeSelectWork(e), this.thread.fullLayer.getElementsByName(t).forEach((s) => {
1083
1138
  s.remove();
1084
1139
  }), this.thread.serviceLayer.getElementsByName(t).forEach((s) => {
1085
1140
  s.remove();
@@ -1090,25 +1145,25 @@ class ye {
1090
1145
  s && (this.activeSelectorShape(t), this.willRunEffectSelectorIds.add(s)), this.runEffect();
1091
1146
  }
1092
1147
  activeSelectorShape(t) {
1093
- var a, h, l;
1148
+ var c, h, l;
1094
1149
  const { workId: e, opt: s, toolsType: o, type: r, selectIds: i } = t;
1095
1150
  if (!e)
1096
1151
  return;
1097
- const n = e.toString();
1098
- if (!((a = this.selectorWorkShapes) != null && a.has(n))) {
1152
+ const a = e.toString();
1153
+ if (!((c = this.selectorWorkShapes) != null && c.has(a))) {
1099
1154
  let S = {
1100
1155
  toolsType: o,
1101
1156
  selectIds: i,
1102
1157
  type: r,
1103
1158
  opt: s
1104
1159
  };
1105
- o && s && (S = this.setNodeKey(n, S, o, s)), (h = this.selectorWorkShapes) == null || h.set(n, S);
1160
+ o && s && (S = this.setNodeKey(a, S, o, s)), (h = this.selectorWorkShapes) == null || h.set(a, S);
1106
1161
  }
1107
- const c = (l = this.selectorWorkShapes) == null ? void 0 : l.get(n);
1108
- r && (c.type = r), c.node && c.node.getWorkId() !== n && c.node.setWorkId(n), c.selectIds = i || [];
1162
+ const n = (l = this.selectorWorkShapes) == null ? void 0 : l.get(a);
1163
+ r && (n.type = r), n.node && n.node.getWorkId() !== a && n.node.setWorkId(a), n.selectIds = i || [];
1109
1164
  }
1110
1165
  setNodeKey(t, e, s, o) {
1111
- return e.toolsType = s, e.node = B({
1166
+ return e.toolsType = s, e.node = U({
1112
1167
  toolsType: s,
1113
1168
  toolsOpt: o,
1114
1169
  vNodes: this.vNodes,
@@ -1122,16 +1177,16 @@ class E {
1122
1177
  constructor() {
1123
1178
  d(this, "localWork");
1124
1179
  d(this, "serviceWork");
1125
- d(this, "scene");
1180
+ d(this, "threadEngine");
1126
1181
  }
1127
- registerMainThread(t, e, s) {
1128
- return this.localWork = t, this.serviceWork = e, this.scene = s, this;
1182
+ registerMainThread(t) {
1183
+ return this.threadEngine = t, this.localWork = t.localWork, this.serviceWork = t.serviceWork, this;
1129
1184
  }
1130
1185
  }
1131
1186
  class me extends E {
1132
1187
  constructor() {
1133
1188
  super(...arguments);
1134
- d(this, "emitEventType", v.CopyNode);
1189
+ d(this, "emitEventType", T.CopyNode);
1135
1190
  }
1136
1191
  async consume(e) {
1137
1192
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1141,13 +1196,13 @@ class me extends E {
1141
1196
  async consumeForLocalWorker(e) {
1142
1197
  var o;
1143
1198
  const { workId: s } = e;
1144
- s && await ((o = this.localWork) == null ? void 0 : o.consumeFull(e, this.scene));
1199
+ s && await ((o = this.localWork) == null ? void 0 : o.consumeFull(e));
1145
1200
  }
1146
1201
  }
1147
- class we extends E {
1202
+ class ye extends E {
1148
1203
  constructor() {
1149
1204
  super(...arguments);
1150
- d(this, "emitEventType", v.SetColorNode);
1205
+ d(this, "emitEventType", T.SetColorNode);
1151
1206
  }
1152
1207
  async consume(e) {
1153
1208
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1155,28 +1210,28 @@ class we extends E {
1155
1210
  return this.consumeForLocalWorker(e), !0;
1156
1211
  }
1157
1212
  async consumeForLocalWorker(e) {
1158
- var a;
1159
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n, textUpdateForWoker: c } = e;
1160
- s === N && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
1213
+ var c;
1214
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a, textUpdateForWoker: n } = e;
1215
+ s === L && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1161
1216
  updateSelectorOpt: o,
1162
1217
  willRefreshSelector: r,
1163
1218
  willSyncService: i,
1164
- willSerializeData: n,
1165
- textUpdateForWoker: c,
1219
+ willSerializeData: a,
1220
+ textUpdateForWoker: n,
1166
1221
  callback: this.updateSelectorCallback
1167
1222
  }));
1168
1223
  }
1169
1224
  updateSelectorCallback(e) {
1170
- const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: n, textUpdateForWoker: c } = s, a = o.sp || [];
1225
+ const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: a, textUpdateForWoker: n } = s, c = o.sp || [];
1171
1226
  if (i)
1172
1227
  for (const [h, l] of r.entries())
1173
- c && l.toolsType === f.Text ? a.push({
1228
+ n && l.toolsType === f.Text ? c.push({
1174
1229
  ...l,
1175
1230
  workId: h,
1176
1231
  type: p.TextUpdate,
1177
1232
  dataType: w.Local,
1178
1233
  willSyncService: !0
1179
- }) : a.push(
1234
+ }) : c.push(
1180
1235
  {
1181
1236
  ...l,
1182
1237
  workId: h,
@@ -1184,18 +1239,18 @@ class we extends E {
1184
1239
  updateNodeOpt: {
1185
1240
  useAnimation: !1
1186
1241
  },
1187
- isSync: n
1242
+ isSync: a
1188
1243
  }
1189
1244
  );
1190
1245
  return {
1191
- sp: a
1246
+ sp: c
1192
1247
  };
1193
1248
  }
1194
1249
  }
1195
- class ve extends E {
1250
+ class we extends E {
1196
1251
  constructor() {
1197
1252
  super(...arguments);
1198
- d(this, "emitEventType", v.ZIndexNode);
1253
+ d(this, "emitEventType", T.ZIndexNode);
1199
1254
  }
1200
1255
  async consume(e) {
1201
1256
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1203,40 +1258,40 @@ class ve extends E {
1203
1258
  return this.consumeForLocalWorker(e), !0;
1204
1259
  }
1205
1260
  async consumeForLocalWorker(e) {
1206
- var c;
1207
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n } = e;
1208
- s === N && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1261
+ var n;
1262
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a } = e;
1263
+ s === L && o && await ((n = this.localWork) == null ? void 0 : n.updateSelector({
1209
1264
  updateSelectorOpt: o,
1210
1265
  willRefreshSelector: r,
1211
1266
  willSyncService: i,
1212
- willSerializeData: n,
1267
+ willSerializeData: a,
1213
1268
  callback: this.updateSelectorCallback
1214
1269
  }));
1215
1270
  }
1216
1271
  updateSelectorCallback(e) {
1217
- const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: n } = s, c = o.sp || [];
1218
- if (i && c)
1219
- for (const [a, h] of r.entries())
1220
- c.push(
1272
+ const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: a } = s, n = o.sp || [];
1273
+ if (i && n)
1274
+ for (const [c, h] of r.entries())
1275
+ n.push(
1221
1276
  {
1222
1277
  ...h,
1223
- workId: a,
1278
+ workId: c,
1224
1279
  type: p.UpdateNode,
1225
1280
  updateNodeOpt: {
1226
1281
  useAnimation: !1
1227
1282
  },
1228
- isSync: n
1283
+ isSync: a
1229
1284
  }
1230
1285
  );
1231
1286
  return {
1232
- sp: c
1287
+ sp: n
1233
1288
  };
1234
1289
  }
1235
1290
  }
1236
- class Te extends E {
1291
+ class ve extends E {
1237
1292
  constructor() {
1238
1293
  super(...arguments);
1239
- d(this, "emitEventType", v.TranslateNode);
1294
+ d(this, "emitEventType", T.TranslateNode);
1240
1295
  }
1241
1296
  async consume(e) {
1242
1297
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1245,29 +1300,28 @@ class Te extends E {
1245
1300
  }
1246
1301
  async consumeForLocalWorker(e) {
1247
1302
  var h, l;
1248
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n, textUpdateForWoker: c, emitEventType: a } = e;
1249
- s === N && o && (o.workState === T.Done && (o != null && o.translate) && (o.translate[0] || o.translate[1]) || o.workState !== T.Done ? await ((h = this.localWork) == null ? void 0 : h.updateSelector({
1303
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a, textUpdateForWoker: n, emitEventType: c } = e;
1304
+ s === L && o && (o.workState === I.Done && (o != null && o.translate) && (o.translate[0] || o.translate[1]) || o.workState !== I.Done ? await ((h = this.localWork) == null ? void 0 : h.updateSelector({
1250
1305
  updateSelectorOpt: o,
1251
1306
  willRefreshSelector: r,
1252
1307
  willSyncService: i,
1253
- willSerializeData: n,
1308
+ willSerializeData: a,
1254
1309
  isSync: !0,
1255
- textUpdateForWoker: c,
1256
- emitEventType: a,
1257
- scene: this.scene,
1310
+ textUpdateForWoker: n,
1311
+ emitEventType: c,
1258
1312
  callback: this.updateSelectorCallback
1259
- })) : o.workState === T.Done && ((l = this.localWork) == null || l.vNodes.deleteLastTarget()));
1313
+ })) : o.workState === I.Done && ((l = this.localWork) == null || l.vNodes.deleteLastTarget()));
1260
1314
  }
1261
1315
  updateSelectorCallback(e) {
1262
- const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: n } = e, { willSyncService: c, isSync: a, updateSelectorOpt: h, textUpdateForWoker: l } = s, S = h.workState, u = o.sp || [];
1263
- if (S === T.Start)
1316
+ const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: a } = e, { willSyncService: n, isSync: c, updateSelectorOpt: h, textUpdateForWoker: l } = s, S = h.workState, u = o.sp || [];
1317
+ if (S === I.Start)
1264
1318
  return {
1265
1319
  sp: [],
1266
1320
  render: []
1267
1321
  };
1268
- const y = n == null ? void 0 : n.selectRect;
1269
- if (c) {
1270
- S === T.Doing && u.push({
1322
+ const y = a == null ? void 0 : a.selectRect;
1323
+ if (n) {
1324
+ S === I.Doing && u.push({
1271
1325
  type: p.Select,
1272
1326
  selectIds: i.selectIds,
1273
1327
  selectRect: y,
@@ -1276,22 +1330,22 @@ class Te extends E {
1276
1330
  points: i.getChildrenPoints(),
1277
1331
  textOpt: i.textOpt
1278
1332
  });
1279
- for (const [m, g] of r.entries())
1280
- l && g.toolsType === f.Text ? u.push({
1281
- ...g,
1333
+ for (const [m, v] of r.entries())
1334
+ l && v.toolsType === f.Text ? u.push({
1335
+ ...v,
1282
1336
  workId: m,
1283
1337
  type: p.TextUpdate,
1284
1338
  dataType: w.Local,
1285
1339
  willSyncService: !0
1286
1340
  }) : u.push(
1287
1341
  {
1288
- ...g,
1342
+ ...v,
1289
1343
  workId: m,
1290
1344
  type: p.UpdateNode,
1291
1345
  updateNodeOpt: {
1292
1346
  useAnimation: !1
1293
1347
  },
1294
- isSync: a
1348
+ isSync: c
1295
1349
  }
1296
1350
  );
1297
1351
  }
@@ -1303,16 +1357,16 @@ class Te extends E {
1303
1357
  class ge extends E {
1304
1358
  constructor() {
1305
1359
  super(...arguments);
1306
- d(this, "emitEventType", v.DeleteNode);
1360
+ d(this, "emitEventType", T.DeleteNode);
1307
1361
  }
1308
1362
  async consume() {
1309
1363
  return !1;
1310
1364
  }
1311
1365
  }
1312
- class We extends E {
1366
+ class Te extends E {
1313
1367
  constructor() {
1314
1368
  super(...arguments);
1315
- d(this, "emitEventType", v.ScaleNode);
1369
+ d(this, "emitEventType", T.ScaleNode);
1316
1370
  }
1317
1371
  async consume(e) {
1318
1372
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1320,35 +1374,34 @@ class We extends E {
1320
1374
  return await this.consumeForLocalWorker(e), !0;
1321
1375
  }
1322
1376
  async consumeForLocalWorker(e) {
1323
- var n;
1377
+ var a;
1324
1378
  const { workId: s, updateNodeOpt: o, willSyncService: r, willSerializeData: i } = e;
1325
- s === N && o && await ((n = this.localWork) == null ? void 0 : n.updateSelector({
1379
+ s === L && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
1326
1380
  updateSelectorOpt: o,
1327
1381
  willSyncService: r,
1328
1382
  willSerializeData: i,
1329
1383
  isSync: !0,
1330
- scene: this.scene,
1331
1384
  callback: this.updateSelectorCallback.bind(this)
1332
1385
  }));
1333
1386
  }
1334
1387
  updateSelectorCallback(e) {
1335
- const { param: s, postData: o, workShapeNode: r, res: i, newServiceStore: n } = e, { updateSelectorOpt: c, willSyncService: a } = s, h = c.workState, l = o.sp || [], S = i == null ? void 0 : i.selectRect;
1336
- if (h === T.Start)
1388
+ const { param: s, postData: o, workShapeNode: r, res: i, newServiceStore: a } = e, { updateSelectorOpt: n, willSyncService: c } = s, h = n.workState, l = o.sp || [], S = i == null ? void 0 : i.selectRect;
1389
+ if (h === I.Start)
1337
1390
  return {
1338
1391
  sp: [],
1339
1392
  render: []
1340
1393
  };
1341
- if (a) {
1394
+ if (c) {
1342
1395
  l.push({
1343
1396
  type: p.Select,
1344
1397
  selectIds: r.selectIds,
1345
1398
  selectRect: S,
1346
1399
  willSyncService: !0,
1347
1400
  isSync: !0,
1348
- points: h === T.Done && r.getChildrenPoints() || void 0,
1401
+ points: h === I.Done && r.getChildrenPoints() || void 0,
1349
1402
  textOpt: r.textOpt
1350
1403
  });
1351
- for (const [u, y] of n.entries())
1404
+ for (const [u, y] of a.entries())
1352
1405
  y.toolsType === f.Text ? l.push({
1353
1406
  ...y,
1354
1407
  workId: u,
@@ -1375,7 +1428,7 @@ class We extends E {
1375
1428
  class Ie extends E {
1376
1429
  constructor() {
1377
1430
  super(...arguments);
1378
- d(this, "emitEventType", v.RotateNode);
1431
+ d(this, "emitEventType", T.RotateNode);
1379
1432
  }
1380
1433
  async consume(e) {
1381
1434
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1383,23 +1436,22 @@ class Ie extends E {
1383
1436
  return await this.consumeForLocalWorker(e), !0;
1384
1437
  }
1385
1438
  async consumeForLocalWorker(e) {
1386
- var a;
1387
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n, emitEventType: c } = e;
1388
- s === N && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
1439
+ var c;
1440
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a, emitEventType: n } = e;
1441
+ s === L && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1389
1442
  updateSelectorOpt: o,
1390
1443
  willRefreshSelector: r,
1391
1444
  willSyncService: i,
1392
- willSerializeData: n,
1393
- emitEventType: c,
1445
+ willSerializeData: a,
1446
+ emitEventType: n,
1394
1447
  isSync: !0,
1395
- scene: this.scene,
1396
1448
  callback: this.updateSelectorCallback
1397
1449
  }));
1398
1450
  }
1399
1451
  updateSelectorCallback(e) {
1400
- const { param: s, postData: o, workShapeNode: r, res: i, newServiceStore: n } = e, { updateSelectorOpt: c, willSyncService: a, willSerializeData: h, isSync: l } = s, S = c.workState, u = o.sp || [], y = i == null ? void 0 : i.selectRect;
1401
- if (a) {
1402
- h && S === T.Done && u.push({
1452
+ const { param: s, postData: o, workShapeNode: r, res: i, newServiceStore: a } = e, { updateSelectorOpt: n, willSyncService: c, willSerializeData: h, isSync: l } = s, S = n.workState, u = o.sp || [], y = i == null ? void 0 : i.selectRect;
1453
+ if (c) {
1454
+ h && S === I.Done && u.push({
1403
1455
  type: p.Select,
1404
1456
  selectIds: r.selectIds,
1405
1457
  selectRect: y,
@@ -1407,10 +1459,10 @@ class Ie extends E {
1407
1459
  isSync: l,
1408
1460
  points: r.getChildrenPoints()
1409
1461
  });
1410
- for (const [m, g] of n.entries())
1462
+ for (const [m, v] of a.entries())
1411
1463
  u.push(
1412
1464
  {
1413
- ...g,
1465
+ ...v,
1414
1466
  workId: m,
1415
1467
  type: p.UpdateNode,
1416
1468
  updateNodeOpt: {
@@ -1425,10 +1477,10 @@ class Ie extends E {
1425
1477
  };
1426
1478
  }
1427
1479
  }
1428
- class Ne extends E {
1480
+ class We extends E {
1429
1481
  constructor() {
1430
1482
  super(...arguments);
1431
- d(this, "emitEventType", v.SetFontStyle);
1483
+ d(this, "emitEventType", T.SetFontStyle);
1432
1484
  }
1433
1485
  async consume(e) {
1434
1486
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1436,26 +1488,26 @@ class Ne extends E {
1436
1488
  return await this.consumeForLocalWorker(e), !0;
1437
1489
  }
1438
1490
  async consumeForLocalWorker(e) {
1439
- var a;
1440
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n, textUpdateForWoker: c } = e;
1441
- s === N && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
1491
+ var c;
1492
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a, textUpdateForWoker: n } = e;
1493
+ s === L && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1442
1494
  updateSelectorOpt: o,
1443
1495
  willRefreshSelector: r,
1444
1496
  willSyncService: i,
1445
- willSerializeData: n,
1446
- textUpdateForWoker: c,
1497
+ willSerializeData: a,
1498
+ textUpdateForWoker: n,
1447
1499
  callback: this.updateSelectorCallback
1448
1500
  }));
1449
1501
  }
1450
1502
  updateSelectorCallback(e) {
1451
- const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: n } = e, { willSyncService: c, isSync: a, updateSelectorOpt: h, textUpdateForWoker: l } = s, S = o.sp || [], u = n == null ? void 0 : n.selectRect;
1452
- if (c && S) {
1503
+ const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: a } = e, { willSyncService: n, isSync: c, updateSelectorOpt: h, textUpdateForWoker: l } = s, S = o.sp || [], u = a == null ? void 0 : a.selectRect;
1504
+ if (n && S) {
1453
1505
  h.fontSize && S.push({
1454
1506
  type: p.Select,
1455
1507
  selectIds: i.selectIds,
1456
1508
  selectRect: u,
1457
- willSyncService: c,
1458
- isSync: a,
1509
+ willSyncService: n,
1510
+ isSync: c,
1459
1511
  points: i.getChildrenPoints()
1460
1512
  });
1461
1513
  for (const [y, m] of r.entries())
@@ -1473,7 +1525,7 @@ class Ne extends E {
1473
1525
  updateNodeOpt: {
1474
1526
  useAnimation: !1
1475
1527
  },
1476
- isSync: a
1528
+ isSync: c
1477
1529
  }
1478
1530
  );
1479
1531
  }
@@ -1482,10 +1534,10 @@ class Ne extends E {
1482
1534
  };
1483
1535
  }
1484
1536
  }
1485
- class Le extends E {
1537
+ class Ne extends E {
1486
1538
  constructor() {
1487
1539
  super(...arguments);
1488
- d(this, "emitEventType", v.SetPoint);
1540
+ d(this, "emitEventType", T.SetPoint);
1489
1541
  }
1490
1542
  async consume(e) {
1491
1543
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1493,22 +1545,22 @@ class Le extends E {
1493
1545
  return this.consumeForLocalWorker(e), !0;
1494
1546
  }
1495
1547
  async consumeForLocalWorker(e) {
1496
- var a;
1497
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n, textUpdateForWoker: c } = e;
1498
- s === N && o && await ((a = this.localWork) == null ? void 0 : a.updateSelector({
1548
+ var c;
1549
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a, textUpdateForWoker: n } = e;
1550
+ s === L && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1499
1551
  updateSelectorOpt: o,
1500
1552
  willRefreshSelector: r,
1501
1553
  willSyncService: i,
1502
1554
  emitEventType: this.emitEventType,
1503
- willSerializeData: n,
1555
+ willSerializeData: a,
1504
1556
  isSync: !0,
1505
- textUpdateForWoker: c,
1557
+ textUpdateForWoker: n,
1506
1558
  callback: this.updateSelectorCallback
1507
1559
  }));
1508
1560
  }
1509
1561
  updateSelectorCallback(e) {
1510
- const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: n } = e, { willSyncService: c, isSync: a } = s, h = o.sp || [], l = n == null ? void 0 : n.selectRect;
1511
- if (c && h) {
1562
+ const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: a } = e, { willSyncService: n, isSync: c } = s, h = o.sp || [], l = a == null ? void 0 : a.selectRect;
1563
+ if (n && h) {
1512
1564
  for (const [S, u] of r.entries())
1513
1565
  h.push(
1514
1566
  {
@@ -1518,15 +1570,15 @@ class Le extends E {
1518
1570
  updateNodeOpt: {
1519
1571
  useAnimation: !1
1520
1572
  },
1521
- isSync: a
1573
+ isSync: c
1522
1574
  }
1523
1575
  );
1524
1576
  h.push({
1525
1577
  type: p.Select,
1526
1578
  selectIds: i.selectIds,
1527
1579
  selectRect: l,
1528
- willSyncService: c,
1529
- isSync: a,
1580
+ willSyncService: n,
1581
+ isSync: c,
1530
1582
  points: i.getChildrenPoints()
1531
1583
  });
1532
1584
  }
@@ -1535,10 +1587,10 @@ class Le extends E {
1535
1587
  };
1536
1588
  }
1537
1589
  }
1538
- class be extends E {
1590
+ class Le extends E {
1539
1591
  constructor() {
1540
1592
  super(...arguments);
1541
- d(this, "emitEventType", v.SetLock);
1593
+ d(this, "emitEventType", T.SetLock);
1542
1594
  }
1543
1595
  async consume(e) {
1544
1596
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1546,19 +1598,19 @@ class be extends E {
1546
1598
  return this.consumeForLocalWorker(e), !0;
1547
1599
  }
1548
1600
  async consumeForLocalWorker(e) {
1549
- var c;
1550
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n } = e;
1551
- s === N && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1601
+ var n;
1602
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a } = e;
1603
+ s === L && o && await ((n = this.localWork) == null ? void 0 : n.updateSelector({
1552
1604
  updateSelectorOpt: o,
1553
1605
  willRefreshSelector: r,
1554
1606
  willSyncService: i,
1555
- willSerializeData: n,
1607
+ willSerializeData: a,
1556
1608
  callback: this.updateSelectorCallback
1557
1609
  }));
1558
1610
  }
1559
1611
  updateSelectorCallback(e) {
1560
- const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: n } = e, { willSyncService: c, isSync: a, updateSelectorOpt: h } = s, l = o.sp || [], S = n == null ? void 0 : n.selectRect;
1561
- if (c && l) {
1612
+ const { param: s, postData: o, newServiceStore: r, workShapeNode: i, res: a } = e, { willSyncService: n, isSync: c, updateSelectorOpt: h } = s, l = o.sp || [], S = a == null ? void 0 : a.selectRect;
1613
+ if (n && l) {
1562
1614
  for (const [u, y] of r.entries())
1563
1615
  l.push(
1564
1616
  {
@@ -1568,7 +1620,7 @@ class be extends E {
1568
1620
  updateNodeOpt: {
1569
1621
  useAnimation: !1
1570
1622
  },
1571
- isSync: a
1623
+ isSync: c
1572
1624
  }
1573
1625
  );
1574
1626
  l.push({
@@ -1579,8 +1631,8 @@ class be extends E {
1579
1631
  type: p.Select,
1580
1632
  selectIds: i.selectIds,
1581
1633
  selectRect: S,
1582
- willSyncService: c,
1583
- isSync: a
1634
+ willSyncService: n,
1635
+ isSync: c
1584
1636
  });
1585
1637
  }
1586
1638
  return {
@@ -1588,10 +1640,10 @@ class be extends E {
1588
1640
  };
1589
1641
  }
1590
1642
  }
1591
- class Oe extends E {
1643
+ class be extends E {
1592
1644
  constructor() {
1593
1645
  super(...arguments);
1594
- d(this, "emitEventType", v.SetShapeOpt);
1646
+ d(this, "emitEventType", T.SetShapeOpt);
1595
1647
  }
1596
1648
  async consume(e) {
1597
1649
  const { msgType: s, dataType: o, emitEventType: r } = e;
@@ -1599,70 +1651,70 @@ class Oe extends E {
1599
1651
  return this.consumeForLocalWorker(e), !0;
1600
1652
  }
1601
1653
  async consumeForLocalWorker(e) {
1602
- var c;
1603
- const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: n } = e;
1604
- s === N && o && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1654
+ var n;
1655
+ const { workId: s, updateNodeOpt: o, willRefreshSelector: r, willSyncService: i, willSerializeData: a } = e;
1656
+ s === L && o && await ((n = this.localWork) == null ? void 0 : n.updateSelector({
1605
1657
  updateSelectorOpt: o,
1606
1658
  willRefreshSelector: r,
1607
1659
  willSyncService: i,
1608
- willSerializeData: n,
1660
+ willSerializeData: a,
1609
1661
  callback: this.updateSelectorCallback
1610
1662
  }));
1611
1663
  }
1612
1664
  updateSelectorCallback(e) {
1613
- const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: n } = s, c = o.sp || [];
1614
- if (i && c)
1615
- for (const [a, h] of r.entries())
1616
- c.push(
1665
+ const { param: s, postData: o, newServiceStore: r } = e, { willSyncService: i, isSync: a } = s, n = o.sp || [];
1666
+ if (i && n)
1667
+ for (const [c, h] of r.entries())
1668
+ n.push(
1617
1669
  {
1618
1670
  ...h,
1619
- workId: a,
1671
+ workId: c,
1620
1672
  type: p.UpdateNode,
1621
1673
  updateNodeOpt: {
1622
1674
  useAnimation: !1
1623
1675
  },
1624
- isSync: n
1676
+ isSync: a
1625
1677
  }
1626
1678
  );
1627
1679
  return {
1628
- sp: c
1680
+ sp: n
1629
1681
  };
1630
1682
  }
1631
1683
  }
1632
- class De {
1684
+ class Me {
1633
1685
  constructor(t) {
1634
1686
  d(this, "builders", /* @__PURE__ */ new Map());
1635
1687
  this.builders = new Map(t.map((e) => [e, this.build(e)]));
1636
1688
  }
1637
1689
  build(t) {
1638
1690
  switch (t) {
1639
- case v.TranslateNode:
1640
- return new Te();
1641
- case v.ZIndexNode:
1691
+ case T.TranslateNode:
1642
1692
  return new ve();
1643
- case v.CopyNode:
1644
- return new me();
1645
- case v.SetColorNode:
1693
+ case T.ZIndexNode:
1646
1694
  return new we();
1647
- case v.DeleteNode:
1695
+ case T.CopyNode:
1696
+ return new me();
1697
+ case T.SetColorNode:
1698
+ return new ye();
1699
+ case T.DeleteNode:
1648
1700
  return new ge();
1649
- case v.ScaleNode:
1650
- return new We();
1651
- case v.RotateNode:
1701
+ case T.ScaleNode:
1702
+ return new Te();
1703
+ case T.RotateNode:
1652
1704
  return new Ie();
1653
- case v.SetFontStyle:
1705
+ case T.SetFontStyle:
1706
+ return new We();
1707
+ case T.SetPoint:
1654
1708
  return new Ne();
1655
- case v.SetPoint:
1709
+ case T.SetLock:
1656
1710
  return new Le();
1657
- case v.SetLock:
1711
+ case T.SetShapeOpt:
1658
1712
  return new be();
1659
- case v.SetShapeOpt:
1660
- return new Oe();
1661
1713
  }
1662
1714
  }
1663
- registerForMainThread(t, e, s) {
1664
- return this.builders.forEach((o) => {
1665
- o && o.registerMainThread(t, e, s);
1715
+ registerForMainThread(t) {
1716
+ return this.builders.forEach((e) => {
1717
+ e && e.registerMainThread(t);
1666
1718
  }), this;
1667
1719
  }
1668
1720
  async consumeForMainThread(t) {
@@ -1672,7 +1724,7 @@ class De {
1672
1724
  return !1;
1673
1725
  }
1674
1726
  }
1675
- class Ee {
1727
+ class Oe {
1676
1728
  constructor(t, e) {
1677
1729
  d(this, "viewId");
1678
1730
  d(this, "fullLayer");
@@ -1694,34 +1746,48 @@ class Ee {
1694
1746
  d(this, "mainThreadPostId");
1695
1747
  d(this, "combinePostMsg", /* @__PURE__ */ new Set());
1696
1748
  d(this, "methodBuilder");
1749
+ d(this, "cacheImages", /* @__PURE__ */ new Map());
1750
+ d(this, "imageResolveMap", /* @__PURE__ */ new Map());
1697
1751
  this.viewId = t, this.opt = e, this.scene = this.createScene({ ...e.canvasOpt, container: e.container }), this.master = e.master;
1698
- const s = F.bufferSize.full, o = F.bufferSize.sub;
1699
- this.fullLayer = this.createLayer("fullLayer", this.scene, { ...e.layerOpt, bufferSize: this.viewId === A ? s : o }), this.topLayer = this.createLayer("topLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === A, o) }), this.localLayer = this.createLayer("localLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === A, o) }), this.serviceLayer = this.createLayer("serviceLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === A, o) }), this.vNodes = new fe(t, this.scene);
1752
+ const s = x.bufferSize.full, o = x.bufferSize.sub;
1753
+ this.fullLayer = this.createLayer("fullLayer", this.scene, { ...e.layerOpt, bufferSize: this.viewId === C ? s : o }), this.topLayer = this.createLayer("topLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === C, o) }), this.localLayer = this.createLayer("localLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === C, o) }), this.serviceLayer = this.createLayer("serviceLayer", this.scene, { ...e.layerOpt, bufferSize: (this.viewId === C, o) }), this.vNodes = new ue(t, this.scene);
1700
1754
  const r = {
1701
1755
  thread: this,
1702
1756
  vNodes: this.vNodes
1703
1757
  };
1704
- this.localWork = new ke(r), this.serviceWork = new ye(r), this.topWork = new Se(r), this.vNodes.init(this.fullLayer), this.methodBuilder = new De([
1705
- v.CopyNode,
1706
- v.SetColorNode,
1707
- v.DeleteNode,
1708
- v.RotateNode,
1709
- v.ScaleNode,
1710
- v.TranslateNode,
1711
- v.ZIndexNode,
1712
- v.SetFontStyle,
1713
- v.SetPoint,
1714
- v.SetLock,
1715
- v.SetShapeOpt
1716
- ]).registerForMainThread(this.localWork, this.serviceWork, this.scene);
1758
+ this.localWork = new Se(r), this.serviceWork = new ke(r), this.topWork = new fe(r), this.vNodes.init(this.fullLayer), this.methodBuilder = new Me([
1759
+ T.CopyNode,
1760
+ T.SetColorNode,
1761
+ T.DeleteNode,
1762
+ T.RotateNode,
1763
+ T.ScaleNode,
1764
+ T.TranslateNode,
1765
+ T.ZIndexNode,
1766
+ T.SetFontStyle,
1767
+ T.SetPoint,
1768
+ T.SetLock,
1769
+ T.SetShapeOpt
1770
+ ]).registerForMainThread(this);
1771
+ }
1772
+ getCachedImages(t) {
1773
+ return this.cacheImages.get(t);
1774
+ }
1775
+ clearCacheImages() {
1776
+ this.cacheImages.forEach((t) => t.close()), this.cacheImages.clear();
1777
+ }
1778
+ clearImageResolveMap() {
1779
+ this.imageResolveMap.forEach(({ timer: t }) => {
1780
+ t && clearTimeout(t);
1781
+ }), this.imageResolveMap.clear();
1717
1782
  }
1718
1783
  post(t) {
1719
1784
  this.combinePostMsg.add(t), this.runBatchPostData();
1720
1785
  }
1721
1786
  async on(t) {
1787
+ var e;
1722
1788
  if (!await this.methodBuilder.consumeForMainThread(t)) {
1723
- const { msgType: e, toolsType: s, opt: o, dataType: r, workId: i, workState: n } = t, c = i == null ? void 0 : i.toString();
1724
- switch (e) {
1789
+ const { msgType: s, toolsType: o, opt: r, dataType: i, workId: a, workState: n, imageSrc: c, imageBitmap: h } = t, l = a == null ? void 0 : a.toString();
1790
+ switch (s) {
1725
1791
  case p.Destroy:
1726
1792
  this.destroy();
1727
1793
  break;
@@ -1732,60 +1798,95 @@ class Ee {
1732
1798
  await this.updateCamera(t);
1733
1799
  break;
1734
1800
  case p.UpdateTools:
1735
- if (s && o) {
1736
- const a = {
1737
- toolsType: s,
1738
- toolsOpt: o
1801
+ if (o && r) {
1802
+ const S = {
1803
+ toolsType: o,
1804
+ toolsOpt: r
1739
1805
  };
1740
- this.topWork.canUseTopLayer(s) ? this.topWork.setToolsOpt(a) : this.localWork.setToolsOpt(a);
1806
+ this.topWork.canUseTopLayer(o) ? this.topWork.setToolsOpt(S) : this.localWork.setToolsOpt(S);
1741
1807
  }
1742
1808
  break;
1743
1809
  case p.CreateWork:
1744
- if (c && o && s) {
1745
- if (this.topWork.canUseTopLayer(s)) {
1810
+ if (l && r && o) {
1811
+ if (this.topWork.canUseTopLayer(o)) {
1746
1812
  this.topWork.getToolsOpt() || this.topWork.setToolsOpt({
1747
- toolsType: s,
1748
- toolsOpt: o
1749
- }), this.topWork.setWorkOptions(c, o);
1813
+ toolsType: o,
1814
+ toolsOpt: r
1815
+ }), this.topWork.setWorkOptions(l, r);
1750
1816
  break;
1751
1817
  }
1752
1818
  this.localWork.getToolsOpt() || this.localWork.setToolsOpt({
1753
- toolsType: s,
1754
- toolsOpt: o
1755
- }), this.localWork.setWorkOptions(c, o);
1819
+ toolsType: o,
1820
+ toolsOpt: r
1821
+ }), this.localWork.setWorkOptions(l, r);
1756
1822
  }
1757
1823
  break;
1758
1824
  case p.DrawWork:
1759
- n === T.Done && r === w.Local ? this.consumeDrawAll(r, t) : this.consumeDraw(r, t);
1825
+ n === I.Done && i === w.Local ? this.consumeDrawAll(i, t) : this.consumeDraw(i, t);
1760
1826
  break;
1761
1827
  case p.UpdateNode:
1762
1828
  case p.FullWork:
1763
- if (s && this.topWork.canUseTopLayer(s)) {
1764
- this.consumeDrawAll(r, t);
1829
+ if (o && this.topWork.canUseTopLayer(o)) {
1830
+ this.consumeDrawAll(i, t);
1765
1831
  break;
1766
1832
  }
1767
- this.consumeFull(r, t);
1833
+ this.consumeFull(i, t);
1768
1834
  break;
1769
1835
  case p.RemoveNode:
1770
1836
  await this.removeNode(t);
1771
1837
  return;
1772
1838
  case p.Select:
1773
- r === w.Service && (i === N ? this.localWork.updateFullSelectWork(t) : this.serviceWork.runSelectWork(t));
1839
+ i === w.Service && (a === L ? this.localWork.updateFullSelectWork(t) : this.serviceWork.runSelectWork(t));
1774
1840
  break;
1775
1841
  case p.CursorHover:
1776
1842
  this.localWork.cursorHover(t);
1777
1843
  break;
1778
1844
  case p.GetTextActive:
1779
- r === w.Local && this.localWork.checkTextActive(t);
1845
+ i === w.Local && this.localWork.checkTextActive(t);
1846
+ break;
1847
+ case p.GetImageBitMap:
1848
+ if (c && h && this.cacheImages.set(c, h), a) {
1849
+ const S = a.toString(), u = (e = this.imageResolveMap.get(S)) == null ? void 0 : e.resolve;
1850
+ u && u(S);
1851
+ }
1780
1852
  break;
1781
1853
  }
1782
1854
  }
1783
1855
  }
1856
+ async loadImageBitMap(t) {
1857
+ const { toolsType: e, opt: s, workId: o } = t;
1858
+ if (e === f.Image && s && s.src && o) {
1859
+ const r = s.src, i = this.cacheImages.has(r), a = o.toString();
1860
+ if (!i) {
1861
+ const n = await new Promise((c) => {
1862
+ const h = this.imageResolveMap.get(a) || {
1863
+ resolve: void 0,
1864
+ timer: void 0
1865
+ };
1866
+ h.timer && clearTimeout(h.timer), h.resolve = c, h.timer = setTimeout(() => {
1867
+ const l = this.imageResolveMap.get(a);
1868
+ l != null && l.resolve && l.resolve(a);
1869
+ }, 5e3), this.imageResolveMap.set(a, h), this.opt.post({
1870
+ sp: [{
1871
+ imageSrc: r,
1872
+ workId: a,
1873
+ viewId: this.viewId,
1874
+ isgl: !!this.fullLayer.parent.gl,
1875
+ isSubWorker: !1,
1876
+ type: p.GetImageBitMap
1877
+ }]
1878
+ });
1879
+ });
1880
+ this.imageResolveMap.delete(n);
1881
+ }
1882
+ return this.cacheImages.get(r);
1883
+ }
1884
+ }
1784
1885
  async removeNode(t) {
1785
1886
  const { dataType: e, workId: s, removeIds: o } = t, r = o || [];
1786
1887
  if (s && r.push(s.toString()), r.length)
1787
1888
  for (const i of r) {
1788
- if (i === N) {
1889
+ if (i === L) {
1789
1890
  await this.localWork.removeSelector(t);
1790
1891
  continue;
1791
1892
  }
@@ -1794,7 +1895,7 @@ class Ee {
1794
1895
  }
1795
1896
  async consumeFull(t, e) {
1796
1897
  const s = await this.localWork.colloctEffectSelectWork(e);
1797
- s && t === w.Local && await this.localWork.consumeFull(s, this.scene), s && t === w.Service && this.serviceWork.consumeFull(s);
1898
+ s && t === w.Local && await this.localWork.consumeFull(s), s && t === w.Service && this.serviceWork.consumeFull(s);
1798
1899
  }
1799
1900
  setCameraOpt(t) {
1800
1901
  this.cameraOpt = t;
@@ -1813,14 +1914,14 @@ class Ee {
1813
1914
  if ((s = o.sp) != null && s.length)
1814
1915
  for (const r of o.sp) {
1815
1916
  let i = !1;
1816
- for (const n of t)
1817
- if (X(r, n)) {
1917
+ for (const a of t)
1918
+ if (j(r, a)) {
1818
1919
  i = !0;
1819
1920
  break;
1820
1921
  }
1821
1922
  i || t.push(r);
1822
1923
  }
1823
- ue(o.drawCount) && (e = o.drawCount);
1924
+ de(o.drawCount) && (e = o.drawCount);
1824
1925
  }
1825
1926
  return this.combinePostMsg.clear(), {
1826
1927
  sp: t,
@@ -1835,7 +1936,7 @@ class Ee {
1835
1936
  clearAll() {
1836
1937
  this.fullLayer.children.length && (this.fullLayer.parent.children.forEach((t) => {
1837
1938
  t.name !== "viewport" && t.remove();
1838
- }), this.fullLayer.removeAllChildren()), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
1939
+ }), this.fullLayer.removeAllChildren()), this.clearCacheImages(), this.clearImageResolveMap(), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
1839
1940
  sp: [{
1840
1941
  type: p.Clear
1841
1942
  }]
@@ -1867,63 +1968,71 @@ class Ee {
1867
1968
  async updateCamera(t) {
1868
1969
  var o;
1869
1970
  const { cameraOpt: e, scenePath: s } = t;
1870
- if (e && !X(this.cameraOpt, e)) {
1971
+ if (e && !j(this.cameraOpt, e)) {
1871
1972
  if (this.taskUpdateCameraId && (clearTimeout(this.taskUpdateCameraId), this.taskUpdateCameraId = void 0), s) {
1872
- let a = !1;
1973
+ let c = !1;
1873
1974
  for (const [h, l] of this.localWork.getWorkShapes().entries())
1874
- if (l.toolsType !== f.Text && l.toolsType !== f.PencilEraser && l.toolsType !== f.Eraser && l.toolsType !== f.Selector && l.toolsType !== f.LaserPen && h !== H && h !== N) {
1875
- a = !0;
1876
- break;
1975
+ switch (l.toolsType) {
1976
+ case f.Text:
1977
+ case f.BitMapEraser:
1978
+ case f.PencilEraser:
1979
+ case f.Eraser:
1980
+ case f.Selector:
1981
+ case f.LaserPen:
1982
+ break;
1983
+ default:
1984
+ h !== _ && h !== L && (c = !0);
1985
+ break;
1877
1986
  }
1878
- if (a) {
1987
+ if (c) {
1879
1988
  this.taskUpdateCameraId = setTimeout(() => {
1880
1989
  this.taskUpdateCameraId = void 0, this.updateCamera(t);
1881
- }, $);
1990
+ }, G);
1882
1991
  return;
1883
1992
  }
1884
1993
  }
1885
1994
  const r = /* @__PURE__ */ new Map();
1886
- for (const [a, h] of this.vNodes.getNodesByType(f.Text).entries()) {
1995
+ for (const [c, h] of this.vNodes.getNodesByType(f.Text).entries()) {
1887
1996
  const l = h.rect;
1888
- r.set(a, ee(l));
1997
+ r.set(c, J(l));
1889
1998
  }
1890
1999
  const i = new Set(r.keys());
1891
- let n = !1;
2000
+ let a = !1;
1892
2001
  if (this.localWork.hasSelector()) {
1893
- const a = (o = this.localWork.getSelector()) == null ? void 0 : o.selectIds;
1894
- if (a) {
1895
- n = !0;
1896
- for (const h of a)
2002
+ const c = (o = this.localWork.getSelector()) == null ? void 0 : o.selectIds;
2003
+ if (c) {
2004
+ a = !0;
2005
+ for (const h of c)
1897
2006
  i.add(h);
1898
2007
  }
1899
2008
  }
1900
- let c = !1;
2009
+ let n = !1;
1901
2010
  if (this.serviceWork.selectorWorkShapes.size)
1902
- for (const a of this.serviceWork.selectorWorkShapes.values()) {
1903
- const h = a.selectIds;
2011
+ for (const c of this.serviceWork.selectorWorkShapes.values()) {
2012
+ const h = c.selectIds;
1904
2013
  if (h) {
1905
- c = !0;
2014
+ n = !0;
1906
2015
  for (const l of h)
1907
2016
  i.add(l);
1908
2017
  }
1909
2018
  }
1910
2019
  if (this.setCameraOpt(e), this.vNodes.curNodeMap.size) {
1911
2020
  this.vNodes.clearTarget(), this.vNodes.updateHighLevelNodesRect(i), this.debounceUpdateCameraId && clearTimeout(this.debounceUpdateCameraId);
1912
- for (const [a, h] of r.entries()) {
1913
- const l = this.vNodes.get(a);
2021
+ for (const [c, h] of r.entries()) {
2022
+ const l = this.vNodes.get(c);
1914
2023
  if (l) {
1915
- const S = h, u = l.rect, y = this.getSceneRect(), m = _(S, y), g = _(u, y);
2024
+ const S = h, u = l.rect, y = this.getSceneRect(), m = z(S, y), v = z(u, y);
1916
2025
  let W = !1;
1917
- if ((m !== g || S.w !== u.w || S.h !== u.h || g === Z.intersect) && (W = !0), W) {
1918
- const { toolsType: M, opt: L } = l;
1919
- M === f.Text && L.workState === T.Done && this.debounceUpdateCache.add(a);
2026
+ if ((m !== v || S.w !== u.w || S.h !== u.h || v === V.intersect) && (W = !0), W) {
2027
+ const { toolsType: g, opt: k } = l;
2028
+ g === f.Text && k.workState === I.Done && this.debounceUpdateCache.add(c);
1920
2029
  }
1921
2030
  }
1922
2031
  }
1923
- if (n && this.localWork.reRenderSelector(), c)
1924
- for (const [a, h] of this.serviceWork.selectorWorkShapes.entries())
2032
+ if (a && this.localWork.reRenderSelector(), n)
2033
+ for (const [c, h] of this.serviceWork.selectorWorkShapes.entries())
1925
2034
  this.serviceWork.runSelectWork({
1926
- workId: a,
2035
+ workId: c,
1927
2036
  selectIds: h.selectIds,
1928
2037
  msgType: p.Select,
1929
2038
  dataType: w.Service,
@@ -1932,22 +2041,22 @@ class Ee {
1932
2041
  this.debounceUpdateCameraId = setTimeout(() => {
1933
2042
  var h;
1934
2043
  this.debounceUpdateCameraId = void 0;
1935
- const a = [];
2044
+ const c = [];
1936
2045
  for (const l of this.debounceUpdateCache.values()) {
1937
2046
  if ((h = this.fullLayer) == null ? void 0 : h.getElementsByName(l)[0]) {
1938
2047
  const u = this.vNodes.get(l);
1939
2048
  if (u) {
1940
- const { toolsType: y, opt: m, rect: g } = u, W = this.localWork.setFullWork({
2049
+ const { toolsType: y, opt: m, rect: v } = u, W = this.localWork.setFullWork({
1941
2050
  toolsType: y,
1942
2051
  opt: m,
1943
2052
  workId: l
1944
2053
  });
1945
2054
  if (W) {
1946
- const M = this.getSceneRect(), L = _(g, M);
1947
- a.push(W.consumeServiceAsync({
2055
+ const g = this.getSceneRect(), k = z(v, g);
2056
+ c.push(W.consumeServiceAsync({
1948
2057
  isFullWork: !0,
1949
2058
  replaceId: l,
1950
- isDrawLabel: L !== Z.outside
2059
+ isDrawLabel: k !== V.outside
1951
2060
  }));
1952
2061
  }
1953
2062
  }
@@ -1955,7 +2064,7 @@ class Ee {
1955
2064
  this.debounceUpdateCache.delete(l);
1956
2065
  }
1957
2066
  this.vNodes.updateLowLevelNodesRect(), this.vNodes.clearHighLevelIds();
1958
- }, $);
2067
+ }, G);
1959
2068
  }
1960
2069
  }
1961
2070
  }
@@ -1969,7 +2078,7 @@ class Ee {
1969
2078
  };
1970
2079
  }
1971
2080
  createScene(t) {
1972
- return new Q({
2081
+ return new Y({
1973
2082
  displayRatio: this.opt.displayer.dpr,
1974
2083
  depth: !1,
1975
2084
  desynchronized: !0,
@@ -1979,14 +2088,14 @@ class Ee {
1979
2088
  });
1980
2089
  }
1981
2090
  createLayer(t, e, s) {
1982
- const { width: o, height: r } = s, i = `canvas-${t}`, n = e.layer(i, { ...s, offscreen: !1 }), c = new J({
2091
+ const { width: o, height: r } = s, i = `canvas-${t}`, a = e.layer(i, { ...s, offscreen: !1 }), n = new Q({
1983
2092
  anchor: [0.5, 0.5],
1984
2093
  pos: [o * 0.5, r * 0.5],
1985
2094
  size: [o, r],
1986
2095
  name: "viewport",
1987
2096
  id: t
1988
2097
  });
1989
- return n.append(c), c;
2098
+ return a.append(n), n;
1990
2099
  }
1991
2100
  updateScene(t) {
1992
2101
  this.scene.attr({ ...t });
@@ -1998,10 +2107,10 @@ class Ee {
1998
2107
  this.fullLayer.parent.setAttribute("width", e), this.fullLayer.parent.setAttribute("height", s), this.fullLayer.setAttribute("size", [e, s]), this.fullLayer.setAttribute("pos", [e * 0.5, s * 0.5]), this.topLayer.parent.setAttribute("width", e), this.topLayer.parent.setAttribute("height", s), this.topLayer.setAttribute("size", [e, s]), this.topLayer.setAttribute("pos", [e * 0.5, s * 0.5]), this.localLayer.parent.setAttribute("width", e), this.localLayer.parent.setAttribute("height", s), this.localLayer.setAttribute("size", [e, s]), this.localLayer.setAttribute("pos", [e * 0.5, s * 0.5]), this.serviceLayer.parent.setAttribute("width", e), this.serviceLayer.parent.setAttribute("height", s), this.serviceLayer.setAttribute("size", [e, s]), this.serviceLayer.setAttribute("pos", [e * 0.5, s * 0.5]);
1999
2108
  }
2000
2109
  destroy() {
2001
- this.vNodes.clear(), this.fullLayer.remove(), this.topLayer.remove(), this.localLayer.remove(), this.serviceLayer.remove(), this.scene.remove(), this.localWork.destroy(), this.serviceWork.destroy(), this.topWork.destroy();
2110
+ this.clearCacheImages(), this.clearImageResolveMap(), this.vNodes.clear(), this.fullLayer.remove(), this.topLayer.remove(), this.localLayer.remove(), this.serviceLayer.remove(), this.scene.remove(), this.localWork.destroy(), this.serviceWork.destroy(), this.topWork.destroy();
2002
2111
  }
2003
2112
  }
2004
- class Me {
2113
+ class Ee {
2005
2114
  constructor(t, e) {
2006
2115
  d(this, "viewId");
2007
2116
  d(this, "fullLayer");
@@ -2011,13 +2120,27 @@ class Me {
2011
2120
  d(this, "mainThreadPostId");
2012
2121
  d(this, "combinePostMsg", /* @__PURE__ */ new Set());
2013
2122
  d(this, "workShapes", /* @__PURE__ */ new Map());
2014
- this.viewId = t, this.opt = e, this.scene = this.createScene({ ...e.canvasOpt, container: e.container }), this.master = e.master, this.fullLayer = this.createLayer("fullLayer", this.scene, { ...e.layerOpt, bufferSize: this.viewId === A ? 6e3 : 3e3 });
2123
+ d(this, "cacheImages", /* @__PURE__ */ new Map());
2124
+ d(this, "imageResolveMap", /* @__PURE__ */ new Map());
2125
+ this.viewId = t, this.opt = e, this.scene = this.createScene({ ...e.canvasOpt, container: e.container }), this.master = e.master, this.fullLayer = this.createLayer("fullLayer", this.scene, { ...e.layerOpt, bufferSize: this.viewId === C ? 6e3 : 3e3 });
2126
+ }
2127
+ getCachedImages(t) {
2128
+ return this.cacheImages.get(t);
2129
+ }
2130
+ clearCacheImages() {
2131
+ this.cacheImages.forEach((t) => t.close()), this.cacheImages.clear();
2132
+ }
2133
+ clearImageResolveMap() {
2134
+ this.imageResolveMap.forEach(({ timer: t }) => {
2135
+ t && clearTimeout(t);
2136
+ }), this.imageResolveMap.clear();
2015
2137
  }
2016
2138
  post(t) {
2017
2139
  this.combinePostMsg.add(t), this.runBatchPostData();
2018
2140
  }
2019
2141
  async on(t) {
2020
- const { msgType: e } = t;
2142
+ var i;
2143
+ const { msgType: e, imageSrc: s, imageBitmap: o, workId: r } = t;
2021
2144
  switch (e) {
2022
2145
  case p.Snapshot:
2023
2146
  await this.getSnapshot(t), this.destroy();
@@ -2025,10 +2148,45 @@ class Me {
2025
2148
  case p.BoundingBox:
2026
2149
  await this.getBoundingRect(t), this.destroy();
2027
2150
  return;
2151
+ case p.GetImageBitMap:
2152
+ if (s && o && this.cacheImages.set(s, o), r) {
2153
+ const a = r.toString(), n = (i = this.imageResolveMap.get(a)) == null ? void 0 : i.resolve;
2154
+ n && n(a);
2155
+ }
2156
+ break;
2157
+ }
2158
+ }
2159
+ async loadImageBitMap(t) {
2160
+ const { toolsType: e, opt: s, workId: o } = t;
2161
+ if (e === f.Image && s && s.src && o) {
2162
+ const r = s.src, i = this.cacheImages.has(r), a = o.toString();
2163
+ if (!i) {
2164
+ const n = await new Promise((c) => {
2165
+ const h = this.imageResolveMap.get(a) || {
2166
+ resolve: void 0,
2167
+ timer: void 0
2168
+ };
2169
+ h.timer && clearTimeout(h.timer), h.resolve = c, h.timer = setTimeout(() => {
2170
+ const l = this.imageResolveMap.get(a);
2171
+ l != null && l.resolve && l.resolve(a);
2172
+ }, 5e3), this.imageResolveMap.set(a, h), this.opt.post({
2173
+ sp: [{
2174
+ imageSrc: r,
2175
+ workId: a,
2176
+ viewId: this.viewId,
2177
+ isgl: !!this.fullLayer.parent.gl,
2178
+ isSubWorker: !0,
2179
+ type: p.GetImageBitMap
2180
+ }]
2181
+ });
2182
+ });
2183
+ this.imageResolveMap.delete(n);
2184
+ }
2185
+ return this.cacheImages.get(r);
2028
2186
  }
2029
2187
  }
2030
2188
  createWorkShapeNode(t) {
2031
- return B({ ...t, fullLayer: this.fullLayer, drawLayer: void 0 });
2189
+ return U({ ...t, fullLayer: this.fullLayer, drawLayer: void 0 });
2032
2190
  }
2033
2191
  setFullWork(t) {
2034
2192
  const { workId: e, opt: s, toolsType: o } = t;
@@ -2043,53 +2201,52 @@ class Me {
2043
2201
  }
2044
2202
  }
2045
2203
  async runFullWork(t) {
2046
- var o, r;
2047
- const e = this.setFullWork(t), s = t.ops && P(t.ops);
2204
+ var o;
2205
+ const e = this.setFullWork(t), s = t.ops && F(t.ops);
2048
2206
  if (e) {
2049
- let i, n;
2050
- const c = (o = e.getWorkId()) == null ? void 0 : o.toString();
2051
- return e.toolsType === f.Image ? i = await e.consumeServiceAsync({
2207
+ let r, i;
2208
+ const a = (o = e.getWorkId()) == null ? void 0 : o.toString();
2209
+ return e.toolsType === f.Image ? r = await e.consumeServiceAsync({
2052
2210
  isFullWork: !0,
2053
- scene: (r = this.fullLayer.parent) == null ? void 0 : r.parent,
2054
- isMainThread: !0
2055
- }) : e.toolsType === f.Text ? i = await e.consumeServiceAsync({
2211
+ worker: this
2212
+ }) : e.toolsType === f.Text ? r = await e.consumeServiceAsync({
2056
2213
  isFullWork: !0,
2057
- replaceId: c,
2214
+ replaceId: a,
2058
2215
  isDrawLabel: !0
2059
- }) : (i = e.consumeService({
2216
+ }) : (r = e.consumeService({
2060
2217
  op: s,
2061
2218
  isFullWork: !0,
2062
- replaceId: c
2063
- }), n = (t == null ? void 0 : t.updateNodeOpt) && e.updataOptService(t.updateNodeOpt)), x(i, n);
2219
+ replaceId: a
2220
+ }), i = (t == null ? void 0 : t.updateNodeOpt) && e.updataOptService(t.updateNodeOpt)), A(r, i);
2064
2221
  }
2065
2222
  }
2066
2223
  async getSnapshot(t) {
2067
2224
  const { scenePath: e, scenes: s, cameraOpt: o, w: r, h: i } = t;
2068
2225
  if (e && s && o) {
2069
2226
  this.setCameraOpt(o);
2070
- let n;
2071
- for (const [a, h] of Object.entries(s))
2227
+ let a;
2228
+ for (const [c, h] of Object.entries(s))
2072
2229
  if (h != null && h.type)
2073
2230
  switch (h == null ? void 0 : h.type) {
2074
2231
  case p.UpdateNode:
2075
2232
  case p.FullWork: {
2076
- const { opt: l } = h, S = await this.runFullWork({
2233
+ const { opt: l } = h, S = {
2077
2234
  ...h,
2078
2235
  opt: l,
2079
- workId: a,
2236
+ workId: c,
2080
2237
  msgType: p.FullWork,
2081
2238
  dataType: w.Service,
2082
2239
  viewId: this.viewId
2083
- });
2084
- n = x(n, S);
2240
+ }, u = await this.runFullWork(S);
2241
+ a = A(a, u);
2085
2242
  break;
2086
2243
  }
2087
2244
  }
2088
- let c;
2089
- r && i && (c = {
2245
+ let n;
2246
+ r && i && (n = {
2090
2247
  resizeWidth: r,
2091
2248
  resizeHeight: i
2092
- }), await this.getSnapshotRender({ scenePath: e, options: c });
2249
+ }), await this.getSnapshotRender({ scenePath: e, options: n });
2093
2250
  }
2094
2251
  }
2095
2252
  getSceneRect() {
@@ -2124,19 +2281,19 @@ class Me {
2124
2281
  if (e && s && o) {
2125
2282
  this.setCameraOpt(o);
2126
2283
  let r;
2127
- for (const [i, n] of Object.entries(s))
2128
- if (n != null && n.type)
2129
- switch (n == null ? void 0 : n.type) {
2284
+ for (const [i, a] of Object.entries(s))
2285
+ if (a != null && a.type)
2286
+ switch (a == null ? void 0 : a.type) {
2130
2287
  case p.UpdateNode:
2131
2288
  case p.FullWork: {
2132
- const c = await this.runFullWork({
2133
- ...n,
2289
+ const n = await this.runFullWork({
2290
+ ...a,
2134
2291
  workId: i,
2135
2292
  msgType: p.FullWork,
2136
2293
  dataType: w.Service,
2137
2294
  viewId: this.viewId
2138
2295
  });
2139
- r = x(r, c);
2296
+ r = A(r, n);
2140
2297
  break;
2141
2298
  }
2142
2299
  }
@@ -2165,7 +2322,7 @@ class Me {
2165
2322
  for (const o of s.sp) {
2166
2323
  let r = !1;
2167
2324
  for (const i of t)
2168
- if (he(o, i)) {
2325
+ if (le(o, i)) {
2169
2326
  r = !0;
2170
2327
  break;
2171
2328
  }
@@ -2181,7 +2338,7 @@ class Me {
2181
2338
  e != null && e.length ? t.sp = e.map((r) => r.viewId ? r : { ...r, viewId: this.viewId }) : delete t.sp, (t != null && t.drawCount || (o = t.sp) != null && o.length) && this.opt.post(t);
2182
2339
  }
2183
2340
  createScene(t) {
2184
- return new Q({
2341
+ return new Y({
2185
2342
  displayRatio: this.opt.displayer.dpr,
2186
2343
  depth: !1,
2187
2344
  desynchronized: !0,
@@ -2190,14 +2347,14 @@ class Me {
2190
2347
  });
2191
2348
  }
2192
2349
  createLayer(t, e, s) {
2193
- const { width: o, height: r } = s, i = `canvas-${t}`, n = e.layer(i, s), c = new J({
2350
+ const { width: o, height: r } = s, i = `canvas-${t}`, a = e.layer(i, s), n = new Q({
2194
2351
  anchor: [0.5, 0.5],
2195
2352
  pos: [o * 0.5, r * 0.5],
2196
2353
  size: [o, r],
2197
2354
  name: "viewport",
2198
2355
  id: t
2199
2356
  });
2200
- return n.append(c), c;
2357
+ return a.append(n), n;
2201
2358
  }
2202
2359
  updateScene(t) {
2203
2360
  this.scene.attr({ ...t });
@@ -2209,10 +2366,10 @@ class Me {
2209
2366
  this.fullLayer.parent.setAttribute("width", e), this.fullLayer.parent.setAttribute("height", s), this.fullLayer.setAttribute("size", [e, s]), this.fullLayer.setAttribute("pos", [e * 0.5, s * 0.5]);
2210
2367
  }
2211
2368
  destroy() {
2212
- this.fullLayer.remove(), this.scene.remove();
2369
+ this.clearCacheImages(), this.clearImageResolveMap(), this.fullLayer.remove(), this.scene.remove();
2213
2370
  }
2214
2371
  }
2215
- class ze {
2372
+ class Be {
2216
2373
  constructor(t) {
2217
2374
  d(this, "mainThreadMap", /* @__PURE__ */ new Map());
2218
2375
  d(this, "snapshotThread");
@@ -2221,84 +2378,88 @@ class ze {
2221
2378
  }
2222
2379
  post(t) {
2223
2380
  const { drawCount: e, sp: s, workerTasksqueueCount: o } = t;
2224
- this.master.isBusy && j(o) && this.master.setWorkerTasksqueueCount(o), j(e) && this.master.setMaxDrawCount(e), s && this.master.collectorSyncData(s);
2381
+ this.master.isBusy && $(o) && this.master.setWorkerTasksqueueCount(o), $(e) && this.master.setMaxDrawCount(e), s && this.master.collectorSyncData(s);
2225
2382
  }
2226
2383
  destroy() {
2227
2384
  this.mainThreadMap.clear();
2228
2385
  }
2229
2386
  createMainThread(t, e) {
2230
- return new Ee(t, e);
2387
+ return new Oe(t, e);
2231
2388
  }
2232
2389
  createSnapshotThread(t, e) {
2233
- return new Me(t, e);
2390
+ return new Ee(t, e);
2234
2391
  }
2235
2392
  async consume(t) {
2236
2393
  var e, s, o, r;
2237
2394
  for (const i of t.values()) {
2238
- const { msgType: n, viewId: c, tasksqueue: a, mainTasksqueueCount: h, layerOpt: l, offscreenCanvasOpt: S, cameraOpt: u } = i;
2239
- if (n === p.Console) {
2395
+ const { msgType: a, viewId: n, tasksqueue: c, mainTasksqueueCount: h, layerOpt: l, offscreenCanvasOpt: S, cameraOpt: u, isSubWorker: y } = i;
2396
+ if (a === p.Console) {
2240
2397
  console.log(this);
2241
2398
  continue;
2242
2399
  }
2243
- if (n === p.Init) {
2244
- const m = (e = this.master.control.viewContainerManager.getView(c)) == null ? void 0 : e.displayer, g = m == null ? void 0 : m.canvasContainerRef.current;
2245
- if (m && g && l && S) {
2246
- const W = this.createMainThread(c, {
2247
- displayer: m,
2248
- container: g,
2400
+ if (a === p.Init) {
2401
+ const v = (e = this.master.control.viewContainerManager.getView(n)) == null ? void 0 : e.displayer, W = v == null ? void 0 : v.canvasContainerRef.current;
2402
+ if (v && W && l && S) {
2403
+ const g = this.createMainThread(n, {
2404
+ displayer: v,
2405
+ container: W,
2249
2406
  layerOpt: l,
2250
2407
  master: this.master,
2251
2408
  canvasOpt: S,
2252
2409
  post: this.post.bind(this)
2253
2410
  });
2254
- this.mainThreadMap.set(c, W), W && u && W.setCameraOpt(u);
2411
+ this.mainThreadMap.set(n, g), g && u && g.setCameraOpt(u);
2255
2412
  }
2256
2413
  continue;
2257
2414
  }
2258
- if ((n === p.Snapshot || n === p.BoundingBox) && c === ((s = this.master.control.viewContainerManager.mainView) == null ? void 0 : s.id)) {
2259
- const m = (o = this.master.control.viewContainerManager.getView(c)) == null ? void 0 : o.displayer, g = (r = m.snapshotContainerRef) == null ? void 0 : r.current;
2260
- if (m && g && u) {
2261
- g.style.width = `${u.width}px`, g.style.height = `${u.height}px`;
2262
- const W = {
2263
- ...G.defaultLayerOpt,
2415
+ if ((a === p.Snapshot || a === p.BoundingBox) && n === ((s = this.master.control.viewContainerManager.mainView) == null ? void 0 : s.id)) {
2416
+ const v = (o = this.master.control.viewContainerManager.getView(n)) == null ? void 0 : o.displayer, W = (r = v.snapshotContainerRef) == null ? void 0 : r.current;
2417
+ if (v && W && u) {
2418
+ W.style.width = `${u.width}px`, W.style.height = `${u.height}px`;
2419
+ const g = {
2420
+ ...Z.defaultLayerOpt,
2264
2421
  offscreen: !1,
2265
2422
  width: u.width,
2266
2423
  height: u.height
2267
- }, M = {
2268
- ...G.defaultScreenCanvasOpt,
2424
+ }, k = {
2425
+ ...Z.defaultScreenCanvasOpt,
2269
2426
  width: u.width,
2270
2427
  height: u.height
2271
2428
  };
2272
- this.snapshotThread = this.createSnapshotThread(c, {
2273
- displayer: m,
2274
- container: g,
2275
- layerOpt: W,
2429
+ this.snapshotThread = this.createSnapshotThread(n, {
2430
+ displayer: v,
2431
+ container: W,
2432
+ layerOpt: g,
2276
2433
  master: this.master,
2277
- canvasOpt: M,
2434
+ canvasOpt: k,
2278
2435
  post: this.post.bind(this)
2279
2436
  }), this.snapshotThread.on(i).then(() => {
2280
- this.snapshotThread = void 0, g.innerHTML = "", g.style.width = "", g.style.height = "";
2437
+ this.snapshotThread = void 0, W.innerHTML = "", W.style.width = "", W.style.height = "";
2281
2438
  });
2282
2439
  continue;
2283
2440
  }
2284
2441
  }
2285
- if (n === p.TasksQueue && (a != null && a.size)) {
2286
- for (const [m, g] of this.mainThreadMap.entries()) {
2287
- const W = a.get(m);
2288
- W && (await g.on(W), h && this.post({ workerTasksqueueCount: h }));
2442
+ if (a === p.GetImageBitMap && y && this.snapshotThread) {
2443
+ this.snapshotThread.on(i);
2444
+ continue;
2445
+ }
2446
+ if (a === p.TasksQueue && (c != null && c.size)) {
2447
+ for (const [v, W] of this.mainThreadMap.entries()) {
2448
+ const g = c.get(v);
2449
+ g && (await W.on(g), h && this.post({ workerTasksqueueCount: h }));
2289
2450
  }
2290
2451
  continue;
2291
2452
  }
2292
- if (c === pe) {
2293
- for (const m of this.mainThreadMap.values())
2294
- m.on(i), n === p.Destroy && this.mainThreadMap.delete(c);
2453
+ if (n === he) {
2454
+ for (const v of this.mainThreadMap.values())
2455
+ v.on(i), a === p.Destroy && this.mainThreadMap.delete(n);
2295
2456
  continue;
2296
2457
  }
2297
- const y = this.mainThreadMap.get(c);
2298
- y && (y.on(i), n === p.Destroy && this.mainThreadMap.delete(c));
2458
+ const m = this.mainThreadMap.get(n);
2459
+ m && (m.on(i), a === p.Destroy && this.mainThreadMap.delete(n));
2299
2460
  }
2300
2461
  }
2301
2462
  }
2302
2463
  export {
2303
- ze as MainThreadManagerImpl
2464
+ Be as MainThreadManagerImpl
2304
2465
  };