@lolyjs/core 0.1.0-alpha.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 +607 -0
- package/bin/loly.cjs +6 -0
- package/dist/bootstrap-BiCQmSkx.d.mts +50 -0
- package/dist/bootstrap-BiCQmSkx.d.ts +50 -0
- package/dist/cli.cjs +5186 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5181 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +5774 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +445 -0
- package/dist/index.d.ts +445 -0
- package/dist/index.js +5731 -0
- package/dist/index.js.map +1 -0
- package/dist/react/cache.cjs +251 -0
- package/dist/react/cache.cjs.map +1 -0
- package/dist/react/cache.d.mts +59 -0
- package/dist/react/cache.d.ts +59 -0
- package/dist/react/cache.js +220 -0
- package/dist/react/cache.js.map +1 -0
- package/dist/react/components.cjs +218 -0
- package/dist/react/components.cjs.map +1 -0
- package/dist/react/components.d.mts +26 -0
- package/dist/react/components.d.ts +26 -0
- package/dist/react/components.js +190 -0
- package/dist/react/components.js.map +1 -0
- package/dist/react/hooks.cjs +86 -0
- package/dist/react/hooks.cjs.map +1 -0
- package/dist/react/hooks.d.mts +19 -0
- package/dist/react/hooks.d.ts +19 -0
- package/dist/react/hooks.js +58 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/sockets.cjs +43 -0
- package/dist/react/sockets.cjs.map +1 -0
- package/dist/react/sockets.d.mts +29 -0
- package/dist/react/sockets.d.ts +29 -0
- package/dist/react/sockets.js +18 -0
- package/dist/react/sockets.js.map +1 -0
- package/dist/react/themes.cjs +145 -0
- package/dist/react/themes.cjs.map +1 -0
- package/dist/react/themes.d.mts +13 -0
- package/dist/react/themes.d.ts +13 -0
- package/dist/react/themes.js +117 -0
- package/dist/react/themes.js.map +1 -0
- package/dist/runtime.cjs +626 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.mts +11 -0
- package/dist/runtime.d.ts +11 -0
- package/dist/runtime.js +599 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// modules/react/cache/index.ts
|
|
21
|
+
var cache_exports = {};
|
|
22
|
+
__export(cache_exports, {
|
|
23
|
+
getRouteData: () => getRouteData,
|
|
24
|
+
prefetchRouteData: () => prefetchRouteData,
|
|
25
|
+
revalidate: () => revalidate,
|
|
26
|
+
revalidatePath: () => revalidatePath,
|
|
27
|
+
revalidateRouteData: () => revalidateRouteData
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(cache_exports);
|
|
30
|
+
|
|
31
|
+
// modules/react/cache/client-data-cache/index.ts
|
|
32
|
+
var CACHE_KEY = "__FW_DATA_CACHE__";
|
|
33
|
+
var MAX_CACHE_SIZE = 100;
|
|
34
|
+
function getCacheStore() {
|
|
35
|
+
if (typeof window !== "undefined") {
|
|
36
|
+
if (!window[CACHE_KEY]) {
|
|
37
|
+
window[CACHE_KEY] = {
|
|
38
|
+
data: /* @__PURE__ */ new Map(),
|
|
39
|
+
index: /* @__PURE__ */ new Map(),
|
|
40
|
+
lru: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return window[CACHE_KEY];
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
data: /* @__PURE__ */ new Map(),
|
|
47
|
+
index: /* @__PURE__ */ new Map(),
|
|
48
|
+
lru: []
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var cacheStore = getCacheStore();
|
|
52
|
+
var dataCache = cacheStore.data;
|
|
53
|
+
var pathIndex = cacheStore.index;
|
|
54
|
+
var lru = cacheStore.lru;
|
|
55
|
+
function extractPathBase(key) {
|
|
56
|
+
return key.split("?")[0];
|
|
57
|
+
}
|
|
58
|
+
function addToIndex(key) {
|
|
59
|
+
const pathBase = extractPathBase(key);
|
|
60
|
+
if (!pathIndex.has(pathBase)) {
|
|
61
|
+
pathIndex.set(pathBase, /* @__PURE__ */ new Set());
|
|
62
|
+
}
|
|
63
|
+
pathIndex.get(pathBase).add(key);
|
|
64
|
+
}
|
|
65
|
+
function removeFromIndex(key) {
|
|
66
|
+
const pathBase = extractPathBase(key);
|
|
67
|
+
const keys = pathIndex.get(pathBase);
|
|
68
|
+
if (keys) {
|
|
69
|
+
keys.delete(key);
|
|
70
|
+
if (keys.size === 0) {
|
|
71
|
+
pathIndex.delete(pathBase);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function updateLRU(key) {
|
|
76
|
+
const index = lru.indexOf(key);
|
|
77
|
+
if (index !== -1) {
|
|
78
|
+
lru.splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
lru.push(key);
|
|
81
|
+
}
|
|
82
|
+
function evictOldest() {
|
|
83
|
+
while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {
|
|
84
|
+
const oldestKey = lru.shift();
|
|
85
|
+
dataCache.delete(oldestKey);
|
|
86
|
+
removeFromIndex(oldestKey);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function setCacheEntry(key, entry) {
|
|
90
|
+
const existingEntry = dataCache.get(key);
|
|
91
|
+
const wasFulfilled = existingEntry?.status === "fulfilled";
|
|
92
|
+
dataCache.set(key, entry);
|
|
93
|
+
if (entry.status === "fulfilled") {
|
|
94
|
+
if (!wasFulfilled) {
|
|
95
|
+
addToIndex(key);
|
|
96
|
+
}
|
|
97
|
+
updateLRU(key);
|
|
98
|
+
evictOldest();
|
|
99
|
+
} else if (wasFulfilled) {
|
|
100
|
+
removeFromIndex(key);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function deleteCacheEntry(key) {
|
|
104
|
+
if (dataCache.has(key)) {
|
|
105
|
+
dataCache.delete(key);
|
|
106
|
+
removeFromIndex(key);
|
|
107
|
+
const lruIndex = lru.indexOf(key);
|
|
108
|
+
if (lruIndex !== -1) {
|
|
109
|
+
lru.splice(lruIndex, 1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function buildDataUrl(url) {
|
|
114
|
+
return url + (url.includes("?") ? "&" : "?") + "__fw_data=1";
|
|
115
|
+
}
|
|
116
|
+
async function fetchRouteDataOnce(url) {
|
|
117
|
+
const dataUrl = buildDataUrl(url);
|
|
118
|
+
const res = await fetch(dataUrl, {
|
|
119
|
+
headers: {
|
|
120
|
+
"x-fw-data": "1",
|
|
121
|
+
Accept: "application/json"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
let json = {};
|
|
125
|
+
try {
|
|
126
|
+
const text = await res.text();
|
|
127
|
+
if (text) {
|
|
128
|
+
json = JSON.parse(text);
|
|
129
|
+
}
|
|
130
|
+
} catch (parseError) {
|
|
131
|
+
console.error(
|
|
132
|
+
"[client][cache] Failed to parse response as JSON:",
|
|
133
|
+
parseError
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const result = {
|
|
137
|
+
ok: res.ok,
|
|
138
|
+
status: res.status,
|
|
139
|
+
json
|
|
140
|
+
};
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
function revalidatePath(path) {
|
|
144
|
+
const normalizedPath = path.split("?")[0];
|
|
145
|
+
const hasQueryParams = path.includes("?");
|
|
146
|
+
const keysForPath = pathIndex.get(normalizedPath);
|
|
147
|
+
if (!keysForPath || keysForPath.size === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let specificQueryParams;
|
|
151
|
+
if (hasQueryParams) {
|
|
152
|
+
const queryPart = path.split("?")[1];
|
|
153
|
+
specificQueryParams = queryPart.split("&").filter((p) => !p.startsWith("__fw_data=")).sort().join("&");
|
|
154
|
+
}
|
|
155
|
+
const keysToDelete = [];
|
|
156
|
+
for (const key of keysForPath) {
|
|
157
|
+
if (hasQueryParams && specificQueryParams) {
|
|
158
|
+
const [, keyQuery = ""] = key.split("?");
|
|
159
|
+
const keyQueryParams = keyQuery.split("&").filter((p) => !p.startsWith("__fw_data=")).sort().join("&");
|
|
160
|
+
if (keyQueryParams === specificQueryParams) {
|
|
161
|
+
keysToDelete.push(key);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
keysToDelete.push(key);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
keysToDelete.forEach((key) => {
|
|
168
|
+
deleteCacheEntry(key);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async function revalidate() {
|
|
172
|
+
if (typeof window === "undefined") {
|
|
173
|
+
throw new Error("revalidate() can only be called on the client");
|
|
174
|
+
}
|
|
175
|
+
const pathname = window.location.pathname + window.location.search;
|
|
176
|
+
revalidatePath(pathname);
|
|
177
|
+
const freshData = await getRouteData(pathname, { revalidate: true });
|
|
178
|
+
if (window.__FW_DATA__ && freshData.ok && freshData.json) {
|
|
179
|
+
const currentData = window.__FW_DATA__;
|
|
180
|
+
window.__FW_DATA__ = {
|
|
181
|
+
...currentData,
|
|
182
|
+
pathname: pathname.split("?")[0],
|
|
183
|
+
params: freshData.json.params || currentData.params || {},
|
|
184
|
+
props: freshData.json.props || currentData.props || {},
|
|
185
|
+
metadata: freshData.json.metadata ?? currentData.metadata ?? null,
|
|
186
|
+
notFound: freshData.json.notFound ?? false,
|
|
187
|
+
error: freshData.json.error ?? false
|
|
188
|
+
};
|
|
189
|
+
window.dispatchEvent(new CustomEvent("fw-data-refresh", {
|
|
190
|
+
detail: { data: freshData }
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
return freshData;
|
|
194
|
+
}
|
|
195
|
+
function revalidateRouteData(url) {
|
|
196
|
+
revalidatePath(url);
|
|
197
|
+
}
|
|
198
|
+
function prefetchRouteData(url) {
|
|
199
|
+
const key = buildDataUrl(url);
|
|
200
|
+
const cached = dataCache.get(key);
|
|
201
|
+
if (cached && cached.status !== "rejected") {
|
|
202
|
+
if (cached.status === "fulfilled") {
|
|
203
|
+
updateLRU(key);
|
|
204
|
+
}
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const promise = fetchRouteDataOnce(url).then((value) => {
|
|
208
|
+
setCacheEntry(key, { status: "fulfilled", value });
|
|
209
|
+
return value;
|
|
210
|
+
}).catch((error) => {
|
|
211
|
+
console.error("[client][cache] Error prefetching route data:", error);
|
|
212
|
+
dataCache.set(key, { status: "rejected", error });
|
|
213
|
+
throw error;
|
|
214
|
+
});
|
|
215
|
+
dataCache.set(key, { status: "pending", promise });
|
|
216
|
+
}
|
|
217
|
+
async function getRouteData(url, options) {
|
|
218
|
+
const key = buildDataUrl(url);
|
|
219
|
+
if (options?.revalidate) {
|
|
220
|
+
deleteCacheEntry(key);
|
|
221
|
+
}
|
|
222
|
+
const entry = dataCache.get(key);
|
|
223
|
+
if (entry) {
|
|
224
|
+
if (entry.status === "fulfilled") {
|
|
225
|
+
updateLRU(key);
|
|
226
|
+
return entry.value;
|
|
227
|
+
}
|
|
228
|
+
if (entry.status === "pending") {
|
|
229
|
+
return entry.promise;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const promise = fetchRouteDataOnce(url).then((value) => {
|
|
233
|
+
setCacheEntry(key, { status: "fulfilled", value });
|
|
234
|
+
return value;
|
|
235
|
+
}).catch((error) => {
|
|
236
|
+
console.error("[client][cache] Error fetching route data:", error);
|
|
237
|
+
dataCache.set(key, { status: "rejected", error });
|
|
238
|
+
throw error;
|
|
239
|
+
});
|
|
240
|
+
dataCache.set(key, { status: "pending", promise });
|
|
241
|
+
return promise;
|
|
242
|
+
}
|
|
243
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
244
|
+
0 && (module.exports = {
|
|
245
|
+
getRouteData,
|
|
246
|
+
prefetchRouteData,
|
|
247
|
+
revalidate,
|
|
248
|
+
revalidatePath,
|
|
249
|
+
revalidateRouteData
|
|
250
|
+
});
|
|
251
|
+
//# sourceMappingURL=cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../modules/react/cache/index.ts","../../modules/react/cache/client-data-cache/index.ts"],"sourcesContent":["export * from \"./client-data-cache\";","type RouteData = {\n ok: boolean;\n status: number;\n json: any;\n};\n\ntype CacheEntry =\n | { status: \"pending\"; promise: Promise<RouteData> }\n | { status: \"fulfilled\"; value: RouteData }\n | { status: \"rejected\"; error: any };\n\n// Use window to guarantee a single shared cache instance\n// across all bundles/modules\nconst CACHE_KEY = \"__FW_DATA_CACHE__\";\n\n// Maximum number of entries in the cache (LRU)\nconst MAX_CACHE_SIZE = 100;\n\ntype CacheStore = {\n data: Map<string, CacheEntry>;\n index: Map<string, Set<string>>; // pathBase -> Set of keys\n lru: string[]; // Ordered list: most recent at end, oldest at start\n};\n\nfunction getCacheStore(): CacheStore {\n if (typeof window !== \"undefined\") {\n if (!(window as any)[CACHE_KEY]) {\n (window as any)[CACHE_KEY] = {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n }\n return (window as any)[CACHE_KEY];\n }\n // Fallback for SSR (though this shouldn't be used on the client)\n return {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n}\n\nconst cacheStore = getCacheStore();\nconst dataCache = cacheStore.data;\nconst pathIndex = cacheStore.index;\nconst lru = cacheStore.lru;\n\n// Helper functions for cache management\n\n/**\n * Extract base path from a cache key (removes query params)\n */\nfunction extractPathBase(key: string): string {\n return key.split(\"?\")[0];\n}\n\n/**\n * Add key to path index\n */\nfunction addToIndex(key: string): void {\n const pathBase = extractPathBase(key);\n if (!pathIndex.has(pathBase)) {\n pathIndex.set(pathBase, new Set());\n }\n pathIndex.get(pathBase)!.add(key);\n}\n\n/**\n * Remove key from path index\n */\nfunction removeFromIndex(key: string): void {\n const pathBase = extractPathBase(key);\n const keys = pathIndex.get(pathBase);\n if (keys) {\n keys.delete(key);\n if (keys.size === 0) {\n pathIndex.delete(pathBase);\n }\n }\n}\n\n/**\n * Update LRU order - move key to end (most recent)\n */\nfunction updateLRU(key: string): void {\n const index = lru.indexOf(key);\n if (index !== -1) {\n lru.splice(index, 1);\n }\n lru.push(key);\n}\n\n/**\n * Remove oldest entries if cache exceeds MAX_CACHE_SIZE\n */\nfunction evictOldest(): void {\n while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {\n const oldestKey = lru.shift()!;\n dataCache.delete(oldestKey);\n removeFromIndex(oldestKey);\n }\n}\n\n/**\n * Set cache entry and maintain indexes\n */\nfunction setCacheEntry(key: string, entry: CacheEntry): void {\n const existingEntry = dataCache.get(key);\n const wasFulfilled = existingEntry?.status === \"fulfilled\";\n \n dataCache.set(key, entry);\n \n // Only track fulfilled entries in LRU and index (not pending/rejected)\n if (entry.status === \"fulfilled\") {\n // Add to index if it wasn't already fulfilled (new entry or transition from pending/rejected)\n if (!wasFulfilled) {\n addToIndex(key);\n }\n updateLRU(key);\n evictOldest();\n } else if (wasFulfilled) {\n // If entry was fulfilled and now isn't (transitioning to pending/rejected), remove from index\n removeFromIndex(key);\n }\n}\n\n/**\n * Delete cache entry and clean up indexes\n */\nfunction deleteCacheEntry(key: string): void {\n if (dataCache.has(key)) {\n dataCache.delete(key);\n removeFromIndex(key);\n const lruIndex = lru.indexOf(key);\n if (lruIndex !== -1) {\n lru.splice(lruIndex, 1);\n }\n }\n}\n\nfunction buildDataUrl(url: string): string {\n return url + (url.includes(\"?\") ? \"&\" : \"?\") + \"__fw_data=1\";\n}\n\nasync function fetchRouteDataOnce(url: string): Promise<RouteData> {\n const dataUrl = buildDataUrl(url);\n\n const res = await fetch(dataUrl, {\n headers: {\n \"x-fw-data\": \"1\",\n Accept: \"application/json\",\n },\n });\n\n let json: any = {};\n\n try {\n const text = await res.text();\n if (text) {\n json = JSON.parse(text);\n }\n } catch (parseError) {\n console.error(\n \"[client][cache] Failed to parse response as JSON:\",\n parseError\n );\n }\n\n const result: RouteData = {\n ok: res.ok,\n status: res.status,\n json,\n };\n\n return result;\n}\n\n/**\n * Revalidates route data by removing it from the cache.\n * The next time you navigate to this route, fresh data will be fetched from the server.\n * This is a client-side function and does not require a server-side revalidation.\n *\n * @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')\n * If query params are not included, revalidates all variants of that route.\n *\n * @example\n * ```ts\n * // After saving something to the DB, revalidate the route\n * await saveToDatabase(data);\n * revalidatePath('/posts');\n * \n * // Revalidate a specific route with query params\n * revalidatePath('/posts?page=2');\n * ```\n */\nexport function revalidatePath(path: string): void {\n // Normalize the base path (without query params)\n const normalizedPath = path.split(\"?\")[0];\n const hasQueryParams = path.includes(\"?\");\n \n // Get all keys for this path base from index (O(1) lookup)\n const keysForPath = pathIndex.get(normalizedPath);\n \n if (!keysForPath || keysForPath.size === 0) {\n return; // No entries to revalidate\n }\n \n // If the path includes specific query params, extract them\n let specificQueryParams: string | undefined;\n if (hasQueryParams) {\n const queryPart = path.split(\"?\")[1];\n // Sort query params for consistent comparison\n specificQueryParams = queryPart\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n }\n \n // Iterate only over keys for this path (much smaller set)\n const keysToDelete: string[] = [];\n for (const key of keysForPath) {\n // If specific query params were specified, check if they match\n if (hasQueryParams && specificQueryParams) {\n const [, keyQuery = \"\"] = key.split(\"?\");\n const keyQueryParams = keyQuery\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (keyQueryParams === specificQueryParams) {\n keysToDelete.push(key);\n }\n } else {\n // If no specific query params, revalidate all variants\n keysToDelete.push(key);\n }\n }\n \n // Delete matching entries\n keysToDelete.forEach((key) => {\n deleteCacheEntry(key);\n });\n}\n\n/**\n * Revalidates and refreshes the current page data.\n * Similar to Next.js's `router.refresh()`.\n * \n * This function:\n * 1. Removes the current route from cache\n * 2. Fetches fresh data from the server\n * 3. Updates window.__FW_DATA__ with the new data\n * 4. Dispatches a 'fw-data-refresh' event for components to listen to\n * \n * @returns Promise that resolves with the fresh route data\n * \n * @example\n * ```ts\n * // Refresh current page data after a mutation\n * await revalidate();\n * ```\n */\nexport async function revalidate(): Promise<RouteData> {\n if (typeof window === \"undefined\") {\n throw new Error(\"revalidate() can only be called on the client\");\n }\n\n const pathname = window.location.pathname + window.location.search;\n \n // Revalidate the path (remove from cache)\n revalidatePath(pathname);\n \n // Fetch fresh data\n const freshData = await getRouteData(pathname, { revalidate: true });\n \n // Update window.__FW_DATA__ if it exists\n if ((window as any).__FW_DATA__ && freshData.ok && freshData.json) {\n const currentData = (window as any).__FW_DATA__;\n (window as any).__FW_DATA__ = {\n ...currentData,\n pathname: pathname.split(\"?\")[0],\n params: freshData.json.params || currentData.params || {},\n props: freshData.json.props || currentData.props || {},\n metadata: freshData.json.metadata ?? currentData.metadata ?? null,\n notFound: freshData.json.notFound ?? false,\n error: freshData.json.error ?? false,\n };\n \n // Dispatch event for components to listen to\n window.dispatchEvent(new CustomEvent(\"fw-data-refresh\", {\n detail: { data: freshData },\n }));\n }\n \n return freshData;\n}\n\n/**\n * @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.\n */\nexport function revalidateRouteData(url: string): void {\n revalidatePath(url);\n}\n\nexport function prefetchRouteData(url: string): void {\n const key = buildDataUrl(url);\n\n const cached = dataCache.get(key);\n\n if (cached && cached.status !== \"rejected\") {\n // Update LRU if it exists and is fulfilled\n if (cached.status === \"fulfilled\") {\n updateLRU(key);\n }\n return;\n }\n\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error prefetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n}\n\nexport type GetRouteDataOptions = {\n /**\n * If true, forces revalidation of route data,\n * ignoring the cache and fetching fresh data from the server.\n * Similar to Next.js's `router.refresh()` behavior.\n */\n revalidate?: boolean;\n};\n\nexport async function getRouteData(\n url: string,\n options?: GetRouteDataOptions\n): Promise<RouteData> {\n const key = buildDataUrl(url);\n\n // If revalidation is requested, remove the entry from cache\n if (options?.revalidate) {\n deleteCacheEntry(key);\n }\n\n const entry = dataCache.get(key);\n\n if (entry) {\n if (entry.status === \"fulfilled\") {\n // Update LRU: mark as recently used\n updateLRU(key);\n return entry.value;\n }\n if (entry.status === \"pending\") {\n return entry.promise;\n }\n }\n\n // No entry in cache, fetch it\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error fetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n return promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,IAAM,Y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BAAU,GAAG;AACb,aAAO,MAAM;AAAA,IACf;AACA,QAAI,MAAM,WAAW,WAAW;AAC9B,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAGA,QAAM,UAAU,mBAAmB,GAAG,EACnC,KAAK,CAAC,UAAU;AACf,kBAAc,KAAK,EAAE,QAAQ,aAAa,MAAM,CAAC;AACjD,WAAO;AAAA,EACT,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,YAAQ,MAAM,8CAA8C,KAAK;AACjE,cAAU,IAAI,KAAK,EAAE,QAAQ,YAAY,MAAM,CAAC;AAChD,UAAM;AAAA,EACR,CAAC;AAEH,YAAU,IAAI,KAAK,EAAE,QAAQ,WAAW,QAAQ,CAAC;AACjD,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type RouteData = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
status: number;
|
|
4
|
+
json: any;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Revalidates route data by removing it from the cache.
|
|
8
|
+
* The next time you navigate to this route, fresh data will be fetched from the server.
|
|
9
|
+
* This is a client-side function and does not require a server-side revalidation.
|
|
10
|
+
*
|
|
11
|
+
* @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')
|
|
12
|
+
* If query params are not included, revalidates all variants of that route.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* // After saving something to the DB, revalidate the route
|
|
17
|
+
* await saveToDatabase(data);
|
|
18
|
+
* revalidatePath('/posts');
|
|
19
|
+
*
|
|
20
|
+
* // Revalidate a specific route with query params
|
|
21
|
+
* revalidatePath('/posts?page=2');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare function revalidatePath(path: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Revalidates and refreshes the current page data.
|
|
27
|
+
* Similar to Next.js's `router.refresh()`.
|
|
28
|
+
*
|
|
29
|
+
* This function:
|
|
30
|
+
* 1. Removes the current route from cache
|
|
31
|
+
* 2. Fetches fresh data from the server
|
|
32
|
+
* 3. Updates window.__FW_DATA__ with the new data
|
|
33
|
+
* 4. Dispatches a 'fw-data-refresh' event for components to listen to
|
|
34
|
+
*
|
|
35
|
+
* @returns Promise that resolves with the fresh route data
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* // Refresh current page data after a mutation
|
|
40
|
+
* await revalidate();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function revalidate(): Promise<RouteData>;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.
|
|
46
|
+
*/
|
|
47
|
+
declare function revalidateRouteData(url: string): void;
|
|
48
|
+
declare function prefetchRouteData(url: string): void;
|
|
49
|
+
type GetRouteDataOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* If true, forces revalidation of route data,
|
|
52
|
+
* ignoring the cache and fetching fresh data from the server.
|
|
53
|
+
* Similar to Next.js's `router.refresh()` behavior.
|
|
54
|
+
*/
|
|
55
|
+
revalidate?: boolean;
|
|
56
|
+
};
|
|
57
|
+
declare function getRouteData(url: string, options?: GetRouteDataOptions): Promise<RouteData>;
|
|
58
|
+
|
|
59
|
+
export { type GetRouteDataOptions, getRouteData, prefetchRouteData, revalidate, revalidatePath, revalidateRouteData };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type RouteData = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
status: number;
|
|
4
|
+
json: any;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Revalidates route data by removing it from the cache.
|
|
8
|
+
* The next time you navigate to this route, fresh data will be fetched from the server.
|
|
9
|
+
* This is a client-side function and does not require a server-side revalidation.
|
|
10
|
+
*
|
|
11
|
+
* @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')
|
|
12
|
+
* If query params are not included, revalidates all variants of that route.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* // After saving something to the DB, revalidate the route
|
|
17
|
+
* await saveToDatabase(data);
|
|
18
|
+
* revalidatePath('/posts');
|
|
19
|
+
*
|
|
20
|
+
* // Revalidate a specific route with query params
|
|
21
|
+
* revalidatePath('/posts?page=2');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare function revalidatePath(path: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Revalidates and refreshes the current page data.
|
|
27
|
+
* Similar to Next.js's `router.refresh()`.
|
|
28
|
+
*
|
|
29
|
+
* This function:
|
|
30
|
+
* 1. Removes the current route from cache
|
|
31
|
+
* 2. Fetches fresh data from the server
|
|
32
|
+
* 3. Updates window.__FW_DATA__ with the new data
|
|
33
|
+
* 4. Dispatches a 'fw-data-refresh' event for components to listen to
|
|
34
|
+
*
|
|
35
|
+
* @returns Promise that resolves with the fresh route data
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* // Refresh current page data after a mutation
|
|
40
|
+
* await revalidate();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function revalidate(): Promise<RouteData>;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.
|
|
46
|
+
*/
|
|
47
|
+
declare function revalidateRouteData(url: string): void;
|
|
48
|
+
declare function prefetchRouteData(url: string): void;
|
|
49
|
+
type GetRouteDataOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* If true, forces revalidation of route data,
|
|
52
|
+
* ignoring the cache and fetching fresh data from the server.
|
|
53
|
+
* Similar to Next.js's `router.refresh()` behavior.
|
|
54
|
+
*/
|
|
55
|
+
revalidate?: boolean;
|
|
56
|
+
};
|
|
57
|
+
declare function getRouteData(url: string, options?: GetRouteDataOptions): Promise<RouteData>;
|
|
58
|
+
|
|
59
|
+
export { type GetRouteDataOptions, getRouteData, prefetchRouteData, revalidate, revalidatePath, revalidateRouteData };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// modules/react/cache/client-data-cache/index.ts
|
|
2
|
+
var CACHE_KEY = "__FW_DATA_CACHE__";
|
|
3
|
+
var MAX_CACHE_SIZE = 100;
|
|
4
|
+
function getCacheStore() {
|
|
5
|
+
if (typeof window !== "undefined") {
|
|
6
|
+
if (!window[CACHE_KEY]) {
|
|
7
|
+
window[CACHE_KEY] = {
|
|
8
|
+
data: /* @__PURE__ */ new Map(),
|
|
9
|
+
index: /* @__PURE__ */ new Map(),
|
|
10
|
+
lru: []
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return window[CACHE_KEY];
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
data: /* @__PURE__ */ new Map(),
|
|
17
|
+
index: /* @__PURE__ */ new Map(),
|
|
18
|
+
lru: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var cacheStore = getCacheStore();
|
|
22
|
+
var dataCache = cacheStore.data;
|
|
23
|
+
var pathIndex = cacheStore.index;
|
|
24
|
+
var lru = cacheStore.lru;
|
|
25
|
+
function extractPathBase(key) {
|
|
26
|
+
return key.split("?")[0];
|
|
27
|
+
}
|
|
28
|
+
function addToIndex(key) {
|
|
29
|
+
const pathBase = extractPathBase(key);
|
|
30
|
+
if (!pathIndex.has(pathBase)) {
|
|
31
|
+
pathIndex.set(pathBase, /* @__PURE__ */ new Set());
|
|
32
|
+
}
|
|
33
|
+
pathIndex.get(pathBase).add(key);
|
|
34
|
+
}
|
|
35
|
+
function removeFromIndex(key) {
|
|
36
|
+
const pathBase = extractPathBase(key);
|
|
37
|
+
const keys = pathIndex.get(pathBase);
|
|
38
|
+
if (keys) {
|
|
39
|
+
keys.delete(key);
|
|
40
|
+
if (keys.size === 0) {
|
|
41
|
+
pathIndex.delete(pathBase);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function updateLRU(key) {
|
|
46
|
+
const index = lru.indexOf(key);
|
|
47
|
+
if (index !== -1) {
|
|
48
|
+
lru.splice(index, 1);
|
|
49
|
+
}
|
|
50
|
+
lru.push(key);
|
|
51
|
+
}
|
|
52
|
+
function evictOldest() {
|
|
53
|
+
while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {
|
|
54
|
+
const oldestKey = lru.shift();
|
|
55
|
+
dataCache.delete(oldestKey);
|
|
56
|
+
removeFromIndex(oldestKey);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function setCacheEntry(key, entry) {
|
|
60
|
+
const existingEntry = dataCache.get(key);
|
|
61
|
+
const wasFulfilled = existingEntry?.status === "fulfilled";
|
|
62
|
+
dataCache.set(key, entry);
|
|
63
|
+
if (entry.status === "fulfilled") {
|
|
64
|
+
if (!wasFulfilled) {
|
|
65
|
+
addToIndex(key);
|
|
66
|
+
}
|
|
67
|
+
updateLRU(key);
|
|
68
|
+
evictOldest();
|
|
69
|
+
} else if (wasFulfilled) {
|
|
70
|
+
removeFromIndex(key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function deleteCacheEntry(key) {
|
|
74
|
+
if (dataCache.has(key)) {
|
|
75
|
+
dataCache.delete(key);
|
|
76
|
+
removeFromIndex(key);
|
|
77
|
+
const lruIndex = lru.indexOf(key);
|
|
78
|
+
if (lruIndex !== -1) {
|
|
79
|
+
lru.splice(lruIndex, 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function buildDataUrl(url) {
|
|
84
|
+
return url + (url.includes("?") ? "&" : "?") + "__fw_data=1";
|
|
85
|
+
}
|
|
86
|
+
async function fetchRouteDataOnce(url) {
|
|
87
|
+
const dataUrl = buildDataUrl(url);
|
|
88
|
+
const res = await fetch(dataUrl, {
|
|
89
|
+
headers: {
|
|
90
|
+
"x-fw-data": "1",
|
|
91
|
+
Accept: "application/json"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
let json = {};
|
|
95
|
+
try {
|
|
96
|
+
const text = await res.text();
|
|
97
|
+
if (text) {
|
|
98
|
+
json = JSON.parse(text);
|
|
99
|
+
}
|
|
100
|
+
} catch (parseError) {
|
|
101
|
+
console.error(
|
|
102
|
+
"[client][cache] Failed to parse response as JSON:",
|
|
103
|
+
parseError
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const result = {
|
|
107
|
+
ok: res.ok,
|
|
108
|
+
status: res.status,
|
|
109
|
+
json
|
|
110
|
+
};
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function revalidatePath(path) {
|
|
114
|
+
const normalizedPath = path.split("?")[0];
|
|
115
|
+
const hasQueryParams = path.includes("?");
|
|
116
|
+
const keysForPath = pathIndex.get(normalizedPath);
|
|
117
|
+
if (!keysForPath || keysForPath.size === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let specificQueryParams;
|
|
121
|
+
if (hasQueryParams) {
|
|
122
|
+
const queryPart = path.split("?")[1];
|
|
123
|
+
specificQueryParams = queryPart.split("&").filter((p) => !p.startsWith("__fw_data=")).sort().join("&");
|
|
124
|
+
}
|
|
125
|
+
const keysToDelete = [];
|
|
126
|
+
for (const key of keysForPath) {
|
|
127
|
+
if (hasQueryParams && specificQueryParams) {
|
|
128
|
+
const [, keyQuery = ""] = key.split("?");
|
|
129
|
+
const keyQueryParams = keyQuery.split("&").filter((p) => !p.startsWith("__fw_data=")).sort().join("&");
|
|
130
|
+
if (keyQueryParams === specificQueryParams) {
|
|
131
|
+
keysToDelete.push(key);
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
keysToDelete.push(key);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
keysToDelete.forEach((key) => {
|
|
138
|
+
deleteCacheEntry(key);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async function revalidate() {
|
|
142
|
+
if (typeof window === "undefined") {
|
|
143
|
+
throw new Error("revalidate() can only be called on the client");
|
|
144
|
+
}
|
|
145
|
+
const pathname = window.location.pathname + window.location.search;
|
|
146
|
+
revalidatePath(pathname);
|
|
147
|
+
const freshData = await getRouteData(pathname, { revalidate: true });
|
|
148
|
+
if (window.__FW_DATA__ && freshData.ok && freshData.json) {
|
|
149
|
+
const currentData = window.__FW_DATA__;
|
|
150
|
+
window.__FW_DATA__ = {
|
|
151
|
+
...currentData,
|
|
152
|
+
pathname: pathname.split("?")[0],
|
|
153
|
+
params: freshData.json.params || currentData.params || {},
|
|
154
|
+
props: freshData.json.props || currentData.props || {},
|
|
155
|
+
metadata: freshData.json.metadata ?? currentData.metadata ?? null,
|
|
156
|
+
notFound: freshData.json.notFound ?? false,
|
|
157
|
+
error: freshData.json.error ?? false
|
|
158
|
+
};
|
|
159
|
+
window.dispatchEvent(new CustomEvent("fw-data-refresh", {
|
|
160
|
+
detail: { data: freshData }
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
return freshData;
|
|
164
|
+
}
|
|
165
|
+
function revalidateRouteData(url) {
|
|
166
|
+
revalidatePath(url);
|
|
167
|
+
}
|
|
168
|
+
function prefetchRouteData(url) {
|
|
169
|
+
const key = buildDataUrl(url);
|
|
170
|
+
const cached = dataCache.get(key);
|
|
171
|
+
if (cached && cached.status !== "rejected") {
|
|
172
|
+
if (cached.status === "fulfilled") {
|
|
173
|
+
updateLRU(key);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const promise = fetchRouteDataOnce(url).then((value) => {
|
|
178
|
+
setCacheEntry(key, { status: "fulfilled", value });
|
|
179
|
+
return value;
|
|
180
|
+
}).catch((error) => {
|
|
181
|
+
console.error("[client][cache] Error prefetching route data:", error);
|
|
182
|
+
dataCache.set(key, { status: "rejected", error });
|
|
183
|
+
throw error;
|
|
184
|
+
});
|
|
185
|
+
dataCache.set(key, { status: "pending", promise });
|
|
186
|
+
}
|
|
187
|
+
async function getRouteData(url, options) {
|
|
188
|
+
const key = buildDataUrl(url);
|
|
189
|
+
if (options?.revalidate) {
|
|
190
|
+
deleteCacheEntry(key);
|
|
191
|
+
}
|
|
192
|
+
const entry = dataCache.get(key);
|
|
193
|
+
if (entry) {
|
|
194
|
+
if (entry.status === "fulfilled") {
|
|
195
|
+
updateLRU(key);
|
|
196
|
+
return entry.value;
|
|
197
|
+
}
|
|
198
|
+
if (entry.status === "pending") {
|
|
199
|
+
return entry.promise;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const promise = fetchRouteDataOnce(url).then((value) => {
|
|
203
|
+
setCacheEntry(key, { status: "fulfilled", value });
|
|
204
|
+
return value;
|
|
205
|
+
}).catch((error) => {
|
|
206
|
+
console.error("[client][cache] Error fetching route data:", error);
|
|
207
|
+
dataCache.set(key, { status: "rejected", error });
|
|
208
|
+
throw error;
|
|
209
|
+
});
|
|
210
|
+
dataCache.set(key, { status: "pending", promise });
|
|
211
|
+
return promise;
|
|
212
|
+
}
|
|
213
|
+
export {
|
|
214
|
+
getRouteData,
|
|
215
|
+
prefetchRouteData,
|
|
216
|
+
revalidate,
|
|
217
|
+
revalidatePath,
|
|
218
|
+
revalidateRouteData
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../modules/react/cache/client-data-cache/index.ts"],"sourcesContent":["type RouteData = {\n ok: boolean;\n status: number;\n json: any;\n};\n\ntype CacheEntry =\n | { status: \"pending\"; promise: Promise<RouteData> }\n | { status: \"fulfilled\"; value: RouteData }\n | { status: \"rejected\"; error: any };\n\n// Use window to guarantee a single shared cache instance\n// across all bundles/modules\nconst CACHE_KEY = \"__FW_DATA_CACHE__\";\n\n// Maximum number of entries in the cache (LRU)\nconst MAX_CACHE_SIZE = 100;\n\ntype CacheStore = {\n data: Map<string, CacheEntry>;\n index: Map<string, Set<string>>; // pathBase -> Set of keys\n lru: string[]; // Ordered list: most recent at end, oldest at start\n};\n\nfunction getCacheStore(): CacheStore {\n if (typeof window !== \"undefined\") {\n if (!(window as any)[CACHE_KEY]) {\n (window as any)[CACHE_KEY] = {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n }\n return (window as any)[CACHE_KEY];\n }\n // Fallback for SSR (though this shouldn't be used on the client)\n return {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n}\n\nconst cacheStore = getCacheStore();\nconst dataCache = cacheStore.data;\nconst pathIndex = cacheStore.index;\nconst lru = cacheStore.lru;\n\n// Helper functions for cache management\n\n/**\n * Extract base path from a cache key (removes query params)\n */\nfunction extractPathBase(key: string): string {\n return key.split(\"?\")[0];\n}\n\n/**\n * Add key to path index\n */\nfunction addToIndex(key: string): void {\n const pathBase = extractPathBase(key);\n if (!pathIndex.has(pathBase)) {\n pathIndex.set(pathBase, new Set());\n }\n pathIndex.get(pathBase)!.add(key);\n}\n\n/**\n * Remove key from path index\n */\nfunction removeFromIndex(key: string): void {\n const pathBase = extractPathBase(key);\n const keys = pathIndex.get(pathBase);\n if (keys) {\n keys.delete(key);\n if (keys.size === 0) {\n pathIndex.delete(pathBase);\n }\n }\n}\n\n/**\n * Update LRU order - move key to end (most recent)\n */\nfunction updateLRU(key: string): void {\n const index = lru.indexOf(key);\n if (index !== -1) {\n lru.splice(index, 1);\n }\n lru.push(key);\n}\n\n/**\n * Remove oldest entries if cache exceeds MAX_CACHE_SIZE\n */\nfunction evictOldest(): void {\n while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {\n const oldestKey = lru.shift()!;\n dataCache.delete(oldestKey);\n removeFromIndex(oldestKey);\n }\n}\n\n/**\n * Set cache entry and maintain indexes\n */\nfunction setCacheEntry(key: string, entry: CacheEntry): void {\n const existingEntry = dataCache.get(key);\n const wasFulfilled = existingEntry?.status === \"fulfilled\";\n \n dataCache.set(key, entry);\n \n // Only track fulfilled entries in LRU and index (not pending/rejected)\n if (entry.status === \"fulfilled\") {\n // Add to index if it wasn't already fulfilled (new entry or transition from pending/rejected)\n if (!wasFulfilled) {\n addToIndex(key);\n }\n updateLRU(key);\n evictOldest();\n } else if (wasFulfilled) {\n // If entry was fulfilled and now isn't (transitioning to pending/rejected), remove from index\n removeFromIndex(key);\n }\n}\n\n/**\n * Delete cache entry and clean up indexes\n */\nfunction deleteCacheEntry(key: string): void {\n if (dataCache.has(key)) {\n dataCache.delete(key);\n removeFromIndex(key);\n const lruIndex = lru.indexOf(key);\n if (lruIndex !== -1) {\n lru.splice(lruIndex, 1);\n }\n }\n}\n\nfunction buildDataUrl(url: string): string {\n return url + (url.includes(\"?\") ? \"&\" : \"?\") + \"__fw_data=1\";\n}\n\nasync function fetchRouteDataOnce(url: string): Promise<RouteData> {\n const dataUrl = buildDataUrl(url);\n\n const res = await fetch(dataUrl, {\n headers: {\n \"x-fw-data\": \"1\",\n Accept: \"application/json\",\n },\n });\n\n let json: any = {};\n\n try {\n const text = await res.text();\n if (text) {\n json = JSON.parse(text);\n }\n } catch (parseError) {\n console.error(\n \"[client][cache] Failed to parse response as JSON:\",\n parseError\n );\n }\n\n const result: RouteData = {\n ok: res.ok,\n status: res.status,\n json,\n };\n\n return result;\n}\n\n/**\n * Revalidates route data by removing it from the cache.\n * The next time you navigate to this route, fresh data will be fetched from the server.\n * This is a client-side function and does not require a server-side revalidation.\n *\n * @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')\n * If query params are not included, revalidates all variants of that route.\n *\n * @example\n * ```ts\n * // After saving something to the DB, revalidate the route\n * await saveToDatabase(data);\n * revalidatePath('/posts');\n * \n * // Revalidate a specific route with query params\n * revalidatePath('/posts?page=2');\n * ```\n */\nexport function revalidatePath(path: string): void {\n // Normalize the base path (without query params)\n const normalizedPath = path.split(\"?\")[0];\n const hasQueryParams = path.includes(\"?\");\n \n // Get all keys for this path base from index (O(1) lookup)\n const keysForPath = pathIndex.get(normalizedPath);\n \n if (!keysForPath || keysForPath.size === 0) {\n return; // No entries to revalidate\n }\n \n // If the path includes specific query params, extract them\n let specificQueryParams: string | undefined;\n if (hasQueryParams) {\n const queryPart = path.split(\"?\")[1];\n // Sort query params for consistent comparison\n specificQueryParams = queryPart\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n }\n \n // Iterate only over keys for this path (much smaller set)\n const keysToDelete: string[] = [];\n for (const key of keysForPath) {\n // If specific query params were specified, check if they match\n if (hasQueryParams && specificQueryParams) {\n const [, keyQuery = \"\"] = key.split(\"?\");\n const keyQueryParams = keyQuery\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (keyQueryParams === specificQueryParams) {\n keysToDelete.push(key);\n }\n } else {\n // If no specific query params, revalidate all variants\n keysToDelete.push(key);\n }\n }\n \n // Delete matching entries\n keysToDelete.forEach((key) => {\n deleteCacheEntry(key);\n });\n}\n\n/**\n * Revalidates and refreshes the current page data.\n * Similar to Next.js's `router.refresh()`.\n * \n * This function:\n * 1. Removes the current route from cache\n * 2. Fetches fresh data from the server\n * 3. Updates window.__FW_DATA__ with the new data\n * 4. Dispatches a 'fw-data-refresh' event for components to listen to\n * \n * @returns Promise that resolves with the fresh route data\n * \n * @example\n * ```ts\n * // Refresh current page data after a mutation\n * await revalidate();\n * ```\n */\nexport async function revalidate(): Promise<RouteData> {\n if (typeof window === \"undefined\") {\n throw new Error(\"revalidate() can only be called on the client\");\n }\n\n const pathname = window.location.pathname + window.location.search;\n \n // Revalidate the path (remove from cache)\n revalidatePath(pathname);\n \n // Fetch fresh data\n const freshData = await getRouteData(pathname, { revalidate: true });\n \n // Update window.__FW_DATA__ if it exists\n if ((window as any).__FW_DATA__ && freshData.ok && freshData.json) {\n const currentData = (window as any).__FW_DATA__;\n (window as any).__FW_DATA__ = {\n ...currentData,\n pathname: pathname.split(\"?\")[0],\n params: freshData.json.params || currentData.params || {},\n props: freshData.json.props || currentData.props || {},\n metadata: freshData.json.metadata ?? currentData.metadata ?? null,\n notFound: freshData.json.notFound ?? false,\n error: freshData.json.error ?? false,\n };\n \n // Dispatch event for components to listen to\n window.dispatchEvent(new CustomEvent(\"fw-data-refresh\", {\n detail: { data: freshData },\n }));\n }\n \n return freshData;\n}\n\n/**\n * @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.\n */\nexport function revalidateRouteData(url: string): void {\n revalidatePath(url);\n}\n\nexport function prefetchRouteData(url: string): void {\n const key = buildDataUrl(url);\n\n const cached = dataCache.get(key);\n\n if (cached && cached.status !== \"rejected\") {\n // Update LRU if it exists and is fulfilled\n if (cached.status === \"fulfilled\") {\n updateLRU(key);\n }\n return;\n }\n\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error prefetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n}\n\nexport type GetRouteDataOptions = {\n /**\n * If true, forces revalidation of route data,\n * ignoring the cache and fetching fresh data from the server.\n * Similar to Next.js's `router.refresh()` behavior.\n */\n revalidate?: boolean;\n};\n\nexport async function getRouteData(\n url: string,\n options?: GetRouteDataOptions\n): Promise<RouteData> {\n const key = buildDataUrl(url);\n\n // If revalidation is requested, remove the entry from cache\n if (options?.revalidate) {\n deleteCacheEntry(key);\n }\n\n const entry = dataCache.get(key);\n\n if (entry) {\n if (entry.status === \"fulfilled\") {\n // Update LRU: mark as recently used\n updateLRU(key);\n return entry.value;\n }\n if (entry.status === \"pending\") {\n return entry.promise;\n }\n }\n\n // No entry in cache, fetch it\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error fetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n return promise;\n}\n"],"mappings":";AA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