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>
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
import { parseRegexp } from '@vitest/utils';
|
|
|
|
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
|
const processSend = process.send?.bind(process);
|
|
const processOn = process.on?.bind(process);
|
|
const processOff = process.off?.bind(process);
|
|
const dispose = [];
|
|
function createThreadsRpcOptions({
|
|
port
|
|
}) {
|
|
return {
|
|
post: (v) => {
|
|
port.postMessage(v);
|
|
},
|
|
on: (fn) => {
|
|
port.addListener("message", fn);
|
|
}
|
|
};
|
|
}
|
|
function disposeInternalListeners() {
|
|
for (const fn of dispose) {
|
|
try {
|
|
fn();
|
|
} catch {
|
|
}
|
|
}
|
|
dispose.length = 0;
|
|
}
|
|
function createForksRpcOptions(nodeV8) {
|
|
return {
|
|
serialize: nodeV8.serialize,
|
|
deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
|
|
post(v) {
|
|
processSend(v);
|
|
},
|
|
on(fn) {
|
|
const handler = (message, ...extras) => {
|
|
if (message?.__tinypool_worker_message__) {
|
|
return;
|
|
}
|
|
return fn(message, ...extras);
|
|
};
|
|
processOn("message", handler);
|
|
dispose.push(() => processOff("message", handler));
|
|
}
|
|
};
|
|
}
|
|
function unwrapSerializableConfig(config) {
|
|
if (config.testNamePattern && typeof config.testNamePattern === "string") {
|
|
const testNamePattern = config.testNamePattern;
|
|
if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX)) {
|
|
config.testNamePattern = parseRegexp(
|
|
testNamePattern.slice(REGEXP_WRAP_PREFIX.length)
|
|
);
|
|
}
|
|
}
|
|
if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
|
|
const { keys, original } = config.defines;
|
|
const defines = {};
|
|
for (const key of keys) {
|
|
defines[key] = original[key];
|
|
}
|
|
config.defines = defines;
|
|
}
|
|
return config;
|
|
}
|
|
|
|
export { createThreadsRpcOptions as a, createForksRpcOptions as c, disposeInternalListeners as d, unwrapSerializableConfig as u };
|