🎯 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
This commit is contained in:
2025-07-20 19:52:16 +07:00
parent 3203463a6a
commit c65cc97a33
64624 changed files with 7199453 additions and 6462 deletions

View File

@@ -0,0 +1,3 @@
import { Rule } from '@angular-devkit/schematics';
import { AngularOptions } from './angular.schema';
export declare function main(options: AngularOptions): Rule;

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = main;
const core_1 = require("@angular-devkit/core");
const schematics_1 = require("@angular-devkit/schematics");
const path_1 = require("path");
const module_declarator_1 = require("../../../utils/module.declarator");
const module_finder_1 = require("../../../utils/module.finder");
const name_parser_1 = require("../../../utils/name.parser");
const source_root_helpers_1 = require("../../../utils/source-root.helpers");
function main(options) {
options = transform(options);
return (tree, context) => {
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
createAngularApplication(options),
(0, source_root_helpers_1.mergeSourceRoot)(options),
addDeclarationToModule(options),
addGlobalPrefix(),
(0, schematics_1.mergeWith)(generate(options)),
]))(tree, context);
};
}
function transform(source) {
const target = Object.assign({}, source);
target.directory = target.name ? core_1.strings.dasherize(target.name) : 'client';
target.name = 'Angular';
target.metadata = 'imports';
target.type = 'module';
const location = new name_parser_1.NameParser().parse(target);
target.name = core_1.strings.dasherize(location.name);
target.path = (0, path_1.join)(core_1.strings.dasherize(location.path), target.name);
return target;
}
function generate(options) {
return (context) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
(0, schematics_1.template)({
...core_1.strings,
...options,
}),
(0, schematics_1.move)(options.path),
])(context);
}
function createAngularApplication(options) {
if (!options.initApp) {
return (0, schematics_1.noop)();
}
return (0, schematics_1.externalSchematic)('@schematics/angular', 'ng-new', {
name: options.directory,
version: '8.0.0',
});
}
function addDeclarationToModule(options) {
return (tree) => {
options.module = new module_finder_1.ModuleFinder(tree).find({
name: options.name,
path: options.path,
});
if (!options.module) {
return tree;
}
const content = tree.read(options.module).toString();
const declarator = new module_declarator_1.ModuleDeclarator();
const rootPath = `${options.directory}/dist/${options.directory}`;
const staticOptions = {
name: 'forRoot',
value: {
rootPath,
},
};
const declarationOptions = {
...options,
staticOptions,
};
tree.overwrite(options.module, declarator.declare(content, declarationOptions));
return tree;
};
}
function addGlobalPrefix() {
return (tree) => {
const mainFilePath = 'src/main.ts';
const fileRef = tree.get(mainFilePath);
if (!fileRef) {
return tree;
}
const ts = require('ts-morph');
const tsProject = new ts.Project({
manipulationSettings: {
indentationText: ts.IndentationText.TwoSpaces,
},
});
const tsFile = tsProject.addSourceFileAtPath(mainFilePath);
const bootstrapFunction = tsFile.getFunction('bootstrap');
const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'));
const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'));
if (!listenStatement || setPrefixStatement) {
return tree;
}
const listenExprIndex = listenStatement.getChildIndex();
bootstrapFunction.insertStatements(listenExprIndex, `app.setGlobalPrefix('api');`);
tree.overwrite(mainFilePath, tsFile.getFullText());
return tree;
};
}

View File

@@ -0,0 +1,4 @@
export const ANGULAR_MODULE_OPTIONS = 'ANGULAR_MODULE_OPTIONS';
export const DEFAULT_ROOT_PATH = 'client/dist';
export const DEFAULT_RENDER_PATH = '*';

View File

