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
21
pwa/node_modules/tinyspy/LICENCE
generated
vendored
Normal file
21
pwa/node_modules/tinyspy/LICENCE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Tinylibs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
11
pwa/node_modules/tinyspy/README.md
generated
vendored
Normal file
11
pwa/node_modules/tinyspy/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# tinyspy
|
||||
|
||||
> minimal fork of nanospy, with more features 🕵🏻♂️
|
||||
|
||||
A `10KB` package for minimal and easy testing with no dependencies.
|
||||
This package was created for having a tiny spy library to use in `vitest`, but it can also be used in `jest` and other test environments.
|
||||
|
||||
_In case you need more tiny libraries like tinypool or tinyspy, please consider submitting an [RFC](https://github.com/tinylibs/rfcs)_
|
||||
|
||||
## Docs
|
||||
Read full docs **[here](https://github.com/tinylibs/tinyspy#readme)**.
|
||||
179
pwa/node_modules/tinyspy/dist/index.cjs
generated
vendored
Normal file
179
pwa/node_modules/tinyspy/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
"use strict";
|
||||
var w = Object.defineProperty;
|
||||
var C = Object.getOwnPropertyDescriptor;
|
||||
var M = Object.getOwnPropertyNames;
|
||||
var E = Object.prototype.hasOwnProperty;
|
||||
var G = (e, t) => {
|
||||
for (var r in t)
|
||||
w(e, r, { get: t[r], enumerable: !0 });
|
||||
}, F = (e, t, r, s) => {
|
||||
if (t && typeof t == "object" || typeof t == "function")
|
||||
for (let n of M(t))
|
||||
!E.call(e, n) && n !== r && w(e, n, { get: () => t[n], enumerable: !(s = C(t, n)) || s.enumerable });
|
||||
return e;
|
||||
};
|
||||
var j = (e) => F(w({}, "__esModule", { value: !0 }), e);
|
||||
|
||||
// src/index.ts
|
||||
var $ = {};
|
||||
G($, {
|
||||
createInternalSpy: () => S,
|
||||
getInternalState: () => I,
|
||||
internalSpyOn: () => P,
|
||||
restoreAll: () => _,
|
||||
spies: () => c,
|
||||
spy: () => V,
|
||||
spyOn: () => L
|
||||
});
|
||||
module.exports = j($);
|
||||
|
||||
// src/utils.ts
|
||||
function x(e, t) {
|
||||
if (!e)
|
||||
throw new Error(t);
|
||||
}
|
||||
function y(e, t) {
|
||||
return typeof t === e;
|
||||
}
|
||||
function k(e) {
|
||||
return e instanceof Promise;
|
||||
}
|
||||
function f(e, t, r) {
|
||||
Object.defineProperty(e, t, r);
|
||||
}
|
||||
function l(e, t, r) {
|
||||
Object.defineProperty(e, t, { value: r });
|
||||
}
|
||||
|
||||
// src/constants.ts
|
||||
var u = Symbol.for("tinyspy:spy");
|
||||
|
||||
// src/internal.ts
|
||||
var c = /* @__PURE__ */ new Set(), D = (e) => {
|
||||
e.called = !1, e.callCount = 0, e.calls = [], e.results = [], e.resolves = [], e.next = [];
|
||||
}, q = (e) => (f(e, u, { value: { reset: () => D(e[u]) } }), e[u]), I = (e) => e[u] || q(e);
|
||||
function S(e) {
|
||||
x(
|
||||
y("function", e) || y("undefined", e),
|
||||
"cannot spy on a non-function value"
|
||||
);
|
||||
let t = function(...s) {
|
||||
let n = I(t);
|
||||
n.called = !0, n.callCount++, n.calls.push(s);
|
||||
let R = n.next.shift();
|
||||
if (R) {
|
||||
n.results.push(R);
|
||||
let [o, m] = R;
|
||||
if (o === "ok")
|
||||
return m;
|
||||
throw m;
|
||||
}
|
||||
let p, d = "ok", a = n.results.length;
|
||||
if (n.impl)
|
||||
try {
|
||||
new.target ? p = Reflect.construct(n.impl, s, new.target) : p = n.impl.apply(this, s), d = "ok";
|
||||
} catch (o) {
|
||||
throw p = o, d = "error", n.results.push([d, o]), o;
|
||||
}
|
||||
let g = [d, p];
|
||||
return k(p) && p.then(
|
||||
(o) => n.resolves[a] = ["ok", o],
|
||||
(o) => n.resolves[a] = ["error", o]
|
||||
), n.results.push(g), p;
|
||||
};
|
||||
l(t, "_isMockFunction", !0), l(t, "length", e ? e.length : 0), l(t, "name", e && e.name || "spy");
|
||||
let r = I(t);
|
||||
return r.reset(), r.impl = e, t;
|
||||
}
|
||||
function A(e) {
|
||||
let t = I(e);
|
||||
"returns" in e || (f(e, "returns", {
|
||||
get: () => t.results.map(([, r]) => r)
|
||||
}), [
|
||||
"called",
|
||||
"callCount",
|
||||
"results",
|
||||
"resolves",
|
||||
"calls",
|
||||
"reset",
|
||||
"impl"
|
||||
].forEach(
|
||||
(r) => f(e, r, { get: () => t[r], set: (s) => t[r] = s })
|
||||
), l(e, "nextError", (r) => (t.next.push(["error", r]), t)), l(e, "nextResult", (r) => (t.next.push(["ok", r]), t)));
|
||||
}
|
||||
|
||||
// src/spy.ts
|
||||
function V(e) {
|
||||
let t = S(e);
|
||||
return A(t), t;
|
||||
}
|
||||
|
||||
// src/spyOn.ts
|
||||
var O = (e, t) => Object.getOwnPropertyDescriptor(e, t), b = (e, t) => {
|
||||
t != null && typeof t == "function" && t.prototype != null && Object.setPrototypeOf(e.prototype, t.prototype);
|
||||
};
|
||||
function P(e, t, r) {
|
||||
x(
|
||||
!y("undefined", e),
|
||||
"spyOn could not find an object to spy upon"
|
||||
), x(
|
||||
y("object", e) || y("function", e),
|
||||
"cannot spyOn on a primitive value"
|
||||
);
|
||||
let [s, n] = (() => {
|
||||
if (!y("object", t))
|
||||
return [t, "value"];
|
||||
if ("getter" in t && "setter" in t)
|
||||
throw new Error("cannot spy on both getter and setter");
|
||||
if ("getter" in t)
|
||||
return [t.getter, "get"];
|
||||
if ("setter" in t)
|
||||
return [t.setter, "set"];
|
||||
throw new Error("specify getter or setter to spy on");
|
||||
})(), R = O(e, s), p = Object.getPrototypeOf(e), d = p && O(p, s), a = R || d;
|
||||
x(
|
||||
a || s in e,
|
||||
`${String(s)} does not exist`
|
||||
);
|
||||
let g = !1;
|
||||
n === "value" && a && !a.value && a.get && (n = "get", g = !0, r = a.get());
|
||||
let o;
|
||||
a ? o = a[n] : n !== "value" ? o = () => e[s] : o = e[s];
|
||||
let m = (v) => {
|
||||
let { value: z, ...h } = a || {
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
};
|
||||
n !== "value" && delete h.writable, h[n] = v, f(e, s, h);
|
||||
}, K = () => a ? f(e, s, a) : m(o);
|
||||
r || (r = o);
|
||||
let i = S(r);
|
||||
n === "value" && b(i, o);
|
||||
let T = i[u];
|
||||
return l(T, "restore", K), l(T, "getOriginal", () => g ? o() : o), l(T, "willCall", (v) => (T.impl = v, i)), m(
|
||||
g ? () => (b(i, r), i) : i
|
||||
), c.add(i), i;
|
||||
}
|
||||
function L(e, t, r) {
|
||||
let s = P(e, t, r);
|
||||
return A(s), ["restore", "getOriginal", "willCall"].forEach((n) => {
|
||||
l(s, n, s[u][n]);
|
||||
}), s;
|
||||
}
|
||||
|
||||
// src/restoreAll.ts
|
||||
function _() {
|
||||
for (let e of c)
|
||||
e.restore();
|
||||
c.clear();
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createInternalSpy,
|
||||
getInternalState,
|
||||
internalSpyOn,
|
||||
restoreAll,
|
||||
spies,
|
||||
spy,
|
||||
spyOn
|
||||
});
|
||||
83
pwa/node_modules/tinyspy/dist/index.d.cts
generated
vendored
Normal file
83
pwa/node_modules/tinyspy/dist/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
declare const S: unique symbol;
|
||||
|
||||
interface GetState {
|
||||
<A extends any[], R>(spy: SpyInternalImpl<A, R>): SpyInternalImplState<A, R>;
|
||||
<A extends any[], R>(spy: SpyInternal<A, R>): SpyInternalState<A, R>;
|
||||
}
|
||||
declare let spies: Set<SpyImpl<any[], any>>;
|
||||
declare let getInternalState: GetState;
|
||||
type ReturnError = ['error', any];
|
||||
type ReturnOk<R> = ['ok', R];
|
||||
type ResultFn<R> = ReturnError | ReturnOk<R>;
|
||||
interface SpyInternal<A extends any[] = any[], R = any> {
|
||||
(this: any, ...args: A): R;
|
||||
[S]: SpyInternalState<A, R>;
|
||||
}
|
||||
interface SpyInternalImpl<A extends any[] = any[], R = any> extends SpyInternal<A, R> {
|
||||
[S]: SpyInternalImplState<A, R>;
|
||||
}
|
||||
interface SpyInternalState<A extends any[] = any[], R = any> {
|
||||
called: boolean;
|
||||
callCount: number;
|
||||
calls: A[];
|
||||
results: ResultFn<R>[];
|
||||
resolves: R extends PromiseLike<infer V> ? ResultFn<V>[] : never;
|
||||
reset(): void;
|
||||
impl: ((...args: A) => R) | undefined;
|
||||
next: ResultFn<R>[];
|
||||
}
|
||||
interface SpyInternalImplState<A extends any[] = any[], R = any> extends SpyInternalState<A, R> {
|
||||
getOriginal(): (...args: A) => R;
|
||||
willCall(cb: (...args: A) => R): this;
|
||||
restore(): void;
|
||||
}
|
||||
interface Spy<A extends any[] = any[], R = any> extends SpyInternalState<A, R> {
|
||||
returns: R[];
|
||||
length: number;
|
||||
nextError(error: any): this;
|
||||
nextResult(result: R): this;
|
||||
}
|
||||
interface SpyImpl<A extends any[] = any[], R = any> extends Spy<A, R> {
|
||||
getOriginal(): (...args: A) => R;
|
||||
willCall(cb: (...args: A) => R): this;
|
||||
restore(): void;
|
||||
}
|
||||
declare function createInternalSpy<A extends any[], R>(cb?: ((...args: A) => R) | {
|
||||
new (...args: A): R;
|
||||
}): SpyInternal<A, R>;
|
||||
|
||||
interface SpyFn<A extends any[] = any[], R = any> extends Spy<A, R> {
|
||||
new (...args: A): R extends void ? any : R;
|
||||
(...args: A): R;
|
||||
}
|
||||
declare function spy<A extends any[], R>(cb?: ((...args: A) => R) | {
|
||||
new (...args: A): R;
|
||||
}): SpyFn<A, R>;
|
||||
|
||||
type Procedure = (...args: any[]) => any;
|
||||
type Methods<T> = {
|
||||
[K in keyof T]: T[K] extends Procedure ? K : never;
|
||||
}[keyof T];
|
||||
type Getters<T> = {
|
||||
[K in keyof T]: T[K] extends Procedure ? never : K;
|
||||
}[keyof T];
|
||||
type Constructors<T> = {
|
||||
[K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
|
||||
}[keyof T];
|
||||
declare function internalSpyOn<T, K extends string & keyof T>(obj: T, methodName: K | {
|
||||
getter: K;
|
||||
} | {
|
||||
setter: K;
|
||||
}, mock?: Procedure): SpyInternalImpl<any[], any>;
|
||||
declare function spyOn<T, S extends Getters<Required<T>>>(obj: T, methodName: {
|
||||
setter: S;
|
||||
}, mock?: (arg: T[S]) => void): SpyImpl<[T[S]], void>;
|
||||
declare function spyOn<T, G extends Getters<Required<T>>>(obj: T, methodName: {
|
||||
getter: G;
|
||||
}, mock?: () => T[G]): SpyImpl<[], T[G]>;
|
||||
declare function spyOn<T, M extends Constructors<Required<T>>>(object: T, method: M): Required<T>[M] extends new (...args: infer A) => infer R ? SpyImpl<A, R> : never;
|
||||
declare function spyOn<T, M extends Methods<Required<T>>>(obj: T, methodName: M, mock?: T[M]): Required<T>[M] extends (...args: infer A) => infer R ? SpyImpl<A, R> : never;
|
||||
|
||||
declare function restoreAll(): void;
|
||||
|
||||
export { type Spy, type SpyFn, type SpyImpl, type SpyInternal, type SpyInternalImpl, createInternalSpy, getInternalState, internalSpyOn, restoreAll, spies, spy, spyOn };
|
||||
83
pwa/node_modules/tinyspy/dist/index.d.ts
generated
vendored
Normal file
83
pwa/node_modules/tinyspy/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
declare const S: unique symbol;
|
||||
|
||||
interface GetState {
|
||||
<A extends any[], R>(spy: SpyInternalImpl<A, R>): SpyInternalImplState<A, R>;
|
||||
<A extends any[], R>(spy: SpyInternal<A, R>): SpyInternalState<A, R>;
|
||||
}
|
||||
declare let spies: Set<SpyImpl<any[], any>>;
|
||||
declare let getInternalState: GetState;
|
||||
type ReturnError = ['error', any];
|
||||
type ReturnOk<R> = ['ok', R];
|
||||
type ResultFn<R> = ReturnError | ReturnOk<R>;
|
||||
interface SpyInternal<A extends any[] = any[], R = any> {
|
||||
(this: any, ...args: A): R;
|
||||
[S]: SpyInternalState<A, R>;
|
||||
}
|
||||
interface SpyInternalImpl<A extends any[] = any[], R = any> extends SpyInternal<A, R> {
|
||||
[S]: SpyInternalImplState<A, R>;
|
||||
}
|
||||
interface SpyInternalState<A extends any[] = any[], R = any> {
|
||||
called: boolean;
|
||||
callCount: number;
|
||||
calls: A[];
|
||||
results: ResultFn<R>[];
|
||||
resolves: R extends PromiseLike<infer V> ? ResultFn<V>[] : never;
|
||||
reset(): void;
|
||||
impl: ((...args: A) => R) | undefined;
|
||||
next: ResultFn<R>[];
|
||||
}
|
||||
interface SpyInternalImplState<A extends any[] = any[], R = any> extends SpyInternalState<A, R> {
|
||||
getOriginal(): (...args: A) => R;
|
||||
willCall(cb: (...args: A) => R): this;
|
||||
restore(): void;
|
||||
}
|
||||
interface Spy<A extends any[] = any[], R = any> extends SpyInternalState<A, R> {
|
||||
returns: R[];
|
||||
length: number;
|
||||
nextError(error: any): this;
|
||||
nextResult(result: R): this;
|
||||
}
|
||||
interface SpyImpl<A extends any[] = any[], R = any> extends Spy<A, R> {
|
||||
getOriginal(): (...args: A) => R;
|
||||
willCall(cb: (...args: A) => R): this;
|
||||
restore(): void;
|
||||
}
|
||||
declare function createInternalSpy<A extends any[], R>(cb?: ((...args: A) => R) | {
|
||||
new (...args: A): R;
|
||||
}): SpyInternal<A, R>;
|
||||
|
||||
interface SpyFn<A extends any[] = any[], R = any> extends Spy<A, R> {
|
||||
new (...args: A): R extends void ? any : R;
|
||||
(...args: A): R;
|
||||
}
|
||||
declare function spy<A extends any[], R>(cb?: ((...args: A) => R) | {
|
||||
new (...args: A): R;
|
||||
}): SpyFn<A, R>;
|
||||
|
||||
type Procedure = (...args: any[]) => any;
|
||||
type Methods<T> = {
|
||||
[K in keyof T]: T[K] extends Procedure ? K : never;
|
||||
}[keyof T];
|
||||
type Getters<T> = {
|
||||
[K in keyof T]: T[K] extends Procedure ? never : K;
|
||||
}[keyof T];
|
||||
type Constructors<T> = {
|
||||
[K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
|
||||
}[keyof T];
|
||||
declare function internalSpyOn<T, K extends string & keyof T>(obj: T, methodName: K | {
|
||||
getter: K;
|
||||
} | {
|
||||
setter: K;
|
||||
}, mock?: Procedure): SpyInternalImpl<any[], any>;
|
||||
declare function spyOn<T, S extends Getters<Required<T>>>(obj: T, methodName: {
|
||||
setter: S;
|
||||
}, mock?: (arg: T[S]) => void): SpyImpl<[T[S]], void>;
|
||||
declare function spyOn<T, G extends Getters<Required<T>>>(obj: T, methodName: {
|
||||
getter: G;
|
||||
}, mock?: () => T[G]): SpyImpl<[], T[G]>;
|
||||
declare function spyOn<T, M extends Constructors<Required<T>>>(object: T, method: M): Required<T>[M] extends new (...args: infer A) => infer R ? SpyImpl<A, R> : never;
|
||||
declare function spyOn<T, M extends Methods<Required<T>>>(obj: T, methodName: M, mock?: T[M]): Required<T>[M] extends (...args: infer A) => infer R ? SpyImpl<A, R> : never;
|
||||
|
||||
declare function restoreAll(): void;
|
||||
|
||||
export { type Spy, type SpyFn, type SpyImpl, type SpyInternal, type SpyInternalImpl, createInternalSpy, getInternalState, internalSpyOn, restoreAll, spies, spy, spyOn };
|
||||
149
pwa/node_modules/tinyspy/dist/index.js
generated
vendored
Normal file
149
pwa/node_modules/tinyspy/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
// src/utils.ts
|
||||
function d(e, t) {
|
||||
if (!e)
|
||||
throw new Error(t);
|
||||
}
|
||||
function y(e, t) {
|
||||
return typeof t === e;
|
||||
}
|
||||
function w(e) {
|
||||
return e instanceof Promise;
|
||||
}
|
||||
function f(e, t, n) {
|
||||
Object.defineProperty(e, t, n);
|
||||
}
|
||||
function l(e, t, n) {
|
||||
Object.defineProperty(e, t, { value: n });
|
||||
}
|
||||
|
||||
// src/constants.ts
|
||||
var u = Symbol.for("tinyspy:spy");
|
||||
|
||||
// src/internal.ts
|
||||
var x = /* @__PURE__ */ new Set(), P = (e) => {
|
||||
e.called = !1, e.callCount = 0, e.calls = [], e.results = [], e.resolves = [], e.next = [];
|
||||
}, K = (e) => (f(e, u, { value: { reset: () => P(e[u]) } }), e[u]), T = (e) => e[u] || K(e);
|
||||
function m(e) {
|
||||
d(
|
||||
y("function", e) || y("undefined", e),
|
||||
"cannot spy on a non-function value"
|
||||
);
|
||||
let t = function(...s) {
|
||||
let r = T(t);
|
||||
r.called = !0, r.callCount++, r.calls.push(s);
|
||||
let S = r.next.shift();
|
||||
if (S) {
|
||||
r.results.push(S);
|
||||
let [o, g] = S;
|
||||
if (o === "ok")
|
||||
return g;
|
||||
throw g;
|
||||
}
|
||||
let p, c = "ok", a = r.results.length;
|
||||
if (r.impl)
|
||||
try {
|
||||
new.target ? p = Reflect.construct(r.impl, s, new.target) : p = r.impl.apply(this, s), c = "ok";
|
||||
} catch (o) {
|
||||
throw p = o, c = "error", r.results.push([c, o]), o;
|
||||
}
|
||||
let R = [c, p];
|
||||
return w(p) && p.then(
|
||||
(o) => r.resolves[a] = ["ok", o],
|
||||
(o) => r.resolves[a] = ["error", o]
|
||||
), r.results.push(R), p;
|
||||
};
|
||||
l(t, "_isMockFunction", !0), l(t, "length", e ? e.length : 0), l(t, "name", e && e.name || "spy");
|
||||
let n = T(t);
|
||||
return n.reset(), n.impl = e, t;
|
||||
}
|
||||
function A(e) {
|
||||
let t = T(e);
|
||||
"returns" in e || (f(e, "returns", {
|
||||
get: () => t.results.map(([, n]) => n)
|
||||
}), [
|
||||
"called",
|
||||
"callCount",
|
||||
"results",
|
||||
"resolves",
|
||||
"calls",
|
||||
"reset",
|
||||
"impl"
|
||||
].forEach(
|
||||
(n) => f(e, n, { get: () => t[n], set: (s) => t[n] = s })
|
||||
), l(e, "nextError", (n) => (t.next.push(["error", n]), t)), l(e, "nextResult", (n) => (t.next.push(["ok", n]), t)));
|
||||
}
|
||||
|
||||
// src/spy.ts
|
||||
function L(e) {
|
||||
let t = m(e);
|
||||
return A(t), t;
|
||||
}
|
||||
|
||||
// src/spyOn.ts
|
||||
var k = (e, t) => Object.getOwnPropertyDescriptor(e, t), O = (e, t) => {
|
||||
t != null && typeof t == "function" && t.prototype != null && Object.setPrototypeOf(e.prototype, t.prototype);
|
||||
};
|
||||
function C(e, t, n) {
|
||||
d(
|
||||
!y("undefined", e),
|
||||
"spyOn could not find an object to spy upon"
|
||||
), d(
|
||||
y("object", e) || y("function", e),
|
||||
"cannot spyOn on a primitive value"
|
||||
);
|
||||
let [s, r] = (() => {
|
||||
if (!y("object", t))
|
||||
return [t, "value"];
|
||||
if ("getter" in t && "setter" in t)
|
||||
throw new Error("cannot spy on both getter and setter");
|
||||
if ("getter" in t)
|
||||
return [t.getter, "get"];
|
||||
if ("setter" in t)
|
||||
return [t.setter, "set"];
|
||||
throw new Error("specify getter or setter to spy on");
|
||||
})(), S = k(e, s), p = Object.getPrototypeOf(e), c = p && k(p, s), a = S || c;
|
||||
d(
|
||||
a || s in e,
|
||||
`${String(s)} does not exist`
|
||||
);
|
||||
let R = !1;
|
||||
r === "value" && a && !a.value && a.get && (r = "get", R = !0, n = a.get());
|
||||
let o;
|
||||
a ? o = a[r] : r !== "value" ? o = () => e[s] : o = e[s];
|
||||
let g = (v) => {
|
||||
let { value: M, ...h } = a || {
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
};
|
||||
r !== "value" && delete h.writable, h[r] = v, f(e, s, h);
|
||||
}, b = () => a ? f(e, s, a) : g(o);
|
||||
n || (n = o);
|
||||
let i = m(n);
|
||||
r === "value" && O(i, o);
|
||||
let I = i[u];
|
||||
return l(I, "restore", b), l(I, "getOriginal", () => R ? o() : o), l(I, "willCall", (v) => (I.impl = v, i)), g(
|
||||
R ? () => (O(i, n), i) : i
|
||||
), x.add(i), i;
|
||||
}
|
||||
function U(e, t, n) {
|
||||
let s = C(e, t, n);
|
||||
return A(s), ["restore", "getOriginal", "willCall"].forEach((r) => {
|
||||
l(s, r, s[u][r]);
|
||||
}), s;
|
||||
}
|
||||
|
||||
// src/restoreAll.ts
|
||||
function Y() {
|
||||
for (let e of x)
|
||||
e.restore();
|
||||
x.clear();
|
||||
}
|
||||
export {
|
||||
m as createInternalSpy,
|
||||
T as getInternalState,
|
||||
C as internalSpyOn,
|
||||
Y as restoreAll,
|
||||
x as spies,
|
||||
L as spy,
|
||||
U as spyOn
|
||||
};
|
||||
43
pwa/node_modules/tinyspy/package.json
generated
vendored
Normal file
43
pwa/node_modules/tinyspy/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "tinyspy",
|
||||
"type": "module",
|
||||
"version": "3.0.2",
|
||||
"packageManager": "pnpm@9.1.1",
|
||||
"description": "A minimal fork of nanospy, with more features",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/tinylibs/tinyspy#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tinylibs/tinyspy.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tinylibs/tinyspy/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"spy",
|
||||
"mock",
|
||||
"typescript",
|
||||
"method"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue