Skip to content

Commit 95f8946

Browse files
author
danhnguyen
committed
🔧 refactor(Mapbox): remove debug option from useOptimizedComputed
🎨 style: import CSS styles in index.ts and configure asset file naming in vite.config.ts ♻️ chore: update package version to 3.2.2 in package.json and yarn.lock
1 parent 571efa6 commit 95f8946

File tree

6 files changed

+23
-90
lines changed

6 files changed

+23
-90
lines changed

libs/components/Mapbox.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ const mapOptions = useOptimizedComputed(
169169
},
170170
{
171171
deepEqual: true, // Use deep equality for complex objects
172-
debug: props.debug,
173172
},
174173
);
175174

libs/composables/utils/useOptimizedComputed.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ interface OptimizedComputedOptions<T> {
1010
equalityFn?: (a: T, b: T) => boolean;
1111
/** Cache duration in milliseconds (default: no expiration) */
1212
cacheDuration?: number;
13-
/** Enable debug logging */
14-
debug?: boolean;
1513
}
1614

1715
/**
@@ -26,12 +24,7 @@ export function useOptimizedComputed<T>(
2624
getter: () => T,
2725
options: OptimizedComputedOptions<T> = {},
2826
): ComputedRef<T> {
29-
const {
30-
deepEqual = false,
31-
equalityFn,
32-
cacheDuration,
33-
debug = false,
34-
} = options;
27+
const { deepEqual = false, equalityFn, cacheDuration } = options;
3528

3629
const lastValue = ref<T>();
3730
const lastComputedTime = ref<number>(0);
@@ -56,9 +49,6 @@ export function useOptimizedComputed<T>(
5649
if (cacheDuration && hasInitialValue.value) {
5750
const timeSinceLastCompute = now - lastComputedTime.value;
5851
if (timeSinceLastCompute < cacheDuration) {
59-
if (debug) {
60-
console.log('useOptimizedComputed: returning cached value');
61-
}
6252
return lastValue.value as T;
6353
}
6454
}
@@ -67,9 +57,6 @@ export function useOptimizedComputed<T>(
6757

6858
// Check if value actually changed
6959
if (hasInitialValue.value && isEqual(newValue, lastValue.value as T)) {
70-
if (debug) {
71-
console.log('useOptimizedComputed: value unchanged, returning cached');
72-
}
7360
return lastValue.value as T;
7461
}
7562

@@ -78,10 +65,6 @@ export function useOptimizedComputed<T>(
7865
lastComputedTime.value = now;
7966
hasInitialValue.value = true;
8067

81-
if (debug) {
82-
console.log('useOptimizedComputed: computed new value', newValue);
83-
}
84-
8568
return newValue;
8669
});
8770
}

libs/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Import CSS styles
2+
import './style.css';
3+
14
// Export all composables
25
export * from './composables';
36

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"vue-eslint-parser": "^9.4.3",
114114
"vue-router": "^4.3.2",
115115
"vue-tsc": "^2.0.19",
116-
"vue3-maplibre-gl": "^3.2.1"
116+
"vue3-maplibre-gl": "^3.2.2"
117117
},
118118
"lint-staged": {
119119
"*.{ts,tsx,js,jsx,cjs,mjs,vue}": "eslint --fix",

vite.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export default defineConfig({
4545
{
4646
format: 'es',
4747
entryFileNames: 'index.js',
48+
assetFileNames: (assetInfo) => {
49+
// Ensure CSS files are named style.css
50+
if (
51+
assetInfo.names &&
52+
assetInfo.names.some((name) => name.endsWith('.css'))
53+
) {
54+
return 'style.css';
55+
}
56+
return '[name].[ext]';
57+
},
4858
globals: {
4959
vue: 'Vue',
5060
'maplibre-gl': 'maplibregl',
@@ -135,8 +145,8 @@ export default defineConfig({
135145
},
136146
// Enable CSS optimization
137147
cssMinify: true,
138-
// CSS code splitting
139-
cssCodeSplit: true,
148+
// Disable CSS code splitting to bundle all CSS into one file
149+
cssCodeSplit: false,
140150
},
141151
// Optimize dependencies
142152
optimizeDeps: {

yarn.lock

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,6 @@
445445
resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe"
446446
integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==
447447

448-
"@maplibre/maplibre-gl-style-spec@^20.3.1":
449-
version "20.4.0"
450-
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.4.0.tgz#408339e051fb51e022b40af2235e0beb037937ea"
451-
integrity sha512-AzBy3095fTFPjDjmWpR2w6HVRAZJ6hQZUCwk5Plz6EyfnfuQW1odeW5i2Ai47Y6TBA2hQnC+azscjBSALpaWgw==
452-
dependencies:
453-
"@mapbox/jsonlint-lines-primitives" "~2.0.2"
454-
"@mapbox/unitbezier" "^0.0.1"
455-
json-stringify-pretty-compact "^4.0.0"
456-
minimist "^1.2.8"
457-
quickselect "^2.0.0"
458-
rw "^1.3.3"
459-
tinyqueue "^3.0.0"
460-
461448
"@maplibre/maplibre-gl-style-spec@^23.3.0":
462449
version "23.3.0"
463450
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.3.0.tgz#b69ab48cb3abead4e49213396c8f83492638b97c"
@@ -1628,7 +1615,7 @@ doctrine@^3.0.0:
16281615
dependencies:
16291616
esutils "^2.0.2"
16301617

1631-
earcut@^3.0.0, earcut@^3.0.1:
1618+
earcut@^3.0.1:
16321619
version "3.0.1"
16331620
resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.0.1.tgz#f60b3f671c5657cca9d3e131c5527c5dde00ef38"
16341621
integrity sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==
@@ -2295,38 +2282,6 @@ maplibre-gl@*, maplibre-gl@^5.6.1:
22952282
tinyqueue "^3.0.0"
22962283
vt-pbf "^3.1.3"
22972284

2298-
maplibre-gl@^4.3.2:
2299-
version "4.7.1"
2300-
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-4.7.1.tgz#06a524438ee2aafbe8bcd91002a4e01468ea5486"
2301-
integrity sha512-lgL7XpIwsgICiL82ITplfS7IGwrB1OJIw/pCvprDp2dhmSSEBgmPzYRvwYYYvJGJD7fxUv1Tvpih4nZ6VrLuaA==
2302-
dependencies:
2303-
"@mapbox/geojson-rewind" "^0.5.2"
2304-
"@mapbox/jsonlint-lines-primitives" "^2.0.2"
2305-
"@mapbox/point-geometry" "^0.1.0"
2306-
"@mapbox/tiny-sdf" "^2.0.6"
2307-
"@mapbox/unitbezier" "^0.0.1"
2308-
"@mapbox/vector-tile" "^1.3.1"
2309-
"@mapbox/whoots-js" "^3.1.0"
2310-
"@maplibre/maplibre-gl-style-spec" "^20.3.1"
2311-
"@types/geojson" "^7946.0.14"
2312-
"@types/geojson-vt" "3.2.5"
2313-
"@types/mapbox__point-geometry" "^0.1.4"
2314-
"@types/mapbox__vector-tile" "^1.3.4"
2315-
"@types/pbf" "^3.0.5"
2316-
"@types/supercluster" "^7.1.3"
2317-
earcut "^3.0.0"
2318-
geojson-vt "^4.0.2"
2319-
gl-matrix "^3.4.3"
2320-
global-prefix "^4.0.0"
2321-
kdbush "^4.0.2"
2322-
murmurhash-js "^1.0.0"
2323-
pbf "^3.3.0"
2324-
potpack "^2.0.0"
2325-
quickselect "^3.0.0"
2326-
supercluster "^8.0.1"
2327-
tinyqueue "^3.0.0"
2328-
vt-pbf "^3.1.3"
2329-
23302285
23312286
version "8.11.1"
23322287
resolved "https://registry.yarnpkg.com/mark.js/-/mark.js-8.11.1.tgz#180f1f9ebef8b0e638e4166ad52db879beb2ffc5"
@@ -2668,11 +2623,6 @@ queue-microtask@^1.2.2:
26682623
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
26692624
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
26702625

2671-
quickselect@^2.0.0:
2672-
version "2.0.0"
2673-
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
2674-
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==
2675-
26762626
quickselect@^3.0.0:
26772627
version "3.0.0"
26782628
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-3.0.0.tgz#a37fc953867d56f095a20ac71c6d27063d2de603"
@@ -3253,24 +3203,12 @@ vue-tsc@^2.0.19:
32533203
"@volar/typescript" "2.4.15"
32543204
"@vue/language-core" "2.2.12"
32553205

3256-
vue3-maplibre-gl@^3.2.0:
3257-
version "3.2.0"
3258-
resolved "https://registry.yarnpkg.com/vue3-maplibre-gl/-/vue3-maplibre-gl-3.2.0.tgz#1503faf9850eb23446d531751b4b219fc196cb34"
3259-
integrity sha512-+aficvPPwyUO6LQGjzh0IlEr0udUckTrqGSeHYKJ6v4+jXNKPnnWKRptgNfI39YK9jkwtMZO0FCyfBzFT4wHdQ==
3260-
dependencies:
3261-
maplibre-gl "^4.3.2"
3262-
vue "^3.4.27"
3263-
3264-
vue3-maplibre-gl@^3.2.1:
3265-
version "3.2.1"
3266-
resolved "https://registry.yarnpkg.com/vue3-maplibre-gl/-/vue3-maplibre-gl-3.2.1.tgz#a194d454682ad2b4d3d22231c0be9adcdc210700"
3267-
integrity sha512-ZNTak3OUraIhg1ZDmHePSzaDzmJJ0taOqQsTi5qhbb83vup8M/zxnO5AvDs3YscJcSV99uW2aIng3mVVw4YCrw==
3268-
dependencies:
3269-
maplibre-gl "^5.6.1"
3270-
vue "^3.5.17"
3271-
vue3-maplibre-gl "^3.2.0"
3206+
vue3-maplibre-gl@^3.2.2:
3207+
version "3.2.2"
3208+
resolved "https://registry.yarnpkg.com/vue3-maplibre-gl/-/vue3-maplibre-gl-3.2.2.tgz#f5112bfb26930687fe1e3991f9215eb49565d361"
3209+
integrity sha512-kr1sCCt8+s866qQuYR/WYLM9njsgAFGL9U+K4LisEzjLHzg/+nbxxWWZtmLC9ej9pTdsLwnxCDeFKMrvyfwTSQ==
32723210

3273-
vue@^3.4.27, vue@^3.5.13, vue@^3.5.17:
3211+
vue@^3.5.13, vue@^3.5.17:
32743212
version "3.5.17"
32753213
resolved "https://registry.yarnpkg.com/vue/-/vue-3.5.17.tgz#ea8a6a45abb2b0620e7d479319ce8434b55650cf"
32763214
integrity sha512-LbHV3xPN9BeljML+Xctq4lbz2lVHCR6DtbpTf5XIO6gugpXUN49j2QQPcMj086r9+AkJ0FfUT8xjulKKBkkr9g==

0 commit comments

Comments
 (0)