@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.
- package/READMA.zh-CN.md +33 -1
- package/README.md +32 -0
- package/cdn/cdn.js +1 -1
- package/cdn/{subWorker-DhqUsi.js → fullWorker-oI42U9.js} +109 -109
- package/cdn/{fullWorker-CuVwdG.js → subWorker-Bk6qRb.js} +109 -109
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/collector/collector.d.ts +0 -1
- package/dist/core/autoShape/index.d.ts +12 -0
- package/dist/core/autoShape/mapper.d.ts +3 -0
- package/dist/core/autoShape/recognizer.d.ts +8 -0
- package/dist/core/autoShape/registry.d.ts +2 -0
- package/dist/core/autoShape/templates.d.ts +2 -0
- package/dist/core/autoShape/types.d.ts +78 -0
- package/dist/core/mainEngine.d.ts +9 -1
- package/dist/core/tools/pencil.d.ts +3 -0
- package/dist/core/types.d.ts +7 -0
- package/dist/fullWorker.js +109 -109
- package/dist/{index-DD4uosmt.mjs → index-BPFYMff6.mjs} +1040 -1012
- package/dist/{index-Djm-u9a7.mjs → index-BTxxBSIk.mjs} +214 -207
- package/dist/index-BzcHKXGG.js +1 -0
- package/dist/index-CFIySwek.js +1 -0
- package/dist/{index-CslUUlge.mjs → index-CIPJM93i.mjs} +2829 -2011
- package/dist/{index-CnVA96FG.js → index-DVZBBduh.js} +3 -3
- package/dist/plugin/baseApplianceManager.d.ts +1 -2
- package/dist/plugin/multi/containerManager.d.ts +7 -0
- package/dist/plugin/types.d.ts +24 -0
- package/dist/plugin/utils.d.ts +0 -8
- package/dist/subWorker.js +109 -109
- package/package.json +8 -18
- package/dist/assets/fullWorker-CItZoPtX.js +0 -593
- package/dist/assets/subWorker-DTQZDdFT.js +0 -593
- package/dist/bridge-C4n1zHQZ.mjs +0 -67
- package/dist/bridge-DCJjH18X.js +0 -1
- package/dist/bridge-runtime.d.ts +0 -11
- package/dist/bridge.d.ts +0 -5
- package/dist/bridge.js +0 -1
- package/dist/bridge.mjs +0 -7
- package/dist/index-BZopbcnP.js +0 -1
- package/dist/index-Bc6Cv0DB.mjs +0 -15802
- package/dist/index-CH_SAlCz.mjs +0 -1255
- package/dist/index-CR9Nc39_.js +0 -1
- package/dist/index-D8qxABte.mjs +0 -9855
- package/dist/index-DjNO25oE.js +0 -1
- package/dist/index-Dk4BLxV5.js +0 -3
- package/dist/index-DnccF_rY.js +0 -1
- 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
|
|
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 ===
|
|
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
|
|
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
|
|
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,
|
|
138
|
+
r.rules.fence = (a, n, c, h, g) => {
|
|
139
139
|
const p = a[n];
|
|
140
140
|
if (p.info.trim() === "mermaid") {
|
|
141
|
-
const
|
|
142
|
-
return i.createContainer(
|
|
141
|
+
const f = i.generateId();
|
|
142
|
+
return i.createContainer(f, p.content, t);
|
|
143
143
|
}
|
|
144
|
-
return s ? s(a, n, c,
|
|
144
|
+
return s ? s(a, n, c, h, g) : "";
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
// 为了向后兼容,保留静态方法(内部使用单例)
|
|
148
148
|
static generateId() {
|
|
149
|
-
return
|
|
149
|
+
return T.getInstance().generateId();
|
|
150
150
|
}
|
|
151
151
|
static createContainer(e, t, r) {
|
|
152
|
-
return
|
|
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
|
|
159
|
+
return T.getInstance().getCode(e, t);
|
|
160
160
|
}
|
|
161
161
|
static clear(e) {
|
|
162
|
-
|
|
162
|
+
T.getInstance().clear(e);
|
|
163
163
|
}
|
|
164
164
|
static extendMarkdown(e, t) {
|
|
165
|
-
|
|
165
|
+
T.getInstance().extendMarkdown(e, t);
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
u(
|
|
169
|
-
let
|
|
170
|
-
class
|
|
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 (
|
|
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
|
|
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((
|
|
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
|
|
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 (!(!
|
|
228
|
+
if (!(!d || !p))
|
|
229
229
|
try {
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
if (!
|
|
237
|
-
const
|
|
238
|
-
(
|
|
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
|
-
|
|
240
|
+
x > 0 && A > 0 && l.setAttribute(
|
|
241
241
|
"viewBox",
|
|
242
|
-
`0 0 ${
|
|
242
|
+
`0 0 ${x} ${A}`
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
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
|
-
|
|
249
|
+
d.outerHTML = v;
|
|
250
250
|
}
|
|
251
|
-
} catch (
|
|
252
|
-
const
|
|
253
|
-
|
|
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
|
|
297
|
-
|
|
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
|
-
),
|
|
306
|
-
if (
|
|
305
|
+
), h = c == null ? void 0 : c.getAttribute("data-mermaid-id");
|
|
306
|
+
if (h)
|
|
307
307
|
try {
|
|
308
|
-
const
|
|
308
|
+
const g = parseFloat(a.getAttribute("x") || "0"), p = parseFloat(a.getAttribute("y") || "0"), d = parseFloat(
|
|
309
309
|
a.getAttribute("width") || "0"
|
|
310
|
-
),
|
|
310
|
+
), f = parseFloat(
|
|
311
311
|
a.getAttribute("height") || "0"
|
|
312
312
|
);
|
|
313
|
-
if (
|
|
313
|
+
if (d <= 0 || f <= 0)
|
|
314
314
|
return;
|
|
315
|
-
const
|
|
316
|
-
if (!
|
|
315
|
+
const w = a.parentElement;
|
|
316
|
+
if (!w || w.tagName !== "g")
|
|
317
317
|
return;
|
|
318
|
-
let v =
|
|
318
|
+
let v = w.getAttribute("transform");
|
|
319
319
|
if (!v)
|
|
320
|
-
v = `translate(${
|
|
320
|
+
v = `translate(${g}, ${p})`;
|
|
321
321
|
else {
|
|
322
|
-
const
|
|
322
|
+
const k = v.match(
|
|
323
323
|
/translate\(([^,]+),([^)]+)\)/
|
|
324
324
|
);
|
|
325
|
-
if (
|
|
326
|
-
const
|
|
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(${
|
|
332
|
+
v = `translate(${g}, ${p}) ${v}`;
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
`g[data-mermaid-wrapper][data-mermaid-id="${
|
|
334
|
+
const I = e.querySelector(
|
|
335
|
+
`g[data-mermaid-wrapper][data-mermaid-id="${h}"][data-mermaid-clone="true"]`
|
|
336
336
|
);
|
|
337
|
-
let
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
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
|
-
|
|
343
|
+
l = document.createElementNS(
|
|
344
344
|
"http://www.w3.org/2000/svg",
|
|
345
345
|
"g"
|
|
346
|
-
),
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
const
|
|
353
|
-
|
|
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
|
-
|
|
355
|
+
x.replace(/px|%/, "") || "0"
|
|
356
356
|
);
|
|
357
|
-
|
|
357
|
+
A > 0 && F > 0 && m.setAttribute(
|
|
358
358
|
"viewBox",
|
|
359
|
-
`0 0 ${
|
|
359
|
+
`0 0 ${A} ${F}`
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
|
|
364
|
-
} catch (
|
|
365
|
-
console.error("[transformMermaidSvgToMarkmapSvg] error: ",
|
|
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 = [],
|
|
382
|
+
let a = "", n = !1, c = [], h = -1;
|
|
383
383
|
for (let p = 0; p < i.length; p++) {
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
386
|
-
n = !0, c = [],
|
|
387
|
-
else if (n &&
|
|
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
|
|
389
|
+
const w = c.join(`
|
|
390
390
|
`);
|
|
391
|
-
|
|
391
|
+
w && a && s.push({
|
|
392
392
|
title: a,
|
|
393
|
-
content:
|
|
394
|
-
index:
|
|
393
|
+
content: w,
|
|
394
|
+
index: h
|
|
395
395
|
}), c = [];
|
|
396
|
-
} else n && c.push(
|
|
396
|
+
} else n && c.push(d);
|
|
397
397
|
}
|
|
398
|
-
const
|
|
398
|
+
const g = (p) => {
|
|
399
399
|
if (!p) return;
|
|
400
|
-
const
|
|
401
|
-
for (const
|
|
402
|
-
if (
|
|
403
|
-
const v =
|
|
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
|
-
|
|
405
|
+
w.content,
|
|
406
406
|
r
|
|
407
407
|
);
|
|
408
|
-
p.content ? p.content = p.content +
|
|
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((
|
|
412
|
-
w
|
|
411
|
+
p.children && p.children.length > 0 && p.children.forEach((w) => {
|
|
412
|
+
g(w);
|
|
413
413
|
});
|
|
414
414
|
};
|
|
415
|
-
return
|
|
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 &&
|
|
445
|
+
this.currentWorkId = t, t && O.extendMarkdown(this, t);
|
|
446
446
|
}
|
|
447
447
|
transform(t, r) {
|
|
448
|
-
this.currentWorkId ?
|
|
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
|
|
530
|
+
const h = new Promise((g) => {
|
|
531
531
|
const p = setTimeout(() => {
|
|
532
|
-
|
|
532
|
+
g();
|
|
533
533
|
}, r);
|
|
534
534
|
if (n.complete && n.naturalWidth > 0) {
|
|
535
|
-
clearTimeout(p),
|
|
535
|
+
clearTimeout(p), g();
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
538
|
-
const
|
|
539
|
-
clearTimeout(p), n.removeEventListener("load",
|
|
540
|
-
},
|
|
541
|
-
clearTimeout(p), n.removeEventListener("load",
|
|
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",
|
|
543
|
+
n.addEventListener("load", d), n.addEventListener("error", f), !n.src && c && (n.src = c);
|
|
544
544
|
});
|
|
545
|
-
i.push(
|
|
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
|
|
573
|
-
|
|
572
|
+
const h = new Image();
|
|
573
|
+
h.crossOrigin = "anonymous", h.onload = () => {
|
|
574
574
|
c(void 0);
|
|
575
|
-
},
|
|
575
|
+
}, h.onerror = () => {
|
|
576
576
|
c(void 0);
|
|
577
|
-
},
|
|
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 (
|
|
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"),
|
|
617
|
-
if (n.querySelector(".mermaid-container") && (c < 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 (
|
|
641
|
-
return console.error("[loadSvgToImageLib] error: ",
|
|
640
|
+
} catch (d) {
|
|
641
|
+
return console.error("[loadSvgToImageLib] error: ", d), null;
|
|
642
642
|
}
|
|
643
|
-
const
|
|
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((
|
|
646
|
+
await new Promise((f) => {
|
|
647
647
|
requestAnimationFrame(() => {
|
|
648
648
|
requestAnimationFrame(() => {
|
|
649
|
-
|
|
649
|
+
f();
|
|
650
650
|
});
|
|
651
651
|
});
|
|
652
652
|
});
|
|
653
|
-
const
|
|
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 =
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
},
|
|
663
|
-
|
|
664
|
-
},
|
|
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 (
|
|
667
|
-
return o.style.width =
|
|
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",
|
|
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,
|
|
712
|
-
return a === c && n ===
|
|
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,
|
|
734
|
-
(!e || e && !this.isSameSize(e)) && (this.element.setAttribute("width", `${c}`), this.element.setAttribute("height", `${
|
|
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,
|
|
744
|
+
var p, d, f;
|
|
745
745
|
(p = this.markmapInstance) == null || p.toggleNode(c);
|
|
746
|
-
const
|
|
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:
|
|
750
|
+
state: h
|
|
751
751
|
},
|
|
752
752
|
!1
|
|
753
|
-
),
|
|
753
|
+
), b.checkNodeHasMermaid(c) && await b.renderMermaidAfterDOMUpdate(
|
|
754
754
|
this.element,
|
|
755
755
|
this.workId
|
|
756
|
-
), this.scenePath && this.collector && ((
|
|
757
|
-
type:
|
|
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 =
|
|
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
|
|
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 &&
|
|
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
|
|
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 ===
|
|
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
|
|
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:
|
|
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
|
|
988
|
+
case y.Destroy: {
|
|
989
989
|
this.destroy();
|
|
990
990
|
break;
|
|
991
991
|
}
|
|
992
|
-
case
|
|
992
|
+
case y.Clear: {
|
|
993
993
|
this.clearAll();
|
|
994
994
|
break;
|
|
995
995
|
}
|
|
996
|
-
case
|
|
996
|
+
case y.UpdateCamera: {
|
|
997
997
|
this.updateCamera(e);
|
|
998
998
|
break;
|
|
999
999
|
}
|
|
1000
|
-
case
|
|
1001
|
-
this.toggleFullLayer(r ===
|
|
1000
|
+
case y.UpdateTools: {
|
|
1001
|
+
this.toggleFullLayer(r === M.Clicker);
|
|
1002
1002
|
break;
|
|
1003
1003
|
}
|
|
1004
|
-
case
|
|
1005
|
-
case
|
|
1006
|
-
case
|
|
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
|
|
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) ===
|
|
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
|
|
1083
|
-
case
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
1175
|
+
var t, r, s, i, a, n;
|
|
1176
|
+
for (const c of e.values()) {
|
|
1177
1177
|
const {
|
|
1178
|
-
msgType:
|
|
1179
|
-
viewId:
|
|
1180
|
-
layerOpt:
|
|
1181
|
-
offscreenCanvasOpt:
|
|
1182
|
-
cameraOpt:
|
|
1183
|
-
tasksqueue:
|
|
1184
|
-
mainTasksqueueCount:
|
|
1185
|
-
} =
|
|
1186
|
-
if (
|
|
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 (
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1193
|
-
const
|
|
1194
|
-
|
|
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:
|
|
1198
|
+
layerOpt: p,
|
|
1197
1199
|
master: this.master,
|
|
1198
|
-
canvasOpt:
|
|
1200
|
+
canvasOpt: d,
|
|
1199
1201
|
post: this.post
|
|
1200
1202
|
});
|
|
1201
|
-
this.backgroundThreadMap.set(
|
|
1203
|
+
this.backgroundThreadMap.set(g, k), k && f && await k.setCameraOpt(f);
|
|
1202
1204
|
}
|
|
1203
1205
|
continue;
|
|
1204
1206
|
}
|
|
1205
|
-
if (
|
|
1206
|
-
const
|
|
1207
|
-
if (
|
|
1208
|
-
|
|
1209
|
-
const
|
|
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:
|
|
1213
|
-
height:
|
|
1214
|
-
},
|
|
1214
|
+
width: f.width,
|
|
1215
|
+
height: f.height
|
|
1216
|
+
}, x = {
|
|
1215
1217
|
...P.defaultScreenCanvasOpt,
|
|
1216
|
-
width:
|
|
1217
|
-
height:
|
|
1218
|
+
width: f.width,
|
|
1219
|
+
height: f.height
|
|
1218
1220
|
};
|
|
1219
|
-
this.snapshotThread = this.createSnapshotThread(
|
|
1220
|
-
displayer:
|
|
1221
|
-
container:
|
|
1222
|
-
layerOpt:
|
|
1221
|
+
this.snapshotThread = this.createSnapshotThread(g, {
|
|
1222
|
+
displayer: l,
|
|
1223
|
+
container: S,
|
|
1224
|
+
layerOpt: k,
|
|
1223
1225
|
master: this.master,
|
|
1224
|
-
canvasOpt:
|
|
1226
|
+
canvasOpt: x,
|
|
1225
1227
|
post: this.post
|
|
1226
|
-
}), await this.snapshotThread.getSnapshot(
|
|
1228
|
+
}), await this.snapshotThread.getSnapshot(c), this.snapshotThread.destroy(), this.snapshotThread = void 0;
|
|
1227
1229
|
continue;
|
|
1228
1230
|
}
|
|
1229
1231
|
}
|
|
1230
|
-
if (
|
|
1231
|
-
for (const [
|
|
1232
|
-
const
|
|
1233
|
-
|
|
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 (
|
|
1238
|
-
for (const
|
|
1239
|
-
|
|
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
|
|
1243
|
-
|
|
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
|
}
|