@heycar/heycars-map 0.9.21-alpha2 → 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-alpha2";
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,19 @@ function androidWatchPosition(onSuccess, onError, option) {
4712
4713
  continue;
4713
4714
  }
4714
4715
  const geoPosition = await new Promise((resolve) => {
4715
- const watchId = navigator.geolocation.watchPosition(
4716
+ let isHandled = false;
4717
+ navigator.geolocation.getCurrentPosition(
4716
4718
  function onSuccess2(geoLocationPosition) {
4717
- navigator.geolocation.clearWatch(watchId);
4719
+ if (isHandled)
4720
+ return;
4721
+ isHandled = true;
4718
4722
  geoErrorMessage = void 0;
4719
4723
  resolve(geoLocationPosition);
4720
4724
  },
4721
4725
  function onFail(geoError) {
4722
- navigator.geolocation.clearWatch(watchId);
4726
+ if (isHandled)
4727
+ return;
4728
+ isHandled = true;
4723
4729
  if (geoError.code === 3 && !!prevGeoPosition) {
4724
4730
  console.warn("警告: navigator.geolocation.watchPosition 超时跳过");
4725
4731
  resolve(prevGeoPosition);
@@ -4736,6 +4742,25 @@ function androidWatchPosition(onSuccess, onError, option) {
4736
4742
  },
4737
4743
  option
4738
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);
4739
4764
  });
4740
4765
  if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
4741
4766
  onSuccess(geoPosition);
@@ -4757,7 +4782,6 @@ function compatibleWathPosition(onSuccess, onError, option) {
4757
4782
  }
4758
4783
  const browserPlatform = detectBrowserPlatform();
4759
4784
  const osPlatform = detectOSPlatform();
4760
- console.log("osPlatform = ", osPlatform);
4761
4785
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4762
4786
  return wechatWatchPosition(onSuccess, onError, option);
4763
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-alpha2";
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,19 @@ function androidWatchPosition(onSuccess, onError, option) {
4710
4711
  continue;
4711
4712
  }
4712
4713
  const geoPosition = await new Promise((resolve) => {
4713
- const watchId = navigator.geolocation.watchPosition(
4714
+ let isHandled = false;
4715
+ navigator.geolocation.getCurrentPosition(
4714
4716
  function onSuccess2(geoLocationPosition) {
4715
- navigator.geolocation.clearWatch(watchId);
4717
+ if (isHandled)
4718
+ return;
4719
+ isHandled = true;
4716
4720
  geoErrorMessage = void 0;
4717
4721
  resolve(geoLocationPosition);
4718
4722
  },
4719
4723
  function onFail(geoError) {
4720
- navigator.geolocation.clearWatch(watchId);
4724
+ if (isHandled)
4725
+ return;
4726
+ isHandled = true;
4721
4727
  if (geoError.code === 3 && !!prevGeoPosition) {
4722
4728
  console.warn("警告: navigator.geolocation.watchPosition 超时跳过");
4723
4729
  resolve(prevGeoPosition);
@@ -4734,6 +4740,25 @@ function androidWatchPosition(onSuccess, onError, option) {
4734
4740
  },
4735
4741
  option
4736
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);
4737
4762
  });
4738
4763
  if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
4739
4764
  onSuccess(geoPosition);
@@ -4755,7 +4780,6 @@ function compatibleWathPosition(onSuccess, onError, option) {
4755
4780
  }
4756
4781
  const browserPlatform = detectBrowserPlatform();
4757
4782
  const osPlatform = detectOSPlatform();
4758
- console.log("osPlatform = ", osPlatform);
4759
4783
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4760
4784
  return wechatWatchPosition(onSuccess, onError, option);
4761
4785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.21-alpha2",
3
+ "version": "0.9.21-alpha3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js"