@netless/appliance-plugin 1.1.40 → 1.1.42-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +31 -0
  2. package/dist/appliance-plugin.js +1 -1
  3. package/dist/appliance-plugin.mjs +17 -16
  4. package/dist/{bridge-b23MKtwT.mjs → bridge-B-QptMEy.mjs} +1 -1
  5. package/dist/{bridge-DLEmhE7Y.js → bridge-hRl_DY0c.js} +1 -1
  6. package/dist/bridge.js +1 -1
  7. package/dist/bridge.mjs +1 -1
  8. package/dist/component/backgroundImageLoadCoordinator.d.ts +61 -0
  9. package/dist/component/svg/base.d.ts +2 -0
  10. package/dist/component/svg/svgElemt.d.ts +3 -1
  11. package/dist/component/svg/types.d.ts +2 -0
  12. package/dist/component/textEditor/types.d.ts +2 -0
  13. package/dist/core/currentSceneGuard.d.ts +6 -0
  14. package/dist/core/initReadyBarrier.d.ts +8 -0
  15. package/dist/core/mainEngine.d.ts +4 -2
  16. package/dist/core/mainThread/base.d.ts +3 -3
  17. package/dist/core/mainThread/snapshotThread.d.ts +3 -3
  18. package/dist/core/mainThread/subLocalThread.d.ts +1 -1
  19. package/dist/core/mainThread/subServiceThread.d.ts +1 -1
  20. package/dist/fullWorker.js +85 -85
  21. package/dist/{index-rhSRO8Tb.mjs → index-1g93HWeU.mjs} +9106 -8749
  22. package/dist/{index-CDDMgpaL.js → index-B0MSTcdT.js} +1 -1
  23. package/dist/index-BpRy_vjc.js +570 -0
  24. package/dist/index-BtNb2M5H.js +1 -0
  25. package/dist/{index-WifS74pI.mjs → index-BwbqPE3q.mjs} +234 -210
  26. package/dist/{index-pyv2KvXa.mjs → index-C3e6mT0j.mjs} +221 -201
  27. package/dist/{index-BSR23bx5.mjs → index-CCO-qEim.mjs} +1 -1
  28. package/dist/{index-CDbcv4B7.js → index-CgEdhx54.js} +1 -1
  29. package/dist/index-CgJv1Exy.js +570 -0
  30. package/dist/{index-GpA_9BZu.mjs → index-DJS3KHjE.mjs} +12695 -12377
  31. package/dist/{index-C3XOupI-.mjs → index-DUVQmCiI.mjs} +1 -1
  32. package/dist/index-vIt18mo2.js +1 -0
  33. package/dist/plugin/applianceMultiPlugin.d.ts +1 -1
  34. package/dist/plugin/applianceSinglePlugin.d.ts +1 -1
  35. package/dist/plugin/backgroundImageQuery.d.ts +4 -0
  36. package/dist/plugin/baseApplianceManager.d.ts +7 -3
  37. package/dist/plugin/renderingCompatibility.d.ts +2 -1
  38. package/dist/plugin/types.d.ts +35 -2
  39. package/dist/subWorker.js +61 -61
  40. package/package.json +9 -4
  41. package/dist/index-DKaa5HSe.js +0 -1
  42. package/dist/index-DoIyQYzA.js +0 -570
  43. package/dist/index-DwW4gzgA.js +0 -1
  44. package/dist/index-RKd-OVPO.js +0 -570
