@flight-framework/core 0.0.1 → 0.0.2
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/actions/index.d.ts +1 -1
- package/dist/actions/index.js +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/{chunk-WAGCTWGY.js → chunk-3TPAA52K.js} +2 -2
- package/dist/{chunk-WAGCTWGY.js.map → chunk-3TPAA52K.js.map} +1 -1
- package/dist/{chunk-AFSKXC6V.js → chunk-5KF3QQWZ.js} +2 -2
- package/dist/chunk-5KF3QQWZ.js.map +1 -0
- package/dist/{chunk-Y22KEW2F.js → chunk-6LYV4VQX.js} +3 -3
- package/dist/chunk-6LYV4VQX.js.map +1 -0
- package/dist/{chunk-QEFGUHYD.js → chunk-ABNCAPQB.js} +2 -2
- package/dist/chunk-ABNCAPQB.js.map +1 -0
- package/dist/{chunk-TKXN7KGE.js → chunk-JIW55ZVD.js} +2 -2
- package/dist/chunk-JIW55ZVD.js.map +1 -0
- package/dist/{chunk-Q4C5CCHK.js → chunk-SUILH4ID.js} +2 -2
- package/dist/chunk-SUILH4ID.js.map +1 -0
- package/dist/{chunk-AJ3IBYXT.js → chunk-W6D62JCI.js} +2 -2
- package/dist/chunk-W6D62JCI.js.map +1 -0
- package/dist/{chunk-I5RHYGX6.js → chunk-WOMWIW7D.js} +39 -3
- package/dist/chunk-WOMWIW7D.js.map +1 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/file-router/index.d.ts +5 -3
- package/dist/file-router/index.js +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +1 -1
- package/dist/index.d.ts +558 -3
- package/dist/index.js +855 -9
- package/dist/index.js.map +1 -1
- package/dist/rsc/index.d.ts +1 -1
- package/dist/rsc/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/streaming/index.d.ts +1 -1
- package/dist/streaming/index.js +1 -1
- package/package.json +100 -99
- package/LICENSE +0 -21
- package/dist/chunk-AFSKXC6V.js.map +0 -1
- package/dist/chunk-AJ3IBYXT.js.map +0 -1
- package/dist/chunk-I5RHYGX6.js.map +0 -1
- package/dist/chunk-Q4C5CCHK.js.map +0 -1
- package/dist/chunk-QEFGUHYD.js.map +0 -1
- package/dist/chunk-TKXN7KGE.js.map +0 -1
- package/dist/chunk-Y22KEW2F.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,865 @@
|
|
|
1
|
-
export { createFileRouter, loadRoutes, scanRoutes } from './chunk-
|
|
2
|
-
export { RedirectError, redirect as actionRedirect, cookies, executeAction, executeFormAction, getAction, handleActionRequest, isRedirectError, parseFormData, registerAction } from './chunk-
|
|
3
|
-
export { createRouteContext, error, json, parseBody, redirect } from './chunk-
|
|
4
|
-
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from './chunk-
|
|
5
|
-
export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError as isRscRedirectError, notFound, revalidatePath, revalidateTag
|
|
1
|
+
export { createFileRouter, loadRoutes, scanRoutes } from './chunk-WOMWIW7D.js';
|
|
2
|
+
export { RedirectError, redirect as actionRedirect, cookies, executeAction, executeFormAction, getAction, handleActionRequest, isRedirectError, parseFormData, registerAction } from './chunk-JIW55ZVD.js';
|
|
3
|
+
export { createRouteContext, error, json, parseBody, redirect } from './chunk-W6D62JCI.js';
|
|
4
|
+
export { createLazyContent, createStreamingResponse, createStreamingSSR, renderWithStreaming, streamParallel, streamSequential } from './chunk-ABNCAPQB.js';
|
|
5
|
+
export { composeComponents, createAsyncComponent, createClientBoundary, createRenderContext, deserializeProps, detectComponentType, executeServerComponent, hasUseClientDirective, hasUseServerDirective, isNotFoundError, isRedirectError as isRscRedirectError, notFound, redirect as rscRedirect, revalidatePath as rscRevalidatePath, revalidateTag as rscRevalidateTag, serializeProps, serverFetch, withErrorBoundary } from './chunk-5KF3QQWZ.js';
|
|
6
6
|
import './chunk-ZVC3ZWLM.js';
|
|
7
7
|
export { createCache } from './chunk-3AIQVGTM.js';
|
|
8
|
-
import './chunk-
|
|
9
|
-
export { createServer } from './chunk-
|
|
8
|
+
import './chunk-SUILH4ID.js';
|
|
9
|
+
export { createServer } from './chunk-6LYV4VQX.js';
|
|
10
10
|
export { createRouter } from './chunk-GCQZ4FHI.js';
|
|
11
11
|
export { createMiddlewareChain } from './chunk-KWFX6WHG.js';
|
|
12
|
-
export { defineConfig } from './chunk-
|
|
12
|
+
export { defineConfig } from './chunk-3TPAA52K.js';
|
|
13
|
+
import { promises } from 'fs';
|
|
14
|
+
import { dirname, join } from 'path';
|
|
15
|
+
|
|
16
|
+
// src/config/route-rules.ts
|
|
17
|
+
function matchRouteRule(path, rules) {
|
|
18
|
+
if (rules[path]) {
|
|
19
|
+
return rules[path];
|
|
20
|
+
}
|
|
21
|
+
const patterns = Object.keys(rules).sort((a, b) => {
|
|
22
|
+
if (!a.includes("*") && b.includes("*")) return -1;
|
|
23
|
+
if (a.includes("*") && !b.includes("*")) return 1;
|
|
24
|
+
return b.length - a.length;
|
|
25
|
+
});
|
|
26
|
+
for (const pattern of patterns) {
|
|
27
|
+
if (matchPattern(path, pattern)) {
|
|
28
|
+
return rules[pattern];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
function matchPattern(path, pattern) {
|
|
34
|
+
if (pattern === path) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\[([^\]]+)\]/g, "[^/]+");
|
|
38
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
39
|
+
return regex.test(path);
|
|
40
|
+
}
|
|
41
|
+
function mergeRouteRules(...rules) {
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const rule of rules) {
|
|
44
|
+
if (!rule) continue;
|
|
45
|
+
Object.assign(result, rule);
|
|
46
|
+
if (rule.headers) {
|
|
47
|
+
result.headers = { ...result.headers, ...rule.headers };
|
|
48
|
+
}
|
|
49
|
+
if (rule.cache) {
|
|
50
|
+
result.cache = { ...result.cache, ...rule.cache };
|
|
51
|
+
}
|
|
52
|
+
if (rule.tags) {
|
|
53
|
+
result.tags = [...result.tags || [], ...rule.tags];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function getRenderModeFromRule(rule) {
|
|
59
|
+
if (rule.ssr === false) {
|
|
60
|
+
return "csr";
|
|
61
|
+
}
|
|
62
|
+
if (rule.prerender) {
|
|
63
|
+
return "ssg";
|
|
64
|
+
}
|
|
65
|
+
if (rule.isr !== void 0) {
|
|
66
|
+
return "isr";
|
|
67
|
+
}
|
|
68
|
+
return "ssr";
|
|
69
|
+
}
|
|
70
|
+
function getRevalidateTime(rule) {
|
|
71
|
+
if (rule.isr !== void 0) {
|
|
72
|
+
if (rule.isr === true) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return typeof rule.isr === "number" ? rule.isr : 60;
|
|
76
|
+
}
|
|
77
|
+
if (rule.swr !== void 0) {
|
|
78
|
+
if (rule.swr === true) {
|
|
79
|
+
return 60;
|
|
80
|
+
}
|
|
81
|
+
return typeof rule.swr === "number" ? rule.swr : 60;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
function getCacheOptionsFromRule(rule) {
|
|
86
|
+
const revalidate = getRevalidateTime(rule);
|
|
87
|
+
if (revalidate === false && !rule.cache) {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
ttl: revalidate || rule.cache?.ttl,
|
|
92
|
+
swr: rule.swr !== void 0 ? typeof rule.swr === "number" ? rule.swr : 60 : void 0,
|
|
93
|
+
tags: rule.tags || rule.cache?.tags
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function buildCacheControlHeader(rule) {
|
|
97
|
+
const revalidate = getRevalidateTime(rule);
|
|
98
|
+
if (rule.ssr === false) {
|
|
99
|
+
return "no-store";
|
|
100
|
+
}
|
|
101
|
+
if (rule.prerender && revalidate === false) {
|
|
102
|
+
return "public, max-age=31536000, immutable";
|
|
103
|
+
}
|
|
104
|
+
if (revalidate !== false) {
|
|
105
|
+
const maxAge = revalidate;
|
|
106
|
+
const swr = rule.swr !== void 0 ? typeof rule.swr === "number" ? rule.swr : 60 : 0;
|
|
107
|
+
if (swr > 0) {
|
|
108
|
+
return `public, max-age=${maxAge}, stale-while-revalidate=${swr}`;
|
|
109
|
+
}
|
|
110
|
+
return `public, max-age=${maxAge}`;
|
|
111
|
+
}
|
|
112
|
+
return void 0;
|
|
113
|
+
}
|
|
114
|
+
function createDefaultRouteRules() {
|
|
115
|
+
return {
|
|
116
|
+
// API routes: no cache by default
|
|
117
|
+
"/api/**": { ssr: true, cache: { ttl: 0 } },
|
|
118
|
+
// Static assets: cache forever
|
|
119
|
+
"/_static/**": { headers: { "Cache-Control": "public, max-age=31536000, immutable" } }
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/render/revalidate.ts
|
|
124
|
+
var globalISRCache = null;
|
|
125
|
+
function setISRCache(cache) {
|
|
126
|
+
globalISRCache = cache;
|
|
127
|
+
}
|
|
128
|
+
function getISRCache() {
|
|
129
|
+
return globalISRCache;
|
|
130
|
+
}
|
|
131
|
+
function createMemoryISRCache() {
|
|
132
|
+
const store = /* @__PURE__ */ new Map();
|
|
133
|
+
const tagIndex = /* @__PURE__ */ new Map();
|
|
134
|
+
return {
|
|
135
|
+
async get(path) {
|
|
136
|
+
const entry = store.get(path);
|
|
137
|
+
if (!entry) return void 0;
|
|
138
|
+
if (entry.revalidateAfter && Date.now() > entry.revalidateAfter) {
|
|
139
|
+
return entry;
|
|
140
|
+
}
|
|
141
|
+
return entry;
|
|
142
|
+
},
|
|
143
|
+
async set(path, entry, options) {
|
|
144
|
+
store.set(path, entry);
|
|
145
|
+
const tags = entry.tags || options?.tags || [];
|
|
146
|
+
for (const tag of tags) {
|
|
147
|
+
if (!tagIndex.has(tag)) {
|
|
148
|
+
tagIndex.set(tag, /* @__PURE__ */ new Set());
|
|
149
|
+
}
|
|
150
|
+
tagIndex.get(tag).add(path);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
async delete(path) {
|
|
154
|
+
return store.delete(path);
|
|
155
|
+
},
|
|
156
|
+
async invalidateTag(tag) {
|
|
157
|
+
const paths = tagIndex.get(tag);
|
|
158
|
+
if (!paths) return;
|
|
159
|
+
for (const path of paths) {
|
|
160
|
+
store.delete(path);
|
|
161
|
+
}
|
|
162
|
+
tagIndex.delete(tag);
|
|
163
|
+
},
|
|
164
|
+
async keys() {
|
|
165
|
+
return Array.from(store.keys());
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
async function revalidatePath2(path) {
|
|
170
|
+
const cache = getISRCache();
|
|
171
|
+
if (!cache) {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
error: "ISR cache not configured",
|
|
175
|
+
timestamp: Date.now()
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const deleted = await cache.delete(path);
|
|
180
|
+
return {
|
|
181
|
+
success: deleted,
|
|
182
|
+
paths: deleted ? [path] : [],
|
|
183
|
+
timestamp: Date.now()
|
|
184
|
+
};
|
|
185
|
+
} catch (error2) {
|
|
186
|
+
return {
|
|
187
|
+
success: false,
|
|
188
|
+
error: error2 instanceof Error ? error2.message : "Unknown error",
|
|
189
|
+
timestamp: Date.now()
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function revalidateTag2(tag) {
|
|
194
|
+
const cache = getISRCache();
|
|
195
|
+
if (!cache) {
|
|
196
|
+
return {
|
|
197
|
+
success: false,
|
|
198
|
+
error: "ISR cache not configured",
|
|
199
|
+
timestamp: Date.now()
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
await cache.invalidateTag(tag);
|
|
204
|
+
return {
|
|
205
|
+
success: true,
|
|
206
|
+
timestamp: Date.now()
|
|
207
|
+
};
|
|
208
|
+
} catch (error2) {
|
|
209
|
+
return {
|
|
210
|
+
success: false,
|
|
211
|
+
error: error2 instanceof Error ? error2.message : "Unknown error",
|
|
212
|
+
timestamp: Date.now()
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function revalidatePaths(paths) {
|
|
217
|
+
const cache = getISRCache();
|
|
218
|
+
if (!cache) {
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
error: "ISR cache not configured",
|
|
222
|
+
timestamp: Date.now()
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const revalidated = [];
|
|
226
|
+
try {
|
|
227
|
+
for (const path of paths) {
|
|
228
|
+
const deleted = await cache.delete(path);
|
|
229
|
+
if (deleted) {
|
|
230
|
+
revalidated.push(path);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
success: true,
|
|
235
|
+
paths: revalidated,
|
|
236
|
+
timestamp: Date.now()
|
|
237
|
+
};
|
|
238
|
+
} catch (error2) {
|
|
239
|
+
return {
|
|
240
|
+
success: false,
|
|
241
|
+
paths: revalidated,
|
|
242
|
+
error: error2 instanceof Error ? error2.message : "Unknown error",
|
|
243
|
+
timestamp: Date.now()
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function createRevalidateHandler(options = {}) {
|
|
248
|
+
const { secret, headerName = "x-revalidate-token" } = options;
|
|
249
|
+
return async (request) => {
|
|
250
|
+
if (secret) {
|
|
251
|
+
const token = request.headers.get(headerName);
|
|
252
|
+
if (token !== secret) {
|
|
253
|
+
return new Response(
|
|
254
|
+
JSON.stringify({ error: "Invalid revalidation token" }),
|
|
255
|
+
{ status: 401, headers: { "Content-Type": "application/json" } }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const body = await request.json();
|
|
261
|
+
const results = [];
|
|
262
|
+
if (body.path) {
|
|
263
|
+
results.push(await revalidatePath2(body.path));
|
|
264
|
+
}
|
|
265
|
+
if (body.paths && body.paths.length > 0) {
|
|
266
|
+
results.push(await revalidatePaths(body.paths));
|
|
267
|
+
}
|
|
268
|
+
if (body.tag) {
|
|
269
|
+
results.push(await revalidateTag2(body.tag));
|
|
270
|
+
}
|
|
271
|
+
if (body.tags && body.tags.length > 0) {
|
|
272
|
+
for (const tag of body.tags) {
|
|
273
|
+
results.push(await revalidateTag2(tag));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const success = results.every((r) => r.success);
|
|
277
|
+
return new Response(
|
|
278
|
+
JSON.stringify({
|
|
279
|
+
revalidated: success,
|
|
280
|
+
results,
|
|
281
|
+
timestamp: Date.now()
|
|
282
|
+
}),
|
|
283
|
+
{
|
|
284
|
+
status: success ? 200 : 500,
|
|
285
|
+
headers: { "Content-Type": "application/json" }
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
} catch (error2) {
|
|
289
|
+
return new Response(
|
|
290
|
+
JSON.stringify({
|
|
291
|
+
error: "Invalid request body",
|
|
292
|
+
message: error2 instanceof Error ? error2.message : "Unknown error"
|
|
293
|
+
}),
|
|
294
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function createISRCacheFromFlightCache(cache) {
|
|
300
|
+
const ISR_PREFIX = "isr:";
|
|
301
|
+
return {
|
|
302
|
+
async get(path) {
|
|
303
|
+
return cache.get(`${ISR_PREFIX}${path}`);
|
|
304
|
+
},
|
|
305
|
+
async set(path, entry, options) {
|
|
306
|
+
const ttl = entry.revalidateAfter ? Math.floor((entry.revalidateAfter - Date.now()) / 1e3) : options?.ttl;
|
|
307
|
+
await cache.set(`${ISR_PREFIX}${path}`, entry, {
|
|
308
|
+
...options,
|
|
309
|
+
ttl: ttl && ttl > 0 ? ttl : void 0,
|
|
310
|
+
tags: entry.tags || options?.tags
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
async delete(path) {
|
|
314
|
+
return cache.delete(`${ISR_PREFIX}${path}`);
|
|
315
|
+
},
|
|
316
|
+
async invalidateTag(tag) {
|
|
317
|
+
await cache.invalidateTag(tag);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async function prerenderRoutes(options) {
|
|
322
|
+
const {
|
|
323
|
+
routes,
|
|
324
|
+
outDir,
|
|
325
|
+
renderFn,
|
|
326
|
+
concurrency = 10,
|
|
327
|
+
onProgress,
|
|
328
|
+
onError,
|
|
329
|
+
crawlLinks = false
|
|
330
|
+
} = options;
|
|
331
|
+
const startTime = Date.now();
|
|
332
|
+
const errors = [];
|
|
333
|
+
const files = [];
|
|
334
|
+
const processedRoutes = /* @__PURE__ */ new Set();
|
|
335
|
+
const routeQueue = typeof routes === "function" ? await routes() : [...routes];
|
|
336
|
+
let discoveredCount = 0;
|
|
337
|
+
await promises.mkdir(outDir, { recursive: true });
|
|
338
|
+
let completed = 0;
|
|
339
|
+
const total = routeQueue.length;
|
|
340
|
+
while (routeQueue.length > 0) {
|
|
341
|
+
const batch = routeQueue.splice(0, concurrency);
|
|
342
|
+
const results = await Promise.allSettled(
|
|
343
|
+
batch.map(async (route) => {
|
|
344
|
+
if (processedRoutes.has(route)) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
processedRoutes.add(route);
|
|
348
|
+
if (onProgress) {
|
|
349
|
+
onProgress({
|
|
350
|
+
currentRoute: route,
|
|
351
|
+
completed,
|
|
352
|
+
total: total + discoveredCount,
|
|
353
|
+
percentage: Math.round(completed / (total + discoveredCount) * 100)
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
const result = await renderFn(route);
|
|
357
|
+
const filePath = getOutputPath(route, outDir);
|
|
358
|
+
await ensureDir(dirname(filePath));
|
|
359
|
+
await promises.writeFile(filePath, result.html, "utf-8");
|
|
360
|
+
files.push(filePath);
|
|
361
|
+
completed++;
|
|
362
|
+
return result.links || [];
|
|
363
|
+
})
|
|
364
|
+
);
|
|
365
|
+
for (let i = 0; i < results.length; i++) {
|
|
366
|
+
const result = results[i];
|
|
367
|
+
const route = batch[i];
|
|
368
|
+
if (result.status === "rejected") {
|
|
369
|
+
const error2 = { route, error: result.reason };
|
|
370
|
+
errors.push(error2);
|
|
371
|
+
if (onError) {
|
|
372
|
+
onError(error2);
|
|
373
|
+
}
|
|
374
|
+
} else if (crawlLinks && result.value) {
|
|
375
|
+
for (const link of result.value) {
|
|
376
|
+
if (!processedRoutes.has(link) && !routeQueue.includes(link)) {
|
|
377
|
+
routeQueue.push(link);
|
|
378
|
+
discoveredCount++;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
total: processedRoutes.size,
|
|
386
|
+
success: files.length,
|
|
387
|
+
failed: errors.length,
|
|
388
|
+
discovered: discoveredCount,
|
|
389
|
+
duration: Date.now() - startTime,
|
|
390
|
+
files,
|
|
391
|
+
errors
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function getOutputPath(route, outDir) {
|
|
395
|
+
let normalizedRoute = route;
|
|
396
|
+
if (!normalizedRoute.startsWith("/")) {
|
|
397
|
+
normalizedRoute = "/" + normalizedRoute;
|
|
398
|
+
}
|
|
399
|
+
if (normalizedRoute === "/") {
|
|
400
|
+
return join(outDir, "index.html");
|
|
401
|
+
}
|
|
402
|
+
if (normalizedRoute.endsWith("/")) {
|
|
403
|
+
return join(outDir, normalizedRoute, "index.html");
|
|
404
|
+
}
|
|
405
|
+
if (!normalizedRoute.includes(".")) {
|
|
406
|
+
return join(outDir, normalizedRoute + ".html");
|
|
407
|
+
}
|
|
408
|
+
return join(outDir, normalizedRoute);
|
|
409
|
+
}
|
|
410
|
+
async function ensureDir(dir) {
|
|
411
|
+
try {
|
|
412
|
+
await promises.mkdir(dir, { recursive: true });
|
|
413
|
+
} catch (error2) {
|
|
414
|
+
if (error2.code !== "EEXIST") {
|
|
415
|
+
throw error2;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function extractLinks(html, baseUrl) {
|
|
420
|
+
const links = [];
|
|
421
|
+
const linkRegex = /<a[^>]+href=["']([^"']+)["'][^>]*>/gi;
|
|
422
|
+
let match;
|
|
423
|
+
while ((match = linkRegex.exec(html)) !== null) {
|
|
424
|
+
const href = match[1];
|
|
425
|
+
if (href.startsWith("http://") || href.startsWith("https://") || href.startsWith("#") || href.startsWith("mailto:") || href.startsWith("tel:") || href.startsWith("javascript:")) {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
let normalizedLink = href;
|
|
429
|
+
if (href.startsWith("/")) {
|
|
430
|
+
normalizedLink = href;
|
|
431
|
+
} else if (baseUrl) {
|
|
432
|
+
const base = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
|
|
433
|
+
normalizedLink = new URL(href, base).pathname;
|
|
434
|
+
}
|
|
435
|
+
normalizedLink = normalizedLink.split("?")[0].split("#")[0];
|
|
436
|
+
if (normalizedLink && !links.includes(normalizedLink)) {
|
|
437
|
+
links.push(normalizedLink);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return links;
|
|
441
|
+
}
|
|
442
|
+
async function expandDynamicRoutes(routePattern, generateParams) {
|
|
443
|
+
const params = await generateParams();
|
|
444
|
+
return params.map((paramSet) => {
|
|
445
|
+
let route = routePattern;
|
|
446
|
+
for (const [key, value] of Object.entries(paramSet)) {
|
|
447
|
+
const paramValue = Array.isArray(value) ? value.join("/") : value;
|
|
448
|
+
route = route.replace(`[${key}]`, paramValue);
|
|
449
|
+
route = route.replace(`[...${key}]`, paramValue);
|
|
450
|
+
}
|
|
451
|
+
return route;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// src/render/static.ts
|
|
456
|
+
async function generateAllStaticPaths(pageModules) {
|
|
457
|
+
const result = /* @__PURE__ */ new Map();
|
|
458
|
+
for (const [path, module] of pageModules) {
|
|
459
|
+
if (module.generateStaticParams) {
|
|
460
|
+
try {
|
|
461
|
+
const params = await module.generateStaticParams();
|
|
462
|
+
result.set(path, params);
|
|
463
|
+
} catch (error2) {
|
|
464
|
+
console.error(`[Flight] Failed to generate static params for ${path}:`, error2);
|
|
465
|
+
result.set(path, []);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
var pageCache = /* @__PURE__ */ new Map();
|
|
472
|
+
async function getOrGeneratePage(path, generateFn, revalidate) {
|
|
473
|
+
const cached = pageCache.get(path);
|
|
474
|
+
const now = Date.now();
|
|
475
|
+
if (cached) {
|
|
476
|
+
if (revalidate === false) {
|
|
477
|
+
return { html: cached.html, fromCache: true };
|
|
478
|
+
}
|
|
479
|
+
if (now < cached.revalidateAfter) {
|
|
480
|
+
return { html: cached.html, fromCache: true };
|
|
481
|
+
}
|
|
482
|
+
regeneratePageInBackground(path, generateFn, revalidate || 60);
|
|
483
|
+
return { html: cached.html, fromCache: true };
|
|
484
|
+
}
|
|
485
|
+
const html = await generateFn();
|
|
486
|
+
if (revalidate !== false) {
|
|
487
|
+
const revalidateMs = (revalidate || 60) * 1e3;
|
|
488
|
+
pageCache.set(path, {
|
|
489
|
+
html,
|
|
490
|
+
generatedAt: now,
|
|
491
|
+
revalidateAfter: now + revalidateMs
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return { html, fromCache: false };
|
|
495
|
+
}
|
|
496
|
+
async function regeneratePageInBackground(path, generateFn, revalidate) {
|
|
497
|
+
try {
|
|
498
|
+
const html = await generateFn();
|
|
499
|
+
const now = Date.now();
|
|
500
|
+
pageCache.set(path, {
|
|
501
|
+
html,
|
|
502
|
+
generatedAt: now,
|
|
503
|
+
revalidateAfter: now + revalidate * 1e3
|
|
504
|
+
});
|
|
505
|
+
} catch (error2) {
|
|
506
|
+
console.error(`[Flight] Background regeneration failed for ${path}:`, error2);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function purgePage(path) {
|
|
510
|
+
return pageCache.delete(path);
|
|
511
|
+
}
|
|
512
|
+
function purgeAllPages() {
|
|
513
|
+
pageCache.clear();
|
|
514
|
+
}
|
|
515
|
+
function shouldDynamicallyRender(module, hasParams) {
|
|
516
|
+
if (module.dynamic === "force-dynamic") {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
if (module.dynamic === "force-static") {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
if (module.dynamic === "error") {
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
if (hasParams && !module.generateStaticParams) {
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
function createStreamingResponse2(stream) {
|
|
531
|
+
return new Response(stream, {
|
|
532
|
+
status: 200,
|
|
533
|
+
headers: {
|
|
534
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
535
|
+
"Transfer-Encoding": "chunked"
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
function createHtmlStream() {
|
|
540
|
+
const encoder = new TextEncoder();
|
|
541
|
+
let controller;
|
|
542
|
+
const readable = new ReadableStream({
|
|
543
|
+
start(c) {
|
|
544
|
+
controller = c;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
return {
|
|
548
|
+
readable,
|
|
549
|
+
write(html) {
|
|
550
|
+
controller.enqueue(encoder.encode(html));
|
|
551
|
+
},
|
|
552
|
+
close() {
|
|
553
|
+
controller.close();
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// src/render/metadata.ts
|
|
559
|
+
function renderMetadataToHead(meta) {
|
|
560
|
+
const tags = [];
|
|
561
|
+
if (meta.title) {
|
|
562
|
+
const title = typeof meta.title === "string" ? meta.title : meta.title.default;
|
|
563
|
+
tags.push(`<title>${escapeHtml(title)}</title>`);
|
|
564
|
+
}
|
|
565
|
+
if (meta.description) {
|
|
566
|
+
tags.push(`<meta name="description" content="${escapeAttr(meta.description)}">`);
|
|
567
|
+
}
|
|
568
|
+
if (meta.keywords) {
|
|
569
|
+
const keywords = Array.isArray(meta.keywords) ? meta.keywords.join(", ") : meta.keywords;
|
|
570
|
+
tags.push(`<meta name="keywords" content="${escapeAttr(keywords)}">`);
|
|
571
|
+
}
|
|
572
|
+
if (meta.canonical) {
|
|
573
|
+
tags.push(`<link rel="canonical" href="${escapeAttr(meta.canonical)}">`);
|
|
574
|
+
}
|
|
575
|
+
if (meta.robots) {
|
|
576
|
+
const robotsContent = typeof meta.robots === "string" ? meta.robots : buildRobotsContent(meta.robots);
|
|
577
|
+
tags.push(`<meta name="robots" content="${escapeAttr(robotsContent)}">`);
|
|
578
|
+
}
|
|
579
|
+
if (meta.openGraph) {
|
|
580
|
+
const og = meta.openGraph;
|
|
581
|
+
if (og.title) tags.push(`<meta property="og:title" content="${escapeAttr(og.title)}">`);
|
|
582
|
+
if (og.description) tags.push(`<meta property="og:description" content="${escapeAttr(og.description)}">`);
|
|
583
|
+
if (og.url) tags.push(`<meta property="og:url" content="${escapeAttr(og.url)}">`);
|
|
584
|
+
if (og.siteName) tags.push(`<meta property="og:site_name" content="${escapeAttr(og.siteName)}">`);
|
|
585
|
+
if (og.type) tags.push(`<meta property="og:type" content="${escapeAttr(og.type)}">`);
|
|
586
|
+
if (og.locale) tags.push(`<meta property="og:locale" content="${escapeAttr(og.locale)}">`);
|
|
587
|
+
if (og.images) {
|
|
588
|
+
for (const image of og.images) {
|
|
589
|
+
if (typeof image === "string") {
|
|
590
|
+
tags.push(`<meta property="og:image" content="${escapeAttr(image)}">`);
|
|
591
|
+
} else {
|
|
592
|
+
tags.push(`<meta property="og:image" content="${escapeAttr(image.url)}">`);
|
|
593
|
+
if (image.width) tags.push(`<meta property="og:image:width" content="${image.width}">`);
|
|
594
|
+
if (image.height) tags.push(`<meta property="og:image:height" content="${image.height}">`);
|
|
595
|
+
if (image.alt) tags.push(`<meta property="og:image:alt" content="${escapeAttr(image.alt)}">`);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (meta.twitter) {
|
|
601
|
+
const tw = meta.twitter;
|
|
602
|
+
if (tw.card) tags.push(`<meta name="twitter:card" content="${escapeAttr(tw.card)}">`);
|
|
603
|
+
if (tw.site) tags.push(`<meta name="twitter:site" content="${escapeAttr(tw.site)}">`);
|
|
604
|
+
if (tw.creator) tags.push(`<meta name="twitter:creator" content="${escapeAttr(tw.creator)}">`);
|
|
605
|
+
if (tw.title) tags.push(`<meta name="twitter:title" content="${escapeAttr(tw.title)}">`);
|
|
606
|
+
if (tw.description) tags.push(`<meta name="twitter:description" content="${escapeAttr(tw.description)}">`);
|
|
607
|
+
if (tw.images) {
|
|
608
|
+
for (const image of tw.images) {
|
|
609
|
+
tags.push(`<meta name="twitter:image" content="${escapeAttr(image)}">`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (meta.icons) {
|
|
614
|
+
const icons = meta.icons;
|
|
615
|
+
if (icons.icon) {
|
|
616
|
+
const iconList = Array.isArray(icons.icon) ? icons.icon : [icons.icon];
|
|
617
|
+
for (const icon of iconList) {
|
|
618
|
+
tags.push(`<link rel="icon" href="${escapeAttr(icon)}">`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (icons.apple) {
|
|
622
|
+
const appleList = Array.isArray(icons.apple) ? icons.apple : [icons.apple];
|
|
623
|
+
for (const icon of appleList) {
|
|
624
|
+
tags.push(`<link rel="apple-touch-icon" href="${escapeAttr(icon)}">`);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (icons.shortcut) {
|
|
628
|
+
tags.push(`<link rel="shortcut icon" href="${escapeAttr(icons.shortcut)}">`);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (meta.alternates) {
|
|
632
|
+
if (meta.alternates.canonical) {
|
|
633
|
+
tags.push(`<link rel="canonical" href="${escapeAttr(meta.alternates.canonical)}">`);
|
|
634
|
+
}
|
|
635
|
+
if (meta.alternates.languages) {
|
|
636
|
+
for (const [lang, url] of Object.entries(meta.alternates.languages)) {
|
|
637
|
+
tags.push(`<link rel="alternate" hreflang="${escapeAttr(lang)}" href="${escapeAttr(url)}">`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (meta.verification) {
|
|
642
|
+
if (meta.verification.google) {
|
|
643
|
+
tags.push(`<meta name="google-site-verification" content="${escapeAttr(meta.verification.google)}">`);
|
|
644
|
+
}
|
|
645
|
+
if (meta.verification.bing) {
|
|
646
|
+
tags.push(`<meta name="msvalidate.01" content="${escapeAttr(meta.verification.bing)}">`);
|
|
647
|
+
}
|
|
648
|
+
if (meta.verification.yandex) {
|
|
649
|
+
tags.push(`<meta name="yandex-verification" content="${escapeAttr(meta.verification.yandex)}">`);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
if (meta.other) {
|
|
653
|
+
for (const [name, content] of Object.entries(meta.other)) {
|
|
654
|
+
tags.push(`<meta name="${escapeAttr(name)}" content="${escapeAttr(content)}">`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return tags.join("\n ");
|
|
658
|
+
}
|
|
659
|
+
function buildRobotsContent(robots) {
|
|
660
|
+
const directives = [];
|
|
661
|
+
if (robots.index === false) directives.push("noindex");
|
|
662
|
+
else if (robots.index === true) directives.push("index");
|
|
663
|
+
if (robots.follow === false) directives.push("nofollow");
|
|
664
|
+
else if (robots.follow === true) directives.push("follow");
|
|
665
|
+
if (robots.nocache) directives.push("nocache");
|
|
666
|
+
return directives.join(", ") || "index, follow";
|
|
667
|
+
}
|
|
668
|
+
function mergeMetadata(...metadataList) {
|
|
669
|
+
const result = {};
|
|
670
|
+
for (const meta of metadataList) {
|
|
671
|
+
if (!meta) continue;
|
|
672
|
+
if (meta.title !== void 0) result.title = meta.title;
|
|
673
|
+
if (meta.description !== void 0) result.description = meta.description;
|
|
674
|
+
if (meta.keywords !== void 0) result.keywords = meta.keywords;
|
|
675
|
+
if (meta.canonical !== void 0) result.canonical = meta.canonical;
|
|
676
|
+
if (meta.robots !== void 0) result.robots = meta.robots;
|
|
677
|
+
if (meta.openGraph) {
|
|
678
|
+
result.openGraph = { ...result.openGraph, ...meta.openGraph };
|
|
679
|
+
}
|
|
680
|
+
if (meta.twitter) {
|
|
681
|
+
result.twitter = { ...result.twitter, ...meta.twitter };
|
|
682
|
+
}
|
|
683
|
+
if (meta.icons) {
|
|
684
|
+
result.icons = { ...result.icons, ...meta.icons };
|
|
685
|
+
}
|
|
686
|
+
if (meta.alternates) {
|
|
687
|
+
result.alternates = { ...result.alternates, ...meta.alternates };
|
|
688
|
+
}
|
|
689
|
+
if (meta.verification) {
|
|
690
|
+
result.verification = { ...result.verification, ...meta.verification };
|
|
691
|
+
}
|
|
692
|
+
if (meta.other) {
|
|
693
|
+
result.other = { ...result.other, ...meta.other };
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
async function resolveMetadata(pageModule, props) {
|
|
699
|
+
if (pageModule.metadata) {
|
|
700
|
+
return pageModule.metadata;
|
|
701
|
+
}
|
|
702
|
+
if (pageModule.generateMetadata) {
|
|
703
|
+
return await pageModule.generateMetadata(props);
|
|
704
|
+
}
|
|
705
|
+
return {};
|
|
706
|
+
}
|
|
707
|
+
function escapeHtml(str) {
|
|
708
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
709
|
+
}
|
|
710
|
+
function escapeAttr(str) {
|
|
711
|
+
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'");
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/render/devtools.ts
|
|
715
|
+
function injectDevTools(options = {}) {
|
|
716
|
+
if (process.env.NODE_ENV !== "development") {
|
|
717
|
+
return "";
|
|
718
|
+
}
|
|
719
|
+
const data = JSON.stringify(options, null, 2);
|
|
720
|
+
return `
|
|
721
|
+
<!-- Flight DevTools - Development Only - NO TELEMETRY -->
|
|
722
|
+
<div id="flight-devtools" style="display:none;">
|
|
723
|
+
<div id="flight-devtools-toggle" style="
|
|
724
|
+
position: fixed;
|
|
725
|
+
bottom: 16px;
|
|
726
|
+
right: 16px;
|
|
727
|
+
width: 40px;
|
|
728
|
+
height: 40px;
|
|
729
|
+
background: #1a1a2e;
|
|
730
|
+
border-radius: 8px;
|
|
731
|
+
cursor: pointer;
|
|
732
|
+
display: flex;
|
|
733
|
+
align-items: center;
|
|
734
|
+
justify-content: center;
|
|
735
|
+
z-index: 99999;
|
|
736
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
737
|
+
font-size: 20px;
|
|
738
|
+
">\u2708</div>
|
|
739
|
+
<div id="flight-devtools-panel" style="
|
|
740
|
+
position: fixed;
|
|
741
|
+
bottom: 70px;
|
|
742
|
+
right: 16px;
|
|
743
|
+
width: 320px;
|
|
744
|
+
max-height: 400px;
|
|
745
|
+
background: #1a1a2e;
|
|
746
|
+
color: #e0e0e0;
|
|
747
|
+
border-radius: 8px;
|
|
748
|
+
padding: 16px;
|
|
749
|
+
font-family: ui-monospace, monospace;
|
|
750
|
+
font-size: 12px;
|
|
751
|
+
z-index: 99998;
|
|
752
|
+
overflow-y: auto;
|
|
753
|
+
display: none;
|
|
754
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
|
755
|
+
">
|
|
756
|
+
<div style="display:flex;justify-content:space-between;margin-bottom:12px;">
|
|
757
|
+
<strong style="color:#60a5fa;">Flight DevTools</strong>
|
|
758
|
+
<span style="color:#6b7280;font-size:10px;">LOCAL ONLY</span>
|
|
759
|
+
</div>
|
|
760
|
+
<div id="flight-devtools-content"></div>
|
|
761
|
+
</div>
|
|
762
|
+
</div>
|
|
763
|
+
<script>
|
|
764
|
+
(function() {
|
|
765
|
+
// DevTools data
|
|
766
|
+
var data = ${data};
|
|
767
|
+
|
|
768
|
+
// Wait for DOM
|
|
769
|
+
if (document.readyState === 'loading') {
|
|
770
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
771
|
+
} else {
|
|
772
|
+
init();
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function init() {
|
|
776
|
+
var container = document.getElementById('flight-devtools');
|
|
777
|
+
var toggle = document.getElementById('flight-devtools-toggle');
|
|
778
|
+
var panel = document.getElementById('flight-devtools-panel');
|
|
779
|
+
var content = document.getElementById('flight-devtools-content');
|
|
780
|
+
|
|
781
|
+
if (!container || !toggle || !panel || !content) return;
|
|
782
|
+
|
|
783
|
+
container.style.display = 'block';
|
|
784
|
+
|
|
785
|
+
// Render content
|
|
786
|
+
var html = '';
|
|
787
|
+
|
|
788
|
+
if (data.route) {
|
|
789
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Route:</span> <span style="color:#34d399;">' + escapeHtml(data.route) + '</span></div>';
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if (data.renderMode) {
|
|
793
|
+
var modeColor = {ssr:'#f59e0b',ssg:'#10b981',isr:'#8b5cf6',csr:'#3b82f6'}[data.renderMode] || '#6b7280';
|
|
794
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Mode:</span> <span style="color:' + modeColor + ';text-transform:uppercase;">' + data.renderMode + '</span></div>';
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (data.renderTime !== undefined) {
|
|
798
|
+
var timeColor = data.renderTime < 50 ? '#10b981' : data.renderTime < 200 ? '#f59e0b' : '#ef4444';
|
|
799
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Render:</span> <span style="color:' + timeColor + ';">' + data.renderTime + 'ms</span></div>';
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (data.cacheStatus) {
|
|
803
|
+
var cacheColor = {hit:'#10b981',miss:'#ef4444',stale:'#f59e0b'}[data.cacheStatus] || '#6b7280';
|
|
804
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Cache:</span> <span style="color:' + cacheColor + ';">' + data.cacheStatus.toUpperCase() + '</span></div>';
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (data.params && Object.keys(data.params).length > 0) {
|
|
808
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Params:</span></div>';
|
|
809
|
+
html += '<pre style="background:#0f0f1a;padding:8px;border-radius:4px;margin:0;overflow-x:auto;">' + escapeHtml(JSON.stringify(data.params, null, 2)) + '</pre>';
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (data.hydrated !== undefined) {
|
|
813
|
+
html += '<div style="margin-bottom:8px;"><span style="color:#6b7280;">Hydrated:</span> <span style="color:' + (data.hydrated ? '#10b981' : '#f59e0b') + ';">' + (data.hydrated ? 'Yes' : 'Pending') + '</span></div>';
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
if (data.customData) {
|
|
817
|
+
html += '<details style="margin-top:12px;"><summary style="cursor:pointer;color:#6b7280;">Custom Data</summary>';
|
|
818
|
+
html += '<pre style="background:#0f0f1a;padding:8px;border-radius:4px;margin-top:8px;overflow-x:auto;">' + escapeHtml(JSON.stringify(data.customData, null, 2)) + '</pre></details>';
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
content.innerHTML = html || '<span style="color:#6b7280;">No data available</span>';
|
|
822
|
+
|
|
823
|
+
// Toggle panel
|
|
824
|
+
toggle.addEventListener('click', function() {
|
|
825
|
+
panel.style.display = panel.style.display === 'none' ? 'block' : 'none';
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// Update hydration status
|
|
829
|
+
window.addEventListener('load', function() {
|
|
830
|
+
setTimeout(function() {
|
|
831
|
+
var hydrationEl = content.querySelector('[data-hydration]');
|
|
832
|
+
if (hydrationEl) {
|
|
833
|
+
hydrationEl.textContent = 'Yes';
|
|
834
|
+
hydrationEl.style.color = '#10b981';
|
|
835
|
+
}
|
|
836
|
+
}, 100);
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
function escapeHtml(str) {
|
|
841
|
+
return String(str).replace(/[&<>"']/g, function(m) {
|
|
842
|
+
return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[m];
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
})();
|
|
846
|
+
</script>
|
|
847
|
+
`;
|
|
848
|
+
}
|
|
849
|
+
function isDevToolsEnabled() {
|
|
850
|
+
return process.env.NODE_ENV === "development";
|
|
851
|
+
}
|
|
852
|
+
function createDevToolsData(startTime, options = {}) {
|
|
853
|
+
return {
|
|
854
|
+
renderTime: Date.now() - startTime,
|
|
855
|
+
hydrated: false,
|
|
856
|
+
...options
|
|
857
|
+
};
|
|
858
|
+
}
|
|
13
859
|
|
|
14
860
|
// src/index.ts
|
|
15
861
|
var VERSION = "0.0.1";
|
|
16
862
|
|
|
17
|
-
export { VERSION };
|
|
863
|
+
export { VERSION, buildCacheControlHeader, createDefaultRouteRules, createDevToolsData, createHtmlStream, createISRCacheFromFlightCache, createMemoryISRCache, createRevalidateHandler, createStreamingResponse2 as createStaticStreamingResponse, expandDynamicRoutes, extractLinks, generateAllStaticPaths, getCacheOptionsFromRule, getISRCache, getOrGeneratePage, getRenderModeFromRule, getRevalidateTime, injectDevTools, isDevToolsEnabled, matchRouteRule, mergeMetadata, mergeRouteRules, prerenderRoutes, purgeAllPages, purgePage, renderMetadataToHead, resolveMetadata, revalidatePath2 as revalidatePath, revalidatePaths, revalidateTag2 as revalidateTag, setISRCache, shouldDynamicallyRender };
|
|
18
864
|
//# sourceMappingURL=index.js.map
|
|
19
865
|
//# sourceMappingURL=index.js.map
|