web3dlink 2.1.2 → 2.1.4

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
@@ -185,14 +185,17 @@ var CommandManager = class {
185
185
  this.transport = e, this.callbacks = {}, this.requestId = 0, this.timeout = 3e3, this.markerEventCallbacks = {
186
186
  Hovered: {},
187
187
  Click: {},
188
+ DoubleClick: {},
188
189
  Unhovered: {}
189
190
  }, this.secondMarkerEventCallbacks = {
190
191
  Hovered: {},
191
192
  Click: {},
193
+ DoubleClick: {},
192
194
  Unhovered: {}
193
195
  }, this.followMarkerEventCallbacks = {
194
196
  Hovered: {},
195
197
  Click: {},
198
+ DoubleClick: {},
196
199
  Unhovered: {}
197
200
  }, this.animationOnDataCallback = { Change: [] }, this.mouseClickCallback = { MouseClick: [] }, this.vtkMouseClickCallback = {}, e.bindMessageHandler((e) => {
198
201
  this._handleRawResponse(e);
@@ -254,17 +257,17 @@ var CommandManager = class {
254
257
  console.warn("注意:非常规响应", t);
255
258
  }
256
259
  _sendPreparePayload(e, t) {
257
- if (e === "marker.iconMarker") {
258
- let { onMarkerClick: e, onMouseHover: n, onMouseLeave: r, ...i } = t || {}, a = i?.id;
259
- return a != null && a !== "" ? (typeof n == "function" && (this.markerEventCallbacks.Hovered[a] = n), typeof e == "function" && (this.markerEventCallbacks.Click[a] = e), typeof r == "function" && (this.markerEventCallbacks.Unhovered[a] = r)) : (typeof n == "function" && (this.markerEventCallbacks.Hovered.__default = n), typeof e == "function" && (this.markerEventCallbacks.Click.__default = e), typeof r == "function" && (this.markerEventCallbacks.Unhovered.__default = r)), i;
260
+ if (e === "marker.iconMarker" || e === "marker.iconUrlMarker") {
261
+ let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
262
+ 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;
260
263
  }
261
264
  if (e === "marker.secondMarker") {
262
- let { onMarkerClick: e, onMouseHover: n, onMouseLeave: r, ...i } = t || {}, a = i?.id;
263
- return a != null && a !== "" ? (typeof n == "function" && (this.secondMarkerEventCallbacks.Hovered[a] = n), typeof e == "function" && (this.secondMarkerEventCallbacks.Click[a] = e), typeof r == "function" && (this.secondMarkerEventCallbacks.Unhovered[a] = r)) : (typeof n == "function" && (this.secondMarkerEventCallbacks.Hovered.__default = n), typeof e == "function" && (this.secondMarkerEventCallbacks.Click.__default = e), typeof r == "function" && (this.secondMarkerEventCallbacks.Unhovered.__default = r)), i;
265
+ let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
266
+ 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;
264
267
  }
265
268
  if (e === "marker.followMarker") {
266
- let { onMarkerClick: e, onMouseHover: n, onMouseLeave: r, ...i } = t || {}, a = i?.id;
267
- return a != null && a !== "" ? (typeof n == "function" && (this.followMarkerEventCallbacks.Hovered[a] = n), typeof e == "function" && (this.followMarkerEventCallbacks.Click[a] = e), typeof r == "function" && (this.followMarkerEventCallbacks.Unhovered[a] = r)) : (typeof n == "function" && (this.followMarkerEventCallbacks.Hovered.__default = n), typeof e == "function" && (this.followMarkerEventCallbacks.Click.__default = e), typeof r == "function" && (this.followMarkerEventCallbacks.Unhovered.__default = r)), i;
269
+ let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
270
+ 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;
268
271
  }
269
272
  if (e === "tool.onMouseClick") {
270
273
  let { onMouseClick: e, ...n } = t || {};
@@ -287,7 +290,7 @@ var CommandManager = class {
287
290
  _processEventResponse(e) {
288
291
  if (!e) return !1;
289
292
  let { command: t, data: n = {} } = e;
290
- if (t === "marker.iconMarker") {
293
+ if (t === "marker.iconMarker" || t === "marker.iconUrlMarker") {
291
294
  if (typeof n.recordData == "string") try {
292
295
  n.recordData = JSON.parse(n.recordData);
293
296
  } catch {}
@@ -1084,7 +1087,7 @@ function isEmptyValue(e) {
1084
1087
  return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
1085
1088
  }
1086
1089
  function generateUniqueId$1() {
1087
- return `marker_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
1090
+ return `marker_${Date.now()}`;
1088
1091
  }
1089
1092
  function ensureIconStyle(e, t, n) {
1090
1093
  let r = e?.[t];
@@ -1221,16 +1224,57 @@ function validateConfigByMarkerType(e, t) {
1221
1224
  "anchor4",
1222
1225
  "anchor5",
1223
1226
  "anchor6"
1224
- ].includes(n) ? validateAnchorConfig(r, t) : n === "html" ? validateHtmlMarkerConfig(r, t) : n === "url" ? validateUrlMarkerConfig(r, t) : validateDefaultConfig(r, t);
1227
+ ].includes(n) ? validateAnchorConfig(r, t) : n === "html" ? validateHtmlMarkerConfig(r, t) : n === "url" ? validateUrlMarkerConfig(r, t) : n === "lod" ? validateLodConfig(r, t) : validateDefaultConfig(r, t);
1228
+ }
1229
+ function validateLodConfig(e, t) {
1230
+ if (ensureIconStyle(e, "iconStyle", t), ensureTextStyle(e, "textStyle", t), e.levels === void 0 || e.levels === null) {
1231
+ e.levels = [];
1232
+ return;
1233
+ }
1234
+ if (!Array.isArray(e.levels)) {
1235
+ t.push("[config.levels]必须是数组");
1236
+ return;
1237
+ }
1238
+ e.levels.forEach((e, n) => {
1239
+ if (!e || typeof e != "object" || Array.isArray(e)) {
1240
+ t.push(`[config.levels[${n}]]必须是对象`);
1241
+ return;
1242
+ }
1243
+ t.push(...validateOptionalArray({
1244
+ normalized: e,
1245
+ field: "distance",
1246
+ value: normalizeEmptyArray(e.distance),
1247
+ length: 2
1248
+ })), (!Array.isArray(e.distance) || e.distance.length !== 2) && t.push(`[config.levels[${n}].distance]必填,格式为 [min, max]`), t.push(...validateOptionalString({
1249
+ normalized: e,
1250
+ field: "text",
1251
+ value: e.text,
1252
+ defaultValue: ""
1253
+ })), t.push(...validateOptionalString({
1254
+ normalized: e,
1255
+ field: "iconAddress",
1256
+ value: e.iconAddress,
1257
+ defaultValue: ""
1258
+ })), ensureIconStyle(e, "iconStyle", t), ensureTextStyle(e, "textStyle", t);
1259
+ });
1225
1260
  }
1226
1261
  function validateHtmlMarkerConfig(e, t) {
1227
- t.push(...validateOptionalNumber({
1262
+ if (t.push(...validateOptionalNumber({
1228
1263
  normalized: e,
1229
1264
  field: "scale",
1230
1265
  value: e.scale,
1231
1266
  defaultValue: 1,
1232
1267
  min: 0
1233
- })), t.push(...validateOptionalString({
1268
+ })), t.push(...validateOptionalArray({
1269
+ normalized: e,
1270
+ field: "size",
1271
+ value: normalizeEmptyArray(e.size),
1272
+ length: 2
1273
+ })), Array.isArray(e.size) && e.size.length === 2) {
1274
+ let [n, r] = e.size;
1275
+ (typeof n != "number" || Number.isNaN(n) || n <= 0) && t.push("[size[0]]必须是>0的数字"), (typeof r != "number" || Number.isNaN(r) || r <= 0) && t.push("[size[1]]必须是>0的数字");
1276
+ }
1277
+ t.push(...validateOptionalString({
1234
1278
  normalized: e,
1235
1279
  field: "content",
1236
1280
  value: e.content,
@@ -1605,6 +1649,27 @@ function validatePopupCustom1Config(e, t) {
1605
1649
  }
1606
1650
  //#endregion
1607
1651
  //#region ../api/marker/validate.js
1652
+ var MARKER_TYPE_LIST = [
1653
+ "default",
1654
+ "default1",
1655
+ "default2",
1656
+ "default3",
1657
+ "flashIcon",
1658
+ "component",
1659
+ "customCom",
1660
+ "menuIcon",
1661
+ "flood",
1662
+ "capture",
1663
+ "anchor1",
1664
+ "anchor2",
1665
+ "anchor3",
1666
+ "anchor4",
1667
+ "anchor5",
1668
+ "anchor6",
1669
+ "html",
1670
+ "url",
1671
+ "lod"
1672
+ ];
1608
1673
  function iconMarker(e) {
1609
1674
  let t = [], n = { ...e };
1610
1675
  if (e.id === void 0 || e.id === null || e.id === "" ? n.id = generateUniqueId$1() : n.id = e.id, t.push(...validateCoordinatesRequired(e.coordinates)), t.push(...validateOptionalString({
@@ -1624,32 +1689,13 @@ function iconMarker(e) {
1624
1689
  defaultValue: 1,
1625
1690
  type: "number",
1626
1691
  list: [0, 1]
1627
- })), t.push(...verifyEnumerationValue({
1692
+ })), e.markerState === void 0 || e.markerState === null ? n.markerState = !0 : typeof e.markerState == "boolean" ? n.markerState = e.markerState : t.push("[markerState]必须是布尔类型"), t.push(...verifyEnumerationValue({
1628
1693
  normalized: n,
1629
1694
  field: "markerType",
1630
1695
  value: e.markerType,
1631
1696
  defaultValue: "default",
1632
1697
  type: "string",
1633
- list: [
1634
- "default",
1635
- "default1",
1636
- "default2",
1637
- "default3",
1638
- "flashIcon",
1639
- "component",
1640
- "customCom",
1641
- "menuIcon",
1642
- "flood",
1643
- "capture",
1644
- "anchor1",
1645
- "anchor2",
1646
- "anchor3",
1647
- "anchor4",
1648
- "anchor5",
1649
- "anchor6",
1650
- "html",
1651
- "url"
1652
- ]
1698
+ list: MARKER_TYPE_LIST
1653
1699
  })), e.recordData !== void 0) {
1654
1700
  let r = e.recordData;
1655
1701
  if (typeof r != "object" || !r || Array.isArray(r)) t.push({
@@ -1693,32 +1739,13 @@ function followMarker(e) {
1693
1739
  defaultValue: 1,
1694
1740
  type: "number",
1695
1741
  list: [0, 1]
1696
- })), t.push(...verifyEnumerationValue({
1742
+ })), e.markerState === void 0 || e.markerState === null ? n.markerState = !0 : typeof e.markerState == "boolean" ? n.markerState = e.markerState : t.push("[markerState]必须是布尔类型"), t.push(...verifyEnumerationValue({
1697
1743
  normalized: n,
1698
1744
  field: "markerType",
1699
1745
  value: e.markerType,
1700
1746
  defaultValue: "default",
1701
1747
  type: "string",
1702
- list: [
1703
- "default",
1704
- "default1",
1705
- "default2",
1706
- "default3",
1707
- "flashIcon",
1708
- "component",
1709
- "customCom",
1710
- "menuIcon",
1711
- "flood",
1712
- "capture",
1713
- "anchor1",
1714
- "anchor2",
1715
- "anchor3",
1716
- "anchor4",
1717
- "anchor5",
1718
- "anchor6",
1719
- "html",
1720
- "url"
1721
- ]
1748
+ list: MARKER_TYPE_LIST
1722
1749
  })), e.recordData !== void 0) {
1723
1750
  let r = e.recordData;
1724
1751
  if (typeof r != "object" || !r || Array.isArray(r)) t.push({
@@ -1745,6 +1772,65 @@ function removeAllMarker(e) {
1745
1772
  normalized: { ...e }
1746
1773
  };
1747
1774
  }
1775
+ function removeMarker(e = {}) {
1776
+ let t = [], n = { ...e };
1777
+ return t.push(...validateOptionalArray({
1778
+ normalized: n,
1779
+ field: "groupIds",
1780
+ value: e.groupIds,
1781
+ minLength: 1
1782
+ })), {
1783
+ errors: t,
1784
+ normalized: n
1785
+ };
1786
+ }
1787
+ function showMarker(e = {}) {
1788
+ let t = [], n = { ...e };
1789
+ return t.push(...validateOptionalArray({
1790
+ normalized: n,
1791
+ field: "groupIds",
1792
+ value: e.groupIds,
1793
+ minLength: 1
1794
+ })), {
1795
+ errors: t,
1796
+ normalized: n
1797
+ };
1798
+ }
1799
+ function showAllMarker(e = {}) {
1800
+ return {
1801
+ errors: [],
1802
+ normalized: { ...e }
1803
+ };
1804
+ }
1805
+ function hideMarker(e = {}) {
1806
+ let t = [], n = { ...e };
1807
+ return t.push(...validateOptionalArray({
1808
+ normalized: n,
1809
+ field: "groupIds",
1810
+ value: e.groupIds,
1811
+ minLength: 1
1812
+ })), {
1813
+ errors: t,
1814
+ normalized: n
1815
+ };
1816
+ }
1817
+ function hideAllMarker(e = {}) {
1818
+ return {
1819
+ errors: [],
1820
+ normalized: { ...e }
1821
+ };
1822
+ }
1823
+ function iconUrlMarker(e = {}) {
1824
+ let t = [], n = { ...e };
1825
+ return t.push(...validateRequiredString({
1826
+ normalized: n,
1827
+ field: "url",
1828
+ value: e.url
1829
+ })), {
1830
+ errors: t,
1831
+ normalized: n
1832
+ };
1833
+ }
1748
1834
  function addClustering(e) {
1749
1835
  let t = [], n = { ...e };
1750
1836
  t.push(...verifyEnumerationValue({
@@ -1893,7 +1979,13 @@ function secondMarker(e) {
1893
1979
  var validator$9 = {
1894
1980
  iconMarker,
1895
1981
  followMarker,
1982
+ removeMarker,
1896
1983
  removeAllMarker,
1984
+ showMarker,
1985
+ showAllMarker,
1986
+ hideMarker,
1987
+ hideAllMarker,
1988
+ iconUrlMarker,
1897
1989
  addClustering,
1898
1990
  removeClustering,
1899
1991
  secondMarker
@@ -1905,8 +1997,8 @@ var validator$9 = {
1905
1997
  let n = `marker.${e}`, r = validator$9[e], i = r ? r(t) : {
1906
1998
  errors: [],
1907
1999
  normalized: t
1908
- };
1909
- return this.commandManager.sendWithDefault(i, n);
2000
+ }, a = e === "iconUrlMarker" ? { timeout: 12e4 } : {};
2001
+ return this.commandManager.sendWithDefault(i, n, a);
1910
2002
  }
1911
2003
  }, validateConfig = (e, t, n) => {
1912
2004
  e && (n === "default" || n === "default1" || n === "default2" || n === "default3" || n === "default4" || n === "flashIcon") && (t.push(...validateOptionalColor({