@teyik0/furin 0.1.0-alpha.10 → 0.1.0-alpha.11
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 +141 -23
- package/dist/cli/index.js +141 -23
- package/dist/dev-inspector.d.ts +89 -0
- package/dist/furin.js +444 -86
- package/dist/link.js +84 -10
- package/dist/render/dev-cache.d.ts +91 -0
- package/dist/render/index.d.ts +2 -1
- package/dist/router.d.ts +14 -0
- package/dist/router.js +346 -57
- package/package.json +4 -4
- package/src/dev-inspector.ts +60 -0
- package/src/dev-page-plugin.ts +7 -0
- package/src/env.d.ts +1 -0
- package/src/furin.ts +3 -0
- package/src/render/dev-cache.ts +223 -0
- package/src/render/index.ts +20 -18
- package/src/router.ts +299 -44
package/dist/build/index.js
CHANGED
|
@@ -2257,14 +2257,21 @@ function assembleHTML(template, headData, reactHtml, data) {
|
|
|
2257
2257
|
// src/render/index.ts
|
|
2258
2258
|
import { createElement as createElement2 } from "react";
|
|
2259
2259
|
import { renderToReadableStream } from "react-dom/server";
|
|
2260
|
-
|
|
2260
|
+
|
|
2261
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/utils.mjs
|
|
2261
2262
|
function formatDuration(ms) {
|
|
2262
2263
|
if (ms < 1000)
|
|
2263
2264
|
return `${Math.round(ms)}ms`;
|
|
2264
2265
|
return `${(ms / 1000).toFixed(2)}s`;
|
|
2265
2266
|
}
|
|
2266
|
-
function
|
|
2267
|
-
|
|
2267
|
+
function isBrowser() {
|
|
2268
|
+
if (typeof window === "undefined")
|
|
2269
|
+
return false;
|
|
2270
|
+
if (typeof document === "undefined")
|
|
2271
|
+
return false;
|
|
2272
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative")
|
|
2273
|
+
return false;
|
|
2274
|
+
return true;
|
|
2268
2275
|
}
|
|
2269
2276
|
function isDev() {
|
|
2270
2277
|
if (typeof process !== "undefined")
|
|
@@ -2350,7 +2357,7 @@ function matchesPattern(path, pattern) {
|
|
|
2350
2357
|
return regex.test(path);
|
|
2351
2358
|
}
|
|
2352
2359
|
|
|
2353
|
-
// ../../node_modules/.bun/evlog@2.
|
|
2360
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/audit-DQoBo7Dl.mjs
|
|
2354
2361
|
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
2355
2362
|
var builtinPatterns = {
|
|
2356
2363
|
creditCard: {
|
|
@@ -2371,7 +2378,7 @@ var builtinPatterns = {
|
|
|
2371
2378
|
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
2372
2379
|
},
|
|
2373
2380
|
phone: {
|
|
2374
|
-
pattern: /(?:\+\d{1,3}[\s.-]
|
|
2381
|
+
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
2375
2382
|
mask: (m) => {
|
|
2376
2383
|
const digits = m.replace(/[^\d]/g, "");
|
|
2377
2384
|
if (m.startsWith("+") && digits.length > 4) {
|
|
@@ -2584,7 +2591,8 @@ function shouldKeep(ctx) {
|
|
|
2584
2591
|
return false;
|
|
2585
2592
|
});
|
|
2586
2593
|
}
|
|
2587
|
-
function emitWideEvent(level, event,
|
|
2594
|
+
function emitWideEvent(level, event, options = {}) {
|
|
2595
|
+
const { deferDrain = false, ownsEvent = false, waitUntil } = options;
|
|
2588
2596
|
if (!globalEnabled)
|
|
2589
2597
|
return null;
|
|
2590
2598
|
if (!ownsEvent) {
|
|
@@ -2615,6 +2623,7 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2615
2623
|
...globalEnv,
|
|
2616
2624
|
...event
|
|
2617
2625
|
};
|
|
2626
|
+
finalizeAudit(formatted);
|
|
2618
2627
|
if (globalRedact)
|
|
2619
2628
|
redactEvent(formatted, globalRedact);
|
|
2620
2629
|
if (!globalSilent)
|
|
@@ -2624,10 +2633,13 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2624
2633
|
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
2625
2634
|
else
|
|
2626
2635
|
console[getConsoleMethod(level)](formatted);
|
|
2627
|
-
if (globalDrain && !deferDrain)
|
|
2628
|
-
Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2636
|
+
if (globalDrain && !deferDrain) {
|
|
2637
|
+
const drainPromise = Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2629
2638
|
console.error("[evlog] drain failed:", err);
|
|
2630
2639
|
});
|
|
2640
|
+
if (waitUntil)
|
|
2641
|
+
waitUntil(drainPromise);
|
|
2642
|
+
}
|
|
2631
2643
|
return formatted;
|
|
2632
2644
|
}
|
|
2633
2645
|
function emitTaggedLog(level, tag, message) {
|
|
@@ -2638,7 +2650,7 @@ function emitTaggedLog(level, tag, message) {
|
|
|
2638
2650
|
return;
|
|
2639
2651
|
if (!shouldSample(level))
|
|
2640
2652
|
return;
|
|
2641
|
-
if (
|
|
2653
|
+
if (isBrowser()) {
|
|
2642
2654
|
const levelColor = getCssLevelColor(level);
|
|
2643
2655
|
const timestamp = isoNow().slice(11, 23);
|
|
2644
2656
|
console.log(`%c${timestamp}%c %c[${escapeFormatString(tag)}]%c ${escapeFormatString(message)}`, cssColors.dim, cssColors.reset, levelColor, cssColors.reset);
|
|
@@ -2835,7 +2847,7 @@ function buildAIEntries(ai) {
|
|
|
2835
2847
|
function prettyPrintWideEvent(event) {
|
|
2836
2848
|
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
2837
2849
|
const ts = timestamp.slice(11, 23);
|
|
2838
|
-
const browser =
|
|
2850
|
+
const browser = isBrowser();
|
|
2839
2851
|
const parts = [];
|
|
2840
2852
|
const styles = [];
|
|
2841
2853
|
if (browser) {
|
|
@@ -2928,12 +2940,14 @@ var noopLogger = {
|
|
|
2928
2940
|
},
|
|
2929
2941
|
getContext() {
|
|
2930
2942
|
return {};
|
|
2931
|
-
}
|
|
2943
|
+
},
|
|
2944
|
+
audit: Object.assign(() => {}, { deny: () => {} })
|
|
2932
2945
|
};
|
|
2933
2946
|
function createLogger(initialContext = {}, internalOptions) {
|
|
2934
2947
|
if (!globalEnabled)
|
|
2935
2948
|
return noopLogger;
|
|
2936
2949
|
const deferDrain = internalOptions?._deferDrain ?? false;
|
|
2950
|
+
const waitUntil = internalOptions?.waitUntil;
|
|
2937
2951
|
const startTime = Date.now();
|
|
2938
2952
|
const context = { ...initialContext };
|
|
2939
2953
|
let hasError = false;
|
|
@@ -2948,7 +2962,27 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2948
2962
|
timestamp: isoNow()
|
|
2949
2963
|
});
|
|
2950
2964
|
}
|
|
2965
|
+
const auditMethod = function audit(input) {
|
|
2966
|
+
if (emitted) {
|
|
2967
|
+
warnPostEmit("log.audit()", `Audit dropped: action=${input.action}.`);
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
const fields = buildAuditFields(input);
|
|
2971
|
+
if (!isPlainObject(context.audit))
|
|
2972
|
+
context.audit = fields;
|
|
2973
|
+
else
|
|
2974
|
+
mergeInto(context.audit, fields);
|
|
2975
|
+
context._auditForceKeep = true;
|
|
2976
|
+
};
|
|
2977
|
+
auditMethod.deny = function deny(reason, input) {
|
|
2978
|
+
auditMethod({
|
|
2979
|
+
...input,
|
|
2980
|
+
outcome: "denied",
|
|
2981
|
+
reason
|
|
2982
|
+
});
|
|
2983
|
+
};
|
|
2951
2984
|
return {
|
|
2985
|
+
audit: auditMethod,
|
|
2952
2986
|
set(data) {
|
|
2953
2987
|
if (emitted) {
|
|
2954
2988
|
const keys = Object.keys(data);
|
|
@@ -3021,6 +3055,8 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3021
3055
|
let forceKeep = false;
|
|
3022
3056
|
if (overrides?._forceKeep)
|
|
3023
3057
|
forceKeep = true;
|
|
3058
|
+
else if (consumeAuditForceKeep(context))
|
|
3059
|
+
forceKeep = true;
|
|
3024
3060
|
else if (globalSampling.keep?.length)
|
|
3025
3061
|
forceKeep = shouldKeep({
|
|
3026
3062
|
status: overrides?.status ?? context.status,
|
|
@@ -3040,7 +3076,11 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3040
3076
|
context[key] = obj[key];
|
|
3041
3077
|
}
|
|
3042
3078
|
context.duration = formatDuration(durationMs);
|
|
3043
|
-
const wide = emitWideEvent(level, context,
|
|
3079
|
+
const wide = emitWideEvent(level, context, {
|
|
3080
|
+
deferDrain,
|
|
3081
|
+
ownsEvent: true,
|
|
3082
|
+
waitUntil
|
|
3083
|
+
});
|
|
3044
3084
|
emitted = true;
|
|
3045
3085
|
return wide;
|
|
3046
3086
|
},
|
|
@@ -3051,6 +3091,78 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
3051
3091
|
}
|
|
3052
3092
|
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
3053
3093
|
initLogger(__EVLOG_CONFIG__);
|
|
3094
|
+
function stableStringify(value) {
|
|
3095
|
+
if (value === null || typeof value !== "object")
|
|
3096
|
+
return JSON.stringify(value);
|
|
3097
|
+
if (Array.isArray(value))
|
|
3098
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
3099
|
+
return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`).join(",")}}`;
|
|
3100
|
+
}
|
|
3101
|
+
function fnv1a32(input, seed) {
|
|
3102
|
+
let h = seed >>> 0;
|
|
3103
|
+
for (let i = 0;i < input.length; i++) {
|
|
3104
|
+
h ^= input.charCodeAt(i) & 255;
|
|
3105
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
3106
|
+
}
|
|
3107
|
+
return h >>> 0;
|
|
3108
|
+
}
|
|
3109
|
+
function computeIdempotencyKey(audit, timestamp) {
|
|
3110
|
+
const seconds = timestamp.slice(0, 19);
|
|
3111
|
+
const payload = stableStringify({
|
|
3112
|
+
action: audit.action,
|
|
3113
|
+
actor: {
|
|
3114
|
+
type: audit.actor.type,
|
|
3115
|
+
id: audit.actor.id
|
|
3116
|
+
},
|
|
3117
|
+
target: audit.target ? {
|
|
3118
|
+
type: audit.target.type,
|
|
3119
|
+
id: audit.target.id
|
|
3120
|
+
} : undefined,
|
|
3121
|
+
outcome: audit.outcome,
|
|
3122
|
+
timestamp: seconds
|
|
3123
|
+
});
|
|
3124
|
+
const a = fnv1a32(payload, 2166136261).toString(16).padStart(8, "0");
|
|
3125
|
+
const b = fnv1a32(payload, 3735928559).toString(16).padStart(8, "0");
|
|
3126
|
+
const c = fnv1a32(payload, 528734635).toString(16).padStart(8, "0");
|
|
3127
|
+
const d = fnv1a32(payload, 1541459225).toString(16).padStart(8, "0");
|
|
3128
|
+
return a + b + c + d;
|
|
3129
|
+
}
|
|
3130
|
+
function buildAuditFields(input) {
|
|
3131
|
+
return {
|
|
3132
|
+
action: input.action,
|
|
3133
|
+
actor: input.actor,
|
|
3134
|
+
target: input.target,
|
|
3135
|
+
outcome: input.outcome ?? "success",
|
|
3136
|
+
reason: input.reason,
|
|
3137
|
+
changes: input.changes,
|
|
3138
|
+
causationId: input.causationId,
|
|
3139
|
+
correlationId: input.correlationId,
|
|
3140
|
+
version: input.version ?? 1
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
function decorateAudit(audit, timestamp) {
|
|
3144
|
+
if (audit.idempotencyKey)
|
|
3145
|
+
return audit;
|
|
3146
|
+
return {
|
|
3147
|
+
...audit,
|
|
3148
|
+
idempotencyKey: computeIdempotencyKey(audit, timestamp)
|
|
3149
|
+
};
|
|
3150
|
+
}
|
|
3151
|
+
function consumeAuditForceKeep(context) {
|
|
3152
|
+
if (context._auditForceKeep) {
|
|
3153
|
+
delete context._auditForceKeep;
|
|
3154
|
+
return true;
|
|
3155
|
+
}
|
|
3156
|
+
if (context.audit)
|
|
3157
|
+
return true;
|
|
3158
|
+
return false;
|
|
3159
|
+
}
|
|
3160
|
+
function finalizeAudit(event) {
|
|
3161
|
+
const a = event.audit;
|
|
3162
|
+
if (!a)
|
|
3163
|
+
return;
|
|
3164
|
+
event.audit = decorateAudit(a, String(event.timestamp));
|
|
3165
|
+
}
|
|
3054
3166
|
// src/link.tsx
|
|
3055
3167
|
import {
|
|
3056
3168
|
createContext,
|
|
@@ -3695,7 +3807,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
3695
3807
|
// src/context-logger.ts
|
|
3696
3808
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3697
3809
|
|
|
3698
|
-
// ../../node_modules/.bun/evlog@2.
|
|
3810
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/elysia/index.mjs
|
|
3699
3811
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3700
3812
|
import { Elysia } from "elysia";
|
|
3701
3813
|
var storage = new AsyncLocalStorage;
|
|
@@ -3956,9 +4068,9 @@ var IS_DEV = true;
|
|
|
3956
4068
|
function withSSRRouterContext(element, contextValue) {
|
|
3957
4069
|
return createElement2(RouterContext.Provider, { value: contextValue }, element);
|
|
3958
4070
|
}
|
|
3959
|
-
async function prepareRender(route, ctx, root, basePath, throwOnFailure) {
|
|
4071
|
+
async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomputedLoaderResult) {
|
|
3960
4072
|
const loaderStart = Date.now();
|
|
3961
|
-
const loaderResult = await runLoaders(route, ctx, root.route);
|
|
4073
|
+
const loaderResult = precomputedLoaderResult ?? await runLoaders(route, ctx, root.route);
|
|
3962
4074
|
const loader_ms = Date.now() - loaderStart;
|
|
3963
4075
|
if (loaderResult.type === "redirect") {
|
|
3964
4076
|
return loaderResult.response;
|
|
@@ -4034,7 +4146,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
4034
4146
|
set: { headers: {} },
|
|
4035
4147
|
path: resolvedPath
|
|
4036
4148
|
};
|
|
4037
|
-
const prepared = await prepareRender(route, ctx, root, basePath, true);
|
|
4149
|
+
const prepared = await prepareRender(route, ctx, root, basePath, true, undefined);
|
|
4038
4150
|
if (prepared instanceof Response) {
|
|
4039
4151
|
return prepared;
|
|
4040
4152
|
}
|
|
@@ -4061,7 +4173,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
4061
4173
|
async function prerenderSSG(route, params, root, origin, basePath) {
|
|
4062
4174
|
const resolvedPath = resolvePath(route.pattern, params);
|
|
4063
4175
|
const cached = getSSGCache(resolvedPath);
|
|
4064
|
-
if (cached
|
|
4176
|
+
if (cached) {
|
|
4065
4177
|
return cached;
|
|
4066
4178
|
}
|
|
4067
4179
|
const renderResult = await renderForPath(route, params, root, origin, "ssg", basePath);
|
|
@@ -4070,9 +4182,7 @@ async function prerenderSSG(route, params, root, origin, basePath) {
|
|
|
4070
4182
|
}
|
|
4071
4183
|
const result = renderResult;
|
|
4072
4184
|
const entry = { html: result.html, cachedAt: Date.now(), status: result.status };
|
|
4073
|
-
|
|
4074
|
-
setSSGCache(resolvedPath, entry);
|
|
4075
|
-
}
|
|
4185
|
+
setSSGCache(resolvedPath, entry);
|
|
4076
4186
|
return entry;
|
|
4077
4187
|
}
|
|
4078
4188
|
var pendingRevalidations = new Set;
|
|
@@ -4274,6 +4384,11 @@ function getCompileContext() {
|
|
|
4274
4384
|
return _compileCtx;
|
|
4275
4385
|
}
|
|
4276
4386
|
|
|
4387
|
+
// src/render/dev-cache.ts
|
|
4388
|
+
var devISRLoaderCache = new Map;
|
|
4389
|
+
var devSSGLoaderCache = new Map;
|
|
4390
|
+
var sourceFileToCacheKeys = new Map;
|
|
4391
|
+
|
|
4277
4392
|
// src/utils.ts
|
|
4278
4393
|
function isFurinPage(value) {
|
|
4279
4394
|
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_PAGE";
|
|
@@ -4347,13 +4462,16 @@ async function scanRootLayout(pagesDir) {
|
|
|
4347
4462
|
};
|
|
4348
4463
|
}
|
|
4349
4464
|
var CONVENTION_FILE_NAMES = ["not-found", "error"];
|
|
4465
|
+
var SOURCE_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
4350
4466
|
function isConventionFileName(name) {
|
|
4351
4467
|
return CONVENTION_FILE_NAMES.includes(name);
|
|
4352
4468
|
}
|
|
4469
|
+
function getSourceModuleCandidates(dir, name) {
|
|
4470
|
+
return SOURCE_MODULE_EXTENSIONS.map((ext) => `${dir}/${name}${ext}`);
|
|
4471
|
+
}
|
|
4353
4472
|
async function loadConventionComponent(dir, name) {
|
|
4354
4473
|
const ctx = getCompileContext();
|
|
4355
|
-
for (const
|
|
4356
|
-
const filePath = `${dir}/${name}${ext}`;
|
|
4474
|
+
for (const filePath of getSourceModuleCandidates(dir, name)) {
|
|
4357
4475
|
if (existsSync8(filePath) || ctx?.modules[filePath]) {
|
|
4358
4476
|
const mod = ctx?.modules[filePath] ?? await import(filePath);
|
|
4359
4477
|
if (mod.default) {
|
|
@@ -4368,7 +4486,7 @@ async function scanPageFiles(pagesDir, root) {
|
|
|
4368
4486
|
const notFoundCache = new Map;
|
|
4369
4487
|
const errorCache = new Map;
|
|
4370
4488
|
for (const absolutePath of await collectPageFilePaths(pagesDir)) {
|
|
4371
|
-
if (!
|
|
4489
|
+
if (!SOURCE_MODULE_EXTENSIONS.some((ext) => absolutePath.endsWith(ext))) {
|
|
4372
4490
|
continue;
|
|
4373
4491
|
}
|
|
4374
4492
|
const relativePath = absolutePath.replace(`${pagesDir}/`, "");
|
package/dist/cli/index.js
CHANGED
|
@@ -2177,14 +2177,21 @@ function assembleHTML(template, headData, reactHtml, data) {
|
|
|
2177
2177
|
// src/render/index.ts
|
|
2178
2178
|
import { createElement as createElement2 } from "react";
|
|
2179
2179
|
import { renderToReadableStream } from "react-dom/server";
|
|
2180
|
-
|
|
2180
|
+
|
|
2181
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/utils.mjs
|
|
2181
2182
|
function formatDuration(ms) {
|
|
2182
2183
|
if (ms < 1000)
|
|
2183
2184
|
return `${Math.round(ms)}ms`;
|
|
2184
2185
|
return `${(ms / 1000).toFixed(2)}s`;
|
|
2185
2186
|
}
|
|
2186
|
-
function
|
|
2187
|
-
|
|
2187
|
+
function isBrowser() {
|
|
2188
|
+
if (typeof window === "undefined")
|
|
2189
|
+
return false;
|
|
2190
|
+
if (typeof document === "undefined")
|
|
2191
|
+
return false;
|
|
2192
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative")
|
|
2193
|
+
return false;
|
|
2194
|
+
return true;
|
|
2188
2195
|
}
|
|
2189
2196
|
function isDev() {
|
|
2190
2197
|
if (typeof process !== "undefined")
|
|
@@ -2270,7 +2277,7 @@ function matchesPattern(path, pattern) {
|
|
|
2270
2277
|
return regex.test(path);
|
|
2271
2278
|
}
|
|
2272
2279
|
|
|
2273
|
-
// ../../node_modules/.bun/evlog@2.
|
|
2280
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/audit-DQoBo7Dl.mjs
|
|
2274
2281
|
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
2275
2282
|
var builtinPatterns = {
|
|
2276
2283
|
creditCard: {
|
|
@@ -2291,7 +2298,7 @@ var builtinPatterns = {
|
|
|
2291
2298
|
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
2292
2299
|
},
|
|
2293
2300
|
phone: {
|
|
2294
|
-
pattern: /(?:\+\d{1,3}[\s.-]
|
|
2301
|
+
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
2295
2302
|
mask: (m) => {
|
|
2296
2303
|
const digits = m.replace(/[^\d]/g, "");
|
|
2297
2304
|
if (m.startsWith("+") && digits.length > 4) {
|
|
@@ -2504,7 +2511,8 @@ function shouldKeep(ctx) {
|
|
|
2504
2511
|
return false;
|
|
2505
2512
|
});
|
|
2506
2513
|
}
|
|
2507
|
-
function emitWideEvent(level, event,
|
|
2514
|
+
function emitWideEvent(level, event, options = {}) {
|
|
2515
|
+
const { deferDrain = false, ownsEvent = false, waitUntil } = options;
|
|
2508
2516
|
if (!globalEnabled)
|
|
2509
2517
|
return null;
|
|
2510
2518
|
if (!ownsEvent) {
|
|
@@ -2535,6 +2543,7 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2535
2543
|
...globalEnv,
|
|
2536
2544
|
...event
|
|
2537
2545
|
};
|
|
2546
|
+
finalizeAudit(formatted);
|
|
2538
2547
|
if (globalRedact)
|
|
2539
2548
|
redactEvent(formatted, globalRedact);
|
|
2540
2549
|
if (!globalSilent)
|
|
@@ -2544,10 +2553,13 @@ function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
|
2544
2553
|
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
2545
2554
|
else
|
|
2546
2555
|
console[getConsoleMethod(level)](formatted);
|
|
2547
|
-
if (globalDrain && !deferDrain)
|
|
2548
|
-
Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2556
|
+
if (globalDrain && !deferDrain) {
|
|
2557
|
+
const drainPromise = Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
2549
2558
|
console.error("[evlog] drain failed:", err);
|
|
2550
2559
|
});
|
|
2560
|
+
if (waitUntil)
|
|
2561
|
+
waitUntil(drainPromise);
|
|
2562
|
+
}
|
|
2551
2563
|
return formatted;
|
|
2552
2564
|
}
|
|
2553
2565
|
function emitTaggedLog(level, tag, message) {
|
|
@@ -2558,7 +2570,7 @@ function emitTaggedLog(level, tag, message) {
|
|
|
2558
2570
|
return;
|
|
2559
2571
|
if (!shouldSample(level))
|
|
2560
2572
|
return;
|
|
2561
|
-
if (
|
|
2573
|
+
if (isBrowser()) {
|
|
2562
2574
|
const levelColor = getCssLevelColor(level);
|
|
2563
2575
|
const timestamp = isoNow().slice(11, 23);
|
|
2564
2576
|
console.log(`%c${timestamp}%c %c[${escapeFormatString(tag)}]%c ${escapeFormatString(message)}`, cssColors.dim, cssColors.reset, levelColor, cssColors.reset);
|
|
@@ -2755,7 +2767,7 @@ function buildAIEntries(ai) {
|
|
|
2755
2767
|
function prettyPrintWideEvent(event) {
|
|
2756
2768
|
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
2757
2769
|
const ts = timestamp.slice(11, 23);
|
|
2758
|
-
const browser =
|
|
2770
|
+
const browser = isBrowser();
|
|
2759
2771
|
const parts = [];
|
|
2760
2772
|
const styles = [];
|
|
2761
2773
|
if (browser) {
|
|
@@ -2848,12 +2860,14 @@ var noopLogger = {
|
|
|
2848
2860
|
},
|
|
2849
2861
|
getContext() {
|
|
2850
2862
|
return {};
|
|
2851
|
-
}
|
|
2863
|
+
},
|
|
2864
|
+
audit: Object.assign(() => {}, { deny: () => {} })
|
|
2852
2865
|
};
|
|
2853
2866
|
function createLogger(initialContext = {}, internalOptions) {
|
|
2854
2867
|
if (!globalEnabled)
|
|
2855
2868
|
return noopLogger;
|
|
2856
2869
|
const deferDrain = internalOptions?._deferDrain ?? false;
|
|
2870
|
+
const waitUntil = internalOptions?.waitUntil;
|
|
2857
2871
|
const startTime = Date.now();
|
|
2858
2872
|
const context = { ...initialContext };
|
|
2859
2873
|
let hasError = false;
|
|
@@ -2868,7 +2882,27 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2868
2882
|
timestamp: isoNow()
|
|
2869
2883
|
});
|
|
2870
2884
|
}
|
|
2885
|
+
const auditMethod = function audit(input) {
|
|
2886
|
+
if (emitted) {
|
|
2887
|
+
warnPostEmit("log.audit()", `Audit dropped: action=${input.action}.`);
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
const fields = buildAuditFields(input);
|
|
2891
|
+
if (!isPlainObject(context.audit))
|
|
2892
|
+
context.audit = fields;
|
|
2893
|
+
else
|
|
2894
|
+
mergeInto(context.audit, fields);
|
|
2895
|
+
context._auditForceKeep = true;
|
|
2896
|
+
};
|
|
2897
|
+
auditMethod.deny = function deny(reason, input) {
|
|
2898
|
+
auditMethod({
|
|
2899
|
+
...input,
|
|
2900
|
+
outcome: "denied",
|
|
2901
|
+
reason
|
|
2902
|
+
});
|
|
2903
|
+
};
|
|
2871
2904
|
return {
|
|
2905
|
+
audit: auditMethod,
|
|
2872
2906
|
set(data) {
|
|
2873
2907
|
if (emitted) {
|
|
2874
2908
|
const keys = Object.keys(data);
|
|
@@ -2941,6 +2975,8 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2941
2975
|
let forceKeep = false;
|
|
2942
2976
|
if (overrides?._forceKeep)
|
|
2943
2977
|
forceKeep = true;
|
|
2978
|
+
else if (consumeAuditForceKeep(context))
|
|
2979
|
+
forceKeep = true;
|
|
2944
2980
|
else if (globalSampling.keep?.length)
|
|
2945
2981
|
forceKeep = shouldKeep({
|
|
2946
2982
|
status: overrides?.status ?? context.status,
|
|
@@ -2960,7 +2996,11 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2960
2996
|
context[key] = obj[key];
|
|
2961
2997
|
}
|
|
2962
2998
|
context.duration = formatDuration(durationMs);
|
|
2963
|
-
const wide = emitWideEvent(level, context,
|
|
2999
|
+
const wide = emitWideEvent(level, context, {
|
|
3000
|
+
deferDrain,
|
|
3001
|
+
ownsEvent: true,
|
|
3002
|
+
waitUntil
|
|
3003
|
+
});
|
|
2964
3004
|
emitted = true;
|
|
2965
3005
|
return wide;
|
|
2966
3006
|
},
|
|
@@ -2971,6 +3011,78 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
2971
3011
|
}
|
|
2972
3012
|
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
2973
3013
|
initLogger(__EVLOG_CONFIG__);
|
|
3014
|
+
function stableStringify(value) {
|
|
3015
|
+
if (value === null || typeof value !== "object")
|
|
3016
|
+
return JSON.stringify(value);
|
|
3017
|
+
if (Array.isArray(value))
|
|
3018
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
3019
|
+
return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`).join(",")}}`;
|
|
3020
|
+
}
|
|
3021
|
+
function fnv1a32(input, seed) {
|
|
3022
|
+
let h = seed >>> 0;
|
|
3023
|
+
for (let i = 0;i < input.length; i++) {
|
|
3024
|
+
h ^= input.charCodeAt(i) & 255;
|
|
3025
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
3026
|
+
}
|
|
3027
|
+
return h >>> 0;
|
|
3028
|
+
}
|
|
3029
|
+
function computeIdempotencyKey(audit, timestamp) {
|
|
3030
|
+
const seconds = timestamp.slice(0, 19);
|
|
3031
|
+
const payload = stableStringify({
|
|
3032
|
+
action: audit.action,
|
|
3033
|
+
actor: {
|
|
3034
|
+
type: audit.actor.type,
|
|
3035
|
+
id: audit.actor.id
|
|
3036
|
+
},
|
|
3037
|
+
target: audit.target ? {
|
|
3038
|
+
type: audit.target.type,
|
|
3039
|
+
id: audit.target.id
|
|
3040
|
+
} : undefined,
|
|
3041
|
+
outcome: audit.outcome,
|
|
3042
|
+
timestamp: seconds
|
|
3043
|
+
});
|
|
3044
|
+
const a = fnv1a32(payload, 2166136261).toString(16).padStart(8, "0");
|
|
3045
|
+
const b = fnv1a32(payload, 3735928559).toString(16).padStart(8, "0");
|
|
3046
|
+
const c = fnv1a32(payload, 528734635).toString(16).padStart(8, "0");
|
|
3047
|
+
const d = fnv1a32(payload, 1541459225).toString(16).padStart(8, "0");
|
|
3048
|
+
return a + b + c + d;
|
|
3049
|
+
}
|
|
3050
|
+
function buildAuditFields(input) {
|
|
3051
|
+
return {
|
|
3052
|
+
action: input.action,
|
|
3053
|
+
actor: input.actor,
|
|
3054
|
+
target: input.target,
|
|
3055
|
+
outcome: input.outcome ?? "success",
|
|
3056
|
+
reason: input.reason,
|
|
3057
|
+
changes: input.changes,
|
|
3058
|
+
causationId: input.causationId,
|
|
3059
|
+
correlationId: input.correlationId,
|
|
3060
|
+
version: input.version ?? 1
|
|
3061
|
+
};
|
|
3062
|
+
}
|
|
3063
|
+
function decorateAudit(audit, timestamp) {
|
|
3064
|
+
if (audit.idempotencyKey)
|
|
3065
|
+
return audit;
|
|
3066
|
+
return {
|
|
3067
|
+
...audit,
|
|
3068
|
+
idempotencyKey: computeIdempotencyKey(audit, timestamp)
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
function consumeAuditForceKeep(context) {
|
|
3072
|
+
if (context._auditForceKeep) {
|
|
3073
|
+
delete context._auditForceKeep;
|
|
3074
|
+
return true;
|
|
3075
|
+
}
|
|
3076
|
+
if (context.audit)
|
|
3077
|
+
return true;
|
|
3078
|
+
return false;
|
|
3079
|
+
}
|
|
3080
|
+
function finalizeAudit(event) {
|
|
3081
|
+
const a = event.audit;
|
|
3082
|
+
if (!a)
|
|
3083
|
+
return;
|
|
3084
|
+
event.audit = decorateAudit(a, String(event.timestamp));
|
|
3085
|
+
}
|
|
2974
3086
|
// src/link.tsx
|
|
2975
3087
|
import {
|
|
2976
3088
|
createContext,
|
|
@@ -3615,7 +3727,7 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
3615
3727
|
// src/context-logger.ts
|
|
3616
3728
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3617
3729
|
|
|
3618
|
-
// ../../node_modules/.bun/evlog@2.
|
|
3730
|
+
// ../../node_modules/.bun/evlog@2.14.1+6b630eaba8c4f70c/node_modules/evlog/dist/elysia/index.mjs
|
|
3619
3731
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3620
3732
|
import { Elysia } from "elysia";
|
|
3621
3733
|
var storage = new AsyncLocalStorage;
|
|
@@ -3876,9 +3988,9 @@ var IS_DEV = true;
|
|
|
3876
3988
|
function withSSRRouterContext(element, contextValue) {
|
|
3877
3989
|
return createElement2(RouterContext.Provider, { value: contextValue }, element);
|
|
3878
3990
|
}
|
|
3879
|
-
async function prepareRender(route, ctx, root, basePath, throwOnFailure) {
|
|
3991
|
+
async function prepareRender(route, ctx, root, basePath, throwOnFailure, precomputedLoaderResult) {
|
|
3880
3992
|
const loaderStart = Date.now();
|
|
3881
|
-
const loaderResult = await runLoaders(route, ctx, root.route);
|
|
3993
|
+
const loaderResult = precomputedLoaderResult ?? await runLoaders(route, ctx, root.route);
|
|
3882
3994
|
const loader_ms = Date.now() - loaderStart;
|
|
3883
3995
|
if (loaderResult.type === "redirect") {
|
|
3884
3996
|
return loaderResult.response;
|
|
@@ -3954,7 +4066,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
3954
4066
|
set: { headers: {} },
|
|
3955
4067
|
path: resolvedPath
|
|
3956
4068
|
};
|
|
3957
|
-
const prepared = await prepareRender(route, ctx, root, basePath, true);
|
|
4069
|
+
const prepared = await prepareRender(route, ctx, root, basePath, true, undefined);
|
|
3958
4070
|
if (prepared instanceof Response) {
|
|
3959
4071
|
return prepared;
|
|
3960
4072
|
}
|
|
@@ -3981,7 +4093,7 @@ function renderForPath(route, params, root, origin, mode, basePath) {
|
|
|
3981
4093
|
async function prerenderSSG(route, params, root, origin, basePath) {
|
|
3982
4094
|
const resolvedPath = resolvePath(route.pattern, params);
|
|
3983
4095
|
const cached = getSSGCache(resolvedPath);
|
|
3984
|
-
if (cached
|
|
4096
|
+
if (cached) {
|
|
3985
4097
|
return cached;
|
|
3986
4098
|
}
|
|
3987
4099
|
const renderResult = await renderForPath(route, params, root, origin, "ssg", basePath);
|
|
@@ -3990,9 +4102,7 @@ async function prerenderSSG(route, params, root, origin, basePath) {
|
|
|
3990
4102
|
}
|
|
3991
4103
|
const result = renderResult;
|
|
3992
4104
|
const entry = { html: result.html, cachedAt: Date.now(), status: result.status };
|
|
3993
|
-
|
|
3994
|
-
setSSGCache(resolvedPath, entry);
|
|
3995
|
-
}
|
|
4105
|
+
setSSGCache(resolvedPath, entry);
|
|
3996
4106
|
return entry;
|
|
3997
4107
|
}
|
|
3998
4108
|
var pendingRevalidations = new Set;
|
|
@@ -4194,6 +4304,11 @@ function getCompileContext() {
|
|
|
4194
4304
|
return _compileCtx;
|
|
4195
4305
|
}
|
|
4196
4306
|
|
|
4307
|
+
// src/render/dev-cache.ts
|
|
4308
|
+
var devISRLoaderCache = new Map;
|
|
4309
|
+
var devSSGLoaderCache = new Map;
|
|
4310
|
+
var sourceFileToCacheKeys = new Map;
|
|
4311
|
+
|
|
4197
4312
|
// src/utils.ts
|
|
4198
4313
|
function isFurinPage(value) {
|
|
4199
4314
|
return typeof value === "object" && value !== null && "__type" in value && value.__type === "FURIN_PAGE";
|
|
@@ -4267,13 +4382,16 @@ async function scanRootLayout(pagesDir) {
|
|
|
4267
4382
|
};
|
|
4268
4383
|
}
|
|
4269
4384
|
var CONVENTION_FILE_NAMES = ["not-found", "error"];
|
|
4385
|
+
var SOURCE_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
4270
4386
|
function isConventionFileName(name) {
|
|
4271
4387
|
return CONVENTION_FILE_NAMES.includes(name);
|
|
4272
4388
|
}
|
|
4389
|
+
function getSourceModuleCandidates(dir, name) {
|
|
4390
|
+
return SOURCE_MODULE_EXTENSIONS.map((ext) => `${dir}/${name}${ext}`);
|
|
4391
|
+
}
|
|
4273
4392
|
async function loadConventionComponent(dir, name) {
|
|
4274
4393
|
const ctx = getCompileContext();
|
|
4275
|
-
for (const
|
|
4276
|
-
const filePath = `${dir}/${name}${ext}`;
|
|
4394
|
+
for (const filePath of getSourceModuleCandidates(dir, name)) {
|
|
4277
4395
|
if (existsSync6(filePath) || ctx?.modules[filePath]) {
|
|
4278
4396
|
const mod = ctx?.modules[filePath] ?? await import(filePath);
|
|
4279
4397
|
if (mod.default) {
|
|
@@ -4288,7 +4406,7 @@ async function scanPageFiles(pagesDir, root) {
|
|
|
4288
4406
|
const notFoundCache = new Map;
|
|
4289
4407
|
const errorCache = new Map;
|
|
4290
4408
|
for (const absolutePath of await collectPageFilePaths(pagesDir)) {
|
|
4291
|
-
if (!
|
|
4409
|
+
if (!SOURCE_MODULE_EXTENSIONS.some((ext) => absolutePath.endsWith(ext))) {
|
|
4292
4410
|
continue;
|
|
4293
4411
|
}
|
|
4294
4412
|
const relativePath = absolutePath.replace(`${pagesDir}/`, "");
|