@heycar/heycars-map 2.0.0-switchMap4 → 2.0.0-switchMap6
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/v2/api/pingConnection.d.ts +9 -0
- package/dist/v2/api/pingConnection.js +107 -0
- package/dist/v2/chunks/{Loading.f2515cd7.js → Loading.492acbc2.js} +2 -2
- package/dist/v2/components/Loading/Loading.js +3 -3
- package/dist/v2/components/Loading/index.js +3 -3
- package/dist/v2/components/MapProvider/MapProvider.js +13 -10
- package/dist/v2/hooks/useDeviceOrientation.js +17 -1
- package/dist/v2/hooks/useDrivingRoute.js +4 -0
- package/dist/v2/hooks/useMapGCJ02.js +3 -31
- package/dist/v2/hooks/useMapLoader.d.ts +4 -2
- package/dist/v2/hooks/useMapLoader.js +110 -85
- package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v2/hooks/usePingConnection.d.ts +10 -0
- package/dist/v2/hooks/usePingConnection.js +26 -0
- package/dist/v2/types/global.d.ts +3 -0
- package/dist/v2/types/interface.d.ts +1 -1
- package/dist/v2/utils/helper.d.ts +1 -0
- package/dist/v2/utils/helper.js +12 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/api/pingConnection.d.ts +9 -0
- package/dist/v3/api/pingConnection.js +107 -0
- package/dist/v3/chunks/{Loading.32ae3c98.js → Loading.21d8e759.js} +2 -2
- package/dist/v3/components/Loading/Loading.js +3 -3
- package/dist/v3/components/Loading/index.js +3 -3
- package/dist/v3/components/MapProvider/MapProvider.js +13 -10
- package/dist/v3/hooks/useDeviceOrientation.js +17 -1
- package/dist/v3/hooks/useDrivingRoute.js +4 -0
- package/dist/v3/hooks/useMapGCJ02.js +3 -31
- package/dist/v3/hooks/useMapLoader.d.ts +4 -2
- package/dist/v3/hooks/useMapLoader.js +110 -85
- package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v3/hooks/usePingConnection.d.ts +10 -0
- package/dist/v3/hooks/usePingConnection.js +26 -0
- package/dist/v3/types/global.d.ts +3 -0
- package/dist/v3/types/interface.d.ts +1 -1
- package/dist/v3/utils/helper.d.ts +1 -0
- package/dist/v3/utils/helper.js +12 -0
- package/dist/v3/utils/log.js +1 -1
- package/package.json +1 -1
- package/dist/v2/api/googleConnection.d.ts +0 -5
- package/dist/v2/api/googleConnection.js +0 -51
- package/dist/v2/chunks/throttle.8bdd8d3b.js +0 -20
- package/dist/v2/hooks/useGoogleConnection.d.ts +0 -7
- package/dist/v2/hooks/useGoogleConnection.js +0 -15
- package/dist/v3/api/googleConnection.d.ts +0 -5
- package/dist/v3/api/googleConnection.js +0 -51
- package/dist/v3/chunks/throttle.8bdd8d3b.js +0 -20
- package/dist/v3/hooks/useGoogleConnection.d.ts +0 -7
- package/dist/v3/hooks/useGoogleConnection.js +0 -15
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AnyFn } from "@vueuse/core";
|
|
2
|
+
import type { ConnectionStatus } from "../types/interface";
|
|
2
3
|
import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
|
|
3
4
|
export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
4
5
|
gmapRasterId: string;
|
|
5
6
|
gmapId: string;
|
|
6
7
|
readyPromise: UseMapLoaderOutput["readyPromise"];
|
|
7
8
|
status: Status;
|
|
9
|
+
pingStatus: ConnectionStatus;
|
|
8
10
|
renderLoadFailedTitle?: (status: Status) => string | undefined;
|
|
9
11
|
renderLoadFailedDescription?: (status: Status) => string | undefined;
|
|
10
12
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PingConnectionOnChangeHandler } from "../api/pingConnection";
|
|
2
|
+
export interface UsePingConnectionProps {
|
|
3
|
+
onChange?: PingConnectionOnChangeHandler;
|
|
4
|
+
}
|
|
5
|
+
export declare const usePingAmapConnection: (props?: UsePingConnectionProps) => {
|
|
6
|
+
connectionStatus: Readonly<import("vue-demi").Ref<import("..").ConnectionStatus>>;
|
|
7
|
+
};
|
|
8
|
+
export declare const usePingGmapConnection: (props?: UsePingConnectionProps) => {
|
|
9
|
+
connectionStatus: Readonly<import("vue-demi").Ref<import("..").ConnectionStatus>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ref, onUnmounted, readonly } from "vue-demi";
|
|
2
|
+
import { apiGetPingAmapStatus, apiSubscribePingAmapChange, apiGetPingGmapStatus, apiSubscribePingGmapChange } from "../api/pingConnection.js";
|
|
3
|
+
const usePingAmapConnection = (props) => {
|
|
4
|
+
const statusRef = ref(apiGetPingAmapStatus());
|
|
5
|
+
const unsubscribe = apiSubscribePingAmapChange((status) => {
|
|
6
|
+
var _a;
|
|
7
|
+
statusRef.value = status;
|
|
8
|
+
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
9
|
+
});
|
|
10
|
+
onUnmounted(unsubscribe);
|
|
11
|
+
return { connectionStatus: readonly(statusRef) };
|
|
12
|
+
};
|
|
13
|
+
const usePingGmapConnection = (props) => {
|
|
14
|
+
const statusRef = ref(apiGetPingGmapStatus());
|
|
15
|
+
const unsubscribe = apiSubscribePingGmapChange((status) => {
|
|
16
|
+
var _a;
|
|
17
|
+
statusRef.value = status;
|
|
18
|
+
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
19
|
+
});
|
|
20
|
+
onUnmounted(unsubscribe);
|
|
21
|
+
return { connectionStatus: readonly(statusRef) };
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
usePingAmapConnection,
|
|
25
|
+
usePingGmapConnection
|
|
26
|
+
};
|
|
@@ -93,7 +93,7 @@ export declare enum CenterPlaceStatus {
|
|
|
93
93
|
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
|
|
94
94
|
OK = "OK"
|
|
95
95
|
}
|
|
96
|
-
export type
|
|
96
|
+
export type ConnectionStatus = "pending" | "connected" | "unconnected";
|
|
97
97
|
export interface BusinessGeolocationPositionError extends GeolocationPositionError {
|
|
98
98
|
isBusinessTimeout: boolean;
|
|
99
99
|
}
|
|
@@ -22,6 +22,7 @@ export declare const pausableSleep: (milliSeconds: number) => {
|
|
|
22
22
|
restart: () => void;
|
|
23
23
|
};
|
|
24
24
|
export declare const createRunOnce: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => R;
|
|
25
|
+
export declare const createOneConcurrent: <P extends any[], R>(fn: (...args: P) => Promise<R>) => (...args: P) => Promise<R> | undefined;
|
|
25
26
|
export declare const createReadOnce: <T>(value: T) => () => T | undefined;
|
|
26
27
|
export declare const createAsyncNoFailNonNullable: <P extends any[], R>(fn: (...args: P) => Promise<R>, defaultValue: NonNullable<R>) => (...args: P) => Promise<NonNullable<R>>;
|
|
27
28
|
export declare const pipeTimeout: <P extends any[], R>(fn: (...args: P) => Promise<R>, defaultValue: R, timeout: number) => (...args: P) => Promise<R>;
|
package/dist/v3/utils/helper.js
CHANGED
|
@@ -93,6 +93,17 @@ const createRunOnce = (fn) => {
|
|
|
93
93
|
return result;
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
+
const createOneConcurrent = (fn) => {
|
|
97
|
+
let isRunning = false;
|
|
98
|
+
return function runOneConcurrent(...args) {
|
|
99
|
+
if (isRunning)
|
|
100
|
+
return;
|
|
101
|
+
isRunning = true;
|
|
102
|
+
const result = fn(...args);
|
|
103
|
+
result.finally(() => isRunning = false);
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
96
107
|
const createReadOnce = (value) => {
|
|
97
108
|
let isRead = false;
|
|
98
109
|
return function read() {
|
|
@@ -171,6 +182,7 @@ export {
|
|
|
171
182
|
assertZone,
|
|
172
183
|
createAbortable,
|
|
173
184
|
createAsyncNoFailNonNullable,
|
|
185
|
+
createOneConcurrent,
|
|
174
186
|
createReadOnce,
|
|
175
187
|
createRunOnce,
|
|
176
188
|
defered,
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.0.0-
|
|
3
|
+
const pkgVersion = "2.0.0-switchMap6";
|
|
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,5 +0,0 @@
|
|
|
1
|
-
import type { GoogleConnectionStatus } from "../types/interface";
|
|
2
|
-
export type GoogleConnectionOnChangeHandler = (status: GoogleConnectionStatus) => void;
|
|
3
|
-
export type GoogleConnectionOnChangeCleanup = () => void;
|
|
4
|
-
export declare const apiGoogleConnectionStatus: () => GoogleConnectionStatus;
|
|
5
|
-
export declare const apiSubscribeGoogleConnectionChange: (handler: GoogleConnectionOnChangeHandler) => GoogleConnectionOnChangeCleanup;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
const GOOGLE_DNS_RESOLVER = "https://dns.google/resolve?name=maps.googleapis.com&type=A";
|
|
8
|
-
const GOOGLE_CONNECTION_DEFAULT_TIMEOUT = 5e3;
|
|
9
|
-
const noop = () => {
|
|
10
|
-
};
|
|
11
|
-
class GoogleConnection {
|
|
12
|
-
constructor() {
|
|
13
|
-
__publicField(this, "status", "pending");
|
|
14
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
15
|
-
this.start();
|
|
16
|
-
}
|
|
17
|
-
async start() {
|
|
18
|
-
const status = await this.check();
|
|
19
|
-
this.status = status;
|
|
20
|
-
for (const handler of this.listeners) {
|
|
21
|
-
try {
|
|
22
|
-
handler(status);
|
|
23
|
-
} catch (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
check(timeout = GOOGLE_CONNECTION_DEFAULT_TIMEOUT) {
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
31
|
-
return fetch(GOOGLE_DNS_RESOLVER, { signal: controller.signal }).then(() => "connected").catch(() => "unconnected").finally(() => clearTimeout(timer));
|
|
32
|
-
}
|
|
33
|
-
onChange(handler) {
|
|
34
|
-
if (typeof handler !== "function")
|
|
35
|
-
return noop;
|
|
36
|
-
this.listeners.add(handler);
|
|
37
|
-
const clear = () => {
|
|
38
|
-
this.listeners.delete(handler);
|
|
39
|
-
};
|
|
40
|
-
return clear;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const googleConnection = new GoogleConnection();
|
|
44
|
-
const apiGoogleConnectionStatus = () => {
|
|
45
|
-
return googleConnection.status;
|
|
46
|
-
};
|
|
47
|
-
const apiSubscribeGoogleConnectionChange = (handler) => googleConnection.onChange(handler);
|
|
48
|
-
export {
|
|
49
|
-
apiGoogleConnectionStatus,
|
|
50
|
-
apiSubscribeGoogleConnectionChange
|
|
51
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { i as isObject, d as debounce } from "./debounce.5afe7867.js";
|
|
2
|
-
var FUNC_ERROR_TEXT = "Expected a function";
|
|
3
|
-
function throttle(func, wait, options) {
|
|
4
|
-
var leading = true, trailing = true;
|
|
5
|
-
if (typeof func != "function") {
|
|
6
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
7
|
-
}
|
|
8
|
-
if (isObject(options)) {
|
|
9
|
-
leading = "leading" in options ? !!options.leading : leading;
|
|
10
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
11
|
-
}
|
|
12
|
-
return debounce(func, wait, {
|
|
13
|
-
"leading": leading,
|
|
14
|
-
"maxWait": wait,
|
|
15
|
-
"trailing": trailing
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
throttle as t
|
|
20
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type GoogleConnectionOnChangeHandler } from "../api/googleConnection";
|
|
2
|
-
export interface UseGoogleConnectionProps {
|
|
3
|
-
onChange?: GoogleConnectionOnChangeHandler;
|
|
4
|
-
}
|
|
5
|
-
export declare const useGoogleConnection: (props?: UseGoogleConnectionProps) => {
|
|
6
|
-
googleConnectionStatus: Readonly<import("vue-demi").Ref<import("..").GoogleConnectionStatus>>;
|
|
7
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ref, onUnmounted, readonly } from "vue-demi";
|
|
2
|
-
import { apiGoogleConnectionStatus, apiSubscribeGoogleConnectionChange } from "../api/googleConnection.js";
|
|
3
|
-
const useGoogleConnection = (props) => {
|
|
4
|
-
const statusRef = ref(apiGoogleConnectionStatus());
|
|
5
|
-
const unsubscribe = apiSubscribeGoogleConnectionChange((status) => {
|
|
6
|
-
var _a;
|
|
7
|
-
statusRef.value = status;
|
|
8
|
-
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
9
|
-
});
|
|
10
|
-
onUnmounted(unsubscribe);
|
|
11
|
-
return { googleConnectionStatus: readonly(statusRef) };
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
useGoogleConnection
|
|
15
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { GoogleConnectionStatus } from "../types/interface";
|
|
2
|
-
export type GoogleConnectionOnChangeHandler = (status: GoogleConnectionStatus) => void;
|
|
3
|
-
export type GoogleConnectionOnChangeCleanup = () => void;
|
|
4
|
-
export declare const apiGoogleConnectionStatus: () => GoogleConnectionStatus;
|
|
5
|
-
export declare const apiSubscribeGoogleConnectionChange: (handler: GoogleConnectionOnChangeHandler) => GoogleConnectionOnChangeCleanup;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
const GOOGLE_DNS_RESOLVER = "https://dns.google/resolve?name=maps.googleapis.com&type=A";
|
|
8
|
-
const GOOGLE_CONNECTION_DEFAULT_TIMEOUT = 5e3;
|
|
9
|
-
const noop = () => {
|
|
10
|
-
};
|
|
11
|
-
class GoogleConnection {
|
|
12
|
-
constructor() {
|
|
13
|
-
__publicField(this, "status", "pending");
|
|
14
|
-
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
15
|
-
this.start();
|
|
16
|
-
}
|
|
17
|
-
async start() {
|
|
18
|
-
const status = await this.check();
|
|
19
|
-
this.status = status;
|
|
20
|
-
for (const handler of this.listeners) {
|
|
21
|
-
try {
|
|
22
|
-
handler(status);
|
|
23
|
-
} catch (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
check(timeout = GOOGLE_CONNECTION_DEFAULT_TIMEOUT) {
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
31
|
-
return fetch(GOOGLE_DNS_RESOLVER, { signal: controller.signal }).then(() => "connected").catch(() => "unconnected").finally(() => clearTimeout(timer));
|
|
32
|
-
}
|
|
33
|
-
onChange(handler) {
|
|
34
|
-
if (typeof handler !== "function")
|
|
35
|
-
return noop;
|
|
36
|
-
this.listeners.add(handler);
|
|
37
|
-
const clear = () => {
|
|
38
|
-
this.listeners.delete(handler);
|
|
39
|
-
};
|
|
40
|
-
return clear;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const googleConnection = new GoogleConnection();
|
|
44
|
-
const apiGoogleConnectionStatus = () => {
|
|
45
|
-
return googleConnection.status;
|
|
46
|
-
};
|
|
47
|
-
const apiSubscribeGoogleConnectionChange = (handler) => googleConnection.onChange(handler);
|
|
48
|
-
export {
|
|
49
|
-
apiGoogleConnectionStatus,
|
|
50
|
-
apiSubscribeGoogleConnectionChange
|
|
51
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { i as isObject, d as debounce } from "./debounce.5afe7867.js";
|
|
2
|
-
var FUNC_ERROR_TEXT = "Expected a function";
|
|
3
|
-
function throttle(func, wait, options) {
|
|
4
|
-
var leading = true, trailing = true;
|
|
5
|
-
if (typeof func != "function") {
|
|
6
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
7
|
-
}
|
|
8
|
-
if (isObject(options)) {
|
|
9
|
-
leading = "leading" in options ? !!options.leading : leading;
|
|
10
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
11
|
-
}
|
|
12
|
-
return debounce(func, wait, {
|
|
13
|
-
"leading": leading,
|
|
14
|
-
"maxWait": wait,
|
|
15
|
-
"trailing": trailing
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
throttle as t
|
|
20
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type GoogleConnectionOnChangeHandler } from "../api/googleConnection";
|
|
2
|
-
export interface UseGoogleConnectionProps {
|
|
3
|
-
onChange?: GoogleConnectionOnChangeHandler;
|
|
4
|
-
}
|
|
5
|
-
export declare const useGoogleConnection: (props?: UseGoogleConnectionProps) => {
|
|
6
|
-
googleConnectionStatus: Readonly<import("vue-demi").Ref<import("..").GoogleConnectionStatus>>;
|
|
7
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ref, onUnmounted, readonly } from "vue-demi";
|
|
2
|
-
import { apiGoogleConnectionStatus, apiSubscribeGoogleConnectionChange } from "../api/googleConnection.js";
|
|
3
|
-
const useGoogleConnection = (props) => {
|
|
4
|
-
const statusRef = ref(apiGoogleConnectionStatus());
|
|
5
|
-
const unsubscribe = apiSubscribeGoogleConnectionChange((status) => {
|
|
6
|
-
var _a;
|
|
7
|
-
statusRef.value = status;
|
|
8
|
-
(_a = props == null ? void 0 : props.onChange) == null ? void 0 : _a.call(props, status);
|
|
9
|
-
});
|
|
10
|
-
onUnmounted(unsubscribe);
|
|
11
|
-
return { googleConnectionStatus: readonly(statusRef) };
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
useGoogleConnection
|
|
15
|
-
};
|