@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
@@ -1,3 +1,4 @@
1
+ import type { AnyFn } from "@vueuse/core";
1
2
  import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
2
3
  export interface MapSupplierPayolad extends UseMapLoaderProps {
3
4
  gmapRasterId: string;
@@ -9,3 +10,6 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
9
10
  }
10
11
  export declare const useMapSupplier: () => MapSupplierPayolad;
11
12
  export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
13
+ export declare const useMapAssertSupplier: () => {
14
+ assertSupplier: <T extends AnyFn>(fn: T) => T;
15
+ };
@@ -7,7 +7,24 @@ const useMapSupplier = () => {
7
7
  return payload;
8
8
  };
9
9
  const provideMapSupplier = (payload) => provide(context, payload);
10
+ const useMapAssertSupplier = () => {
11
+ const payload = useMapSupplier();
12
+ const instanceSupplier = payload.supplier;
13
+ function assertSupplier(fn) {
14
+ return function fnWithAssertSupplier(...args) {
15
+ console.log("instanceSupplier, payload.supplier = ", instanceSupplier, payload.supplier);
16
+ if (instanceSupplier === payload.supplier)
17
+ return fn(...args);
18
+ throw Error(
19
+ `MyError: expect instance supplier ${payload.supplier}, actual is ${instanceSupplier}
20
+ You probably call the api (exposed by useBusinessXXX) before the Element <BusinessXXX /> rendering!`
21
+ );
22
+ };
23
+ }
24
+ return { assertSupplier };
25
+ };
10
26
  export {
11
27
  provideMapSupplier,
28
+ useMapAssertSupplier,
12
29
  useMapSupplier
13
30
  };
@@ -1,5 +1,5 @@
1
1
  import { reactive, ref, readonly } from "vue-demi";
2
- import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
2
+ import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.f589ebf7.js";
3
3
  import { CenterPlaceStatus } from "../types/interface.js";
4
4
  import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
5
5
  const useBusinessRecomendPlaceMap = () => {
package/dist/v2/index.js CHANGED
@@ -2,7 +2,7 @@ import "./utils/alipayPolyfill.js";
2
2
  import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
3
3
  import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
4
4
  import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
5
- import { B } from "./chunks/BusinessRecomendPlaceMap.5be4fdcf.js";
5
+ import { B } from "./chunks/BusinessRecomendPlaceMap.f589ebf7.js";
6
6
  import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
7
7
  import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
8
8
  import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
@@ -0,0 +1,3 @@
1
+ export declare const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
2
+ export declare const throwNoneManualAbortError: (e: unknown) => void;
3
+ export declare const logNoneManualAbortError: (e: unknown) => void;
@@ -0,0 +1,14 @@
1
+ const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
2
+ const throwNoneManualAbortError = (e) => {
3
+ if (e !== MANUAL_ABORT_MESSAGE)
4
+ throw e;
5
+ };
6
+ const logNoneManualAbortError = (e) => {
7
+ if (e !== MANUAL_ABORT_MESSAGE)
8
+ console.error(e);
9
+ };
10
+ export {
11
+ MANUAL_ABORT_MESSAGE,
12
+ logNoneManualAbortError,
13
+ throwNoneManualAbortError
14
+ };
@@ -33,4 +33,5 @@ export declare const assertAssingedBeforeUsed: () => never;
33
33
  type PickFunctionalPropertyName<T, K extends keyof T = keyof T> = K extends any ? T[K] extends (...args: any) => any ? K : never : never;
34
34
  type PickFunctionalProperty<T> = Pick<T, PickFunctionalPropertyName<T>>;
35
35
  export declare const proxyFunctionalProperty: <T extends object>(target: T) => PickFunctionalProperty<T>;
36
+ export declare const createAbortable: (signal?: AbortSignal) => <F extends ((...args: any) => Promise<any>) | undefined>(fn: F) => F;
36
37
  export {};
@@ -147,12 +147,29 @@ const proxyFunctionalProperty = (target) => {
147
147
  }
148
148
  return result;
149
149
  };
