@heycar/heycars-map 0.3.7 → 0.3.8

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 (174) hide show
  1. package/dist/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +1 -2
  2. package/dist/business-components/AddressBox/AddressBox.d.ts +1 -2
  3. package/dist/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +1 -0
  4. package/dist/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +1 -2
  5. package/dist/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +1 -2
  6. package/dist/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +2 -3
  7. package/dist/business-components/DrivingLine/DrivingLine.d.ts +1 -2
  8. package/dist/business-components/DrivingRoute/DrivingRoute.d.ts +1 -2
  9. package/dist/business-components/PassengerCircle/PassengerCircle.d.ts +1 -2
  10. package/dist/business-components/PickupPoints/PickupPoints.d.ts +1 -2
  11. package/dist/business-components/PlaceCircle/PlaceCircle.d.ts +1 -2
  12. package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +1 -2
  13. package/dist/business-components/TaxiCar/TaxiCar.d.ts +1 -2
  14. package/dist/business-components/WalkingLine/WalkingLine.d.ts +1 -2
  15. package/dist/business-components/WalkingRoute/WalkingRoute.d.ts +1 -2
  16. package/dist/business-components/WaveCircle/WaveCircle.d.ts +1 -2
  17. package/dist/components/Gmap/Gmap.d.ts +0 -2
  18. package/dist/components/MapProvider/MapProvider.d.ts +1 -4
  19. package/dist/hooks/useMapAutoComplete.d.ts +1 -2
  20. package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +1 -2
  21. package/dist/index.cjs +55 -55
  22. package/dist/index.js +1966 -2061
  23. package/package.json +1 -1
  24. package/todo.md +16 -4
  25. package/dist/Demo/CityBound/SearchDemo.d.ts +0 -1
  26. package/dist/Demo/CityBound/country.d.ts +0 -5
  27. package/dist/Demo/CityBound/searchResult.d.ts +0 -8
  28. package/dist/hooks/useMapLog.d.ts +0 -5
  29. package/src/App.tsx +0 -27
  30. package/src/Demo/CityBound/SearchDemo.tsx +0 -142
  31. package/src/Demo/CityBound/country.ts +0 -4179
  32. package/src/Demo/CityBound/searchResult.ts +0 -21122
  33. package/src/Demo/Demo.css.ts +0 -6
  34. package/src/Demo/Demo.tsx +0 -97
  35. package/src/Demo/DemoBusinessQuoting.tsx +0 -18
  36. package/src/Demo/DemoBusinessRecomendPlace.tsx +0 -89
  37. package/src/Demo/DemoBusinessTaxiEnd.tsx +0 -38
  38. package/src/Demo/DemoBusinessTaxiService.tsx +0 -58
  39. package/src/Demo/sample.json +0 -793
  40. package/src/api/contants.ts +0 -3
  41. package/src/api/driving.ts +0 -87
  42. package/src/api/geocoder.ts +0 -88
  43. package/src/api/geometry.ts +0 -44
  44. package/src/api/place.ts +0 -105
  45. package/src/assets/icons/svg/address-locator.svg +0 -1
  46. package/src/assets/icons/svg/arrow-right.svg +0 -1
  47. package/src/assets/icons/svg/end-point.svg +0 -1
  48. package/src/assets/icons/svg/passenger-circle.svg +0 -1
  49. package/src/assets/icons/svg/place-circle.svg +0 -22
  50. package/src/assets/icons/svg/start-point.svg +0 -1
  51. package/src/assets/icons/svg/taxi-car.svg +0 -1
  52. package/src/assets/icons/svg/wave-circle.svg +0 -1
  53. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.ts +0 -68
  54. package/src/business-components/AbsoluteAddressBox/AbsoluteAddressBox.tsx +0 -50
  55. package/src/business-components/AbsoluteAddressBox/index.ts +0 -1
  56. package/src/business-components/AddressBox/AddressBox.css.ts +0 -55
  57. package/src/business-components/AddressBox/AddressBox.tsx +0 -76
  58. package/src/business-components/AddressBox/index.ts +0 -1
  59. package/src/business-components/AddressLocator/AddressLocator.css.ts +0 -7
  60. package/src/business-components/AddressLocator/AddressLocator.tsx +0 -40
  61. package/src/business-components/AddressLocator/index.ts +0 -1
  62. package/src/business-components/BusinessQuotingMap/BusinessQuotingMap.tsx +0 -49
  63. package/src/business-components/BusinessQuotingMap/index.ts +0 -1
  64. package/src/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.tsx +0 -218
  65. package/src/business-components/BusinessRecomendPlaceMap/index.ts +0 -1
  66. package/src/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.tsx +0 -43
  67. package/src/business-components/BusinessTaxiEndMap/index.ts +0 -1
  68. package/src/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.tsx +0 -453
  69. package/src/business-components/BusinessTaxiServiceMap/index.ts +0 -1
  70. package/src/business-components/DrivingLine/DrivingLine.css.ts +0 -10
  71. package/src/business-components/DrivingLine/DrivingLine.tsx +0 -135
  72. package/src/business-components/DrivingLine/index.ts +0 -1
  73. package/src/business-components/DrivingRoute/DrivingRoute.tsx +0 -52
  74. package/src/business-components/DrivingRoute/index.ts +0 -1
  75. package/src/business-components/FitView/FitView.tsx +0 -22
  76. package/src/business-components/FitView/index.ts +0 -1
  77. package/src/business-components/PassengerCircle/PassengerCircle.css.ts +0 -21
  78. package/src/business-components/PassengerCircle/PassengerCircle.tsx +0 -69
  79. package/src/business-components/PassengerCircle/index.ts +0 -1
  80. package/src/business-components/PickupPoints/PickupPoints.tsx +0 -38
  81. package/src/business-components/PickupPoints/index.ts +0 -1
  82. package/src/business-components/PlaceCircle/PlaceCircle.css.ts +0 -76
  83. package/src/business-components/PlaceCircle/PlaceCircle.tsx +0 -110
  84. package/src/business-components/PlaceCircle/index.ts +0 -1
  85. package/src/business-components/StartEndPoint/StartEndPoint.css.ts +0 -70
  86. package/src/business-components/StartEndPoint/StartEndPoint.tsx +0 -122
  87. package/src/business-components/StartEndPoint/index.ts +0 -1
  88. package/src/business-components/TaxiCar/TaxiCar.css.ts +0 -16
  89. package/src/business-components/TaxiCar/TaxiCar.tsx +0 -93
  90. package/src/business-components/TaxiCar/index.ts +0 -1
  91. package/src/business-components/WalkingLine/WalkingLine.tsx +0 -80
  92. package/src/business-components/WalkingLine/index.ts +0 -1
  93. package/src/business-components/WalkingRoute/WalkingRoute.tsx +0 -43
  94. package/src/business-components/WalkingRoute/index.ts +0 -1
  95. package/src/business-components/WaveCircle/WaveCircle.css.ts +0 -54
  96. package/src/business-components/WaveCircle/WaveCircle.tsx +0 -59
  97. package/src/business-components/WaveCircle/index.ts +0 -1
  98. package/src/components/Amap/Amap.css.ts +0 -5
  99. package/src/components/Amap/Amap.ts +0 -76
  100. package/src/components/Amap/index.ts +0 -1
  101. package/src/components/AmapInfoWindow/AmapInfoWindow.ts +0 -45
  102. package/src/components/AmapInfoWindow/index.ts +0 -1
  103. package/src/components/AmapLoader/AmapLoader.ts +0 -20
  104. package/src/components/AmapLoader/index.ts +0 -1
  105. package/src/components/AmapMarker/AmapMarker.ts +0 -48
  106. package/src/components/AmapMarker/index.ts +0 -1
  107. package/src/components/AmapPolygon/AmapPolygon.ts +0 -41
  108. package/src/components/AmapPolygon/index.ts +0 -1
  109. package/src/components/AmapPolyline/AmapPolyline.ts +0 -40
  110. package/src/components/AmapPolyline/index.ts +0 -1
  111. package/src/components/AmapText/AmapText.ts +0 -39
  112. package/src/components/AmapText/index.ts +0 -1
  113. package/src/components/Gmap/Gmap.css.ts +0 -10
  114. package/src/components/Gmap/Gmap.ts +0 -54
  115. package/src/components/Gmap/index.ts +0 -1
  116. package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +0 -63
  117. package/src/components/GmapAdvancedMarkerView/index.ts +0 -1
  118. package/src/components/GmapInfoWindow/GmapInfoWindow.ts +0 -38
  119. package/src/components/GmapInfoWindow/index.ts +0 -1
  120. package/src/components/GmapLoader/GmapLoader.ts +0 -21
  121. package/src/components/GmapLoader/index.ts +0 -1
  122. package/src/components/GmapMarker/GmapMarker.ts +0 -34
  123. package/src/components/GmapMarker/index.ts +0 -1
  124. package/src/components/GmapPolygon/GmapPolygon.ts +0 -29
  125. package/src/components/GmapPolygon/index.ts +0 -1
  126. package/src/components/GmapPolyline/GmapPolyline.ts +0 -29
  127. package/src/components/GmapPolyline/index.ts +0 -1
  128. package/src/components/MapProvider/MapProvider.tsx +0 -83
  129. package/src/components/MapProvider/index.ts +0 -1
  130. package/src/hooks/useDrivingRoute.ts +0 -106
  131. package/src/hooks/useGeoLocation.ts +0 -70
  132. package/src/hooks/useHeycarMap.ts +0 -28
  133. package/src/hooks/useMap.ts +0 -43
  134. package/src/hooks/useMapAngle.ts +0 -42
  135. package/src/hooks/useMapAutoComplete.ts +0 -130
  136. package/src/hooks/useMapCityBound.ts +0 -64
  137. package/src/hooks/useMapDrag.ts +0 -72
  138. package/src/hooks/useMapEventSource.ts +0 -20
  139. package/src/hooks/useMapFitView.ts +0 -135
  140. package/src/hooks/useMapGeometry.ts +0 -27
  141. package/src/hooks/useMapLngLatToVw.ts +0 -31
  142. package/src/hooks/useMapLoader.ts +0 -164
  143. package/src/hooks/useMapLog.ts +0 -24
  144. package/src/hooks/useMapPlace.ts +0 -138
  145. package/src/hooks/useMapRecomendPlace.ts +0 -150
  146. package/src/hooks/useMapSupplier.ts +0 -16
  147. package/src/hooks/useOverlay.ts +0 -23
  148. package/src/hooks/usePlacesLabelDirection.ts +0 -61
  149. package/src/hooks/useUdate.ts +0 -9
  150. package/src/hooks/useWaitTimer.ts +0 -25
  151. package/src/hooks/useWalkingRoute.ts +0 -87
  152. package/src/hooks-business/useBusinessMapAutoComplete.ts +0 -22
  153. package/src/hooks-business/useBusinessQuotingMap.ts +0 -11
  154. package/src/hooks-business/useBusinessRecomendPlaceMap.ts +0 -45
  155. package/src/hooks-business/useBusinessTaxiServiceMap.ts +0 -12
  156. package/src/index.ts +0 -33
  157. package/src/main.ts +0 -6
  158. package/src/style.css +0 -0
  159. package/src/types/amap/autocomplete.d.ts +0 -64
  160. package/src/types/amap/driving.d.ts +0 -170
  161. package/src/types/amap/geocoder.d.ts +0 -217
  162. package/src/types/amap/marker.ts +0 -11
  163. package/src/types/amap/place.d.ts +0 -114
  164. package/src/types/amap/plugin.d.ts +0 -27
  165. package/src/types/amap/walking.d.ts +0 -78
  166. package/src/types/global.d.ts +0 -10
  167. package/src/types/helper.ts +0 -172
  168. package/src/types/interface.ts +0 -62
  169. package/src/types/mapHelper.ts +0 -1
  170. package/src/utils/compare.ts +0 -189
  171. package/src/utils/dom.ts +0 -14
  172. package/src/utils/helper.ts +0 -5
  173. package/src/utils/transform.ts +0 -68
  174. package/src/vite-env.d.ts +0 -12