@@ -0,0 +1,41 @@
import { DynamicModule, Inject, Module, OnModuleInit } from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
import {
ANGULAR_MODULE_OPTIONS,
DEFAULT_RENDER_PATH,
DEFAULT_ROOT_PATH,
} from './angular.constants';
import { angularProviders } from './angular.providers';
import { AngularModuleOptions } from './interfaces/angular-options.interface';
import { AbstractLoader } from './loaders/abstract.loader';
@Module({
providers: [...angularProviders],
})
export class AngularModule implements OnModuleInit {
constructor(
@Inject(ANGULAR_MODULE_OPTIONS)
private readonly ngOptions: AngularModuleOptions,
private readonly loader: AbstractLoader,
private readonly httpAdapterHost: HttpAdapterHost,
) {}
public static forRoot(options: AngularModuleOptions = {}): DynamicModule {
options.rootPath = options.rootPath || DEFAULT_ROOT_PATH;
options.renderPath = options.renderPath || DEFAULT_RENDER_PATH;
return {
module: AngularModule,
providers: [
{
provide: ANGULAR_MODULE_OPTIONS,
useValue: options,
},
],
};
}
public async onModuleInit() {
const httpAdapter = this.httpAdapterHost.httpAdapter;
this.loader.register(httpAdapter, this.ngOptions);
}
}

View File

@@ -0,0 +1,27 @@
import { Provider } from '@nestjs/common';
import { HttpAdapterHost } from '@nestjs/core';
import { AbstractLoader } from './loaders/abstract.loader';
import { ExpressLoader } from './loaders/express.loader';
import { FastifyLoader } from './loaders/fastify.loader';
import { NoopLoader } from './loaders/noop.loader';
export const angularProviders: Provider[] = [
{
provide: AbstractLoader,
useFactory: (httpAdapterHost: HttpAdapterHost) => {
if (!httpAdapterHost) {
return new NoopLoader();
}
const httpAdapter = httpAdapterHost.httpAdapter;
if (
httpAdapter &&
httpAdapter.constructor &&
httpAdapter.constructor.name === 'FastifyAdapter'
) {
return new FastifyLoader();
}
return new ExpressLoader();
},
inject: [HttpAdapterHost],
},
];

View File

@@ -0,0 +1,19 @@
import { Logger } from '@nestjs/common';
const MISSING_REQUIRED_DEPENDENCY = (name: string, reason: string) =>
`The "${name}" package is missing. Please, make sure to install this library ($ npm install ${name}) to take advantage of ${reason}.`;
const logger = new Logger('PackageLoader');
export function loadPackage<T = any>(
packageName: string,
context: string,
loaderFn?: () => T,
): T {
try {
return loaderFn ? loaderFn() : require(packageName);
} catch (e) {
logger.error(MISSING_REQUIRED_DEPENDENCY(packageName, context));
process.exit(1);
}
}

View File

@@ -0,0 +1,87 @@
export interface AngularModuleOptions {
/**
* Static files root directory.
* Default: "client/dist"
*/
rootPath?: string;
/**
* Path to render Angular app.
* Default: * (wildcard - all paths)
*/
renderPath?: string;
/**
* Serve static options (static files)
* Passed down to the underlying either `express.static` or `fastify-static.send`
*/
serveStaticOptions?: {
/**
* Enable or disable setting Cache-Control response header, defaults to true.
* Disabling this will ignore the immutable and maxAge options.
*/
cacheControl?: boolean;
/**
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
* Note this check is done on the path itself without checking if the path actually exists on the disk.
* If root is specified, only the dotfiles above the root are checked
* (i.e. the root itself can be within a dotfile when when set to "deny").
* The default value is 'ignore'.
* 'allow' No special treatment for dotfiles
* 'deny' Send a 403 for any request for a dotfile
* 'ignore' Pretend like the dotfile does not exist and call next()
*/
dotfiles?: string;
/**
* Enable or disable etag generation, defaults to true.
*/
etag?: boolean;
/**
* Set file extension fallbacks. When set, if a file is not found, the given extensions
* will be added to the file name and search for.
* The first that exists will be served. Example: ['html', 'htm'].
* The default value is false.
*/
extensions?: string[];
/**
* Enable or disable the immutable directive in the Cache-Control response header.
* If enabled, the maxAge option should also be specified to enable caching.
* The immutable directive will prevent supported clients from making conditional
* requests during the life of the maxAge option to check if the file has changed.
*/
immutable?: boolean;
/**
* By default this module will send "index.html" files in response to a request on a directory.
* To disable this set false or to supply a new index pass a string or an array in preferred order.
*/
index?: boolean | string | string[];
/**
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
*/
lastModified?: boolean;
/**
* Provide a max-age in milliseconds for http caching, defaults to 0.
* This can also be a string accepted by the ms module.
*/
maxAge?: number | string;
/**
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
*/
redirect?: boolean;
/**
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
* The function is called as fn(res, path, stat), where the arguments are:
* res the response object
* path the file path that is being sent
* stat the stat object of the file that is being sent
*/
setHeaders?: (res: any, path: string, stat: any) => any;
};
}

