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

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 (75) 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/api/pingConnection.d.ts +9 -0
  5. package/dist/v2/api/pingConnection.js +107 -0
  6. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  7. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  8. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
  9. package/dist/v2/chunks/{BusinessRecomendPlaceMap.f589ebf7.js → BusinessRecomendPlaceMap.4b641c71.js} +6 -3
  10. package/dist/v2/chunks/{Loading.da68a2a6.js → Loading.492acbc2.js} +10 -12
  11. package/dist/v2/components/Loading/Loading.css.d.ts +2 -2
  12. package/dist/v2/components/Loading/Loading.js +3 -3
  13. package/dist/v2/components/Loading/index.js +3 -3
  14. package/dist/v2/components/MapProvider/MapProvider.js +13 -10
  15. package/dist/v2/css/{Loading-0e058b68.css → Loading-49e58ced.css} +6 -11
  16. package/dist/v2/hooks/useDeviceOrientation.js +17 -1
  17. package/dist/v2/hooks/useMapGCJ02.js +0 -3
  18. package/dist/v2/hooks/useMapGeometry.d.ts +1 -3
  19. package/dist/v2/hooks/useMapGeometry.js +4 -4
  20. package/dist/v2/hooks/useMapLoader.d.ts +4 -2
  21. package/dist/v2/hooks/useMapLoader.js +110 -85
  22. package/dist/v2/hooks/useMapPlace.js +42 -35
  23. package/dist/v2/hooks/useMapRecomendPlace.js +4 -4
  24. package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
  25. package/dist/v2/hooks/usePingConnection.d.ts +10 -0
  26. package/dist/v2/hooks/usePingConnection.js +26 -0
  27. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  28. package/dist/v2/index.js +1 -1
  29. package/dist/v2/types/global.d.ts +3 -0
  30. package/dist/v2/types/interface.d.ts +1 -1
  31. package/dist/v2/utils/helper.d.ts +1 -0
  32. package/dist/v2/utils/helper.js +12 -0
  33. package/dist/v2/utils/log.js +1 -1
  34. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  35. package/dist/v3/api/pingConnection.d.ts +9 -0
  36. package/dist/v3/api/pingConnection.js +107 -0
  37. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  38. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  39. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
  40. package/dist/v3/chunks/{BusinessRecomendPlaceMap.86e9c287.js → BusinessRecomendPlaceMap.4befb6c7.js} +6 -3
  41. package/dist/v3/chunks/{Loading.98d687c0.js → Loading.21d8e759.js} +10 -12
  42. package/dist/v3/components/Loading/Loading.css.d.ts +2 -2
  43. package/dist/v3/components/Loading/Loading.js +3 -3
  44. package/dist/v3/components/Loading/index.js +3 -3
  45. package/dist/v3/components/MapProvider/MapProvider.js +13 -10
  46. package/dist/v3/css/{Loading-0e058b68.css → Loading-49e58ced.css} +6 -11
  47. package/dist/v3/hooks/useDeviceOrientation.js +17 -1
  48. package/dist/v3/hooks/useMapGCJ02.js +0 -3
  49. package/dist/v3/hooks/useMapGeometry.d.ts +1 -3
  50. package/dist/v3/hooks/useMapGeometry.js +4 -4
  51. package/dist/v3/hooks/useMapLoader.d.ts +4 -2
  52. package/dist/v3/hooks/useMapLoader.js +110 -85
  53. package/dist/v3/hooks/useMapPlace.js +42 -35
  54. package/dist/v3/hooks/useMapRecomendPlace.js +4 -4
  55. package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
  56. package/dist/v3/hooks/usePingConnection.d.ts +10 -0
  57. package/dist/v3/hooks/usePingConnection.js +26 -0
  58. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  59. package/dist/v3/index.js +1 -1
  60. package/dist/v3/types/global.d.ts +3 -0
  61. package/dist/v3/types/interface.d.ts +1 -1
  62. package/dist/v3/utils/helper.d.ts +1 -0
  63. package/dist/v3/utils/helper.js +12 -0
  64. package/dist/v3/utils/log.js +1 -1
  65. package/package.json +1 -1
  66. package/dist/v2/api/googleConnection.d.ts +0 -5
  67. package/dist/v2/api/googleConnection.js +0 -51
  68. package/dist/v2/chunks/throttle.8bdd8d3b.js +0 -20
  69. package/dist/v2/hooks/useGoogleConnection.d.ts +0 -7
  70. package/dist/v2/hooks/useGoogleConnection.js +0 -15
  71. package/dist/v3/api/googleConnection.d.ts +0 -5
  72. package/dist/v3/api/googleConnection.js +0 -51
  73. package/dist/v3/chunks/throttle.8bdd8d3b.js +0 -20
  74. package/dist/v3/hooks/useGoogleConnection.d.ts +0 -7
  75. package/dist/v3/hooks/useGoogleConnection.js +0 -15