150
+ const createAbortable = (signal) => {
151
+ return function abortable(fn) {
152
+ if (!fn || !signal)
153
+ return fn;
154
+ return function abrotableFn(...args) {
155
+ return new Promise((resolve, reject) => {
156
+ if (signal.aborted)
157
+ return reject(signal.reason);
158
+ signal.addEventListener("abort", () => reject(signal.reason));
159
+ fn(...args).then((result) => {
160
+ signal.aborted ? reject(signal.reason) : resolve(result);
161
+ }, reject);
162
+ });
163
+ };
164
+ };
165
+ };
150
166
  export {
151
167
  assertAngle,
152
168
  assertAssingedBeforeUsed,
153
169
  assertNotEmptyArray,
154
170
  assertPoint,
155
171
  assertZone,
172
+ createAbortable,
156
173
  createAsyncNoFailNonNullable,
157
174
  createReadOnce,
158
175
  createRunOnce,
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.0.0-switchMap2";
3
+ const pkgVersion = "2.0.0-switchMap3";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
@@ -0,0 +1,2 @@
1
+ import { Loader } from "@googlemaps/js-api-loader";
2
+ export declare const patchGoogleMapLoader: (loader: Loader) => void;
@@ -0,0 +1,64 @@
1
+ const patchGoogleMapLoader = (loader) => {
2
+ loader.setScript = setScript;
3
+ };
4
+ function setScript() {
5
+ var _a, _b;
6
+ if (document.getElementById(this.id)) {
7
+ this.callback();
8
+ return;
9
+ }
10
+ const params = {
11
+ key: this.apiKey,
12
+ channel: this.channel,
13
+ client: this.client,
14
+ libraries: this.libraries.length && this.libraries,
15
+ v: this.version,
16
+ mapIds: this.mapIds,
17
+ language: this.language,
18
+ region: this.region,
19
+ authReferrerPolicy: this.authReferrerPolicy
20
+ };
21
+ Object.keys(params).forEach((key) => !params[key] && delete params[key]);
22
+ if (!((_b = (_a = window == null ? void 0 : window.google) == null ? void 0 : _a.maps) == null ? void 0 : _b.importLibrary)) {
23
+ ((g) => {
24
+ let h, a, k, p = "The Google Maps JavaScript API", c = "google", l = "importLibrary", q = "__ib__", m = document, b = window;
25
+ b = b[c] || (b[c] = {});
26
+ const d = b.maps || (b.maps = {}), r = /* @__PURE__ */ new Set(), e = new URLSearchParams(), u = () => (
27
+ // @ts-ignore
28
+ h || (h = new Promise(async (f, n) => {
29
+ var _a2;
30
+ await (a = m.createElement("script"));
31
+ a.id = this.id;
32
+ e.set("libraries", [...r] + "");
33
+ for (k in g)
34
+ e.set(
35
+ k.replace(/[A-Z]/g, (t) => "_" + t[0].toLowerCase()),
36
+ g[k]
37
+ );
38
+ e.set("callback", c + ".maps." + q);
39
+ e.set("t", Date.now().toString());
40
+ a.src = this.url + `?` + e;
41
+ d[q] = f;
42
+ a.onerror = () => h = n(Error(p + " could not load."));
43
+ a.nonce = this.nonce || ((_a2 = m.querySelector("script[nonce]")) == null ? void 0 : _a2.nonce) || "";
44
+ m.head.append(a);
45
+ }))
46
+ );
47
+ d[l] ? console.warn(p + " only loads once. Ignoring:", g) : d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n));
48
+ })(params);
49
+ }
50
+ const libraryPromises = this.libraries.map((library) => this.importLibrary(library));
51
+ if (!libraryPromises.length) {
52
+ libraryPromises.push(this.importLibrary("core"));
53
+ }
54
+ Promise.all(libraryPromises).then(
55
+ () => this.callback(),
56
+ (error) => {
57
+ const event = new ErrorEvent("error", { error });
58
+ this.loadErrorCallback(event);
59
+ }
60
+ );
61
+ }
62
+ export {
63
+ patchGoogleMapLoader
64
+ };
@@ -1,5 +1,5 @@
1
1
  import { createVNode } from "vue";
2
- import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.39888296.js";
2
+ import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.86e9c287.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.39888296.js";
29
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.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.39888296.js";
1
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -1,5 +1,5 @@
1
1
  import { createVNode } 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.39888296.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.86e9c287.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;
241
248
  const {
@@ -1,5 +1,5 @@
1
1
  import { createVNode } 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 { createVNode } 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;
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>;