@heycar/heycars-map 2.0.0-switchMap2 → 2.0.0-switchMap3

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.
Files changed (49) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
  4. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  5. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  6. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  7. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  8. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  9. package/dist/v2/chunks/{BusinessRecomendPlaceMap.5be4fdcf.js → BusinessRecomendPlaceMap.f589ebf7.js} +17 -10
  10. package/dist/v2/hooks/useMapLoader.js +3 -0
  11. package/dist/v2/hooks/useMapPlace.d.ts +1 -0
  12. package/dist/v2/hooks/useMapPlace.js +9 -7
  13. package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
  14. package/dist/v2/hooks/useMapRecomendPlace.js +72 -64
  15. package/dist/v2/hooks/useMapSupplier.d.ts +4 -0
  16. package/dist/v2/hooks/useMapSupplier.js +17 -0
  17. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  18. package/dist/v2/index.js +1 -1
  19. package/dist/v2/utils/ManualAbortError.d.ts +3 -0
  20. package/dist/v2/utils/ManualAbortError.js +14 -0
  21. package/dist/v2/utils/helper.d.ts +1 -0
  22. package/dist/v2/utils/helper.js +17 -0
  23. package/dist/v2/utils/log.js +1 -1
  24. package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
  25. package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
  26. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  27. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  28. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  29. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  30. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  31. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  32. package/dist/v3/chunks/{BusinessRecomendPlaceMap.39888296.js → BusinessRecomendPlaceMap.86e9c287.js} +17 -10
  33. package/dist/v3/hooks/useMapLoader.js +3 -0
  34. package/dist/v3/hooks/useMapPlace.d.ts +1 -0
  35. package/dist/v3/hooks/useMapPlace.js +9 -7
  36. package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
  37. package/dist/v3/hooks/useMapRecomendPlace.js +72 -64
  38. package/dist/v3/hooks/useMapSupplier.d.ts +4 -0
  39. package/dist/v3/hooks/useMapSupplier.js +17 -0
  40. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  41. package/dist/v3/index.js +1 -1
  42. package/dist/v3/utils/ManualAbortError.d.ts +3 -0
  43. package/dist/v3/utils/ManualAbortError.js +14 -0
  44. package/dist/v3/utils/helper.d.ts +1 -0
  45. package/dist/v3/utils/helper.js +17 -0
  46. package/dist/v3/utils/log.js +1 -1
  47. package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
  48. package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
  49. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./v2"
1
+ export * from "./v3"
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./v2"
1
+ export * from "./v3"
@@ -1,5 +1,5 @@
1
1
  import { h } from "vue";
2
- import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
2
+ import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.f589ebf7.js";
3
3
  import { useBusinessRecomendPlaceMap } from "../hooks-business/useBusinessRecomendPlaceMap.js";
4
4
  import { defineSetup } from "../types/helper.js";
5
5
  import { d as demo } from "../chunks/Demo.css.e921a2f6.js";
@@ -4,7 +4,7 @@ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
4
4
  import { useHeycarMap } from "../../hooks/useHeycarMap.js";
5
5
  import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
6
6
  import { useMapFitView } from "../../hooks/useMapFitView.js";
7
- import { useMapSupplier } from "../../hooks/useMapSupplier.js";
7
+ import { useMapSupplier, useMapAssertSupplier } from "../../hooks/useMapSupplier.js";
8
8
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
9
9
  import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
10
10
  import { place2point, pipeDefer } from "../../utils/transform.js";
@@ -25,6 +25,9 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
25
25
  const {
26
26
  language
27
27
  } = useMapSupplier();
28
+ const {
29
+ assertSupplier
30
+ } = useMapAssertSupplier();
28
31
  const {
29
32
  mapRef,
30
33
  setMap
@@ -40,7 +43,7 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
40
43
  mapRef,
41
44
  padding: BUSINESS_QUOTING_FITVIEW_PANDING
42
45
  });
