@heycar/heycars-map 2.0.0-switchMap9 → 2.1.0-speedupAmap2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v2/App.js CHANGED
@@ -22,6 +22,10 @@ const App = defineComponent({
22
22
  "supplier": supplierRef.value,
23
23
  "renderLoadFailedTitle": () => supplierRef.value === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败",
24
24
  "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0
25
+ },
26
+ "on": {
27
+ "success": () => console.log(`${supplierRef.value} load success`),
28
+ "fail": () => console.log(`${supplierRef.value} load failed`)
25
29
  }
26
30
  }, [h(DemoBusinessQuoting)]);
27
31
  }
@@ -6,7 +6,7 @@ import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
8
  export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "renderLoadFailedTitle" | "renderLoadFailedDescription">;
9
- export declare const MapProvider: import("vue").DefineComponent<import("vue3").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail", MapProviderProps>;
9
+ export declare const MapProvider: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail", MapProviderProps>;
10
10
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
11
11
  mapRef?: SetMap<AmapMap> | SetMap<google.maps.Map>;
12
12
  outerArea?: () => VueNode;
@@ -16,4 +16,4 @@ export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "load
16
16
  onZoomEnd?: (value: number) => any;
17
17
  onResize?: () => any;
18
18
  }
19
- export declare const HeycarMap: import("vue").DefineComponent<import("vue3").ComponentObjectPropsOptions<HeycarMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", HeycarMapProps>;
19
+ export declare const HeycarMap: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<HeycarMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", HeycarMapProps>;
@@ -1,5 +1,6 @@
1
1
  import "../../css/MapProvider-156bfd53.css";
2
2
  import { h } from "vue";
3
+ import { reactive, toRefs } from "vue-demi";
3
4
  import { L as LoadFailed, a as Loading, i as imgGrid } from "../../chunks/Loading.492acbc2.js";
4
5
  import { useMapLoader, Status } from "../../hooks/useMapLoader.js";
