✨ 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
80 lines
2.6 KiB
TypeScript
80 lines
2.6 KiB
TypeScript
import type {CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition} from "../../types"
|
|
import type {KeywordCxt} from "../../compile/validate"
|
|
import {checkDataTypes, getSchemaTypes, DataType} from "../../compile/validate/dataType"
|
|
import {_, str, Name} from "../../compile/codegen"
|
|
import {useFunc} from "../../compile/util"
|
|
import equal from "../../runtime/equal"
|
|
|
|
export type UniqueItemsError = ErrorObject<
|
|
"uniqueItems",
|
|
{i: number; j: number},
|
|
boolean | {$data: string}
|
|
>
|
|
|
|
const error: KeywordErrorDefinition = {
|
|
message: ({params: {i, j}}) =>
|
|
str`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
|
|
params: ({params: {i, j}}) => _`{i: ${i}, j: ${j}}`,
|
|
}
|
|
|
|
const def: CodeKeywordDefinition = {
|
|
keyword: "uniqueItems",
|
|
type: "array",
|
|
schemaType: "boolean",
|
|
$data: true,
|
|
error,
|
|
code(cxt: KeywordCxt) {
|
|
const {gen, data, $data, schema, parentSchema, schemaCode, it} = cxt
|
|
if (!$data && !schema) return
|
|
const valid = gen.let("valid")
|
|
const itemTypes = parentSchema.items ? getSchemaTypes(parentSchema.items) : []
|
|
cxt.block$data(valid, validateUniqueItems, _`${schemaCode} === false`)
|
|
cxt.ok(valid)
|
|
|
|
function validateUniqueItems(): void {
|
|
const i = gen.let("i", _`${data}.length`)
|
|
const j = gen.let("j")
|
|
cxt.setParams({i, j})
|
|
gen.assign(valid, true)
|
|
gen.if(_`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j))
|
|
}
|
|
|
|
function canOptimize(): boolean {
|
|
return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array")
|
|
}
|
|
|
|
function loopN(i: Name, j: Name): void {
|
|
const item = gen.name("item")
|
|
const wrongType = checkDataTypes(itemTypes, item, it.opts.strictNumbers, DataType.Wrong)
|
|
const indices = gen.const("indices", _`{}`)
|
|
gen.for(_`;${i}--;`, () => {
|
|
gen.let(item, _`${data}[${i}]`)
|
|
gen.if(wrongType, _`continue`)
|
|
if (itemTypes.length > 1) gen.if(_`typeof ${item} == "string"`, _`${item} += "_"`)
|
|
gen
|
|
.if(_`typeof ${indices}[${item}] == "number"`, () => {
|
|
gen.assign(j, _`${indices}[${item}]`)
|
|
cxt.error()
|
|
gen.assign(valid, false).break()
|
|
})
|
|
.code(_`${indices}[${item}] = ${i}`)
|
|
})
|
|
}
|
|
|
|
function loopN2(i: Name, j: Name): void {
|
|
const eql = useFunc(gen, equal)
|
|
const outer = gen.name("outer")
|
|
gen.label(outer).for(_`;${i}--;`, () =>
|
|
gen.for(_`${j} = ${i}; ${j}--;`, () =>
|
|
gen.if(_`${eql}(${data}[${i}], ${data}[${j}])`, () => {
|
|
cxt.error()
|
|
gen.assign(valid, false).break(outer)
|
|
})
|
|
)
|
|
)
|
|
}
|
|
},
|
|
}
|
|
|
|
export default def
|