Add progressive web app companion for cross-platform access
Vite + TypeScript PWA that mirrors the Android app's core features: - Pre-processed shelter data (build-time UTM33N→WGS84 conversion) - Leaflet map with shelter markers, user location, and offline tiles - Canvas compass arrow (ported from DirectionArrowView.kt) - IndexedDB shelter cache with 7-day staleness check - Service worker with CacheFirst tiles and precached app shell - i18n for en, nb, nn (ported from Android strings.xml) - iOS/Android compass handling with low-pass filter - Respects user map interaction (no auto-snap on pan/zoom) - Build revision cache-breaker for reliable SW updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
46365b713b
commit
e8428de775
12051 changed files with 1799735 additions and 0 deletions
46
pwa/node_modules/ajv/lib/runtime/timestamp.ts
generated
vendored
Normal file
46
pwa/node_modules/ajv/lib/runtime/timestamp.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
const DT_SEPARATOR = /t|\s/i
|
||||
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
|
||||
const TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i
|
||||
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
|
||||
export default function validTimestamp(str: string, allowDate: boolean): boolean {
|
||||
// http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
const dt: string[] = str.split(DT_SEPARATOR)
|
||||
return (
|
||||
(dt.length === 2 && validDate(dt[0]) && validTime(dt[1])) ||
|
||||
(allowDate && dt.length === 1 && validDate(dt[0]))
|
||||
)
|
||||
}
|
||||
|
||||
function validDate(str: string): boolean {
|
||||
const matches: string[] | null = DATE.exec(str)
|
||||
if (!matches) return false
|
||||
const y: number = +matches[1]
|
||||
const m: number = +matches[2]
|
||||
const d: number = +matches[3]
|
||||
return (
|
||||
m >= 1 &&
|
||||
m <= 12 &&
|
||||
d >= 1 &&
|
||||
(d <= DAYS[m] ||
|
||||
// leap year: https://tools.ietf.org/html/rfc3339#appendix-C
|
||||
(m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0)))
|
||||
)
|
||||
}
|
||||
|
||||
function validTime(str: string): boolean {
|
||||
const matches: string[] | null = TIME.exec(str)
|
||||
if (!matches) return false
|
||||
const hr: number = +matches[1]
|
||||
const min: number = +matches[2]
|
||||
const sec: number = +matches[3]
|
||||
const tzH: number = +(matches[4] || 0)
|
||||
const tzM: number = +(matches[5] || 0)
|
||||
return (
|
||||
(hr <= 23 && min <= 59 && sec <= 59) ||
|
||||
// leap second
|
||||
(hr - tzH === 23 && min - tzM === 59 && sec === 60)
|
||||
)
|
||||
}
|
||||
|
||||
validTimestamp.code = 'require("ajv/dist/runtime/timestamp").default'
|
||||
Loading…
Add table
Add a link
Reference in a new issue