@@ -26,7 +26,7 @@ import "../GreenZone/GreenZone.js";
26
26
  import "../PassengerCircle/PassengerCircle.js";
27
27
  import "../PickupPoints/PickupPoints.js";
28
28
  import "./useCacheCenterPlace.js";
29
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.js";
29
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.4befb6c7.js";
30
30
  export {
31
31
  B as BusinessRecomendPlaceMap,
32
32
  f as BusinessRecomendPlaceMapInner,
@@ -1,4 +1,4 @@
1
- import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.86e9c287.js";
1
+ import { B, f, D, E, a, c, R, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.4befb6c7.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -20,7 +20,7 @@ import { detectBrowserPlatform } from "../../utils/platform.js";
20
20
  import { place2point, isPlaceEqual, pipeOnlyLastEffect, isZoneEqual, geoPositionError2businessTimeout } from "../../utils/transform.js";
21
21
  import { toCoordinatePlaceType, toCoordinatePointType, toCoordinateRecommendZonePlacesType } from "../../utils/typeChecking.js";
22
22
  import { AbsoluteAddressBox } from "../AbsoluteAddressBox/AbsoluteAddressBox.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
+ 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.4befb6c7.js";
24
24
  import { DeviceOrientation } from "../DeviceOrientation/DeviceOrientation.js";
25
25
  import { GreenZone } from "../GreenZone/GreenZone.js";
26
26
  import { PassengerCircle } from "../PassengerCircle/PassengerCircle.js";
@@ -316,7 +316,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
316
316
  defaultValue: DEFAULT_ZOOM
317
317
  });
318
318
  const {
319
- readyPromise
319
+ readyPromise,
320
+ supplier
320
321
  } = useMapSupplier();
321
322
  const {
322
323
  assertSupplier
@@ -400,7 +401,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
400
401
  if (!isFirstLoad)
401
402
  return;
402
403
  const [lng, lat] = value.position;
403
- await readyPromise;
404
+ if (supplier === "amap")
405
+ await readyPromise;
404
406
  centerSource.source = "geo";
405
407
  centerPlace.lng = lng;
406
408
  centerPlace.lat = lat;
@@ -410,7 +412,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
410
412
  emit("loadDefaultGeoLocation", coordinatifyGeoPosition(value));
411
413
  if (!isFirstLoad)
412
414
  return;
413
- await readyPromise;
415
+ if (supplier === "amap")
416
+ await readyPromise;
414
417
  centerSource.source = "geo";
415
418
  updatePlace(value.position);
416
419
  },
@@ -1,17 +1,17 @@
1
- import "../css/Loading-0e058b68.css";
1
+ import "../css/Loading-49e58ced.css";
2
2
  import { createVNode } from "vue";
3
3
  import { ICON_LOAD_FAILED_URL } from "../api/cdn.js";
4
4
  import { AbsoluteAddressBox } from "../business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
5
5
  import { defineSetup } from "../types/helper.js";
6
6
  const imgGrid = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzg1IiBoZWlnaHQ9IjgxNyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBzdHJva2U9IiNEOERCRTIiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlLWRhc2hhcnJheT0iMSI+PHBhdGggZD0iTS41IDgxN1YwTTI0LjUgODE3VjBNNDguNSA4MTdWME03Mi41IDgxN1YwTTk2LjUgODE3VjBNMTIwLjUgODE3VjBNMTQ0LjUgODE3VjBNMTY4LjUgODE3VjBNMTkyLjUgODE3VjBNMjE2LjUgODE3VjBNMjQwLjUgODE3VjBNMjY0LjUgODE3VjBNMjg4LjUgODE3VjBNMzEyLjUgODE3VjBNMzM2LjUgODE3VjBNMzYwLjUgODE3VjBNMzg0LjUgODE3VjBNMCAuNWgzODVNMCAyNC41aDM4NU0wIDQ4LjVoMzg1TTAgNzIuNWgzODVNMCA5Ni41aDM4NU0wIDEyMC41aDM4NU0wIDE0NC41aDM4NU0wIDE2OC41aDM4NU0wIDE5Mi41aDM4NU0wIDIxNi41aDM4NU0wIDI0MC41aDM4NU0wIDI2NC41aDM4NU0wIDI4OC41aDM4NU0wIDMxMi41aDM4NU0wIDMzNi41aDM4NU0wIDM2MC41aDM4NU0wIDM4NC41aDM4NU0wIDQwOC41aDM4NU0wIDQzMi41aDM4NU0wIDQ1Ni41aDM4NU0wIDQ4MC41aDM4NU0wIDUwNC41aDM4NU0wIDUyOC41aDM4NU0wIDU1Mi41aDM4NU0wIDU3Ni41aDM4NU0wIDYwMC41aDM4NU0wIDYyNC41aDM4NU0wIDY0OC41aDM4NU0wIDY3Mi41aDM4NU0wIDY5Ni41aDM4NU0wIDcyMC41aDM4NU0wIDc0NC41aDM4NU0wIDc2OC41aDM4NU0wIDc5Mi41aDM4NU0wIDgxNi41aDM4NSIvPjwvZz48L3N2Zz4=";
