@netless/appliance-plugin 1.1.43 → 1.1.44

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 (34) hide show
  1. package/dist/appliance-plugin.js +1 -1
  2. package/dist/appliance-plugin.mjs +3 -3
  3. package/dist/{bridge-GmRa7-tp.js → bridge-B7BW1lpB.js} +1 -1
  4. package/dist/{bridge-D30E9dr6.mjs → bridge-DQud78k4.mjs} +1 -1
  5. package/dist/bridge.js +1 -1
  6. package/dist/bridge.mjs +1 -1
  7. package/dist/core/mainEngine.d.ts +10 -2
  8. package/dist/core/mainThread/base.d.ts +5 -1
  9. package/dist/core/mainThread/subServiceThread.d.ts +2 -0
  10. package/dist/core/tools/image.d.ts +1 -0
  11. package/dist/core/utils/serviceImageRecovery.d.ts +9 -0
  12. package/dist/core/worker/base.d.ts +5 -1
  13. package/dist/core/worker/fullWorkerService.d.ts +3 -0
  14. package/dist/core/worker/simpleWorker.d.ts +2 -2
  15. package/dist/fullWorker.js +98 -98
  16. package/dist/{index-CatWUcZt.mjs → index-4ZI3GxVI.mjs} +1 -1
  17. package/dist/{index-DGdruTPt.js → index-AJCkfnUu.js} +1 -1
  18. package/dist/{index-rDe1jjPM.mjs → index-B8Ls8sf_.mjs} +1 -1
  19. package/dist/{index-CQuJ6lL1.mjs → index-BBtV40zU.mjs} +597 -493
  20. package/dist/{index-Ct5ShjRI.js → index-BOzOWS7h.js} +1 -1
  21. package/dist/index-BQiBrpib.js +1 -0
  22. package/dist/index-BYriQtGa.js +1 -0
  23. package/dist/{index-CrJWLjuD.mjs → index-C2tUvh2a.mjs} +12105 -12033
  24. package/dist/{index-C-pO2InQ.mjs → index-DSFxl2wM.mjs} +8068 -7982
  25. package/dist/index-DnJkIouU.js +570 -0
  26. package/dist/index-DptnZ-h8.js +570 -0
  27. package/dist/{index-DYDy0dd5.mjs → index-ZUpKkvbD.mjs} +597 -493
  28. package/dist/plugin/baseApplianceManager.d.ts +2 -2
  29. package/dist/subWorker.js +74 -74
  30. package/package.json +57 -56
  31. package/dist/index-B44Av4kp.js +0 -1
  32. package/dist/index-CKtpWZ9L.js +0 -1
  33. package/dist/index-DLzvL8jo.js +0 -570
  34. package/dist/index-LmgcnMI8.js +0 -570
