@heycar/heycars-map 2.5.0 → 2.5.1
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 +3 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +2 -0
- package/dist/v2/hooks/useMapRecomendPlace.js +5 -3
- package/dist/v2/hooks/useMapSupplier.js +0 -1
- package/dist/v2/hooks/useWalkingRoute.js +6 -0
- package/dist/v2/utils/ManualAbortError.d.ts +3 -0
- package/dist/v2/utils/ManualAbortError.js +22 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +2 -0
- package/dist/v3/hooks/useMapRecomendPlace.js +5 -3
- package/dist/v3/hooks/useMapSupplier.js +0 -1
- package/dist/v3/hooks/useWalkingRoute.js +6 -0
- package/dist/v3/utils/ManualAbortError.d.ts +3 -0
- package/dist/v3/utils/ManualAbortError.js +22 -0
- package/dist/v3/utils/log.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -236,7 +236,8 @@ export default defineComponent({
|
|
|
236
236
|
<BusinessRecomendPlaceMap
|
|
237
237
|
class={"demo"}
|
|
238
238
|
geoLoadingTitle={"正在获取您当前的位置"}
|
|
239
|
-
unavailableTitle={"
|
|
239
|
+
unavailableTitle={"当前区域暂未开通服务"}
|
|
240
|
+
forbiddenTitle={"当前区域不可叫车"}
|
|
240
241
|
emptyTitle={"当前位置"}
|
|
241
242
|
queryingTitle={"正在获取地址信息"}
|
|
242
243
|
recomendDescription={"您将在此处上车"}
|
|
@@ -358,6 +359,7 @@ export default defineComponent({
|
|
|
358
359
|
<BusinessReselectPlaceMap
|
|
359
360
|
class={"demo"}
|
|
360
361
|
unavailableTitle={"当前区域暂未开通服务"}
|
|
362
|
+
forbiddenTitle={"当前区域不可叫车"}
|
|
361
363
|
emptyTitle={"当前位置"}
|
|
362
364
|
queryingTitle={"正在获取地址信息"}
|
|
363
365
|
recomendDescription={"您将在此处上车"}
|
|
@@ -227,6 +227,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
227
227
|
place,
|
|
228
228
|
inputPlace,
|
|
229
229
|
type,
|
|
230
|
+
zone,
|
|
230
231
|
isSameZone
|
|
231
232
|
}) => {
|
|
232
233
|
var _a;
|
|
@@ -242,6 +243,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
242
243
|
place,
|
|
243
244
|
inputPlace,
|
|
244
245
|
type,
|
|
246
|
+
zone,
|
|
245
247
|
isSameZone
|
|
246
248
|
}));
|
|
247
249
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, reactive } from "vue-demi";
|
|
2
2
|
import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
|
|
3
|
-
import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
3
|
+
import { recoverablyIgnoreManualAbortReject, logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
4
4
|
import { createAbortableOneConcurrent, AbortSignalAny, equalAssign, isPlacesInclude, createAbortable } from "../utils/helper.js";
|
|
5
5
|
import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
|
|
6
6
|
import { assertNoConflictTypeAndZone } from "../utils/typeChecking.js";
|
|
@@ -103,7 +103,9 @@ const useMapRecomendPlace = (props) => {
|
|
|
103
103
|
const [lng, lat] = point;
|
|
104
104
|
const { type, zone, available, candidates } = prevState;
|
|
105
105
|
if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
|
|
106
|
-
const
|
|
106
|
+
const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
|
|
107
|
+
getPlaceByRegeo(point, opt)
|
|
108
|
+
);
|
|
107
109
|
const {
|
|
108
110
|
place: closestPlace,
|
|
109
111
|
candidates: candidates2,
|
|
@@ -114,7 +116,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
114
116
|
if (isPlacesInclude(candidates2, closestPlace)) {
|
|
115
117
|
return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
116
118
|
}
|
|
117
|
-
const regeoPlace = await
|
|
119
|
+
const regeoPlace = await reGeoPlacePromiseIgnored.recover();
|
|
118
120
|
return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
119
121
|
}
|
|
120
122
|
if (type === "Forbidden") {
|
|
@@ -12,7 +12,6 @@ const useMapAssertSupplier = () => {
|
|
|
12
12
|
const instanceSupplier = payload.supplier;
|
|
13
13
|
function assertSupplier(fn) {
|
|
14
14
|
return function fnWithAssertSupplier(...args) {
|
|
15
|
-
console.log("instanceSupplier, payload.supplier = ", instanceSupplier, payload.supplier);
|
|
16
15
|
if (instanceSupplier === payload.supplier)
|
|
17
16
|
return fn(...args);
|
|
18
17
|
throw Error(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { shallowRef } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
3
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
4
|
+
const isIgnoredAmapWalkingRouteError = (err) => err === "RETURN_TIMEOUT";
|
|
4
5
|
const useAWalkingRoute = (props) => {
|
|
5
6
|
const pathRef = shallowRef([]);
|
|
6
7
|
const amapWalking = new AMap.Walking({});
|
|
@@ -30,6 +31,11 @@ const useAWalkingRoute = (props) => {
|
|
|
30
31
|
pathRef.value = [];
|
|
31
32
|
return;
|
|
32
33
|
default:
|
|
34
|
+
if (isIgnoredAmapWalkingRouteError(result)) {
|
|
35
|
+
console.warn(result);
|
|
36
|
+
pathRef.value = [];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
33
39
|
throw result;
|
|
34
40
|
}
|
|
35
41
|
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
|
|
2
2
|
export declare const throwNoneManualAbortError: (e: unknown) => void;
|
|
3
3
|
export declare const logNoneManualAbortError: (e: unknown) => void;
|
|
4
|
+
export declare const recoverablyIgnoreManualAbortReject: <T>(promise: Promise<T>) => {
|
|
5
|
+
recover: () => Promise<T>;
|
|
6
|
+
};
|
|
@@ -7,8 +7,30 @@ const logNoneManualAbortError = (e) => {
|
|
|
7
7
|
if (e !== MANUAL_ABORT_MESSAGE)
|
|
8
8
|
console.error(e);
|
|
9
9
|
};
|
|
10
|
+
function recoverablyIgnoreReject(promise, ignoreFilter) {
|
|
11
|
+
let isValid = true;
|
|
12
|
+
let error;
|
|
13
|
+
const ignoredPromise = promise.catch((err) => {
|
|
14
|
+
if (!isValid || !ignoreFilter(err))
|
|
15
|
+
throw err;
|
|
16
|
+
isValid = false;
|
|
17
|
+
error = err;
|
|
18
|
+
return void 0;
|
|
19
|
+
});
|
|
20
|
+
const recover = () => {
|
|
21
|
+
if (!isValid)
|
|
22
|
+
return Promise.reject(error);
|
|
23
|
+
isValid = false;
|
|
24
|
+
return ignoredPromise;
|
|
25
|
+
};
|
|
26
|
+
return { recover };
|
|
27
|
+
}
|
|
28
|
+
const recoverablyIgnoreManualAbortReject = (promise) => {
|
|
29
|
+
return recoverablyIgnoreReject(promise, (e) => e === MANUAL_ABORT_MESSAGE);
|
|
30
|
+
};
|
|
10
31
|
export {
|
|
11
32
|
MANUAL_ABORT_MESSAGE,
|
|
12
33
|
logNoneManualAbortError,
|
|
34
|
+
recoverablyIgnoreManualAbortReject,
|
|
13
35
|
throwNoneManualAbortError
|
|
14
36
|
};
|
package/dist/v2/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.5.
|
|
3
|
+
const pkgVersion = "2.5.1";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -227,6 +227,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
227
227
|
place,
|
|
228
228
|
inputPlace,
|
|
229
229
|
type,
|
|
230
|
+
zone,
|
|
230
231
|
isSameZone
|
|
231
232
|
}) => {
|
|
232
233
|
var _a;
|
|
@@ -242,6 +243,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
|
|
|
242
243
|
place,
|
|
243
244
|
inputPlace,
|
|
244
245
|
type,
|
|
246
|
+
zone,
|
|
245
247
|
isSameZone
|
|
246
248
|
}));
|
|
247
249
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, reactive } from "vue-demi";
|
|
2
2
|
import { GET_RECOMMEND_PLACE_TIMEOUT } from "../api/contants.js";
|
|
3
|
-
import { logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
3
|
+
import { recoverablyIgnoreManualAbortReject, logNoneManualAbortError } from "../utils/ManualAbortError.js";
|
|
4
4
|
import { createAbortableOneConcurrent, AbortSignalAny, equalAssign, isPlacesInclude, createAbortable } from "../utils/helper.js";
|
|
5
5
|
import { isZoneEqual, place2point, isPlaceEqual, businessCandidatesToAdsorptionPlace } from "../utils/transform.js";
|
|
6
6
|
import { assertNoConflictTypeAndZone } from "../utils/typeChecking.js";
|
|
@@ -103,7 +103,9 @@ const useMapRecomendPlace = (props) => {
|
|
|
103
103
|
const [lng, lat] = point;
|
|
104
104
|
const { type, zone, available, candidates } = prevState;
|
|
105
105
|
if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
|
|
106
|
-
const
|
|
106
|
+
const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
|
|
107
|
+
getPlaceByRegeo(point, opt)
|
|
108
|
+
);
|
|
107
109
|
const {
|
|
108
110
|
place: closestPlace,
|
|
109
111
|
candidates: candidates2,
|
|
@@ -114,7 +116,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
114
116
|
if (isPlacesInclude(candidates2, closestPlace)) {
|
|
115
117
|
return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
116
118
|
}
|
|
117
|
-
const regeoPlace = await
|
|
119
|
+
const regeoPlace = await reGeoPlacePromiseIgnored.recover();
|
|
118
120
|
return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
119
121
|
}
|
|
120
122
|
if (type === "Forbidden") {
|
|
@@ -12,7 +12,6 @@ const useMapAssertSupplier = () => {
|
|
|
12
12
|
const instanceSupplier = payload.supplier;
|
|
13
13
|
function assertSupplier(fn) {
|
|
14
14
|
return function fnWithAssertSupplier(...args) {
|
|
15
|
-
console.log("instanceSupplier, payload.supplier = ", instanceSupplier, payload.supplier);
|
|
16
15
|
if (instanceSupplier === payload.supplier)
|
|
17
16
|
return fn(...args);
|
|
18
17
|
throw Error(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { shallowRef } from "vue-demi";
|
|
2
2
|
import { watchPostEffectForDeepOption } from "../utils/compare.js";
|
|
3
3
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
4
|
+
const isIgnoredAmapWalkingRouteError = (err) => err === "RETURN_TIMEOUT";
|
|
4
5
|
const useAWalkingRoute = (props) => {
|
|
5
6
|
const pathRef = shallowRef([]);
|
|
6
7
|
const amapWalking = new AMap.Walking({});
|
|
@@ -30,6 +31,11 @@ const useAWalkingRoute = (props) => {
|
|
|
30
31
|
pathRef.value = [];
|
|
31
32
|
return;
|
|
32
33
|
default:
|
|
34
|
+
if (isIgnoredAmapWalkingRouteError(result)) {
|
|
35
|
+
console.warn(result);
|
|
36
|
+
pathRef.value = [];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
33
39
|
throw result;
|
|
34
40
|
}
|
|
35
41
|
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const MANUAL_ABORT_MESSAGE = "MANUAL_ABORT_MESSAGE";
|
|
2
2
|
export declare const throwNoneManualAbortError: (e: unknown) => void;
|
|
3
3
|
export declare const logNoneManualAbortError: (e: unknown) => void;
|
|
4
|
+
export declare const recoverablyIgnoreManualAbortReject: <T>(promise: Promise<T>) => {
|
|
5
|
+
recover: () => Promise<T>;
|
|
6
|
+
};
|
|
@@ -7,8 +7,30 @@ const logNoneManualAbortError = (e) => {
|
|
|
7
7
|
if (e !== MANUAL_ABORT_MESSAGE)
|
|
8
8
|
console.error(e);
|
|
9
9
|
};
|
|
10
|
+
function recoverablyIgnoreReject(promise, ignoreFilter) {
|
|
11
|
+
let isValid = true;
|
|
12
|
+
let error;
|
|
13
|
+
const ignoredPromise = promise.catch((err) => {
|
|
14
|
+
if (!isValid || !ignoreFilter(err))
|
|
15
|
+
throw err;
|
|
16
|
+
isValid = false;
|
|
17
|
+
error = err;
|
|
18
|
+
return void 0;
|
|
19
|
+
});
|
|
20
|
+
const recover = () => {
|
|
21
|
+
if (!isValid)
|
|
22
|
+
return Promise.reject(error);
|
|
23
|
+
isValid = false;
|
|
24
|
+
return ignoredPromise;
|
|
25
|
+
};
|
|
26
|
+
return { recover };
|
|
27
|
+
}
|
|
28
|
+
const recoverablyIgnoreManualAbortReject = (promise) => {
|
|
29
|
+
return recoverablyIgnoreReject(promise, (e) => e === MANUAL_ABORT_MESSAGE);
|
|
30
|
+
};
|
|
10
31
|
export {
|
|
11
32
|
MANUAL_ABORT_MESSAGE,
|
|
12
33
|
logNoneManualAbortError,
|
|
34
|
+
recoverablyIgnoreManualAbortReject,
|
|
13
35
|
throwNoneManualAbortError
|
|
14
36
|
};
|
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.5.
|
|
3
|
+
const pkgVersion = "2.5.1";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|