@teyik0/furin 0.2.0-alpha.1 → 0.2.0-alpha.3
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 -21
- package/README.md +33 -33
- package/dist/adapter/static.d.ts +1 -1
- package/dist/build/compile-entry.ts +109 -109
- package/dist/build/entry-template.ts +156 -156
- package/dist/build/index.js +1724 -687
- package/dist/build/route-types.d.ts +3 -1
- package/dist/build/server-routes-entry.ts +36 -36
- package/dist/build/shared.d.ts +1 -0
- package/dist/build/ssg-cache.d.ts +1 -1
- package/dist/cli/index.js +1673 -658
- package/dist/client/link.js +883 -89
- package/dist/client/router/index.d.ts +4 -0
- package/dist/client/router/link-utils.d.ts +3 -1
- package/dist/client/router/navigation.d.ts +10 -0
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/search/index.d.ts +18 -0
- package/dist/client/router/search-store.d.ts +21 -0
- package/dist/client/router/types.d.ts +14 -1
- package/dist/client/sync.d.ts +25 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +44 -0
- package/dist/furin.d.ts +9 -1
- package/dist/furin.js +1578 -258
- package/dist/server/auto-invalidate/runtime.d.ts +1 -1
- package/dist/server/dev-page-plugin.d.ts +3 -0
- package/dist/server/render/assemble.d.ts +2 -0
- package/dist/server/render/isr.d.ts +2 -1
- package/dist/server/render/ssg.d.ts +3 -2
- package/dist/server/render/ssr.d.ts +5 -4
- package/dist/server/router/hmr.d.ts +4 -3
- package/dist/server/router/index.d.ts +1 -1
- package/dist/server/router/index.js +1 -2
- package/dist/server/router/index.ts +1 -2
- package/dist/server/router/plugin.d.ts +2 -1
- package/dist/server/router/schemas.d.ts +25 -17
- package/dist/server/sync/config.d.ts +6 -0
- package/dist/server/sync/index.d.ts +4 -0
- package/dist/server/sync/plugin.d.ts +369 -0
- package/dist/server/sync/stream.d.ts +47 -0
- package/dist/shared/search-params.d.ts +17 -0
- package/package.json +10 -5
- package/src/adapter/README.md +13 -13
- package/src/adapter/static.ts +23 -6
- package/src/build/client.ts +152 -149
- package/src/build/compile-entry.ts +109 -109
- package/src/build/entry-template.ts +156 -156
- package/src/build/hydrate.ts +340 -331
- package/src/build/index.ts +152 -152
- package/src/build/route-types.ts +145 -115
- package/src/build/scan-server.ts +95 -95
- package/src/build/server-routes-entry.ts +36 -36
- package/src/build/shared.ts +80 -78
- package/src/build/ssg-cache.ts +32 -31
- package/src/build/types.ts +89 -89
- package/src/client/link.tsx +13 -4
- package/src/client/router/context.ts +2 -0
- package/src/client/router/index.ts +9 -0
- package/src/client/router/link-utils.ts +184 -180
- package/src/client/router/navigation.ts +61 -0
- package/src/client/router/provider.tsx +804 -723
- package/src/client/router/search/index.ts +99 -0
- package/src/client/router/search-store.ts +86 -0
- package/src/client/router/types.ts +276 -263
- package/src/client/sync.ts +98 -0
- package/src/client.ts +369 -355
- package/src/furin.ts +465 -437
- package/src/server/auto-invalidate/runtime.ts +134 -133
- package/src/server/dev-page-plugin.ts +454 -449
- package/src/server/render/assemble.ts +160 -133
- package/src/server/render/isr.ts +323 -295
- package/src/server/render/not-found.ts +2 -0
- package/src/server/render/ssg.ts +15 -4
- package/src/server/render/ssr.ts +585 -545
- package/src/server/router/hmr.ts +14 -10
- package/src/server/router/index.ts +1 -2
- package/src/server/router/patterns.ts +5 -0
- package/src/server/router/plugin.ts +384 -401
- package/src/server/router/schemas.ts +172 -57
- package/src/server/sync/config.ts +29 -0
- package/src/server/sync/index.ts +14 -0
- package/src/server/sync/plugin.ts +108 -0
- package/src/server/sync/stream.ts +144 -0
- package/src/shared/search-params.ts +182 -0
package/dist/client/link.js
CHANGED
|
@@ -1,6 +1,132 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/client/link.tsx
|
|
3
|
-
import { createElement as createElement3, useCallback as
|
|
3
|
+
import { createElement as createElement3, useCallback as useCallback3, useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
4
|
+
|
|
5
|
+
// src/shared/search-params.ts
|
|
6
|
+
function routeSegmentSpecificity(segment) {
|
|
7
|
+
if (segment === "*") {
|
|
8
|
+
return 1;
|
|
9
|
+
}
|
|
10
|
+
if (segment.startsWith(":")) {
|
|
11
|
+
return 2;
|
|
12
|
+
}
|
|
13
|
+
return 3;
|
|
14
|
+
}
|
|
15
|
+
function compareSearchRouteSpecificity(a, b) {
|
|
16
|
+
const aSegments = a.split("/").filter((segment) => segment.length > 0);
|
|
17
|
+
const bSegments = b.split("/").filter((segment) => segment.length > 0);
|
|
18
|
+
const length = Math.max(aSegments.length, bSegments.length);
|
|
19
|
+
for (let i = 0;i < length; i++) {
|
|
20
|
+
const aSegment = aSegments[i];
|
|
21
|
+
const bSegment = bSegments[i];
|
|
22
|
+
if (aSegment === undefined) {
|
|
23
|
+
return -1;
|
|
24
|
+
}
|
|
25
|
+
if (bSegment === undefined) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
const diff = routeSegmentSpecificity(aSegment) - routeSegmentSpecificity(bSegment);
|
|
29
|
+
if (diff !== 0) {
|
|
30
|
+
return diff;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
function isObject(value) {
|
|
36
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
function arraysDeepEqual(a, b) {
|
|
39
|
+
if (a.length !== b.length) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0;i < a.length; i++) {
|
|
43
|
+
if (!deepEqual(a[i], b[i])) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
function objectsDeepEqual(a, b) {
|
|
50
|
+
const aKeys = Object.keys(a);
|
|
51
|
+
if (aKeys.length !== Object.keys(b).length) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
for (const key of aKeys) {
|
|
55
|
+
if (!(Object.hasOwn(b, key) && deepEqual(a[key], b[key]))) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function deepEqual(a, b) {
|
|
62
|
+
if (Object.is(a, b)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
66
|
+
return arraysDeepEqual(a, b);
|
|
67
|
+
}
|
|
68
|
+
if (isObject(a) && isObject(b)) {
|
|
69
|
+
return objectsDeepEqual(a, b);
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
function stripSearchDefaults(search, defaults) {
|
|
74
|
+
if (!defaults) {
|
|
75
|
+
return search;
|
|
76
|
+
}
|
|
77
|
+
const stripped = {};
|
|
78
|
+
for (const [key, value] of Object.entries(search)) {
|
|
79
|
+
if (Object.hasOwn(defaults, key) && deepEqual(value, defaults[key])) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
stripped[key] = value;
|
|
83
|
+
}
|
|
84
|
+
return stripped;
|
|
85
|
+
}
|
|
86
|
+
function appendSearchParamValue(params, key, value) {
|
|
87
|
+
if (value == null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
for (const item of value) {
|
|
92
|
+
if (item != null) {
|
|
93
|
+
params.append(key, typeof item === "object" ? JSON.stringify(item) : String(item));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
params.set(key, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
99
|
+
}
|
|
100
|
+
function buildSearchParams(search, defaults) {
|
|
101
|
+
const params = new URLSearchParams;
|
|
102
|
+
for (const [key, value] of Object.entries(stripSearchDefaults(search, defaults))) {
|
|
103
|
+
appendSearchParamValue(params, key, value);
|
|
104
|
+
}
|
|
105
|
+
return params;
|
|
106
|
+
}
|
|
107
|
+
function findSearchDefaults(pathname, routes) {
|
|
108
|
+
let match;
|
|
109
|
+
for (const route of routes) {
|
|
110
|
+
if (!route.regex.test(pathname)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (!match || compareSearchRouteSpecificity(route.pattern, match.pattern) > 0) {
|
|
114
|
+
match = route;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return match?.searchDefaults;
|
|
118
|
+
}
|
|
119
|
+
function findSearchDefaultsForRouteTarget(to, routes) {
|
|
120
|
+
if (to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//")) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const pathname = new URL(to, "http://furin.local").pathname;
|
|
125
|
+
return findSearchDefaults(pathname, routes);
|
|
126
|
+
} catch {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
4
130
|
|
|
5
131
|
// src/client/router/boundary-tree.tsx
|
|
6
132
|
import { createElement } from "react";
|
|
@@ -460,6 +586,8 @@ var RouterContext = createContext(null);
|
|
|
460
586
|
var CLIENT_FALLBACK_ROUTER = {
|
|
461
587
|
basePath: "",
|
|
462
588
|
currentHref: "/",
|
|
589
|
+
search: {},
|
|
590
|
+
searchRoutes: [],
|
|
463
591
|
navigate: (href, _opts) => {
|
|
464
592
|
window.location.href = href;
|
|
465
593
|
return Promise.resolve();
|
|
@@ -556,15 +684,10 @@ function isStaleDeployResponse(res) {
|
|
|
556
684
|
// src/client/router/link-utils.ts
|
|
557
685
|
var HASH_FRAGMENT_RE = /#.*$/;
|
|
558
686
|
var TRAILING_SLASHES_RE = /\/+$/;
|
|
559
|
-
function buildHref(to, search, hash) {
|
|
687
|
+
function buildHref(to, search, hash, searchDefaults) {
|
|
560
688
|
let url = to;
|
|
561
689
|
if (search && Object.keys(search).length > 0) {
|
|
562
|
-
const params =
|
|
563
|
-
for (const [k, v] of Object.entries(search)) {
|
|
564
|
-
if (v != null) {
|
|
565
|
-
params.set(k, String(v));
|
|
566
|
-
}
|
|
567
|
-
}
|
|
690
|
+
const params = buildSearchParams(search, searchDefaults);
|
|
568
691
|
const qs = params.toString();
|
|
569
692
|
if (qs) {
|
|
570
693
|
url += `?${qs}`;
|
|
@@ -580,7 +703,10 @@ function applyRevalidateHeader(headers, invalidate) {
|
|
|
580
703
|
if (!headerValue) {
|
|
581
704
|
return;
|
|
582
705
|
}
|
|
583
|
-
|
|
706
|
+
applyRevalidateEntries(headerValue.split(","), invalidate);
|
|
707
|
+
}
|
|
708
|
+
function applyRevalidateEntries(entries, invalidate) {
|
|
709
|
+
for (const entry of entries) {
|
|
584
710
|
const trimmed = entry.trim();
|
|
585
711
|
if (!trimmed) {
|
|
586
712
|
continue;
|
|
@@ -662,7 +788,34 @@ function toLogical(physicalPathname, basePath) {
|
|
|
662
788
|
}
|
|
663
789
|
return physicalPathname;
|
|
664
790
|
}
|
|
665
|
-
//
|
|
791
|
+
// src/client/router/navigation.ts
|
|
792
|
+
import { useCallback } from "react";
|
|
793
|
+
function isExternalAbsoluteHref(href) {
|
|
794
|
+
if (href.startsWith("//")) {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
if (!(href.startsWith("http://") || href.startsWith("https://"))) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
if (typeof window === "undefined") {
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
return new URL(href).origin !== window.location.origin;
|
|
804
|
+
}
|
|
805
|
+
function useNavigate() {
|
|
806
|
+
const router = useRouter();
|
|
807
|
+
return useCallback((next) => {
|
|
808
|
+
const searchDefaults = findSearchDefaultsForRouteTarget(next.to, router.searchRoutes);
|
|
809
|
+
const href = buildHref(next.to, next.search, next.hash, searchDefaults);
|
|
810
|
+
if (isExternalAbsoluteHref(href) && typeof window !== "undefined") {
|
|
811
|
+
window.location.assign(href);
|
|
812
|
+
return Promise.resolve();
|
|
813
|
+
}
|
|
814
|
+
const opts = next.replace === undefined && next.resetScroll === undefined ? undefined : { replace: next.replace, resetScroll: next.resetScroll };
|
|
815
|
+
return router.navigate(href, opts);
|
|
816
|
+
}, [router]);
|
|
817
|
+
}
|
|
818
|
+
// ../../node_modules/.bun/evlog@2.19.2+7724ce3de6b3bca4/node_modules/evlog/dist/utils.mjs
|
|
666
819
|
function formatDuration(ms) {
|
|
667
820
|
if (ms < 1000)
|
|
668
821
|
return `${Math.round(ms)}ms`;
|
|
@@ -750,9 +903,451 @@ function getCssLevelColor(level) {
|
|
|
750
903
|
function escapeFormatString(str) {
|
|
751
904
|
return str.replace(/%/g, "%%");
|
|
752
905
|
}
|
|
906
|
+
var SENSITIVE_HEADERS = [
|
|
907
|
+
"authorization",
|
|
908
|
+
"cookie",
|
|
909
|
+
"set-cookie",
|
|
910
|
+
"x-api-key",
|
|
911
|
+
"x-auth-token",
|
|
912
|
+
"proxy-authorization"
|
|
913
|
+
];
|
|
914
|
+
var SENSITIVE_HEADER_SET = new Set(SENSITIVE_HEADERS);
|
|
915
|
+
var patternCache = /* @__PURE__ */ new Map;
|
|
916
|
+
function globToRegExp(pattern, separator = "/") {
|
|
917
|
+
const cacheKey = `${separator}:${pattern}`;
|
|
918
|
+
let regex = patternCache.get(cacheKey);
|
|
919
|
+
if (!regex) {
|
|
920
|
+
const segment = separator === "/" ? "[^/]*" : "[^.]*";
|
|
921
|
+
const char = separator === "/" ? "[^/]" : "[^.]";
|
|
922
|
+
const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, segment).replace(/{{GLOBSTAR}}/g, ".*").replace(/\?/g, char);
|
|
923
|
+
regex = new RegExp(`^${regexPattern}$`);
|
|
924
|
+
patternCache.set(cacheKey, regex);
|
|
925
|
+
}
|
|
926
|
+
return regex;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// ../../node_modules/.bun/evlog@2.19.2+7724ce3de6b3bca4/node_modules/evlog/dist/pretty-error-THg0U0w9.mjs
|
|
930
|
+
var snippetReader = null;
|
|
931
|
+
var PRETTY_ERROR_TREE_SPACER = "__EVLOG_TREE_SPACER__";
|
|
932
|
+
function pushTreeSpacer(children) {
|
|
933
|
+
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
934
|
+
}
|
|
935
|
+
var SKIP_PATH_RE = /(?:^|[/\\])(?:node_modules|\.nuxt|\.next|\.output)(?:[/\\]|$)/;
|
|
936
|
+
var SKIP_FRAME_PATH_RE = /(?:^|[/\\])(?:packages[/\\]evlog|evlog[/\\](?:dist|src))(?:[/\\]|$)/;
|
|
937
|
+
var SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
938
|
+
function isPlainObject(val) {
|
|
939
|
+
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
940
|
+
}
|
|
941
|
+
function pickString(obj, key) {
|
|
942
|
+
const val = obj[key];
|
|
943
|
+
return typeof val === "string" && val.length > 0 ? val : undefined;
|
|
944
|
+
}
|
|
945
|
+
function pickNumber(obj, key) {
|
|
946
|
+
const val = obj[key];
|
|
947
|
+
return typeof val === "number" ? val : undefined;
|
|
948
|
+
}
|
|
949
|
+
function extractGuidance(data) {
|
|
950
|
+
return {
|
|
951
|
+
code: pickString(data, "code"),
|
|
952
|
+
why: pickString(data, "why"),
|
|
953
|
+
fix: pickString(data, "fix"),
|
|
954
|
+
link: pickString(data, "link")
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function normalizeErrorContext(error) {
|
|
958
|
+
if (error === null || error === undefined)
|
|
959
|
+
return null;
|
|
960
|
+
if (typeof error === "string")
|
|
961
|
+
return { message: error };
|
|
962
|
+
if (!isPlainObject(error))
|
|
963
|
+
return { message: String(error) };
|
|
964
|
+
const result = {
|
|
965
|
+
message: pickString(error, "message") ?? pickString(error, "statusText") ?? pickString(error, "statusMessage") ?? "Unknown error",
|
|
966
|
+
name: pickString(error, "name"),
|
|
967
|
+
code: pickString(error, "code"),
|
|
968
|
+
why: pickString(error, "why"),
|
|
969
|
+
fix: pickString(error, "fix"),
|
|
970
|
+
link: pickString(error, "link"),
|
|
971
|
+
status: pickNumber(error, "status") ?? pickNumber(error, "statusCode"),
|
|
972
|
+
stack: pickString(error, "stack")
|
|
973
|
+
};
|
|
974
|
+
const { data, cause } = error;
|
|
975
|
+
if (isPlainObject(data)) {
|
|
976
|
+
const guidance = extractGuidance(data);
|
|
977
|
+
if (!result.code)
|
|
978
|
+
result.code = guidance.code;
|
|
979
|
+
if (!result.why)
|
|
980
|
+
result.why = guidance.why;
|
|
981
|
+
if (!result.fix)
|
|
982
|
+
result.fix = guidance.fix;
|
|
983
|
+
if (!result.link)
|
|
984
|
+
result.link = guidance.link;
|
|
985
|
+
}
|
|
986
|
+
if (cause instanceof Error)
|
|
987
|
+
result.cause = cause.message;
|
|
988
|
+
else if (isPlainObject(cause) && pickString(cause, "message"))
|
|
989
|
+
result.cause = pickString(cause, "message");
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
function decodeFileUrl(file) {
|
|
993
|
+
if (file.startsWith("file://"))
|
|
994
|
+
try {
|
|
995
|
+
return decodeURIComponent(new URL(file).pathname);
|
|
996
|
+
} catch {
|
|
997
|
+
return file.slice(7);
|
|
998
|
+
}
|
|
999
|
+
return file;
|
|
1000
|
+
}
|
|
1001
|
+
function isAppPath(file) {
|
|
1002
|
+
const normalized = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1003
|
+
if (normalized.startsWith("node:"))
|
|
1004
|
+
return false;
|
|
1005
|
+
if (SKIP_PATH_RE.test(normalized))
|
|
1006
|
+
return false;
|
|
1007
|
+
if (normalized.includes("/node_modules/"))
|
|
1008
|
+
return false;
|
|
1009
|
+
if (isFrameworkRuntimePath(normalized))
|
|
1010
|
+
return false;
|
|
1011
|
+
return true;
|
|
1012
|
+
}
|
|
1013
|
+
function formatDisplayPath(file, cwd) {
|
|
1014
|
+
const decoded = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1015
|
+
const cwdNorm = cwd.replace(/\\/g, "/").replace(/\/$/, "");
|
|
1016
|
+
if (cwdNorm && decoded.startsWith(`${cwdNorm}/`)) {
|
|
1017
|
+
const rel = decoded.slice(cwdNorm.length + 1);
|
|
1018
|
+
return rel.startsWith("./") ? rel.slice(2) : rel;
|
|
1019
|
+
}
|
|
1020
|
+
const serverIdx = decoded.indexOf("/server/");
|
|
1021
|
+
if (serverIdx >= 0)
|
|
1022
|
+
return decoded.slice(serverIdx + 1);
|
|
1023
|
+
const srcIdx = decoded.indexOf("/src/");
|
|
1024
|
+
if (srcIdx >= 0)
|
|
1025
|
+
return decoded.slice(srcIdx + 1);
|
|
1026
|
+
return decoded;
|
|
1027
|
+
}
|
|
1028
|
+
function parseStackFrames(stack) {
|
|
1029
|
+
if (!stack)
|
|
1030
|
+
return [];
|
|
1031
|
+
const lines = stack.split(`
|
|
1032
|
+
`);
|
|
1033
|
+
const frames = [];
|
|
1034
|
+
for (const line of lines) {
|
|
1035
|
+
const trimmed = line.trim();
|
|
1036
|
+
if (!trimmed.startsWith("at "))
|
|
1037
|
+
continue;
|
|
1038
|
+
const withFn = trimmed.match(/^at (.+?) \((.+):(\d+):(\d+)\)$/);
|
|
1039
|
+
if (withFn) {
|
|
1040
|
+
const [, fn, file, lineStr, colStr] = withFn;
|
|
1041
|
+
frames.push({
|
|
1042
|
+
raw: trimmed,
|
|
1043
|
+
fn,
|
|
1044
|
+
file,
|
|
1045
|
+
line: Number(lineStr),
|
|
1046
|
+
column: Number(colStr),
|
|
1047
|
+
isApp: isAppPath(file)
|
|
1048
|
+
});
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
const withoutFn = trimmed.match(/^at (.+):(\d+):(\d+)$/);
|
|
1052
|
+
if (withoutFn) {
|
|
1053
|
+
const [, file, lineStr, colStr] = withoutFn;
|
|
1054
|
+
frames.push({
|
|
1055
|
+
raw: trimmed,
|
|
1056
|
+
file,
|
|
1057
|
+
line: Number(lineStr),
|
|
1058
|
+
column: Number(colStr),
|
|
1059
|
+
isApp: isAppPath(file)
|
|
1060
|
+
});
|
|
1061
|
+
continue;
|
|
1062
|
+
}
|
|
1063
|
+
const asyncFn = trimmed.match(/^at async (.+?) \((.+):(\d+):(\d+)\)$/);
|
|
1064
|
+
if (asyncFn) {
|
|
1065
|
+
const [, fn, file, lineStr, colStr] = asyncFn;
|
|
1066
|
+
frames.push({
|
|
1067
|
+
raw: trimmed,
|
|
1068
|
+
fn: `async ${fn}`,
|
|
1069
|
+
file,
|
|
1070
|
+
line: Number(lineStr),
|
|
1071
|
+
column: Number(colStr),
|
|
1072
|
+
isApp: isAppPath(file)
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
return frames;
|
|
1077
|
+
}
|
|
1078
|
+
function isFrameworkRuntimePath(path) {
|
|
1079
|
+
const normalized = path.replace(/\\/g, "/");
|
|
1080
|
+
return normalized.includes("route-modules/") || normalized.includes("webpack://next/") || normalized.includes("/next/dist/") || normalized.includes("/compiled/next-server/");
|
|
1081
|
+
}
|
|
1082
|
+
function isFrameworkRuntimeFrame(frame) {
|
|
1083
|
+
if (!frame.file)
|
|
1084
|
+
return false;
|
|
1085
|
+
return isFrameworkRuntimePath(decodeFileUrl(frame.file));
|
|
1086
|
+
}
|
|
1087
|
+
function isInternalErrorFrame(frame) {
|
|
1088
|
+
if (isFrameworkRuntimeFrame(frame))
|
|
1089
|
+
return true;
|
|
1090
|
+
if (frame.fn) {
|
|
1091
|
+
const fn = frame.fn.replace(/^async /, "");
|
|
1092
|
+
if (SKIP_FRAME_FN_RE.test(fn))
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
if (!frame.file)
|
|
1096
|
+
return true;
|
|
1097
|
+
const path = decodeFileUrl(frame.file).replace(/\\/g, "/");
|
|
1098
|
+
if (SKIP_FRAME_PATH_RE.test(path))
|
|
1099
|
+
return true;
|
|
1100
|
+
if (path.includes(".nuxt/"))
|
|
1101
|
+
return true;
|
|
1102
|
+
if (path.includes(".next/"))
|
|
1103
|
+
return true;
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
function pickPrimaryFrame(frames) {
|
|
1107
|
+
for (const frame of frames)
|
|
1108
|
+
if (frame.isApp && frame.file && frame.line && !isInternalErrorFrame(frame))
|
|
1109
|
+
return frame;
|
|
1110
|
+
}
|
|
1111
|
+
function readCodeSnippet(file, line, contextLines = 2) {
|
|
1112
|
+
if (!isDev() || isBrowser() || !snippetReader)
|
|
1113
|
+
return null;
|
|
1114
|
+
const path = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1115
|
+
if (path.includes(".next/") || path.includes(".nuxt/") || path.includes(".output/"))
|
|
1116
|
+
return null;
|
|
1117
|
+
return snippetReader(file, line, contextLines);
|
|
1118
|
+
}
|
|
1119
|
+
function formatSnippetLines(snippet) {
|
|
1120
|
+
const width = String(snippet[snippet.length - 1]?.line ?? 0).length;
|
|
1121
|
+
return snippet.map(({ line, content, isErrorLine }) => {
|
|
1122
|
+
const marker = isErrorLine ? `${colors.red}\u276F${colors.reset}` : `${colors.dim} ${colors.reset}`;
|
|
1123
|
+
const numColor = isErrorLine ? colors.red : colors.gray;
|
|
1124
|
+
const trimmed = content.length > 120 ? `${content.slice(0, 117)}\u2026` : content;
|
|
1125
|
+
return `${marker} ${numColor}${String(line).padStart(width, " ")}${colors.reset} ${colors.dim}\u2503${colors.reset} ${colors.dim}${trimmed}${colors.reset}`;
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
function formatFrameLocation(frame, cwd) {
|
|
1129
|
+
const file = frame.file ? formatDisplayPath(frame.file, cwd) : "unknown";
|
|
1130
|
+
const loc = frame.line ? `${file}:${frame.line}` : file;
|
|
1131
|
+
const fn = frame.fn && frame.fn !== "<unknown>" ? frame.fn : undefined;
|
|
1132
|
+
return fn ? `at ${fn} (${loc})` : `at ${loc}`;
|
|
1133
|
+
}
|
|
1134
|
+
function formatCollapsedFrame(frame, cwd) {
|
|
1135
|
+
const file = frame.file ? formatDisplayPath(frame.file, cwd) : "unknown";
|
|
1136
|
+
const loc = frame.line ? `${file}:${frame.line}` : file;
|
|
1137
|
+
const prefix = frame.fn?.startsWith("async") ? "at async " : "at ";
|
|
1138
|
+
const fn = frame.fn?.replace(/^async /, "");
|
|
1139
|
+
if (fn && fn !== "<unknown>" && fn !== loc)
|
|
1140
|
+
return `${prefix}${fn} (${loc})`;
|
|
1141
|
+
return `${prefix}${loc}`;
|
|
1142
|
+
}
|
|
1143
|
+
var GUIDANCE_WRAP_WIDTH = 76;
|
|
1144
|
+
var GUIDANCE_CONTINUATION = " ";
|
|
1145
|
+
function formatGuidanceLine(label, text, labelColor) {
|
|
1146
|
+
const prefix = `${labelColor}${label}:${colors.reset} `;
|
|
1147
|
+
const lines = [];
|
|
1148
|
+
let remaining = text.trim();
|
|
1149
|
+
let first = true;
|
|
1150
|
+
while (remaining.length > 0) {
|
|
1151
|
+
const budget = first ? Math.max(24, GUIDANCE_WRAP_WIDTH - prefix.length) : Math.max(24, GUIDANCE_WRAP_WIDTH - 5);
|
|
1152
|
+
if (remaining.length <= budget) {
|
|
1153
|
+
lines.push(first ? `${prefix}${remaining}` : `${GUIDANCE_CONTINUATION}${remaining}`);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
let split = remaining.lastIndexOf(" ", budget);
|
|
1157
|
+
if (split <= 0)
|
|
1158
|
+
split = budget;
|
|
1159
|
+
const chunk = remaining.slice(0, split).trimEnd();
|
|
1160
|
+
lines.push(first ? `${prefix}${chunk}` : `${GUIDANCE_CONTINUATION}${chunk}`);
|
|
1161
|
+
remaining = remaining.slice(split).trimStart();
|
|
1162
|
+
first = false;
|
|
1163
|
+
}
|
|
1164
|
+
return lines;
|
|
1165
|
+
}
|
|
1166
|
+
function buildErrorEntries(error, options = {}) {
|
|
1167
|
+
const normalized = normalizeErrorContext(error);
|
|
1168
|
+
if (!normalized)
|
|
1169
|
+
return [];
|
|
1170
|
+
const cwd = options.cwd ?? (typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ".");
|
|
1171
|
+
const compact = options.compact ?? isDev();
|
|
1172
|
+
const guidanceOnly = (options.detail ?? "full") === "guidance";
|
|
1173
|
+
const showFrames = !guidanceOnly && !isBrowser() && (options.snippet ?? isDev());
|
|
1174
|
+
const stackDepth = guidanceOnly ? 0 : options.stackDepth ?? (compact ? 2 : 3);
|
|
1175
|
+
const snippetContextLines = compact ? 1 : 2;
|
|
1176
|
+
const children = [];
|
|
1177
|
+
const frames = guidanceOnly ? [] : parseStackFrames(normalized.stack);
|
|
1178
|
+
const primary = guidanceOnly ? undefined : pickPrimaryFrame(frames);
|
|
1179
|
+
if (!guidanceOnly && primary?.file && primary.line) {
|
|
1180
|
+
pushTreeSpacer(children);
|
|
1181
|
+
if (showFrames) {
|
|
1182
|
+
const snippet = readCodeSnippet(primary.file, primary.line, snippetContextLines);
|
|
1183
|
+
children.push(`${colors.dim} ${formatFrameLocation(primary, cwd)}${colors.reset}`);
|
|
1184
|
+
if (snippet)
|
|
1185
|
+
children.push(...formatSnippetLines(snippet));
|
|
1186
|
+
} else
|
|
1187
|
+
children.push(`${colors.dim} ${formatFrameLocation(primary, cwd)}${colors.reset}`);
|
|
1188
|
+
}
|
|
1189
|
+
if (normalized.code)
|
|
1190
|
+
children.push(`${colors.dim}Code:${colors.reset} ${normalized.code}`);
|
|
1191
|
+
if (Boolean(normalized.why || normalized.fix || normalized.link))
|
|
1192
|
+
pushTreeSpacer(children);
|
|
1193
|
+
if (normalized.why)
|
|
1194
|
+
children.push(...formatGuidanceLine("Why", normalized.why, colors.yellow));
|
|
1195
|
+
if (normalized.fix)
|
|
1196
|
+
children.push(...formatGuidanceLine("Fix", normalized.fix, colors.cyan));
|
|
1197
|
+
if (normalized.link)
|
|
1198
|
+
children.push(`${colors.dim}More:${colors.reset} ${normalized.link}`);
|
|
1199
|
+
if (normalized.cause && normalized.cause !== normalized.message)
|
|
1200
|
+
children.push(`${colors.dim}Caused by:${colors.reset} ${normalized.cause}`);
|
|
1201
|
+
const hiddenCount = guidanceOnly ? 0 : frames.filter((f) => !f.isApp || isInternalErrorFrame(f)).length;
|
|
1202
|
+
const tailFrames = stackDepth > 0 ? frames.filter((f) => f !== primary && !isInternalErrorFrame(f)).slice(0, stackDepth) : [];
|
|
1203
|
+
if (!guidanceOnly && (hiddenCount > 0 || tailFrames.length > 0)) {
|
|
1204
|
+
pushTreeSpacer(children);
|
|
1205
|
+
if (hiddenCount > 0)
|
|
1206
|
+
children.push(`${colors.gray}stack (${hiddenCount} frame${hiddenCount === 1 ? "" : "s"} hidden in node_modules)${colors.reset}`);
|
|
1207
|
+
else
|
|
1208
|
+
children.push(`${colors.gray}stack${colors.reset}`);
|
|
1209
|
+
for (const frame of tailFrames)
|
|
1210
|
+
children.push(`${colors.gray} ${formatCollapsedFrame(frame, cwd)}${colors.reset}`);
|
|
1211
|
+
}
|
|
1212
|
+
return [{
|
|
1213
|
+
key: "error",
|
|
1214
|
+
value: `${colors.red}${colors.bold}${normalized.message}${colors.reset}`,
|
|
1215
|
+
children: children.length > 0 ? children : undefined
|
|
1216
|
+
}];
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// ../../node_modules/.bun/evlog@2.19.2+7724ce3de6b3bca4/node_modules/evlog/dist/dev-terminal-D4UaEm17.mjs
|
|
1220
|
+
var DEV_PRESETS = {
|
|
1221
|
+
evlog: {
|
|
1222
|
+
frameworkOverlay: false,
|
|
1223
|
+
detail: "full"
|
|
1224
|
+
},
|
|
1225
|
+
nitro: {
|
|
1226
|
+
frameworkOverlay: true,
|
|
1227
|
+
detail: "guidance"
|
|
1228
|
+
},
|
|
1229
|
+
both: {
|
|
1230
|
+
frameworkOverlay: true,
|
|
1231
|
+
detail: "full"
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1235
|
+
const compact = partial.compact ?? (inDev && pretty);
|
|
1236
|
+
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
1237
|
+
const stackDepth = detail === "guidance" ? 0 : partial.stackDepth ?? (compact ? 2 : 3);
|
|
1238
|
+
return {
|
|
1239
|
+
snippet: partial.snippet ?? (detail === "full" && pretty && inDev),
|
|
1240
|
+
stackDepth,
|
|
1241
|
+
compact,
|
|
1242
|
+
detail
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
function resolveDevTerminal(input = {}) {
|
|
1246
|
+
const pretty = input.pretty ?? isDev();
|
|
1247
|
+
const inDev = isDev();
|
|
1248
|
+
let frameworkOverlay;
|
|
1249
|
+
let prettyError = {};
|
|
1250
|
+
if (typeof input.dev === "string" && input.dev in DEV_PRESETS) {
|
|
1251
|
+
const { frameworkOverlay: presetOverlay, detail } = DEV_PRESETS[input.dev];
|
|
1252
|
+
frameworkOverlay = presetOverlay;
|
|
1253
|
+
prettyError = { detail };
|
|
1254
|
+
} else if (input.dev && typeof input.dev === "object") {
|
|
1255
|
+
const { frameworkOverlay: devOverlay, prettyError: devPrettyError } = input.dev;
|
|
1256
|
+
frameworkOverlay = devOverlay;
|
|
1257
|
+
if (devPrettyError)
|
|
1258
|
+
prettyError = devPrettyError;
|
|
1259
|
+
}
|
|
1260
|
+
if (frameworkOverlay === undefined)
|
|
1261
|
+
frameworkOverlay = !(pretty && inDev);
|
|
1262
|
+
return {
|
|
1263
|
+
frameworkOverlay,
|
|
1264
|
+
prettyError: finalizePrettyError(prettyError, frameworkOverlay, pretty, inDev)
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
753
1267
|
|
|
754
|
-
// ../../node_modules/.bun/evlog@2.
|
|
1268
|
+
// ../../node_modules/.bun/evlog@2.19.2+7724ce3de6b3bca4/node_modules/evlog/dist/audit-CL0q7GJU.mjs
|
|
755
1269
|
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
1270
|
+
function normalizeRedactPathPattern(pattern) {
|
|
1271
|
+
if (!pattern.includes("*") && !pattern.includes("."))
|
|
1272
|
+
return `**.${pattern}`;
|
|
1273
|
+
return pattern;
|
|
1274
|
+
}
|
|
1275
|
+
function compileRedactPathMatchers(patterns) {
|
|
1276
|
+
if (!patterns?.length)
|
|
1277
|
+
return;
|
|
1278
|
+
const exactPaths = /* @__PURE__ */ new Set;
|
|
1279
|
+
const pathGlobs = [];
|
|
1280
|
+
const keyGlobs = [];
|
|
1281
|
+
const caseInsensitiveLeaves = /* @__PURE__ */ new Set;
|
|
1282
|
+
for (const raw of patterns) {
|
|
1283
|
+
if (!raw.includes("*")) {
|
|
1284
|
+
if (raw.includes("."))
|
|
1285
|
+
exactPaths.add(raw);
|
|
1286
|
+
else
|
|
1287
|
+
addPathGlobPattern(normalizeRedactPathPattern(raw), exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
if (!raw.includes("."))
|
|
1291
|
+
keyGlobs.push(globToRegExp(raw, "."));
|
|
1292
|
+
else
|
|
1293
|
+
addPathGlobPattern(raw, exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1294
|
+
}
|
|
1295
|
+
if (exactPaths.size === 0 && pathGlobs.length === 0 && keyGlobs.length === 0 && caseInsensitiveLeaves.size === 0)
|
|
1296
|
+
return;
|
|
1297
|
+
return {
|
|
1298
|
+
exactPaths,
|
|
1299
|
+
pathGlobs,
|
|
1300
|
+
keyGlobs,
|
|
1301
|
+
caseInsensitiveLeaves
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function addPathGlobPattern(pattern, exactPaths, pathGlobs, caseInsensitiveLeaves) {
|
|
1305
|
+
pathGlobs.push(globToRegExp(pattern, "."));
|
|
1306
|
+
const leaf = pattern.match(/^\*\*\.([^.?*]+)$/);
|
|
1307
|
+
if (leaf) {
|
|
1308
|
+
exactPaths.add(leaf[1]);
|
|
1309
|
+
caseInsensitiveLeaves.add(leaf[1].toLowerCase());
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
function matchesRedactPath(fullPath, leafKey, matchers) {
|
|
1313
|
+
if (matchers.exactPaths.has(fullPath))
|
|
1314
|
+
return true;
|
|
1315
|
+
if (matchers.caseInsensitiveLeaves.has(leafKey.toLowerCase()))
|
|
1316
|
+
return true;
|
|
1317
|
+
for (const glob of matchers.pathGlobs) {
|
|
1318
|
+
glob.lastIndex = 0;
|
|
1319
|
+
if (glob.test(fullPath))
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1322
|
+
for (const glob of matchers.keyGlobs) {
|
|
1323
|
+
glob.lastIndex = 0;
|
|
1324
|
+
if (glob.test(leafKey))
|
|
1325
|
+
return true;
|
|
1326
|
+
}
|
|
1327
|
+
return false;
|
|
1328
|
+
}
|
|
1329
|
+
function redactPathsInTree(obj, matchers, replacement, prefix = "") {
|
|
1330
|
+
if (obj === null || obj === undefined)
|
|
1331
|
+
return;
|
|
1332
|
+
if (Array.isArray(obj)) {
|
|
1333
|
+
for (let i = 0;i < obj.length; i++) {
|
|
1334
|
+
const segment = String(i);
|
|
1335
|
+
const fullPath = prefix ? `${prefix}.${segment}` : segment;
|
|
1336
|
+
redactPathsInTree(obj[i], matchers, replacement, fullPath);
|
|
1337
|
+
}
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
if (typeof obj === "object") {
|
|
1341
|
+
const record = obj;
|
|
1342
|
+
for (const key in record) {
|
|
1343
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
1344
|
+
if (matchesRedactPath(fullPath, key, matchers))
|
|
1345
|
+
record[key] = replacement;
|
|
1346
|
+
else
|
|
1347
|
+
redactPathsInTree(record[key], matchers, replacement, fullPath);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
756
1351
|
var builtinPatterns = {
|
|
757
1352
|
creditCard: {
|
|
758
1353
|
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
@@ -806,11 +1401,15 @@ function resolveRedactConfig(input) {
|
|
|
806
1401
|
if (input === true)
|
|
807
1402
|
return { _maskers: allBuiltinMaskers() };
|
|
808
1403
|
if (input.builtins === false)
|
|
809
|
-
return
|
|
1404
|
+
return {
|
|
1405
|
+
...input,
|
|
1406
|
+
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
1407
|
+
};
|
|
810
1408
|
const maskers = Array.isArray(input.builtins) ? input.builtins.map((name) => builtinPatterns[name]).filter(Boolean).map((b) => [cloneRegex(b.pattern), b.mask]) : allBuiltinMaskers();
|
|
811
1409
|
return {
|
|
812
1410
|
...input,
|
|
813
|
-
_maskers: maskers
|
|
1411
|
+
_maskers: maskers,
|
|
1412
|
+
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
814
1413
|
};
|
|
815
1414
|
}
|
|
816
1415
|
function allBuiltinMaskers() {
|
|
@@ -819,28 +1418,37 @@ function allBuiltinMaskers() {
|
|
|
819
1418
|
function cloneRegex(re) {
|
|
820
1419
|
return new RegExp(re.source, re.flags);
|
|
821
1420
|
}
|
|
1421
|
+
var globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
1422
|
+
function markGloballyRedacted(event) {
|
|
1423
|
+
Object.defineProperty(event, globallyRedacted, {
|
|
1424
|
+
value: true,
|
|
1425
|
+
enumerable: false,
|
|
1426
|
+
configurable: true
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
function cloneForRedaction(event) {
|
|
1430
|
+
try {
|
|
1431
|
+
return structuredClone(event);
|
|
1432
|
+
} catch {
|
|
1433
|
+
try {
|
|
1434
|
+
return JSON.parse(JSON.stringify(event));
|
|
1435
|
+
} catch {
|
|
1436
|
+
console.warn("[cloneForRedaction] Shallow clone used \u2014 nested objects may be mutated by redactPath, redactPatterns, and applyMaskersToTree");
|
|
1437
|
+
return { ...event };
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
822
1441
|
function redactEvent(event, config) {
|
|
1442
|
+
const clone = cloneForRedaction(event);
|
|
823
1443
|
const replacement = config.replacement ?? DEFAULT_REPLACEMENT;
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1444
|
+
const pathMatchers = config._pathMatchers ?? compileRedactPathMatchers(config.paths);
|
|
1445
|
+
if (pathMatchers)
|
|
1446
|
+
redactPathsInTree(clone, pathMatchers, replacement);
|
|
827
1447
|
if (config._maskers?.length)
|
|
828
|
-
applyMaskersToTree(
|
|
1448
|
+
applyMaskersToTree(clone, config._maskers);
|
|
829
1449
|
if (config.patterns?.length)
|
|
830
|
-
redactPatterns(
|
|
831
|
-
|
|
832
|
-
function redactPath(obj, segments, replacement) {
|
|
833
|
-
let current = obj;
|
|
834
|
-
for (let i = 0;i < segments.length - 1; i++) {
|
|
835
|
-
if (current === null || current === undefined || typeof current !== "object")
|
|
836
|
-
return;
|
|
837
|
-
current = current[segments[i]];
|
|
838
|
-
}
|
|
839
|
-
if (current === null || current === undefined || typeof current !== "object")
|
|
840
|
-
return;
|
|
841
|
-
const leaf = segments[segments.length - 1];
|
|
842
|
-
if (leaf in current)
|
|
843
|
-
current[leaf] = replacement;
|
|
1450
|
+
redactPatterns(clone, config.patterns, replacement);
|
|
1451
|
+
return clone;
|
|
844
1452
|
}
|
|
845
1453
|
function redactPatterns(obj, patterns, replacement) {
|
|
846
1454
|
if (obj === null || obj === undefined)
|
|
@@ -866,10 +1474,8 @@ function redactPatterns(obj, patterns, replacement) {
|
|
|
866
1474
|
}
|
|
867
1475
|
function applyPatterns(value, patterns, replacement) {
|
|
868
1476
|
let result = value;
|
|
869
|
-
for (const pattern of patterns)
|
|
870
|
-
pattern.lastIndex = 0;
|
|
1477
|
+
for (const pattern of patterns)
|
|
871
1478
|
result = result.replace(pattern, replacement);
|
|
872
|
-
}
|
|
873
1479
|
return result;
|
|
874
1480
|
}
|
|
875
1481
|
function applyMaskersToTree(obj, maskers) {
|
|
@@ -896,10 +1502,8 @@ function applyMaskersToTree(obj, maskers) {
|
|
|
896
1502
|
}
|
|
897
1503
|
function applyMaskers(value, maskers) {
|
|
898
1504
|
let result = value;
|
|
899
|
-
for (const [pattern, mask] of maskers)
|
|
900
|
-
pattern.lastIndex = 0;
|
|
1505
|
+
for (const [pattern, mask] of maskers)
|
|
901
1506
|
result = result.replace(pattern, mask);
|
|
902
|
-
}
|
|
903
1507
|
return result;
|
|
904
1508
|
}
|
|
905
1509
|
function logPluginError(name, hook, err) {
|
|
@@ -1013,6 +1617,10 @@ var emptyRunner = createPluginRunner([]);
|
|
|
1013
1617
|
function getEmptyPluginRunner() {
|
|
1014
1618
|
return emptyRunner;
|
|
1015
1619
|
}
|
|
1620
|
+
var nativeStdoutWrite = typeof process !== "undefined" && typeof process.stdout?.write === "function" ? process.stdout.write.bind(process.stdout) : undefined;
|
|
1621
|
+
function writePrettyStdout(text) {
|
|
1622
|
+
(globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
|
|
1623
|
+
}
|
|
1016
1624
|
function isPlainObject$1(val) {
|
|
1017
1625
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1018
1626
|
}
|
|
@@ -1026,6 +1634,12 @@ var globalEnv = {
|
|
|
1026
1634
|
environment: "development"
|
|
1027
1635
|
};
|
|
1028
1636
|
var globalPretty = isDev();
|
|
1637
|
+
var globalPrettyError = {
|
|
1638
|
+
snippet: isDev(),
|
|
1639
|
+
stackDepth: 2,
|
|
1640
|
+
compact: isDev(),
|
|
1641
|
+
detail: "full"
|
|
1642
|
+
};
|
|
1029
1643
|
var globalSampling = {};
|
|
1030
1644
|
var globalStringify = true;
|
|
1031
1645
|
var globalDrain;
|
|
@@ -1045,6 +1659,7 @@ function initLogger(config = {}) {
|
|
|
1045
1659
|
region: config.env?.region ?? detected.region
|
|
1046
1660
|
};
|
|
1047
1661
|
globalPretty = config.pretty ?? isDev();
|
|
1662
|
+
globalPrettyError = resolveDevTerminal(config).prettyError;
|
|
1048
1663
|
globalSampling = config.sampling ?? {};
|
|
1049
1664
|
globalStringify = config.stringify ?? true;
|
|
1050
1665
|
globalDrain = config.drain;
|
|
@@ -1102,8 +1717,10 @@ function emitWideEvent(level, event, options = {}) {
|
|
|
1102
1717
|
...event
|
|
1103
1718
|
};
|
|
1104
1719
|
finalizeAudit(formatted);
|
|
1105
|
-
if (globalRedact)
|
|
1106
|
-
redactEvent(formatted, globalRedact);
|
|
1720
|
+
if (globalRedact) {
|
|
1721
|
+
formatted = redactEvent(formatted, globalRedact);
|
|
1722
|
+
markGloballyRedacted(formatted);
|
|
1723
|
+
}
|
|
1107
1724
|
if (!globalSilent)
|
|
1108
1725
|
if (globalPretty)
|
|
1109
1726
|
prettyPrintWideEvent(formatted);
|
|
@@ -1384,11 +2001,34 @@ function buildAIEntries(ai) {
|
|
|
1384
2001
|
});
|
|
1385
2002
|
return entries;
|
|
1386
2003
|
}
|
|
2004
|
+
function flushPrettyLines(lines) {
|
|
2005
|
+
if (lines.length === 0)
|
|
2006
|
+
return;
|
|
2007
|
+
const text = `${lines.join(`
|
|
2008
|
+
`)}
|
|
2009
|
+
`;
|
|
2010
|
+
if (nativeStdoutWrite && !isBrowser() && process.env.VITEST !== "true") {
|
|
2011
|
+
writePrettyStdout(text);
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
console.log(lines.join(`
|
|
2015
|
+
`));
|
|
2016
|
+
}
|
|
1387
2017
|
function prettyPrintWideEvent(event) {
|
|
1388
2018
|
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
1389
2019
|
const ts = typeof timestamp === "string" ? timestamp.slice(11, 23) : "";
|
|
1390
2020
|
const levelLabel = typeof level === "string" ? level : "info";
|
|
1391
2021
|
const browser = isBrowser();
|
|
2022
|
+
const lines = [];
|
|
2023
|
+
const writeLine = (...args) => {
|
|
2024
|
+
if (browser) {
|
|
2025
|
+
console.log(...args);
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
const [line] = args;
|
|
2029
|
+
if (typeof line === "string")
|
|
2030
|
+
lines.push(line);
|
|
2031
|
+
};
|
|
1392
2032
|
const parts = [];
|
|
1393
2033
|
const styles = [];
|
|
1394
2034
|
if (browser) {
|
|
@@ -1397,7 +2037,10 @@ function prettyPrintWideEvent(event) {
|
|
|
1397
2037
|
styles.push(cssColors.dim, cssColors.reset, lc, cssColors.reset, cssColors.cyan, cssColors.reset);
|
|
1398
2038
|
} else {
|
|
1399
2039
|
const lc = getLevelColor(levelLabel);
|
|
1400
|
-
|
|
2040
|
+
if (isDev())
|
|
2041
|
+
parts.push(`${lc}${levelLabel.toUpperCase()}${colors.reset} ${colors.cyan}[${service}]${colors.reset}`);
|
|
2042
|
+
else
|
|
2043
|
+
parts.push(`${colors.dim}${ts}${colors.reset} ${lc}${levelLabel.toUpperCase()}${colors.reset} ${colors.cyan}[${service}]${colors.reset}`);
|
|
1401
2044
|
}
|
|
1402
2045
|
if (rest.method && rest.path) {
|
|
1403
2046
|
parts.push(browser ? ` ${escapeFormatString(String(rest.method))} ${escapeFormatString(String(rest.path))}` : ` ${rest.method} ${rest.path}`);
|
|
@@ -1422,16 +2065,21 @@ function prettyPrintWideEvent(event) {
|
|
|
1422
2065
|
parts.push(` ${colors.dim}in ${rest.duration}${colors.reset}`);
|
|
1423
2066
|
delete rest.duration;
|
|
1424
2067
|
}
|
|
1425
|
-
|
|
2068
|
+
writeLine(parts.join(""), ...styles);
|
|
1426
2069
|
const aiData = isPlainObject$1(rest.ai) ? rest.ai : undefined;
|
|
1427
2070
|
if (aiData)
|
|
1428
2071
|
delete rest.ai;
|
|
2072
|
+
const errorData = rest.error;
|
|
2073
|
+
if (errorData !== undefined)
|
|
2074
|
+
delete rest.error;
|
|
1429
2075
|
const restEntries = Object.entries(rest).filter(([_, v]) => v !== undefined);
|
|
1430
2076
|
const aiEntries = aiData ? buildAIEntries(aiData) : [];
|
|
1431
|
-
const
|
|
2077
|
+
const errorEntries = errorData !== undefined ? buildErrorEntries(errorData, globalPrettyError) : [];
|
|
2078
|
+
const contextEntries = [...restEntries.map(([key, value]) => ({
|
|
1432
2079
|
key,
|
|
1433
2080
|
value: formatValue(value)
|
|
1434
2081
|
})), ...aiEntries];
|
|
2082
|
+
const allEntries = errorEntries.length > 0 ? [...errorEntries, ...contextEntries] : contextEntries;
|
|
1435
2083
|
for (let i = 0;i < allEntries.length; i++) {
|
|
1436
2084
|
const entry = allEntries[i];
|
|
1437
2085
|
if (!entry)
|
|
@@ -1441,10 +2089,10 @@ function prettyPrintWideEvent(event) {
|
|
|
1441
2089
|
const prefix = i === allEntries.length - 1 && !hasChildren ? "\u2514\u2500" : "\u251C\u2500";
|
|
1442
2090
|
if (browser) {
|
|
1443
2091
|
const val = entry.value ? ` ${escapeFormatString(entry.value)}` : "";
|
|
1444
|
-
|
|
2092
|
+
writeLine(` %c${prefix}%c %c${escapeFormatString(entry.key)}:%c${val}`, cssColors.dim, cssColors.reset, cssColors.cyan, cssColors.reset);
|
|
1445
2093
|
} else {
|
|
1446
2094
|
const val = entry.value ? ` ${entry.value}` : "";
|
|
1447
|
-
|
|
2095
|
+
writeLine(` ${colors.dim}${prefix}${colors.reset} ${colors.cyan}${entry.key}:${colors.reset}${val}`);
|
|
1448
2096
|
}
|
|
1449
2097
|
if (hasChildren && children) {
|
|
1450
2098
|
const connector = i === allEntries.length - 1 ? " " : "\u2502";
|
|
@@ -1452,14 +2100,26 @@ function prettyPrintWideEvent(event) {
|
|
|
1452
2100
|
const child = children[j];
|
|
1453
2101
|
if (child === undefined)
|
|
1454
2102
|
continue;
|
|
2103
|
+
if (child === "__EVLOG_TREE_SPACER__") {
|
|
2104
|
+
writeLine(` ${colors.dim}${connector}${colors.reset}`);
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
1455
2107
|
const childPrefix = j === children.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
2108
|
+
if (child === "") {
|
|
2109
|
+
writeLine("");
|
|
2110
|
+
continue;
|
|
2111
|
+
}
|
|
1456
2112
|
if (browser)
|
|
1457
|
-
|
|
2113
|
+
writeLine(` %c${connector} ${childPrefix}%c ${escapeFormatString(child)}`, cssColors.dim, cssColors.reset);
|
|
2114
|
+
else if (child.startsWith(" ") || child.startsWith("\x1B"))
|
|
2115
|
+
writeLine(` ${colors.dim}${connector}${colors.reset}${child}`);
|
|
1458
2116
|
else
|
|
1459
|
-
|
|
2117
|
+
writeLine(` ${colors.dim}${connector} ${childPrefix}${colors.reset} ${child}`);
|
|
1460
2118
|
}
|
|
1461
2119
|
}
|
|
1462
2120
|
}
|
|
2121
|
+
if (!browser && lines.length > 0)
|
|
2122
|
+
flushPrettyLines(lines);
|
|
1463
2123
|
}
|
|
1464
2124
|
function createLogMethod(level) {
|
|
1465
2125
|
return function logMethod(tagOrEvent, message) {
|
|
@@ -1493,21 +2153,24 @@ var noopLogger = {
|
|
|
1493
2153
|
};
|
|
1494
2154
|
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
1495
2155
|
initLogger(__EVLOG_CONFIG__);
|
|
1496
|
-
function
|
|
2156
|
+
function isPlainObject2(value) {
|
|
1497
2157
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
1498
2158
|
return false;
|
|
1499
2159
|
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
1500
2160
|
return false;
|
|
1501
2161
|
return Object.getPrototypeOf(value) === Object.prototype || value.constructor === Object;
|
|
1502
2162
|
}
|
|
1503
|
-
function stableStringify(value) {
|
|
2163
|
+
function stableStringify(value, ancestors = /* @__PURE__ */ new WeakSet) {
|
|
1504
2164
|
if (value === null || typeof value !== "object")
|
|
1505
2165
|
return JSON.stringify(value);
|
|
1506
|
-
if (
|
|
1507
|
-
return
|
|
1508
|
-
if (!
|
|
2166
|
+
if (ancestors.has(value))
|
|
2167
|
+
return '"[Circular]"';
|
|
2168
|
+
if (!Array.isArray(value) && !isPlainObject2(value))
|
|
1509
2169
|
return JSON.stringify(value);
|
|
1510
|
-
|
|
2170
|
+
ancestors.add(value);
|
|
2171
|
+
const out = Array.isArray(value) ? `[${value.map((v) => stableStringify(v, ancestors)).join(",")}]` : `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stableStringify(value[k], ancestors)}`).join(",")}}`;
|
|
2172
|
+
ancestors.delete(value);
|
|
2173
|
+
return out;
|
|
1511
2174
|
}
|
|
1512
2175
|
function fnv1a32(input, seed) {
|
|
1513
2176
|
let h = seed >>> 0;
|
|
@@ -1538,6 +2201,7 @@ function computeIdempotencyKey(audit, timestamp) {
|
|
|
1538
2201
|
const d = fnv1a32(payload, 1541459225).toString(16).padStart(8, "0");
|
|
1539
2202
|
return a + b + c + d;
|
|
1540
2203
|
}
|
|
2204
|
+
var _testCollector = null;
|
|
1541
2205
|
function decorateAudit(audit, timestamp) {
|
|
1542
2206
|
if (audit.idempotencyKey)
|
|
1543
2207
|
return audit;
|
|
@@ -1550,11 +2214,12 @@ function finalizeAudit(event) {
|
|
|
1550
2214
|
const a = event.audit;
|
|
1551
2215
|
if (!a)
|
|
1552
2216
|
return;
|
|
1553
|
-
|
|
2217
|
+
const decorated = decorateAudit(a, String(event.timestamp));
|
|
2218
|
+
event.audit = decorated;
|
|
2219
|
+
_testCollector?.(decorated, event);
|
|
1554
2220
|
}
|
|
1555
|
-
|
|
1556
2221
|
// src/client/router/provider.tsx
|
|
1557
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2222
|
+
import { useCallback as useCallback2, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
1558
2223
|
|
|
1559
2224
|
// ../../node_modules/.bun/seroval@1.5.4/node_modules/seroval/dist/esm/development/index.mjs
|
|
1560
2225
|
var ALL_ENABLED = 1 | 2 | 4 | 8 | 16 | 32;
|
|
@@ -2680,6 +3345,64 @@ async function readDeferredLines(readLine, resolvers) {
|
|
|
2680
3345
|
}
|
|
2681
3346
|
}
|
|
2682
3347
|
|
|
3348
|
+
// src/client/router/search-store.ts
|
|
3349
|
+
import { createContext as createContext2 } from "react";
|
|
3350
|
+
function searchSnapshotChanged(a, b) {
|
|
3351
|
+
return a.currentHref !== b.currentHref || a.navigate !== b.navigate || a.search !== b.search || a.searchRoutes !== b.searchRoutes;
|
|
3352
|
+
}
|
|
3353
|
+
function createSearchStore(initialSnapshot) {
|
|
3354
|
+
let snapshot = initialSnapshot;
|
|
3355
|
+
let version = 0;
|
|
3356
|
+
let flushedVersion = 0;
|
|
3357
|
+
const listeners = new Set;
|
|
3358
|
+
return {
|
|
3359
|
+
flush: () => {
|
|
3360
|
+
if (flushedVersion === version) {
|
|
3361
|
+
return;
|
|
3362
|
+
}
|
|
3363
|
+
flushedVersion = version;
|
|
3364
|
+
for (const listener of [...listeners]) {
|
|
3365
|
+
listener();
|
|
3366
|
+
}
|
|
3367
|
+
},
|
|
3368
|
+
getServerSnapshot: () => snapshot,
|
|
3369
|
+
getSnapshot: () => snapshot,
|
|
3370
|
+
setSnapshot: (next) => {
|
|
3371
|
+
if (!searchSnapshotChanged(snapshot, next)) {
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
snapshot = next;
|
|
3375
|
+
version++;
|
|
3376
|
+
},
|
|
3377
|
+
subscribe: (listener) => {
|
|
3378
|
+
listeners.add(listener);
|
|
3379
|
+
return () => {
|
|
3380
|
+
listeners.delete(listener);
|
|
3381
|
+
};
|
|
3382
|
+
}
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
function searchSnapshotFromRouterContext(context) {
|
|
3386
|
+
return {
|
|
3387
|
+
currentHref: context.currentHref,
|
|
3388
|
+
navigate: context.navigate,
|
|
3389
|
+
search: context.search,
|
|
3390
|
+
searchRoutes: context.searchRoutes
|
|
3391
|
+
};
|
|
3392
|
+
}
|
|
3393
|
+
var FALLBACK_SEARCH_STORE = createSearchStore({
|
|
3394
|
+
currentHref: "/",
|
|
3395
|
+
navigate: (href, _opts) => {
|
|
3396
|
+
if (typeof window !== "undefined") {
|
|
3397
|
+
window.location.href = href;
|
|
3398
|
+
}
|
|
3399
|
+
return Promise.resolve();
|
|
3400
|
+
},
|
|
3401
|
+
search: {},
|
|
3402
|
+
searchRoutes: []
|
|
3403
|
+
});
|
|
3404
|
+
var SearchStoreContext = createContext2(null);
|
|
3405
|
+
|
|
2683
3406
|
// src/client/router/spa-response.ts
|
|
2684
3407
|
import { createElement as createElement2 } from "react";
|
|
2685
3408
|
function isFurinErrorPayload(value) {
|
|
@@ -2751,6 +3474,8 @@ function detectStaticMode() {
|
|
|
2751
3474
|
}
|
|
2752
3475
|
|
|
2753
3476
|
// src/client/router/provider.tsx
|
|
3477
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
3478
|
+
var EMPTY_SEARCH = {};
|
|
2754
3479
|
function setPrefetchCacheEntry(cache, href, entry, maxSize) {
|
|
2755
3480
|
if (cache.has(href)) {
|
|
2756
3481
|
cache.delete(href);
|
|
@@ -2775,7 +3500,8 @@ function RouterProvider({
|
|
|
2775
3500
|
defaultPreload,
|
|
2776
3501
|
defaultPreloadDelay,
|
|
2777
3502
|
defaultPreloadStaleTime,
|
|
2778
|
-
prefetchCacheSize
|
|
3503
|
+
prefetchCacheSize,
|
|
3504
|
+
syncStream
|
|
2779
3505
|
}) {
|
|
2780
3506
|
const [state, setState] = useState(() => ({
|
|
2781
3507
|
match: initialMatch,
|
|
@@ -2795,6 +3521,8 @@ function RouterProvider({
|
|
|
2795
3521
|
const pendingScrollRef = useRef(null);
|
|
2796
3522
|
const currentMatchRef = useRef(initialMatch);
|
|
2797
3523
|
const staticModeRef = useRef(detectStaticMode());
|
|
3524
|
+
const resolvedSearch = state.data.query ?? EMPTY_SEARCH;
|
|
3525
|
+
const searchStoreRef = useRef(null);
|
|
2798
3526
|
const rootBoundaries = useMemo(() => {
|
|
2799
3527
|
for (const route of routes) {
|
|
2800
3528
|
const depth0 = route.segmentBoundaries?.find((b) => b.depth === 0);
|
|
@@ -2804,7 +3532,7 @@ function RouterProvider({
|
|
|
2804
3532
|
}
|
|
2805
3533
|
return;
|
|
2806
3534
|
}, [routes]);
|
|
2807
|
-
const resolveNoMatchState =
|
|
3535
|
+
const resolveNoMatchState = useCallback2(async (physicalHref, signal) => {
|
|
2808
3536
|
const res = await fetch(physicalHref, { signal });
|
|
2809
3537
|
if (isStaleDeployResponse(res)) {
|
|
2810
3538
|
window.location.href = physicalHref;
|
|
@@ -2825,7 +3553,7 @@ function RouterProvider({
|
|
|
2825
3553
|
notFoundBoundaries: rootBoundaries
|
|
2826
3554
|
};
|
|
2827
3555
|
}, [basePath, rootBoundaries]);
|
|
2828
|
-
const fetchPageState =
|
|
3556
|
+
const fetchPageState = useCallback2(async (rawLogicalHref, signal) => {
|
|
2829
3557
|
const logicalHref = normalizeHref(rawLogicalHref);
|
|
2830
3558
|
try {
|
|
2831
3559
|
const physicalHref = basePath + logicalHref;
|
|
@@ -2903,7 +3631,7 @@ function RouterProvider({
|
|
|
2903
3631
|
return null;
|
|
2904
3632
|
}
|
|
2905
3633
|
}, [routes, basePath, resolveNoMatchState]);
|
|
2906
|
-
const invalidatePrefetch =
|
|
3634
|
+
const invalidatePrefetch = useCallback2((path, type) => {
|
|
2907
3635
|
const normalizedPath = stripHashFromHref(path);
|
|
2908
3636
|
if (type === "page") {
|
|
2909
3637
|
for (const key of [...prefetchCache.current.keys()]) {
|
|
@@ -2921,7 +3649,7 @@ function RouterProvider({
|
|
|
2921
3649
|
}
|
|
2922
3650
|
}
|
|
2923
3651
|
}, []);
|
|
2924
|
-
const prefetch =
|
|
3652
|
+
const prefetch = useCallback2((href, opts) => {
|
|
2925
3653
|
const staleTime = opts?.staleTime ?? defaultPreloadStaleTime;
|
|
2926
3654
|
const existing = prefetchCache.current.get(href);
|
|
2927
3655
|
if (existing && !shouldRefetch(existing)) {
|
|
@@ -2941,7 +3669,7 @@ function RouterProvider({
|
|
|
2941
3669
|
}
|
|
2942
3670
|
return state2;
|
|
2943
3671
|
}
|
|
2944
|
-
const navigate =
|
|
3672
|
+
const navigate = useCallback2(async function navigateTo(rawLogicalHref, opts) {
|
|
2945
3673
|
const logicalHref = normalizeHref(rawLogicalHref);
|
|
2946
3674
|
const myVersion = ++navVersion.current;
|
|
2947
3675
|
navAbortRef.current?.abort();
|
|
@@ -3020,7 +3748,26 @@ function RouterProvider({
|
|
|
3020
3748
|
}
|
|
3021
3749
|
}
|
|
3022
3750
|
}, [basePath, fetchPageState, defaultPreloadStaleTime, prefetchCacheSize]);
|
|
3023
|
-
|
|
3751
|
+
if (searchStoreRef.current === null) {
|
|
3752
|
+
searchStoreRef.current = createSearchStore({
|
|
3753
|
+
currentHref,
|
|
3754
|
+
navigate,
|
|
3755
|
+
search: resolvedSearch,
|
|
3756
|
+
searchRoutes: routes
|
|
3757
|
+
});
|
|
3758
|
+
}
|
|
3759
|
+
const searchStore = searchStoreRef.current;
|
|
3760
|
+
const searchSnapshot = useMemo(() => ({
|
|
3761
|
+
currentHref,
|
|
3762
|
+
navigate,
|
|
3763
|
+
search: resolvedSearch,
|
|
3764
|
+
searchRoutes: routes
|
|
3765
|
+
}), [currentHref, navigate, resolvedSearch, routes]);
|
|
3766
|
+
useLayoutEffect(() => {
|
|
3767
|
+
searchStore.setSnapshot(searchSnapshot);
|
|
3768
|
+
searchStore.flush();
|
|
3769
|
+
}, [searchStore, searchSnapshot]);
|
|
3770
|
+
const refresh = useCallback2(async (opts) => {
|
|
3024
3771
|
const logicalPath = toLogical(window.location.pathname, basePath);
|
|
3025
3772
|
const logicalHref = logicalPath + window.location.search;
|
|
3026
3773
|
invalidatePrefetch(logicalHref, "page");
|
|
@@ -3034,7 +3781,7 @@ function RouterProvider({
|
|
|
3034
3781
|
};
|
|
3035
3782
|
}
|
|
3036
3783
|
}, [refresh]);
|
|
3037
|
-
const handlePopState =
|
|
3784
|
+
const handlePopState = useCallback2(() => {
|
|
3038
3785
|
const destKey = getHistoryKey(history.state);
|
|
3039
3786
|
const logicalPath = normalizeHref(toLogical(window.location.pathname, basePath));
|
|
3040
3787
|
const logicalHref = logicalPath + window.location.search;
|
|
@@ -3172,9 +3919,10 @@ function RouterProvider({
|
|
|
3172
3919
|
const wrapped = async (...args) => {
|
|
3173
3920
|
const response = await originalFetch.apply(window, args);
|
|
3174
3921
|
const invalidated = [];
|
|
3175
|
-
applyRevalidateHeader(response.headers, (path, type
|
|
3176
|
-
|
|
3177
|
-
|
|
3922
|
+
applyRevalidateHeader(response.headers, (path, type) => {
|
|
3923
|
+
const resolvedType = type ?? "page";
|
|
3924
|
+
invalidatePrefetch(path, resolvedType);
|
|
3925
|
+
invalidated.push({ path, type: resolvedType });
|
|
3178
3926
|
});
|
|
3179
3927
|
if (autoRefresh && invalidated.length > 0) {
|
|
3180
3928
|
const currentLogicalPath = normalizeHref(toLogical(window.location.pathname, basePath)) + window.location.search;
|
|
@@ -3190,6 +3938,39 @@ function RouterProvider({
|
|
|
3190
3938
|
window.fetch = originalFetch;
|
|
3191
3939
|
};
|
|
3192
3940
|
}, [invalidatePrefetch, refresh, autoRefresh, basePath]);
|
|
3941
|
+
useEffect(() => {
|
|
3942
|
+
if (!syncStream || typeof window === "undefined" || typeof EventSource === "undefined") {
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
const streamUrl = syncStream.startsWith("/") ? `${basePath}${syncStream}` : `${basePath}/${syncStream}`;
|
|
3946
|
+
const source = new EventSource(streamUrl);
|
|
3947
|
+
const onInvalidate = (event) => {
|
|
3948
|
+
let payload;
|
|
3949
|
+
try {
|
|
3950
|
+
payload = JSON.parse(event.data);
|
|
3951
|
+
} catch {
|
|
3952
|
+
_log.warn({ action: "sync_invalid_event", event: "furin.invalidate" });
|
|
3953
|
+
return;
|
|
3954
|
+
}
|
|
3955
|
+
const invalidations = [];
|
|
3956
|
+
applyRevalidateEntries(payload.invalidations ?? [], (path, type) => {
|
|
3957
|
+
const resolvedType = type ?? "page";
|
|
3958
|
+
invalidatePrefetch(path, resolvedType);
|
|
3959
|
+
invalidations.push({ path, type: resolvedType });
|
|
3960
|
+
});
|
|
3961
|
+
if (autoRefresh && invalidations.length > 0) {
|
|
3962
|
+
const currentLogicalPath = normalizeHref(toLogical(window.location.pathname, basePath)) + window.location.search;
|
|
3963
|
+
if (shouldAutoRefreshPath(currentLogicalPath, invalidations)) {
|
|
3964
|
+
refresh(undefined);
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
};
|
|
3968
|
+
source.addEventListener("furin.invalidate", onInvalidate);
|
|
3969
|
+
return () => {
|
|
3970
|
+
source.removeEventListener("furin.invalidate", onInvalidate);
|
|
3971
|
+
source.close();
|
|
3972
|
+
};
|
|
3973
|
+
}, [syncStream, basePath, invalidatePrefetch, refresh, autoRefresh]);
|
|
3193
3974
|
let pageElement;
|
|
3194
3975
|
if (state.notFound || !state.match) {
|
|
3195
3976
|
pageElement = buildNotFoundPageElement(state.notFoundBoundaries ?? state.match?.segmentBoundaries ?? rootBoundaries, state.notFound ?? {});
|
|
@@ -3203,26 +3984,31 @@ function RouterProvider({
|
|
|
3203
3984
|
resetKey: currentHref
|
|
3204
3985
|
}, state.error);
|
|
3205
3986
|
}
|
|
3206
|
-
return
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3987
|
+
return /* @__PURE__ */ jsxDEV4(SearchStoreContext.Provider, {
|
|
3988
|
+
value: searchStore,
|
|
3989
|
+
children: buildRouterTree({
|
|
3990
|
+
basePath,
|
|
3991
|
+
currentHref,
|
|
3992
|
+
search: resolvedSearch,
|
|
3993
|
+
searchRoutes: routes,
|
|
3994
|
+
navigate,
|
|
3995
|
+
prefetch,
|
|
3996
|
+
refresh,
|
|
3997
|
+
invalidatePrefetch,
|
|
3998
|
+
isNavigating,
|
|
3999
|
+
defaultPreload,
|
|
4000
|
+
defaultPreloadDelay,
|
|
4001
|
+
defaultPreloadStaleTime
|
|
4002
|
+
}, pageElement, {
|
|
4003
|
+
digest: initialDigest,
|
|
4004
|
+
onReset: () => {
|
|
4005
|
+
refresh(undefined).catch((err) => {
|
|
4006
|
+
_log.error({ action: "boundary_reset_failed", error: String(err) });
|
|
4007
|
+
});
|
|
4008
|
+
},
|
|
4009
|
+
resetKey: currentHref
|
|
4010
|
+
})
|
|
4011
|
+
}, undefined, false, undefined, this);
|
|
3226
4012
|
}
|
|
3227
4013
|
// src/client/link.tsx
|
|
3228
4014
|
function computeLinkView({
|
|
@@ -3233,8 +4019,9 @@ function computeLinkView({
|
|
|
3233
4019
|
activeProps,
|
|
3234
4020
|
inactiveProps
|
|
3235
4021
|
}, router2) {
|
|
3236
|
-
const
|
|
3237
|
-
const
|
|
4022
|
+
const searchDefaults = findSearchDefaultsForRouteTarget(to, router2.searchRoutes);
|
|
4023
|
+
const logicalHref = buildHref(to, search, hash, searchDefaults);
|
|
4024
|
+
const logicalHrefWithoutHash = buildHref(to, search, undefined, searchDefaults);
|
|
3238
4025
|
const isAbsolute = logicalHref.startsWith("http://") || logicalHref.startsWith("https://") || logicalHref.startsWith("//");
|
|
3239
4026
|
const href = isAbsolute ? logicalHref : router2.basePath + logicalHref;
|
|
3240
4027
|
const isActive = !isAbsolute && router2.currentHref === normalizeHref(logicalHrefWithoutHash);
|
|
@@ -3273,7 +4060,7 @@ function LinkInteractive({
|
|
|
3273
4060
|
const effectiveDelay = preloadDelay ?? router2.defaultPreloadDelay;
|
|
3274
4061
|
const effectiveStaleTime = preloadStaleTime ?? router2.defaultPreloadStaleTime;
|
|
3275
4062
|
const { prefetch } = router2;
|
|
3276
|
-
const triggerPrefetch =
|
|
4063
|
+
const triggerPrefetch = useCallback3(() => {
|
|
3277
4064
|
prefetch(logicalHref, { staleTime: effectiveStaleTime });
|
|
3278
4065
|
}, [prefetch, logicalHref, effectiveStaleTime]);
|
|
3279
4066
|
useEffect2(() => {
|
|
@@ -3368,6 +4155,8 @@ function LinkInteractive({
|
|
|
3368
4155
|
var SSR_FALLBACK_ROUTER = {
|
|
3369
4156
|
basePath: "",
|
|
3370
4157
|
currentHref: "/",
|
|
4158
|
+
search: {},
|
|
4159
|
+
searchRoutes: [],
|
|
3371
4160
|
navigate: (_href, _opts) => Promise.resolve(),
|
|
3372
4161
|
prefetch: (_href, _opts) => {},
|
|
3373
4162
|
invalidatePrefetch: (_path, _type) => {},
|
|
@@ -3418,11 +4207,13 @@ function Link(props) {
|
|
|
3418
4207
|
}
|
|
3419
4208
|
export {
|
|
3420
4209
|
useRouter,
|
|
4210
|
+
useNavigate,
|
|
3421
4211
|
toLogical,
|
|
3422
4212
|
stripHashFromHref,
|
|
3423
4213
|
shouldRefetch,
|
|
3424
4214
|
shouldInterceptClick,
|
|
3425
4215
|
shouldAutoRefreshPath,
|
|
4216
|
+
searchSnapshotFromRouterContext,
|
|
3426
4217
|
saveScrollPosition,
|
|
3427
4218
|
pickDeepestNotFound,
|
|
3428
4219
|
parsePageResponse,
|
|
@@ -3433,6 +4224,7 @@ export {
|
|
|
3433
4224
|
generateHistoryKey,
|
|
3434
4225
|
fromCrossJSON,
|
|
3435
4226
|
detectStaticMode,
|
|
4227
|
+
createSearchStore,
|
|
3436
4228
|
classifySpaResponse,
|
|
3437
4229
|
buildRouterTree,
|
|
3438
4230
|
buildPageElement,
|
|
@@ -3441,10 +4233,12 @@ export {
|
|
|
3441
4233
|
buildDataEndpoint,
|
|
3442
4234
|
applyRevalidateHeader,
|
|
3443
4235
|
TRAILING_SLASHES_RE,
|
|
4236
|
+
SearchStoreContext,
|
|
3444
4237
|
SSR_FALLBACK_ROUTER,
|
|
3445
4238
|
SCROLL_STORAGE_KEY,
|
|
3446
4239
|
RouterProvider,
|
|
3447
4240
|
RouterContext,
|
|
3448
4241
|
Link,
|
|
4242
|
+
FALLBACK_SEARCH_STORE,
|
|
3449
4243
|
CLIENT_FALLBACK_ROUTER
|
|
3450
4244
|
};
|