✨ 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
123 lines
2.5 KiB
JavaScript
123 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
exports.isInteger = num => {
|
|
if (typeof num === 'number') {
|
|
return Number.isInteger(num);
|
|
}
|
|
if (typeof num === 'string' && num.trim() !== '') {
|
|
return Number.isInteger(Number(num));
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Find a node of the given type
|
|
*/
|
|
|
|
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
|
|
|
/**
|
|
* Find a node of the given type
|
|
*/
|
|
|
|
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
if (limit === false) return false;
|
|
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
|
};
|
|
|
|
/**
|
|
* Escape the given node with '\\' before node.value
|
|
*/
|
|
|
|
exports.escapeNode = (block, n = 0, type) => {
|
|
const node = block.nodes[n];
|
|
if (!node) return;
|
|
|
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
if (node.escaped !== true) {
|
|
node.value = '\\' + node.value;
|
|
node.escaped = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns true if the given brace node should be enclosed in literal braces
|
|
*/
|
|
|
|
exports.encloseBrace = node => {
|
|
if (node.type !== 'brace') return false;
|
|
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
|
node.invalid = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Returns true if a brace node is invalid.
|
|
*/
|
|
|
|
exports.isInvalidBrace = block => {
|
|
if (block.type !== 'brace') return false;
|
|
if (block.invalid === true || block.dollar) return true;
|
|
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
|
block.invalid = true;
|
|
return true;
|
|
}
|
|
if (block.open !== true || block.close !== true) {
|
|
block.invalid = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Returns true if a node is an open or close node
|
|
*/
|
|
|
|
exports.isOpenOrClose = node => {
|
|
if (node.type === 'open' || node.type === 'close') {
|
|
return true;
|
|
}
|
|
return node.open === true || node.close === true;
|
|
};
|
|
|
|
/**
|
|
* Reduce an array of text nodes.
|
|
*/
|
|
|
|
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
|
if (node.type === 'text') acc.push(node.value);
|
|
if (node.type === 'range') node.type = 'text';
|
|
return acc;
|
|
}, []);
|
|
|
|
/**
|
|
* Flatten an array
|
|
*/
|
|
|
|
exports.flatten = (...args) => {
|
|
const result = [];
|
|
|
|
const flat = arr => {
|
|
for (let i = 0; i < arr.length; i++) {
|
|
const ele = arr[i];
|
|
|
|
if (Array.isArray(ele)) {
|
|
flat(ele);
|
|
continue;
|
|
}
|
|
|
|
if (ele !== undefined) {
|
|
result.push(ele);
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
|
|
flat(args);
|
|
return result;
|
|
};
|