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
136
pwa/node_modules/check-error/index.js
generated
vendored
Normal file
136
pwa/node_modules/check-error/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
function isErrorInstance(obj) {
|
||||
return obj instanceof Error || Object.prototype.toString.call(obj) === '[object Error]';
|
||||
}
|
||||
|
||||
function isRegExp(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .compatibleInstance(thrown, errorLike)
|
||||
*
|
||||
* Checks if two instances are compatible (strict equal).
|
||||
* Returns false if errorLike is not an instance of Error, because instances
|
||||
* can only be compatible if they're both error instances.
|
||||
*
|
||||
* @name compatibleInstance
|
||||
* @param {Error} thrown error
|
||||
* @param {Error|ErrorConstructor} errorLike object to compare against
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleInstance(thrown, errorLike) {
|
||||
return isErrorInstance(errorLike) && thrown === errorLike;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .compatibleConstructor(thrown, errorLike)
|
||||
*
|
||||
* Checks if two constructors are compatible.
|
||||
* This function can receive either an error constructor or
|
||||
* an error instance as the `errorLike` argument.
|
||||
* Constructors are compatible if they're the same or if one is
|
||||
* an instance of another.
|
||||
*
|
||||
* @name compatibleConstructor
|
||||
* @param {Error} thrown error
|
||||
* @param {Error|ErrorConstructor} errorLike object to compare against
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleConstructor(thrown, errorLike) {
|
||||
if (isErrorInstance(errorLike)) {
|
||||
// If `errorLike` is an instance of any error we compare their constructors
|
||||
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
||||
} else if ((typeof errorLike === 'object' || typeof errorLike === 'function') && errorLike.prototype) {
|
||||
// If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly
|
||||
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .compatibleMessage(thrown, errMatcher)
|
||||
*
|
||||
* Checks if an error's message is compatible with a matcher (String or RegExp).
|
||||
* If the message contains the String or passes the RegExp test,
|
||||
* it is considered compatible.
|
||||
*
|
||||
* @name compatibleMessage
|
||||
* @param {Error} thrown error
|
||||
* @param {String|RegExp} errMatcher to look for into the message
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleMessage(thrown, errMatcher) {
|
||||
const comparisonString = typeof thrown === 'string' ? thrown : thrown.message;
|
||||
if (comparisonString === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (isRegExp(errMatcher)) {
|
||||
return errMatcher.test(comparisonString);
|
||||
} else if (typeof errMatcher === 'string') {
|
||||
return comparisonString.indexOf(errMatcher) !== -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getConstructorName(errorLike)
|
||||
*
|
||||
* Gets the constructor name for an Error instance or constructor itself.
|
||||
*
|
||||
* @name getConstructorName
|
||||
* @param {Error|ErrorConstructor} errorLike
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function getConstructorName(errorLike) {
|
||||
let constructorName = errorLike;
|
||||
if (isErrorInstance(errorLike)) {
|
||||
constructorName = errorLike.constructor.name;
|
||||
} else if (typeof errorLike === 'function') {
|
||||
// If `err` is not an instance of Error it is an error constructor itself or another function.
|
||||
// If we've got a common function we get its name, otherwise we may need to create a new instance
|
||||
// of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
|
||||
constructorName = errorLike.name;
|
||||
if (constructorName === '') {
|
||||
const newConstructorName = (new errorLike().name);
|
||||
constructorName = newConstructorName || constructorName;
|
||||
}
|
||||
}
|
||||
|
||||
return constructorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getMessage(errorLike)
|
||||
*
|
||||
* Gets the error message from an error.
|
||||
* If `err` is a String itself, we return it.
|
||||
* If the error has no message, we return an empty string.
|
||||
*
|
||||
* @name getMessage
|
||||
* @param {Error|String} errorLike
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function getMessage(errorLike) {
|
||||
let msg = '';
|
||||
if (errorLike && errorLike.message) {
|
||||
msg = errorLike.message;
|
||||
} else if (typeof errorLike === 'string') {
|
||||
msg = errorLike;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
export { compatibleInstance, compatibleConstructor, compatibleMessage, getMessage, getConstructorName };
|
||||
Loading…
Add table
Add a link
Reference in a new issue