@heycar/heycars-map 0.9.20-querying3 → 0.9.20-timeout1

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/index.cjs CHANGED
@@ -18,152 +18,8 @@ if (typeof GeolocationPositionError === "undefined") {
18
18
  TIMEOUT: 3
19
19
  };
20
20
  }
21
- var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
22
- BRWOSER_PLATFORM2["WECHAT"] = "WECHAT";
23
- BRWOSER_PLATFORM2["WECHAT_MINIPROGRAM"] = "WECHAT_MINIPROGRAM";
24
- BRWOSER_PLATFORM2["ALIPAY"] = "ALIPAY";
25
- BRWOSER_PLATFORM2["ALIPAY_MINIPROGRAM"] = "ALIPAY_MINIPROGRAM";
26
- BRWOSER_PLATFORM2["H5"] = "H5";
27
- BRWOSER_PLATFORM2["NODE_JS"] = "NODE_JS";
28
- return BRWOSER_PLATFORM2;
29
- })(BRWOSER_PLATFORM || {});
30
- var OS_PLATFORM = /* @__PURE__ */ ((OS_PLATFORM2) => {
31
- OS_PLATFORM2["IOS"] = "IOS";
32
- OS_PLATFORM2["ANDROID"] = "ANDROID";
33
- OS_PLATFORM2["OTHER"] = "OTHER";
34
- return OS_PLATFORM2;
35
- })(OS_PLATFORM || {});
36
- var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
37
- WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
38
- WEBGL_STATUS2["DISABLED"] = "DISABLED";
39
- WEBGL_STATUS2["ENABLED"] = "ENABLED";
40
- return WEBGL_STATUS2;
41
- })(WEBGL_STATUS || {});
42
- var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
43
- ALIPAY_WALLET2["TNGD"] = "TNGD";
44
- ALIPAY_WALLET2["TMN"] = "TMN";
45
- return ALIPAY_WALLET2;
46
- })(ALIPAY_WALLET || {});
47
- const detectAlipayWallet = () => {
48
- if (!navigator)
49
- return void 0;
50
- const useragent = navigator.userAgent.toLowerCase();
51
- if (!useragent.includes("alipay"))
52
- return void 0;
53
- if (useragent.includes("tngkit"))
54
- return "TNGD";
55
- if (useragent.includes("truemoney"))
56
- return "TMN";
57
- };
58
- const detectBrowserPlatform = () => {
59
- if (typeof navigator === "undefined")
60
- return "NODE_JS";
61
- const useragent = navigator.userAgent.toLowerCase();
62
- if (useragent.includes("micromessenger")) {
63
- return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : "WECHAT";
64
- }
65
- if (useragent.includes("alipay")) {
66
- return useragent.includes("miniprogram") ? "ALIPAY_MINIPROGRAM" : "ALIPAY";
67
- }
68
- return "H5";
69
- };
70
- const detectOSPlatform = () => {
71
- if (typeof navigator === "undefined")
72
- return "OTHER";
73
- const userAgent = navigator.userAgent || navigator.vendor;
74
- if (/android/i.test(userAgent)) {
75
- return "ANDROID";
76
- }
77
- if (/iPad|iPhone|iPod/.test(userAgent) && !globalThis.MSStream) {
78
- return "IOS";
79
- }
80
- return "OTHER";
81
- };
82
- function detectWebGL() {
83
- if (typeof window === "undefined")
84
- return "NOT_SUPPORTED";
85
- if (window.WebGLRenderingContext) {
86
- const canvas = document.createElement("canvas");
87
- const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
88
- let context2 = null;
89
- for (const name2 of names) {
90
- try {
91
- context2 = canvas.getContext(name2);
92
- if (context2 && typeof context2.getParameter === "function") {
93
- return "ENABLED";
94
- }
95
- } catch (e) {
96
- console.error("MyError: detectWebGL catch e = ", e);
97
- return "NOT_SUPPORTED";
98
- }
99
- }
100
- return "DISABLED";
101
- }
102
- return "NOT_SUPPORTED";
103
- }
104
- const createMockWx = (opt) => {
105
- const { timeout, lng, lat, status } = opt.getLocation;
106
- const mockWx = {
107
- ready(callback) {
108
- callback();
109
- },
110
- error(callback) {
111
- callback({ errCode: "mock error code", errMsg: "mock error message" });
112
- },
113
- getLocation(props) {
114
- const { success, fail } = props;
115
- if (status === "success") {
116
- setTimeout(() => {
117
- success({
118
- longitude: String(lng),
119
- latitude: String(lat),
120
- accuracy: "30",
121
- speed: "0",
122
- errCode: "",
123
- errMsg: ""
124
- });
125
- }, timeout);
126
- }
127
- if (status === "fail") {
128
- setTimeout(() => {
129
- fail == null ? void 0 : fail({ errCode: "mock error code", errMsg: "mock error message" });
130
- }, timeout);
131
- }
132
- },
133
- config() {
134
- return;
135
- },
136
- miniProgram: {
137
- redirectTo() {
138
- return;
139
- },
140
- getEnv() {
141
- const miniprogram = detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM;
142
- return { miniprogram };
143
- }
144
- }
145
- };
146
- return mockWx;
147
- };
148
- const mockWxByUrl = () => {
149
- const searchParams = new URLSearchParams(location.search);
150
- const enable = searchParams.has("enableMockWx");
151
- if (!enable)
152
- return;
153
- const lng = Number(searchParams.get("lng"));
154
- const lat = Number(searchParams.get("lat"));
155
- const timeout = Number(searchParams.get("timeout")) * 1e3;
156
- const status = searchParams.get("status");
157
- if (status !== "success" && status !== "fail" || isNaN(timeout)) {
158
- console.error("MyError: createMockWxByUrl: wrong parameter from url");
159
- return;
160
- }
161
- const mockWx = createMockWx({ getLocation: { lng, lat, timeout, status } });
162
- window.wx = mockWx;
163
- };
164
- mockWxByUrl();
165
21
  const name = "@heycar/heycars-map";
