@heycar/heycars-map 2.0.0-switchMap4 → 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.
- 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/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/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,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
|
-
};
|