@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.
- package/README.md +31 -0
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +17 -16
- package/dist/{bridge-b23MKtwT.mjs → bridge-B-QptMEy.mjs} +1 -1
- package/dist/{bridge-DLEmhE7Y.js → bridge-hRl_DY0c.js} +1 -1
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/component/backgroundImageLoadCoordinator.d.ts +61 -0
- package/dist/component/svg/base.d.ts +2 -0
- package/dist/component/svg/svgElemt.d.ts +3 -1
- package/dist/component/svg/types.d.ts +2 -0
- package/dist/component/textEditor/types.d.ts +2 -0
- package/dist/core/currentSceneGuard.d.ts +6 -0
- package/dist/core/initReadyBarrier.d.ts +8 -0
- package/dist/core/mainEngine.d.ts +4 -2
- package/dist/core/mainThread/base.d.ts +3 -3
- package/dist/core/mainThread/snapshotThread.d.ts +3 -3
- package/dist/core/mainThread/subLocalThread.d.ts +1 -1
- package/dist/core/mainThread/subServiceThread.d.ts +1 -1
- package/dist/fullWorker.js +85 -85
- package/dist/{index-rhSRO8Tb.mjs → index-1g93HWeU.mjs} +9106 -8749
- package/dist/{index-CDDMgpaL.js → index-B0MSTcdT.js} +1 -1
- package/dist/index-BpRy_vjc.js +570 -0
- package/dist/index-BtNb2M5H.js +1 -0
- package/dist/{index-WifS74pI.mjs → index-BwbqPE3q.mjs} +234 -210
- package/dist/{index-pyv2KvXa.mjs → index-C3e6mT0j.mjs} +221 -201
- package/dist/{index-BSR23bx5.mjs → index-CCO-qEim.mjs} +1 -1
- package/dist/{index-CDbcv4B7.js → index-CgEdhx54.js} +1 -1
- package/dist/index-CgJv1Exy.js +570 -0
- package/dist/{index-GpA_9BZu.mjs → index-DJS3KHjE.mjs} +12695 -12377
- package/dist/{index-C3XOupI-.mjs → index-DUVQmCiI.mjs} +1 -1
- package/dist/index-vIt18mo2.js +1 -0
- package/dist/plugin/applianceMultiPlugin.d.ts +1 -1
- package/dist/plugin/applianceSinglePlugin.d.ts +1 -1
- package/dist/plugin/backgroundImageQuery.d.ts +4 -0
- package/dist/plugin/baseApplianceManager.d.ts +7 -3
- package/dist/plugin/renderingCompatibility.d.ts +2 -1
- package/dist/plugin/types.d.ts +35 -2
- package/dist/subWorker.js +61 -61
- package/package.json +9 -4
- package/dist/index-DKaa5HSe.js +0 -1
- package/dist/index-DoIyQYzA.js +0 -570
- package/dist/index-DwW4gzgA.js +0 -1
- package/dist/index-RKd-OVPO.js +0 -570
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (
|
|
4
|
-
import { E as
|
|
5
|
-
import { isEqual as
|
|
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
|
|
23
|
+
class H extends R {
|
|
22
24
|
constructor() {
|
|
23
25
|
super(...arguments);
|
|
24
|
-
h(this, "emitEventType",
|
|
26
|
+
h(this, "emitEventType", T.CopyNode);
|
|
25
27
|
}
|
|
26
28
|
async consume(t) {
|
|
27
|
-
const { msgType: s, dataType:
|
|
28
|
-
if (s === d.FullWork &&
|
|
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
|
|
34
|
+
var r;
|
|
33
35
|
const { workId: s } = t;
|
|
34
|
-
s && await ((
|
|
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
|
|
45
|
-
return new
|
|
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
|
|
61
|
-
const e =
|
|
62
|
-
if (!
|
|
63
|
-
const
|
|
64
|
-
|
|
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
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
|
|
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
|
|
75
|
-
|
|
76
|
-
|
|
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 =
|
|
85
|
+
}, l.src = i.href.baseVal;
|
|
84
86
|
})
|
|
85
87
|
));
|
|
86
88
|
});
|
|
87
89
|
}), await Promise.all(t);
|
|
88
90
|
}
|
|
89
|
-
async function $(
|
|
91
|
+
async function $(n) {
|
|
90
92
|
const s = Date.now();
|
|
91
|
-
let
|
|
93
|
+
let r = !1;
|
|
92
94
|
for (; Date.now() - s < 5e3; ) {
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
}),
|
|
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((
|
|
101
|
+
await new Promise((o) => setTimeout(o, 50));
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
|
-
async function z(
|
|
103
|
-
const e =
|
|
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
|
|
109
|
-
t.push($(
|
|
110
|
+
const r = e[s];
|
|
111
|
+
t.push($(r));
|
|
110
112
|
}
|
|
111
113
|
await Promise.all(t);
|
|
112
114
|
}
|
|
113
|
-
async function
|
|
114
|
-
if (
|
|
115
|
+
async function P(n) {
|
|
116
|
+
if (n.querySelectorAll("svg[data-type='mermaid']").length > 0) {
|
|
115
117
|
const s = Date.now();
|
|
116
|
-
let
|
|
117
|
-
for (; Date.now() - s < 5e3 && !
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
let
|
|
121
|
-
for (const
|
|
122
|
-
const c = parseFloat(
|
|
123
|
-
if (
|
|
124
|
-
|
|
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 (
|
|
129
|
-
|
|
130
|
+
if (o) {
|
|
131
|
+
r = !0;
|
|
130
132
|
break;
|
|
131
133
|
}
|
|
132
134
|
} else
|
|
133
|
-
|
|
134
|
-
await new Promise((
|
|
135
|
+
r = !0;
|
|
136
|
+
await new Promise((o) => setTimeout(o, 50));
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
|
-
async function G(
|
|
139
|
-
const { width: t =
|
|
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:
|
|
142
|
-
let c =
|
|
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
|
|
147
|
+
c = await o();
|
|
146
148
|
} catch (w) {
|
|
147
149
|
return console.error("[loadSvgToImageLib] error: ", w), null;
|
|
148
150
|
}
|
|
149
|
-
const l =
|
|
150
|
-
|
|
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((
|
|
154
|
+
await new Promise((m) => {
|
|
153
155
|
requestAnimationFrame(() => {
|
|
154
156
|
requestAnimationFrame(() => {
|
|
155
|
-
|
|
157
|
+
m();
|
|
156
158
|
});
|
|
157
159
|
});
|
|
158
160
|
});
|
|
159
|
-
const w = await c.toPng(
|
|
160
|
-
width:
|
|
161
|
-
height:
|
|
161
|
+
const w = await c.toPng(n, {
|
|
162
|
+
width: r,
|
|
163
|
+
height: a,
|
|
162
164
|
quality: 1
|
|
163
165
|
});
|
|
164
|
-
return
|
|
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
|
-
|
|
169
|
+
m(u);
|
|
168
170
|
}, u.onerror = () => {
|
|
169
|
-
|
|
171
|
+
m(null);
|
|
170
172
|
}, u.src = w;
|
|
171
173
|
});
|
|
172
174
|
} catch (w) {
|
|
173
|
-
return
|
|
175
|
+
return n.style.width = l, n.style.height = p, n.style.display = y, console.error("[divToImageElement] error: ", w), null;
|
|
174
176
|
}
|
|
175
|
-
} catch (
|
|
176
|
-
return console.error("[divToImageElement] error: ",
|
|
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",
|
|
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
|
-
|
|
190
|
-
this
|
|
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:
|
|
218
|
-
return
|
|
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:
|
|
222
|
-
return
|
|
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
|
|
237
|
+
return I(t, s);
|
|
231
238
|
}
|
|
232
239
|
isSameData(e) {
|
|
233
240
|
const { data: t } = e, { data: s } = this.workOptions;
|
|
234
|
-
return
|
|
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:
|
|
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 = `${
|
|
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
|
|
246
|
-
if (this.markmapInstance || (this.markmapInstance =
|
|
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,
|
|
257
|
+
var w, m, u;
|
|
251
258
|
(w = this.markmapInstance) == null || w.toggleNode(l);
|
|
252
|
-
const
|
|
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:
|
|
263
|
+
state: p
|
|
257
264
|
},
|
|
258
265
|
!1
|
|
259
|
-
),
|
|
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
|
|
273
|
-
let { root:
|
|
274
|
-
|
|
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,
|
|
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:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
327
|
+
var r;
|
|
314
328
|
const t = [e], s = [];
|
|
315
329
|
for (; t.length > 0; ) {
|
|
316
|
-
const
|
|
317
|
-
|
|
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
|
|
325
|
-
|
|
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 (!
|
|
333
|
-
const s =
|
|
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.
|
|
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
|
|
351
|
-
const { toolsType: e, ...t } =
|
|
368
|
+
function C(n) {
|
|
369
|
+
const { toolsType: e, ...t } = n;
|
|
352
370
|
switch (e) {
|
|
353
|
-
case
|
|
371
|
+
case k.BackgroundSVG:
|
|
354
372
|
return new X(t);
|
|
355
373
|
default:
|
|
356
374
|
return;
|
|
357
375
|
}
|
|
358
376
|
}
|
|
359
|
-
class
|
|
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
|
|
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",
|
|
423
|
+
h(this, "updateCamera", D(async (e) => {
|
|
406
424
|
const { cameraOpt: t } = e;
|
|
407
|
-
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
|
-
|
|
411
|
-
]).registerForBackgroundThread(this), this.vNodes = new
|
|
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:
|
|
448
|
+
const { scale: s, centerX: r, centerY: a, width: o, height: i } = this.camera;
|
|
431
449
|
return {
|
|
432
|
-
x: (e -
|
|
433
|
-
y: (t -
|
|
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 ===
|
|
465
|
+
return e === k.BackgroundSVG;
|
|
448
466
|
}
|
|
449
467
|
async consumeFull(e) {
|
|
450
|
-
const { toolsType: t, opt: s, workId: a } = e;
|
|
451
|
-
if (
|
|
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
|
|
471
|
+
case k.BackgroundSVG:
|
|
454
472
|
await this.setFullWork({
|
|
455
473
|
toolsType: t,
|
|
456
474
|
opt: s,
|
|
457
|
-
workId:
|
|
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
|
|
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
|
|
468
|
-
return !
|
|
486
|
+
const c = this.vNodes.get(o);
|
|
487
|
+
return !c || !c.workShape ? (i = this.createWorkShapeNode({
|
|
469
488
|
toolsOpt: s,
|
|
470
|
-
toolsType:
|
|
471
|
-
workId:
|
|
472
|
-
|
|
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
|
|
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 ===
|
|
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
|
|
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,
|
|
580
|
+
const { width: t, height: s } = e.canvasOpt, r = new OffscreenCanvas(
|
|
561
581
|
e.canvasOpt.width,
|
|
562
582
|
e.canvasOpt.height
|
|
563
583
|
);
|
|
564
|
-
|
|
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:
|
|
594
|
+
const { scale: s, centerX: r, centerY: a, width: o, height: i } = this.camera;
|
|
575
595
|
return {
|
|
576
|
-
x: (e -
|
|
577
|
-
y: (t -
|
|
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:
|
|
582
|
-
if (t && s &&
|
|
583
|
-
await this.setCameraOpt(
|
|
584
|
-
for (const [
|
|
585
|
-
if (
|
|
586
|
-
switch (
|
|
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:
|
|
590
|
-
...
|
|
591
|
-
opt:
|
|
592
|
-
workId:
|
|
609
|
+
const { opt: i } = o, c = {
|
|
610
|
+
...o,
|
|
611
|
+
opt: i,
|
|
612
|
+
workId: a,
|
|
593
613
|
msgType: d.FullWork,
|
|
594
|
-
dataType:
|
|
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
|
|
604
|
-
const
|
|
605
|
-
|
|
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:
|
|
631
|
+
imageElement: a,
|
|
611
632
|
viewId: this.viewId,
|
|
612
633
|
index: 1
|
|
613
634
|
}
|
|
614
635
|
]
|
|
615
636
|
});
|
|
616
637
|
}
|
|
617
|
-
} catch (
|
|
618
|
-
const
|
|
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: ${
|
|
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
|
|
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
|
|
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
|
|
643
|
-
return !
|
|
664
|
+
const c = this.vNodes.get(o);
|
|
665
|
+
return !c || !c.workShape ? (i = this.createWorkShapeNode({
|
|
644
666
|
toolsOpt: s,
|
|
645
|
-
toolsType:
|
|
646
|
-
workId:
|
|
647
|
-
|
|
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:
|
|
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
|
|
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,
|
|
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:
|
|
685
|
-
layerOpt:
|
|
708
|
+
viewId: p,
|
|
709
|
+
layerOpt: y,
|
|
686
710
|
offscreenCanvasOpt: w,
|
|
687
|
-
cameraOpt:
|
|
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(
|
|
696
|
-
if (g && v &&
|
|
697
|
-
const f = this.backgroundThreadMap.get(
|
|
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(
|
|
723
|
+
const S = this.createBackgroundThread(p, {
|
|
700
724
|
displayer: g,
|
|
701
725
|
container: v,
|
|
702
|
-
layerOpt:
|
|
726
|
+
layerOpt: y,
|
|
703
727
|
master: this.master,
|
|
704
728
|
canvasOpt: w,
|
|
705
729
|
post: this.post
|
|
706
730
|
});
|
|
707
|
-
this.backgroundThreadMap.set(
|
|
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 = (
|
|
713
|
-
if (g && f &&
|
|
714
|
-
(
|
|
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:
|
|
719
|
-
height:
|
|
720
|
-
},
|
|
742
|
+
width: m.width,
|
|
743
|
+
height: m.height
|
|
744
|
+
}, B = {
|
|
721
745
|
...b.defaultScreenCanvasOpt,
|
|
722
|
-
width:
|
|
723
|
-
height:
|
|
746
|
+
width: m.width,
|
|
747
|
+
height: m.height
|
|
724
748
|
};
|
|
725
|
-
this.snapshotThread = this.createSnapshotThread(
|
|
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:
|
|
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 (
|
|
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(
|
|
750
|
-
O && (await O.on(c), l === d.Destroy && this.backgroundThreadMap.delete(
|
|
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
|
-
|
|
790
|
+
he as BackgroundThreadManagerImpl
|
|
767
791
|
};
|