✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
import { DetachedPromise } from "./detached-promise";
|
|
/**
|
|
* A wrapper for a function that will only allow one call to the function to
|
|
* execute at a time.
|
|
*/ export class Batcher {
|
|
constructor(cacheKeyFn, /**
|
|
* A function that will be called to schedule the wrapped function to be
|
|
* executed. This defaults to a function that will execute the function
|
|
* immediately.
|
|
*/ schedulerFn = (fn)=>fn()){
|
|
this.cacheKeyFn = cacheKeyFn;
|
|
this.schedulerFn = schedulerFn;
|
|
this.pending = new Map();
|
|
}
|
|
static create(options) {
|
|
return new Batcher(options == null ? void 0 : options.cacheKeyFn, options == null ? void 0 : options.schedulerFn);
|
|
}
|
|
/**
|
|
* Wraps a function in a promise that will be resolved or rejected only once
|
|
* for a given key. This will allow multiple calls to the function to be
|
|
* made, but only one will be executed at a time. The result of the first
|
|
* call will be returned to all callers.
|
|
*
|
|
* @param key the key to use for the cache
|
|
* @param fn the function to wrap
|
|
* @returns a promise that resolves to the result of the function
|
|
*/ async batch(key, fn) {
|
|
const cacheKey = this.cacheKeyFn ? await this.cacheKeyFn(key) : key;
|
|
if (cacheKey === null) {
|
|
return fn(cacheKey, Promise.resolve);
|
|
}
|
|
const pending = this.pending.get(cacheKey);
|
|
if (pending) return pending;
|
|
const { promise, resolve, reject } = new DetachedPromise();
|
|
this.pending.set(cacheKey, promise);
|
|
this.schedulerFn(async ()=>{
|
|
try {
|
|
const result = await fn(cacheKey, resolve);
|
|
// Resolving a promise multiple times is a no-op, so we can safely
|
|
// resolve all pending promises with the same result.
|
|
resolve(result);
|
|
} catch (err) {
|
|
reject(err);
|
|
} finally{
|
|
this.pending.delete(cacheKey);
|
|
}
|
|
});
|
|
return promise;
|
|
}
|
|
}
|
|
|
|
//# sourceMappingURL=batcher.js.map
|