166
- const version = "0.9.20-querying3";
22
+ const version = "0.9.20-timeout1";
167
23
  const type = "module";
168
24
  const bin = {
169
25
  checkVersion: "./bin/checkVersion.js"
@@ -1559,6 +1415,14 @@ const createAsyncNoFailNonNullable = (fn, defaultValue) => {
1559
1415
  return fn(...args).then((result) => result != null ? result : defaultValue).catch(() => defaultValue);
1560
1416
  };
1561
1417
  };
1418
+ const pipeTimeout = (fn, defaultValue, timeout) => {
1419
+ return function pipedTimeoutedFunction(...args) {
1420
+ return new Promise((resolve, reject) => {
1421
+ setTimeout(() => resolve(defaultValue), timeout);
1422
+ fn(...args).then(resolve).catch(reject);
1423
+ });
1424
+ };
1425
+ };
1562
1426
  const MAX_ANIMATION_DISTANCE_VW = 300;
1563
1427
  const MIN_ANIMATION_DURATION = 300;
1564
1428
  const ANIMATION_DURATION_FOR_100VW = 200;
@@ -1575,8 +1439,93 @@ const ZINDEX_AUXILIARY_GRASP = 14;
1575
1439
  const ZINDEX_LINE_LAYER = 12;
1576
1440
  const ZINDEX_GREEN_ZONE = 10;
1577
1441
  const TRACKS_MATCH_MAX_LENGTH = 3;
1442
+ const REGEO_TIMEOUT = 5e3;
1443
+ const GET_RECOMMEND_PLACE_TIMEOUT = 5e3;
1578
1444
  const IS_ENABLE_AUXILIARY_GRASP_ROAD = location.search.includes("enableAuxiliaryGraspRoad");
1579
1445
  const AMAP_DEFAULT_MARKER_ICON_URL = "https://webapi.amap.com/theme/v1.3/markers/b/mark_bs.png";
