@heycar/heycars-map 2.13.0-relay2 → 2.15.0-domestic1
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/README.md +47 -4
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +2 -1
- package/dist/v2/Demo/DemoBusinessTaxiEnd.d.ts +2 -1
- package/dist/v2/Demo/DemoBusinessTaxiEnd.js +9 -2
- package/dist/v2/Demo/DemoBusinessTaxiService.d.ts +4 -1
- package/dist/v2/Demo/DemoBusinessTaxiService.js +19 -1
- package/dist/v2/Demo/demo.data.mock.d.ts +4 -0
- package/dist/v2/Demo/demo.data.mock.js +1194 -0
- package/dist/v2/api/contants.d.ts +3 -0
- package/dist/v2/api/contants.js +6 -0
- package/dist/v2/business-components/AuxiliaryPassanger/AuxiliaryPassanger.d.ts +6 -0
- package/dist/v2/business-components/AuxiliaryPassanger/AuxiliaryPassanger.js +50 -0
- package/dist/v2/business-components/AuxiliaryPassanger/index.d.ts +1 -0
- package/dist/v2/business-components/AuxiliaryPassanger/index.js +4 -0
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
- package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +6 -2
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +4 -1
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +51 -7
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.d.ts +6 -1
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +81 -19
- package/dist/v2/business-components/TaxiCar/RandomCars.d.ts +6 -0
- package/dist/v2/business-components/TaxiCar/RandomCars.js +47 -0
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.e9166e7d.js → BusinessRecomendPlaceMap.eebd0822.js} +7 -1
- package/dist/v2/hooks/useMapCoordinatify.d.ts +2 -1
- package/dist/v2/hooks/useMapCoordinatify.js +6 -1
- package/dist/v2/hooks/useMapGeometry.d.ts +3 -3
- package/dist/v2/hooks/useMapGeometry.js +3 -3
- package/dist/v2/hooks/useWalkingRoute.js +46 -4
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/types/interface.d.ts +12 -0
- package/dist/v2/utils/geometry.d.ts +1 -0
- package/dist/v2/utils/geometry.js +4 -2
- package/dist/v2/utils/geometryPolygon.d.ts +14 -0
- package/dist/v2/utils/geometryPolygon.js +46 -0
- package/dist/v2/utils/log.js +11 -3
- package/dist/v2/utils/platform.d.ts +2 -1
- package/dist/v2/utils/platform.js +2 -1
- package/dist/v2/utils/ttlCache.d.ts +34 -0
- package/dist/v2/utils/ttlCache.js +64 -0
- package/dist/v2/utils/typeChecking.d.ts +7 -1
- package/dist/v2/utils/typeChecking.js +18 -0
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +2 -1
- package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +2 -1
- package/dist/v3/Demo/DemoBusinessTaxiEnd.js +9 -2
- package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +4 -1
- package/dist/v3/Demo/DemoBusinessTaxiService.js +19 -1
- package/dist/v3/Demo/demo.data.mock.d.ts +4 -0
- package/dist/v3/Demo/demo.data.mock.js +1194 -0
- package/dist/v3/api/contants.d.ts +3 -0
- package/dist/v3/api/contants.js +6 -0
- package/dist/v3/business-components/AuxiliaryPassanger/AuxiliaryPassanger.d.ts +8 -0
- package/dist/v3/business-components/AuxiliaryPassanger/AuxiliaryPassanger.js +46 -0
- package/dist/v3/business-components/AuxiliaryPassanger/index.d.ts +1 -0
- package/dist/v3/business-components/AuxiliaryPassanger/index.js +4 -0
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +2 -1
- package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +1 -1
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +6 -2
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +4 -1
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +49 -7
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.d.ts +6 -1
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +63 -19
- package/dist/v3/business-components/TaxiCar/RandomCars.d.ts +8 -0
- package/dist/v3/business-components/TaxiCar/RandomCars.js +45 -0
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.c71d0b97.js → BusinessRecomendPlaceMap.71c439c6.js} +5 -1
- package/dist/v3/hooks/useMapCoordinatify.d.ts +2 -1
- package/dist/v3/hooks/useMapCoordinatify.js +6 -1
- package/dist/v3/hooks/useMapGeometry.d.ts +3 -3
- package/dist/v3/hooks/useMapGeometry.js +3 -3
- package/dist/v3/hooks/useWalkingRoute.js +46 -4
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/index.js +1 -1
- package/dist/v3/types/interface.d.ts +12 -0
- package/dist/v3/utils/geometry.d.ts +1 -0
- package/dist/v3/utils/geometry.js +4 -2
- package/dist/v3/utils/geometryPolygon.d.ts +14 -0
- package/dist/v3/utils/geometryPolygon.js +46 -0
- package/dist/v3/utils/log.js +11 -3
- package/dist/v3/utils/platform.d.ts +2 -1
- package/dist/v3/utils/platform.js +2 -1
- package/dist/v3/utils/ttlCache.d.ts +34 -0
- package/dist/v3/utils/ttlCache.js +64 -0
- package/dist/v3/utils/typeChecking.d.ts +7 -1
- package/dist/v3/utils/typeChecking.js +18 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
|
|
|
5
5
|
BRWOSER_PLATFORM2["ALIPAY_MINIPROGRAM"] = "ALIPAY_MINIPROGRAM";
|
|
6
6
|
BRWOSER_PLATFORM2["H5"] = "H5";
|
|
7
7
|
BRWOSER_PLATFORM2["NODE_JS"] = "NODE_JS";
|
|
8
|
+
BRWOSER_PLATFORM2["ENTERPRISE_WECHAT"] = "ENTERPRISE_WECHAT";
|
|
8
9
|
return BRWOSER_PLATFORM2;
|
|
9
10
|
})(BRWOSER_PLATFORM || {});
|
|
10
11
|
var OS_PLATFORM = /* @__PURE__ */ ((OS_PLATFORM2) => {
|
|
@@ -39,7 +40,7 @@ const detectBrowserPlatform = () => {
|
|
|
39
40
|
return "NODE_JS";
|
|
40
41
|
const useragent = navigator.userAgent.toLowerCase();
|
|
41
42
|
if (useragent.includes("micromessenger")) {
|
|
42
|
-
return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : "WECHAT";
|
|
43
|
+
return useragent.includes("miniprogram") ? "WECHAT_MINIPROGRAM" : useragent.includes("wxwork") ? "ENTERPRISE_WECHAT" : "WECHAT";
|
|
43
44
|
}
|
|
44
45
|
if (useragent.includes("alipay") || detectAlipayWallet()) {
|
|
45
46
|
return useragent.includes("miniprogram") ? "ALIPAY_MINIPROGRAM" : "ALIPAY";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Milliseconds = number;
|
|
2
|
+
export interface TTLCache<K, V> {
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
set(key: K, value: V): void;
|
|
5
|
+
delete(key: K): boolean;
|
|
6
|
+
clear(): void;
|
|
7
|
+
entries(): IterableIterator<[K, V]>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 高性能 TTL Cache(固定 TTL,不支持动态变更)。
|
|
11
|
+
* - 仅提供最小接口:get/set/delete/clear/entries
|
|
12
|
+
* - 惰性过期:在访问时清理过期项,无额外定时器
|
|
13
|
+
*/
|
|
14
|
+
export declare function createTTLCache<K, V>(ttlMs: Milliseconds): TTLCache<K, V>;
|
|
15
|
+
/**
|
|
16
|
+
* 异步函数的 TTL 记忆化工厂
|
|
17
|
+
*
|
|
18
|
+
* 命中策略(按顺序):
|
|
19
|
+
* 1. 精确命中:用 `computeKey(args)` 查缓存。
|
|
20
|
+
* 2. 近似命中:用 `selectFromCache(args, entries)` 在当前有效条目中挑选。
|
|
21
|
+
* 3. 未命中:执行原函数,结果写入缓存。
|
|
22
|
+
*
|
|
23
|
+
* 过期策略:惰性按 `ttlMs` 过期;`ttlMs <= 0` 表示不缓存;传 `Infinity` 视为永不过期。
|
|
24
|
+
*
|
|
25
|
+
* 参数:
|
|
26
|
+
* - `ttlMs`:缓存有效期(毫秒)。
|
|
27
|
+
* - `selectFromCache`:近似命中选择器,入参为本次 `args` 与有效缓存条目的迭代器,返回命中值或 `undefined`。
|
|
28
|
+
* - `computeKey`:精确命中的 key 生成函数,默认 `JSON.stringify`。
|
|
29
|
+
*
|
|
30
|
+
* 返回:`memoize(fn)`,将异步函数包装为带缓存的版本。
|
|
31
|
+
*
|
|
32
|
+
* 说明:不做并发合并;仅实现 TTL 驱逐(无容量上限);近似匹配会遍历有效条目。
|
|
33
|
+
*/
|
|
34
|
+
export declare function createMemoizeWithTTL<A extends any[], R>(ttlMs: Milliseconds, selectFromCache: (args: A, cacheEntries: IterableIterator<[A, R]>) => R | undefined, computeKey?: (args: A) => string): (fn: (...args: A) => Promise<R>) => (...args: A) => Promise<R>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function createTTLCache(ttlMs) {
|
|
2
|
+
const store = /* @__PURE__ */ new Map();
|
|
3
|
+
const get = (key) => {
|
|
4
|
+
const record = store.get(key);
|
|
5
|
+
if (!record)
|
|
6
|
+
return void 0;
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
if (record.expireAt !== Infinity && record.expireAt <= now) {
|
|
9
|
+
store.delete(key);
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
return record.value;
|
|
13
|
+
};
|
|
14
|
+
const set = (key, value) => {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
const expireAt = Number.isFinite(ttlMs) ? now + ttlMs : Infinity;
|
|
17
|
+
if (Number.isFinite(ttlMs) && ttlMs <= 0) {
|
|
18
|
+
store.delete(key);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
store.set(key, { value, expireAt });
|
|
22
|
+
};
|
|
23
|
+
const del = (key) => store.delete(key);
|
|
24
|
+
const clear = () => {
|
|
25
|
+
store.clear();
|
|
26
|
+
};
|
|
27
|
+
function* entries() {
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
for (const [key, record] of store) {
|
|
30
|
+
if (record.expireAt !== Infinity && record.expireAt <= now) {
|
|
31
|
+
store.delete(key);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
yield [key, record.value];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { get, set, delete: del, clear, entries };
|
|
38
|
+
}
|
|
39
|
+
function createMemoizeWithTTL(ttlMs, selectFromCache, computeKey = JSON.stringify) {
|
|
40
|
+
const cache = createTTLCache(ttlMs);
|
|
41
|
+
function* cacheEntries() {
|
|
42
|
+
for (const [, record] of cache.entries()) {
|
|
43
|
+
yield [record.args, record.value];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return function memoize(fn) {
|
|
47
|
+
return async function memoizedTTLFn(...args) {
|
|
48
|
+
const key = computeKey(args);
|
|
49
|
+
const direct = cache.get(key);
|
|
50
|
+
if (direct !== void 0)
|
|
51
|
+
return direct.value;
|
|
52
|
+
const hit = selectFromCache(args, cacheEntries());
|
|
53
|
+
if (hit !== void 0)
|
|
54
|
+
return hit;
|
|
55
|
+
const result = await fn(...args);
|
|
56
|
+
cache.set(key, { args, value: result });
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
createMemoizeWithTTL,
|
|
63
|
+
createTTLCache
|
|
64
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone, ProxyServiceError, RecommendType } from "../types/interface";
|
|
1
|
+
import type { CoordinateExternalRoute, CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone, ProxyServiceError, RecommendType } from "../types/interface";
|
|
2
2
|
export declare const createTypeError: (typeName: string, value: unknown, detail?: string) => Error;
|
|
3
3
|
export declare function isCoordinateType(type: unknown): type is CoordinateType;
|
|
4
4
|
export declare function isRecommendType(type: unknown): type is RecommendType;
|
|
@@ -41,6 +41,12 @@ interface MaybeCoordinateTrackPoint {
|
|
|
41
41
|
timestamp?: number | string;
|
|
42
42
|
}
|
|
43
43
|
export declare const toCoordinateTrackPoint: (value?: MaybeCoordinateTrackPoint) => CoordinateTrackPoint;
|
|
44
|
+
interface MaybeCoordinateExternalRoute {
|
|
45
|
+
path?: MaybeCoordinatePoint[];
|
|
46
|
+
duration?: number | string | null;
|
|
47
|
+
distance?: number | string | null;
|
|
48
|
+
}
|
|
49
|
+
export declare const toCoordinateExternalRoute: (maybeCoordinateExternalRoute?: MaybeCoordinateExternalRoute) => CoordinateExternalRoute;
|
|
44
50
|
export declare function isProxyServiceError(error: unknown): error is ProxyServiceError;
|
|
45
51
|
export declare function toGeolocationPositionError(error: unknown, prefix?: string): GeolocationPositionError;
|
|
46
52
|
/**
|
|
@@ -107,6 +107,23 @@ const toCoordinateTrackPoint = (value) => {
|
|
|
107
107
|
}
|
|
108
108
|
return { lng, lat, type, angle, speed, timestamp };
|
|
109
109
|
};
|
|
110
|
+
const toCoordinateExternalRoute = (maybeCoordinateExternalRoute) => {
|
|
111
|
+
var _a;
|
|
112
|
+
try {
|
|
113
|
+
if (!maybeCoordinateExternalRoute)
|
|
114
|
+
throw Error();
|
|
115
|
+
const duration = Number(maybeCoordinateExternalRoute.duration);
|
|
116
|
+
const distance = Number(maybeCoordinateExternalRoute.distance);
|
|
117
|
+
if (isNaN(duration) || isNaN(distance))
|
|
118
|
+
throw Error();
|
|
119
|
+
if (!Array.isArray(maybeCoordinateExternalRoute.path))
|
|
120
|
+
throw Error();
|
|
121
|
+
const path = (_a = maybeCoordinateExternalRoute.path) == null ? void 0 : _a.map(toCoordinatePointType);
|
|
122
|
+
return { path, duration, distance };
|
|
123
|
+
} catch (err) {
|
|
124
|
+
throw createTypeError("CoordinateExternalRoute", maybeCoordinateExternalRoute, err == null ? void 0 : err.message);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
110
127
|
function isProxyServiceError(error) {
|
|
111
128
|
return !!error && typeof error === "object" && "msg" in error && "code" in error;
|
|
112
129
|
}
|
|
@@ -172,6 +189,7 @@ export {
|
|
|
172
189
|
isCoordinateType,
|
|
173
190
|
isProxyServiceError,
|
|
174
191
|
isRecommendType,
|
|
192
|
+
toCoordinateExternalRoute,
|
|
175
193
|
toCoordinatePlaceType,
|
|
176
194
|
toCoordinatePointType,
|
|
177
195
|
toCoordinateRecommendZonePlacesType,
|