@heycar/heycars-map 2.0.0-switchMap1 → 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 (96) hide show
  1. package/README.md +43 -29
  2. package/dist/v2/App.js +5 -3
  3. package/dist/v2/Demo/DemoBusinessQuoting.js +3 -2
  4. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
  5. package/dist/v2/api/cdn.d.ts +1 -0
  6. package/dist/v2/api/cdn.js +2 -0
  7. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  8. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  9. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  10. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  11. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  12. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  13. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  14. package/dist/v2/chunks/{BusinessRecomendPlaceMap.5be4fdcf.js → BusinessRecomendPlaceMap.f589ebf7.js} +17 -10
  15. package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.da68a2a6.js} +31 -1
  16. package/dist/v2/chunks/throttle.8bdd8d3b.js +20 -0
  17. package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
  18. package/dist/v2/components/Loading/Loading.d.ts +6 -0
  19. package/dist/v2/components/Loading/Loading.js +3 -1
  20. package/dist/v2/components/Loading/index.js +2 -1
  21. package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
  22. package/dist/v2/components/MapProvider/MapProvider.js +16 -9
  23. package/dist/v2/css/Loading-0e058b68.css +51 -0
  24. package/dist/v2/hooks/useDeviceOrientation.js +1 -17
  25. package/dist/v2/hooks/useMapGCJ02.js +1 -3
  26. package/dist/v2/hooks/useMapGraspRoad.js +1 -2
  27. package/dist/v2/hooks/useMapInChina.d.ts +3 -15
  28. package/dist/v2/hooks/useMapInChina.js +11 -16
  29. package/dist/v2/hooks/useMapLoader.d.ts +10 -6
  30. package/dist/v2/hooks/useMapLoader.js +88 -59
  31. package/dist/v2/hooks/useMapPlace.d.ts +1 -0
  32. package/dist/v2/hooks/useMapPlace.js +10 -9
  33. package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
  34. package/dist/v2/hooks/useMapRecomendPlace.js +72 -64
  35. package/dist/v2/hooks/useMapSupplier.d.ts +6 -0
  36. package/dist/v2/hooks/useMapSupplier.js +17 -0
  37. package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  38. package/dist/v2/hooks-business/useBusinessQuotingMap.js +7 -2
  39. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  40. package/dist/v2/index.js +1 -1
  41. package/dist/v2/utils/ManualAbortError.d.ts +3 -0
  42. package/dist/v2/utils/ManualAbortError.js +14 -0
  43. package/dist/v2/utils/helper.d.ts +1 -0
  44. package/dist/v2/utils/helper.js +17 -0
  45. package/dist/v2/utils/log.js +1 -1
  46. package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
  47. package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
  48. package/dist/v3/App.js +5 -3
  49. package/dist/v3/Demo/DemoBusinessQuoting.js +4 -3
  50. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  51. package/dist/v3/api/cdn.d.ts +1 -0
  52. package/dist/v3/api/cdn.js +2 -0
  53. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  54. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  55. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
  56. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  57. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  58. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +18 -11
  59. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  60. package/dist/v3/chunks/{BusinessRecomendPlaceMap.39888296.js → BusinessRecomendPlaceMap.86e9c287.js} +17 -10
  61. package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.98d687c0.js} +27 -1
  62. package/dist/v3/chunks/throttle.8bdd8d3b.js +20 -0
  63. package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
  64. package/dist/v3/components/Loading/Loading.d.ts +8 -0
  65. package/dist/v3/components/Loading/Loading.js +3 -1
  66. package/dist/v3/components/Loading/index.js +2 -1
  67. package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
  68. package/dist/v3/components/MapProvider/MapProvider.js +14 -9
  69. package/dist/v3/css/Loading-0e058b68.css +51 -0
  70. package/dist/v3/hooks/useDeviceOrientation.js +1 -17
  71. package/dist/v3/hooks/useMapGCJ02.js +1 -3
  72. package/dist/v3/hooks/useMapGraspRoad.js +1 -2
  73. package/dist/v3/hooks/useMapInChina.d.ts +3 -15
  74. package/dist/v3/hooks/useMapInChina.js +11 -16
  75. package/dist/v3/hooks/useMapLoader.d.ts +10 -6
  76. package/dist/v3/hooks/useMapLoader.js +88 -59
  77. package/dist/v3/hooks/useMapPlace.d.ts +1 -0
  78. package/dist/v3/hooks/useMapPlace.js +10 -9
  79. package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
  80. package/dist/v3/hooks/useMapRecomendPlace.js +72 -64
  81. package/dist/v3/hooks/useMapSupplier.d.ts +6 -0
  82. package/dist/v3/hooks/useMapSupplier.js +17 -0
  83. package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  84. package/dist/v3/hooks-business/useBusinessQuotingMap.js +7 -2
  85. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  86. package/dist/v3/index.js +1 -1
  87. package/dist/v3/utils/ManualAbortError.d.ts +3 -0
  88. package/dist/v3/utils/ManualAbortError.js +14 -0
  89. package/dist/v3/utils/helper.d.ts +1 -0
  90. package/dist/v3/utils/helper.js +17 -0
  91. package/dist/v3/utils/log.js +1 -1
  92. package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
  93. package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
  94. package/package.json +2 -2
  95. package/dist/v2/css/Loading-523061b9.css +0 -9
  96. package/dist/v3/css/Loading-523061b9.css +0 -9
@@ -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-switchMap1";
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.0.0-switchMap1",
3
+ "version": "2.0.0-switchMap3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@amap/amap-jsapi-loader": "^1.0.1",
39
39
  "@amap/amap-jsapi-types": "^0.0.13",
40
- "@googlemaps/js-api-loader": "^1.16.6",
40
+ "@googlemaps/js-api-loader": "1.16.6",
41
41
  "@googlemaps/typescript-guards": "^2.0.3",
42
42
  "@types/google.maps": "^3.54.10",
43
43
  "@types/lodash-es": "^4.17.6",
@@ -1,9 +0,0 @@
1
- ._17ify490 {
2
- position: relative;
3
- background-color: #EDF1F5;
4
- }
5
- ._17ify491 {
6
- width: 100%;
7
- height: 100%;
8
- object-fit: cover;
9
- }
@@ -1,9 +0,0 @@
1
- ._17ify490 {
2
- position: relative;
3
- background-color: #EDF1F5;
4
- }
5
- ._17ify491 {
6
- width: 100%;
7
- height: 100%;
8
- object-fit: cover;
9
- }