@sweidos/eidos 1.0.17 → 1.0.20
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 +115 -17
- package/dist/eidos.cjs.js +4 -746
- package/dist/eidos.cjs.js.map +1 -1
- package/dist/eidos.es.js +420 -555
- package/dist/eidos.es.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/query.cjs.js +48 -0
- package/dist/query.d.ts +81 -0
- package/dist/query.js +48 -0
- package/dist/vite.cjs.js +31 -0
- package/dist/vite.d.ts +28 -0
- package/dist/vite.js +31 -0
- package/package.json +30 -4
package/dist/eidos.es.js
CHANGED
|
@@ -1,333 +1,285 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isOnline: typeof navigator !== "undefined" ? navigator.onLine : true,
|
|
1
|
+
import { jsx as B, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as U, useRef as N, useSyncExternalStore as $ } from "react";
|
|
3
|
+
let y;
|
|
4
|
+
const D = /* @__PURE__ */ new Set();
|
|
5
|
+
function W() {
|
|
6
|
+
D.forEach((e) => e());
|
|
7
|
+
}
|
|
8
|
+
function g(e) {
|
|
9
|
+
y = { ...y, ...e(y) }, W();
|
|
10
|
+
}
|
|
11
|
+
y = {
|
|
12
|
+
isOnline: typeof navigator < "u" ? navigator.onLine : !0,
|
|
14
13
|
swStatus: "idle",
|
|
15
14
|
swError: void 0,
|
|
16
15
|
resources: {},
|
|
17
16
|
queue: [],
|
|
18
|
-
setOnline: (
|
|
19
|
-
setSwStatus: (
|
|
20
|
-
registerResource: (
|
|
21
|
-
updateResource: (
|
|
17
|
+
setOnline: (e) => g(() => ({ isOnline: e })),
|
|
18
|
+
setSwStatus: (e, t) => g(() => ({ swStatus: e, swError: t })),
|
|
19
|
+
registerResource: (e, t) => g((n) => ({ resources: { ...n.resources, [e]: t } })),
|
|
20
|
+
updateResource: (e, t) => g((n) => ({
|
|
22
21
|
resources: {
|
|
23
|
-
...
|
|
24
|
-
[
|
|
22
|
+
...n.resources,
|
|
23
|
+
[e]: n.resources[e] ? { ...n.resources[e], ...t } : n.resources[e]
|
|
25
24
|
}
|
|
26
25
|
})),
|
|
27
|
-
unregisterResource: (
|
|
28
|
-
const { [
|
|
29
|
-
return { resources:
|
|
26
|
+
unregisterResource: (e) => g((t) => {
|
|
27
|
+
const { [e]: n, ...r } = t.resources;
|
|
28
|
+
return { resources: r };
|
|
30
29
|
}),
|
|
31
|
-
addQueueItem: (
|
|
32
|
-
updateQueueItem: (
|
|
33
|
-
queue:
|
|
30
|
+
addQueueItem: (e) => g((t) => ({ queue: [...t.queue, e] })),
|
|
31
|
+
updateQueueItem: (e, t) => g((n) => ({
|
|
32
|
+
queue: n.queue.map((r) => r.id === e ? { ...r, ...t } : r)
|
|
34
33
|
})),
|
|
35
|
-
removeQueueItem: (
|
|
36
|
-
hydrateQueue: (
|
|
34
|
+
removeQueueItem: (e) => g((t) => ({ queue: t.queue.filter((n) => n.id !== e) })),
|
|
35
|
+
hydrateQueue: (e) => g(() => ({ queue: e }))
|
|
37
36
|
};
|
|
38
|
-
function
|
|
39
|
-
return
|
|
37
|
+
function G() {
|
|
38
|
+
return y;
|
|
40
39
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_listeners.delete(listener);
|
|
40
|
+
function K(e) {
|
|
41
|
+
return D.add(e), () => {
|
|
42
|
+
D.delete(e);
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
|
-
const
|
|
48
|
-
getState:
|
|
49
|
-
subscribe:
|
|
45
|
+
const o = {
|
|
46
|
+
getState: G,
|
|
47
|
+
subscribe: K,
|
|
50
48
|
// Test/devtools helper — merges partial state, preserves action methods.
|
|
51
|
-
setState: (
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
_notify();
|
|
49
|
+
setState: (e) => {
|
|
50
|
+
const t = typeof e == "function" ? e(y) : e;
|
|
51
|
+
y = { ...y, ...t }, W();
|
|
55
52
|
}
|
|
56
53
|
};
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
useEidosStore.getState().setSwStatus("unsupported");
|
|
54
|
+
let w = null, Q = [];
|
|
55
|
+
function V() {
|
|
56
|
+
return w;
|
|
57
|
+
}
|
|
58
|
+
async function Y(e) {
|
|
59
|
+
if (typeof navigator > "u" || !("serviceWorker" in navigator)) {
|
|
60
|
+
o.getState().setSwStatus("unsupported");
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
63
|
+
const t = o.getState();
|
|
64
|
+
t.setSwStatus("registering");
|
|
69
65
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
navigator.serviceWorker.addEventListener("message", onSwMessage);
|
|
74
|
-
window.addEventListener("online", () => store.setOnline(true));
|
|
75
|
-
window.addEventListener("offline", () => store.setOnline(false));
|
|
76
|
-
flushPendingMessages();
|
|
77
|
-
} catch (err) {
|
|
78
|
-
store.setSwStatus("error", String(err));
|
|
66
|
+
w = await navigator.serviceWorker.register(e, { scope: "/" }), await z(w), t.setSwStatus("active"), navigator.serviceWorker.addEventListener("message", J), window.addEventListener("online", () => t.setOnline(!0)), window.addEventListener("offline", () => t.setOnline(!1)), Z();
|
|
67
|
+
} catch (n) {
|
|
68
|
+
t.setSwStatus("error", String(n));
|
|
79
69
|
}
|
|
80
70
|
}
|
|
81
|
-
function
|
|
82
|
-
return new Promise((
|
|
83
|
-
if (
|
|
84
|
-
|
|
71
|
+
function z(e) {
|
|
72
|
+
return new Promise((t) => {
|
|
73
|
+
if (e.active) {
|
|
74
|
+
t();
|
|
85
75
|
return;
|
|
86
76
|
}
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
89
|
-
|
|
77
|
+
const n = e.installing ?? e.waiting;
|
|
78
|
+
if (!n) {
|
|
79
|
+
t();
|
|
90
80
|
return;
|
|
91
81
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
sw.removeEventListener("statechange", handler);
|
|
97
|
-
resolve();
|
|
98
|
-
}
|
|
82
|
+
const r = setTimeout(t, 1e4);
|
|
83
|
+
n.addEventListener("statechange", function s() {
|
|
84
|
+
n.state === "activated" && (clearTimeout(r), n.removeEventListener("statechange", s), t());
|
|
99
85
|
});
|
|
100
86
|
});
|
|
101
87
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
sw.postMessage(message);
|
|
106
|
-
} else {
|
|
107
|
-
_pendingMessages.push(message);
|
|
108
|
-
}
|
|
88
|
+
function q(e) {
|
|
89
|
+
const t = w == null ? void 0 : w.active;
|
|
90
|
+
t ? t.postMessage(e) : Q.push(e);
|
|
109
91
|
}
|
|
110
|
-
let
|
|
111
|
-
function
|
|
112
|
-
|
|
92
|
+
let O = null;
|
|
93
|
+
function X(e) {
|
|
94
|
+
O = e;
|
|
113
95
|
}
|
|
114
|
-
function
|
|
96
|
+
function we() {
|
|
115
97
|
try {
|
|
116
|
-
return typeof navigator
|
|
98
|
+
return typeof navigator < "u" && "serviceWorker" in navigator && w !== null && "sync" in w;
|
|
117
99
|
} catch {
|
|
118
|
-
return
|
|
100
|
+
return !1;
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
123
|
-
if (!(
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
_bgSyncHandler == null ? void 0 : _bgSyncHandler();
|
|
103
|
+
function J(e) {
|
|
104
|
+
const t = e.data;
|
|
105
|
+
if (!(t != null && t.type)) return;
|
|
106
|
+
const n = o.getState(), { type: r, url: s } = t;
|
|
107
|
+
if (r === "EIDOS_BACKGROUND_SYNC") {
|
|
108
|
+
O == null || O();
|
|
128
109
|
return;
|
|
129
110
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
111
|
+
if (s)
|
|
112
|
+
switch (r) {
|
|
113
|
+
case "EIDOS_CACHE_HIT": {
|
|
114
|
+
const i = n.resources[s];
|
|
115
|
+
n.updateResource(s, {
|
|
116
|
+
status: "fresh",
|
|
117
|
+
lastEvent: "cache-hit",
|
|
118
|
+
cacheHits: ((i == null ? void 0 : i.cacheHits) ?? 0) + 1
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "EIDOS_CACHE_UPDATED": {
|
|
123
|
+
n.updateResource(s, {
|
|
124
|
+
status: "fresh",
|
|
125
|
+
lastEvent: "cache-updated",
|
|
126
|
+
cachedAt: Date.now()
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "EIDOS_NETWORK_ERROR": {
|
|
131
|
+
n.updateResource(s, {
|
|
132
|
+
status: "error",
|
|
133
|
+
lastEvent: "network-error"
|
|
134
|
+
});
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
155
137
|
}
|
|
156
|
-
}
|
|
157
138
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
139
|
+
function ge(e) {
|
|
140
|
+
q({ type: "EIDOS_SIMULATE_OFFLINE", enabled: e }), o.getState().setOnline(!e);
|
|
141
|
+
}
|
|
142
|
+
function Z() {
|
|
143
|
+
const e = w == null ? void 0 : w.active;
|
|
144
|
+
if (e) {
|
|
145
|
+
for (const t of Q) e.postMessage(t);
|
|
146
|
+
Q = [];
|
|
147
|
+
}
|
|
161
148
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_pendingMessages = [];
|
|
149
|
+
const R = /* @__PURE__ */ new Map();
|
|
150
|
+
let x = null;
|
|
151
|
+
function ye(e) {
|
|
152
|
+
x = e;
|
|
167
153
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return url.includes("*") || /:[^/]+/.test(url);
|
|
154
|
+
function S(e) {
|
|
155
|
+
return e.includes("*") || /:[^/]+/.test(e);
|
|
171
156
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
return "^" + escaped.replace(/\*\*/g, ".+").replace(/\*/g, "[^/]+").replace(/:[^/]+/g, "[^/]+") + "$";
|
|
157
|
+
function ee(e) {
|
|
158
|
+
return "^" + e.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".+").replace(/\*/g, "[^/]+").replace(/:[^/]+/g, "[^/]+") + "$";
|
|
175
159
|
}
|
|
176
|
-
function
|
|
160
|
+
function b(e, t) {
|
|
177
161
|
return new Error(
|
|
178
|
-
`[eidos] resource('${
|
|
162
|
+
`[eidos] resource('${e}') is a URL pattern — ${t}() is not supported on pattern handles. The SW intercepts matching requests automatically; call fetch(specificUrl) directly in your app code.`
|
|
179
163
|
);
|
|
180
164
|
}
|
|
181
|
-
function
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
url,
|
|
189
|
-
config,
|
|
190
|
-
strategy,
|
|
165
|
+
function Se(e, t) {
|
|
166
|
+
if (R.has(e))
|
|
167
|
+
return R.get(e);
|
|
168
|
+
const n = te(e, t), r = S(e) ? ee(e) : void 0, s = {
|
|
169
|
+
url: e,
|
|
170
|
+
config: t,
|
|
171
|
+
strategy: n,
|
|
191
172
|
status: "idle",
|
|
192
173
|
cacheHits: 0,
|
|
193
174
|
cacheMisses: 0
|
|
194
175
|
};
|
|
195
|
-
|
|
196
|
-
sendToWorker({
|
|
176
|
+
o.getState().registerResource(e, s), q({
|
|
197
177
|
type: "EIDOS_REGISTER_RESOURCE",
|
|
198
|
-
url,
|
|
199
|
-
strategy:
|
|
200
|
-
cacheName:
|
|
201
|
-
...
|
|
178
|
+
url: e,
|
|
179
|
+
strategy: n.swStrategy,
|
|
180
|
+
cacheName: n.cacheName,
|
|
181
|
+
...r !== void 0 && { pattern: r }
|
|
202
182
|
});
|
|
203
|
-
const
|
|
204
|
-
url,
|
|
205
|
-
config,
|
|
206
|
-
strategy,
|
|
183
|
+
const i = {
|
|
184
|
+
url: e,
|
|
185
|
+
config: t,
|
|
186
|
+
strategy: n,
|
|
207
187
|
fetch: async () => {
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
188
|
+
if (S(e)) throw b(e, "fetch");
|
|
189
|
+
const a = o.getState();
|
|
190
|
+
a.updateResource(e, { status: "fetching", fetchedAt: Date.now() });
|
|
191
|
+
const c = await caches.open(n.cacheName).catch(() => null);
|
|
212
192
|
try {
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (cached && !expired) {
|
|
218
|
-
store.updateResource(url, {
|
|
193
|
+
if (n.swStrategy !== "network-first") {
|
|
194
|
+
const d = c ? await c.match(e).catch(() => null) : null, f = o.getState().resources[e], E = t.maxAge !== void 0 && (f == null ? void 0 : f.cachedAt) !== void 0 && Date.now() - f.cachedAt > t.maxAge;
|
|
195
|
+
if (d && !E)
|
|
196
|
+
return a.updateResource(e, {
|
|
219
197
|
status: "fresh",
|
|
220
198
|
lastEvent: "cache-hit",
|
|
221
|
-
cacheHits: ((
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}).catch(() => {
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
return cached;
|
|
236
|
-
}
|
|
237
|
-
const storeEntry = useEidosStore.getState().resources[url];
|
|
238
|
-
store.updateResource(url, {
|
|
239
|
-
cacheMisses: ((storeEntry == null ? void 0 : storeEntry.cacheMisses) ?? 0) + 1
|
|
199
|
+
cacheHits: ((f == null ? void 0 : f.cacheHits) ?? 0) + 1
|
|
200
|
+
}), n.swStrategy === "stale-while-revalidate" && fetch(e).then(async (P) => {
|
|
201
|
+
P.ok && c && (await c.put(e, P.clone()), o.getState().updateResource(e, {
|
|
202
|
+
cachedAt: Date.now(),
|
|
203
|
+
lastEvent: "cache-updated"
|
|
204
|
+
}));
|
|
205
|
+
}).catch(() => {
|
|
206
|
+
}), d;
|
|
207
|
+
const I = o.getState().resources[e];
|
|
208
|
+
a.updateResource(e, {
|
|
209
|
+
cacheMisses: ((I == null ? void 0 : I.cacheMisses) ?? 0) + 1
|
|
240
210
|
});
|
|
241
211
|
}
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
store.updateResource(url, {
|
|
212
|
+
const u = await fetch(e);
|
|
213
|
+
if (u.ok)
|
|
214
|
+
return c && await c.put(e, u.clone()), a.updateResource(e, {
|
|
246
215
|
status: "fresh",
|
|
247
216
|
cachedAt: Date.now(),
|
|
248
217
|
lastEvent: "cache-updated"
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
store.updateResource(url, { status: response.status === 503 ? "offline" : "error" });
|
|
253
|
-
const isOffline = response.headers.get("X-Eidos-Offline") === "true";
|
|
218
|
+
}), u;
|
|
219
|
+
a.updateResource(e, { status: u.status === 503 ? "offline" : "error" });
|
|
220
|
+
const l = u.headers.get("X-Eidos-Offline") === "true";
|
|
254
221
|
throw new Error(
|
|
255
|
-
|
|
222
|
+
l ? `offline: no cached response for ${e}` : `${u.status} ${u.statusText}`
|
|
256
223
|
);
|
|
257
|
-
} catch (
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
|
|
224
|
+
} catch (u) {
|
|
225
|
+
const l = c ? await c.match(e).catch(() => null) : null;
|
|
226
|
+
if (l) {
|
|
227
|
+
const d = o.getState().resources[e];
|
|
228
|
+
return a.updateResource(e, {
|
|
262
229
|
status: "fresh",
|
|
263
230
|
lastEvent: "cache-hit",
|
|
264
|
-
cacheHits: ((
|
|
265
|
-
});
|
|
266
|
-
return fallback;
|
|
231
|
+
cacheHits: ((d == null ? void 0 : d.cacheHits) ?? 0) + 1
|
|
232
|
+
}), l;
|
|
267
233
|
}
|
|
268
|
-
|
|
269
|
-
throw err;
|
|
234
|
+
throw a.updateResource(e, { status: "error" }), u;
|
|
270
235
|
}
|
|
271
236
|
},
|
|
272
237
|
json: async () => {
|
|
273
|
-
if (
|
|
274
|
-
|
|
275
|
-
return res.json();
|
|
238
|
+
if (S(e)) throw b(e, "json");
|
|
239
|
+
return (await i.fetch()).json();
|
|
276
240
|
},
|
|
277
241
|
query: () => {
|
|
278
|
-
if (
|
|
242
|
+
if (S(e)) throw b(e, "query");
|
|
279
243
|
return {
|
|
280
|
-
queryKey: ["eidos",
|
|
281
|
-
queryFn: () =>
|
|
244
|
+
queryKey: ["eidos", e],
|
|
245
|
+
queryFn: () => i.json()
|
|
282
246
|
};
|
|
283
247
|
},
|
|
284
248
|
prefetch: async () => {
|
|
285
|
-
if (
|
|
286
|
-
await
|
|
249
|
+
if (S(e)) throw b(e, "prefetch");
|
|
250
|
+
await i.fetch();
|
|
287
251
|
},
|
|
288
252
|
invalidate: async () => {
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
const
|
|
293
|
-
const patternRe = regexStr ? new RegExp(regexStr) : null;
|
|
294
|
-
const isCrossOrigin = url.startsWith("http");
|
|
253
|
+
q({ type: "EIDOS_CLEAR_CACHE", url: e });
|
|
254
|
+
const a = await caches.open(n.cacheName).catch(() => null);
|
|
255
|
+
if (a) {
|
|
256
|
+
const c = await a.keys(), u = r ? new RegExp(r) : null, l = e.startsWith("http");
|
|
295
257
|
await Promise.all(
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return patternRe.test(isCrossOrigin ? rUrl : p);
|
|
301
|
-
}
|
|
302
|
-
return isCrossOrigin ? rUrl === url : rUrl === url || p === url;
|
|
303
|
-
}).map((r) => cache.delete(r))
|
|
258
|
+
c.filter((d) => {
|
|
259
|
+
const f = d.url, E = new URL(f).pathname;
|
|
260
|
+
return u ? u.test(l ? f : E) : l ? f === e : f === e || E === e;
|
|
261
|
+
}).map((d) => a.delete(d))
|
|
304
262
|
);
|
|
305
263
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
});
|
|
314
|
-
}
|
|
264
|
+
S(e) || o.getState().updateResource(e, {
|
|
265
|
+
status: "stale",
|
|
266
|
+
cachedAt: void 0,
|
|
267
|
+
lastEvent: "cache-cleared",
|
|
268
|
+
cacheHits: 0,
|
|
269
|
+
cacheMisses: 0
|
|
270
|
+
}), x == null || x(["eidos", e]);
|
|
315
271
|
},
|
|
316
272
|
unregister: () => {
|
|
317
|
-
|
|
318
|
-
sendToWorker({ type: "EIDOS_UNREGISTER_RESOURCE", url });
|
|
319
|
-
useEidosStore.getState().unregisterResource(url);
|
|
273
|
+
R.delete(e), q({ type: "EIDOS_UNREGISTER_RESOURCE", url: e }), o.getState().unregisterResource(e);
|
|
320
274
|
}
|
|
321
275
|
};
|
|
322
|
-
|
|
323
|
-
return handle;
|
|
276
|
+
return R.set(e, i), i;
|
|
324
277
|
}
|
|
325
|
-
function
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
return buildStrategy(explicit ?? "network-first", url, config.cacheName);
|
|
278
|
+
function te(e, t) {
|
|
279
|
+
const n = t.strategy;
|
|
280
|
+
return t.offline ? T(n ?? "stale-while-revalidate", e, t.cacheName) : T(n ?? "network-first", e, t.cacheName);
|
|
329
281
|
}
|
|
330
|
-
const
|
|
282
|
+
const ne = {
|
|
331
283
|
"stale-while-revalidate": {
|
|
332
284
|
name: "StaleWhileRevalidate",
|
|
333
285
|
reasoning: "offline: true signals resilience. SWR returns cached data instantly while revalidating in the background — the best tradeoff between speed and freshness for offline-capable resources.",
|
|
@@ -374,383 +326,296 @@ new NetworkFirst({
|
|
|
374
326
|
})`
|
|
375
327
|
}
|
|
376
328
|
};
|
|
377
|
-
function
|
|
329
|
+
function T(e, t, n) {
|
|
378
330
|
return {
|
|
379
|
-
...
|
|
380
|
-
swStrategy,
|
|
381
|
-
cacheName:
|
|
331
|
+
...ne[e],
|
|
332
|
+
swStrategy: e,
|
|
333
|
+
cacheName: n ?? "eidos-resources-v1"
|
|
382
334
|
};
|
|
383
335
|
}
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (!db.objectStoreNames.contains(QUEUE_STORE)) {
|
|
395
|
-
const store = db.createObjectStore(QUEUE_STORE, { keyPath: "id" });
|
|
396
|
-
store.createIndex("status", "status", { unique: false });
|
|
397
|
-
store.createIndex("actionId", "actionId", { unique: false });
|
|
336
|
+
const se = "eidos", re = 1, h = "action-queue";
|
|
337
|
+
let A = null;
|
|
338
|
+
function m() {
|
|
339
|
+
return A ? Promise.resolve(A) : new Promise((e, t) => {
|
|
340
|
+
const n = indexedDB.open(se, re);
|
|
341
|
+
n.onupgradeneeded = (r) => {
|
|
342
|
+
const s = r.target.result;
|
|
343
|
+
if (!s.objectStoreNames.contains(h)) {
|
|
344
|
+
const i = s.createObjectStore(h, { keyPath: "id" });
|
|
345
|
+
i.createIndex("status", "status", { unique: !1 }), i.createIndex("actionId", "actionId", { unique: !1 });
|
|
398
346
|
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
resolve(req.result);
|
|
403
|
-
};
|
|
404
|
-
req.onerror = () => reject(req.error);
|
|
347
|
+
}, n.onsuccess = () => {
|
|
348
|
+
A = n.result, e(n.result);
|
|
349
|
+
}, n.onerror = () => t(n.error);
|
|
405
350
|
});
|
|
406
351
|
}
|
|
407
|
-
async function
|
|
408
|
-
const
|
|
409
|
-
return new Promise((
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
tx.oncomplete = () => resolve();
|
|
413
|
-
tx.onerror = () => reject(tx.error);
|
|
352
|
+
async function ae(e) {
|
|
353
|
+
const t = await m();
|
|
354
|
+
return new Promise((n, r) => {
|
|
355
|
+
const s = t.transaction(h, "readwrite");
|
|
356
|
+
s.objectStore(h).add(e), s.oncomplete = () => n(), s.onerror = () => r(s.error);
|
|
414
357
|
});
|
|
415
358
|
}
|
|
416
|
-
async function
|
|
417
|
-
const
|
|
418
|
-
return new Promise((
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
req.onsuccess = () => resolve(req.result);
|
|
422
|
-
req.onerror = () => reject(req.error);
|
|
359
|
+
async function ie() {
|
|
360
|
+
const e = await m();
|
|
361
|
+
return new Promise((t, n) => {
|
|
362
|
+
const s = e.transaction(h, "readonly").objectStore(h).getAll();
|
|
363
|
+
s.onsuccess = () => t(s.result), s.onerror = () => n(s.error);
|
|
423
364
|
});
|
|
424
365
|
}
|
|
425
|
-
async function
|
|
426
|
-
const
|
|
427
|
-
return new Promise((
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (get.result) {
|
|
433
|
-
store.put({ ...get.result, ...update });
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
tx.oncomplete = () => resolve();
|
|
437
|
-
tx.onerror = () => reject(tx.error);
|
|
366
|
+
async function k(e, t) {
|
|
367
|
+
const n = await m();
|
|
368
|
+
return new Promise((r, s) => {
|
|
369
|
+
const i = n.transaction(h, "readwrite"), a = i.objectStore(h), c = a.get(e);
|
|
370
|
+
c.onsuccess = () => {
|
|
371
|
+
c.result && a.put({ ...c.result, ...t });
|
|
372
|
+
}, i.oncomplete = () => r(), i.onerror = () => s(i.error);
|
|
438
373
|
});
|
|
439
374
|
}
|
|
440
|
-
async function
|
|
441
|
-
const
|
|
442
|
-
return new Promise((
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
tx.oncomplete = () => resolve();
|
|
446
|
-
tx.onerror = () => reject(tx.error);
|
|
375
|
+
async function oe(e) {
|
|
376
|
+
const t = await m();
|
|
377
|
+
return new Promise((n, r) => {
|
|
378
|
+
const s = t.transaction(h, "readwrite");
|
|
379
|
+
s.objectStore(h).delete(e), s.oncomplete = () => n(), s.onerror = () => r(s.error);
|
|
447
380
|
});
|
|
448
381
|
}
|
|
449
|
-
async function
|
|
450
|
-
const
|
|
451
|
-
return new Promise((
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (err) {
|
|
458
|
-
reject(err);
|
|
382
|
+
async function ce() {
|
|
383
|
+
const e = await m();
|
|
384
|
+
return new Promise((t, n) => {
|
|
385
|
+
const s = e.transaction(h, "readonly").objectStore(h).index("status"), i = [];
|
|
386
|
+
let a = 0;
|
|
387
|
+
function c(d) {
|
|
388
|
+
if (d) {
|
|
389
|
+
n(d);
|
|
459
390
|
return;
|
|
460
391
|
}
|
|
461
|
-
|
|
392
|
+
++a === 2 && t(i);
|
|
462
393
|
}
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
failedReq.onsuccess = (e) => {
|
|
474
|
-
const cursor = e.target.result;
|
|
475
|
-
if (cursor) {
|
|
476
|
-
results.push(cursor.value);
|
|
477
|
-
cursor.continue();
|
|
478
|
-
} else finish();
|
|
479
|
-
};
|
|
480
|
-
failedReq.onerror = () => finish(failedReq.error);
|
|
394
|
+
const u = s.openCursor(IDBKeyRange.only("pending"));
|
|
395
|
+
u.onsuccess = (d) => {
|
|
396
|
+
const f = d.target.result;
|
|
397
|
+
f ? (i.push(f.value), f.continue()) : c();
|
|
398
|
+
}, u.onerror = () => c(u.error);
|
|
399
|
+
const l = s.openCursor(IDBKeyRange.only("failed"));
|
|
400
|
+
l.onsuccess = (d) => {
|
|
401
|
+
const f = d.target.result;
|
|
402
|
+
f ? (i.push(f.value), f.continue()) : c();
|
|
403
|
+
}, l.onerror = () => c(l.error);
|
|
481
404
|
});
|
|
482
405
|
}
|
|
483
|
-
async function
|
|
484
|
-
const
|
|
485
|
-
return new Promise((
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
tx.oncomplete = () => resolve();
|
|
489
|
-
tx.onerror = () => reject(tx.error);
|
|
406
|
+
async function ue() {
|
|
407
|
+
const e = await m();
|
|
408
|
+
return new Promise((t, n) => {
|
|
409
|
+
const r = e.transaction(h, "readwrite");
|
|
410
|
+
r.objectStore(h).clear(), r.oncomplete = () => t(), r.onerror = () => n(r.error);
|
|
490
411
|
});
|
|
491
412
|
}
|
|
492
|
-
const
|
|
493
|
-
function
|
|
413
|
+
const H = /* @__PURE__ */ new Map();
|
|
414
|
+
function L() {
|
|
494
415
|
return crypto.randomUUID();
|
|
495
416
|
}
|
|
496
|
-
function
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
const { isOnline } =
|
|
501
|
-
if (
|
|
502
|
-
if (!
|
|
503
|
-
return
|
|
504
|
-
}
|
|
417
|
+
function me(e, t) {
|
|
418
|
+
const n = t.name || e.name || L();
|
|
419
|
+
H.set(n, e);
|
|
420
|
+
const r = async (...s) => {
|
|
421
|
+
const { isOnline: i } = o.getState();
|
|
422
|
+
if (t.reliability === "neverLose") {
|
|
423
|
+
if (!i)
|
|
424
|
+
return j(n, n, s, t);
|
|
505
425
|
try {
|
|
506
|
-
return await
|
|
426
|
+
return await e(...s);
|
|
507
427
|
} catch {
|
|
508
|
-
return
|
|
428
|
+
return j(n, n, s, t);
|
|
509
429
|
}
|
|
510
430
|
}
|
|
511
|
-
return
|
|
431
|
+
return e(...s);
|
|
512
432
|
};
|
|
513
|
-
Object.defineProperty(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
actionId,
|
|
522
|
-
actionName,
|
|
523
|
-
args,
|
|
433
|
+
return Object.defineProperty(r, "id", { value: n, writable: !1 }), Object.defineProperty(r, "config", { value: t, writable: !1 }), r;
|
|
434
|
+
}
|
|
435
|
+
async function j(e, t, n, r) {
|
|
436
|
+
const s = L(), i = {
|
|
437
|
+
id: s,
|
|
438
|
+
actionId: e,
|
|
439
|
+
actionName: t,
|
|
440
|
+
args: n,
|
|
524
441
|
queuedAt: Date.now(),
|
|
525
442
|
retryCount: 0,
|
|
526
|
-
maxRetries:
|
|
443
|
+
maxRetries: r.maxRetries ?? 3,
|
|
527
444
|
status: "pending"
|
|
528
445
|
};
|
|
529
|
-
await
|
|
530
|
-
useEidosStore.getState().addQueueItem(item);
|
|
446
|
+
await ae(i), o.getState().addQueueItem(i);
|
|
531
447
|
try {
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
await reg.sync.register("eidos-queue-replay");
|
|
535
|
-
}
|
|
448
|
+
const a = V();
|
|
449
|
+
a && "sync" in a && await a.sync.register("eidos-queue-replay");
|
|
536
450
|
} catch {
|
|
537
451
|
}
|
|
538
452
|
return {
|
|
539
|
-
queued:
|
|
540
|
-
id,
|
|
541
|
-
message: `"${
|
|
453
|
+
queued: !0,
|
|
454
|
+
id: s,
|
|
455
|
+
message: `"${t}" queued — will execute when online`
|
|
542
456
|
};
|
|
543
457
|
}
|
|
544
|
-
function
|
|
545
|
-
|
|
546
|
-
return base * (0.8 + Math.random() * 0.4);
|
|
458
|
+
function de(e) {
|
|
459
|
+
return Math.min(2e3 * 2 ** e, 3e5) * (0.8 + Math.random() * 0.4);
|
|
547
460
|
}
|
|
548
|
-
let
|
|
549
|
-
async function
|
|
550
|
-
const
|
|
551
|
-
if (!
|
|
461
|
+
let _ = !1;
|
|
462
|
+
async function C() {
|
|
463
|
+
const e = o.getState();
|
|
464
|
+
if (!e.isOnline || _)
|
|
552
465
|
return { attempted: 0, succeeded: 0, failed: 0, retrying: 0, skipped: 0 };
|
|
553
|
-
|
|
554
|
-
_replaying = true;
|
|
466
|
+
_ = !0;
|
|
555
467
|
try {
|
|
556
|
-
return await
|
|
468
|
+
return await fe(e);
|
|
557
469
|
} finally {
|
|
558
|
-
|
|
470
|
+
_ = !1;
|
|
559
471
|
}
|
|
560
472
|
}
|
|
561
|
-
async function
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
pending.map(async (item) => {
|
|
570
|
-
const fn = _actionRegistry.get(item.actionId);
|
|
571
|
-
if (!fn) return "skipped";
|
|
572
|
-
store.updateQueueItem(item.id, { status: "replaying" });
|
|
573
|
-
await idbUpdateQueueItem(item.id, { status: "replaying" });
|
|
473
|
+
async function fe(e) {
|
|
474
|
+
const t = await ce(), n = Date.now(), r = t.filter(
|
|
475
|
+
(a) => !a.nextRetryAt || a.nextRetryAt <= n
|
|
476
|
+
), s = { attempted: 0, succeeded: 0, failed: 0, retrying: 0, skipped: 0 }, i = await Promise.allSettled(
|
|
477
|
+
r.map(async (a) => {
|
|
478
|
+
const c = H.get(a.actionId);
|
|
479
|
+
if (!c) return "skipped";
|
|
480
|
+
e.updateQueueItem(a.id, { status: "replaying" }), await k(a.id, { status: "replaying" });
|
|
574
481
|
try {
|
|
575
|
-
await
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
store.updateQueueItem(item.id, { status: "failed", error: String(err), retryCount });
|
|
588
|
-
await idbUpdateQueueItem(item.id, { status: "failed", error: String(err), retryCount });
|
|
589
|
-
return "failed";
|
|
590
|
-
} else {
|
|
591
|
-
const nextRetryAt = Date.now() + backoffMs(retryCount);
|
|
592
|
-
store.updateQueueItem(item.id, { status: "pending", retryCount, nextRetryAt });
|
|
593
|
-
await idbUpdateQueueItem(item.id, { status: "pending", retryCount, nextRetryAt });
|
|
594
|
-
return "retrying";
|
|
482
|
+
await c(...a.args);
|
|
483
|
+
const u = Date.now();
|
|
484
|
+
return e.updateQueueItem(a.id, { status: "succeeded", completedAt: u }), await k(a.id, { status: "succeeded", completedAt: u }), setTimeout(() => {
|
|
485
|
+
e.removeQueueItem(a.id), oe(a.id);
|
|
486
|
+
}, 3e3), "succeeded";
|
|
487
|
+
} catch (u) {
|
|
488
|
+
const l = a.retryCount + 1;
|
|
489
|
+
if (l >= a.maxRetries)
|
|
490
|
+
return e.updateQueueItem(a.id, { status: "failed", error: String(u), retryCount: l }), await k(a.id, { status: "failed", error: String(u), retryCount: l }), "failed";
|
|
491
|
+
{
|
|
492
|
+
const d = Date.now() + de(l);
|
|
493
|
+
return e.updateQueueItem(a.id, { status: "pending", retryCount: l, nextRetryAt: d }), await k(a.id, { status: "pending", retryCount: l, nextRetryAt: d }), "retrying";
|
|
595
494
|
}
|
|
596
495
|
}
|
|
597
496
|
})
|
|
598
497
|
);
|
|
599
|
-
for (const
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
result.skipped++;
|
|
603
|
-
} else {
|
|
604
|
-
result.attempted++;
|
|
605
|
-
result[outcome]++;
|
|
606
|
-
}
|
|
498
|
+
for (const a of i) {
|
|
499
|
+
const c = a.status === "fulfilled" ? a.value : "failed";
|
|
500
|
+
c === "skipped" ? s.skipped++ : (s.attempted++, s[c]++);
|
|
607
501
|
}
|
|
608
|
-
return
|
|
609
|
-
}
|
|
610
|
-
async function
|
|
611
|
-
await
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const swPath = config.swPath ?? "/eidos-sw.js";
|
|
619
|
-
const autoReplay = config.autoReplay ?? true;
|
|
502
|
+
return s;
|
|
503
|
+
}
|
|
504
|
+
async function ve() {
|
|
505
|
+
await ue(), o.getState().hydrateQueue([]);
|
|
506
|
+
}
|
|
507
|
+
let M = !1;
|
|
508
|
+
async function le(e = {}) {
|
|
509
|
+
if (M) return;
|
|
510
|
+
M = !0;
|
|
511
|
+
const t = e.swPath ?? "/eidos-sw.js", n = e.autoReplay ?? !0;
|
|
620
512
|
try {
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
useEidosStore.getState().hydrateQueue(persisted);
|
|
624
|
-
}
|
|
513
|
+
const r = await ie();
|
|
514
|
+
r.length > 0 && o.getState().hydrateQueue(r);
|
|
625
515
|
} catch {
|
|
626
516
|
}
|
|
627
517
|
try {
|
|
628
|
-
await
|
|
518
|
+
await Y(t);
|
|
629
519
|
} catch {
|
|
630
520
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
useEidosStore.subscribe(() => {
|
|
639
|
-
const { isOnline } = useEidosStore.getState();
|
|
640
|
-
const justCameOnline = isOnline && !prevIsOnline;
|
|
641
|
-
prevIsOnline = isOnline;
|
|
642
|
-
if (justCameOnline) {
|
|
643
|
-
setTimeout(replayQueue, 600);
|
|
644
|
-
}
|
|
521
|
+
if (X(() => {
|
|
522
|
+
o.getState().isOnline && setTimeout(C, 200);
|
|
523
|
+
}), n) {
|
|
524
|
+
let r = o.getState().isOnline;
|
|
525
|
+
o.subscribe(() => {
|
|
526
|
+
const { isOnline: a } = o.getState(), c = a && !r;
|
|
527
|
+
r = a, c && setTimeout(C, 600);
|
|
645
528
|
});
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
if (store.isOnline && hasPending) {
|
|
649
|
-
setTimeout(replayQueue, 1200);
|
|
650
|
-
}
|
|
529
|
+
const s = o.getState(), i = s.queue.some((a) => a.status === "pending" || a.status === "failed");
|
|
530
|
+
s.isOnline && i && setTimeout(C, 1200);
|
|
651
531
|
}
|
|
652
532
|
}
|
|
653
|
-
function
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}, []);
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
function useEidosOnDrain(callback) {
|
|
689
|
-
const total = useStore((s) => s.queue.length);
|
|
690
|
-
const prevRef = useRef(0);
|
|
691
|
-
const callbackRef = useRef(callback);
|
|
692
|
-
callbackRef.current = callback;
|
|
693
|
-
useEffect(() => {
|
|
694
|
-
if (prevRef.current > 0 && total === 0) {
|
|
695
|
-
callbackRef.current();
|
|
696
|
-
}
|
|
697
|
-
prevRef.current = total;
|
|
698
|
-
}, [total]);
|
|
533
|
+
function Ee({ children: e, swPath: t, autoReplay: n }) {
|
|
534
|
+
return U(() => {
|
|
535
|
+
le({ swPath: t, autoReplay: n });
|
|
536
|
+
}, []), /* @__PURE__ */ B(F, { children: e });
|
|
537
|
+
}
|
|
538
|
+
function p(e) {
|
|
539
|
+
const t = e ?? ((n) => n);
|
|
540
|
+
return $(o.subscribe, () => t(o.getState()));
|
|
541
|
+
}
|
|
542
|
+
function Re() {
|
|
543
|
+
return p();
|
|
544
|
+
}
|
|
545
|
+
function be(e) {
|
|
546
|
+
return p((t) => t.resources[e]);
|
|
547
|
+
}
|
|
548
|
+
function ke() {
|
|
549
|
+
return p((e) => e.queue);
|
|
550
|
+
}
|
|
551
|
+
function qe(e) {
|
|
552
|
+
return p((t) => t.queue.find((n) => n.id === e));
|
|
553
|
+
}
|
|
554
|
+
function Oe() {
|
|
555
|
+
const e = p((r) => r.isOnline), t = p((r) => r.swStatus), n = p((r) => r.swError);
|
|
556
|
+
return { isOnline: e, swStatus: t, swError: n };
|
|
557
|
+
}
|
|
558
|
+
function xe() {
|
|
559
|
+
const e = p((s) => s.queue.filter((i) => i.status === "pending").length), t = p((s) => s.queue.filter((i) => i.status === "failed").length), n = p((s) => s.queue.filter((i) => i.status === "replaying").length), r = p((s) => s.queue.length);
|
|
560
|
+
return { pending: e, failed: t, replaying: n, total: r };
|
|
561
|
+
}
|
|
562
|
+
function Ie(e) {
|
|
563
|
+
const t = p((s) => s.queue.length), n = N(0), r = N(e);
|
|
564
|
+
r.current = e, U(() => {
|
|
565
|
+
n.current > 0 && t === 0 && r.current(), n.current = t;
|
|
566
|
+
}, [t]);
|
|
699
567
|
}
|
|
700
|
-
const
|
|
701
|
-
function
|
|
568
|
+
const Ae = "1.0.12";
|
|
569
|
+
function v(e) {
|
|
702
570
|
return {
|
|
703
|
-
subscribe(
|
|
704
|
-
|
|
705
|
-
return useEidosStore.subscribe(() => run(selector(useEidosStore.getState())));
|
|
571
|
+
subscribe(t) {
|
|
572
|
+
return t(e(o.getState())), o.subscribe(() => t(e(o.getState())));
|
|
706
573
|
},
|
|
707
574
|
getState() {
|
|
708
|
-
return
|
|
575
|
+
return e(o.getState());
|
|
709
576
|
}
|
|
710
577
|
};
|
|
711
578
|
}
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
pending:
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
function
|
|
726
|
-
return
|
|
727
|
-
}
|
|
728
|
-
function eidosAction(id) {
|
|
729
|
-
return readable((s) => s.queue.find((item) => item.id === id));
|
|
579
|
+
const _e = v((e) => e), Ce = v((e) => e.queue), De = v((e) => ({
|
|
580
|
+
isOnline: e.isOnline,
|
|
581
|
+
swStatus: e.swStatus,
|
|
582
|
+
swError: e.swError
|
|
583
|
+
})), Qe = v((e) => {
|
|
584
|
+
let t = 0, n = 0, r = 0;
|
|
585
|
+
for (const s of e.queue)
|
|
586
|
+
s.status === "pending" ? t++ : s.status === "failed" ? n++ : s.status === "replaying" && r++;
|
|
587
|
+
return { pending: t, failed: n, replaying: r, total: e.queue.length };
|
|
588
|
+
});
|
|
589
|
+
function Pe(e) {
|
|
590
|
+
return v((t) => t.resources[e]);
|
|
591
|
+
}
|
|
592
|
+
function Ne(e) {
|
|
593
|
+
return v((t) => t.queue.find((n) => n.id === e));
|
|
730
594
|
}
|
|
731
595
|
export {
|
|
732
|
-
EidosProvider,
|
|
733
|
-
VERSION,
|
|
734
|
-
action,
|
|
735
|
-
clearQueue,
|
|
736
|
-
eidosAction,
|
|
737
|
-
eidosQueue,
|
|
738
|
-
eidosQueueStats,
|
|
739
|
-
eidosResource,
|
|
740
|
-
eidosStatus,
|
|
741
|
-
eidosStore,
|
|
742
|
-
initEidos,
|
|
743
|
-
isBgSyncSupported,
|
|
744
|
-
replayQueue,
|
|
745
|
-
resource,
|
|
746
|
-
setOfflineSimulation,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
596
|
+
Ee as EidosProvider,
|
|
597
|
+
Ae as VERSION,
|
|
598
|
+
me as action,
|
|
599
|
+
ve as clearQueue,
|
|
600
|
+
Ne as eidosAction,
|
|
601
|
+
Ce as eidosQueue,
|
|
602
|
+
Qe as eidosQueueStats,
|
|
603
|
+
Pe as eidosResource,
|
|
604
|
+
De as eidosStatus,
|
|
605
|
+
_e as eidosStore,
|
|
606
|
+
le as initEidos,
|
|
607
|
+
we as isBgSyncSupported,
|
|
608
|
+
C as replayQueue,
|
|
609
|
+
Se as resource,
|
|
610
|
+
ge as setOfflineSimulation,
|
|
611
|
+
ye as setQueryInvalidator,
|
|
612
|
+
Re as useEidos,
|
|
613
|
+
qe as useEidosAction,
|
|
614
|
+
Ie as useEidosOnDrain,
|
|
615
|
+
ke as useEidosQueue,
|
|
616
|
+
xe as useEidosQueueStats,
|
|
617
|
+
be as useEidosResource,
|
|
618
|
+
Oe as useEidosStatus,
|
|
619
|
+
o as useEidosStore
|
|
755
620
|
};
|
|
756
621
|
//# sourceMappingURL=eidos.es.js.map
|