web3dlink 2.1.12 → 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 +2 -148
- 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,
|
|
@@ -24244,147 +24239,6 @@ function getLarkSR() {
|
|
|
24244
24239
|
return loadStream.getLarkSR();
|
|
24245
24240
|
}
|
|
24246
24241
|
//#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
24242
|
//#region linkFlowzsStream.js
|
|
24389
24243
|
var activeStream = null;
|
|
24390
24244
|
async function ZsStreamMount(e, t = {}) {
|