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