web3dlink 2.1.10 → 2.1.11

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.10", 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.11", 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 = {
@@ -173,6 +173,20 @@ console.log(`[web3dlink] version: ${version}`), (function(e) {
173
173
  })(typeof window < "u" ? window : globalThis);
174
174
  //#endregion
175
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
+ }
176
190
  function createSuccessResponse(e, t, n) {
177
191
  return {
178
192
  success: !0,
@@ -184,7 +198,7 @@ function createSuccessResponse(e, t, n) {
184
198
  function createErrorResponse(e, t, n) {
185
199
  let r = {
186
200
  success: !1,
187
- message: e,
201
+ message: normalizeMessageList(e),
188
202
  params: t,
189
203
  command: n
190
204
  };
@@ -193,7 +207,7 @@ function createErrorResponse(e, t, n) {
193
207
  function createWarnResponse(e, t, n) {
194
208
  let r = {
195
209
  success: !1,
196
- message: e,
210
+ message: normalizeMessageList(e),
197
211
  params: t,
198
212
  command: n
199
213
  };
@@ -984,6 +998,12 @@ function aroundMode(e = {}) {
984
998
  defaultValue: 0,
985
999
  min: -180,
986
1000
  max: 180
1001
+ })), t.push(...validateOptionalNumber({
1002
+ normalized: n,
1003
+ field: "duration",
1004
+ value: e.duration,
1005
+ defaultValue: 2,
1006
+ min: 0
987
1007
  })), t.push(...validateOptionalNumber({
988
1008
  normalized: n,
989
1009
  field: "minDistanceToTarget",
@@ -1679,6 +1699,28 @@ function validatePopupCustom1Config(e, t) {
1679
1699
  }
1680
1700
  //#endregion
1681
1701
  //#region ../api/marker/validate.js
1702
+ var DEFAULT_VISIBLE_RANGE = [0, 2147483647];
1703
+ function validateVisibleRange(e, t, n, r = "visibleRange") {
1704
+ n.push(...validateOptionalArray({
1705
+ normalized: t,
1706
+ field: r,
1707
+ value: e[r],
1708
+ length: 2,
1709
+ defaultValue: [...DEFAULT_VISIBLE_RANGE]
1710
+ }));
1711
+ let i = t[r];
1712
+ if (!Array.isArray(i) || i.length !== 2) return;
1713
+ let a = Number(i[0]), o = Number(i[1]);
1714
+ if (!Number.isFinite(a) || !Number.isFinite(o)) {
1715
+ n.push(`[${r}]元素必须是数字`);
1716
+ return;
1717
+ }
1718
+ if (a > o) {
1719
+ n.push(`[${r}]最小值不能大于最大值`);
1720
+ return;
1721
+ }
1722
+ t[r] = [a, o];
1723
+ }
1682
1724
  var MARKER_TYPE_LIST = [
1683
1725
  "default",
1684
1726
  "default1",
@@ -1706,13 +1748,7 @@ function iconMarker(e) {
1706
1748
  normalized: n,
1707
1749
  field: "groupId",
1708
1750
  value: e.groupId
1709
- })), t.push(...validateOptionalArray({
1710
- normalized: n,
1711
- field: "visibleRange",
1712
- value: e.visibleRange,
1713
- length: 2,
1714
- defaultValue: [0, 2147483647]
1715
- })), t.push(...verifyEnumerationValue({
1751
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1716
1752
  normalized: n,
1717
1753
  field: "isScreenSpace",
1718
1754
  value: e.isScreenSpace,
@@ -1728,17 +1764,11 @@ function iconMarker(e) {
1728
1764
  list: MARKER_TYPE_LIST
1729
1765
  })), e.recordData !== void 0) {
1730
1766
  let r = e.recordData;
1731
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1732
- field: "recordData",
1733
- message: "[recordData] 必须是对象类型"
1734
- });
1767
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1735
1768
  else try {
1736
1769
  n.recordData = JSON.stringify(r);
1737
1770
  } catch {
1738
- t.push({
1739
- field: "recordData",
1740
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1741
- });
1771
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
1742
1772
  }
1743
1773
  }
1744
1774
  return validateConfigByMarkerType(n, t), {
@@ -1756,13 +1786,7 @@ function followMarker(e) {
1756
1786
  normalized: n,
1757
1787
  field: "groupId",
1758
1788
  value: e.groupId
1759
- })), t.push(...validateOptionalArray({
1760
- normalized: n,
1761
- field: "visibleRange",
1762
- value: e.visibleRange,
1763
- length: 2,
1764
- defaultValue: [0, 2147483647]
1765
- })), t.push(...verifyEnumerationValue({
1789
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1766
1790
  normalized: n,
1767
1791
  field: "isScreenSpace",
1768
1792
  value: e.isScreenSpace,
@@ -1778,17 +1802,11 @@ function followMarker(e) {
1778
1802
  list: MARKER_TYPE_LIST
1779
1803
  })), e.recordData !== void 0) {
1780
1804
  let r = e.recordData;
1781
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1782
- field: "recordData",
1783
- message: "[recordData] 必须是对象类型"
1784
- });
1805
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1785
1806
  else try {
1786
1807
  n.recordData = JSON.stringify(r);
1787
1808
  } catch {
1788
- t.push({
1789
- field: "recordData",
1790
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1791
- });
1809
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
1792
1810
  }
1793
1811
  }
1794
1812
  return validateConfigByMarkerType(n, t), {
@@ -1935,23 +1953,14 @@ function secondMarker(e) {
1935
1953
  normalized: n,
1936
1954
  field: "groupId",
1937
1955
  value: e.groupId
1938
- })), t.push(...validateOptionalArray({
1939
- normalized: n,
1940
- field: "visibleRange",
1941
- value: e.visibleRange,
1942
- length: 2,
1943
- defaultValue: [0, 2147483647]
1944
- })), t.push(...verifyEnumerationValue({
1956
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1945
1957
  normalized: n,
1946
1958
  field: "isScreenSpace",
1947
1959
  value: e.isScreenSpace,
1948
1960
  defaultValue: 1,
1949
1961
  type: "number",
1950
1962
  list: [0, 1]
1951
- })), typeof e.isInitSecond == "boolean" ? n.isInitSecond = e.isInitSecond : e.isInitSecond === void 0 ? n.isInitSecond = !1 : t.push({
1952
- field: "isInitSecond",
1953
- message: "isInitSecond must be boolean"
1954
- }), t.push(...verifyEnumerationValue({
1963
+ })), typeof e.isInitSecond == "boolean" ? n.isInitSecond = e.isInitSecond : e.isInitSecond === void 0 ? n.isInitSecond = !1 : t.push("[isInitSecond]必须是布尔类型"), t.push(...verifyEnumerationValue({
1955
1964
  normalized: n,
1956
1965
  field: "triggerType",
1957
1966
  value: e.triggerType,
@@ -1986,17 +1995,11 @@ function secondMarker(e) {
1986
1995
  value: e.value ?? ""
1987
1996
  })) : r.dataTexts = []), e.recordData !== void 0) {
1988
1997
  let r = e.recordData;
1989
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1990
- field: "recordData",
1991
- message: "[recordData] 必须是对象类型"
1992
- });
1998
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1993
1999
  else try {
1994
2000
  n.recordData = JSON.stringify(r);
1995
2001
  } catch {
1996
- t.push({
1997
- field: "recordData",
1998
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1999
- });
2002
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
2000
2003
  }
2001
2004
  }
2002
2005
  return {