View File

@@ -0,0 +1,16 @@
import { Injectable } from '@nestjs/common';
import { AbstractHttpAdapter } from '@nestjs/core';
import { join } from 'path';
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
@Injectable()
export abstract class AbstractLoader {
public abstract register(
httpAdapter: AbstractHttpAdapter,
options: AngularModuleOptions,
);
public getIndexFilePath(clientPath: string): string {
return join(clientPath, 'index.html');
}
}

View File

@@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common';
import { AbstractHttpAdapter } from '@nestjs/core';
import { loadPackage } from '../angular.utils';
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
import { AbstractLoader } from './abstract.loader';
@Injectable()
export class ExpressLoader extends AbstractLoader {
public register(
httpAdapter: AbstractHttpAdapter,
options: AngularModuleOptions,
) {
const app = httpAdapter.getInstance();
const express = loadPackage('express', 'AngularModule', () =>
require('express'),
);
const clientPath = options.rootPath;
const indexFilePath = this.getIndexFilePath(clientPath);
app.use(express.static(clientPath, options.serveStaticOptions));
app.get(options.renderPath, (req: any, res: any) =>
res.sendFile(indexFilePath),
);
}
}

View File

@@ -0,0 +1,34 @@
import { Injectable } from '@nestjs/common';
import { AbstractHttpAdapter } from '@nestjs/core';
import * as fs from 'fs';
import { loadPackage } from '../angular.utils';
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
import { AbstractLoader } from './abstract.loader';
@Injectable()
export class FastifyLoader extends AbstractLoader {
public register(
httpAdapter: AbstractHttpAdapter,
options: AngularModuleOptions,
) {
const app = httpAdapter.getInstance();
const fastifyStatic = loadPackage('fastify-static', 'AngularModule', () =>
require('fastify-static'),
);
const { setHeaders, redirect, ...send } =
options.serveStaticOptions || ({} as any);
const clientPath = options.rootPath;
const indexFilePath = this.getIndexFilePath(clientPath);
app.register(fastifyStatic, {
root: clientPath,
setHeaders,
redirect,
send,
});
app.get(options.renderPath, (req: any, res: any) => {
const stream = fs.createReadStream(indexFilePath);
res.type('text/html').send(stream);
});
}
}

View File

@@ -0,0 +1,12 @@
import { Injectable } from '@nestjs/common';
import { AbstractHttpAdapter } from '@nestjs/core';
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
import { AbstractLoader } from './abstract.loader';
@Injectable()
export class NoopLoader extends AbstractLoader {
public register(
httpAdapter: AbstractHttpAdapter,
options: AngularModuleOptions,
) {}
}

View File

@@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsNestModule",
"title": "Nest Module Options Schema",
"type": "object",
"properties": {
"initApp": {
"type": "boolean",
"description": "Flag to skip the angular application generation.",
"default": false,
"x-prompt": "Would you like to initialize Angular application?"
},
"name": {
"type": "string",
"description": "The name of the application.",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "What name would you like to (or do you) use for Angular application?"
}
},
"required": ["name"]
}