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