@netless/appliance-plugin 1.1.34-beta.2 → 1.1.34

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 (47) hide show
  1. package/READMA.zh-CN.md +33 -1
  2. package/README.md +32 -0
  3. package/cdn/cdn.js +1 -1
  4. package/cdn/{subWorker-DhqUsi.js → fullWorker-oI42U9.js} +109 -109
  5. package/cdn/{fullWorker-CuVwdG.js → subWorker-Bk6qRb.js} +109 -109
  6. package/dist/appliance-plugin.js +1 -1
  7. package/dist/appliance-plugin.mjs +1 -1
  8. package/dist/collector/collector.d.ts +0 -1
  9. package/dist/core/autoShape/index.d.ts +12 -0
  10. package/dist/core/autoShape/mapper.d.ts +3 -0
  11. package/dist/core/autoShape/recognizer.d.ts +8 -0
  12. package/dist/core/autoShape/registry.d.ts +2 -0
  13. package/dist/core/autoShape/templates.d.ts +2 -0
  14. package/dist/core/autoShape/types.d.ts +78 -0
  15. package/dist/core/mainEngine.d.ts +9 -1
  16. package/dist/core/tools/pencil.d.ts +3 -0
  17. package/dist/core/types.d.ts +7 -0
  18. package/dist/fullWorker.js +109 -109
  19. package/dist/{index-DD4uosmt.mjs → index-BPFYMff6.mjs} +1040 -1012
  20. package/dist/{index-Djm-u9a7.mjs → index-BTxxBSIk.mjs} +214 -207
  21. package/dist/index-BzcHKXGG.js +1 -0
  22. package/dist/index-CFIySwek.js +1 -0
  23. package/dist/{index-CslUUlge.mjs → index-CIPJM93i.mjs} +2829 -2011
  24. package/dist/{index-CnVA96FG.js → index-DVZBBduh.js} +3 -3
  25. package/dist/plugin/baseApplianceManager.d.ts +1 -2
  26. package/dist/plugin/multi/containerManager.d.ts +7 -0
  27. package/dist/plugin/types.d.ts +24 -0
  28. package/dist/plugin/utils.d.ts +0 -8
  29. package/dist/subWorker.js +109 -109
  30. package/package.json +8 -18
  31. package/dist/assets/fullWorker-CItZoPtX.js +0 -593
  32. package/dist/assets/subWorker-DTQZDdFT.js +0 -593
  33. package/dist/bridge-C4n1zHQZ.mjs +0 -67
  34. package/dist/bridge-DCJjH18X.js +0 -1
  35. package/dist/bridge-runtime.d.ts +0 -11
  36. package/dist/bridge.d.ts +0 -5
  37. package/dist/bridge.js +0 -1
  38. package/dist/bridge.mjs +0 -7
  39. package/dist/index-BZopbcnP.js +0 -1
  40. package/dist/index-Bc6Cv0DB.mjs +0 -15802
  41. package/dist/index-CH_SAlCz.mjs +0 -1255
  42. package/dist/index-CR9Nc39_.js +0 -1
  43. package/dist/index-D8qxABte.mjs +0 -9855
  44. package/dist/index-DjNO25oE.js +0 -1
  45. package/dist/index-Dk4BLxV5.js +0 -3
  46. package/dist/index-DnccF_rY.js +0 -1
  47. package/dist/plugin/external.bridge.d.ts +0 -1
@@ -1,7 +1,7 @@
1
1
  var K = Object.defineProperty;