@@ -1,15 +1,51 @@
1
- var ye = Object.defineProperty;
2
- var we = (M, e, t) => e in M ? ye(M, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : M[e] = t;
3
- var u = (M, e, t) => we(M, typeof e != "symbol" ? e + "" : e, t);
4
- import { D as K, e as b, c as m, r as $, b as R, f as Z, t as V, a as h, h as de, M as ve, i as D, j, k as ke, C as H, l as z, m as Se, n as te, o as Ie, p as se, q as ge, s as Te, u as re, v as ie, w as Y, x as _, E as N, y as ee, z as Q, A as We, B as Re, F as Ee, G as be, H as Le, I as pe, J as ue, T as oe, K as ae, L as Ce, N as Ne, P as fe, Q as me, R as ne, U as Be, S as ce, W as q, X as Oe, V as he, Y as De } from "./index-CrJWLjuD.mjs";
5
- import { cloneDeep as J, xor as Me, isNumber as G, isEqual as le } from "lodash";
1
+ var ke = Object.defineProperty;
2
+ var Se = (D, e, t) => e in D ? ke(D, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : D[e] = t;
3
+ var u = (D, e, t) => Se(D, typeof e != "symbol" ? e + "" : e, t);
4
+ import { D as Y, e as b, c as m, r as K, b as R, f as J, t as H, a as h, h as fe, M as Ie, i as P, j as ee, k as ge, C as j, l as _, m as Te, n as ie, o as We, p as oe, q as Re, s as Ee, u as ae, v as ne, w as Z, x as Q, E as N, y as se, z as X, A as be, B as me, F as ye, G as Le, H as Ce, I as Ne, J as Be, T as ce, K as he, L as Oe, N as De, P as we, Q as ve, R as le, U as Me, S as de, W as $, X as Pe, V as pe, Y as Ae } from "./index-C2tUvh2a.mjs";
5
+ import { cloneDeep as te, xor as Fe, isNumber as z, isEqual as ue } from "lodash";
6
6
  import "clipper-lib";
7
7
  import "lineclip";
8
8
  import "rbush";
9
9
  import "xss";
10
10
  import "react-dom";
11
11
  import "react";
12
- class Pe {
12
+ class Ue {
13
+ constructor() {
14
+ u(this, "jobs", /* @__PURE__ */ new Map());
15
+ }
16
+ request(e, t, s, r, i) {
17
+ const o = this.jobs.get(e);
18
+ if ((o == null ? void 0 : o.src) === t) return;
19
+ this.cancel(e);
20
+ const a = { src: t };
21
+ this.jobs.set(e, a), (async () => {
22
+ if (this.jobs.get(e) !== a) return;
23
+ if (!r()) {
24
+ this.cancel(e);
25
+ return;
26
+ }
27
+ let c;
28
+ try {
29
+ c = await s();
30
+ } catch {
31
+ }
32
+ if (this.jobs.get(e) === a) {
33
+ if (!r()) {
34
+ this.cancel(e);
35
+ return;
36
+ }
37
+ c && (this.jobs.delete(e), i(c));
38
+ }
39
+ })();
40
+ }
41
+ cancel(e) {
42
+ this.jobs.delete(e);
43
+ }
44
+ clear() {
45
+ for (const e of this.jobs.keys()) this.cancel(e);
46
+ }
47
+ }
48
+ class xe {
13
49
  constructor(e) {
14
50
  u(this, "vNodes");
15
51
  u(this, "thread");
@@ -17,7 +53,7 @@ class Pe {
17
53
  u(this, "localWorkShapes", /* @__PURE__ */ new Map());
18
54
  u(this, "tmpOpt");
19
55
  u(this, "animationId");
20
- u(this, "syncUnitTime", K.syncOpt.interval);
56
+ u(this, "syncUnitTime", Y.syncOpt.interval);
21
57
  this.vNodes = e.vNodes, this.thread = e.thread;
22
58
  }
23
59
  createLocalWork(e) {
@@ -55,7 +91,7 @@ class Pe {
55
91
  clearAll() {
56
92
  this.thread.topLayer.children.length && (this.thread.topLayer.parent.children.forEach((e) => {
57
93
  e.name !== "viewport" && e.remove();
58
- }), $(
94
+ }), K(
59
95
  this.thread.serviceLayer,
60
96
  this.thread.serviceLayer.parent
61
97
  )), this.serviceWorkShapes.clear(), this.localWorkShapes.clear();
@@ -87,7 +123,7 @@ class Pe {
87
123
  createWorkShapeNode(e) {
88
124
  const { toolsType: t } = e;
89
125
  if (t === m.LaserPen)
90
- return Z({
126
+ return J({
91
127
  ...e,
92
128
  vNodes: this.vNodes,
93
129
  fullLayer: this.thread.topLayer,
@@ -120,7 +156,7 @@ class Pe {
120
156
  r && s && (w = this.setNodeKey(c, w, r, s)), this.serviceWorkShapes.set(c, w);
121
157
  }
122
158
  const l = this.serviceWorkShapes.get(c);
123
- i && (l.type = i), a && (l.animationWorkData = V(a), l.ops = a), o && (l.updateNodeOpt = o), n && (l.animationWorkData = n), l.node && l.node.getWorkId() !== c && l.node.setWorkId(c), d && (l.oldRect = d), r && s && (l.toolsType !== r && r && s && this.setNodeKey(c, l, r, s), l.node && l.node.setWorkOptions(s));
159
+ i && (l.type = i), a && (l.animationWorkData = H(a), l.ops = a), o && (l.updateNodeOpt = o), n && (l.animationWorkData = n), l.node && l.node.getWorkId() !== c && l.node.setWorkId(c), d && (l.oldRect = d), r && s && (l.toolsType !== r && r && s && this.setNodeKey(c, l, r, s), l.node && l.node.setWorkOptions(s));
124
160
  }
125
161
  computNextAnimationIndex(e, t) {
126
162
  var i;
@@ -184,7 +220,7 @@ class Pe {
184
220
  e && this.runAnimation(), t.size && t.forEach((n, c) => {
185
221
  s.push({
186
222
  type: h.Cursor,
187
- uid: c.split(de)[0],
223
+ uid: c.split(fe)[0],
188
224
  op: n.op,
189
225
  workState: n.workState,
190
226
  viewId: this.thread.viewId
@@ -223,7 +259,7 @@ class Pe {
223
259
  this.runAnimation();
224
260
  }
225
261
  }
226
- class Ae {
262
+ class Ge {
227
263
  constructor(e) {
228
264
  u(this, "vNodes");
229
265
  u(this, "thread");
@@ -232,12 +268,12 @@ class Ae {
232
268
  u(this, "batchEraserRemoveNodes", /* @__PURE__ */ new Set());
233
269
  u(this, "batchEraserWorks", /* @__PURE__ */ new Set());
234
270
  u(this, "tmpOpt");
235
- u(this, "syncUnitTime", K.syncOpt.interval);
271
+ u(this, "syncUnitTime", Y.syncOpt.interval);
236
272
  u(this, "fullWorkerDrawCount", 0);
237
273
  u(this, "drawWorkActiveId");
238
274
  u(this, "consumeCount", 0);
239
275
  u(this, "combineDrawActiveId");
240
- u(this, "eraserBatchScheduler", new ve());
276
+ u(this, "eraserBatchScheduler", new Ie());
241
277
  u(this, "disposeVNodeRevisionObserver");
242
278
  u(this, "bitmapEraserRenderQueue", Promise.resolve());
243
279
  u(this, "bitmapEraserRevalidationQueued", !1);
@@ -284,25 +320,25 @@ class Ae {
284
320
  async updateSelector(e) {
285
321
  var f;
286
322
  const t = this.workShapes.get(
287
- D
323
+ P
288
324
  );
289
325
  if (!((f = t == null ? void 0 : t.selectIds) != null && f.length)) return;
290
326
  const { callback: s, ...r } = e, { updateSelectorOpt: i, willSerializeData: o, smoothSync: a } = r, n = await (t == null ? void 0 : t.updateSelector({
291
327
  updateSelectorOpt: i,
292
- selectIds: J(t.selectIds),
328
+ selectIds: te(t.selectIds),
293
329
  vNodes: this.vNodes,
294
330
  willSerializeData: o,
295
331
  worker: this
296
332
  })), c = /* @__PURE__ */ new Map();
297
333
  let d;
298
- n != null && n.selectIds && (d = Me(t.selectIds, n.selectIds), n.selectIds.forEach((w) => {
299
- const S = this.vNodes.get(w);
300
- if (S) {
301
- const { toolsType: I, op: W, opt: g } = S;
334
+ n != null && n.selectIds && (d = Fe(t.selectIds, n.selectIds), n.selectIds.forEach((w) => {
335
+ const k = this.vNodes.get(w);
336
+ if (k) {
337
+ const { toolsType: I, op: E, opt: g } = k;
302
338
  c.set(w, {
303
339
  opt: g,
304
340
  toolsType: I,
305
- ops: (W == null ? void 0 : W.length) && j(W) || void 0
341
+ ops: (E == null ? void 0 : E.length) && ee(E) || void 0
306
342
  });
307
343
  }
308
344
  }), t.selectIds = n.selectIds);
@@ -327,11 +363,11 @@ class Ae {
327
363
  clearAll() {
328
364
  if (this.eraserBatchScheduler.cancel(), this.thread.localLayer.children.length && (this.thread.topLayer.parent.children.forEach((t) => {
329
365
  t.name !== "viewport" && t.remove();
330
- }), $(
366
+ }), K(
331
367
  this.thread.localLayer,
332
368
  this.thread.localLayer.parent
333
369
  )), this.workShapes.get(
334
- D
370
+ P
335
371
  )) {
336
372
  const t = [];
337
373
  t.push({
@@ -349,7 +385,7 @@ class Ae {
349
385
  let i;
350
386
  for (const o of this.vNodes.curNodeMap.values()) {
351
387
  const { rect: a, name: n, toolsType: c, opt: d } = o, l = t[0] * this.thread.fullLayer.worldScaling[0] + this.thread.fullLayer.worldPosition[0], p = t[1] * this.thread.fullLayer.worldScaling[1] + this.thread.fullLayer.worldPosition[1];
352
- if (c === m.Text && ke([l, p], a) && d.workState === b.Done) {
388
+ if (c === m.Text && ge([l, p], a) && d.workState === b.Done) {
353
389
  i = n;
354
390
  break;
355
391
  }
@@ -372,7 +408,7 @@ class Ae {
372
408
  }
373
409
  cursorHover(e) {
374
410
  const { opt: t, toolsType: s, point: r } = e, i = this.setFullWork({
375
- workId: H,
411
+ workId: j,
376
412
  toolsType: s,
377
413
  opt: t
378
414
  });
@@ -380,15 +416,15 @@ class Ae {
380
416
  }
381
417
  cursorBlur() {
382
418
  var t;
383
- const e = this.getWorkShape(H);
384
- e && ((t = e.selectIds) != null && t.length) && (e.cursorBlur(), this.clearWorkShapeNodeCache(H)), this.thread.fullLayer.parent.children.forEach((s) => {
419
+ const e = this.getWorkShape(j);
420
+ e && ((t = e.selectIds) != null && t.length) && (e.cursorBlur(), this.clearWorkShapeNodeCache(j)), this.thread.fullLayer.parent.children.forEach((s) => {
385
421
  s.name === "Cursor_Hover_Id" && s.remove();
386
422
  });
387
423
  }
388
424
  async updateFullSelectWork(e) {
389
425
  var r, i, o, a, n;
390
426
  const t = this.workShapes.get(
391
- D
427
+ P
392
428
  ), { selectIds: s } = e;
393
429
  if (!(s != null && s.length)) {
394
430
  await this.blurSelector(e);
@@ -396,7 +432,7 @@ class Ae {
396
432
  }
397
433
  if (!t) {
398
434
  this.setFullWork({
399
- workId: D,
435
+ workId: P,
400
436
  toolsType: m.Selector,
401
437
  opt: e.opt || (((r = this.tmpOpt) == null ? void 0 : r.toolsType) === m.Selector ? this.tmpOpt.toolsOpt : {})
402
438
  }) && await this.updateFullSelectWork(e);
@@ -434,7 +470,7 @@ class Ae {
434
470
  }
435
471
  async removeSelector(e) {
436
472
  const { willSyncService: t, needUndoTicker: s } = e, r = [], i = [], o = this.workShapes.get(
437
- D
473
+ P
438
474
  );
439
475
  if (!o)
440
476
  return;
@@ -497,9 +533,9 @@ class Ae {
497
533
  }
498
534
  ]
499
535
  }), (r = this.thread.fullLayer) == null || r.getElementsByName(e).forEach((i) => {
500
- i.remove(), z(i, this.thread.fullLayer.parent);
536
+ i.remove(), _(i, this.thread.fullLayer.parent);
501
537
  }), this.vNodes.delete(e)), this.workShapes.has(e) && (this.thread.localLayer.getElementsByName(e).forEach((i) => {
502
- i.remove(), z(i, this.thread.localLayer.parent);
538
+ i.remove(), _(i, this.thread.localLayer.parent);
503
539
  }), this.clearWorkShapeNodeCache(e));
504
540
  }
505
541
  setFullWork(e) {
@@ -522,24 +558,24 @@ class Ae {
522
558
  var o, a;
523
559
  const t = (o = e.workId) == null ? void 0 : o.toString(), s = (a = e.updateNodeOpt) == null ? void 0 : a.eraserGeometryDelta;
524
560
  if (t) {
525
- const n = this.vNodes.get(t), c = e.ops && V(e.ops) || e.op || [];
561
+ const n = this.vNodes.get(t), c = e.ops && H(e.ops) || e.op || [];
526
562
  if (s) {
527
- if (!n || !e.centerPos || !Se(
563
+ if (!n || !e.centerPos || !Te(
528
564
  this.vNodes,
529
565
  t,
530
566
  s,
531
567
  n,
532
568
  { op: c, centerPos: e.centerPos }
533
569
  )) {
534
- te(this.vNodes, t);
570
+ ie(this.vNodes, t);
535
571
  return;
536
572
  }
537
- } else n && e.centerPos && Ie(this.vNodes, t) && se(n.op, n.centerPos) !== se(c, e.centerPos) && te(this.vNodes, t);
573
+ } else n && e.centerPos && We(this.vNodes, t) && oe(n.op, n.centerPos) !== oe(c, e.centerPos) && ie(this.vNodes, t);
538
574
  }
539
- const r = this.setFullWork(e), i = e.ops && V(e.ops);
575
+ const r = this.setFullWork(e), i = e.ops && H(e.ops);
540
576
  if (r) {
541
577
  t && e.clearPreviewLocalWork && this.thread.localLayer.getElementsByName(t).forEach((c) => {
542
- c.remove(), z(c, this.thread.localLayer.parent);
578
+ c.remove(), _(c, this.thread.localLayer.parent);
543
579
  }), r.toolsType === m.BackgroundSVG ? r.consumeService({
544
580
  isFullWork: !0,
545
581
  replaceId: t
@@ -584,7 +620,7 @@ class Ae {
584
620
  }
585
621
  async colloctEffectSelectWork(e) {
586
622
  const t = this.workShapes.get(
587
- D
623
+ P
588
624
  ), { workId: s, msgType: r } = e;
589
625
  if (t && s && t.selectIds && t.selectIds.includes(s.toString())) {
590
626
  r === h.RemoveNode ? t.selectIds = t.selectIds.filter(
@@ -618,7 +654,7 @@ class Ae {
618
654
  boxRect: this.thread.getSceneRect()
619
655
  });
620
656
  else {
621
- const o = s.ops && V(s.ops);
657
+ const o = s.ops && H(s.ops);
622
658
  r.consumeService({
623
659
  op: o,
624
660
  isFullWork: !0,
@@ -632,15 +668,15 @@ class Ae {
632
668
  this.reRenderSelector(e);
633
669
  }
634
670
  hasSelector() {
635
- return this.workShapes.has(D);
671
+ return this.workShapes.has(P);
636
672
  }
637
673
  getSelector() {
638
- return this.workShapes.get(D);
674
+ return this.workShapes.get(P);
639
675
  }
640
676
  reRenderSelector(e = !1) {
641
677
  var r;
642
678
  const t = this.workShapes.get(
643
- D
679
+ P
644
680
  );
645
681
  if (!t) return;
646
682
  if (t && !((r = t.selectIds) != null && r.length))
@@ -677,10 +713,10 @@ class Ae {
677
713
  async blurSelector(e) {
678
714
  var r;
679
715
  const t = this.workShapes.get(
680
- D
716
+ P
681
717
  ), s = t == null ? void 0 : t.blurSelector();
682
- if (this.clearWorkShapeNodeCache(D), ((r = this.thread.fullLayer) == null ? void 0 : r.parent).children.forEach((i) => {
683
- i.name === D && i.remove();
718
+ if (this.clearWorkShapeNodeCache(P), ((r = this.thread.fullLayer) == null ? void 0 : r.parent).children.forEach((i) => {
719
+ i.name === P && i.remove();
684
720
  }), s) {
685
721
  const i = [];
686
722
  i.push({
@@ -795,7 +831,7 @@ class Ae {
795
831
  type: h.FullWork,
796
832
  dataType: R.Local,
797
833
  toolsType: l.toolsType,
798
- ops: j(l.op),
834
+ ops: ee(l.op),
799
835
  opt: l.opt,
800
836
  workId: d,
801
837
  updateNodeOpt: {
@@ -865,7 +901,7 @@ class Ae {
865
901
  dataType: R.Local
866
902
  },
867
903
  t
868
- ), this.drawWorkActiveId = void 0), !this.drawWorkActiveId && n !== D && (this.drawWorkActiveId = n), G(o) && (this.consumeCount = o), d) {
904
+ ), this.drawWorkActiveId = void 0), !this.drawWorkActiveId && n !== P && (this.drawWorkActiveId = n), z(o) && (this.consumeCount = o), d) {
869
905
  case m.Selector: {
870
906
  const l = c.consume({
871
907
  data: e,
@@ -896,7 +932,7 @@ class Ae {
896
932
  e.needUndoTicker,
897
933
  e.collectUndoTicker
898
934
  );
899
- }, ge(this.thread.master.maxCombineEraserTime));
935
+ }, Re(this.thread.master.maxCombineEraserTime));
900
936
  break;
901
937
  }
902
938
  case m.BitMapEraser: {
@@ -975,48 +1011,48 @@ class Ae {
975
1011
  if (i || r) {
976
1012
  const p = i == null ? void 0 : i.willDeleteNodes, f = i == null ? void 0 : i.willNewNodes, w = [
977
1013
  ...p ? Array.from(p) : []
978
- ], S = {
1014
+ ], k = {
979
1015
  render: [],
980
1016
  sp: [],
981
1017
  ...r
982
1018
  };
983
1019
  if (i != null && i.rect) {
984
- const I = Te(i.rect);
985
- (a = S.render) == null || a.push(
1020
+ const I = Ee(i.rect);
1021
+ (a = k.render) == null || a.push(
986
1022
  {
987
1023
  rect: I,
988
1024
  isClear: !0,
989
- clearCanvas: re.Bg,
1025
+ clearCanvas: ae.Bg,
990
1026
  viewId: this.thread.viewId,
991
1027
  eraseTxnId: e
992
1028
  },
993
1029
  {
994
1030
  rect: I,
995
- drawCanvas: re.Bg,
1031
+ drawCanvas: ae.Bg,
996
1032
  viewId: this.thread.viewId,
997
1033
  eraseTxnId: e
998
1034
  }
999
1035
  );
1000
1036
  }
1001
- if (s && w.length && ((n = this.getWorkShape(e)) == null ? void 0 : n.toolsType) === m.BitMapEraser && ((c = S.sp) == null || c.push({
1037
+ if (s && w.length && ((n = this.getWorkShape(e)) == null ? void 0 : n.toolsType) === m.BitMapEraser && ((c = k.sp) == null || c.push({
1002
1038
  type: h.None,
1003
1039
  collectUndoTicker: s,
1004
1040
  undoScopeIds: w,
1005
1041
  undoScopePhase: "collect"
1006
- })), p != null && p.size && ((d = S.sp) == null || d.push({
1042
+ })), p != null && p.size && ((d = k.sp) == null || d.push({
1007
1043
  type: h.RemoveNode,
1008
1044
  removeIds: [...p],
1009
1045
  viewId: this.thread.viewId,
1010
1046
  needUndoTicker: t,
1011
1047
  collectUndoTicker: s
1012
1048
  })), f != null && f.size)
1013
- for (const [I, W] of f)
1014
- (l = S.sp) == null || l.push({
1049
+ for (const [I, E] of f)
1050
+ (l = k.sp) == null || l.push({
1015
1051
  type: h.FullWork,
1016
1052
  dataType: R.Local,
1017
- toolsType: W.toolsType,
1018
- ops: j(W.op),
1019
- opt: W.opt,
1053
+ toolsType: E.toolsType,
1054
+ ops: ee(E.op),
1055
+ opt: E.opt,
1020
1056
  workId: I,
1021
1057
  updateNodeOpt: {
1022
1058
  useAnimation: !1
@@ -1024,7 +1060,7 @@ class Ae {
1024
1060
  needUndoTicker: t,
1025
1061
  collectUndoTicker: s
1026
1062
  });
1027
- i != null && i.rect && await this.thread.fullLayer.parent.prepareRender, this.thread.post(S);
1063
+ i != null && i.rect && await this.thread.fullLayer.parent.prepareRender, this.thread.post(k);
1028
1064
  }
1029
1065
  }
1030
1066
  async consumeDrawAll(e, t) {
@@ -1042,23 +1078,23 @@ class Ae {
1042
1078
  if (p === m.LaserPen)
1043
1079
  return;
1044
1080
  p === m.BitMapEraser && await this.bitmapEraserRenderQueue;
1045
- const f = this.workShapes.get(H), w = (a = f == null ? void 0 : f.selectIds) == null ? void 0 : a[0], S = await l.consumeAll({ data: e, workerEngine: this });
1081
+ const f = this.workShapes.get(j), w = (a = f == null ? void 0 : f.selectIds) == null ? void 0 : a[0], k = await l.consumeAll({ data: e, workerEngine: this });
1046
1082
  switch (p) {
1047
1083
  case m.Selector:
1048
1084
  {
1049
- S.selectIds && w && ((n = S.selectIds) != null && n.includes(w)) && f.cursorBlur();
1085
+ k.selectIds && w && ((n = k.selectIds) != null && n.includes(w)) && f.cursorBlur();
1050
1086
  const I = [];
1051
1087
  i && I.push({
1052
1088
  type: h.None,
1053
1089
  isLockSentEventCursor: i,
1054
1090
  scenePath: r
1055
- }), S.type === h.Select && (S.selectIds && t.runReverseSelectWork(S.selectIds), I.push({ ...S, scenePath: r })), I.length && this.thread.post({ sp: I }), (c = l.selectIds) != null && c.length ? l.clearTmpPoints() : this.clearWorkShapeNodeCache(d);
1091
+ }), k.type === h.Select && (k.selectIds && t.runReverseSelectWork(k.selectIds), I.push({ ...k, scenePath: r })), I.length && this.thread.post({ sp: I }), (c = l.selectIds) != null && c.length ? l.clearTmpPoints() : this.clearWorkShapeNodeCache(d);
1056
1092
  }
1057
1093
  break;
1058
1094
  case m.PencilEraser:
1059
1095
  await this.drawPencilEraserFull(
1060
1096
  l,
1061
- S,
1097
+ k,
1062
1098
  i,
1063
1099
  o
1064
1100
  ), this.fullWorkerDrawCount = 0, this.clearWorkShapeNodeCache(d);
@@ -1066,14 +1102,14 @@ class Ae {
1066
1102
  case m.BitMapEraser:
1067
1103
  await this.drawBitMapEraserFull(
1068
1104
  l,
1069
- S,
1105
+ k,
1070
1106
  i,
1071
1107
  o
1072
1108
  ), this.fullWorkerDrawCount = 0, this.clearWorkShapeNodeCache(d);
1073
1109
  break;
1074
1110
  case m.Eraser:
1075
1111
  await this.drawEraser(
1076
- { ...S, scenePath: r },
1112
+ { ...k, scenePath: r },
1077
1113
  i,
1078
1114
  o,
1079
1115
  e.collectUndoTicker
@@ -1092,17 +1128,17 @@ class Ae {
1092
1128
  type: h.None,
1093
1129
  isLockSentEventCursor: i,
1094
1130
  scenePath: r
1095
- }), S) {
1096
- const g = p === m.Pencil && S.type === h.RemoveNode;
1097
- g ? $(
1131
+ }), k) {
1132
+ const g = p === m.Pencil && k.type === h.RemoveNode;
1133
+ g ? K(
1098
1134
  this.thread.localLayer,
1099
1135
  this.thread.localLayer.parent
1100
1136
  ) : I.push({
1101
- ...S,
1137
+ ...k,
1102
1138
  scenePath: r,
1103
1139
  needUndoTicker: e.needUndoTicker,
1104
- undoScopeIds: S.undoScopeIds || (S.workId !== void 0 ? [S.workId.toString()] : void 0),
1105
- undoScopePhase: S.undoScopePhase || "finalize"
1140
+ undoScopeIds: k.undoScopeIds || (k.workId !== void 0 ? [k.workId.toString()] : void 0),
1141
+ undoScopePhase: k.undoScopePhase || "finalize"
1106
1142
  }), this.fullWorkerDrawCount = 0, e.needUndoTicker && I.push({
1107
1143
  type: h.None,
1108
1144
  needUndoTicker: e.needUndoTicker,
@@ -1130,7 +1166,7 @@ class Ae {
1130
1166
  if ((t = this.tmpOpt) != null && t.toolsType && this.tmpOpt.toolsType !== e.toolsType) {
1131
1167
  this.eraserBatchScheduler.cancel();
1132
1168
  for (const [r, i] of this.workShapes)
1133
- r !== D && (i.clearTmpPoints(), this.workShapes.delete(r));
1169
+ r !== P && (i.clearTmpPoints(), this.workShapes.delete(r));
1134
1170
  }
1135
1171
  this.tmpOpt = e, (s = e.toolsOpt) != null && s.syncUnitTime && (this.syncUnitTime = e.toolsOpt.syncUnitTime);
1136
1172
  }
@@ -1143,7 +1179,7 @@ class Ae {
1143
1179
  t.syncUnitTime || (t.syncUnitTime = this.syncUnitTime), s == null || s.setWorkOptions(t);
1144
1180
  }
1145
1181
  createWorkShapeNode(e) {
1146
- return Z(
1182
+ return J(
1147
1183
  {
1148
1184
  ...e,
1149
1185
  vNodes: this.vNodes,
@@ -1154,22 +1190,24 @@ class Ae {
1154
1190
  );
1155
1191
  }
1156
1192
  }
1157
- class Fe {
1193
+ class qe {
1158
1194
  constructor(e) {
1159
1195
  u(this, "vNodes");
1160
1196
  u(this, "thread");
1161
1197
  u(this, "workShapes", /* @__PURE__ */ new Map());
1162
1198
  u(this, "selectorWorkShapes", /* @__PURE__ */ new Map());
1163
1199
  u(this, "willRunEffectSelectorIds", /* @__PURE__ */ new Set());
1164
- u(this, "syncUnitTime", K.syncOpt.interval);
1200
+ u(this, "syncUnitTime", Y.syncOpt.interval);
1165
1201
  u(this, "animationScheduler");
1166
1202
  u(this, "effectScheduler");
1167
- this.vNodes = e.vNodes, this.thread = e.thread, this.animationScheduler = new ie({
1203
+ u(this, "imageRecovery", new Ue());
1204
+ u(this, "readyImages", /* @__PURE__ */ new Map());
1205
+ this.vNodes = e.vNodes, this.thread = e.thread, this.animationScheduler = new ne({
1168
1206
  run: async () => {
1169
1207
  try {
1170
1208
  await this.animationDraw();
1171
1209
  } catch (t) {
1172
- throw Y(t, {
1210
+ throw Z(t, {
1173
1211
  business: "service-render",
1174
1212
  stage: "animation-draw"
1175
1213
  });
@@ -1181,12 +1219,12 @@ class Fe {
1181
1219
  business: "service-render",
1182
1220
  stage: "animation-draw"
1183
1221
  })
1184
- }), this.effectScheduler = new ie({
1222
+ }), this.effectScheduler = new ne({
1185
1223
  run: async () => {
1186
1224
  try {
1187
1225
  await this.effectRunSelector();
1188
1226
  } catch (t) {
1189
- throw Y(t, {
1227
+ throw Z(t, {
1190
1228
  business: "service-render",
1191
1229
  stage: "selector-effect"
1192
1230
  });
@@ -1207,9 +1245,9 @@ class Fe {
1207
1245
  this.animationScheduler.destroy(), this.effectScheduler.destroy(), this.clearAll();
1208
1246
  }
1209
1247
  clearAll() {
1210
- this.thread.serviceLayer.children.length && (this.thread.serviceLayer.parent.children.forEach((e) => {
1248
+ this.imageRecovery.clear(), this.readyImages.clear(), this.thread.serviceLayer.children.length && (this.thread.serviceLayer.parent.children.forEach((e) => {
1211
1249
  e.name !== "viewport" && e.remove();
1212
- }), $(
1250
+ }), K(
1213
1251
  this.thread.serviceLayer,
1214
1252
  this.thread.serviceLayer.parent
1215
1253
  )), this.workShapes.clear(), this.selectorWorkShapes.clear(), this.willRunEffectSelectorIds.clear();
@@ -1236,7 +1274,7 @@ class Fe {
1236
1274
  removeWork(e) {
1237
1275
  const { workId: t } = e, s = t == null ? void 0 : t.toString();
1238
1276
  if (s) {
1239
- if (this.workShapes.get(s)) {
1277
+ if (this.imageRecovery.cancel(s), this.readyImages.delete(s), this.workShapes.get(s)) {
1240
1278
  this.workShapes.delete(s), this.removeNode(s, e);
1241
1279
  return;
1242
1280
  }
@@ -1274,45 +1312,75 @@ class Fe {
1274
1312
  );
1275
1313
  }
1276
1314
  async animationDraw() {
1277
- var r, i, o, a, n, c, d, l, p, f, w, S, I, W, g, y, v, T, C, L, A;
1315
+ var r, i, o, a, n, c, d, l, p, f, w, k, I, E, g, y, S, T, C, L, O, A;
1278
1316
  let e = !1;
1279
1317
  const t = /* @__PURE__ */ new Map(), s = [];
1280
- for (const [E, k] of this.workShapes.entries())
1281
- switch (k.toolsType) {
1318
+ for (const [W, v] of this.workShapes.entries())
1319
+ switch (v.toolsType) {
1282
1320
  case m.BackgroundSVG: {
1283
- (r = k.node) == null || r.consumeService({
1321
+ (r = v.node) == null || r.consumeService({
1284
1322
  isFullWork: !0,
1285
- replaceId: E
1286
- }), this.selectorWorkShapes.forEach((B, O) => {
1287
- var P;
1288
- (P = B.selectIds) != null && P.includes(E) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
1289
- }), this.workShapes.delete(E);
1323
+ replaceId: W
1324
+ }), this.selectorWorkShapes.forEach((B, F) => {
1325
+ var M;
1326
+ (M = B.selectIds) != null && M.includes(W) && (this.willRunEffectSelectorIds.add(F), this.runEffect());
1327
+ }), this.workShapes.delete(W);
1290
1328
  break;
1291
1329
  }
1292
1330
  case m.Image: {
1293
- await ((i = k.node) == null ? void 0 : i.consumeServiceAsync({
1331
+ const B = (i = v.node) == null ? void 0 : i.getWorkOptions(), M = (B == null ? void 0 : B.src) && this.thread.getImageSourceKey(B), U = this.readyImages.get(W);
1332
+ this.readyImages.delete(W);
1333
+ const x = U && U.src === M && U.image || M && this.thread.getCachedImages(M) || null;
1334
+ await ((o = v.node) == null ? void 0 : o.consumeServiceAsync({
1294
1335
  isFullWork: !0,
1295
- worker: this
1296
- })), this.selectorWorkShapes.forEach((B, O) => {
1297
- var P;
1298
- (P = B.selectIds) != null && P.includes(E) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
1299
- }), this.workShapes.delete(E);
1336
+ worker: this,
1337
+ imageSourceOverride: x
1338
+ })), M && !x ? this.imageRecovery.request(
1339
+ W,
1340
+ M,
1341
+ () => this.thread.loadImageBitMap({
1342
+ toolsType: m.Image,
1343
+ opt: B,
1344
+ workId: W,
1345
+ timeoutMs: 15e3
1346
+ }),
1347
+ () => {
1348
+ const G = this.vNodes.get(W), V = this.workShapes.get(W);
1349
+ return (G == null ? void 0 : G.toolsType) === m.Image && this.thread.getImageSourceKey(G.opt) === M && (!V || !!V.node && this.thread.getImageSourceKey(
1350
+ V.node.getWorkOptions()
1351
+ ) === M);
1352
+ },
1353
+ (G) => {
1354
+ const V = this.vNodes.get(W);
1355
+ V && (this.readyImages.set(W, { src: M, image: G }), this.consumeFull({
1356
+ msgType: h.FullWork,
1357
+ dataType: R.Service,
1358
+ viewId: this.thread.viewId,
1359
+ workId: W,
1360
+ toolsType: m.Image,
1361
+ opt: V.opt
1362
+ }));
1363
+ }
1364
+ ) : this.imageRecovery.cancel(W), this.selectorWorkShapes.forEach((G, V) => {
1365
+ var re;
1366
+ (re = G.selectIds) != null && re.includes(W) && (this.willRunEffectSelectorIds.add(V), this.runEffect());
1367
+ }), this.workShapes.delete(W);
1300
1368
  break;
1301
1369
  }
1302
1370
  case m.Text: {
1303
- k.node && (await ((o = k.node) == null ? void 0 : o.consumeServiceAsync({
1371
+ v.node && (await ((a = v.node) == null ? void 0 : a.consumeServiceAsync({
1304
1372
  isFullWork: !0,
1305
- replaceId: E,
1373
+ replaceId: W,
1306
1374
  boxRect: this.thread.getSceneRect()
1307
- })), this.selectorWorkShapes.forEach((B, O) => {
1308
- var P;
1309
- (P = B.selectIds) != null && P.includes(E) && (this.willRunEffectSelectorIds.add(O), this.runEffect());
1310
- }), k.refreshTextRender && k.requestId && s.push({
1375
+ })), this.selectorWorkShapes.forEach((B, F) => {
1376
+ var M;
1377
+ (M = B.selectIds) != null && M.includes(W) && (this.willRunEffectSelectorIds.add(F), this.runEffect());
1378
+ }), v.refreshTextRender && v.requestId && s.push({
1311
1379
  type: h.RefreshTextRender,
1312
- requestId: k.requestId,
1313
- workId: E,
1380
+ requestId: v.requestId,
1381
+ workId: W,
1314
1382
  viewId: this.thread.viewId
1315
- }), (a = k.node) == null || a.clearTmpPoints(), this.workShapes.delete(E));
1383
+ }), (n = v.node) == null || n.clearTmpPoints(), this.workShapes.delete(W));
1316
1384
  break;
1317
1385
  }
1318
1386
  case m.Arrow:
@@ -1322,98 +1390,98 @@ class Fe {
1322
1390
  case m.Star:
1323
1391
  case m.Polygon:
1324
1392
  case m.SpeechBalloon: {
1325
- const B = !!k.ops;
1326
- if ((n = k.animationWorkData) != null && n.length) {
1327
- const O = k.oldRect;
1328
- (c = k.node) == null || c.consumeService({
1329
- op: k.animationWorkData,
1393
+ const B = !!v.ops;
1394
+ if ((c = v.animationWorkData) != null && c.length) {
1395
+ const F = v.oldRect;
1396
+ (d = v.node) == null || d.consumeService({
1397
+ op: v.animationWorkData,
1330
1398
  isFullWork: B
1331
- }), B && (this.selectorWorkShapes.forEach((P, F) => {
1332
- var U;
1333
- (U = P.selectIds) != null && U.includes(E) && (this.willRunEffectSelectorIds.add(F), this.runEffect());
1334
- }), (d = k.node) == null || d.clearTmpPoints(), this.workShapes.delete(E)), k.isEnableCursor ? t.set(E, {
1335
- cursorTool: _(k.toolsType),
1336
- workState: O ? k.ops ? b.Done : b.Doing : b.Start,
1337
- op: k.animationWorkData.slice(-3, -1)
1338
- }) : B && !k.useAnimation && ((l = k.updateNodeOpt) != null && l.useAnimation) && t.set(E, {
1339
- cursorTool: _(k.toolsType),
1399
+ }), B && (this.selectorWorkShapes.forEach((M, U) => {
1400
+ var x;
1401
+ (x = M.selectIds) != null && x.includes(W) && (this.willRunEffectSelectorIds.add(U), this.runEffect());
1402
+ }), (l = v.node) == null || l.clearTmpPoints(), this.workShapes.delete(W)), v.isEnableCursor ? t.set(W, {
1403
+ cursorTool: Q(v.toolsType),
1404
+ workState: F ? v.ops ? b.Done : b.Doing : b.Start,
1405
+ op: v.animationWorkData.slice(-3, -1)
1406
+ }) : B && !v.useAnimation && ((p = v.updateNodeOpt) != null && p.useAnimation) && t.set(W, {
1407
+ cursorTool: Q(v.toolsType),
1340
1408
  workState: b.Done,
1341
- op: k.animationWorkData.slice(-3, -1),
1342
- uid: (p = k.updateNodeOpt) == null ? void 0 : p.uid
1343
- }), k.animationWorkData.length = 0;
1409
+ op: v.animationWorkData.slice(-3, -1),
1410
+ uid: (f = v.updateNodeOpt) == null ? void 0 : f.uid
1411
+ }), v.animationWorkData.length = 0;
1344
1412
  }
1345
1413
  break;
1346
1414
  }
1347
1415
  case m.Pencil: {
1348
- if (k.useAnimation) {
1349
- if (k.useAnimation) {
1350
- if (k.isDel) {
1351
- (y = k.node) == null || y.clearTmpPoints(), this.workShapes.delete(E);
1416
+ if (v.useAnimation) {
1417
+ if (v.useAnimation) {
1418
+ if (v.isDel) {
1419
+ (S = v.node) == null || S.clearTmpPoints(), this.workShapes.delete(W);
1352
1420
  break;
1353
1421
  }
1354
- const B = 3, O = this.computNextAnimationIndex(
1355
- k,
1422
+ const B = 3, F = this.computNextAnimationIndex(
1423
+ v,
1356
1424
  B
1357
- ), P = k.isDiff ? 0 : Math.max(0, (k.animationIndex || 0) - B), F = (k.animationWorkData || []).slice(
1358
- P,
1359
- O
1360
- ), U = (T = (v = k.node) == null ? void 0 : v.getWorkId()) == null ? void 0 : T.toString();
1361
- if ((k.animationIndex || 0) < O || k.isDiff) {
1362
- if ((C = k.node) == null || C.consumeService({
1363
- op: F,
1425
+ ), M = v.isDiff ? 0 : Math.max(0, (v.animationIndex || 0) - B), U = (v.animationWorkData || []).slice(
1426
+ M,
1427
+ F
1428
+ ), x = (C = (T = v.node) == null ? void 0 : T.getWorkId()) == null ? void 0 : C.toString();
1429
+ if ((v.animationIndex || 0) < F || v.isDiff) {
1430
+ if ((L = v.node) == null || L.consumeService({
1431
+ op: U,
1364
1432
  isFullWork: !1
1365
- }), k.animationIndex = O, k.isDiff && (k.isDiff = !1), F.length && k.isEnableCursor) {
1366
- const X = F.slice(-3, -1);
1367
- t.set(E, {
1368
- cursorTool: _(k.toolsType),
1369
- workState: P === 0 ? b.Start : O === ((L = k.animationWorkData) == null ? void 0 : L.length) ? b.Done : b.Doing,
1370
- op: X
1433
+ }), v.animationIndex = F, v.isDiff && (v.isDiff = !1), U.length && v.isEnableCursor) {
1434
+ const G = U.slice(-3, -1);
1435
+ t.set(W, {
1436
+ cursorTool: Q(v.toolsType),
1437
+ workState: M === 0 ? b.Start : F === ((O = v.animationWorkData) == null ? void 0 : O.length) ? b.Done : b.Doing,
1438
+ op: G
1371
1439
  });
1372
1440
  }
1373
- } else k.ops && ((A = k.node) == null || A.consumeService({
1374
- op: k.animationWorkData || [],
1441
+ } else v.ops && ((A = v.node) == null || A.consumeService({
1442
+ op: v.animationWorkData || [],
1375
1443
  isFullWork: !0,
1376
- replaceId: U
1377
- }), k.isDel = !0, k.isEnableCursor && t.set(E, {
1378
- cursorTool: _(k.toolsType),
1444
+ replaceId: x
1445
+ }), v.isDel = !0, v.isEnableCursor && t.set(W, {
1446
+ cursorTool: Q(v.toolsType),
1379
1447
  workState: b.Done,
1380
- op: F.slice(-3, -1)
1448
+ op: U.slice(-3, -1)
1381
1449
  }));
1382
1450
  e = !0;
1383
1451
  break;
1384
1452
  }
1385
1453
  } else {
1386
- const B = !!k.ops;
1387
- if ((f = k.node) == null || f.consumeService({
1388
- op: k.animationWorkData || [],
1454
+ const B = !!v.ops;
1455
+ if ((w = v.node) == null || w.consumeService({
1456
+ op: v.animationWorkData || [],
1389
1457
  isFullWork: B,
1390
- replaceId: E
1391
- }), (w = k.node) == null || w.updataOptService(k.updateNodeOpt), B) {
1392
- if (!k.isEnableCursor && ((S = k.updateNodeOpt) != null && S.useAnimation) && ((I = k.animationWorkData) != null && I.length)) {
1393
- const O = k.animationWorkData.slice(-3, -1);
1394
- t.set(E, {
1395
- cursorTool: _(k.toolsType),
1458
+ replaceId: W
1459
+ }), (k = v.node) == null || k.updataOptService(v.updateNodeOpt), B) {
1460
+ if (!v.isEnableCursor && ((I = v.updateNodeOpt) != null && I.useAnimation) && ((E = v.animationWorkData) != null && E.length)) {
1461
+ const F = v.animationWorkData.slice(-3, -1);
1462
+ t.set(W, {
1463
+ cursorTool: Q(v.toolsType),
1396
1464
  workState: b.Done,
1397
- op: O,
1398
- uid: (W = k.updateNodeOpt) == null ? void 0 : W.uid
1465
+ op: F,
1466
+ uid: (g = v.updateNodeOpt) == null ? void 0 : g.uid
1399
1467
  });
1400
1468
  }
1401
- this.selectorWorkShapes.forEach((O, P) => {
1402
- var F;
1403
- (F = O.selectIds) != null && F.includes(E) && (this.willRunEffectSelectorIds.add(P), this.runEffect());
1404
- }), (g = k.node) == null || g.clearTmpPoints(), this.workShapes.delete(E);
1469
+ this.selectorWorkShapes.forEach((F, M) => {
1470
+ var U;
1471
+ (U = F.selectIds) != null && U.includes(W) && (this.willRunEffectSelectorIds.add(M), this.runEffect());
1472
+ }), (y = v.node) == null || y.clearTmpPoints(), this.workShapes.delete(W);
1405
1473
  }
1406
1474
  }
1407
1475
  break;
1408
1476
  }
1409
1477
  }
1410
- e && this.runAnimation(), t.size && t.forEach((E, k) => {
1478
+ e && this.runAnimation(), t.size && t.forEach((W, v) => {
1411
1479
  s.push({
1412
1480
  type: h.Cursor,
1413
- uid: E.uid || k.split(de)[0],
1414
- op: E.op,
1415
- workState: E.workState,
1416
- cursorTool: E.cursorTool,
1481
+ uid: W.uid || v.split(fe)[0],
1482
+ op: W.op,
1483
+ workState: W.workState,
1484
+ cursorTool: W.cursorTool,
1417
1485
  viewId: this.thread.viewId
1418
1486
  });
1419
1487
  }), s.length && this.thread.post({ sp: s });
@@ -1445,7 +1513,7 @@ class Fe {
1445
1513
  return !1;
1446
1514
  }
1447
1515
  activeWorkShape(e) {
1448
- var W, g, y, v;
1516
+ var E, g, y, S;
1449
1517
  const {
1450
1518
  workId: t,
1451
1519
  opt: s,
@@ -1462,7 +1530,7 @@ class Fe {
1462
1530
  } = e;
1463
1531
  if (!t)
1464
1532
  return;
1465
- const w = t.toString(), S = (W = this.vNodes.get(w)) == null ? void 0 : W.rect;
1533
+ const w = t.toString(), k = (E = this.vNodes.get(w)) == null ? void 0 : E.rect;
1466
1534
  if (!((g = this.workShapes) != null && g.has(w))) {
1467
1535
  let T = {
1468
1536
  toolsType: r,
@@ -1472,25 +1540,25 @@ class Fe {
1472
1540
  updateNodeOpt: o,
1473
1541
  ops: a,
1474
1542
  useAnimation: typeof c < "u" ? c : typeof (o == null ? void 0 : o.useAnimation) < "u" ? o == null ? void 0 : o.useAnimation : !0,
1475
- oldRect: S,
1543
+ oldRect: k,
1476
1544
  isDiff: !1,
1477
1545
  imageBitmap: d,
1478
1546
  isEnableCursor: l
1479
1547
  };
1480
1548
  r && s && (T = this.setNodeKey(w, T, r, s)), (y = this.workShapes) == null || y.set(w, T);
1481
1549
  }
1482
- const I = (v = this.workShapes) == null ? void 0 : v.get(w);
1483
- I.isEnableCursor = l, I.requestId = p, I.refreshTextRender = !!f, i && (I.type = i), a && (I.animationWorkData = V(a), I.ops = a), o && (I.updateNodeOpt = o), n && (I.isDiff = this.hasDiffData(
1550
+ const I = (S = this.workShapes) == null ? void 0 : S.get(w);
1551
+ I.isEnableCursor = l, I.requestId = p, I.refreshTextRender = !!f, i && (I.type = i), a && (I.animationWorkData = H(a), I.ops = a), o && (I.updateNodeOpt = o), n && (I.isDiff = this.hasDiffData(
1484
1552
  I.animationWorkData || [],
1485
1553
  n,
1486
1554
  I.toolsType
1487
- ), I.toolsType, m.Pencil, I.animationWorkData = n), I.node && I.node.getWorkId() !== w && I.node.setWorkId(w), S && (I.oldRect = S), r && s && (s.syncUnitTime && (this.syncUnitTime = s.syncUnitTime), I.toolsType !== r && r && s && this.setNodeKey(w, I, r, s), I.node && I.node.setWorkOptions(s)), d && (I.imageBitmap = d);
1555
+ ), I.toolsType, m.Pencil, I.animationWorkData = n), I.node && I.node.getWorkId() !== w && I.node.setWorkId(w), k && (I.oldRect = k), r && s && (s.syncUnitTime && (this.syncUnitTime = s.syncUnitTime), I.toolsType !== r && r && s && this.setNodeKey(w, I, r, s), I.node && I.node.setWorkOptions(s)), d && (I.imageBitmap = d);
1488
1556
  }
1489
1557
  removeNode(e, t) {
1490
- e.indexOf(D) > -1 && this.removeSelectWork(t), this.thread.fullLayer.getElementsByName(e).forEach((r) => {
1491
- r.remove(), z(r, this.thread.fullLayer.parent);
1558
+ e.indexOf(P) > -1 && this.removeSelectWork(t), this.thread.fullLayer.getElementsByName(e).forEach((r) => {
1559
+ r.remove(), _(r, this.thread.fullLayer.parent);
1492
1560
  }), this.thread.serviceLayer.getElementsByName(e).forEach((r) => {
1493
- r.remove(), z(r, this.thread.serviceLayer.parent);
1561
+ r.remove(), _(r, this.thread.serviceLayer.parent);
1494
1562
  });
1495
1563
  const s = this.vNodes.get(e);
1496
1564
  s && s.toolsType === m.BackgroundSVG && this.thread.post({
@@ -1528,7 +1596,7 @@ class Fe {
1528
1596
  i && (n.type = i), n.node && n.node.getWorkId() !== a && n.node.setWorkId(a), n.selectIds = o || [];
1529
1597
  }
1530
1598
  setNodeKey(e, t, s, r) {
1531
- return t.toolsType = s, t.node = Z(
1599
+ return t.toolsType = s, t.node = J(
1532
1600
  {
1533
1601
  toolsType: s,
1534
1602
  toolsOpt: r,
@@ -1541,7 +1609,7 @@ class Fe {
1541
1609
  ), t;
1542
1610
  }
1543
1611
  }
1544
- class x {
1612
+ class q {
1545
1613
  constructor() {
1546
1614
  u(this, "localWork");
1547
1615
  u(this, "serviceWork");
@@ -1551,7 +1619,7 @@ class x {
1551
1619
  return this.threadEngine = e, this.localWork = e.localWork, this.serviceWork = e.serviceWork, this;
1552
1620
  }
1553
1621
  }
1554
- class Ue extends x {
1622
+ class ze extends q {
1555
1623
  constructor() {
1556
1624
  super(...arguments);
1557
1625
  u(this, "emitEventType", N.CopyNode);
@@ -1567,7 +1635,7 @@ class Ue extends x {
1567
1635
  s && await ((r = this.localWork) == null ? void 0 : r.consumeFull(t));
1568
1636
  }
1569
1637
  }
1570
- class xe extends x {
1638
+ class Ve extends q {
1571
1639
  constructor() {
1572
1640
  super(...arguments);
1573
1641
  u(this, "emitEventType", N.SetColorNode);
@@ -1589,7 +1657,7 @@ class xe extends x {
1589
1657
  needUndoTicker: c,
1590
1658
  requestId: d
1591
1659
  } = t;
1592
- s === D && r && await ((l = this.localWork) == null ? void 0 : l.updateSelector({
1660
+ s === P && r && await ((l = this.localWork) == null ? void 0 : l.updateSelector({
1593
1661
  updateSelectorOpt: r,
1594
1662
  willRefreshSelector: i,
1595
1663
  willSyncService: o,
@@ -1641,7 +1709,7 @@ class xe extends x {
1641
1709
  };
1642
1710
  }
1643
1711
  }
1644
- class Ge extends x {
1712
+ class $e extends q {
1645
1713
  constructor() {
1646
1714
  super(...arguments);
1647
1715
  u(this, "emitEventType", N.ZIndexNode);
@@ -1662,7 +1730,7 @@ class Ge extends x {
1662
1730
  needUndoTicker: n,
1663
1731
  requestId: c
1664
1732
  } = t;
1665
- s === D && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
1733
+ s === P && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
1666
1734
  updateSelectorOpt: r,
1667
1735
  willRefreshSelector: i,
1668
1736
  willSyncService: o,
@@ -1714,19 +1782,19 @@ class Ge extends x {
1714
1782
  };
1715
1783
  }
1716
1784
  }
1717
- class qe extends x {
1785
+ class _e extends q {
1718
1786
  constructor() {
1719
1787
  super(...arguments);
1720
1788
  u(this, "emitEventType", N.TranslateNode);
1721
1789
  u(this, "updateSelectorCallback", (t) => {
1722
- var W;
1790
+ var E;
1723
1791
  const { param: s, postData: r, newServiceStore: i, workShapeNode: o, res: a, smoothSync: n } = t, {
1724
1792
  willSyncService: c,
1725
1793
  isSync: d,
1726
1794
  updateSelectorOpt: l,
1727
1795
  textUpdateForWoker: p,
1728
1796
  needUndoTicker: f
1729
- } = s, w = l.workState, S = r.sp || [];
1797
+ } = s, w = l.workState, k = r.sp || [];
1730
1798
  if (w === b.Start)
1731
1799
  return {
1732
1800
  sp: [
@@ -1741,7 +1809,7 @@ class qe extends x {
1741
1809
  const I = a == null ? void 0 : a.selectRect;
1742
1810
  if (c) {
1743
1811
  const g = w === b.Done ? f : void 0;
1744
- S.push({
1812
+ k.push({
1745
1813
  type: h.Select,
1746
1814
  selectIds: o.selectIds,
1747
1815
  selectRect: I,
@@ -1757,34 +1825,34 @@ class qe extends x {
1757
1825
  useAnimation: l.useAnimation || !1
1758
1826
  };
1759
1827
  l.uid && (y.uid = l.uid);
1760
- for (const [v, T] of i.entries())
1761
- T.toolsType === m.BackgroundSVG && S.push({
1828
+ for (const [S, T] of i.entries())
1829
+ T.toolsType === m.BackgroundSVG && k.push({
1762
1830
  ...T,
1763
- workId: v,
1831
+ workId: S,
1764
1832
  type: h.BackgroundSVGUpdate,
1765
1833
  dataType: R.Local,
1766
1834
  willSyncService: w === b.Done ? !0 : n,
1767
1835
  updateNodeOpt: y,
1768
1836
  needUndoTicker: g,
1769
1837
  emitEventType: this.emitEventType
1770
- }), p && T.toolsType === m.Text ? S.push({
1838
+ }), p && T.toolsType === m.Text ? k.push({
1771
1839
  ...T,
1772
- workId: v,
1840
+ workId: S,
1773
1841
  type: h.TextUpdate,
1774
1842
  dataType: R.Local,
1775
1843
  willSyncService: w === b.Done ? !0 : n,
1776
1844
  updateNodeOpt: y,
1777
1845
  needUndoTicker: g,
1778
1846
  emitEventType: this.emitEventType
1779
- }) : (n || w === b.Done) && S.push({
1847
+ }) : (n || w === b.Done) && k.push({
1780
1848
  ...T,
1781
- workId: v,
1849
+ workId: S,
1782
1850
  type: h.UpdateNode,
1783
1851
  updateNodeOpt: {
1784
1852
  ...y,
1785
- eraserGeometryDelta: ee(
1786
- (W = this.localWork) == null ? void 0 : W.vNodes,
1787
- v
1853
+ eraserGeometryDelta: se(
1854
+ (E = this.localWork) == null ? void 0 : E.vNodes,
1855
+ S
1788
1856
  )
1789
1857
  },
1790
1858
  isSync: d,
@@ -1792,15 +1860,15 @@ class qe extends x {
1792
1860
  emitEventType: this.emitEventType
1793
1861
  });
1794
1862
  }
1795
- return f && S.push({
1863
+ return f && k.push({
1796
1864
  type: h.None,
1797
1865
  needUndoTicker: f
1798
- }), S.push({
1866
+ }), k.push({
1799
1867
  type: h.SelectorTransform,
1800
1868
  emitEventType: this.emitEventType,
1801
1869
  workState: w
1802
1870
  }), {
1803
- sp: S
1871
+ sp: k
1804
1872
  };
1805
1873
  });
1806
1874
  }
@@ -1822,7 +1890,7 @@ class qe extends x {
1822
1890
  smoothSync: d,
1823
1891
  needUndoTicker: l
1824
1892
  } = t;
1825
- s === D && r && (r.workState === b.Done && (r != null && r.translate) && (r.translate[0] || r.translate[1]) || r.workState !== b.Done ? await ((p = this.localWork) == null ? void 0 : p.updateSelector({
1893
+ s === P && r && (r.workState === b.Done && (r != null && r.translate) && (r.translate[0] || r.translate[1]) || r.workState !== b.Done ? await ((p = this.localWork) == null ? void 0 : p.updateSelector({
1826
1894
  updateSelectorOpt: r,
1827
1895
  willRefreshSelector: i,
1828
1896
  willSyncService: o,
@@ -1836,13 +1904,13 @@ class qe extends x {
1836
1904
  })) : r.workState === b.Done && ((f = this.localWork) == null || f.vNodes.deleteLastTarget()));
1837
1905
  }
1838
1906
  }
1839
- class ze extends x {
1907
+ class He extends q {
1840
1908
  constructor() {
1841
1909
  super(...arguments);
1842
1910
  u(this, "emitEventType", N.ScaleNode);
1843
1911
  u(this, "updateSelectorCallback", (t) => {
1844
1912
  var I;
1845
- const { param: s, postData: r, workShapeNode: i, res: o, newServiceStore: a, smoothSync: n } = t, { updateSelectorOpt: c, willSyncService: d, needUndoTicker: l } = s, p = c.workState, f = r.sp || [], w = o == null ? void 0 : o.selectRect, S = p === b.Done ? l : void 0;
1913
+ const { param: s, postData: r, workShapeNode: i, res: o, newServiceStore: a, smoothSync: n } = t, { updateSelectorOpt: c, willSyncService: d, needUndoTicker: l } = s, p = c.workState, f = r.sp || [], w = o == null ? void 0 : o.selectRect, k = p === b.Done ? l : void 0;
1846
1914
  if (p === b.Start)
1847
1915
  return {
1848
1916
  sp: [
@@ -1864,10 +1932,10 @@ class ze extends x {
1864
1932
  points: p === b.Done && i.getChildrenPoints() || void 0,
1865
1933
  textOpt: i.textOpt
1866
1934
  });
1867
- const W = {
1935
+ const E = {
1868
1936
  useAnimation: c.useAnimation || !1
1869
1937
  };
1870
- c.uid && (W.uid = c.uid);
1938
+ c.uid && (E.uid = c.uid);
1871
1939
  for (const [g, y] of a.entries())
1872
1940
  y.toolsType === m.BackgroundSVG && f.push({
1873
1941
  ...y,
@@ -1875,8 +1943,8 @@ class ze extends x {
1875
1943
  type: h.BackgroundSVGUpdate,
1876
1944
  dataType: R.Local,
1877
1945
  willSyncService: p === b.Done ? !0 : n,
1878
- updateNodeOpt: W,
1879
- needUndoTicker: S,
1946
+ updateNodeOpt: E,
1947
+ needUndoTicker: k,
1880
1948
  emitEventType: this.emitEventType
1881
1949
  }), y.toolsType === m.Text ? f.push({
1882
1950
  ...y,
@@ -1884,22 +1952,22 @@ class ze extends x {
1884
1952
  type: h.TextUpdate,
1885
1953
  dataType: R.Local,
1886
1954
  willSyncService: p === b.Done ? !0 : n,
1887
- updateNodeOpt: W,
1888
- needUndoTicker: S,
1955
+ updateNodeOpt: E,
1956
+ needUndoTicker: k,
1889
1957
  emitEventType: this.emitEventType
1890
1958
  }) : (n || p === b.Done) && f.push({
1891
1959
  ...y,
1892
1960
  workId: g,
1893
1961
  type: h.UpdateNode,
1894
1962
  updateNodeOpt: {
1895
- ...W,
1896
- eraserGeometryDelta: ee(
1963
+ ...E,
1964
+ eraserGeometryDelta: se(
1897
1965
  (I = this.localWork) == null ? void 0 : I.vNodes,
1898
1966
  g
1899
1967
  )
1900
1968
  },
1901
1969
  isSync: !0,
1902
- needUndoTicker: S,
1970
+ needUndoTicker: k,
1903
1971
  emitEventType: this.emitEventType
1904
1972
  });
1905
1973
  }
@@ -1930,7 +1998,7 @@ class ze extends x {
1930
1998
  smoothSync: a,
1931
1999
  needUndoTicker: n
1932
2000
  } = t;
1933
- s === D && r && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
2001
+ s === P && r && await ((c = this.localWork) == null ? void 0 : c.updateSelector({
1934
2002
  updateSelectorOpt: r,
1935
2003
  willSyncService: i,
1936
2004
  willSerializeData: o,
@@ -1941,7 +2009,7 @@ class ze extends x {
1941
2009
  }));
1942
2010
  }
1943
2011
  }
1944
- class Ve extends x {
2012
+ class Ke extends q {
1945
2013
  constructor() {
1946
2014
  super(...arguments);
1947
2015
  u(this, "emitEventType", N.RotateNode);
@@ -1953,9 +2021,9 @@ class Ve extends x {
1953
2021
  willSerializeData: l,
1954
2022
  isSync: p,
1955
2023
  needUndoTicker: f
1956
- } = s, w = c.workState, S = r.sp || [], I = o == null ? void 0 : o.selectRect, W = w === b.Done ? f : void 0;
2024
+ } = s, w = c.workState, k = r.sp || [], I = o == null ? void 0 : o.selectRect, E = w === b.Done ? f : void 0;
1957
2025
  if (d) {
1958
- l && w === b.Done && S.push({
2026
+ l && w === b.Done && k.push({
1959
2027
  type: h.Select,
1960
2028
  selectIds: i.selectIds,
1961
2029
  selectRect: I,
@@ -1967,32 +2035,32 @@ class Ve extends x {
1967
2035
  useAnimation: c.useAnimation || !1
1968
2036
  };
1969
2037
  if (c.uid && (y.uid = c.uid), n || w === b.Done)
1970
- for (const [v, T] of a.entries())
1971
- S.push({
2038
+ for (const [S, T] of a.entries())
2039
+ k.push({
1972
2040
  ...T,
1973
- workId: v,
2041
+ workId: S,
1974
2042
  type: h.UpdateNode,
1975
2043
  updateNodeOpt: {
1976
2044
  ...y,
1977
- eraserGeometryDelta: ee(
2045
+ eraserGeometryDelta: se(
1978
2046
  (g = this.localWork) == null ? void 0 : g.vNodes,
1979
- v
2047
+ S
1980
2048
  )
1981
2049
  },
1982
2050
  isSync: p,
1983
- needUndoTicker: W,
2051
+ needUndoTicker: E,
1984
2052
  emitEventType: this.emitEventType
1985
2053
  });
1986
2054
  }
1987
- return f && S.push({
2055
+ return f && k.push({
1988
2056
  type: h.None,
1989
2057
  needUndoTicker: f
1990
- }), S.push({
2058
+ }), k.push({
1991
2059
  type: h.SelectorTransform,
1992
2060
  emitEventType: this.emitEventType,
1993
2061
  workState: w
1994
2062
  }), {
1995
- sp: S
2063
+ sp: k
1996
2064
  };
1997
2065
  });
1998
2066
  }
@@ -2013,7 +2081,7 @@ class Ve extends x {
2013
2081
  smoothSync: c,
2014
2082
  needUndoTicker: d
2015
2083
  } = t;
2016
- s === D && r && await ((l = this.localWork) == null ? void 0 : l.updateSelector({
2084
+ s === P && r && await ((l = this.localWork) == null ? void 0 : l.updateSelector({
2017
2085
  updateSelectorOpt: r,
2018
2086
  willRefreshSelector: i,
2019
2087
  willSyncService: o,
@@ -2026,7 +2094,7 @@ class Ve extends x {
2026
2094
  }));
2027
2095
  }
2028
2096
  }
2029
- class $e extends x {
2097
+ class Qe extends q {
2030
2098
  constructor() {
2031
2099
  super(...arguments);
2032
2100
  u(this, "emitEventType", N.SetFontStyle);
@@ -2047,7 +2115,7 @@ class $e extends x {
2047
2115
  textUpdateForWoker: n,
2048
2116
  requestId: c
2049
2117
  } = t;
2050
- s === D && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2118
+ s === P && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2051
2119
  updateSelectorOpt: r,
2052
2120
  willRefreshSelector: i,
2053
2121
  willSyncService: o,
@@ -2066,19 +2134,19 @@ class $e extends x {
2066
2134
  textUpdateForWoker: l,
2067
2135
  requestId: p,
2068
2136
  emitEventType: f
2069
- } = s, w = r.sp || [], S = a == null ? void 0 : a.selectRect;
2137
+ } = s, w = r.sp || [], k = a == null ? void 0 : a.selectRect;
2070
2138
  if (n && w) {
2071
2139
  d.fontSize && w.push({
2072
2140
  type: h.Select,
2073
2141
  selectIds: o.selectIds,
2074
- selectRect: S,
2142
+ selectRect: k,
2075
2143
  willSyncService: n,
2076
2144
  isSync: c,
2077
2145
  points: o.getChildrenPoints()
2078
2146
  });
2079
- for (const [I, W] of i.entries())
2080
- l && W.toolsType === m.Text ? w.push({
2081
- ...W,
2147
+ for (const [I, E] of i.entries())
2148
+ l && E.toolsType === m.Text ? w.push({
2149
+ ...E,
2082
2150
  workId: I,
2083
2151
  type: h.TextUpdate,
2084
2152
  dataType: R.Local,
@@ -2086,7 +2154,7 @@ class $e extends x {
2086
2154
  emitEventType: f,
2087
2155
  requestId: p
2088
2156
  }) : w.push({
2089
- ...W,
2157
+ ...E,
2090
2158
  workId: I,
2091
2159
  type: h.UpdateNode,
2092
2160
  updateNodeOpt: {
@@ -2102,7 +2170,7 @@ class $e extends x {
2102
2170
  };
2103
2171
  }
2104
2172
  }
2105
- class _e extends x {
2173
+ class je extends q {
2106
2174
  constructor() {
2107
2175
  super(...arguments);
2108
2176
  u(this, "emitEventType", N.SetPoint);
@@ -2158,7 +2226,7 @@ class _e extends x {
2158
2226
  textUpdateForWoker: n,
2159
2227
  needUndoTicker: c
2160
2228
  } = t;
2161
- s === D && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2229
+ s === P && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2162
2230
  updateSelectorOpt: r,
2163
2231
  willRefreshSelector: i,
2164
2232
  willSyncService: o,
@@ -2171,7 +2239,7 @@ class _e extends x {
2171
2239
  }));
2172
2240
  }
2173
2241
  }
2174
- class He extends x {
2242
+ class Xe extends q {
2175
2243
  constructor() {
2176
2244
  super(...arguments);
2177
2245
  u(this, "emitEventType", N.SetLock);
@@ -2192,7 +2260,7 @@ class He extends x {
2192
2260
  needUndoTicker: n,
2193
2261
  requestId: c
2194
2262
  } = t;
2195
- s === D && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2263
+ s === P && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2196
2264
  updateSelectorOpt: r,
2197
2265
  willRefreshSelector: i,
2198
2266
  willSyncService: o,
@@ -2211,11 +2279,11 @@ class He extends x {
2211
2279
  needUndoTicker: l,
2212
2280
  requestId: p,
2213
2281
  emitEventType: f
2214
- } = s, w = r.sp || [], S = a == null ? void 0 : a.selectRect;
2282
+ } = s, w = r.sp || [], k = a == null ? void 0 : a.selectRect;
2215
2283
  if (n && w) {
2216
- for (const [I, W] of i.entries())
2284
+ for (const [I, E] of i.entries())
2217
2285
  w.push({
2218
- ...W,
2286
+ ...E,
2219
2287
  workId: I,
2220
2288
  type: h.UpdateNode,
2221
2289
  updateNodeOpt: {
@@ -2232,7 +2300,7 @@ class He extends x {
2232
2300
  canRotate: o.canRotate,
2233
2301
  type: h.Select,
2234
2302
  selectIds: o.selectIds,
2235
- selectRect: S,
2303
+ selectRect: k,
2236
2304
  willSyncService: n,
2237
2305
  isSync: c
2238
2306
  });
@@ -2245,7 +2313,7 @@ class He extends x {
2245
2313
  };
2246
2314
  }
2247
2315
  }
2248
- class Qe extends x {
2316
+ class Ye extends q {
2249
2317
  constructor() {
2250
2318
  super(...arguments);
2251
2319
  u(this, "emitEventType", N.SetShapeOpt);
@@ -2266,7 +2334,7 @@ class Qe extends x {
2266
2334
  needUndoTicker: n,
2267
2335
  requestId: c
2268
2336
  } = t;
2269
- s === D && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2337
+ s === P && r && await ((d = this.localWork) == null ? void 0 : d.updateSelector({
2270
2338
  updateSelectorOpt: r,
2271
2339
  willRefreshSelector: i,
2272
2340
  willSyncService: o,
@@ -2306,7 +2374,7 @@ class Qe extends x {
2306
2374
  };
2307
2375
  }
2308
2376
  }
2309
- class Ke {
2377
+ class Ze {
2310
2378
  constructor(e) {
2311
2379
  u(this, "builders", /* @__PURE__ */ new Map());
2312
2380
  this.builders = new Map(e.map((t) => [t, this.build(t)]));
@@ -2314,25 +2382,25 @@ class Ke {
2314
2382
  build(e) {
2315
2383
  switch (e) {
2316
2384
  case N.TranslateNode:
2317
- return new qe();
2385
+ return new _e();
2318
2386
  case N.ZIndexNode:
2319
- return new Ge();
2387
+ return new $e();
2320
2388
  case N.CopyNode:
2321
- return new Ue();
2389
+ return new ze();
2322
2390
  case N.SetColorNode:
2323
- return new xe();
2391
+ return new Ve();
2324
2392
  case N.ScaleNode:
2325
- return new ze();
2393
+ return new He();
2326
2394
  case N.RotateNode:
2327
- return new Ve();
2395
+ return new Ke();
2328
2396
  case N.SetFontStyle:
2329
- return new $e();
2397
+ return new Qe();
2330
2398
  case N.SetPoint:
2331
- return new _e();
2399
+ return new je();
2332
2400
  case N.SetLock:
2333
- return new He();
2401
+ return new Xe();
2334
2402
  case N.SetShapeOpt:
2335
- return new Qe();
2403
+ return new Ye();
2336
2404
  }
2337
2405
  }
2338
2406
  registerForMainThread(e) {
@@ -2347,14 +2415,14 @@ class Ke {
2347
2415
  return !1;
2348
2416
  }
2349
2417
  }
2350
- function Xe({
2351
- subThreads: M,
2418
+ function Je({
2419
+ subThreads: D,
2352
2420
  layers: e,
2353
2421
  scene: t,
2354
2422
  removeLayerTexture: s
2355
2423
  }) {
2356
2424
  let r;
2357
- for (const i of M)
2425
+ for (const i of D)
2358
2426
  try {
2359
2427
  i.destroy();
2360
2428
  } catch (o) {
@@ -2382,8 +2450,8 @@ function Xe({
2382
2450
  if (r)
2383
2451
  throw r;
2384
2452
  }
2385
- const Ye = 4;
2386
- class Ze {
2453
+ const et = 4;
2454
+ class tt {
2387
2455
  constructor(e = {}) {
2388
2456
  u(this, "pendingFrames", /* @__PURE__ */ new Map());
2389
2457
  u(this, "failedCanvases", /* @__PURE__ */ new Set());
@@ -2395,7 +2463,7 @@ class Ze {
2395
2463
  u(this, "destroyed", !1);
2396
2464
  this.tailFrameCount = Math.max(
2397
2465
  1,
2398
- Math.floor(e.tailFrameCount ?? Ye)
2466
+ Math.floor(e.tailFrameCount ?? et)
2399
2467
  ), this.requestFrame = e.requestFrame ?? ((t) => requestAnimationFrame(t)), this.cancelFrame = e.cancelFrame ?? ((t) => cancelAnimationFrame(t)), this.onReadbackError = e.onReadbackError;
2400
2468
  }
2401
2469
  markRendered(e) {
@@ -2426,7 +2494,7 @@ class Ze {
2426
2494
  }
2427
2495
  }
2428
2496
  }
2429
- class je {
2497
+ class st {
2430
2498
  constructor(e, t) {
2431
2499
  u(this, "viewId");
2432
2500
  u(this, "fullLayer");
@@ -2462,33 +2530,33 @@ class je {
2462
2530
  ...t.canvasOpt,
2463
2531
  container: t.container
2464
2532
  }), this.master = t.master;
2465
- const s = K.bufferSize.full, r = K.bufferSize.sub;
2533
+ const s = Y.bufferSize.full, r = Y.bufferSize.sub;
2466
2534
  this.fullLayer = this.createLayer("fullLayer", this.scene, {
2467
2535
  ...t.layerOpt,
2468
- bufferSize: this.viewId === Q ? s : r * 2
2536
+ bufferSize: this.viewId === X ? s : r * 2
2469
2537
  }), this.topLayer = this.createLayer("topLayer", this.scene, {
2470
2538
  ...t.layerOpt,
2471
- bufferSize: (this.viewId === Q, r),
2539
+ bufferSize: (this.viewId === X, r),
2472
2540
  contextType: "2d"
2473
2541
  }), this.localLayer = this.createLayer("localLayer", this.scene, {
2474
2542
  ...t.layerOpt,
2475
- bufferSize: (this.viewId === Q, r),
2543
+ bufferSize: (this.viewId === X, r),
2476
2544
  contextType: "2d"
2477
2545
  }), this.serviceLayer = this.createLayer("serviceLayer", this.scene, {
2478
2546
  ...t.layerOpt,
2479
- bufferSize: (this.viewId === Q, r),
2547
+ bufferSize: (this.viewId === X, r),
2480
2548
  contextType: "2d"
2481
2549
  }), t.mainThreadRenderMode === "readback" && this.enableCanvas2DReadback([
2482
2550
  this.fullLayer.parent,
2483
2551
  this.topLayer.parent,
2484
2552
  this.localLayer.parent,
2485
2553
  this.serviceLayer.parent
2486
- ]), this.vNodes = new We(e, this.scene);
2554
+ ]), this.vNodes = new be(e, this.scene);
2487
2555
  const i = {
2488
2556
  thread: this,
2489
2557
  vNodes: this.vNodes
2490
2558
  };
2491
- this.localWork = new Ae(i), this.serviceWork = new Fe(i), this.topWork = new Pe(i), this.vNodes.init(this.fullLayer), this.methodBuilder = new Ke([
2559
+ this.localWork = new Ge(i), this.serviceWork = new qe(i), this.topWork = new xe(i), this.vNodes.init(this.fullLayer), this.methodBuilder = new Ze([
2492
2560
  N.CopyNode,
2493
2561
  N.SetColorNode,
2494
2562
  N.DeleteNode,
@@ -2506,6 +2574,16 @@ class je {
2506
2574
  var t;
2507
2575
  return (t = this.cacheImages.get(e)) == null ? void 0 : t.imageSource;
2508
2576
  }
2577
+ getImageSourceKey(e) {
2578
+ if (!e.src) return;
2579
+ if (e.type !== me.Iconify) return e.src;
2580
+ const [t, s] = this.getIconSize(
2581
+ e.width,
2582
+ e.height,
2583
+ this.opt.displayer.dpr
2584
+ );
2585
+ return ye(e.src, t, s, e.strokeColor);
2586
+ }
2509
2587
  getCachedImagesByWorkId(e) {
2510
2588
  for (const [t, s] of this.cacheImages.entries())
2511
2589
  if (t === e && s.imageSource)
@@ -2534,7 +2612,7 @@ class je {
2534
2612
  this.destroyed || (this.combinePostMsg.add(e), this.runBatchPostData());
2535
2613
  }
2536
2614
  reportRendererBusinessError(e, t) {
2537
- const s = Y(e, t);
2615
+ const s = Z(e, t);
2538
2616
  s.reported || (s.reported = !0, this.post({
2539
2617
  sp: [
2540
2618
  {
@@ -2544,7 +2622,7 @@ class je {
2544
2622
  reportErrorCode: "RENDERER_RUNTIME_ERROR",
2545
2623
  reportStage: s.stage,
2546
2624
  reportError: s.message,
2547
- reportString: Re(s, t, {
2625
+ reportString: Le(s, t, {
2548
2626
  viewId: this.viewId,
2549
2627
  renderer: "mainThread"
2550
2628
  })
@@ -2574,26 +2652,26 @@ class je {
2574
2652
  workState: p,
2575
2653
  imageSrc: f,
2576
2654
  imageBitmap: w,
2577
- imageElement: S,
2655
+ imageElement: k,
2578
2656
  workIds: I,
2579
- isLockSentEventCursor: W,
2657
+ isLockSentEventCursor: E,
2580
2658
  requestId: g
2581
2659
  } = e, y = l == null ? void 0 : l.toString();
2582
2660
  switch (a) {
2583
2661
  case h.UpdateDpr:
2584
- G(e.dpr) && this.updateDpr(e.dpr);
2662
+ z(e.dpr) && this.updateDpr(e.dpr);
2585
2663
  break;
2586
2664
  case h.AuthClear: {
2587
- const { clearUids: v, localUid: T } = e;
2588
- this.vNodes.setCanClearUids(v), this.vNodes.setLocalUid(T);
2665
+ const { clearUids: S, localUid: T } = e;
2666
+ this.vNodes.setCanClearUids(S), this.vNodes.setLocalUid(T);
2589
2667
  break;
2590
2668
  }
2591
2669
  case h.Destroy:
2592
2670
  this.destroy();
2593
2671
  break;
2594
2672
  case h.CancelBitmapEraser: {
2595
- const v = y;
2596
- v && this.localWork.abortBitmapEraser(v);
2673
+ const S = y;
2674
+ S && this.localWork.abortBitmapEraser(S);
2597
2675
  break;
2598
2676
  }
2599
2677
  case h.Clear:
@@ -2601,18 +2679,18 @@ class je {
2601
2679
  break;
2602
2680
  case h.ServiceSyncCommit: {
2603
2681
  if (this.destroyed) break;
2604
- const v = [
2682
+ const S = [
2605
2683
  (s = this.fullLayer) == null ? void 0 : s.parent,
2606
2684
  (r = this.topLayer) == null ? void 0 : r.parent,
2607
2685
  (i = this.localLayer) == null ? void 0 : i.parent,
2608
2686
  (o = this.serviceLayer) == null ? void 0 : o.parent
2609
2687
  ].filter(Boolean);
2610
2688
  try {
2611
- await be(
2689
+ await Ne(
2612
2690
  (async () => {
2613
- await Le(
2691
+ await Be(
2614
2692
  this.serviceWork,
2615
- v
2693
+ S
2616
2694
  );
2617
2695
  })(),
2618
2696
  {
@@ -2622,7 +2700,7 @@ class je {
2622
2700
  }
2623
2701
  );
2624
2702
  } catch (T) {
2625
- throw Y(T, {
2703
+ throw Z(T, {
2626
2704
  business: "service-sync-commit",
2627
2705
  stage: "flush-and-prepare-render"
2628
2706
  });
@@ -2644,28 +2722,28 @@ class je {
2644
2722
  }
2645
2723
  case h.UpdateCamera:
2646
2724
  try {
2647
- await Ee(
2725
+ await Ce(
2648
2726
  e.cameraTaskId,
2649
- async (v) => {
2650
- this.activeCameraTaskContext = v;
2727
+ async (S) => {
2728
+ this.activeCameraTaskContext = S;
2651
2729
  try {
2652
- await this.updateCamera(e, v);
2730
+ await this.updateCamera(e, S);
2653
2731
  } finally {
2654
- this.activeCameraTaskContext === v && (this.activeCameraTaskContext = void 0);
2732
+ this.activeCameraTaskContext === S && (this.activeCameraTaskContext = void 0);
2655
2733
  }
2656
2734
  }
2657
2735
  );
2658
- } catch (v) {
2659
- throw this.cameraOpt = void 0, this.cancelCameraSettledRender(), v;
2736
+ } catch (S) {
2737
+ throw this.cameraOpt = void 0, this.cancelCameraSettledRender(), S;
2660
2738
  }
2661
2739
  break;
2662
2740
  case h.UpdateTools:
2663
2741
  if (n && c) {
2664
- const v = {
2742
+ const S = {
2665
2743
  toolsType: n,
2666
2744
  toolsOpt: c
2667
2745
  };
2668
- this.topWork.canUseTopLayer(n) ? this.topWork.setToolsOpt(v) : this.localWork.setToolsOpt(v);
2746
+ this.topWork.canUseTopLayer(n) ? this.topWork.setToolsOpt(S) : this.localWork.setToolsOpt(S);
2669
2747
  }
2670
2748
  break;
2671
2749
  case h.CreateWork:
@@ -2684,11 +2762,11 @@ class je {
2684
2762
  }
2685
2763
  break;
2686
2764
  case h.DrawWork:
2687
- p === b.Done && d === R.Local ? (await this.consumeDrawAll(d, e), n === m.LaserPen && W && this.post({
2765
+ p === b.Done && d === R.Local ? (await this.consumeDrawAll(d, e), n === m.LaserPen && E && this.post({
2688
2766
  sp: [
2689
2767
  {
2690
2768
  type: h.None,
2691
- isLockSentEventCursor: W
2769
+ isLockSentEventCursor: E
2692
2770
  }
2693
2771
  ]
2694
2772
  })) : await this.consumeDraw(d, e);
@@ -2705,7 +2783,7 @@ class je {
2705
2783
  await this.removeNode(e);
2706
2784
  return;
2707
2785
  case h.Select:
2708
- d === R.Local || l === D ? await this.localWork.updateFullSelectWork(e) : d === R.Service && this.serviceWork.runSelectWork(e);
2786
+ d === R.Local || l === P ? await this.localWork.updateFullSelectWork(e) : d === R.Service && this.serviceWork.runSelectWork(e);
2709
2787
  break;
2710
2788
  case h.CursorBlur:
2711
2789
  this.localWork.cursorBlur();
@@ -2717,31 +2795,57 @@ class je {
2717
2795
  d === R.Local && this.localWork.checkTextActive(e);
2718
2796
  break;
2719
2797
  case h.GetImageBitMap:
2720
- if (f && (w || S) && l) {
2721
- const v = this.imageResolveMap.get(f);
2722
- if (!v || v.requestId !== g) {
2723
- this.closeImageSource(w || S);
2798
+ if (f && l) {
2799
+ const S = this.imageResolveMap.get(f);
2800
+ if (!S || S.requestId !== g) {
2801
+ const L = w || k;
2802
+ if (L && !S && this.serviceWork) {
2803
+ const O = [
2804
+ ...this.vNodes.getNodesByType(m.Image)
2805
+ ].filter(
2806
+ ([, A]) => A.opt && this.getImageSourceKey(A.opt) === f
2807
+ );
2808
+ if (O.length && !this.cacheImages.has(f)) {
2809
+ this.cacheImages.set(f, {
2810
+ imageSource: L,
2811
+ workId: O[0][0]
2812
+ }), O.forEach(([A, W]) => {
2813
+ this.serviceWork.consumeFull({
2814
+ msgType: h.FullWork,
2815
+ dataType: R.Service,
2816
+ viewId: this.viewId,
2817
+ workId: A,
2818
+ toolsType: m.Image,
2819
+ opt: W.opt
2820
+ });
2821
+ });
2822
+ break;
2823
+ }
2824
+ }
2825
+ this.closeImageSource(L);
2724
2826
  break;
2725
2827
  }
2726
- const T = l.toString();
2727
- this.deleteCachedImagesByWorkId(T), this.cacheImages.set(f, {
2728
- imageSource: w || S,
2729
- workId: T
2730
- });
2731
- const { resolve: C, timer: L } = v;
2732
- L && clearTimeout(L), C && C(f);
2828
+ if (w || k) {
2829
+ const L = l.toString();
2830
+ this.deleteCachedImagesByWorkId(L), this.cacheImages.set(f, {
2831
+ imageSource: w || k,
2832
+ workId: L
2833
+ });
2834
+ }
2835
+ const { resolve: T, timer: C } = S;
2836
+ C && clearTimeout(C), T && T(f);
2733
2837
  }
2734
2838
  break;
2735
2839
  case h.GetVNodeInfo:
2736
2840
  if (l && I) {
2737
- const v = I.map((T) => this.vNodes.get(T));
2841
+ const S = I.map((T) => this.vNodes.get(T));
2738
2842
  this.post({
2739
2843
  sp: [
2740
2844
  {
2741
2845
  type: h.GetVNodeInfo,
2742
2846
  dataType: R.Local,
2743
2847
  workId: l,
2744
- vInfo: v
2848
+ vInfo: S
2745
2849
  }
2746
2850
  ]
2747
2851
  });
@@ -2755,16 +2859,12 @@ class je {
2755
2859
  return r <= 50 || i <= 50 ? [50, 50] : r <= 100 || i <= 100 ? [100, 100] : r <= 200 || i <= 200 ? [200, 200] : r <= 400 || i <= 400 ? [400, 400] : r <= 800 || i <= 800 ? [800, 800] : [1600, 1600];
2756
2860
  }
2757
2861
  async loadImageBitMap(e) {
2758
- const { toolsType: t, opt: s, workId: r, requestId: i } = e;
2862
+ const { toolsType: t, opt: s, workId: r, requestId: i, timeoutMs: o } = e;
2759
2863
  if (t === m.Image && s && r) {
2760
- const o = r.toString(), { src: a, type: n, width: c, height: d, strokeColor: l } = s;
2761
- if (!a || !n || !c || !d)
2864
+ const a = r.toString(), { src: n, type: c, width: d, height: l } = s;
2865
+ if (!n || !c || !d || !l)
2762
2866
  return;
2763
- let p = a;
2764
- if (n === pe.Iconify) {
2765
- const [y, v] = this.getIconSize(c, d, this.opt.displayer.dpr);
2766
- p = ue(a, y, v, l);
2767
- }
2867
+ const p = this.getImageSourceKey(s);
2768
2868
  if (this.cacheImages.has(p)) {
2769
2869
  const y = this.getCachedImages(p);
2770
2870
  if (y)
@@ -2773,23 +2873,23 @@ class je {
2773
2873
  const w = this.imageResolveMap.get(p);
2774
2874
  if (w)
2775
2875
  return await w.promise, this.getCachedImages(p);
2776
- let S, I;
2777
- const W = new Promise((y, v) => {
2778
- S = y, I = v;
2876
+ let k, I;
2877
+ const E = new Promise((y, S) => {
2878
+ k = y, I = S;
2779
2879
  }), g = {
2780
- resolve: S,
2880
+ resolve: k,
2781
2881
  reject: I,
2782
2882
  timer: void 0,
2783
2883
  requestId: i,
2784
- promise: W
2884
+ promise: E
2785
2885
  };
2786
2886
  return g.timer = setTimeout(() => {
2787
- this.imageResolveMap.get(p) === g && S(p);
2788
- }, 5e3), this.imageResolveMap.set(p, g), this.opt.post({
2887
+ this.imageResolveMap.get(p) === g && k(p);
2888
+ }, o ?? 5e3), this.imageResolveMap.set(p, g), this.opt.post({
2789
2889
  sp: [
2790
2890
  {
2791
2891
  imageSrc: p,
2792
- workId: o,
2892
+ workId: a,
2793
2893
  viewId: this.viewId,
2794
2894
  isgl: !!this.fullLayer.parent.gl,
2795
2895
  isSubWorker: !1,
@@ -2797,14 +2897,14 @@ class je {
2797
2897
  type: h.GetImageBitMap
2798
2898
  }
2799
2899
  ]
2800
- }), await W, this.imageResolveMap.get(p) === g && this.imageResolveMap.delete(p), this.getCachedImages(p);
2900
+ }), await E, this.imageResolveMap.get(p) === g && this.imageResolveMap.delete(p), this.getCachedImages(p);
2801
2901
  }
2802
2902
  }
2803
2903
  async removeNode(e) {
2804
2904
  const { dataType: t, workId: s, removeIds: r } = e, i = r || [];
2805
2905
  if (s && i.push(s.toString()), i.length)
2806
2906
  for (const o of i) {
2807
- if (o === D) {
2907
+ if (o === P) {
2808
2908
  await this.localWork.removeSelector(e);
2809
2909
  continue;
2810
2910
  }
@@ -2840,13 +2940,13 @@ class je {
2840
2940
  };
2841
2941
  let c = !1;
2842
2942
  for (const d of e)
2843
- if (le(n, d)) {
2943
+ if (ue(n, d)) {
2844
2944
  c = !0;
2845
2945
  break;
2846
2946
  }
2847
2947
  c || e.push(n);
2848
2948
  }
2849
- G(o.fullWorkerDrawCount) && (t = o.fullWorkerDrawCount), G(o.consumeCount) && (s = o.consumeCount, r = o.consumeWorkId);
2949
+ z(o.fullWorkerDrawCount) && (t = o.fullWorkerDrawCount), z(o.consumeCount) && (s = o.consumeCount, r = o.consumeWorkId);
2850
2950
  }
2851
2951
  return this.combinePostMsg.clear(), {
2852
2952
  sp: e,
@@ -2876,7 +2976,7 @@ class je {
2876
2976
  clearAll() {
2877
2977
  this.cancelCameraSettledRender(), this.debounceUpdateCache.clear(), this.fullLayer.children.length && (this.fullLayer.parent.children.forEach((e) => {
2878
2978
  e.name !== "viewport" && e.remove();
2879
- }), $(this.fullLayer, this.fullLayer.parent)), this.clearCacheImages(), this.clearImageResolveMap(), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
2979
+ }), K(this.fullLayer, this.fullLayer.parent)), this.clearCacheImages(), this.clearImageResolveMap(), this.localWork.clearAll(), this.topWork.clearAll(), this.serviceWork.clearAll(), this.vNodes.clear(), this.post({
2880
2980
  sp: [
2881
2981
  {
2882
2982
  type: h.Clear
@@ -2913,13 +3013,13 @@ class je {
2913
3013
  var d, l;
2914
3014
  const { cameraOpt: s, scenePath: r, cameraTaskId: i } = e;
2915
3015
  let o = !1;
2916
- const a = this.cameraOpt, n = !!(s && le(a, s));
3016
+ const a = this.cameraOpt, n = !!(s && ue(a, s));
2917
3017
  let c = !1;
2918
3018
  if (s && n) {
2919
3019
  const p = !!this.activeCameraSettledRender;
2920
3020
  if (this.retargetCameraSettledRender(i)) return;
2921
3021
  if (!p) {
2922
- G(i) && this.opt.post({
3022
+ z(i) && this.opt.post({
2923
3023
  viewId: this.viewId,
2924
3024
  viewGeneration: this.viewGeneration,
2925
3025
  cameraSettledTaskId: i
@@ -2945,43 +3045,43 @@ class je {
2945
3045
  case m.LaserPen:
2946
3046
  break;
2947
3047
  default:
2948
- T !== H && T !== D && y.push(`${T}:${C.toolsType}`);
3048
+ T !== j && T !== P && y.push(`${T}:${C.toolsType}`);
2949
3049
  break;
2950
3050
  }
2951
3051
  if (t && (t.stage = "blocking-works", t.blockingWorks = y), !y.length) break;
2952
3052
  if (!await new Promise((T) => {
2953
3053
  this.taskUpdateCameraResolve = T, this.taskUpdateCameraId = setTimeout(() => {
2954
3054
  this.taskUpdateCameraId = void 0, this.taskUpdateCameraResolve = void 0, T(!0);
2955
- }, oe);
3055
+ }, ce);
2956
3056
  }) || t != null && t.aborted) return;
2957
3057
  } while (y.length);
2958
3058
  t && (t.stage = "update-camera", t.blockingWorks = void 0);
2959
3059
  }
2960
3060
  if (t != null && t.aborted) return;
2961
3061
  const f = /* @__PURE__ */ new Map();
2962
- for (const [y, v] of this.vNodes.getNodesByType(m.Text).entries()) {
2963
- const T = v.rect;
2964
- f.set(y, J(T));
3062
+ for (const [y, S] of this.vNodes.getNodesByType(m.Text).entries()) {
3063
+ const T = S.rect;
3064
+ f.set(y, te(T));
2965
3065
  }
2966
- for (const [y, v] of this.vNodes.gethasEraserNodes().entries())
2967
- f.set(y, J(v.rect));
3066
+ for (const [y, S] of this.vNodes.gethasEraserNodes().entries())
3067
+ f.set(y, te(S.rect));
2968
3068
  const w = new Set(f.keys());
2969
- let S = !1;
3069
+ let k = !1;
2970
3070
  if (this.localWork.hasSelector()) {
2971
3071
  const y = (l = this.localWork.getSelector()) == null ? void 0 : l.selectIds;
2972
3072
  if (y) {
2973
- S = !0;
2974
- for (const v of y)
2975
- w.add(v);
3073
+ k = !0;
3074
+ for (const S of y)
3075
+ w.add(S);
2976
3076
  }
2977
3077
  }
2978
3078
  let I = !1;
2979
3079
  if (this.serviceWork.selectorWorkShapes.size)
2980
3080
  for (const y of this.serviceWork.selectorWorkShapes.values()) {
2981
- const v = y.selectIds;
2982
- if (v) {
3081
+ const S = y.selectIds;
3082
+ if (S) {
2983
3083
  I = !0;
2984
- for (const T of v)
3084
+ for (const T of S)
2985
3085
  w.add(T);
2986
3086
  }
2987
3087
  }
@@ -2990,14 +3090,14 @@ class je {
2990
3090
  for (const [T, C] of f.entries()) {
2991
3091
  const L = this.vNodes.get(T);
2992
3092
  if (L) {
2993
- const A = C, E = L.rect, k = this.getSceneRect(), B = ae(A, k), O = ae(E, k);
2994
- let P = c;
2995
- (B !== O || A.w !== E.w || A.h !== E.h || O === Ce.intersect) && (P = !0);
2996
- const { toolsType: F, opt: U } = L, X = U.eraserlines && U.eraserlines.length > 0 || !!U.eraserFaces;
2997
- (P || p && X) && (F === m.Text || X) && this.debounceUpdateCache.add(T);
3093
+ const O = C, A = L.rect, W = this.getSceneRect(), v = he(O, W), B = he(A, W);
3094
+ let F = c;
3095
+ (v !== B || O.w !== A.w || O.h !== A.h || B === Oe.intersect) && (F = !0);
3096
+ const { toolsType: M, opt: U } = L, x = U.eraserlines && U.eraserlines.length > 0 || !!U.eraserFaces;
3097
+ (F || p && x) && (M === m.Text || x) && this.debounceUpdateCache.add(T);
2998
3098
  }
2999
3099
  }
3000
- if (S && this.localWork.reRenderSelector(), I)
3100
+ if (k && this.localWork.reRenderSelector(), I)
3001
3101
  for (const [
3002
3102
  T,
3003
3103
  C
@@ -3012,48 +3112,48 @@ class je {
3012
3112
  o = !0;
3013
3113
  const y = { cancelled: !1, cameraTaskId: i, context: t };
3014
3114
  this.activeCameraSettledRender = y;
3015
- const v = () => !this.destroyed && !y.cancelled && this.activeCameraSettledRender === y && !(t != null && t.aborted);
3115
+ const S = () => !this.destroyed && !y.cancelled && this.activeCameraSettledRender === y && !(t != null && t.aborted);
3016
3116
  this.debounceUpdateCameraId = setTimeout(async () => {
3017
3117
  var T;
3018
3118
  this.debounceUpdateCameraId = void 0;
3019
3119
  try {
3020
- if (!v()) return;
3120
+ if (!S()) return;
3021
3121
  const C = [];
3022
- for (const E of this.debounceUpdateCache.values()) {
3023
- const k = (T = this.fullLayer) == null ? void 0 : T.getElementsByName(E)[0], B = this.vNodes.get(E);
3024
- if (B) {
3025
- const { toolsType: O, opt: P } = B;
3026
- if (k || O !== m.Text) {
3027
- const F = this.localWork.setFullWork({
3028
- toolsType: O,
3029
- opt: P,
3030
- workId: E
3122
+ for (const A of this.debounceUpdateCache.values()) {
3123
+ const W = (T = this.fullLayer) == null ? void 0 : T.getElementsByName(A)[0], v = this.vNodes.get(A);
3124
+ if (v) {
3125
+ const { toolsType: B, opt: F } = v;
3126
+ if (W || B !== m.Text) {
3127
+ const M = this.localWork.setFullWork({
3128
+ toolsType: B,
3129
+ opt: F,
3130
+ workId: A
3031
3131
  });
3032
- if (F) {
3033
- if (O === m.Text)
3132
+ if (M) {
3133
+ if (B === m.Text)
3034
3134
  C.push(
3035
- F.consumeServiceAsync({
3135
+ M.consumeServiceAsync({
3036
3136
  isFullWork: !0,
3037
- replaceId: E,
3137
+ replaceId: A,
3038
3138
  boxRect: this.getSceneRect(),
3039
- isActive: v
3139
+ isActive: S
3040
3140
  })
3041
3141
  );
3042
- else if (P.eraserlines && P.eraserlines.length > 0 || P.eraserFaces) {
3043
- const U = F.consumeService({
3044
- op: B.op,
3142
+ else if (F.eraserlines && F.eraserlines.length > 0 || F.eraserFaces) {
3143
+ const U = M.consumeService({
3144
+ op: v.op,
3045
3145
  isFullWork: !0,
3046
- replaceId: E,
3146
+ replaceId: A,
3047
3147
  workState: b.Done
3048
3148
  });
3049
- this.localWork.clearWorkShapeNodeCache(E), C.push(Promise.resolve(U));
3149
+ this.localWork.clearWorkShapeNodeCache(A), C.push(Promise.resolve(U));
3050
3150
  }
3051
3151
  }
3052
3152
  }
3053
3153
  }
3054
- this.debounceUpdateCache.delete(E);
3154
+ this.debounceUpdateCache.delete(A);
3055
3155
  }
3056
- if (await Promise.all(C), !v()) return;
3156
+ if (await Promise.all(C), !S()) return;
3057
3157
  this.vNodes.updateLowLevelNodesRect(), this.vNodes.clearHighLevelIds();
3058
3158
  const L = [
3059
3159
  this.fullLayer.parent.prepareRender,
@@ -3066,63 +3166,63 @@ class je {
3066
3166
  this.topLayer.parent,
3067
3167
  this.localLayer.parent,
3068
3168
  this.serviceLayer.parent
3069
- ], await Promise.all(L), y.renderLayers = void 0, !v()) return;
3070
- const A = y.cameraTaskId;
3071
- G(A) && this.opt.post({
3169
+ ], await Promise.all(L), y.renderLayers = void 0, !S()) return;
3170
+ const O = y.cameraTaskId;
3171
+ z(O) && this.opt.post({
3072
3172
  viewId: this.viewId,
3073
3173
  viewGeneration: this.viewGeneration,
3074
- cameraSettledTaskId: A
3174
+ cameraSettledTaskId: O
3075
3175
  });
3076
3176
  } catch (C) {
3077
- if (!v()) return;
3177
+ if (!S()) return;
3078
3178
  const L = {
3079
3179
  code: "RENDERER_BUSINESS_ERROR",
3080
3180
  business: "updateCamera",
3081
3181
  message: C instanceof Error ? C.message : String(C),
3082
3182
  stage: "camera-settled-render",
3083
3183
  workerType: "mainThread"
3084
- }, A = y.cameraTaskId;
3085
- if (G(A))
3184
+ }, O = y.cameraTaskId;
3185
+ if (z(O))
3086
3186
  try {
3087
3187
  this.opt.post({
3088
3188
  viewId: this.viewId,
3089
3189
  viewGeneration: this.viewGeneration,
3090
- cameraTaskId: A,
3190
+ cameraTaskId: O,
3091
3191
  cameraTaskStatus: "failed",
3092
3192
  cameraTaskError: L
3093
3193
  });
3094
- } catch (E) {
3194
+ } catch (A) {
3095
3195
  console.error(
3096
- `[cameraSettledRender] failed ACK post failed viewId=${this.viewId} taskId=${A}`,
3097
- E
3196
+ `[cameraSettledRender] failed ACK post failed viewId=${this.viewId} taskId=${O}`,
3197
+ A
3098
3198
  );
3099
3199
  }
3100
3200
  } finally {
3101
3201
  y.renderLayers = void 0, this.activeCameraSettledRender === y && (this.activeCameraSettledRender = void 0);
3102
3202
  }
3103
- }, oe);
3203
+ }, ce);
3104
3204
  }
3105
- const W = [
3205
+ const E = [
3106
3206
  this.fullLayer.parent,
3107
3207
  this.topLayer.parent,
3108
3208
  this.localLayer.parent,
3109
3209
  this.serviceLayer.parent
3110
3210
  ], g = Promise.all(
3111
- W.map((y) => y.prepareRender)
3211
+ E.map((y) => y.prepareRender)
3112
3212
  );
3113
- if (t && !await Ne(
3213
+ if (t && !await De(
3114
3214
  t,
3115
3215
  g,
3116
3216
  "prepare-render"
3117
3217
  )) {
3118
- W.filter(
3119
- (v) => v.cancelPendingRender()
3120
- ).forEach((v) => v.render()), g.catch(() => {
3218
+ E.filter(
3219
+ (S) => S.cancelPendingRender()
3220
+ ).forEach((S) => S.render()), g.catch(() => {
3121
3221
  });
3122
3222
  return;
3123
3223
  }
3124
3224
  if (t || await g, t != null && t.aborted) return;
3125
- !o && G(i) && this.opt.post({
3225
+ !o && z(i) && this.opt.post({
3126
3226
  viewId: this.viewId,
3127
3227
  viewGeneration: this.viewGeneration,
3128
3228
  cameraSettledTaskId: i
@@ -3139,7 +3239,7 @@ class je {
3139
3239
  };
3140
3240
  }
3141
3241
  createScene(e) {
3142
- return new fe({
3242
+ return new we({
3143
3243
  displayRatio: this.opt.displayer.dpr,
3144
3244
  depth: !1,
3145
3245
  desynchronized: !0,
@@ -3150,7 +3250,7 @@ class je {
3150
3250
  });
3151
3251
  }
3152
3252
  createLayer(e, t, s) {
3153
- const { width: r, height: i } = s, o = `canvas-${e}`, a = t.layer(o, { ...s, offscreen: !1 }), n = new me({
3253
+ const { width: r, height: i } = s, o = `canvas-${e}`, a = t.layer(o, { ...s, offscreen: !1 }), n = new ve({
3154
3254
  anchor: [0.5, 0.5],
3155
3255
  pos: [r * 0.5, i * 0.5],
3156
3256
  size: [r, i],
@@ -3160,7 +3260,7 @@ class je {
3160
3260
  return a.append(n), n;
3161
3261
  }
3162
3262
  enableCanvas2DReadback(e) {
3163
- this.readbackScheduler = new Ze({
3263
+ this.readbackScheduler = new tt({
3164
3264
  onReadbackError: (t) => this.opt.master.Logger.warn(
3165
3265
  `[Appliance]: [main-thread-readback] stage=failed viewId=${this.viewId} error=${t instanceof Error ? t.message : String(t)}`
3166
3266
  )
@@ -3198,7 +3298,7 @@ class je {
3198
3298
  }
3199
3299
  retargetCameraSettledRender(e) {
3200
3300
  var s;
3201
- if (!G(e)) return !1;
3301
+ if (!z(e)) return !1;
3202
3302
  const t = this.activeCameraSettledRender;
3203
3303
  return !t || t.cancelled || (s = t.context) != null && s.aborted ? !1 : (t.cameraTaskId = e, !0);
3204
3304
  }
@@ -3211,7 +3311,7 @@ class je {
3211
3311
  var e, t;
3212
3312
  this.destroyed || (this.destroyed = !0, this.disableCanvas2DReadback(), (t = (e = this.activeCameraTaskContext) == null ? void 0 : e.abort) == null || t.call(e), this.activeCameraTaskContext = void 0, this.mainThreadPostId !== void 0 && (cancelAnimationFrame(this.mainThreadPostId), this.mainThreadPostId = void 0), this.combinePostMsg.clear(), this.cancelCameraBlockingWait(), this.cancelCameraSettledRender(), this.debounceUpdateCache.clear(), this.clearCacheImages(), this.clearImageResolveMap(
3213
3313
  new Error(`main-thread view destroyed: ${this.viewId}`)
3214
- ), this.vNodes.clear(), Xe({
3314
+ ), this.vNodes.clear(), Je({
3215
3315
  subThreads: [this.localWork, this.serviceWork, this.topWork],
3216
3316
  layers: [
3217
3317
  this.fullLayer,
@@ -3220,11 +3320,11 @@ class je {
3220
3320
  this.serviceLayer
3221
3321
  ],
3222
3322
  scene: this.scene,
3223
- removeLayerTexture: (s, r) => z(s, r)
3323
+ removeLayerTexture: (s, r) => _(s, r)
3224
3324
  }));
3225
3325
  }
3226
3326
  }
3227
- class Je {
3327
+ class rt {
3228
3328
  constructor(e, t) {
3229
3329
  u(this, "viewId");
3230
3330
  u(this, "fullLayer");
@@ -3245,7 +3345,7 @@ class Je {
3245
3345
  container: t.container
3246
3346
  }), this.master = t.master, this.fullLayer = this.createLayer("fullLayer", this.scene, {
3247
3347
  ...t.layerOpt,
3248
- bufferSize: this.viewId === Q ? 6e3 : 3e3,
3348
+ bufferSize: this.viewId === X ? 6e3 : 3e3,
3249
3349
  contextType: "2d"
3250
3350
  });
3251
3351
  }
@@ -3370,18 +3470,22 @@ class Je {
3370
3470
  return;
3371
3471
  }
3372
3472
  case h.GetImageBitMap: {
3373
- if (s && (r || i) && o) {
3374
- const n = o.toString(), c = this.imageResolveMap.get(s);
3375
- if (!c || c.requestId !== a) {
3473
+ if (s && o) {
3474
+ const n = this.imageResolveMap.get(s);
3475
+ if (!n || n.requestId !== a) {
3376
3476
  this.closeImageSource(r || i);
3377
3477
  break;
3378
3478
  }
3379
- if (this.deleteCachedImagesByWorkId(n), this.cacheImages.set(s, {
3380
- imageSource: r || i,
3381
- workId: n
3382
- }), c) {
3383
- const { resolve: d, timer: l } = c;
3384
- l && clearTimeout(l), d && d(s);
3479
+ if (r || i) {
3480
+ const c = o.toString();
3481
+ this.deleteCachedImagesByWorkId(c), this.cacheImages.set(s, {
3482
+ imageSource: r || i,
3483
+ workId: c
3484
+ });
3485
+ }
3486
+ if (n) {
3487
+ const { resolve: c, timer: d } = n;
3488
+ d && clearTimeout(d), c && c(s);
3385
3489
  }
3386
3490
  }
3387
3491
  break;
@@ -3399,9 +3503,9 @@ class Je {
3399
3503
  if (!a || !n || !c || !d)
3400
3504
  return;
3401
3505
  let p = a;
3402
- if (n === pe.Iconify) {
3506
+ if (n === me.Iconify) {
3403
3507
  const [g, y] = this.getIconSize(c, d, this.opt.displayer.dpr);
3404
- p = ue(a, g, y, l);
3508
+ p = ye(a, g, y, l);
3405
3509
  }
3406
3510
  if (this.cacheImages.has(p)) {
3407
3511
  const g = this.getCachedImages(p);
@@ -3411,18 +3515,18 @@ class Je {
3411
3515
  const w = this.imageResolveMap.get(p);
3412
3516
  if (w)
3413
3517
  return await w.promise, this.getCachedImages(p);
3414
- let S;
3518
+ let k;
3415
3519
  const I = new Promise((g) => {
3416
- S = g;
3417
- }), W = {
3418
- resolve: S,
3520
+ k = g;
3521
+ }), E = {
3522
+ resolve: k,
3419
3523
  timer: void 0,
3420
3524
  requestId: i,
3421
3525
  promise: I
3422
3526
  };
3423
- return W.timer = setTimeout(() => {
3424
- this.imageResolveMap.get(p) === W && S(p);
3425
- }, 5e3), this.imageResolveMap.set(p, W), this.opt.post({
3527
+ return E.timer = setTimeout(() => {
3528
+ this.imageResolveMap.get(p) === E && k(p);
3529
+ }, 5e3), this.imageResolveMap.set(p, E), this.opt.post({
3426
3530
  viewId: this.viewId,
3427
3531
  viewGeneration: this.viewGeneration,
3428
3532
  viewOwner: this.viewOwner,
@@ -3437,11 +3541,11 @@ class Je {
3437
3541
  requestId: i
3438
3542
  }
3439
3543
  ]
3440
- }), await I, this.imageResolveMap.get(p) === W && this.imageResolveMap.delete(p), this.getCachedImages(p);
3544
+ }), await I, this.imageResolveMap.get(p) === E && this.imageResolveMap.delete(p), this.getCachedImages(p);
3441
3545
  }
3442
3546
  }
3443
3547
  createWorkShapeNode(e) {
3444
- return Z({
3548
+ return J({
3445
3549
  ...e,
3446
3550
  fullLayer: this.fullLayer,
3447
3551
  drawLayer: void 0
@@ -3461,7 +3565,7 @@ class Je {
3461
3565
  }
3462
3566
  async runFullWork(e) {
3463
3567
  var r;
3464
- const t = this.setFullWork(e), s = e.ops && V(e.ops);
3568
+ const t = this.setFullWork(e), s = e.ops && H(e.ops);
3465
3569
  if (t) {
3466
3570
  let i, o;
3467
3571
  const a = (r = t.getWorkId()) == null ? void 0 : r.toString();
@@ -3480,7 +3584,7 @@ class Je {
3480
3584
  op: s,
3481
3585
  isFullWork: !0,
3482
3586
  replaceId: a
3483
- }), o = (e == null ? void 0 : e.updateNodeOpt) && t.updataOptService(e.updateNodeOpt)), ne(i, o);
3587
+ }), o = (e == null ? void 0 : e.updateNodeOpt) && t.updataOptService(e.updateNodeOpt)), le(i, o);
3484
3588
  }
3485
3589
  }
3486
3590
  async getSnapshot(e) {
@@ -3556,7 +3660,7 @@ class Je {
3556
3660
  requestId: r
3557
3661
  }
3558
3662
  ]
3559
- }), this.fullLayer && !this.destroyed && $(this.fullLayer, this.fullLayer.parent);
3663
+ }), this.fullLayer && !this.destroyed && K(this.fullLayer, this.fullLayer.parent);
3560
3664
  }
3561
3665
  }
3562
3666
  async getBoundingRect(e) {
@@ -3578,7 +3682,7 @@ class Je {
3578
3682
  viewId: this.viewId,
3579
3683
  requestId: i
3580
3684
  });
3581
- o = ne(o, c);
3685
+ o = le(o, c);
3582
3686
  break;
3583
3687
  }
3584
3688
  }
@@ -3615,7 +3719,7 @@ class Je {
3615
3719
  for (const r of s.sp) {
3616
3720
  let i = !1;
3617
3721
  for (const o of e)
3618
- if (Be(r, o)) {
3722
+ if (Me(r, o)) {
3619
3723
  i = !0;
3620
3724
  break;
3621
3725
  }
@@ -3655,7 +3759,7 @@ class Je {
3655
3759
  this.releaseBatchImageBitmaps(e);
3656
3760
  }
3657
3761
  createScene(e) {
3658
- return new fe({
3762
+ return new we({
3659
3763
  displayRatio: this.opt.displayer.dpr,
3660
3764
  depth: !1,
3661
3765
  desynchronized: !0,
@@ -3665,7 +3769,7 @@ class Je {
3665
3769
  });
3666
3770
  }
3667
3771
  createLayer(e, t, s) {
3668
- const { width: r, height: i } = s, o = `canvas-${e}`, a = t.layer(o, s), n = new me({
3772
+ const { width: r, height: i } = s, o = `canvas-${e}`, a = t.layer(o, s), n = new ve({
3669
3773
  anchor: [0.5, 0.5],
3670
3774
  pos: [r * 0.5, i * 0.5],
3671
3775
  size: [r, i],
@@ -3719,7 +3823,7 @@ class Je {
3719
3823
  t.push(r);
3720
3824
  }
3721
3825
  try {
3722
- s && z(this.fullLayer, s);
3826
+ s && _(this.fullLayer, s);
3723
3827
  } catch (r) {
3724
3828
  t.push(r);
3725
3829
  }
@@ -3732,7 +3836,7 @@ class Je {
3732
3836
  throw t[0];
3733
3837
  }
3734
3838
  }
3735
- class ht {
3839
+ class ut {
3736
3840
  constructor(e) {
3737
3841
  u(this, "mainThreadMap", /* @__PURE__ */ new Map());
3738
3842
  u(this, "cameraRenderQueueByView", /* @__PURE__ */ new Map());
@@ -3767,8 +3871,8 @@ class ht {
3767
3871
  consumeCount: l,
3768
3872
  consumeWorkId: p
3769
3873
  } = e;
3770
- if (c && q(i)) {
3771
- const f = Oe(
3874
+ if (c && $(i)) {
3875
+ const f = Pe(
3772
3876
  o,
3773
3877
  a,
3774
3878
  "mainThread"
@@ -3780,11 +3884,11 @@ class ht {
3780
3884
  d
3781
3885
  ) : this.master.ackCameraTask(c, i, d);
3782
3886
  }
3783
- c && q(n) && this.master.ackCameraSettledTask(
3887
+ c && $(n) && this.master.ackCameraSettledTask(
3784
3888
  c,
3785
3889
  n,
3786
3890
  d
3787
- ), this.master.isBusy && q(r) && this.master.setWorkerTasksqueueCount(r), q(t) && this.master.setMaxDrawCount(t), q(l) && this.master.setConsumeCount(l, p), s && this.master.collectorSyncData(
3891
+ ), this.master.isBusy && $(r) && this.master.setWorkerTasksqueueCount(r), $(t) && this.master.setMaxDrawCount(t), $(l) && this.master.setConsumeCount(l, p), s && this.master.collectorSyncData(
3788
3892
  e.viewOwner === void 0 ? s : s.map(
3789
3893
  (f) => f.type === h.GetImageBitMap && f.viewOwner === void 0 ? { ...f, viewOwner: e.viewOwner } : f
3790
3894
  )
@@ -3798,7 +3902,7 @@ class ht {
3798
3902
  return this.cameraRenderQueueByView.set(e, r), r;
3799
3903
  }
3800
3904
  isStaleViewMessage(e) {
3801
- if (!e.viewId || e.viewId === ce || e.viewGeneration === void 0)
3905
+ if (!e.viewId || e.viewId === de || e.viewGeneration === void 0)
3802
3906
  return !1;
3803
3907
  const t = this.viewGenerationById.get(e.viewId);
3804
3908
  return t !== void 0 && e.viewGeneration < t;
@@ -3853,10 +3957,10 @@ class ht {
3853
3957
  );
3854
3958
  }
3855
3959
  createMainThread(e, t) {
3856
- return new je(e, t);
3960
+ return new st(e, t);
3857
3961
  }
3858
3962
  createSnapshotThread(e, t) {
3859
- return new Je(e, t);
3963
+ return new rt(e, t);
3860
3964
  }
3861
3965
  getSnapshotRequestKey(e) {
3862
3966
  return e.requestId || `${e.viewId}\0${e.scenePath || ""}\0${e.msgType}`;
@@ -3923,36 +4027,36 @@ class ht {
3923
4027
  if (o === h.Init) {
3924
4028
  const g = i.viewGeneration ?? (this.viewGenerationById.get(a) || 0) + 1;
3925
4029
  await this.enqueueViewTask(a, async () => {
3926
- var E, k, B;
4030
+ var A, W, v;
3927
4031
  const y = this.viewGenerationById.get(a);
3928
4032
  if (y !== void 0 && g < y)
3929
4033
  return;
3930
4034
  this.viewGenerationById.set(a, g);
3931
- const v = i.viewOwner || `${a}:${g}:${++this.ownerSequence}`, T = (E = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : E.displayer, C = T == null ? void 0 : T.canvasContainerRef.current;
4035
+ const S = i.viewOwner || `${a}:${g}:${++this.ownerSequence}`, T = (A = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : A.displayer, C = T == null ? void 0 : T.canvasContainerRef.current;
3932
4036
  if (!T || !C || !l || !p) {
3933
4037
  this.viewOwnerById.delete(a);
3934
4038
  return;
3935
4039
  }
3936
- this.viewOwnerById.set(a, v);
4040
+ this.viewOwnerById.set(a, S);
3937
4041
  const L = this.mainThreadMap.get(a);
3938
4042
  L == null || L.destroy();
3939
- const A = this.createMainThread(a, {
4043
+ const O = this.createMainThread(a, {
3940
4044
  displayer: T,
3941
4045
  container: C,
3942
4046
  layerOpt: l,
3943
4047
  master: this.master,
3944
4048
  canvasOpt: p,
3945
- viewOwner: v,
4049
+ viewOwner: S,
3946
4050
  viewGeneration: g,
3947
- mainThreadRenderMode: ((B = (k = this.master.control) == null ? void 0 : k.renderingCompatibilityDecision) == null ? void 0 : B.mainThreadRenderMode) ?? "normal",
3948
- post: (O) => this.post({
3949
- ...O,
3950
- viewId: O.viewId || a,
3951
- viewGeneration: O.viewGeneration ?? g,
3952
- viewOwner: v
4051
+ mainThreadRenderMode: ((v = (W = this.master.control) == null ? void 0 : W.renderingCompatibilityDecision) == null ? void 0 : v.mainThreadRenderMode) ?? "normal",
4052
+ post: (B) => this.post({
4053
+ ...B,
4054
+ viewId: B.viewId || a,
4055
+ viewGeneration: B.viewGeneration ?? g,
4056
+ viewOwner: S
3953
4057
  })
3954
4058
  });
3955
- this.mainThreadMap.set(a, A), A && f && A.setCameraOpt(f), this.post({
4059
+ this.mainThreadMap.set(a, O), O && f && O.setCameraOpt(f), this.post({
3956
4060
  sp: [
3957
4061
  {
3958
4062
  type: h.Init,
@@ -3965,40 +4069,40 @@ class ht {
3965
4069
  continue;
3966
4070
  }
3967
4071
  if (o === h.Snapshot || o === h.BoundingBox) {
3968
- const g = (t = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : t.displayer, y = (s = this.master.control.viewContainerManager.mainView) == null ? void 0 : s.displayer, v = (r = y == null ? void 0 : y.snapshotContainerRef) == null ? void 0 : r.current;
3969
- if (g && v && f) {
4072
+ const g = (t = this.master.control.viewContainerManager.getView(a)) == null ? void 0 : t.displayer, y = (s = this.master.control.viewContainerManager.mainView) == null ? void 0 : s.displayer, S = (r = y == null ? void 0 : y.snapshotContainerRef) == null ? void 0 : r.current;
4073
+ if (g && S && f) {
3970
4074
  const T = this.getSnapshotRequestKey(i), C = this.snapshotThreadsByRequest.get(T);
3971
4075
  C && this.disposeSnapshotThread(T, C.thread, "replaced");
3972
4076
  const L = document.createElement("div");
3973
- L.style.width = `${f.width}px`, L.style.height = `${f.height}px`, v.append(L);
3974
- const A = {
3975
- ...he.defaultLayerOpt,
4077
+ L.style.width = `${f.width}px`, L.style.height = `${f.height}px`, S.append(L);
4078
+ const O = {
4079
+ ...pe.defaultLayerOpt,
3976
4080
  offscreen: !1,
3977
4081
  width: f.width,
3978
4082
  height: f.height
3979
- }, E = {
3980
- ...he.defaultScreenCanvasOpt,
4083
+ }, A = {
4084
+ ...pe.defaultScreenCanvasOpt,
3981
4085
  width: f.width,
3982
4086
  height: f.height
3983
- }, k = this.createSnapshotThread(a, {
4087
+ }, W = this.createSnapshotThread(a, {
3984
4088
  displayer: g,
3985
4089
  container: L,
3986
- layerOpt: A,
4090
+ layerOpt: O,
3987
4091
  master: this.master,
3988
- canvasOpt: E,
4092
+ canvasOpt: A,
3989
4093
  post: this.post,
3990
4094
  viewOwner: this.viewOwnerById.get(a),
3991
4095
  viewGeneration: this.viewGenerationById.get(a)
3992
4096
  });
3993
4097
  this.snapshotThreadsByRequest.set(T, {
3994
- thread: k,
4098
+ thread: W,
3995
4099
  surface: L
3996
- }), k.on(i).then(() => {
3997
- this.disposeSnapshotThread(T, k);
3998
- }).catch((B) => {
4100
+ }), W.on(i).then(() => {
4101
+ this.disposeSnapshotThread(T, W);
4102
+ }).catch((v) => {
3999
4103
  this.master.Logger.error(
4000
- `[Appliance]: snapshot render failed; viewId=${a}; error=${B instanceof Error ? B.message : String(B)}`
4001
- ), this.disposeSnapshotThread(T, k);
4104
+ `[Appliance]: snapshot render failed; viewId=${a}; error=${v instanceof Error ? v.message : String(v)}`
4105
+ ), this.disposeSnapshotThread(T, W);
4002
4106
  });
4003
4107
  continue;
4004
4108
  }
@@ -4029,8 +4133,8 @@ class ht {
4029
4133
  continue;
4030
4134
  }
4031
4135
  if (o === h.GetImageBitMap) {
4032
- const g = this.mainThreadMap.get(a), y = this.viewGenerationById.get(a), v = this.viewOwnerById.get(a);
4033
- if (!g || i.viewGeneration !== void 0 && i.viewGeneration !== y || i.viewOwner !== void 0 && i.viewOwner !== v || this.mainThreadMap.get(a) !== g) {
4136
+ const g = this.mainThreadMap.get(a), y = this.viewGenerationById.get(a), S = this.viewOwnerById.get(a);
4137
+ if (!g || i.viewGeneration !== void 0 && i.viewGeneration !== y || i.viewOwner !== void 0 && i.viewOwner !== S || this.mainThreadMap.get(a) !== g) {
4034
4138
  this.releaseMessageBitmap(i);
4035
4139
  continue;
4036
4140
  }
@@ -4038,30 +4142,30 @@ class ht {
4038
4142
  continue;
4039
4143
  }
4040
4144
  if (o === h.TasksQueue && (n != null && n.size)) {
4041
- const g = n.get(a), y = this.mainThreadMap.get(a), v = this.viewGenerationById.get(a), T = this.viewOwnerById.get(a);
4145
+ const g = n.get(a), y = this.mainThreadMap.get(a), S = this.viewGenerationById.get(a), T = this.viewOwnerById.get(a);
4042
4146
  let C;
4043
4147
  if (g && y)
4044
4148
  try {
4045
4149
  await this.enqueueViewTask(a, async () => {
4046
- this.viewGenerationById.get(a) !== v || this.viewOwnerById.get(a) !== T || this.mainThreadMap.get(a) !== y || await y.on(g);
4150
+ this.viewGenerationById.get(a) !== S || this.viewOwnerById.get(a) !== T || this.mainThreadMap.get(a) !== y || await y.on(g);
4047
4151
  });
4048
4152
  } catch (L) {
4049
4153
  if (g.msgType !== h.UpdateCamera) throw L;
4050
- const A = De(L);
4154
+ const O = Ae(L);
4051
4155
  C = {
4052
- code: A ? "RENDERER_BUSINESS_TIMEOUT" : "RENDERER_BUSINESS_ERROR",
4156
+ code: O ? "RENDERER_BUSINESS_TIMEOUT" : "RENDERER_BUSINESS_ERROR",
4053
4157
  business: "updateCamera",
4054
4158
  message: L instanceof Error ? L.message : String(L),
4055
- elapsedMs: A ? L.elapsedMs : void 0,
4056
- stage: A ? L.stage : "update-camera",
4057
- blockingWorks: A ? L.blockingWorks : void 0,
4159
+ elapsedMs: O ? L.elapsedMs : void 0,
4160
+ stage: O ? L.stage : "update-camera",
4161
+ blockingWorks: O ? L.blockingWorks : void 0,
4058
4162
  workerType: "mainThread"
4059
4163
  };
4060
4164
  }
4061
- if (C && q(d)) {
4165
+ if (C && $(d)) {
4062
4166
  this.post({
4063
4167
  viewId: a,
4064
- viewGeneration: v,
4168
+ viewGeneration: S,
4065
4169
  viewOwner: T,
4066
4170
  cameraTaskId: d,
4067
4171
  cameraTaskStatus: C.code === "RENDERER_BUSINESS_TIMEOUT" ? "timeout" : "failed",
@@ -4069,30 +4173,30 @@ class ht {
4069
4173
  });
4070
4174
  continue;
4071
4175
  }
4072
- c && q(d) && this.post({
4176
+ c && $(d) && this.post({
4073
4177
  workerTasksqueueCount: c,
4074
4178
  cameraTaskId: d,
4075
4179
  viewId: a,
4076
- viewGeneration: v,
4180
+ viewGeneration: S,
4077
4181
  viewOwner: T
4078
4182
  });
4079
4183
  continue;
4080
4184
  }
4081
- if (a === ce) {
4185
+ if (a === de) {
4082
4186
  const g = [...this.mainThreadMap.entries()];
4083
- for (const [y, v] of g) {
4187
+ for (const [y, S] of g) {
4084
4188
  const T = this.enqueueViewTask(y, async () => {
4085
- this.mainThreadMap.get(y) === v && (o === h.Destroy ? (v.destroy(), this.mainThreadMap.delete(y), this.viewOwnerById.delete(y), this.viewGenerationById.set(
4189
+ this.mainThreadMap.get(y) === S && (o === h.Destroy ? (S.destroy(), this.mainThreadMap.delete(y), this.viewOwnerById.delete(y), this.viewGenerationById.set(
4086
4190
  y,
4087
4191
  (this.viewGenerationById.get(y) || 0) + 1
4088
- )) : await v.on(i));
4192
+ )) : await S.on(i));
4089
4193
  });
4090
4194
  await T, this.cameraRenderQueueByView.get(y) === T && this.cameraRenderQueueByView.delete(y);
4091
4195
  }
4092
4196
  continue;
4093
4197
  }
4094
- const S = this.mainThreadMap.get(a);
4095
- if (o === h.Destroy && !S) {
4198
+ const k = this.mainThreadMap.get(a);
4199
+ if (o === h.Destroy && !k) {
4096
4200
  await this.enqueueViewTask(a, async () => {
4097
4201
  this.viewGenerationById.set(
4098
4202
  a,
@@ -4101,12 +4205,12 @@ class ht {
4101
4205
  });
4102
4206
  continue;
4103
4207
  }
4104
- if (!S)
4208
+ if (!k)
4105
4209
  continue;
4106
- const I = this.viewGenerationById.get(a), W = this.enqueueViewTask(a, async () => {
4107
- this.viewGenerationById.get(a) !== I || this.mainThreadMap.get(a) !== S || await S.on(i);
4210
+ const I = this.viewGenerationById.get(a), E = this.enqueueViewTask(a, async () => {
4211
+ this.viewGenerationById.get(a) !== I || this.mainThreadMap.get(a) !== k || await k.on(i);
4108
4212
  });
4109
- o === h.Destroy && (await W, this.mainThreadMap.get(a) === S && this.mainThreadMap.delete(a), this.viewOwnerById.delete(a), this.cameraRenderQueueByView.get(a) === W && this.cameraRenderQueueByView.delete(a), this.viewGenerationById.set(
4213
+ o === h.Destroy && (await E, this.mainThreadMap.get(a) === k && this.mainThreadMap.delete(a), this.viewOwnerById.delete(a), this.cameraRenderQueueByView.get(a) === E && this.cameraRenderQueueByView.delete(a), this.viewGenerationById.set(
4110
4214
  a,
4111
4215
  i.viewGeneration ?? (I || 0) + 1
4112
4216
  ));
@@ -4114,5 +4218,5 @@ class ht {
4114
4218
  }
4115
4219
  }
4116
4220
  export {
4117
- ht as MainThreadManagerImpl
4221
+ ut as MainThreadManagerImpl
4118
4222
  };