5
6
  import { provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
@@ -19,9 +20,16 @@ if (detectWebGL() === WEBGL_STATUS.ENABLED) {
19
20
  window.forceWebGL = true;
20
21
  }
21
22
  const MapProvider = defineLagecySetup("MapProvider", function(props, {
22
- slots
23
+ slots,
24
+ emit
23
25
  }) {
24
- const payload = useMapLoader(props);
26
+ const onSuccess = () => emit("success");
27
+ const onFail = () => emit("fail");
28
+ const payload = useMapLoader(reactive({
29
+ ...toRefs(props),
30
+ onSuccess,
31
+ onFail
32
+ }));
25
33
  const context = new Proxy(props, {
26
34
  get(target, name, receiver) {
27
35
  if (name === "status")
@@ -1,5 +1,5 @@
1
- import { load as loadAmap } from "@amap/amap-jsapi-loader";
2
1
  import { type LoaderOptions } from "@googlemaps/js-api-loader";
2
+ import { load as loadAmap } from "@heycar/amap-jsapi-loader";
3
3
  import { type Ref } from "vue-demi";
4
4
  import type { VNodeChild } from "../demi-polyfill";
5
5
  import type { ConnectionStatus, Language } from "../types/interface";
@@ -3,201 +3,6 @@ import { apiPingAmap, apiPingGmap } from "../api/pingConnection.js";
3
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
4
4
  import { createOneConcurrent, sleep, createRunOnce } from "../utils/helper.js";
5
5
  import { patchGoogleMapLoader } from "../utils/patchGoogleMapLoader.js";
6
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7
- var distExports = {};
8
- var dist = {
9
- get exports() {
10
- return distExports;
11
- },
12
- set exports(v) {
13
- distExports = v;
14
- }
15
- };
16
- (function(module, exports) {
17
- (function(m, p) {
18
- module.exports = p();
19
- })(commonjsGlobal, function() {
20
- function m(a) {
21
- var b2 = [];
22
- a.AMapUI && b2.push(p(a.AMapUI));
23
- a.Loca && b2.push(r(a.Loca));
24
- return Promise.all(b2);
25
- }
26
- function p(a) {
27
- return new Promise(function(h, c) {
28
- var f = [];
29
- if (a.plugins)
30
- for (var e = 0; e < a.plugins.length; e += 1)
31
- -1 == d.AMapUI.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
32
- if (g.AMapUI === b.failed)
33
- c("前次请求 AMapUI 失败");
34
- else if (g.AMapUI === b.notload) {
35
- g.AMapUI = b.loading;
36
- d.AMapUI.version = a.version || d.AMapUI.version;
37
- e = d.AMapUI.version;
38
- var l = document.body || document.head, k = document.createElement("script");
39
- k.type = "text/javascript";
40
- k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
41
- k.onerror = function(a2) {
42
- g.AMapUI = b.failed;
43
- c("请求 AMapUI 失败");
44
- };
45
- k.onload = function() {
46
- g.AMapUI = b.loaded;
47
- if (f.length)
48
- window.AMapUI.loadUI(f, function() {
49
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
50
- var c2 = f[a2].split("/").slice(-1)[0];
51
- window.AMapUI[c2] = arguments[a2];
52
- }
53
- for (h(); n.AMapUI.length; )
54
- n.AMapUI.splice(0, 1)[0]();
55
- });
56
- else
57
- for (h(); n.AMapUI.length; )
58
- n.AMapUI.splice(0, 1)[0]();
59
- };
60
- l.appendChild(k);
61
- } else
62
- g.AMapUI === b.loaded ? a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
63
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
64
- var c2 = f[a2].split("/").slice(-1)[0];
65
- window.AMapUI[c2] = arguments[a2];
66
- }
67
- h();
68
- }) : h() : a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a2) {
69
- a2 ? c(a2) : f.length ? window.AMapUI.loadUI(f, function() {
70
- for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
71
- var c2 = f[a3].split("/").slice(-1)[0];
72
- window.AMapUI[c2] = arguments[a3];
73
- }
74
- h();
75
- }) : h();
76
- });
77
- });
78
- }
79
- function r(a) {
80
- return new Promise(function(h, c) {
81
- if (g.Loca === b.failed)
82
- c("前次请求 Loca 失败");
83
- else if (g.Loca === b.notload) {
84
- g.Loca = b.loading;
85
- d.Loca.version = a.version || d.Loca.version;
86
- var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
87
- if (e && !l || !e && l)
88
- c("JSAPI 与 Loca 版本不对应!!");
89
- else {
90
- e = d.key;
91
- l = document.body || document.head;
92
- var k = document.createElement("script");
93
- k.type = "text/javascript";
94
- k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
95
- k.onerror = function(a2) {
96
- g.Loca = b.failed;
97
- c("请求 AMapUI 失败");
98
- };
99
- k.onload = function() {
100
- g.Loca = b.loaded;
101
- for (h(); n.Loca.length; )
102
- n.Loca.splice(0, 1)[0]();
103
- };
104
- l.appendChild(k);
105
- }
106
- } else
107
- g.Loca === b.loaded ? a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h() : a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a2) {
108
- a2 ? c(a2) : c();
109
- });
110
- });
111
- }
112
- if (!window)
113
- throw Error("AMap JSAPI can only be used in Browser.");
114
- var b;
115
- (function(a) {
116
- a.notload = "notload";
117
- a.loading = "loading";
118
- a.loaded = "loaded";
119
- a.failed = "failed";
120
- })(b || (b = {}));
121
- var d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(a) {
122
- "function" == typeof a && (g.AMap === b.loaded ? a(window.AMap) : q.push(a));
123
- };
124
- return { load: function(a) {
125
- return new Promise(function(h, c) {
126
- if (g.AMap == b.failed)
127
- c("");
128
- else if (g.AMap == b.notload) {
129
- var f = a.key, e = a.version, l = a.plugins;
130
- f ? (window.AMap && "lbs.amap.com" !== location.host && c("禁止多种API加载方式混用"), d.key = f, d.AMap.version = e || d.AMap.version, d.AMap.plugins = l || d.AMap.plugins, g.AMap = b.loading, e = document.body || document.head, window.___onAPILoaded = function(d2) {
131
- delete window.___onAPILoaded;
132
- if (d2)
133
- g.AMap = b.failed, c(d2);
134
- else
135
- for (g.AMap = b.loaded, m(a).then(function() {
136
- h(window.AMap);
137
- })["catch"](c); q.length; )
138
- q.splice(0, 1)[0]();
139
- }, l = document.createElement("script"), l.type = "text/javascript", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(a2) {
140
- g.AMap = b.failed;
141
- c(a2);
142
- }, e.appendChild(l)) : c("请填写key");
143
- } else if (g.AMap == b.loaded)
144
- if (a.key && a.key !== d.key)
145
- c("多个不一致的 key");
146
- else if (a.version && a.version !== d.AMap.version)
147
- c("不允许多个版本 JSAPI 混用");
148
- else {
149
- f = [];
150
- if (a.plugins)
151
- for (e = 0; e < a.plugins.length; e += 1)
152
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
153
- if (f.length)
154
- window.AMap.plugin(f, function() {
155
- m(a).then(function() {
156
- h(window.AMap);
157
- })["catch"](c);
158
- });
159
- else
160
- m(a).then(function() {
161
- h(window.AMap);
162
- })["catch"](c);
163
- }
164
- else if (a.key && a.key !== d.key)
165
- c("多个不一致的 key");
166
- else if (a.version && a.version !== d.AMap.version)
167
- c("不允许多个版本 JSAPI 混用");
168
- else {
169
- var k = [];
170
- if (a.plugins)
171
- for (e = 0; e < a.plugins.length; e += 1)
172
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && k.push(a.plugins[e]);
173
- t(function() {
174
- if (k.length)
175
- window.AMap.plugin(k, function() {
176
- m(a).then(function() {
177
- h(window.AMap);
178
- })["catch"](c);
179
- });
180
- else
181
- m(a).then(function() {
182
- h(window.AMap);
183
- })["catch"](c);
184
- });
185
- }
186
- });
187
- }, reset: function() {
188
- delete window.AMap;
189
- delete window.AMapUI;
190
- delete window.Loca;
191
- d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } };
192
- g = {
193
- AMap: b.notload,
194
- AMapUI: b.notload,
195
- Loca: b.notload
196
- };
197
- n = { AMap: [], AMapUI: [], Loca: [] };
198
- } };
199
- });
200
- })(dist);
201
6
  function __awaiter(thisArg, _arguments, P, generator) {
202
7
  function adopt(value) {
203
8
  return value instanceof P ? value : new P(function(resolve) {
@@ -539,6 +344,208 @@ class Loader {
539
344
  }
540
345
  }
541
346
  }
347
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
348
+ var distExports = {};
349
+ var dist = {
350
+ get exports() {
351
+ return distExports;
352
+ },
353
+ set exports(v) {
354
+ distExports = v;
355
+ }
356
+ };
357
+ (function(module, exports) {
358
+ (function(m, p) {
359
+ module.exports = p();
360
+ })(commonjsGlobal, function() {
361
+ function m(a) {
362
+ var b2 = [];
363
+ a.AMapUI && b2.push(p(a.AMapUI));
364
+ a.Loca && b2.push(r(a.Loca));
365
+ return Promise.all(b2);
366
+ }
367
+ function p(a) {
368
+ return new Promise(function(h, c) {
369
+ var f = [];
370
+ if (a.plugins)
371
+ for (var e = 0; e < a.plugins.length; e += 1)
372
+ -1 == d.AMapUI.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
373
+ if (g.AMapUI === b.failed)
374
+ c("前次请求 AMapUI 失败");
375
+ else if (g.AMapUI === b.notload) {
376
+ g.AMapUI = b.loading;
377
+ d.AMapUI.version = a.version || d.AMapUI.version;
378
+ e = d.AMapUI.version;
379
+ var l = document.body || document.head, k = document.createElement("script");
380
+ k.type = "text/javascript";
381
+ k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
382
+ k.onerror = function(a2) {
383
+ g.AMapUI = b.failed;
384
+ c("请求 AMapUI 失败");
385
+ };
386
+ k.onload = function() {
387
+ g.AMapUI = b.loaded;
388
+ if (f.length)
389
+ window.AMapUI.loadUI(f, function() {
390
+ for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
391
+ var c2 = f[a2].split("/").slice(-1)[0];
392
+ window.AMapUI[c2] = arguments[a2];
393
+ }
394
+ for (h(); n.AMapUI.length; )
395
+ n.AMapUI.splice(0, 1)[0]();
396
+ });
397
+ else
398
+ for (h(); n.AMapUI.length; )
399
+ n.AMapUI.splice(0, 1)[0]();
400
+ };
401
+ l.appendChild(k);
402
+ } else
403
+ g.AMapUI === b.loaded ? a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
404
+ for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
405
+ var c2 = f[a2].split("/").slice(-1)[0];
406
+ window.AMapUI[c2] = arguments[a2];
407
+ }
408
+ h();
409
+ }) : h() : a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a2) {
410
+ a2 ? c(a2) : f.length ? window.AMapUI.loadUI(f, function() {
411
+ for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
412
+ var c2 = f[a3].split("/").slice(-1)[0];
413
+ window.AMapUI[c2] = arguments[a3];
414
+ }
415
+ h();
416
+ }) : h();
417
+ });
418
+ });
419
+ }
420
+ function r(a) {
421
+ return new Promise(function(h, c) {
422
+ if (g.Loca === b.failed)
423
+ c("前次请求 Loca 失败");
424
+ else if (g.Loca === b.notload) {
425
+ g.Loca = b.loading;
426
+ d.Loca.version = a.version || d.Loca.version;
427
+ var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
428
+ if (e && !l || !e && l)
429
+ c("JSAPI 与 Loca 版本不对应!!");
430
+ else {
431
+ e = d.key;
432
+ l = document.body || document.head;
433
+ var k = document.createElement("script");
434
+ k.type = "text/javascript";
435
+ k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
436
+ k.onerror = function(a2) {
437
+ g.Loca = b.failed;
438
+ c("请求 AMapUI 失败");
439
+ };
440
+ k.onload = function() {
441
+ g.Loca = b.loaded;
442
+ for (h(); n.Loca.length; )
443
+ n.Loca.splice(0, 1)[0]();
444
+ };
445
+ l.appendChild(k);
446
+ }
447
+ } else
448
+ g.Loca === b.loaded ? a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h() : a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a2) {
449
+ a2 ? c(a2) : c();
450
+ });
451
+ });
452
+ }
453
+ var b;
454
+ (function(a) {
455
+ a.notload = "notload";
456
+ a.loading = "loading";
457
+ a.loaded = "loaded";
458
+ a.failed = "failed";
459
+ })(b || (b = {}));
460
+ var d = {
461
+ key: "",
462
+ AMap: { version: "1.4.15", plugins: [] },
463
+ AMapUI: { version: "1.1", plugins: [] },
464
+ Loca: { version: "1.3.2" }
465
+ }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(a) {
466
+ "function" == typeof a && (g.AMap === b.loaded ? a(window.AMap) : q.push(a));
467
+ };
468
+ return {
469
+ load: function(a) {
470
+ return new Promise(function(h, c) {
471
+ if (g.AMap == b.failed)
472
+ c("");
473
+ else if (g.AMap == b.notload) {
474
+ var f = a.key, e = a.version, l = a.plugins;
475
+ f ? (window.AMap && "lbs.amap.com" !== location.host && c("禁止多种API加载方式混用"), d.key = f, d.AMap.version = e || d.AMap.version, d.AMap.plugins = l || d.AMap.plugins, g.AMap = b.loading, e = document.body || document.head, window.___onAPILoaded = function(d2) {
476
+ delete window.___onAPILoaded;
477
+ if (d2)
478
+ g.AMap = b.failed, c(d2);
479
+ else
480
+ for (g.AMap = b.loaded, m(a).then(function() {
481
+ h(window.AMap);
482
+ })["catch"](c); q.length; )
483
+ q.splice(0, 1)[0]();
484
+ }, l = document.createElement("script"), l.type = "text/javascript", l.async = true, l.fetchPriority = "high", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(a2) {
485
+ g.AMap = b.failed;
486
+ c(a2);
487
+ }, e.appendChild(l)) : c("请填写key");
488
+ } else if (g.AMap == b.loaded)
489
+ if (a.key && a.key !== d.key)
490
+ c("多个不一致的 key");
491
+ else if (a.version && a.version !== d.AMap.version)
492
+ c("不允许多个版本 JSAPI 混用");
493
+ else {
494
+ f = [];
495
+ if (a.plugins)
496
+ for (e = 0; e < a.plugins.length; e += 1)
497
+ -1 == d.AMap.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
498
+ if (f.length)
499
+ window.AMap.plugin(f, function() {
500
+ m(a).then(function() {
501
+ h(window.AMap);
502
+ })["catch"](c);
503
+ });
504
+ else
505
+ m(a).then(function() {
506
+ h(window.AMap);
507
+ })["catch"](c);
508
+ }
509
+ else if (a.key && a.key !== d.key)
510
+ c("多个不一致的 key");
511
+ else if (a.version && a.version !== d.AMap.version)
512
+ c("不允许多个版本 JSAPI 混用");
513
+ else {
514
+ var k = [];
515
+ if (a.plugins)
516
+ for (e = 0; e < a.plugins.length; e += 1)
517
+ -1 == d.AMap.plugins.indexOf(a.plugins[e]) && k.push(a.plugins[e]);
518
+ t(function() {
519
+ if (k.length)
520
+ window.AMap.plugin(k, function() {
521
+ m(a).then(function() {
522
+ h(window.AMap);
523
+ })["catch"](c);
524
+ });
525
+ else
526
+ m(a).then(function() {
527
+ h(window.AMap);
528
+ })["catch"](c);
529
+ });
530
+ }
531
+ });
532
+ },
533
+ reset: function() {
534
+ delete window.AMap;
535
+ delete window.AMapUI;
536
+ delete window.Loca;
537
+ d = {
538
+ key: "",
539
+ AMap: { version: "1.4.15", plugins: [] },
540
+ AMapUI: { version: "1.1", plugins: [] },
541
+ Loca: { version: "1.3.2" }
542
+ };
543
+ g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload };
544
+ n = { AMap: [], AMapUI: [], Loca: [] };
545
+ }
546
+ };
547
+ });
548
+ })(dist);
542
549
  const MIN_MAP_RELOAD_INTERVAL = 5e3;
