✨ 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
117 lines
3.7 KiB
JavaScript
117 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
var anchors = require('../doc/anchors.js');
|
|
var visit = require('../visit.js');
|
|
var identity = require('./identity.js');
|
|
var Node = require('./Node.js');
|
|
var toJS = require('./toJS.js');
|
|
|
|
class Alias extends Node.NodeBase {
|
|
constructor(source) {
|
|
super(identity.ALIAS);
|
|
this.source = source;
|
|
Object.defineProperty(this, 'tag', {
|
|
set() {
|
|
throw new Error('Alias nodes cannot have tags');
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Resolve the value of this alias within `doc`, finding the last
|
|
* instance of the `source` anchor before this node.
|
|
*/
|
|
resolve(doc, ctx) {
|
|
let nodes;
|
|
if (ctx?.aliasResolveCache) {
|
|
nodes = ctx.aliasResolveCache;
|
|
}
|
|
else {
|
|
nodes = [];
|
|
visit.visit(doc, {
|
|
Node: (_key, node) => {
|
|
if (identity.isAlias(node) || identity.hasAnchor(node))
|
|
nodes.push(node);
|
|
}
|
|
});
|
|
if (ctx)
|
|
ctx.aliasResolveCache = nodes;
|
|
}
|
|
let found = undefined;
|
|
for (const node of nodes) {
|
|
if (node === this)
|
|
break;
|
|
if (node.anchor === this.source)
|
|
found = node;
|
|
}
|
|
return found;
|
|
}
|
|
toJSON(_arg, ctx) {
|
|
if (!ctx)
|
|
return { source: this.source };
|
|
const { anchors, doc, maxAliasCount } = ctx;
|
|
const source = this.resolve(doc, ctx);
|
|
if (!source) {
|
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
throw new ReferenceError(msg);
|
|
}
|
|
let data = anchors.get(source);
|
|
if (!data) {
|
|
// Resolve anchors for Node.prototype.toJS()
|
|
toJS.toJS(source, null, ctx);
|
|
data = anchors.get(source);
|
|
}
|
|
/* istanbul ignore if */
|
|
if (!data || data.res === undefined) {
|
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
throw new ReferenceError(msg);
|
|
}
|
|
if (maxAliasCount >= 0) {
|
|
data.count += 1;
|
|
if (data.aliasCount === 0)
|
|
data.aliasCount = getAliasCount(doc, source, anchors);
|
|
if (data.count * data.aliasCount > maxAliasCount) {
|
|
const msg = 'Excessive alias count indicates a resource exhaustion attack';
|
|
throw new ReferenceError(msg);
|
|
}
|
|
}
|
|
return data.res;
|
|
}
|
|
toString(ctx, _onComment, _onChompKeep) {
|
|
const src = `*${this.source}`;
|
|
if (ctx) {
|
|
anchors.anchorIsValid(this.source);
|
|
if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) {
|
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
throw new Error(msg);
|
|
}
|
|
if (ctx.implicitKey)
|
|
return `${src} `;
|
|
}
|
|
return src;
|
|
}
|
|
}
|
|
function getAliasCount(doc, node, anchors) {
|
|
if (identity.isAlias(node)) {
|
|
const source = node.resolve(doc);
|
|
const anchor = anchors && source && anchors.get(source);
|
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
}
|
|
else if (identity.isCollection(node)) {
|
|
let count = 0;
|
|
for (const item of node.items) {
|
|
const c = getAliasCount(doc, item, anchors);
|
|
if (c > count)
|
|
count = c;
|
|
}
|
|
return count;
|
|
}
|
|
else if (identity.isPair(node)) {
|
|
const kc = getAliasCount(doc, node.key, anchors);
|
|
const vc = getAliasCount(doc, node.value, anchors);
|
|
return Math.max(kc, vc);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
exports.Alias = Alias;
|