web3dlink 2.1.11 → 2.1.12
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 +441 -444
- package/dist/web3dlink.js.map +1 -1
- package/package.json +1 -1
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.12", 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 = {
|
|
@@ -29,369 +29,11 @@ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t),
|
|
|
29
29
|
keywords,
|
|
30
30
|
license: "MIT",
|
|
31
31
|
sideEffects
|
|
32
|
-
}, version = package_default.version;
|
|
32
|
+
}, version = package_default.version, logStyle = "background: #22c55e; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: 600;";
|
|
33
|
+
console.log(`%c [web3dlink] version: ${version} `, logStyle), console.log("%c [larksr_websdk] version: 3.3.119 ", logStyle);
|
|
33
34
|
//#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 = {
|
|
35
|
+
//#region baseConfig/color/colorCodeData.json
|
|
36
|
+
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
37
|
lightpink,
|
|
396
38
|
pink,
|
|
397
39
|
crimson,
|
|
@@ -530,7 +172,7 @@ var CommandManager = class {
|
|
|
530
172
|
black
|
|
531
173
|
};
|
|
532
174
|
//#endregion
|
|
533
|
-
//#region
|
|
175
|
+
//#region baseConfig/color/color.js
|
|
534
176
|
function analyzeColorValue(e) {
|
|
535
177
|
if (!e || typeof e != "string") return !1;
|
|
536
178
|
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 +209,7 @@ function convertSimpleRgbaToHex8(e) {
|
|
|
567
209
|
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
210
|
}
|
|
569
211
|
//#endregion
|
|
570
|
-
//#region
|
|
212
|
+
//#region baseConfig/validators.js
|
|
571
213
|
function isValidNumber(e, t = null, n = null) {
|
|
572
214
|
return !(e == null || typeof e != "number" || isNaN(e) || t !== null && e < t || n !== null && e > n);
|
|
573
215
|
}
|
|
@@ -782,7 +424,7 @@ function verifyEnumerationValue(e) {
|
|
|
782
424
|
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
425
|
}
|
|
784
426
|
//#endregion
|
|
785
|
-
//#region
|
|
427
|
+
//#region api/camera/validate.js
|
|
786
428
|
function validateOptionalBoolean$1(e, t, n, r, i) {
|
|
787
429
|
if (n == null || n === "") {
|
|
788
430
|
e[t] = i;
|
|
@@ -1104,7 +746,7 @@ function viewLock(e = {}) {
|
|
|
1104
746
|
};
|
|
1105
747
|
}
|
|
1106
748
|
//#endregion
|
|
1107
|
-
//#region
|
|
749
|
+
//#region api/camera/cameraApi.js
|
|
1108
750
|
var validator$10 = {
|
|
1109
751
|
flyTo,
|
|
1110
752
|
focusToID,
|
|
@@ -1129,7 +771,7 @@ var validator$10 = {
|
|
|
1129
771
|
}
|
|
1130
772
|
};
|
|
1131
773
|
//#endregion
|
|
1132
|
-
//#region
|
|
774
|
+
//#region api/marker/iconMarkerValidate.js
|
|
1133
775
|
function normalizeEmptyArray(e) {
|
|
1134
776
|
return Array.isArray(e) && e.length === 0 ? void 0 : e;
|
|
1135
777
|
}
|
|
@@ -1698,7 +1340,7 @@ function validatePopupCustom1Config(e, t) {
|
|
|
1698
1340
|
})) : e.dataTexts = [];
|
|
1699
1341
|
}
|
|
1700
1342
|
//#endregion
|
|
1701
|
-
//#region
|
|
1343
|
+
//#region api/marker/validate.js
|
|
1702
1344
|
var DEFAULT_VISIBLE_RANGE = [0, 2147483647];
|
|
1703
1345
|
function validateVisibleRange(e, t, n, r = "visibleRange") {
|
|
1704
1346
|
n.push(...validateOptionalArray({
|
|
@@ -2008,7 +1650,7 @@ function secondMarker(e) {
|
|
|
2008
1650
|
};
|
|
2009
1651
|
}
|
|
2010
1652
|
//#endregion
|
|
2011
|
-
//#region
|
|
1653
|
+
//#region api/marker/markerApi.js
|
|
2012
1654
|
var validator$9 = {
|
|
2013
1655
|
iconMarker,
|
|
2014
1656
|
followMarker,
|
|
@@ -2188,7 +1830,7 @@ function getList(e) {
|
|
|
2188
1830
|
};
|
|
2189
1831
|
}
|
|
2190
1832
|
//#endregion
|
|
2191
|
-
//#region
|
|
1833
|
+
//#region api/floodPeak/floodPeakApi.js
|
|
2192
1834
|
var validator$8 = {
|
|
2193
1835
|
getList,
|
|
2194
1836
|
record,
|
|
@@ -2310,7 +1952,7 @@ function onData(e = {}) {
|
|
|
2310
1952
|
};
|
|
2311
1953
|
}
|
|
2312
1954
|
//#endregion
|
|
2313
|
-
//#region
|
|
1955
|
+
//#region api/animation/animationApi.js
|
|
2314
1956
|
var validator$7 = {
|
|
2315
1957
|
play,
|
|
2316
1958
|
carryOn,
|
|
@@ -2332,7 +1974,7 @@ var validator$7 = {
|
|
|
2332
1974
|
}
|
|
2333
1975
|
};
|
|
2334
1976
|
//#endregion
|
|
2335
|
-
//#region
|
|
1977
|
+
//#region api/hydrodynamicForce/validate.js
|
|
2336
1978
|
function create$1(e) {
|
|
2337
1979
|
let t = [], n = { ...e };
|
|
2338
1980
|
return t.push(...validateRequiredNumber({
|
|
@@ -2514,7 +2156,7 @@ function close$1(e) {
|
|
|
2514
2156
|
};
|
|
2515
2157
|
}
|
|
2516
2158
|
//#endregion
|
|
2517
|
-
//#region
|
|
2159
|
+
//#region api/hydrodynamicForce/hydrodynamicForceApi.js
|
|
2518
2160
|
var validator$6 = {
|
|
2519
2161
|
create: create$1,
|
|
2520
2162
|
waterFlow,
|
|
@@ -2907,7 +2549,7 @@ function closeAllSlice(e = {}) {
|
|
|
2907
2549
|
};
|
|
2908
2550
|
}
|
|
2909
2551
|
//#endregion
|
|
2910
|
-
//#region
|
|
2552
|
+
//#region api/sceneModel/sceneModelApi.js
|
|
2911
2553
|
var validator$5 = {
|
|
2912
2554
|
getById,
|
|
2913
2555
|
getByTag,
|
|
@@ -2940,7 +2582,7 @@ var validator$5 = {
|
|
|
2940
2582
|
}
|
|
2941
2583
|
};
|
|
2942
2584
|
//#endregion
|
|
2943
|
-
//#region
|
|
2585
|
+
//#region api/atmosphericEffects/validate.js
|
|
2944
2586
|
function time(e) {
|
|
2945
2587
|
let t = [], n = { ...e };
|
|
2946
2588
|
return t.push(...validateRequiredNumber({
|
|
@@ -2962,7 +2604,7 @@ function weather(e) {
|
|
|
2962
2604
|
};
|
|
2963
2605
|
}
|
|
2964
2606
|
//#endregion
|
|
2965
|
-
//#region
|
|
2607
|
+
//#region api/atmosphericEffects/atmosphericEffectsApi.js
|
|
2966
2608
|
var validator$4 = {
|
|
2967
2609
|
time,
|
|
2968
2610
|
weather
|
|
@@ -2979,7 +2621,7 @@ var validator$4 = {
|
|
|
2979
2621
|
}
|
|
2980
2622
|
};
|
|
2981
2623
|
//#endregion
|
|
2982
|
-
//#region
|
|
2624
|
+
//#region api/tool/validate.js
|
|
2983
2625
|
function onMouseClick$1(e) {
|
|
2984
2626
|
let t = [], n = { ...e };
|
|
2985
2627
|
return t.push(...verifyEnumerationValue({
|
|
@@ -3035,7 +2677,7 @@ function editConfigFile(e) {
|
|
|
3035
2677
|
};
|
|
3036
2678
|
}
|
|
3037
2679
|
//#endregion
|
|
3038
|
-
//#region
|
|
2680
|
+
//#region api/tool/toolApi.js
|
|
3039
2681
|
var validator$3 = {
|
|
3040
2682
|
onMouseClick: onMouseClick$1,
|
|
3041
2683
|
offMouseClick: offMouseClick$1,
|
|
@@ -3055,7 +2697,7 @@ var validator$3 = {
|
|
|
3055
2697
|
}
|
|
3056
2698
|
};
|
|
3057
2699
|
//#endregion
|
|
3058
|
-
//#region
|
|
2700
|
+
//#region api/line/validate.js
|
|
3059
2701
|
function generateUniqueId() {
|
|
3060
2702
|
return "line_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
3061
2703
|
}
|
|
@@ -3150,7 +2792,7 @@ function clearAllLine(e) {
|
|
|
3150
2792
|
};
|
|
3151
2793
|
}
|
|
3152
2794
|
//#endregion
|
|
3153
|
-
//#region
|
|
2795
|
+
//#region api/line/lineApi.js
|
|
3154
2796
|
var validator$2 = {
|
|
3155
2797
|
addLine,
|
|
3156
2798
|
clearLine,
|
|
@@ -3168,7 +2810,7 @@ var validator$2 = {
|
|
|
3168
2810
|
}
|
|
3169
2811
|
};
|
|
3170
2812
|
//#endregion
|
|
3171
|
-
//#region
|
|
2813
|
+
//#region api/level/validate.js
|
|
3172
2814
|
function switchLevel(e) {
|
|
3173
2815
|
let t = [], n = { ...e };
|
|
3174
2816
|
return t.push(...validateRequiredString({
|
|
@@ -3181,7 +2823,7 @@ function switchLevel(e) {
|
|
|
3181
2823
|
};
|
|
3182
2824
|
}
|
|
3183
2825
|
//#endregion
|
|
3184
|
-
//#region
|
|
2826
|
+
//#region api/level/levelApi.js
|
|
3185
2827
|
var validator$1 = { switch: switchLevel }, LevelApi = class {
|
|
3186
2828
|
constructor(e) {
|
|
3187
2829
|
this.commandManager = e;
|
|
@@ -3195,7 +2837,7 @@ var validator$1 = { switch: switchLevel }, LevelApi = class {
|
|
|
3195
2837
|
}
|
|
3196
2838
|
};
|
|
3197
2839
|
//#endregion
|
|
3198
|
-
//#region
|
|
2840
|
+
//#region api/vtk/validate.js
|
|
3199
2841
|
function getInfo(e = {}) {
|
|
3200
2842
|
let t = [], n = { ...e };
|
|
3201
2843
|
return t.push(...validateRequiredString({
|
|
@@ -3587,7 +3229,7 @@ function clearAllSequence(e = {}) {
|
|
|
3587
3229
|
};
|
|
3588
3230
|
}
|
|
3589
3231
|
//#endregion
|
|
3590
|
-
//#region
|
|
3232
|
+
//#region api/vtk/vtkApi.js
|
|
3591
3233
|
var validator = {
|
|
3592
3234
|
getInfo,
|
|
3593
3235
|
getFieldRange,
|
|
@@ -3620,7 +3262,16 @@ var validator = {
|
|
|
3620
3262
|
};
|
|
3621
3263
|
return this.commandManager.sendWithDefault(i, n, { timeout: 0 });
|
|
3622
3264
|
}
|
|
3623
|
-
},
|
|
3265
|
+
}, ueLogEnabled = !0;
|
|
3266
|
+
function setUELogEnabled(e) {
|
|
3267
|
+
ueLogEnabled = !!e;
|
|
3268
|
+
}
|
|
3269
|
+
function log(...e) {
|
|
3270
|
+
ueLogEnabled && console.log(...e);
|
|
3271
|
+
}
|
|
3272
|
+
//#endregion
|
|
3273
|
+
//#region api/other/otherApi.js
|
|
3274
|
+
var OtherApi = class {
|
|
3624
3275
|
constructor(e) {
|
|
3625
3276
|
this.commandManager = e;
|
|
3626
3277
|
}
|
|
@@ -3679,14 +3330,226 @@ var validator = {
|
|
|
3679
3330
|
async arrow(e, t) {
|
|
3680
3331
|
return this._otherApi._handleSend(`arrow.${e}`, t);
|
|
3681
3332
|
}
|
|
3682
|
-
async VTKLS(e, t) {
|
|
3683
|
-
return this._otherApi._handleSend(`VTK.${e}`, t);
|
|
3333
|
+
async VTKLS(e, t) {
|
|
3334
|
+
return this._otherApi._handleSend(`VTK.${e}`, t);
|
|
3335
|
+
}
|
|
3336
|
+
async NC(e, t) {
|
|
3337
|
+
return this._otherApi._handleSend(`NC.${e}`, t);
|
|
3338
|
+
}
|
|
3339
|
+
async gateOperation(e, t) {
|
|
3340
|
+
return this._otherApi._handleSend(`gateOperation.${e}`, t);
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
//#endregion
|
|
3344
|
+
//#region baseConfig/responses.js
|
|
3345
|
+
function normalizeMessageList(e) {
|
|
3346
|
+
return (Array.isArray(e) ? e : [e]).map((e) => {
|
|
3347
|
+
if (typeof e == "string") return e;
|
|
3348
|
+
if (e && typeof e == "object") {
|
|
3349
|
+
if (typeof e.message == "string" && e.message) return e.message;
|
|
3350
|
+
try {
|
|
3351
|
+
return JSON.stringify(e);
|
|
3352
|
+
} catch {
|
|
3353
|
+
return String(e);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
return e == null ? "" : String(e);
|
|
3357
|
+
}).filter((e) => e !== "");
|
|
3358
|
+
}
|
|
3359
|
+
function createSuccessResponse(e, t, n) {
|
|
3360
|
+
return {
|
|
3361
|
+
success: !0,
|
|
3362
|
+
message: e,
|
|
3363
|
+
data: t,
|
|
3364
|
+
command: n
|
|
3365
|
+
};
|
|
3366
|
+
}
|
|
3367
|
+
function createErrorResponse(e, t, n) {
|
|
3368
|
+
let r = {
|
|
3369
|
+
success: !1,
|
|
3370
|
+
message: normalizeMessageList(e),
|
|
3371
|
+
params: t,
|
|
3372
|
+
command: n
|
|
3373
|
+
};
|
|
3374
|
+
return console.error("三维场景报错:", r), r;
|
|
3375
|
+
}
|
|
3376
|
+
function createWarnResponse(e, t, n) {
|
|
3377
|
+
let r = {
|
|
3378
|
+
success: !1,
|
|
3379
|
+
message: normalizeMessageList(e),
|
|
3380
|
+
params: t,
|
|
3381
|
+
command: n
|
|
3382
|
+
};
|
|
3383
|
+
return console.warn("三维场景警告:", r), r;
|
|
3384
|
+
}
|
|
3385
|
+
//#endregion
|
|
3386
|
+
//#region commFlow.js
|
|
3387
|
+
var CommandManager = class {
|
|
3388
|
+
constructor(e) {
|
|
3389
|
+
this.transport = e, this.callbacks = {}, this.requestId = 0, this.timeout = 3e3, this.markerEventCallbacks = {
|
|
3390
|
+
Hovered: {},
|
|
3391
|
+
Click: {},
|
|
3392
|
+
DoubleClick: {},
|
|
3393
|
+
Unhovered: {}
|
|
3394
|
+
}, this.secondMarkerEventCallbacks = {
|
|
3395
|
+
Hovered: {},
|
|
3396
|
+
Click: {},
|
|
3397
|
+
DoubleClick: {},
|
|
3398
|
+
Unhovered: {}
|
|
3399
|
+
}, this.followMarkerEventCallbacks = {
|
|
3400
|
+
Hovered: {},
|
|
3401
|
+
Click: {},
|
|
3402
|
+
DoubleClick: {},
|
|
3403
|
+
Unhovered: {}
|
|
3404
|
+
}, this.animationOnDataCallback = { Change: [] }, this.mouseClickCallback = { MouseClick: [] }, this.vtkMouseClickCallback = {}, e.bindMessageHandler((e) => {
|
|
3405
|
+
this._handleRawResponse(e);
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
sendWithDefault(e, t, n = {}) {
|
|
3409
|
+
let r = this._sendPreparePayload(t, e.normalized || {});
|
|
3410
|
+
if (e.errors.length > 0) return createErrorResponse(e.errors, r, t);
|
|
3411
|
+
let i = (++this.requestId).toString(), a = n?.timeout === 0 ? 0 : this.timeout, o = new Promise((e, t) => {
|
|
3412
|
+
let n = null;
|
|
3413
|
+
a !== 0 && (n = setTimeout(() => {
|
|
3414
|
+
delete this.callbacks[i], t(/* @__PURE__ */ Error("Command timeout with no results"));
|
|
3415
|
+
}, a)), this.callbacks[i] = {
|
|
3416
|
+
resolve: e,
|
|
3417
|
+
reject: t,
|
|
3418
|
+
timeoutId: n
|
|
3419
|
+
};
|
|
3420
|
+
}), s = {
|
|
3421
|
+
command: t,
|
|
3422
|
+
requestId: i,
|
|
3423
|
+
params: r
|
|
3424
|
+
};
|
|
3425
|
+
return log("消息下发成功:", s), this.transport.sendTextToDataChannel(JSON.stringify(s)), o.then((e) => {
|
|
3426
|
+
if (e && e.command && e.command === t) switch (e.status) {
|
|
3427
|
+
case "info": return createSuccessResponse("操作执行成功", e.data, t);
|
|
3428
|
+
case "warn": return createWarnResponse(e.message, e.data, t);
|
|
3429
|
+
default: return createErrorResponse(e.message, e.data, t);
|
|
3430
|
+
}
|
|
3431
|
+
return createErrorResponse("返回数据格式错乱【请注意command参数】", e?.command, t);
|
|
3432
|
+
}).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));
|
|
3433
|
+
}
|
|
3434
|
+
_handleRawResponse(e) {
|
|
3435
|
+
if (!e) return console.error("数据第一步解析失败:", e), null;
|
|
3436
|
+
let t;
|
|
3437
|
+
try {
|
|
3438
|
+
let n = JSON.parse(String(e).trim());
|
|
3439
|
+
if (t = {
|
|
3440
|
+
command: n.command || "",
|
|
3441
|
+
message: n.message || "",
|
|
3442
|
+
data: n.data || {},
|
|
3443
|
+
status: n.status || "error",
|
|
3444
|
+
requestId: n.requestId || ""
|
|
3445
|
+
}, t.message === "The data channel has been connected." || t.message === "The level has been initialized") return null;
|
|
3446
|
+
} catch {
|
|
3447
|
+
return console.error("数据第二步解析失败:", e), null;
|
|
3448
|
+
}
|
|
3449
|
+
if (this._processEventResponse(t)) return;
|
|
3450
|
+
let { command: n, message: r, data: i, status: a, requestId: o } = t;
|
|
3451
|
+
if (o && this.callbacks[o]) {
|
|
3452
|
+
let { resolve: e, timeoutId: t } = this.callbacks[o];
|
|
3453
|
+
clearTimeout(t), delete this.callbacks[o], e({
|
|
3454
|
+
command: n,
|
|
3455
|
+
message: r,
|
|
3456
|
+
data: i,
|
|
3457
|
+
status: a
|
|
3458
|
+
});
|
|
3459
|
+
return;
|
|
3460
|
+
}
|
|
3461
|
+
console.warn("注意:非常规响应", t);
|
|
3462
|
+
}
|
|
3463
|
+
_sendPreparePayload(e, t) {
|
|
3464
|
+
if (e === "marker.iconMarker" || e === "marker.iconUrlMarker") {
|
|
3465
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3466
|
+
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;
|
|
3467
|
+
}
|
|
3468
|
+
if (e === "marker.secondMarker") {
|
|
3469
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3470
|
+
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;
|
|
3471
|
+
}
|
|
3472
|
+
if (e === "marker.followMarker") {
|
|
3473
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
3474
|
+
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;
|
|
3475
|
+
}
|
|
3476
|
+
if (e === "tool.onMouseClick") {
|
|
3477
|
+
let { onMouseClick: e, ...n } = t || {};
|
|
3478
|
+
return typeof e == "function" && (Array.isArray(this.mouseClickCallback.MouseClick) || (this.mouseClickCallback.MouseClick = []), this.mouseClickCallback.MouseClick.includes(e) || this.mouseClickCallback.MouseClick.push(e)), n;
|
|
3479
|
+
}
|
|
3480
|
+
if (e === "VTK.onMouseClick") {
|
|
3481
|
+
let { onMouseClick: e, ...n } = t || {}, r = n?.id;
|
|
3482
|
+
return r != null && r !== "" && typeof e == "function" && (this.vtkMouseClickCallback[r] = e), n;
|
|
3483
|
+
}
|
|
3484
|
+
if (e === "VTK.offMouseClick") {
|
|
3485
|
+
let e = t?.id;
|
|
3486
|
+
return e != null && e !== "" && delete this.vtkMouseClickCallback[e], t;
|
|
3487
|
+
}
|
|
3488
|
+
if (e === "animation.onData") {
|
|
3489
|
+
let { onChange: e, ...n } = t || {};
|
|
3490
|
+
return typeof e == "function" && (Array.isArray(this.animationOnDataCallback.Change) || (this.animationOnDataCallback.Change = []), this.animationOnDataCallback.Change.includes(e) || this.animationOnDataCallback.Change.push(e)), n;
|
|
3491
|
+
}
|
|
3492
|
+
return t;
|
|
3493
|
+
}
|
|
3494
|
+
_processEventResponse(e) {
|
|
3495
|
+
if (!e) return !1;
|
|
3496
|
+
let { command: t, data: n = {} } = e;
|
|
3497
|
+
if (t === "marker.iconMarker" || t === "marker.iconUrlMarker") {
|
|
3498
|
+
if (typeof n.recordData == "string") try {
|
|
3499
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3500
|
+
} catch {}
|
|
3501
|
+
let { pointId: e, eventType: r } = n;
|
|
3502
|
+
if (!(r && this.markerEventCallbacks)) return !1;
|
|
3503
|
+
let i = this.markerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3504
|
+
return this._executeCallback(a, t, n);
|
|
3505
|
+
}
|
|
3506
|
+
if (t === "marker.secondMarker") {
|
|
3507
|
+
if (typeof n.recordData == "string") try {
|
|
3508
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3509
|
+
} catch {}
|
|
3510
|
+
let { pointId: e, eventType: r } = n;
|
|
3511
|
+
if (!(r && this.secondMarkerEventCallbacks)) return !1;
|
|
3512
|
+
let i = this.secondMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3513
|
+
return this._executeCallback(a, t, n);
|
|
3514
|
+
}
|
|
3515
|
+
if (t === "marker.followMarker") {
|
|
3516
|
+
if (typeof n.recordData == "string") try {
|
|
3517
|
+
n.recordData = JSON.parse(n.recordData);
|
|
3518
|
+
} catch {}
|
|
3519
|
+
let { pointId: e, eventType: r } = n;
|
|
3520
|
+
if (!(r && this.followMarkerEventCallbacks)) return !1;
|
|
3521
|
+
let i = this.followMarkerEventCallbacks[r], a = i?.[e] || i?.__default;
|
|
3522
|
+
return this._executeCallback(a, t, n);
|
|
3523
|
+
}
|
|
3524
|
+
if (t === "tool.onMouseClick") {
|
|
3525
|
+
let { coordinates: e } = n;
|
|
3526
|
+
if (!(e && this.mouseClickCallback)) return !1;
|
|
3527
|
+
let r = this.mouseClickCallback.MouseClick;
|
|
3528
|
+
return this._executeCallbacks(r, t, n);
|
|
3529
|
+
}
|
|
3530
|
+
if (t === "VTK.onMouseClick") {
|
|
3531
|
+
if (!this.vtkMouseClickCallback || !Object.keys(this.vtkMouseClickCallback).length) return !1;
|
|
3532
|
+
let e = n?.id, r = e ? this.vtkMouseClickCallback[e] : null;
|
|
3533
|
+
return r ? this._executeCallback(r, t, n) : this._executeCallbacks(Object.values(this.vtkMouseClickCallback), t, n);
|
|
3534
|
+
}
|
|
3535
|
+
if (t === "animation.onData") {
|
|
3536
|
+
let { type: e } = n;
|
|
3537
|
+
if (!(e && this.animationOnDataCallback)) return !1;
|
|
3538
|
+
let r = this.animationOnDataCallback.Change;
|
|
3539
|
+
return this._executeCallbacks(r, t, n);
|
|
3540
|
+
}
|
|
3541
|
+
return !1;
|
|
3684
3542
|
}
|
|
3685
|
-
|
|
3686
|
-
return
|
|
3543
|
+
_executeCallback(e, t, n) {
|
|
3544
|
+
if (typeof e != "function") return log(`${t}未监听:${n.eventType}`), !0;
|
|
3545
|
+
try {
|
|
3546
|
+
return e(n), !0;
|
|
3547
|
+
} catch (e) {
|
|
3548
|
+
return console.error(`执行${t}回调出错:`, e, n), !0;
|
|
3549
|
+
}
|
|
3687
3550
|
}
|
|
3688
|
-
|
|
3689
|
-
return this.
|
|
3551
|
+
_executeCallbacks(e, t, n) {
|
|
3552
|
+
return e ? Array.isArray(e) ? (e.forEach((e) => this._executeCallback(e, t, n)), !0) : this._executeCallback(e, t, n) : !1;
|
|
3690
3553
|
}
|
|
3691
3554
|
}, require_larksr_web_sdk_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3692
3555
|
(function(e, t) {
|
|
@@ -24286,38 +24149,7 @@ var validator = {
|
|
|
24286
24149
|
}(), __webpack_exports__ = __webpack_exports__.default, __webpack_exports__;
|
|
24287
24150
|
}();
|
|
24288
24151
|
}));
|
|
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 {
|
|
24152
|
+
})), import_larksr_web_sdk_min = require_larksr_web_sdk_min(), LoadStream = class {
|
|
24321
24153
|
constructor() {
|
|
24322
24154
|
this._gameApi = null, this._larksr = null;
|
|
24323
24155
|
}
|
|
@@ -24378,7 +24210,16 @@ var LoadStream = class {
|
|
|
24378
24210
|
}
|
|
24379
24211
|
init(e) {
|
|
24380
24212
|
try {
|
|
24381
|
-
let t = new CommandManager(
|
|
24213
|
+
let t = new CommandManager({
|
|
24214
|
+
sendTextToDataChannel(t) {
|
|
24215
|
+
e.sendTextToDataChannel(t);
|
|
24216
|
+
},
|
|
24217
|
+
bindMessageHandler(t) {
|
|
24218
|
+
e.on("datachanneltext", (e) => {
|
|
24219
|
+
e?.type === "datachanneltext" && typeof e.data == "string" && t(e.data);
|
|
24220
|
+
});
|
|
24221
|
+
}
|
|
24222
|
+
});
|
|
24382
24223
|
return this._gameApi = new GameAPI(t), console.log(`插件初始化成功 [web3dlink@${version}]`), this._gameApi;
|
|
24383
24224
|
} catch (e) {
|
|
24384
24225
|
throw console.error("插件初始化失败", e), e;
|
|
@@ -24395,10 +24236,160 @@ var LoadStream = class {
|
|
|
24395
24236
|
getLarkSR() {
|
|
24396
24237
|
return this._larksr;
|
|
24397
24238
|
}
|
|
24398
|
-
}, loadStream = new LoadStream(),
|
|
24239
|
+
}, loadStream = new LoadStream(), createAndInitLarkSR = LoadStream.createAndInitLarkSR.bind(LoadStream);
|
|
24240
|
+
function closeGameApi() {
|
|
24241
|
+
return loadStream.close();
|
|
24242
|
+
}
|
|
24243
|
+
function getLarkSR() {
|
|
24244
|
+
return loadStream.getLarkSR();
|
|
24245
|
+
}
|
|
24246
|
+
//#endregion
|
|
24247
|
+
//#region zs-stream-parent.js
|
|
24248
|
+
(function(e) {
|
|
24249
|
+
let t = "zs-stream-parent", n = "zs-stream-embed";
|
|
24250
|
+
function r(e) {
|
|
24251
|
+
return e ? typeof e == "string" ? document.querySelector(e) : e : null;
|
|
24252
|
+
}
|
|
24253
|
+
function i(e, t, n) {
|
|
24254
|
+
let r = (e || "").replace(/\/+$/, "") || (typeof location < "u" ? location.origin : ""), i = new URLSearchParams({
|
|
24255
|
+
template: t || "default",
|
|
24256
|
+
autoconnect: "1",
|
|
24257
|
+
muted: "1"
|
|
24258
|
+
});
|
|
24259
|
+
return n && i.set("streamId", n), `${r}/embed?${i.toString()}`;
|
|
24260
|
+
}
|
|
24261
|
+
function a(e, n, r) {
|
|
24262
|
+
return e?.contentWindow ? (e.contentWindow.postMessage({
|
|
24263
|
+
source: t,
|
|
24264
|
+
streamId: n,
|
|
24265
|
+
...r
|
|
24266
|
+
}, "*"), { ok: !0 }) : {
|
|
24267
|
+
ok: !1,
|
|
24268
|
+
error: "iframe 未就绪"
|
|
24269
|
+
};
|
|
24270
|
+
}
|
|
24271
|
+
class o {
|
|
24272
|
+
constructor({ streamId: t, template: n, container: i, baseUrl: a } = {}) {
|
|
24273
|
+
if (!t) throw Error("ZsStream: streamId 必填(同页多路时用于区分)");
|
|
24274
|
+
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();
|
|
24275
|
+
}
|
|
24276
|
+
_mountIframe() {
|
|
24277
|
+
if (!this.container) throw Error("ZsStream: container 未找到");
|
|
24278
|
+
let e = document.createElement("iframe");
|
|
24279
|
+
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;
|
|
24280
|
+
}
|
|
24281
|
+
_onMessage(e) {
|
|
24282
|
+
let t = e.data;
|
|
24283
|
+
if (!t || t.source !== n || t.streamId && t.streamId !== this.streamId || t.type !== "event") return;
|
|
24284
|
+
let r = t.event;
|
|
24285
|
+
r === "ready" && (this._ready = !0), r === "inputready" && (this._inputReady = !0), this._emit(r, t.data);
|
|
24286
|
+
}
|
|
24287
|
+
_emit(e, t) {
|
|
24288
|
+
let n = this._handlers.get(e);
|
|
24289
|
+
if (n) for (let e of n) try {
|
|
24290
|
+
e(t);
|
|
24291
|
+
} catch (e) {
|
|
24292
|
+
console.error("[ZsStream]", e);
|
|
24293
|
+
}
|
|
24294
|
+
}
|
|
24295
|
+
on(e, t) {
|
|
24296
|
+
return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this.off(e, t);
|
|
24297
|
+
}
|
|
24298
|
+
off(e, t) {
|
|
24299
|
+
this._handlers.get(e)?.delete(t);
|
|
24300
|
+
}
|
|
24301
|
+
_send(e, t) {
|
|
24302
|
+
return a(this.iframe, this.streamId, {
|
|
24303
|
+
type: e,
|
|
24304
|
+
...t
|
|
24305
|
+
});
|
|
24306
|
+
}
|
|
24307
|
+
invoke(e, t, n) {
|
|
24308
|
+
return this._send("invoke", {
|
|
24309
|
+
module: e,
|
|
24310
|
+
action: t,
|
|
24311
|
+
params: n ?? {}
|
|
24312
|
+
});
|
|
24313
|
+
}
|
|
24314
|
+
camera(e, t) {
|
|
24315
|
+
return this._send("camera", {
|
|
24316
|
+
action: e,
|
|
24317
|
+
params: t ?? {}
|
|
24318
|
+
});
|
|
24319
|
+
}
|
|
24320
|
+
sendRaw(e) {
|
|
24321
|
+
return this._send("sendRaw", { descriptor: String(e) });
|
|
24322
|
+
}
|
|
24323
|
+
sendCommand(e, t) {
|
|
24324
|
+
return this._send("larkCommand", {
|
|
24325
|
+
command: e,
|
|
24326
|
+
params: t ?? {}
|
|
24327
|
+
});
|
|
24328
|
+
}
|
|
24329
|
+
sendTextToDataChannel(e) {
|
|
24330
|
+
let t = typeof e == "string" ? e : JSON.stringify({
|
|
24331
|
+
command: e.command,
|
|
24332
|
+
params: e.params ?? {}
|
|
24333
|
+
});
|
|
24334
|
+
return this._send("sendRaw", { descriptor: t });
|
|
24335
|
+
}
|
|
24336
|
+
disconnect() {
|
|
24337
|
+
return this._send("disconnect", {});
|
|
24338
|
+
}
|
|
24339
|
+
destroy() {
|
|
24340
|
+
e.removeEventListener("message", this._onMessage), this.disconnect(), this.iframe?.parentNode && this.iframe.parentNode.removeChild(this.iframe), this.iframe = null, this._handlers.clear();
|
|
24341
|
+
}
|
|
24342
|
+
get isReady() {
|
|
24343
|
+
return this._ready;
|
|
24344
|
+
}
|
|
24345
|
+
get isInputReady() {
|
|
24346
|
+
return this._inputReady;
|
|
24347
|
+
}
|
|
24348
|
+
}
|
|
24349
|
+
class s {
|
|
24350
|
+
constructor() {
|
|
24351
|
+
this._streams = /* @__PURE__ */ new Map();
|
|
24352
|
+
}
|
|
24353
|
+
mount(e) {
|
|
24354
|
+
let t = e?.streamId;
|
|
24355
|
+
if (!t) throw Error("ZsStreamHub.mount: streamId 必填");
|
|
24356
|
+
this._streams.has(t) && this._streams.get(t).destroy();
|
|
24357
|
+
let n = new o(e);
|
|
24358
|
+
return this._streams.set(t, n), n;
|
|
24359
|
+
}
|
|
24360
|
+
get(e) {
|
|
24361
|
+
return this._streams.get(e) || null;
|
|
24362
|
+
}
|
|
24363
|
+
has(e) {
|
|
24364
|
+
return this._streams.has(e);
|
|
24365
|
+
}
|
|
24366
|
+
destroy(e) {
|
|
24367
|
+
let t = this._streams.get(e);
|
|
24368
|
+
t && (t.destroy(), this._streams.delete(e));
|
|
24369
|
+
}
|
|
24370
|
+
destroyAll() {
|
|
24371
|
+
for (let e of [...this._streams.keys()]) this.destroy(e);
|
|
24372
|
+
}
|
|
24373
|
+
list() {
|
|
24374
|
+
return [...this._streams.keys()];
|
|
24375
|
+
}
|
|
24376
|
+
}
|
|
24377
|
+
e.ZsStream = {
|
|
24378
|
+
mount(e) {
|
|
24379
|
+
return new o(e);
|
|
24380
|
+
},
|
|
24381
|
+
Hub: s,
|
|
24382
|
+
buildEmbedSrc: i,
|
|
24383
|
+
MSG_SOURCE_PARENT: t,
|
|
24384
|
+
MSG_SOURCE_EMBED: n
|
|
24385
|
+
}, e.ZsStreamHub = s;
|
|
24386
|
+
})(typeof window < "u" ? window : globalThis);
|
|
24387
|
+
//#endregion
|
|
24388
|
+
//#region linkFlowzsStream.js
|
|
24389
|
+
var activeStream = null;
|
|
24399
24390
|
async function ZsStreamMount(e, t = {}) {
|
|
24400
24391
|
if (!globalThis.ZsStream?.mount) throw Error("ZsStream 未加载,请确认已引入 zs-stream-parent.js");
|
|
24401
|
-
ZsStreamDestroy(), setUELogEnabled(e?.UELogLevel ?? !0);
|
|
24392
|
+
await ZsStreamDestroy(), setUELogEnabled(e?.UELogLevel ?? !0);
|
|
24402
24393
|
let n = globalThis.ZsStream.mount(e);
|
|
24403
24394
|
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
24395
|
if (t.onSceneInit && typeof e == "string") try {
|
|
@@ -24407,25 +24398,31 @@ async function ZsStreamMount(e, t = {}) {
|
|
|
24407
24398
|
} catch {}
|
|
24408
24399
|
t.onMessage && t.onMessage(e);
|
|
24409
24400
|
}), 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
|
-
|
|
24401
|
+
let r = new GameAPI(new CommandManager({
|
|
24402
|
+
sendTextToDataChannel(e) {
|
|
24403
|
+
n.sendTextToDataChannel(e);
|
|
24404
|
+
},
|
|
24405
|
+
bindMessageHandler(e) {
|
|
24406
|
+
n.on("message", (t) => {
|
|
24407
|
+
if (typeof t == "string") {
|
|
24408
|
+
e(t);
|
|
24409
|
+
return;
|
|
24410
|
+
}
|
|
24411
|
+
t != null && e(JSON.stringify(t));
|
|
24412
|
+
});
|
|
24413
|
+
}
|
|
24414
|
+
}));
|
|
24415
|
+
return r.destroy = () => ZsStreamDestroy(), r;
|
|
24423
24416
|
}
|
|
24424
|
-
function
|
|
24425
|
-
|
|
24417
|
+
async function ZsStreamDestroy() {
|
|
24418
|
+
if (activeStream && typeof activeStream.destroy == "function") try {
|
|
24419
|
+
await activeStream.destroy(), console.log("连接关闭成功");
|
|
24420
|
+
} catch (e) {
|
|
24421
|
+
console.error("连接关闭失败:", e);
|
|
24422
|
+
}
|
|
24423
|
+
activeStream = null;
|
|
24426
24424
|
}
|
|
24427
|
-
var web3dlink_default = loadStream;
|
|
24428
24425
|
//#endregion
|
|
24429
|
-
export { CommandManager, GameAPI, ZsStreamDestroy, ZsStreamMount, closeGameApi, createAndInitLarkSR,
|
|
24426
|
+
export { CommandManager, GameAPI, ZsStreamDestroy, ZsStreamMount, closeGameApi, createAndInitLarkSR, getLarkSR, version };
|
|
24430
24427
|
|
|
24431
24428
|
//# sourceMappingURL=web3dlink.js.map
|