1446
+ var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
1447
+ BRWOSER_PLATFORM2["WECHAT"] = "WECHAT";
1448
+ BRWOSER_PLATFORM2["WECHAT_MINIPROGRAM"] = "WECHAT_MINIPROGRAM";
1449
+ BRWOSER_PLATFORM2["ALIPAY"] = "ALIPAY";
1450
+ BRWOSER_PLATFORM2["ALIPAY_MINIPROGRAM"] = "ALIPAY_MINIPROGRAM";
1451
+ BRWOSER_PLATFORM2["H5"] = "H5";
1452
+ BRWOSER_PLATFORM2["NODE_JS"] = "NODE_JS";
1453
+ return BRWOSER_PLATFORM2;
1454
+ })(BRWOSER_PLATFORM || {});
1455
+ var OS_PLATFORM = /* @__PURE__ */ ((OS_PLATFORM2) => {
1456
+ OS_PLATFORM2["IOS"] = "IOS";
1457
+ OS_PLATFORM2["ANDROID"] = "ANDROID";
1458
+ OS_PLATFORM2["OTHER"] = "OTHER";
1459
+ return OS_PLATFORM2;
1460
+ })(OS_PLATFORM || {});
1461
+ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
1462
+ WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
1463
+ WEBGL_STATUS2["DISABLED"] = "DISABLED";
1464
+ WEBGL_STATUS2["ENABLED"] = "ENABLED";
1465
+ return WEBGL_STATUS2;
1466
+ })(WEBGL_STATUS || {});
1467
+ var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
1468
+ ALIPAY_WALLET2["TNGD"] = "TNGD";
1469
+ ALIPAY_WALLET2["TMN"] = "TMN";
1470
+ return ALIPAY_WALLET2;
1471
+ })(ALIPAY_WALLET || {});
1472
+ const detectAlipayWallet = () => {
1473
+ if (!navigator)
1474
+ return void 0;
1475
+ const useragent = navigator.userAgent.toLowerCase();
1476
+ if (!useragent.includes("alipay"))
1477
+ return void 0;
1478
+ if (useragent.includes("tngkit"))
1479
+ return "TNGD";
1480
+ if (useragent.includes("truemoney"))
1481
+ return "TMN";
1482
+ };
1483
+ const detectBrowserPlatform = () => {
1484
+ if (typeof navigator === "undefined")
1485
+ return "NODE_JS";
1486
+ const useragent = navigator.userAgent.toLowerCase();
1487
+ if (useragent.includes("micromessenger")) {
1488
+ return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : "WECHAT";
1489
+ }
1490
+ if (useragent.includes("alipay")) {
1491
+ return useragent.includes("miniprogram") ? "ALIPAY_MINIPROGRAM" : "ALIPAY";
1492
+ }
1493
+ return "H5";
1494
+ };
1495
+ const detectOSPlatform = () => {
1496
+ if (typeof navigator === "undefined")
1497
+ return "OTHER";
1498
+ const userAgent = navigator.userAgent || navigator.vendor;
1499
+ if (/android/i.test(userAgent)) {
1500
+ return "ANDROID";
1501
+ }
1502
+ if (/iPad|iPhone|iPod/.test(userAgent) && !globalThis.MSStream) {
1503
+ return "IOS";
1504
+ }
1505
+ return "OTHER";
1506
+ };
1507
+ function detectWebGL() {
1508
+ if (typeof window === "undefined")
1509
+ return "NOT_SUPPORTED";
1510
+ if (window.WebGLRenderingContext) {
1511
+ const canvas = document.createElement("canvas");
1512
+ const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
1513
+ let context2 = null;
1514
+ for (const name2 of names) {
1515
+ try {
1516
+ context2 = canvas.getContext(name2);
1517
+ if (context2 && typeof context2.getParameter === "function") {
1518
+ return "ENABLED";
1519
+ }
1520
+ } catch (e) {
1521
+ console.error("MyError: detectWebGL catch e = ", e);
1522
+ return "NOT_SUPPORTED";
1523
+ }
1524
+ }
1525
+ return "DISABLED";
1526
+ }
1527
+ return "NOT_SUPPORTED";
1528
+ }
1580
1529
  const vec2lnglat = ([lng, lat]) => ({
1581
1530
  lng: Number(lng),
1582
1531
  lat: Number(lat)
@@ -4605,7 +4554,19 @@ function wechatWatchPosition(onSuccess, onError, option) {
4605
4554
  const isGeoWorkingRef = Vue.ref(true);
4606
4555
  const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
4607
4556
  const startWatch = async () => {
4608
- await wxReady();
4557
+ try {
4558
+ await wxReady();
4559
+ } catch (err) {
4560
+ console.error(err);
4561
+ onError == null ? void 0 : onError(
4562
+ createCustomGeolocationPositionError(
4563
+ err.errMsg,
4564
+ // 签名失败,也算无权限的一种
4565
+ GeolocationPositionError.PERMISSION_DENIED
4566
+ )
4567
+ );
4568
+ return;
4569
+ }
4609
4570
  do {
4610
4571
  if (visibilityStateRef.value === "hidden") {
4611
4572
  await sleep(WX_GET_LOCATION_INTERVAL);
@@ -6702,6 +6663,12 @@ const useAmapPlace = (props) => {
6702
6663
  }
6703
6664
  }
6704
6665
  });
6666
+ setTimeout(() => {
6667
+ console.warn("高德逆地理请求超时!");
6668
+ const name2 = emptyPlaceName;
6669
+ const displayName = emptyPlaceName;
6670
+ resolve({ lng, lat, name: name2, displayName });
6671
+ }, REGEO_TIMEOUT);
6705
6672
  });
6706
6673
  };