7
7
  const Loading_css_ts_vanilla = "";
8
+ var contentLayout = "_17ify492";
8
9
  var description = "_17ify496";
9
- var iconLayout = "_17ify492";
10
10
  var iconLoadFailed = "_17ify493";
11
11
  var loadingBg = "_17ify491";
12
12
  var loadingLayout = "_17ify490";
13
- var textLayout = "_17ify494";
14
13
  var title = "_17ify495";
14
+ var verticalGap = "_17ify494";
15
15
  const Loading = defineSetup("Loading", function() {
16
16
  return () => createVNode("div", {
17
17
  "class": loadingLayout
@@ -30,20 +30,18 @@ const LoadFailed = defineSetup("LoadFailed", function(props) {
30
30
  "class": loadingBg,
31
31
  "src": imgGrid
32
32
  }, null), createVNode("div", {
33
- "class": iconLayout
33
+ "class": contentLayout
34
34
  }, [createVNode("img", {
35
35
  "class": iconLoadFailed,
36
36
  "src": ICON_LOAD_FAILED_URL
37
- }, null), createVNode("div", {
38
- "class": textLayout
39
- }, [createVNode("span", {
40
- "class": title
37
+ }, null), createVNode("span", {
38
+ "class": `${title} ${verticalGap}`
41
39
  }, [props.title]), createVNode("span", {
42
- "class": description
43
- }, [props.description])])])]);
40
+ "class": `${description} ${verticalGap}`
41
+ }, [props.description])])]);
44
42
  });
45
43
  export {
46
- Loading as L,
47
- LoadFailed as a,
44
+ LoadFailed as L,
45
+ Loading as a,
48
46
  imgGrid as i
49
47
  };
@@ -1,7 +1,7 @@
1
1
  export declare const loadingLayout: string;
2
2
  export declare const loadingBg: string;
3
- export declare const iconLayout: string;
3
+ export declare const contentLayout: string;
4
4
  export declare const iconLoadFailed: string;
5
- export declare const textLayout: string;
5
+ export declare const verticalGap: string;
6
6
  export declare const title: string;
7
7
  export declare const description: string;
@@ -1,9 +1,9 @@
1
1
  import "vue";
2
2
  import "../../api/cdn.js";
3
- import { a, L } from "../../chunks/Loading.98d687c0.js";
3
+ import { L, a } from "../../chunks/Loading.21d8e759.js";
4
4
  import "../../business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
5
5
  import "../../types/helper.js";
6
6
  export {
7
- a as LoadFailed,
8
- L as Loading
7
+ L as LoadFailed,
8
+ a as Loading
9
9
  };
