✨ 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
127 lines
5.8 KiB
JavaScript
127 lines
5.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.AssetsManager = void 0;
|
|
const chokidar = require("chokidar");
|
|
const fs_1 = require("fs");
|
|
const glob_1 = require("glob");
|
|
const path_1 = require("path");
|
|
const copy_path_resolve_1 = require("./helpers/copy-path-resolve");
|
|
const get_value_or_default_1 = require("./helpers/get-value-or-default");
|
|
class AssetsManager {
|
|
constructor() {
|
|
this.watchAssetsKeyValue = {};
|
|
this.watchers = [];
|
|
this.actionInProgress = false;
|
|
}
|
|
/**
|
|
* Using on `nest build` to close file watch or the build process will not end
|
|
* Interval like process
|
|
* If no action has been taken recently close watchers
|
|
* If action has been taken recently flag and try again
|
|
*/
|
|
closeWatchers() {
|
|
// Consider adjusting this for larger files
|
|
const timeoutMs = 500;
|
|
const closeFn = () => {
|
|
if (this.actionInProgress) {
|
|
this.actionInProgress = false;
|
|
setTimeout(closeFn, timeoutMs);
|
|
}
|
|
else {
|
|
this.watchers.forEach((watcher) => watcher.close());
|
|
}
|
|
};
|
|
setTimeout(closeFn, timeoutMs);
|
|
}
|
|
copyAssets(configuration, appName, outDir, watchAssetsMode) {
|
|
const assets = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.assets', appName) || [];
|
|
if (assets.length <= 0) {
|
|
return;
|
|
}
|
|
try {
|
|
let sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
|
|
sourceRoot = (0, path_1.join)(process.cwd(), sourceRoot);
|
|
const filesToCopy = assets.map((item) => {
|
|
let includePath = typeof item === 'string' ? item : item.include;
|
|
let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
|
|
includePath = (0, path_1.join)(sourceRoot, includePath).replace(/\\/g, '/');
|
|
excludePath = excludePath
|
|
? (0, path_1.join)(sourceRoot, excludePath).replace(/\\/g, '/')
|
|
: undefined;
|
|
return {
|
|
outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
|
|
glob: includePath,
|
|
exclude: excludePath,
|
|
flat: typeof item !== 'string' ? item.flat : undefined, // deprecated field
|
|
watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
|
|
};
|
|
});
|
|
const isWatchEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
|
|
for (const item of filesToCopy) {
|
|
const option = {
|
|
action: 'change',
|
|
item,
|
|
path: '',
|
|
sourceRoot,
|
|
watchAssetsMode: isWatchEnabled,
|
|
};
|
|
if (isWatchEnabled || item.watchAssets) {
|
|
// prettier-ignore
|
|
const watcher = chokidar
|
|
.watch(item.glob, { ignored: item.exclude })
|
|
.on('add', (path) => this.actionOnFile({ ...option, path, action: 'change' }))
|
|
.on('change', (path) => this.actionOnFile({ ...option, path, action: 'change' }))
|
|
.on('unlink', (path) => this.actionOnFile({ ...option, path, action: 'unlink' }));
|
|
this.watchers.push(watcher);
|
|
}
|
|
else {
|
|
const matchedPaths = (0, glob_1.sync)(item.glob, {
|
|
ignore: item.exclude,
|
|
dot: true,
|
|
});
|
|
const files = item.glob.endsWith('*')
|
|
? matchedPaths.filter((matched) => (0, fs_1.statSync)(matched).isFile())
|
|
: matchedPaths.flatMap((matched) => {
|
|
if ((0, fs_1.statSync)(matched).isDirectory()) {
|
|
return (0, glob_1.sync)(`${matched}/**/*`, {
|
|
ignore: item.exclude,
|
|
}).filter((file) => (0, fs_1.statSync)(file).isFile());
|
|
}
|
|
return matched;
|
|
});
|
|
for (const path of files) {
|
|
this.actionOnFile({ ...option, path, action: 'change' });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (err) {
|
|
throw new Error(`An error occurred during the assets copying process. ${err.message}`);
|
|
}
|
|
}
|
|
actionOnFile(option) {
|
|
const { action, item, path, sourceRoot, watchAssetsMode } = option;
|
|
const isWatchEnabled = watchAssetsMode || item.watchAssets;
|
|
const assetCheckKey = path + (item.outDir ?? '');
|
|
// Allow to do action for the first time before check watchMode
|
|
if (!isWatchEnabled && this.watchAssetsKeyValue[assetCheckKey]) {
|
|
return;
|
|
}
|
|
// Set path value to true for watching the first time
|
|
this.watchAssetsKeyValue[assetCheckKey] = true;
|
|
// Set action to true to avoid watches getting cutoff
|
|
this.actionInProgress = true;
|
|
const dest = (0, copy_path_resolve_1.copyPathResolve)(path, item.outDir, sourceRoot.split(path_1.sep).length);
|
|
// Copy to output dir if file is changed or added
|
|
if (action === 'change') {
|
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(dest), { recursive: true });
|
|
(0, fs_1.copyFileSync)(path, dest);
|
|
}
|
|
else if (action === 'unlink') {
|
|
// Remove from output dir if file is deleted
|
|
(0, fs_1.rmSync)(dest, { force: true });
|
|
}
|
|
}
|
|
}
|
|
exports.AssetsManager = AssetsManager;
|