@floegence/floe-webapp-core 0.68.0 → 0.70.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/dist/reload-placeholder.d.ts +24 -0
- package/dist/reload-placeholder.js +124 -0
- package/dist/resource-cache.d.ts +2 -0
- package/dist/resource-cache.js +132 -123
- package/package.json +5 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ReloadPlaceholderOptions {
|
|
2
|
+
/** Session-only presentation storage; never put resource data in this record. */
|
|
3
|
+
storageKey: string;
|
|
4
|
+
/** Optional session-storage identity to isolate navigation between environments. */
|
|
5
|
+
scopeStorageKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ReloadPlaceholder {
|
|
8
|
+
active(): boolean;
|
|
9
|
+
/** Keep the matching content placeholder while the live shell becomes usable. */
|
|
10
|
+
restrictTo(element: Element): void;
|
|
11
|
+
finish(): void;
|
|
12
|
+
/** Capture only anonymous geometry on pagehide, from the current authorized view. */
|
|
13
|
+
arm(root: Element, surfaces: string): void;
|
|
14
|
+
/** Explicit revocation discards the placeholder and its session record. */
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
__floeReloadPlaceholder?: ReloadPlaceholder;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Insert before external scripts/styles. It restores anonymous layout, never cached facts. */
|
|
23
|
+
export declare function createReloadPlaceholderScript(options: ReloadPlaceholderOptions): string;
|
|
24
|
+
export declare function getReloadPlaceholder(): ReloadPlaceholder | undefined;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
function P(h) {
|
|
2
|
+
const s = document, $ = 48e3, b = 240, A = () => h.scopeStorageKey ? sessionStorage.getItem(h.scopeStorageKey) ?? "" : "", g = (o) => typeof o == "string" && o.length <= 120 && !/[;{}<>\\]|url\(|var\(/i.test(o) && CSS.supports("color", o);
|
|
3
|
+
let l, a, C = "", d;
|
|
4
|
+
try {
|
|
5
|
+
const o = sessionStorage.getItem(h.storageKey), e = o && o.length <= $ ? JSON.parse(o) : void 0;
|
|
6
|
+
e?.version === 1 && e.scope === A() && e.width === innerWidth && e.height === innerHeight && g(e.background) && Array.isArray(e.scroll) && e.scroll.length <= 12 && e.scroll.every((r) => Array.isArray(r) && r.length === 3 && /^[a-z0-9-]{1,48}$/.test(r[0]) && r.slice(1).every((i) => typeof i == "number" && Number.isFinite(i) && i >= 0 && i <= 1e7)) && Array.isArray(e.boxes) && e.boxes.length > 0 && e.boxes.length <= b && e.boxes.every((r) => Array.isArray(r) && r.length === 7 && r.slice(0, 5).every((i) => typeof i == "number" && Number.isFinite(i) && i >= 0 && i <= 2e4) && g(r[5]) && g(r[6])) && (d = e);
|
|
7
|
+
} catch {
|
|
8
|
+
}
|
|
9
|
+
const M = () => {
|
|
10
|
+
if (!(!d || !s.body)) {
|
|
11
|
+
l = s.createElement("div"), l.dataset.floeReloadPlaceholder = "", l.setAttribute("aria-hidden", "true"), l.inert = !0, Object.assign(l.style, {
|
|
12
|
+
position: "fixed",
|
|
13
|
+
inset: "0",
|
|
14
|
+
zIndex: "2147483000",
|
|
15
|
+
overflow: "hidden",
|
|
16
|
+
backgroundColor: d.background,
|
|
17
|
+
pointerEvents: "none",
|
|
18
|
+
contain: "strict"
|
|
19
|
+
});
|
|
20
|
+
for (const [o, e, r, i, x, m, w] of d.boxes) {
|
|
21
|
+
const p = s.createElement("div");
|
|
22
|
+
Object.assign(p.style, {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
left: `${o}px`,
|
|
25
|
+
top: `${e}px`,
|
|
26
|
+
width: `${r}px`,
|
|
27
|
+
height: `${i}px`,
|
|
28
|
+
borderRadius: `${x}px`,
|
|
29
|
+
backgroundColor: m,
|
|
30
|
+
border: `1px solid ${w}`,
|
|
31
|
+
boxSizing: "border-box"
|
|
32
|
+
}), l.append(p);
|
|
33
|
+
}
|
|
34
|
+
s.body.append(l);
|
|
35
|
+
}
|
|
36
|
+
}, v = new MutationObserver(() => {
|
|
37
|
+
s.body && (v.disconnect(), M());
|
|
38
|
+
});
|
|
39
|
+
s.body ? M() : d && v.observe(s.documentElement, { childList: !0 });
|
|
40
|
+
const y = () => {
|
|
41
|
+
v.disconnect();
|
|
42
|
+
for (const [o, e, r] of d?.scroll ?? []) {
|
|
43
|
+
const i = s.querySelector(`[data-floe-reload-scroll="${o}"]`);
|
|
44
|
+
i && (i.scrollLeft = e, i.scrollTop = r);
|
|
45
|
+
}
|
|
46
|
+
d = void 0, l?.remove(), l = void 0;
|
|
47
|
+
}, N = () => {
|
|
48
|
+
a = void 0, y();
|
|
49
|
+
try {
|
|
50
|
+
sessionStorage.removeItem(h.storageKey);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}, O = () => {
|
|
54
|
+
if (!a?.isConnected || l) return;
|
|
55
|
+
const o = [], e = getComputedStyle(s.body).backgroundColor;
|
|
56
|
+
if (!g(e)) return;
|
|
57
|
+
const r = (n) => {
|
|
58
|
+
const t = n.getBoundingClientRect(), c = getComputedStyle(n);
|
|
59
|
+
return t.width && t.height && t.bottom > 0 && t.right > 0 && t.top < innerHeight && t.left < innerWidth && c.visibility === "visible" ? t : null;
|
|
60
|
+
}, i = (n, t, c = "transparent", u = 3) => {
|
|
61
|
+
if (o.length >= b || !g(t) || !g(c)) return;
|
|
62
|
+
const f = Math.max(0, n.x), R = Math.max(0, n.y), k = Math.min(innerWidth, n.right) - f, E = Math.min(innerHeight, n.bottom) - R;
|
|
63
|
+
k <= 0 || E <= 0 || o.push([f, R, k, E, Math.max(0, Math.min(u, 100)), t, c]);
|
|
64
|
+
};
|
|
65
|
+
for (const n of a.querySelectorAll(C)) {
|
|
66
|
+
const t = r(n);
|
|
67
|
+
if (!t) continue;
|
|
68
|
+
const c = getComputedStyle(n);
|
|
69
|
+
i(t, c.backgroundColor, c.borderTopStyle === "none" ? "transparent" : c.borderTopColor, parseFloat(c.borderRadius) || 0);
|
|
70
|
+
}
|
|
71
|
+
const x = getComputedStyle(a).color, m = g(x) ? `color-mix(in srgb, ${x} 9%, ${e})` : "#d4d4d4";
|
|
72
|
+
for (const n of a.querySelectorAll("img,svg,input,textarea,canvas,video")) {
|
|
73
|
+
const t = r(n);
|
|
74
|
+
t && i(t, m, "transparent", Math.min(t.height / 4, 8));
|
|
75
|
+
}
|
|
76
|
+
const w = s.createTreeWalker(a, NodeFilter.SHOW_TEXT), p = s.createRange();
|
|
77
|
+
let S, T = 0;
|
|
78
|
+
for (; (S = w.nextNode()) && o.length < b && T++ < 12e3; ) {
|
|
79
|
+
const n = S.parentElement;
|
|
80
|
+
if (!(!n || n.closest('script,style,textarea,svg,[aria-hidden="true"]') || !r(n))) {
|
|
81
|
+
p.selectNodeContents(S);
|
|
82
|
+
for (const t of p.getClientRects())
|
|
83
|
+
t.width < 2 || i(new DOMRect(t.x, t.y + t.height * 0.22, t.width, t.height * 0.56), m);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (o.length)
|
|
87
|
+
try {
|
|
88
|
+
const n = [];
|
|
89
|
+
for (const u of a.querySelectorAll("[data-floe-reload-scroll]")) {
|
|
90
|
+
const f = u.getAttribute("data-floe-reload-scroll");
|
|
91
|
+
/^[a-z0-9-]{1,48}$/.test(f) && n.length < 12 && r(u) && n.push([f, u.scrollLeft, u.scrollTop]);
|
|
92
|
+
}
|
|
93
|
+
const t = { version: 1, scope: A(), width: innerWidth, height: innerHeight, background: e, boxes: o, scroll: n }, c = JSON.stringify(t);
|
|
94
|
+
c.length <= $ && sessionStorage.setItem(h.storageKey, c);
|
|
95
|
+
} catch {
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
window.__floeReloadPlaceholder = {
|
|
99
|
+
active: () => !!d,
|
|
100
|
+
restrictTo(o) {
|
|
101
|
+
if (!l) return;
|
|
102
|
+
const e = o.getBoundingClientRect();
|
|
103
|
+
l.style.clipPath = `inset(${Math.max(0, e.top)}px ${Math.max(0, innerWidth - e.right)}px ${Math.max(0, innerHeight - e.bottom)}px ${Math.max(0, e.left)}px)`;
|
|
104
|
+
},
|
|
105
|
+
finish: y,
|
|
106
|
+
arm(o, e) {
|
|
107
|
+
a = o, C = e;
|
|
108
|
+
},
|
|
109
|
+
clear: N
|
|
110
|
+
}, window.addEventListener("pagehide", O), window.addEventListener("resize", y, { once: !0 }), window.addEventListener("pageshow", (o) => {
|
|
111
|
+
o.persisted && y();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function W(h) {
|
|
115
|
+
const s = JSON.stringify(h).replaceAll("<", "\\u003c").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
116
|
+
return `;(${P.toString()})(${s});`;
|
|
117
|
+
}
|
|
118
|
+
function H() {
|
|
119
|
+
return typeof window > "u" ? void 0 : window.__floeReloadPlaceholder;
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
W as createReloadPlaceholderScript,
|
|
123
|
+
H as getReloadPlaceholder
|
|
124
|
+
};
|
package/dist/resource-cache.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface CachedResourceDefinition<T> {
|
|
|
38
38
|
}
|
|
39
39
|
export interface ResourceCache {
|
|
40
40
|
resource<T>(definition: CachedResourceDefinition<T>): CachedResource<T>;
|
|
41
|
+
/** Abort pending refreshes without retiring snapshots, storage, hydration or subscribers. */
|
|
42
|
+
cancelRefreshes(scope: string): void;
|
|
41
43
|
clearScope(scope: string): Promise<void>;
|
|
42
44
|
flush(): Promise<void>;
|
|
43
45
|
dispose(): void;
|
package/dist/resource-cache.js
CHANGED
|
@@ -1,177 +1,186 @@
|
|
|
1
|
-
async function
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
for (const
|
|
6
|
-
if (
|
|
7
|
-
await
|
|
1
|
+
async function J(y, l) {
|
|
2
|
+
const m = [...await y.list()].sort((r, s) => r.lastAccessedAt - s.lastAccessedAt);
|
|
3
|
+
let i = m.reduce((r, s) => r + s.bytes, 0);
|
|
4
|
+
const a = [];
|
|
5
|
+
for (const r of m) {
|
|
6
|
+
if (i <= Math.max(0, l)) break;
|
|
7
|
+
await y.remove(r.key), a.push(r.key), i -= r.bytes;
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
let
|
|
14
|
-
const d = (
|
|
15
|
-
}),
|
|
16
|
-
const
|
|
17
|
-
list: async () => (await
|
|
18
|
-
remove: (
|
|
19
|
-
},
|
|
20
|
-
for (const
|
|
21
|
-
},
|
|
22
|
-
clearTimeout(
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
for (const [
|
|
26
|
-
if (
|
|
11
|
+
function z(y) {
|
|
12
|
+
const l = y.storage, m = Math.max(0, y.maxBytes ?? 32 * 1024 * 1024), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
13
|
+
let r, s = Promise.resolve(), n = !1;
|
|
14
|
+
const d = (t) => (s = s.then(t).catch(() => {
|
|
15
|
+
}), s), f = async () => {
|
|
16
|
+
const t = await J({
|
|
17
|
+
list: async () => (await l.list()).map((e) => ({ ...e, lastAccessedAt: Math.max(e.lastAccessedAt, i.get(e.key)?.accessedAt ?? 0) })),
|
|
18
|
+
remove: (e) => l.remove(e)
|
|
19
|
+
}, m);
|
|
20
|
+
for (const e of t) i.get(e)?.evicted();
|
|
21
|
+
}, p = async () => {
|
|
22
|
+
clearTimeout(r), r = void 0;
|
|
23
|
+
const t = [...a];
|
|
24
|
+
a.clear(), t.length && d(async () => {
|
|
25
|
+
for (const [e, v] of t)
|
|
26
|
+
if (v.valid())
|
|
27
27
|
try {
|
|
28
|
-
await
|
|
28
|
+
await l.set(e, v.value), v.stored();
|
|
29
29
|
} catch {
|
|
30
30
|
}
|
|
31
|
-
await
|
|
32
|
-
}), await
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
31
|
+
await f();
|
|
32
|
+
}), await s;
|
|
33
|
+
}, x = (t, e, v, o) => {
|
|
34
|
+
a.set(t, { value: e, valid: v, stored: o }), r === void 0 && (r = setTimeout(() => {
|
|
35
|
+
p();
|
|
36
|
+
}, y.writeDelayMs ?? 100));
|
|
37
37
|
};
|
|
38
38
|
return {
|
|
39
|
-
resource: (
|
|
40
|
-
if (
|
|
41
|
-
if (!
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
let
|
|
46
|
-
const
|
|
47
|
-
let
|
|
48
|
-
const
|
|
49
|
-
for (const c of
|
|
50
|
-
},
|
|
51
|
-
++
|
|
39
|
+
resource: (t) => {
|
|
40
|
+
if (n) throw new Error("Resource cache is disposed");
|
|
41
|
+
if (!t.scope || !t.key || !Number.isSafeInteger(t.version)) throw new Error("Invalid resource identity");
|
|
42
|
+
const e = JSON.stringify([t.scope, t.key, t.version]), v = i.get(e);
|
|
43
|
+
if (v)
|
|
44
|
+
return v.accessedAt = Date.now(), v.handle;
|
|
45
|
+
let o = { data: void 0, restoring: !0, refreshing: !1, stale: !0, error: void 0 };
|
|
46
|
+
const S = /* @__PURE__ */ new Set();
|
|
47
|
+
let D = 0, w = 0, E, R, g, h, M;
|
|
48
|
+
const b = () => {
|
|
49
|
+
for (const c of S) c();
|
|
50
|
+
}, P = (c) => {
|
|
51
|
+
++D, o = { data: c, restoring: !1, refreshing: o.refreshing, stale: !1, error: void 0 };
|
|
52
52
|
try {
|
|
53
|
-
const u = JSON.stringify({ version:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}) :
|
|
53
|
+
const u = JSON.stringify({ version: t.version, data: t.persist ? t.persist(c) : c });
|
|
54
|
+
E = u, u !== R ? x(e, u, () => E === u, () => {
|
|
55
|
+
R = u;
|
|
56
|
+
}) : a.delete(e);
|
|
57
57
|
} catch {
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
if (!(
|
|
59
|
+
b();
|
|
60
|
+
}, C = D, O = l.get(e).then((c) => {
|
|
61
|
+
if (!(n || D !== C || c === null))
|
|
62
62
|
try {
|
|
63
63
|
const u = JSON.parse(c);
|
|
64
|
-
if (u.version !==
|
|
65
|
-
const A =
|
|
66
|
-
|
|
64
|
+
if (u.version !== t.version) throw new Error("Unsupported snapshot");
|
|
65
|
+
const A = t.decode(u.data);
|
|
66
|
+
o = { ...o, data: A, stale: !0 }, E = c, R = c;
|
|
67
67
|
} catch {
|
|
68
|
-
d(() =>
|
|
68
|
+
d(() => l.remove(e));
|
|
69
69
|
}
|
|
70
70
|
}).catch(() => {
|
|
71
71
|
}).finally(() => {
|
|
72
|
-
|
|
73
|
-
}),
|
|
74
|
-
snapshot: () =>
|
|
75
|
-
subscribe: (c) => (
|
|
76
|
-
|
|
72
|
+
n || !o.restoring || (o = { ...o, restoring: !1 }, b());
|
|
73
|
+
}), q = {
|
|
74
|
+
snapshot: () => o,
|
|
75
|
+
subscribe: (c) => (S.add(c), () => {
|
|
76
|
+
S.delete(c);
|
|
77
77
|
}),
|
|
78
|
-
hydrate: () =>
|
|
78
|
+
hydrate: () => O,
|
|
79
79
|
refresh: (c) => {
|
|
80
|
-
if (
|
|
81
|
-
const u = ++
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
if (h) return h;
|
|
81
|
+
const u = ++w, A = new AbortController();
|
|
82
|
+
g = A, o = { ...o, refreshing: !0, error: void 0 }, b();
|
|
83
|
+
const B = new Promise((k, I) => {
|
|
84
|
+
M = () => I(new DOMException("Resource refresh cancelled", "AbortError"));
|
|
85
|
+
}), N = Promise.resolve().then(() => c(A.signal)).then((k) => (!n && u === w && !A.signal.aborted && P(k), k), (k) => {
|
|
86
|
+
throw !n && u === w && !A.signal.aborted && (o = { ...o, stale: !0, error: k }, b()), k;
|
|
87
|
+
});
|
|
88
|
+
return h = Promise.race([N, B]).finally(() => {
|
|
89
|
+
u === w && (h = void 0, g = void 0, M = void 0, o = { ...o, refreshing: !1 }, b());
|
|
90
|
+
}), h;
|
|
87
91
|
},
|
|
88
92
|
set: (c) => {
|
|
89
|
-
++
|
|
93
|
+
++w, g?.abort(), h = void 0, o = { ...o, refreshing: !1 }, P(c);
|
|
90
94
|
},
|
|
91
95
|
invalidate: (c = !1) => {
|
|
92
|
-
++
|
|
96
|
+
++D, ++w, g?.abort(), g = void 0, h = void 0, E = void 0, R = void 0, a.delete(e), o = { data: c ? void 0 : o.data, restoring: !1, refreshing: !1, stale: !0, error: void 0 }, b(), d(() => l.remove(e));
|
|
93
97
|
}
|
|
94
98
|
};
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
}, handle:
|
|
98
|
-
++
|
|
99
|
-
}
|
|
99
|
+
return i.set(e, { scope: t.scope, accessedAt: Date.now(), evicted: () => {
|
|
100
|
+
R = void 0;
|
|
101
|
+
}, handle: q, cancelRefresh: () => {
|
|
102
|
+
h && (++w, M?.(), M = void 0, g?.abort(), g = void 0, h = void 0, o = { ...o, refreshing: !1, stale: !0 }, b());
|
|
103
|
+
}, stop: () => {
|
|
104
|
+
++w, g?.abort(), S.clear();
|
|
105
|
+
} }), q;
|
|
100
106
|
},
|
|
101
|
-
flush:
|
|
102
|
-
|
|
103
|
-
for (const
|
|
107
|
+
flush: p,
|
|
108
|
+
cancelRefreshes: (t) => {
|
|
109
|
+
for (const e of i.values()) e.scope === t && e.cancelRefresh();
|
|
110
|
+
},
|
|
111
|
+
clearScope: async (t) => {
|
|
112
|
+
for (const e of i.values()) e.scope === t && e.handle.invalidate(!0);
|
|
104
113
|
await d(async () => {
|
|
105
|
-
for (const
|
|
114
|
+
for (const e of await l.list())
|
|
106
115
|
try {
|
|
107
|
-
JSON.parse(
|
|
116
|
+
JSON.parse(e.key)[0] === t && await l.remove(e.key);
|
|
108
117
|
} catch {
|
|
109
118
|
}
|
|
110
119
|
});
|
|
111
120
|
},
|
|
112
121
|
dispose: () => {
|
|
113
|
-
if (!
|
|
114
|
-
|
|
115
|
-
for (const
|
|
116
|
-
|
|
122
|
+
if (!n) {
|
|
123
|
+
n = !0;
|
|
124
|
+
for (const t of i.values()) t.stop();
|
|
125
|
+
p(), i.clear();
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
128
|
};
|
|
120
129
|
}
|
|
121
|
-
function
|
|
122
|
-
let
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}, n
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
|
|
130
|
+
function L(y = "floe-resource-cache") {
|
|
131
|
+
let l;
|
|
132
|
+
const m = () => l ??= new Promise((a, r) => {
|
|
133
|
+
const s = indexedDB.open(y, 1);
|
|
134
|
+
s.onupgradeneeded = () => s.result.createObjectStore("snapshots", { keyPath: "key" }), s.onsuccess = () => {
|
|
135
|
+
const n = s.result;
|
|
136
|
+
n.onversionchange = () => {
|
|
137
|
+
n.close(), l = void 0;
|
|
138
|
+
}, a(n);
|
|
139
|
+
}, s.onerror = () => {
|
|
140
|
+
l = void 0, r(s.error);
|
|
141
|
+
}, s.onblocked = () => {
|
|
142
|
+
l = void 0, r(new Error("Resource cache database is blocked"));
|
|
134
143
|
};
|
|
135
|
-
}),
|
|
136
|
-
const
|
|
137
|
-
return new Promise((
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
}), i = async (a, r) => {
|
|
145
|
+
const s = await m();
|
|
146
|
+
return new Promise((n, d) => {
|
|
147
|
+
const f = s.transaction("snapshots", a);
|
|
148
|
+
let p;
|
|
149
|
+
f.oncomplete = () => n(p), f.onerror = () => d(f.error), f.onabort = () => d(f.error ?? new Error("Resource cache transaction aborted")), r(f.objectStore("snapshots"), (x) => {
|
|
150
|
+
p = x;
|
|
142
151
|
});
|
|
143
152
|
});
|
|
144
153
|
};
|
|
145
154
|
return {
|
|
146
|
-
get: (
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
const d =
|
|
150
|
-
d &&
|
|
155
|
+
get: (a) => i("readwrite", (r, s) => {
|
|
156
|
+
const n = r.get(a);
|
|
157
|
+
n.onsuccess = () => {
|
|
158
|
+
const d = n.result;
|
|
159
|
+
d && r.put({ ...d, lastAccessedAt: Date.now() }), s(d?.value ?? null);
|
|
151
160
|
};
|
|
152
161
|
}),
|
|
153
|
-
set: (
|
|
154
|
-
|
|
162
|
+
set: (a, r) => i("readwrite", (s, n) => {
|
|
163
|
+
s.put({ key: a, value: r, bytes: new TextEncoder().encode(r).byteLength, lastAccessedAt: Date.now() }), n(void 0);
|
|
155
164
|
}),
|
|
156
|
-
remove: (
|
|
157
|
-
|
|
165
|
+
remove: (a) => i("readwrite", (r, s) => {
|
|
166
|
+
r.delete(a), s(void 0);
|
|
158
167
|
}),
|
|
159
|
-
list: () =>
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
const d =
|
|
168
|
+
list: () => i("readonly", (a, r) => {
|
|
169
|
+
const s = [], n = a.openCursor();
|
|
170
|
+
n.onsuccess = () => {
|
|
171
|
+
const d = n.result;
|
|
163
172
|
if (!d) {
|
|
164
|
-
|
|
173
|
+
r(s);
|
|
165
174
|
return;
|
|
166
175
|
}
|
|
167
|
-
const { key:
|
|
168
|
-
|
|
176
|
+
const { key: f, bytes: p, lastAccessedAt: x } = d.value;
|
|
177
|
+
s.push({ key: f, bytes: p, lastAccessedAt: x }), d.continue();
|
|
169
178
|
};
|
|
170
179
|
})
|
|
171
180
|
};
|
|
172
181
|
}
|
|
173
182
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
183
|
+
L as createIndexedDBResourceCacheStorage,
|
|
184
|
+
z as createResourceCache,
|
|
185
|
+
J as enforceResourceCacheBudget
|
|
177
186
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -112,6 +112,10 @@
|
|
|
112
112
|
"types": "./dist/window-status.d.ts",
|
|
113
113
|
"import": "./dist/window-status.js",
|
|
114
114
|
"default": "./dist/window-status.js"
|
|
115
|
+
},
|
|
116
|
+
"./reload-placeholder": {
|
|
117
|
+
"types": "./dist/reload-placeholder.d.ts",
|
|
118
|
+
"import": "./dist/reload-placeholder.js"
|
|
115
119
|
}
|
|
116
120
|
},
|
|
117
121
|
"files": [
|