✨ 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
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import type {CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject} from "../../types"
|
|
import type {KeywordCxt} from "../../compile/validate"
|
|
import {_, or, and, Code} from "../../compile/codegen"
|
|
import {checkMetadata} from "./metadata"
|
|
import {checkNullable} from "./nullable"
|
|
|
|
export type JTDEnumError = ErrorObject<"enum", {allowedValues: string[]}, string[]>
|
|
|
|
const error: KeywordErrorDefinition = {
|
|
message: "must be equal to one of the allowed values",
|
|
params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`,
|
|
}
|
|
|
|
const def: CodeKeywordDefinition = {
|
|
keyword: "enum",
|
|
schemaType: "array",
|
|
error,
|
|
code(cxt: KeywordCxt) {
|
|
checkMetadata(cxt)
|
|
const {gen, data, schema, schemaValue, parentSchema, it} = cxt
|
|
if (schema.length === 0) throw new Error("enum must have non-empty array")
|
|
if (schema.length !== new Set(schema).size) throw new Error("enum items must be unique")
|
|
let valid: Code
|
|
const isString = _`typeof ${data} == "string"`
|
|
if (schema.length >= it.opts.loopEnum) {
|
|
let cond: Code
|
|
;[valid, cond] = checkNullable(cxt, isString)
|
|
gen.if(cond, loopEnum)
|
|
} else {
|
|
/* istanbul ignore if */
|
|
if (!Array.isArray(schema)) throw new Error("ajv implementation error")
|
|
valid = and(isString, or(...schema.map((value: string) => _`${data} === ${value}`)))
|
|
if (parentSchema.nullable) valid = or(_`${data} === null`, valid)
|
|
}
|
|
cxt.pass(valid)
|
|
|
|
function loopEnum(): void {
|
|
gen.forOf("v", schemaValue as Code, (v) =>
|
|
gen.if(_`${valid} = ${data} === ${v}`, () => gen.break())
|
|
)
|
|
}
|
|
},
|
|
}
|
|
|
|
export default def
|