@teyik0/furin 0.1.0-alpha.10 → 0.1.0-alpha.12
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/build/index.js +533 -238
- package/dist/cli/index.js +533 -238
- package/dist/dev-inspector.d.ts +89 -0
- package/dist/furin.js +896 -403
- package/dist/link.d.ts +5 -438
- package/dist/link.js +309 -146
- package/dist/render/cache.d.ts +18 -5
- package/dist/render/dev-cache.d.ts +120 -0
- package/dist/render/index.d.ts +2 -1
- package/dist/render/route-cache.d.ts +26 -0
- package/dist/router-provider.d.ts +466 -0
- package/dist/router.d.ts +14 -0
- package/dist/router.js +979 -551
- package/package.json +9 -8
- package/src/build/hydrate.ts +7 -5
- package/src/dev-inspector.ts +60 -0
- package/src/dev-page-plugin.ts +13 -0
- package/src/env.d.ts +1 -0
- package/src/furin.ts +3 -0
- package/src/link.tsx +40 -1295
- package/src/render/cache.ts +77 -67
- package/src/render/dev-cache.ts +314 -0
- package/src/render/index.ts +21 -19
- package/src/render/route-cache.ts +124 -0
- package/src/router-provider.tsx +1426 -0
- package/src/router.ts +299 -44
package/dist/build/index.js
CHANGED
|
@@ -1598,10 +1598,15 @@ function generateHydrateEntry(routes, rootLayout, basePath) {
|
|
|
1598
1598
|
const conventionImportLines = [...conventionIdents.entries()].map(([filePath, ident]) => `import ${ident} from "${filePath.replace(/\\/g, "/")}";`).join(`
|
|
1599
1599
|
`);
|
|
1600
1600
|
const basePathLiteral = JSON.stringify(basePath);
|
|
1601
|
-
const pathnameExpr = basePath ? `(() => { const p = window.location.pathname; const b = ${basePathLiteral};
|
|
1601
|
+
const pathnameExpr = basePath ? `(() => { const p = window.location.pathname; const b = ${basePathLiteral}; const stripped = (p.startsWith(b) && (p.length === b.length || p[b.length] === "/")) ? p.slice(b.length) || "/" : p; return stripped === "/" ? "/" : stripped.replace(/\\/+$/, ""); })()` : `window.location.pathname.replace(/\\/+$/, "") || "/"`;
|
|
1602
1602
|
const logEndpoint = basePath ? `${JSON.stringify(basePath)} + "/_furin/ingest"` : `"/_furin/ingest"`;
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1603
|
+
const routerProviderDefaults = `
|
|
1604
|
+
autoRefresh: true,
|
|
1605
|
+
basePath: ${basePathLiteral},
|
|
1606
|
+
defaultPreload: "intent",
|
|
1607
|
+
defaultPreloadDelay: 50,
|
|
1608
|
+
defaultPreloadStaleTime: 30000,
|
|
1609
|
+
prefetchCacheSize: 50,`;
|
|
1605
1610
|
const conventionImportsBlock = conventionImportLines ? `
|
|
1606
1611
|
${conventionImportLines}` : "";
|
|
1607
1612
|
return `import { hydrateRoot, createRoot } from "react-dom/client";
|
|
@@ -1650,7 +1655,7 @@ const rootEl = document.getElementById("root") as HTMLElement;
|
|
|
1650
1655
|
initialMatch: match,
|
|
1651
1656
|
initialData: loaderData,
|
|
1652
1657
|
initialDigest: loaderData.__furinError?.digest,
|
|
1653
|
-
initialNotFound: isNotFound ? (loaderData.__furinNotFound ?? loaderData) : undefined,${
|
|
1658
|
+
initialNotFound: isNotFound ? (loaderData.__furinNotFound ?? loaderData) : undefined,${routerProviderDefaults}
|
|
1654
1659
|
} as any);
|
|
1655
1660
|
} else if (loaderData.__furinStatus === 404) {
|
|
1656
1661
|
// Direct load to an unknown URL. The server sent the root not-found UI
|
|
@@ -1667,7 +1672,7 @@ const rootEl = document.getElementById("root") as HTMLElement;
|
|
|
1667
1672
|
initialMatch: null,
|
|
1668
1673
|
initialData: cleanData,
|
|
1669
1674
|
initialDigest: loaderData.__furinError?.digest,
|
|
1670
|
-
initialNotFound: loaderData.__furinNotFound ?? {},${
|
|
1675
|
+
initialNotFound: loaderData.__furinNotFound ?? {},${routerProviderDefaults}
|
|
1671
1676
|
} as any);
|
|
1672
1677
|
} else {
|
|
1673
1678
|
// No match and no 404 signal \u2014 either the client bundle is out of sync
|
|
@@ -2255,16 +2260,38 @@ function assembleHTML(template, headData, reactHtml, data) {
|
|
|
2255
2260
|
}
|
|
2256
2261
|
|
|
2257
2262
|
// src/render/index.ts
|
|
2258
|
-
import { createElement as
|
|
2263
|
+
import { createElement as createElement3 } from "react";
|
|
2259
2264
|
import { renderToReadableStream } from "react-dom/server";
|
|
2260
|
-
|
|
2265
|
+
|
|
2266
|
+
// src/not-found.ts
|
|
2267
|
+
var NOT_FOUND_BRAND = "FURIN_NOT_FOUND";
|
|
2268
|
+
|
|
2269
|
+
class FurinNotFoundError extends Error {
|
|
2270
|
+
__furinBrand = NOT_FOUND_BRAND;
|
|
2271
|
+
data;
|
|
2272
|
+
constructor(options) {
|
|
2273
|
+
super(options?.message ?? "");
|
|
2274
|
+
this.data = options?.data;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
function isNotFoundError(err) {
|
|
2278
|
+
return err instanceof FurinNotFoundError || typeof err === "object" && err !== null && err.__furinBrand === NOT_FOUND_BRAND;
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/utils.mjs
|
|
2261
2282
|
function formatDuration(ms) {
|
|
2262
2283
|
if (ms < 1000)
|
|
2263
2284
|
return `${Math.round(ms)}ms`;
|
|
2264
2285
|
return `${(ms / 1000).toFixed(2)}s`;
|
|
2265
2286
|
}
|
|
2266
|
-
function
|
|
2267
|
-
|
|
2287
|
+
function isBrowser() {
|
|
2288
|
+
if (typeof window === "undefined")
|
|
2289
|
+
return false;
|
|
2290
|
+
if (typeof document === "undefined")
|
|
2291
|
+
return false;
|
|
2292
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative")
|
|
2293
|
+
return false;
|
|
2294
|
+
return true;
|
|
2268
2295
|
}
|
|
2269
2296
|
function isDev() {
|
|
2270
2297
|
if (typeof process !== "undefined")
|
|
@@ -2350,7 +2377,7 @@ function matchesPattern(path, pattern) {
|
|
|
2350
2377
|
return regex.test(path);
|
|
2351
2378
|
}
|
|
2352
2379
|
|
|
2353
|
-
// ../../node_modules/.bun/evlog@2.
|
|
2380
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/audit-DQoBo7Dl.mjs
|
|
2354
2381
|
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
2355
2382
|
var builtinPatterns = {
|
|
2356
2383
|
creditCard: {
|
|
@@ -2371,7 +2398,7 @@ var builtinPatterns = {
|
|
|
2371
2398
|
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
2372
2399
|
},
|
|
2373
2400
|
phone: {
|
|
2374
|
-
pattern: /(?:\+\d{1,3}[\s.-]
|
|
2401
|
+
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
2375
2402
|
mask: (m) => {
|
|
2376
2403
|
const digits = m.replace(/[^\d]/g, "");
|
|
2377
2404
|
if (m.startsWith("+") && digits.length > 4) {
|
|
@@ -2584,7 +2611,8 @@ function shouldKeep(ctx) {
|
|
|
2584
2611
|
return false;
|
|
2585
2612
|
});
|
|
2586
2613
|
}
|
|
2587
|
-
function emitWideEvent(level, event,
|
|
2614
|
+
function emitWideEvent(level, event, options = {}) {
|
|
2615
|
+
const { deferDrain = false, ownsEvent = false, waitUntil } = options;
|
|
2588
2616
|
if (!globalEnabled)
|
|
2589
2617
|
return null;
|
|
2590
2618
|
if (!ownsEvent) {
|
|
@@ -2615,6 +2643,7 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2615
2643
|
...globalEnv,
|
|
2616
2644
|
...event
|
|
2617
2645
|
};
|
|
2646
|
+
finalizeAudit(formatted);
|
|
2618
2647
|
if (globalRedact)
|
|
2619
2648
|
redactEvent(formatted, globalRedact);
|
|
2620
2649
|
if (!globalSilent)
|
|
@@ -2624,10 +2653,13 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2624
2653
|
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
2625
2654
|
else
|
|
2626
2655
|
console[getConsoleMethod(level)](formatted);
|
|
2627
|
-
if (globalDrain && !deferDrain)
|
|
2628
|
-
Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2656
|
+
if (globalDrain && !deferDrain) {
|
|
2657
|
+
const drainPromise = Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2629
2658
|
console.error("[evlog] drain failed:", err);
|
|
2630
2659
|
});
|
|
2660
|
+
if (waitUntil)
|
|
2661
|
+
waitUntil(drainPromise);
|
|
2662
|
+
}
|
|
2631
2663
|
return formatted;
|
|
2632
2664
|
}
|
|
2633
2665
|
function emitTaggedLog(level, tag, message) {
|
|
@@ -2638,7 +2670,7 @@ function emitTaggedLog(level, tag, message) {
|
|
|
2638
2670
|
return;
|
|
2639
2671
|
if (!shouldSample(level))
|
|
2640
2672
|
return;
|
|
2641
|
-
if (
|
|
2673
|
+
if (isBrowser()) {
|
|
2642
2674
|
const levelColor = getCssLevelColor(level);
|
|
2643
2675
|
const timestamp = isoNow().slice(11, 23);
|
|
2644
2676
|
console.log(`%c${timestamp}%c %c[${escapeFormatString(tag)}]%c ${escapeFormatString(message)}`, cssColors.dim, cssColors.reset, levelColor, cssColors.reset);
|
|
@@ -2835,7 +2867,7 @@ function buildAIEntries(ai) {
|
|
|
2835
2867
|
function prettyPrintWideEvent(event) {
|
|
2836
2868
|
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
2837
2869
|
const ts = timestamp.slice(11, 23);
|
|
2838
|
-
const browser =
|
|
2870
|
+
const browser = isBrowser();
|
|
2839
2871
|
const parts = [];
|
|
2840
2872
|
const styles = [];
|
|
2841
2873
|
if (browser) {
|
|
@@ -2928,12 +2960,14 @@ var noopLogger = {
|
|
|
2928
2960
|
},
|
|
2929
2961
|
getContext() {
|
|
2930
2962
|
return {};
|
|
2931
|
-
}
|
|
2963
|
+
},
|
|
2964
|
+
audit: Object.assign(() => {}, { deny: () => {} })
|
|
2932
2965
|
};
|
|
2933
2966
|
function createLogger(initialContext = {}, internalOptions) {
|
|
2934
2967
|
if (!globalEnabled)
|
|
2935
2968
|
return noopLogger;
|
|
2936
2969
|
const deferDrain = internalOptions?._deferDrain ?? false;
|
|
2970
|
+
const waitUntil = internalOptions?.waitUntil;
|
|
2937
2971
|
const startTime = Date.now();
|
|
2938
2972
|
const context = { ...initialContext };
|
|
2939
2973
|
let hasError = false;
|
|
@@ -2948,7 +2982,27 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2948
2982
|
timestamp: isoNow()
|
|
2949
2983
|
});
|
|
2950
2984
|
}
|
|
2985
|
+
const auditMethod = function audit(input) {
|
|
2986
|
+
if (emitted) {
|
|
2987
|
+
warnPostEmit("log.audit()", `Audit dropped: action=${input.action}.`);
|
|
2988
|
+
return;
|
|
2989
|
+
}
|
|
2990
|
+
const fields = buildAuditFields(input);
|
|
2991
|
+
if (!isPlainObject(context.audit))
|
|
2992
|
+
context.audit = fields;
|
|
2993
|
+
else
|
|
2994
|
+
mergeInto(context.audit, fields);
|
|
2995
|
+
context._auditForceKeep = true;
|
|
2996
|
+
};
|
|
2997
|
+
auditMethod.deny = function deny(reason, input) {
|
|
2998
|
+
auditMethod({
|
|
2999
|
+
...input,
|
|
3000
|
+
outcome: "denied",
|
|
3001
|
+
reason
|
|
3002
|
+
});
|
|
3003
|
+
};
|
|
2951
3004
|
return {
|
|
3005
|
+
audit: auditMethod,
|
|
2952
3006
|
set(data) {
|
|
2953
3007
|
if (emitted) {
|
|
2954
3008
|
const keys = Object.keys(data);
|
|
@@ -3021,6 +3075,8 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3021
3075
|
let forceKeep = false;
|
|
3022
3076
|
if (overrides?._forceKeep)
|
|
3023
3077
|
forceKeep = true;
|
|
3078
|
+
else if (consumeAuditForceKeep(context))
|
|
3079
|
+
forceKeep = true;
|
|
3024
3080
|
else if (globalSampling.keep?.length)
|
|
3025
3081
|
forceKeep = shouldKeep({
|
|
3026
3082
|
status: overrides?.status ?? context.status,
|
|
@@ -3040,7 +3096,11 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3040
3096
|
context[key] = obj[key];
|
|
3041
3097
|
}
|
|
3042
3098
|
context.duration = formatDuration(durationMs);
|
|
3043
|
-
const wide = emitWideEvent(level, context,
|
|
3099
|
+
const wide = emitWideEvent(level, context, {
|
|
3100
|
+
deferDrain,
|
|
3101
|
+
ownsEvent: true,
|
|
3102
|
+
waitUntil
|
|
3103
|
+
});
|
|
3044
3104
|
emitted = true;
|
|
3045
3105
|
return wide;
|
|
3046
3106
|
},
|
|
@@ -3051,15 +3111,88 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3051
3111
|
}
|
|
3052
3112
|
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
3053
3113
|
initLogger(__EVLOG_CONFIG__);
|
|
3054
|
-
|
|
3114
|
+
function stableStringify(value) {
|
|
3115
|
+
if (value === null || typeof value !== "object")
|
|
3116
|
+
return JSON.stringify(value);
|
|
3117
|
+
if (Array.isArray(value))
|
|
3118
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
3119
|
+
return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`).join(",")}}`;
|
|
3120
|
+
}
|
|
3121
|
+
function fnv1a32(input, seed) {
|
|
3122
|
+
let h = seed >>> 0;
|
|
3123
|
+
for (let i = 0;i < input.length; i++) {
|
|
3124
|
+
h ^= input.charCodeAt(i) & 255;
|
|
3125
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
3126
|
+
}
|
|
3127
|
+
return h >>> 0;
|
|
3128
|
+
}
|
|
3129
|
+
function computeIdempotencyKey(audit, timestamp) {
|
|
3130
|
+
const seconds = timestamp.slice(0, 19);
|
|
3131
|
+
const payload = stableStringify({
|
|
3132
|
+
action: audit.action,
|
|
3133
|
+
actor: {
|
|
3134
|
+
type: audit.actor.type,
|
|
3135
|
+
id: audit.actor.id
|
|
3136
|
+
},
|
|
3137
|
+
target: audit.target ? {
|
|
3138
|
+
type: audit.target.type,
|
|
3139
|
+
id: audit.target.id
|
|
3140
|
+
} : undefined,
|
|
3141
|
+
outcome: audit.outcome,
|
|
3142
|
+
timestamp: seconds
|
|
3143
|
+
});
|
|
3144
|
+
const a = fnv1a32(payload, 2166136261).toString(16).padStart(8, "0");
|
|
3145
|
+
const b = fnv1a32(payload, 3735928559).toString(16).padStart(8, "0");
|
|
3146
|
+
const c = fnv1a32(payload, 528734635).toString(16).padStart(8, "0");
|
|
3147
|
+
const d = fnv1a32(payload, 1541459225).toString(16).padStart(8, "0");
|
|
3148
|
+
return a + b + c + d;
|
|
3149
|
+
}
|
|
3150
|
+
function buildAuditFields(input) {
|
|
3151
|
+
return {
|
|
3152
|
+
action: input.action,
|
|
3153
|
+
actor: input.actor,
|
|
3154
|
+
target: input.target,
|
|
3155
|
+
outcome: input.outcome ?? "success",
|
|
3156
|
+
reason: input.reason,
|
|
3157
|
+
changes: input.changes,
|
|
3158
|
+
causationId: input.causationId,
|
|
3159
|
+
correlationId: input.correlationId,
|
|
3160
|
+
version: input.version ?? 1
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
3163
|
+
function decorateAudit(audit, timestamp) {
|
|
3164
|
+
if (audit.idempotencyKey)
|
|
3165
|
+
return audit;
|
|
3166
|
+
return {
|
|
3167
|
+
...audit,
|
|
3168
|
+
idempotencyKey: computeIdempotencyKey(audit, timestamp)
|
|
3169
|
+
};
|
|
3170
|
+
}
|
|
3171
|
+
function consumeAuditForceKeep(context) {
|
|
3172
|
+
if (context._auditForceKeep) {
|
|
3173
|
+
delete context._auditForceKeep;
|
|
3174
|
+
return true;
|
|
3175
|
+
}
|
|
3176
|
+
if (context.audit)
|
|
3177
|
+
return true;
|
|
3178
|
+
return false;
|
|
3179
|
+
}
|
|
3180
|
+
function finalizeAudit(event) {
|
|
3181
|
+
const a = event.audit;
|
|
3182
|
+
if (!a)
|
|
3183
|
+
return;
|
|
3184
|
+
event.audit = decorateAudit(a, String(event.timestamp));
|
|
3185
|
+
}
|
|
3186
|
+
// src/router-provider.tsx
|
|
3055
3187
|
import {
|
|
3056
3188
|
createContext,
|
|
3057
|
-
createElement,
|
|
3058
|
-
useCallback,
|
|
3189
|
+
createElement as createElement2,
|
|
3190
|
+
useCallback as useCallback2,
|
|
3059
3191
|
useContext,
|
|
3060
|
-
useEffect,
|
|
3192
|
+
useEffect as useEffect2,
|
|
3193
|
+
useLayoutEffect,
|
|
3061
3194
|
useMemo,
|
|
3062
|
-
useRef,
|
|
3195
|
+
useRef as useRef2,
|
|
3063
3196
|
useState
|
|
3064
3197
|
} from "react";
|
|
3065
3198
|
|
|
@@ -3075,19 +3208,193 @@ function getPublicErrorMessage(error) {
|
|
|
3075
3208
|
return "Something went wrong";
|
|
3076
3209
|
}
|
|
3077
3210
|
|
|
3078
|
-
// src/
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3211
|
+
// src/link.tsx
|
|
3212
|
+
import { createElement, useCallback, useEffect, useRef } from "react";
|
|
3213
|
+
function computeLinkView({
|
|
3214
|
+
to,
|
|
3215
|
+
search,
|
|
3216
|
+
hash,
|
|
3217
|
+
children,
|
|
3218
|
+
activeProps,
|
|
3219
|
+
inactiveProps
|
|
3220
|
+
}, router) {
|
|
3221
|
+
const logicalHref = buildHref(to, search, hash);
|
|
3222
|
+
const logicalHrefWithoutHash = buildHref(to, search, undefined);
|
|
3223
|
+
const isAbsolute = logicalHref.startsWith("http://") || logicalHref.startsWith("https://") || logicalHref.startsWith("//");
|
|
3224
|
+
const href = isAbsolute ? logicalHref : router.basePath + logicalHref;
|
|
3225
|
+
const isActive = router.currentHref === logicalHrefWithoutHash;
|
|
3226
|
+
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
3227
|
+
const extraProps = {
|
|
3228
|
+
...inactiveProps && !isActive ? inactiveProps() : {},
|
|
3229
|
+
...activeProps ? activeProps({ isActive }) : {}
|
|
3230
|
+
};
|
|
3231
|
+
return { logicalHref, href, isActive, resolvedChildren, extraProps };
|
|
3088
3232
|
}
|
|
3089
|
-
function
|
|
3090
|
-
|
|
3233
|
+
function LinkInteractive({
|
|
3234
|
+
to,
|
|
3235
|
+
search,
|
|
3236
|
+
hash,
|
|
3237
|
+
preload,
|
|
3238
|
+
preloadDelay,
|
|
3239
|
+
preloadStaleTime,
|
|
3240
|
+
replace,
|
|
3241
|
+
disabled,
|
|
3242
|
+
resetScroll,
|
|
3243
|
+
activeProps,
|
|
3244
|
+
inactiveProps,
|
|
3245
|
+
onClick,
|
|
3246
|
+
onMouseEnter,
|
|
3247
|
+
onMouseLeave,
|
|
3248
|
+
onFocus,
|
|
3249
|
+
children,
|
|
3250
|
+
href: _href,
|
|
3251
|
+
...anchorProps
|
|
3252
|
+
}) {
|
|
3253
|
+
const router = useRouter();
|
|
3254
|
+
const anchorRef = useRef(null);
|
|
3255
|
+
const intentTimerRef = useRef(null);
|
|
3256
|
+
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
|
|
3257
|
+
const effectivePreload = preload ?? router.defaultPreload;
|
|
3258
|
+
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
3259
|
+
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
3260
|
+
const triggerPrefetch = useCallback(() => {
|
|
3261
|
+
router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
3262
|
+
}, [router, logicalHref, effectiveStaleTime]);
|
|
3263
|
+
useEffect(() => {
|
|
3264
|
+
if (effectivePreload === "render") {
|
|
3265
|
+
triggerPrefetch();
|
|
3266
|
+
}
|
|
3267
|
+
}, [effectivePreload, triggerPrefetch]);
|
|
3268
|
+
useEffect(() => {
|
|
3269
|
+
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
3270
|
+
return;
|
|
3271
|
+
}
|
|
3272
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
3273
|
+
if (entry?.isIntersecting) {
|
|
3274
|
+
triggerPrefetch();
|
|
3275
|
+
observer.disconnect();
|
|
3276
|
+
}
|
|
3277
|
+
}, { rootMargin: "200px" });
|
|
3278
|
+
observer.observe(anchorRef.current);
|
|
3279
|
+
return () => observer.disconnect();
|
|
3280
|
+
}, [effectivePreload, triggerPrefetch]);
|
|
3281
|
+
useEffect(() => () => {
|
|
3282
|
+
if (intentTimerRef.current !== null) {
|
|
3283
|
+
clearTimeout(intentTimerRef.current);
|
|
3284
|
+
intentTimerRef.current = null;
|
|
3285
|
+
}
|
|
3286
|
+
}, []);
|
|
3287
|
+
const isInternal = (url) => {
|
|
3288
|
+
try {
|
|
3289
|
+
return new URL(url, window.location.origin).origin === window.location.origin;
|
|
3290
|
+
} catch {
|
|
3291
|
+
return false;
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
const handleClick = (e) => {
|
|
3295
|
+
onClick?.(e);
|
|
3296
|
+
if (e.defaultPrevented) {
|
|
3297
|
+
return;
|
|
3298
|
+
}
|
|
3299
|
+
if (disabled) {
|
|
3300
|
+
e.preventDefault();
|
|
3301
|
+
return;
|
|
3302
|
+
}
|
|
3303
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
if (anchorProps.target && anchorProps.target !== "_self") {
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
if (!isInternal(href)) {
|
|
3310
|
+
return;
|
|
3311
|
+
}
|
|
3312
|
+
e.preventDefault();
|
|
3313
|
+
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
3314
|
+
};
|
|
3315
|
+
const handleMouseEnter = (e) => {
|
|
3316
|
+
onMouseEnter?.(e);
|
|
3317
|
+
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
3318
|
+
intentTimerRef.current = setTimeout(triggerPrefetch, effectiveDelay);
|
|
3319
|
+
}
|
|
3320
|
+
};
|
|
3321
|
+
const handleMouseLeave = (e) => {
|
|
3322
|
+
onMouseLeave?.(e);
|
|
3323
|
+
if (intentTimerRef.current !== null) {
|
|
3324
|
+
clearTimeout(intentTimerRef.current);
|
|
3325
|
+
intentTimerRef.current = null;
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
const handleFocus = (e) => {
|
|
3329
|
+
onFocus?.(e);
|
|
3330
|
+
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
3331
|
+
triggerPrefetch();
|
|
3332
|
+
}
|
|
3333
|
+
};
|
|
3334
|
+
return createElement("a", {
|
|
3335
|
+
ref: anchorRef,
|
|
3336
|
+
href,
|
|
3337
|
+
"data-furin-link": true,
|
|
3338
|
+
onClick: handleClick,
|
|
3339
|
+
onMouseEnter: handleMouseEnter,
|
|
3340
|
+
onMouseLeave: handleMouseLeave,
|
|
3341
|
+
onFocus: handleFocus,
|
|
3342
|
+
...isActive ? { "data-status": "active" } : {},
|
|
3343
|
+
...anchorProps,
|
|
3344
|
+
...extraProps,
|
|
3345
|
+
...disabled ? { "aria-disabled": true } : {}
|
|
3346
|
+
}, resolvedChildren);
|
|
3347
|
+
}
|
|
3348
|
+
var SSR_FALLBACK_ROUTER = {
|
|
3349
|
+
basePath: "",
|
|
3350
|
+
currentHref: "/",
|
|
3351
|
+
navigate: () => Promise.resolve(),
|
|
3352
|
+
prefetch: () => {},
|
|
3353
|
+
invalidatePrefetch: () => {},
|
|
3354
|
+
refresh: () => Promise.resolve(),
|
|
3355
|
+
isNavigating: false,
|
|
3356
|
+
defaultPreload: "intent",
|
|
3357
|
+
defaultPreloadDelay: 50,
|
|
3358
|
+
defaultPreloadStaleTime: 30000
|
|
3359
|
+
};
|
|
3360
|
+
function renderLinkElement(props, router) {
|
|
3361
|
+
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
|
|
3362
|
+
const {
|
|
3363
|
+
to: _to,
|
|
3364
|
+
search: _search,
|
|
3365
|
+
hash: _hash,
|
|
3366
|
+
children: _children,
|
|
3367
|
+
activeProps: _ap,
|
|
3368
|
+
inactiveProps: _ip,
|
|
3369
|
+
disabled,
|
|
3370
|
+
preload: _p,
|
|
3371
|
+
preloadDelay: _pd,
|
|
3372
|
+
preloadStaleTime: _ps,
|
|
3373
|
+
replace: _r,
|
|
3374
|
+
resetScroll: _rs,
|
|
3375
|
+
onClick: _oc,
|
|
3376
|
+
onMouseEnter: _ome,
|
|
3377
|
+
onMouseLeave: _oml,
|
|
3378
|
+
onFocus: _of,
|
|
3379
|
+
href: _href,
|
|
3380
|
+
...anchorProps
|
|
3381
|
+
} = props;
|
|
3382
|
+
return createElement("a", {
|
|
3383
|
+
href,
|
|
3384
|
+
"data-furin-link": true,
|
|
3385
|
+
...isActive ? { "data-status": "active" } : {},
|
|
3386
|
+
...anchorProps,
|
|
3387
|
+
...extraProps,
|
|
3388
|
+
...disabled ? { "aria-disabled": true } : {}
|
|
3389
|
+
}, resolvedChildren);
|
|
3390
|
+
}
|
|
3391
|
+
function Link(props) {
|
|
3392
|
+
if (typeof window === "undefined") {
|
|
3393
|
+
return createElement(RouterContext.Consumer, {
|
|
3394
|
+
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
return createElement(LinkInteractive, props);
|
|
3091
3398
|
}
|
|
3092
3399
|
|
|
3093
3400
|
// src/render/default-screens.tsx
|
|
@@ -3475,7 +3782,7 @@ class FurinNotFoundBoundary extends Component {
|
|
|
3475
3782
|
}
|
|
3476
3783
|
}
|
|
3477
3784
|
|
|
3478
|
-
// src/
|
|
3785
|
+
// src/router-provider.tsx
|
|
3479
3786
|
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
3480
3787
|
function buildHref(to, search, hash) {
|
|
3481
3788
|
let url = to;
|
|
@@ -3498,7 +3805,8 @@ function buildHref(to, search, hash) {
|
|
|
3498
3805
|
}
|
|
3499
3806
|
var RouterContext = createContext(null);
|
|
3500
3807
|
function useRouter() {
|
|
3501
|
-
|
|
3808
|
+
const ctx = useContext(RouterContext);
|
|
3809
|
+
return ctx ?? {
|
|
3502
3810
|
basePath: "",
|
|
3503
3811
|
currentHref: "/",
|
|
3504
3812
|
navigate: (href) => {
|
|
@@ -3517,177 +3825,6 @@ function useRouter() {
|
|
|
3517
3825
|
defaultPreloadStaleTime: 30000
|
|
3518
3826
|
};
|
|
3519
3827
|
}
|
|
3520
|
-
function computeLinkView({
|
|
3521
|
-
to,
|
|
3522
|
-
search,
|
|
3523
|
-
hash,
|
|
3524
|
-
children,
|
|
3525
|
-
activeProps,
|
|
3526
|
-
inactiveProps
|
|
3527
|
-
}, router) {
|
|
3528
|
-
const logicalHref = buildHref(to, search, hash);
|
|
3529
|
-
const logicalHrefWithoutHash = buildHref(to, search, undefined);
|
|
3530
|
-
const href = router.basePath + logicalHref;
|
|
3531
|
-
const isActive = router.currentHref === logicalHrefWithoutHash;
|
|
3532
|
-
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
3533
|
-
const extraProps = {
|
|
3534
|
-
...inactiveProps && !isActive ? inactiveProps() : {},
|
|
3535
|
-
...activeProps ? activeProps({ isActive }) : {}
|
|
3536
|
-
};
|
|
3537
|
-
return { logicalHref, href, isActive, resolvedChildren, extraProps };
|
|
3538
|
-
}
|
|
3539
|
-
function LinkInteractive({
|
|
3540
|
-
to,
|
|
3541
|
-
search,
|
|
3542
|
-
hash,
|
|
3543
|
-
preload,
|
|
3544
|
-
preloadDelay,
|
|
3545
|
-
preloadStaleTime,
|
|
3546
|
-
replace,
|
|
3547
|
-
disabled,
|
|
3548
|
-
resetScroll,
|
|
3549
|
-
activeProps,
|
|
3550
|
-
inactiveProps,
|
|
3551
|
-
onClick,
|
|
3552
|
-
onMouseEnter,
|
|
3553
|
-
onMouseLeave,
|
|
3554
|
-
onFocus,
|
|
3555
|
-
children,
|
|
3556
|
-
...anchorProps
|
|
3557
|
-
}) {
|
|
3558
|
-
const router = useRouter();
|
|
3559
|
-
const anchorRef = useRef(null);
|
|
3560
|
-
const intentTimerRef = useRef(null);
|
|
3561
|
-
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
|
|
3562
|
-
const effectivePreload = preload ?? router.defaultPreload;
|
|
3563
|
-
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
3564
|
-
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
3565
|
-
const triggerPrefetch = useCallback(() => {
|
|
3566
|
-
router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
3567
|
-
}, [router, logicalHref, effectiveStaleTime]);
|
|
3568
|
-
useEffect(() => {
|
|
3569
|
-
if (effectivePreload === "render") {
|
|
3570
|
-
triggerPrefetch();
|
|
3571
|
-
}
|
|
3572
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
3573
|
-
useEffect(() => {
|
|
3574
|
-
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
3575
|
-
return;
|
|
3576
|
-
}
|
|
3577
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
3578
|
-
if (entry?.isIntersecting) {
|
|
3579
|
-
triggerPrefetch();
|
|
3580
|
-
observer.disconnect();
|
|
3581
|
-
}
|
|
3582
|
-
}, { rootMargin: "200px" });
|
|
3583
|
-
observer.observe(anchorRef.current);
|
|
3584
|
-
return () => observer.disconnect();
|
|
3585
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
3586
|
-
const isInternal = (url) => {
|
|
3587
|
-
try {
|
|
3588
|
-
return new URL(url, window.location.origin).origin === window.location.origin;
|
|
3589
|
-
} catch {
|
|
3590
|
-
return false;
|
|
3591
|
-
}
|
|
3592
|
-
};
|
|
3593
|
-
const handleClick = (e) => {
|
|
3594
|
-
onClick?.(e);
|
|
3595
|
-
if (e.defaultPrevented || disabled) {
|
|
3596
|
-
return;
|
|
3597
|
-
}
|
|
3598
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
3599
|
-
return;
|
|
3600
|
-
}
|
|
3601
|
-
if (anchorProps.target && anchorProps.target !== "_self") {
|
|
3602
|
-
return;
|
|
3603
|
-
}
|
|
3604
|
-
if (!isInternal(href)) {
|
|
3605
|
-
return;
|
|
3606
|
-
}
|
|
3607
|
-
e.preventDefault();
|
|
3608
|
-
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
3609
|
-
};
|
|
3610
|
-
const handleMouseEnter = (e) => {
|
|
3611
|
-
onMouseEnter?.(e);
|
|
3612
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
3613
|
-
intentTimerRef.current = setTimeout(triggerPrefetch, effectiveDelay);
|
|
3614
|
-
}
|
|
3615
|
-
};
|
|
3616
|
-
const handleMouseLeave = (e) => {
|
|
3617
|
-
onMouseLeave?.(e);
|
|
3618
|
-
if (intentTimerRef.current !== null) {
|
|
3619
|
-
clearTimeout(intentTimerRef.current);
|
|
3620
|
-
intentTimerRef.current = null;
|
|
3621
|
-
}
|
|
3622
|
-
};
|
|
3623
|
-
const handleFocus = (e) => {
|
|
3624
|
-
onFocus?.(e);
|
|
3625
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
3626
|
-
triggerPrefetch();
|
|
3627
|
-
}
|
|
3628
|
-
};
|
|
3629
|
-
return createElement("a", {
|
|
3630
|
-
ref: anchorRef,
|
|
3631
|
-
href,
|
|
3632
|
-
onClick: handleClick,
|
|
3633
|
-
onMouseEnter: handleMouseEnter,
|
|
3634
|
-
onMouseLeave: handleMouseLeave,
|
|
3635
|
-
onFocus: handleFocus,
|
|
3636
|
-
...isActive ? { "data-status": "active" } : {},
|
|
3637
|
-
...anchorProps,
|
|
3638
|
-
...extraProps,
|
|
3639
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
3640
|
-
}, resolvedChildren);
|
|
3641
|
-
}
|
|
3642
|
-
var SSR_FALLBACK_ROUTER = {
|
|
3643
|
-
basePath: "",
|
|
3644
|
-
currentHref: "/",
|
|
3645
|
-
navigate: () => Promise.resolve(),
|
|
3646
|
-
prefetch: () => {},
|
|
3647
|
-
invalidatePrefetch: () => {},
|
|
3648
|
-
refresh: () => Promise.resolve(),
|
|
3649
|
-
isNavigating: false,
|
|
3650
|
-
defaultPreload: "intent",
|
|
3651
|
-
defaultPreloadDelay: 50,
|
|
3652
|
-
defaultPreloadStaleTime: 30000
|
|
3653
|
-
};
|
|
3654
|
-
function renderLinkElement(props, router) {
|
|
3655
|
-
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
|
|
3656
|
-
const {
|
|
3657
|
-
to: _to,
|
|
3658
|
-
search: _search,
|
|
3659
|
-
hash: _hash,
|
|
3660
|
-
children: _children,
|
|
3661
|
-
activeProps: _ap,
|
|
3662
|
-
inactiveProps: _ip,
|
|
3663
|
-
disabled,
|
|
3664
|
-
preload: _p,
|
|
3665
|
-
preloadDelay: _pd,
|
|
3666
|
-
preloadStaleTime: _ps,
|
|
3667
|
-
replace: _r,
|
|
3668
|
-
resetScroll: _rs,
|
|
3669
|
-
onClick: _oc,
|
|
3670
|
-
onMouseEnter: _ome,
|
|
3671
|
-
onMouseLeave: _oml,
|
|
3672
|
-
onFocus: _of,
|
|
3673
|
-
...anchorProps
|
|
3674
|
-
} = props;
|
|
3675
|
-
return createElement("a", {
|
|
3676
|
-
href,
|
|
3677
|
-
...isActive ? { "data-status": "active" } : {},
|
|
3678
|
-
...anchorProps,
|
|
3679
|
-
...extraProps,
|
|
3680
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
3681
|
-
}, resolvedChildren);
|
|
3682
|
-
}
|
|
3683
|
-
function Link(props) {
|
|
3684
|
-
if (typeof window === "undefined") {
|
|
3685
|
-
return createElement(RouterContext.Consumer, {
|
|
3686
|
-
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
3687
|
-
});
|
|
3688
|
-
}
|
|
3689
|
-
return createElement(LinkInteractive, props);
|
|
3690
|
-
}
|
|
3691
3828
|
|
|
3692
3829
|
// src/render/cache.ts
|
|
3693
3830
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
@@ -3695,7 +3832,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
3695
3832
|
// src/context-logger.ts
|
|
3696
3833
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3697
3834
|
|
|
3698
|
-
// ../../node_modules/.bun/evlog@2.
|
|
3835
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/elysia/index.mjs
|
|
3699
3836
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3700
3837
|
import { Elysia } from "elysia";
|
|
3701
3838
|
var storage = new AsyncLocalStorage;
|
|
@@ -3738,33 +3875,139 @@ async function runInSyntheticRenderScope(fn, initialContext) {
|
|
|
3738
3875
|
}
|
|
3739
3876
|
}
|
|
3740
3877
|
|
|
3741
|
-
// src/render/cache.ts
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
function
|
|
3746
|
-
if (
|
|
3747
|
-
|
|
3878
|
+
// src/render/route-cache.ts
|
|
3879
|
+
function defaultPathFromKey(key) {
|
|
3880
|
+
return key;
|
|
3881
|
+
}
|
|
3882
|
+
function matchesPath(urlPath, path, type) {
|
|
3883
|
+
if (type === "page") {
|
|
3884
|
+
return urlPath === path;
|
|
3885
|
+
}
|
|
3886
|
+
const prefix = path === "/" || path.endsWith("/") ? path : `${path}/`;
|
|
3887
|
+
return urlPath === path || urlPath.startsWith(prefix);
|
|
3888
|
+
}
|
|
3889
|
+
function createRouteCache(options) {
|
|
3890
|
+
const store = new Map;
|
|
3891
|
+
const pathFromKey = options.pathFromKey ?? defaultPathFromKey;
|
|
3892
|
+
const evictOldest = () => {
|
|
3893
|
+
if (options.maxSize === undefined || store.size <= options.maxSize) {
|
|
3894
|
+
return;
|
|
3895
|
+
}
|
|
3896
|
+
const oldest = store.keys().next().value;
|
|
3748
3897
|
if (oldest !== undefined) {
|
|
3749
|
-
|
|
3898
|
+
deleteEntry(oldest);
|
|
3750
3899
|
}
|
|
3751
|
-
}
|
|
3900
|
+
};
|
|
3901
|
+
const deleteEntry = (key) => {
|
|
3902
|
+
const entry = store.get(key);
|
|
3903
|
+
if (entry === undefined) {
|
|
3904
|
+
return false;
|
|
3905
|
+
}
|
|
3906
|
+
store.delete(key);
|
|
3907
|
+
options.onDelete?.(key, entry);
|
|
3908
|
+
return true;
|
|
3909
|
+
};
|
|
3910
|
+
return {
|
|
3911
|
+
name: options.name,
|
|
3912
|
+
store,
|
|
3913
|
+
get size() {
|
|
3914
|
+
return store.size;
|
|
3915
|
+
},
|
|
3916
|
+
get(key) {
|
|
3917
|
+
const entry = store.get(key);
|
|
3918
|
+
if (entry !== undefined && options.maxSize !== undefined) {
|
|
3919
|
+
store.delete(key);
|
|
3920
|
+
store.set(key, entry);
|
|
3921
|
+
}
|
|
3922
|
+
return entry;
|
|
3923
|
+
},
|
|
3924
|
+
set(key, entry) {
|
|
3925
|
+
const previous = store.get(key);
|
|
3926
|
+
if (previous !== undefined) {
|
|
3927
|
+
store.delete(key);
|
|
3928
|
+
}
|
|
3929
|
+
store.set(key, entry);
|
|
3930
|
+
options.onSet?.(key, entry, previous);
|
|
3931
|
+
evictOldest();
|
|
3932
|
+
},
|
|
3933
|
+
delete(key) {
|
|
3934
|
+
return deleteEntry(key);
|
|
3935
|
+
},
|
|
3936
|
+
clear() {
|
|
3937
|
+
for (const key of [...store.keys()]) {
|
|
3938
|
+
deleteEntry(key);
|
|
3939
|
+
}
|
|
3940
|
+
store.clear();
|
|
3941
|
+
},
|
|
3942
|
+
has(key) {
|
|
3943
|
+
return store.has(key);
|
|
3944
|
+
},
|
|
3945
|
+
entries() {
|
|
3946
|
+
return store.entries();
|
|
3947
|
+
},
|
|
3948
|
+
keys() {
|
|
3949
|
+
return store.keys();
|
|
3950
|
+
},
|
|
3951
|
+
invalidatePath(path, type) {
|
|
3952
|
+
let deleted = false;
|
|
3953
|
+
const purgedPaths = [];
|
|
3954
|
+
for (const key of [...store.keys()]) {
|
|
3955
|
+
const urlPath = pathFromKey(key);
|
|
3956
|
+
if (urlPath === null || !matchesPath(urlPath, path, type)) {
|
|
3957
|
+
continue;
|
|
3958
|
+
}
|
|
3959
|
+
deleteEntry(key);
|
|
3960
|
+
deleted = true;
|
|
3961
|
+
purgedPaths.push(urlPath);
|
|
3962
|
+
}
|
|
3963
|
+
return { deleted, purgedPaths: [...new Set(purgedPaths)] };
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3752
3966
|
}
|
|
3967
|
+
|
|
3968
|
+
// src/render/cache.ts
|
|
3969
|
+
var MAX_ISR_CACHE_SIZE = 1000;
|
|
3970
|
+
var MAX_SSG_CACHE_SIZE = 1000;
|
|
3971
|
+
var isrRouteCache = createRouteCache({
|
|
3972
|
+
maxSize: MAX_ISR_CACHE_SIZE,
|
|
3973
|
+
name: "render:isr-html"
|
|
3974
|
+
});
|
|
3975
|
+
var ssgRouteCache = createRouteCache({
|
|
3976
|
+
maxSize: MAX_SSG_CACHE_SIZE,
|
|
3977
|
+
name: "render:ssg-html"
|
|
3978
|
+
});
|
|
3979
|
+
var isrCache = isrRouteCache.store;
|
|
3980
|
+
var ssgCache = ssgRouteCache.store;
|
|
3753
3981
|
function getSSGCache(key) {
|
|
3754
|
-
|
|
3755
|
-
if (entry !== undefined) {
|
|
3756
|
-
ssgCache.delete(key);
|
|
3757
|
-
ssgCache.set(key, entry);
|
|
3758
|
-
}
|
|
3759
|
-
return entry;
|
|
3982
|
+
return ssgRouteCache.get(key);
|
|
3760
3983
|
}
|
|
3761
3984
|
function setSSGCache(key, entry) {
|
|
3762
|
-
|
|
3763
|
-
ssgCache.set(key, entry);
|
|
3764
|
-
evictOldest(ssgCache, MAX_SSG_CACHE_SIZE);
|
|
3985
|
+
ssgRouteCache.set(key, entry);
|
|
3765
3986
|
}
|
|
3766
3987
|
var _requestInvalidationScope = new AsyncLocalStorage3;
|
|
3767
3988
|
var _globalPendingInvalidations = new Set;
|
|
3989
|
+
var _cacheInvalidators = new Map;
|
|
3990
|
+
function registerCacheInvalidator(invalidator) {
|
|
3991
|
+
const existing = _cacheInvalidators.get(invalidator.name);
|
|
3992
|
+
if (existing !== undefined && existing !== invalidator) {
|
|
3993
|
+
throw new Error(`Cache invalidator "${invalidator.name}" is already registered with a different instance.`);
|
|
3994
|
+
}
|
|
3995
|
+
if (existing === invalidator) {
|
|
3996
|
+
return () => {
|
|
3997
|
+
if (_cacheInvalidators.get(invalidator.name) === invalidator) {
|
|
3998
|
+
_cacheInvalidators.delete(invalidator.name);
|
|
3999
|
+
}
|
|
4000
|
+
};
|
|
4001
|
+
}
|
|
4002
|
+
_cacheInvalidators.set(invalidator.name, invalidator);
|
|
4003
|
+
return () => {
|
|
4004
|
+
if (_cacheInvalidators.get(invalidator.name) === invalidator) {
|
|
4005
|
+
_cacheInvalidators.delete(invalidator.name);
|
|
4006
|
+
}
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
registerCacheInvalidator(isrRouteCache);
|
|
4010
|
+
registerCacheInvalidator(ssgRouteCache);
|
|
3768
4011
|
|
|
3769
4012
|
// src/render/element.tsx
|
|
3770
4013
|
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
@@ -3954,11 +4197,11 @@ var IS_DEV = true;
|
|
|
3954
4197
|
|
|
3955
4198
|
// src/render/index.ts
|
|
3956
4199
|
function withSSRRouterContext(element, contextValue) {
|
|
3957
|
-
return
|
|
4200
|
+
return createElement3(RouterContext.Provider, { value: contextValue }, element);
|
|
3958
4201
|
}
|
|
3959
|
-
async function prepareRender(route, ctx, root, basePath, throwOnFailure) {
|
|
4202
|
+
async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomputedLoaderResult) {
|
|
3960
4203
|
const loaderStart = Date.now();
|
|
3961
|
-
const loaderResult = await runLoaders(route, ctx, root.route);
|
|
4204
|
+
const loaderResult = precomputedLoaderResult ?? await runLoaders(route, ctx, root.route);
|
|
3962
4205
|
const loader_ms = Date.now() - loaderStart;
|
|
3963
4206
|
if (loaderResult.type === "redirect") {
|
|
3964
4207
|
return loaderResult.response;
|
|
@@ -4034,7 +4277,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
4034
4277
|
set: { headers: {} },
|
|
4035
4278
|
path: resolvedPath
|
|
4036
4279
|
};
|
|
4037
|
-
const prepared = await prepareRender(route, ctx, root, basePath, true);
|
|
4280
|
+
const prepared = await prepareRender(route, ctx, root, basePath, true, undefined);
|
|
4038
4281
|
if (prepared instanceof Response) {
|
|
4039
4282
|
return prepared;
|
|
4040
4283
|
}
|
|
@@ -4061,7 +4304,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
4061
4304
|
async function prerenderSSG(route, params, root, origin, basePath) {
|
|
4062
4305
|
const resolvedPath = resolvePath(route.pattern, params);
|
|
4063
4306
|
const cached = getSSGCache(resolvedPath);
|
|
4064
|
-
if (cached
|
|
4307
|
+
if (cached) {
|
|
4065
4308
|
return cached;
|
|
4066
4309
|
}
|
|
4067
4310
|
const renderResult = await renderForPath(route, params, root, origin, "ssg", basePath);
|
|
@@ -4070,9 +4313,7 @@ async function prerenderSSG(route, params, root, origin, basePath) {
|
|
|
4070
4313
|
}
|
|
4071
4314
|
const result = renderResult;
|
|
4072
4315
|
const entry = { html: result.html, cachedAt: Date.now(), status: result.status };
|
|
4073
|
-
|
|
4074
|
-
setSSGCache(resolvedPath, entry);
|
|
4075
|
-
}
|
|
4316
|
+
setSSGCache(resolvedPath, entry);
|
|
4076
4317
|
return entry;
|
|
4077
4318
|
}
|
|
4078
4319
|
var pendingRevalidations = new Set;
|
|
@@ -4274,6 +4515,57 @@ function getCompileContext() {
|
|
|
4274
4515
|
return _compileCtx;
|
|
4275
4516
|
}
|
|
4276
4517
|
|
|
4518
|
+
// src/render/dev-cache.ts
|
|
4519
|
+
var sourceFileToCacheKeys = new Map;
|
|
4520
|
+
function indexEntryDependencies(cacheKey, deps) {
|
|
4521
|
+
for (const dep of deps) {
|
|
4522
|
+
let bucket = sourceFileToCacheKeys.get(dep);
|
|
4523
|
+
if (!bucket) {
|
|
4524
|
+
bucket = new Set;
|
|
4525
|
+
sourceFileToCacheKeys.set(dep, bucket);
|
|
4526
|
+
}
|
|
4527
|
+
bucket.add(cacheKey);
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
function unindexEntryDependencies(cacheKey, deps) {
|
|
4531
|
+
for (const dep of deps) {
|
|
4532
|
+
const bucket = sourceFileToCacheKeys.get(dep);
|
|
4533
|
+
if (!bucket) {
|
|
4534
|
+
continue;
|
|
4535
|
+
}
|
|
4536
|
+
bucket.delete(cacheKey);
|
|
4537
|
+
if (bucket.size === 0) {
|
|
4538
|
+
sourceFileToCacheKeys.delete(dep);
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
function createDevLoaderCache(name) {
|
|
4543
|
+
return createRouteCache({
|
|
4544
|
+
name,
|
|
4545
|
+
onDelete: (key, entry) => {
|
|
4546
|
+
unindexEntryDependencies(key, entry.dependencies);
|
|
4547
|
+
},
|
|
4548
|
+
onSet: (key, entry, previous) => {
|
|
4549
|
+
if (previous) {
|
|
4550
|
+
unindexEntryDependencies(key, previous.dependencies);
|
|
4551
|
+
}
|
|
4552
|
+
indexEntryDependencies(key, entry.dependencies);
|
|
4553
|
+
},
|
|
4554
|
+
pathFromKey: urlPathFromCacheKey
|
|
4555
|
+
});
|
|
4556
|
+
}
|
|
4557
|
+
var devISRLoaderCache = createDevLoaderCache("render:dev-isr-loader");
|
|
4558
|
+
var devSSGLoaderCache = createDevLoaderCache("render:dev-ssg-loader");
|
|
4559
|
+
function urlPathFromCacheKey(key) {
|
|
4560
|
+
const sep2 = key.lastIndexOf(":/");
|
|
4561
|
+
if (sep2 === -1) {
|
|
4562
|
+
return null;
|
|
4563
|
+
}
|
|
4564
|
+
return key.slice(sep2 + 1);
|
|
4565
|
+
}
|
|
4566
|
+
registerCacheInvalidator(devISRLoaderCache);
|
|
4567
|
+
registerCacheInvalidator(devSSGLoaderCache);
|
|
4568
|
+
|
|
4277
4569
|
// src/utils.ts
|
|
4278
4570
|
function isFurinPage(value) {
|
|
4279
4571
|
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_PAGE";
|
|
@@ -4347,13 +4639,16 @@ async function scanRootLayout(pagesDir) {
|
|
|
4347
4639
|
};
|
|
4348
4640
|
}
|
|
4349
4641
|
var CONVENTION_FILE_NAMES = ["not-found", "error"];
|
|
4642
|
+
var SOURCE_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
4350
4643
|
function isConventionFileName(name) {
|
|
4351
4644
|
return CONVENTION_FILE_NAMES.includes(name);
|
|
4352
4645
|
}
|
|
4646
|
+
function getSourceModuleCandidates(dir, name) {
|
|
4647
|
+
return SOURCE_MODULE_EXTENSIONS.map((ext) => `${dir}/${name}${ext}`);
|
|
4648
|
+
}
|
|
4353
4649
|
async function loadConventionComponent(dir, name) {
|
|
4354
4650
|
const ctx = getCompileContext();
|
|
4355
|
-
for (const
|
|
4356
|
-
const filePath = `${dir}/${name}${ext}`;
|
|
4651
|
+
for (const filePath of getSourceModuleCandidates(dir, name)) {
|
|
4357
4652
|
if (existsSync8(filePath) || ctx?.modules[filePath]) {
|
|
4358
4653
|
const mod = ctx?.modules[filePath] ?? await import(filePath);
|
|
4359
4654
|
if (mod.default) {
|
|
@@ -4368,7 +4663,7 @@ async function scanPageFiles(pagesDir, root) {
|
|
|
4368
4663
|
const notFoundCache = new Map;
|
|
4369
4664
|
const errorCache = new Map;
|
|
4370
4665
|
for (const absolutePath of await collectPageFilePaths(pagesDir)) {
|
|
4371
|
-
if (!
|
|
4666
|
+
if (!SOURCE_MODULE_EXTENSIONS.some((ext) => absolutePath.endsWith(ext))) {
|
|
4372
4667
|
continue;
|
|
4373
4668
|
}
|
|
4374
4669
|
const relativePath = absolutePath.replace(`${pagesDir}/`, "");
|