✨ 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
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { AbortError, } from './Errors.js';
|
|
import { Deferred } from './Deferred.js';
|
|
import { AbstractStreamReader } from "./AbstractStreamReader.js";
|
|
/**
|
|
* Node.js Readable Stream Reader
|
|
* Ref: https://nodejs.org/api/stream.html#readable-streams
|
|
*/
|
|
export class StreamReader extends AbstractStreamReader {
|
|
constructor(s) {
|
|
super();
|
|
this.s = s;
|
|
/**
|
|
* Deferred used for postponed read request (as not data is yet available to read)
|
|
*/
|
|
this.deferred = null;
|
|
if (!s.read || !s.once) {
|
|
throw new Error('Expected an instance of stream.Readable');
|
|
}
|
|
this.s.once('end', () => {
|
|
this.endOfStream = true;
|
|
if (this.deferred) {
|
|
this.deferred.resolve(0);
|
|
}
|
|
});
|
|
this.s.once('error', err => this.reject(err));
|
|
this.s.once('close', () => this.abort());
|
|
}
|
|
/**
|
|
* Read chunk from stream
|
|
* @param buffer Target Uint8Array (or Buffer) to store data read from stream in
|
|
* @param mayBeLess - If true, may fill the buffer partially
|
|
* @returns Number of bytes read
|
|
*/
|
|
async readFromStream(buffer, mayBeLess) {
|
|
if (buffer.length === 0)
|
|
return 0;
|
|
const readBuffer = this.s.read(buffer.length);
|
|
if (readBuffer) {
|
|
buffer.set(readBuffer);
|
|
return readBuffer.length;
|
|
}
|
|
const request = {
|
|
buffer,
|
|
mayBeLess,
|
|
deferred: new Deferred()
|
|
};
|
|
this.deferred = request.deferred;
|
|
this.s.once('readable', () => {
|
|
this.readDeferred(request);
|
|
});
|
|
return request.deferred.promise;
|
|
}
|
|
/**
|
|
* Process deferred read request
|
|
* @param request Deferred read request
|
|
*/
|
|
readDeferred(request) {
|
|
const readBuffer = this.s.read(request.buffer.length);
|
|
if (readBuffer) {
|
|
request.buffer.set(readBuffer);
|
|
request.deferred.resolve(readBuffer.length);
|
|
this.deferred = null;
|
|
}
|
|
else {
|
|
this.s.once('readable', () => {
|
|
this.readDeferred(request);
|
|
});
|
|
}
|
|
}
|
|
reject(err) {
|
|
this.interrupted = true;
|
|
if (this.deferred) {
|
|
this.deferred.reject(err);
|
|
this.deferred = null;
|
|
}
|
|
}
|
|
async abort() {
|
|
this.reject(new AbortError());
|
|
}
|
|
async close() {
|
|
return this.abort();
|
|
}
|
|
}
|