@teyik0/furin 0.1.0-alpha.9 → 0.2.0-alpha.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/LICENSE +21 -0
- package/README.md +33 -0
- package/package.json +61 -25
- package/src/adapter/bun.ts +90 -41
- package/src/adapter/static.ts +100 -40
- package/src/build/client.ts +13 -14
- package/src/build/compile-entry.ts +20 -14
- package/src/build/entry-template.ts +90 -8
- package/src/build/hydrate.ts +219 -36
- package/src/build/index.ts +10 -9
- package/src/build/route-types.ts +65 -9
- package/src/build/scan-server.ts +52 -67
- package/src/build/server-routes-entry.ts +7 -11
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +32 -0
- package/src/build/types.ts +5 -1
- package/src/cli/index.ts +1 -0
- package/src/client/boundaries.tsx +259 -0
- package/src/client/default-screens.tsx +304 -0
- package/src/client/link.tsx +347 -0
- package/src/client/router/boundary-tree.tsx +116 -0
- package/src/client/router/context.ts +40 -0
- package/src/client/router/history.ts +41 -0
- package/src/client/router/index.ts +56 -0
- package/src/client/router/link-utils.ts +177 -0
- package/src/client/router/navigation.ts +61 -0
- package/src/client/router/provider.tsx +759 -0
- package/src/client/router/search/index.ts +99 -0
- package/src/client/router/search-store.ts +86 -0
- package/src/client/router/spa-response.ts +143 -0
- package/src/client/router/types.ts +271 -0
- package/src/client/server-error.ts +47 -0
- package/src/client.ts +80 -3
- package/src/config.ts +11 -3
- package/src/env.d.ts +1 -0
- package/src/furin.ts +114 -29
- package/src/plugin/index.ts +7 -8
- package/src/plugin/transform-client.ts +146 -120
- package/src/server/auto-invalidate/index.ts +10 -0
- package/src/server/auto-invalidate/plugin.ts +25 -0
- package/src/server/auto-invalidate/registry.ts +60 -0
- package/src/server/auto-invalidate/runtime.ts +133 -0
- package/src/server/auto-invalidate/types.ts +16 -0
- package/src/server/cache/dev-loader.ts +211 -0
- package/src/server/cache/index.ts +34 -0
- package/src/server/cache/invalidation.ts +111 -0
- package/src/server/cache/isr-ssg.ts +41 -0
- package/src/server/cache/isr.ts +17 -0
- package/src/server/cache/registry.ts +35 -0
- package/src/server/cache/route-cache.ts +124 -0
- package/src/server/cache/ssg.ts +15 -0
- package/src/{context-logger.ts → server/context-logger.ts} +5 -0
- package/src/server/dev-inspector.ts +60 -0
- package/src/{dev-page-plugin.ts → server/dev-page-plugin.ts} +15 -0
- package/src/{internal.ts → server/internal.ts} +17 -0
- package/src/server/lang-detect.ts +46 -0
- package/src/server/render/assemble.ts +133 -0
- package/src/server/render/element.tsx +113 -0
- package/src/server/render/index.ts +22 -0
- package/src/server/render/isr.ts +317 -0
- package/src/server/render/loaders.ts +328 -0
- package/src/server/render/not-found.ts +98 -0
- package/src/{render → server/render}/shell.ts +28 -13
- package/src/server/render/ssg.ts +148 -0
- package/src/server/render/ssr.ts +583 -0
- package/src/server/router/discovery.ts +474 -0
- package/src/server/router/hmr.ts +376 -0
- package/src/server/router/index.ts +28 -0
- package/src/server/router/patterns.ts +219 -0
- package/src/server/router/plugin.ts +384 -0
- package/src/server/router/schemas.ts +278 -0
- package/src/server/router/types.ts +59 -0
- package/src/shared/await.tsx +192 -0
- package/src/shared/deferred-ndjson.ts +244 -0
- package/src/shared/digest.ts +71 -0
- package/src/shared/error.ts +49 -0
- package/src/shared/not-found.ts +40 -0
- package/src/shared/search-params.ts +182 -0
- package/src/shared/utils/ast-walk.ts +51 -0
- package/src/{utils.ts → shared/utils/index.ts} +32 -1
- package/dist/adapter/bun.d.ts +0 -3
- package/dist/adapter/static.d.ts +0 -3
- package/dist/build/client.d.ts +0 -25
- package/dist/build/compile-entry.d.ts +0 -23
- package/dist/build/entry-template.d.ts +0 -14
- package/dist/build/hydrate.d.ts +0 -24
- package/dist/build/index.d.ts +0 -7
- package/dist/build/index.js +0 -3727
- package/dist/build/route-types.d.ts +0 -21
- package/dist/build/scan-server.d.ts +0 -8
- package/dist/build/server-routes-entry.d.ts +0 -23
- package/dist/build/shared.d.ts +0 -11
- package/dist/build/types.d.ts +0 -76
- package/dist/cli/config.d.ts +0 -9
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -3762
- package/dist/client.d.ts +0 -195
- package/dist/client.js +0 -20
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -28
- package/dist/context-logger.d.ts +0 -26
- package/dist/dev-page-plugin.d.ts +0 -109
- package/dist/furin.d.ts +0 -34
- package/dist/furin.js +0 -2744
- package/dist/internal.d.ts +0 -19
- package/dist/link.d.ts +0 -245
- package/dist/link.js +0 -1232
- package/dist/plugin/index.d.ts +0 -20
- package/dist/plugin/index.js +0 -1408
- package/dist/plugin/transform-client.d.ts +0 -9
- package/dist/render/assemble.d.ts +0 -15
- package/dist/render/cache.d.ts +0 -95
- package/dist/render/element.d.ts +0 -4
- package/dist/render/index.d.ts +0 -27
- package/dist/render/loaders.d.ts +0 -12
- package/dist/render/shell.d.ts +0 -29
- package/dist/render/template.d.ts +0 -6
- package/dist/router.d.ts +0 -45
- package/dist/router.js +0 -1671
- package/dist/runtime-env.d.ts +0 -3
- package/dist/utils.d.ts +0 -6
- package/src/link.tsx +0 -1120
- package/src/render/assemble.ts +0 -66
- package/src/render/cache.ts +0 -241
- package/src/render/element.tsx +0 -28
- package/src/render/index.ts +0 -483
- package/src/render/loaders.ts +0 -117
- package/src/router.ts +0 -439
- /package/src/{render → server/render}/template.ts +0 -0
- /package/src/{runtime-env.ts → server/runtime-env.ts} +0 -0
package/dist/link.js
DELETED
|
@@ -1,1232 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// ../../node_modules/.bun/evlog@2.13.0+449e6d239244fccb/node_modules/evlog/dist/utils.mjs
|
|
3
|
-
function formatDuration(ms) {
|
|
4
|
-
if (ms < 1000)
|
|
5
|
-
return `${Math.round(ms)}ms`;
|
|
6
|
-
return `${(ms / 1000).toFixed(2)}s`;
|
|
7
|
-
}
|
|
8
|
-
function isClient() {
|
|
9
|
-
return typeof window !== "undefined";
|
|
10
|
-
}
|
|
11
|
-
function isDev() {
|
|
12
|
-
if (typeof process !== "undefined")
|
|
13
|
-
return true;
|
|
14
|
-
if (typeof window !== "undefined")
|
|
15
|
-
return true;
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function detectEnvironment() {
|
|
19
|
-
const env = typeof process !== "undefined" ? process.env : {};
|
|
20
|
-
const defaultEnvironment = isDev() ? "development" : "production";
|
|
21
|
-
return {
|
|
22
|
-
environment: env.NODE_ENV || defaultEnvironment,
|
|
23
|
-
service: env.SERVICE_NAME || "app",
|
|
24
|
-
version: env.APP_VERSION,
|
|
25
|
-
commitHash: env.COMMIT_SHA || env.GITHUB_SHA || env.VERCEL_GIT_COMMIT_SHA || env.CF_PAGES_COMMIT_SHA,
|
|
26
|
-
region: env.VERCEL_REGION || env.AWS_REGION || env.FLY_REGION || env.CF_REGION
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
var LEVEL_ORDER = {
|
|
30
|
-
debug: 0,
|
|
31
|
-
info: 1,
|
|
32
|
-
warn: 2,
|
|
33
|
-
error: 3
|
|
34
|
-
};
|
|
35
|
-
function isLevelEnabled(level, minLevel) {
|
|
36
|
-
return LEVEL_ORDER[level] >= LEVEL_ORDER[minLevel];
|
|
37
|
-
}
|
|
38
|
-
function getConsoleMethod(level) {
|
|
39
|
-
return level;
|
|
40
|
-
}
|
|
41
|
-
var colors = {
|
|
42
|
-
reset: "\x1B[0m",
|
|
43
|
-
bold: "\x1B[1m",
|
|
44
|
-
dim: "\x1B[2m",
|
|
45
|
-
red: "\x1B[31m",
|
|
46
|
-
green: "\x1B[32m",
|
|
47
|
-
yellow: "\x1B[33m",
|
|
48
|
-
blue: "\x1B[34m",
|
|
49
|
-
magenta: "\x1B[35m",
|
|
50
|
-
cyan: "\x1B[36m",
|
|
51
|
-
white: "\x1B[37m",
|
|
52
|
-
gray: "\x1B[90m"
|
|
53
|
-
};
|
|
54
|
-
var levelColorMap = {
|
|
55
|
-
error: colors.red,
|
|
56
|
-
warn: colors.yellow,
|
|
57
|
-
info: colors.cyan,
|
|
58
|
-
debug: colors.gray
|
|
59
|
-
};
|
|
60
|
-
function getLevelColor(level) {
|
|
61
|
-
return levelColorMap[level] ?? colors.white;
|
|
62
|
-
}
|
|
63
|
-
var cssColors = {
|
|
64
|
-
dim: "color: #6b7280",
|
|
65
|
-
red: "color: #ef4444; font-weight: bold",
|
|
66
|
-
green: "color: #22c55e",
|
|
67
|
-
yellow: "color: #f59e0b; font-weight: bold",
|
|
68
|
-
cyan: "color: #06b6d4; font-weight: bold",
|
|
69
|
-
gray: "color: #6b7280; font-weight: bold",
|
|
70
|
-
reset: "color: inherit; font-weight: normal"
|
|
71
|
-
};
|
|
72
|
-
var cssLevelColorMap = {
|
|
73
|
-
error: cssColors.red,
|
|
74
|
-
warn: cssColors.yellow,
|
|
75
|
-
info: cssColors.cyan,
|
|
76
|
-
debug: cssColors.gray
|
|
77
|
-
};
|
|
78
|
-
function getCssLevelColor(level) {
|
|
79
|
-
return cssLevelColorMap[level] ?? cssColors.reset;
|
|
80
|
-
}
|
|
81
|
-
function escapeFormatString(str) {
|
|
82
|
-
return str.replace(/%/g, "%%");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ../../node_modules/.bun/evlog@2.13.0+449e6d239244fccb/node_modules/evlog/dist/logger-DnobymUQ.mjs
|
|
86
|
-
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
87
|
-
var builtinPatterns = {
|
|
88
|
-
creditCard: {
|
|
89
|
-
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
90
|
-
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
91
|
-
},
|
|
92
|
-
email: {
|
|
93
|
-
pattern: /[\w.+-]+@[\w-]+\.[\w.]+/g,
|
|
94
|
-
mask: (m) => {
|
|
95
|
-
if (m.indexOf("@") < 1)
|
|
96
|
-
return "***@***";
|
|
97
|
-
const tld = m.slice(m.lastIndexOf("."));
|
|
98
|
-
return `${m[0]}***@***${tld}`;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
ipv4: {
|
|
102
|
-
pattern: /\b(?!0\.0\.0\.0\b)(?!127\.0\.0\.1\b)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,
|
|
103
|
-
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
104
|
-
},
|
|
105
|
-
phone: {
|
|
106
|
-
pattern: /(?:\+\d{1,3}[\s.-]?)?\(?\d{1,4}\)?[\s.-]?\d{2,4}[\s.-]?\d{2,4}[\s.-]?\d{2,4}\b/g,
|
|
107
|
-
mask: (m) => {
|
|
108
|
-
const digits = m.replace(/[^\d]/g, "");
|
|
109
|
-
if (m.startsWith("+") && digits.length > 4) {
|
|
110
|
-
const ccMatch = m.match(/^\+\d{1,3}/);
|
|
111
|
-
return `${ccMatch ? ccMatch[0] : "+"}******${digits.slice(-2)}`;
|
|
112
|
-
}
|
|
113
|
-
if (digits.length > 2)
|
|
114
|
-
return `${"*".repeat(digits.length - 2)}${digits.slice(-2)}`;
|
|
115
|
-
return "***";
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
jwt: {
|
|
119
|
-
pattern: /\beyJ[\w-]*\.[\w-]*\.[\w-]*\b/g,
|
|
120
|
-
mask: () => "eyJ***.***"
|
|
121
|
-
},
|
|
122
|
-
bearer: {
|
|
123
|
-
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
124
|
-
mask: () => "Bearer ***"
|
|
125
|
-
},
|
|
126
|
-
iban: {
|
|
127
|
-
pattern: /\b[A-Z]{2}\d{2}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}\b/g,
|
|
128
|
-
mask: (m) => {
|
|
129
|
-
const clean = m.replace(/[\s-]/g, "");
|
|
130
|
-
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
function resolveRedactConfig(input) {
|
|
135
|
-
if (input === undefined || input === false)
|
|
136
|
-
return;
|
|
137
|
-
if (input === true)
|
|
138
|
-
return { _maskers: allBuiltinMaskers() };
|
|
139
|
-
if (input.builtins === false)
|
|
140
|
-
return input;
|
|
141
|
-
const maskers = Array.isArray(input.builtins) ? input.builtins.map((name) => builtinPatterns[name]).filter(Boolean).map((b) => [cloneRegex(b.pattern), b.mask]) : allBuiltinMaskers();
|
|
142
|
-
return {
|
|
143
|
-
...input,
|
|
144
|
-
_maskers: maskers
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function allBuiltinMaskers() {
|
|
148
|
-
return Object.values(builtinPatterns).map((b) => [cloneRegex(b.pattern), b.mask]);
|
|
149
|
-
}
|
|
150
|
-
function cloneRegex(re) {
|
|
151
|
-
return new RegExp(re.source, re.flags);
|
|
152
|
-
}
|
|
153
|
-
function redactEvent(event, config) {
|
|
154
|
-
const replacement = config.replacement ?? DEFAULT_REPLACEMENT;
|
|
155
|
-
if (config.paths?.length)
|
|
156
|
-
for (const path of config.paths)
|
|
157
|
-
redactPath(event, path.split("."), replacement);
|
|
158
|
-
if (config._maskers?.length)
|
|
159
|
-
applyMaskersToTree(event, config._maskers);
|
|
160
|
-
if (config.patterns?.length)
|
|
161
|
-
redactPatterns(event, config.patterns, replacement);
|
|
162
|
-
}
|
|
163
|
-
function redactPath(obj, segments, replacement) {
|
|
164
|
-
let current = obj;
|
|
165
|
-
for (let i = 0;i < segments.length - 1; i++) {
|
|
166
|
-
if (current === null || current === undefined || typeof current !== "object")
|
|
167
|
-
return;
|
|
168
|
-
current = current[segments[i]];
|
|
169
|
-
}
|
|
170
|
-
if (current === null || current === undefined || typeof current !== "object")
|
|
171
|
-
return;
|
|
172
|
-
const leaf = segments[segments.length - 1];
|
|
173
|
-
if (leaf in current)
|
|
174
|
-
current[leaf] = replacement;
|
|
175
|
-
}
|
|
176
|
-
function redactPatterns(obj, patterns, replacement) {
|
|
177
|
-
if (obj === null || obj === undefined)
|
|
178
|
-
return;
|
|
179
|
-
if (Array.isArray(obj)) {
|
|
180
|
-
for (let i = 0;i < obj.length; i++)
|
|
181
|
-
if (typeof obj[i] === "string")
|
|
182
|
-
obj[i] = applyPatterns(obj[i], patterns, replacement);
|
|
183
|
-
else if (typeof obj[i] === "object")
|
|
184
|
-
redactPatterns(obj[i], patterns, replacement);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
if (typeof obj === "object") {
|
|
188
|
-
const record = obj;
|
|
189
|
-
for (const key in record) {
|
|
190
|
-
const val = record[key];
|
|
191
|
-
if (typeof val === "string")
|
|
192
|
-
record[key] = applyPatterns(val, patterns, replacement);
|
|
193
|
-
else if (typeof val === "object")
|
|
194
|
-
redactPatterns(val, patterns, replacement);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function applyPatterns(value, patterns, replacement) {
|
|
199
|
-
let result = value;
|
|
200
|
-
for (const pattern of patterns) {
|
|
201
|
-
pattern.lastIndex = 0;
|
|
202
|
-
result = result.replace(pattern, replacement);
|
|
203
|
-
}
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
function applyMaskersToTree(obj, maskers) {
|
|
207
|
-
if (obj === null || obj === undefined)
|
|
208
|
-
return;
|
|
209
|
-
if (Array.isArray(obj)) {
|
|
210
|
-
for (let i = 0;i < obj.length; i++)
|
|
211
|
-
if (typeof obj[i] === "string")
|
|
212
|
-
obj[i] = applyMaskers(obj[i], maskers);
|
|
213
|
-
else if (typeof obj[i] === "object")
|
|
214
|
-
applyMaskersToTree(obj[i], maskers);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
if (typeof obj === "object") {
|
|
218
|
-
const record = obj;
|
|
219
|
-
for (const key in record) {
|
|
220
|
-
const val = record[key];
|
|
221
|
-
if (typeof val === "string")
|
|
222
|
-
record[key] = applyMaskers(val, maskers);
|
|
223
|
-
else if (typeof val === "object")
|
|
224
|
-
applyMaskersToTree(val, maskers);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function applyMaskers(value, maskers) {
|
|
229
|
-
let result = value;
|
|
230
|
-
for (const [pattern, mask] of maskers) {
|
|
231
|
-
pattern.lastIndex = 0;
|
|
232
|
-
result = result.replace(pattern, mask);
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
var _tsDate = /* @__PURE__ */ new Date;
|
|
237
|
-
function isoNow() {
|
|
238
|
-
_tsDate.setTime(Date.now());
|
|
239
|
-
return _tsDate.toISOString();
|
|
240
|
-
}
|
|
241
|
-
var globalEnv = {
|
|
242
|
-
service: "app",
|
|
243
|
-
environment: "development"
|
|
244
|
-
};
|
|
245
|
-
var globalPretty = isDev();
|
|
246
|
-
var globalSampling = {};
|
|
247
|
-
var globalStringify = true;
|
|
248
|
-
var globalDrain;
|
|
249
|
-
var globalRedact;
|
|
250
|
-
var globalEnabled = true;
|
|
251
|
-
var globalSilent = false;
|
|
252
|
-
var globalMinLevel = "debug";
|
|
253
|
-
function initLogger(config = {}) {
|
|
254
|
-
globalEnabled = config.enabled ?? true;
|
|
255
|
-
const detected = detectEnvironment();
|
|
256
|
-
globalEnv = {
|
|
257
|
-
service: config.env?.service ?? detected.service ?? "app",
|
|
258
|
-
environment: config.env?.environment ?? detected.environment ?? "development",
|
|
259
|
-
version: config.env?.version ?? detected.version,
|
|
260
|
-
commitHash: config.env?.commitHash ?? detected.commitHash,
|
|
261
|
-
region: config.env?.region ?? detected.region
|
|
262
|
-
};
|
|
263
|
-
globalPretty = config.pretty ?? isDev();
|
|
264
|
-
globalSampling = config.sampling ?? {};
|
|
265
|
-
globalStringify = config.stringify ?? true;
|
|
266
|
-
globalDrain = config.drain;
|
|
267
|
-
globalRedact = resolveRedactConfig(config.redact ?? !isDev());
|
|
268
|
-
globalSilent = config.silent ?? false;
|
|
269
|
-
globalMinLevel = config.minLevel ?? "debug";
|
|
270
|
-
if (globalSilent && !globalDrain && !config._suppressDrainWarning)
|
|
271
|
-
console.warn("[evlog] silent mode is enabled but no drain is configured. Events will be built and sampled but not output anywhere. Set a drain via initLogger({ drain }) or a framework hook (evlog:drain).");
|
|
272
|
-
}
|
|
273
|
-
function shouldSample(level) {
|
|
274
|
-
const { rates } = globalSampling;
|
|
275
|
-
if (!rates)
|
|
276
|
-
return true;
|
|
277
|
-
const percentage = level === "error" && rates.error === undefined ? 100 : rates[level] ?? 100;
|
|
278
|
-
if (percentage <= 0)
|
|
279
|
-
return false;
|
|
280
|
-
if (percentage >= 100)
|
|
281
|
-
return true;
|
|
282
|
-
return Math.random() * 100 < percentage;
|
|
283
|
-
}
|
|
284
|
-
function emitWideEvent(level, event, deferDrain = false, ownsEvent = false) {
|
|
285
|
-
if (!globalEnabled)
|
|
286
|
-
return null;
|
|
287
|
-
if (!ownsEvent) {
|
|
288
|
-
if (!isLevelEnabled(level, globalMinLevel))
|
|
289
|
-
return null;
|
|
290
|
-
if (!shouldSample(level))
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
let formatted;
|
|
294
|
-
if (ownsEvent) {
|
|
295
|
-
event.timestamp = isoNow();
|
|
296
|
-
event.level = level;
|
|
297
|
-
if (event.service === undefined)
|
|
298
|
-
event.service = globalEnv.service;
|
|
299
|
-
if (event.environment === undefined)
|
|
300
|
-
event.environment = globalEnv.environment;
|
|
301
|
-
if (globalEnv.version !== undefined && event.version === undefined)
|
|
302
|
-
event.version = globalEnv.version;
|
|
303
|
-
if (globalEnv.commitHash !== undefined && event.commitHash === undefined)
|
|
304
|
-
event.commitHash = globalEnv.commitHash;
|
|
305
|
-
if (globalEnv.region !== undefined && event.region === undefined)
|
|
306
|
-
event.region = globalEnv.region;
|
|
307
|
-
formatted = event;
|
|
308
|
-
} else
|
|
309
|
-
formatted = {
|
|
310
|
-
timestamp: isoNow(),
|
|
311
|
-
level,
|
|
312
|
-
...globalEnv,
|
|
313
|
-
...event
|
|
314
|
-
};
|
|
315
|
-
if (globalRedact)
|
|
316
|
-
redactEvent(formatted, globalRedact);
|
|
317
|
-
if (!globalSilent)
|
|
318
|
-
if (globalPretty)
|
|
319
|
-
prettyPrintWideEvent(formatted);
|
|
320
|
-
else if (globalStringify)
|
|
321
|
-
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
322
|
-
else
|
|
323
|
-
console[getConsoleMethod(level)](formatted);
|
|
324
|
-
if (globalDrain && !deferDrain)
|
|
325
|
-
Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
326
|
-
console.error("[evlog] drain failed:", err);
|
|
327
|
-
});
|
|
328
|
-
return formatted;
|
|
329
|
-
}
|
|
330
|
-
function emitTaggedLog(level, tag, message) {
|
|
331
|
-
if (!globalEnabled)
|
|
332
|
-
return;
|
|
333
|
-
if (globalPretty && !globalSilent) {
|
|
334
|
-
if (!isLevelEnabled(level, globalMinLevel))
|
|
335
|
-
return;
|
|
336
|
-
if (!shouldSample(level))
|
|
337
|
-
return;
|
|
338
|
-
if (isClient()) {
|
|
339
|
-
const levelColor = getCssLevelColor(level);
|
|
340
|
-
const timestamp = isoNow().slice(11, 23);
|
|
341
|
-
console.log(`%c${timestamp}%c %c[${escapeFormatString(tag)}]%c ${escapeFormatString(message)}`, cssColors.dim, cssColors.reset, levelColor, cssColors.reset);
|
|
342
|
-
} else {
|
|
343
|
-
const color = getLevelColor(level);
|
|
344
|
-
const timestamp = isoNow().slice(11, 23);
|
|
345
|
-
console.log(`${colors.dim}${timestamp}${colors.reset} ${color}[${tag}]${colors.reset} ${message}`);
|
|
346
|
-
}
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
emitWideEvent(level, {
|
|
350
|
-
tag,
|
|
351
|
-
message
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
function formatValue(value) {
|
|
355
|
-
if (value === null || value === undefined)
|
|
356
|
-
return String(value);
|
|
357
|
-
if (typeof value === "object") {
|
|
358
|
-
const pairs = [];
|
|
359
|
-
for (const [k, v] of Object.entries(value))
|
|
360
|
-
if (v !== undefined && v !== null)
|
|
361
|
-
if (typeof v === "object")
|
|
362
|
-
pairs.push(`${k}=${JSON.stringify(v)}`);
|
|
363
|
-
else
|
|
364
|
-
pairs.push(`${k}=${v}`);
|
|
365
|
-
return pairs.join(" ");
|
|
366
|
-
}
|
|
367
|
-
return String(value);
|
|
368
|
-
}
|
|
369
|
-
function formatCost(cost) {
|
|
370
|
-
if (cost < 0.01)
|
|
371
|
-
return `$${cost.toFixed(6)}`;
|
|
372
|
-
if (cost < 1)
|
|
373
|
-
return `$${cost.toFixed(4)}`;
|
|
374
|
-
return `$${cost.toFixed(2)}`;
|
|
375
|
-
}
|
|
376
|
-
function buildAIEntries(ai) {
|
|
377
|
-
const entries = [];
|
|
378
|
-
const headerParts = [];
|
|
379
|
-
if (ai.model) {
|
|
380
|
-
let m = String(ai.model);
|
|
381
|
-
if (ai.provider)
|
|
382
|
-
m += ` (${ai.provider})`;
|
|
383
|
-
headerParts.push(m);
|
|
384
|
-
}
|
|
385
|
-
if (ai.calls)
|
|
386
|
-
headerParts.push(`${ai.calls} call${ai.calls > 1 ? "s" : ""}`);
|
|
387
|
-
if (ai.steps && ai.steps > 1)
|
|
388
|
-
headerParts.push(`${ai.steps} steps`);
|
|
389
|
-
entries.push({
|
|
390
|
-
key: "ai",
|
|
391
|
-
value: headerParts.join(" \xB7 ")
|
|
392
|
-
});
|
|
393
|
-
const inputTokens = ai.inputTokens;
|
|
394
|
-
const outputTokens = ai.outputTokens;
|
|
395
|
-
const totalTokens = ai.totalTokens;
|
|
396
|
-
if (inputTokens !== undefined && outputTokens !== undefined) {
|
|
397
|
-
let tokLine = `${inputTokens} in \u2192 ${outputTokens} out`;
|
|
398
|
-
if (totalTokens)
|
|
399
|
-
tokLine += ` (${totalTokens} total)`;
|
|
400
|
-
const extras = [];
|
|
401
|
-
if (ai.cacheReadTokens)
|
|
402
|
-
extras.push(`${ai.cacheReadTokens} cache read`);
|
|
403
|
-
if (ai.cacheWriteTokens)
|
|
404
|
-
extras.push(`${ai.cacheWriteTokens} cache write`);
|
|
405
|
-
if (ai.reasoningTokens)
|
|
406
|
-
extras.push(`${ai.reasoningTokens} reasoning`);
|
|
407
|
-
if (extras.length)
|
|
408
|
-
tokLine += ` \xB7 ${extras.join(" \xB7 ")}`;
|
|
409
|
-
entries.push({
|
|
410
|
-
key: "ai.tokens",
|
|
411
|
-
value: tokLine
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
const msFirst = ai.msToFirstChunk;
|
|
415
|
-
const msFinish = ai.msToFinish;
|
|
416
|
-
const tps = ai.tokensPerSecond;
|
|
417
|
-
if (msFirst !== undefined || msFinish !== undefined) {
|
|
418
|
-
const parts = [];
|
|
419
|
-
if (msFirst !== undefined)
|
|
420
|
-
parts.push(`${formatDuration(msFirst)} to first chunk`);
|
|
421
|
-
if (msFinish !== undefined)
|
|
422
|
-
parts.push(`${formatDuration(msFinish)} total`);
|
|
423
|
-
let streamLine = parts.join(" \u2192 ");
|
|
424
|
-
if (tps)
|
|
425
|
-
streamLine += ` \xB7 ${tps} tok/s`;
|
|
426
|
-
entries.push({
|
|
427
|
-
key: "ai.streaming",
|
|
428
|
-
value: streamLine
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
if (ai.estimatedCost !== undefined)
|
|
432
|
-
entries.push({
|
|
433
|
-
key: "ai.cost",
|
|
434
|
-
value: formatCost(ai.estimatedCost)
|
|
435
|
-
});
|
|
436
|
-
if (ai.totalDurationMs !== undefined)
|
|
437
|
-
entries.push({
|
|
438
|
-
key: "ai.totalDuration",
|
|
439
|
-
value: formatDuration(ai.totalDurationMs)
|
|
440
|
-
});
|
|
441
|
-
const toolCalls = ai.toolCalls;
|
|
442
|
-
const tools = ai.tools;
|
|
443
|
-
const hasInputs = toolCalls?.length ? typeof toolCalls[0] === "object" : false;
|
|
444
|
-
if (tools?.length) {
|
|
445
|
-
const children = tools.map((t, idx) => {
|
|
446
|
-
const mark = t.success ? "\u2713" : "\u2717";
|
|
447
|
-
let line = `${t.name} ${formatDuration(t.durationMs)} ${mark}`;
|
|
448
|
-
if (t.error)
|
|
449
|
-
line += ` ${t.error}`;
|
|
450
|
-
if (hasInputs && toolCalls && idx < toolCalls.length) {
|
|
451
|
-
const tc = toolCalls[idx];
|
|
452
|
-
const inputStr = typeof tc.input === "string" ? tc.input : JSON.stringify(tc.input);
|
|
453
|
-
const truncated = inputStr.length > 100 ? `${inputStr.slice(0, 100)}\u2026` : inputStr;
|
|
454
|
-
line += ` ${truncated}`;
|
|
455
|
-
}
|
|
456
|
-
return line;
|
|
457
|
-
});
|
|
458
|
-
entries.push({
|
|
459
|
-
key: "ai.tools",
|
|
460
|
-
value: "",
|
|
461
|
-
children
|
|
462
|
-
});
|
|
463
|
-
} else if (toolCalls?.length)
|
|
464
|
-
if (hasInputs) {
|
|
465
|
-
const children = toolCalls.map((tc) => {
|
|
466
|
-
const inputStr = typeof tc.input === "string" ? tc.input : JSON.stringify(tc.input);
|
|
467
|
-
const truncated = inputStr.length > 100 ? `${inputStr.slice(0, 100)}\u2026` : inputStr;
|
|
468
|
-
return `${tc.name}(${truncated})`;
|
|
469
|
-
});
|
|
470
|
-
entries.push({
|
|
471
|
-
key: "ai.tools",
|
|
472
|
-
value: "",
|
|
473
|
-
children
|
|
474
|
-
});
|
|
475
|
-
} else
|
|
476
|
-
entries.push({
|
|
477
|
-
key: "ai.tools",
|
|
478
|
-
value: toolCalls.join(", ")
|
|
479
|
-
});
|
|
480
|
-
const stepsUsage = ai.stepsUsage;
|
|
481
|
-
if (stepsUsage?.length) {
|
|
482
|
-
const allSameModel = stepsUsage.every((s) => s.model === stepsUsage[0].model);
|
|
483
|
-
const children = stepsUsage.map((s) => {
|
|
484
|
-
let line = `${allSameModel ? "" : `${s.model} `}${s.inputTokens} in \u2192 ${s.outputTokens} out`;
|
|
485
|
-
const stepTools = s.toolCalls;
|
|
486
|
-
if (stepTools?.length)
|
|
487
|
-
line += ` [${stepTools.join(", ")}]`;
|
|
488
|
-
return line;
|
|
489
|
-
});
|
|
490
|
-
entries.push({
|
|
491
|
-
key: "ai.steps",
|
|
492
|
-
value: "",
|
|
493
|
-
children
|
|
494
|
-
});
|
|
495
|
-
} else if (ai.steps && ai.steps > 1)
|
|
496
|
-
entries.push({
|
|
497
|
-
key: "ai.steps",
|
|
498
|
-
value: String(ai.steps)
|
|
499
|
-
});
|
|
500
|
-
const embedding = ai.embedding;
|
|
501
|
-
if (embedding) {
|
|
502
|
-
const parts = [];
|
|
503
|
-
if (embedding.model)
|
|
504
|
-
parts.push(String(embedding.model));
|
|
505
|
-
parts.push(`${embedding.tokens} tokens`);
|
|
506
|
-
if (embedding.dimensions)
|
|
507
|
-
parts.push(`${embedding.dimensions}d`);
|
|
508
|
-
if (embedding.count)
|
|
509
|
-
parts.push(`${embedding.count} items`);
|
|
510
|
-
entries.push({
|
|
511
|
-
key: "ai.embedding",
|
|
512
|
-
value: parts.join(" \xB7 ")
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
if (ai.finishReason)
|
|
516
|
-
entries.push({
|
|
517
|
-
key: "ai.finishReason",
|
|
518
|
-
value: String(ai.finishReason)
|
|
519
|
-
});
|
|
520
|
-
if (ai.error)
|
|
521
|
-
entries.push({
|
|
522
|
-
key: "ai.error",
|
|
523
|
-
value: String(ai.error)
|
|
524
|
-
});
|
|
525
|
-
if (ai.responseId)
|
|
526
|
-
entries.push({
|
|
527
|
-
key: "ai.responseId",
|
|
528
|
-
value: String(ai.responseId)
|
|
529
|
-
});
|
|
530
|
-
return entries;
|
|
531
|
-
}
|
|
532
|
-
function prettyPrintWideEvent(event) {
|
|
533
|
-
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
534
|
-
const ts = timestamp.slice(11, 23);
|
|
535
|
-
const browser = isClient();
|
|
536
|
-
const parts = [];
|
|
537
|
-
const styles = [];
|
|
538
|
-
if (browser) {
|
|
539
|
-
const lc = getCssLevelColor(level);
|
|
540
|
-
parts.push(`%c${ts}%c %c${level.toUpperCase()}%c %c[${escapeFormatString(String(service))}]%c`);
|
|
541
|
-
styles.push(cssColors.dim, cssColors.reset, lc, cssColors.reset, cssColors.cyan, cssColors.reset);
|
|
542
|
-
} else {
|
|
543
|
-
const lc = getLevelColor(level);
|
|
544
|
-
parts.push(`${colors.dim}${ts}${colors.reset} ${lc}${level.toUpperCase()}${colors.reset} ${colors.cyan}[${service}]${colors.reset}`);
|
|
545
|
-
}
|
|
546
|
-
if (rest.method && rest.path) {
|
|
547
|
-
parts.push(browser ? ` ${escapeFormatString(String(rest.method))} ${escapeFormatString(String(rest.path))}` : ` ${rest.method} ${rest.path}`);
|
|
548
|
-
delete rest.method;
|
|
549
|
-
delete rest.path;
|
|
550
|
-
}
|
|
551
|
-
if (rest.status) {
|
|
552
|
-
const sc = browser ? rest.status >= 400 ? cssColors.red : cssColors.green : rest.status >= 400 ? colors.red : colors.green;
|
|
553
|
-
if (browser) {
|
|
554
|
-
parts.push(` %c${rest.status}%c`);
|
|
555
|
-
styles.push(sc, cssColors.reset);
|
|
556
|
-
} else
|
|
557
|
-
parts.push(` ${sc}${rest.status}${colors.reset}`);
|
|
558
|
-
delete rest.status;
|
|
559
|
-
}
|
|
560
|
-
if (rest.duration) {
|
|
561
|
-
if (browser) {
|
|
562
|
-
parts.push(` %c${escapeFormatString(`in ${rest.duration}`)}%c`);
|
|
563
|
-
styles.push(cssColors.dim, cssColors.reset);
|
|
564
|
-
} else
|
|
565
|
-
parts.push(` ${colors.dim}in ${rest.duration}${colors.reset}`);
|
|
566
|
-
delete rest.duration;
|
|
567
|
-
}
|
|
568
|
-
console.log(parts.join(""), ...styles);
|
|
569
|
-
const aiData = rest.ai;
|
|
570
|
-
if (aiData && typeof aiData === "object")
|
|
571
|
-
delete rest.ai;
|
|
572
|
-
const restEntries = Object.entries(rest).filter(([_, v]) => v !== undefined);
|
|
573
|
-
const aiEntries = aiData ? buildAIEntries(aiData) : [];
|
|
574
|
-
const allEntries = [...restEntries.map(([key, value]) => ({
|
|
575
|
-
key,
|
|
576
|
-
value: formatValue(value)
|
|
577
|
-
})), ...aiEntries];
|
|
578
|
-
for (let i = 0;i < allEntries.length; i++) {
|
|
579
|
-
const entry = allEntries[i];
|
|
580
|
-
const hasChildren = entry.children && entry.children.length > 0;
|
|
581
|
-
const prefix = i === allEntries.length - 1 && !hasChildren ? "\u2514\u2500" : "\u251C\u2500";
|
|
582
|
-
if (browser) {
|
|
583
|
-
const val = entry.value ? ` ${escapeFormatString(entry.value)}` : "";
|
|
584
|
-
console.log(` %c${prefix}%c %c${escapeFormatString(entry.key)}:%c${val}`, cssColors.dim, cssColors.reset, cssColors.cyan, cssColors.reset);
|
|
585
|
-
} else {
|
|
586
|
-
const val = entry.value ? ` ${entry.value}` : "";
|
|
587
|
-
console.log(` ${colors.dim}${prefix}${colors.reset} ${colors.cyan}${entry.key}:${colors.reset}${val}`);
|
|
588
|
-
}
|
|
589
|
-
if (hasChildren) {
|
|
590
|
-
const connector = i === allEntries.length - 1 ? " " : "\u2502";
|
|
591
|
-
for (let j = 0;j < entry.children.length; j++) {
|
|
592
|
-
const child = entry.children[j];
|
|
593
|
-
const childPrefix = j === entry.children.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
594
|
-
if (browser)
|
|
595
|
-
console.log(` %c${connector} ${childPrefix}%c ${escapeFormatString(child)}`, cssColors.dim, cssColors.reset);
|
|
596
|
-
else
|
|
597
|
-
console.log(` ${colors.dim}${connector} ${childPrefix}${colors.reset} ${child}`);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function createLogMethod(level) {
|
|
603
|
-
return function logMethod(tagOrEvent, message) {
|
|
604
|
-
if (typeof tagOrEvent === "string" && message !== undefined)
|
|
605
|
-
emitTaggedLog(level, tagOrEvent, message);
|
|
606
|
-
else if (typeof tagOrEvent === "object")
|
|
607
|
-
emitWideEvent(level, tagOrEvent);
|
|
608
|
-
else
|
|
609
|
-
emitTaggedLog(level, "log", String(tagOrEvent));
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
var _log = {
|
|
613
|
-
info: createLogMethod("info"),
|
|
614
|
-
error: createLogMethod("error"),
|
|
615
|
-
warn: createLogMethod("warn"),
|
|
616
|
-
debug: createLogMethod("debug")
|
|
617
|
-
};
|
|
618
|
-
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
619
|
-
initLogger(__EVLOG_CONFIG__);
|
|
620
|
-
// src/link.tsx
|
|
621
|
-
import {
|
|
622
|
-
createContext,
|
|
623
|
-
createElement,
|
|
624
|
-
useCallback,
|
|
625
|
-
useContext,
|
|
626
|
-
useEffect,
|
|
627
|
-
useRef,
|
|
628
|
-
useState
|
|
629
|
-
} from "react";
|
|
630
|
-
function buildHref(to, search, hash) {
|
|
631
|
-
let url = to;
|
|
632
|
-
if (search && Object.keys(search).length > 0) {
|
|
633
|
-
const params = new URLSearchParams;
|
|
634
|
-
for (const [k, v] of Object.entries(search)) {
|
|
635
|
-
if (v != null) {
|
|
636
|
-
params.set(k, String(v));
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const qs = params.toString();
|
|
640
|
-
if (qs) {
|
|
641
|
-
url += `?${qs}`;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
if (hash) {
|
|
645
|
-
url += `#${hash}`;
|
|
646
|
-
}
|
|
647
|
-
return url;
|
|
648
|
-
}
|
|
649
|
-
function applyRevalidateHeader(headers, invalidate) {
|
|
650
|
-
const headerValue = headers.get("x-furin-revalidate");
|
|
651
|
-
if (!headerValue) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
for (const entry of headerValue.split(",")) {
|
|
655
|
-
const trimmed = entry.trim();
|
|
656
|
-
if (!trimmed) {
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
if (trimmed.endsWith(":layout")) {
|
|
660
|
-
invalidate(trimmed.slice(0, -":layout".length), "layout");
|
|
661
|
-
} else {
|
|
662
|
-
invalidate(trimmed, "page");
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function shouldAutoRefreshPath(currentPath, invalidations) {
|
|
667
|
-
const normalizedCurrent = currentPath.split("?")[0] ?? currentPath;
|
|
668
|
-
return invalidations.some(({ path, type }) => {
|
|
669
|
-
if (type === "page") {
|
|
670
|
-
return path === normalizedCurrent;
|
|
671
|
-
}
|
|
672
|
-
const prefix = path === "/" || path.endsWith("/") ? path : `${path}/`;
|
|
673
|
-
return normalizedCurrent === path || normalizedCurrent.startsWith(prefix);
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
var RouterContext = createContext(null);
|
|
677
|
-
function useRouter() {
|
|
678
|
-
return useContext(RouterContext) ?? {
|
|
679
|
-
basePath: "",
|
|
680
|
-
currentHref: "/",
|
|
681
|
-
navigate: (href) => {
|
|
682
|
-
window.location.href = href;
|
|
683
|
-
return Promise.resolve();
|
|
684
|
-
},
|
|
685
|
-
prefetch: () => {},
|
|
686
|
-
invalidatePrefetch: () => {},
|
|
687
|
-
refresh: () => {
|
|
688
|
-
window.location.reload();
|
|
689
|
-
return Promise.resolve();
|
|
690
|
-
},
|
|
691
|
-
isNavigating: false,
|
|
692
|
-
defaultPreload: "intent",
|
|
693
|
-
defaultPreloadDelay: 50,
|
|
694
|
-
defaultPreloadStaleTime: 30000
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
function shouldRefetch(entry) {
|
|
698
|
-
return Date.now() - entry.createdAt > entry.staleTime;
|
|
699
|
-
}
|
|
700
|
-
var HASH_FRAGMENT_RE = /#.*$/;
|
|
701
|
-
function stripHashFromHref(href) {
|
|
702
|
-
return href.replace(HASH_FRAGMENT_RE, "");
|
|
703
|
-
}
|
|
704
|
-
function buildPageElement(match, root, data) {
|
|
705
|
-
let element = createElement(match.component, data);
|
|
706
|
-
const allLayouts = [];
|
|
707
|
-
let current = match.pageRoute;
|
|
708
|
-
while (current) {
|
|
709
|
-
if (current.layout) {
|
|
710
|
-
allLayouts.unshift(current.layout);
|
|
711
|
-
}
|
|
712
|
-
current = current.parent;
|
|
713
|
-
}
|
|
714
|
-
const layouts = root ? allLayouts.slice(1) : allLayouts;
|
|
715
|
-
for (let i = layouts.length - 1;i >= 0; i--) {
|
|
716
|
-
const Layout = layouts[i];
|
|
717
|
-
if (Layout) {
|
|
718
|
-
element = createElement(Layout, { ...data }, element);
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
if (root?.layout) {
|
|
722
|
-
element = createElement(root.layout, { ...data }, element);
|
|
723
|
-
}
|
|
724
|
-
return element;
|
|
725
|
-
}
|
|
726
|
-
function handleScrollRestoration(href, navigationToken, navVersion) {
|
|
727
|
-
const destUrl = new URL(href, window.location.origin);
|
|
728
|
-
if (destUrl.hash) {
|
|
729
|
-
const id = decodeURIComponent(destUrl.hash.slice(1));
|
|
730
|
-
const scrollToHashTarget = () => {
|
|
731
|
-
if (navVersion.current !== navigationToken) {
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
const element = document.getElementById(id);
|
|
735
|
-
if (element) {
|
|
736
|
-
element.scrollIntoView({ behavior: "instant", block: "start" });
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
window.requestAnimationFrame(() => {
|
|
740
|
-
scrollToHashTarget();
|
|
741
|
-
if (document.getElementById(id)) {
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
window.requestAnimationFrame(() => {
|
|
745
|
-
scrollToHashTarget();
|
|
746
|
-
});
|
|
747
|
-
});
|
|
748
|
-
} else {
|
|
749
|
-
window.scrollTo({ top: 0, behavior: "instant" });
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
var SCROLL_STORAGE_KEY = "__furin_scroll__";
|
|
753
|
-
function getHistoryKey(state) {
|
|
754
|
-
return state?._furinKey;
|
|
755
|
-
}
|
|
756
|
-
function generateHistoryKey() {
|
|
757
|
-
return Math.random().toString(36).slice(2, 9);
|
|
758
|
-
}
|
|
759
|
-
function saveScrollPosition(key) {
|
|
760
|
-
try {
|
|
761
|
-
const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);
|
|
762
|
-
const positions = raw ? JSON.parse(raw) : {};
|
|
763
|
-
positions[key] = window.scrollY;
|
|
764
|
-
const keys = Object.keys(positions);
|
|
765
|
-
if (keys.length > 50) {
|
|
766
|
-
delete positions[keys[0]];
|
|
767
|
-
}
|
|
768
|
-
sessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(positions));
|
|
769
|
-
} catch {}
|
|
770
|
-
}
|
|
771
|
-
function restoreScrollPosition(key, token, version) {
|
|
772
|
-
try {
|
|
773
|
-
const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);
|
|
774
|
-
const positions = raw ? JSON.parse(raw) : {};
|
|
775
|
-
const y = positions[key] ?? 0;
|
|
776
|
-
window.requestAnimationFrame(() => {
|
|
777
|
-
window.requestAnimationFrame(() => {
|
|
778
|
-
if (version.current !== token) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
window.scrollTo({ top: y, behavior: "instant" });
|
|
782
|
-
});
|
|
783
|
-
});
|
|
784
|
-
} catch {
|
|
785
|
-
window.scrollTo({ top: 0, behavior: "instant" });
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function toLogical(physicalPathname, basePath) {
|
|
789
|
-
if (basePath && physicalPathname.startsWith(basePath) && (physicalPathname.length === basePath.length || physicalPathname[basePath.length] === "/")) {
|
|
790
|
-
return physicalPathname.slice(basePath.length) || "/";
|
|
791
|
-
}
|
|
792
|
-
return physicalPathname;
|
|
793
|
-
}
|
|
794
|
-
function RouterProvider({
|
|
795
|
-
routes,
|
|
796
|
-
root,
|
|
797
|
-
initialMatch,
|
|
798
|
-
initialData,
|
|
799
|
-
autoRefresh = true,
|
|
800
|
-
basePath = "",
|
|
801
|
-
defaultPreload = "intent",
|
|
802
|
-
defaultPreloadDelay = 50,
|
|
803
|
-
defaultPreloadStaleTime = 30000,
|
|
804
|
-
prefetchCacheSize = 50
|
|
805
|
-
}) {
|
|
806
|
-
const [state, setState] = useState({
|
|
807
|
-
match: initialMatch,
|
|
808
|
-
data: initialData
|
|
809
|
-
});
|
|
810
|
-
const [isNavigating, setIsNavigating] = useState(false);
|
|
811
|
-
const [currentHref, setCurrentHref] = useState(() => {
|
|
812
|
-
if (typeof window === "undefined") {
|
|
813
|
-
return "/";
|
|
814
|
-
}
|
|
815
|
-
return toLogical(window.location.pathname, basePath) + window.location.search;
|
|
816
|
-
});
|
|
817
|
-
const prefetchCache = useRef(new Map);
|
|
818
|
-
const navVersion = useRef(0);
|
|
819
|
-
const fetchPageState = useCallback(async (logicalHref) => {
|
|
820
|
-
try {
|
|
821
|
-
const physicalHref = basePath + logicalHref;
|
|
822
|
-
const url = new URL(physicalHref, window.location.origin);
|
|
823
|
-
const logicalPathname = toLogical(url.pathname, basePath);
|
|
824
|
-
const match = routes.find((r) => r.regex.test(logicalPathname));
|
|
825
|
-
if (!match) {
|
|
826
|
-
return null;
|
|
827
|
-
}
|
|
828
|
-
const [res, loadedMod] = await Promise.all([fetch(physicalHref), match.load()]);
|
|
829
|
-
const serverBuildId = res.headers.get("x-furin-build-id");
|
|
830
|
-
if (serverBuildId) {
|
|
831
|
-
const metaEl = typeof document === "undefined" ? null : document.querySelector('meta[name="furin-build-id"]');
|
|
832
|
-
const clientBuildId = metaEl?.content;
|
|
833
|
-
if (clientBuildId && serverBuildId !== clientBuildId) {
|
|
834
|
-
window.location.href = physicalHref;
|
|
835
|
-
return null;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
if (!res.ok) {
|
|
839
|
-
_log.warn({ action: "navigate_server_error", href: physicalHref, status: res.status });
|
|
840
|
-
return null;
|
|
841
|
-
}
|
|
842
|
-
let finalHref;
|
|
843
|
-
if (res.redirected) {
|
|
844
|
-
const final = new URL(res.url);
|
|
845
|
-
finalHref = toLogical(final.pathname, basePath) + final.search;
|
|
846
|
-
}
|
|
847
|
-
const html = await res.text();
|
|
848
|
-
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
849
|
-
const dataEl = doc.getElementById("__FURIN_DATA__");
|
|
850
|
-
const data = dataEl ? JSON.parse(dataEl.textContent || "{}") : {};
|
|
851
|
-
const loadedMatch = {
|
|
852
|
-
...match,
|
|
853
|
-
component: loadedMod.default.component,
|
|
854
|
-
pageRoute: loadedMod.default._route
|
|
855
|
-
};
|
|
856
|
-
return { match: loadedMatch, data, title: doc.title, finalHref };
|
|
857
|
-
} catch (err) {
|
|
858
|
-
_log.error({ action: "navigate_failed", href: basePath + logicalHref, error: String(err) });
|
|
859
|
-
return null;
|
|
860
|
-
}
|
|
861
|
-
}, [routes, basePath]);
|
|
862
|
-
const invalidatePrefetch = useCallback((path, type = "page") => {
|
|
863
|
-
const normalizedPath = stripHashFromHref(path);
|
|
864
|
-
if (type === "page") {
|
|
865
|
-
for (const key of [...prefetchCache.current.keys()]) {
|
|
866
|
-
if (stripHashFromHref(key) === normalizedPath) {
|
|
867
|
-
prefetchCache.current.delete(key);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
const prefix = normalizedPath === "/" || normalizedPath.endsWith("/") ? normalizedPath : `${normalizedPath}/`;
|
|
873
|
-
for (const key of [...prefetchCache.current.keys()]) {
|
|
874
|
-
const normalizedKey = stripHashFromHref(key);
|
|
875
|
-
if (normalizedKey === normalizedPath || normalizedKey.startsWith(prefix)) {
|
|
876
|
-
prefetchCache.current.delete(key);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}, []);
|
|
880
|
-
const prefetch = useCallback((href, opts) => {
|
|
881
|
-
const staleTime = opts?.staleTime ?? defaultPreloadStaleTime;
|
|
882
|
-
const existing = prefetchCache.current.get(href);
|
|
883
|
-
if (existing && !shouldRefetch(existing)) {
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
prefetchCache.current.set(href, {
|
|
887
|
-
promise: fetchPageState(href),
|
|
888
|
-
createdAt: Date.now(),
|
|
889
|
-
staleTime
|
|
890
|
-
});
|
|
891
|
-
if (prefetchCache.current.size > prefetchCacheSize) {
|
|
892
|
-
const oldest = prefetchCache.current.keys().next().value;
|
|
893
|
-
prefetchCache.current.delete(oldest);
|
|
894
|
-
}
|
|
895
|
-
}, [fetchPageState, defaultPreloadStaleTime, prefetchCacheSize]);
|
|
896
|
-
const navigate = useCallback(async (logicalHref, opts) => {
|
|
897
|
-
prefetch(logicalHref);
|
|
898
|
-
const myVersion = ++navVersion.current;
|
|
899
|
-
setIsNavigating(true);
|
|
900
|
-
try {
|
|
901
|
-
const newState = await prefetchCache.current.get(logicalHref)?.promise;
|
|
902
|
-
if (navVersion.current !== myVersion) {
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
if (!newState) {
|
|
906
|
-
_log.warn({
|
|
907
|
-
action: "navigate_fallback",
|
|
908
|
-
href: logicalHref,
|
|
909
|
-
reason: "prefetch_returned_null"
|
|
910
|
-
});
|
|
911
|
-
window.location.href = basePath + logicalHref;
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
|
-
setState(newState);
|
|
915
|
-
if (newState.title) {
|
|
916
|
-
document.title = newState.title;
|
|
917
|
-
}
|
|
918
|
-
const effectiveLogical = newState.finalHref ?? logicalHref;
|
|
919
|
-
const physicalEffective = basePath + effectiveLogical;
|
|
920
|
-
if (opts?.replace) {
|
|
921
|
-
window.history.replaceState({
|
|
922
|
-
...history.state ?? {},
|
|
923
|
-
_furinKey: getHistoryKey(history.state) ?? generateHistoryKey()
|
|
924
|
-
}, "", physicalEffective);
|
|
925
|
-
} else {
|
|
926
|
-
const currentKey = getHistoryKey(history.state);
|
|
927
|
-
if (currentKey) {
|
|
928
|
-
saveScrollPosition(currentKey);
|
|
929
|
-
}
|
|
930
|
-
window.history.pushState({ _furinKey: generateHistoryKey() }, "", physicalEffective);
|
|
931
|
-
}
|
|
932
|
-
const effectiveUrl = new URL(physicalEffective, window.location.origin);
|
|
933
|
-
const logicalPath = toLogical(effectiveUrl.pathname, basePath);
|
|
934
|
-
setCurrentHref(logicalPath + effectiveUrl.search);
|
|
935
|
-
if (opts?.resetScroll ?? true) {
|
|
936
|
-
handleScrollRestoration(physicalEffective, myVersion, navVersion);
|
|
937
|
-
}
|
|
938
|
-
} finally {
|
|
939
|
-
if (navVersion.current === myVersion) {
|
|
940
|
-
setIsNavigating(false);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}, [prefetch, basePath]);
|
|
944
|
-
const refresh = useCallback(async (opts) => {
|
|
945
|
-
const logicalPath = toLogical(window.location.pathname, basePath);
|
|
946
|
-
const logicalHref = logicalPath + window.location.search;
|
|
947
|
-
invalidatePrefetch(logicalHref, "page");
|
|
948
|
-
await navigate(logicalHref, { replace: true, resetScroll: opts?.resetScroll ?? false });
|
|
949
|
-
}, [navigate, invalidatePrefetch, basePath]);
|
|
950
|
-
const handlePopState = useCallback(async () => {
|
|
951
|
-
const destKey = getHistoryKey(history.state);
|
|
952
|
-
const logicalPath = toLogical(window.location.pathname, basePath);
|
|
953
|
-
const logicalHref = logicalPath + window.location.search;
|
|
954
|
-
const myVersion = ++navVersion.current;
|
|
955
|
-
setIsNavigating(true);
|
|
956
|
-
try {
|
|
957
|
-
const cached = prefetchCache.current.get(logicalHref);
|
|
958
|
-
let newState;
|
|
959
|
-
if (cached && !shouldRefetch(cached)) {
|
|
960
|
-
newState = await cached.promise;
|
|
961
|
-
} else {
|
|
962
|
-
newState = await fetchPageState(logicalHref);
|
|
963
|
-
}
|
|
964
|
-
if (navVersion.current !== myVersion) {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
if (!newState) {
|
|
968
|
-
_log.warn({
|
|
969
|
-
action: "popstate_fallback",
|
|
970
|
-
href: logicalHref,
|
|
971
|
-
reason: "fetchPageState_returned_null"
|
|
972
|
-
});
|
|
973
|
-
window.location.reload();
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
setState(newState);
|
|
977
|
-
if (newState.title) {
|
|
978
|
-
document.title = newState.title;
|
|
979
|
-
}
|
|
980
|
-
const effectiveLogical = newState.finalHref ?? logicalHref;
|
|
981
|
-
if (newState.finalHref) {
|
|
982
|
-
window.history.replaceState(history.state, "", basePath + effectiveLogical);
|
|
983
|
-
}
|
|
984
|
-
setCurrentHref(effectiveLogical);
|
|
985
|
-
if (destKey) {
|
|
986
|
-
restoreScrollPosition(destKey, myVersion, navVersion);
|
|
987
|
-
} else {
|
|
988
|
-
window.scrollTo({ top: 0, behavior: "instant" });
|
|
989
|
-
}
|
|
990
|
-
} finally {
|
|
991
|
-
if (navVersion.current === myVersion) {
|
|
992
|
-
setIsNavigating(false);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}, [fetchPageState, basePath]);
|
|
996
|
-
useEffect(() => {
|
|
997
|
-
const prevScrollRestoration = history.scrollRestoration;
|
|
998
|
-
history.scrollRestoration = "manual";
|
|
999
|
-
if (!getHistoryKey(history.state)) {
|
|
1000
|
-
history.replaceState({ ...history.state ?? {}, _furinKey: generateHistoryKey() }, "");
|
|
1001
|
-
}
|
|
1002
|
-
return () => {
|
|
1003
|
-
history.scrollRestoration = prevScrollRestoration;
|
|
1004
|
-
};
|
|
1005
|
-
}, []);
|
|
1006
|
-
useEffect(() => {
|
|
1007
|
-
window.addEventListener("popstate", handlePopState);
|
|
1008
|
-
return () => window.removeEventListener("popstate", handlePopState);
|
|
1009
|
-
}, [handlePopState]);
|
|
1010
|
-
useEffect(() => {
|
|
1011
|
-
if (typeof window === "undefined") {
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
const originalFetch = window.fetch;
|
|
1015
|
-
const wrapped = async (...args) => {
|
|
1016
|
-
const response = await originalFetch.apply(window, args);
|
|
1017
|
-
const invalidated = [];
|
|
1018
|
-
applyRevalidateHeader(response.headers, (path, type = "page") => {
|
|
1019
|
-
invalidatePrefetch(path, type);
|
|
1020
|
-
invalidated.push({ path, type });
|
|
1021
|
-
});
|
|
1022
|
-
if (autoRefresh && invalidated.length > 0) {
|
|
1023
|
-
const currentPath = window.location.pathname + window.location.search;
|
|
1024
|
-
if (shouldAutoRefreshPath(currentPath, invalidated)) {
|
|
1025
|
-
refresh();
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
return response;
|
|
1029
|
-
};
|
|
1030
|
-
Object.assign(wrapped, originalFetch);
|
|
1031
|
-
window.fetch = wrapped;
|
|
1032
|
-
return () => {
|
|
1033
|
-
window.fetch = originalFetch;
|
|
1034
|
-
};
|
|
1035
|
-
}, [invalidatePrefetch, refresh, autoRefresh]);
|
|
1036
|
-
return createElement(RouterContext.Provider, {
|
|
1037
|
-
value: {
|
|
1038
|
-
basePath,
|
|
1039
|
-
currentHref,
|
|
1040
|
-
navigate,
|
|
1041
|
-
prefetch,
|
|
1042
|
-
refresh,
|
|
1043
|
-
invalidatePrefetch,
|
|
1044
|
-
isNavigating,
|
|
1045
|
-
defaultPreload,
|
|
1046
|
-
defaultPreloadDelay,
|
|
1047
|
-
defaultPreloadStaleTime
|
|
1048
|
-
}
|
|
1049
|
-
}, buildPageElement(state.match, root, state.data));
|
|
1050
|
-
}
|
|
1051
|
-
function computeLinkView({
|
|
1052
|
-
to,
|
|
1053
|
-
search,
|
|
1054
|
-
hash,
|
|
1055
|
-
children,
|
|
1056
|
-
activeProps,
|
|
1057
|
-
inactiveProps
|
|
1058
|
-
}, router) {
|
|
1059
|
-
const logicalHref = buildHref(to, search, hash);
|
|
1060
|
-
const logicalHrefWithoutHash = buildHref(to, search, undefined);
|
|
1061
|
-
const href = router.basePath + logicalHref;
|
|
1062
|
-
const isActive = router.currentHref === logicalHrefWithoutHash;
|
|
1063
|
-
const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
|
|
1064
|
-
const extraProps = {
|
|
1065
|
-
...inactiveProps && !isActive ? inactiveProps() : {},
|
|
1066
|
-
...activeProps ? activeProps({ isActive }) : {}
|
|
1067
|
-
};
|
|
1068
|
-
return { logicalHref, href, isActive, resolvedChildren, extraProps };
|
|
1069
|
-
}
|
|
1070
|
-
function LinkInteractive({
|
|
1071
|
-
to,
|
|
1072
|
-
search,
|
|
1073
|
-
hash,
|
|
1074
|
-
preload,
|
|
1075
|
-
preloadDelay,
|
|
1076
|
-
preloadStaleTime,
|
|
1077
|
-
replace,
|
|
1078
|
-
disabled,
|
|
1079
|
-
resetScroll,
|
|
1080
|
-
activeProps,
|
|
1081
|
-
inactiveProps,
|
|
1082
|
-
onClick,
|
|
1083
|
-
onMouseEnter,
|
|
1084
|
-
onMouseLeave,
|
|
1085
|
-
onFocus,
|
|
1086
|
-
children,
|
|
1087
|
-
...anchorProps
|
|
1088
|
-
}) {
|
|
1089
|
-
const router = useRouter();
|
|
1090
|
-
const anchorRef = useRef(null);
|
|
1091
|
-
const intentTimerRef = useRef(null);
|
|
1092
|
-
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
|
|
1093
|
-
const effectivePreload = preload ?? router.defaultPreload;
|
|
1094
|
-
const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
|
|
1095
|
-
const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
|
|
1096
|
-
const triggerPrefetch = useCallback(() => {
|
|
1097
|
-
router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
1098
|
-
}, [router, logicalHref, effectiveStaleTime]);
|
|
1099
|
-
useEffect(() => {
|
|
1100
|
-
if (effectivePreload === "render") {
|
|
1101
|
-
triggerPrefetch();
|
|
1102
|
-
}
|
|
1103
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
1104
|
-
useEffect(() => {
|
|
1105
|
-
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
1109
|
-
if (entry?.isIntersecting) {
|
|
1110
|
-
triggerPrefetch();
|
|
1111
|
-
observer.disconnect();
|
|
1112
|
-
}
|
|
1113
|
-
}, { rootMargin: "200px" });
|
|
1114
|
-
observer.observe(anchorRef.current);
|
|
1115
|
-
return () => observer.disconnect();
|
|
1116
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
1117
|
-
const isInternal = (url) => {
|
|
1118
|
-
try {
|
|
1119
|
-
return new URL(url, window.location.origin).origin === window.location.origin;
|
|
1120
|
-
} catch {
|
|
1121
|
-
return false;
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
const handleClick = (e) => {
|
|
1125
|
-
onClick?.(e);
|
|
1126
|
-
if (e.defaultPrevented || disabled) {
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
if (anchorProps.target && anchorProps.target !== "_self") {
|
|
1133
|
-
return;
|
|
1134
|
-
}
|
|
1135
|
-
if (!isInternal(href)) {
|
|
1136
|
-
return;
|
|
1137
|
-
}
|
|
1138
|
-
e.preventDefault();
|
|
1139
|
-
router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
|
|
1140
|
-
};
|
|
1141
|
-
const handleMouseEnter = (e) => {
|
|
1142
|
-
onMouseEnter?.(e);
|
|
1143
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1144
|
-
intentTimerRef.current = setTimeout(triggerPrefetch, effectiveDelay);
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
const handleMouseLeave = (e) => {
|
|
1148
|
-
onMouseLeave?.(e);
|
|
1149
|
-
if (intentTimerRef.current !== null) {
|
|
1150
|
-
clearTimeout(intentTimerRef.current);
|
|
1151
|
-
intentTimerRef.current = null;
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
const handleFocus = (e) => {
|
|
1155
|
-
onFocus?.(e);
|
|
1156
|
-
if (!disabled && effectivePreload === "intent" && isInternal(href)) {
|
|
1157
|
-
triggerPrefetch();
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
return createElement("a", {
|
|
1161
|
-
ref: anchorRef,
|
|
1162
|
-
href,
|
|
1163
|
-
onClick: handleClick,
|
|
1164
|
-
onMouseEnter: handleMouseEnter,
|
|
1165
|
-
onMouseLeave: handleMouseLeave,
|
|
1166
|
-
onFocus: handleFocus,
|
|
1167
|
-
...isActive ? { "data-status": "active" } : {},
|
|
1168
|
-
...anchorProps,
|
|
1169
|
-
...extraProps,
|
|
1170
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
1171
|
-
}, resolvedChildren);
|
|
1172
|
-
}
|
|
1173
|
-
var SSR_FALLBACK_ROUTER = {
|
|
1174
|
-
basePath: "",
|
|
1175
|
-
currentHref: "/",
|
|
1176
|
-
navigate: () => Promise.resolve(),
|
|
1177
|
-
prefetch: () => {},
|
|
1178
|
-
invalidatePrefetch: () => {},
|
|
1179
|
-
refresh: () => Promise.resolve(),
|
|
1180
|
-
isNavigating: false,
|
|
1181
|
-
defaultPreload: "intent",
|
|
1182
|
-
defaultPreloadDelay: 50,
|
|
1183
|
-
defaultPreloadStaleTime: 30000
|
|
1184
|
-
};
|
|
1185
|
-
function renderLinkElement(props, router) {
|
|
1186
|
-
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
|
|
1187
|
-
const {
|
|
1188
|
-
to: _to,
|
|
1189
|
-
search: _search,
|
|
1190
|
-
hash: _hash,
|
|
1191
|
-
children: _children,
|
|
1192
|
-
activeProps: _ap,
|
|
1193
|
-
inactiveProps: _ip,
|
|
1194
|
-
disabled,
|
|
1195
|
-
preload: _p,
|
|
1196
|
-
preloadDelay: _pd,
|
|
1197
|
-
preloadStaleTime: _ps,
|
|
1198
|
-
replace: _r,
|
|
1199
|
-
resetScroll: _rs,
|
|
1200
|
-
onClick: _oc,
|
|
1201
|
-
onMouseEnter: _ome,
|
|
1202
|
-
onMouseLeave: _oml,
|
|
1203
|
-
onFocus: _of,
|
|
1204
|
-
...anchorProps
|
|
1205
|
-
} = props;
|
|
1206
|
-
return createElement("a", {
|
|
1207
|
-
href,
|
|
1208
|
-
...isActive ? { "data-status": "active" } : {},
|
|
1209
|
-
...anchorProps,
|
|
1210
|
-
...extraProps,
|
|
1211
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
1212
|
-
}, resolvedChildren);
|
|
1213
|
-
}
|
|
1214
|
-
function Link(props) {
|
|
1215
|
-
if (typeof window === "undefined") {
|
|
1216
|
-
return createElement(RouterContext.Consumer, {
|
|
1217
|
-
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
return createElement(LinkInteractive, props);
|
|
1221
|
-
}
|
|
1222
|
-
export {
|
|
1223
|
-
useRouter,
|
|
1224
|
-
shouldRefetch,
|
|
1225
|
-
shouldAutoRefreshPath,
|
|
1226
|
-
buildPageElement,
|
|
1227
|
-
buildHref,
|
|
1228
|
-
applyRevalidateHeader,
|
|
1229
|
-
RouterProvider,
|
|
1230
|
-
RouterContext,
|
|
1231
|
-
Link
|
|
1232
|
-
};
|