✨ 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
119 lines
3.7 KiB
TypeScript
119 lines
3.7 KiB
TypeScript
import type {
|
|
CodeKeywordDefinition,
|
|
AddedKeywordDefinition,
|
|
ErrorObject,
|
|
KeywordErrorDefinition,
|
|
AnySchema,
|
|
} from "../../types"
|
|
import {allSchemaProperties, usePattern, isOwnProperty} from "../code"
|
|
import {_, nil, or, not, Code, Name} from "../../compile/codegen"
|
|
import N from "../../compile/names"
|
|
import type {SubschemaArgs} from "../../compile/validate/subschema"
|
|
import {alwaysValidSchema, schemaRefOrVal, Type} from "../../compile/util"
|
|
|
|
export type AdditionalPropertiesError = ErrorObject<
|
|
"additionalProperties",
|
|
{additionalProperty: string},
|
|
AnySchema
|
|
>
|
|
|
|
const error: KeywordErrorDefinition = {
|
|
message: "must NOT have additional properties",
|
|
params: ({params}) => _`{additionalProperty: ${params.additionalProperty}}`,
|
|
}
|
|
|
|
const def: CodeKeywordDefinition & AddedKeywordDefinition = {
|
|
keyword: "additionalProperties",
|
|
type: ["object"],
|
|
schemaType: ["boolean", "object"],
|
|
allowUndefined: true,
|
|
trackErrors: true,
|
|
error,
|
|
code(cxt) {
|
|
const {gen, schema, parentSchema, data, errsCount, it} = cxt
|
|
/* istanbul ignore if */
|
|
if (!errsCount) throw new Error("ajv implementation error")
|
|
const {allErrors, opts} = it
|
|
it.props = true
|
|
if (opts.removeAdditional !== "all" && alwaysValidSchema(it, schema)) return
|
|
const props = allSchemaProperties(parentSchema.properties)
|
|
const patProps = allSchemaProperties(parentSchema.patternProperties)
|
|
checkAdditionalProperties()
|
|
cxt.ok(_`${errsCount} === ${N.errors}`)
|
|
|
|
function checkAdditionalProperties(): void {
|
|
gen.forIn("key", data, (key: Name) => {
|
|
if (!props.length && !patProps.length) additionalPropertyCode(key)
|
|
else gen.if(isAdditional(key), () => additionalPropertyCode(key))
|
|
})
|
|
}
|
|
|
|
function isAdditional(key: Name): Code {
|
|
let definedProp: Code
|
|
if (props.length > 8) {
|
|
// TODO maybe an option instead of hard-coded 8?
|
|
const propsSchema = schemaRefOrVal(it, parentSchema.properties, "properties")
|
|
definedProp = isOwnProperty(gen, propsSchema as Code, key)
|
|
} else if (props.length) {
|
|
definedProp = or(...props.map((p) => _`${key} === ${p}`))
|
|
} else {
|
|
definedProp = nil
|
|
}
|
|
if (patProps.length) {
|
|
definedProp = or(definedProp, ...patProps.map((p) => _`${usePattern(cxt, p)}.test(${key})`))
|
|
}
|
|
return not(definedProp)
|
|
}
|
|
|
|
function deleteAdditional(key: Name): void {
|
|
gen.code(_`delete ${data}[${key}]`)
|
|
}
|
|
|
|
function additionalPropertyCode(key: Name): void {
|
|
if (opts.removeAdditional === "all" || (opts.removeAdditional && schema === false)) {
|
|
deleteAdditional(key)
|
|
return
|
|
}
|
|
|
|
if (schema === false) {
|
|
cxt.setParams({additionalProperty: key})
|
|
cxt.error()
|
|
if (!allErrors) gen.break()
|
|
return
|
|
}
|
|
|
|
if (typeof schema == "object" && !alwaysValidSchema(it, schema)) {
|
|
const valid = gen.name("valid")
|
|
if (opts.removeAdditional === "failing") {
|
|
applyAdditionalSchema(key, valid, false)
|
|
gen.if(not(valid), () => {
|
|
cxt.reset()
|
|
deleteAdditional(key)
|
|
})
|
|
} else {
|
|
applyAdditionalSchema(key, valid)
|
|
if (!allErrors) gen.if(not(valid), () => gen.break())
|
|
}
|
|
}
|
|
}
|
|
|
|
function applyAdditionalSchema(key: Name, valid: Name, errors?: false): void {
|
|
const subschema: SubschemaArgs = {
|
|
keyword: "additionalProperties",
|
|
dataProp: key,
|
|
dataPropType: Type.Str,
|
|
}
|
|
if (errors === false) {
|
|
Object.assign(subschema, {
|
|
compositeRule: true,
|
|
createErrors: false,
|
|
allErrors: false,
|
|
})
|
|
}
|
|
cxt.subschema(subschema, valid)
|
|
}
|
|
},
|
|
}
|
|
|
|
export default def
|