43
- mapContext.setFitView = () => setFitView(false);
46
+ mapContext.setFitView = assertSupplier(() => setFitView(false));
44
47
  const fittableRegistryOverlay = createFittableRegisterOverlay({
45
48
  registerOverlay,
46
49
  immediate: true
@@ -14,6 +14,7 @@ import "../../hooks/useMapSupplier.js";
14
14
  import "../../hooks/useMapZoom.js";
15
15
  import "../../types/helper.js";
16
16
  import "../../types/interface.js";
17
+ import "../../utils/ManualAbortError.js";
17
18
  import "../../utils/compare.js";
18
19
  import "../../utils/helper.js";
19
20
  import "../../utils/platform.js";
@@ -25,7 +26,7 @@ import "../GreenZone/GreenZone.js";
25
26
  import "../PassengerCircle/PassengerCircle.js";
26
27
  import "../PickupPoints/PickupPoints.js";
27
28
  import "./useCacheCenterPlace.js";
28
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
29
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.f589ebf7.js";
29
30
  export {
30
31
  B as BusinessRecomendPlaceMap,
31
32
  f as BusinessRecomendPlaceMapInner,
@@ -1,4 +1,4 @@
1
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
1
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.f589ebf7.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -1,5 +1,5 @@
1
1
  import { h } from "vue";
2
- import { reactive, watch, watchEffect } from "vue-demi";
2
+ import { reactive, watch, watchEffect, onUnmounted } from "vue-demi";
3
3
  import { apiMemoryShouldSkipByKey } from "../../api/memory.js";
4
4
  import { HeycarMap } from "../../components/MapProvider/MapProvider.js";
5
5
  import { createElement } from "../../demi-polyfill/demi-polyfill.js";
@@ -9,17 +9,18 @@ import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
9
9
  import { useMapDrag } from "../../hooks/useMapDrag.js";
10
10
  import { useMapGeometry } from "../../hooks/useMapGeometry.js";
11
11
  import { useMapRecomendPlace } from "../../hooks/useMapRecomendPlace.js";
12
- import { useMapSupplier } from "../../hooks/useMapSupplier.js";
12
+ import { useMapAssertSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
13
13
  import { useMapZoom } from "../../hooks/useMapZoom.js";
14
14
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
15
15
  import { CenterPlaceStatus } from "../../types/interface.js";
16
+ import { throwNoneManualAbortError, MANUAL_ABORT_MESSAGE } from "../../utils/ManualAbortError.js";
16
17
  import { watchPostEffectOnce, generateCreateElementV2PropsOn } from "../../utils/compare.js";
17
18
  import { equalAssign, isPlacesInclude } from "../../utils/helper.js";
18
19
  import { detectBrowserPlatform } from "../../utils/platform.js";
19
20
  import { place2point, isPlaceEqual, pipeOnlyLastEffect, isZoneEqual, geoPositionError2businessTimeout } from "../../utils/transform.js";
20
21
  import { toCoordinatePlaceType, toCoordinatePointType, toCoordinateRecommendZonePlacesType } from "../../utils/typeChecking.js";
21
22
  import { AbsoluteAddressBox } from "../AbsoluteAddressBox/AbsoluteAddressBox.js";
22
- import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_LARGE_LIMIT, a as RECOMMEND_PLACE_DRAG_LIMIT, Z as ZONE_ZOOM, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM } from "../../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
23
+ import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_LARGE_LIMIT, a as RECOMMEND_PLACE_DRAG_LIMIT, Z as ZONE_ZOOM, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM } from "../../chunks/BusinessRecomendPlaceMap.f589ebf7.js";
23
24
  import { DeviceOrientation } from "../DeviceOrientation/DeviceOrientation.js";
24
25
  import { GreenZone } from "../GreenZone/GreenZone.js";
25
26
  import { PassengerCircle } from "../PassengerCircle/PassengerCircle.js";
@@ -41,6 +42,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
41
42
  ...EMPTY_PLACE
42
43
  }
43
44
  } = props;
45
+ const abortController = new AbortController();
44
46
  const {
45
47
  coordinatifyPoint,
46
48
  unCoordinatifyPoint,
@@ -68,6 +70,9 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
68
70
  mapRef,
69
71
  defaultValue: DEFAULT_ZOOM
70
72
  });
73
+ const {
74
+ assertSupplier
75
+ } = useMapAssertSupplier();
71
76
  const defaultPlace = unCoordinatifyPlace(toCoordinatePlaceType(inputDefaultPlace));
72
77
  const centerPlace = reactive({
73
78
  lng: defaultPlace.lng,
@@ -148,19 +153,19 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
148
153
  emitGeoErrorOnce(error);
149
154
  }
150
155
  });