@@ -1,5 +1,5 @@
1
- import { a, L } from "../../chunks/Loading.98d687c0.js";
1
+ import { L, a } from "../../chunks/Loading.21d8e759.js";
2
2
  export {
3
- a as LoadFailed,
4
- L as Loading
3
+ L as LoadFailed,
4
+ a as Loading
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import "../../css/MapProvider-156bfd53.css";
2
2
  import { createVNode, isVNode } from "vue";
3
- import { L as Loading, a as LoadFailed, i as imgGrid } from "../../chunks/Loading.98d687c0.js";
3
+ import { L as LoadFailed, a as Loading, i as imgGrid } from "../../chunks/Loading.21d8e759.js";
4
4
  import { useMapLoader, Status } from "../../hooks/useMapLoader.js";
5
5
  import { provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
6
6
  import { defineLagecySetup } from "../../types/helper.js";
@@ -29,6 +29,8 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
29
29
  get(target, name, receiver) {
30
30
  if (name === "status")
31
31
  return payload.statusRef.value;
32
+ if (name === "pingStatus")
33
+ return payload.pingStatusRef.value;
32
34
  if (name === "readyPromise")
33
35
  return payload.readyPromise;
34
36
  return Reflect.get(target, name, receiver);
@@ -73,7 +75,8 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
73
75
  gmapId,
74
76
  gmapRasterId,
75
77
  language = "zh",
76
- status
78
+ status,
79
+ pingStatus
77
80
  } = payload;
78
81
  const {
79
82
  mapRef: setMap,
@@ -82,19 +85,19 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
82
85
  touchEnable = true,
83
86
  touchZoomCenter
84
87
  } = props;
85
- if (status === Status.LOADING) {
86
- const node = (_a = slots.loading) == null ? void 0 : _a.call(slots);
87
- return node ? createVNode("div", null, [node]) : createVNode(Loading, null, null);
88
- }
89
- if (status === Status.FAILURE || status === Status.TIMEOUT) {
90
- const node = (_b = slots.fallback) == null ? void 0 : _b.call(slots);
91
- const title = (_c = payload.renderLoadFailedTitle) == null ? void 0 : _c.call(payload, status);
92
- const description = (_d = payload.renderLoadFailedDescription) == null ? void 0 : _d.call(payload, status);
88
+ if (status === Status.FAILURE || pingStatus === "unconnected") {
89
+ const node = (_a = slots.fallback) == null ? void 0 : _a.call(slots);
90
+ const title = (_b = payload.renderLoadFailedTitle) == null ? void 0 : _b.call(payload, status);
91
+ const description = (_c = payload.renderLoadFailedDescription) == null ? void 0 : _c.call(payload, status);
93
92
  return node ? createVNode("div", null, [node]) : createVNode(LoadFailed, {
94
93
  "title": title,
95
94
  "description": description
96
95
  }, null);
97
96
  }
97
+ if (status === Status.LOADING || status === Status.SUCCESS && pingStatus === "pending") {
98
+ const node = (_d = slots.loading) == null ? void 0 : _d.call(slots);
99
+ return node ? createVNode("div", null, [node]) : createVNode(Loading, null, null);
100
+ }
98
101
  const children = (_e = slots.default) == null ? void 0 : _e.call(slots);
99
102
  const outArea = (_f = slots.outerArea) == null ? void 0 : _f.call(slots);
100
103
  const mapId = patchGmapIdForAlipayCompatible({
@@ -3,6 +3,7 @@
3
3
  background-color: #EDF1F5;
4
4
  }
5
5
  ._17ify491 {
6
+ position: absolute;
6
7
  width: 100%;
7
8
  height: 100%;
8
9
  object-fit: cover;
@@ -10,29 +11,24 @@
10
11
  ._17ify492 {
11
12
  position: absolute;
12
13
  margin: auto;
13
- top: 0;
14
+ top: -5vh;
14
15
  left: 0;
15
16
  right: 0;
16
17
  bottom: 0;
17
18
  width: fit-content;
18
19
  height: fit-content;
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
19
23
  }
20
24
  ._17ify493 {
21
25
  width: 40.8vw;
22
26
  height: 24.53vw;
23
27
  }
24
28
  ._17ify494 {
25
- position: absolute;
26
- top: 100%;
27
- display: flex;
28
- flex-direction: column;
29
- align-items: center;
30
- width: max-content;
31
- left: 50%;
32
- transform: translate(-50%, 0);
29
+ margin-top: 1.6vw;
33
30
  }
34
31
  ._17ify495 {
35
- margin-top: 1.6vw;
36
32
  font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
37
33
  font-weight: 500;
38
34
  font-size: 4vw;
@@ -40,7 +36,6 @@
40
36
  line-height: 6.4vw;
41
37
  }
42
38
  ._17ify496 {
43
- margin-top: 1.6vw;
44
39
  font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
45
40
  font-weight: 400;
46
41
  font-size: 3.73vw;
@@ -1,7 +1,23 @@
1
1
  import { reactive, watch } from "vue-demi";
2
2
  import { MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT } from "../utils/patchMiniprogram.js";
3
3
  import { OS_PLATFORM, detectOSPlatform } from "../utils/platform.js";
4
- import { t as throttle } from "../chunks/throttle.8bdd8d3b.js";
4
+ import { i as isObject, d as debounce } from "../chunks/debounce.5afe7867.js";
5
+ var FUNC_ERROR_TEXT = "Expected a function";
6
+ function throttle(func, wait, options) {
7
+ var leading = true, trailing = true;
8
+ if (typeof func != "function") {
9
+ throw new TypeError(FUNC_ERROR_TEXT);
10
+ }
11
+ if (isObject(options)) {
12
+ leading = "leading" in options ? !!options.leading : leading;
13
+ trailing = "trailing" in options ? !!options.trailing : trailing;
14
+ }
15
+ return debounce(func, wait, {
16
+ "leading": leading,
17
+ "maxWait": wait,
18
+ "trailing": trailing
19
+ });
20
+ }
5
21
  const DEVICE_ORIENTATION_INTERVAL = 200;
6
22
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
7
23
  const useDeviceOrientation = (props) => {
@@ -565,7 +565,6 @@ const useAmapGCJ02 = () => {
565
565
  return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
566
566
  };
567
567
  const useGmapGCJ02 = () => {
568
- const { readyPromise } = useMapSupplier();
569
568
  const toCoordinateType = (p) => {
570
569
  return inChina(p) && !inHongkong(p) && !inMacau(p) ? "gcj02" : "wgs84";
571
570
  };
@@ -583,11 +582,9 @@ const useGmapGCJ02 = () => {
583
582
  };
584
583
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
585
584
  const toGcj02 = async (point) => {
586
- await readyPromise;
587
585
  return toLocalGcj02Points([point])[0];
588
586
  };
589
587
  const toGcj02Points = async (points) => {
590
- await readyPromise;
591
588
  return toLocalGcj02Points(points);
592
589
  };
593
590
  return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
@@ -1,19 +1,17 @@
1
1
  import type { Point } from "../types/interface";
2
+ export declare const apiLocalIsPointInRing: (point: Point, path: Point[]) => boolean;
2
3
  export declare const useAmapGeometry: () => {
3
4
  apiMapDistance: (from: Point, to: Point) => number | undefined;
4
5
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
5
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
6
6
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
7
7
  };
8
8
  export declare const useGmapGeometry: () => {
9
9
  apiMapDistance: (from: Point, to: Point) => number | undefined;
10
10
  apiMapDistanceToLine: (from: Point, line: Point[]) => 0 | undefined;
11
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
12
11
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
13
12
  };
14
13
  export declare const useMapGeometry: () => {
15
14
  apiMapDistance: (from: Point, to: Point) => number | undefined;
16
15
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
17
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
18
16
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
19
17
  };
@@ -2,6 +2,7 @@ import { pointInPolygon } from "../utils/geometryPolygon.js";
2
2
  import { vec2lnglat } from "../utils/transform.js";
3
3
  import { Status } from "./useMapLoader.js";
4
4
  import { useMapSupplier } from "./useMapSupplier.js";
5
+ const apiLocalIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
5
6
  const useAmapGeometry = () => {
6
7
  const payload = useMapSupplier();
7
8
  const apiMapDistance = (from, to) => {
@@ -19,8 +20,7 @@ const useAmapGeometry = () => {
19
20
  return void 0;
20
21
  return AMap.GeometryUtil.distanceOfLine(line);
21
22
  };
22
- const apiMapIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
23
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
23
+ return { apiMapDistance, apiMapDistanceToLine, apiMapDistanceOfLine };
24
24
  };
25
25
  const useGmapGeometry = () => {
26
26
  const payload = useMapSupplier();
@@ -39,14 +39,14 @@ const useGmapGeometry = () => {
39
39
  return void 0;
40
40
  return google.maps.geometry.spherical.computeLength(line.map(vec2lnglat));
41
41
  };
42
- const apiMapIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
43
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
42
+ return { apiMapDistance, apiMapDistanceToLine, apiMapDistanceOfLine };
44
43
  };
45
44
  const useMapGeometry = () => {
46
45
  const { supplier } = useMapSupplier();
47
46
  return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
48
47
  };
49
48
  export {
49
+ apiLocalIsPointInRing,
50
50
  useAmapGeometry,
51
51
  useGmapGeometry,
52
52
  useMapGeometry
@@ -2,12 +2,11 @@ import { load as loadAmap } from "@amap/amap-jsapi-loader";
2
2
  import { type LoaderOptions } from "@googlemaps/js-api-loader";
3
3
  import { type Ref } from "vue-demi";
4
4
  import type { VNodeChild } from "../demi-polyfill";
5
- import type { Language } from "../types/interface";
5
+ import type { ConnectionStatus, Language } from "../types/interface";
6
6
  export declare const DEFAULT_AMAP_PLUGINS: AmapLoaderProps["plugins"];
7
7
  export declare const DEFAULT_GMAP_LIBRARIES: LoaderOptions["libraries"];
8
8
  export declare enum Status {
9
9
  LOADING = "LOADING",
10
- TIMEOUT = "TIMEOUT",
11
10
  FAILURE = "FAILURE",
12
11
  SUCCESS = "SUCCESS"
13
12
  }
@@ -30,6 +29,7 @@ export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loa
30
29
  }
31
30
  export declare const useAmapLoader: (props: AmapLoaderProps) => {
32
31
  statusRef: import("vue-demi").ShallowRef<Status>;
32
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
33
33
  readyPromise: Promise<undefined>;
34
34
  };
35
35
  export interface GmapLoaderProps extends LoaderOptions {
@@ -53,11 +53,13 @@ export interface GmapLoaderProps extends LoaderOptions {
53
53
  }
54
54
  export declare const useGmapLoader: (props: GmapLoaderProps) => {
55
55
  statusRef: import("vue-demi").ShallowRef<Status>;
56
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
56
57
  readyPromise: Promise<undefined>;
57
58
  };
58
59
  export type MapSupplier = "gmap" | "amap";
59
60
  export interface UseMapLoaderOutput {
60
61
  statusRef: Ref<Status>;
62
+ pingStatusRef: Ref<ConnectionStatus>;
61
63
  readyPromise: Promise<undefined>;
62
64
  }
63
65
  export interface UseMapLoaderProps {
@@ -1,8 +1,8 @@
1
- import { shallowRef, computed, ref } from "vue-demi";
1
+ import { shallowRef, computed } from "vue-demi";
2
+ import { apiPingAmap, apiPingGmap } from "../api/pingConnection.js";
2
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
- import { createRunOnce } from "../utils/helper.js";
4
+ import { createOneConcurrent, sleep, createRunOnce } from "../utils/helper.js";
4
5
  import { patchGoogleMapLoader } from "../utils/patchGoogleMapLoader.js";
5
- import { t as throttle } from "../chunks/throttle.8bdd8d3b.js";
6
6
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7
7
  var distExports = {};
8
8
  var dist = {
@@ -540,7 +540,6 @@ class Loader {
540
540
  }
541
541
  }
542
542
  const MIN_MAP_RELOAD_INTERVAL = 5e3;
543
- const GMAP_LOAD_TIMEOUT = 1e4;
544
543
  const DEFAULT_AMAP_PLUGINS = [
545
544
  "AMap.Geocoder",
546
545
  "AMap.Driving",
@@ -550,7 +549,6 @@ const DEFAULT_AMAP_PLUGINS = [
550
549
  const DEFAULT_GMAP_LIBRARIES = ["marker", "geometry"];
551
550
  var Status = /* @__PURE__ */ ((Status2) => {
552
551
  Status2["LOADING"] = "LOADING";
553
- Status2["TIMEOUT"] = "TIMEOUT";
554
552
  Status2["FAILURE"] = "FAILURE";
555
553
  Status2["SUCCESS"] = "SUCCESS";
556
554
  return Status2;
@@ -558,15 +556,14 @@ var Status = /* @__PURE__ */ ((Status2) => {
558
556
  const useAmapLoader = (props) => {
559
557
  const { disableRef, onSuccess, onFail } = props;
560
558
  let resolveLoader;
561
- let rejectLoader;
562
- const readyPromise = new Promise((resolve, reject) => {
559
+ const readyPromise = new Promise((resolve) => {
563
560
  resolveLoader = resolve;
564
- rejectLoader = reject;
565
561
  });
566
562
  const statusRef = shallowRef(
567
563
  "LOADING"
568
564
  /* LOADING */
569
565
  );
566
+ const pingStatusRef = shallowRef("connected");
570
567
  const optionsRef = computed(() => {
571
568
  const {
572
569
  onSuccess: onSuccess2,
@@ -586,102 +583,123 @@ const useAmapLoader = (props) => {
586
583
  serviceHost: props.apiServiceHost
587
584
  } : { securityJsCode: props.apiSecret };
588
585
  });
589
- const reload = throttle(
590
- (options) => {
591
- if (statusRef.value === "SUCCESS")
592
- return;
593
- statusRef.value = "LOADING";
594
- defineSecurityOnce();
595
- return distExports.load(options).then(
596
- () => {
597
- statusRef.value = "SUCCESS";
598
- resolveLoader();
599
- onSuccess == null ? void 0 : onSuccess();
600
- },
601
- () => {
602
- statusRef.value = "FAILURE";
603
- rejectLoader();
604
- onFail == null ? void 0 : onFail();
605
- }
606
- );
607
- },
608
- MIN_MAP_RELOAD_INTERVAL,
609
- { trailing: false }
610
- );
611
- watchPostEffectForDeepOption(
612
- () => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
613
- ([options, disable]) => {
614
- if (disable)
615
- return;
616
- reload(options);
586
+ const reload = createOneConcurrent((options) => {
587
+ if (statusRef.value === "SUCCESS")
588
+ return Promise.resolve();
589
+ defineSecurityOnce();
590
+ distExports.reset();
591
+ statusRef.value = "LOADING";
592
+ return distExports.load(options).then(
593
+ () => {
594
+ statusRef.value = "SUCCESS";
595
+ resolveLoader();
596
+ onSuccess == null ? void 0 : onSuccess();
597
+ },
598
+ () => {
599
+ statusRef.value = "FAILURE";
600
+ onFail == null ? void 0 : onFail();
601
+ }
602
+ );
603
+ });
604
+ const keepRetry = createOneConcurrent(async () => {
605
+ const options = optionsRef.value;
606
+ while (!(disableRef == null ? void 0 : disableRef.value) && statusRef.value !== "SUCCESS") {
607
+ if (statusRef.value === "LOADING") {
608
+ await reload(options);
609
+ continue;
610
+ }
611
+ await sleep(MIN_MAP_RELOAD_INTERVAL);
612
+ const pingStatus = await apiPingAmap();
613
+ if (pingStatus === "unconnected")
614
+ continue;
615
+ await reload(options);
617
616
  }
618
- );
619
- return { statusRef, readyPromise };
617
+ });
618
+ watchPostEffectForDeepOption(() => [optionsRef.value, disableRef == null ? void 0 : disableRef.value], keepRetry);
619
+ return { statusRef, pingStatusRef, readyPromise };
620
620
  };
621
621
  const useGmapLoader = (props) => {
622
622
  const { disableRef, onSuccess, onFail } = props;
623
623
  let resolveLoader;
624
- let rejectLoader;
625
- const readyPromise = new Promise((resolve, reject) => {
624
+ const readyPromise = new Promise((resolve) => {
626
625
  resolveLoader = resolve;
627
- rejectLoader = reject;
628
626
  });
629
627
  const statusRef = shallowRef(
630
628
  "LOADING"
631
629
  /* LOADING */
632
630
  );
631
+ const pingStatusRef = shallowRef("pending");
633
632
  const optionsRef = computed(() => {
634
633
  const { onSuccess: onSuccess2, onFail: onFail2, fallback, loading, language, ...options } = props;
635
634
  return options;
636
635
  });
637
- const timerRef = ref();
638
- const reload = throttle(
639
- (options) => {
640
- if (statusRef.value === "SUCCESS")
641
- return;
642
- const loader = new Loader(options);
643
- patchGoogleMapLoader(loader);
644
- clearTimeout(timerRef.value);
645
- timerRef.value = window.setTimeout(() => {
646
- statusRef.value = "TIMEOUT";
647
- }, GMAP_LOAD_TIMEOUT);
648
- if (loader.status !== LoaderStatus.INITIALIZED) {
649
- window.google = void 0;
650
- loader.reset();
636
+ const reload = createOneConcurrent((options, signal) => {
637
+ if (statusRef.value === "SUCCESS")
638
+ return Promise.resolve();
639
+ const loader = new Loader({ ...options, retries: 0 });
640
+ patchGoogleMapLoader(loader);
641
+ if (loader.status !== LoaderStatus.INITIALIZED) {
642
+ window.google = void 0;
643
+ loader.reset();
644
+ }
645
+ const abortPromise = new Promise((resolve) => signal == null ? void 0 : signal.addEventListener("abort", resolve));
646
+ statusRef.value = "LOADING";
647
+ const loadPromise = loader.load().then(
648
+ () => {
649
+ if (signal == null ? void 0 : signal.aborted)
650
+ return;
651
+ statusRef.value = "SUCCESS";
652
+ resolveLoader();
653
+ onSuccess == null ? void 0 : onSuccess();
654
+ },
655
+ () => {
656
+ if (signal == null ? void 0 : signal.aborted)
657
+ return;
658
+ statusRef.value = "FAILURE";
659
+ onFail == null ? void 0 : onFail();
660
+ }
661
+ );
662
+ return Promise.race([abortPromise, loadPromise]);
663
+ });
664
+ const keepRetry = createOneConcurrent(async () => {
665
+ if (statusRef.value === "SUCCESS") {
666
+ pingStatusRef.value = "pending";
667
+ while (pingStatusRef.value !== "connected") {
668
+ if (pingStatusRef.value === "unconnected")
669
+ await sleep(MIN_MAP_RELOAD_INTERVAL);
670
+ pingStatusRef.value = await apiPingGmap();
651
671
  }
652
- statusRef.value = "LOADING";
653
- return loader.load().then(
654
- () => {
655
- clearTimeout(timerRef.value);
656
- statusRef.value = "SUCCESS";
657
- resolveLoader();
658
- onSuccess == null ? void 0 : onSuccess();
659
- },
660
- () => {
661
- clearTimeout(timerRef.value);
662
- statusRef.value = "FAILURE";
663
- rejectLoader();
664
- onFail == null ? void 0 : onFail();
665
- }
666
- );
667
- },
668
- MIN_MAP_RELOAD_INTERVAL,
669
- { trailing: false }
670
- );
671
- watchPostEffectForDeepOption(
672
- () => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
673
- ([options, disable]) => {
674
- if (disable)
675
- return;
676
- const language = navigator.language;
677
- reload({ ...options, language });
678
672
  }
679
- );
680
- return { statusRef, readyPromise };
673
+ const language = navigator.language;
674
+ const options = { ...optionsRef.value, language };
675
+ while (!(disableRef == null ? void 0 : disableRef.value) && statusRef.value !== "SUCCESS") {
676
+ if (statusRef.value === "FAILURE" || pingStatusRef.value === "unconnected") {
677
+ await sleep(MIN_MAP_RELOAD_INTERVAL);
678
+ pingStatusRef.value = await apiPingGmap();
679
+ if (pingStatusRef.value === "connected")
680
+ statusRef.value = "LOADING";
681
+ continue;
682
+ }
683
+ const controller = new AbortController();
684
+ const reloadPromise = reload(options, controller.signal);
685
+ pingStatusRef.value = await apiPingGmap();
686
+ if (pingStatusRef.value === "unconnected") {
687
+ controller.abort();
688
+ continue;
689
+ }
690
+ await reloadPromise;
691
+ }
692
+ });
693
+ watchPostEffectForDeepOption(() => [optionsRef.value, disableRef == null ? void 0 : disableRef.value], keepRetry);
694
+ return { statusRef, pingStatusRef, readyPromise };
681
695
  };
682
696
  const useMapLoader = (props) => {
683
697
  const { gmapKey, amapKey, amapSecret, amapServiceHost, language, onSuccess, onFail } = props;
684
- const { statusRef: amapStatusRef, readyPromise: amapReadyPromise } = useAmapLoader({
698
+ const {
699
+ statusRef: amapStatusRef,
700
+ pingStatusRef: amapPingStatusRef,
701
+ readyPromise: amapReadyPromise
702
+ } = useAmapLoader({
685
703
  apiKey: amapKey,
686
704
  apiSecret: amapSecret,
687
705
  apiServiceHost: amapServiceHost,
@@ -690,7 +708,11 @@ const useMapLoader = (props) => {
690
708
  onSuccess,
691
709
  onFail
692
710
  });
693
- const { statusRef: gmapStatusRef, readyPromise: gmapReadyPromise } = useGmapLoader({
711
+ const {
712
+ statusRef: gmapStatusRef,
713
+ pingStatusRef: gmapPingStatusRef,
714
+ readyPromise: gmapReadyPromise
715
+ } = useGmapLoader({
694
716
  apiKey: gmapKey,
695
717
  language,
696
718
  version: "weekly",
@@ -705,6 +727,9 @@ const useMapLoader = (props) => {
705
727
  get statusRef() {
706
728
  return props.supplier === "gmap" ? gmapStatusRef : amapStatusRef;
707
729
  },
730
+ get pingStatusRef() {
731
+ return props.supplier === "gmap" ? gmapPingStatusRef : amapPingStatusRef;
732
+ },
708
733
  get readyPromise() {
709
734
  return props.supplier === "gmap" ? gmapReadyPromise : amapReadyPromise;
710
735
  }