web3dlink 2.1.11 → 2.1.13
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/dist/web3dlink.js +295 -444
- package/dist/web3dlink.js.map +1 -1
- package/package.json +2 -5
package/dist/web3dlink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
-
var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), name = "web3dlink", version$1 = "2.1.
|
|
2
|
+
var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), name = "web3dlink", version$1 = "2.1.13", description = "LarkSR / ZS 推流 GameAPI SDK", type = "module", main = "./dist/web3dlink.js", module$1 = "./dist/web3dlink.js", exports$1 = { ".": {
|
|
3
3
|
import: "./dist/web3dlink.js",
|
|
4
4
|
default: "./dist/web3dlink.js"
|
|
5
5
|
} }, files = ["dist"], scripts = {
|
|
@@ -11,12 +11,7 @@ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t),
|
|
|
11
11
|
"game-api",
|
|
12
12
|
"streaming",
|
|
13
13
|
"web3dlink"
|
|
14
|
-
], license = "MIT", sideEffects = [
|
|
15
|
-
"./dist/web3dlink.js",
|
|
16
|
-
"./index.js",
|
|
17
|
-
"./version.js",
|
|
18
|
-
"./zs-stream-parent.js"
|
|
19
|
-
], package_default = {
|
|
14
|
+
], license = "MIT", sideEffects = ["./dist/web3dlink.js"], package_default = {
|
|
20
15
|
name,
|
|
21
16
|
version: version$1,
|
|
22
17
|
description,
|
|
@@ -29,369 +24,11 @@ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t),
|
|
|
29
24
|
keywords,
|
|
30
25
|
license: "MIT",
|
|
31
26
|
sideEffects
|
|
32
|
-
}, version = package_default.version;
|
|
27
|
+
}, version = package_default.version, logStyle = "background: #22c55e; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: 600;";
|
|
28
|
+
console.log(`%c [web3dlink] version: ${version} `, logStyle), console.log("%c [larksr_websdk] version: 3.3.119 ", logStyle);
|
|
33
29
|
//#endregion
|
|
34
|
-
//#region
|
|
35
|
-
|
|
36
|
-
let t = "zs-stream-parent", n = "zs-stream-embed";
|
|
37
|
-
function r(e) {
|
|
38
|
-
return e ? typeof e == "string" ? document.querySelector(e) : e : null;
|
|
39
|
-
}
|
|
40
|
-
function i(e, t, n) {
|
|
41
|
-
let r = (e || "").replace(/\/+$/, "") || (typeof location < "u" ? location.origin : ""), i = new URLSearchParams({
|
|
42
|
-
template: t || "default",
|
|
43
|
-
autoconnect: "1",
|
|
44
|
-
muted: "1"
|
|
45
|
-
});
|
|
46
|
-
return n && i.set("streamId", n), `${r}/embed?${i.toString()}`;
|
|
47
|
-
}
|
|
48
|
-
function a(e, n, r) {
|
|
49
|
-
return e?.contentWindow ? (e.contentWindow.postMessage({
|
|
50
|
-
source: t,
|
|
51
|
-
streamId: n,
|
|
52
|
-
...r
|
|
53
|
-
}, "*"), { ok: !0 }) : {
|
|
54
|
-
ok: !1,
|
|
55
|
-
error: "iframe 未就绪"
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
class o {
|
|
59
|
-
constructor({ streamId: t, template: n, container: i, baseUrl: a } = {}) {
|
|
60
|
-
if (!t) throw Error("ZsStream: streamId 必填(同页多路时用于区分)");
|
|
61
|
-
this.streamId = t, this.template = n || "default", this.baseUrl = a, this.container = r(i), this.iframe = null, this._handlers = /* @__PURE__ */ new Map(), this._ready = !1, this._inputReady = !1, this._onMessage = this._onMessage.bind(this), e.addEventListener("message", this._onMessage), this._mountIframe();
|
|
62
|
-
}
|
|
63
|
-
_mountIframe() {
|
|
64
|
-
if (!this.container) throw Error("ZsStream: container 未找到");
|
|
65
|
-
let e = document.createElement("iframe");
|
|
66
|
-
e.src = i(this.baseUrl, this.template, this.streamId), e.style.width = "100%", e.style.height = "100%", e.style.border = "0", e.setAttribute("allow", "autoplay; fullscreen; encrypted-media"), e.title = `ZS Stream ${this.streamId}`, this.container.innerHTML = "", this.container.appendChild(e), this.iframe = e;
|
|
67
|
-
}
|
|
68
|
-
_onMessage(e) {
|
|
69
|
-
let t = e.data;
|
|
70
|
-
if (!t || t.source !== n || t.streamId && t.streamId !== this.streamId || t.type !== "event") return;
|
|
71
|
-
let r = t.event;
|
|
72
|
-
r === "ready" && (this._ready = !0), r === "inputready" && (this._inputReady = !0), this._emit(r, t.data);
|
|
73
|
-
}
|
|
74
|
-
_emit(e, t) {
|
|
75
|
-
let n = this._handlers.get(e);
|
|
76
|
-
if (n) for (let e of n) try {
|
|
77
|
-
e(t);
|
|
78
|
-
} catch (e) {
|
|
79
|
-
console.error("[ZsStream]", e);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
on(e, t) {
|
|
83
|
-
return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this.off(e, t);
|
|
84
|
-
}
|
|
85
|
-
off(e, t) {
|
|
86
|
-
this._handlers.get(e)?.delete(t);
|
|
87
|
-
}
|
|
88
|
-
_send(e, t) {
|
|
89
|
-
return a(this.iframe, this.streamId, {
|
|
90
|
-
type: e,
|
|
91
|
-
...t
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
invoke(e, t, n) {
|
|
95
|
-
return this._send("invoke", {
|
|
96
|
-
module: e,
|
|
97
|
-
action: t,
|
|
98
|
-
params: n ?? {}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
camera(e, t) {
|
|
102
|
-
return this._send("camera", {
|
|
103
|
-
action: e,
|
|
104
|
-
params: t ?? {}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
sendRaw(e) {
|
|
108
|
-
return this._send("sendRaw", { descriptor: String(e) });
|
|
109
|
-
}
|
|
110
|
-
sendCommand(e, t) {
|
|
111
|
-
return this._send("larkCommand", {
|
|
112
|
-
command: e,
|
|
113
|
-
params: t ?? {}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
sendTextToDataChannel(e) {
|
|
117
|
-
let t = typeof e == "string" ? e : JSON.stringify({
|
|
118
|
-
command: e.command,
|
|
119
|
-
params: e.params ?? {}
|
|
120
|
-
});
|
|
121
|
-
return this._send("sendRaw", { descriptor: t });
|
|
122
|
-
}
|
|
123
|
-
disconnect() {
|
|
124
|
-
return this._send("disconnect", {});
|
|
125
|
-
}
|
|
126
|
-
destroy() {
|
|
127
|
-
e.removeEventListener("message", this._onMessage), this.disconnect(), this.iframe?.parentNode && this.iframe.parentNode.removeChild(this.iframe), this.iframe = null, this._handlers.clear();
|
|
128
|
-
}
|
|
129
|
-
get isReady() {
|
|
130
|
-
return this._ready;
|
|
131
|
-
}
|
|
132
|
-
get isInputReady() {
|
|
133
|
-
return this._inputReady;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
class s {
|
|
137
|
-
constructor() {
|
|
138
|
-
this._streams = /* @__PURE__ */ new Map();
|
|
139
|
-
}
|
|
140
|
-
mount(e) {
|
|
141
|
-
let t = e?.streamId;
|
|
142
|
-
if (!t) throw Error("ZsStreamHub.mount: streamId 必填");
|
|
143
|
-
this._streams.has(t) && this._streams.get(t).destroy();
|
|
144
|
-
let n = new o(e);
|
|
145
|
-
return this._streams.set(t, n), n;
|
|
146
|
-
}
|
|
147
|
-
get(e) {
|
|
148
|
-
return this._streams.get(e) || null;
|
|
149
|
-
}
|
|
150
|
-
has(e) {
|
|
151
|
-
return this._streams.has(e);
|
|
152
|
-
}
|
|
153
|
-
destroy(e) {
|
|
154
|
-
let t = this._streams.get(e);
|
|
155
|
-
t && (t.destroy(), this._streams.delete(e));
|
|
156
|
-
}
|
|
157
|
-
destroyAll() {
|
|
158
|
-
for (let e of [...this._streams.keys()]) this.destroy(e);
|
|
159
|
-
}
|
|
160
|
-
list() {
|
|
161
|
-
return [...this._streams.keys()];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
e.ZsStream = {
|
|
165
|
-
mount(e) {
|
|
166
|
-
return new o(e);
|
|
167
|
-
},
|
|
168
|
-
Hub: s,
|
|
169
|
-
buildEmbedSrc: i,
|
|
170
|
-
MSG_SOURCE_PARENT: t,
|
|
171
|
-
MSG_SOURCE_EMBED: n
|
|
172
|
-
}, e.ZsStreamHub = s;
|
|
173
|
-
})(typeof window < "u" ? window : globalThis);
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region ../baseConfig/responses.js
|
|
176
|
-
function normalizeMessageList(e) {
|
|
177
|
-
return (Array.isArray(e) ? e : [e]).map((e) => {
|
|
178
|
-
if (typeof e == "string") return e;
|
|
179
|
-
if (e && typeof e == "object") {
|
|
180
|
-
if (typeof e.message == "string" && e.message) return e.message;
|
|
181
|
-
try {
|
|
182
|
-
return JSON.stringify(e);
|
|
183
|
-
} catch {
|
|
184
|
-
return String(e);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return e == null ? "" : String(e);
|
|
188
|
-
}).filter((e) => e !== "");
|
|
189
|
-
}
|
|
190
|
-
function createSuccessResponse(e, t, n) {
|
|
191
|
-
return {
|
|
192
|
-
success: !0,
|
|
193
|
-
message: e,
|
|
194
|
-
data: t,
|
|
195
|
-
command: n
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function createErrorResponse(e, t, n) {
|
|
199
|
-
let r = {
|
|
200
|
-
success: !1,
|
|
201
|
-
message: normalizeMessageList(e),
|
|
202
|
-
params: t,
|
|
203
|
-
command: n
|
|
204
|
-
};
|
|
205
|
-
return console.error("三维场景报错:", r), r;
|
|
206
|
-
}
|
|
207
|
-
function createWarnResponse(e, t, n) {
|
|
208
|
-
let r = {
|
|
209
|
-
success: !1,
|
|
210
|
-
message: normalizeMessageList(e),
|
|
211
|
-
params: t,
|
|
212
|
-
command: n
|
|
213
|
-
};
|
|
214
|
-
return console.warn("三维场景警告:", r), r;
|
|
215
|
-
}
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region ../baseConfig/logger.js
|
|
218
|
-
var ueLogEnabled = !0;
|
|
219
|
-
function setUELogEnabled(e) {
|
|
220
|
-
ueLogEnabled = !!e;
|
|
221
|
-
}
|
|
222
|
-
function log(...e) {
|
|
223
|
-
ueLogEnabled && console.log(...e);
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region commFlow.js
|
|
227
|
-
var CommandManager = class {
|
|
228
|
-
constructor(e) {
|
|
229
|
-
this.transport = e, this.callbacks = {}, this.requestId = 0, this.timeout = 3e3, this.markerEventCallbacks = {
|
|
230
|
-
Hovered: {},
|
|
231
|
-
Click: {},
|
|
232
|
-
DoubleClick: {},
|
|
233
|
-
Unhovered: {}
|
|
234
|
-
}, this.secondMarkerEventCallbacks = {
|
|
235
|
-
Hovered: {},
|
|
236
|
-
Click: {},
|
|
237
|
-
DoubleClick: {},
|
|
238
|
-
Unhovered: {}
|
|
239
|
-
}, this.followMarkerEventCallbacks = {
|
|
240
|
-
Hovered: {},
|
|
241
|
-
Click: {},
|
|
242
|
-
DoubleClick: {},
|
|
243
|
-
Unhovered: {}
|
|
244
|
-
}, this.animationOnDataCallback = { Change: [] }, this.mouseClickCallback = { MouseClick: [] }, this.vtkMouseClickCallback = {}, e.bindMessageHandler((e) => {
|
|
245
|
-
this._handleRawResponse(e);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
sendWithDefault(e, t, n = {}) {
|
|
249
|
-
let r = this._sendPreparePayload(t, e.normalized || {});
|
|
250
|
-
if (e.errors.length > 0) return createErrorResponse(e.errors, r, t);
|
|
251
|
-
let i = (++this.requestId).toString(), a = n?.timeout === 0 ? 0 : this.timeout, o = new Promise((e, t) => {
|
|
252
|
-
let n = null;
|
|
253
|
-
a !== 0 && (n = setTimeout(() => {
|
|
254
|
-
delete this.callbacks[i], t(/* @__PURE__ */ Error("Command timeout with no results"));
|
|
255
|
-
}, a)), this.callbacks[i] = {
|
|
256
|
-
resolve: e,
|
|
257
|
-
reject: t,
|
|
258
|
-
timeoutId: n
|
|
259
|
-
};
|
|
260
|
-
}), s = {
|
|
261
|
-
command: t,
|
|
262
|
-
requestId: i,
|
|
263
|
-
params: r
|
|
264
|
-
};
|
|
265
|
-
return log("消息下发成功:", s), this.transport.sendTextToDataChannel(JSON.stringify(s)), o.then((e) => {
|
|
266
|
-
if (e && e.command && e.command === t) switch (e.status) {
|
|
267
|
-
case "info": return createSuccessResponse("操作执行成功", e.data, t);
|
|
268
|
-
case "warn": return createWarnResponse(e.message, e.data, t);
|
|
269
|
-
default: return createErrorResponse(e.message, e.data, t);
|
|
270
|
-
}
|
|
271
|
-
return createErrorResponse("返回数据格式错乱【请注意command参数】", e?.command, t);
|
|
272
|
-
}).catch((e) => e && e.message ? e.message === "Command timeout with no results" ? createWarnResponse(e.message, r, t) : createErrorResponse(e.message, r, t) : createErrorResponse("数据返回发生错误", r, t));
|
|
273
|
-
}
|
|
274
|
-
_handleRawResponse(e) {
|
|
275
|
-
if (!e) return console.error("数据第一步解析失败:", e), null;
|
|
276
|
-
let t;
|
|
277
|
-
try {
|
|
278
|
-
let n = JSON.parse(String(e).trim());
|
|
279
|
-
if (t = {
|
|
280
|
-
command: n.command || "",
|
|
281
|
-
message: n.message || "",
|
|
282
|
-
data: n.data || {},
|
|
283
|
-
status: n.status || "error",
|
|
284
|
-
requestId: n.requestId || ""
|
|
285
|
-
}, t.message === "The data channel has been connected." || t.message === "The level has been initialized") return null;
|
|
286
|
-
} catch {
|
|
287
|
-
return console.error("数据第二步解析失败:", e), null;
|
|
288
|
-
}
|
|
289
|
-
if (this._processEventResponse(t)) return;
|
|
290
|
-
let { command: n, message: r, data: i, status: a, requestId: o } = t;
|
|
291
|
-
if (o && this.callbacks[o]) {
|
|
292
|
-
let { resolve: e, timeoutId: t } = this.callbacks[o];
|
|
293
|
-
clearTimeout(t), delete this.callbacks[o], e({
|
|
294
|
-
command: n,
|
|
295
|
-
message: r,
|
|
296
|
-
data: i,
|
|
297
|
-
status: a
|
|
298
|
-
});
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
console.warn("注意:非常规响应", t);
|
|
302
|
-
}
|
|
303
|
-
_sendPreparePayload(e, t) {
|
|
304
|
-
if (e === "marker.iconMarker" || e === "marker.iconUrlMarker") {
|
|
305
|
-
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
306
|
-
return c != null && c !== "" ? (typeof i == "function" && (this.markerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.markerEventCallbacks.Click[c] = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.markerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.markerEventCallbacks.Click.__default = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered.__default = a)), o;
|
|
307
|
-
}
|
|
308
|
-
if (e === "marker.secondMarker") {
|
|
309
|
-
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
310
|
-
return c != null && c !== "" ? (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
311
|
-
}
|
|
312
|
-
if (e === "marker.followMarker") {
|
|
313
|
-
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
314
|
-
return c != null && c !== "" ? (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
315
|
-
}
|
|
316
|
-
if (e === "tool.onMouseClick") {
|
|
317
|
-
let { onMouseClick: e, ...n } = t || {};
|
|
318
|
-
return typeof e == "function" && (Array.isArray(this.mouseClickCallback.MouseClick) || (this.mouseClickCallback.MouseClick = []), this.mouseClickCallback.MouseClick.includes(e) || this.mouseClickCallback.MouseClick.push(e)), n;
|
|
319
|
-
}
|
|
320
|
-
if (e === "VTK.onMouseClick") {
|
|
321
|
-
let { onMouseClick: e, ...n } = t || {}, r = n?.id;
|
|
322
|
-
return r != null && r !== "" && typeof e == "function" && (this.vtkMouseClickCallback[r] = e), n;
|
|
323
|
-
}
|
|
324
|
-
if (e === "VTK.offMouseClick") {
|
|
325
|
-
let e = t?.id;
|
|
326
|
-
return e != null && e !== "" && delete this.vtkMouseClickCallback[e], t;
|
|
327
|
-
}
|
|
328
|
-
if (e === "animation.onData") {
|
|
329
|
-
let { onChange: e, ...n } = t || {};
|
|
330
|
-
return typeof e == "function" && (Array.isArray(this.animationOnDataCallback.Change) || (this.animationOnDataCallback.Change = []), this.animationOnDataCallback.Change.includes(e) || this.animationOnDataCallback.Change.push(e)), n;
|
|
331
|
-
}
|
|
332
|
-
return t;
|
|
333
|
-
}
|
|
334
|
-
_processEventResponse(e) {
|
|
335
|
-
if (!e) return !1;
|
|
336
|
-
let { command: t, data: n = {} } = e;
|
|
337
|
-
if (t === "marker.iconMarker" || t === "marker.iconUrlMarker") {
|
|
338
|
-
if (typeof n.recordData == "string") try {
|
|
339
|
-
n.recordData = JSON.parse(n.recordData);
|
|
340
|
-
} catch {}
|
|
341
|
-
let { pointId: e, eventType: r } = n;
|
|
342
|
-
if (!(r && this.markerEventCallbacks)) return !1;
|
|
343
|
-
let i = this.markerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
344
|
-
return this._executeCallback(a, t, n);
|
|
345
|
-
}
|
|
346
|
-
if (t === "marker.secondMarker") {
|
|
347
|
-
if (typeof n.recordData == "string") try {
|
|
348
|
-
n.recordData = JSON.parse(n.recordData);
|
|
349
|
-
} catch {}
|
|
350
|
-
let { pointId: e, eventType: r } = n;
|
|
351
|
-
if (!(r && this.secondMarkerEventCallbacks)) return !1;
|
|
352
|
-
let i = this.secondMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
353
|
-
return this._executeCallback(a, t, n);
|
|
354
|
-
}
|
|
355
|
-
if (t === "marker.followMarker") {
|
|
356
|
-
if (typeof n.recordData == "string") try {
|
|
357
|
-
n.recordData = JSON.parse(n.recordData);
|
|
358
|
-
} catch {}
|
|
359
|
-
let { pointId: e, eventType: r } = n;
|
|
360
|
-
if (!(r && this.followMarkerEventCallbacks)) return !1;
|
|
361
|
-
let i = this.followMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
362
|
-
return this._executeCallback(a, t, n);
|
|
363
|
-
}
|
|
364
|
-
if (t === "tool.onMouseClick") {
|
|
365
|
-
let { coordinates: e } = n;
|
|
366
|
-
if (!(e && this.mouseClickCallback)) return !1;
|
|
367
|
-
let r = this.mouseClickCallback.MouseClick;
|
|
368
|
-
return this._executeCallbacks(r, t, n);
|
|
369
|
-
}
|
|
370
|
-
if (t === "VTK.onMouseClick") {
|
|
371
|
-
if (!this.vtkMouseClickCallback || !Object.keys(this.vtkMouseClickCallback).length) return !1;
|
|
372
|
-
let e = n?.id, r = e ? this.vtkMouseClickCallback[e] : null;
|
|
373
|
-
return r ? this._executeCallback(r, t, n) : this._executeCallbacks(Object.values(this.vtkMouseClickCallback), t, n);
|
|
374
|
-
}
|
|
375
|
-
if (t === "animation.onData") {
|
|
376
|
-
let { type: e } = n;
|
|
377
|
-
if (!(e && this.animationOnDataCallback)) return !1;
|
|
378
|
-
let r = this.animationOnDataCallback.Change;
|
|
379
|
-
return this._executeCallbacks(r, t, n);
|
|
380
|
-
}
|
|
381
|
-
return !1;
|
|
382
|
-
}
|
|
383
|
-
_executeCallback(e, t, n) {
|
|
384
|
-
if (typeof e != "function") return log(`${t}未监听:${n.eventType}`), !0;
|
|
385
|
-
try {
|
|
386
|
-
return e(n), !0;
|
|
387
|
-
} catch (e) {
|
|
388
|
-
return console.error(`执行${t}回调出错:`, e, n), !0;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
_executeCallbacks(e, t, n) {
|
|
392
|
-
return e ? Array.isArray(e) ? (e.forEach((e) => this._executeCallback(e, t, n)), !0) : this._executeCallback(e, t, n) : !1;
|
|
393
|
-
}
|
|
394
|
-
}, lightpink = "#FFB6C1", pink = "#FFC0CB", crimson = "#DC143C", lavenderblush = "#FFF0F5", palevioletred = "#DB7093", hotpink = "#FF69B4", deeppink = "#FF1493", mediumvioletred = "#C71585", orchid = "#DA70D6", thistle = "#D8BFD8", plum = "#DDA0DD", violet = "#EE82EE", magenta = "#FF00FF", fuchsia = "#FF00FF", darkmagenta = "#8B008B", purple = "#800080", mediumorchid = "#BA55D3", darkvoilet = "#9400D3", darkorchid = "#9932CC", indigo = "#4B0082", blueviolet = "#8A2BE2", mediumpurple = "#9370DB", mediumslateblue = "#7B68EE", slateblue = "#6A5ACD", darkslateblue = "#483D8B", lavender = "#E6E6FA", ghostwhite = "#F8F8FF", blue = "#0000FF", mediumblue = "#0000CD", midnightblue = "#191970", darkblue = "#00008B", navy = "#000080", royalblue = "#4169E1", cornflowerblue = "#6495ED", lightsteelblue = "#B0C4DE", lightslategray = "#778899", slategray = "#708090", doderblue = "#1E90FF", aliceblue = "#F0F8FF", steelblue = "#4682B4", lightskyblue = "#87CEFA", skyblue = "#87CEEB", deepskyblue = "#00BFFF", lightblue = "#ADD8E6", powderblue = "#B0E0E6", cadetblue = "#5F9EA0", azure = "#F0FFFF", lightcyan = "#E1FFFF", paleturquoise = "#AFEEEE", cyan = "#00FFFF", aqua = "#D4F2E7", darkturquoise = "#00CED1", darkslategray = "#2F4F4F", darkcyan = "#008B8B", teal = "#008080", mediumturquoise = "#48D1CC", lightseagreen = "#20B2AA", turquoise = "#40E0D0", auqamarin = "#7FFFAA", mediumaquamarine = "#00FA9A", mediumspringgreen = "#00FF7F", mintcream = "#F5FFFA", springgreen = "#3CB371", seagreen = "#2E8B57", honeydew = "#F0FFF0", lightgreen = "#90EE90", palegreen = "#98FB98", darkseagreen = "#8FBC8F", limegreen = "#32CD32", lime = "#00FF00", forestgreen = "#228B22", green = "#008000", darkgreen = "#006400", chartreuse = "#7FFF00", lawngreen = "#7CFC00", greenyellow = "#ADFF2F", olivedrab = "#556B2F", beige = "#F5F5DC", lightgoldenrodyellow = "#FAFAD2", ivory = "#FFFFF0", lightyellow = "#FFFFE0", yellow = "#FFFF00", olive = "#808000", darkkhaki = "#BDB76B", lemonchiffon = "#FFFACD", palegodenrod = "#EEE8AA", khaki = "#F0E68C", gold = "#FFD700", cornislk = "#FFF8DC", goldenrod = "#DAA520", floralwhite = "#FFFAF0", oldlace = "#FDF5E6", wheat = "#F5DEB3", moccasin = "#FFE4B5", orange = "#FFA500", papayawhip = "#FFEFD5", blanchedalmond = "#FFEBCD", navajowhite = "#FFDEAD", antiquewhite = "#FAEBD7", tan = "#D2B48C", brulywood = "#DEB887", bisque = "#FFE4C4", darkorange = "#FF8C00", linen = "#FAF0E6", peru = "#CD853F", peachpuff = "#FFDAB9", sandybrown = "#F4A460", chocolate = "#D2691E", saddlebrown = "#8B4513", seashell = "#FFF5EE", sienna = "#A0522D", lightsalmon = "#FFA07A", coral = "#FF7F50", orangered = "#FF4500", darksalmon = "#E9967A", tomato = "#FF6347", mistyrose = "#FFE4E1", salmon = "#FA8072", snow = "#FFFAFA", lightcoral = "#F08080", rosybrown = "#BC8F8F", indianred = "#CD5C5C", red = "#FF0000", brown = "#A52A2A", firebrick = "#B22222", darkred = "#8B0000", maroon = "#800000", white = "#FFFFFF", whitesmoke = "#F5F5F5", gainsboro = "#DCDCDC", lightgrey = "#D3D3D3", silver = "#C0C0C0", darkgray = "#A9A9A9", gray = "#808080", dimgray = "#696969", black = "#000000", colorCodeData_default = {
|
|
30
|
+
//#region baseConfig/color/colorCodeData.json
|
|
31
|
+
var lightpink = "#FFB6C1", pink = "#FFC0CB", crimson = "#DC143C", lavenderblush = "#FFF0F5", palevioletred = "#DB7093", hotpink = "#FF69B4", deeppink = "#FF1493", mediumvioletred = "#C71585", orchid = "#DA70D6", thistle = "#D8BFD8", plum = "#DDA0DD", violet = "#EE82EE", magenta = "#FF00FF", fuchsia = "#FF00FF", darkmagenta = "#8B008B", purple = "#800080", mediumorchid = "#BA55D3", darkvoilet = "#9400D3", darkorchid = "#9932CC", indigo = "#4B0082", blueviolet = "#8A2BE2", mediumpurple = "#9370DB", mediumslateblue = "#7B68EE", slateblue = "#6A5ACD", darkslateblue = "#483D8B", lavender = "#E6E6FA", ghostwhite = "#F8F8FF", blue = "#0000FF", mediumblue = "#0000CD", midnightblue = "#191970", darkblue = "#00008B", navy = "#000080", royalblue = "#4169E1", cornflowerblue = "#6495ED", lightsteelblue = "#B0C4DE", lightslategray = "#778899", slategray = "#708090", doderblue = "#1E90FF", aliceblue = "#F0F8FF", steelblue = "#4682B4", lightskyblue = "#87CEFA", skyblue = "#87CEEB", deepskyblue = "#00BFFF", lightblue = "#ADD8E6", powderblue = "#B0E0E6", cadetblue = "#5F9EA0", azure = "#F0FFFF", lightcyan = "#E1FFFF", paleturquoise = "#AFEEEE", cyan = "#00FFFF", aqua = "#D4F2E7", darkturquoise = "#00CED1", darkslategray = "#2F4F4F", darkcyan = "#008B8B", teal = "#008080", mediumturquoise = "#48D1CC", lightseagreen = "#20B2AA", turquoise = "#40E0D0", auqamarin = "#7FFFAA", mediumaquamarine = "#00FA9A", mediumspringgreen = "#00FF7F", mintcream = "#F5FFFA", springgreen = "#3CB371", seagreen = "#2E8B57", honeydew = "#F0FFF0", lightgreen = "#90EE90", palegreen = "#98FB98", darkseagreen = "#8FBC8F", limegreen = "#32CD32", lime = "#00FF00", forestgreen = "#228B22", green = "#008000", darkgreen = "#006400", chartreuse = "#7FFF00", lawngreen = "#7CFC00", greenyellow = "#ADFF2F", olivedrab = "#556B2F", beige = "#F5F5DC", lightgoldenrodyellow = "#FAFAD2", ivory = "#FFFFF0", lightyellow = "#FFFFE0", yellow = "#FFFF00", olive = "#808000", darkkhaki = "#BDB76B", lemonchiffon = "#FFFACD", palegodenrod = "#EEE8AA", khaki = "#F0E68C", gold = "#FFD700", cornislk = "#FFF8DC", goldenrod = "#DAA520", floralwhite = "#FFFAF0", oldlace = "#FDF5E6", wheat = "#F5DEB3", moccasin = "#FFE4B5", orange = "#FFA500", papayawhip = "#FFEFD5", blanchedalmond = "#FFEBCD", navajowhite = "#FFDEAD", antiquewhite = "#FAEBD7", tan = "#D2B48C", brulywood = "#DEB887", bisque = "#FFE4C4", darkorange = "#FF8C00", linen = "#FAF0E6", peru = "#CD853F", peachpuff = "#FFDAB9", sandybrown = "#F4A460", chocolate = "#D2691E", saddlebrown = "#8B4513", seashell = "#FFF5EE", sienna = "#A0522D", lightsalmon = "#FFA07A", coral = "#FF7F50", orangered = "#FF4500", darksalmon = "#E9967A", tomato = "#FF6347", mistyrose = "#FFE4E1", salmon = "#FA8072", snow = "#FFFAFA", lightcoral = "#F08080", rosybrown = "#BC8F8F", indianred = "#CD5C5C", red = "#FF0000", brown = "#A52A2A", firebrick = "#B22222", darkred = "#8B0000", maroon = "#800000", white = "#FFFFFF", whitesmoke = "#F5F5F5", gainsboro = "#DCDCDC", lightgrey = "#D3D3D3", silver = "#C0C0C0", darkgray = "#A9A9A9", gray = "#808080", dimgray = "#696969", black = "#000000", colorCodeData_default = {
|
|
395
32
|
lightpink,
|
|
396
33
|
pink,
|
|
397
34
|
crimson,
|
|
@@ -530,7 +167,7 @@ var CommandManager = class {
|
|
|
530
167
|
black
|
|
531
168
|
};
|
|
532
169
|
//#endregion
|
|
533
|
-
//#region
|
|
170
|
+
//#region baseConfig/color/color.js
|
|
534
171
|
function analyzeColorValue(e) {
|
|
535
172
|
if (!e || typeof e != "string") return !1;
|
|
536
173
|
let t = e.trim().toLowerCase(), n = /^#?([0-9A-Fa-f]{3})$/, r = /^#?([0-9A-Fa-f]{6})$/, i = /^#?([0-9A-Fa-f]{8})$/, a = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/, o = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)$/, s = /^(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)$/;
|
|
@@ -567,7 +204,7 @@ function convertSimpleRgbaToHex8(e) {
|
|
|
567
204
|
return c < 0 || c > 1 ? !1 : `#${(u << 16 | d << 8 | f).toString(16).padStart(6, "0").toUpperCase()}${Math.round(c * 255).toString(16).padStart(2, "0").toUpperCase()}`;
|
|
568
205
|
}
|
|
569
206
|
//#endregion
|
|
570
|
-
//#region
|
|
207
|
+
//#region baseConfig/validators.js
|
|
571
208
|
function isValidNumber(e, t = null, n = null) {
|
|
572
209
|
return !(e == null || typeof e != "number" || isNaN(e) || t !== null && e < t || n !== null && e > n);
|
|
573
210
|
}
|
|
@@ -782,7 +419,7 @@ function verifyEnumerationValue(e) {
|
|
|
782
419
|
return r == null || r === "" ? (i != null && t && typeof t == "object" && t && (t[c] = i), s) : a === "string" && typeof r != "string" ? (s.push(`[${c}] 必须是字符串类型`), s) : a === "number" && typeof r != "number" ? (s.push(`[${c}] 必须是数字类型`), s) : !Array.isArray(o) || o.length === 0 ? (s.push(`[${c}] 枚举列表配置错误`), s) : o.includes(r) ? (t && typeof t == "object" && t && (t[c] = r), s) : (s.push(`[${c}] 必须是有效的值: ${o.join(", ")}`), s);
|
|
783
420
|
}
|
|
784
421
|
//#endregion
|
|
785
|
-
//#region
|
|
422
|
+
//#region api/camera/validate.js
|
|
786
423
|
function validateOptionalBoolean$1(e, t, n, r, i) {
|
|
787
424
|
if (n == null || n === "") {
|
|
788
425
|
e[t] = i;
|
|
@@ -1104,7 +741,7 @@ function viewLock(e = {}) {
|
|
|
1104
741
|
};
|
|
1105
742
|
}
|
|
1106
743
|
//#endregion
|
|
1107
|
-
//#region
|
|
744
|
+
//#region api/camera/cameraApi.js
|
|
1108
745
|
var validator$10 = {
|
|
1109
746
|
flyTo,
|
|
1110
747
|
focusToID,
|
|
@@ -1129,7 +766,7 @@ var validator$10 = {
|
|
|
1129
766
|
}
|
|
1130
767
|
};
|
|
1131
768
|
//#endregion
|
|
1132
|
-
//#region
|
|
769
|
+
//#region api/marker/iconMarkerValidate.js
|
|
1133
770
|
function normalizeEmptyArray(e) {
|
|
1134
771
|
return Array.isArray(e) && e.length === 0 ? void 0 : e;
|
|
1135
772
|
}
|
|
@@ -1698,7 +1335,7 @@ function validatePopupCustom1Config(e, t) {
|
|
|
1698
1335
|
})) : e.dataTexts = [];
|
|
1699
1336
|
}
|
|
1700
1337
|
//#endregion
|
|
1701
|
-
//#region
|
|
1338
|
+
//#region api/marker/validate.js
|
|
1702
1339
|
var DEFAULT_VISIBLE_RANGE = [0, 2147483647];
|
|
1703
1340
|
function validateVisibleRange(e, t, n, r = "visibleRange") {
|
|
1704
1341
|
n.push(...validateOptionalArray({
|
|
@@ -2008,7 +1645,7 @@ function secondMarker(e) {
|
|
|
2008
1645
|
};
|
|
2009
1646
|
}
|
|
2010
1647
|
//#endregion
|
|
2011
|
-
//#region
|
|
1648
|
+
//#region api/marker/markerApi.js
|
|
2012
1649
|
var validator$9 = {
|
|
2013
1650
|
iconMarker,
|
|
2014
1651
|
followMarker,
|
|
@@ -2188,7 +1825,7 @@ function getList(e) {
|
|
|
2188
1825
|
};
|
|
2189
1826
|
}
|
|
2190
1827
|
//#endregion
|
|
2191
|
-
//#region
|
|
1828
|
+
//#region api/floodPeak/floodPeakApi.js
|
|
2192
1829
|
var validator$8 = {
|
|
2193
1830
|
getList,
|
|
2194
1831
|
record,
|
|
@@ -2310,7 +1947,7 @@ function onData(e = {}) {
|
|
|
2310
1947
|
};
|
|
2311
1948
|
}
|
|
2312
1949
|
//#endregion
|
|
2313
|
-
//#region
|
|
1950
|
+
//#region api/animation/animationApi.js
|
|
2314
1951
|
var validator$7 = {
|
|
2315
1952
|
play,
|
|
2316
1953
|
carryOn,
|
|
@@ -2332,7 +1969,7 @@ var validator$7 = {
|
|
|
2332
1969
|
}
|
|
2333
1970
|
};
|
|
2334
1971
|
//#endregion
|
|
2335
|
-
//#region
|
|
1972
|
+
//#region api/hydrodynamicForce/validate.js
|
|
2336
1973
|
function create$1(e) {
|
|
2337
1974
|
let t = [], n = { ...e };
|
|
2338
1975
|
return t.push(...validateRequiredNumber({
|
|
@@ -2514,7 +2151,7 @@ function close$1(e) {
|
|
|
2514
2151
|
};
|
|
2515
2152
|
}
|
|
2516
2153
|
//#endregion
|
|
2517
|
-
//#region
|
|
2154
|
+
//#region api/hydrodynamicForce/hydrodynamicForceApi.js
|
|
2518
2155
|
var validator$6 = {
|
|
2519
2156
|
create: create$1,
|
|
2520
2157
|
waterFlow,
|
|
@@ -2907,7 +2544,7 @@ function closeAllSlice(e = {}) {
|
|
|
2907
2544
|
};
|
|
2908
2545
|
}
|
|
2909
2546
|
//#endregion
|
|
2910
|
-
//#region
|
|
2547
|
+
//#region api/sceneModel/sceneModelApi.js
|
|
2911
2548
|
var validator$5 = {
|
|
2912
2549
|
getById,
|
|
2913
2550
|
getByTag,
|
|
@@ -2940,7 +2577,7 @@ var validator$5 = {
|
|
|
2940
2577
|
}
|
|
2941
2578
|
};
|
|
2942
2579
|
//#endregion
|
|
2943
|
-
//#region
|
|
2580
|
+
//#region api/atmosphericEffects/validate.js
|
|
2944
2581
|
function time(e) {
|
|
2945
2582
|
let t = [], n = { ...e };
|
|
2946
2583
|
return t.push(...validateRequiredNumber({
|
|
@@ -2962,7 +2599,7 @@ function weather(e) {
|
|
|
2962
2599
|
};
|
|
2963
2600
|
}
|
|
2964
2601
|
//#endregion
|
|
2965
|
-
//#region
|
|
2602
|
+
//#region api/atmosphericEffects/atmosphericEffectsApi.js
|
|
2966
2603
|
var validator$4 = {
|
|
2967
2604
|
time,
|
|
2968
2605
|
weather
|
|
@@ -2979,7 +2616,7 @@ var validator$4 = {
|
|
|
2979
2616
|
}
|
|
2980
2617
|
};
|
|
2981
2618
|
//#endregion
|
|
2982
|
-
//#region
|
|
2619
|
+
//#region api/tool/validate.js
|
|
2983
2620
|
function onMouseClick$1(e) {
|
|
2984
2621
|
let t = [], n = { ...e };
|
|
2985
2622
|
return t.push(...verifyEnumerationValue({
|
|
@@ -3035,7 +2672,7 @@ function editConfigFile(e) {
|
|
|
3035
2672
|
};
|
|
3036
2673
|
}
|
|
3037
2674
|
//#endregion
|
|
3038
|
-
//#region
|
|
2675
|
+
//#region api/tool/toolApi.js
|
|
3039
2676
|
var validator$3 = {
|
|
3040
2677
|
onMouseClick: onMouseClick$1,
|
|
3041
2678
|
offMouseClick: offMouseClick$1,
|
|
@@ -3055,7 +2692,7 @@ var validator$3 = {
|
|
|
3055
2692
|
}
|
|
3056
2693
|
};
|
|
3057
2694
|
//#endregion
|
|
3058
|
-
//#region
|
|
2695
|
+
//#region api/line/validate.js
|
|
3059
2696
|
function generateUniqueId() {
|
|
3060
2697
|
return "line_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
3061
2698
|
}
|
|
@@ -3150,7 +2787,7 @@ function clearAllLine(e) {
|
|
|
3150
2787
|
};
|
|
3151
2788
|
}
|
|
3152
2789
|
//#endregion
|
|
3153
|
-
//#region
|
|
2790
|
+
//#region api/line/lineApi.js
|
|
3154
2791
|
var validator$2 = {
|
|
3155
2792
|
addLine,
|
|
3156
2793
|
clearLine,
|
|
@@ -3168,7 +2805,7 @@ var validator$2 = {
|
|
|
3168
2805
|
}
|
|
3169
2806
|
};
|
|
3170
2807
|
//#endregion
|
|
3171
|
-
//#region
|
|
2808
|
+
//#region api/level/validate.js
|
|
3172
2809
|
function switchLevel(e) {
|
|
3173
2810
|
let t = [], n = { ...e };
|
|
3174
2811
|
return t.push(...validateRequiredString({
|
|
@@ -3181,7 +2818,7 @@ function switchLevel(e) {
|
|
|
3181
2818
|
};
|
|
3182
2819
|
}
|
|
3183
2820
|
//#endregion
|
|
3184
|
-
//#region
|
|
2821
|
+
//#region api/level/levelApi.js
|
|
3185
2822
|
var validator$1 = { switch: switchLevel }, LevelApi = class {
|
|
3186
2823
|
constructor(e) {
|
|
3187
2824
|
this.commandManager = e;
|
|
@@ -3195,7 +2832,7 @@ var validator$1 = { switch: switchLevel }, LevelApi = class {
|
|
|
3195
2832
|
}
|
|
3196
2833
|
};
|
|
3197
2834
|
//#endregion
|
|
3198
|
-
//#region
|
|
2835
|
+
//#region api/vtk/validate.js
|
|
3199
2836
|
function getInfo(e = {}) {
|
|
3200
2837
|
let t = [], n = { ...e };
|
|
3201
2838
|
return t.push(...validateRequiredString({
|
|
@@ -3587,7 +3224,7 @@ function clearAllSequence(e = {}) {
|
|
|
3587
3224
|
};
|
|
3588
3225
|
}
|
|
3589
3226
|
//#endregion
|
|
3590
|
-
//#region
|
|
3227
|
+
//#region api/vtk/vtkApi.js
|
|
3591
3228
|
var validator = {
|
|
3592
3229
|
getInfo,
|
|
3593
3230
|
getFieldRange,
|
|
@@ -3620,7 +3257,16 @@ var validator = {
|
|
|
3620
3257
|
};
|
|
3621
3258
|
return this.commandManager.sendWithDefault(i, n, { timeout: 0 });
|
|
3622
3259
|
}
|
|
3623
|
-
},
|
|
3260
|
+
}, ueLogEnabled = !0;
|
|
3261
|
+
function setUELogEnabled(e) {
|
|
3262
|
+
ueLogEnabled = !!e;
|
|
3263
|
+
}
|
|
3264
|
+
function log(...e) {
|
|
3265
|
+
ueLogEnabled && console.log(...e);
|
|
3266
|
+
}
|
|
3267
|
+
//#endregion
|
|
3268
|
+
//#region api/other/otherApi.js
|
|
3269
|
+
var OtherApi = class {
|
|
3624
3270
|
constructor(e) {
|
|
3625
3271
|
this.commandManager = e;
|
|
3626
3272
|
}
|
|
@@ -3688,6 +3334,218 @@ var validator = {
|
|
|
3688
3334
|
async gateOperation(e, t) {
|
|
3689
3335
|
return this._otherApi._handleSend(`gateOperation.${e}`, t);
|
|
3690
3336
|
}
|
|
3337
|
+
};
|
|
3338
|
+
//#endregion
|
|
3339
|
+
//#region baseConfig/responses.js
|
|
3340
|
+
function normalizeMessageList(e) {
|
|
3341
|
+
return (Array.isArray(e) ? e : [e]).map((e) => {
|
|
3342
|
+
if (typeof e == "string") return e;
|
|
3343
|
+
if (e && typeof e == "object") {
|
|
3344
|
+
if (typeof e.message == "string" && e.message) return e.message;
|
|
3345
|
+
try {
|
|
3346
|
+
return JSON.stringify(e);
|
|
3347
|
+
} catch {
|
|
3348
|
+
return String(e);
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
return e == null ? "" : String(e);
|
|
3352
|
+
}).filter((e) => e !== "");
|
|
3353
|
+
}
|
|
3354
|
+
function createSuccessResponse(e, t, n) {
|
|
3355
|
+
return {
|
|
3356
|
+
success: !0,
|
|
3357
|
+
message: e,
|
|
3358
|
+
data: t,
|
|
3359
|
+
command: n
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
function createErrorResponse(e, t, n) {
|
|
3363
|
+
let r = {
|
|
3364
|
+
success: !1,
|
|
3365
|
+
message: normalizeMessageList(e),
|
|
3366
|
+
params: t,
|
|
3367
|
+
command: n
|
|
3368
|
+
};
|
|
3369
|
+
return console.error("三维场景报错:", r), r;
|
|
3370
|
+
}
|
|
3371
|
+
function createWarnResponse(e, t, n) {
|
|
3372
|
+
let r = {
|
|
3373
|
+
success: !1,
|
|
3374
|
+
message: normalizeMessageList(e),
|
|
3375
|
+
params: t,
|
|
3376
|
+
command: n
|
|
3377
|
+
};
|
|
3378
|
+
return console.warn("三维场景警告:", r), r;
|
|
3379
|
+
}
|
|
3380
|
+
//#endregion
|
|
3381
|
+
//#region commFlow.js
|
|
3382
|
+
var CommandManager = class {
|
|
3383
|
+
constructor(e) {
|
|
3384
|
+
this.transport = e, this.callbacks = {}, this.requestId = 0, this.timeout = 3e3, this.markerEventCallbacks = {
|
|
3385
|
+
Hovered: {},
|
|
3386
|
+
Click: {},
|
|
3387
|
+
DoubleClick: {},
|
|
3388
|
+
Unhovered: {}
|
|
3389
|
+
}, this.secondMarkerEventCallbacks = {
|
|
3390
|
+
Hovered: {},
|
|
3391
|
+
Click: {},
|
|
3392
|
+
DoubleClick: {},
|
|
3393
|
+
Unhovered: {}
|
|
3394
|
+
}, this.followMarkerEventCallbacks = {
|
|
3395
|
+
Hovered: {},
|
|
3396
|
+
Click: {},
|
|
3397
|
+
DoubleClick: {},
|
|
3398
|
+
Unhovered: {}
|
|
3399
|
+
}, this.animationOnDataCallback = { Change: [] }, this.mouseClickCallback = { MouseClick: [] }, this.vtkMouseClickCallback = {}, e.bindMessageHandler((e) => {
|
|
3400
|
+
this._handleRawResponse(e);
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
sendWithDefault(e, t, n = {}) {
|
|
3404
|
+
let r = this._sendPreparePayload(t, e.normalized || {});
|
|
3405
|
+
if (e.errors.length > 0) return createErrorResponse(e.errors, r, t);
|
|
3406
|
+
let i = (++this.requestId).toString(), a = n?.timeout === 0 ? 0 : this.timeout, o = new Promise((e, t) => {
|
|
3407
|
+
let n = null;
|
|
3408
|
+
a !== 0 && (n = setTimeout(() => {
|
|
3409
|
+
delete this.callbacks[i], t(/* @__PURE__ */ Error("Command timeout with no results"));
|
|
3410
|
+
}, a)), this.callbacks[i] = {
|
|
3411
|
+
resolve: e,
|
|
3412
|
+
reject: t,
|
|
3413
|
+
timeoutId: n
|
|
3414
|
+
};
|
|
3415
|
+
}), s = {
|
|
3416
|
+
command: t,
|
|
3417
|
+
requestId: i,
|
|
3418
|
+
params: r
|
|
3419
|
+
};
|
|
3420
|
+
return log("消息下发成功:", s), this.transport.sendTextToDataChannel(JSON.stringify(s)), o.then((e) => {
|
|
3421
|
+
if (e && e.command && e.command === t) switch (e.status) {
|
|
3422
|
+
case "info": return createSuccessResponse("操作执行成功", e.data, t);
|
|
3423
|
+
case "warn": return createWarnResponse(e.message, e.data, t);
|
|
3424
|
+
default: return createErrorResponse(e.message, e.data, t);
|
|
3425
|
+
}
|
|
3426
|
+
return createErrorResponse("返回数据格式错乱【请注意command参数】", e?.command, t);
|
|
3427
|
+
}).catch((e) => e && e.message ? e.message === "Command timeout with no results" ? createWarnResponse(e.message, r, t) : createErrorResponse(e.message, r, t) : createErrorResponse("数据返回发生错误", r, t));
|
|
3428
|
+
}
|
|
3429
|
+
_handleRawResponse(e) {
|
|
3430
|
+
if (!e) return console.error("数据第一步解析失败:", e), null;
|
|
3431
|
+
let t;
|
|
3432
|
+
try {
|
|
3433
|
+
let n = JSON.parse(String(e).trim());
|
|
3434
|
+
if (t = {
|
|
3435
|
+
command: n.command || "",
|
|
3436
|
+
message: n.message || "",
|
|
3437
|
+
data: n.data || {},
|
|
3438
|
+
status: n.status || "error",
|
|
3439
|
+
requestId: n.requestId || ""
|
|
3440
|
+
}, t.message === "The data channel has been connected." || t.message === "The level has been initialized") return null;
|
|
3441
|
+
} catch {
|
|
3442
|
+
return console.error("数据第二步解析失败:", e), null;
|
|
3443
|
+
}
|
|
3444
|
+
if (this._processEventResponse(t)) return;
|
|
3445
|
+
let { command: n, message: r, data: i, status: a, requestId: o } = t;
|
|
3446
|
+
if (o && this.callbacks[o]) {
|
|
3447
|
+
let { resolve: e, timeoutId: t } = this.callbacks[o];
|
|
3448
|
+
clearTimeout(t), delete this.callbacks[o], e({
|
|
3449
|
+
command: n,
|
|
3450
|
+
message: r,
|
|
3451
|
+
data: i,
|
|
3452
|
+
status: a
|
|
3453
|
+
});
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
console.warn("注意:非常规响应", t);
|
|
3457
|
+
}
|
|
3458
|
+
_sendPreparePayload(e, t) {
|
|
3459
|
+
if (e === "marker.iconMarker" || e === "marker.iconUrlMarker") {
|
|
3460
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3461
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.markerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.markerEventCallbacks.Click[c] = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.markerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.markerEventCallbacks.Click.__default = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered.__default = a)), o;
|
|
3462
|
+
}
|
|
3463
|
+
if (e === "marker.secondMarker") {
|
|
3464
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3465
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
3466
|
+
}
|
|
3467
|
+
if (e === "marker.followMarker") {
|
|
3468
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3469
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
3470
|
+
}
|
|
3471
|
+
if (e === "tool.onMouseClick") {
|
|
3472
|
+
let { onMouseClick: e, ...n } = t || {};
|
|
3473
|
+
return typeof e == "function" && (Array.isArray(this.mouseClickCallback.MouseClick) || (this.mouseClickCallback.MouseClick = []), this.mouseClickCallback.MouseClick.includes(e) || this.mouseClickCallback.MouseClick.push(e)), n;
|
|
3474
|
+
}
|
|
3475
|
+
if (e === "VTK.onMouseClick") {
|
|
3476
|
+
let { onMouseClick: e, ...n } = t || {}, r = n?.id;
|
|
3477
|
+
return r != null && r !== "" && typeof e == "function" && (this.vtkMouseClickCallback[r] = e), n;
|
|
3478
|
+
}
|
|
3479
|
+
if (e === "VTK.offMouseClick") {
|
|
3480
|
+
let e = t?.id;
|
|
3481
|
+
return e != null && e !== "" && delete this.vtkMouseClickCallback[e], t;
|
|
3482
|
+
}
|
|
3483
|
+
if (e === "animation.onData") {
|
|
3484
|
+
let { onChange: e, ...n } = t || {};
|
|
3485
|
+
return typeof e == "function" && (Array.isArray(this.animationOnDataCallback.Change) || (this.animationOnDataCallback.Change = []), this.animationOnDataCallback.Change.includes(e) || this.animationOnDataCallback.Change.push(e)), n;
|
|
3486
|
+
}
|
|
3487
|
+
return t;
|
|
3488
|
+
}
|
|
3489
|
+
_processEventResponse(e) {
|
|
3490
|
+
if (!e) return !1;
|
|
3491
|
+
let { command: t, data: n = {} } = e;
|
|
3492
|
+
if (t === "marker.iconMarker" || t === "marker.iconUrlMarker") {
|
|
3493
|
+
if (typeof n.recordData == "string") try {
|
|
3494
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3495
|
+
} catch {}
|
|
3496
|
+
let { pointId: e, eventType: r } = n;
|
|
3497
|
+
if (!(r && this.markerEventCallbacks)) return !1;
|
|
3498
|
+
let i = this.markerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3499
|
+
return this._executeCallback(a, t, n);
|
|
3500
|
+
}
|
|
3501
|
+
if (t === "marker.secondMarker") {
|
|
3502
|
+
if (typeof n.recordData == "string") try {
|
|
3503
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3504
|
+
} catch {}
|
|
3505
|
+
let { pointId: e, eventType: r } = n;
|
|
3506
|
+
if (!(r && this.secondMarkerEventCallbacks)) return !1;
|
|
3507
|
+
let i = this.secondMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3508
|
+
return this._executeCallback(a, t, n);
|
|
3509
|
+
}
|
|
3510
|
+
if (t === "marker.followMarker") {
|
|
3511
|
+
if (typeof n.recordData == "string") try {
|
|
3512
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3513
|
+
} catch {}
|
|
3514
|
+
let { pointId: e, eventType: r } = n;
|
|
3515
|
+
if (!(r && this.followMarkerEventCallbacks)) return !1;
|
|
3516
|
+
let i = this.followMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3517
|
+
return this._executeCallback(a, t, n);
|
|
3518
|
+
}
|
|
3519
|
+
if (t === "tool.onMouseClick") {
|
|
3520
|
+
let { coordinates: e } = n;
|
|
3521
|
+
if (!(e && this.mouseClickCallback)) return !1;
|
|
3522
|
+
let r = this.mouseClickCallback.MouseClick;
|
|
3523
|
+
return this._executeCallbacks(r, t, n);
|
|
3524
|
+
}
|
|
3525
|
+
if (t === "VTK.onMouseClick") {
|
|
3526
|
+
if (!this.vtkMouseClickCallback || !Object.keys(this.vtkMouseClickCallback).length) return !1;
|
|
3527
|
+
let e = n?.id, r = e ? this.vtkMouseClickCallback[e] : null;
|
|
3528
|
+
return r ? this._executeCallback(r, t, n) : this._executeCallbacks(Object.values(this.vtkMouseClickCallback), t, n);
|
|
3529
|
+
}
|
|
3530
|
+
if (t === "animation.onData") {
|
|
3531
|
+
let { type: e } = n;
|
|
3532
|
+
if (!(e && this.animationOnDataCallback)) return !1;
|
|
3533
|
+
let r = this.animationOnDataCallback.Change;
|
|
3534
|
+
return this._executeCallbacks(r, t, n);
|
|
3535
|
+
}
|
|
3536
|
+
return !1;
|
|
3537
|
+
}
|
|
3538
|
+
_executeCallback(e, t, n) {
|
|
3539
|
+
if (typeof e != "function") return log(`${t}未监听:${n.eventType}`), !0;
|
|
3540
|
+
try {
|
|
3541
|
+
return e(n), !0;
|
|
3542
|
+
} catch (e) {
|
|
3543
|
+
return console.error(`执行${t}回调出错:`, e, n), !0;
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
_executeCallbacks(e, t, n) {
|
|
3547
|
+
return e ? Array.isArray(e) ? (e.forEach((e) => this._executeCallback(e, t, n)), !0) : this._executeCallback(e, t, n) : !1;
|
|
3548
|
+
}
|
|
3691
3549
|
}, require_larksr_web_sdk_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3692
3550
|
(function(e, t) {
|
|
3693
3551
|
typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define("larksr_websdk", [], t) : typeof exports == "object" ? exports.larksr_websdk = t() : e.larksr_websdk = t();
|
|
@@ -24286,38 +24144,7 @@ var validator = {
|
|
|
24286
24144
|
}(), __webpack_exports__ = __webpack_exports__.default, __webpack_exports__;
|
|
24287
24145
|
}();
|
|
24288
24146
|
}));
|
|
24289
|
-
})), import_larksr_web_sdk_min = require_larksr_web_sdk_min()
|
|
24290
|
-
function createLarkSRTransport(e) {
|
|
24291
|
-
return {
|
|
24292
|
-
sendTextToDataChannel(t) {
|
|
24293
|
-
e.sendTextToDataChannel(t);
|
|
24294
|
-
},
|
|
24295
|
-
bindMessageHandler(t) {
|
|
24296
|
-
e.on("datachanneltext", (e) => {
|
|
24297
|
-
e?.type === "datachanneltext" && typeof e.data == "string" && t(e.data);
|
|
24298
|
-
});
|
|
24299
|
-
}
|
|
24300
|
-
};
|
|
24301
|
-
}
|
|
24302
|
-
function createZsStreamTransport(e) {
|
|
24303
|
-
return {
|
|
24304
|
-
sendTextToDataChannel(t) {
|
|
24305
|
-
e.sendTextToDataChannel(t);
|
|
24306
|
-
},
|
|
24307
|
-
bindMessageHandler(t) {
|
|
24308
|
-
e.on("message", (e) => {
|
|
24309
|
-
if (typeof e == "string") {
|
|
24310
|
-
t(e);
|
|
24311
|
-
return;
|
|
24312
|
-
}
|
|
24313
|
-
e != null && t(JSON.stringify(e));
|
|
24314
|
-
});
|
|
24315
|
-
}
|
|
24316
|
-
};
|
|
24317
|
-
}
|
|
24318
|
-
//#endregion
|
|
24319
|
-
//#region linkFlowLarkSR.js
|
|
24320
|
-
var LoadStream = class {
|
|
24147
|
+
})), import_larksr_web_sdk_min = require_larksr_web_sdk_min(), LoadStream = class {
|
|
24321
24148
|
constructor() {
|
|
24322
24149
|
this._gameApi = null, this._larksr = null;
|
|
24323
24150
|
}
|
|
@@ -24378,7 +24205,16 @@ var LoadStream = class {
|
|
|
24378
24205
|
}
|
|
24379
24206
|
init(e) {
|
|
24380
24207
|
try {
|
|
24381
|
-
let t = new CommandManager(
|
|
24208
|
+
let t = new CommandManager({
|
|
24209
|
+
sendTextToDataChannel(t) {
|
|
24210
|
+
e.sendTextToDataChannel(t);
|
|
24211
|
+
},
|
|
24212
|
+
bindMessageHandler(t) {
|
|
24213
|
+
e.on("datachanneltext", (e) => {
|
|
24214
|
+
e?.type === "datachanneltext" && typeof e.data == "string" && t(e.data);
|
|
24215
|
+
});
|
|
24216
|
+
}
|
|
24217
|
+
});
|
|
24382
24218
|
return this._gameApi = new GameAPI(t), console.log(`插件初始化成功 [web3dlink@${version}]`), this._gameApi;
|
|
24383
24219
|
} catch (e) {
|
|
24384
24220
|
throw console.error("插件初始化失败", e), e;
|
|
@@ -24395,10 +24231,19 @@ var LoadStream = class {
|
|
|
24395
24231
|
getLarkSR() {
|
|
24396
24232
|
return this._larksr;
|
|
24397
24233
|
}
|
|
24398
|
-
}, loadStream = new LoadStream(),
|
|
24234
|
+
}, loadStream = new LoadStream(), createAndInitLarkSR = LoadStream.createAndInitLarkSR.bind(LoadStream);
|
|
24235
|
+
function closeGameApi() {
|
|
24236
|
+
return loadStream.close();
|
|
24237
|
+
}
|
|
24238
|
+
function getLarkSR() {
|
|
24239
|
+
return loadStream.getLarkSR();
|
|
24240
|
+
}
|
|
24241
|
+
//#endregion
|
|
24242
|
+
//#region linkFlowzsStream.js
|
|
24243
|
+
var activeStream = null;
|
|
24399
24244
|
async function ZsStreamMount(e, t = {}) {
|
|
24400
24245
|
if (!globalThis.ZsStream?.mount) throw Error("ZsStream 未加载,请确认已引入 zs-stream-parent.js");
|
|
24401
|
-
ZsStreamDestroy(), setUELogEnabled(e?.UELogLevel ?? !0);
|
|
24246
|
+
await ZsStreamDestroy(), setUELogEnabled(e?.UELogLevel ?? !0);
|
|
24402
24247
|
let n = globalThis.ZsStream.mount(e);
|
|
24403
24248
|
activeStream = n, t.onInputready && n.on("inputready", t.onInputready), t.onPlatform && n.on("platform", t.onPlatform), t.onQueue && n.on("queue", t.onQueue), n.on("message", (e) => {
|
|
24404
24249
|
if (t.onSceneInit && typeof e == "string") try {
|
|
@@ -24407,25 +24252,31 @@ async function ZsStreamMount(e, t = {}) {
|
|
|
24407
24252
|
} catch {}
|
|
24408
24253
|
t.onMessage && t.onMessage(e);
|
|
24409
24254
|
}), t.onError && n.on("error", t.onError);
|
|
24410
|
-
let r = new GameAPI(new CommandManager(
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24415
|
-
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24255
|
+
let r = new GameAPI(new CommandManager({
|
|
24256
|
+
sendTextToDataChannel(e) {
|
|
24257
|
+
n.sendTextToDataChannel(e);
|
|
24258
|
+
},
|
|
24259
|
+
bindMessageHandler(e) {
|
|
24260
|
+
n.on("message", (t) => {
|
|
24261
|
+
if (typeof t == "string") {
|
|
24262
|
+
e(t);
|
|
24263
|
+
return;
|
|
24264
|
+
}
|
|
24265
|
+
t != null && e(JSON.stringify(t));
|
|
24266
|
+
});
|
|
24267
|
+
}
|
|
24268
|
+
}));
|
|
24269
|
+
return r.destroy = () => ZsStreamDestroy(), r;
|
|
24423
24270
|
}
|
|
24424
|
-
function
|
|
24425
|
-
|
|
24271
|
+
async function ZsStreamDestroy() {
|
|
24272
|
+
if (activeStream && typeof activeStream.destroy == "function") try {
|
|
24273
|
+
await activeStream.destroy(), console.log("连接关闭成功");
|
|
24274
|
+
} catch (e) {
|
|
24275
|
+
console.error("连接关闭失败:", e);
|
|
24276
|
+
}
|
|
24277
|
+
activeStream = null;
|
|
24426
24278
|
}
|
|
24427
|
-
var web3dlink_default = loadStream;
|
|
24428
24279
|
//#endregion
|
|
24429
|
-
export { CommandManager, GameAPI, ZsStreamDestroy, ZsStreamMount, closeGameApi, createAndInitLarkSR,
|
|
24280
|
+
export { CommandManager, GameAPI, ZsStreamDestroy, ZsStreamMount, closeGameApi, createAndInitLarkSR, getLarkSR, version };
|
|
24430
24281
|
|
|
24431
24282
|
//# sourceMappingURL=web3dlink.js.map
|