@heycar/heycars-map 2.4.6 → 2.5.0

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.
Files changed (52) hide show
  1. package/README.md +25 -9
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/v2/App.js +2 -4
  5. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +11 -6
  6. package/dist/v2/Demo/DemoBusinessReselectPlace.js +10 -5
  7. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  8. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  9. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  10. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
  11. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +17 -10
  12. package/dist/v2/business-components/GreenZone/GreenZone.d.ts +1 -0
  13. package/dist/v2/business-components/GreenZone/GreenZone.js +7 -5
  14. package/dist/v2/chunks/{BusinessRecomendPlaceMap.81a4b640.js → BusinessRecomendPlaceMap.d8f5b904.js} +18 -9
  15. package/dist/v2/components/MapProvider/MapProvider.js +13 -14
  16. package/dist/v2/hooks/useMapCoordinatify.js +6 -4
  17. package/dist/v2/hooks/useMapRecomendPlace.d.ts +3 -3
  18. package/dist/v2/hooks/useMapRecomendPlace.js +50 -40
  19. package/dist/v2/hooks/useMapSupplier.d.ts +1 -1
  20. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  21. package/dist/v2/index.js +1 -1
  22. package/dist/v2/types/gmap.d.ts +10 -0
  23. package/dist/v2/types/interface.d.ts +6 -3
  24. package/dist/v2/utils/log.js +1 -1
  25. package/dist/v2/utils/transform.js +1 -1
  26. package/dist/v2/utils/typeChecking.d.ts +5 -2
  27. package/dist/v2/utils/typeChecking.js +32 -4
  28. package/dist/v3/App.js +2 -4
  29. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +11 -6
  30. package/dist/v3/Demo/DemoBusinessReselectPlace.js +10 -5
  31. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -0
  32. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  33. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  34. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +1 -1
  35. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +17 -10
  36. package/dist/v3/business-components/GreenZone/GreenZone.d.ts +1 -0
  37. package/dist/v3/business-components/GreenZone/GreenZone.js +7 -5
  38. package/dist/v3/chunks/{BusinessRecomendPlaceMap.7133beea.js → BusinessRecomendPlaceMap.4c38b1fb.js} +18 -9
  39. package/dist/v3/components/MapProvider/MapProvider.js +13 -14
  40. package/dist/v3/hooks/useMapCoordinatify.js +6 -4
  41. package/dist/v3/hooks/useMapRecomendPlace.d.ts +3 -3
  42. package/dist/v3/hooks/useMapRecomendPlace.js +50 -40
  43. package/dist/v3/hooks/useMapSupplier.d.ts +1 -1
  44. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  45. package/dist/v3/index.js +1 -1
  46. package/dist/v3/types/gmap.d.ts +10 -0
  47. package/dist/v3/types/interface.d.ts +6 -3
  48. package/dist/v3/utils/log.js +1 -1
  49. package/dist/v3/utils/transform.js +1 -1
  50. package/dist/v3/utils/typeChecking.d.ts +5 -2
  51. package/dist/v3/utils/typeChecking.js +32 -4
  52. package/package.json +1 -1
@@ -33,7 +33,7 @@ export interface CoordinateZone extends Omit<Zone, "path"> {
33
33
  }
34
34
  export interface RecommendZonePlaces {
35
35
  adsorption?: boolean;
36
- force?: boolean;
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
- isInZone: boolean;
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,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.4.6";
3
+ const pkgVersion = "2.5.0";
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
- force?: boolean;
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 { force, available, zone, places, adsorption } = value;
82
+ const { type, available, zone, places, adsorption } = value;
83
+ assertNoConflictTypeAndZone(type, zone);
59
84
  return {
60
- force: !!force,
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.4.6",
3
+ "version": "2.5.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",