Files
Laca-City/backend/node_modules/@nestjs/swagger/dist/swagger-module.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

180 lines
9.3 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SwaggerModule = void 0;
const jsyaml = require("js-yaml");
const metadata_loader_1 = require("./plugin/metadata-loader");
const swagger_scanner_1 = require("./swagger-scanner");
const swagger_ui_1 = require("./swagger-ui");
const assign_two_levels_deep_1 = require("./utils/assign-two-levels-deep");
const get_global_prefix_1 = require("./utils/get-global-prefix");
const normalize_rel_path_1 = require("./utils/normalize-rel-path");
const resolve_path_util_1 = require("./utils/resolve-path.util");
const validate_global_prefix_util_1 = require("./utils/validate-global-prefix.util");
const validate_path_util_1 = require("./utils/validate-path.util");
class SwaggerModule {
static createDocument(app, config, options = {}) {
const swaggerScanner = new swagger_scanner_1.SwaggerScanner();
const document = swaggerScanner.scanApplication(app, options);
document.components = (0, assign_two_levels_deep_1.assignTwoLevelsDeep)({}, config.components, document.components);
return Object.assign(Object.assign({ openapi: '3.0.0', paths: {} }, config), document);
}
static loadPluginMetadata(metadataFn) {
return __awaiter(this, void 0, void 0, function* () {
const metadata = yield metadataFn();
return this.metadataLoader.load(metadata);
});
}
static serveStatic(finalPath, app, customStaticPath) {
const httpAdapter = app.getHttpAdapter();
const swaggerAssetsPath = customStaticPath
? (0, resolve_path_util_1.resolvePath)(customStaticPath)
: (0, swagger_ui_1.getSwaggerAssetsAbsoluteFSPath)();
if (httpAdapter && httpAdapter.getType() === 'fastify') {
app.useStaticAssets({
root: swaggerAssetsPath,
prefix: finalPath,
decorateReply: false
});
}
else {
app.useStaticAssets(swaggerAssetsPath, {
prefix: finalPath
});
}
}
static serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, documentOrFactory, options) {
let document;
const getBuiltDocument = () => {
if (!document) {
document =
typeof documentOrFactory === 'function'
? documentOrFactory()
: documentOrFactory;
}
return document;
};
if (options.swaggerUiEnabled) {
this.serveSwaggerUi(finalPath, urlLastSubdirectory, httpAdapter, getBuiltDocument, options.swaggerOptions);
}
this.serveDefinitions(httpAdapter, getBuiltDocument, options);
}
static serveSwaggerUi(finalPath, urlLastSubdirectory, httpAdapter, getBuiltDocument, swaggerOptions) {
const baseUrlForSwaggerUI = (0, normalize_rel_path_1.normalizeRelPath)(`./${urlLastSubdirectory}/`);
let swaggerUiHtml;
let swaggerUiInitJS;
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}/swagger-ui-init.js`), (req, res) => {
res.type('application/javascript');
const document = getBuiltDocument();
if (swaggerOptions.patchDocumentOnRequest) {
const documentToSerialize = swaggerOptions.patchDocumentOnRequest(req, res, document);
const swaggerInitJsPerRequest = (0, swagger_ui_1.buildSwaggerInitJS)(documentToSerialize, swaggerOptions);
return res.send(swaggerInitJsPerRequest);
}
if (!swaggerUiInitJS) {
swaggerUiInitJS = (0, swagger_ui_1.buildSwaggerInitJS)(document, swaggerOptions);
}
res.send(swaggerUiInitJS);
});
try {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}/${urlLastSubdirectory}/swagger-ui-init.js`), (req, res) => {
res.type('application/javascript');
const document = getBuiltDocument();
if (swaggerOptions.patchDocumentOnRequest) {
const documentToSerialize = swaggerOptions.patchDocumentOnRequest(req, res, document);
const swaggerInitJsPerRequest = (0, swagger_ui_1.buildSwaggerInitJS)(documentToSerialize, swaggerOptions);
return res.send(swaggerInitJsPerRequest);
}
if (!swaggerUiInitJS) {
swaggerUiInitJS = (0, swagger_ui_1.buildSwaggerInitJS)(document, swaggerOptions);
}
res.send(swaggerUiInitJS);
});
}
catch (err) {
}
httpAdapter.get(finalPath, (_, res) => {
res.type('text/html');
if (!swaggerUiHtml) {
swaggerUiHtml = (0, swagger_ui_1.buildSwaggerHTML)(baseUrlForSwaggerUI, swaggerOptions);
}
res.send(swaggerUiHtml);
});
try {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}/`), (_, res) => {
res.type('text/html');
if (!swaggerUiHtml) {
swaggerUiHtml = (0, swagger_ui_1.buildSwaggerHTML)(baseUrlForSwaggerUI, swaggerOptions);
}
res.send(swaggerUiHtml);
});
}
catch (err) {
}
}
static serveDefinitions(httpAdapter, getBuiltDocument, options) {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(options.jsonDocumentUrl), (req, res) => {
res.type('application/json');
const document = getBuiltDocument();
const documentToSerialize = options.swaggerOptions.patchDocumentOnRequest
? options.swaggerOptions.patchDocumentOnRequest(req, res, document)
: document;
res.send(JSON.stringify(documentToSerialize));
});
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(options.yamlDocumentUrl), (req, res) => {
res.type('text/yaml');
const document = getBuiltDocument();
const documentToSerialize = options.swaggerOptions.patchDocumentOnRequest
? options.swaggerOptions.patchDocumentOnRequest(req, res, document)
: document;
const yamlDocument = jsyaml.dump(documentToSerialize, {
skipInvalid: true,
noRefs: true
});
res.send(yamlDocument);
});
}
static setup(path, app, documentOrFactory, options) {
var _a;
const globalPrefix = (0, get_global_prefix_1.getGlobalPrefix)(app);
const finalPath = (0, validate_path_util_1.validatePath)((options === null || options === void 0 ? void 0 : options.useGlobalPrefix) && (0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)
? `${globalPrefix}${(0, validate_path_util_1.validatePath)(path)}`
: path);
const urlLastSubdirectory = finalPath.split('/').slice(-1).pop() || '';
const validatedGlobalPrefix = (options === null || options === void 0 ? void 0 : options.useGlobalPrefix) && (0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)
? (0, validate_path_util_1.validatePath)(globalPrefix)
: '';
const finalJSONDocumentPath = (options === null || options === void 0 ? void 0 : options.jsonDocumentUrl)
? `${validatedGlobalPrefix}${(0, validate_path_util_1.validatePath)(options.jsonDocumentUrl)}`
: `${finalPath}-json`;
const finalYAMLDocumentPath = (options === null || options === void 0 ? void 0 : options.yamlDocumentUrl)
? `${validatedGlobalPrefix}${(0, validate_path_util_1.validatePath)(options.yamlDocumentUrl)}`
: `${finalPath}-yaml`;
const swaggerUiEnabled = (_a = options === null || options === void 0 ? void 0 : options.swaggerUiEnabled) !== null && _a !== void 0 ? _a : true;
const httpAdapter = app.getHttpAdapter();
SwaggerModule.serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, documentOrFactory, {
swaggerUiEnabled,
jsonDocumentUrl: finalJSONDocumentPath,
yamlDocumentUrl: finalYAMLDocumentPath,
swaggerOptions: options || {}
});
if (swaggerUiEnabled) {
SwaggerModule.serveStatic(finalPath, app, options === null || options === void 0 ? void 0 : options.customSwaggerUiPath);
const serveStaticSlashEndingPath = `${finalPath}/${urlLastSubdirectory}`;
if (serveStaticSlashEndingPath !== finalPath) {
SwaggerModule.serveStatic(serveStaticSlashEndingPath, app);
}
}
}
}
exports.SwaggerModule = SwaggerModule;
SwaggerModule.metadataLoader = new metadata_loader_1.MetadataLoader();