✨ 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
94 lines
2.5 KiB
JavaScript
94 lines
2.5 KiB
JavaScript
/* eslint-env jest */
|
|
import getProp from '../src/getProp';
|
|
|
|
const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10);
|
|
|
|
export const fallbackToBabylon = nodeVersion < 6;
|
|
|
|
let parserName;
|
|
const babelParser = fallbackToBabylon ? require('babylon') : require('@babel/parser');
|
|
const flowParser = require('flow-parser');
|
|
|
|
const defaultPlugins = [
|
|
'jsx',
|
|
'functionBind',
|
|
'estree',
|
|
'objectRestSpread',
|
|
'optionalChaining',
|
|
// 'nullishCoalescing', // TODO: update to babel 7
|
|
];
|
|
let plugins = [...defaultPlugins];
|
|
let isESM = false;
|
|
|
|
export function setParserName(name) {
|
|
parserName = name;
|
|
}
|
|
|
|
export function changePlugins(pluginOrFn) {
|
|
if (Array.isArray(pluginOrFn)) {
|
|
plugins = pluginOrFn;
|
|
} else if (typeof pluginOrFn === 'function') {
|
|
plugins = pluginOrFn(plugins);
|
|
} else {
|
|
throw new Error('changePlugins argument should be either an array or a function');
|
|
}
|
|
}
|
|
|
|
export function setIsESM() {
|
|
isESM = true;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
plugins = [...defaultPlugins];
|
|
isESM = false;
|
|
});
|
|
|
|
function parse(code) {
|
|
if (parserName === undefined) {
|
|
throw new Error('No parser specified');
|
|
}
|
|
if (parserName === 'babel') {
|
|
try {
|
|
return babelParser.parse(code, { plugins, sourceFilename: 'test.js', ...(isESM && { sourceType: 'module' }) });
|
|
} catch (_) {
|
|
// eslint-disable-next-line no-console
|
|
console.warn(`Failed to parse with ${fallbackToBabylon ? 'babylon' : 'Babel'} parser.`);
|
|
}
|
|
}
|
|
if (parserName === 'flow') {
|
|
try {
|
|
return flowParser.parse(code, { plugins });
|
|
} catch (_) {
|
|
// eslint-disable-next-line no-console
|
|
console.warn('Failed to parse with the Flow parser');
|
|
}
|
|
}
|
|
throw new Error(`The parser ${parserName} is not yet supported for testing.`);
|
|
}
|
|
|
|
export function getOpeningElement(code) {
|
|
const parsedCode = parse(code);
|
|
let body;
|
|
if (parsedCode.program) {
|
|
// eslint-disable-next-line prefer-destructuring
|
|
body = parsedCode.program.body;
|
|
} else {
|
|
// eslint-disable-next-line prefer-destructuring
|
|
body = parsedCode.body;
|
|
}
|
|
if (Array.isArray(body) && body[0] != null) {
|
|
const [{ expression }] = body;
|
|
return expression.type === 'JSXFragment' ? expression.openingFragment : expression.openingElement;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function extractProp(code, prop = 'foo') {
|
|
const node = getOpeningElement(code);
|
|
const { attributes: props } = node;
|
|
return getProp(props, prop);
|
|
}
|
|
|
|
export const describeIfNotBabylon = fallbackToBabylon ? describe.skip : describe;
|