@@ -1,9 +1,8 @@
1
- var E = Object.defineProperty;
2
- var B = (o, e, t) => e in o ? E(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var h = (o, e, t) => B(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { E as I, a as d, b as C, c as y, d as M, O as x, V as N, S as A } from "./index-GpA_9BZu.mjs";
5
- import { isEqual as T, isString as V, clone as D, throttle as H } from "lodash";
6
- import "white-web-sdk";
1
+ var F = Object.defineProperty;
2
+ var E = (n, e, t) => e in n ? F(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var h = (n, e, t) => E(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { E as T, a as d, b as L, c as k, d as M, g as b, O as A, V as N, S as x } from "./index-DJS3KHjE.mjs";
5
+ import { isEqual as I, isString as V, clone as U, throttle as D } from "lodash";
7
6
  import "clipper-lib";
8
7
  import "lz-string";
9
8
  import "lineclip";
@@ -11,7 +10,6 @@ import "xss";
11
10
  import "rbush";
12
11
  import "react-dom";
13
12
  import "react";
14
- import { g as b } from "./markmap-runtime-Cg3OxuZ2.mjs";
15
13
  class R {
16
14
  constructor() {
17
15
  h(this, "threadEngine");
@@ -20,31 +18,31 @@ class R {
20
18
  return this.threadEngine = e, this;
21
19
  }
22
20
  }
23
- class U extends R {
21
+ class H extends R {
24
22
  constructor() {
25
23
  super(...arguments);
26
- h(this, "emitEventType", I.CopyNode);
24
+ h(this, "emitEventType", T.CopyNode);
27
25
  }
28
26
  async consume(t) {
29
- const { msgType: s, dataType: a, emitEventType: r } = t;
30
- if (s === d.FullWork && a === C.Local && r === this.emitEventType)
27
+ const { msgType: s, dataType: r, emitEventType: a } = t;
28
+ if (s === d.FullWork && r === L.Local && a === this.emitEventType)
31
29
  return this.consumeForLocalWorker(t), !0;
32
30
  }
33
31
  async consumeForLocalWorker(t) {
34
- var a;
32
+ var r;
35
33
  const { workId: s } = t;
36
- s && await ((a = this.threadEngine) == null ? void 0 : a.consumeFull(t));
34
+ s && await ((r = this.threadEngine) == null ? void 0 : r.consumeFull(t));
37
35
  }
38
36
  }
39
- class _ {
37
+ class q {
40
38
  constructor(e) {
41
39
  h(this, "builders", /* @__PURE__ */ new Map());
42
40
  this.builders = new Map(e.map((t) => [t, this.build(t)]));
43
41
  }
44
42
  build(e) {
45
43
  switch (e) {
46
- case I.CopyNode:
47
- return new U();
44
+ case T.CopyNode:
45
+ return new H();
48
46
  }
49
47
  }
50
48
  registerForBackgroundThread(e) {
@@ -59,120 +57,120 @@ class _ {
59
57
  return !1;
60
58
  }
61
59
  }
62
- async function q(o) {
63
- const e = o.querySelectorAll("img"), t = Array.from(e).map((r) => {
64
- if (!r.crossOrigin && r.src && !r.src.startsWith("data:") && (r.crossOrigin = "anonymous", r.complete)) {
65
- const i = r.src;
66
- r.src = "", r.src = i;
60
+ async function _(n) {
61
+ const e = n.querySelectorAll("img"), t = Array.from(e).map((a) => {
62
+ if (!a.crossOrigin && a.src && !a.src.startsWith("data:") && (a.crossOrigin = "anonymous", a.complete)) {
63
+ const i = a.src;
64
+ a.src = "", a.src = i;
67
65
  }
68
- return r.complete && r.crossOrigin ? Promise.resolve() : new Promise((i) => {
69
- r.onload = () => {
66
+ return a.complete && a.crossOrigin ? Promise.resolve() : new Promise((i) => {
67
+ a.onload = () => {
70
68
  i(void 0);
71
- }, r.onerror = () => {
69
+ }, a.onerror = () => {
72
70
  i(void 0);
73
71
  };
74
72
  });
75
73
  });
76
- return o.querySelectorAll("svg").forEach((r) => {
77
- r.querySelectorAll("image").forEach((n) => {
78
- n.href && !n.href.baseVal.startsWith("data:") && (n.getAttribute("crossorigin") || n.setAttribute("crossorigin", "anonymous"), t.push(
74
+ return n.querySelectorAll("svg").forEach((a) => {
75
+ a.querySelectorAll("image").forEach((o) => {
76
+ o.href && !o.href.baseVal.startsWith("data:") && (o.getAttribute("crossorigin") || o.setAttribute("crossorigin", "anonymous"), t.push(
79
77
  new Promise((c) => {
80
78
  const l = new Image();
81
79
  l.crossOrigin = "anonymous", l.onload = () => {
82
80
  c(void 0);
83
81
  }, l.onerror = () => {
84
82
  c(void 0);
85
- }, l.src = n.href.baseVal;
83
+ }, l.src = o.href.baseVal;
86
84
  })
87
85
  ));
88
86
  });
89
87
  }), await Promise.all(t);
90
88
  }
91
- async function $(o) {
89
+ async function $(n) {
92
90
  const s = Date.now();
93
- let a = !1;
91
+ let r = !1;
94
92
  for (; Date.now() - s < 5e3; ) {
95
- const r = o.querySelectorAll("path");
96
- if (r.length > 0 && (a = Array.from(r).some((i) => {
97
- const n = i.getAttribute("d") || "";
98
- return n !== "M0,0C0,0,0,0,0,0" && n.length > 10;
99
- }), a))
93
+ const a = n.querySelectorAll("path");
94
+ if (a.length > 0 && (r = Array.from(a).some((i) => {
95
+ const o = i.getAttribute("d") || "";
96
+ return o !== "M0,0C0,0,0,0,0,0" && o.length > 10;
97
+ }), r))
100
98
  break;
101
99
  await new Promise((i) => setTimeout(i, 50));
102
100
  }
103
101
  }
104
- async function z(o) {
105
- const e = o.querySelectorAll("svg");
102
+ async function z(n) {
103
+ const e = n.querySelectorAll("svg");
106
104
  if (!e.length)
107
105
  return;
108
106
  const t = [];
109
107
  for (let s = 0; s < e.length; s++) {
110
- const a = e[s];
111
- t.push($(a));
108
+ const r = e[s];
109
+ t.push($(r));
112
110
  }
113
111
  await Promise.all(t);
114
112
  }
115
- async function L(o) {
116
- if (o.querySelectorAll("svg[data-type='mermaid']").length > 0) {
113
+ async function P(n) {
114
+ if (n.querySelectorAll("svg[data-type='mermaid']").length > 0) {
117
115
  const s = Date.now();
118
- let a = !1;
119
- for (; Date.now() - s < 5e3 && !a; ) {
120
- const r = o.querySelectorAll("foreignObject");
121
- if (r.length > 0) {
116
+ let r = !1;
117
+ for (; Date.now() - s < 5e3 && !r; ) {
118
+ const a = n.querySelectorAll("foreignObject");
119
+ if (a.length > 0) {
122
120
  let i = !0;
123
- for (const n of Array.from(r)) {
124
- const c = parseFloat(n.getAttribute("width") || "0"), l = parseFloat(n.getAttribute("height") || "0");
125
- if (n.querySelector(".mermaid-container") && (c < 50 || l < 50)) {
121
+ for (const o of Array.from(a)) {
122
+ const c = parseFloat(o.getAttribute("width") || "0"), l = parseFloat(o.getAttribute("height") || "0");
123
+ if (o.querySelector(".mermaid-container") && (c < 50 || l < 50)) {
126
124
  i = !1;
127
125
  break;
128
126
  }
129
127
  }
130
128
  if (i) {
131
- a = !0;
129
+ r = !0;
132
130
  break;
133
131
  }
134
132
  } else
135
- a = !0;
133
+ r = !0;
136
134
  await new Promise((i) => setTimeout(i, 50));
137
135
  }
138
136
  }
139
137
  }
140
- async function G(o, e = {}) {
141
- const { width: t = o.offsetWidth, height: s = o.offsetHeight } = e, a = o.offsetWidth || t, r = o.offsetHeight || s;
138
+ async function G(n, e = {}) {
139
+ const { width: t = n.offsetWidth, height: s = n.offsetHeight } = e, r = n.offsetWidth || t, a = n.offsetHeight || s;
142
140
  try {
143
- const { loadSvgToImageLib: i, getSvgToImageLib: n } = await import("./svgToImageLoader-DZz5bAo4.mjs");
144
- let c = n();
141
+ const { loadSvgToImageLib: i, getSvgToImageLib: o } = await import("./svgToImageLoader-DZz5bAo4.mjs");
142
+ let c = o();
145
143
  if (!c)
146
144
  try {
147
145
  c = await i();
148
146
  } catch (w) {
149
147
  return console.error("[loadSvgToImageLib] error: ", w), null;
150
148
  }
151
- const l = o.style.width, m = o.style.height, k = o.style.display;
152
- o.style.width || (o.style.width = `${a}px`), o.style.height || (o.style.height = `${r}px`), (!o.style.display || o.style.display === "none") && (o.style.display = "block");
149
+ const l = n.style.width, p = n.style.height, y = n.style.display;
150
+ n.style.width || (n.style.width = `${r}px`), n.style.height || (n.style.height = `${a}px`), (!n.style.display || n.style.display === "none") && (n.style.display = "block");
153
151
  try {
154
- await new Promise((p) => {
152
+ await new Promise((m) => {
155
153
  requestAnimationFrame(() => {
156
154
  requestAnimationFrame(() => {
157
- p();
155
+ m();
158
156
  });
159
157
  });
160
158
  });
161
- const w = await c.toPng(o, {
162
- width: a,
163
- height: r,
159
+ const w = await c.toPng(n, {
160
+ width: r,
161
+ height: a,
164
162
  quality: 1
165
163
  });
166
- return o.style.width = l, o.style.height = m, o.style.display = k, new Promise((p) => {
164
+ return n.style.width = l, n.style.height = p, n.style.display = y, new Promise((m) => {
167
165
  const u = new Image();
168
166
  u.crossOrigin = "anonymous", u.onload = () => {
169
- p(u);
167
+ m(u);
170
168
  }, u.onerror = () => {
171
- p(null);
169
+ m(null);
172
170
  }, u.src = w;
173
171
  });
174
172
  } catch (w) {
175
- return o.style.width = l, o.style.height = m, o.style.display = k, console.error("[divToImageElement] error: ", w), null;
173
+ return n.style.width = l, n.style.height = p, n.style.display = y, console.error("[divToImageElement] error: ", w), null;
176
174
  }
177
175
  } catch (i) {
178
176
  return console.error("[divToImageElement] error: ", i), null;
@@ -180,7 +178,7 @@ async function G(o, e = {}) {
180
178
  }
181
179
  class X {
182
180
  constructor(e) {
183
- h(this, "toolsType", y.BackgroundSVG);
181
+ h(this, "toolsType", k.BackgroundSVG);
184
182
  h(this, "vNodes");
185
183
  h(this, "workOptions");
186
184
  h(this, "workId");
@@ -188,8 +186,18 @@ class X {
188
186
  h(this, "isDestroyed", !1);
189
187
  h(this, "element");
190
188
  h(this, "manager");
191
- const { vNodes: t, workId: s, toolsOpt: a, manager: r } = e;
192
- this.workId = s, this.vNodes = t, this.workOptions = a, this.manager = r, this.element = this.createElement(), this.manager.fullLayer.appendChild(this.element), this.vNodes.setInfo(this.workId, {
189
+ h(this, "scenePath");
190
+ h(this, "trackBackgroundImageLoad");
191
+ h(this, "reloadSourceUrl");
192
+ const {
193
+ vNodes: t,
194
+ workId: s,
195
+ toolsOpt: r,
196
+ manager: a,
197
+ scenePath: i,
198
+ trackBackgroundImageLoad: o = !0
199
+ } = e;
200
+ this.workId = s, this.vNodes = t, this.workOptions = r, this.manager = a, this.scenePath = i, this.trackBackgroundImageLoad = o, this.element = this.createElement(), this.manager.fullLayer.appendChild(this.element), this.vNodes.setInfo(this.workId, {
193
201
  workShape: this
194
202
  });
195
203
  }
@@ -199,11 +207,6 @@ class X {
199
207
  get collector() {
200
208
  return this.manager.master.control.collector;
201
209
  }
202
- get scenePath() {
203
- return this.manager.master.control.viewContainerManager.getCurScenePath(
204
- this.manager.viewId
205
- );
206
- }
207
210
  async init() {
208
211
  await this.render();
209
212
  }
@@ -216,12 +219,12 @@ class X {
216
219
  this.isDestroyed || !this.element || !this.element.parentNode || (this.updateElementPosition(e), await this.updateSvg(e));
217
220
  }
218
221
  isSameSize(e) {
219
- const { width: t, height: s } = e, { width: a, height: r } = this.workOptions, i = t * this.manager.camera.scale, n = s * this.manager.camera.scale, c = a * this.manager.camera.scale, l = r * this.manager.camera.scale;
220
- return i === c && n === l;
222
+ const { width: t, height: s } = e, { width: r, height: a } = this.workOptions, i = t * this.manager.camera.scale, o = s * this.manager.camera.scale, c = r * this.manager.camera.scale, l = a * this.manager.camera.scale;
223
+ return i === c && o === l;
221
224
  }
222
225
  isSamePosition(e) {
223
- const { centerX: t, centerY: s } = e, { centerX: a, centerY: r } = this.workOptions, i = this.manager.getPagePoint(a, r), n = this.manager.getPagePoint(t, s);
224
- return T(n, i);
226
+ const { centerX: t, centerY: s } = e, { centerX: r, centerY: a } = this.workOptions, i = this.manager.getPagePoint(r, a), o = this.manager.getPagePoint(t, s);
227
+ return I(o, i);
225
228
  }
226
229
  isSameZIndex(e) {
227
230
  const { zIndex: t } = e, { zIndex: s } = this.workOptions;
@@ -229,36 +232,36 @@ class X {
229
232
  }
230
233
  isSameState(e) {
231
234
  const { state: t } = e, { state: s } = this.workOptions;
232
- return T(t, s);
235
+ return I(t, s);
233
236
  }
234
237
  isSameData(e) {
235
238
  const { data: t } = e, { data: s } = this.workOptions;
236
- return T(t, s);
239
+ return I(t, s);
237
240
  }
238
241
  updateElementPosition(e) {
239
242
  if (this.isDestroyed || !this.element || !this.fullLayer)
240
243
  return;
241
- const { centerX: t, centerY: s, width: a, height: r, zIndex: i } = this.workOptions, n = this.manager.getPagePoint(t, s), c = a * this.manager.camera.scale, l = r * this.manager.camera.scale;
242
- (!e || e && !this.isSameSize(e)) && (this.element.setAttribute("width", `${c}`), this.element.setAttribute("height", `${l}`), this.element.style.width = `${c}px`, this.element.style.height = `${l}px`), (!e || e && !this.isSamePosition(e)) && (this.element.style.left = `${n.x}px`, this.element.style.top = `${n.y}px`), (!e || e && !this.isSameZIndex(e)) && (this.element.style.zIndex = (i || 0).toString());
244
+ const { centerX: t, centerY: s, width: r, height: a, zIndex: i } = this.workOptions, o = this.manager.getPagePoint(t, s), c = r * this.manager.camera.scale, l = a * this.manager.camera.scale;
245
+ (!e || e && !this.isSameSize(e)) && (this.element.setAttribute("width", `${c}`), this.element.setAttribute("height", `${l}`), this.element.style.width = `${c}px`, this.element.style.height = `${l}px`), (!e || e && !this.isSamePosition(e)) && (this.element.style.left = `${o.x}px`, this.element.style.top = `${o.y}px`), (!e || e && !this.isSameZIndex(e)) && (this.element.style.zIndex = (i || 0).toString());
243
246
  }
244
247
  async updateSvg(e) {
245
248
  const { type: t, state: s } = this.workOptions;
246
249
  if (t === M.markmap) {
247
- const a = b(), { data: r } = this.workOptions;
248
- if (this.markmapInstance || (this.markmapInstance = a.createMarkmap(
250
+ const r = b(), { data: a } = this.workOptions;
251
+ if (this.markmapInstance || (this.markmapInstance = r.createMarkmap(
249
252
  this.element,
250
253
  this.manager.markmapOptions
251
254
  ), this.markmapInstance.handleClick = async (c, l) => {
252
- var w, p, u;
255
+ var w, m, u;
253
256
  (w = this.markmapInstance) == null || w.toggleNode(l);
254
- const m = this.serializeData((p = this.markmapInstance) == null ? void 0 : p.state.data);
257
+ const p = this.serializeData((m = this.markmapInstance) == null ? void 0 : m.state.data);
255
258
  this.setWorkOptions(
256
259
  {
257
260
  ...this.workOptions,
258
- state: m
261
+ state: p
259
262
  },
260
263
  !1
261
- ), a.checkNodeHasMermaid(l) && await a.renderMermaidAfterDOMUpdate(
264
+ ), r.checkNodeHasMermaid(l) && await r.renderMermaidAfterDOMUpdate(
262
265
  this.element,
263
266
  this.workId
264
267
  ), this.scenePath && this.collector && ((u = this.collector) == null || u.dispatch({
@@ -271,11 +274,11 @@ class X {
271
274
  }));
272
275
  }), e && this.isSameState(e) && this.isSameSize(e) && this.isSameData(e))
273
276
  return;
274
- const i = a.transform(this.workId, r);
275
- let { root: n } = i;
276
- r && a.hasMermaidCodeBlock(r) && (n = a.injectMermaidHtml(n, r, this.workId));
277
+ const i = r.transform(this.workId, a);
278
+ let { root: o } = i;
279
+ a && r.hasMermaidCodeBlock(a) && (o = r.injectMermaidHtml(o, a, this.workId));
277
280
  try {
278
- s && Array.isArray(s) && this.transformState(s, n), await this.markmapInstance.setData(n), !this.isDestroyed && this.element && this.fullLayer && this.markmapInstance && (window.markmapInstance = this.markmapInstance, r && a.hasMermaidCodeBlock(r) && await a.renderMermaidAfterDOMUpdate(
281
+ s && Array.isArray(s) && this.transformState(s, o), await this.markmapInstance.setData(o), !this.isDestroyed && this.element && this.fullLayer && this.markmapInstance && (window.markmapInstance = this.markmapInstance, a && r.hasMermaidCodeBlock(a) && await r.renderMermaidAfterDOMUpdate(
279
282
  this.element,
280
283
  this.workId
281
284
  ), await this.fit(
@@ -285,19 +288,26 @@ class X {
285
288
  console.error("[updateSvg] error: ", c);
286
289
  }
287
290
  } else {
288
- const { src: a, crossOrigin: r } = this.workOptions;
289
- this.element.src = a, this.element.crossOrigin = V(r) ? r : "anonymous";
290
- try {
291
- await new Promise((i, n) => {
292
- this.element.onload = () => {
293
- i();
294
- }, this.element.onerror = function() {
295
- n();
296
- };
291
+ const { src: r, crossOrigin: a } = this.workOptions, i = this.reloadSourceUrl ?? r;
292
+ if (this.element.crossOrigin = V(a) ? a : "anonymous", !this.trackBackgroundImageLoad) {
293
+ this.element.src = i, await new Promise((o, c) => {
294
+ this.element.onload = () => o(), this.element.onerror = () => c();
297
295
  });
298
- } catch (i) {
299
- console.error("[updateSvg] error: ", i);
296
+ return;
300
297
  }
298
+ await this.manager.master.control.backgroundImageLoadCoordinator.load({
299
+ viewId: this.manager.viewId,
300
+ scenePath: this.scenePath,
301
+ resourceId: this.workId,
302
+ src: i,
303
+ image: this.element,
304
+ isActive: () => !this.isDestroyed && this.manager.master.control.viewContainerManager.getCurScenePath(
305
+ this.manager.viewId
306
+ ) === this.scenePath,
307
+ onReloadUrl: (o) => {
308
+ this.reloadSourceUrl = o;
309
+ }
310
+ });
301
311
  }
302
312
  }
303
313
  async fit(e = !0) {
@@ -306,38 +316,42 @@ class X {
306
316
  const s = b();
307
317
  e && this.element && await s.waitForImagesInForeignObjects(
308
318
  this.element
309
- ), await ((t = this.markmapInstance) == null ? void 0 : t.fit()), this.element && s.isSafari() && s.hasMermaidSvg(this.element) && (await L(this.element), await s.transformMermaidSvgToMarkmapSvg(
319
+ ), await ((t = this.markmapInstance) == null ? void 0 : t.fit()), this.element && s.isSafari() && s.hasMermaidSvg(this.element) && (await P(this.element), await s.transformMermaidSvgToMarkmapSvg(
310
320
  this.element
311
321
  ));
312
322
  }
313
323
  }
314
324
  serializeData(e) {
315
- var a;
325
+ var r;
316
326
  const t = [e], s = [];
317
327
  for (; t.length > 0; ) {
318
- const r = t.pop();
319
- r && (r != null && r.children && t.push(...r.children), s.push(((a = r == null ? void 0 : r.payload) == null ? void 0 : a.fold) || 0));
328
+ const a = t.pop();
329
+ a && (a != null && a.children && t.push(...a.children), s.push(((r = a == null ? void 0 : a.payload) == null ? void 0 : r.fold) || 0));
320
330
  }
321
331
  return s;
322
332
  }
323
333
  transformState(e, t) {
324
334
  const s = [t];
325
335
  for (; s.length > 0; ) {
326
- const a = s.pop();
327
- a && (a != null && a.children && s.push(...a.children), a.payload ? a.payload.fold = e.shift() : e.shift());
336
+ const r = s.pop();
337
+ r && (r != null && r.children && s.push(...r.children), r.payload ? r.payload.fold = e.shift() : e.shift());
328
338
  }
329
339
  }
330
340
  async updateCamera() {
331
341
  this.updateElementPosition(), await this.fit(!1);
332
342
  }
333
343
  async setWorkOptions(e, t = !0) {
334
- if (!T(this.workOptions, e)) {
335
- const s = D(this.workOptions);
336
- this.workOptions = e, t && await this.render(s);
344
+ if (!I(this.workOptions, e)) {
345
+ const s = U(this.workOptions), r = "src" in this.workOptions ? this.workOptions.src : void 0, a = "src" in e ? e.src : void 0;
346
+ r !== a && (this.reloadSourceUrl = void 0), this.workOptions = e, t && await this.render(s);
337
347
  }
338
348
  }
339
349
  destroy() {
340
- this.isDestroyed = !0, this.element.remove();
350
+ this.isDestroyed = !0, this.reloadSourceUrl = void 0, this.trackBackgroundImageLoad && this.manager.master.control.backgroundImageLoadCoordinator.cancelResource(
351
+ this.manager.viewId,
352
+ this.scenePath,
353
+ this.workId
354
+ ), this.element.remove();
341
355
  }
342
356
  getRectFromLayer() {
343
357
  const e = this.element.getBoundingClientRect();
@@ -349,21 +363,21 @@ class X {
349
363
  };
350
364
  }
351
365
  }
352
- function W(o) {
353
- const { toolsType: e, ...t } = o;
366
+ function C(n) {
367
+ const { toolsType: e, ...t } = n;
354
368
  switch (e) {
355
- case y.BackgroundSVG:
369
+ case k.BackgroundSVG:
356
370
  return new X(t);
357
371
  default:
358
372
  return;
359
373
  }
360
374
  }
361
- class F {
375
+ class W {
362
376
  constructor(e) {
363
377
  h(this, "viewId");
364
378
  h(this, "fullLayer");
365
379
  h(this, "curNodeMap");
366
- this.viewId = e, this.curNodeMap = new x();
380
+ this.viewId = e, this.curNodeMap = new A();
367
381
  }
368
382
  init(e) {
369
383
  this.fullLayer = e;
@@ -404,13 +418,13 @@ class Y {
404
418
  h(this, "master");
405
419
  h(this, "cameraOpt");
406
420
  h(this, "methodBuilder");
407
- h(this, "updateCamera", H(async (e) => {
421
+ h(this, "updateCamera", D(async (e) => {
408
422
  const { cameraOpt: t } = e;
409
- t && !T(this.cameraOpt, t) && await this.setCameraOpt(t);
423
+ t && !I(this.cameraOpt, t) && await this.setCameraOpt(t);
410
424
  }, 100));
411
- this.viewId = e, this.opt = t, this.master = t.master, this.fullLayer = t.container, this.methodBuilder = new _([
412
- I.CopyNode
413
- ]).registerForBackgroundThread(this), this.vNodes = new F(e), this.vNodes.init(this.fullLayer);
425
+ this.viewId = e, this.opt = t, this.master = t.master, this.fullLayer = t.container, this.methodBuilder = new q([
426
+ T.CopyNode
427
+ ]).registerForBackgroundThread(this), this.vNodes = new W(e), this.vNodes.init(this.fullLayer);
414
428
  }
415
429
  get camera() {
416
430
  return this.cameraOpt || {
@@ -429,10 +443,10 @@ class Y {
429
443
  return this.master.control.pluginOptions.extras.markmap.options;
430
444
  }
431
445
  getPagePoint(e, t) {
432
- const { scale: s, centerX: a, centerY: r, width: i, height: n } = this.camera;
446
+ const { scale: s, centerX: r, centerY: a, width: i, height: o } = this.camera;
433
447
  return {
434
- x: (e - a) * s + i / 2,
435
- y: (t - r) * s + n / 2
448
+ x: (e - r) * s + i / 2,
449
+ y: (t - a) * s + o / 2
436
450
  };
437
451
  }
438
452
  async setCameraOpt(e) {
@@ -446,36 +460,38 @@ class Y {
446
460
  this.vNodes.clear();
447
461
  }
448
462
  canUseFullLayer(e) {
449
- return e === y.BackgroundSVG;
463
+ return e === k.BackgroundSVG;
450
464
  }
451
465
  async consumeFull(e) {
452
- const { toolsType: t, opt: s, workId: a } = e;
453
- if (a != null && a.toString() && t && this.canUseFullLayer(t))
466
+ const { toolsType: t, opt: s, workId: r, scenePath: a } = e;
467
+ if (r != null && r.toString() && t && this.canUseFullLayer(t))
454
468
  switch (t) {
455
- case y.BackgroundSVG:
469
+ case k.BackgroundSVG:
456
470
  await this.setFullWork({
457
471
  toolsType: t,
458
472
  opt: s,
459
- workId: a
473
+ workId: r,
474
+ scenePath: a
460
475
  });
461
476
  break;
462
477
  }
463
478
  }
464
479
  async setFullWork(e) {
465
- const { workId: t, opt: s, toolsType: a } = e;
466
- if (t && s && a) {
467
- const r = t.toString();
468
- let i;
469
- const n = this.vNodes.get(r);
470
- return !n || !n.workShape ? (i = this.createWorkShapeNode({
480
+ const { workId: t, opt: s, toolsType: r, scenePath: a } = e;
481
+ if (t && s && r && a) {
482
+ const i = t.toString();
483
+ let o;
484
+ const c = this.vNodes.get(i);
485
+ return !c || !c.workShape ? (o = this.createWorkShapeNode({
471
486
  toolsOpt: s,
472
- toolsType: y.BackgroundSVG,
473
- workId: r
474
- }), i && await i.init()) : (i = n.workShape, await i.setWorkOptions(s)), i;
487
+ toolsType: k.BackgroundSVG,
488
+ workId: i,
489
+ scenePath: a
490
+ }), o && await o.init()) : (o = c.workShape, await o.setWorkOptions(s)), o;
475
491
  }
476
492
  }
477
493
  createWorkShapeNode(e) {
478
- return W({
494
+ return C({
479
495
  ...e,
480
496
  vNodes: this.vNodes,
481
497
  manager: this
@@ -505,7 +521,7 @@ class Y {
505
521
  break;
506
522
  }
507
523
  case d.UpdateTools: {
508
- this.toggleFullLayer(s === y.Clicker);
524
+ this.toggleFullLayer(s === k.Clicker);
509
525
  break;
510
526
  }
511
527
  case d.BackgroundSVGUpdate:
@@ -540,7 +556,7 @@ class j {
540
556
  h(this, "cameraOpt");
541
557
  h(this, "opt");
542
558
  h(this, "workShapes", /* @__PURE__ */ new Map());
543
- this.viewId = e, this.opt = t, this.master = t.master, this.fullLayer = t.container, this.vNodes = new F(e), this.vNodes.init(this.fullLayer);
559
+ this.viewId = e, this.opt = t, this.master = t.master, this.fullLayer = t.container, this.vNodes = new W(e), this.vNodes.init(this.fullLayer);
544
560
  }
545
561
  get camera() {
546
562
  return this.cameraOpt || {
@@ -559,11 +575,11 @@ class j {
559
575
  return this.master.control.pluginOptions.extras.markmap.options;
560
576
  }
561
577
  createOffscreenCanvas(e) {
562
- const { width: t, height: s } = e.canvasOpt, a = new OffscreenCanvas(
578
+ const { width: t, height: s } = e.canvasOpt, r = new OffscreenCanvas(
563
579
  e.canvasOpt.width,
564
580
  e.canvasOpt.height
565
581
  );
566
- a.width = t, a.height = s;
582
+ r.width = t, r.height = s;
567
583
  }
568
584
  async setCameraOpt(e) {
569
585
  this.cameraOpt = e;
@@ -573,28 +589,29 @@ class j {
573
589
  }
574
590
  }
575
591
  getPagePoint(e, t) {
576
- const { scale: s, centerX: a, centerY: r, width: i, height: n } = this.camera;
592
+ const { scale: s, centerX: r, centerY: a, width: i, height: o } = this.camera;
577
593
  return {
578
- x: (e - a) * s + i / 2,
579
- y: (t - r) * s + n / 2
594
+ x: (e - r) * s + i / 2,
595
+ y: (t - a) * s + o / 2
580
596
  };
581
597
  }
582
598
  async getSnapshot(e) {
583
- const { scenePath: t, scenes: s, cameraOpt: a } = e;
584
- if (t && s && a) {
585
- await this.setCameraOpt(a);
586
- for (const [r, i] of Object.entries(s))
587
- if (i != null && i.type && (i == null ? void 0 : i.toolsType) === y.BackgroundSVG)
599
+ const { scenePath: t, scenes: s, cameraOpt: r } = e;
600
+ if (t && s && r) {
601
+ await this.setCameraOpt(r);
602
+ for (const [a, i] of Object.entries(s))
603
+ if (i != null && i.type && (i == null ? void 0 : i.toolsType) === k.BackgroundSVG)
588
604
  switch (i == null ? void 0 : i.type) {
589
605
  case d.UpdateNode:
590
606
  case d.FullWork: {
591
- const { opt: n } = i, c = {
607
+ const { opt: o } = i, c = {
592
608
  ...i,
593
- opt: n,
594
- workId: r,
609
+ opt: o,
610
+ workId: a,
595
611
  msgType: d.FullWork,
596
- dataType: C.Service,
597
- viewId: this.viewId
612
+ dataType: L.Service,
613
+ viewId: this.viewId,
614
+ scenePath: t
598
615
  };
599
616
  await this.runFullWork(c);
600
617
  break;
@@ -602,22 +619,22 @@ class j {
602
619
  }
603
620
  try {
604
621
  if (t) {
605
- await L(this.fullLayer), await q(this.fullLayer), await z(this.fullLayer);
606
- const r = await G(this.fullLayer);
607
- r && this.opt.post({
622
+ await P(this.fullLayer), await _(this.fullLayer), await z(this.fullLayer);
623
+ const a = await G(this.fullLayer);
624
+ a && this.opt.post({
608
625
  sp: [
609
626
  {
610
627
  type: d.Snapshot,
611
628
  scenePath: t,
612
- imageElement: r,
629
+ imageElement: a,
613
630
  viewId: this.viewId,
614
631
  index: 1
615
632
  }
616
633
  ]
617
634
  });
618
635
  }
619
- } catch (r) {
620
- const i = r && r instanceof Error ? r.message : r == null ? void 0 : r.toString();
636
+ } catch (a) {
637
+ const i = a && a instanceof Error ? a.message : a == null ? void 0 : a.toString();
621
638
  this.opt.post({
622
639
  sp: [
623
640
  {
@@ -630,38 +647,41 @@ class j {
630
647
  }
631
648
  }
632
649
  createWorkShapeNode(e) {
633
- return W({
650
+ return C({
634
651
  ...e,
635
652
  vNodes: this.vNodes,
636
- manager: this
653
+ manager: this,
654
+ trackBackgroundImageLoad: !1
637
655
  });
638
656
  }
639
657
  async setFullWork(e) {
640
- const { workId: t, opt: s, toolsType: a } = e;
641
- if (t && s && a) {
642
- const r = t.toString();
643
- let i;
644
- const n = this.vNodes.get(r);
645
- return !n || !n.workShape ? (i = this.createWorkShapeNode({
658
+ const { workId: t, opt: s, toolsType: r, scenePath: a } = e;
659
+ if (t && s && r && a) {
660
+ const i = t.toString();
661
+ let o;
662
+ const c = this.vNodes.get(i);
663
+ return !c || !c.workShape ? (o = this.createWorkShapeNode({
646
664
  toolsOpt: s,
647
- toolsType: y.BackgroundSVG,
648
- workId: r
649
- }), i && await i.init()) : (i = n.workShape, await i.setWorkOptions(s)), i;
665
+ toolsType: k.BackgroundSVG,
666
+ workId: i,
667
+ scenePath: a
668
+ }), o && await o.init()) : (o = c.workShape, await o.setWorkOptions(s)), o;
650
669
  }
651
670
  }
652
671
  async runFullWork(e) {
653
- const { toolsType: t, opt: s, workId: a } = e;
672
+ const { toolsType: t, opt: s, workId: r, scenePath: a } = e;
654
673
  await this.setFullWork({
655
674
  toolsType: t,
656
675
  opt: s,
657
- workId: a
676
+ workId: r,
677
+ scenePath: a
658
678
  });
659
679
  }
660
680
  destroy() {
661
681
  this.fullLayer.innerHTML = "", this.fullLayer.style.width = "", this.fullLayer.style.height = "";
662
682
  }
663
683
  }
664
- class he {
684
+ class oe {
665
685
  constructor(e) {
666
686
  h(this, "backgroundThreadMap", /* @__PURE__ */ new Map());
667
687
  h(this, "snapshotThread");
@@ -679,14 +699,14 @@ class he {
679
699
  return new j(e, t);
680
700
  }
681
701
  async consume(e) {
682
- var t, s, a, r, i, n;
702
+ var t, s, r, a, i, o;
683
703
  for (const c of e.values()) {
684
704
  const {
685
705
  msgType: l,
686
- viewId: m,
687
- layerOpt: k,
706
+ viewId: p,
707
+ layerOpt: y,
688
708
  offscreenCanvasOpt: w,
689
- cameraOpt: p,
709
+ cameraOpt: m,
690
710
  tasksqueue: u
691
711
  } = c;
692
712
  if (l === d.Console) {
@@ -694,42 +714,42 @@ class he {
694
714
  continue;
695
715
  }
696
716
  if (l === d.Init) {
697
- const g = (t = this.master.control.viewContainerManager.getView(m)) == null ? void 0 : t.displayer, v = (s = g == null ? void 0 : g.backgroundContainerRef) == null ? void 0 : s.current;
698
- if (g && v && k && w) {
699
- const f = this.backgroundThreadMap.get(m);
717
+ const g = (t = this.master.control.viewContainerManager.getView(p)) == null ? void 0 : t.displayer, v = (s = g == null ? void 0 : g.backgroundContainerRef) == null ? void 0 : s.current;
718
+ if (g && v && y && w) {
719
+ const f = this.backgroundThreadMap.get(p);
700
720
  f == null || f.destroy();
701
- const S = this.createBackgroundThread(m, {
721
+ const S = this.createBackgroundThread(p, {
702
722
  displayer: g,
703
723
  container: v,
704
- layerOpt: k,
724
+ layerOpt: y,
705
725
  master: this.master,
706
726
  canvasOpt: w,
707
727
  post: this.post
708
728
  });
709
- this.backgroundThreadMap.set(m, S), S && p && await S.setCameraOpt(p);
729
+ this.backgroundThreadMap.set(p, S), S && m && await S.setCameraOpt(m);
710
730
  }
711
731
  continue;
712
732
  }
713
733
  if (l === d.Snapshot) {
714
- const g = (a = this.master.control.viewContainerManager.getView(m)) == null ? void 0 : a.displayer, f = (i = ((r = this.master.control.viewContainerManager.mainView) == null ? void 0 : r.displayer).backgroundSnapshotContainerRef) == null ? void 0 : i.current;
715
- if (g && f && p) {
716
- (n = this.snapshotThread) == null || n.destroy(), f.style.width = `${p.width}px`, f.style.height = `${p.height}px`;
734
+ const g = (r = this.master.control.viewContainerManager.getView(p)) == null ? void 0 : r.displayer, f = (i = ((a = this.master.control.viewContainerManager.mainView) == null ? void 0 : a.displayer).backgroundSnapshotContainerRef) == null ? void 0 : i.current;
735
+ if (g && f && m) {
736
+ (o = this.snapshotThread) == null || o.destroy(), f.style.width = `${m.width}px`, f.style.height = `${m.height}px`;
717
737
  const S = {
718
738
  ...N.defaultLayerOpt,
719
739
  offscreen: !1,
720
- width: p.width,
721
- height: p.height
722
- }, P = {
740
+ width: m.width,
741
+ height: m.height
742
+ }, B = {
723
743
  ...N.defaultScreenCanvasOpt,
724
- width: p.width,
725
- height: p.height
744
+ width: m.width,
745
+ height: m.height
726
746
  };
727
- this.snapshotThread = this.createSnapshotThread(m, {
747
+ this.snapshotThread = this.createSnapshotThread(p, {
728
748
  displayer: g,
729
749
  container: f,
730
750
  layerOpt: S,
731
751
  master: this.master,
732
- canvasOpt: P,
752
+ canvasOpt: B,
733
753
  post: this.post
734
754
  }), await this.snapshotThread.getSnapshot(c), this.snapshotThread.destroy(), this.snapshotThread = void 0;
735
755
  continue;
@@ -742,14 +762,14 @@ class he {
742
762
  }
743
763
  continue;
744
764
  }
745
- if (m === A) {
765
+ if (p === x) {
746
766
  for (const g of this.backgroundThreadMap.values())
747
767
  await g.on(c);
748
768
  l === d.Destroy && this.backgroundThreadMap.clear();
749
769
  continue;
750
770
  }
751
- const O = this.backgroundThreadMap.get(m);
752
- O && (await O.on(c), l === d.Destroy && this.backgroundThreadMap.delete(m));
771
+ const O = this.backgroundThreadMap.get(p);
772
+ O && (await O.on(c), l === d.Destroy && this.backgroundThreadMap.delete(p));
753
773
  }
754
774
  }
755
775
  async consumeTargetOne(e, t) {
@@ -765,5 +785,5 @@ class he {
765
785
  }
766
786
  }
767
787
  export {
768
- he as BackgroundThreadManagerImpl
788
+ oe as BackgroundThreadManagerImpl
769
789
  };