✨ 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
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import type {
|
|
CodeKeywordDefinition,
|
|
ErrorObject,
|
|
KeywordErrorDefinition,
|
|
AnySchema,
|
|
} from "../../types"
|
|
import type {KeywordCxt} from "../../compile/validate"
|
|
import {_, Name} from "../../compile/codegen"
|
|
import {alwaysValidSchema} from "../../compile/util"
|
|
import {SchemaCxt} from "../../compile"
|
|
|
|
export type OneOfError = ErrorObject<
|
|
"oneOf",
|
|
{passingSchemas: [number, number] | null},
|
|
AnySchema[]
|
|
>
|
|
|
|
const error: KeywordErrorDefinition = {
|
|
message: "must match exactly one schema in oneOf",
|
|
params: ({params}) => _`{passingSchemas: ${params.passing}}`,
|
|
}
|
|
|
|
const def: CodeKeywordDefinition = {
|
|
keyword: "oneOf",
|
|
schemaType: "array",
|
|
trackErrors: true,
|
|
error,
|
|
code(cxt: KeywordCxt) {
|
|
const {gen, schema, parentSchema, it} = cxt
|
|
/* istanbul ignore if */
|
|
if (!Array.isArray(schema)) throw new Error("ajv implementation error")
|
|
if (it.opts.discriminator && parentSchema.discriminator) return
|
|
const schArr: AnySchema[] = schema
|
|
const valid = gen.let("valid", false)
|
|
const passing = gen.let("passing", null)
|
|
const schValid = gen.name("_valid")
|
|
cxt.setParams({passing})
|
|
// TODO possibly fail straight away (with warning or exception) if there are two empty always valid schemas
|
|
|
|
gen.block(validateOneOf)
|
|
|
|
cxt.result(
|
|
valid,
|
|
() => cxt.reset(),
|
|
() => cxt.error(true)
|
|
)
|
|
|
|
function validateOneOf(): void {
|
|
schArr.forEach((sch: AnySchema, i: number) => {
|
|
let schCxt: SchemaCxt | undefined
|
|
if (alwaysValidSchema(it, sch)) {
|
|
gen.var(schValid, true)
|
|
} else {
|
|
schCxt = cxt.subschema(
|
|
{
|
|
keyword: "oneOf",
|
|
schemaProp: i,
|
|
compositeRule: true,
|
|
},
|
|
schValid
|
|
)
|
|
}
|
|
|
|
if (i > 0) {
|
|
gen
|
|
.if(_`${schValid} && ${valid}`)
|
|
.assign(valid, false)
|
|
.assign(passing, _`[${passing}, ${i}]`)
|
|
.else()
|
|
}
|
|
|
|
gen.if(schValid, () => {
|
|
gen.assign(valid, true)
|
|
gen.assign(passing, i)
|
|
if (schCxt) cxt.mergeEvaluated(schCxt, Name)
|
|
})
|
|
})
|
|
}
|
|
},
|
|
}
|
|
|
|
export default def
|