Files
Laca-City/backend/node_modules/webpack/lib/logging/truncateArgs.js
PhongPham c65cc97a33 🎯 MapView v2.0 - Global Deployment Ready
 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
2025-07-20 19:52:16 +07:00

84 lines
2.3 KiB
JavaScript

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/**
* @param {Array<number>} array array of numbers
* @returns {number} sum of all numbers in array
*/
const arraySum = array => {
let sum = 0;
for (const item of array) sum += item;
return sum;
};
/**
* @param {EXPECTED_ANY[]} args items to be truncated
* @param {number} maxLength maximum length of args including spaces between
* @returns {string[]} truncated args
*/
const truncateArgs = (args, maxLength) => {
const lengths = args.map(a => `${a}`.length);
const availableLength = maxLength - lengths.length + 1;
if (availableLength > 0 && args.length === 1) {
if (availableLength >= args[0].length) {
return args;
} else if (availableLength > 3) {
return [`...${args[0].slice(-availableLength + 3)}`];
}
return [args[0].slice(-availableLength)];
}
// Check if there is space for at least 4 chars per arg
if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) {
// remove args
if (args.length > 1) return truncateArgs(args.slice(0, -1), maxLength);
return [];
}
let currentLength = arraySum(lengths);
// Check if all fits into maxLength
if (currentLength <= availableLength) return args;
// Try to remove chars from the longest items until it fits
while (currentLength > availableLength) {
const maxLength = Math.max(...lengths);
const shorterItems = lengths.filter(l => l !== maxLength);
const nextToMaxLength =
shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
const maxReduce = maxLength - nextToMaxLength;
let maxItems = lengths.length - shorterItems.length;
let overrun = currentLength - availableLength;
for (let i = 0; i < lengths.length; i++) {
if (lengths[i] === maxLength) {
const reduce = Math.min(Math.floor(overrun / maxItems), maxReduce);
lengths[i] -= reduce;
currentLength -= reduce;
overrun -= reduce;
maxItems--;
}
}
}
// Return args reduced to length in lengths
return args.map((a, i) => {
const str = `${a}`;
const length = lengths[i];
if (str.length === length) {
return str;
} else if (length > 5) {
return `...${str.slice(-length + 3)}`;
} else if (length > 0) {
return str.slice(-length);
}
return "";
});
};
module.exports = truncateArgs;