543
550
  const DEFAULT_AMAP_PLUGINS = [
544
551
  "AMap.Geocoder",
@@ -546,6 +553,7 @@ const DEFAULT_AMAP_PLUGINS = [
546
553
  "AMap.Walking",
547
554
  "AMap.GraspRoad"
548
555
  ];
556
+ const AMAP_PRELOAD_STYLE_URL = "https://vdata.amap.com/style/2.0.1";
549
557
  const DEFAULT_GMAP_LIBRARIES = ["marker", "geometry"];
550
558
  var Status = /* @__PURE__ */ ((Status2) => {
551
559
  Status2["LOADING"] = "LOADING";
@@ -553,6 +561,15 @@ var Status = /* @__PURE__ */ ((Status2) => {
553
561
  Status2["SUCCESS"] = "SUCCESS";
554
562
  return Status2;
555
563
  })(Status || {});
564
+ const preloadAmapStyleOnce = createRunOnce(() => {
565
+ const link = document.createElement("link");
566
+ link.rel = "preload";
567
+ link.as = "fetch";
568
+ link.href = AMAP_PRELOAD_STYLE_URL;
569
+ link.crossOrigin = "anonymous";
570
+ document.head.appendChild(link);
571
+ return link;
572
+ });
556
573
  const useAmapLoader = (props) => {
557
574
  const { disableRef, onSuccess, onFail } = props;
558
575
  let resolveLoader;
@@ -589,6 +606,7 @@ const useAmapLoader = (props) => {
589
606
  defineSecurityOnce();
590
607
  distExports.reset();
591
608
  statusRef.value = "LOADING";
609
+ setTimeout(preloadAmapStyleOnce);
592
610
  return distExports.load(options).then(
593
611
  () => {
594
612
  statusRef.value = "SUCCESS";
@@ -20,6 +20,6 @@ declare global {
20
20
  deviceorientationabsolute: DeviceOrientationEvent;
21
21
  }
22
22
  }
23
- declare module "@amap/amap-jsapi-loader" {
23
+ declare module "@heycar/amap-jsapi-loader" {
24
24
  const reset: () => void;
25
25
  }
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.0.0-switchMap9";
3
+ const pkgVersion = "2.1.0-speedupAmap2";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
package/dist/v3/App.js CHANGED
@@ -20,7 +20,9 @@ const App = /* @__PURE__ */ defineComponent({
20
20
  "language": "en",
21
21
  "supplier": supplierRef.value,
22
22
  "renderLoadFailedTitle": () => supplierRef.value === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败",
23
- "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0
23
+ "renderLoadFailedDescription": () => supplierRef.value === "gmap" ? "请确认您的网络能正常访问谷歌地图, \n或切回高德地图" : void 0,
24
+ "onSuccess": () => console.log(`${supplierRef.value} load success`),
25
+ "onFail": () => console.log(`${supplierRef.value} load failed`)
24
26
  }, {
25
27
  default: () => [createVNode(DemoBusinessQuoting, null, null)]
26
28
  });
@@ -6,7 +6,7 @@ import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
8
  export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "renderLoadFailedTitle" | "renderLoadFailedDescription">;
9
- export declare const MapProvider: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail", import("vue").PublicProps, MapProviderProps, MapProviderProps, import("vue").SlotsType<{
9
+ export declare const MapProvider: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail", import("vue-demi").PublicProps, MapProviderProps, MapProviderProps, import("vue-demi").SlotsType<{
10
10
  renderLoadFailedTitle?: ((status: Status) => string | undefined) | undefined;
11
11
  renderLoadFailedDescription?: ((status: Status) => string | undefined) | undefined;
12
12
  } & {
@@ -21,11 +21,11 @@ export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "load
21
21
  onZoomEnd?: (value: number) => any;
22
22
  onResize?: () => any;
23
23
  }
24
- export declare const HeycarMap: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<HeycarMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", import("vue").PublicProps, HeycarMapProps, HeycarMapProps, import("vue").SlotsType<{
24
+ export declare const HeycarMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<HeycarMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", import("vue-demi").PublicProps, HeycarMapProps, HeycarMapProps, import("vue-demi").SlotsType<{
25
25
  mapRef?: SetMap<import("../Amap/SafeAmap").SafeAmap> | SetMap<google.maps.Map> | undefined;
26
26
  outerArea?: (() => VueNode) | undefined;
27
- fallback?: (() => import("vue").VNodeChild) | undefined;
28
- loading?: (() => import("vue").VNodeChild) | undefined;
27
+ fallback?: (() => import("vue-demi").VNodeChild) | undefined;
28
+ loading?: (() => import("vue-demi").VNodeChild) | undefined;
29
29
  } & {
30
30
  default?: import("../../demi-polyfill").Slot | undefined;
31
31
  }>>;
@@ -1,5 +1,6 @@
1
1
  import "../../css/MapProvider-156bfd53.css";
2
2
  import { createVNode, isVNode } from "vue";
3
+ import { reactive, toRefs } from "vue-demi";
3
4
  import { L as LoadFailed, a as Loading, i as imgGrid } from "../../chunks/Loading.21d8e759.js";
4
5
  import { useMapLoader, Status } from "../../hooks/useMapLoader.js";
5
6
  import { provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
@@ -22,9 +23,16 @@ if (detectWebGL() === WEBGL_STATUS.ENABLED) {
22
23
  window.forceWebGL = true;
23
24
  }
24
25
  const MapProvider = defineLagecySetup("MapProvider", function(props, {
25
- slots
26
+ slots,
27
+ emit
26
28
  }) {
27
- const payload = useMapLoader(props);
29
+ const onSuccess = () => emit("success");
30
+ const onFail = () => emit("fail");
31
+ const payload = useMapLoader(reactive({
32
+ ...toRefs(props),
33
+ onSuccess,
34
+ onFail
35
+ }));
28
36
  const context = new Proxy(props, {
29
37
  get(target, name, receiver) {
30
38
  if (name === "status")
@@ -1,5 +1,5 @@
1
- import { load as loadAmap } from "@amap/amap-jsapi-loader";
2
1
  import { type LoaderOptions } from "@googlemaps/js-api-loader";
2
+ import { load as loadAmap } from "@heycar/amap-jsapi-loader";
3
3
  import { type Ref } from "vue-demi";
4
4
  import type { VNodeChild } from "../demi-polyfill";
5
5
  import type { ConnectionStatus, Language } from "../types/interface";
@@ -3,201 +3,6 @@ import { apiPingAmap, apiPingGmap } from "../api/pingConnection.js";
3
3
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
4
4
  import { createOneConcurrent, sleep, createRunOnce } from "../utils/helper.js";
5
5
  import { patchGoogleMapLoader } from "../utils/patchGoogleMapLoader.js";
6
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7
- var distExports = {};
8
- var dist = {
9
- get exports() {
10
- return distExports;
11
- },
12
- set exports(v) {
13
- distExports = v;
14
- }
15
- };
16
- (function(module, exports) {
17
- (function(m, p) {
18
- module.exports = p();
19
- })(commonjsGlobal, function() {
20
- function m(a) {
21
- var b2 = [];
22
- a.AMapUI && b2.push(p(a.AMapUI));
23
- a.Loca && b2.push(r(a.Loca));
24
- return Promise.all(b2);
25
- }
26
- function p(a) {
27
- return new Promise(function(h, c) {
28
- var f = [];
29
- if (a.plugins)
30
- for (var e = 0; e < a.plugins.length; e += 1)
31
- -1 == d.AMapUI.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
32
- if (g.AMapUI === b.failed)
33
- c("前次请求 AMapUI 失败");
34
- else if (g.AMapUI === b.notload) {
35
- g.AMapUI = b.loading;
36
- d.AMapUI.version = a.version || d.AMapUI.version;
37
- e = d.AMapUI.version;
38
- var l = document.body || document.head, k = document.createElement("script");
39
- k.type = "text/javascript";
40
- k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
41
- k.onerror = function(a2) {
42
- g.AMapUI = b.failed;
43
- c("请求 AMapUI 失败");
44
- };
45
- k.onload = function() {
46
- g.AMapUI = b.loaded;
47
- if (f.length)
48
- window.AMapUI.loadUI(f, function() {
49
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
50
- var c2 = f[a2].split("/").slice(-1)[0];
51
- window.AMapUI[c2] = arguments[a2];
52
- }
53
- for (h(); n.AMapUI.length; )
54
- n.AMapUI.splice(0, 1)[0]();
55
- });
56
- else
57
- for (h(); n.AMapUI.length; )
58
- n.AMapUI.splice(0, 1)[0]();
59
- };
60
- l.appendChild(k);
61
- } else
62
- g.AMapUI === b.loaded ? a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
63
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
64
- var c2 = f[a2].split("/").slice(-1)[0];
65
- window.AMapUI[c2] = arguments[a2];
66
- }
67
- h();
68
- }) : h() : a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a2) {
69
- a2 ? c(a2) : f.length ? window.AMapUI.loadUI(f, function() {
70
- for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
71
- var c2 = f[a3].split("/").slice(-1)[0];
72
- window.AMapUI[c2] = arguments[a3];
73
- }
74
- h();
75
- }) : h();
76
- });
77
- });
78
- }
79
- function r(a) {
80
- return new Promise(function(h, c) {
81
- if (g.Loca === b.failed)
82
- c("前次请求 Loca 失败");
83
- else if (g.Loca === b.notload) {
84
- g.Loca = b.loading;
85
- d.Loca.version = a.version || d.Loca.version;
86
- var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
87
- if (e && !l || !e && l)
88
- c("JSAPI 与 Loca 版本不对应!!");
89
- else {
90
- e = d.key;
91
- l = document.body || document.head;
92
- var k = document.createElement("script");
93
- k.type = "text/javascript";
94
- k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
95
- k.onerror = function(a2) {
96
- g.Loca = b.failed;
97
- c("请求 AMapUI 失败");
98
- };
99
- k.onload = function() {
100
- g.Loca = b.loaded;
101
- for (h(); n.Loca.length; )
102
- n.Loca.splice(0, 1)[0]();
103
- };
104
- l.appendChild(k);
105
- }
106
- } else
107
- g.Loca === b.loaded ? a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h() : a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a2) {
108
- a2 ? c(a2) : c();
109
- });
110
- });
111
- }
112
- if (!window)
113
- throw Error("AMap JSAPI can only be used in Browser.");
114
- var b;
115
- (function(a) {
116
- a.notload = "notload";
117
- a.loading = "loading";
118
- a.loaded = "loaded";
119
- a.failed = "failed";
120
- })(b || (b = {}));
121
- var d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(a) {
122
- "function" == typeof a && (g.AMap === b.loaded ? a(window.AMap) : q.push(a));
123
- };
124
- return { load: function(a) {
125
- return new Promise(function(h, c) {
126
- if (g.AMap == b.failed)
127
- c("");
128
- else if (g.AMap == b.notload) {
129
- var f = a.key, e = a.version, l = a.plugins;
130
- f ? (window.AMap && "lbs.amap.com" !== location.host && c("禁止多种API加载方式混用"), d.key = f, d.AMap.version = e || d.AMap.version, d.AMap.plugins = l || d.AMap.plugins, g.AMap = b.loading, e = document.body || document.head, window.___onAPILoaded = function(d2) {
131
- delete window.___onAPILoaded;
132
- if (d2)
133
- g.AMap = b.failed, c(d2);
134
- else
135
- for (g.AMap = b.loaded, m(a).then(function() {
136
- h(window.AMap);
137
- })["catch"](c); q.length; )
138
- q.splice(0, 1)[0]();
139
- }, l = document.createElement("script"), l.type = "text/javascript", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(a2) {
140
- g.AMap = b.failed;
141
- c(a2);
142
- }, e.appendChild(l)) : c("请填写key");
143
- } else if (g.AMap == b.loaded)
144
- if (a.key && a.key !== d.key)
145
- c("多个不一致的 key");
146
- else if (a.version && a.version !== d.AMap.version)
147
- c("不允许多个版本 JSAPI 混用");
148
- else {
149
- f = [];
150
- if (a.plugins)
151
- for (e = 0; e < a.plugins.length; e += 1)
152
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
153
- if (f.length)
154
- window.AMap.plugin(f, function() {
155
- m(a).then(function() {
156
- h(window.AMap);
157
- })["catch"](c);
158
- });
159
- else
160
- m(a).then(function() {
161
- h(window.AMap);
162
- })["catch"](c);
163
- }
164
- else if (a.key && a.key !== d.key)
165
- c("多个不一致的 key");
166
- else if (a.version && a.version !== d.AMap.version)
167
- c("不允许多个版本 JSAPI 混用");
168
- else {
169
- var k = [];
170
- if (a.plugins)
171
- for (e = 0; e < a.plugins.length; e += 1)
172
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && k.push(a.plugins[e]);
173
- t(function() {
174
- if (k.length)
175
- window.AMap.plugin(k, function() {
176
- m(a).then(function() {
177
- h(window.AMap);
178
- })["catch"](c);
179
- });
180
- else
181
- m(a).then(function() {
182
- h(window.AMap);
183
- })["catch"](c);
184
- });
185
- }
186
- });
187
- }, reset: function() {
188
- delete window.AMap;
189
- delete window.AMapUI;
190
- delete window.Loca;
191
- d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } };
192
- g = {
193
- AMap: b.notload,
194
- AMapUI: b.notload,
195
- Loca: b.notload
196
- };
197
- n = { AMap: [], AMapUI: [], Loca: [] };
198
- } };
199
- });
200
- })(dist);
201
6
  function __awaiter(thisArg, _arguments, P, generator) {
202
7
  function adopt(value) {
203
8
  return value instanceof P ? value : new P(function(resolve) {
@@ -539,6 +344,208 @@ class Loader {
539
344
  }
540
345
  }
541
346
  }
347
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
348
+ var distExports = {};
349
+ var dist = {
350
+ get exports() {
351
+ return distExports;
352
+ },
353
+ set exports(v) {
354
+ distExports = v;
355
+ }
356
+ };
357
+ (function(module, exports) {
358
+ (function(m, p) {
359
+ module.exports = p();
360
+ })(commonjsGlobal, function() {
361
+ function m(a) {
362
+ var b2 = [];
363
+ a.AMapUI && b2.push(p(a.AMapUI));
364
+ a.Loca && b2.push(r(a.Loca));
365
+ return Promise.all(b2);
366
+ }
367
+ function p(a) {
368
+ return new Promise(function(h, c) {
369
+ var f = [];
370
+ if (a.plugins)
371
+ for (var e = 0; e < a.plugins.length; e += 1)
372
+ -1 == d.AMapUI.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
373
+ if (g.AMapUI === b.failed)
374
+ c("前次请求 AMapUI 失败");
375
+ else if (g.AMapUI === b.notload) {
376
+ g.AMapUI = b.loading;
377
+ d.AMapUI.version = a.version || d.AMapUI.version;
378
+ e = d.AMapUI.version;
379
+ var l = document.body || document.head, k = document.createElement("script");
380
+ k.type = "text/javascript";
381
+ k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
382
+ k.onerror = function(a2) {
383
+ g.AMapUI = b.failed;
384
+ c("请求 AMapUI 失败");
385
+ };
386
+ k.onload = function() {
387
+ g.AMapUI = b.loaded;
388
+ if (f.length)
389
+ window.AMapUI.loadUI(f, function() {
390
+ for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
391
+ var c2 = f[a2].split("/").slice(-1)[0];
392
+ window.AMapUI[c2] = arguments[a2];
393
+ }
394
+ for (h(); n.AMapUI.length; )
395
+ n.AMapUI.splice(0, 1)[0]();
396
+ });
397
+ else
398
+ for (h(); n.AMapUI.length; )
399
+ n.AMapUI.splice(0, 1)[0]();
400
+ };
401
+ l.appendChild(k);
402
+ } else
403
+ g.AMapUI === b.loaded ? a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
404
+ for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
405
+ var c2 = f[a2].split("/").slice(-1)[0];
406
+ window.AMapUI[c2] = arguments[a2];
407
+ }
408
+ h();
409
+ }) : h() : a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a2) {
410
+ a2 ? c(a2) : f.length ? window.AMapUI.loadUI(f, function() {
411
+ for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
412
+ var c2 = f[a3].split("/").slice(-1)[0];
413
+ window.AMapUI[c2] = arguments[a3];
414
+ }
415
+ h();
416
+ }) : h();
417
+ });
418
+ });
419
+ }
420
+ function r(a) {
421
+ return new Promise(function(h, c) {
422
+ if (g.Loca === b.failed)
423
+ c("前次请求 Loca 失败");
424
+ else if (g.Loca === b.notload) {
425
+ g.Loca = b.loading;
426
+ d.Loca.version = a.version || d.Loca.version;
427
+ var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
428
+ if (e && !l || !e && l)
429
+ c("JSAPI 与 Loca 版本不对应!!");
430
+ else {
431
+ e = d.key;
432
+ l = document.body || document.head;
433
+ var k = document.createElement("script");
434
+ k.type = "text/javascript";
435
+ k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
436
+ k.onerror = function(a2) {
437
+ g.Loca = b.failed;
438
+ c("请求 AMapUI 失败");
439
+ };
440
+ k.onload = function() {
441
+ g.Loca = b.loaded;
442
+ for (h(); n.Loca.length; )
443
+ n.Loca.splice(0, 1)[0]();
444
+ };
445
+ l.appendChild(k);
446
+ }
447
+ } else
448
+ g.Loca === b.loaded ? a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h() : a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a2) {
449
+ a2 ? c(a2) : c();
450
+ });
451
+ });
452
+ }
453
+ var b;
454
+ (function(a) {
455
+ a.notload = "notload";
456
+ a.loading = "loading";
457
+ a.loaded = "loaded";
458
+ a.failed = "failed";
459
+ })(b || (b = {}));
460
+ var d = {
461
+ key: "",
462
+ AMap: { version: "1.4.15", plugins: [] },
463
+ AMapUI: { version: "1.1", plugins: [] },
464
+ Loca: { version: "1.3.2" }
465
+ }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(a) {
466
+ "function" == typeof a && (g.AMap === b.loaded ? a(window.AMap) : q.push(a));
467
+ };
468
+ return {
469
+ load: function(a) {
470
+ return new Promise(function(h, c) {
471
+ if (g.AMap == b.failed)
472
+ c("");
473
+ else if (g.AMap == b.notload) {
474
+ var f = a.key, e = a.version, l = a.plugins;
475
+ f ? (window.AMap && "lbs.amap.com" !== location.host && c("禁止多种API加载方式混用"), d.key = f, d.AMap.version = e || d.AMap.version, d.AMap.plugins = l || d.AMap.plugins, g.AMap = b.loading, e = document.body || document.head, window.___onAPILoaded = function(d2) {
476
+ delete window.___onAPILoaded;
477
+ if (d2)
478
+ g.AMap = b.failed, c(d2);
479
+ else
480
+ for (g.AMap = b.loaded, m(a).then(function() {
481
+ h(window.AMap);
482
+ })["catch"](c); q.length; )
483
+ q.splice(0, 1)[0]();
484
+ }, l = document.createElement("script"), l.type = "text/javascript", l.async = true, l.fetchPriority = "high", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(a2) {
485
+ g.AMap = b.failed;
486
+ c(a2);
487
+ }, e.appendChild(l)) : c("请填写key");
488
+ } else if (g.AMap == b.loaded)
489
+ if (a.key && a.key !== d.key)
490
+ c("多个不一致的 key");
491
+ else if (a.version && a.version !== d.AMap.version)
492
+ c("不允许多个版本 JSAPI 混用");
493
+ else {
494
+ f = [];
495
+ if (a.plugins)
496
+ for (e = 0; e < a.plugins.length; e += 1)
497
+ -1 == d.AMap.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
498
+ if (f.length)
499
+ window.AMap.plugin(f, function() {
500
+ m(a).then(function() {
501
+ h(window.AMap);
502
+ })["catch"](c);
503
+ });
504
+ else
505
+ m(a).then(function() {
506
+ h(window.AMap);
507
+ })["catch"](c);
508
+ }
509
+ else if (a.key && a.key !== d.key)
510
+ c("多个不一致的 key");
511
+ else if (a.version && a.version !== d.AMap.version)
512
+ c("不允许多个版本 JSAPI 混用");
513
+ else {
514
+ var k = [];
515
+ if (a.plugins)
516
+ for (e = 0; e < a.plugins.length; e += 1)
517
+ -1 == d.AMap.plugins.indexOf(a.plugins[e]) && k.push(a.plugins[e]);
518
+ t(function() {
519
+ if (k.length)
520
+ window.AMap.plugin(k, function() {
521
+ m(a).then(function() {
522
+ h(window.AMap);
523
+ })["catch"](c);
524
+ });
525
+ else
526
+ m(a).then(function() {
527
+ h(window.AMap);
528
+ })["catch"](c);
529
+ });
530
+ }
531
+ });
532
+ },
533
+ reset: function() {
534
+ delete window.AMap;
535
+ delete window.AMapUI;
536
+ delete window.Loca;
537
+ d = {
538
+ key: "",
539
+ AMap: { version: "1.4.15", plugins: [] },
540
+ AMapUI: { version: "1.1", plugins: [] },
541
+ Loca: { version: "1.3.2" }
542
+ };
543
+ g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload };
544
+ n = { AMap: [], AMapUI: [], Loca: [] };
545
+ }
546
+ };
547
+ });
548
+ })(dist);
542
549
  const MIN_MAP_RELOAD_INTERVAL = 5e3;
