@sweidos/eidos 1.0.34 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -89
- package/dist/action.js +119 -86
- package/dist/async-storage-adapter.js +15 -12
- package/dist/devtools.js +953 -555
- package/dist/eidos.cjs +15 -0
- package/dist/idb.js +59 -56
- package/dist/index.d.ts +37 -15
- package/dist/index.js +42 -41
- package/dist/nextjs.js +1 -10
- package/dist/query.cjs +131 -0
- package/dist/query.js +121 -41
- package/dist/queue-storage.js +5 -4
- package/dist/react/Devtools.d.ts +1 -1
- package/dist/react/Provider.js +11 -7
- package/dist/react/hooks.js +48 -38
- package/dist/react-native.js +47 -53
- package/dist/replay.js +15 -0
- package/dist/resource.js +77 -79
- package/dist/runtime.js +22 -28
- package/dist/store-slices.js +43 -0
- package/dist/store.js +32 -49
- package/dist/stores.js +25 -22
- package/dist/sveltekit.js +22 -6
- package/dist/sw-bridge.js +48 -46
- package/dist/testing.cjs +165 -0
- package/dist/testing.js +140 -70
- package/dist/version.js +4 -3
- package/dist/vite.cjs +48 -0
- package/dist/vite.js +45 -29
- package/package.json +48 -27
- package/dist/action.js.map +0 -1
- package/dist/async-storage-adapter.js.map +0 -1
- package/dist/eidos.cjs.js +0 -14
- package/dist/eidos.cjs.js.map +0 -1
- package/dist/idb.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/query.cjs.js +0 -48
- package/dist/queue-storage.js.map +0 -1
- package/dist/react/Provider.js.map +0 -1
- package/dist/react/hooks.js.map +0 -1
- package/dist/resource.js.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/stores.js.map +0 -1
- package/dist/sw-bridge.js.map +0 -1
- package/dist/testing.cjs.js +0 -86
- package/dist/version.js.map +0 -1
- package/dist/vite.cjs.js +0 -31
package/dist/resource.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { useEidosStore as h } from "./store.js";
|
|
2
|
-
import { sendToWorker as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
m = e;
|
|
2
|
+
import { sendToWorker as v } from "./sw-bridge.js";
|
|
3
|
+
var p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), E = null;
|
|
4
|
+
function N(e) {
|
|
5
|
+
E = e;
|
|
7
6
|
}
|
|
8
|
-
function
|
|
7
|
+
function d(e) {
|
|
9
8
|
return e.includes("*") || /:[^/]+/.test(e);
|
|
10
9
|
}
|
|
11
|
-
function
|
|
10
|
+
function R(e) {
|
|
12
11
|
return "^" + e.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".+").replace(/\*/g, "[^/]+").replace(/:[^/]+/g, "[^/]+") + "$";
|
|
13
12
|
}
|
|
14
13
|
function w(e, a) {
|
|
15
|
-
return new Error(
|
|
16
|
-
`[eidos] resource('${e}') is a URL pattern — ${a}() is not supported on pattern handles. The SW intercepts matching requests automatically; call fetch(specificUrl) directly in your app code.`
|
|
17
|
-
);
|
|
14
|
+
return /* @__PURE__ */ new Error(`[eidos] resource('${e}') is a URL pattern — ${a}() is not supported on pattern handles. The SW intercepts matching requests automatically; call fetch(specificUrl) directly in your app code.`);
|
|
18
15
|
}
|
|
19
16
|
function A(e, a) {
|
|
20
|
-
if (p.has(e))
|
|
21
|
-
|
|
22
|
-
const s = S(e, a), t = l(e) ? E(e) : void 0, o = {
|
|
17
|
+
if (p.has(e)) return p.get(e);
|
|
18
|
+
const s = S(a), t = d(e) ? R(e) : void 0, c = {
|
|
23
19
|
url: e,
|
|
24
20
|
config: a,
|
|
25
21
|
strategy: s,
|
|
@@ -27,120 +23,123 @@ function A(e, a) {
|
|
|
27
23
|
cacheHits: 0,
|
|
28
24
|
cacheMisses: 0
|
|
29
25
|
};
|
|
30
|
-
h.getState().registerResource(e,
|
|
26
|
+
h.getState().registerResource(e, c), v({
|
|
31
27
|
type: "EIDOS_REGISTER_RESOURCE",
|
|
32
28
|
url: e,
|
|
33
29
|
strategy: s.swStrategy,
|
|
34
30
|
cacheName: s.cacheName,
|
|
35
31
|
...t !== void 0 && { pattern: t }
|
|
36
32
|
});
|
|
37
|
-
const
|
|
33
|
+
const r = {
|
|
38
34
|
url: e,
|
|
39
35
|
config: a,
|
|
40
36
|
strategy: s,
|
|
41
37
|
fetch: async () => {
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
38
|
+
if (d(e)) throw w(e, "fetch");
|
|
39
|
+
const n = m.get(e);
|
|
40
|
+
if (n) return n.then((o) => o.clone());
|
|
45
41
|
const i = k(e, a, s);
|
|
46
|
-
return
|
|
47
|
-
}), i.then((
|
|
42
|
+
return m.set(e, i), i.finally(() => m.delete(e)).catch(() => {
|
|
43
|
+
}), i.then((o) => o.clone());
|
|
48
44
|
},
|
|
49
45
|
json: async () => {
|
|
50
|
-
if (
|
|
51
|
-
return (await
|
|
46
|
+
if (d(e)) throw w(e, "json");
|
|
47
|
+
return (await r.fetch()).json();
|
|
52
48
|
},
|
|
53
49
|
query: () => {
|
|
54
|
-
if (
|
|
50
|
+
if (d(e)) throw w(e, "query");
|
|
55
51
|
return {
|
|
56
52
|
queryKey: ["eidos", e],
|
|
57
|
-
queryFn: () =>
|
|
53
|
+
queryFn: () => r.json()
|
|
58
54
|
};
|
|
59
55
|
},
|
|
60
56
|
prefetch: async () => {
|
|
61
|
-
if (
|
|
62
|
-
await
|
|
57
|
+
if (d(e)) throw w(e, "prefetch");
|
|
58
|
+
await r.fetch();
|
|
63
59
|
},
|
|
64
60
|
invalidate: async () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
v({
|
|
62
|
+
type: "EIDOS_CLEAR_CACHE",
|
|
63
|
+
url: e
|
|
64
|
+
});
|
|
65
|
+
const n = await caches.open(s.cacheName).catch(() => null);
|
|
66
|
+
if (n) {
|
|
67
|
+
const i = await n.keys(), o = t ? new RegExp(t) : null, l = e.startsWith("http");
|
|
68
|
+
await Promise.all(i.filter((u) => {
|
|
69
|
+
const f = u.url, g = new URL(f).pathname;
|
|
70
|
+
return o ? o.test(l ? f : g) : l ? f === e : f === e || g === e;
|
|
71
|
+
}).map((u) => n.delete(u)));
|
|
75
72
|
}
|
|
76
|
-
|
|
73
|
+
d(e) || h.getState().updateResource(e, {
|
|
77
74
|
status: "stale",
|
|
78
75
|
cachedAt: void 0,
|
|
79
76
|
lastEvent: "cache-cleared",
|
|
80
77
|
cacheHits: 0,
|
|
81
78
|
cacheMisses: 0
|
|
82
|
-
}),
|
|
79
|
+
}), E?.(["eidos", e]);
|
|
83
80
|
},
|
|
84
81
|
unregister: () => {
|
|
85
|
-
p.delete(e),
|
|
82
|
+
p.delete(e), v({
|
|
83
|
+
type: "EIDOS_UNREGISTER_RESOURCE",
|
|
84
|
+
url: e
|
|
85
|
+
}), h.getState().unregisterResource(e);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
return p.set(e,
|
|
88
|
+
return p.set(e, r), r;
|
|
89
89
|
}
|
|
90
90
|
async function k(e, a, s) {
|
|
91
91
|
const t = h.getState();
|
|
92
|
-
t.updateResource(e, {
|
|
93
|
-
|
|
92
|
+
t.updateResource(e, {
|
|
93
|
+
status: "fetching",
|
|
94
|
+
fetchedAt: Date.now()
|
|
95
|
+
});
|
|
96
|
+
const c = await caches.open(s.cacheName).catch(() => null);
|
|
94
97
|
try {
|
|
95
98
|
if (s.swStrategy !== "network-first") {
|
|
96
|
-
const i =
|
|
97
|
-
if (i && !
|
|
99
|
+
const i = c ? await c.match(e).catch(() => null) : null, o = h.getState().resources[e], l = a.maxAge !== void 0 && o?.cachedAt !== void 0 && Date.now() - o.cachedAt > a.maxAge;
|
|
100
|
+
if (i && !l)
|
|
98
101
|
return t.updateResource(e, {
|
|
99
102
|
status: "fresh",
|
|
100
103
|
lastEvent: "cache-hit",
|
|
101
|
-
cacheHits: (
|
|
102
|
-
}), s.swStrategy === "stale-while-revalidate" && fetch(e, { signal: AbortSignal.timeout(5e3) }).then(async (
|
|
103
|
-
|
|
104
|
+
cacheHits: (o?.cacheHits ?? 0) + 1
|
|
105
|
+
}), s.swStrategy === "stale-while-revalidate" && fetch(e, { signal: AbortSignal.timeout(5e3) }).then(async (f) => {
|
|
106
|
+
f.ok && c && (await c.put(e, f.clone()), h.getState().updateResource(e, {
|
|
104
107
|
cachedAt: Date.now(),
|
|
105
108
|
lastEvent: "cache-updated"
|
|
106
109
|
}));
|
|
107
110
|
}).catch(() => {
|
|
108
111
|
}), i;
|
|
109
|
-
const
|
|
110
|
-
t.updateResource(e, {
|
|
111
|
-
cacheMisses: ((f == null ? void 0 : f.cacheMisses) ?? 0) + 1
|
|
112
|
-
});
|
|
112
|
+
const u = h.getState().resources[e];
|
|
113
|
+
t.updateResource(e, { cacheMisses: (u?.cacheMisses ?? 0) + 1 });
|
|
113
114
|
}
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
return
|
|
115
|
+
const r = await fetch(e);
|
|
116
|
+
if (r.ok)
|
|
117
|
+
return c && await c.put(e, r.clone()), t.updateResource(e, {
|
|
117
118
|
status: "fresh",
|
|
118
119
|
cachedAt: Date.now(),
|
|
119
120
|
lastEvent: "cache-updated"
|
|
120
|
-
}),
|
|
121
|
-
t.updateResource(e, { status:
|
|
122
|
-
const
|
|
123
|
-
throw new Error(
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const r = o ? await o.match(e).catch(() => null) : null;
|
|
128
|
-
if (r) {
|
|
121
|
+
}), r;
|
|
122
|
+
t.updateResource(e, { status: r.status === 503 ? "offline" : "error" });
|
|
123
|
+
const n = r.headers.get("X-Eidos-Offline") === "true";
|
|
124
|
+
throw new Error(n ? `offline: no cached response for ${e}` : `${r.status} ${r.statusText}`);
|
|
125
|
+
} catch (r) {
|
|
126
|
+
const n = c ? await c.match(e).catch(() => null) : null;
|
|
127
|
+
if (n) {
|
|
129
128
|
const i = h.getState().resources[e];
|
|
130
129
|
return t.updateResource(e, {
|
|
131
130
|
status: "fresh",
|
|
132
131
|
lastEvent: "cache-hit",
|
|
133
|
-
cacheHits: (
|
|
134
|
-
}),
|
|
132
|
+
cacheHits: (i?.cacheHits ?? 0) + 1
|
|
133
|
+
}), n;
|
|
135
134
|
}
|
|
136
|
-
throw t.updateResource(e, { status: "error" }),
|
|
135
|
+
throw t.updateResource(e, { status: "error" }), r;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
|
-
function S(e
|
|
140
|
-
const
|
|
141
|
-
return
|
|
138
|
+
function S(e) {
|
|
139
|
+
const a = e.strategy;
|
|
140
|
+
return e.offline ? y(a ?? "stale-while-revalidate", e.cacheName) : y(a ?? "network-first", e.cacheName);
|
|
142
141
|
}
|
|
143
|
-
|
|
142
|
+
var b = {
|
|
144
143
|
"stale-while-revalidate": "StaleWhileRevalidate",
|
|
145
144
|
"cache-first": "CacheFirst",
|
|
146
145
|
"network-first": "NetworkFirst"
|
|
@@ -188,16 +187,14 @@ new NetworkFirst({
|
|
|
188
187
|
})`
|
|
189
188
|
}
|
|
190
189
|
};
|
|
191
|
-
function
|
|
192
|
-
const
|
|
190
|
+
function y(e, a) {
|
|
191
|
+
const s = x[e];
|
|
193
192
|
return {
|
|
194
193
|
name: b[e],
|
|
195
194
|
swStrategy: e,
|
|
196
|
-
cacheName:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
reasoning: t.reasoning,
|
|
200
|
-
behavior: t.behavior,
|
|
195
|
+
cacheName: a ?? "eidos-resources-v1",
|
|
196
|
+
reasoning: s.reasoning,
|
|
197
|
+
behavior: s.behavior,
|
|
201
198
|
equivalentCode: ""
|
|
202
199
|
};
|
|
203
200
|
}
|
|
@@ -211,7 +208,8 @@ async function _(e) {
|
|
|
211
208
|
}
|
|
212
209
|
export {
|
|
213
210
|
A as resource,
|
|
214
|
-
|
|
211
|
+
N as setQueryInvalidator,
|
|
215
212
|
_ as warmCache
|
|
216
213
|
};
|
|
217
|
-
|
|
214
|
+
|
|
215
|
+
//# sourceMappingURL=resource.js.map
|
package/dist/runtime.js
CHANGED
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useEidosStore as o } from "./store.js";
|
|
2
|
+
import { registerBgSyncHandler as a, registerServiceWorker as u } from "./sw-bridge.js";
|
|
3
|
+
import { idbGetQueue as c } from "./idb.js";
|
|
4
|
+
import { replayQueue as f } from "./action.js";
|
|
5
|
+
import { subscribeReplayOnReconnect as l } from "./replay.js";
|
|
6
|
+
var e = !1, t = null;
|
|
7
|
+
async function h(r = {}) {
|
|
8
|
+
if (typeof window > "u" || e) return;
|
|
9
|
+
e = !0;
|
|
10
|
+
const s = r.swPath ?? "/eidos-sw.js", n = r.autoReplay ?? !0;
|
|
10
11
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const i = await c();
|
|
13
|
+
i.length > 0 && o.getState().hydrateQueue(i);
|
|
13
14
|
} catch {
|
|
14
15
|
}
|
|
15
16
|
try {
|
|
16
|
-
await
|
|
17
|
+
await u(s);
|
|
17
18
|
} catch {
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}), l)
|
|
22
|
-
let t = e.getState().isOnline;
|
|
23
|
-
i = e.subscribe(() => {
|
|
24
|
-
const { isOnline: n } = e.getState(), c = n && !t;
|
|
25
|
-
t = n, c && setTimeout(s, 600);
|
|
26
|
-
});
|
|
27
|
-
const a = e.getState(), f = a.queue.some((n) => n.status === "pending");
|
|
28
|
-
a.isOnline && f && setTimeout(s, 1200);
|
|
29
|
-
}
|
|
20
|
+
a(() => {
|
|
21
|
+
o.getState().isOnline && setTimeout(f, 200);
|
|
22
|
+
}), n && (t = l());
|
|
30
23
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
24
|
+
function b() {
|
|
25
|
+
t?.(), t = null, e = !1;
|
|
33
26
|
}
|
|
34
27
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
b as _resetEidos,
|
|
29
|
+
h as initEidos
|
|
37
30
|
};
|
|
38
|
-
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function t(o) {
|
|
2
|
+
return {
|
|
3
|
+
registerResource: (e, r) => o((u) => ({ resources: {
|
|
4
|
+
...u.resources,
|
|
5
|
+
[e]: r
|
|
6
|
+
} })),
|
|
7
|
+
updateResource: (e, r) => o((u) => ({ resources: {
|
|
8
|
+
...u.resources,
|
|
9
|
+
[e]: u.resources[e] ? {
|
|
10
|
+
...u.resources[e],
|
|
11
|
+
...r
|
|
12
|
+
} : u.resources[e]
|
|
13
|
+
} })),
|
|
14
|
+
unregisterResource: (e) => o((r) => ({ resources: Object.fromEntries(Object.entries(r.resources).filter(([u]) => u !== e)) }))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function n(o) {
|
|
18
|
+
return {
|
|
19
|
+
addQueueItem: (e) => o((r) => ({ queue: [...r.queue, e] })),
|
|
20
|
+
updateQueueItem: (e, r) => o((u) => ({ queue: u.queue.map((c) => c.id === e ? {
|
|
21
|
+
...c,
|
|
22
|
+
...r
|
|
23
|
+
} : c) })),
|
|
24
|
+
batchUpdateQueueItems: (e) => o((r) => {
|
|
25
|
+
const u = new Map(e.map((c) => [c.id, c.update]));
|
|
26
|
+
return { queue: r.queue.map((c) => {
|
|
27
|
+
const s = u.get(c.id);
|
|
28
|
+
return s ? {
|
|
29
|
+
...c,
|
|
30
|
+
...s
|
|
31
|
+
} : c;
|
|
32
|
+
}) };
|
|
33
|
+
}),
|
|
34
|
+
removeQueueItem: (e) => o((r) => ({ queue: r.queue.filter((u) => u.id !== e) })),
|
|
35
|
+
hydrateQueue: (e) => o(() => ({ queue: e }))
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
n as createQueueActions,
|
|
40
|
+
t as createResourceActions
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=store-slices.js.map
|
package/dist/store.js
CHANGED
|
@@ -1,66 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import { createQueueActions as u, createResourceActions as i } from "./store-slices.js";
|
|
2
|
+
var t, s = /* @__PURE__ */ new Set();
|
|
3
|
+
function r() {
|
|
4
|
+
s.forEach((e) => e());
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
function n(e) {
|
|
7
|
+
t = {
|
|
8
|
+
...t,
|
|
9
|
+
...e(t)
|
|
10
|
+
}, r();
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
// navigator.onLine is undefined in React Native — default to true unless explicitly false
|
|
12
|
+
t = {
|
|
11
13
|
isOnline: typeof navigator > "u" || navigator.onLine !== !1,
|
|
12
14
|
swStatus: "idle",
|
|
13
15
|
swError: void 0,
|
|
14
16
|
resources: {},
|
|
15
17
|
queue: [],
|
|
16
|
-
setOnline: (e) =>
|
|
17
|
-
setSwStatus: (e,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
resources: {
|
|
21
|
-
...t.resources,
|
|
22
|
-
[e]: t.resources[e] ? { ...t.resources[e], ...u } : t.resources[e]
|
|
23
|
-
}
|
|
24
|
-
})),
|
|
25
|
-
unregisterResource: (e) => r((u) => ({
|
|
26
|
-
resources: Object.fromEntries(
|
|
27
|
-
Object.entries(u.resources).filter(([t]) => t !== e)
|
|
28
|
-
)
|
|
18
|
+
setOnline: (e) => n(() => ({ isOnline: e })),
|
|
19
|
+
setSwStatus: (e, o) => n(() => ({
|
|
20
|
+
swStatus: e,
|
|
21
|
+
swError: o
|
|
29
22
|
})),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
queue: t.queue.map((s) => s.id === e ? { ...s, ...u } : s)
|
|
33
|
-
})),
|
|
34
|
-
batchUpdateQueueItems: (e) => r((u) => {
|
|
35
|
-
const t = new Map(e.map((s) => [s.id, s.update]));
|
|
36
|
-
return {
|
|
37
|
-
queue: u.queue.map((s) => {
|
|
38
|
-
const c = t.get(s.id);
|
|
39
|
-
return c ? { ...s, ...c } : s;
|
|
40
|
-
})
|
|
41
|
-
};
|
|
42
|
-
}),
|
|
43
|
-
removeQueueItem: (e) => r((u) => ({ queue: u.queue.filter((t) => t.id !== e) })),
|
|
44
|
-
hydrateQueue: (e) => r(() => ({ queue: e }))
|
|
23
|
+
...i(n),
|
|
24
|
+
...u(n)
|
|
45
25
|
};
|
|
46
|
-
function
|
|
47
|
-
return
|
|
26
|
+
function a() {
|
|
27
|
+
return t;
|
|
48
28
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
51
|
-
|
|
29
|
+
function c(e) {
|
|
30
|
+
return s.add(e), () => {
|
|
31
|
+
s.delete(e);
|
|
52
32
|
};
|
|
53
33
|
}
|
|
54
|
-
|
|
55
|
-
getState:
|
|
56
|
-
subscribe:
|
|
57
|
-
// Test/devtools helper — merges partial state, preserves action methods.
|
|
34
|
+
var d = {
|
|
35
|
+
getState: a,
|
|
36
|
+
subscribe: c,
|
|
58
37
|
setState: (e) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
38
|
+
const o = typeof e == "function" ? e(t) : e;
|
|
39
|
+
t = {
|
|
40
|
+
...t,
|
|
41
|
+
...o
|
|
42
|
+
}, r();
|
|
61
43
|
}
|
|
62
44
|
};
|
|
63
45
|
export {
|
|
64
|
-
|
|
46
|
+
d as useEidosStore
|
|
65
47
|
};
|
|
66
|
-
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=store.js.map
|
package/dist/stores.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEidosStore as i } from "./store.js";
|
|
2
2
|
function a(e, t) {
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
for (const
|
|
3
|
+
const r = Object.keys(e);
|
|
4
|
+
if (r.length !== Object.keys(t).length) return !1;
|
|
5
|
+
for (const s of r) if (e[s] !== t[s]) return !1;
|
|
6
6
|
return !0;
|
|
7
7
|
}
|
|
8
8
|
function o(e, t) {
|
|
@@ -10,11 +10,11 @@ function o(e, t) {
|
|
|
10
10
|
}
|
|
11
11
|
function u(e, t = Object.is) {
|
|
12
12
|
return {
|
|
13
|
-
subscribe(
|
|
14
|
-
let
|
|
15
|
-
return s
|
|
16
|
-
const
|
|
17
|
-
t(
|
|
13
|
+
subscribe(r) {
|
|
14
|
+
let s = e(i.getState());
|
|
15
|
+
return r(s), i.subscribe(() => {
|
|
16
|
+
const n = e(i.getState());
|
|
17
|
+
t(s, n) || (s = n, r(n));
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
getState() {
|
|
@@ -22,23 +22,25 @@ function u(e, t = Object.is) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
var l = u((e) => e), c = u((e) => e.queue), d = u((e) => ({
|
|
26
|
+
isOnline: e.isOnline,
|
|
27
|
+
swStatus: e.swStatus,
|
|
28
|
+
swError: e.swError
|
|
29
|
+
}), o), g = u((e) => {
|
|
30
|
+
let t = 0, r = 0, s = 0;
|
|
31
|
+
for (const n of e.queue) n.status === "pending" ? t++ : n.status === "failed" ? r++ : n.status === "replaying" && s++;
|
|
32
|
+
return {
|
|
33
|
+
pending: t,
|
|
34
|
+
failed: r,
|
|
35
|
+
replaying: s,
|
|
36
|
+
total: e.queue.length
|
|
37
|
+
};
|
|
38
|
+
}, o);
|
|
37
39
|
function S(e) {
|
|
38
40
|
return u((t) => t.resources[e]);
|
|
39
41
|
}
|
|
40
42
|
function b(e) {
|
|
41
|
-
return u((t) => t.queue.find((
|
|
43
|
+
return u((t) => t.queue.find((r) => r.id === e));
|
|
42
44
|
}
|
|
43
45
|
export {
|
|
44
46
|
b as eidosAction,
|
|
@@ -48,4 +50,5 @@ export {
|
|
|
48
50
|
d as eidosStatus,
|
|
49
51
|
l as eidosStore
|
|
50
52
|
};
|
|
51
|
-
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=stores.js.map
|
package/dist/sveltekit.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { initEidos } from "@sweidos/eidos";
|
|
2
|
+
//#region src/sveltekit.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns an `onMount`-compatible callback that initialises the Eidos runtime
|
|
5
|
+
* on the client only. Prevents SSR crashes caused by accessing `indexedDB` or
|
|
6
|
+
* `navigator.serviceWorker` during server-side rendering.
|
|
7
|
+
*
|
|
8
|
+
* Call inside `onMount()` in your root `+layout.svelte`:
|
|
9
|
+
*
|
|
10
|
+
* ```svelte
|
|
11
|
+
* <script>
|
|
12
|
+
* import { onMount } from 'svelte'
|
|
13
|
+
* import { initEidosSvelteKit } from '@sweidos/eidos/sveltekit'
|
|
14
|
+
*
|
|
15
|
+
* onMount(initEidosSvelteKit({ swPath: '/eidos-sw.js' }))
|
|
16
|
+
* <\/script>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
2
19
|
function initEidosSvelteKit(config) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
20
|
+
return () => {
|
|
21
|
+
initEidos(config);
|
|
22
|
+
};
|
|
6
23
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { initEidosSvelteKit };
|