@teyik0/furin 0.3.0-alpha.1 → 0.4.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/dist/adapter/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +2 -2
- package/dist/build/compile-entry.d.ts +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +8 -2
- package/dist/build/entry-template.ts +48 -11
- package/dist/build/index.d.ts +2 -2
- package/dist/build/index.js +11720 -7840
- package/dist/build/route-types.d.ts +2 -22
- package/dist/build/shared.d.ts +1 -1
- package/dist/build/ssg-cache.d.ts +14 -1
- package/dist/build/types.d.ts +26 -3
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +11815 -7793
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +3 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +36 -0
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +27 -0
- package/dist/client/hmr.d.ts +12 -0
- package/dist/client/internal/runtime-types.d.ts +3 -1
- package/dist/client/link.js +1392 -940
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +9 -0
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/search/index.d.ts +3 -7
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +40 -34
- package/dist/client.d.ts +4 -159
- package/dist/client.js +197 -21
- package/dist/config.d.ts +25 -8
- package/dist/config.js +15 -7
- package/dist/define-route.d.ts +1358 -0
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +18 -34
- package/dist/furin.js +16038 -9395
- package/dist/plugin/index.js +1401 -223
- package/dist/plugin/route-config-autofix.d.ts +31 -0
- package/dist/plugin/routes.d.ts +28 -0
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +1 -0
- package/dist/rsc/build/index.d.ts +6 -2
- package/dist/rsc.js +3 -3
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +5 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.d.ts +7 -5
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +2 -2
- package/dist/server/devtools/instrumentation.production.d.ts +2 -2
- package/dist/server/devtools/plugin.d.ts +2 -2
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +17 -2
- package/dist/server/internal.js +436 -1
- package/dist/server/logger.d.ts +4 -0
- package/dist/server/render/assemble.d.ts +0 -9
- package/dist/server/render/document.d.ts +4 -0
- package/dist/server/render/element.d.ts +3 -1
- package/dist/server/render/index.d.ts +2 -2
- package/dist/server/render/index.ts +1 -2
- package/dist/server/render/isr.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +1 -1
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +4 -2
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +3 -1
- package/dist/server/render/ssr.d.ts +23 -11
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +24 -0
- package/dist/server/router/hmr.d.ts +16 -8
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +7 -0
- package/dist/server/router/plugin.d.ts +6 -3
- package/dist/server/router/schema-merge.d.ts +2 -2
- package/dist/server/router/schemas.d.ts +5 -5
- package/dist/server/router/source-version.d.ts +2 -0
- package/dist/server/router/types.d.ts +1 -0
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +1115 -985
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/postgres/migrate.js +3 -2
- package/dist/server/sync/stream.d.ts +4 -13
- package/dist/shared/await.d.ts +4 -5
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/elysia-contract.d.ts +41 -0
- package/dist/shared/prefix.d.ts +2 -0
- package/dist/shared/route-map.d.ts +5 -0
- package/dist/shared/utils/index.d.ts +1 -3
- package/package.json +55 -43
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +62 -265
- package/src/adapter/package.ts +34 -22
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +83 -5
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +58 -16
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +48 -11
- package/src/build/hydrate.ts +147 -37
- package/src/build/index.ts +21 -7
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/route-types.ts +19 -114
- package/src/build/shared.ts +3 -2
- package/src/build/ssg-cache.ts +99 -16
- package/src/build/types.ts +32 -3
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +62 -10
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +19 -2
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +38 -0
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +162 -0
- package/src/client/hmr.ts +63 -0
- package/src/client/internal/runtime-types.ts +3 -1
- package/src/client/link.tsx +21 -6
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/index.ts +1 -0
- package/src/client/router/link-utils.ts +26 -0
- package/src/client/router/provider.tsx +190 -65
- package/src/client/router/search/index.ts +4 -12
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +56 -30
- package/src/client.ts +14 -316
- package/src/config.ts +35 -10
- package/src/define-route.ts +972 -0
- package/src/devtools/devtools-element.js +67 -87
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +431 -101
- package/src/plugin/route-config-autofix.ts +1140 -0
- package/src/plugin/routes.ts +1061 -0
- package/src/plugin/transform-client.ts +776 -228
- package/src/plugin/transform-isomorphic.ts +1 -1
- package/src/react-dom-edge.d.ts +6 -0
- package/src/routes.ts +6 -0
- package/src/rsc/build/index.ts +16 -4
- package/src/server/auto-invalidate/registry.ts +2 -2
- package/src/server/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +24 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +110 -52
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +3 -3
- package/src/server/devtools/instrumentation.ts +14 -8
- package/src/server/devtools/plugin.ts +12 -153
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +5 -5
- package/src/server/internal.ts +42 -2
- package/src/server/logger.ts +21 -0
- package/src/server/render/assemble.ts +4 -45
- package/src/server/render/document.tsx +34 -0
- package/src/server/render/element.tsx +31 -15
- package/src/server/render/index.ts +1 -2
- package/src/server/render/isr.ts +70 -24
- package/src/server/render/loaders.ts +43 -8
- package/src/server/render/not-found.ts +77 -29
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +153 -32
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +39 -21
- package/src/server/render/ssr.ts +429 -143
- package/src/server/render/template.ts +128 -2
- package/src/server/router/defined-route.ts +78 -0
- package/src/server/router/discovery.ts +129 -29
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +177 -67
- package/src/server/router/patterns.ts +45 -13
- package/src/server/router/plugin.ts +184 -78
- package/src/server/router/schema-merge.ts +4 -14
- package/src/server/router/schemas.ts +11 -8
- package/src/server/router/source-version.ts +9 -0
- package/src/server/router/types.ts +2 -0
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/postgres/migrate.ts +3 -2
- package/src/server/sync/response.ts +14 -10
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +4 -5
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/elysia-contract.ts +63 -0
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +46 -0
- package/src/shared/utils/index.ts +2 -20
- package/dist/build/server-routes-entry.d.ts +0 -13
- package/dist/build/server-routes-entry.ts +0 -30
- package/dist/server/router/index.d.ts +0 -7
- package/dist/server/router/index.js +0 -27
- package/dist/server/router/index.ts +0 -28
- package/src/build/server-routes-entry.ts +0 -30
- package/src/server/router/index.ts +0 -28
package/dist/client/link.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/client/link.tsx
|
|
3
|
-
import { createElement as
|
|
3
|
+
import { createElement as createElement5, useCallback as useCallback3, useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
4
4
|
|
|
5
5
|
// src/shared/search-params.ts
|
|
6
6
|
function routeSegmentSpecificity(segment) {
|
|
@@ -178,6 +178,18 @@ function isSameOriginFetchResult(input, responseUrl, currentOrigin) {
|
|
|
178
178
|
return false;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
function applyLinkParams(to, params) {
|
|
182
|
+
if (!params) {
|
|
183
|
+
return to;
|
|
184
|
+
}
|
|
185
|
+
let url = to.replaceAll(/:([a-zA-Z0-9_]+)/g, (match, name) => (name in params) ? encodeURIComponent(String(params[name])) : match);
|
|
186
|
+
const wildcard = params["*"];
|
|
187
|
+
if (wildcard !== undefined && url.includes("/*")) {
|
|
188
|
+
const encodedWildcard = String(wildcard).split("/").map(encodeURIComponent).join("/");
|
|
189
|
+
url = url.replace("/*", () => `/${encodedWildcard}`);
|
|
190
|
+
}
|
|
191
|
+
return url;
|
|
192
|
+
}
|
|
181
193
|
function buildHref(to, search, hash, searchDefaults) {
|
|
182
194
|
let url = to;
|
|
183
195
|
if (search && Object.keys(search).length > 0) {
|
|
@@ -314,10 +326,10 @@ function useRouter() {
|
|
|
314
326
|
}
|
|
315
327
|
|
|
316
328
|
// src/client/router/boundary-tree.tsx
|
|
317
|
-
import { createElement } from "react";
|
|
329
|
+
import { createElement as createElement2 } from "react";
|
|
318
330
|
|
|
319
331
|
// src/client/boundaries.tsx
|
|
320
|
-
import { Component, Fragment } from "react";
|
|
332
|
+
import { Component, Fragment as Fragment2 } from "react";
|
|
321
333
|
|
|
322
334
|
// src/shared/digest.ts
|
|
323
335
|
function computeErrorDigest(err) {
|
|
@@ -653,6 +665,145 @@ var DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */ jsxDEV(DefaultNotFo
|
|
|
653
665
|
message: error.message
|
|
654
666
|
}, undefined, false, undefined, this);
|
|
655
667
|
|
|
668
|
+
// src/client/document.tsx
|
|
669
|
+
import { createContext as createContext2, createElement, useContext as useContext2 } from "react";
|
|
670
|
+
import { jsxDEV as jsxDEV2, Fragment } from "react/jsx-dev-runtime";
|
|
671
|
+
var DocumentContext = createContext2(null);
|
|
672
|
+
function serializeJson(value) {
|
|
673
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
674
|
+
}
|
|
675
|
+
function DocumentProvider({
|
|
676
|
+
children,
|
|
677
|
+
value
|
|
678
|
+
}) {
|
|
679
|
+
return /* @__PURE__ */ jsxDEV2(DocumentContext.Provider, {
|
|
680
|
+
value,
|
|
681
|
+
children
|
|
682
|
+
}, undefined, false, undefined, this);
|
|
683
|
+
}
|
|
684
|
+
function useDocumentState() {
|
|
685
|
+
return useContext2(DocumentContext);
|
|
686
|
+
}
|
|
687
|
+
function renderMeta(meta, index) {
|
|
688
|
+
if ("title" in meta) {
|
|
689
|
+
return /* @__PURE__ */ jsxDEV2("title", {
|
|
690
|
+
children: meta.title
|
|
691
|
+
}, `title:${index}`, false, undefined, this);
|
|
692
|
+
}
|
|
693
|
+
if ("script:ld+json" in meta) {
|
|
694
|
+
return /* @__PURE__ */ jsxDEV2("script", {
|
|
695
|
+
dangerouslySetInnerHTML: { __html: serializeJson(meta["script:ld+json"]) },
|
|
696
|
+
type: "application/ld+json"
|
|
697
|
+
}, `json-ld:${index}`, false, undefined, this);
|
|
698
|
+
}
|
|
699
|
+
if ("tagName" in meta) {
|
|
700
|
+
const { tagName, ...attributes } = meta;
|
|
701
|
+
return createElement(tagName, { ...attributes, key: `${tagName}:${index}` });
|
|
702
|
+
}
|
|
703
|
+
return createElement("meta", { ...meta, key: `meta:${index}` });
|
|
704
|
+
}
|
|
705
|
+
function HeadContent() {
|
|
706
|
+
const state = useContext2(DocumentContext);
|
|
707
|
+
if (state === null) {
|
|
708
|
+
throw new Error("[furin] <HeadContent /> must be rendered inside the root layout.");
|
|
709
|
+
}
|
|
710
|
+
return /* @__PURE__ */ jsxDEV2(Fragment, {
|
|
711
|
+
children: [
|
|
712
|
+
/* @__PURE__ */ jsxDEV2("meta", {
|
|
713
|
+
charSet: "utf-8",
|
|
714
|
+
"data-furin-head": ""
|
|
715
|
+
}, undefined, false, undefined, this),
|
|
716
|
+
/* @__PURE__ */ jsxDEV2("meta", {
|
|
717
|
+
content: "width=device-width, initial-scale=1.0",
|
|
718
|
+
name: "viewport"
|
|
719
|
+
}, undefined, false, undefined, this),
|
|
720
|
+
state.assets.buildId ? /* @__PURE__ */ jsxDEV2("meta", {
|
|
721
|
+
content: state.assets.buildId,
|
|
722
|
+
name: "furin-build-id"
|
|
723
|
+
}, undefined, false, undefined, this) : null,
|
|
724
|
+
state.assets.staticMode ? /* @__PURE__ */ jsxDEV2("meta", {
|
|
725
|
+
content: "static",
|
|
726
|
+
name: "furin-mode"
|
|
727
|
+
}, undefined, false, undefined, this) : null,
|
|
728
|
+
state.assets.faviconHref ? /* @__PURE__ */ jsxDEV2("link", {
|
|
729
|
+
href: state.assets.faviconHref,
|
|
730
|
+
rel: "icon"
|
|
731
|
+
}, undefined, false, undefined, this) : null,
|
|
732
|
+
state.assets.stylesheets.map((href) => /* @__PURE__ */ jsxDEV2("link", {
|
|
733
|
+
crossOrigin: "",
|
|
734
|
+
href,
|
|
735
|
+
rel: "stylesheet"
|
|
736
|
+
}, href, false, undefined, this)),
|
|
737
|
+
state.head?.meta?.map(renderMeta),
|
|
738
|
+
state.head?.links?.map((link, index) => /* @__PURE__ */ jsxDEV2("link", {
|
|
739
|
+
...link
|
|
740
|
+
}, `${link.rel}:${link.href}:${index}`, false, undefined, this)),
|
|
741
|
+
state.head?.scripts?.map(({ children, ...attributes }, index) => /* @__PURE__ */ jsxDEV2("script", {
|
|
742
|
+
...attributes,
|
|
743
|
+
dangerouslySetInnerHTML: children === undefined ? undefined : { __html: children }
|
|
744
|
+
}, `script:${index}`, false, undefined, this)),
|
|
745
|
+
state.head?.styles?.map(({ children, type }, index) => /* @__PURE__ */ jsxDEV2("style", {
|
|
746
|
+
dangerouslySetInnerHTML: { __html: children },
|
|
747
|
+
type
|
|
748
|
+
}, `style:${index}`, false, undefined, this))
|
|
749
|
+
]
|
|
750
|
+
}, undefined, true, undefined, this);
|
|
751
|
+
}
|
|
752
|
+
function Scripts() {
|
|
753
|
+
const state = useContext2(DocumentContext);
|
|
754
|
+
if (state === null) {
|
|
755
|
+
throw new Error("[furin] <Scripts /> must be rendered inside the root layout.");
|
|
756
|
+
}
|
|
757
|
+
return /* @__PURE__ */ jsxDEV2(Fragment, {
|
|
758
|
+
children: [
|
|
759
|
+
state.syncJson === undefined ? null : /* @__PURE__ */ jsxDEV2("script", {
|
|
760
|
+
dangerouslySetInnerHTML: { __html: state.syncJson },
|
|
761
|
+
id: "__FURIN_SYNC__",
|
|
762
|
+
type: "application/json"
|
|
763
|
+
}, undefined, false, undefined, this),
|
|
764
|
+
state.dataJson === undefined ? null : /* @__PURE__ */ jsxDEV2("script", {
|
|
765
|
+
dangerouslySetInnerHTML: { __html: state.dataJson },
|
|
766
|
+
id: "__FURIN_DATA__",
|
|
767
|
+
type: "application/json"
|
|
768
|
+
}, undefined, false, undefined, this),
|
|
769
|
+
/* @__PURE__ */ jsxDEV2("script", {
|
|
770
|
+
dangerouslySetInnerHTML: { __html: serializeJson(state.head ?? {}) },
|
|
771
|
+
"data-furin-scripts": "",
|
|
772
|
+
id: "__FURIN_HEAD__",
|
|
773
|
+
type: "application/json"
|
|
774
|
+
}, undefined, false, undefined, this),
|
|
775
|
+
state.assets.frameworkModules.map((src) => /* @__PURE__ */ jsxDEV2("script", {
|
|
776
|
+
crossOrigin: "",
|
|
777
|
+
"data-furin-framework-module": "",
|
|
778
|
+
src,
|
|
779
|
+
type: "module"
|
|
780
|
+
}, src, false, undefined, this)),
|
|
781
|
+
state.assets.entryModule === undefined ? null : /* @__PURE__ */ jsxDEV2("script", {
|
|
782
|
+
crossOrigin: "",
|
|
783
|
+
"data-furin-entry": "",
|
|
784
|
+
src: state.assets.entryModule,
|
|
785
|
+
type: "module"
|
|
786
|
+
}, undefined, false, undefined, this)
|
|
787
|
+
]
|
|
788
|
+
}, undefined, true, undefined, this);
|
|
789
|
+
}
|
|
790
|
+
function FurinDocumentFallback({ children }) {
|
|
791
|
+
return /* @__PURE__ */ jsxDEV2("html", {
|
|
792
|
+
lang: "en",
|
|
793
|
+
children: [
|
|
794
|
+
/* @__PURE__ */ jsxDEV2("head", {
|
|
795
|
+
children: /* @__PURE__ */ jsxDEV2(HeadContent, {}, undefined, false, undefined, this)
|
|
796
|
+
}, undefined, false, undefined, this),
|
|
797
|
+
/* @__PURE__ */ jsxDEV2("body", {
|
|
798
|
+
children: [
|
|
799
|
+
children,
|
|
800
|
+
/* @__PURE__ */ jsxDEV2(Scripts, {}, undefined, false, undefined, this)
|
|
801
|
+
]
|
|
802
|
+
}, undefined, true, undefined, this)
|
|
803
|
+
]
|
|
804
|
+
}, undefined, true, undefined, this);
|
|
805
|
+
}
|
|
806
|
+
|
|
656
807
|
// src/client/server-error.ts
|
|
657
808
|
var SERVER_ERROR_BRAND = "FURIN_SERVER_ERROR";
|
|
658
809
|
|
|
@@ -671,7 +822,7 @@ function isFurinServerError(err) {
|
|
|
671
822
|
}
|
|
672
823
|
|
|
673
824
|
// src/client/boundaries.tsx
|
|
674
|
-
import { jsxDEV as
|
|
825
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
675
826
|
var DEFAULT_ERROR_STATUS = 500;
|
|
676
827
|
var SERVER_RESET_NOOP = () => {};
|
|
677
828
|
function getServerDigest(error) {
|
|
@@ -707,6 +858,9 @@ class FurinErrorBoundary extends Component {
|
|
|
707
858
|
error: normalizeCaughtError(error)
|
|
708
859
|
};
|
|
709
860
|
}
|
|
861
|
+
componentDidCatch(error) {
|
|
862
|
+
if (undefined) {}
|
|
863
|
+
}
|
|
710
864
|
componentDidUpdate(prevProps) {
|
|
711
865
|
if (prevProps.resetKey !== this.props.resetKey && this.state.error) {
|
|
712
866
|
this.reset();
|
|
@@ -728,12 +882,15 @@ class FurinErrorBoundary extends Component {
|
|
|
728
882
|
const finalDigest = serverDigest ?? digest ?? this.props.digest ?? computeErrorDigest(error);
|
|
729
883
|
const message = this.props.fallback ? error.message : getPublicErrorMessage(error);
|
|
730
884
|
const status = isFurinServerError(error) ? error.status : DEFAULT_ERROR_STATUS;
|
|
731
|
-
|
|
885
|
+
const fallback = /* @__PURE__ */ jsxDEV3(Fallback, {
|
|
732
886
|
error: { digest: finalDigest, message, status },
|
|
733
887
|
reset: typeof window === "undefined" ? SERVER_RESET_NOOP : this.reset
|
|
734
888
|
}, undefined, false, undefined, this);
|
|
889
|
+
return this.props.document ? /* @__PURE__ */ jsxDEV3(FurinDocumentFallback, {
|
|
890
|
+
children: fallback
|
|
891
|
+
}, undefined, false, undefined, this) : fallback;
|
|
735
892
|
}
|
|
736
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ jsxDEV3(Fragment2, {
|
|
737
894
|
children: this.props.children
|
|
738
895
|
}, epoch, false, undefined, this);
|
|
739
896
|
}
|
|
@@ -756,11 +913,11 @@ class FurinNotFoundBoundary extends Component {
|
|
|
756
913
|
throw error;
|
|
757
914
|
}
|
|
758
915
|
const Fallback = this.props.fallback ?? DefaultNotFoundFallback;
|
|
759
|
-
return /* @__PURE__ */
|
|
916
|
+
return /* @__PURE__ */ jsxDEV3(Fallback, {
|
|
760
917
|
error: { data: error.data, message: error.message }
|
|
761
918
|
}, undefined, false, undefined, this);
|
|
762
919
|
}
|
|
763
|
-
return /* @__PURE__ */
|
|
920
|
+
return /* @__PURE__ */ jsxDEV3(Fragment2, {
|
|
764
921
|
children: this.props.children
|
|
765
922
|
}, epoch, false, undefined, this);
|
|
766
923
|
}
|
|
@@ -771,14 +928,14 @@ function wrapSegmentBoundaries(inner, segment, options) {
|
|
|
771
928
|
}
|
|
772
929
|
let wrapped = inner;
|
|
773
930
|
if (segment.notFound) {
|
|
774
|
-
wrapped = /* @__PURE__ */
|
|
931
|
+
wrapped = /* @__PURE__ */ jsxDEV3(FurinNotFoundBoundary, {
|
|
775
932
|
fallback: segment.notFound,
|
|
776
933
|
resetKey: options?.resetKey,
|
|
777
934
|
children: wrapped
|
|
778
935
|
}, undefined, false, undefined, this);
|
|
779
936
|
}
|
|
780
937
|
if (segment.error) {
|
|
781
|
-
wrapped = /* @__PURE__ */
|
|
938
|
+
wrapped = /* @__PURE__ */ jsxDEV3(FurinErrorBoundary, {
|
|
782
939
|
fallback: segment.error,
|
|
783
940
|
onReset: options?.onReset,
|
|
784
941
|
resetKey: options?.resetKey,
|
|
@@ -789,11 +946,11 @@ function wrapSegmentBoundaries(inner, segment, options) {
|
|
|
789
946
|
}
|
|
790
947
|
|
|
791
948
|
// src/client/router/boundary-tree.tsx
|
|
792
|
-
import { jsxDEV as
|
|
949
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
793
950
|
function buildRouterTree(context, pageElement, options) {
|
|
794
|
-
return /* @__PURE__ */
|
|
951
|
+
return /* @__PURE__ */ jsxDEV4(RouterContext.Provider, {
|
|
795
952
|
value: context,
|
|
796
|
-
children: /* @__PURE__ */
|
|
953
|
+
children: /* @__PURE__ */ jsxDEV4(FurinErrorBoundary, {
|
|
797
954
|
...options,
|
|
798
955
|
children: pageElement
|
|
799
956
|
}, undefined, false, undefined, this)
|
|
@@ -805,7 +962,7 @@ function RouteErrorThrower({
|
|
|
805
962
|
throw new FurinServerError(error);
|
|
806
963
|
}
|
|
807
964
|
function buildPageElement(match, root, data, options, error) {
|
|
808
|
-
let element = error ?
|
|
965
|
+
let element = error ? createElement2(RouteErrorThrower, { error }) : createElement2(match.component, data);
|
|
809
966
|
const chain = [];
|
|
810
967
|
let current = match.pageRoute;
|
|
811
968
|
while (current) {
|
|
@@ -821,13 +978,13 @@ function buildPageElement(match, root, data, options, error) {
|
|
|
821
978
|
element = wrapSegmentBoundaries(element, byDepth.get(i), options);
|
|
822
979
|
const Layout = chain[i]?.layout;
|
|
823
980
|
if (Layout) {
|
|
824
|
-
element =
|
|
981
|
+
element = createElement2(Layout, data, element);
|
|
825
982
|
}
|
|
826
983
|
}
|
|
827
984
|
if (root) {
|
|
828
985
|
element = wrapSegmentBoundaries(element, byDepth.get(0), options);
|
|
829
986
|
if (root.layout) {
|
|
830
|
-
element =
|
|
987
|
+
element = createElement2(root.layout, data, element);
|
|
831
988
|
}
|
|
832
989
|
}
|
|
833
990
|
return element;
|
|
@@ -880,7 +1037,7 @@ function useNavigate() {
|
|
|
880
1037
|
return router.navigate(href, opts);
|
|
881
1038
|
}, [router]);
|
|
882
1039
|
}
|
|
883
|
-
// ../../node_modules/.bun/evlog@2.
|
|
1040
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/utils.mjs
|
|
884
1041
|
function formatDuration(ms) {
|
|
885
1042
|
if (ms < 1000)
|
|
886
1043
|
return `${Math.round(ms)}ms`;
|
|
@@ -990,559 +1147,294 @@ function globToRegExp(pattern, separator = "/") {
|
|
|
990
1147
|
}
|
|
991
1148
|
return regex;
|
|
992
1149
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
var
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
return
|
|
1005
|
-
}
|
|
1006
|
-
function pickString(obj, key) {
|
|
1007
|
-
const val = obj[key];
|
|
1008
|
-
return typeof val === "string" && val.length > 0 ? val : undefined;
|
|
1150
|
+
var _isoDate = /* @__PURE__ */ new Date;
|
|
1151
|
+
var _isoCachedSecond = -1;
|
|
1152
|
+
var _isoCachedPrefix = "";
|
|
1153
|
+
function isoNow() {
|
|
1154
|
+
const now = Date.now();
|
|
1155
|
+
const sec = Math.floor(now / 1000);
|
|
1156
|
+
if (sec !== _isoCachedSecond) {
|
|
1157
|
+
_isoCachedSecond = sec;
|
|
1158
|
+
_isoDate.setTime(now);
|
|
1159
|
+
_isoCachedPrefix = _isoDate.toISOString().slice(0, 19);
|
|
1160
|
+
}
|
|
1161
|
+
return `${_isoCachedPrefix}.${String(now % 1000).padStart(3, "0")}Z`;
|
|
1009
1162
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1163
|
+
|
|
1164
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/redact-C7FmdhwI.mjs
|
|
1165
|
+
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
1166
|
+
function normalizeRedactPathPattern(pattern) {
|
|
1167
|
+
if (!pattern.includes("*") && !pattern.includes("."))
|
|
1168
|
+
return `**.${pattern}`;
|
|
1169
|
+
return pattern;
|
|
1013
1170
|
}
|
|
1014
|
-
function
|
|
1171
|
+
function compileRedactPathMatchers(patterns) {
|
|
1172
|
+
if (!patterns?.length)
|
|
1173
|
+
return;
|
|
1174
|
+
const exactPaths = /* @__PURE__ */ new Set;
|
|
1175
|
+
const pathGlobs = [];
|
|
1176
|
+
const keyGlobs = [];
|
|
1177
|
+
const caseInsensitiveLeaves = /* @__PURE__ */ new Set;
|
|
1178
|
+
for (const raw of patterns) {
|
|
1179
|
+
if (!raw.includes("*")) {
|
|
1180
|
+
if (raw.includes("."))
|
|
1181
|
+
exactPaths.add(raw);
|
|
1182
|
+
else
|
|
1183
|
+
addPathGlobPattern(normalizeRedactPathPattern(raw), exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1184
|
+
continue;
|
|
1185
|
+
}
|
|
1186
|
+
if (!raw.includes("."))
|
|
1187
|
+
keyGlobs.push(globToRegExp(raw, "."));
|
|
1188
|
+
else
|
|
1189
|
+
addPathGlobPattern(raw, exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1190
|
+
}
|
|
1191
|
+
if (exactPaths.size === 0 && pathGlobs.length === 0 && keyGlobs.length === 0 && caseInsensitiveLeaves.size === 0)
|
|
1192
|
+
return;
|
|
1015
1193
|
return {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1194
|
+
exactPaths,
|
|
1195
|
+
pathGlobs,
|
|
1196
|
+
keyGlobs,
|
|
1197
|
+
caseInsensitiveLeaves
|
|
1020
1198
|
};
|
|
1021
1199
|
}
|
|
1022
|
-
function
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
if (
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
return { message: String(error) };
|
|
1029
|
-
const result = {
|
|
1030
|
-
message: pickString(error, "message") ?? pickString(error, "statusText") ?? pickString(error, "statusMessage") ?? "Unknown error",
|
|
1031
|
-
name: pickString(error, "name"),
|
|
1032
|
-
code: pickString(error, "code"),
|
|
1033
|
-
why: pickString(error, "why"),
|
|
1034
|
-
fix: pickString(error, "fix"),
|
|
1035
|
-
link: pickString(error, "link"),
|
|
1036
|
-
status: pickNumber(error, "status") ?? pickNumber(error, "statusCode"),
|
|
1037
|
-
stack: pickString(error, "stack")
|
|
1038
|
-
};
|
|
1039
|
-
const { data, cause } = error;
|
|
1040
|
-
if (isPlainObject(data)) {
|
|
1041
|
-
const guidance = extractGuidance(data);
|
|
1042
|
-
if (!result.code)
|
|
1043
|
-
result.code = guidance.code;
|
|
1044
|
-
if (!result.why)
|
|
1045
|
-
result.why = guidance.why;
|
|
1046
|
-
if (!result.fix)
|
|
1047
|
-
result.fix = guidance.fix;
|
|
1048
|
-
if (!result.link)
|
|
1049
|
-
result.link = guidance.link;
|
|
1200
|
+
function addPathGlobPattern(pattern, exactPaths, pathGlobs, caseInsensitiveLeaves) {
|
|
1201
|
+
pathGlobs.push(globToRegExp(pattern, "."));
|
|
1202
|
+
const leaf = pattern.match(/^\*\*\.([^.?*]+)$/);
|
|
1203
|
+
if (leaf) {
|
|
1204
|
+
exactPaths.add(leaf[1]);
|
|
1205
|
+
caseInsensitiveLeaves.add(leaf[1].toLowerCase());
|
|
1050
1206
|
}
|
|
1051
|
-
if (cause instanceof Error)
|
|
1052
|
-
result.cause = cause.message;
|
|
1053
|
-
else if (isPlainObject(cause) && pickString(cause, "message"))
|
|
1054
|
-
result.cause = pickString(cause, "message");
|
|
1055
|
-
return result;
|
|
1056
|
-
}
|
|
1057
|
-
function decodeFileUrl(file) {
|
|
1058
|
-
if (file.startsWith("file://"))
|
|
1059
|
-
try {
|
|
1060
|
-
return decodeURIComponent(new URL(file).pathname);
|
|
1061
|
-
} catch {
|
|
1062
|
-
return file.slice(7);
|
|
1063
|
-
}
|
|
1064
|
-
return file;
|
|
1065
|
-
}
|
|
1066
|
-
function isAppPath(file) {
|
|
1067
|
-
const normalized = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1068
|
-
if (normalized.startsWith("node:"))
|
|
1069
|
-
return false;
|
|
1070
|
-
if (SKIP_PATH_RE.test(normalized))
|
|
1071
|
-
return false;
|
|
1072
|
-
if (normalized.includes("/node_modules/"))
|
|
1073
|
-
return false;
|
|
1074
|
-
if (isFrameworkRuntimePath(normalized))
|
|
1075
|
-
return false;
|
|
1076
|
-
return true;
|
|
1077
1207
|
}
|
|
1078
|
-
function
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
if (
|
|
1082
|
-
|
|
1083
|
-
|
|
1208
|
+
function matchesRedactPath(fullPath, leafKey, matchers) {
|
|
1209
|
+
if (matchers.exactPaths.has(fullPath))
|
|
1210
|
+
return true;
|
|
1211
|
+
if (matchers.caseInsensitiveLeaves.has(leafKey.toLowerCase()))
|
|
1212
|
+
return true;
|
|
1213
|
+
for (const glob of matchers.pathGlobs) {
|
|
1214
|
+
glob.lastIndex = 0;
|
|
1215
|
+
if (glob.test(fullPath))
|
|
1216
|
+
return true;
|
|
1084
1217
|
}
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
return decoded;
|
|
1218
|
+
for (const glob of matchers.keyGlobs) {
|
|
1219
|
+
glob.lastIndex = 0;
|
|
1220
|
+
if (glob.test(leafKey))
|
|
1221
|
+
return true;
|
|
1222
|
+
}
|
|
1223
|
+
return false;
|
|
1092
1224
|
}
|
|
1093
|
-
function
|
|
1094
|
-
if (
|
|
1095
|
-
return
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
if (!trimmed.startsWith("at "))
|
|
1102
|
-
continue;
|
|
1103
|
-
const withFn = trimmed.match(/^at (.+?) \((.+):(\d+):(\d+)\)$/);
|
|
1104
|
-
if (withFn) {
|
|
1105
|
-
const [, fn, file, lineStr, colStr] = withFn;
|
|
1106
|
-
frames.push({
|
|
1107
|
-
raw: trimmed,
|
|
1108
|
-
fn,
|
|
1109
|
-
file,
|
|
1110
|
-
line: Number(lineStr),
|
|
1111
|
-
column: Number(colStr),
|
|
1112
|
-
isApp: isAppPath(file)
|
|
1113
|
-
});
|
|
1114
|
-
continue;
|
|
1225
|
+
function resolveReplacement(replacement, matched, ctx) {
|
|
1226
|
+
if (typeof replacement === "string")
|
|
1227
|
+
return replacement;
|
|
1228
|
+
try {
|
|
1229
|
+
const result = replacement(matched, ctx);
|
|
1230
|
+
if (typeof result !== "string") {
|
|
1231
|
+
console.error(`[evlog] redact replacement returned ${typeof result} for "${ctx.path}", expected string \u2014 using ${DEFAULT_REPLACEMENT}`);
|
|
1232
|
+
return DEFAULT_REPLACEMENT;
|
|
1115
1233
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1234
|
+
return result;
|
|
1235
|
+
} catch (err) {
|
|
1236
|
+
console.error(`[evlog] redact replacement failed for "${ctx.path}":`, err);
|
|
1237
|
+
return DEFAULT_REPLACEMENT;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function redactPathsInTree(obj, matchers, replacement, prefix = "") {
|
|
1241
|
+
if (obj === null || obj === undefined)
|
|
1242
|
+
return;
|
|
1243
|
+
if (Array.isArray(obj)) {
|
|
1244
|
+
for (let i = 0;i < obj.length; i++) {
|
|
1245
|
+
const segment = String(i);
|
|
1246
|
+
const fullPath = prefix ? `${prefix}.${segment}` : segment;
|
|
1247
|
+
redactPathsInTree(obj[i], matchers, replacement, fullPath);
|
|
1127
1248
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
if (typeof obj === "object") {
|
|
1252
|
+
const record = obj;
|
|
1253
|
+
for (const key of redactableKeys(record)) {
|
|
1254
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
1255
|
+
if (matchesRedactPath(fullPath, key, matchers))
|
|
1256
|
+
setRedacted(record, key, resolveReplacement(replacement, record[key], {
|
|
1257
|
+
path: fullPath,
|
|
1258
|
+
key
|
|
1259
|
+
}), fullPath);
|
|
1260
|
+
else
|
|
1261
|
+
redactPathsInTree(record[key], matchers, replacement, fullPath);
|
|
1139
1262
|
}
|
|
1140
1263
|
}
|
|
1141
|
-
return frames;
|
|
1142
1264
|
}
|
|
1143
|
-
function
|
|
1144
|
-
|
|
1145
|
-
return normalized.includes("route-modules/") || normalized.includes("webpack://next/") || normalized.includes("/next/dist/") || normalized.includes("/compiled/next-server/");
|
|
1265
|
+
function redactableKeys(record) {
|
|
1266
|
+
return Object.keys(record);
|
|
1146
1267
|
}
|
|
1147
|
-
function
|
|
1148
|
-
if (
|
|
1149
|
-
return
|
|
1150
|
-
|
|
1268
|
+
function setRedacted(record, key, value, path) {
|
|
1269
|
+
if (Reflect.set(record, key, value))
|
|
1270
|
+
return;
|
|
1271
|
+
const desc = Object.getOwnPropertyDescriptor(record, key);
|
|
1272
|
+
if (desc && "value" in desc && desc.configurable) {
|
|
1273
|
+
Object.defineProperty(record, key, {
|
|
1274
|
+
...desc,
|
|
1275
|
+
value
|
|
1276
|
+
});
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
console.warn(`[evlog] redact could not rewrite read-only field "${path}" \u2014 value left as-is`);
|
|
1151
1280
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1281
|
+
var builtinPatterns = {
|
|
1282
|
+
creditCard: {
|
|
1283
|
+
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
1284
|
+
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
1285
|
+
},
|
|
1286
|
+
email: {
|
|
1287
|
+
pattern: /[\w.+-]+@[\w-]+\.[\w.]+/g,
|
|
1288
|
+
mask: (m) => {
|
|
1289
|
+
if (m.indexOf("@") < 1)
|
|
1290
|
+
return "***@***";
|
|
1291
|
+
const tld = m.slice(m.lastIndexOf("."));
|
|
1292
|
+
return `${m[0]}***@***${tld}`;
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
ipv4: {
|
|
1296
|
+
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,
|
|
1297
|
+
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
1298
|
+
},
|
|
1299
|
+
phone: {
|
|
1300
|
+
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
1301
|
+
mask: (m) => {
|
|
1302
|
+
const digits = m.replace(/[^\d]/g, "");
|
|
1303
|
+
if (m.startsWith("+") && digits.length > 4) {
|
|
1304
|
+
const ccMatch = m.match(/^\+\d{1,3}/);
|
|
1305
|
+
return `${ccMatch ? ccMatch[0] : "+"}******${digits.slice(-2)}`;
|
|
1306
|
+
}
|
|
1307
|
+
if (digits.length > 2)
|
|
1308
|
+
return `${"*".repeat(digits.length - 2)}${digits.slice(-2)}`;
|
|
1309
|
+
return "***";
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
jwt: {
|
|
1313
|
+
pattern: /\beyJ[\w-]*\.[\w-]*\.[\w-]*\b/g,
|
|
1314
|
+
mask: () => "eyJ***.***"
|
|
1315
|
+
},
|
|
1316
|
+
bearer: {
|
|
1317
|
+
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
1318
|
+
mask: () => "Bearer ***"
|
|
1319
|
+
},
|
|
1320
|
+
iban: {
|
|
1321
|
+
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,
|
|
1322
|
+
mask: (m) => {
|
|
1323
|
+
const clean = m.replace(/[\s-]/g, "");
|
|
1324
|
+
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
1325
|
+
}
|
|
1159
1326
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1327
|
+
};
|
|
1328
|
+
function resolveRedactConfig(input) {
|
|
1329
|
+
if (input === undefined || input === false)
|
|
1330
|
+
return;
|
|
1331
|
+
if (input === true)
|
|
1332
|
+
return { _maskers: allBuiltinMaskers() };
|
|
1333
|
+
if (input.builtins === false)
|
|
1334
|
+
return {
|
|
1335
|
+
...input,
|
|
1336
|
+
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
1337
|
+
};
|
|
1338
|
+
const maskers = Array.isArray(input.builtins) ? input.builtins.map((name) => builtinPatterns[name]).filter(Boolean).map((b) => [cloneRegex(b.pattern), b.mask]) : allBuiltinMaskers();
|
|
1339
|
+
return {
|
|
1340
|
+
...input,
|
|
1341
|
+
_maskers: maskers,
|
|
1342
|
+
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
1343
|
+
};
|
|
1170
1344
|
}
|
|
1171
|
-
function
|
|
1172
|
-
|
|
1173
|
-
if (frame.isApp && frame.file && frame.line && !isInternalErrorFrame(frame))
|
|
1174
|
-
return frame;
|
|
1345
|
+
function allBuiltinMaskers() {
|
|
1346
|
+
return Object.values(builtinPatterns).map((b) => [cloneRegex(b.pattern), b.mask]);
|
|
1175
1347
|
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1178
|
-
return null;
|
|
1179
|
-
const path = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1180
|
-
if (path.includes(".next/") || path.includes(".nuxt/") || path.includes(".output/"))
|
|
1181
|
-
return null;
|
|
1182
|
-
return snippetReader(file, line, contextLines);
|
|
1348
|
+
function cloneRegex(re) {
|
|
1349
|
+
return new RegExp(re.source, re.flags);
|
|
1183
1350
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
return `${marker} ${numColor}${String(line).padStart(width, " ")}${colors.reset} ${colors.dim}\u2503${colors.reset} ${colors.dim}${trimmed}${colors.reset}`;
|
|
1351
|
+
var globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
1352
|
+
function markGloballyRedacted(event) {
|
|
1353
|
+
Object.defineProperty(event, globallyRedacted, {
|
|
1354
|
+
value: true,
|
|
1355
|
+
enumerable: false,
|
|
1356
|
+
configurable: true
|
|
1191
1357
|
});
|
|
1192
1358
|
}
|
|
1193
|
-
function
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
const prefix = frame.fn?.startsWith("async") ? "at async " : "at ";
|
|
1203
|
-
const fn = frame.fn?.replace(/^async /, "");
|
|
1204
|
-
if (fn && fn !== "<unknown>" && fn !== loc)
|
|
1205
|
-
return `${prefix}${fn} (${loc})`;
|
|
1206
|
-
return `${prefix}${loc}`;
|
|
1207
|
-
}
|
|
1208
|
-
var GUIDANCE_WRAP_WIDTH = 76;
|
|
1209
|
-
var GUIDANCE_CONTINUATION = " ";
|
|
1210
|
-
function formatGuidanceLine(label, text, labelColor) {
|
|
1211
|
-
const prefix = `${labelColor}${label}:${colors.reset} `;
|
|
1212
|
-
const lines = [];
|
|
1213
|
-
let remaining = text.trim();
|
|
1214
|
-
let first = true;
|
|
1215
|
-
while (remaining.length > 0) {
|
|
1216
|
-
const budget = first ? Math.max(24, GUIDANCE_WRAP_WIDTH - prefix.length) : Math.max(24, GUIDANCE_WRAP_WIDTH - 5);
|
|
1217
|
-
if (remaining.length <= budget) {
|
|
1218
|
-
lines.push(first ? `${prefix}${remaining}` : `${GUIDANCE_CONTINUATION}${remaining}`);
|
|
1219
|
-
break;
|
|
1359
|
+
function cloneForRedaction(event) {
|
|
1360
|
+
try {
|
|
1361
|
+
return structuredClone(event);
|
|
1362
|
+
} catch {
|
|
1363
|
+
try {
|
|
1364
|
+
return JSON.parse(JSON.stringify(event));
|
|
1365
|
+
} catch {
|
|
1366
|
+
console.warn("[cloneForRedaction] Shallow clone used \u2014 nested objects may be mutated by redactPath, redactPatterns, and applyMaskersToTree");
|
|
1367
|
+
return { ...event };
|
|
1220
1368
|
}
|
|
1221
|
-
let split = remaining.lastIndexOf(" ", budget);
|
|
1222
|
-
if (split <= 0)
|
|
1223
|
-
split = budget;
|
|
1224
|
-
const chunk = remaining.slice(0, split).trimEnd();
|
|
1225
|
-
lines.push(first ? `${prefix}${chunk}` : `${GUIDANCE_CONTINUATION}${chunk}`);
|
|
1226
|
-
remaining = remaining.slice(split).trimStart();
|
|
1227
|
-
first = false;
|
|
1228
1369
|
}
|
|
1229
|
-
return lines;
|
|
1230
1370
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1371
|
+
function redactEvent(event, config) {
|
|
1372
|
+
const clone = cloneForRedaction(event);
|
|
1373
|
+
const replacement = config.replacement ?? DEFAULT_REPLACEMENT;
|
|
1374
|
+
if (config.transform)
|
|
1375
|
+
try {
|
|
1376
|
+
config.transform(clone);
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
console.error("[evlog] redact transform failed:", err);
|
|
1379
|
+
}
|
|
1380
|
+
const pathMatchers = config._pathMatchers ?? compileRedactPathMatchers(config.paths);
|
|
1381
|
+
if (pathMatchers)
|
|
1382
|
+
redactPathsInTree(clone, pathMatchers, replacement);
|
|
1383
|
+
if (config._maskers?.length)
|
|
1384
|
+
applyMaskersToTree(clone, config._maskers);
|
|
1385
|
+
if (config.patterns?.length)
|
|
1386
|
+
redactPatterns(clone, config.patterns, replacement);
|
|
1387
|
+
return clone;
|
|
1388
|
+
}
|
|
1389
|
+
function redactPatterns(obj, patterns, replacement, prefix = "") {
|
|
1390
|
+
if (obj === null || obj === undefined)
|
|
1391
|
+
return;
|
|
1392
|
+
if (Array.isArray(obj)) {
|
|
1393
|
+
for (let i = 0;i < obj.length; i++) {
|
|
1394
|
+
const key = String(i);
|
|
1395
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
1396
|
+
if (typeof obj[i] === "string")
|
|
1397
|
+
obj[i] = applyPatterns(obj[i], patterns, replacement, fullPath, key);
|
|
1398
|
+
else if (typeof obj[i] === "object")
|
|
1399
|
+
redactPatterns(obj[i], patterns, replacement, fullPath);
|
|
1400
|
+
}
|
|
1401
|
+
return;
|
|
1253
1402
|
}
|
|
1254
|
-
if (
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
if (normalized.cause && normalized.cause !== normalized.message)
|
|
1265
|
-
children.push(`${colors.dim}Caused by:${colors.reset} ${normalized.cause}`);
|
|
1266
|
-
const hiddenCount = guidanceOnly ? 0 : frames.filter((f) => !f.isApp || isInternalErrorFrame(f)).length;
|
|
1267
|
-
const tailFrames = stackDepth > 0 ? frames.filter((f) => f !== primary && !isInternalErrorFrame(f)).slice(0, stackDepth) : [];
|
|
1268
|
-
if (!guidanceOnly && (hiddenCount > 0 || tailFrames.length > 0)) {
|
|
1269
|
-
pushTreeSpacer(children);
|
|
1270
|
-
if (hiddenCount > 0)
|
|
1271
|
-
children.push(`${colors.gray}stack (${hiddenCount} frame${hiddenCount === 1 ? "" : "s"} hidden in node_modules)${colors.reset}`);
|
|
1272
|
-
else
|
|
1273
|
-
children.push(`${colors.gray}stack${colors.reset}`);
|
|
1274
|
-
for (const frame of tailFrames)
|
|
1275
|
-
children.push(`${colors.gray} ${formatCollapsedFrame(frame, cwd)}${colors.reset}`);
|
|
1403
|
+
if (typeof obj === "object") {
|
|
1404
|
+
const record = obj;
|
|
1405
|
+
for (const key of redactableKeys(record)) {
|
|
1406
|
+
const val = record[key];
|
|
1407
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
1408
|
+
if (typeof val === "string")
|
|
1409
|
+
setRedacted(record, key, applyPatterns(val, patterns, replacement, fullPath, key), fullPath);
|
|
1410
|
+
else if (typeof val === "object")
|
|
1411
|
+
redactPatterns(val, patterns, replacement, fullPath);
|
|
1412
|
+
}
|
|
1276
1413
|
}
|
|
1277
|
-
return [{
|
|
1278
|
-
key: "error",
|
|
1279
|
-
value: `${colors.red}${colors.bold}${normalized.message}${colors.reset}`,
|
|
1280
|
-
children: children.length > 0 ? children : undefined
|
|
1281
|
-
}];
|
|
1282
1414
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1415
|
+
function applyPatterns(value, patterns, replacement, path, key) {
|
|
1416
|
+
let result = value;
|
|
1417
|
+
for (const pattern of patterns) {
|
|
1418
|
+
if (typeof replacement === "string") {
|
|
1419
|
+
result = result.replace(pattern, replacement);
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
result = result.replace(pattern, (...args) => {
|
|
1423
|
+
const match = args[0];
|
|
1424
|
+
return resolveReplacement(replacement, match, {
|
|
1425
|
+
path,
|
|
1426
|
+
key,
|
|
1427
|
+
groups: captureGroups(args)
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1297
1430
|
}
|
|
1298
|
-
};
|
|
1299
|
-
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1300
|
-
const compact = partial.compact ?? (inDev && pretty);
|
|
1301
|
-
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
1302
|
-
const stackDepth = detail === "guidance" ? 0 : partial.stackDepth ?? (compact ? 2 : 3);
|
|
1303
|
-
return {
|
|
1304
|
-
snippet: partial.snippet ?? (detail === "full" && pretty && inDev),
|
|
1305
|
-
stackDepth,
|
|
1306
|
-
compact,
|
|
1307
|
-
detail
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
function resolveDevTerminal(input = {}) {
|
|
1311
|
-
const pretty = input.pretty ?? isDev();
|
|
1312
|
-
const inDev = isDev();
|
|
1313
|
-
let frameworkOverlay;
|
|
1314
|
-
let prettyError = {};
|
|
1315
|
-
if (typeof input.dev === "string" && input.dev in DEV_PRESETS) {
|
|
1316
|
-
const { frameworkOverlay: presetOverlay, detail } = DEV_PRESETS[input.dev];
|
|
1317
|
-
frameworkOverlay = presetOverlay;
|
|
1318
|
-
prettyError = { detail };
|
|
1319
|
-
} else if (input.dev && typeof input.dev === "object") {
|
|
1320
|
-
const { frameworkOverlay: devOverlay, prettyError: devPrettyError } = input.dev;
|
|
1321
|
-
frameworkOverlay = devOverlay;
|
|
1322
|
-
if (devPrettyError)
|
|
1323
|
-
prettyError = devPrettyError;
|
|
1324
|
-
}
|
|
1325
|
-
if (frameworkOverlay === undefined)
|
|
1326
|
-
frameworkOverlay = !(pretty && inDev);
|
|
1327
|
-
return {
|
|
1328
|
-
frameworkOverlay,
|
|
1329
|
-
prettyError: finalizePrettyError(prettyError, frameworkOverlay, pretty, inDev)
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
// ../../node_modules/.bun/evlog@2.22.3+6e5ab44a2bca2113/node_modules/evlog/dist/audit-CPODPtOL.mjs
|
|
1334
|
-
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
1335
|
-
function normalizeRedactPathPattern(pattern) {
|
|
1336
|
-
if (!pattern.includes("*") && !pattern.includes("."))
|
|
1337
|
-
return `**.${pattern}`;
|
|
1338
|
-
return pattern;
|
|
1339
|
-
}
|
|
1340
|
-
function compileRedactPathMatchers(patterns) {
|
|
1341
|
-
if (!patterns?.length)
|
|
1342
|
-
return;
|
|
1343
|
-
const exactPaths = /* @__PURE__ */ new Set;
|
|
1344
|
-
const pathGlobs = [];
|
|
1345
|
-
const keyGlobs = [];
|
|
1346
|
-
const caseInsensitiveLeaves = /* @__PURE__ */ new Set;
|
|
1347
|
-
for (const raw of patterns) {
|
|
1348
|
-
if (!raw.includes("*")) {
|
|
1349
|
-
if (raw.includes("."))
|
|
1350
|
-
exactPaths.add(raw);
|
|
1351
|
-
else
|
|
1352
|
-
addPathGlobPattern(normalizeRedactPathPattern(raw), exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1353
|
-
continue;
|
|
1354
|
-
}
|
|
1355
|
-
if (!raw.includes("."))
|
|
1356
|
-
keyGlobs.push(globToRegExp(raw, "."));
|
|
1357
|
-
else
|
|
1358
|
-
addPathGlobPattern(raw, exactPaths, pathGlobs, caseInsensitiveLeaves);
|
|
1359
|
-
}
|
|
1360
|
-
if (exactPaths.size === 0 && pathGlobs.length === 0 && keyGlobs.length === 0 && caseInsensitiveLeaves.size === 0)
|
|
1361
|
-
return;
|
|
1362
|
-
return {
|
|
1363
|
-
exactPaths,
|
|
1364
|
-
pathGlobs,
|
|
1365
|
-
keyGlobs,
|
|
1366
|
-
caseInsensitiveLeaves
|
|
1367
|
-
};
|
|
1368
|
-
}
|
|
1369
|
-
function addPathGlobPattern(pattern, exactPaths, pathGlobs, caseInsensitiveLeaves) {
|
|
1370
|
-
pathGlobs.push(globToRegExp(pattern, "."));
|
|
1371
|
-
const leaf = pattern.match(/^\*\*\.([^.?*]+)$/);
|
|
1372
|
-
if (leaf) {
|
|
1373
|
-
exactPaths.add(leaf[1]);
|
|
1374
|
-
caseInsensitiveLeaves.add(leaf[1].toLowerCase());
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
function matchesRedactPath(fullPath, leafKey, matchers) {
|
|
1378
|
-
if (matchers.exactPaths.has(fullPath))
|
|
1379
|
-
return true;
|
|
1380
|
-
if (matchers.caseInsensitiveLeaves.has(leafKey.toLowerCase()))
|
|
1381
|
-
return true;
|
|
1382
|
-
for (const glob of matchers.pathGlobs) {
|
|
1383
|
-
glob.lastIndex = 0;
|
|
1384
|
-
if (glob.test(fullPath))
|
|
1385
|
-
return true;
|
|
1386
|
-
}
|
|
1387
|
-
for (const glob of matchers.keyGlobs) {
|
|
1388
|
-
glob.lastIndex = 0;
|
|
1389
|
-
if (glob.test(leafKey))
|
|
1390
|
-
return true;
|
|
1391
|
-
}
|
|
1392
|
-
return false;
|
|
1393
|
-
}
|
|
1394
|
-
function redactPathsInTree(obj, matchers, replacement, prefix = "") {
|
|
1395
|
-
if (obj === null || obj === undefined)
|
|
1396
|
-
return;
|
|
1397
|
-
if (Array.isArray(obj)) {
|
|
1398
|
-
for (let i = 0;i < obj.length; i++) {
|
|
1399
|
-
const segment = String(i);
|
|
1400
|
-
const fullPath = prefix ? `${prefix}.${segment}` : segment;
|
|
1401
|
-
redactPathsInTree(obj[i], matchers, replacement, fullPath);
|
|
1402
|
-
}
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
if (typeof obj === "object") {
|
|
1406
|
-
const record = obj;
|
|
1407
|
-
for (const key in record) {
|
|
1408
|
-
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
1409
|
-
if (matchesRedactPath(fullPath, key, matchers))
|
|
1410
|
-
record[key] = replacement;
|
|
1411
|
-
else
|
|
1412
|
-
redactPathsInTree(record[key], matchers, replacement, fullPath);
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
var builtinPatterns = {
|
|
1417
|
-
creditCard: {
|
|
1418
|
-
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
1419
|
-
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
1420
|
-
},
|
|
1421
|
-
email: {
|
|
1422
|
-
pattern: /[\w.+-]+@[\w-]+\.[\w.]+/g,
|
|
1423
|
-
mask: (m) => {
|
|
1424
|
-
if (m.indexOf("@") < 1)
|
|
1425
|
-
return "***@***";
|
|
1426
|
-
const tld = m.slice(m.lastIndexOf("."));
|
|
1427
|
-
return `${m[0]}***@***${tld}`;
|
|
1428
|
-
}
|
|
1429
|
-
},
|
|
1430
|
-
ipv4: {
|
|
1431
|
-
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,
|
|
1432
|
-
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
1433
|
-
},
|
|
1434
|
-
phone: {
|
|
1435
|
-
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
1436
|
-
mask: (m) => {
|
|
1437
|
-
const digits = m.replace(/[^\d]/g, "");
|
|
1438
|
-
if (m.startsWith("+") && digits.length > 4) {
|
|
1439
|
-
const ccMatch = m.match(/^\+\d{1,3}/);
|
|
1440
|
-
return `${ccMatch ? ccMatch[0] : "+"}******${digits.slice(-2)}`;
|
|
1441
|
-
}
|
|
1442
|
-
if (digits.length > 2)
|
|
1443
|
-
return `${"*".repeat(digits.length - 2)}${digits.slice(-2)}`;
|
|
1444
|
-
return "***";
|
|
1445
|
-
}
|
|
1446
|
-
},
|
|
1447
|
-
jwt: {
|
|
1448
|
-
pattern: /\beyJ[\w-]*\.[\w-]*\.[\w-]*\b/g,
|
|
1449
|
-
mask: () => "eyJ***.***"
|
|
1450
|
-
},
|
|
1451
|
-
bearer: {
|
|
1452
|
-
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
1453
|
-
mask: () => "Bearer ***"
|
|
1454
|
-
},
|
|
1455
|
-
iban: {
|
|
1456
|
-
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,
|
|
1457
|
-
mask: (m) => {
|
|
1458
|
-
const clean = m.replace(/[\s-]/g, "");
|
|
1459
|
-
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
};
|
|
1463
|
-
function resolveRedactConfig(input) {
|
|
1464
|
-
if (input === undefined || input === false)
|
|
1465
|
-
return;
|
|
1466
|
-
if (input === true)
|
|
1467
|
-
return { _maskers: allBuiltinMaskers() };
|
|
1468
|
-
if (input.builtins === false)
|
|
1469
|
-
return {
|
|
1470
|
-
...input,
|
|
1471
|
-
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
1472
|
-
};
|
|
1473
|
-
const maskers = Array.isArray(input.builtins) ? input.builtins.map((name) => builtinPatterns[name]).filter(Boolean).map((b) => [cloneRegex(b.pattern), b.mask]) : allBuiltinMaskers();
|
|
1474
|
-
return {
|
|
1475
|
-
...input,
|
|
1476
|
-
_maskers: maskers,
|
|
1477
|
-
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
function allBuiltinMaskers() {
|
|
1481
|
-
return Object.values(builtinPatterns).map((b) => [cloneRegex(b.pattern), b.mask]);
|
|
1482
|
-
}
|
|
1483
|
-
function cloneRegex(re) {
|
|
1484
|
-
return new RegExp(re.source, re.flags);
|
|
1485
|
-
}
|
|
1486
|
-
var globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
1487
|
-
function markGloballyRedacted(event) {
|
|
1488
|
-
Object.defineProperty(event, globallyRedacted, {
|
|
1489
|
-
value: true,
|
|
1490
|
-
enumerable: false,
|
|
1491
|
-
configurable: true
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
function cloneForRedaction(event) {
|
|
1495
|
-
try {
|
|
1496
|
-
return structuredClone(event);
|
|
1497
|
-
} catch {
|
|
1498
|
-
try {
|
|
1499
|
-
return JSON.parse(JSON.stringify(event));
|
|
1500
|
-
} catch {
|
|
1501
|
-
console.warn("[cloneForRedaction] Shallow clone used \u2014 nested objects may be mutated by redactPath, redactPatterns, and applyMaskersToTree");
|
|
1502
|
-
return { ...event };
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
function redactEvent(event, config) {
|
|
1507
|
-
const clone = cloneForRedaction(event);
|
|
1508
|
-
const replacement = config.replacement ?? DEFAULT_REPLACEMENT;
|
|
1509
|
-
const pathMatchers = config._pathMatchers ?? compileRedactPathMatchers(config.paths);
|
|
1510
|
-
if (pathMatchers)
|
|
1511
|
-
redactPathsInTree(clone, pathMatchers, replacement);
|
|
1512
|
-
if (config._maskers?.length)
|
|
1513
|
-
applyMaskersToTree(clone, config._maskers);
|
|
1514
|
-
if (config.patterns?.length)
|
|
1515
|
-
redactPatterns(clone, config.patterns, replacement);
|
|
1516
|
-
return clone;
|
|
1517
|
-
}
|
|
1518
|
-
function redactPatterns(obj, patterns, replacement) {
|
|
1519
|
-
if (obj === null || obj === undefined)
|
|
1520
|
-
return;
|
|
1521
|
-
if (Array.isArray(obj)) {
|
|
1522
|
-
for (let i = 0;i < obj.length; i++)
|
|
1523
|
-
if (typeof obj[i] === "string")
|
|
1524
|
-
obj[i] = applyPatterns(obj[i], patterns, replacement);
|
|
1525
|
-
else if (typeof obj[i] === "object")
|
|
1526
|
-
redactPatterns(obj[i], patterns, replacement);
|
|
1527
|
-
return;
|
|
1528
|
-
}
|
|
1529
|
-
if (typeof obj === "object") {
|
|
1530
|
-
const record = obj;
|
|
1531
|
-
for (const key in record) {
|
|
1532
|
-
const val = record[key];
|
|
1533
|
-
if (typeof val === "string")
|
|
1534
|
-
record[key] = applyPatterns(val, patterns, replacement);
|
|
1535
|
-
else if (typeof val === "object")
|
|
1536
|
-
redactPatterns(val, patterns, replacement);
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
function applyPatterns(value, patterns, replacement) {
|
|
1541
|
-
let result = value;
|
|
1542
|
-
for (const pattern of patterns)
|
|
1543
|
-
result = result.replace(pattern, replacement);
|
|
1544
1431
|
return result;
|
|
1545
1432
|
}
|
|
1433
|
+
function captureGroups(args) {
|
|
1434
|
+
const last = args.at(-1);
|
|
1435
|
+
const trailing = typeof last === "object" && last !== null ? 3 : 2;
|
|
1436
|
+
return args.slice(1, Math.max(1, args.length - trailing));
|
|
1437
|
+
}
|
|
1546
1438
|
function applyMaskersToTree(obj, maskers) {
|
|
1547
1439
|
if (obj === null || obj === undefined)
|
|
1548
1440
|
return;
|
|
@@ -1556,10 +1448,10 @@ function applyMaskersToTree(obj, maskers) {
|
|
|
1556
1448
|
}
|
|
1557
1449
|
if (typeof obj === "object") {
|
|
1558
1450
|
const record = obj;
|
|
1559
|
-
for (const key
|
|
1451
|
+
for (const key of redactableKeys(record)) {
|
|
1560
1452
|
const val = record[key];
|
|
1561
1453
|
if (typeof val === "string")
|
|
1562
|
-
record
|
|
1454
|
+
setRedacted(record, key, applyMaskers(val, maskers), key);
|
|
1563
1455
|
else if (typeof val === "object")
|
|
1564
1456
|
applyMaskersToTree(val, maskers);
|
|
1565
1457
|
}
|
|
@@ -1571,6 +1463,8 @@ function applyMaskers(value, maskers) {
|
|
|
1571
1463
|
result = result.replace(pattern, mask);
|
|
1572
1464
|
return result;
|
|
1573
1465
|
}
|
|
1466
|
+
|
|
1467
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
|
|
1574
1468
|
function logPluginError(name, hook, err) {
|
|
1575
1469
|
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
1576
1470
|
}
|
|
@@ -1682,6 +1576,404 @@ var emptyRunner = createPluginRunner([]);
|
|
|
1682
1576
|
function getEmptyPluginRunner() {
|
|
1683
1577
|
return emptyRunner;
|
|
1684
1578
|
}
|
|
1579
|
+
var EVLOG_MAJOR = 2;
|
|
1580
|
+
var REGISTRY_KEY = Symbol.for(`evlog.registry.v${EVLOG_MAJOR}`);
|
|
1581
|
+
var MAJORS_KEY = Symbol.for("evlog.majors");
|
|
1582
|
+
function createConfig() {
|
|
1583
|
+
return {
|
|
1584
|
+
env: {
|
|
1585
|
+
service: "app",
|
|
1586
|
+
environment: "development"
|
|
1587
|
+
},
|
|
1588
|
+
pretty: isDev(),
|
|
1589
|
+
prettyError: {
|
|
1590
|
+
snippet: isDev(),
|
|
1591
|
+
stackDepth: 2,
|
|
1592
|
+
compact: isDev(),
|
|
1593
|
+
detail: "full"
|
|
1594
|
+
},
|
|
1595
|
+
sampling: {},
|
|
1596
|
+
stringify: true,
|
|
1597
|
+
drain: undefined,
|
|
1598
|
+
redact: undefined,
|
|
1599
|
+
enabled: true,
|
|
1600
|
+
silent: false,
|
|
1601
|
+
minLevel: "debug",
|
|
1602
|
+
locked: false,
|
|
1603
|
+
initialized: false,
|
|
1604
|
+
pluginRunner: getEmptyPluginRunner()
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function warnOnMultiMajor(host) {
|
|
1608
|
+
const majors = host[MAJORS_KEY] ??= /* @__PURE__ */ new Set;
|
|
1609
|
+
if (majors.has(EVLOG_MAJOR))
|
|
1610
|
+
return;
|
|
1611
|
+
majors.add(EVLOG_MAJOR);
|
|
1612
|
+
if (majors.size > 1)
|
|
1613
|
+
console.warn(`[evlog] Multiple major versions of evlog are loaded in this process (${[...majors].map((m) => `${m}.x`).join(", ")}). They cannot share request scope or logger configuration: events emitted through the other copy will be undrained and unredacted, and useLogger() may throw. Deduplicate evlog to a single major.`);
|
|
1614
|
+
}
|
|
1615
|
+
function getRegistry() {
|
|
1616
|
+
const host = globalThis;
|
|
1617
|
+
warnOnMultiMajor(host);
|
|
1618
|
+
return host[REGISTRY_KEY] ??= {
|
|
1619
|
+
config: createConfig(),
|
|
1620
|
+
storages: /* @__PURE__ */ new Map
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
var globalConfig = getRegistry().config;
|
|
1624
|
+
|
|
1625
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/pretty-error-DTIHxnBN.mjs
|
|
1626
|
+
var snippetReader = null;
|
|
1627
|
+
var PRETTY_ERROR_TREE_SPACER = "__EVLOG_TREE_SPACER__";
|
|
1628
|
+
function pushTreeSpacer(children) {
|
|
1629
|
+
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
1630
|
+
}
|
|
1631
|
+
var SKIP_PATH_RE = /(?:^|[/\\])(?:node_modules|\.nuxt|\.next|\.output)(?:[/\\]|$)/;
|
|
1632
|
+
var SKIP_FRAME_PATH_RE = /(?:^|[/\\])(?:packages[/\\]evlog|evlog[/\\](?:dist|src))(?:[/\\]|$)/;
|
|
1633
|
+
var SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
1634
|
+
function isPlainObject(val) {
|
|
1635
|
+
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1636
|
+
}
|
|
1637
|
+
function pickString(obj, key) {
|
|
1638
|
+
const val = obj[key];
|
|
1639
|
+
return typeof val === "string" && val.length > 0 ? val : undefined;
|
|
1640
|
+
}
|
|
1641
|
+
function pickNumber(obj, key) {
|
|
1642
|
+
const val = obj[key];
|
|
1643
|
+
return typeof val === "number" ? val : undefined;
|
|
1644
|
+
}
|
|
1645
|
+
function extractGuidance(data) {
|
|
1646
|
+
return {
|
|
1647
|
+
code: pickString(data, "code"),
|
|
1648
|
+
why: pickString(data, "why"),
|
|
1649
|
+
fix: pickString(data, "fix"),
|
|
1650
|
+
link: pickString(data, "link")
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
function normalizeErrorContext(error) {
|
|
1654
|
+
if (error === null || error === undefined)
|
|
1655
|
+
return null;
|
|
1656
|
+
if (typeof error === "string")
|
|
1657
|
+
return { message: error };
|
|
1658
|
+
if (!isPlainObject(error))
|
|
1659
|
+
return { message: String(error) };
|
|
1660
|
+
const result = {
|
|
1661
|
+
message: pickString(error, "message") ?? pickString(error, "statusText") ?? pickString(error, "statusMessage") ?? "Unknown error",
|
|
1662
|
+
name: pickString(error, "name"),
|
|
1663
|
+
code: pickString(error, "code"),
|
|
1664
|
+
why: pickString(error, "why"),
|
|
1665
|
+
fix: pickString(error, "fix"),
|
|
1666
|
+
link: pickString(error, "link"),
|
|
1667
|
+
status: pickNumber(error, "status") ?? pickNumber(error, "statusCode"),
|
|
1668
|
+
stack: pickString(error, "stack")
|
|
1669
|
+
};
|
|
1670
|
+
const { data, cause } = error;
|
|
1671
|
+
if (isPlainObject(data)) {
|
|
1672
|
+
const guidance = extractGuidance(data);
|
|
1673
|
+
if (!result.code)
|
|
1674
|
+
result.code = guidance.code;
|
|
1675
|
+
if (!result.why)
|
|
1676
|
+
result.why = guidance.why;
|
|
1677
|
+
if (!result.fix)
|
|
1678
|
+
result.fix = guidance.fix;
|
|
1679
|
+
if (!result.link)
|
|
1680
|
+
result.link = guidance.link;
|
|
1681
|
+
}
|
|
1682
|
+
if (cause instanceof Error)
|
|
1683
|
+
result.cause = cause.message;
|
|
1684
|
+
else if (isPlainObject(cause) && pickString(cause, "message"))
|
|
1685
|
+
result.cause = pickString(cause, "message");
|
|
1686
|
+
return result;
|
|
1687
|
+
}
|
|
1688
|
+
function decodeFileUrl(file) {
|
|
1689
|
+
if (file.startsWith("file://"))
|
|
1690
|
+
try {
|
|
1691
|
+
return decodeURIComponent(new URL(file).pathname);
|
|
1692
|
+
} catch {
|
|
1693
|
+
return file.slice(7);
|
|
1694
|
+
}
|
|
1695
|
+
return file;
|
|
1696
|
+
}
|
|
1697
|
+
function isAppPath(file) {
|
|
1698
|
+
const normalized = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1699
|
+
if (normalized.startsWith("node:"))
|
|
1700
|
+
return false;
|
|
1701
|
+
if (SKIP_PATH_RE.test(normalized))
|
|
1702
|
+
return false;
|
|
1703
|
+
if (normalized.includes("/node_modules/"))
|
|
1704
|
+
return false;
|
|
1705
|
+
if (isFrameworkRuntimePath(normalized))
|
|
1706
|
+
return false;
|
|
1707
|
+
return true;
|
|
1708
|
+
}
|
|
1709
|
+
function formatDisplayPath(file, cwd) {
|
|
1710
|
+
const decoded = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1711
|
+
const cwdNorm = cwd.replace(/\\/g, "/").replace(/\/$/, "");
|
|
1712
|
+
if (cwdNorm && decoded.startsWith(`${cwdNorm}/`)) {
|
|
1713
|
+
const rel = decoded.slice(cwdNorm.length + 1);
|
|
1714
|
+
return rel.startsWith("./") ? rel.slice(2) : rel;
|
|
1715
|
+
}
|
|
1716
|
+
const serverIdx = decoded.indexOf("/server/");
|
|
1717
|
+
if (serverIdx >= 0)
|
|
1718
|
+
return decoded.slice(serverIdx + 1);
|
|
1719
|
+
const srcIdx = decoded.indexOf("/src/");
|
|
1720
|
+
if (srcIdx >= 0)
|
|
1721
|
+
return decoded.slice(srcIdx + 1);
|
|
1722
|
+
return decoded;
|
|
1723
|
+
}
|
|
1724
|
+
function parseStackFrames(stack) {
|
|
1725
|
+
if (!stack)
|
|
1726
|
+
return [];
|
|
1727
|
+
const lines = stack.split(`
|
|
1728
|
+
`);
|
|
1729
|
+
const frames = [];
|
|
1730
|
+
for (const line of lines) {
|
|
1731
|
+
const trimmed = line.trim();
|
|
1732
|
+
if (!trimmed.startsWith("at "))
|
|
1733
|
+
continue;
|
|
1734
|
+
const withFn = trimmed.match(/^at (.+?) \((.+):(\d+):(\d+)\)$/);
|
|
1735
|
+
if (withFn) {
|
|
1736
|
+
const [, fn, file, lineStr, colStr] = withFn;
|
|
1737
|
+
frames.push({
|
|
1738
|
+
raw: trimmed,
|
|
1739
|
+
fn,
|
|
1740
|
+
file,
|
|
1741
|
+
line: Number(lineStr),
|
|
1742
|
+
column: Number(colStr),
|
|
1743
|
+
isApp: isAppPath(file)
|
|
1744
|
+
});
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
const withoutFn = trimmed.match(/^at (.+):(\d+):(\d+)$/);
|
|
1748
|
+
if (withoutFn) {
|
|
1749
|
+
const [, file, lineStr, colStr] = withoutFn;
|
|
1750
|
+
frames.push({
|
|
1751
|
+
raw: trimmed,
|
|
1752
|
+
file,
|
|
1753
|
+
line: Number(lineStr),
|
|
1754
|
+
column: Number(colStr),
|
|
1755
|
+
isApp: isAppPath(file)
|
|
1756
|
+
});
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
const asyncFn = trimmed.match(/^at async (.+?) \((.+):(\d+):(\d+)\)$/);
|
|
1760
|
+
if (asyncFn) {
|
|
1761
|
+
const [, fn, file, lineStr, colStr] = asyncFn;
|
|
1762
|
+
frames.push({
|
|
1763
|
+
raw: trimmed,
|
|
1764
|
+
fn: `async ${fn}`,
|
|
1765
|
+
file,
|
|
1766
|
+
line: Number(lineStr),
|
|
1767
|
+
column: Number(colStr),
|
|
1768
|
+
isApp: isAppPath(file)
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return frames;
|
|
1773
|
+
}
|
|
1774
|
+
function isFrameworkRuntimePath(path) {
|
|
1775
|
+
const normalized = path.replace(/\\/g, "/");
|
|
1776
|
+
return normalized.includes("route-modules/") || normalized.includes("webpack://next/") || normalized.includes("/next/dist/") || normalized.includes("/compiled/next-server/");
|
|
1777
|
+
}
|
|
1778
|
+
function isFrameworkRuntimeFrame(frame) {
|
|
1779
|
+
if (!frame.file)
|
|
1780
|
+
return false;
|
|
1781
|
+
return isFrameworkRuntimePath(decodeFileUrl(frame.file));
|
|
1782
|
+
}
|
|
1783
|
+
function isInternalErrorFrame(frame) {
|
|
1784
|
+
if (isFrameworkRuntimeFrame(frame))
|
|
1785
|
+
return true;
|
|
1786
|
+
if (frame.fn) {
|
|
1787
|
+
const fn = frame.fn.replace(/^async /, "");
|
|
1788
|
+
if (SKIP_FRAME_FN_RE.test(fn))
|
|
1789
|
+
return true;
|
|
1790
|
+
}
|
|
1791
|
+
if (!frame.file)
|
|
1792
|
+
return true;
|
|
1793
|
+
const path = decodeFileUrl(frame.file).replace(/\\/g, "/");
|
|
1794
|
+
if (SKIP_FRAME_PATH_RE.test(path))
|
|
1795
|
+
return true;
|
|
1796
|
+
if (path.includes(".nuxt/"))
|
|
1797
|
+
return true;
|
|
1798
|
+
if (path.includes(".next/"))
|
|
1799
|
+
return true;
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
function pickPrimaryFrame(frames) {
|
|
1803
|
+
for (const frame of frames)
|
|
1804
|
+
if (frame.isApp && frame.file && frame.line && !isInternalErrorFrame(frame))
|
|
1805
|
+
return frame;
|
|
1806
|
+
}
|
|
1807
|
+
function readCodeSnippet(file, line, contextLines = 2) {
|
|
1808
|
+
if (!isDev() || isBrowser() || !snippetReader)
|
|
1809
|
+
return null;
|
|
1810
|
+
const path = decodeFileUrl(file).replace(/\\/g, "/");
|
|
1811
|
+
if (path.includes(".next/") || path.includes(".nuxt/") || path.includes(".output/"))
|
|
1812
|
+
return null;
|
|
1813
|
+
return snippetReader(file, line, contextLines);
|
|
1814
|
+
}
|
|
1815
|
+
function formatSnippetLines(snippet) {
|
|
1816
|
+
const width = String(snippet[snippet.length - 1]?.line ?? 0).length;
|
|
1817
|
+
return snippet.map(({ line, content, isErrorLine }) => {
|
|
1818
|
+
const marker = isErrorLine ? `${colors.red}\u276F${colors.reset}` : `${colors.dim} ${colors.reset}`;
|
|
1819
|
+
const numColor = isErrorLine ? colors.red : colors.gray;
|
|
1820
|
+
const trimmed = content.length > 120 ? `${content.slice(0, 117)}\u2026` : content;
|
|
1821
|
+
return `${marker} ${numColor}${String(line).padStart(width, " ")}${colors.reset} ${colors.dim}\u2503${colors.reset} ${colors.dim}${trimmed}${colors.reset}`;
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
function formatFrameLocation(frame, cwd) {
|
|
1825
|
+
const file = frame.file ? formatDisplayPath(frame.file, cwd) : "unknown";
|
|
1826
|
+
const loc = frame.line ? `${file}:${frame.line}` : file;
|
|
1827
|
+
const fn = frame.fn && frame.fn !== "<unknown>" ? frame.fn : undefined;
|
|
1828
|
+
return fn ? `at ${fn} (${loc})` : `at ${loc}`;
|
|
1829
|
+
}
|
|
1830
|
+
function formatCollapsedFrame(frame, cwd) {
|
|
1831
|
+
const file = frame.file ? formatDisplayPath(frame.file, cwd) : "unknown";
|
|
1832
|
+
const loc = frame.line ? `${file}:${frame.line}` : file;
|
|
1833
|
+
const prefix = frame.fn?.startsWith("async") ? "at async " : "at ";
|
|
1834
|
+
const fn = frame.fn?.replace(/^async /, "");
|
|
1835
|
+
if (fn && fn !== "<unknown>" && fn !== loc)
|
|
1836
|
+
return `${prefix}${fn} (${loc})`;
|
|
1837
|
+
return `${prefix}${loc}`;
|
|
1838
|
+
}
|
|
1839
|
+
var GUIDANCE_WRAP_WIDTH = 76;
|
|
1840
|
+
var GUIDANCE_CONTINUATION = " ";
|
|
1841
|
+
function formatGuidanceLine(label, text, labelColor) {
|
|
1842
|
+
const prefix = `${labelColor}${label}:${colors.reset} `;
|
|
1843
|
+
const lines = [];
|
|
1844
|
+
let remaining = text.trim();
|
|
1845
|
+
let first = true;
|
|
1846
|
+
while (remaining.length > 0) {
|
|
1847
|
+
const budget = first ? Math.max(24, GUIDANCE_WRAP_WIDTH - prefix.length) : Math.max(24, GUIDANCE_WRAP_WIDTH - 5);
|
|
1848
|
+
if (remaining.length <= budget) {
|
|
1849
|
+
lines.push(first ? `${prefix}${remaining}` : `${GUIDANCE_CONTINUATION}${remaining}`);
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
let split = remaining.lastIndexOf(" ", budget);
|
|
1853
|
+
if (split <= 0)
|
|
1854
|
+
split = budget;
|
|
1855
|
+
const chunk = remaining.slice(0, split).trimEnd();
|
|
1856
|
+
lines.push(first ? `${prefix}${chunk}` : `${GUIDANCE_CONTINUATION}${chunk}`);
|
|
1857
|
+
remaining = remaining.slice(split).trimStart();
|
|
1858
|
+
first = false;
|
|
1859
|
+
}
|
|
1860
|
+
return lines;
|
|
1861
|
+
}
|
|
1862
|
+
function buildErrorEntries(error, options = {}) {
|
|
1863
|
+
const normalized = normalizeErrorContext(error);
|
|
1864
|
+
if (!normalized)
|
|
1865
|
+
return [];
|
|
1866
|
+
const cwd = options.cwd ?? (typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ".");
|
|
1867
|
+
const compact = options.compact ?? isDev();
|
|
1868
|
+
const guidanceOnly = (options.detail ?? "full") === "guidance";
|
|
1869
|
+
const showFrames = !guidanceOnly && !isBrowser() && (options.snippet ?? isDev());
|
|
1870
|
+
const stackDepth = guidanceOnly ? 0 : options.stackDepth ?? (compact ? 2 : 3);
|
|
1871
|
+
const snippetContextLines = compact ? 1 : 2;
|
|
1872
|
+
const children = [];
|
|
1873
|
+
const frames = guidanceOnly ? [] : parseStackFrames(normalized.stack);
|
|
1874
|
+
const primary = guidanceOnly ? undefined : pickPrimaryFrame(frames);
|
|
1875
|
+
if (!guidanceOnly && primary?.file && primary.line) {
|
|
1876
|
+
pushTreeSpacer(children);
|
|
1877
|
+
if (showFrames) {
|
|
1878
|
+
const snippet = readCodeSnippet(primary.file, primary.line, snippetContextLines);
|
|
1879
|
+
children.push(`${colors.dim} ${formatFrameLocation(primary, cwd)}${colors.reset}`);
|
|
1880
|
+
if (snippet)
|
|
1881
|
+
children.push(...formatSnippetLines(snippet));
|
|
1882
|
+
} else
|
|
1883
|
+
children.push(`${colors.dim} ${formatFrameLocation(primary, cwd)}${colors.reset}`);
|
|
1884
|
+
}
|
|
1885
|
+
if (normalized.code)
|
|
1886
|
+
children.push(`${colors.dim}Code:${colors.reset} ${normalized.code}`);
|
|
1887
|
+
if (Boolean(normalized.why || normalized.fix || normalized.link))
|
|
1888
|
+
pushTreeSpacer(children);
|
|
1889
|
+
if (normalized.why)
|
|
1890
|
+
children.push(...formatGuidanceLine("Why", normalized.why, colors.yellow));
|
|
1891
|
+
if (normalized.fix)
|
|
1892
|
+
children.push(...formatGuidanceLine("Fix", normalized.fix, colors.cyan));
|
|
1893
|
+
if (normalized.link)
|
|
1894
|
+
children.push(`${colors.dim}More:${colors.reset} ${normalized.link}`);
|
|
1895
|
+
if (normalized.cause && normalized.cause !== normalized.message)
|
|
1896
|
+
children.push(`${colors.dim}Caused by:${colors.reset} ${normalized.cause}`);
|
|
1897
|
+
const hiddenCount = guidanceOnly ? 0 : frames.filter((f) => !f.isApp || isInternalErrorFrame(f)).length;
|
|
1898
|
+
const tailFrames = stackDepth > 0 ? frames.filter((f) => f !== primary && !isInternalErrorFrame(f)).slice(0, stackDepth) : [];
|
|
1899
|
+
if (!guidanceOnly && (hiddenCount > 0 || tailFrames.length > 0)) {
|
|
1900
|
+
pushTreeSpacer(children);
|
|
1901
|
+
if (hiddenCount > 0)
|
|
1902
|
+
children.push(`${colors.gray}stack (${hiddenCount} frame${hiddenCount === 1 ? "" : "s"} hidden in node_modules)${colors.reset}`);
|
|
1903
|
+
else
|
|
1904
|
+
children.push(`${colors.gray}stack${colors.reset}`);
|
|
1905
|
+
for (const frame of tailFrames)
|
|
1906
|
+
children.push(`${colors.gray} ${formatCollapsedFrame(frame, cwd)}${colors.reset}`);
|
|
1907
|
+
}
|
|
1908
|
+
return [{
|
|
1909
|
+
key: "error",
|
|
1910
|
+
value: `${colors.red}${colors.bold}${normalized.message}${colors.reset}`,
|
|
1911
|
+
children: children.length > 0 ? children : undefined
|
|
1912
|
+
}];
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
|
|
1916
|
+
var DEV_PRESETS = {
|
|
1917
|
+
evlog: {
|
|
1918
|
+
frameworkOverlay: false,
|
|
1919
|
+
detail: "full"
|
|
1920
|
+
},
|
|
1921
|
+
nitro: {
|
|
1922
|
+
frameworkOverlay: true,
|
|
1923
|
+
detail: "guidance"
|
|
1924
|
+
},
|
|
1925
|
+
both: {
|
|
1926
|
+
frameworkOverlay: true,
|
|
1927
|
+
detail: "full"
|
|
1928
|
+
}
|
|
1929
|
+
};
|
|
1930
|
+
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1931
|
+
const compact = partial.compact ?? (inDev && pretty);
|
|
1932
|
+
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
1933
|
+
const stackDepth = detail === "guidance" ? 0 : partial.stackDepth ?? (compact ? 2 : 3);
|
|
1934
|
+
return {
|
|
1935
|
+
snippet: partial.snippet ?? (detail === "full" && pretty && inDev),
|
|
1936
|
+
stackDepth,
|
|
1937
|
+
compact,
|
|
1938
|
+
detail
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
function resolveDevTerminal(input = {}) {
|
|
1942
|
+
const pretty = input.pretty ?? isDev();
|
|
1943
|
+
const inDev = isDev();
|
|
1944
|
+
let frameworkOverlay;
|
|
1945
|
+
let prettyError = {};
|
|
1946
|
+
if (typeof input.dev === "string" && input.dev in DEV_PRESETS) {
|
|
1947
|
+
const { frameworkOverlay: presetOverlay, detail } = DEV_PRESETS[input.dev];
|
|
1948
|
+
frameworkOverlay = presetOverlay;
|
|
1949
|
+
prettyError = { detail };
|
|
1950
|
+
} else if (input.dev && typeof input.dev === "object") {
|
|
1951
|
+
const { frameworkOverlay: devOverlay, prettyError: devPrettyError } = input.dev;
|
|
1952
|
+
frameworkOverlay = devOverlay;
|
|
1953
|
+
if (devPrettyError)
|
|
1954
|
+
prettyError = devPrettyError;
|
|
1955
|
+
}
|
|
1956
|
+
if (frameworkOverlay === undefined)
|
|
1957
|
+
frameworkOverlay = !(pretty && inDev);
|
|
1958
|
+
return {
|
|
1959
|
+
frameworkOverlay,
|
|
1960
|
+
prettyError: finalizePrettyError(prettyError, frameworkOverlay, pretty, inDev)
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
|
|
1965
|
+
var publisher = null;
|
|
1966
|
+
function publishWideEvent(event) {
|
|
1967
|
+
if (!publisher)
|
|
1968
|
+
return;
|
|
1969
|
+
try {
|
|
1970
|
+
publisher(event);
|
|
1971
|
+
} catch (err) {
|
|
1972
|
+
console.error("[evlog] diagnostics channel publish failed:", err);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/audit-CW8wdQDm.mjs
|
|
1685
1977
|
var nativeStdoutWrite = typeof process !== "undefined" && typeof process.stdout?.write === "function" ? process.stdout.write.bind(process.stdout) : undefined;
|
|
1686
1978
|
function writePrettyStdout(text) {
|
|
1687
1979
|
(globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
|
|
@@ -1689,59 +1981,35 @@ function writePrettyStdout(text) {
|
|
|
1689
1981
|
function isPlainObject$1(val) {
|
|
1690
1982
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1691
1983
|
}
|
|
1692
|
-
var
|
|
1693
|
-
function isoNow() {
|
|
1694
|
-
_tsDate.setTime(Date.now());
|
|
1695
|
-
return _tsDate.toISOString();
|
|
1696
|
-
}
|
|
1697
|
-
var globalEnv = {
|
|
1698
|
-
service: "app",
|
|
1699
|
-
environment: "development"
|
|
1700
|
-
};
|
|
1701
|
-
var globalPretty = isDev();
|
|
1702
|
-
var globalPrettyError = {
|
|
1703
|
-
snippet: isDev(),
|
|
1704
|
-
stackDepth: 2,
|
|
1705
|
-
compact: isDev(),
|
|
1706
|
-
detail: "full"
|
|
1707
|
-
};
|
|
1708
|
-
var globalSampling = {};
|
|
1709
|
-
var globalStringify = true;
|
|
1710
|
-
var globalDrain;
|
|
1711
|
-
var globalRedact;
|
|
1712
|
-
var globalEnabled = true;
|
|
1713
|
-
var globalSilent = false;
|
|
1714
|
-
var globalMinLevel = "debug";
|
|
1715
|
-
var _loggerInitialized = false;
|
|
1716
|
-
var globalPluginRunner = getEmptyPluginRunner();
|
|
1984
|
+
var state = globalConfig;
|
|
1717
1985
|
function initLogger(config = {}) {
|
|
1718
|
-
|
|
1986
|
+
state.enabled = config.enabled ?? true;
|
|
1719
1987
|
const detected = detectEnvironment();
|
|
1720
|
-
|
|
1988
|
+
state.env = {
|
|
1721
1989
|
service: config.env?.service ?? detected.service ?? "app",
|
|
1722
1990
|
environment: config.env?.environment ?? detected.environment ?? "development",
|
|
1723
1991
|
version: config.env?.version ?? detected.version,
|
|
1724
1992
|
commitHash: config.env?.commitHash ?? detected.commitHash,
|
|
1725
1993
|
region: config.env?.region ?? detected.region
|
|
1726
1994
|
};
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
if (
|
|
1737
|
-
|
|
1738
|
-
const hasAnyDrain = !!
|
|
1739
|
-
if (
|
|
1995
|
+
state.pretty = config.pretty ?? isDev();
|
|
1996
|
+
state.prettyError = resolveDevTerminal(config).prettyError;
|
|
1997
|
+
state.sampling = config.sampling ?? {};
|
|
1998
|
+
state.stringify = config.stringify ?? true;
|
|
1999
|
+
state.drain = config.drain;
|
|
2000
|
+
state.redact = resolveRedactConfig(config.redact ?? !isDev());
|
|
2001
|
+
state.silent = config.silent ?? false;
|
|
2002
|
+
state.minLevel = config.minLevel ?? "debug";
|
|
2003
|
+
state.pluginRunner = config.plugins?.length ? createPluginRunner(config.plugins) : getEmptyPluginRunner();
|
|
2004
|
+
if (state.pluginRunner.plugins.length > 0)
|
|
2005
|
+
state.pluginRunner.runSetup({ env: { ...state.env } });
|
|
2006
|
+
const hasAnyDrain = !!state.drain || state.pluginRunner.hasDrain;
|
|
2007
|
+
if (state.silent && !hasAnyDrain && !config._suppressDrainWarning)
|
|
1740
2008
|
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).");
|
|
1741
|
-
|
|
2009
|
+
state.initialized = true;
|
|
1742
2010
|
}
|
|
1743
2011
|
function shouldSample(level) {
|
|
1744
|
-
const { rates } =
|
|
2012
|
+
const { rates } = state.sampling;
|
|
1745
2013
|
if (!rates)
|
|
1746
2014
|
return true;
|
|
1747
2015
|
const percentage = level === "error" && rates.error === undefined ? 100 : rates[level] ?? 100;
|
|
@@ -1753,10 +2021,10 @@ function shouldSample(level) {
|
|
|
1753
2021
|
}
|
|
1754
2022
|
function emitWideEvent(level, event, options = {}) {
|
|
1755
2023
|
const { deferDrain = false, ownsEvent = false, waitUntil } = options;
|
|
1756
|
-
if (!
|
|
2024
|
+
if (!state.enabled)
|
|
1757
2025
|
return null;
|
|
1758
2026
|
if (!ownsEvent) {
|
|
1759
|
-
if (!isLevelEnabled(level,
|
|
2027
|
+
if (!isLevelEnabled(level, state.minLevel))
|
|
1760
2028
|
return null;
|
|
1761
2029
|
if (!shouldSample(level))
|
|
1762
2030
|
return null;
|
|
@@ -1766,57 +2034,58 @@ function emitWideEvent(level, event, options = {}) {
|
|
|
1766
2034
|
event.timestamp = isoNow();
|
|
1767
2035
|
event.level = level;
|
|
1768
2036
|
if (event.service === undefined)
|
|
1769
|
-
event.service =
|
|
2037
|
+
event.service = state.env.service;
|
|
1770
2038
|
if (event.environment === undefined)
|
|
1771
|
-
event.environment =
|
|
1772
|
-
if (
|
|
1773
|
-
event.version =
|
|
1774
|
-
if (
|
|
1775
|
-
event.commitHash =
|
|
1776
|
-
if (
|
|
1777
|
-
event.region =
|
|
2039
|
+
event.environment = state.env.environment;
|
|
2040
|
+
if (state.env.version !== undefined && event.version === undefined)
|
|
2041
|
+
event.version = state.env.version;
|
|
2042
|
+
if (state.env.commitHash !== undefined && event.commitHash === undefined)
|
|
2043
|
+
event.commitHash = state.env.commitHash;
|
|
2044
|
+
if (state.env.region !== undefined && event.region === undefined)
|
|
2045
|
+
event.region = state.env.region;
|
|
1778
2046
|
formatted = event;
|
|
1779
2047
|
} else
|
|
1780
2048
|
formatted = {
|
|
1781
2049
|
timestamp: isoNow(),
|
|
1782
2050
|
level,
|
|
1783
|
-
...
|
|
2051
|
+
...state.env,
|
|
1784
2052
|
...event
|
|
1785
2053
|
};
|
|
1786
2054
|
finalizeAudit(formatted);
|
|
1787
|
-
if (
|
|
1788
|
-
formatted = redactEvent(formatted,
|
|
2055
|
+
if (state.redact) {
|
|
2056
|
+
formatted = redactEvent(formatted, state.redact);
|
|
1789
2057
|
markGloballyRedacted(formatted);
|
|
1790
2058
|
}
|
|
1791
|
-
if (!
|
|
1792
|
-
if (
|
|
2059
|
+
if (!state.silent)
|
|
2060
|
+
if (state.pretty)
|
|
1793
2061
|
prettyPrintWideEvent(formatted);
|
|
1794
|
-
else if (
|
|
2062
|
+
else if (state.stringify)
|
|
1795
2063
|
console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
1796
2064
|
else
|
|
1797
2065
|
console[getConsoleMethod(level)](formatted);
|
|
1798
2066
|
if (!deferDrain) {
|
|
2067
|
+
publishWideEvent(formatted);
|
|
1799
2068
|
const drainPromises = [];
|
|
1800
|
-
if (
|
|
2069
|
+
if (state.drain)
|
|
1801
2070
|
drainPromises.push((async () => {
|
|
1802
2071
|
try {
|
|
1803
|
-
await
|
|
2072
|
+
await state.drain({ event: formatted });
|
|
1804
2073
|
} catch (err) {
|
|
1805
2074
|
console.error("[evlog] drain failed:", err);
|
|
1806
2075
|
}
|
|
1807
2076
|
})());
|
|
1808
|
-
if (
|
|
1809
|
-
drainPromises.push(
|
|
2077
|
+
if (state.pluginRunner.hasDrain)
|
|
2078
|
+
drainPromises.push(state.pluginRunner.runDrain({ event: formatted }));
|
|
1810
2079
|
if (drainPromises.length > 0 && waitUntil)
|
|
1811
2080
|
waitUntil(Promise.all(drainPromises));
|
|
1812
2081
|
}
|
|
1813
2082
|
return formatted;
|
|
1814
2083
|
}
|
|
1815
2084
|
function emitTaggedLog(level, tag, message) {
|
|
1816
|
-
if (!
|
|
2085
|
+
if (!state.enabled)
|
|
1817
2086
|
return;
|
|
1818
|
-
if (
|
|
1819
|
-
if (!isLevelEnabled(level,
|
|
2087
|
+
if (state.pretty && !state.silent) {
|
|
2088
|
+
if (!isLevelEnabled(level, state.minLevel))
|
|
1820
2089
|
return;
|
|
1821
2090
|
if (!shouldSample(level))
|
|
1822
2091
|
return;
|
|
@@ -2131,6 +2400,7 @@ function prettyPrintWideEvent(event) {
|
|
|
2131
2400
|
parts.push(` ${colors.dim}in ${rest.duration}${colors.reset}`);
|
|
2132
2401
|
delete rest.duration;
|
|
2133
2402
|
}
|
|
2403
|
+
delete rest.durationMs;
|
|
2134
2404
|
writeLine(parts.join(""), ...styles);
|
|
2135
2405
|
const aiData = isPlainObject$1(rest.ai) ? rest.ai : undefined;
|
|
2136
2406
|
if (aiData)
|
|
@@ -2140,7 +2410,7 @@ function prettyPrintWideEvent(event) {
|
|
|
2140
2410
|
delete rest.error;
|
|
2141
2411
|
const restEntries = Object.entries(rest).filter(([_, v]) => v !== undefined);
|
|
2142
2412
|
const aiEntries = aiData ? buildAIEntries(aiData) : [];
|
|
2143
|
-
const errorEntries = errorData !== undefined ? buildErrorEntries(errorData,
|
|
2413
|
+
const errorEntries = errorData !== undefined ? buildErrorEntries(errorData, state.prettyError) : [];
|
|
2144
2414
|
const contextEntries = [...restEntries.map(([key, value]) => ({
|
|
2145
2415
|
key,
|
|
2146
2416
|
value: formatValue(value)
|
|
@@ -2293,8 +2563,7 @@ function finalizeAudit(event) {
|
|
|
2293
2563
|
// src/client/router/provider.tsx
|
|
2294
2564
|
import { useCallback as useCallback2, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2295
2565
|
|
|
2296
|
-
// ../../node_modules/.bun/seroval@1.
|
|
2297
|
-
var ALL_ENABLED = 1 | 2 | 4 | 8 | 16 | 32;
|
|
2566
|
+
// ../../node_modules/.bun/seroval@1.6.7/node_modules/seroval/dist/dev/index.js
|
|
2298
2567
|
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
2299
2568
|
var SYM_HAS_INSTANCE = Symbol.hasInstance;
|
|
2300
2569
|
var SYM_IS_CONCAT_SPREADABLE = Symbol.isConcatSpreadable;
|
|
@@ -2338,16 +2607,15 @@ var SYMBOL_REF = {
|
|
|
2338
2607
|
[11]: SYM_TO_STRING_TAG,
|
|
2339
2608
|
[12]: SYM_UNSCOPABLES
|
|
2340
2609
|
};
|
|
2341
|
-
var NIL = undefined;
|
|
2342
2610
|
var CONSTANT_VAL = {
|
|
2343
2611
|
[2]: true,
|
|
2344
2612
|
[3]: false,
|
|
2345
|
-
[1]:
|
|
2613
|
+
[1]: undefined,
|
|
2346
2614
|
[0]: null,
|
|
2347
2615
|
[4]: -0,
|
|
2348
2616
|
[5]: Number.POSITIVE_INFINITY,
|
|
2349
2617
|
[6]: Number.NEGATIVE_INFINITY,
|
|
2350
|
-
[7]:
|
|
2618
|
+
[7]: NaN
|
|
2351
2619
|
};
|
|
2352
2620
|
var ERROR_CONSTRUCTOR = {
|
|
2353
2621
|
[0]: Error,
|
|
@@ -2358,6 +2626,8 @@ var ERROR_CONSTRUCTOR = {
|
|
|
2358
2626
|
[5]: TypeError,
|
|
2359
2627
|
[6]: URIError
|
|
2360
2628
|
};
|
|
2629
|
+
var MIN_JSON_STRINGIFY_LENGTH = 64;
|
|
2630
|
+
var JSON_ESCAPE_DIFFERENCES = /[\x00-\x07\x0b\x0e-\x1f<\u2028\u2029\ud800-\udfff]/;
|
|
2361
2631
|
function serializeChar(str) {
|
|
2362
2632
|
switch (str) {
|
|
2363
2633
|
case '"':
|
|
@@ -2382,10 +2652,12 @@ function serializeChar(str) {
|
|
|
2382
2652
|
case "\u2029":
|
|
2383
2653
|
return "\\u2029";
|
|
2384
2654
|
default:
|
|
2385
|
-
return
|
|
2655
|
+
return;
|
|
2386
2656
|
}
|
|
2387
2657
|
}
|
|
2388
2658
|
function serializeString(str) {
|
|
2659
|
+
if (str.length >= MIN_JSON_STRINGIFY_LENGTH && !JSON_ESCAPE_DIFFERENCES.test(str))
|
|
2660
|
+
return JSON.stringify(str).slice(1, -1);
|
|
2389
2661
|
let result = "";
|
|
2390
2662
|
let lastPos = 0;
|
|
2391
2663
|
let replacement;
|
|
@@ -2396,11 +2668,10 @@ function serializeString(str) {
|
|
|
2396
2668
|
lastPos = i + 1;
|
|
2397
2669
|
}
|
|
2398
2670
|
}
|
|
2399
|
-
if (lastPos === 0)
|
|
2671
|
+
if (lastPos === 0)
|
|
2400
2672
|
result = str;
|
|
2401
|
-
|
|
2673
|
+
else
|
|
2402
2674
|
result += str.slice(lastPos);
|
|
2403
|
-
}
|
|
2404
2675
|
return result;
|
|
2405
2676
|
}
|
|
2406
2677
|
function deserializeReplacer(str) {
|
|
@@ -2431,53 +2702,13 @@ function deserializeReplacer(str) {
|
|
|
2431
2702
|
}
|
|
2432
2703
|
}
|
|
2433
2704
|
function deserializeString(str) {
|
|
2705
|
+
if (typeof str === "string" && !str.includes("\\"))
|
|
2706
|
+
return str;
|
|
2434
2707
|
return str.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g, deserializeReplacer);
|
|
2435
2708
|
}
|
|
2436
|
-
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
2437
|
-
var GLOBAL_CONTEXT_REFERENCES = "$R";
|
|
2438
|
-
var GLOBAL_CONTEXT_R = `self.${GLOBAL_CONTEXT_REFERENCES}`;
|
|
2439
|
-
var INV_REFERENCE = /* @__PURE__ */ new Map;
|
|
2440
|
-
function hasReference(id) {
|
|
2441
|
-
return INV_REFERENCE.has(id);
|
|
2442
|
-
}
|
|
2443
|
-
function getReference(id) {
|
|
2444
|
-
if (hasReference(id)) {
|
|
2445
|
-
return INV_REFERENCE.get(id);
|
|
2446
|
-
}
|
|
2447
|
-
throw new SerovalMissingReferenceForIdError(id);
|
|
2448
|
-
}
|
|
2449
|
-
if (typeof globalThis !== "undefined") {
|
|
2450
|
-
Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
2451
|
-
value: INV_REFERENCE,
|
|
2452
|
-
configurable: true,
|
|
2453
|
-
writable: false,
|
|
2454
|
-
enumerable: false
|
|
2455
|
-
});
|
|
2456
|
-
} else if (typeof window !== "undefined") {
|
|
2457
|
-
Object.defineProperty(window, REFERENCES_KEY, {
|
|
2458
|
-
value: INV_REFERENCE,
|
|
2459
|
-
configurable: true,
|
|
2460
|
-
writable: false,
|
|
2461
|
-
enumerable: false
|
|
2462
|
-
});
|
|
2463
|
-
} else if (typeof self !== "undefined") {
|
|
2464
|
-
Object.defineProperty(self, REFERENCES_KEY, {
|
|
2465
|
-
value: INV_REFERENCE,
|
|
2466
|
-
configurable: true,
|
|
2467
|
-
writable: false,
|
|
2468
|
-
enumerable: false
|
|
2469
|
-
});
|
|
2470
|
-
} else if (typeof global !== "undefined") {
|
|
2471
|
-
Object.defineProperty(global, REFERENCES_KEY, {
|
|
2472
|
-
value: INV_REFERENCE,
|
|
2473
|
-
configurable: true,
|
|
2474
|
-
writable: false,
|
|
2475
|
-
enumerable: false
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
2709
|
var { toString: objectToString } = Object.prototype;
|
|
2479
2710
|
function getErrorMessageDev(type, cause) {
|
|
2480
|
-
if (cause instanceof Error)
|
|
2711
|
+
if (cause instanceof Error)
|
|
2481
2712
|
return `Seroval caught an error during the ${type} process.
|
|
2482
2713
|
|
|
2483
2714
|
${cause.name}
|
|
@@ -2485,7 +2716,6 @@ ${cause.message}
|
|
|
2485
2716
|
|
|
2486
2717
|
- For more information, please check the "cause" property of this error.
|
|
2487
2718
|
- If you believe this is an error in Seroval, please submit an issue at https://github.com/lxsmnsyc/seroval/issues/new`;
|
|
2488
|
-
}
|
|
2489
2719
|
return `Seroval caught an error during the ${type} process.
|
|
2490
2720
|
|
|
2491
2721
|
"${objectToString.call(cause)}"
|
|
@@ -2539,6 +2769,44 @@ var SerovalDepthLimitError = class extends Error {
|
|
|
2539
2769
|
super("Depth limit of " + limit + " reached");
|
|
2540
2770
|
}
|
|
2541
2771
|
};
|
|
2772
|
+
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
2773
|
+
var INV_REFERENCE = /* @__PURE__ */ new Map;
|
|
2774
|
+
function hasReference(id) {
|
|
2775
|
+
return INV_REFERENCE.has(id);
|
|
2776
|
+
}
|
|
2777
|
+
function getReference(id) {
|
|
2778
|
+
if (hasReference(id))
|
|
2779
|
+
return INV_REFERENCE.get(id);
|
|
2780
|
+
throw new SerovalMissingReferenceForIdError(id);
|
|
2781
|
+
}
|
|
2782
|
+
if (typeof globalThis !== "undefined")
|
|
2783
|
+
Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
2784
|
+
value: INV_REFERENCE,
|
|
2785
|
+
configurable: true,
|
|
2786
|
+
writable: false,
|
|
2787
|
+
enumerable: false
|
|
2788
|
+
});
|
|
2789
|
+
else if (typeof window !== "undefined")
|
|
2790
|
+
Object.defineProperty(window, REFERENCES_KEY, {
|
|
2791
|
+
value: INV_REFERENCE,
|
|
2792
|
+
configurable: true,
|
|
2793
|
+
writable: false,
|
|
2794
|
+
enumerable: false
|
|
2795
|
+
});
|
|
2796
|
+
else if (typeof self !== "undefined")
|
|
2797
|
+
Object.defineProperty(self, REFERENCES_KEY, {
|
|
2798
|
+
value: INV_REFERENCE,
|
|
2799
|
+
configurable: true,
|
|
2800
|
+
writable: false,
|
|
2801
|
+
enumerable: false
|
|
2802
|
+
});
|
|
2803
|
+
else if (typeof global !== "undefined")
|
|
2804
|
+
Object.defineProperty(global, REFERENCES_KEY, {
|
|
2805
|
+
value: INV_REFERENCE,
|
|
2806
|
+
configurable: true,
|
|
2807
|
+
writable: false,
|
|
2808
|
+
enumerable: false
|
|
2809
|
+
});
|
|
2542
2810
|
var PROMISE_CONSTRUCTOR = () => {
|
|
2543
2811
|
const resolver = {
|
|
2544
2812
|
p: 0,
|
|
@@ -2557,58 +2825,69 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
2557
2825
|
let alive = true;
|
|
2558
2826
|
let success = false;
|
|
2559
2827
|
let count = 0;
|
|
2560
|
-
const
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
listeners[x]
|
|
2828
|
+
const internal = {
|
|
2829
|
+
flush(value, mode, x) {
|
|
2830
|
+
for (x = 0;x < count; x++) {
|
|
2831
|
+
const listener = listeners[x];
|
|
2832
|
+
if (listener)
|
|
2833
|
+
listener[mode](value);
|
|
2564
2834
|
}
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
listener.next(current);
|
|
2835
|
+
},
|
|
2836
|
+
up(listener, x, z, current) {
|
|
2837
|
+
for (x = 0, z = buffer.length;x < z; x++) {
|
|
2838
|
+
current = buffer[x];
|
|
2839
|
+
if (!alive && x === z - 1)
|
|
2840
|
+
listener[success ? "return" : "throw"](current);
|
|
2841
|
+
else
|
|
2842
|
+
listener.next(current);
|
|
2574
2843
|
}
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
if (alive) {
|
|
2579
|
-
temp = count++;
|
|
2580
|
-
listeners[temp] = listener;
|
|
2581
|
-
}
|
|
2582
|
-
up(listener);
|
|
2583
|
-
return () => {
|
|
2844
|
+
},
|
|
2845
|
+
on(listener, temp = 0) {
|
|
2846
|
+
let subscribed = alive;
|
|
2584
2847
|
if (alive) {
|
|
2585
|
-
|
|
2586
|
-
|
|
2848
|
+
for (temp = 0;temp < count; temp++)
|
|
2849
|
+
if (!listeners[temp])
|
|
2850
|
+
break;
|
|
2851
|
+
if (temp === count)
|
|
2852
|
+
count++;
|
|
2853
|
+
listeners[temp] = listener;
|
|
2587
2854
|
}
|
|
2588
|
-
|
|
2855
|
+
internal.up(listener);
|
|
2856
|
+
return () => {
|
|
2857
|
+
if (alive && subscribed) {
|
|
2858
|
+
subscribed = false;
|
|
2859
|
+
listeners[temp] = undefined;
|
|
2860
|
+
while (count > 0 && !listeners[count - 1])
|
|
2861
|
+
count--;
|
|
2862
|
+
listeners.length = count;
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
}
|
|
2589
2866
|
};
|
|
2590
2867
|
return {
|
|
2591
2868
|
__SEROVAL_STREAM__: true,
|
|
2592
|
-
on
|
|
2593
|
-
|
|
2869
|
+
on(listener) {
|
|
2870
|
+
return internal.on(listener);
|
|
2871
|
+
},
|
|
2872
|
+
next(value) {
|
|
2594
2873
|
if (alive) {
|
|
2595
2874
|
buffer.push(value);
|
|
2596
|
-
flush(value, "next");
|
|
2875
|
+
internal.flush(value, "next");
|
|
2597
2876
|
}
|
|
2598
2877
|
},
|
|
2599
|
-
throw
|
|
2878
|
+
throw(value) {
|
|
2600
2879
|
if (alive) {
|
|
2601
2880
|
buffer.push(value);
|
|
2602
|
-
flush(value, "throw");
|
|
2881
|
+
internal.flush(value, "throw");
|
|
2603
2882
|
alive = false;
|
|
2604
2883
|
success = false;
|
|
2605
2884
|
listeners.length = 0;
|
|
2606
2885
|
}
|
|
2607
2886
|
},
|
|
2608
|
-
return
|
|
2887
|
+
return(value) {
|
|
2609
2888
|
if (alive) {
|
|
2610
2889
|
buffer.push(value);
|
|
2611
|
-
flush(value, "return");
|
|
2890
|
+
internal.flush(value, "return");
|
|
2612
2891
|
alive = false;
|
|
2613
2892
|
success = true;
|
|
2614
2893
|
listeners.length = 0;
|
|
@@ -2619,19 +2898,19 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
2619
2898
|
var ITERATOR_CONSTRUCTOR = (symbol) => (sequence) => () => {
|
|
2620
2899
|
let index = 0;
|
|
2621
2900
|
const instance = {
|
|
2622
|
-
[symbol]
|
|
2623
|
-
|
|
2624
|
-
|
|
2901
|
+
[symbol]() {
|
|
2902
|
+
return instance;
|
|
2903
|
+
},
|
|
2904
|
+
next() {
|
|
2905
|
+
if (index > sequence.d)
|
|
2625
2906
|
return {
|
|
2626
2907
|
done: true,
|
|
2627
2908
|
value: undefined
|
|
2628
2909
|
};
|
|
2629
|
-
}
|
|
2630
2910
|
const currentIndex = index++;
|
|
2631
2911
|
const data = sequence.v[currentIndex];
|
|
2632
|
-
if (currentIndex === sequence.t)
|
|
2912
|
+
if (currentIndex === sequence.t)
|
|
2633
2913
|
throw data;
|
|
2634
|
-
}
|
|
2635
2914
|
return {
|
|
2636
2915
|
done: currentIndex === sequence.d,
|
|
2637
2916
|
value: data
|
|
@@ -2646,74 +2925,75 @@ var ASYNC_ITERATOR_CONSTRUCTOR = (symbol, createPromise) => (stream) => () => {
|
|
|
2646
2925
|
let isThrow = false;
|
|
2647
2926
|
const buffer = [];
|
|
2648
2927
|
const pending = [];
|
|
2649
|
-
const
|
|
2650
|
-
for (;i < len; i++)
|
|
2928
|
+
const internal = { finalize(i = 0, len = pending.length) {
|
|
2929
|
+
for (;i < len; i++)
|
|
2651
2930
|
pending[i].s({
|
|
2652
2931
|
done: true,
|
|
2653
2932
|
value: undefined
|
|
2654
2933
|
});
|
|
2655
|
-
|
|
2656
|
-
};
|
|
2934
|
+
} };
|
|
2657
2935
|
stream.on({
|
|
2658
|
-
next
|
|
2936
|
+
next(value) {
|
|
2659
2937
|
const temp = pending.shift();
|
|
2660
|
-
if (temp)
|
|
2661
|
-
temp.s({
|
|
2662
|
-
|
|
2938
|
+
if (temp)
|
|
2939
|
+
temp.s({
|
|
2940
|
+
done: false,
|
|
2941
|
+
value
|
|
2942
|
+
});
|
|
2663
2943
|
buffer.push(value);
|
|
2664
2944
|
},
|
|
2665
|
-
throw
|
|
2945
|
+
throw(value) {
|
|
2666
2946
|
const temp = pending.shift();
|
|
2667
|
-
if (temp)
|
|
2947
|
+
if (temp)
|
|
2668
2948
|
temp.f(value);
|
|
2669
|
-
|
|
2670
|
-
finalize();
|
|
2949
|
+
internal.finalize();
|
|
2671
2950
|
doneAt = buffer.length;
|
|
2672
2951
|
isThrow = true;
|
|
2673
2952
|
buffer.push(value);
|
|
2674
2953
|
},
|
|
2675
|
-
return
|
|
2954
|
+
return(value) {
|
|
2676
2955
|
const temp = pending.shift();
|
|
2677
|
-
if (temp)
|
|
2678
|
-
temp.s({
|
|
2679
|
-
|
|
2680
|
-
|
|
2956
|
+
if (temp)
|
|
2957
|
+
temp.s({
|
|
2958
|
+
done: true,
|
|
2959
|
+
value
|
|
2960
|
+
});
|
|
2961
|
+
internal.finalize();
|
|
2681
2962
|
doneAt = buffer.length;
|
|
2682
2963
|
buffer.push(value);
|
|
2683
2964
|
}
|
|
2684
2965
|
});
|
|
2685
2966
|
const instance = {
|
|
2686
|
-
[symbol]
|
|
2687
|
-
|
|
2967
|
+
[symbol]() {
|
|
2968
|
+
return instance;
|
|
2969
|
+
},
|
|
2970
|
+
next() {
|
|
2688
2971
|
if (doneAt === -1) {
|
|
2689
|
-
const
|
|
2690
|
-
if (
|
|
2972
|
+
const index = count++;
|
|
2973
|
+
if (index >= buffer.length) {
|
|
2691
2974
|
const temp = createPromise();
|
|
2692
2975
|
pending.push(temp);
|
|
2693
2976
|
return temp.p;
|
|
2694
2977
|
}
|
|
2695
2978
|
return {
|
|
2696
2979
|
done: false,
|
|
2697
|
-
value: buffer[
|
|
2980
|
+
value: buffer[index]
|
|
2698
2981
|
};
|
|
2699
2982
|
}
|
|
2700
|
-
if (count > doneAt)
|
|
2983
|
+
if (count > doneAt)
|
|
2701
2984
|
return {
|
|
2702
2985
|
done: true,
|
|
2703
2986
|
value: undefined
|
|
2704
2987
|
};
|
|
2705
|
-
}
|
|
2706
2988
|
const index = count++;
|
|
2707
2989
|
const value = buffer[index];
|
|
2708
|
-
if (index !== doneAt)
|
|
2990
|
+
if (index !== doneAt)
|
|
2709
2991
|
return {
|
|
2710
2992
|
done: false,
|
|
2711
2993
|
value
|
|
2712
2994
|
};
|
|
2713
|
-
|
|
2714
|
-
if (isThrow) {
|
|
2995
|
+
if (isThrow)
|
|
2715
2996
|
throw value;
|
|
2716
|
-
}
|
|
2717
2997
|
return {
|
|
2718
2998
|
done: true,
|
|
2719
2999
|
value
|
|
@@ -2726,9 +3006,8 @@ var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
|
2726
3006
|
const decoded = atob(b64);
|
|
2727
3007
|
const length = decoded.length;
|
|
2728
3008
|
const arr = new Uint8Array(length);
|
|
2729
|
-
for (let i = 0;i < length; i++)
|
|
3009
|
+
for (let i = 0;i < length; i++)
|
|
2730
3010
|
arr[i] = decoded.charCodeAt(i);
|
|
2731
|
-
}
|
|
2732
3011
|
return arr.buffer;
|
|
2733
3012
|
};
|
|
2734
3013
|
function createSequence(values, throwAt, doneAt) {
|
|
@@ -2755,9 +3034,8 @@ function dedupePlugins(deduped, plugins) {
|
|
|
2755
3034
|
const current = plugins[i];
|
|
2756
3035
|
if (!deduped.has(current)) {
|
|
2757
3036
|
deduped.add(current);
|
|
2758
|
-
if (current.extends)
|
|
3037
|
+
if (current.extends)
|
|
2759
3038
|
dedupePlugins(deduped, current.extends);
|
|
2760
|
-
}
|
|
2761
3039
|
}
|
|
2762
3040
|
}
|
|
2763
3041
|
}
|
|
@@ -2767,7 +3045,6 @@ function resolvePlugins(plugins) {
|
|
|
2767
3045
|
dedupePlugins(deduped, plugins);
|
|
2768
3046
|
return [...deduped];
|
|
2769
3047
|
}
|
|
2770
|
-
return;
|
|
2771
3048
|
}
|
|
2772
3049
|
function getTypedArrayConstructor(name) {
|
|
2773
3050
|
switch (name) {
|
|
@@ -2822,7 +3099,8 @@ function isValidSymbol(symbol) {
|
|
|
2822
3099
|
return false;
|
|
2823
3100
|
}
|
|
2824
3101
|
}
|
|
2825
|
-
var
|
|
3102
|
+
var DEFAULT_MAX_BASE64_LENGTH = 1e6;
|
|
3103
|
+
var MIN_NATIVE_BASE64_LENGTH = 512;
|
|
2826
3104
|
var MAX_BIGINT_LENGTH = 1e4;
|
|
2827
3105
|
var MAX_REGEXP_SOURCE_LENGTH = 20000;
|
|
2828
3106
|
function applyObjectFlag(obj, flag) {
|
|
@@ -2839,26 +3117,27 @@ function applyObjectFlag(obj, flag) {
|
|
|
2839
3117
|
}
|
|
2840
3118
|
var DEFAULT_DEPTH_LIMIT = 1000;
|
|
2841
3119
|
function createBaseDeserializerContext(mode, options) {
|
|
2842
|
-
var
|
|
3120
|
+
var _options$maxBase64Len, _options$features;
|
|
3121
|
+
const maxBase64Length = (_options$maxBase64Len = options.maxBase64Length) !== null && _options$maxBase64Len !== undefined ? _options$maxBase64Len : DEFAULT_MAX_BASE64_LENGTH;
|
|
3122
|
+
if (!Number.isSafeInteger(maxBase64Length) || maxBase64Length < 0)
|
|
3123
|
+
throw new RangeError("maxBase64Length must be a non-negative safe integer");
|
|
2843
3124
|
const refs = options.refs || /* @__PURE__ */ new Map;
|
|
2844
|
-
if (!("types" in refs))
|
|
2845
|
-
Object.assign(refs, {
|
|
2846
|
-
types: /* @__PURE__ */ new Map
|
|
2847
|
-
});
|
|
2848
|
-
}
|
|
3125
|
+
if (!("types" in refs))
|
|
3126
|
+
Object.assign(refs, { types: /* @__PURE__ */ new Map });
|
|
2849
3127
|
return {
|
|
2850
3128
|
mode,
|
|
2851
3129
|
plugins: options.plugins,
|
|
2852
3130
|
refs,
|
|
2853
|
-
features: (
|
|
2854
|
-
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT
|
|
3131
|
+
features: (_options$features = options.features) !== null && _options$features !== undefined ? _options$features : 127 ^ (options.disabledFeatures || 0),
|
|
3132
|
+
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT,
|
|
3133
|
+
maxBase64Length
|
|
2855
3134
|
};
|
|
2856
3135
|
}
|
|
2857
3136
|
function createCrossDeserializerContext(options) {
|
|
2858
3137
|
return {
|
|
2859
3138
|
mode: 2,
|
|
2860
3139
|
base: createBaseDeserializerContext(2, options),
|
|
2861
|
-
child:
|
|
3140
|
+
child: undefined
|
|
2862
3141
|
};
|
|
2863
3142
|
}
|
|
2864
3143
|
var DeserializePluginContext = class {
|
|
@@ -2867,25 +3146,25 @@ var DeserializePluginContext = class {
|
|
|
2867
3146
|
this.depth = depth;
|
|
2868
3147
|
}
|
|
2869
3148
|
deserialize(node) {
|
|
2870
|
-
return deserialize(this._p, this.depth, node);
|
|
3149
|
+
return deserialize$1(this._p, this.depth, node);
|
|
2871
3150
|
}
|
|
2872
3151
|
};
|
|
2873
3152
|
function guardIndexedValue(ctx, id) {
|
|
2874
|
-
if (id < 0 || !Number.isFinite(id) || !Number.isInteger(id))
|
|
3153
|
+
if (id < 0 || !Number.isFinite(id) || !Number.isInteger(id))
|
|
2875
3154
|
throw new SerovalMalformedNodeError({
|
|
2876
3155
|
t: 4,
|
|
2877
3156
|
i: id
|
|
2878
3157
|
});
|
|
2879
|
-
|
|
2880
|
-
if (ctx.refs.has(id)) {
|
|
3158
|
+
if (ctx.refs.has(id))
|
|
2881
3159
|
throw new Error("Conflicted ref id: " + id);
|
|
2882
|
-
|
|
3160
|
+
}
|
|
3161
|
+
function isThennable(value) {
|
|
3162
|
+
return !!value && typeof value === "object" && "then" in value && typeof value.then === "function";
|
|
2883
3163
|
}
|
|
2884
3164
|
function assignIndexedValueVanilla(ctx, id, value) {
|
|
2885
3165
|
guardIndexedValue(ctx.base, id);
|
|
2886
|
-
if (ctx.state.marked.has(id))
|
|
3166
|
+
if (ctx.state.marked.has(id))
|
|
2887
3167
|
ctx.base.refs.set(id, value);
|
|
2888
|
-
}
|
|
2889
3168
|
return value;
|
|
2890
3169
|
}
|
|
2891
3170
|
function assignIndexedValueCross(ctx, id, value) {
|
|
@@ -2893,56 +3172,52 @@ function assignIndexedValueCross(ctx, id, value) {
|
|
|
2893
3172
|
ctx.base.refs.set(id, value);
|
|
2894
3173
|
return value;
|
|
2895
3174
|
}
|
|
2896
|
-
function assignIndexedValue(ctx, id, value) {
|
|
3175
|
+
function assignIndexedValue$1(ctx, id, value) {
|
|
2897
3176
|
return ctx.mode === 1 ? assignIndexedValueVanilla(ctx, id, value) : assignIndexedValueCross(ctx, id, value);
|
|
2898
3177
|
}
|
|
2899
3178
|
function deserializeKnownValue(node, record, key) {
|
|
2900
|
-
if (Object.hasOwn(record, key))
|
|
3179
|
+
if (Object.hasOwn(record, key))
|
|
2901
3180
|
return record[key];
|
|
2902
|
-
}
|
|
2903
3181
|
throw new SerovalMalformedNodeError(node);
|
|
2904
3182
|
}
|
|
2905
3183
|
function deserializeReference(ctx, node) {
|
|
2906
|
-
return assignIndexedValue(ctx, node.i, getReference(deserializeString(node.s)));
|
|
3184
|
+
return assignIndexedValue$1(ctx, node.i, getReference(deserializeString(node.s)));
|
|
2907
3185
|
}
|
|
2908
3186
|
function deserializeArray(ctx, depth, node) {
|
|
2909
3187
|
const items = node.a;
|
|
2910
3188
|
const len = items.length;
|
|
2911
|
-
const result = assignIndexedValue(ctx, node.i, new Array(len));
|
|
3189
|
+
const result = assignIndexedValue$1(ctx, node.i, new Array(len));
|
|
2912
3190
|
for (let i = 0, item;i < len; i++) {
|
|
2913
3191
|
item = items[i];
|
|
2914
|
-
if (item)
|
|
2915
|
-
result[i] = deserialize(ctx, depth, item);
|
|
2916
|
-
}
|
|
3192
|
+
if (item)
|
|
3193
|
+
result[i] = deserialize$1(ctx, depth, item);
|
|
2917
3194
|
}
|
|
2918
3195
|
applyObjectFlag(result, node.o);
|
|
2919
3196
|
return result;
|
|
2920
3197
|
}
|
|
2921
3198
|
function assignStringProperty(object, key, value) {
|
|
2922
|
-
if (isValidKey(key))
|
|
3199
|
+
if (isValidKey(key))
|
|
2923
3200
|
object[key] = value;
|
|
2924
|
-
|
|
3201
|
+
else
|
|
2925
3202
|
Object.defineProperty(object, key, {
|
|
2926
3203
|
value,
|
|
2927
3204
|
configurable: true,
|
|
2928
3205
|
enumerable: true,
|
|
2929
3206
|
writable: true
|
|
2930
3207
|
});
|
|
2931
|
-
}
|
|
2932
3208
|
}
|
|
2933
3209
|
function assignProperty(ctx, depth, object, key, value) {
|
|
2934
|
-
if (typeof key === "string")
|
|
2935
|
-
assignStringProperty(object, deserializeString(key), deserialize(ctx, depth, value));
|
|
2936
|
-
|
|
2937
|
-
const actual = deserialize(ctx, depth, key);
|
|
3210
|
+
if (typeof key === "string")
|
|
3211
|
+
assignStringProperty(object, deserializeString(key), deserialize$1(ctx, depth, value));
|
|
3212
|
+
else {
|
|
3213
|
+
const actual = deserialize$1(ctx, depth, key);
|
|
2938
3214
|
switch (typeof actual) {
|
|
2939
3215
|
case "string":
|
|
2940
|
-
assignStringProperty(object, actual, deserialize(ctx, depth, value));
|
|
3216
|
+
assignStringProperty(object, actual, deserialize$1(ctx, depth, value));
|
|
2941
3217
|
break;
|
|
2942
3218
|
case "symbol":
|
|
2943
|
-
if (isValidSymbol(actual))
|
|
2944
|
-
object[actual] = deserialize(ctx, depth, value);
|
|
2945
|
-
}
|
|
3219
|
+
if (isValidSymbol(actual))
|
|
3220
|
+
object[actual] = deserialize$1(ctx, depth, value);
|
|
2946
3221
|
break;
|
|
2947
3222
|
default:
|
|
2948
3223
|
throw new SerovalMalformedNodeError(key);
|
|
@@ -2953,80 +3228,116 @@ function assignNodeType(ctx, id, type) {
|
|
|
2953
3228
|
ctx.base.refs.types.set(id, type);
|
|
2954
3229
|
}
|
|
2955
3230
|
function validateNodeType(ctx, node, id, type) {
|
|
2956
|
-
if (ctx.base.refs.types.get(id) !== type)
|
|
3231
|
+
if (ctx.base.refs.types.get(id) !== type)
|
|
2957
3232
|
throw new SerovalMalformedNodeError(node);
|
|
2958
|
-
}
|
|
2959
3233
|
}
|
|
2960
3234
|
function deserializeProperties(ctx, depth, node, result) {
|
|
2961
3235
|
const keys = node.k;
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
for (let i = 0, vals = node.v, len2 = keys.length;i < len2; i++) {
|
|
3236
|
+
if (keys.length > 0)
|
|
3237
|
+
for (let i = 0, vals = node.v, len = keys.length;i < len; i++)
|
|
2965
3238
|
assignProperty(ctx, depth, result, keys[i], vals[i]);
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
3239
|
return result;
|
|
2969
3240
|
}
|
|
2970
3241
|
function deserializeObject(ctx, depth, node) {
|
|
2971
|
-
const result = assignIndexedValue(ctx, node.i, node.t === 10 ? {} :
|
|
3242
|
+
const result = assignIndexedValue$1(ctx, node.i, node.t === 10 ? {} : Object.create(null));
|
|
2972
3243
|
deserializeProperties(ctx, depth, node.p, result);
|
|
2973
3244
|
applyObjectFlag(result, node.o);
|
|
2974
3245
|
return result;
|
|
2975
3246
|
}
|
|
2976
3247
|
function deserializeDate(ctx, node) {
|
|
2977
|
-
return assignIndexedValue(ctx, node.i, new Date(node.s));
|
|
3248
|
+
return assignIndexedValue$1(ctx, node.i, new Date(node.s));
|
|
3249
|
+
}
|
|
3250
|
+
function deserializeTemporal(ctx, node) {
|
|
3251
|
+
if (!(ctx.base.features & 64))
|
|
3252
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
3253
|
+
let value;
|
|
3254
|
+
switch (node.c) {
|
|
3255
|
+
case 0:
|
|
3256
|
+
value = Temporal.Instant.from(node.s);
|
|
3257
|
+
break;
|
|
3258
|
+
case 1:
|
|
3259
|
+
value = Temporal.Duration.from(node.s);
|
|
3260
|
+
break;
|
|
3261
|
+
case 2:
|
|
3262
|
+
value = Temporal.PlainDate.from(node.s);
|
|
3263
|
+
break;
|
|
3264
|
+
case 3:
|
|
3265
|
+
value = Temporal.PlainDateTime.from(node.s);
|
|
3266
|
+
break;
|
|
3267
|
+
case 4:
|
|
3268
|
+
value = Temporal.PlainMonthDay.from(node.s);
|
|
3269
|
+
break;
|
|
3270
|
+
case 5:
|
|
3271
|
+
value = Temporal.PlainTime.from(node.s);
|
|
3272
|
+
break;
|
|
3273
|
+
case 6:
|
|
3274
|
+
value = Temporal.PlainYearMonth.from(node.s);
|
|
3275
|
+
break;
|
|
3276
|
+
case 7:
|
|
3277
|
+
value = Temporal.ZonedDateTime.from(node.s);
|
|
3278
|
+
break;
|
|
3279
|
+
default:
|
|
3280
|
+
throw new SerovalMalformedNodeError(node);
|
|
3281
|
+
}
|
|
3282
|
+
return assignIndexedValue$1(ctx, node.i, value);
|
|
2978
3283
|
}
|
|
2979
3284
|
function deserializeRegExp(ctx, node) {
|
|
2980
3285
|
if (ctx.base.features & 32) {
|
|
2981
3286
|
const source = deserializeString(node.c);
|
|
2982
|
-
if (source.length > MAX_REGEXP_SOURCE_LENGTH)
|
|
3287
|
+
if (source.length > MAX_REGEXP_SOURCE_LENGTH)
|
|
2983
3288
|
throw new SerovalMalformedNodeError(node);
|
|
2984
|
-
|
|
2985
|
-
return assignIndexedValue(ctx, node.i, new RegExp(source, node.m));
|
|
3289
|
+
return assignIndexedValue$1(ctx, node.i, new RegExp(source, node.m));
|
|
2986
3290
|
}
|
|
2987
3291
|
throw new SerovalUnsupportedNodeError(node);
|
|
2988
3292
|
}
|
|
2989
3293
|
function deserializeSet(ctx, depth, node) {
|
|
2990
|
-
const result = assignIndexedValue(ctx, node.i, /* @__PURE__ */ new Set);
|
|
2991
|
-
for (let i = 0, items = node.a, len = items.length;i < len; i++)
|
|
2992
|
-
result.add(deserialize(ctx, depth, items[i]));
|
|
2993
|
-
}
|
|
3294
|
+
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Set);
|
|
3295
|
+
for (let i = 0, items = node.a, len = items.length;i < len; i++)
|
|
3296
|
+
result.add(deserialize$1(ctx, depth, items[i]));
|
|
2994
3297
|
return result;
|
|
2995
3298
|
}
|
|
2996
3299
|
function deserializeMap(ctx, depth, node) {
|
|
2997
|
-
const result = assignIndexedValue(ctx, node.i, /* @__PURE__ */ new Map);
|
|
2998
|
-
for (let i = 0, keys = node.e.k, vals = node.e.v, len = keys.length;i < len; i++)
|
|
2999
|
-
result.set(deserialize(ctx, depth, keys[i]), deserialize(ctx, depth, vals[i]));
|
|
3000
|
-
}
|
|
3300
|
+
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Map);
|
|
3301
|
+
for (let i = 0, keys = node.e.k, vals = node.e.v, len = keys.length;i < len; i++)
|
|
3302
|
+
result.set(deserialize$1(ctx, depth, keys[i]), deserialize$1(ctx, depth, vals[i]));
|
|
3001
3303
|
return result;
|
|
3002
3304
|
}
|
|
3003
3305
|
function deserializeArrayBuffer(ctx, node) {
|
|
3004
|
-
if (node.s
|
|
3306
|
+
if (typeof node.s !== "string")
|
|
3005
3307
|
throw new SerovalMalformedNodeError(node);
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3308
|
+
if (node.s.length > ctx.base.maxBase64Length)
|
|
3309
|
+
throw new RangeError("ArrayBuffer exceeds maxBase64Length (" + ctx.base.maxBase64Length + ")");
|
|
3310
|
+
const source = deserializeString(node.s);
|
|
3311
|
+
let buffer;
|
|
3312
|
+
if (source.length < MIN_NATIVE_BASE64_LENGTH || typeof Buffer === "undefined")
|
|
3313
|
+
buffer = ARRAY_BUFFER_CONSTRUCTOR(source);
|
|
3314
|
+
else {
|
|
3315
|
+
const decoded = atob(source);
|
|
3316
|
+
buffer = new ArrayBuffer(decoded.length);
|
|
3317
|
+
Buffer.from(buffer).write(decoded, "latin1");
|
|
3318
|
+
}
|
|
3319
|
+
return assignIndexedValue$1(ctx, node.i, buffer);
|
|
3009
3320
|
}
|
|
3010
3321
|
function deserializeTypedArray(ctx, depth, node) {
|
|
3011
|
-
var
|
|
3322
|
+
var _node$b;
|
|
3012
3323
|
const construct = getTypedArrayConstructor(node.c);
|
|
3013
|
-
const source = deserialize(ctx, depth, node.f);
|
|
3014
|
-
|
|
3015
|
-
if (offset < 0 || offset > source.byteLength) {
|
|
3324
|
+
const source = deserialize$1(ctx, depth, node.f);
|
|
3325
|
+
if (!(source instanceof ArrayBuffer))
|
|
3016
3326
|
throw new SerovalMalformedNodeError(node);
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3327
|
+
const offset = (_node$b = node.b) !== null && _node$b !== undefined ? _node$b : 0;
|
|
3328
|
+
if (offset < 0 || offset > source.byteLength)
|
|
3329
|
+
throw new SerovalMalformedNodeError(node);
|
|
3330
|
+
return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
|
|
3020
3331
|
}
|
|
3021
3332
|
function deserializeDataView(ctx, depth, node) {
|
|
3022
|
-
var
|
|
3023
|
-
const source = deserialize(ctx, depth, node.f);
|
|
3024
|
-
|
|
3025
|
-
if (offset < 0 || offset > source.byteLength) {
|
|
3333
|
+
var _node$b2;
|
|
3334
|
+
const source = deserialize$1(ctx, depth, node.f);
|
|
3335
|
+
if (!(source instanceof ArrayBuffer))
|
|
3026
3336
|
throw new SerovalMalformedNodeError(node);
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3337
|
+
const offset = (_node$b2 = node.b) !== null && _node$b2 !== undefined ? _node$b2 : 0;
|
|
3338
|
+
if (offset < 0 || offset > source.byteLength)
|
|
3339
|
+
throw new SerovalMalformedNodeError(node);
|
|
3340
|
+
return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
|
|
3030
3341
|
}
|
|
3031
3342
|
function deserializeDictionary(ctx, depth, node, result) {
|
|
3032
3343
|
if (node.p) {
|
|
@@ -3036,27 +3347,26 @@ function deserializeDictionary(ctx, depth, node, result) {
|
|
|
3036
3347
|
return result;
|
|
3037
3348
|
}
|
|
3038
3349
|
function deserializeAggregateError(ctx, depth, node) {
|
|
3039
|
-
|
|
3040
|
-
return deserializeDictionary(ctx, depth, node, result);
|
|
3350
|
+
return deserializeDictionary(ctx, depth, node, assignIndexedValue$1(ctx, node.i, new AggregateError([], deserializeString(node.m))));
|
|
3041
3351
|
}
|
|
3042
3352
|
function deserializeError(ctx, depth, node) {
|
|
3043
3353
|
const construct = deserializeKnownValue(node, ERROR_CONSTRUCTOR, node.s);
|
|
3044
|
-
|
|
3045
|
-
return deserializeDictionary(ctx, depth, node, result);
|
|
3354
|
+
return deserializeDictionary(ctx, depth, node, assignIndexedValue$1(ctx, node.i, new construct(deserializeString(node.m))));
|
|
3046
3355
|
}
|
|
3047
3356
|
function deserializePromise(ctx, depth, node) {
|
|
3048
3357
|
const deferred = PROMISE_CONSTRUCTOR();
|
|
3049
|
-
const result = assignIndexedValue(ctx, node.i, deferred.p);
|
|
3050
|
-
const deserialized = deserialize(ctx, depth, node.f);
|
|
3051
|
-
if (
|
|
3358
|
+
const result = assignIndexedValue$1(ctx, node.i, deferred.p);
|
|
3359
|
+
const deserialized = deserialize$1(ctx, depth, node.f);
|
|
3360
|
+
if (isThennable(deserialized))
|
|
3361
|
+
throw new SerovalMalformedNodeError(node.f);
|
|
3362
|
+
if (node.s)
|
|
3052
3363
|
deferred.s(deserialized);
|
|
3053
|
-
|
|
3364
|
+
else
|
|
3054
3365
|
deferred.f(deserialized);
|
|
3055
|
-
}
|
|
3056
3366
|
return result;
|
|
3057
3367
|
}
|
|
3058
3368
|
function deserializeBoxed(ctx, depth, node) {
|
|
3059
|
-
return assignIndexedValue(ctx, node.i, Object(deserialize(ctx, depth, node.f)));
|
|
3369
|
+
return assignIndexedValue$1(ctx, node.i, Object(deserialize$1(ctx, depth, node.f)));
|
|
3060
3370
|
}
|
|
3061
3371
|
function deserializePlugin(ctx, depth, node) {
|
|
3062
3372
|
const currentPlugins = ctx.base.plugins;
|
|
@@ -3064,66 +3374,64 @@ function deserializePlugin(ctx, depth, node) {
|
|
|
3064
3374
|
const tag = deserializeString(node.c);
|
|
3065
3375
|
for (let i = 0, len = currentPlugins.length;i < len; i++) {
|
|
3066
3376
|
const plugin = currentPlugins[i];
|
|
3067
|
-
if (plugin.tag === tag)
|
|
3068
|
-
return assignIndexedValue(ctx, node.i, plugin.deserialize(node.s, new DeserializePluginContext(ctx, depth), {
|
|
3069
|
-
id: node.i
|
|
3070
|
-
}));
|
|
3071
|
-
}
|
|
3377
|
+
if (plugin.tag === tag)
|
|
3378
|
+
return assignIndexedValue$1(ctx, node.i, plugin.deserialize(node.s, new DeserializePluginContext(ctx, depth), { id: node.i }));
|
|
3072
3379
|
}
|
|
3073
3380
|
}
|
|
3074
3381
|
throw new SerovalMissingPluginError(node.c);
|
|
3075
3382
|
}
|
|
3076
3383
|
function deserializePromiseConstructor(ctx, node) {
|
|
3077
|
-
const value = assignIndexedValue(ctx, node.i, assignIndexedValue(ctx, node.s, PROMISE_CONSTRUCTOR()).p);
|
|
3384
|
+
const value = assignIndexedValue$1(ctx, node.i, assignIndexedValue$1(ctx, node.s, PROMISE_CONSTRUCTOR()).p);
|
|
3078
3385
|
assignNodeType(ctx, node.s, 22);
|
|
3079
3386
|
return value;
|
|
3080
3387
|
}
|
|
3081
|
-
function
|
|
3082
|
-
const deferred = ctx.base.refs.get(node.i);
|
|
3083
|
-
if (deferred) {
|
|
3084
|
-
validateNodeType(ctx, node, node.i, 22);
|
|
3085
|
-
deferred.s(deserialize(ctx, depth, node.a[1]));
|
|
3086
|
-
return NIL;
|
|
3087
|
-
}
|
|
3088
|
-
throw new SerovalMissingInstanceError("Promise");
|
|
3089
|
-
}
|
|
3090
|
-
function deserializePromiseReject(ctx, depth, node) {
|
|
3388
|
+
function deserializePromiseFulfill(ctx, depth, node) {
|
|
3091
3389
|
const deferred = ctx.base.refs.get(node.i);
|
|
3092
3390
|
if (deferred) {
|
|
3093
3391
|
validateNodeType(ctx, node, node.i, 22);
|
|
3094
|
-
|
|
3095
|
-
|
|
3392
|
+
const deserialized = deserialize$1(ctx, depth, node.a[1]);
|
|
3393
|
+
if (isThennable(deserialized))
|
|
3394
|
+
throw new SerovalMalformedNodeError(node.a[1]);
|
|
3395
|
+
if (node.t === 23)
|
|
3396
|
+
deferred.s(deserialized);
|
|
3397
|
+
else
|
|
3398
|
+
deferred.f(deserialized);
|
|
3399
|
+
return;
|
|
3096
3400
|
}
|
|
3097
3401
|
throw new SerovalMissingInstanceError("Promise");
|
|
3098
3402
|
}
|
|
3099
3403
|
function deserializeIteratorFactoryInstance(ctx, depth, node) {
|
|
3100
|
-
deserialize(ctx, depth, node.a[0]);
|
|
3101
|
-
const source = deserialize(ctx, depth, node.a[1]);
|
|
3404
|
+
deserialize$1(ctx, depth, node.a[0]);
|
|
3405
|
+
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
3406
|
+
validateNodeType(ctx, node, node.a[1].i, 35);
|
|
3407
|
+
if (!source)
|
|
3408
|
+
throw new SerovalMalformedNodeError(node.a[1]);
|
|
3102
3409
|
return sequenceToIterator(source);
|
|
3103
3410
|
}
|
|
3104
3411
|
function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
3105
|
-
deserialize(ctx, depth, node.a[0]);
|
|
3106
|
-
const source = deserialize(ctx, depth, node.a[1]);
|
|
3412
|
+
deserialize$1(ctx, depth, node.a[0]);
|
|
3413
|
+
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
3414
|
+
validateNodeType(ctx, node, node.a[1].i, 31);
|
|
3415
|
+
if (!source)
|
|
3416
|
+
throw new SerovalMalformedNodeError(node.a[1]);
|
|
3107
3417
|
return streamToAsyncIterable(source);
|
|
3108
3418
|
}
|
|
3109
3419
|
function deserializeStreamConstructor(ctx, depth, node) {
|
|
3110
|
-
const result = assignIndexedValue(ctx, node.i, createStream());
|
|
3420
|
+
const result = assignIndexedValue$1(ctx, node.i, createStream());
|
|
3111
3421
|
assignNodeType(ctx, node.i, 31);
|
|
3112
3422
|
const items = node.a;
|
|
3113
3423
|
const len = items.length;
|
|
3114
|
-
if (len)
|
|
3115
|
-
for (let i = 0;i < len; i++)
|
|
3116
|
-
deserialize(ctx, depth, items[i]);
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3424
|
+
if (len)
|
|
3425
|
+
for (let i = 0;i < len; i++)
|
|
3426
|
+
deserialize$1(ctx, depth, items[i]);
|
|
3119
3427
|
return result;
|
|
3120
3428
|
}
|
|
3121
3429
|
function deserializeStreamNext(ctx, depth, node) {
|
|
3122
3430
|
const deferred = ctx.base.refs.get(node.i);
|
|
3123
3431
|
if (deferred) {
|
|
3124
3432
|
validateNodeType(ctx, node, node.i, 31);
|
|
3125
|
-
deferred.next(deserialize(ctx, depth, node.f));
|
|
3126
|
-
return
|
|
3433
|
+
deferred.next(deserialize$1(ctx, depth, node.f));
|
|
3434
|
+
return;
|
|
3127
3435
|
}
|
|
3128
3436
|
throw new SerovalMissingInstanceError("Stream");
|
|
3129
3437
|
}
|
|
@@ -3131,8 +3439,8 @@ function deserializeStreamThrow(ctx, depth, node) {
|
|
|
3131
3439
|
const deferred = ctx.base.refs.get(node.i);
|
|
3132
3440
|
if (deferred) {
|
|
3133
3441
|
validateNodeType(ctx, node, node.i, 31);
|
|
3134
|
-
deferred.throw(deserialize(ctx, depth, node.f));
|
|
3135
|
-
return
|
|
3442
|
+
deferred.throw(deserialize$1(ctx, depth, node.f));
|
|
3443
|
+
return;
|
|
3136
3444
|
}
|
|
3137
3445
|
throw new SerovalMissingInstanceError("Stream");
|
|
3138
3446
|
}
|
|
@@ -3140,30 +3448,27 @@ function deserializeStreamReturn(ctx, depth, node) {
|
|
|
3140
3448
|
const deferred = ctx.base.refs.get(node.i);
|
|
3141
3449
|
if (deferred) {
|
|
3142
3450
|
validateNodeType(ctx, node, node.i, 31);
|
|
3143
|
-
deferred.return(deserialize(ctx, depth, node.f));
|
|
3144
|
-
return
|
|
3451
|
+
deferred.return(deserialize$1(ctx, depth, node.f));
|
|
3452
|
+
return;
|
|
3145
3453
|
}
|
|
3146
3454
|
throw new SerovalMissingInstanceError("Stream");
|
|
3147
3455
|
}
|
|
3148
3456
|
function deserializeIteratorFactory(ctx, depth, node) {
|
|
3149
|
-
deserialize(ctx, depth, node.f);
|
|
3150
|
-
return NIL;
|
|
3457
|
+
deserialize$1(ctx, depth, node.f);
|
|
3151
3458
|
}
|
|
3152
3459
|
function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
3153
|
-
deserialize(ctx, depth, node.a[1]);
|
|
3154
|
-
return NIL;
|
|
3460
|
+
deserialize$1(ctx, depth, node.a[1]);
|
|
3155
3461
|
}
|
|
3156
3462
|
function deserializeSequence(ctx, depth, node) {
|
|
3157
|
-
const result = assignIndexedValue(ctx, node.i, createSequence([], node.s, node.l));
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3463
|
+
const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
|
|
3464
|
+
assignNodeType(ctx, node.i, 35);
|
|
3465
|
+
for (let i = 0, len = node.a.length;i < len; i++)
|
|
3466
|
+
result.v[i] = deserialize$1(ctx, depth, node.a[i]);
|
|
3161
3467
|
return result;
|
|
3162
3468
|
}
|
|
3163
|
-
function deserialize(ctx, depth, node) {
|
|
3164
|
-
if (depth > ctx.base.depthLimit)
|
|
3469
|
+
function deserialize$1(ctx, depth, node) {
|
|
3470
|
+
if (depth > ctx.base.depthLimit)
|
|
3165
3471
|
throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
3166
|
-
}
|
|
3167
3472
|
depth += 1;
|
|
3168
3473
|
switch (node.t) {
|
|
3169
3474
|
case 2:
|
|
@@ -3173,9 +3478,8 @@ function deserialize(ctx, depth, node) {
|
|
|
3173
3478
|
case 1:
|
|
3174
3479
|
return deserializeString(String(node.s));
|
|
3175
3480
|
case 3:
|
|
3176
|
-
if (String(node.s).length > MAX_BIGINT_LENGTH)
|
|
3481
|
+
if (String(node.s).length > MAX_BIGINT_LENGTH)
|
|
3177
3482
|
throw new SerovalMalformedNodeError(node);
|
|
3178
|
-
}
|
|
3179
3483
|
return BigInt(node.s);
|
|
3180
3484
|
case 4:
|
|
3181
3485
|
return ctx.base.refs.get(node.i);
|
|
@@ -3216,9 +3520,8 @@ function deserialize(ctx, depth, node) {
|
|
|
3216
3520
|
case 22:
|
|
3217
3521
|
return deserializePromiseConstructor(ctx, node);
|
|
3218
3522
|
case 23:
|
|
3219
|
-
return deserializePromiseResolve(ctx, depth, node);
|
|
3220
3523
|
case 24:
|
|
3221
|
-
return
|
|
3524
|
+
return deserializePromiseFulfill(ctx, depth, node);
|
|
3222
3525
|
case 28:
|
|
3223
3526
|
return deserializeIteratorFactoryInstance(ctx, depth, node);
|
|
3224
3527
|
case 30:
|
|
@@ -3237,38 +3540,84 @@ function deserialize(ctx, depth, node) {
|
|
|
3237
3540
|
return deserializeAsyncIteratorFactory(ctx, depth, node);
|
|
3238
3541
|
case 35:
|
|
3239
3542
|
return deserializeSequence(ctx, depth, node);
|
|
3543
|
+
case 36:
|
|
3544
|
+
return deserializeTemporal(ctx, node);
|
|
3240
3545
|
default:
|
|
3241
3546
|
throw new SerovalUnsupportedNodeError(node);
|
|
3242
3547
|
}
|
|
3243
3548
|
}
|
|
3244
3549
|
function deserializeTop(ctx, node) {
|
|
3245
3550
|
try {
|
|
3246
|
-
return deserialize(ctx, 0, node);
|
|
3551
|
+
return deserialize$1(ctx, 0, node);
|
|
3247
3552
|
} catch (error) {
|
|
3248
3553
|
throw new SerovalDeserializationError(error);
|
|
3249
3554
|
}
|
|
3250
3555
|
}
|
|
3251
|
-
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
3252
|
-
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
3253
|
-
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
3254
|
-
var REF_CHARS_LEN = REF_CHARS.length;
|
|
3255
3556
|
function fromCrossJSON(source, options) {
|
|
3256
3557
|
const plugins = resolvePlugins(options.plugins);
|
|
3257
|
-
|
|
3558
|
+
return deserializeTop(createCrossDeserializerContext({
|
|
3559
|
+
maxBase64Length: options.maxBase64Length,
|
|
3258
3560
|
plugins,
|
|
3259
3561
|
refs: options.refs,
|
|
3260
3562
|
features: options.features,
|
|
3261
3563
|
disabledFeatures: options.disabledFeatures,
|
|
3262
3564
|
depthLimit: options.depthLimit
|
|
3565
|
+
}), source);
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
// src/shared/compact-json.ts
|
|
3569
|
+
var COMPACT_JSON_TAG = "__furin_json_v1__";
|
|
3570
|
+
function isJsonValue(value, seen) {
|
|
3571
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
3572
|
+
return true;
|
|
3573
|
+
}
|
|
3574
|
+
if (typeof value === "number") {
|
|
3575
|
+
return Number.isFinite(value) && !Object.is(value, -0);
|
|
3576
|
+
}
|
|
3577
|
+
if (typeof value !== "object" || seen.has(value)) {
|
|
3578
|
+
return false;
|
|
3579
|
+
}
|
|
3580
|
+
seen.add(value);
|
|
3581
|
+
if (Array.isArray(value)) {
|
|
3582
|
+
if (Reflect.ownKeys(value).length !== value.length + 1) {
|
|
3583
|
+
return false;
|
|
3584
|
+
}
|
|
3585
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
3586
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, index);
|
|
3587
|
+
if (!(descriptor && ("value" in descriptor) && isJsonValue(descriptor.value, seen))) {
|
|
3588
|
+
return false;
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
return true;
|
|
3592
|
+
}
|
|
3593
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3594
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
3595
|
+
return false;
|
|
3596
|
+
}
|
|
3597
|
+
const keys = Object.keys(value);
|
|
3598
|
+
if (Reflect.ownKeys(value).length !== keys.length) {
|
|
3599
|
+
return false;
|
|
3600
|
+
}
|
|
3601
|
+
return keys.every((key) => {
|
|
3602
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
3603
|
+
return descriptor !== undefined && "value" in descriptor && isJsonValue(descriptor.value, seen);
|
|
3263
3604
|
});
|
|
3264
|
-
|
|
3605
|
+
}
|
|
3606
|
+
function isJsonObject(value) {
|
|
3607
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && isJsonValue(value, new WeakSet);
|
|
3608
|
+
}
|
|
3609
|
+
function parseCompactJsonLine(value) {
|
|
3610
|
+
if (!Array.isArray(value) || value.length !== 2 || value[0] !== COMPACT_JSON_TAG || !isJsonObject(value[1])) {
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
return value[1];
|
|
3265
3614
|
}
|
|
3266
3615
|
|
|
3267
3616
|
// src/rsc/shared.tsx
|
|
3268
3617
|
import {
|
|
3269
3618
|
Children,
|
|
3270
3619
|
cloneElement,
|
|
3271
|
-
createElement as
|
|
3620
|
+
createElement as createElement3,
|
|
3272
3621
|
isValidElement,
|
|
3273
3622
|
use
|
|
3274
3623
|
} from "react";
|
|
@@ -3301,7 +3650,7 @@ function decodeFlightBytes(bytes) {
|
|
|
3301
3650
|
}));
|
|
3302
3651
|
}
|
|
3303
3652
|
function createRenderableSource(state) {
|
|
3304
|
-
const element =
|
|
3653
|
+
const element = createElement3(RscNode, { state });
|
|
3305
3654
|
return new Proxy(element, {
|
|
3306
3655
|
get(target, property, receiver) {
|
|
3307
3656
|
if (property === RSC_SOURCE) {
|
|
@@ -3610,7 +3959,16 @@ async function parseDeferredNdjson(stream, signal) {
|
|
|
3610
3959
|
});
|
|
3611
3960
|
return { deferredPromises: result.deferredPromises, syncData: result.syncData };
|
|
3612
3961
|
}
|
|
3613
|
-
const
|
|
3962
|
+
const parsed = JSON.parse(firstLine);
|
|
3963
|
+
const compactJson = parseCompactJsonLine(parsed);
|
|
3964
|
+
if (compactJson !== undefined) {
|
|
3965
|
+
cleanupAbortHandler();
|
|
3966
|
+
try {
|
|
3967
|
+
reader.releaseLock();
|
|
3968
|
+
} catch {}
|
|
3969
|
+
return { deferredPromises: {}, syncData: compactJson };
|
|
3970
|
+
}
|
|
3971
|
+
const node = parsed;
|
|
3614
3972
|
const deserialized = fromCrossJSON(node, {});
|
|
3615
3973
|
const syncData = {};
|
|
3616
3974
|
const deferredPromises = {};
|
|
@@ -3705,13 +4063,20 @@ async function readDeferredLines(readLine, resolvers) {
|
|
|
3705
4063
|
}
|
|
3706
4064
|
}
|
|
3707
4065
|
|
|
4066
|
+
// src/client/browser-events.ts
|
|
4067
|
+
var BROWSER_EVENT_RUNTIME_KEY = Symbol.for("furin.browser-events.runtime");
|
|
4068
|
+
function subscribeBrowserEvent(channel, listener) {
|
|
4069
|
+
const runtime = globalThis[BROWSER_EVENT_RUNTIME_KEY];
|
|
4070
|
+
return runtime?.subscribe(channel, listener);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
3708
4073
|
// src/client/router/abort.ts
|
|
3709
4074
|
function isAbortError(error) {
|
|
3710
4075
|
return error !== null && typeof error === "object" && "name" in error && error.name === "AbortError";
|
|
3711
4076
|
}
|
|
3712
4077
|
|
|
3713
4078
|
// src/client/router/search-store.ts
|
|
3714
|
-
import { createContext as
|
|
4079
|
+
import { createContext as createContext3 } from "react";
|
|
3715
4080
|
function searchSnapshotChanged(a, b) {
|
|
3716
4081
|
return a.currentHref !== b.currentHref || a.navigate !== b.navigate || a.search !== b.search || a.searchRoutes !== b.searchRoutes;
|
|
3717
4082
|
}
|
|
@@ -3769,10 +4134,10 @@ var FALLBACK_SEARCH_STORE = createSearchStore({
|
|
|
3769
4134
|
search: {},
|
|
3770
4135
|
searchRoutes: []
|
|
3771
4136
|
});
|
|
3772
|
-
var SearchStoreContext =
|
|
4137
|
+
var SearchStoreContext = createContext3(null);
|
|
3773
4138
|
|
|
3774
4139
|
// src/client/router/spa-response.ts
|
|
3775
|
-
import { createElement as
|
|
4140
|
+
import { createElement as createElement4 } from "react";
|
|
3776
4141
|
function isFurinErrorPayload(value) {
|
|
3777
4142
|
if (!value || typeof value !== "object") {
|
|
3778
4143
|
return false;
|
|
@@ -3807,10 +4172,10 @@ function pickDeepestNotFound(boundaries) {
|
|
|
3807
4172
|
}
|
|
3808
4173
|
}
|
|
3809
4174
|
}
|
|
3810
|
-
var DefaultClientNotFoundFallback = ({ error }) =>
|
|
4175
|
+
var DefaultClientNotFoundFallback = ({ error }) => createElement4(DefaultNotFoundScreen, { message: error.message });
|
|
3811
4176
|
function buildNotFoundPageElement(boundaries, error) {
|
|
3812
4177
|
const Fallback = pickDeepestNotFound(boundaries) ?? DefaultClientNotFoundFallback;
|
|
3813
|
-
return
|
|
4178
|
+
return createElement4(Fallback, { error });
|
|
3814
4179
|
}
|
|
3815
4180
|
async function parsePageResponse(res, basePath) {
|
|
3816
4181
|
let finalHref;
|
|
@@ -3905,20 +4270,39 @@ function createSyncCatchUp(options) {
|
|
|
3905
4270
|
return running;
|
|
3906
4271
|
},
|
|
3907
4272
|
cursor: () => currentCursor,
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
currentCursor = page.cursor;
|
|
4273
|
+
seed(cursor) {
|
|
4274
|
+
currentCursor ??= cursor;
|
|
3911
4275
|
}
|
|
3912
4276
|
};
|
|
3913
4277
|
}
|
|
3914
4278
|
|
|
3915
4279
|
// src/client/router/provider.tsx
|
|
3916
|
-
import { jsxDEV as
|
|
4280
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
3917
4281
|
var EMPTY_SEARCH = {};
|
|
3918
4282
|
function getHistoryStateObject() {
|
|
3919
4283
|
const value = history.state;
|
|
3920
4284
|
return value !== null && typeof value === "object" ? value : {};
|
|
3921
4285
|
}
|
|
4286
|
+
function beginUserNavigation(ref) {
|
|
4287
|
+
let resolveNavigation = () => {
|
|
4288
|
+
return;
|
|
4289
|
+
};
|
|
4290
|
+
const navigation = new Promise((resolve) => {
|
|
4291
|
+
resolveNavigation = resolve;
|
|
4292
|
+
});
|
|
4293
|
+
ref.current = navigation;
|
|
4294
|
+
return () => {
|
|
4295
|
+
if (ref.current === navigation) {
|
|
4296
|
+
ref.current = null;
|
|
4297
|
+
}
|
|
4298
|
+
resolveNavigation();
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4301
|
+
async function waitForUserNavigation(ref) {
|
|
4302
|
+
while (ref.current) {
|
|
4303
|
+
await ref.current;
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
3922
4306
|
function setPrefetchCacheEntry(cache, href, entry, maxSize) {
|
|
3923
4307
|
if (cache.has(href)) {
|
|
3924
4308
|
cache.delete(href);
|
|
@@ -3937,6 +4321,7 @@ function RouterProvider({
|
|
|
3937
4321
|
initialMatch,
|
|
3938
4322
|
initialData,
|
|
3939
4323
|
initialDigest,
|
|
4324
|
+
initialError,
|
|
3940
4325
|
initialNotFound,
|
|
3941
4326
|
autoRefresh,
|
|
3942
4327
|
basePath,
|
|
@@ -3944,13 +4329,20 @@ function RouterProvider({
|
|
|
3944
4329
|
defaultPreloadDelay,
|
|
3945
4330
|
defaultPreloadStaleTime,
|
|
3946
4331
|
prefetchCacheSize,
|
|
3947
|
-
|
|
4332
|
+
syncPath
|
|
3948
4333
|
}) {
|
|
4334
|
+
const initialDocumentState = useDocumentState();
|
|
3949
4335
|
const [state, setState] = useState(() => ({
|
|
3950
4336
|
data: initialData,
|
|
4337
|
+
error: initialError ? {
|
|
4338
|
+
...initialError,
|
|
4339
|
+
message: initialError.message || "Something went wrong"
|
|
4340
|
+
} : undefined,
|
|
4341
|
+
head: initialDocumentState?.head,
|
|
3951
4342
|
match: initialMatch,
|
|
3952
4343
|
notFound: initialNotFound
|
|
3953
4344
|
}));
|
|
4345
|
+
const [boundaryResetVersion, setBoundaryResetVersion] = useState(0);
|
|
3954
4346
|
const [isNavigating, setIsNavigating] = useState(false);
|
|
3955
4347
|
const [currentHref, setCurrentHref] = useState(() => {
|
|
3956
4348
|
if (typeof window === "undefined") {
|
|
@@ -3960,6 +4352,9 @@ function RouterProvider({
|
|
|
3960
4352
|
});
|
|
3961
4353
|
const prefetchCache = useRef(new Map);
|
|
3962
4354
|
const navVersion = useRef(0);
|
|
4355
|
+
const hmrVersion = useRef(0);
|
|
4356
|
+
const hmrState = useRef({ dataInvalidated: false });
|
|
4357
|
+
const pendingUserNavigation = useRef(null);
|
|
3963
4358
|
const navAbortRef = useRef(null);
|
|
3964
4359
|
const pendingScrollRef = useRef(null);
|
|
3965
4360
|
const currentMatchRef = useRef(initialMatch);
|
|
@@ -3994,7 +4389,7 @@ function RouterProvider({
|
|
|
3994
4389
|
title
|
|
3995
4390
|
};
|
|
3996
4391
|
}, [basePath, rootBoundaries]);
|
|
3997
|
-
const fetchPageState = useCallback2(async (rawLogicalHref, signal) => {
|
|
4392
|
+
const fetchPageState = useCallback2(async (rawLogicalHref, signal, hmrRefresh) => {
|
|
3998
4393
|
const logicalHref = normalizeHref(rawLogicalHref);
|
|
3999
4394
|
try {
|
|
4000
4395
|
const physicalHref = basePath + logicalHref;
|
|
@@ -4005,7 +4400,14 @@ function RouterProvider({
|
|
|
4005
4400
|
return await resolveNoMatchState(physicalHref, signal);
|
|
4006
4401
|
}
|
|
4007
4402
|
const dataEndpoint = buildDataEndpoint(basePath, logicalHref, staticMode);
|
|
4008
|
-
const
|
|
4403
|
+
const loadedModule = hmrRefresh ? Promise.resolve(undefined) : match.load();
|
|
4404
|
+
const [res, loadedMod] = await Promise.all([
|
|
4405
|
+
fetch(dataEndpoint, {
|
|
4406
|
+
headers: hmrRefresh ? { "x-furin-hmr-refresh": "1" } : undefined,
|
|
4407
|
+
signal
|
|
4408
|
+
}),
|
|
4409
|
+
loadedModule
|
|
4410
|
+
]);
|
|
4009
4411
|
if (isStaleDeployResponse(res)) {
|
|
4010
4412
|
window.location.href = physicalHref;
|
|
4011
4413
|
return null;
|
|
@@ -4025,6 +4427,7 @@ function RouterProvider({
|
|
|
4025
4427
|
}
|
|
4026
4428
|
const { syncData, deferredPromises } = parsed;
|
|
4027
4429
|
const {
|
|
4430
|
+
__furinHead,
|
|
4028
4431
|
__furinStatus,
|
|
4029
4432
|
__furinNotFound,
|
|
4030
4433
|
__furinRedirect,
|
|
@@ -4035,17 +4438,21 @@ function RouterProvider({
|
|
|
4035
4438
|
const finalHref = typeof __furinRedirect === "string" ? __furinRedirect : undefined;
|
|
4036
4439
|
const data = { ...cleanSyncData, ...deferredPromises };
|
|
4037
4440
|
const title = typeof __furinTitle === "string" ? __furinTitle : "";
|
|
4038
|
-
const loadedMatch = {
|
|
4441
|
+
const loadedMatch = loadedMod ? {
|
|
4039
4442
|
...match,
|
|
4040
4443
|
component: loadedMod.default.component,
|
|
4041
4444
|
pageRoute: loadedMod.default._route,
|
|
4042
4445
|
segmentBoundaries: loadedMod.segmentBoundaries ?? match.segmentBoundaries
|
|
4043
|
-
};
|
|
4446
|
+
} : currentMatchRef.current;
|
|
4447
|
+
if (!loadedMatch) {
|
|
4448
|
+
return null;
|
|
4449
|
+
}
|
|
4044
4450
|
if (__furinError) {
|
|
4045
4451
|
return {
|
|
4046
|
-
data
|
|
4452
|
+
data,
|
|
4047
4453
|
error: __furinError,
|
|
4048
4454
|
finalHref,
|
|
4455
|
+
head: __furinHead,
|
|
4049
4456
|
match: loadedMatch,
|
|
4050
4457
|
title
|
|
4051
4458
|
};
|
|
@@ -4059,6 +4466,7 @@ function RouterProvider({
|
|
|
4059
4466
|
return {
|
|
4060
4467
|
data,
|
|
4061
4468
|
finalHref,
|
|
4469
|
+
head: __furinHead,
|
|
4062
4470
|
match: loadedMatch,
|
|
4063
4471
|
notFound,
|
|
4064
4472
|
title
|
|
@@ -4067,7 +4475,7 @@ function RouterProvider({
|
|
|
4067
4475
|
if (finalHref) {
|
|
4068
4476
|
return { data, finalHref, match: null, title };
|
|
4069
4477
|
}
|
|
4070
|
-
return { data, finalHref, match: loadedMatch, title };
|
|
4478
|
+
return { data, finalHref, head: __furinHead, match: loadedMatch, title };
|
|
4071
4479
|
} catch (err) {
|
|
4072
4480
|
if (!isAbortError(err)) {
|
|
4073
4481
|
_log.error({
|
|
@@ -4105,13 +4513,13 @@ function RouterProvider({
|
|
|
4105
4513
|
}
|
|
4106
4514
|
setPrefetchCacheEntry(prefetchCache.current, href, {
|
|
4107
4515
|
createdAt: Date.now(),
|
|
4108
|
-
promise: fetchPageState(href, undefined),
|
|
4516
|
+
promise: fetchPageState(href, undefined, false),
|
|
4109
4517
|
staleTime
|
|
4110
4518
|
}, prefetchCacheSize);
|
|
4111
4519
|
}, [fetchPageState, defaultPreloadStaleTime, prefetchCacheSize]);
|
|
4112
4520
|
async function resolveRedirectState(redirectLogical, myVersion, signal) {
|
|
4113
4521
|
const cached = prefetchCache.current.get(redirectLogical);
|
|
4114
|
-
const redirectState = cached && !shouldRefetch(cached) ? await cached.promise : await fetchPageState(redirectLogical, signal);
|
|
4522
|
+
const redirectState = cached && !shouldRefetch(cached) ? await cached.promise : await fetchPageState(redirectLogical, signal, false);
|
|
4115
4523
|
if (navVersion.current !== myVersion) {
|
|
4116
4524
|
return null;
|
|
4117
4525
|
}
|
|
@@ -4119,6 +4527,7 @@ function RouterProvider({
|
|
|
4119
4527
|
}
|
|
4120
4528
|
const navigate = useCallback2(async function navigateTo(rawLogicalHref, opts) {
|
|
4121
4529
|
const logicalHref = normalizeHref(rawLogicalHref);
|
|
4530
|
+
const finishUserNavigation = opts?.hmrRefresh === true ? undefined : beginUserNavigation(pendingUserNavigation);
|
|
4122
4531
|
navVersion.current += 1;
|
|
4123
4532
|
const myVersion = navVersion.current;
|
|
4124
4533
|
navAbortRef.current?.abort();
|
|
@@ -4128,8 +4537,8 @@ function RouterProvider({
|
|
|
4128
4537
|
setIsNavigating(true);
|
|
4129
4538
|
try {
|
|
4130
4539
|
const cached = prefetchCache.current.get(logicalHref);
|
|
4131
|
-
let newState = cached && !shouldRefetch(cached) ? await cached.promise : await fetchPageState(logicalHref, navSignal);
|
|
4132
|
-
if (navVersion.current !== myVersion) {
|
|
4540
|
+
let newState = cached && !shouldRefetch(cached) ? await cached.promise : await fetchPageState(logicalHref, navSignal, opts?.hmrRefresh === true);
|
|
4541
|
+
if (navVersion.current !== myVersion || opts?.shouldCommit?.() === false) {
|
|
4133
4542
|
return;
|
|
4134
4543
|
}
|
|
4135
4544
|
if (newState && (!cached || shouldRefetch(cached))) {
|
|
@@ -4166,7 +4575,14 @@ function RouterProvider({
|
|
|
4166
4575
|
}
|
|
4167
4576
|
newState = redirectState;
|
|
4168
4577
|
}
|
|
4578
|
+
if (opts?.shouldCommit?.() === false) {
|
|
4579
|
+
return;
|
|
4580
|
+
}
|
|
4581
|
+
opts?.beforeCommit?.();
|
|
4169
4582
|
currentMatchRef.current = newState.match;
|
|
4583
|
+
if (!newState.error) {
|
|
4584
|
+
setBoundaryResetVersion((version) => version + 1);
|
|
4585
|
+
}
|
|
4170
4586
|
setState(newState);
|
|
4171
4587
|
if (newState.title) {
|
|
4172
4588
|
document.title = newState.title;
|
|
@@ -4192,6 +4608,7 @@ function RouterProvider({
|
|
|
4192
4608
|
pendingScrollRef.current = { href: physicalEffective, type: "reset" };
|
|
4193
4609
|
}
|
|
4194
4610
|
} finally {
|
|
4611
|
+
finishUserNavigation?.();
|
|
4195
4612
|
if (navVersion.current === myVersion) {
|
|
4196
4613
|
setIsNavigating(false);
|
|
4197
4614
|
}
|
|
@@ -4217,7 +4634,13 @@ function RouterProvider({
|
|
|
4217
4634
|
const logicalPath = toLogical(window.location.pathname, basePath);
|
|
4218
4635
|
const logicalHref = logicalPath + window.location.search;
|
|
4219
4636
|
invalidatePrefetch(logicalHref, "page");
|
|
4220
|
-
await navigate(logicalHref, {
|
|
4637
|
+
await navigate(logicalHref, {
|
|
4638
|
+
beforeCommit: opts?.beforeCommit,
|
|
4639
|
+
hmrRefresh: opts?.hmrRefresh,
|
|
4640
|
+
replace: true,
|
|
4641
|
+
resetScroll: opts?.resetScroll ?? false,
|
|
4642
|
+
shouldCommit: opts?.shouldCommit
|
|
4643
|
+
});
|
|
4221
4644
|
}, [navigate, invalidatePrefetch, basePath]);
|
|
4222
4645
|
const invalidationRefresh = useMemo(() => createInvalidationRefresh({
|
|
4223
4646
|
onError: (error) => {
|
|
@@ -4227,13 +4650,40 @@ function RouterProvider({
|
|
|
4227
4650
|
}), [refresh]);
|
|
4228
4651
|
useEffect(() => {
|
|
4229
4652
|
if (typeof window !== "undefined") {
|
|
4230
|
-
window.__FURIN_HMR_REFRESH__ =
|
|
4653
|
+
window.__FURIN_HMR_REFRESH__ = async (beforeCommit, dataChanged) => {
|
|
4654
|
+
hmrVersion.current += 1;
|
|
4655
|
+
const myHmrVersion = hmrVersion.current;
|
|
4656
|
+
const shouldRefreshData = hmrState.current.dataInvalidated || dataChanged !== false;
|
|
4657
|
+
if (!shouldRefreshData) {
|
|
4658
|
+
beforeCommit?.();
|
|
4659
|
+
setState((current) => ({ ...current }));
|
|
4660
|
+
return;
|
|
4661
|
+
}
|
|
4662
|
+
hmrState.current.dataInvalidated = true;
|
|
4663
|
+
await waitForUserNavigation(pendingUserNavigation);
|
|
4664
|
+
if (hmrVersion.current !== myHmrVersion) {
|
|
4665
|
+
return;
|
|
4666
|
+
}
|
|
4667
|
+
let didCommit = false;
|
|
4668
|
+
await refresh({
|
|
4669
|
+
beforeCommit: () => {
|
|
4670
|
+
didCommit = true;
|
|
4671
|
+
beforeCommit?.();
|
|
4672
|
+
},
|
|
4673
|
+
hmrRefresh: true,
|
|
4674
|
+
shouldCommit: () => hmrVersion.current === myHmrVersion
|
|
4675
|
+
});
|
|
4676
|
+
if (didCommit && hmrVersion.current === myHmrVersion) {
|
|
4677
|
+
hmrState.current.dataInvalidated = false;
|
|
4678
|
+
}
|
|
4679
|
+
};
|
|
4231
4680
|
return () => {
|
|
4232
4681
|
window.__FURIN_HMR_REFRESH__ = undefined;
|
|
4233
4682
|
};
|
|
4234
4683
|
}
|
|
4235
4684
|
}, [refresh]);
|
|
4236
4685
|
const handlePopState = useCallback2(() => {
|
|
4686
|
+
const finishUserNavigation = beginUserNavigation(pendingUserNavigation);
|
|
4237
4687
|
const destKey = getHistoryKey(history.state);
|
|
4238
4688
|
const logicalPath = normalizeHref(toLogical(window.location.pathname, basePath));
|
|
4239
4689
|
const logicalHref = logicalPath + window.location.search;
|
|
@@ -4251,7 +4701,7 @@ function RouterProvider({
|
|
|
4251
4701
|
if (cached && !shouldRefetch(cached)) {
|
|
4252
4702
|
newState = await cached.promise;
|
|
4253
4703
|
} else {
|
|
4254
|
-
newState = await fetchPageState(logicalHref, navSignal);
|
|
4704
|
+
newState = await fetchPageState(logicalHref, navSignal, false);
|
|
4255
4705
|
}
|
|
4256
4706
|
if (navVersion.current !== myVersion) {
|
|
4257
4707
|
return;
|
|
@@ -4280,6 +4730,9 @@ function RouterProvider({
|
|
|
4280
4730
|
newState = redirectState;
|
|
4281
4731
|
}
|
|
4282
4732
|
currentMatchRef.current = newState.match;
|
|
4733
|
+
if (!newState.error) {
|
|
4734
|
+
setBoundaryResetVersion((version) => version + 1);
|
|
4735
|
+
}
|
|
4283
4736
|
setState(newState);
|
|
4284
4737
|
if (newState.title) {
|
|
4285
4738
|
document.title = newState.title;
|
|
@@ -4295,6 +4748,7 @@ function RouterProvider({
|
|
|
4295
4748
|
window.scrollTo({ behavior: "instant", top: 0 });
|
|
4296
4749
|
}
|
|
4297
4750
|
} finally {
|
|
4751
|
+
finishUserNavigation();
|
|
4298
4752
|
if (navVersion.current === myVersion) {
|
|
4299
4753
|
setIsNavigating(false);
|
|
4300
4754
|
}
|
|
@@ -4400,11 +4854,11 @@ function RouterProvider({
|
|
|
4400
4854
|
};
|
|
4401
4855
|
}, [invalidatePrefetch, invalidationRefresh, autoRefresh, basePath]);
|
|
4402
4856
|
useEffect(() => {
|
|
4403
|
-
if (!
|
|
4857
|
+
if (!syncPath || typeof window === "undefined") {
|
|
4404
4858
|
return;
|
|
4405
4859
|
}
|
|
4406
|
-
const
|
|
4407
|
-
let
|
|
4860
|
+
const changesUrl = syncPath.startsWith("/") ? `${basePath}${syncPath}` : `${basePath}/${syncPath}`;
|
|
4861
|
+
let unsubscribe;
|
|
4408
4862
|
let disposed = false;
|
|
4409
4863
|
const applyInvalidations = (entries) => {
|
|
4410
4864
|
if (disposed) {
|
|
@@ -4425,7 +4879,7 @@ function RouterProvider({
|
|
|
4425
4879
|
};
|
|
4426
4880
|
const catchUp = createSyncCatchUp({
|
|
4427
4881
|
fetchPage: async (after) => {
|
|
4428
|
-
const url = new URL(`${
|
|
4882
|
+
const url = new URL(`${changesUrl}/changes`, window.location.origin);
|
|
4429
4883
|
if (after !== undefined) {
|
|
4430
4884
|
url.searchParams.set("after", after);
|
|
4431
4885
|
}
|
|
@@ -4447,46 +4901,29 @@ function RouterProvider({
|
|
|
4447
4901
|
}
|
|
4448
4902
|
});
|
|
4449
4903
|
};
|
|
4450
|
-
const onOpen = () => recover();
|
|
4451
4904
|
const onSync = (event) => {
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
if (typeof payload.cursor !== "string") {
|
|
4455
|
-
throw new Error("Missing sync cursor");
|
|
4456
|
-
}
|
|
4457
|
-
} catch {
|
|
4458
|
-
_log.warn({ action: "sync_invalid_event", event: "furin.sync" });
|
|
4905
|
+
if (typeof event.data.cursor !== "string") {
|
|
4906
|
+
_log.warn({ action: "sync_invalid_event", event: "browser-events.sync" });
|
|
4459
4907
|
return;
|
|
4460
4908
|
}
|
|
4909
|
+
catchUp.seed(event.data.cursor);
|
|
4461
4910
|
recover();
|
|
4462
4911
|
};
|
|
4463
4912
|
const connect = () => {
|
|
4464
|
-
if (disposed ||
|
|
4465
|
-
return;
|
|
4466
|
-
}
|
|
4467
|
-
source = new EventSource(streamUrl);
|
|
4468
|
-
source.addEventListener("open", onOpen);
|
|
4469
|
-
source.addEventListener("furin.sync", onSync);
|
|
4470
|
-
};
|
|
4471
|
-
catchUp.initialize().then(() => {
|
|
4472
|
-
if (disposed) {
|
|
4913
|
+
if (disposed || unsubscribe) {
|
|
4473
4914
|
return;
|
|
4474
4915
|
}
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
return;
|
|
4916
|
+
unsubscribe = subscribeBrowserEvent("sync", onSync);
|
|
4917
|
+
if (!unsubscribe) {
|
|
4918
|
+
_log.warn({ action: "sync_transport_unavailable" });
|
|
4479
4919
|
}
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
});
|
|
4920
|
+
};
|
|
4921
|
+
connect();
|
|
4483
4922
|
return () => {
|
|
4484
4923
|
disposed = true;
|
|
4485
|
-
|
|
4486
|
-
source?.removeEventListener("furin.sync", onSync);
|
|
4487
|
-
source?.close();
|
|
4924
|
+
unsubscribe?.();
|
|
4488
4925
|
};
|
|
4489
|
-
}, [
|
|
4926
|
+
}, [syncPath, basePath, invalidatePrefetch, invalidationRefresh, autoRefresh]);
|
|
4490
4927
|
let pageElement;
|
|
4491
4928
|
if (state.notFound || !state.match) {
|
|
4492
4929
|
pageElement = buildNotFoundPageElement(state.notFoundBoundaries ?? state.match?.segmentBoundaries ?? rootBoundaries, state.notFound ?? {});
|
|
@@ -4497,10 +4934,10 @@ function RouterProvider({
|
|
|
4497
4934
|
_log.error({ action: "boundary_reset_failed", error: String(err) });
|
|
4498
4935
|
});
|
|
4499
4936
|
},
|
|
4500
|
-
resetKey: currentHref
|
|
4937
|
+
resetKey: `${currentHref}:${boundaryResetVersion}`
|
|
4501
4938
|
}, state.error);
|
|
4502
4939
|
}
|
|
4503
|
-
|
|
4940
|
+
const routerTree = /* @__PURE__ */ jsxDEV5(SearchStoreContext.Provider, {
|
|
4504
4941
|
value: searchStore,
|
|
4505
4942
|
children: buildRouterTree({
|
|
4506
4943
|
basePath,
|
|
@@ -4517,27 +4954,40 @@ function RouterProvider({
|
|
|
4517
4954
|
searchRoutes: routes
|
|
4518
4955
|
}, pageElement, {
|
|
4519
4956
|
digest: initialDigest,
|
|
4957
|
+
document: initialDocumentState !== null,
|
|
4520
4958
|
onReset: () => {
|
|
4521
4959
|
refresh(undefined).catch((err) => {
|
|
4522
4960
|
_log.error({ action: "boundary_reset_failed", error: String(err) });
|
|
4523
4961
|
});
|
|
4524
4962
|
},
|
|
4525
|
-
resetKey: currentHref
|
|
4963
|
+
resetKey: `${currentHref}:${boundaryResetVersion}`
|
|
4526
4964
|
})
|
|
4527
4965
|
}, undefined, false, undefined, this);
|
|
4966
|
+
if (initialDocumentState === null) {
|
|
4967
|
+
return routerTree;
|
|
4968
|
+
}
|
|
4969
|
+
return /* @__PURE__ */ jsxDEV5(DocumentProvider, {
|
|
4970
|
+
value: {
|
|
4971
|
+
...initialDocumentState,
|
|
4972
|
+
head: state.head
|
|
4973
|
+
},
|
|
4974
|
+
children: routerTree
|
|
4975
|
+
}, undefined, false, undefined, this);
|
|
4528
4976
|
}
|
|
4529
4977
|
// src/client/link.tsx
|
|
4530
4978
|
function computeLinkView({
|
|
4531
4979
|
to,
|
|
4980
|
+
params,
|
|
4532
4981
|
search,
|
|
4533
4982
|
hash,
|
|
4534
4983
|
children,
|
|
4535
4984
|
activeProps,
|
|
4536
4985
|
inactiveProps
|
|
4537
4986
|
}, router2) {
|
|
4538
|
-
const
|
|
4539
|
-
const
|
|
4540
|
-
const
|
|
4987
|
+
const resolvedTo = applyLinkParams(to, params);
|
|
4988
|
+
const searchDefaults = findSearchDefaultsForRouteTarget(resolvedTo, router2.searchRoutes);
|
|
4989
|
+
const logicalHref = buildHref(resolvedTo, search, hash, searchDefaults);
|
|
4990
|
+
const logicalHrefWithoutHash = buildHref(resolvedTo, search, undefined, searchDefaults);
|
|
4541
4991
|
const isAbsolute = logicalHref.startsWith("http://") || logicalHref.startsWith("https://") || logicalHref.startsWith("//");
|
|
4542
4992
|
const candidateHref = isAbsolute ? logicalHref : router2.basePath + logicalHref;
|
|
4543
4993
|
const href = navigationHrefPolicy(candidateHref, undefined) === "blocked" ? "#" : candidateHref;
|
|
@@ -4554,6 +5004,7 @@ function isSameOriginUrl(url) {
|
|
|
4554
5004
|
}
|
|
4555
5005
|
function LinkInteractive({
|
|
4556
5006
|
to,
|
|
5007
|
+
params,
|
|
4557
5008
|
search,
|
|
4558
5009
|
hash,
|
|
4559
5010
|
preload,
|
|
@@ -4575,7 +5026,7 @@ function LinkInteractive({
|
|
|
4575
5026
|
const router2 = useRouter();
|
|
4576
5027
|
const anchorRef = useRef2(null);
|
|
4577
5028
|
const intentTimerRef = useRef2(null);
|
|
4578
|
-
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ activeProps, children, hash, inactiveProps, search, to }, router2);
|
|
5029
|
+
const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ activeProps, children, hash, inactiveProps, params, search, to }, router2);
|
|
4579
5030
|
const effectivePreload = preload ?? router2.defaultPreload;
|
|
4580
5031
|
const effectiveDelay = preloadDelay ?? router2.defaultPreloadDelay;
|
|
4581
5032
|
const effectiveStaleTime = preloadStaleTime ?? router2.defaultPreloadStaleTime;
|
|
@@ -4655,7 +5106,7 @@ function LinkInteractive({
|
|
|
4655
5106
|
triggerPrefetch();
|
|
4656
5107
|
}
|
|
4657
5108
|
};
|
|
4658
|
-
return
|
|
5109
|
+
return createElement5("a", {
|
|
4659
5110
|
"data-furin-link": true,
|
|
4660
5111
|
href,
|
|
4661
5112
|
onClick: handleClick,
|
|
@@ -4687,6 +5138,7 @@ function renderLinkElement(props, router2) {
|
|
|
4687
5138
|
const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router2);
|
|
4688
5139
|
const {
|
|
4689
5140
|
to: _to,
|
|
5141
|
+
params: _params,
|
|
4690
5142
|
search: _search,
|
|
4691
5143
|
hash: _hash,
|
|
4692
5144
|
children: _children,
|
|
@@ -4705,7 +5157,7 @@ function renderLinkElement(props, router2) {
|
|
|
4705
5157
|
href: _href,
|
|
4706
5158
|
...anchorProps
|
|
4707
5159
|
} = props;
|
|
4708
|
-
return
|
|
5160
|
+
return createElement5("a", {
|
|
4709
5161
|
"data-furin-link": true,
|
|
4710
5162
|
href,
|
|
4711
5163
|
...isActive ? { "data-status": "active" } : {},
|
|
@@ -4716,11 +5168,11 @@ function renderLinkElement(props, router2) {
|
|
|
4716
5168
|
}
|
|
4717
5169
|
function Link(props) {
|
|
4718
5170
|
if (typeof window === "undefined") {
|
|
4719
|
-
return
|
|
5171
|
+
return createElement5(RouterContext.Consumer, {
|
|
4720
5172
|
children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
|
|
4721
5173
|
});
|
|
4722
5174
|
}
|
|
4723
|
-
return
|
|
5175
|
+
return createElement5(LinkInteractive, props);
|
|
4724
5176
|
}
|
|
4725
5177
|
export {
|
|
4726
5178
|
CLIENT_FALLBACK_ROUTER,
|