543
550
  const DEFAULT_AMAP_PLUGINS = [
544
551
  "AMap.Geocoder",
@@ -546,6 +553,7 @@ const DEFAULT_AMAP_PLUGINS = [
546
553
  "AMap.Walking",
547
554
  "AMap.GraspRoad"
548
555
  ];
556
+ const AMAP_PRELOAD_STYLE_URL = "https://vdata.amap.com/style/2.0.1";
549
557
  const DEFAULT_GMAP_LIBRARIES = ["marker", "geometry"];
550
558
  var Status = /* @__PURE__ */ ((Status2) => {
551
559
  Status2["LOADING"] = "LOADING";
@@ -553,6 +561,15 @@ var Status = /* @__PURE__ */ ((Status2) => {
553
561
  Status2["SUCCESS"] = "SUCCESS";
554
562
  return Status2;
555
563
  })(Status || {});
564
+ const preloadAmapStyleOnce = createRunOnce(() => {
565
+ const link = document.createElement("link");
566
+ link.rel = "preload";
567
+ link.as = "fetch";
568
+ link.href = AMAP_PRELOAD_STYLE_URL;
569
+ link.crossOrigin = "anonymous";
570
+ document.head.appendChild(link);
571
+ return link;
572
+ });
556
573
  const useAmapLoader = (props) => {
557
574
  const { disableRef, onSuccess, onFail } = props;
558
575
  let resolveLoader;
@@ -589,6 +606,7 @@ const useAmapLoader = (props) => {
589
606
  defineSecurityOnce();
590
607
  distExports.reset();
591
608
  statusRef.value = "LOADING";
609
+ setTimeout(preloadAmapStyleOnce);
592
610
  return distExports.load(options).then(
593
611
  () => {
594
612
  statusRef.value = "SUCCESS";
@@ -20,6 +20,6 @@ declare global {
20
20
  deviceorientationabsolute: DeviceOrientationEvent;
21
21
  }
22
22
  }
23
- declare module "@amap/amap-jsapi-loader" {
23
+ declare module "@heycar/amap-jsapi-loader" {
24
24
  const reset: () => void;
25
25
  }
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.0.0-switchMap9";
3
+ const pkgVersion = "2.1.0-speedupAmap2";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.0.0-switchMap9",
3
+ "version": "2.1.0-speedupAmap2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",
@@ -35,10 +35,10 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@amap/amap-jsapi-loader": "^1.0.1",
39
38
  "@amap/amap-jsapi-types": "^0.0.13",
40
39
  "@googlemaps/js-api-loader": "1.16.6",
41
40
  "@googlemaps/typescript-guards": "^2.0.3",
41
+ "@heycar/amap-jsapi-loader": "npm:@heycar/amap-jsapi-loader@1.0.1-fetchPriority",
42
42
  "@types/google.maps": "^3.54.10",
43
43
  "@types/lodash-es": "^4.17.6",
44
44
  "@use-gesture/vanilla": "^10.2.26",