Skip to content

Commit f7e5a2a

Browse files
author
danhnguyen
committed
🔧 refactor: streamline documentation build process and improve type imports
1 parent 9c42468 commit f7e5a2a

File tree

7 files changed

+35
-142
lines changed

7 files changed

+35
-142
lines changed

‎.github/workflows/deploy-docs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
2828
- name: Build documentation
2929
run: |
30-
yarn docs:build --debug
30+
yarn docs:build
3131
env:
3232
NODE_ENV: production
3333

‎examples/src/views/Home.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script lang="ts" setup>
22
import { computed } from 'vue';
33
import { useMapbox } from '@libs/composables';
4-
import { type MapOptions, GeolocateControls, Mapbox } from 'vue3-maplibre-gl';
4+
import GeolocateControls from '@libs/components/GeolocateControls.vue';
5+
import Mapbox from '@libs/components/Mapbox.vue';
56
import 'vue3-maplibre-gl/dist/style.css';
67
7-
const options = computed<MapOptions>(() => ({
8+
const options = computed(() => ({
89
container: 'map',
910
style: 'https://worldwidemaps.sqkii.com/api/maps/purple/style.json',
1011
center: [103.8198, 1.3521],
@@ -13,7 +14,6 @@ const options = computed<MapOptions>(() => ({
1314
maxZoom: 20,
1415
}));
1516
16-
// Enhanced useMapbox with better error handling and validation
1717
const { register: registerMap } = useMapbox();
1818
</script>
1919
<template>

‎libs/components/Mapbox.vue‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,18 @@ import {
1616
useMapEventListener,
1717
useLogger,
1818
} from '@libs/composables';
19-
import { MapTouchEvent, MapWheelEvent } from 'maplibre-gl';
2019
import type { CreateMaplibreActions, MaplibreActions } from '@libs/types';
2120
import type {
2221
Map,
2322
MapContextEvent,
2423
MapDataEvent,
2524
MapEventType,
26-
MapLibreEvent,
2725
MapLibreZoomEvent,
2826
MapMouseEvent,
2927
MapOptions,
3028
MapSourceDataEvent,
31-
MapStyleDataEvent,
32-
MapStyleImageMissingEvent,
33-
MapTerrainEvent,
29+
MapTouchEvent,
30+
MapWheelEvent,
3431
} from 'maplibre-gl';
3532
3633
/**
@@ -60,7 +57,7 @@ interface Emits {
6057
(e: 'register', actions: MaplibreActions): void;
6158
(
6259
e: 'error' | 'load' | 'idle' | 'remove' | 'render' | 'resize',
63-
ev: MapLibreEvent,
60+
ev: Event,
6461
): void;
6562
(e: 'webglcontextlost' | 'webglcontextrestored', ev: MapContextEvent): void;
6663
(
@@ -71,8 +68,8 @@ interface Emits {
7168
e: 'sourcedataloading' | 'sourcedata' | 'sourcedataabort',
7269
ev: MapSourceDataEvent,
7370
): void;
74-
(e: 'styledata', ev: MapStyleDataEvent): void;
75-
(e: 'styleimagemissing', ev: MapStyleImageMissingEvent): void;
71+
(e: 'styledata', ev: Event): void;
72+
(e: 'styleimagemissing', ev: Event): void;
7673
(
7774
e: 'boxzoomcancel' | 'boxzoomstart' | 'boxzoomend',
7875
ev: MapLibreZoomEvent,
@@ -110,10 +107,10 @@ interface Emits {
110107
| 'pitchstart'
111108
| 'pitch'
112109
| 'pitchend',
113-
ev: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>,
110+
ev: Event,
114111
): void;
115112
(e: 'wheel', ev: MapWheelEvent): void;
116-
(e: 'terrain', ev: MapTerrainEvent): void;
113+
(e: 'terrain', ev: Event): void;
117114
}
118115
119116
const props = withDefaults(defineProps<MapboxProps>(), {
@@ -273,7 +270,7 @@ MapboxEvents.map((evt) => {
273270
event: evt,
274271
on: (data) => {
275272
try {
276-
emits(evt, data);
273+
emits(evt as keyof MapEventType, data);
277274
} catch (error) {
278275
logError(`Error in ${evt} event handler:`, error, { data });
279276
}

‎libs/composables/map/useCreateMapbox.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import { useLogger } from '@libs/composables';
1010
import { MapCreationStatus } from '@libs/enums';
1111
import { type CreateMaplibreActions } from '@libs/types';
1212
import type { MaybeRef } from 'vue';
13+
import { Map } from 'maplibre-gl';
1314
import type {
14-
Map,
1515
MapOptions,
1616
LngLatBoundsLike,
1717
LngLatLike,
1818
StyleSpecification,
19+
CameraOptions,
1920
StyleSwapOptions,
2021
StyleOptions,
21-
CameraOptions,
22-
} from 'vue3-maplibre-gl';
22+
} from 'maplibre-gl';
2323

2424
interface CreateMapboxProps extends MapOptions {
2525
register?: (actions: EnhancedCreateMaplibreActions) => void;

‎libs/composables/map/useMapbox.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
QueryRenderedFeaturesOptions,
2121
QuerySourceFeatureOptions,
2222
StyleSpecification,
23-
} from 'vue3-maplibre-gl';
23+
} from 'maplibre-gl';
2424

2525
import { useLogger } from '@libs/composables';
2626
import { MapCreationStatus } from '@libs/enums';

‎libs/types/index.ts‎

Lines changed: 17 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
LngLatLike,
1010
Map,
1111
MapEventType,
12-
MapGeoJSONFeature,
1312
MapOptions,
1413
PaddingOptions,
1514
Point,
@@ -19,7 +18,7 @@ import type {
1918
StyleImageInterface,
2019
StyleSetterOptions,
2120
StyleSpecification,
22-
} from 'vue3-maplibre-gl';
21+
} from 'maplibre-gl';
2322
import type { MapCreationStatus } from '@libs/enums';
2423

2524
export type Nullable<T> = T | null;
@@ -75,11 +74,11 @@ export type MaplibreMethods = CreateMaplibreActions & {
7574
queryRenderedFeatures: (
7675
point: PointLike | [PointLike, PointLike],
7776
options?: QueryRenderedFeaturesOptions,
78-
) => MapGeoJSONFeature[] | undefined;
77+
) => any[] | undefined;
7978
querySourceFeatures: (
8079
sourceID: string,
8180
options?: QuerySourceFeatureOptions,
82-
) => MapGeoJSONFeature[] | undefined;
81+
) => any[] | undefined;
8382
queryTerrainElevation: (lnglat: LngLatLike) => number | null | undefined;
8483
isStyleLoaded: () => boolean | void;
8584
isMoving: () => boolean | undefined;
@@ -175,111 +174,8 @@ export interface Layout {
175174
visibility?: Visibility;
176175
}
177176

178-
export type ExpressionsName =
179-
// Types
180-
| 'array'
181-
| 'boolean'
182-
| 'collator'
183-
| 'format'
184-
| 'literal'
185-
| 'number'
186-
| 'number-format'
187-
| 'object'
188-
| 'string'
189-
| 'image'
190-
| 'to-boolean'
191-
| 'to-color'
192-
| 'to-number'
193-
| 'to-string'
194-
| 'typeof'
195-
// Feature data
196-
| 'feature-state'
197-
| 'geometry-type'
198-
| 'id'
199-
| 'line-progress'
200-
| 'properties'
201-
// Lookup
202-
| 'at'
203-
| 'get'
204-
| 'has'
205-
| 'in'
206-
| 'index-of'
207-
| 'length'
208-
| 'slice'
209-
| 'config'
210-
// Decision
211-
| '!'
212-
| '!='
213-
| '<'
214-
| '<='
215-
| '=='
216-
| '>'
217-
| '>='
218-
| 'all'
219-
| 'any'
220-
| 'case'
221-
| 'match'
222-
| 'coalesce'
223-
| 'within'
224-
// Ramps, scales, curves
225-
| 'interpolate'
226-
| 'interpolate-hcl'
227-
| 'interpolate-lab'
228-
| 'step'
229-
// Variable binding
230-
| 'let'
231-
| 'var'
232-
// String
233-
| 'concat'
234-
| 'downcase'
235-
| 'is-supported-script'
236-
| 'resolved-locale'
237-
| 'upcase'
238-
// Color
239-
| 'hsl'
240-
| 'hsla'
241-
| 'rgb'
242-
| 'rgba'
243-
| 'to-rgba'
244-
// Math
245-
| '-'
246-
| '*'
247-
| '/'
248-
| '%'
249-
| '^'
250-
| '+'
251-
| 'abs'
252-
| 'acos'
253-
| 'asin'
254-
| 'atan'
255-
| 'ceil'
256-
| 'cos'
257-
| 'distance'
258-
| 'e'
259-
| 'floor'
260-
| 'ln'
261-
| 'ln2'
262-
| 'log10'
263-
| 'log2'
264-
| 'max'
265-
| 'min'
266-
| 'pi'
267-
| 'random'
268-
| 'round'
269-
| 'sin'
270-
| 'sqrt'
271-
| 'tan'
272-
// Camera
273-
| 'distance-from-center'
274-
| 'pitch'
275-
| 'zoom'
276-
| 'raster-value'
277-
// Lights
278-
| 'measure-light'
279-
// Heatmap
280-
| 'heatmap-density';
281-
282-
export type Expressions = [ExpressionsName, ...any[]];
177+
// Use any for expressions to avoid type conflicts
178+
export type Expressions = any;
283179
export interface StyleFunction {
284180
stops?: any[][];
285181
property?: string;
@@ -297,8 +193,8 @@ export interface FillPaint {
297193
'fill-opacity'?: number | StyleFunction | Expressions | undefined;
298194
'fill-color'?: string | StyleFunction | Expressions | undefined;
299195
'fill-outline-color'?: string | StyleFunction | Expressions | undefined;
300-
'fill-translate'?: number[] | undefined;
301-
'fill-translate-anchor'?: 'map' | 'viewport' | undefined;
196+
'fill-translate'?: any;
197+
'fill-translate-anchor'?: any;
302198
'fill-pattern'?: string | Expressions | undefined;
303199
}
304200

@@ -313,10 +209,10 @@ export interface CirclePaint {
313209
'circle-color'?: string | StyleFunction | Expressions | undefined;
314210
'circle-blur'?: number | StyleFunction | Expressions | undefined;
315211
'circle-opacity'?: number | StyleFunction | Expressions | undefined;
316-
'circle-translate'?: number[] | Expressions | undefined;
317-
'circle-translate-anchor'?: 'map' | 'viewport' | undefined;
318-
'circle-pitch-scale'?: 'map' | 'viewport' | undefined;
319-
'circle-pitch-alignment'?: 'map' | 'viewport' | undefined;
212+
'circle-translate'?: any;
213+
'circle-translate-anchor'?: any;
214+
'circle-pitch-scale'?: any;
215+
'circle-pitch-alignment'?: any;
320216
'circle-stroke-width'?: number | StyleFunction | Expressions | undefined;
321217
'circle-stroke-color'?: string | StyleFunction | Expressions | undefined;
322218
'circle-stroke-opacity'?: number | StyleFunction | Expressions | undefined;
@@ -335,8 +231,8 @@ export interface LineLayout extends Layout {
335231
export interface LinePaint {
336232
'line-opacity'?: number | StyleFunction | Expressions | undefined;
337233
'line-color'?: string | StyleFunction | Expressions | undefined;
338-
'line-translate'?: number[] | Expressions | undefined;
339-
'line-translate-anchor'?: 'map' | 'viewport' | undefined;
234+
'line-translate'?: any;
235+
'line-translate-anchor'?: any;
340236
'line-width'?: number | StyleFunction | Expressions | undefined;
341237
'line-gap-width'?: number | StyleFunction | Expressions | undefined;
342238
'line-offset'?: number | StyleFunction | Expressions | undefined;
@@ -412,15 +308,15 @@ export interface SymbolPaint {
412308
'icon-halo-color'?: string | StyleFunction | Expressions | undefined;
413309
'icon-halo-width'?: number | StyleFunction | Expressions | undefined;
414310
'icon-halo-blur'?: number | StyleFunction | Expressions | undefined;
415-
'icon-translate'?: number[] | Expressions | undefined;
416-
'icon-translate-anchor'?: 'map' | 'viewport' | undefined;
311+
'icon-translate'?: any;
312+
'icon-translate-anchor'?: any;
417313
'text-opacity'?: number | StyleFunction | Expressions | undefined;
418314
'text-color'?: string | StyleFunction | Expressions | undefined;
419315
'text-halo-color'?: string | StyleFunction | Expressions | undefined;
420316
'text-halo-width'?: number | StyleFunction | Expressions | undefined;
421317
'text-halo-blur'?: number | StyleFunction | Expressions | undefined;
422-
'text-translate'?: number[] | Expressions | undefined;
423-
'text-translate-anchor'?: 'map' | 'viewport' | undefined;
318+
'text-translate'?: any;
319+
'text-translate-anchor'?: any;
424320
}
425321

426322
export type SymbolLayerStyle = SymbolLayout & SymbolPaint;

‎vite.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export default defineConfig({
1111
include: ['libs/**/*'],
1212
exclude: ['examples/**/*', 'node_modules/**/*'],
1313
insertTypesEntry: true,
14-
rollupTypes: true,
15-
copyDtsFiles: true,
14+
rollupTypes: false,
15+
copyDtsFiles: false,
1616
}),
1717
],
1818
resolve: {

0 commit comments

Comments
 (0)