6707
6674
  Vue.watch(
@@ -6812,7 +6779,11 @@ const useMapRecomendPlace = (props) => {
6812
6779
  );
6813
6780
  });
6814
6781
  const isQueryingRef = Vue.ref(false);
6815
- const getRecomendPlaceNoFail = createAsyncNoFailNonNullable(getRecomendPlace, {});
6782
+ const getRecomendPlaceNoFail = pipeTimeout(
6783
+ createAsyncNoFailNonNullable(getRecomendPlace, {}),
6784
+ { available: true },
6785
+ GET_RECOMMEND_PLACE_TIMEOUT
6786
+ );
6816
6787
  const findAttachedPlace = async (place) => {
6817
6788
  const inputRecommendZonePlaces = await getRecomendPlaceNoFail({ ...place }, context2);
6818
6789
  const {
@@ -6833,18 +6804,22 @@ const useMapRecomendPlace = (props) => {
6833
6804
  return { place: { ...resultPlace }, zone, candidates: placeCandidates, available };
6834
6805
  };
6835
6806
  const getRecommendPlaceZoneState = async (point, prevState) => {
6807
+ const [lng, lat] = point;
6836
6808
  const zone = zoneRef.value;
6837
6809
  if (!zone || !apiMapIsPointInRing(point, zone.path)) {
6838
- const reGeoPlace = await getPlaceByRegeo(point);
6810
+ const reGeoPlacePromise = getPlaceByRegeo(point);
6839
6811
  const {
6840
- place: resultPlace2,
6812
+ place: closestPlace,
6841
6813
  candidates,
6842
6814
  available,
6843
6815
  zone: zone2
6844
- } = await findAttachedPlace(reGeoPlace);
6845
- return { place: { ...resultPlace2 }, zone: zone2, available, candidates };
6816
+ } = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
6817
+ if (!isPointEqual(place2point(closestPlace), point)) {
6818
+ return { place: { ...closestPlace }, zone: zone2, available, candidates };
6819
+ }
6820
+ const regeoPlace = await reGeoPlacePromise;
6821
+ return { place: { ...regeoPlace }, zone: zone2, available, candidates };
6846
6822
  }
6847
- const [lng, lat] = point;
6848
6823
  const { shortestPlace: resultPlace } = findNearestPlace(
6849
6824
  { lng, lat, name: "", displayName: "" },
6850
6825
  prevState.candidates,
package/dist/index.js CHANGED
@@ -16,152 +16,8 @@ if (typeof GeolocationPositionError === "undefined") {
16
16
  TIMEOUT: 3
17
17
  };
18
18
  }
19
- var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
20
- BRWOSER_PLATFORM2["WECHAT"] = "WECHAT";
21
- BRWOSER_PLATFORM2["WECHAT_MINIPROGRAM"] = "WECHAT_MINIPROGRAM";
22
- BRWOSER_PLATFORM2["ALIPAY"] = "ALIPAY";
23
- BRWOSER_PLATFORM2["ALIPAY_MINIPROGRAM"] = "ALIPAY_MINIPROGRAM";
24
- BRWOSER_PLATFORM2["H5"] = "H5";
25
- BRWOSER_PLATFORM2["NODE_JS"] = "NODE_JS";
26
- return BRWOSER_PLATFORM2;
27
- })(BRWOSER_PLATFORM || {});
28
- var OS_PLATFORM = /* @__PURE__ */ ((OS_PLATFORM2) => {
29
- OS_PLATFORM2["IOS"] = "IOS";
30
- OS_PLATFORM2["ANDROID"] = "ANDROID";
31
- OS_PLATFORM2["OTHER"] = "OTHER";
32
- return OS_PLATFORM2;
33
- })(OS_PLATFORM || {});
34
- var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
35
- WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
36
- WEBGL_STATUS2["DISABLED"] = "DISABLED";
37
- WEBGL_STATUS2["ENABLED"] = "ENABLED";
38
- return WEBGL_STATUS2;
39
- })(WEBGL_STATUS || {});
40
- var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
41
- ALIPAY_WALLET2["TNGD"] = "TNGD";
42
- ALIPAY_WALLET2["TMN"] = "TMN";
43
- return ALIPAY_WALLET2;
44
- })(ALIPAY_WALLET || {});
45
- const detectAlipayWallet = () => {
46
- if (!navigator)
47
- return void 0;
48
- const useragent = navigator.userAgent.toLowerCase();
49
- if (!useragent.includes("alipay"))
50
- return void 0;
51
- if (useragent.includes("tngkit"))
52
- return "TNGD";
53
- if (useragent.includes("truemoney"))
54
- return "TMN";
55
- };
56
- const detectBrowserPlatform = () => {
57
- if (typeof navigator === "undefined")
58
- return "NODE_JS";
59
- const useragent = navigator.userAgent.toLowerCase();
60
- if (useragent.includes("micromessenger")) {
61
- return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : "WECHAT";
62
- }
63
- if (useragent.includes("alipay")) {
64
- return useragent.includes("miniprogram") ? "ALIPAY_MINIPROGRAM" : "ALIPAY";
65
- }
66
- return "H5";
67
- };
68
- const detectOSPlatform = () => {
69
- if (typeof navigator === "undefined")
70
- return "OTHER";
71
- const userAgent = navigator.userAgent || navigator.vendor;
72
- if (/android/i.test(userAgent)) {
73
- return "ANDROID";
74
- }
75
- if (/iPad|iPhone|iPod/.test(userAgent) && !globalThis.MSStream) {
76
- return "IOS";
77
- }
78
- return "OTHER";
79
- };
80
- function detectWebGL() {
81
- if (typeof window === "undefined")
82
- return "NOT_SUPPORTED";
83
- if (window.WebGLRenderingContext) {
84
- const canvas = document.createElement("canvas");
85
- const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
86
- let context2 = null;
87
- for (const name2 of names) {
88
- try {
89
- context2 = canvas.getContext(name2);
90
- if (context2 && typeof context2.getParameter === "function") {
91
- return "ENABLED";
92
- }
93
- } catch (e) {
94
- console.error("MyError: detectWebGL catch e = ", e);
95
- return "NOT_SUPPORTED";
96
- }
97
- }
98
- return "DISABLED";
99
- }
100
- return "NOT_SUPPORTED";
101
- }
102
- const createMockWx = (opt) => {
103
- const { timeout, lng, lat, status } = opt.getLocation;
104
- const mockWx = {
105
- ready(callback) {
106
- callback();
107
- },
108
- error(callback) {
109
- callback({ errCode: "mock error code", errMsg: "mock error message" });
110
- },
111
- getLocation(props) {
112
- const { success, fail } = props;
113
- if (status === "success") {
114
- setTimeout(() => {
115
- success({
116
- longitude: String(lng),
117
- latitude: String(lat),
118
- accuracy: "30",
119
- speed: "0",
120
- errCode: "",
121
- errMsg: ""
122
- });
123
- }, timeout);
124
- }
125
- if (status === "fail") {
126
- setTimeout(() => {
127
- fail == null ? void 0 : fail({ errCode: "mock error code", errMsg: "mock error message" });
128
- }, timeout);
129
- }
130
- },
131
- config() {
132
- return;
133
- },
134
- miniProgram: {
135
- redirectTo() {
136
- return;
137
- },
138
- getEnv() {
139
- const miniprogram = detectBrowserPlatform() === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM;
140
- return { miniprogram };
141
- }
142
- }
143
- };
144
- return mockWx;
145
- };
146
- const mockWxByUrl = () => {
147
- const searchParams = new URLSearchParams(location.search);
148
- const enable = searchParams.has("enableMockWx");
149
- if (!enable)
150
- return;
151
- const lng = Number(searchParams.get("lng"));
152
- const lat = Number(searchParams.get("lat"));
153
- const timeout = Number(searchParams.get("timeout")) * 1e3;
154
- const status = searchParams.get("status");
155
- if (status !== "success" && status !== "fail" || isNaN(timeout)) {
156
- console.error("MyError: createMockWxByUrl: wrong parameter from url");
157
- return;
158
- }
159
- const mockWx = createMockWx({ getLocation: { lng, lat, timeout, status } });
160
- window.wx = mockWx;
161
- };
162
- mockWxByUrl();
163
19
  const name = "@heycar/heycars-map";