151
- mapContext.apiMapDistance = (from, to) => {
156
+ mapContext.apiMapDistance = assertSupplier((from, to) => {
152
157
  return apiMapDistance(unCoordinatifyPoint(toCoordinatePointType(from)), unCoordinatifyPoint(toCoordinatePointType(to)));
153
- };
154
- mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
155
- mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
156
- mapContext.panToGeoPositionByRecomend = () => {
158
+ });
159
+ mapContext.setCenterPlaceByUserSpecified = assertSupplier(setCenterPlaceByUserSpecified);
160
+ mapContext.setCenterPlaceByUserSpecifiedInZone = assertSupplier(setCenterPlaceByUserSpecifiedInZone);
161
+ mapContext.panToGeoPositionByRecomend = assertSupplier(() => {
157
162
  if (geoError.value)
158
163
  return false;
159
164
  updateCenterPlaceByPoint(geoPosition.value, {
160
165
  source: "geo"
161
166
  });
162
167
  return true;
163
- };
168
+ });
164
169
  const {
165
170
  isDragging
166
171
  } = useMapDrag({
@@ -183,6 +188,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
183
188
  emptyPlaceName: emptyTitle,
184
189
  queryingPlaceName: queryingTitle,
185
190
  context: centerSource,
191
+ signal: abortController.signal,
186
192
  getAvailable: pipedGetAvailable,
187
193
  getRecomendPlace: pipedGetRecomendPlace,
188
194
  getLimit: (context) => {
@@ -202,7 +208,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
202
208
  ...place
203
209
  }),
204
210
  onChangePlace: (place) => emit("changePlace", coordinatifyPlace(place)),
205
- onChange: async ({
211
+ onChange: ({
206
212
  place,
207
213
  inputPlace,
208
214
  isInZone,
@@ -224,7 +230,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
224
230
  }));
225
231
  }
226
232
  });
