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>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
|
|
var isPrimitive = require('./helpers/isPrimitive');
|
|
|
|
var isCallable = require('is-callable');
|
|
|
|
/** @type {{ [k in `[[${string}]]`]: (O: { toString?: unknown, valueOf?: unknown }, actualHint?: StringConstructor | NumberConstructor) => null | undefined | string | symbol | number | boolean | bigint; }} */
|
|
// http://ecma-international.org/ecma-262/5.1/#sec-8.12.8
|
|
var ES5internalSlots = {
|
|
'[[DefaultValue]]': function (O) {
|
|
var actualHint;
|
|
if (arguments.length > 1) {
|
|
actualHint = arguments[1];
|
|
} else {
|
|
actualHint = toStr.call(O) === '[object Date]' ? String : Number;
|
|
}
|
|
|
|
if (actualHint === String || actualHint === Number) {
|
|
/** @type {('toString' | 'valueOf')[]} */
|
|
var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
|
|
var value, i;
|
|
for (i = 0; i < methods.length; ++i) {
|
|
var method = methods[i];
|
|
if (isCallable(O[method])) {
|
|
// eslint-disable-next-line no-extra-parens
|
|
value = /** @type {Function} */ (O[method])();
|
|
if (isPrimitive(value)) {
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
throw new TypeError('No default value');
|
|
}
|
|
throw new TypeError('invalid [[DefaultValue]] hint supplied');
|
|
}
|
|
};
|
|
|
|
/** @type {import('./es5')} */
|
|
// http://ecma-international.org/ecma-262/5.1/#sec-9.1
|
|
module.exports = function ToPrimitive(input) {
|
|
if (isPrimitive(input)) {
|
|
return input;
|
|
}
|
|
if (arguments.length > 1) {
|
|
// eslint-disable-next-line no-extra-parens
|
|
return ES5internalSlots['[[DefaultValue]]'](/** @type {object} */ (input), arguments[1]);
|
|
}
|
|
// eslint-disable-next-line no-extra-parens
|
|
return ES5internalSlots['[[DefaultValue]]'](/** @type {object} */ (input));
|
|
};
|