@heycar/heycars-map 2.4.6 → 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 +26 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/v2/App.js +2 -4
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +11 -6
- package/dist/v2/Demo/DemoBusinessReselectPlace.js +10 -5
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +19 -10
- package/dist/v2/business-components/GreenZone/GreenZone.d.ts +1 -0
- package/dist/v2/business-components/GreenZone/GreenZone.js +7 -5
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.81a4b640.js → BusinessRecomendPlaceMap.d8f5b904.js} +18 -9
- package/dist/v2/components/MapProvider/MapProvider.js +13 -14
- package/dist/v2/hooks/useMapCoordinatify.js +6 -4
- package/dist/v2/hooks/useMapRecomendPlace.d.ts +3 -3
- package/dist/v2/hooks/useMapRecomendPlace.js +55 -43
- package/dist/v2/hooks/useMapSupplier.d.ts +1 -1
- package/dist/v2/hooks/useMapSupplier.js +0 -1
- package/dist/v2/hooks/useWalkingRoute.js +6 -0
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/types/gmap.d.ts +10 -0
- package/dist/v2/types/interface.d.ts +6 -3
- 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/v2/utils/transform.js +1 -1
- package/dist/v2/utils/typeChecking.d.ts +5 -2
- package/dist/v2/utils/typeChecking.js +32 -4
- package/dist/v3/App.js +2 -4
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +11 -6
- package/dist/v3/Demo/DemoBusinessReselectPlace.js +10 -5
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +19 -10
- package/dist/v3/business-components/GreenZone/GreenZone.d.ts +1 -0
- package/dist/v3/business-components/GreenZone/GreenZone.js +7 -5
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.7133beea.js → BusinessRecomendPlaceMap.4c38b1fb.js} +18 -9
- package/dist/v3/components/MapProvider/MapProvider.js +13 -14
- package/dist/v3/hooks/useMapCoordinatify.js +6 -4
- package/dist/v3/hooks/useMapRecomendPlace.d.ts +3 -3
- package/dist/v3/hooks/useMapRecomendPlace.js +55 -43
- package/dist/v3/hooks/useMapSupplier.d.ts +1 -1
- package/dist/v3/hooks/useMapSupplier.js +0 -1
- package/dist/v3/hooks/useWalkingRoute.js +6 -0
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
- package/dist/v3/index.js +1 -1
- package/dist/v3/types/gmap.d.ts +10 -0
- package/dist/v3/types/interface.d.ts +6 -3
- 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/dist/v3/utils/transform.js +1 -1
- package/dist/v3/utils/typeChecking.d.ts +5 -2
- package/dist/v3/utils/typeChecking.js +32 -4
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
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
|
+
import { assertNoConflictTypeAndZone } from "../utils/typeChecking.js";
|
|
6
7
|
import { useMapGeometry, apiLocalIsPointInRing } from "./useMapGeometry.js";
|
|
7
8
|
import { useMapPlace } from "./useMapPlace.js";
|
|
9
|
+
const DEFAULT_RECOMMEND_TYPE = "Recommend";
|
|
8
10
|
function mergeGetRecommendPlaceAndGetAvailable(getRecomendPlace, getAvailable, timeout) {
|
|
9
11
|
return function mergedGetRecommendPlace(place, context) {
|
|
10
12
|
const available = true;
|
|
@@ -49,7 +51,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
49
51
|
onChangePlace
|
|
50
52
|
} = props;
|
|
51
53
|
const availableRef = ref(true);
|
|
52
|
-
const
|
|
54
|
+
const recommendTypeRef = ref(DEFAULT_RECOMMEND_TYPE);
|
|
53
55
|
const placeCandidatesRef = ref([]);
|
|
54
56
|
const zoneRef = ref();
|
|
55
57
|
const abortable = createAbortable(inputSignal);
|
|
@@ -77,16 +79,16 @@ const useMapRecomendPlace = (props) => {
|
|
|
77
79
|
places: placeCandidates,
|
|
78
80
|
zone,
|
|
79
81
|
available = false,
|
|
80
|
-
|
|
82
|
+
type = DEFAULT_RECOMMEND_TYPE,
|
|
81
83
|
adsorption = false
|
|
82
84
|
} = await getRecomendPlaceNoFail({ ...place }, context);
|
|
83
85
|
(_a = opt == null ? void 0 : opt.signal) == null ? void 0 : _a.throwIfAborted();
|
|
84
|
-
if (!available || !placeCandidates) {
|
|
85
|
-
return { place: { ...place }, zone, candidates: [], available,
|
|
86
|
+
if (!available || !placeCandidates || placeCandidates.length === 0) {
|
|
87
|
+
return { place: { ...place }, zone, candidates: [], available, type };
|
|
86
88
|
}
|
|
87
89
|
if (!zone) {
|
|
88
90
|
const resultPlace2 = adsorption ? businessCandidatesToAdsorptionPlace(placeCandidates) : place;
|
|
89
|
-
return { place: { ...resultPlace2 }, zone, candidates: placeCandidates, available,
|
|
91
|
+
return { place: { ...resultPlace2 }, zone, candidates: placeCandidates, available, type };
|
|
90
92
|
}
|
|
91
93
|
const { shortestPlace, shortestDistance } = findNearestPlace(
|
|
92
94
|
place,
|
|
@@ -95,42 +97,43 @@ const useMapRecomendPlace = (props) => {
|
|
|
95
97
|
);
|
|
96
98
|
const limit = getLimit(context);
|
|
97
99
|
const resultPlace = zone || shortestDistance <= limit ? shortestPlace : place;
|
|
98
|
-
return { place: { ...resultPlace }, zone, candidates: placeCandidates, available,
|
|
100
|
+
return { place: { ...resultPlace }, zone, candidates: placeCandidates, available, type };
|
|
99
101
|
};
|
|
100
102
|
const getRecommendPlaceZoneState = async (point, prevState, opt) => {
|
|
101
103
|
const [lng, lat] = point;
|
|
102
|
-
const zone =
|
|
104
|
+
const { type, zone, available, candidates } = prevState;
|
|
103
105
|
if (!zone || !apiLocalIsPointInRing(point, zone.path)) {
|
|
104
|
-
const
|
|
106
|
+
const reGeoPlacePromiseIgnored = recoverablyIgnoreManualAbortReject(
|
|
107
|
+
getPlaceByRegeo(point, opt)
|
|
108
|
+
);
|
|
105
109
|
const {
|
|
106
110
|
place: closestPlace,
|
|
107
|
-
candidates,
|
|
108
|
-
available,
|
|
109
|
-
|
|
111
|
+
candidates: candidates2,
|
|
112
|
+
available: available2,
|
|
113
|
+
type: type2,
|
|
110
114
|
zone: zone2
|
|
111
115
|
} = await findAttachedPlace({ lng, lat, name: "", displayName: "" }, opt);
|
|
112
|
-
if (isPlacesInclude(
|
|
113
|
-
return { place: { ...closestPlace }, zone: zone2, available, candidates,
|
|
116
|
+
if (isPlacesInclude(candidates2, closestPlace)) {
|
|
117
|
+
return { place: { ...closestPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
114
118
|
}
|
|
115
|
-
const regeoPlace = await
|
|
116
|
-
return { place: { ...regeoPlace }, zone: zone2, available, candidates,
|
|
119
|
+
const regeoPlace = await reGeoPlacePromiseIgnored.recover();
|
|
120
|
+
return { place: { ...regeoPlace }, zone: zone2, available: available2, candidates: candidates2, type: type2 };
|
|
121
|
+
}
|
|
122
|
+
if (type === "Forbidden") {
|
|
123
|
+
const regeoPlace = await getPlaceByRegeo(point, opt);
|
|
124
|
+
return { place: { ...regeoPlace }, zone, available, candidates, type };
|
|
117
125
|
}
|
|
118
126
|
const { shortestPlace: resultPlace } = findNearestPlace(
|
|
119
127
|
{ lng, lat, name: "", displayName: "" },
|
|
120
|
-
|
|
128
|
+
candidates,
|
|
121
129
|
apiMapDistance
|
|
122
130
|
);
|
|
123
|
-
return {
|
|
124
|
-
place: { ...resultPlace },
|
|
125
|
-
zone,
|
|
126
|
-
available: prevState.available,
|
|
127
|
-
force: prevState.force,
|
|
128
|
-
candidates: prevState.candidates
|
|
129
|
-
};
|
|
131
|
+
return { place: { ...resultPlace }, zone, type, available, candidates };
|
|
130
132
|
};
|
|
131
133
|
const updateIntermediateQueryingState = (point) => {
|
|
134
|
+
const type = recommendTypeRef.value;
|
|
132
135
|
const zone = zoneRef.value;
|
|
133
|
-
if (zone && apiLocalIsPointInRing(point, zone.path))
|
|
136
|
+
if (type === "Restricted" && zone && apiLocalIsPointInRing(point, zone.path))
|
|
134
137
|
return;
|
|
135
138
|
const [lng, lat] = point;
|
|
136
139
|
const intermediateQueryingPlace = {
|
|
@@ -141,8 +144,10 @@ const useMapRecomendPlace = (props) => {
|
|
|
141
144
|
};
|
|
142
145
|
isQueryingRef.value = true;
|
|
143
146
|
availableRef.value = true;
|
|
144
|
-
if (zone)
|
|
147
|
+
if (type === "Restricted" || type === "Forbidden" && (!zone || !apiLocalIsPointInRing(point, zone.path))) {
|
|
145
148
|
zoneRef.value = void 0;
|
|
149
|
+
recommendTypeRef.value = "Recommend";
|
|
150
|
+
}
|
|
146
151
|
placeCandidatesRef.value = [];
|
|
147
152
|
equalAssign(recomendPlace, { ...intermediateQueryingPlace });
|
|
148
153
|
onQueryingPlace == null ? void 0 : onQueryingPlace({ ...intermediateQueryingPlace });
|
|
@@ -156,13 +161,13 @@ const useMapRecomendPlace = (props) => {
|
|
|
156
161
|
candidates,
|
|
157
162
|
zone,
|
|
158
163
|
available,
|
|
159
|
-
|
|
164
|
+
type
|
|
160
165
|
} = await getRecommendPlaceZoneState(
|
|
161
166
|
point,
|
|
162
167
|
{
|
|
163
168
|
place: recomendPlace,
|
|
164
169
|
available: availableRef.value,
|
|
165
|
-
|
|
170
|
+
type: recommendTypeRef.value,
|
|
166
171
|
candidates: placeCandidatesRef.value,
|
|
167
172
|
zone: zoneRef.value
|
|
168
173
|
},
|
|
@@ -171,13 +176,13 @@ const useMapRecomendPlace = (props) => {
|
|
|
171
176
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
172
177
|
isQueryingRef.value = false;
|
|
173
178
|
availableRef.value = available;
|
|
174
|
-
|
|
179
|
+
recommendTypeRef.value = type;
|
|
175
180
|
zoneRef.value = zone;
|
|
176
181
|
placeCandidatesRef.value = candidates;
|
|
177
182
|
equalAssign(recomendPlace, { ...resultPlace });
|
|
178
183
|
onChangePlace == null ? void 0 : onChangePlace({ ...resultPlace });
|
|
179
184
|
const inputPlace = { name: "", displayName: "", lng: point[0], lat: point[1] };
|
|
180
|
-
onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace,
|
|
185
|
+
onChange == null ? void 0 : onChange({ place: { ...resultPlace }, inputPlace, type, zone, isSameZone });
|
|
181
186
|
},
|
|
182
187
|
{ silent: true }
|
|
183
188
|
);
|
|
@@ -188,19 +193,19 @@ const useMapRecomendPlace = (props) => {
|
|
|
188
193
|
places: placeCandidates,
|
|
189
194
|
zone,
|
|
190
195
|
available = false,
|
|
191
|
-
|
|
196
|
+
type = DEFAULT_RECOMMEND_TYPE
|
|
192
197
|
} = await getRecomendPlaceNoFail({ ...place }, context);
|
|
193
198
|
signal.throwIfAborted();
|
|
194
199
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
195
200
|
isQueryingRef.value = false;
|
|
196
201
|
availableRef.value = !!available;
|
|
197
|
-
|
|
202
|
+
recommendTypeRef.value = type;
|
|
198
203
|
zoneRef.value = zone;
|
|
199
204
|
placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
|
|
200
205
|
return {
|
|
201
206
|
inputPlace: { ...place },
|
|
202
|
-
isInZone: !!zone,
|
|
203
207
|
place: { ...place },
|
|
208
|
+
type,
|
|
204
209
|
isSameZone
|
|
205
210
|
};
|
|
206
211
|
};
|
|
@@ -210,13 +215,13 @@ const useMapRecomendPlace = (props) => {
|
|
|
210
215
|
place: resultPlace,
|
|
211
216
|
candidates,
|
|
212
217
|
available,
|
|
213
|
-
|
|
218
|
+
type,
|
|
214
219
|
zone
|
|
215
220
|
} = await findAttachedPlace(place, opt);
|
|
216
221
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
217
222
|
isQueryingRef.value = false;
|
|
218
223
|
availableRef.value = available;
|
|
219
|
-
|
|
224
|
+
recommendTypeRef.value = type;
|
|
220
225
|
zoneRef.value = zone;
|
|
221
226
|
placeCandidatesRef.value = candidates;
|
|
222
227
|
equalAssign(recomendPlace, { ...resultPlace });
|
|
@@ -224,7 +229,8 @@ const useMapRecomendPlace = (props) => {
|
|
|
224
229
|
onChange == null ? void 0 : onChange({
|
|
225
230
|
place: { ...resultPlace },
|
|
226
231
|
inputPlace: { ...place },
|
|
227
|
-
|
|
232
|
+
type,
|
|
233
|
+
zone,
|
|
228
234
|
isSameZone
|
|
229
235
|
});
|
|
230
236
|
};
|
|
@@ -235,14 +241,14 @@ const useMapRecomendPlace = (props) => {
|
|
|
235
241
|
place: foundPlace,
|
|
236
242
|
candidates,
|
|
237
243
|
available,
|
|
238
|
-
|
|
244
|
+
type,
|
|
239
245
|
zone
|
|
240
246
|
} = await findAttachedPlace(place, opt);
|
|
241
|
-
const resultPlace =
|
|
247
|
+
const resultPlace = type === "Restricted" ? foundPlace : (_a = candidates.find((p) => isPlaceEqual(p, place))) != null ? _a : place;
|
|
242
248
|
const isSameZone = !!zone && isZoneEqual(zone, zoneRef.value);
|
|
243
249
|
isQueryingRef.value = false;
|
|
244
250
|
availableRef.value = available;
|
|
245
|
-
|
|
251
|
+
recommendTypeRef.value = type;
|
|
246
252
|
zoneRef.value = zone;
|
|
247
253
|
placeCandidatesRef.value = candidates;
|
|
248
254
|
equalAssign(recomendPlace, { ...resultPlace });
|
|
@@ -250,13 +256,19 @@ const useMapRecomendPlace = (props) => {
|
|
|
250
256
|
onChange == null ? void 0 : onChange({
|
|
251
257
|
place: { ...resultPlace },
|
|
252
258
|
inputPlace: { ...place },
|
|
253
|
-
|
|
259
|
+
type,
|
|
260
|
+
zone,
|
|
254
261
|
isSameZone
|
|
255
262
|
});
|
|
256
263
|
};
|
|
257
|
-
const setPlaceCandidatesAndZone = ({
|
|
264
|
+
const setPlaceCandidatesAndZone = ({
|
|
265
|
+
type = DEFAULT_RECOMMEND_TYPE,
|
|
266
|
+
zone,
|
|
267
|
+
places: placeCandidates
|
|
268
|
+
}) => {
|
|
269
|
+
assertNoConflictTypeAndZone(type, zone);
|
|
258
270
|
availableRef.value = true;
|
|
259
|
-
|
|
271
|
+
recommendTypeRef.value = type;
|
|
260
272
|
zoneRef.value = zone ? zone : void 0;
|
|
261
273
|
placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
|
|
262
274
|
};
|
|
@@ -265,7 +277,7 @@ const useMapRecomendPlace = (props) => {
|
|
|
265
277
|
recomendPlace,
|
|
266
278
|
placeCandidates: placeCandidatesRef,
|
|
267
279
|
availableRef,
|
|
268
|
-
|
|
280
|
+
recommendTypeRef,
|
|
269
281
|
isQueryingRef,
|
|
270
282
|
updateRecommendPlace,
|
|
271
283
|
updateRecommendPlaceOnlyInZone,
|
|
@@ -2,7 +2,7 @@ import type { AnyFn } from "@vueuse/core";
|
|
|
2
2
|
import type { ConnectionStatus } from "../types/interface";
|
|
3
3
|
import type { Status, UseMapLoaderOutput, UseMapLoaderProps } from "./useMapLoader";
|
|
4
4
|
export interface MapSupplierPayolad extends UseMapLoaderProps {
|
|
5
|
-
gmapRasterId
|
|
5
|
+
gmapRasterId?: string;
|
|
6
6
|
gmapId: string;
|
|
7
7
|
readyPromise: UseMapLoaderOutput["readyPromise"];
|
|
8
8
|
status: Status;
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { reactive, ref, readonly } from "vue-demi";
|
|
2
|
-
import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.
|
|
2
|
+
import { E as EMPTY_PLACE } from "../chunks/BusinessRecomendPlaceMap.4c38b1fb.js";
|
|
3
3
|
import { CenterPlaceStatus } from "../types/interface.js";
|
|
4
4
|
import { proxyFunctionalProperty, assertAssingedBeforeUsed } from "../utils/helper.js";
|
|
5
5
|
const useBusinessRecomendPlaceMap = () => {
|
package/dist/v3/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isCoordinatePointEqual } from "./api/geometry.js";
|
|
|
3
3
|
import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
4
4
|
import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
|
|
5
5
|
import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
|
|
6
|
-
import { B } from "./chunks/BusinessRecomendPlaceMap.
|
|
6
|
+
import { B } from "./chunks/BusinessRecomendPlaceMap.4c38b1fb.js";
|
|
7
7
|
import { BusinessReselectPlaceMap } from "./business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js";
|
|
8
8
|
import { BusinessTaxiEndMap } from "./business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js";
|
|
9
9
|
import { BusinessTaxiServiceMap } from "./business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js";
|
package/dist/v3/types/gmap.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
declare global {
|
|
3
|
+
namespace google.maps {
|
|
4
|
+
interface MapOptions {
|
|
5
|
+
headingInteractionEnabled?: boolean;
|
|
6
|
+
tiltInteractionEnabled?: boolean;
|
|
7
|
+
renderingType?: RenderingType;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
1
11
|
export type GmapGeocoderAddressComponentType = "street_number" | "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
|
|
@@ -33,7 +33,7 @@ export interface CoordinateZone extends Omit<Zone, "path"> {
|
|
|
33
33
|
}
|
|
34
34
|
export interface RecommendZonePlaces {
|
|
35
35
|
adsorption?: boolean;
|
|
36
|
-
|
|
36
|
+
type?: RecommendType;
|
|
37
37
|
available?: boolean;
|
|
38
38
|
zone?: Zone;
|
|
39
39
|
places?: Place[];
|
|
@@ -43,14 +43,16 @@ export interface CoordinateRecommendZonePlaces extends Omit<RecommendZonePlaces,
|
|
|
43
43
|
places?: CoordinatePlace[];
|
|
44
44
|
}
|
|
45
45
|
export interface ValueOfOnChangeRecommendPlace {
|
|
46
|
+
type: RecommendType;
|
|
46
47
|
place: Place;
|
|
47
48
|
inputPlace: Place;
|
|
48
|
-
|
|
49
|
+
zone?: Zone;
|
|
49
50
|
isSameZone: boolean;
|
|
50
51
|
}
|
|
51
|
-
export interface CoordinateValueOfOnChangeRecommendPlace extends Omit<ValueOfOnChangeRecommendPlace, "place" | "inputPlace"> {
|
|
52
|
+
export interface CoordinateValueOfOnChangeRecommendPlace extends Omit<ValueOfOnChangeRecommendPlace, "place" | "inputPlace" | "zone"> {
|
|
52
53
|
place: CoordinatePlace;
|
|
53
54
|
inputPlace: CoordinatePlace;
|
|
55
|
+
zone?: CoordinateZone;
|
|
54
56
|
}
|
|
55
57
|
export interface GeoPosition {
|
|
56
58
|
position: Point;
|
|
@@ -86,6 +88,7 @@ export interface TrackPoint {
|
|
|
86
88
|
export interface CoordinateTrackPoint extends TrackPoint {
|
|
87
89
|
type: CoordinateType;
|
|
88
90
|
}
|
|
91
|
+
export type RecommendType = "Restricted" | "Forbidden" | "Recommend";
|
|
89
92
|
export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService" | "completed" | "canceling" | "banlanceRefund" | "waitBanlanceRefund" | "rechargePayed" | "waitRechargePay" | "payed" | "waitpay" | "refund" | "confirmed" | "assign" | "orderReassigned";
|
|
90
93
|
export declare enum CenterPlaceStatus {
|
|
91
94
|
GEO_LOADING = "GEO_LOADING",
|
|
@@ -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.
|
|
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}`);
|
|
@@ -74,7 +74,7 @@ const isGeoPositionEqual = (p1, p2) => {
|
|
|
74
74
|
return p1.coords.longitude === p2.coords.longitude && p1.coords.latitude === p2.coords.latitude;
|
|
75
75
|
};
|
|
76
76
|
const isZoneEqual = (z1, z2) => {
|
|
77
|
-
return z1.path.every((point, idx) => isPointEqual(point, z2 == null ? void 0 : z2.path[idx]));
|
|
77
|
+
return z1.name === (z2 == null ? void 0 : z2.name) && z1.path.every((point, idx) => isPointEqual(point, z2 == null ? void 0 : z2.path[idx]));
|
|
78
78
|
};
|
|
79
79
|
const amapPlaceName2DisplayName = (name, options) => {
|
|
80
80
|
const { isChina } = options;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone } from "../types/interface";
|
|
1
|
+
import type { CoordinatePlace, CoordinatePoint, CoordinateRecommendZonePlaces, CoordinateTrackPoint, CoordinateType, CoordinateZone, RecommendType } from "../types/interface";
|
|
2
2
|
export declare function isCoordinateType(type: unknown): type is CoordinateType;
|
|
3
|
+
export declare function isRecommendType(type: unknown): type is RecommendType;
|
|
4
|
+
export declare function toRecommendType(type: unknown): RecommendType;
|
|
3
5
|
interface MaybeCoordinatePlace {
|
|
4
6
|
displayName?: string;
|
|
5
7
|
name: string;
|
|
@@ -20,9 +22,10 @@ interface MaybeCoordinateZone {
|
|
|
20
22
|
path: MaybeCoordinatePoint[];
|
|
21
23
|
}
|
|
22
24
|
export declare const toCoordinateZoneType: (value?: MaybeCoordinateZone) => CoordinateZone;
|
|
25
|
+
export declare const assertNoConflictTypeAndZone: (type: unknown, zone: unknown) => void;
|
|
23
26
|
interface MaybeCoordinateRecomendZonePlaces {
|
|
24
27
|
adsorption?: boolean;
|
|
25
|
-
|
|
28
|
+
type?: string;
|
|
26
29
|
available?: boolean;
|
|
27
30
|
zone?: MaybeCoordinateZone;
|
|
28
31
|
places?: MaybeCoordinatePlace[];
|
|
@@ -11,6 +11,16 @@ const createTypeError = (typeName, value, detail) => {
|
|
|
11
11
|
function isCoordinateType(type) {
|
|
12
12
|
return type === "wgs84" || type === "gcj02" || type === "bd09";
|
|
13
13
|
}
|
|
14
|
+
function isRecommendType(type) {
|
|
15
|
+
return type === "Recommend" || type === "Restricted" || type === "Forbidden";
|
|
16
|
+
}
|
|
17
|
+
function toRecommendType(type) {
|
|
18
|
+
if (type === void 0)
|
|
19
|
+
return "Recommend";
|
|
20
|
+
if (isRecommendType(type))
|
|
21
|
+
return type;
|
|
22
|
+
throw createTypeError("RecommendType", type);
|
|
23
|
+
}
|
|
14
24
|
const toCoordinatePlaceType = (value) => {
|
|
15
25
|
var _a;
|
|
16
26
|
try {
|
|
@@ -48,16 +58,31 @@ const toCoordinateZoneType = (value) => {
|
|
|
48
58
|
const { name = "", path } = value;
|
|
49
59
|
if (!Array.isArray(path))
|
|
50
60
|
throw Error();
|
|
51
|
-
return { name, path: path.map(toCoordinatePointType) };
|
|
61
|
+
return { ...value, name, path: path.map(toCoordinatePointType) };
|
|
52
62
|
} catch (err) {
|
|
53
63
|
throw createTypeError("CoordinateZone", value, err == null ? void 0 : err.message);
|
|
54
64
|
}
|
|
55
65
|
};
|
|
66
|
+
const assertNoConflictTypeAndZone = (type, zone) => {
|
|
67
|
+
if (!!zone && type !== "Restricted" && type !== "Forbidden") {
|
|
68
|
+
throw Error(
|
|
69
|
+
`MyTypeError: zone exist, so expected type: Restricted | Forbidden, but received: ${JSON.stringify(
|
|
70
|
+
type
|
|
71
|
+
)}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (!zone && (type === "Restricted" || type === "Forbidden")) {
|
|
75
|
+
throw Error(
|
|
76
|
+
`MyTypeError: zone not exist, so expected type: Recommend | undefined, but received: ${type}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
56
80
|
const toCoordinateRecommendZonePlacesType = (value) => {
|
|
57
81
|
try {
|
|
58
|
-
const {
|
|
82
|
+
const { type, available, zone, places, adsorption } = value;
|
|
83
|
+
assertNoConflictTypeAndZone(type, zone);
|
|
59
84
|
return {
|
|
60
|
-
|
|
85
|
+
type: toRecommendType(type),
|
|
61
86
|
available: !!available,
|
|
62
87
|
zone: zone === void 0 ? void 0 : toCoordinateZoneType(zone),
|
|
63
88
|
places: places === void 0 ? void 0 : places.map(toCoordinatePlaceType),
|
|
@@ -81,11 +106,14 @@ const toCoordinateTrackPoint = (value) => {
|
|
|
81
106
|
return { lng, lat, type, angle, speed, timestamp };
|
|
82
107
|
};
|
|
83
108
|
export {
|
|
109
|
+
assertNoConflictTypeAndZone,
|
|
84
110
|
isCoordinatePoint,
|
|
85
111
|
isCoordinateType,
|
|
112
|
+
isRecommendType,
|
|
86
113
|
toCoordinatePlaceType,
|
|
87
114
|
toCoordinatePointType,
|
|
88
115
|
toCoordinateRecommendZonePlacesType,
|
|
89
116
|
toCoordinateTrackPoint,
|
|
90
|
-
toCoordinateZoneType
|
|
117
|
+
toCoordinateZoneType,
|
|
118
|
+
toRecommendType
|
|
91
119
|
};
|