2
2
  var j = (o, e, t) => e in o ? K(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var u = (o, e, t) => j(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { E as B, a as k, b as D, c as x, d as E, V as P, S as Z } from "./index-Bc6Cv0DB.mjs";
4
+ import { E as B, a as y, b as D, c as M, d as E, V as P, S as Z } from "./index-CIPJM93i.mjs";
5
5
  import { isEqual as W, isString as _, clone as J, throttle as Q } from "lodash";
6
6
  import "white-web-sdk";
7
7
  import "spritejs";
@@ -29,7 +29,7 @@ class ae extends re {
29
29
  }
30
30
  async consume(t) {
31
31
  const { msgType: r, dataType: s, emitEventType: i } = t;
32
- if (r === k.FullWork && s === D.Local && i === this.emitEventType)
32
+ if (r === y.FullWork && s === D.Local && i === this.emitEventType)
33
33
  return this.consumeForLocalWorker(t), !0;
34
34
  }
35
35
  async consumeForLocalWorker(t) {
@@ -80,7 +80,7 @@ async function ne() {
80
80
  function oe() {
81
81
  return (N == null ? void 0 : N.default) || null;
82
82
  }
83
- const I = class I {
83
+ const T = class T {
84
84
  constructor() {
85
85
  // 使用 workId 作为 key,存储每个实例的 mermaid 代码块
86
86
  u(this, "mermaidCodeBlocksByWorkId", /* @__PURE__ */ new Map());
@@ -89,7 +89,7 @@ const I = class I {
89
89
  * 获取 MermaidManager 单例实例
90
90
  */
91
91
  static getInstance() {
92
- return I.instance || (I.instance = new I()), I.instance;
92
+ return T.instance || (T.instance = new T()), T.instance;
93
93
  }
94
94
  /**
95
95
  * 生成唯一的 mermaid ID
@@ -135,39 +135,39 @@ const I = class I {
135
135
  */
136
136
  extendMarkdown(e, t) {
137
137
  const r = e.md.renderer, s = r.rules.fence, i = this;
138
- r.rules.fence = (a, n, c, d, w) => {
138
+ r.rules.fence = (a, n, c, h, g) => {
139
139
  const p = a[n];
140
140
  if (p.info.trim() === "mermaid") {
141
- const g = i.generateId();
142
- return i.createContainer(g, p.content, t);
141
+ const f = i.generateId();
142
+ return i.createContainer(f, p.content, t);
143
143
  }
144
- return s ? s(a, n, c, d, w) : "";
144
+ return s ? s(a, n, c, h, g) : "";
145
145
  };
146
146
  }
147
147
  // 为了向后兼容,保留静态方法(内部使用单例)
148
148
  static generateId() {
149
- return I.getInstance().generateId();
149
+ return T.getInstance().generateId();
150
150
  }
151
151
  static createContainer(e, t, r) {
152
- return I.getInstance().createContainer(
152
+ return T.getInstance().createContainer(
153
153
  e,
154
154
  t,
155
155
  r
156
156
  );
157
157
  }
158
158
  static getCode(e, t) {
159
- return I.getInstance().getCode(e, t);
159
+ return T.getInstance().getCode(e, t);
160
160
  }
161
161
  static clear(e) {
162
- I.getInstance().clear(e);
162
+ T.getInstance().clear(e);
163
163
  }
164
164
  static extendMarkdown(e, t) {
165
- I.getInstance().extendMarkdown(e, t);
165
+ T.getInstance().extendMarkdown(e, t);
166
166
  }
167
167
  };
168
- u(I, "instance", null);
169
- let b = I;
170
- class T {
168
+ u(T, "instance", null);
169
+ let O = T;
170
+ class b {
171
171
  /**
172
172
  * 检查 markmap 节点及其子节点是否包含 mermaid 代码块
173
173
  * @param node markmap 节点数据
@@ -180,7 +180,7 @@ class T {
180
180
  return !0;
181
181
  if (e.children && Array.isArray(e.children)) {
182
182
  for (const t of e.children)
183
- if (T.checkNodeHasMermaid(t))
183
+ if (b.checkNodeHasMermaid(t))
184
184
  return !0;
185
185
  }
186
186
  return !1;
@@ -192,7 +192,7 @@ class T {
192
192
  * @returns Promise<void>
193
193
  */
194
194
  static async renderMermaidAfterDOMUpdate(e, t) {
195
- await T.renderMermaidBlocks(e, t);
195
+ await b.renderMermaidBlocks(e, t);
196
196
  }
197
197
  /**
198
198
  * 渲染所有 mermaid 容器中的图表
@@ -215,42 +215,42 @@ class T {
215
215
  let s = null, i = !1;
216
216
  for (let n = 0; n < 30; n++) {
217
217
  const c = e.querySelectorAll("foreignObject");
218
- if (s = e.querySelectorAll(".mermaid-container"), s.length > 0 || (c.length > 0 && (i = !0), await new Promise((d) => setTimeout(d, 50)), i && n >= 20))
218
+ if (s = e.querySelectorAll(".mermaid-container"), s.length > 0 || (c.length > 0 && (i = !0), await new Promise((h) => setTimeout(h, 50)), i && n >= 20))
219
219
  break;
220
220
  }
221
221
  if (!s || s.length === 0)
222
222
  return;
223
223
  const a = Array.from(s).map(
224
224
  async (n, c) => {
225
- const d = n, w = d.getAttribute("data-mermaid-id"), p = w ? b.getCode(w, t) : void 0, l = d.querySelector(
225
+ const h = n, g = h.getAttribute("data-mermaid-id"), p = g ? O.getCode(g, t) : void 0, d = h.querySelector(
226
226
  ".mermaid-placeholder"
227
227
  );
228
- if (!(!l || !p))
228
+ if (!(!d || !p))
229
229
  try {
230
- const f = `mermaid-${t.replace(/[^a-zA-Z0-9_-]/g, "-")}-${Date.now()}-${c}`, { svg: v } = await r.render(f, p);
231
- if (l && l.parentNode) {
232
- const y = document.createElement("div");
233
- y.innerHTML = v;
234
- const m = y.querySelector("svg");
235
- if (m) {
236
- if (!m.getAttribute("viewBox") && m.getAttribute("width") && m.getAttribute("height")) {
237
- const A = m.getAttribute("width"), S = m.getAttribute("height"), M = parseFloat((A == null ? void 0 : A.replace(/px|%/, "")) || "0"), O = parseFloat(
238
- (S == null ? void 0 : S.replace(/px|%/, "")) || "0"
230
+ const w = `mermaid-${t.replace(/[^a-zA-Z0-9_-]/g, "-")}-${Date.now()}-${c}`, { svg: v } = await r.render(w, p);
231
+ if (d && d.parentNode) {
232
+ const I = document.createElement("div");
233
+ I.innerHTML = v;
234
+ const l = I.querySelector("svg");
235
+ if (l) {
236
+ if (!l.getAttribute("viewBox") && l.getAttribute("width") && l.getAttribute("height")) {
237
+ const S = l.getAttribute("width"), k = l.getAttribute("height"), x = parseFloat((S == null ? void 0 : S.replace(/px|%/, "")) || "0"), A = parseFloat(
238
+ (k == null ? void 0 : k.replace(/px|%/, "")) || "0"
239
239
  );
240
- M > 0 && O > 0 && m.setAttribute(
240
+ x > 0 && A > 0 && l.setAttribute(
241
241
  "viewBox",
242
- `0 0 ${M} ${O}`
242
+ `0 0 ${x} ${A}`
243
243
  );
244
244
  }
245
- m.style.display = "block", m.style.maxWidth = "100%", m.style.width = "auto", m.style.height = "auto", m.style.overflow = "visible", m.style.verticalAlign = "top", m.style.objectFit = "contain";
246
- const h = document.createElement("div");
247
- h.className = "mermaid-wrapper", h.style.width = "100%", h.style.height = "auto", h.style.overflow = "hidden", h.style.display = "inline-block", h.style.verticalAlign = "top", h.style.margin = "0", h.style.padding = "0", h.style.boxSizing = "border-box", h.style.position = "relative", this.isSafari() && (h.style.clipPath = "inset(100% 0 0 0)", h.style.pointerEvents = "none"), h.appendChild(m), m.style.width = "100%", m.style.height = "100%", m.style.maxWidth = "100%", m.style.maxHeight = "100%", m.style.objectFit = "contain", m.setAttribute("data-type", "mermaid"), this.isSafari() && (m.style.opacity = "0"), l.parentNode.replaceChild(h, l);
245
+ l.style.display = "block", l.style.maxWidth = "100%", l.style.width = "auto", l.style.height = "auto", l.style.overflow = "visible", l.style.verticalAlign = "top", l.style.objectFit = "contain";
246
+ const m = document.createElement("div");
247
+ m.className = "mermaid-wrapper", m.style.width = "100%", m.style.height = "auto", m.style.overflow = "hidden", m.style.display = "inline-block", m.style.verticalAlign = "top", m.style.margin = "0", m.style.padding = "0", m.style.boxSizing = "border-box", m.style.position = "relative", this.isSafari() && (m.style.clipPath = "inset(100% 0 0 0)", m.style.pointerEvents = "none"), m.appendChild(l), l.style.width = "100%", l.style.height = "100%", l.style.maxWidth = "100%", l.style.maxHeight = "100%", l.style.objectFit = "contain", l.setAttribute("data-type", "mermaid"), this.isSafari() && (l.style.opacity = "0"), d.parentNode.replaceChild(m, d);
248
248
  } else
249
- l.outerHTML = v;
249
+ d.outerHTML = v;
250
250
  }
251
- } catch (g) {
252
- const f = g instanceof Error ? g.message : String(g);
253
- l && (l.textContent = `Mermaid 渲染失败: ${f}`, l.style.color = "red", l.style.fontSize = "12px");
251
+ } catch (f) {
252
+ const w = f instanceof Error ? f.message : String(f);
253
+ d && (d.textContent = `Mermaid 渲染失败: ${w}`, d.style.color = "red", d.style.fontSize = "12px");
254
254
  }
255
255
  }
256
256
  );
@@ -293,8 +293,8 @@ class T {
293
293
  'svg[data-type="mermaid"]'
294
294
  );
295
295
  if (!n) {
296
- const w = a.querySelector(".mermaid-wrapper");
297
- w && (n = w.querySelector(
296
+ const g = a.querySelector(".mermaid-wrapper");
297
+ g && (n = g.querySelector(
298
298
  'svg[data-type="mermaid"]'
299
299
  ));
300
300
  }
@@ -302,67 +302,67 @@ class T {
302
302
  return;
303
303
  const c = a.querySelector(
304
304
  ".mermaid-container"
305
- ), d = c == null ? void 0 : c.getAttribute("data-mermaid-id");
306
- if (d)
305
+ ), h = c == null ? void 0 : c.getAttribute("data-mermaid-id");
306
+ if (h)
307
307
  try {
308
- const w = parseFloat(a.getAttribute("x") || "0"), p = parseFloat(a.getAttribute("y") || "0"), l = parseFloat(
308
+ const g = parseFloat(a.getAttribute("x") || "0"), p = parseFloat(a.getAttribute("y") || "0"), d = parseFloat(
309
309
  a.getAttribute("width") || "0"
310
- ), g = parseFloat(
310
+ ), f = parseFloat(
311
311
  a.getAttribute("height") || "0"
312
312
  );
313
- if (l <= 0 || g <= 0)
313
+ if (d <= 0 || f <= 0)
314
314
  return;
315
- const f = a.parentElement;
316
- if (!f || f.tagName !== "g")
315
+ const w = a.parentElement;
316
+ if (!w || w.tagName !== "g")
317
317
  return;
318
- let v = f.getAttribute("transform");
318
+ let v = w.getAttribute("transform");
319
319
  if (!v)
320
- v = `translate(${w}, ${p})`;
320
+ v = `translate(${g}, ${p})`;
321
321
  else {
322
- const S = v.match(
322
+ const k = v.match(
323
323
  /translate\(([^,]+),([^)]+)\)/
324
324
  );
325
- if (S) {
326
- const M = parseFloat(S[1]), O = parseFloat(S[2]), F = M + w, R = O + p;
325
+ if (k) {
326
+ const x = parseFloat(k[1]), A = parseFloat(k[2]), F = x + g, R = A + p;
327
327
  v = v.replace(
328
328
  /translate\([^)]+\)/,
329
329
  `translate(${F}, ${R})`
330
330
  );
331
331
  } else
332
- v = `translate(${w}, ${p}) ${v}`;
332
+ v = `translate(${g}, ${p}) ${v}`;
333
333
  }
334
- const y = e.querySelector(
335
- `g[data-mermaid-wrapper][data-mermaid-id="${d}"][data-mermaid-clone="true"]`
334
+ const I = e.querySelector(
335
+ `g[data-mermaid-wrapper][data-mermaid-id="${h}"][data-mermaid-clone="true"]`
336
336
  );
337
- let m;
338
- if (y) {
339
- m = y;
340
- const S = m.querySelector('svg[data-type="mermaid"]');
341
- S && m.removeChild(S);
337
+ let l;
338
+ if (I) {
339
+ l = I;
340
+ const k = l.querySelector('svg[data-type="mermaid"]');
341
+ k && l.removeChild(k);
342
342
  } else
343
- m = document.createElementNS(
343
+ l = document.createElementNS(
344
344
  "http://www.w3.org/2000/svg",
345
345
  "g"
346
- ), m.setAttribute("data-mermaid-wrapper", "true"), m.setAttribute("data-mermaid-clone", "true"), m.setAttribute("data-mermaid-id", d);
347
- m.setAttribute("transform", v);
348
- const h = n.cloneNode(!0);
349
- if (h.setAttribute("width", l.toString()), h.setAttribute("height", g.toString()), h.setAttribute("data-mermaid-transformed", "true"), h.style.width = "", h.style.height = "", h.style.maxWidth = "", h.style.maxHeight = "", h.style.transform = "", h.style.transformOrigin = "", h.style.display = "block", h.style.overflow = "visible", h.style.opacity = "1", !h.getAttribute("viewBox")) {
350
- const S = h.getAttribute("width"), M = h.getAttribute("height");
351
- if (S && M) {
352
- const O = parseFloat(
353
- S.replace(/px|%/, "") || "0"
346
+ ), l.setAttribute("data-mermaid-wrapper", "true"), l.setAttribute("data-mermaid-clone", "true"), l.setAttribute("data-mermaid-id", h);
347
+ l.setAttribute("transform", v);
348
+ const m = n.cloneNode(!0);
349
+ if (m.setAttribute("width", d.toString()), m.setAttribute("height", f.toString()), m.setAttribute("data-mermaid-transformed", "true"), m.style.width = "", m.style.height = "", m.style.maxWidth = "", m.style.maxHeight = "", m.style.transform = "", m.style.transformOrigin = "", m.style.display = "block", m.style.overflow = "visible", m.style.opacity = "1", !m.getAttribute("viewBox")) {
350
+ const k = m.getAttribute("width"), x = m.getAttribute("height");
351
+ if (k && x) {
352
+ const A = parseFloat(
353
+ k.replace(/px|%/, "") || "0"
354
354
  ), F = parseFloat(
355
- M.replace(/px|%/, "") || "0"
355
+ x.replace(/px|%/, "") || "0"
356
356
  );
357
- O > 0 && F > 0 && h.setAttribute(
357
+ A > 0 && F > 0 && m.setAttribute(
358
358
  "viewBox",
359
- `0 0 ${O} ${F}`
359
+ `0 0 ${A} ${F}`
360
360
  );
361
361
  }
362
362
  }
363
- m.appendChild(h), y || (f && f.parentNode ? f.parentNode.insertBefore(m, f.nextSibling) : e.appendChild(m)), c && (c.style.opacity = "0", c.style.pointerEvents = "none");
364
- } catch (w) {
365
- console.error("[transformMermaidSvgToMarkmapSvg] error: ", w);
363
+ l.appendChild(m), I || (w && w.parentNode ? w.parentNode.insertBefore(l, w.nextSibling) : e.appendChild(l)), c && (c.style.opacity = "0", c.style.pointerEvents = "none");
364
+ } catch (g) {
365
+ console.error("[transformMermaidSvgToMarkmapSvg] error: ", g);
366
366
  }
367
367
  }
368
368
  );
@@ -379,40 +379,40 @@ class T {
379
379
  static injectMermaidHtml(e, t, r) {
380
380
  const s = [], i = t.split(`
381
381
  `);
382
- let a = "", n = !1, c = [], d = -1;
382
+ let a = "", n = !1, c = [], h = -1;
383
383
  for (let p = 0; p < i.length; p++) {
384
- const l = i[p], g = l.match(/^(#{1,6})\s+(.+)$/);
385
- if (g && (a = g[2].trim()), l.trim().startsWith("```mermaid"))
386
- n = !0, c = [], d = p;
387
- else if (n && l.trim() === "```") {
384
+ const d = i[p], f = d.match(/^(#{1,6})\s+(.+)$/);
385
+ if (f && (a = f[2].trim()), d.trim().startsWith("```mermaid"))
386
+ n = !0, c = [], h = p;
387
+ else if (n && d.trim() === "```") {
388
388
  n = !1;
389
- const f = c.join(`
389
+ const w = c.join(`
390
390
  `);
391
- f && a && s.push({
391
+ w && a && s.push({
392
392
  title: a,
393
- content: f,
394
- index: d
393
+ content: w,
394
+ index: h
395
395
  }), c = [];
396
- } else n && c.push(l);
396
+ } else n && c.push(d);
397
397
  }
398
- const w = (p) => {
398
+ const g = (p) => {
399
399
  if (!p) return;
400
- const l = p.content || "", g = T.decodeHtmlEntities(l);
401
- for (const f of s)
402
- if (g.includes(f.title) || l.includes(f.title)) {
403
- const v = b.generateId(), y = b.createContainer(
400
+ const d = p.content || "", f = b.decodeHtmlEntities(d);
401
+ for (const w of s)
402
+ if (f.includes(w.title) || d.includes(w.title)) {
403
+ const v = O.generateId(), I = O.createContainer(
404
404
  v,
405
- f.content,
405
+ w.content,
406
406
  r
407
407
  );
408
- p.content ? p.content = p.content + y : p.content = y;
408
+ p.content ? p.content = p.content + I : p.content = I;
409
409
  break;
410
410
  }
411
- p.children && p.children.length > 0 && p.children.forEach((f) => {
412
- w(f);
411
+ p.children && p.children.length > 0 && p.children.forEach((w) => {
412
+ g(w);
413
413
  });
414
414
  };
415
- return w(e), e;
415
+ return g(e), e;
416
416
  }
417
417
  /**
418
418
  * 解码 HTML 实体
@@ -442,10 +442,10 @@ class U extends ee {
442
442
  * @param workId 工作 ID
443
443
  */
444
444
  setWorkId(t) {
445
- this.currentWorkId = t, t && b.extendMarkdown(this, t);
445
+ this.currentWorkId = t, t && O.extendMarkdown(this, t);
446
446
  }
447
447
  transform(t, r) {
448
- this.currentWorkId ? b.clear(this.currentWorkId) : b.clear();
448
+ this.currentWorkId ? O.clear(this.currentWorkId) : O.clear();
449
449
  const s = this.convertKatexToText(t), i = super.transform(s, r);
450
450
  return i.root && this.processKatexInRoot(i.root), i;
451
451
  }
@@ -527,22 +527,22 @@ class U extends ee {
527
527
  const c = n.src || n.getAttribute("src");
528
528
  if (!c || a.has(c) || (a.add(c), n.complete && n.naturalWidth > 0))
529
529
  return;
530
- const d = new Promise((w) => {
530
+ const h = new Promise((g) => {
531
531
  const p = setTimeout(() => {
532
- w();
532
+ g();
533
533
  }, r);
534
534
  if (n.complete && n.naturalWidth > 0) {
535
- clearTimeout(p), w();
535
+ clearTimeout(p), g();
536
536
  return;
537
537
  }
538
- const l = () => {
539
- clearTimeout(p), n.removeEventListener("load", l), n.removeEventListener("error", g), w();
540
- }, g = () => {
541
- clearTimeout(p), n.removeEventListener("load", l), n.removeEventListener("error", g), w();
538
+ const d = () => {
539
+ clearTimeout(p), n.removeEventListener("load", d), n.removeEventListener("error", f), g();
540
+ }, f = () => {
541
+ clearTimeout(p), n.removeEventListener("load", d), n.removeEventListener("error", f), g();
542
542
  };
543
- n.addEventListener("load", l), n.addEventListener("error", g), !n.src && c && (n.src = c);
543
+ n.addEventListener("load", d), n.addEventListener("error", f), !n.src && c && (n.src = c);
544
544
  });
545
- i.push(d);
545
+ i.push(h);
546
546
  }), i.length > 0 && await Promise.all(i);
547
547
  }
548
548
  }
@@ -569,12 +569,12 @@ async function de(o) {
569
569
  i.querySelectorAll("image").forEach((n) => {
570
570
  n.href && !n.href.baseVal.startsWith("data:") && (n.getAttribute("crossorigin") || n.setAttribute("crossorigin", "anonymous"), t.push(
571
571
  new Promise((c) => {
572
- const d = new Image();
573
- d.crossOrigin = "anonymous", d.onload = () => {
572
+ const h = new Image();
573
+ h.crossOrigin = "anonymous", h.onload = () => {
574
574
  c(void 0);
575
- }, d.onerror = () => {
575
+ }, h.onerror = () => {
576
576
  c(void 0);
577
- }, d.src = n.href.baseVal;
577
+ }, h.src = n.href.baseVal;
578
578
  })
579
579
  ));
580
580
  });
@@ -605,7 +605,7 @@ async function pe(o) {
605
605
  await Promise.all(t);
606
606
  }
607
607
  async function G(o) {
608
- if (T.hasMermaidSvg(o)) {
608
+ if (b.hasMermaidSvg(o)) {
609
609
  const r = Date.now();
610
610
  let s = !1;
611
611
  for (; Date.now() - r < 5e3 && !s; ) {
@@ -613,8 +613,8 @@ async function G(o) {
613
613
  if (i.length > 0) {
614
614
  let a = !0;
615
615
  for (const n of Array.from(i)) {
616
- const c = parseFloat(n.getAttribute("width") || "0"), d = parseFloat(n.getAttribute("height") || "0");
617
- if (n.querySelector(".mermaid-container") && (c < 50 || d < 50)) {
616
+ const c = parseFloat(n.getAttribute("width") || "0"), h = parseFloat(n.getAttribute("height") || "0");
617
+ if (n.querySelector(".mermaid-container") && (c < 50 || h < 50)) {
618
618
  a = !1;
619
619
  break;
620
620
  }
@@ -637,34 +637,34 @@ async function ue(o, e = {}) {
637
637
  if (!c)
638
638
  try {
639
639
  c = await a();
640
- } catch (l) {
641
- return console.error("[loadSvgToImageLib] error: ", l), null;
640
+ } catch (d) {
641
+ return console.error("[loadSvgToImageLib] error: ", d), null;
642
642
  }
643
- const d = o.style.width, w = o.style.height, p = o.style.display;
643
+ const h = o.style.width, g = o.style.height, p = o.style.display;
644
644
  o.style.width || (o.style.width = `${s}px`), o.style.height || (o.style.height = `${i}px`), (!o.style.display || o.style.display === "none") && (o.style.display = "block");
645
645
  try {
646
- await new Promise((g) => {
646
+ await new Promise((f) => {
647
647
  requestAnimationFrame(() => {
648
648
  requestAnimationFrame(() => {
649
- g();
649
+ f();
650
650
  });
651
651
  });
652
652
  });
653
- const l = await c.toPng(o, {
653
+ const d = await c.toPng(o, {
654
654
  width: s,
655
655
  height: i,
656
656
  quality: 1
657
657
  });
658
- return o.style.width = d, o.style.height = w, o.style.display = p, new Promise((g) => {
659
- const f = new Image();
660
- f.crossOrigin = "anonymous", f.onload = () => {
661
- g(f);
662
- }, f.onerror = () => {
663
- g(null);
664
- }, f.src = l;
658
+ return o.style.width = h, o.style.height = g, o.style.display = p, new Promise((f) => {
659
+ const w = new Image();
660
+ w.crossOrigin = "anonymous", w.onload = () => {
661
+ f(w);
662
+ }, w.onerror = () => {
663
+ f(null);
664
+ }, w.src = d;
665
665
  });
666
- } catch (l) {
667
- return o.style.width = d, o.style.height = w, o.style.display = p, console.error("[divToImageElement] error: ", l), null;
666
+ } catch (d) {
667
+ return o.style.width = h, o.style.height = g, o.style.display = p, console.error("[divToImageElement] error: ", d), null;
668
668
  }
669
669
  } catch (a) {
670
670
  return console.error("[divToImageElement] error: ", a), null;
@@ -672,7 +672,7 @@ async function ue(o, e = {}) {
672
672
  }
673
673
  class ge {
674
674
  constructor(e) {
675
- u(this, "toolsType", x.BackgroundSVG);
675
+ u(this, "toolsType", M.BackgroundSVG);
676
676
  u(this, "vNodes");
677
677
  u(this, "workOptions");
678
678
  u(this, "workId");
@@ -708,8 +708,8 @@ class ge {
708
708
  this.isDestroyed || !this.element || !this.element.parentNode || (this.updateElementPosition(e), await this.updateSvg(e));
709
709
  }
710
710
  isSameSize(e) {
711
- const { width: t, height: r } = e, { width: s, height: i } = this.workOptions, a = t * this.manager.camera.scale, n = r * this.manager.camera.scale, c = s * this.manager.camera.scale, d = i * this.manager.camera.scale;
712
- return a === c && n === d;
711
+ const { width: t, height: r } = e, { width: s, height: i } = this.workOptions, a = t * this.manager.camera.scale, n = r * this.manager.camera.scale, c = s * this.manager.camera.scale, h = i * this.manager.camera.scale;
712
+ return a === c && n === h;
713
713
  }
714
714
  isSamePosition(e) {
715
715
  const { centerX: t, centerY: r } = e, { centerX: s, centerY: i } = this.workOptions, a = this.manager.getPagePoint(s, i), n = this.manager.getPagePoint(t, r);
@@ -730,8 +730,8 @@ class ge {
730
730
  updateElementPosition(e) {
731
731
  if (this.isDestroyed || !this.element || !this.fullLayer)
732
732
  return;
733
- const { centerX: t, centerY: r, width: s, height: i, zIndex: a } = this.workOptions, n = this.manager.getPagePoint(t, r), c = s * this.manager.camera.scale, d = i * this.manager.camera.scale;
734
- (!e || e && !this.isSameSize(e)) && (this.element.setAttribute("width", `${c}`), this.element.setAttribute("height", `${d}`), this.element.style.width = `${c}px`, this.element.style.height = `${d}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 = (a || 0).toString());
733
+ const { centerX: t, centerY: r, width: s, height: i, zIndex: a } = this.workOptions, n = this.manager.getPagePoint(t, r), c = s * this.manager.camera.scale, h = i * this.manager.camera.scale;
734
+ (!e || e && !this.isSameSize(e)) && (this.element.setAttribute("width", `${c}`), this.element.setAttribute("height", `${h}`), this.element.style.width = `${c}px`, this.element.style.height = `${h}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 = (a || 0).toString());
735
735
  }
736
736
  async updateSvg(e) {
737
737
  const { type: t, state: r } = this.workOptions;
@@ -741,20 +741,20 @@ class ge {
741
741
  this.element,
742
742
  this.manager.markmapOptions
743
743
  ), this.markmapInstance.handleClick = async (n, c) => {
744
- var p, l, g;
744
+ var p, d, f;
745
745
  (p = this.markmapInstance) == null || p.toggleNode(c);
746
- const d = this.serializeData((l = this.markmapInstance) == null ? void 0 : l.state.data);
746
+ const h = this.serializeData((d = this.markmapInstance) == null ? void 0 : d.state.data);
747
747
  this.setWorkOptions(
748
748
  {
749
749
  ...this.workOptions,
750
- state: d
750
+ state: h
751
751
  },
752
752
  !1
753
- ), T.checkNodeHasMermaid(c) && await T.renderMermaidAfterDOMUpdate(
753
+ ), b.checkNodeHasMermaid(c) && await b.renderMermaidAfterDOMUpdate(
754
754
  this.element,
755
755
  this.workId
756
- ), this.scenePath && this.collector && ((g = this.collector) == null || g.dispatch({
757
- type: k.UpdateNode,
756
+ ), this.scenePath && this.collector && ((f = this.collector) == null || f.dispatch({
757
+ type: y.UpdateNode,
758
758
  workId: this.workId,
759
759
  opt: this.workOptions,
760
760
  isSync: !0,
@@ -766,12 +766,12 @@ class ge {
766
766
  L.setWorkId(this.workId);
767
767
  const i = L.transform(s);
768
768
  let { root: a } = i;
769
- s && q(s) && (a = T.injectMermaidHtml(a, s, this.workId));
769
+ s && q(s) && (a = b.injectMermaidHtml(a, s, this.workId));
770
770
  try {
771
771
  r && Array.isArray(r) && this.transformState(
772
772
  r,
773
773
  a
774
- ), await this.markmapInstance.setData(a), !this.isDestroyed && this.element && this.fullLayer && this.markmapInstance && (window.markmapInstance = this.markmapInstance, s && q(s) && await T.renderMermaidAfterDOMUpdate(
774
+ ), await this.markmapInstance.setData(a), !this.isDestroyed && this.element && this.fullLayer && this.markmapInstance && (window.markmapInstance = this.markmapInstance, s && q(s) && await b.renderMermaidAfterDOMUpdate(
775
775
  this.element,
776
776
  this.workId
777
777
  ), await this.fit(
@@ -800,7 +800,7 @@ class ge {
800
800
  var t;
801
801
  !this.isDestroyed && this.element && this.fullLayer && this.markmapInstance && (e && this.element && await U.waitForImagesInForeignObjects(
802
802
  this.element
803
- ), await ((t = this.markmapInstance) == null ? void 0 : t.fit()), this.element && T.isSafari() && T.hasMermaidSvg(this.element) && (await G(this.element), await T.transformMermaidSvgToMarkmapSvg(
803
+ ), await ((t = this.markmapInstance) == null ? void 0 : t.fit()), this.element && b.isSafari() && b.hasMermaidSvg(this.element) && (await G(this.element), await b.transformMermaidSvgToMarkmapSvg(
804
804
  this.element
805
805
  )));
806
806
  }
@@ -845,7 +845,7 @@ class ge {
845
845
  function X(o) {
846
846
  const { toolsType: e, ...t } = o;
847
847
  switch (e) {
848
- case x.BackgroundSVG:
848
+ case M.BackgroundSVG:
849
849
  return new ge(t);
850
850
  default:
851
851
  return;
@@ -939,13 +939,13 @@ class fe {
939
939
  this.vNodes.clear();
940
940
  }
941
941
  canUseFullLayer(e) {
942
- return e === x.BackgroundSVG;
942
+ return e === M.BackgroundSVG;
943
943
  }
944
944
  async consumeFull(e) {
945
945
  const { toolsType: t, opt: r, workId: s } = e;
946
946
  if (s != null && s.toString() && t && this.canUseFullLayer(t))
947
947
  switch (t) {
948
- case x.BackgroundSVG:
948
+ case M.BackgroundSVG:
949
949
  await this.setFullWork({
950
950
  toolsType: t,
951
951
  opt: r,
@@ -962,7 +962,7 @@ class fe {
962
962
  const n = this.vNodes.get(i);
963
963
  return !n || !n.workShape ? (a = this.createWorkShapeNode({
964
964
  toolsOpt: r,
965
- toolsType: x.BackgroundSVG,
965
+ toolsType: M.BackgroundSVG,
966
966
  workId: i
967
967
  }), a && await a.init()) : (a = n.workShape, await a.setWorkOptions(r)), a;
968
968
  }
@@ -985,29 +985,29 @@ class fe {
985
985
  if (!await this.methodBuilder.consumeForBackgroundThread(e)) {
986
986
  const { msgType: t, toolsType: r } = e;
987
987
  switch (t) {
988
- case k.Destroy: {
988
+ case y.Destroy: {
989
989
  this.destroy();
990
990
  break;
991
991
  }
992
- case k.Clear: {
992
+ case y.Clear: {
993
993
  this.clearAll();
994
994
  break;
995
995
  }
996
- case k.UpdateCamera: {
996
+ case y.UpdateCamera: {
997
997
  this.updateCamera(e);
998
998
  break;
999
999
  }
1000
- case k.UpdateTools: {
1001
- this.toggleFullLayer(r === x.Clicker);
1000
+ case y.UpdateTools: {
1001
+ this.toggleFullLayer(r === M.Clicker);
1002
1002
  break;
1003
1003
  }
1004
- case k.BackgroundSVGUpdate:
1005
- case k.UpdateNode:
1006
- case k.FullWork: {
1004
+ case y.BackgroundSVGUpdate:
1005
+ case y.UpdateNode:
1006
+ case y.FullWork: {
1007
1007
  r && this.canUseFullLayer(r) && await this.consumeFull(e);
1008
1008
  break;
1009
1009
  }
1010
- case k.BackgroundSVGDelete: {
1010
+ case y.BackgroundSVGDelete: {
1011
1011
  this.removeWork(e);
1012
1012
  break;
1013
1013
  }
@@ -1077,15 +1077,15 @@ class we {
1077
1077
  if (t && r && s) {
1078
1078
  await this.setCameraOpt(s);
1079
1079
  for (const [i, a] of Object.entries(r))
1080
- if (a != null && a.type && (a == null ? void 0 : a.toolsType) === x.BackgroundSVG)
1080
+ if (a != null && a.type && (a == null ? void 0 : a.toolsType) === M.BackgroundSVG)
1081
1081
  switch (a == null ? void 0 : a.type) {
1082
- case k.UpdateNode:
1083
- case k.FullWork: {
1082
+ case y.UpdateNode:
1083
+ case y.FullWork: {
1084
1084
  const { opt: n } = a, c = {
1085
1085
  ...a,
1086
1086
  opt: n,
1087
1087
  workId: i,
1088
- msgType: k.FullWork,
1088
+ msgType: y.FullWork,
1089
1089
  dataType: D.Service,
1090
1090
  viewId: this.viewId
1091
1091
  };
@@ -1100,7 +1100,7 @@ class we {
1100
1100
  i && this.opt.post({
1101
1101
  sp: [
1102
1102
  {
1103
- type: k.Snapshot,
1103
+ type: y.Snapshot,
1104
1104
  scenePath: t,
1105
1105
  imageElement: i,
1106
1106
  viewId: this.viewId,
@@ -1114,7 +1114,7 @@ class we {
1114
1114
  this.opt.post({
1115
1115
  sp: [
1116
1116
  {
1117
- type: k.ReportError,
1117
+ type: y.ReportError,
1118
1118
  reportString: `[SnapshotThreadImpl] getSnapshotRender error: ${a}`
1119
1119
  }
1120
1120
  ]
@@ -1137,7 +1137,7 @@ class we {
1137
1137
  const n = this.vNodes.get(i);
1138
1138
  return !n || !n.workShape ? (a = this.createWorkShapeNode({
1139
1139
  toolsOpt: r,
1140
- toolsType: x.BackgroundSVG,
1140
+ toolsType: M.BackgroundSVG,
1141
1141
  workId: i
1142
1142
  }), a && await a.init()) : (a = n.workShape, await a.setWorkOptions(r)), a;
1143
1143
  }
@@ -1172,75 +1172,78 @@ class We {
1172
1172
  return new we(e, t);
1173
1173
  }
1174
1174
  async consume(e) {
1175
- var t, r, s, i, a;
1176
- for (const n of e.values()) {
1175
+ var t, r, s, i, a, n;
1176
+ for (const c of e.values()) {
1177
1177
  const {
1178
- msgType: c,
1179
- viewId: d,
1180
- layerOpt: w,
1181
- offscreenCanvasOpt: p,
1182
- cameraOpt: l,
1183
- tasksqueue: g,
1184
- mainTasksqueueCount: f
1185
- } = n;
1186
- if (c === k.Console) {
1178
+ msgType: h,
1179
+ viewId: g,
1180
+ layerOpt: p,
1181
+ offscreenCanvasOpt: d,
1182
+ cameraOpt: f,
1183
+ tasksqueue: w,
1184
+ mainTasksqueueCount: v
1185
+ } = c;
1186
+ if (h === y.Console) {
1187
1187
  console.log(this);
1188
1188
  continue;
1189
1189
  }
1190
- if (c === k.Init) {
1191
- const y = (t = this.master.control.viewContainerManager.getView(d)) == null ? void 0 : t.displayer, m = (r = y == null ? void 0 : y.backgroundContainerRef) == null ? void 0 : r.current;
1192
- if (y && m && w && p) {
1193
- const h = this.createBackgroundThread(d, {
1194
- displayer: y,
1190
+ if (h === y.Init) {
1191
+ const l = (t = this.master.control.viewContainerManager.getView(g)) == null ? void 0 : t.displayer, m = (r = l == null ? void 0 : l.backgroundContainerRef) == null ? void 0 : r.current;
1192
+ if (l && m && p && d) {
1193
+ const S = this.backgroundThreadMap.get(g);
1194
+ S == null || S.destroy();
1195
+ const k = this.createBackgroundThread(g, {
1196
+ displayer: l,
1195
1197
  container: m,
1196
- layerOpt: w,
1198
+ layerOpt: p,
1197
1199
  master: this.master,
1198
- canvasOpt: p,
1200
+ canvasOpt: d,
1199
1201
  post: this.post
1200
1202
  });
1201
- this.backgroundThreadMap.set(d, h), h && l && await h.setCameraOpt(l);
1203
+ this.backgroundThreadMap.set(g, k), k && f && await k.setCameraOpt(f);
1202
1204
  }
1203
1205
  continue;
1204
1206
  }
1205
- if (c === k.Snapshot) {
1206
- const y = (s = this.master.control.viewContainerManager.getView(d)) == null ? void 0 : s.displayer, h = (a = ((i = this.master.control.viewContainerManager.mainView) == null ? void 0 : i.displayer).backgroundSnapshotContainerRef) == null ? void 0 : a.current;
1207
- if (y && h && l) {
1208
- h.style.width = `${l.width}px`, h.style.height = `${l.height}px`;
1209
- const A = {
1207
+ if (h === y.Snapshot) {
1208
+ const l = (s = this.master.control.viewContainerManager.getView(g)) == null ? void 0 : s.displayer, S = (a = ((i = this.master.control.viewContainerManager.mainView) == null ? void 0 : i.displayer).backgroundSnapshotContainerRef) == null ? void 0 : a.current;
1209
+ if (l && S && f) {
1210
+ (n = this.snapshotThread) == null || n.destroy(), S.style.width = `${f.width}px`, S.style.height = `${f.height}px`;
1211
+ const k = {
1210
1212
  ...P.defaultLayerOpt,
1211
1213
  offscreen: !1,
1212
- width: l.width,
1213
- height: l.height
1214
- }, S = {
1214
+ width: f.width,
1215
+ height: f.height
1216
+ }, x = {
1215
1217
  ...P.defaultScreenCanvasOpt,
1216
- width: l.width,
1217
- height: l.height
1218
+ width: f.width,
1219
+ height: f.height
1218
1220
  };
1219
- this.snapshotThread = this.createSnapshotThread(d, {
1220
- displayer: y,
1221
- container: h,
1222
- layerOpt: A,
1221
+ this.snapshotThread = this.createSnapshotThread(g, {
1222
+ displayer: l,
1223
+ container: S,
1224
+ layerOpt: k,
1223
1225
  master: this.master,
1224
- canvasOpt: S,
1226
+ canvasOpt: x,
1225
1227
  post: this.post
1226
- }), await this.snapshotThread.getSnapshot(n), this.snapshotThread.destroy(), this.snapshotThread = void 0;
1228
+ }), await this.snapshotThread.getSnapshot(c), this.snapshotThread.destroy(), this.snapshotThread = void 0;
1227
1229
  continue;
1228
1230
  }
1229
1231
  }
1230
- if (c === k.TasksQueue && (g != null && g.size)) {
1231
- for (const [y, m] of this.backgroundThreadMap.entries()) {
1232
- const h = g.get(y);
1233
- h && (await m.on(h), f && this.post({ workerTasksqueueCount: f }));
1232
+ if (h === y.TasksQueue && (w != null && w.size)) {
1233
+ for (const [l, m] of this.backgroundThreadMap.entries()) {
1234
+ const S = w.get(l);
1235
+ S && (await m.on(S), v && this.post({ workerTasksqueueCount: v }));
1234
1236
  }
1235
1237
  continue;
1236
1238
  }
1237
- if (d === Z) {
1238
- for (const y of this.backgroundThreadMap.values())
1239
- y.on(n), c === k.Destroy && this.backgroundThreadMap.delete(d);
1239
+ if (g === Z) {
1240
+ for (const l of this.backgroundThreadMap.values())
1241
+ await l.on(c);
1242
+ h === y.Destroy && this.backgroundThreadMap.clear();
1240
1243
  continue;
1241
1244
  }
1242
- const v = this.backgroundThreadMap.get(d);
1243
- v && (v.on(n), c === k.Destroy && this.backgroundThreadMap.delete(d));
1245
+ const I = this.backgroundThreadMap.get(g);
1246
+ I && (await I.on(c), h === y.Destroy && this.backgroundThreadMap.delete(g));
1244
1247
  }
1245
1248
  }
1246
1249
  async consumeTargetOne(e, t) {
@@ -1248,6 +1251,10 @@ class We {
1248
1251
  r && await r.on(t);
1249
1252
  }
1250
1253
  destroy() {
1254
+ var e;
1255
+ (e = this.snapshotThread) == null || e.destroy(), this.snapshotThread = void 0;
1256
+ for (const t of this.backgroundThreadMap.values())
1257
+ t.destroy();
1251
1258
  this.backgroundThreadMap.clear();
1252
1259
  }
1253
1260
  }