@@ -1,172 +0,0 @@
1
- import "@amap/amap-jsapi-types";
2
- import { kebabCase } from "lodash-es";
3
- import { DefineComponent, defineComponent, h, SetupContext, VNode } from "vue-demi";
4
-
5
- // vue2
6
- import type { VNodeChildren } from "vue/types/umd";
7
- import type { ComponentOptionsBase } from "vue/types/v3-component-options";
8
- import type { ComponentObjectPropsOptions } from "vue/types/v3-component-props";
9
- import type { EmitFn, ObjectEmitsOptions, Slot } from "vue/types/v3-setup-context";
10
- export type VNodeChild = VNode | VNodeChildren;
11
- export type VueNode = VNode | null | undefined;
12
-
13
- // vue3
14
- // export type { VNodeChild } from "vue";
15
-
16
- type LagecyPropNames<N> = N extends `on${string}` ? never : N;
17
- export type EmitByProps<T, R = Required<T>> = {
18
- [K in keyof R as K extends `on${infer N}` ? Uncapitalize<N> : never]: R[K];
19
- };
20
- export type EmitPayloadByProps<T, R = Required<T>> = {
21
- [K in keyof R as K extends `on${infer N}` ? Uncapitalize<N> : never]: R[K] extends (
22
- props: infer P
23
- ) => any
24
- ? P
25
- : never;
26
- };
27
- type RenderFunction = (...args: any[]) => VNodeChild;
28
- export type SC<P> = Omit<SetupContext<Extract<EmitByProps<P>, ObjectEmitsOptions>>, "slots"> & {
29
- slots: {
30
- [K in keyof P as Exclude<P[K], undefined> extends RenderFunction
31
- ? K extends `on${string}`
32
- ? never
33
- : K
34
- : never]: P[K];
35
- } & { default?: Slot };
36
- };
37
- // SetupContextEmitHandler 是通用处理函数的类型,不是严格意义的重载类型
38
- export type SetupContextEmitHandler<P, E = EmitPayloadByProps<P>> = (
39
- eventName: keyof E,
40
- payload: E[keyof E]
41
- ) => any;
42
- export type SetupOptions<P> = ComponentOptionsBase<
43
- P,
44
- Empty,
45
- Empty,
46
- Empty,
47
- Empty,
48
- Empty,
49
- Empty,
50
- Extract<EmitByProps<P>, ObjectEmitsOptions>,
51
- Extract<keyof EmitByProps<P>, string>,
52
- Empty
53
- >;
54
-
55
- export type Empty = Record<string, never>;
56
-
57
- export function defineFc<P = Empty>(render: (props: P, ctx: SC<P>) => VueNode) {
58
- return defineComponent({
59
- name: render.name,
60
- inheritAttrs: false,
61
- setup(_, ctx) {
62
- const { attrs, slots, emit } = ctx;
63
- const originEmit = emit as EmitFn;
64
- const emitKebab = (eventName: string, data: any) => {
65
- const kebabName = kebabCase(eventName);
66
- originEmit(eventName, data);
67
- if (eventName !== kebabName) originEmit(kebabName, data);
68
- };
69
- const props = attrs as unknown as P;
70
- // todo: 下面是实时订阅的实现,是否不需要。
71
- const proxiedSlots = new Proxy(slots, {
72
- get(target, name, receiver) {
73
- return Reflect.get(target, name, receiver) ?? Reflect.get(props as any, name);
74
- },
75
- });
76
- return () =>
77
- render(props, { ...ctx, slots: proxiedSlots, emit: emitKebab } as unknown as SC<P>);
78
- },
79
- }) as DefineComponent<
80
- ComponentObjectPropsOptions<P>,
81
- Empty,
82
- Empty,
83
- Empty,
84
- Empty,
85
- Empty,
86
- Empty,
87
- Extract<EmitByProps<P>, ObjectEmitsOptions>,
88
- Extract<keyof EmitByProps<P>, string>,
89
- P
90
- >;
91
- }
92
-
93
- export function defineSetup<P>(setup: (props: P, ctx: SC<P>) => () => VueNode) {
94
- return defineComponent({
95
- name: setup.name,
96
- inheritAttrs: false,
97
- setup(_, ctx) {
98
- const { attrs, slots, emit } = ctx;
99
- const props = attrs as unknown as P;
100
- const originEmit = emit as EmitFn;
101
- const emitKebab = (eventName: string, data: any) => {
102
- const kebabName = kebabCase(eventName);
103
- originEmit(eventName, data);
104
- if (eventName !== kebabName) originEmit(kebabName, data);
105
- };
106
- const proxiedSlots = new Proxy(slots, {
107
- get(target, name, receiver) {
108
- return Reflect.get(target, name, receiver) ?? Reflect.get(props as any, name);
109
- },
110
- });
111
- return setup(props, { ...ctx, slots: proxiedSlots, emit: emitKebab } as unknown as SC<P>);
112
- },
113
- }) as DefineComponent<
114
- ComponentObjectPropsOptions<P>,
115
- Empty,
116
- Empty,
117
- Empty,
118
- Empty,
119
- Empty,
120
- Empty,
121
- Extract<EmitByProps<P>, ObjectEmitsOptions>,
122
- Extract<keyof EmitByProps<P>, string>,
123
- P
124
- >;
125
- }
126
-
127
- export function defineLagecySetup<P>(setup: (props: P, ctx: SC<P>) => () => VueNode) {
128
- return {
129
- props: (propNames: LagecyPropNames<keyof P>[]) => {
130
- return defineComponent({
131
- name: setup.name,
132
- inheritAttrs: false,
133
- props: propNames as string[],
134
- setup(setupProps, ctx) {
135
- const props = setupProps as P;
136
- const { slots, emit } = ctx;
137
- const originEmit = emit as EmitFn;
138
- const emitKebab = (eventName: string, data: any) => {
139
- const kebabName = kebabCase(eventName);
140
- originEmit(eventName, data);
141
- if (eventName !== kebabName) originEmit(kebabName, data);
142
- };
143
- const proxiedSlots = new Proxy(slots, {
144
- get(target, name, receiver) {
145
- return Reflect.get(target, name, receiver) ?? Reflect.get(props as any, name);
146
- },
147
- });
148
- return setup(props, { ...ctx, slots: proxiedSlots, emit: emitKebab } as unknown as SC<P>);
149
- },
150
- }) as DefineComponent<
151
- ComponentObjectPropsOptions<P>,
152
- Empty,
153
- Empty,
154
- Empty,
155
- Empty,
156
- Empty,
157
- Empty,
158
- Extract<EmitByProps<P>, ObjectEmitsOptions>,
159
- Extract<keyof EmitByProps<P>, string>,
160
- P
161
- >;
162
- },
163
- };
164
- }
165
-
166
- // eslint-disable-next-line @typescript-eslint/no-empty-function
167
- export function Noop() {}
168
-
169
- export const createElement = h;
170
-
171
- // todo 从 provider 那边去设置
172
- export const LANGUAGE = "zh-CN";
@@ -1,62 +0,0 @@
1
- import type { ShallowRef } from "vue-demi";
2
-
3
- export type Point = [number, number];
4
- export type MapShallowRef<M = AMap.Map | google.maps.Map> = ShallowRef<M | undefined>;
5
- export type Place = {
6
- lng: number;
7
- lat: number;
8
- name: string;
9
- cityName?: string;
10
- cityParentName?: string;
11
- countryName?: string;
12
- };
13
-
14
- export interface AutoCompletePlace extends Place {
15
- placeId?: string;
16
- description: string;
17
- distance?: number;
18
- }
19
-
20
- export type Region = {
21
- bound?: {
22
- east: number;
23
- north: number;
24
- south: number;
25
- west: number;
26
- };
27
- name: string;
28
- };
29
-
30
- export interface RegisterOverlay<T> {
31
- add: (overlay: T) => void;
32
- remove: (overlay: T) => void;
33
- setFitView: () => void;
34
- }
35
-
36
- export interface Route {
37
- path: Point[];
38
- distance: number;
39
- duration: number;
40
- }
41
-
42
- export type DriverStatus =
43
- | "dispatching"
44
- | "book-dispatching"
45
- | "dispatched"
46
- | "driverStartService"
47
- | "book-driverStartService"
48
- | "book-dispatched"
49
- | "driverArrived"
50
- | "inService"
51
- | "canceled"
52
- | "endService"
53
- | "completed"
54
- | "canceling"
55
- | "banlanceRefund"
56
- | "waitBanlanceRefund"
57
- | "rechargePayed"
58
- | "waitRechargePay"
59
- | "payed"
60
- | "waitpay"
61
- | "refund"
62
- | "confirmed";
@@ -1 +0,0 @@
1
- export type MapEventHandler<T> = (e: { target: T }) => any;
@@ -1,189 +0,0 @@
1
- import { isLatLngLiteral } from "@googlemaps/typescript-guards";
2
- import { createCustomEqual } from "fast-equals";
3
- import { watch, WatchCallback, watchPostEffect } from "vue-demi";
4
- import type { Ref, ShallowRef, WatchOptions } from "vue/types/v3-generated";
5
- import type { EmitFn } from "vue/types/v3-setup-context";
6
- import type { EmitByProps } from "../types/helper";
7
- import { property2emitEventName, property2mapEventName } from "./transform";
8
-
9
- export const deepCompareEqualsForMaps = createCustomEqual((deepEqual) => (a, b) => {
10
- if (isLatLngLiteral(a) || isLatLngLiteral(b)) {
11
- return new google.maps.LatLng(a).equals(new google.maps.LatLng(b));
12
- }
13
-
14
- // TODO extend to other types
15
-
16
- // use fast-equals for other objects
17
- return deepEqual(a, b);
18
- });
19
-
20
- export function createDeepCompareMemoize<T>() {
21
- let prev: T | undefined = undefined;
22
-
23
- return function memorizedFilter(value: T): T {
24
- if (!deepCompareEqualsForMaps(value, prev)) {
25
- prev = value;
26
- }
27
- return prev as T;
28
- };
29
- }
30
-
31
- export function useDeepCompareEffectForMaps(callback: () => () => any, dependencies: any[]) {
32
- const memorizedGetters = dependencies.map(createDeepCompareMemoize);
33
- watch(memorizedGetters, (value, prev, onClean) => {
34
- onClean(callback());
35
- });
36
- }
37
-
38
- export function watchNoneImmediatePostEffectForDeepOption<T>(
39
- getOption: () => T,
40
- callback: WatchCallback<T, T>,
41
- watchOptions?: WatchOptions<false>
42
- ) {
43
- const memorizedFilter = createDeepCompareMemoize<T>();
44
- return watch<T, false>(() => memorizedFilter(getOption()), callback, {
45
- immediate: false,
46
- flush: "post",
47
- ...watchOptions,
48
- });
49
- }
50
-
51
- export function watchPostEffectForDeepOption<T>(
52
- getOption: () => T,
53
- callback: WatchCallback<T, T | undefined>,
54
- watchOptions?: WatchOptions<true>
55
- ) {
56
- const memorizedFilter = createDeepCompareMemoize<T>();
57
- return watch<T, true>(() => memorizedFilter(getOption()), callback, {
58
- immediate: true,
59
- flush: "post",
60
- ...watchOptions,
61
- });
62
- }
63
-
64
- export function watchEffectForDeepOption<T>(
65
- getOption: () => T,
66
- callback: WatchCallback<T, T | undefined>,
67
- watchOptions?: WatchOptions<true>
68
- ) {
69
- const memorizedFilter = createDeepCompareMemoize<T>();
70
- return watch<T, true>(() => memorizedFilter(getOption()), callback, {
71
- immediate: true,
72
- ...watchOptions,
73
- });
74
- }
75
-
76
- function name2setterName<N extends string>(name: N) {
77
- return `set${name.charAt(0).toUpperCase()}${name.slice(1)}`;
78
- }
79
- type AnyFunction = (...args: any[]) => any;
80
- type PickSettableOptions<T, S, K extends keyof T = keyof T> = K extends `set${infer N}`
81
- ? Uncapitalize<N> extends S
82
- ? {
83
- name: Uncapitalize<N>;
84
- defaultValue?: T[K] extends AnyFunction ? Parameters<T[K]>[0] : never;
85
- }
86
- : never
87
- : never;
88
-
89
- export function watchPostEffectForMapProperty<T, P>(
90
- targetRef: ShallowRef<T | undefined> | Ref<T | undefined>,
91
- props: P,
92
- nameOptions: PickSettableOptions<T, keyof P>[],
93
- watchOptions?: WatchOptions<true>
94
- ) {
95
- const deps = nameOptions.map(
96
- ({ name }) =>
97
- () =>
98
- props[name]
99
- );
100
- watch(
101
- deps,
102
- (values, prevValues) => {
103
- const target = targetRef.value;
104
- if (!target) return;
105
- for (const [idx, value] of values.entries()) {
106
- const { name, defaultValue } = nameOptions[idx];
107
- const prev = prevValues[idx];
108
- if (!deepCompareEqualsForMaps(value, prev)) {
109
- (target[name2setterName(name) as keyof T] as any)(value ?? defaultValue);
110
- }
111
- }
112
- },
113
- {
114
- immediate: true,
115
- flush: "post",
116
- ...watchOptions,
117
- }
118
- );
119
- }
120
-
121
- export function watchNoneImmediatePostEffectForMapProperty<T, P>(
122
- targetRef: ShallowRef<T | undefined> | Ref<T | undefined>,
123
- props: P,
124
- nameOptions: PickSettableOptions<T, keyof P>[],
125
- watchOptions?: WatchOptions<false>
126
- ) {
127
- return watchPostEffectForMapProperty(targetRef, props, nameOptions, {
128
- immediate: false,
129
- ...watchOptions,
130
- } as unknown as WatchOptions<true>);
131
- }
132
-
133
- type NamesRestrict<N, S extends string> = N extends `on${string}`
134
- ? Lowercase<N> extends `on${S}`
135
- ? N
136
- : never
137
- : never;
138
- export function watchPostEffectForAMapEvent<
139
- T extends AMap.Event,
140
- P,
141
- E extends string = AMap.EventType
142
- >(
143
- targetRef: ShallowRef<T | undefined> | Ref<T | undefined> | undefined,
144
- props: P,
145
- emit: EmitFn<EmitByProps<P>>,
146
- propertyNames: NamesRestrict<keyof P, E>[]
147
- ) {
148
- watchPostEffect((onCleanup) => {
149
- const target = targetRef?.value;
150
- if (!target) return;
151
- const cleanList: (() => void)[] = [];
152
- for (const name of propertyNames) {
153
- const emitEventName = property2emitEventName(name);
154
- const eventName = property2mapEventName(name) as AMap.EventType;
155
- const handler = (e: any) => (emit as EmitFn)(emitEventName, e);
156
- target.on(eventName, handler);
157
- cleanList.push(() => target?.off(eventName, handler));
158
- }
159
- onCleanup(() => {
160
- for (const clean of cleanList) clean();
161
- });
162
- });
163
- }
164
-
165
- export function watchPostEffectForGMapEvent<
166
- T extends google.maps.MVCObject | google.maps.marker.AdvancedMarkerView,
167
- P
168
- >(
169
- targetRef: ShallowRef<T | undefined> | Ref<T | undefined> | undefined,
170
- props: P,
171
- emit: EmitFn<EmitByProps<P>>,
172
- propertyNames: NamesRestrict<keyof P, string>[]
173
- ) {
174
- watchPostEffect((onCleanup) => {
175
- const target = targetRef?.value;
176
- if (!target) return;
177
- const cleanList: (() => void)[] = [];
178
- for (const name of propertyNames) {
179
- const emitEventName = property2emitEventName(name);
180
- const eventName = property2mapEventName(name);
181
- const handler = (e: any) => (emit as EmitFn)(emitEventName, e);
182
- const listener = target.addListener(eventName, handler);
183
- cleanList.push(() => google.maps.event.removeListener(listener));
184
- }
185
- onCleanup(() => {
186
- for (const clean of cleanList) clean();
187
- });
188
- });
189
- }
package/src/utils/dom.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { HTMLAttributes, ImgHTMLAttributes } from "vue/types/jsx";
2
-
3
- export const createDom = (
4
- tag: string,
5
- props?: HTMLAttributes | ImgHTMLAttributes,
6
- innerHtml?: string
7
- ) => {
8
- const { class: className, ...restProps } = props ?? {};
9
- const elm = document.createElement(tag);
10
- if (className) elm.className = className;
11
- Object.assign(elm, restProps);
12
- if (innerHtml) elm.innerHTML = innerHtml;
13
- return elm;
14
- };
@@ -1,5 +0,0 @@
1
- import type { Place } from "../types/interface";
2
-
3
- export const isPlace = (place: Partial<Place>): place is Place => {
4
- return place.lng !== undefined && place.lat !== undefined;
5
- };
@@ -1,68 +0,0 @@
1
- import type { Place, Point } from "../types/interface";
2
-
3
- export const vec2lnglat = ([lng, lat]: [number, number]): google.maps.LatLngLiteral => ({
4
- lng,
5
- lat,
6
- });
7
-
8
- export interface AsteriskItem {
9
- type: "normal" | "emphasize";
10
- value: string;
11
- }
12
- export const decodeAsterisk = (encodedValue: string): AsteriskItem[] => {
13
- const result: AsteriskItem[] = [];
14
- const tokens = encodedValue.split("*");
15
- for (const [idx, token] of tokens.entries()) {
16
- if (!token) continue;
17
- result.push({ value: token, type: idx % 2 === 0 ? "normal" : "emphasize" });
18
- }
19
- return result;
20
- };
21
-
22
- export const property2emitEventName = (propertyName: string) => {
23
- const firstLetter = propertyName.charAt(2).toLocaleLowerCase();
24
- return `${firstLetter}${propertyName.slice(3)}`;
25
- };
26
-
27
- export const property2mapEventName = (propertyName: string) => {
28
- return propertyName.slice(2).toLowerCase();
29
- };
30
-
31
- export type VectorMapForeign = "style_en" | "style_local" | "style_zh_cn";
32
- export const language2vectorMapForeign = (lang: "en" | "zh"): VectorMapForeign => {
33
- switch (lang) {
34
- case "en":
35
- return "style_en";
36
- case "zh":
37
- return "style_zh_cn";
38
- }
39
- };
40
-
41
- export const place2point = (place: Place): Point => [place.lng, place.lat];
42
-
43
- export const pipeAsync =
44
- <P extends any[]>(fn?: (...args: P) => any) =>
45
- (...args: P) => {
46
- setTimeout(() => fn?.(...args));
47
- };
48
-
49
- export const geocoderResult2cityName = (value: google.maps.GeocoderResult): string | undefined => {
50
- const { address_components } = value;
51
- const address = address_components.find(
52
- (item) =>
53
- item.types[0] === "administrative_area_level_1" ||
54
- item.types[0] === "administrative_area_level_2"
55
- );
56
- if (address) return address.long_name;
57
- const countryIdx = address_components.findIndex((item) => item.types[0] === "country");
58
- if (countryIdx > 0) return address_components[countryIdx - 1].long_name;
59
- return undefined;
60
- };
61
-
62
- export const isPlaceEqual = (p1: Place, p2?: Place) => {
63
- return p1.lng === p2?.lng && p1.lat === p2?.lat;
64
- };
65
-
66
- export const isPointEqual = (p1: Point, p2?: Point) => {
67
- return p1[0] === p2?.[0] && p1[1] === p2?.[1];
68
- };
package/src/vite-env.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_GMAP_API_KEY: string;
5
- readonly VITE_GMAP_MAP_ID: string;
6
- readonly VITE_AMAP_API_KEY: string;
7
- readonly VITE_AMAP_API_SECRET: string;
8
- }
9
-
10
- interface ImportMeta {
11
- readonly env: ImportMetaEnv;
12
- }