164
- const version = "0.9.20-querying3";
20
+ const version = "0.9.20-timeout1";
165
21
  const type = "module";
166
22
  const bin = {
167
23
  checkVersion: "./bin/checkVersion.js"
@@ -1557,6 +1413,14 @@ const createAsyncNoFailNonNullable = (fn, defaultValue) => {
1557
1413
  return fn(...args).then((result) => result != null ? result : defaultValue).catch(() => defaultValue);
1558
1414
  };
1559
1415
  };
1416
+ const pipeTimeout = (fn, defaultValue, timeout) => {
1417
+ return function pipedTimeoutedFunction(...args) {
1418
+ return new Promise((resolve, reject) => {
1419
+ setTimeout(() => resolve(defaultValue), timeout);
1420
+ fn(...args).then(resolve).catch(reject);
1421
+ });
1422
+ };
1423
+ };
1560
1424
  const MAX_ANIMATION_DISTANCE_VW = 300;
1561
1425
  const MIN_ANIMATION_DURATION = 300;
1562
1426
  const ANIMATION_DURATION_FOR_100VW = 200;
@@ -1573,8 +1437,93 @@ const ZINDEX_AUXILIARY_GRASP = 14;
1573
1437
  const ZINDEX_LINE_LAYER = 12;
1574
1438
  const ZINDEX_GREEN_ZONE = 10;
