@heycar/heycars-map 0.9.21-alpha → 0.9.21-alpha3

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
@@ -19,7 +19,7 @@ if (typeof GeolocationPositionError === "undefined") {
19
19
  };
20
20
  }
21
21
  const name = "@heycar/heycars-map";
22
- const version = "0.9.21-alpha";
22
+ const version = "0.9.21-alpha3";
23
23
  const type = "module";
24
24
  const bin = {
25
25
  checkVersion: "./bin/checkVersion.js"
@@ -4542,6 +4542,7 @@ const WX_GET_LOCATION_INTERVAL = 1 * 1e3;
4542
4542
  const ALIPAY_GET_LOCATION_INTERVAL = 1 * 1e3;
4543
4543
  const ALIPAY_GEO_CACHE_TIMEOUT = 5e3;
4544
4544
  const ANDROID_GET_LOCATION_INTERVAL = 1 * 1e3;
4545
+ const ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT = 8e3;
4545
4546
  const takeIsForceBrowserGeo = () => {
4546
4547
  const searchParam = new URLSearchParams(location.search);
4547
4548
  return searchParam.has(`force-browser-geo`);
@@ -4613,7 +4614,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
4613
4614
  if (isHandled)
4614
4615
  return;
4615
4616
  if (lastSuccessfulResponse) {
4616
- console.warn("警告: my.getLocation failed with errcode 13 which has been bypassed");
4617
+ console.warn("警告: wx.getLocation 超时跳过");
4617
4618
  return resolve(
4618
4619
  wxGetLocationSuccessResponse2GeolocationPosition(lastSuccessfulResponse)
4619
4620
  );
@@ -4712,14 +4713,21 @@ function androidWatchPosition(onSuccess, onError, option) {
4712
4713
  continue;
4713
4714
  }
4714
4715
  const geoPosition = await new Promise((resolve) => {
4716
+ let isHandled = false;
4715
4717
  navigator.geolocation.getCurrentPosition(
4716
4718
  function onSuccess2(geoLocationPosition) {
4719
+ if (isHandled)
4720
+ return;
4721
+ isHandled = true;
4717
4722
  geoErrorMessage = void 0;
4718
4723
  resolve(geoLocationPosition);
4719
4724
  },
4720
4725
  function onFail(geoError) {
4726
+ if (isHandled)
4727
+ return;
4728
+ isHandled = true;
4721
4729
  if (geoError.code === 3 && !!prevGeoPosition) {
4722
- console.warn("警告: navigator.geolocation.getCurrentPosition 超时跳过");
4730
+ console.warn("警告: navigator.geolocation.watchPosition 超时跳过");
4723
4731
  resolve(prevGeoPosition);
4724
4732
  return;
4725
4733
  }
@@ -4729,11 +4737,30 @@ function androidWatchPosition(onSuccess, onError, option) {
4729
4737
  resolve(void 0);
4730
4738
  if (prevMessage === message)
4731
4739
  return;
4732
- console.warn("MyWarning: navigator.geolocation.getCurrentPosition failed: ", message);
4740
+ console.warn("MyWarning: navigator.geolocation.watchPosition failed: ", message);
4733
4741
  onError == null ? void 0 : onError(geoError);
4734
4742
  },
4735
4743
  option
4736
4744
  );
4745
+ setTimeout(() => {
4746
+ if (isHandled)
4747
+ return;
4748
+ isHandled = true;
4749
+ if (prevGeoPosition) {
4750
+ console.warn("警告: navigator.geolocation.watchPosition 无响应,超时跳过");
4751
+ return resolve(prevGeoPosition);
4752
+ }
4753
+ const message = `无响应超时: exceed ${ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT}s`;
4754
+ const prevMessage = geoErrorMessage;
4755
+ geoErrorMessage = message;
4756
+ resolve(void 0);
4757
+ if (prevMessage === message)
4758
+ return;
4759
+ console.warn("MyWarning: navigator.geolocation.watchPosition failed message = ", message);
4760
+ onError == null ? void 0 : onError(
4761
+ createCustomGeolocationPositionError(message, GeolocationPositionError.TIMEOUT)
4762
+ );
4763
+ }, ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT);
4737
4764
  });
4738
4765
  if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
4739
4766
  onSuccess(geoPosition);
@@ -4755,7 +4782,6 @@ function compatibleWathPosition(onSuccess, onError, option) {
4755
4782
  }
4756
4783
  const browserPlatform = detectBrowserPlatform();
4757
4784
  const osPlatform = detectOSPlatform();
4758
- console.log("osPlatform = ", osPlatform);
4759
4785
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4760
4786
  return wechatWatchPosition(onSuccess, onError, option);
4761
4787
  }
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ if (typeof GeolocationPositionError === "undefined") {
17
17
  };
18
18
  }
19
19
  const name = "@heycar/heycars-map";
20
- const version = "0.9.21-alpha";
20
+ const version = "0.9.21-alpha3";
21
21
  const type = "module";
22
22
  const bin = {
23
23
  checkVersion: "./bin/checkVersion.js"
@@ -4540,6 +4540,7 @@ const WX_GET_LOCATION_INTERVAL = 1 * 1e3;
4540
4540
  const ALIPAY_GET_LOCATION_INTERVAL = 1 * 1e3;
4541
4541
  const ALIPAY_GEO_CACHE_TIMEOUT = 5e3;
4542
4542
  const ANDROID_GET_LOCATION_INTERVAL = 1 * 1e3;
4543
+ const ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT = 8e3;
4543
4544
  const takeIsForceBrowserGeo = () => {
4544
4545
  const searchParam = new URLSearchParams(location.search);
4545
4546
  return searchParam.has(`force-browser-geo`);
@@ -4611,7 +4612,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
4611
4612
  if (isHandled)
4612
4613
  return;
4613
4614
  if (lastSuccessfulResponse) {
4614
- console.warn("警告: my.getLocation failed with errcode 13 which has been bypassed");
4615
+ console.warn("警告: wx.getLocation 超时跳过");
4615
4616
  return resolve(
4616
4617
  wxGetLocationSuccessResponse2GeolocationPosition(lastSuccessfulResponse)
4617
4618
  );
@@ -4710,14 +4711,21 @@ function androidWatchPosition(onSuccess, onError, option) {
4710
4711
  continue;
4711
4712
  }
4712
4713
  const geoPosition = await new Promise((resolve) => {
4714
+ let isHandled = false;
4713
4715
  navigator.geolocation.getCurrentPosition(
4714
4716
  function onSuccess2(geoLocationPosition) {
4717
+ if (isHandled)
4718
+ return;
4719
+ isHandled = true;
4715
4720
  geoErrorMessage = void 0;
4716
4721
  resolve(geoLocationPosition);
4717
4722
  },
4718
4723
  function onFail(geoError) {
4724
+ if (isHandled)
4725
+ return;
4726
+ isHandled = true;
4719
4727
  if (geoError.code === 3 && !!prevGeoPosition) {
4720
- console.warn("警告: navigator.geolocation.getCurrentPosition 超时跳过");
4728
+ console.warn("警告: navigator.geolocation.watchPosition 超时跳过");
4721
4729
  resolve(prevGeoPosition);
4722
4730
  return;
4723
4731
  }
@@ -4727,11 +4735,30 @@ function androidWatchPosition(onSuccess, onError, option) {
4727
4735
  resolve(void 0);
4728
4736
  if (prevMessage === message)
4729
4737
  return;
4730
- console.warn("MyWarning: navigator.geolocation.getCurrentPosition failed: ", message);
4738
+ console.warn("MyWarning: navigator.geolocation.watchPosition failed: ", message);
4731
4739
  onError == null ? void 0 : onError(geoError);
4732
4740
  },
4733
4741
  option
4734
4742
  );
4743
+ setTimeout(() => {
4744
+ if (isHandled)
4745
+ return;
4746
+ isHandled = true;
4747
+ if (prevGeoPosition) {
4748
+ console.warn("警告: navigator.geolocation.watchPosition 无响应,超时跳过");
4749
+ return resolve(prevGeoPosition);
4750
+ }
4751
+ const message = `无响应超时: exceed ${ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT}s`;
4752
+ const prevMessage = geoErrorMessage;
4753
+ geoErrorMessage = message;
4754
+ resolve(void 0);
4755
+ if (prevMessage === message)
4756
+ return;
4757
+ console.warn("MyWarning: navigator.geolocation.watchPosition failed message = ", message);
4758
+ onError == null ? void 0 : onError(
4759
+ createCustomGeolocationPositionError(message, GeolocationPositionError.TIMEOUT)
4760
+ );
4761
+ }, ANDROID_WATCH_POSITION_NO_RESPONSE_TIMEOUT);
4735
4762
  });
4736
4763
  if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
4737
4764
  onSuccess(geoPosition);
@@ -4753,7 +4780,6 @@ function compatibleWathPosition(onSuccess, onError, option) {
4753
4780
  }
4754
4781
  const browserPlatform = detectBrowserPlatform();
4755
4782
  const osPlatform = detectOSPlatform();
4756
- console.log("osPlatform = ", osPlatform);
4757
4783
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4758
4784
  return wechatWatchPosition(onSuccess, onError, option);
4759
4785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.21-alpha",
3
+ "version": "0.9.21-alpha3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js"