web3dlink 2.1.13 → 2.1.15

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 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.13", description = "LarkSR / ZS 推流 GameAPI SDK", type = "module", main = "./dist/web3dlink.js", module$1 = "./dist/web3dlink.js", exports$1 = { ".": {
2
+ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), name = "web3dlink", version$1 = "2.1.15", 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,7 +11,11 @@ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t),
11
11
  "game-api",
12
12
  "streaming",
13
13
  "web3dlink"
14
- ], license = "MIT", sideEffects = ["./dist/web3dlink.js"], package_default = {
14
+ ], license = "MIT", sideEffects = [
15
+ "./dist/web3dlink.js",
16
+ "./zs-stream-parent.js",
17
+ "./version.js"
18
+ ], package_default = {
15
19
  name,
16
20
  version: version$1,
17
21
  description,
@@ -2139,6 +2143,58 @@ function sediment(e) {
2139
2143
  normalized: n
2140
2144
  };
2141
2145
  }
2146
+ function materialParams(e = {}) {
2147
+ let t = [], n = { ...e };
2148
+ return t.push(...validateRequiredString({
2149
+ normalized: n,
2150
+ field: "key",
2151
+ value: e.key
2152
+ })), t.push(...validateOptionalNumber({
2153
+ normalized: n,
2154
+ field: "heightOffset",
2155
+ value: e.heightOffset,
2156
+ defaultValue: 0
2157
+ })), t.push(...validateOptionalNumber({
2158
+ normalized: n,
2159
+ field: "resolutionScale",
2160
+ value: e.resolutionScale,
2161
+ defaultValue: .2,
2162
+ min: 0
2163
+ })), t.push(...validateOptionalNumber({
2164
+ normalized: n,
2165
+ field: "cameraLODDistance",
2166
+ value: e.cameraLODDistance,
2167
+ defaultValue: 4e4,
2168
+ min: 0
2169
+ })), t.push(...validateOptionalNumber({
2170
+ normalized: n,
2171
+ field: "cameraLODNum",
2172
+ value: e.cameraLODNum,
2173
+ defaultValue: 4,
2174
+ min: 0
2175
+ })), t.push(...validateOptionalNumber({
2176
+ normalized: n,
2177
+ field: "cameraRemapMaxOffest",
2178
+ value: e.cameraRemapMaxOffest,
2179
+ defaultValue: 40,
2180
+ min: 0
2181
+ })), t.push(...validateOptionalNumber({
2182
+ normalized: n,
2183
+ field: "flowAmplitude",
2184
+ value: e.flowAmplitude,
2185
+ defaultValue: .5,
2186
+ min: 0
2187
+ })), t.push(...validateOptionalNumber({
2188
+ normalized: n,
2189
+ field: "flowFrequency",
2190
+ value: e.flowFrequency,
2191
+ defaultValue: .5,
2192
+ min: 0
2193
+ })), {
2194
+ errors: t,
2195
+ normalized: n
2196
+ };
2197
+ }
2142
2198
  function close$1(e) {
2143
2199
  let t = [], n = { ...e };
2144
2200
  return t.push(...validateRequiredString({
@@ -2157,6 +2213,7 @@ var validator$6 = {
2157
2213
  waterFlow,
2158
2214
  waterDepth,
2159
2215
  sediment,
2216
+ materialParams,
2160
2217
  close: close$1
2161
2218
  }, HydrodynamicForceApi = class {
2162
2219
  constructor(e) {
@@ -24240,6 +24297,145 @@ function getLarkSR() {
24240
24297
  }
24241
24298
  //#endregion
24242
24299
  //#region linkFlowzsStream.js
24300
+ (function(e) {
24301
+ let t = "zs-stream-parent", n = "zs-stream-embed";
24302
+ function r(e) {
24303
+ return e ? typeof e == "string" ? document.querySelector(e) : e : null;
24304
+ }
24305
+ function i(e, t, n) {
24306
+ let r = (e || "").replace(/\/+$/, "") || (typeof location < "u" ? location.origin : ""), i = new URLSearchParams({
24307
+ template: t || "default",
24308
+ autoconnect: "1",
24309
+ muted: "1"
24310
+ });
24311
+ return n && i.set("streamId", n), `${r}/embed?${i.toString()}`;
24312
+ }
24313
+ function a(e, n, r) {
24314
+ return e?.contentWindow ? (e.contentWindow.postMessage({
24315
+ source: t,
24316
+ streamId: n,
24317
+ ...r
24318
+ }, "*"), { ok: !0 }) : {
24319
+ ok: !1,
24320
+ error: "iframe 未就绪"
24321
+ };
24322
+ }
24323
+ class o {
24324
+ constructor({ streamId: t, template: n, container: i, baseUrl: a } = {}) {
24325
+ if (!t) throw Error("ZsStream: streamId 必填(同页多路时用于区分)");
24326
+ 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();
24327
+ }
24328
+ _mountIframe() {
24329
+ if (!this.container) throw Error("ZsStream: container 未找到");
24330
+ let e = document.createElement("iframe");
24331
+ 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;
24332
+ }
24333
+ _onMessage(e) {
24334
+ let t = e.data;
24335
+ if (!t || t.source !== n || t.streamId && t.streamId !== this.streamId || t.type !== "event") return;
24336
+ let r = t.event;
24337
+ r === "ready" && (this._ready = !0), r === "inputready" && (this._inputReady = !0), this._emit(r, t.data);
24338
+ }
24339
+ _emit(e, t) {
24340
+ let n = this._handlers.get(e);
24341
+ if (n) for (let e of n) try {
24342
+ e(t);
24343
+ } catch (e) {
24344
+ console.error("[ZsStream]", e);
24345
+ }
24346
+ }
24347
+ on(e, t) {
24348
+ return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this.off(e, t);
24349
+ }
24350
+ off(e, t) {
24351
+ this._handlers.get(e)?.delete(t);
24352
+ }
24353
+ _send(e, t) {
24354
+ return a(this.iframe, this.streamId, {
24355
+ type: e,
24356
+ ...t
24357
+ });
24358
+ }
24359
+ invoke(e, t, n) {
24360
+ return this._send("invoke", {
24361
+ module: e,
24362
+ action: t,
24363
+ params: n ?? {}
24364
+ });
24365
+ }
24366
+ camera(e, t) {
24367
+ return this._send("camera", {
24368
+ action: e,
24369
+ params: t ?? {}
24370
+ });
24371
+ }
24372
+ sendRaw(e) {
24373
+ return this._send("sendRaw", { descriptor: String(e) });
24374
+ }
24375
+ sendCommand(e, t) {
24376
+ return this._send("larkCommand", {
24377
+ command: e,
24378
+ params: t ?? {}
24379
+ });
24380
+ }
24381
+ sendTextToDataChannel(e) {
24382
+ let t = typeof e == "string" ? e : JSON.stringify({
24383
+ command: e.command,
24384
+ params: e.params ?? {}
24385
+ });
24386
+ return this._send("sendRaw", { descriptor: t });
24387
+ }
24388
+ disconnect() {
24389
+ return this._send("disconnect", {});
24390
+ }
24391
+ destroy() {
24392
+ e.removeEventListener("message", this._onMessage), this.disconnect(), this.iframe?.parentNode && this.iframe.parentNode.removeChild(this.iframe), this.iframe = null, this._handlers.clear();
24393
+ }
24394
+ get isReady() {
24395
+ return this._ready;
24396
+ }
24397
+ get isInputReady() {
24398
+ return this._inputReady;
24399
+ }
24400
+ }
24401
+ class s {
24402
+ constructor() {
24403
+ this._streams = /* @__PURE__ */ new Map();
24404
+ }
24405
+ mount(e) {
24406
+ let t = e?.streamId;
24407
+ if (!t) throw Error("ZsStreamHub.mount: streamId 必填");
24408
+ this._streams.has(t) && this._streams.get(t).destroy();
24409
+ let n = new o(e);
24410
+ return this._streams.set(t, n), n;
24411
+ }
24412
+ get(e) {
24413
+ return this._streams.get(e) || null;
24414
+ }
24415
+ has(e) {
24416
+ return this._streams.has(e);
24417
+ }
24418
+ destroy(e) {
24419
+ let t = this._streams.get(e);
24420
+ t && (t.destroy(), this._streams.delete(e));
24421
+ }
24422
+ destroyAll() {
24423
+ for (let e of [...this._streams.keys()]) this.destroy(e);
24424
+ }
24425
+ list() {
24426
+ return [...this._streams.keys()];
24427
+ }
24428
+ }
24429
+ e.ZsStream = {
24430
+ mount(e) {
24431
+ return new o(e);
24432
+ },
24433
+ Hub: s,
24434
+ buildEmbedSrc: i,
24435
+ MSG_SOURCE_PARENT: t,
24436
+ MSG_SOURCE_EMBED: n
24437
+ }, e.ZsStreamHub = s;
24438
+ })(typeof window < "u" ? window : globalThis);
24243
24439
  var activeStream = null;
24244
24440
  async function ZsStreamMount(e, t = {}) {
24245
24441
  if (!globalThis.ZsStream?.mount) throw Error("ZsStream 未加载,请确认已引入 zs-stream-parent.js");