1575
1439
  const TRACKS_MATCH_MAX_LENGTH = 3;
1440
+ const REGEO_TIMEOUT = 5e3;
1441
+ const GET_RECOMMEND_PLACE_TIMEOUT = 5e3;
1576
1442
  const IS_ENABLE_AUXILIARY_GRASP_ROAD = location.search.includes("enableAuxiliaryGraspRoad");
1577
1443
  const AMAP_DEFAULT_MARKER_ICON_URL = "https://webapi.amap.com/theme/v1.3/markers/b/mark_bs.png";
1444
+ var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
1445
+ BRWOSER_PLATFORM2["WECHAT"] = "WECHAT";
1446
+ BRWOSER_PLATFORM2["WECHAT_MINIPROGRAM"] = "WECHAT_MINIPROGRAM";
1447
+ BRWOSER_PLATFORM2["ALIPAY"] = "ALIPAY";
1448
+ BRWOSER_PLATFORM2["ALIPAY_MINIPROGRAM"] = "ALIPAY_MINIPROGRAM";
1449
+ BRWOSER_PLATFORM2["H5"] = "H5";
1450
+ BRWOSER_PLATFORM2["NODE_JS"] = "NODE_JS";
1451
+ return BRWOSER_PLATFORM2;
1452
+ })(BRWOSER_PLATFORM || {});
1453
+ var OS_PLATFORM = /* @__PURE__ */ ((OS_PLATFORM2) => {
1454
+ OS_PLATFORM2["IOS"] = "IOS";
1455
+ OS_PLATFORM2["ANDROID"] = "ANDROID";
1456
+ OS_PLATFORM2["OTHER"] = "OTHER";
1457
+ return OS_PLATFORM2;
1458
+ })(OS_PLATFORM || {});
1459
+ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
1460
+ WEBGL_STATUS2["NOT_SUPPORTED"] = "NOT_SUPPORTED";
1461
+ WEBGL_STATUS2["DISABLED"] = "DISABLED";
1462
+ WEBGL_STATUS2["ENABLED"] = "ENABLED";
1463
+ return WEBGL_STATUS2;
1464
+ })(WEBGL_STATUS || {});
1465
+ var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
1466
+ ALIPAY_WALLET2["TNGD"] = "TNGD";
1467
+ ALIPAY_WALLET2["TMN"] = "TMN";
1468
+ return ALIPAY_WALLET2;
1469
+ })(ALIPAY_WALLET || {});
1470
+ const detectAlipayWallet = () => {
1471
+ if (!navigator)
1472
+ return void 0;
1473
+ const useragent = navigator.userAgent.toLowerCase();
1474
+ if (!useragent.includes("alipay"))
1475
+ return void 0;
1476
+ if (useragent.includes("tngkit"))
1477
+ return "TNGD";
1478
+ if (useragent.includes("truemoney"))
1479
+ return "TMN";
1480
+ };
1481
+ const detectBrowserPlatform = () => {
1482
+ if (typeof navigator === "undefined")
1483
+ return "NODE_JS";
1484
+ const useragent = navigator.userAgent.toLowerCase();
1485
+ if (useragent.includes("micromessenger")) {
1486
+ return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : "WECHAT";
1487
+ }
1488
+ if (useragent.includes("alipay")) {
1489
+ return useragent.includes("miniprogram") ? "ALIPAY_MINIPROGRAM" : "ALIPAY";
1490
+ }
1491
+ return "H5";
1492
+ };
1493
+ const detectOSPlatform = () => {
1494
+ if (typeof navigator === "undefined")
1495
+ return "OTHER";
1496
+ const userAgent = navigator.userAgent || navigator.vendor;
1497
+ if (/android/i.test(userAgent)) {
1498
+ return "ANDROID";
1499
+ }
1500
+ if (/iPad|iPhone|iPod/.test(userAgent) && !globalThis.MSStream) {
1501
+ return "IOS";
1502
+ }
1503
+ return "OTHER";
1504
+ };
1505
+ function detectWebGL() {
1506
+ if (typeof window === "undefined")
1507
+ return "NOT_SUPPORTED";
1508
+ if (window.WebGLRenderingContext) {
1509
+ const canvas = document.createElement("canvas");
1510
+ const names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"];
1511
+ let context2 = null;
1512
+ for (const name2 of names) {
1513
+ try {
1514
+ context2 = canvas.getContext(name2);
1515
+ if (context2 && typeof context2.getParameter === "function") {
1516
+ return "ENABLED";
1517
+ }
1518
+ } catch (e) {
1519
+ console.error("MyError: detectWebGL catch e = ", e);
1520
+ return "NOT_SUPPORTED";
1521
+ }
1522
+ }
1523
+ return "DISABLED";
1524
+ }
1525
+ return "NOT_SUPPORTED";
1526
+ }
1578
1527
  const vec2lnglat = ([lng, lat]) => ({
1579
1528
  lng: Number(lng),
1580
1529
  lat: Number(lat)
@@ -4603,7 +4552,19 @@ function wechatWatchPosition(onSuccess, onError, option) {
4603
4552
  const isGeoWorkingRef = ref(true);
4604
4553
  const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
4605
4554
  const startWatch = async () => {
4606
- await wxReady();
4555
+ try {
4556
+ await wxReady();
4557
+ } catch (err) {
4558
+ console.error(err);
4559
+ onError == null ? void 0 : onError(
4560
+ createCustomGeolocationPositionError(
4561
+ err.errMsg,
4562
+ // 签名失败,也算无权限的一种
4563
+ GeolocationPositionError.PERMISSION_DENIED
4564
+ )
4565
+ );
4566
+ return;
4567
+ }
4607
4568
  do {
4608
4569
  if (visibilityStateRef.value === "hidden") {
4609
4570
  await sleep(WX_GET_LOCATION_INTERVAL);
@@ -6700,6 +6661,12 @@ const useAmapPlace = (props) => {
6700
6661
  }
6701
6662
  }
6702
6663
  });
6664
+ setTimeout(() => {
6665
+ console.warn("高德逆地理请求超时!");
6666
+ const name2 = emptyPlaceName;
6667
+ const displayName = emptyPlaceName;
6668
+ resolve({ lng, lat, name: name2, displayName });
6669
+ }, REGEO_TIMEOUT);
6703
6670
  });
6704
6671
  };