227
- watchPostEffectOnce(() => updateRecommendPlaceOnlyInZone(defaultPlace));
233
+ watchPostEffectOnce(() => updateRecommendPlaceOnlyInZone(defaultPlace).catch(throwNoneManualAbortError));
228
234
  watch(centerPlace, (place) => {
229
235
  equalAssign(mapContext.centerPlace, coordinatifyPlace({
230
236
  ...place
@@ -236,6 +242,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
236
242
  watchEffect(() => {
237
243
  mapContext.centerPlaceStatusRef.value = isQueryingRef.value ? CenterPlaceStatus.QUERYING_INFO : !availableRef.value ? CenterPlaceStatus.SERVICE_UNAVAILABLE : CenterPlaceStatus.OK;
238
244
  });
245
+ onUnmounted(() => abortController.abort(MANUAL_ABORT_MESSAGE));
239
246
  return () => {
240
247
  var _a, _b, _c;
241
248
  const {
@@ -1,5 +1,5 @@
1
1
  import { h } from "vue";
2
- import { ref, watch } from "vue-demi";
2
+ import { ref, watch, onUnmounted } from "vue-demi";
3
3
  import { apiGetAuxiliaryGrapStatus } from "../../api/browser.js";
4
4
  import { setGlobalGoogleSnapRoadProxyUrl } from "../../api/googleSnapRoad.js";
5
5
  import { HeycarMap } from "../../components/MapProvider/MapProvider.js";
@@ -8,9 +8,10 @@ import { useGeoLocation } from "../../hooks/useGeoLocation.js";
8
8
  import { useHeycarMap } from "../../hooks/useHeycarMap.js";
9
9
  import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
10
10
  import { useMapFitView } from "../../hooks/useMapFitView.js";
11
- import { useMapSupplier } from "../../hooks/useMapSupplier.js";
11
+ import { useMapAssertSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
12
12
  import { defineSetup, defineLagecySetup } from "../../types/helper.js";
13
- import { assertNotEmptyArray } from "../../utils/helper.js";
13
+ import { MANUAL_ABORT_MESSAGE } from "../../utils/ManualAbortError.js";
14
+ import { createAbortable, assertNotEmptyArray } from "../../utils/helper.js";
14
15
  import { place2point, pipeDefer, lnglat2point } from "../../utils/transform.js";
15
16
  import { toCoordinatePlaceType, toCoordinateTrackPoint } from "../../utils/typeChecking.js";
16
17
  import { AuxiliaryGraspRoad } from "../AuxiliaryGraspRoad/AuxiliaryGraspRoad.js";
@@ -26,7 +27,6 @@ const BusinessTaxiServiceMapInner = defineSetup("BusinessTaxiServiceMapInner", f
26
27
  interval,
27
28
  disablePassenger,
28
29
  mapContext,
29
- getDriverPositionTrack,
30
30
  renderStartSerivceTitle,
31
31
  renderInServiceTitle
32
32
  } = props;
@@ -36,6 +36,12 @@ const BusinessTaxiServiceMapInner = defineSetup("BusinessTaxiServiceMapInner", f
36
36
  setMap,
37
37
  mapElementRef
38
38
  } = useHeycarMap();
39
+ const {
40
+ assertSupplier
41
+ } = useMapAssertSupplier();
42
+ const abortController = new AbortController();
43
+ const abortable = createAbortable(abortController.signal);
44
+ const getDriverPositionTrack = abortable(props.getDriverPositionTrack);
39
45
  const {
40
46
  unCoordinatifyPlace,
41
47
  unCoordinatifyTrackPoint
@@ -47,7 +53,7 @@ const BusinessTaxiServiceMapInner = defineSetup("BusinessTaxiServiceMapInner", f
47
53
  mapRef,
48
54
  padding: BUSINESS_TAXI_SERVICE_FITVIEW_PANDING
49
55
  });
50
- mapContext.setFitView = () => setFitView(false);
56
+ mapContext.setFitView = assertSupplier(() => setFitView(false));
51
57
  const deferedSetFitView = pipeDefer(() => registerOverlay.setFitView(true));
52
58
  const {
53
59
  geoLoading,
@@ -79,6 +85,7 @@ const BusinessTaxiServiceMapInner = defineSetup("BusinessTaxiServiceMapInner", f
79
85
  }, {
80
86
  immediate: true
81
87
  });
88
+ onUnmounted(() => abortController.abort(MANUAL_ABORT_MESSAGE));
82
89
  return () => {
83
90
  const {
84
91
  driverStatus,
@@ -1,5 +1,5 @@
1
1
  import { h } from "vue";
2
- import { computed, watch, watchEffect } from "vue-demi";
2
+ import { computed, watch, watchEffect, onUnmounted } from "vue-demi";
3
3
  import { apiSaveCenterPlaceToCache } from "../api/browser.js";
4
4
  import { apiMemoryShouldSkipByKey } from "../api/memory.js";
5
5
  import { HeycarMap } from "../components/MapProvider/MapProvider.js";
@@ -10,10 +10,11 @@ import { useMapCoordinatify } from "../hooks/useMapCoordinatify.js";
10
10
  import { useMapDrag } from "../hooks/useMapDrag.js";
11
11
  import { useMapGeometry } from "../hooks/useMapGeometry.js";
12
12
  import { useMapRecomendPlace } from "../hooks/useMapRecomendPlace.js";
13
- import { useMapSupplier } from "../hooks/useMapSupplier.js";
13
+ import { useMapSupplier, useMapAssertSupplier } from "../hooks/useMapSupplier.js";
14
14
  import { useMapZoom } from "../hooks/useMapZoom.js";
15
15
  import { defineSetup, defineLagecySetup } from "../types/helper.js";
16
16
  import { CenterPlaceStatus } from "../types/interface.js";
17
+ import { throwNoneManualAbortError, MANUAL_ABORT_MESSAGE } from "../utils/ManualAbortError.js";
17
18
  import { watchPostEffectOnce, generateCreateElementV2PropsOn } from "../utils/compare.js";
18
19
  import { equalAssign, isPlacesInclude } from "../utils/helper.js";
19
20
  import { detectBrowserPlatform } from "../utils/platform.js";
@@ -286,6 +287,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
286
287
  getRecomendPlace,
287
288
  mapContext
288
289
  } = props;
290
+ const abortController = new AbortController();
289
291
  const {
290
292
  coordinatifyPoint,
291
293
  unCoordinatifyPoint,
@@ -316,6 +318,9 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
316
318
  const {
317
319
  readyPromise
318
320
  } = useMapSupplier();
321
+ const {
322
+ assertSupplier
323
+ } = useMapAssertSupplier();
319
324
  const {
320
325
  centerPlace,
321
326
  isFirstLoad,
@@ -418,19 +423,19 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
418
423
  emitGeoErrorOnce(error);
419
424
  }
420
425
  });
421
- mapContext.apiMapDistance = (from, to) => {
426
+ mapContext.apiMapDistance = assertSupplier((from, to) => {
422
427
  return apiMapDistance(unCoordinatifyPoint(toCoordinatePointType(from)), unCoordinatifyPoint(toCoordinatePointType(to)));
423
- };
424
- mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
425
- mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
426
- mapContext.panToGeoPositionByRecomend = () => {
428
+ });
429
+ mapContext.setCenterPlaceByUserSpecified = assertSupplier(setCenterPlaceByUserSpecified);
430
+ mapContext.setCenterPlaceByUserSpecifiedInZone = assertSupplier(setCenterPlaceByUserSpecifiedInZone);
431
+ mapContext.panToGeoPositionByRecomend = assertSupplier(() => {
427
432
  if (geoError.value)
428
433
  return false;
429
434
  updateCenterPlaceByPoint(geoPosition.value, {
430
435
  source: "geo"
431
436
  });
432
437
  return true;
433
- };
438
+ });
434
439
  const {
435
440
  isDragging
436
441
  } = useMapDrag({
@@ -454,6 +459,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
454
459
  emptyPlaceName: emptyTitle,
455
460
  queryingPlaceName: queryingTitle,
456
461
  context: centerSource,
462
+ signal: abortController.signal,
457
463
  getAvailable: pipedGetAvailable,
458
464
  getRecomendPlace: pipedGetRecomendPlace,
459
465
  getLimit: (context) => {
@@ -473,7 +479,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
473
479
  ...place
474
480
  }),
475
481
  onChangePlace: (place) => emit("changePlace", coordinatifyPlace(place)),
476
- onChange: async ({
482
+ onChange: ({
477
483
  place,
478
484
  inputPlace,
479
485
  isInZone,
@@ -498,7 +504,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
498
504
  const centerPlaceStatusRef = computed(() => isFirstLoad && geoLoading.value ? CenterPlaceStatus.GEO_LOADING : isQueryingRef.value ? CenterPlaceStatus.QUERYING_INFO : !availableRef.value ? CenterPlaceStatus.SERVICE_UNAVAILABLE : CenterPlaceStatus.OK);
499
505
  watchPostEffectOnce(() => {
500
506
  if (!isFirstLoad)
501
- updateRecommendPlaceOnlyInZone(defaultCenterPlace);
507
+ updateRecommendPlaceOnlyInZone(defaultCenterPlace).catch(throwNoneManualAbortError);
502
508
  });
503
509
  watch(centerPlace, (place) => {
504
510
  if (centerPlaceStatusRef.value === CenterPlaceStatus.OK) {
@@ -516,6 +522,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
516
522
  watchEffect(() => {
517
523
  mapContext.centerPlaceStatusRef.value = centerPlaceStatusRef.value;
518
524
  });
525
+ onUnmounted(() => abortController.abort(MANUAL_ABORT_MESSAGE));
519
526
  return () => {
520
527
  var _a, _b, _c;
521
528
  const {
@@ -1,6 +1,7 @@
1
1
  import { shallowRef, computed, ref } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
3
  import { createRunOnce } from "../utils/helper.js";
4
+ import { patchGoogleMapLoader } from "../utils/patchGoogleMapLoader.js";
4
5
  import { t as throttle } from "../chunks/throttle.8bdd8d3b.js";
5
6
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6
7
  var distExports = {};
@@ -639,11 +640,13 @@ const useGmapLoader = (props) => {
639
640
  if (statusRef.value === "SUCCESS")
640
641
  return;
641
642
  const loader = new Loader(options);
643
+ patchGoogleMapLoader(loader);
642
644
  clearTimeout(timerRef.value);
643
645
  timerRef.value = window.setTimeout(() => {
644
646
  statusRef.value = "TIMEOUT";
645
647
  }, GMAP_LOAD_TIMEOUT);
646
648
  if (loader.status !== LoaderStatus.INITIALIZED) {
649
+ window.google = void 0;
647
650
  loader.reset();
648
651
  }
649
652
  statusRef.value = "LOADING";
@@ -3,6 +3,7 @@ import type { Place, Point } from "../types/interface";
3
3
  export interface UseMapPlaceProps {
4
4
  pointRef: Ref<Point>;
5
5
  emptyPlaceName: string;
6
+ signal?: AbortSignal;
6
7
  onChange?: (value: Place) => any;
7
8
  }
8
9
  export declare const useAmapPlace: (props: UseMapPlaceProps) => {
@@ -1,13 +1,13 @@
1
1
  import { ref, reactive, watch } from "vue-demi";
2
2
  import { REGEO_TIMEOUT } from "../api/contants.js";
3
3
  import { createPipeTw } from "../utils/cn2tw.js";
4
- import { equalAssign } from "../utils/helper.js";
4
+ import { equalAssign, createAbortable } from "../utils/helper.js";
5
5
  import { amapPlaceName2DisplayName, gmapPlaceName2DisplayName } from "../utils/transform.js";
6
6
  import { inChina } from "./useMapInChina.js";
7
7
  import { useMapSupplier } from "./useMapSupplier.js";
8
8
  import { useUpdate } from "./useUdate.js";
9
9
  const useAmapPlace = (props) => {
10
- const { onChange, emptyPlaceName } = props;
10
+ const { signal, onChange, emptyPlaceName } = props;
11
11
  const defaultPoint = [...props.pointRef.value];
12
12
  const pointRef = ref(defaultPoint);
13
13
  const { readyPromise, language } = useMapSupplier();
@@ -17,6 +17,7 @@ const useAmapPlace = (props) => {
17
17
  name: "",
18
18
  displayName: ""
19
19
  });
20
+ const abortable = createAbortable(signal);
20
21
  const { idx: placeKey, update } = useUpdate();
21
22
  const updatePlace = (value) => {
22
23
  pointRef.value = value;
@@ -28,7 +29,7 @@ const useAmapPlace = (props) => {
28
29
  place.name = value.name;
29
30
  place.displayName = value.displayName;
30
31
  };
31
- const getPlaceByRegeo = ([lng, lat]) => {
32
+ const getPlaceByRegeo = abortable(([lng, lat]) => {
32
33
  return new Promise((resolve) => {
33
34
  const geocoder = new AMap.Geocoder({ lang: language === "en" ? "en" : "zh_cn" });
34
35
  const pipeTw = createPipeTw(language === "zh-TW");
@@ -58,7 +59,7 @@ const useAmapPlace = (props) => {
58
59
  resolve({ lng, lat, name, displayName });
59
60
  }, REGEO_TIMEOUT);
60
61
  });
61
- };
62
+ });
62
63
  watch(
63
64
  () => [placeKey.value],
64
65
  async () => {
@@ -71,7 +72,7 @@ const useAmapPlace = (props) => {
71
72
  return { place, updatePlace, setPlace, getPlaceByRegeo };
72
73
  };
73
74
  const useGmapPlace = (props) => {
74
- const { onChange, emptyPlaceName } = props;
75
+ const { signal, onChange, emptyPlaceName } = props;
75
76
  const defaultPoint = [...props.pointRef.value];
76
77
  const pointRef = ref(defaultPoint);
77
78
  const { readyPromise, language } = useMapSupplier();
@@ -82,6 +83,7 @@ const useGmapPlace = (props) => {
82
83
  name: "",
83
84
  displayName: ""
84
85
  });
86
+ const abortable = createAbortable(signal);
85
87
  const updatePlace = (value) => {
86
88
  pointRef.value = value;
87
89
  update();
@@ -92,7 +94,7 @@ const useGmapPlace = (props) => {
92
94
  place.name = value.name;
93
95
  place.displayName = value.displayName;
94
96
  };
95
- const getPlaceByRegeo = ([lng, lat]) => {
97
+ const getPlaceByRegeo = abortable(([lng, lat]) => {
96
98
  return new Promise((resolve) => {
97
99
  const geocoder = new google.maps.Geocoder();
98
100
  const pipeTw = createPipeTw(language === "zh-TW");
@@ -113,7 +115,7 @@ const useGmapPlace = (props) => {
113
115
  resolve({ lng, lat, name, displayName });
114
116
  }, REGEO_TIMEOUT);
115
117
  });
116
- };
118
+ });
117
119
  watch(
118
120
  () => placeKey.value,
119
121
  async () => {
@@ -5,6 +5,7 @@ export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
5
5
  context?: C;
6
6
  emptyPlaceName: string;
7
7
  queryingPlaceName: string;
8
+ signal?: AbortSignal;
8
9
  getLimit: (context?: C) => number;
9
10
  getAvailable?: (place: Place) => Promise<boolean>;
10
11
  getRecomendPlace: (place: Place, context?: C) => Promise<RecommendZonePlaces | undefined>;
@@ -1,6 +1,7 @@
1
1
  import { ref, reactive } from "vue-demi";
2
2
  import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
3
- import { equalAssign, isPlacesInclude } from "../utils/helper.js";
3
+ import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
4
+ import { equalAssign, createAbortable, isPlacesInclude } from "../utils/helper.js";
4
5
  import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
5
6
  import { useMapGeometry } from "./useMapGeometry.js";
6
7
  import { useMapPlace } from "./useMapPlace.js";
@@ -11,9 +12,9 @@ function mergeGetRecommendPlaceAndGetAvailable(getRecomendPlace, getAvailable, t
11
12
  getAvailable == null ? void 0 : getAvailable(place).then((value) => {
12
13
  if (!value)
13
14
  resolve({ available: false });
14
- }).catch((error) => console.error(error));
15
+ }).catch(logNoneManualAbortError);
15
16
  getRecomendPlace(place, context).then((result) => resolve(result != null ? result : { available })).catch((error) => {
16
- console.error(error);
17
+ logNoneManualAbortError(error);
17
18
  resolve({ available });
18
19
  });
19
20
  setTimeout(() => resolve({ available }), timeout);
@@ -42,6 +43,7 @@ const useMapRecomendPlace = (props) => {
42
43
  context,
43
44
  emptyPlaceName,
44
45
  queryingPlaceName,
46
+ signal,
45
47
  onChange,
46
48
  onQueryingPlace,
47
49
  onChangePlace
@@ -50,10 +52,12 @@ const useMapRecomendPlace = (props) => {
50
52
  const forceRef = ref(false);
51
53
  const placeCandidatesRef = ref([]);
52
54
  const zoneRef = ref();
55
+ const abortable = createAbortable(signal);
53
56
  const { apiMapIsPointInRing, apiMapDistance } = useMapGeometry();
54
57
  const { getPlaceByRegeo } = useMapPlace({
55
58
  emptyPlaceName,
56
- pointRef: ref([...defaultPoint])
59
+ pointRef: ref([...defaultPoint]),
60
+ signal
57
61
  });
58
62
  const recomendPlace = reactive({
59
63
  lng: defaultPoint[0],
@@ -63,11 +67,11 @@ const useMapRecomendPlace = (props) => {
63
67
  });
64
68
  const isQueryingRef = ref(false);
65
69
  const getRecomendPlaceNoFail = mergeGetRecommendPlaceAndGetAvailable(
66
- getRecomendPlace,
67
- getAvailable,
70
+ abortable(getRecomendPlace),
71
+ abortable(getAvailable),
68
72
  GET_RECOMMEND_PLACE_TIMEOUT
69
73
  );
70
- const findAttachedPlace = async (place) => {
74
+ const findAttachedPlace = abortable(async (place) => {
71
75
  const {
72
76
  places: placeCandidates,
73
77
  zone,
@@ -90,38 +94,40 @@ const useMapRecomendPlace = (props) => {
90
94
  const limit = getLimit(context);
91
95
  const resultPlace = zone || shortestDistance <= limit ? shortestPlace : place;
92
96
  return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, force };
93
- };
94
- const getRecommendPlaceZoneState = async (point, prevState) => {
95
- const [lng, lat] = point;
96
- const zone = zoneRef.value;
97
- if (!zone || !apiMapIsPointInRing(point, zone.path)) {
98
- const reGeoPlacePromise = getPlaceByRegeo(point);
99
- const {
100
- place: closestPlace,
101
- candidates,
102
- available,
103
- force,
104
- zone: zone2
105
- } = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
106
- if (isPlacesInclude(candidates, closestPlace)) {
107
- return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
97
+ });
98
+ const getRecommendPlaceZoneState = abortable(
99
+ async (point, prevState) => {
100
+ const [lng, lat] = point;
101
+ const zone = zoneRef.value;
102
+ if (!zone || !apiMapIsPointInRing(point, zone.path)) {
103
+ const reGeoPlacePromise = getPlaceByRegeo(point);
104
+ const {
105
+ place: closestPlace,
106
+ candidates,
107
+ available,
108
+ force,
109
+ zone: zone2
110
+ } = await findAttachedPlace({ lng, lat, name: "", displayName: "" });
111
+ if (isPlacesInclude(candidates, closestPlace)) {
112
+ return { place: { ...closestPlace }, zone: zone2, available, candidates, force };
113
+ }
114
+ const regeoPlace = await reGeoPlacePromise;
115
+ return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
108
116
  }
109
- const regeoPlace = await reGeoPlacePromise;
110
- return { place: { ...regeoPlace }, zone: zone2, available, candidates, force };
117
+ const { shortestPlace: resultPlace } = findNearestPlace(
118
+ { lng, lat, name: "", displayName: "" },
119
+ prevState.candidates,
120
+ apiMapDistance
121
+ );
122
+ return {
123
+ place: { ...resultPlace },
124
+ zone,
125
+ available: prevState.available,
126
+ force: prevState.force,
127
+ candidates: prevState.candidates
128
+ };
111
129
  }
112
- const { shortestPlace: resultPlace } = findNearestPlace(
113
- { lng, lat, name: "", displayName: "" },
114
- prevState.candidates,
115
- apiMapDistance
116
- );
117
- return {
118
- place: { ...resultPlace },
119
- zone,
120
- available: prevState.available,
121
- force: prevState.force,
122
- candidates: prevState.candidates
123
- };
124
- };
130
+ );
125
131
  const updateIntermediateQueryingState = (point) => {
126
132
  const zone = zoneRef.value;
127
133
  if (zone && apiMapIsPointInRing(point, zone.path))
@@ -141,7 +147,7 @@ const useMapRecomendPlace = (props) => {
141
147
  equalAssign(recomendPlace, { ...intermediateQueryingPlace });
142
148
  onQueryingPlace == null ? void 0 : onQueryingPlace({ ...intermediateQueryingPlace });
143
149
  };
144
- const updatePlace = async (point) => {
150
+ const updatePlace = abortable(async (point) => {
145
151
  updateIntermediateQueryingState(point);
146
152
  const {
147
153
  place: resultPlace,
@@ -166,29 +172,31 @@ const useMapRecomendPlace = (props) => {
166
172
  onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
167
173
  const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
168
174
  onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, isInZone: !!zone, isSameZone });
169
- };
170
- const updatePlaceCandidates = async (place) => {
171
- updateIntermediateQueryingState(place2point(place));
172
- const {
173
- places: placeCandidates,
174
- zone,
175
- available = false,
176
- force = false
177
- } = await getRecomendPlaceNoFail({ ...place }, context);
178
- const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
179
- isQueryingRef.value = false;
180
- availableRef.value = !!available;
181
- forceRef.value = !!force;
182
- zoneRef.value = zone;
183
- placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
184
- return {
185
- inputPlace: { ...place },
186
- isInZone: !!zone,
187
- place: { ...place },
188
- isSameZone
189
- };
190
- };
191
- const updateRecommendPlace = async (place) => {
175
+ });
176
+ const updatePlaceCandidates = abortable(
177
+ async (place) => {
178
+ updateIntermediateQueryingState(place2point(place));
179
+ const {
180
+ places: placeCandidates,
181
+ zone,
182
+ available = false,
183
+ force = false
184
+ } = await getRecomendPlaceNoFail({ ...place }, context);
185
+ const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
186
+ isQueryingRef.value = false;
187
+ availableRef.value = !!available;
188
+ forceRef.value = !!force;
189
+ zoneRef.value = zone;
190
+ placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
191
+ return {
192
+ inputPlace: { ...place },
193
+ isInZone: !!zone,
194
+ place: { ...place },
195
+ isSameZone
196
+ };
197
+ }
198
+ );
199
+ const updateRecommendPlace = abortable(async (place) => {
192
200
  updateIntermediateQueryingState(place2point(place));
193
201
  const {
194
202
  place: resultPlace,
@@ -211,8 +219,8 @@ const useMapRecomendPlace = (props) => {
211
219
  isInZone: !!zone,
212
220
  isSameZone
213
221
  });
214
- };
215
- const updateRecommendPlaceOnlyInZone = async (place) => {
222
+ });
223
+ const updateRecommendPlaceOnlyInZone = abortable(async (place) => {
216
224
  var _a;
217
225
  updateIntermediateQueryingState(place2point(place));
218
226
  const {
@@ -237,7 +245,7 @@ const useMapRecomendPlace = (props) => {
237
245
  isInZone: !!zone,
238
246
  isSameZone
239
247
  });
240
- };
248
+ });
241
249
  const setPlaceCandidatesAndZone = ({ zone, places: placeCandidates }) => {
242
250
  availableRef.value = true;
243
251
  forceRef.value = !!zone;