6705
6672
  watch(
@@ -6810,7 +6777,11 @@ const useMapRecomendPlace = (props) => {
6810
6777
  );
6811
6778
  });
6812
6779
  const isQueryingRef = ref(false);
6813
- const getRecomendPlaceNoFail = createAsyncNoFailNonNullable(getRecomendPlace, {});
6780
+ const getRecomendPlaceNoFail = pipeTimeout(
6781
+ createAsyncNoFailNonNullable(getRecomendPlace, {}),
6782
+ { available: true },
6783
+ GET_RECOMMEND_PLACE_TIMEOUT
6784
+ );
6814
6785
  const findAttachedPlace = async (place) => {
6815
6786
  const inputRecommendZonePlaces = await getRecomendPlaceNoFail({ ...place }, context2);
6816
6787
  const {
@@ -6831,18 +6802,22 @@ const useMapRecomendPlace = (props) => {
6831
6802
  return { place: { ...resultPlace }, zone, candidates: placeCandidates, available };
6832
6803
  };
6833
6804
  const getRecommendPlaceZoneState = async (point, prevState) => {
6805
+ const [lng, lat] = point;
6834
6806
  const zone = zoneRef.value;
6835
6807
  if (!zone || !apiMapIsPointInRing(point, zone.path)) {
6836
- const reGeoPlace = await getPlaceByRegeo(point);
6808
+ const reGeoPlacePromise = getPlaceByRegeo(point);
6837
6809
  const {
6838
- place: resultPlace2,
6810
+ place: closestPlace,
6839
6811
  candidates,
6840
6812
  available,
6841
6813
  zone: zone2
6842
- } = await findAttachedPlace(reGeoPlace);
6843
- return { place: { ...resultPlace2 }, zone: zone2, available, candidates };
6814
+ } = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
6815
+ if (!isPointEqual(place2point(closestPlace), point)) {
6816
+ return { place: { ...closestPlace }, zone: zone2, available, candidates };
6817
+ }
6818
+ const regeoPlace = await reGeoPlacePromise;
6819
+ return { place: { ...regeoPlace }, zone: zone2, available, candidates };
6844
6820
  }
6845
- const [lng, lat] = point;
6846
6821
  const { shortestPlace: resultPlace } = findNearestPlace(
6847
6822
  { lng, lat, name: "", displayName: "" },
6848
6823
  prevState.candidates,
@@ -15,5 +15,7 @@ export declare const ZINDEX_AUXILIARY_GRASP = 14;
15
15
  export declare const ZINDEX_LINE_LAYER = 12;
16
16
  export declare const ZINDEX_GREEN_ZONE = 10;
17
17
  export declare const TRACKS_MATCH_MAX_LENGTH = 3;
18
+ export declare const REGEO_TIMEOUT = 5000;
19
+ export declare const GET_RECOMMEND_PLACE_TIMEOUT = 5000;
18
20
  export declare const IS_ENABLE_AUXILIARY_GRASP_ROAD: boolean;
19
21
  export declare const AMAP_DEFAULT_MARKER_ICON_URL = "https://webapi.amap.com/theme/v1.3/markers/b/mark_bs.png";
@@ -1,6 +1,5 @@
1
1
  import "./style.css";
2
2
  import "./utils/alipayPolyfill";
3
- import "./utils/mockWx";
4
3
  export { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox";
5
4
  export { AddressBox } from "./business-components/AddressBox";
6
5
  export { BusinessQuotingMap } from "./business-components/BusinessQuotingMap";
@@ -23,4 +23,5 @@ export declare const pausableSleep: (milliSeconds: number) => {
23
23
  };
24
24
  export declare const createRunOnce: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => R;
25
25
  export declare const createAsyncNoFailNonNullable: <P extends any[], R>(fn: (...args: P) => Promise<R>, defaultValue: NonNullable<R>) => (...args: P) => Promise<NonNullable<R>>;
26
+ export declare const pipeTimeout: <P extends any[], R>(fn: (...args: P) => Promise<R>, defaultValue: R, timeout: number) => (...args: P) => Promise<R>;
26
27
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { Wx } from "../types/wx";
2
2
  interface CreateMockWxProps {
3
+ configOk: boolean;
3
4
  getLocation: {
4
5
  timeout: number;
5
6
  lng?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.20-querying3",
3
+ "version": "0.9.20-timeout1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js"