vorma 0.0.0-pre.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +48 -0
- package/internal/framework/_typescript/client/index.ts +64 -0
- package/internal/framework/_typescript/client/src/asset_manager.ts +67 -0
- package/internal/framework/_typescript/client/src/client.ts +1201 -0
- package/internal/framework/_typescript/client/src/client_loaders.ts +249 -0
- package/internal/framework/_typescript/client/src/component_loader.ts +105 -0
- package/internal/framework/_typescript/client/src/error_boundary.ts +7 -0
- package/internal/framework/_typescript/client/src/events.ts +54 -0
- package/internal/framework/_typescript/client/src/global_loading_indicator/global_loading_indicator.ts +125 -0
- package/internal/framework/_typescript/client/src/hard_reload.ts +1 -0
- package/internal/framework/_typescript/client/src/head_elements/head_elements.ts +193 -0
- package/internal/framework/_typescript/client/src/history/history.ts +118 -0
- package/internal/framework/_typescript/client/src/history/npm_history_types.ts +83 -0
- package/internal/framework/_typescript/client/src/hmr/hmr.ts +71 -0
- package/internal/framework/_typescript/client/src/init_client.ts +134 -0
- package/internal/framework/_typescript/client/src/links.ts +218 -0
- package/internal/framework/_typescript/client/src/redirects/redirects.ts +203 -0
- package/internal/framework/_typescript/client/src/rendering.ts +135 -0
- package/internal/framework/_typescript/client/src/resolve_public_href.ts +15 -0
- package/internal/framework/_typescript/client/src/scroll_state_manager.ts +100 -0
- package/internal/framework/_typescript/client/src/static_route_defs/route_def_helpers.ts +22 -0
- package/internal/framework/_typescript/client/src/ui_lib_impl_helpers/link_components.ts +131 -0
- package/internal/framework/_typescript/client/src/ui_lib_impl_helpers/route_components.ts +56 -0
- package/internal/framework/_typescript/client/src/ui_lib_impl_helpers/typed_navigate.ts +58 -0
- package/internal/framework/_typescript/client/src/utils/errors.ts +10 -0
- package/internal/framework/_typescript/client/src/utils/logging.ts +7 -0
- package/internal/framework/_typescript/client/src/vorma_app_helpers/vorma_app_helpers.ts +290 -0
- package/internal/framework/_typescript/client/src/vorma_ctx/vorma_ctx.ts +128 -0
- package/internal/framework/_typescript/client/src/window_focus_revalidation/window_focus_revalidation.ts +32 -0
- package/internal/framework/_typescript/client/tsconfig.json +3 -0
- package/internal/framework/_typescript/create/main.ts +378 -0
- package/internal/framework/_typescript/create/package.json +33 -0
- package/internal/framework/_typescript/create/pnpm-lock.yaml +70 -0
- package/internal/framework/_typescript/create/tsconfig.json +3 -0
- package/internal/framework/_typescript/preact/index.tsx +10 -0
- package/internal/framework/_typescript/preact/src/helpers.ts +113 -0
- package/internal/framework/_typescript/preact/src/link.tsx +107 -0
- package/internal/framework/_typescript/preact/src/preact.tsx +191 -0
- package/internal/framework/_typescript/preact/tsconfig.json +7 -0
- package/internal/framework/_typescript/react/index.tsx +10 -0
- package/internal/framework/_typescript/react/src/helpers.ts +118 -0
- package/internal/framework/_typescript/react/src/link.tsx +115 -0
- package/internal/framework/_typescript/react/src/react.tsx +299 -0
- package/internal/framework/_typescript/react/tsconfig.json +6 -0
- package/internal/framework/_typescript/solid/index.tsx +10 -0
- package/internal/framework/_typescript/solid/src/helpers.ts +114 -0
- package/internal/framework/_typescript/solid/src/link.tsx +104 -0
- package/internal/framework/_typescript/solid/src/solid.tsx +204 -0
- package/internal/framework/_typescript/solid/tsconfig.json +7 -0
- package/internal/framework/_typescript/vite/tsconfig.json +3 -0
- package/internal/framework/_typescript/vite/vite.ts +93 -0
- package/internal/site/frontend/assets/vorma-banner.webp +0 -0
- package/kit/_typescript/converters/converters.ts +152 -0
- package/kit/_typescript/cookies/cookies.ts +18 -0
- package/kit/_typescript/csrf/csrf.ts +10 -0
- package/kit/_typescript/debounce/debounce.ts +17 -0
- package/kit/_typescript/fmt/fmt.ts +3 -0
- package/kit/_typescript/json/deep_equals.ts +54 -0
- package/kit/_typescript/json/json.ts +3 -0
- package/kit/_typescript/json/search_param_serializer.ts +49 -0
- package/kit/_typescript/json/stringify_stable.ts +43 -0
- package/kit/_typescript/listeners/listeners.ts +16 -0
- package/kit/_typescript/matcher/find_best_match.ts +205 -0
- package/kit/_typescript/matcher/find_nested_matches.ts +357 -0
- package/kit/_typescript/matcher/parse_segments.ts +30 -0
- package/kit/_typescript/matcher/register.ts +271 -0
- package/kit/_typescript/theme/theme.ts +166 -0
- package/kit/_typescript/tsconfig.json +3 -0
- package/kit/_typescript/url/url.ts +132 -0
- package/npm_dist/internal/framework/_typescript/client/index.d.ts +17 -0
- package/npm_dist/internal/framework/_typescript/client/index.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/index.js +2489 -0
- package/npm_dist/internal/framework/_typescript/client/index.js.map +7 -0
- package/npm_dist/internal/framework/_typescript/client/src/asset_manager.d.ts +6 -0
- package/npm_dist/internal/framework/_typescript/client/src/asset_manager.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/client.d.ts +119 -0
- package/npm_dist/internal/framework/_typescript/client/src/client.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/client_loaders.d.ts +18 -0
- package/npm_dist/internal/framework/_typescript/client/src/client_loaders.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/component_loader.d.ts +10 -0
- package/npm_dist/internal/framework/_typescript/client/src/component_loader.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/error_boundary.d.ts +3 -0
- package/npm_dist/internal/framework/_typescript/client/src/error_boundary.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/events.d.ts +26 -0
- package/npm_dist/internal/framework/_typescript/client/src/events.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/global_loading_indicator/global_loading_indicator.d.ts +12 -0
- package/npm_dist/internal/framework/_typescript/client/src/global_loading_indicator/global_loading_indicator.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/hard_reload.d.ts +2 -0
- package/npm_dist/internal/framework/_typescript/client/src/hard_reload.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/head_elements/head_elements.d.ts +7 -0
- package/npm_dist/internal/framework/_typescript/client/src/head_elements/head_elements.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/history/history.d.ts +14 -0
- package/npm_dist/internal/framework/_typescript/client/src/history/history.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/history/npm_history_types.d.ts +84 -0
- package/npm_dist/internal/framework/_typescript/client/src/history/npm_history_types.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/hmr/hmr.d.ts +3 -0
- package/npm_dist/internal/framework/_typescript/client/src/hmr/hmr.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/init_client.d.ts +9 -0
- package/npm_dist/internal/framework/_typescript/client/src/init_client.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/links.d.ts +33 -0
- package/npm_dist/internal/framework/_typescript/client/src/links.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/redirects/redirects.d.ts +26 -0
- package/npm_dist/internal/framework/_typescript/client/src/redirects/redirects.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/rendering.d.ts +18 -0
- package/npm_dist/internal/framework/_typescript/client/src/rendering.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/resolve_public_href.d.ts +2 -0
- package/npm_dist/internal/framework/_typescript/client/src/resolve_public_href.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/scroll_state_manager.d.ts +22 -0
- package/npm_dist/internal/framework/_typescript/client/src/scroll_state_manager.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/static_route_defs/route_def_helpers.d.ts +12 -0
- package/npm_dist/internal/framework/_typescript/client/src/static_route_defs/route_def_helpers.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/link_components.d.ts +28 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/link_components.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/route_components.d.ts +18 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/route_components.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/typed_navigate.d.ts +11 -0
- package/npm_dist/internal/framework/_typescript/client/src/ui_lib_impl_helpers/typed_navigate.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/utils/errors.d.ts +3 -0
- package/npm_dist/internal/framework/_typescript/client/src/utils/errors.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/utils/logging.d.ts +3 -0
- package/npm_dist/internal/framework/_typescript/client/src/utils/logging.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/vorma_app_helpers/vorma_app_helpers.d.ts +119 -0
- package/npm_dist/internal/framework/_typescript/client/src/vorma_app_helpers/vorma_app_helpers.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/vorma_ctx/vorma_ctx.d.ts +88 -0
- package/npm_dist/internal/framework/_typescript/client/src/vorma_ctx/vorma_ctx.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/client/src/window_focus_revalidation/window_focus_revalidation.d.ts +10 -0
- package/npm_dist/internal/framework/_typescript/client/src/window_focus_revalidation/window_focus_revalidation.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/create/main.d.ts +3 -0
- package/npm_dist/internal/framework/_typescript/create/main.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/preact/index.d.ts +4 -0
- package/npm_dist/internal/framework/_typescript/preact/index.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/preact/index.js +283 -0
- package/npm_dist/internal/framework/_typescript/preact/index.js.map +7 -0
- package/npm_dist/internal/framework/_typescript/preact/src/helpers.d.ts +21 -0
- package/npm_dist/internal/framework/_typescript/preact/src/helpers.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/preact/src/link.d.ts +11 -0
- package/npm_dist/internal/framework/_typescript/preact/src/link.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/preact/src/preact.d.ts +21 -0
- package/npm_dist/internal/framework/_typescript/preact/src/preact.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/react/index.d.ts +4 -0
- package/npm_dist/internal/framework/_typescript/react/index.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/react/index.js +370 -0
- package/npm_dist/internal/framework/_typescript/react/index.js.map +7 -0
- package/npm_dist/internal/framework/_typescript/react/src/helpers.d.ts +21 -0
- package/npm_dist/internal/framework/_typescript/react/src/helpers.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/react/src/link.d.ts +11 -0
- package/npm_dist/internal/framework/_typescript/react/src/link.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/react/src/react.d.ts +20 -0
- package/npm_dist/internal/framework/_typescript/react/src/react.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/solid/index.d.ts +4 -0
- package/npm_dist/internal/framework/_typescript/solid/index.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/solid/index.js +314 -0
- package/npm_dist/internal/framework/_typescript/solid/index.js.map +7 -0
- package/npm_dist/internal/framework/_typescript/solid/src/helpers.d.ts +22 -0
- package/npm_dist/internal/framework/_typescript/solid/src/helpers.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/solid/src/link.d.ts +11 -0
- package/npm_dist/internal/framework/_typescript/solid/src/link.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/solid/src/solid.d.ts +22 -0
- package/npm_dist/internal/framework/_typescript/solid/src/solid.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/vite/vite.d.ts +11 -0
- package/npm_dist/internal/framework/_typescript/vite/vite.d.ts.map +1 -0
- package/npm_dist/internal/framework/_typescript/vite/vite.js +82 -0
- package/npm_dist/internal/framework/_typescript/vite/vite.js.map +7 -0
- package/npm_dist/kit/_typescript/chunk-YBAPNBS2.js +202 -0
- package/npm_dist/kit/_typescript/chunk-YBAPNBS2.js.map +7 -0
- package/npm_dist/kit/_typescript/converters/converters.d.ts +26 -0
- package/npm_dist/kit/_typescript/converters/converters.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/converters/converters.js +99 -0
- package/npm_dist/kit/_typescript/converters/converters.js.map +7 -0
- package/npm_dist/kit/_typescript/cookies/cookies.d.ts +13 -0
- package/npm_dist/kit/_typescript/cookies/cookies.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/cookies/cookies.js +13 -0
- package/npm_dist/kit/_typescript/cookies/cookies.js.map +7 -0
- package/npm_dist/kit/_typescript/csrf/csrf.d.ts +5 -0
- package/npm_dist/kit/_typescript/csrf/csrf.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/csrf/csrf.js +11 -0
- package/npm_dist/kit/_typescript/csrf/csrf.js.map +7 -0
- package/npm_dist/kit/_typescript/debounce/debounce.d.ts +4 -0
- package/npm_dist/kit/_typescript/debounce/debounce.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/debounce/debounce.js +16 -0
- package/npm_dist/kit/_typescript/debounce/debounce.js.map +7 -0
- package/npm_dist/kit/_typescript/fmt/fmt.d.ts +2 -0
- package/npm_dist/kit/_typescript/fmt/fmt.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/fmt/fmt.js +8 -0
- package/npm_dist/kit/_typescript/fmt/fmt.js.map +7 -0
- package/npm_dist/kit/_typescript/json/deep_equals.d.ts +7 -0
- package/npm_dist/kit/_typescript/json/deep_equals.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/json/json.d.ts +4 -0
- package/npm_dist/kit/_typescript/json/json.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/json/json.js +110 -0
- package/npm_dist/kit/_typescript/json/json.js.map +7 -0
- package/npm_dist/kit/_typescript/json/search_param_serializer.d.ts +2 -0
- package/npm_dist/kit/_typescript/json/search_param_serializer.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/json/stringify_stable.d.ts +7 -0
- package/npm_dist/kit/_typescript/json/stringify_stable.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/listeners/listeners.d.ts +2 -0
- package/npm_dist/kit/_typescript/listeners/listeners.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/listeners/listeners.js +20 -0
- package/npm_dist/kit/_typescript/listeners/listeners.js.map +7 -0
- package/npm_dist/kit/_typescript/matcher/find_best_match.d.ts +10 -0
- package/npm_dist/kit/_typescript/matcher/find_best_match.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/matcher/find_best_match.js +146 -0
- package/npm_dist/kit/_typescript/matcher/find_best_match.js.map +7 -0
- package/npm_dist/kit/_typescript/matcher/find_nested_matches.d.ts +14 -0
- package/npm_dist/kit/_typescript/matcher/find_nested_matches.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/matcher/find_nested_matches.js +248 -0
- package/npm_dist/kit/_typescript/matcher/find_nested_matches.js.map +7 -0
- package/npm_dist/kit/_typescript/matcher/parse_segments.d.ts +2 -0
- package/npm_dist/kit/_typescript/matcher/parse_segments.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/matcher/register.d.ts +54 -0
- package/npm_dist/kit/_typescript/matcher/register.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/matcher/register.js +21 -0
- package/npm_dist/kit/_typescript/matcher/register.js.map +7 -0
- package/npm_dist/kit/_typescript/theme/theme.d.ts +23 -0
- package/npm_dist/kit/_typescript/theme/theme.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/theme/theme.js +122 -0
- package/npm_dist/kit/_typescript/theme/theme.js.map +7 -0
- package/npm_dist/kit/_typescript/url/url.d.ts +30 -0
- package/npm_dist/kit/_typescript/url/url.d.ts.map +1 -0
- package/npm_dist/kit/_typescript/url/url.js +100 -0
- package/npm_dist/kit/_typescript/url/url.js.map +7 -0
- package/package.json +135 -3
- package/tsconfig.base.json +17 -0
- package/index.js +0 -1
|
@@ -0,0 +1,2489 @@
|
|
|
1
|
+
// internal/framework/_typescript/client/src/client.ts
|
|
2
|
+
import { debounce } from "vorma/kit/debounce";
|
|
3
|
+
import { jsonDeepEquals as jsonDeepEquals2 } from "vorma/kit/json";
|
|
4
|
+
import { findNestedMatches as findNestedMatches2 } from "vorma/kit/matcher/find-nested";
|
|
5
|
+
import { getIsGETRequest as getIsGETRequest2 } from "vorma/kit/url";
|
|
6
|
+
|
|
7
|
+
// internal/framework/_typescript/client/src/vorma_ctx/vorma_ctx.ts
|
|
8
|
+
var VORMA_SYMBOL = Symbol.for("__vorma_internal__");
|
|
9
|
+
function __getVormaClientGlobal() {
|
|
10
|
+
const dangerousGlobalThis = globalThis;
|
|
11
|
+
function get(key) {
|
|
12
|
+
return dangerousGlobalThis[VORMA_SYMBOL][key];
|
|
13
|
+
}
|
|
14
|
+
function set(key, value) {
|
|
15
|
+
dangerousGlobalThis[VORMA_SYMBOL][key] = value;
|
|
16
|
+
}
|
|
17
|
+
return { get, set };
|
|
18
|
+
}
|
|
19
|
+
var __vormaClientGlobal = __getVormaClientGlobal();
|
|
20
|
+
function getRouterData() {
|
|
21
|
+
const rootData = __vormaClientGlobal.get("hasRootData") ? __vormaClientGlobal.get("loadersData")[0] : null;
|
|
22
|
+
return {
|
|
23
|
+
buildID: __vormaClientGlobal.get("buildID") || "",
|
|
24
|
+
matchedPatterns: __vormaClientGlobal.get("matchedPatterns") || [],
|
|
25
|
+
splatValues: __vormaClientGlobal.get("splatValues") || [],
|
|
26
|
+
params: __vormaClientGlobal.get("params") || {},
|
|
27
|
+
rootData
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// internal/framework/_typescript/client/src/resolve_public_href.ts
|
|
32
|
+
function resolvePublicHref(relativeHref) {
|
|
33
|
+
let baseURL = __vormaClientGlobal.get("viteDevURL");
|
|
34
|
+
if (!baseURL) {
|
|
35
|
+
baseURL = __vormaClientGlobal.get("publicPathPrefix");
|
|
36
|
+
}
|
|
37
|
+
if (baseURL.endsWith("/")) {
|
|
38
|
+
baseURL = baseURL.slice(0, -1);
|
|
39
|
+
}
|
|
40
|
+
let final = relativeHref.startsWith("/") ? baseURL + relativeHref : baseURL + "/" + relativeHref;
|
|
41
|
+
return final;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// internal/framework/_typescript/client/src/asset_manager.ts
|
|
45
|
+
var AssetManager = class {
|
|
46
|
+
static preloadModule(url) {
|
|
47
|
+
const href = resolvePublicHref(url);
|
|
48
|
+
if (document.querySelector(
|
|
49
|
+
`link[rel="modulepreload"][href="${CSS.escape(href)}"]`
|
|
50
|
+
)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const link = document.createElement("link");
|
|
54
|
+
link.rel = "modulepreload";
|
|
55
|
+
link.href = href;
|
|
56
|
+
document.head.appendChild(link);
|
|
57
|
+
}
|
|
58
|
+
static preloadCSS(url) {
|
|
59
|
+
const href = resolvePublicHref(url);
|
|
60
|
+
if (document.querySelector(
|
|
61
|
+
`link[rel="preload"][href="${CSS.escape(href)}"]`
|
|
62
|
+
)) {
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
}
|
|
65
|
+
const link = document.createElement("link");
|
|
66
|
+
link.rel = "preload";
|
|
67
|
+
link.setAttribute("as", "style");
|
|
68
|
+
link.href = href;
|
|
69
|
+
document.head.appendChild(link);
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
link.onload = () => resolve();
|
|
72
|
+
link.onerror = reject;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
static applyCSS(bundles) {
|
|
76
|
+
window.requestAnimationFrame(() => {
|
|
77
|
+
const prefix = __vormaClientGlobal.get("publicPathPrefix");
|
|
78
|
+
for (const bundle of bundles) {
|
|
79
|
+
if (document.querySelector(
|
|
80
|
+
`link[data-vorma-css-bundle="${bundle}"]`
|
|
81
|
+
)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const link = document.createElement("link");
|
|
85
|
+
link.rel = "stylesheet";
|
|
86
|
+
link.href = prefix + bundle;
|
|
87
|
+
link.setAttribute("data-vorma-css-bundle", bundle);
|
|
88
|
+
document.head.appendChild(link);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// internal/framework/_typescript/client/src/client_loaders.ts
|
|
95
|
+
import { findNestedMatches } from "vorma/kit/matcher/find-nested";
|
|
96
|
+
import { registerPattern } from "vorma/kit/matcher/register";
|
|
97
|
+
|
|
98
|
+
// internal/framework/_typescript/client/src/component_loader.ts
|
|
99
|
+
import { jsonDeepEquals } from "vorma/kit/json";
|
|
100
|
+
function getEffectiveErrorData() {
|
|
101
|
+
const serverErrorIdx = __vormaClientGlobal.get("outermostServerErrorIdx");
|
|
102
|
+
const clientErrorIdx = __vormaClientGlobal.get("outermostClientErrorIdx");
|
|
103
|
+
let errorIdx;
|
|
104
|
+
if (serverErrorIdx != null && clientErrorIdx != null) {
|
|
105
|
+
errorIdx = Math.min(serverErrorIdx, clientErrorIdx);
|
|
106
|
+
} else {
|
|
107
|
+
errorIdx = serverErrorIdx ?? clientErrorIdx;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
index: errorIdx,
|
|
111
|
+
error: errorIdx === serverErrorIdx ? __vormaClientGlobal.get("outermostServerError") : errorIdx === clientErrorIdx ? __vormaClientGlobal.get("outermostClientError") : void 0
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
var ComponentLoader = class {
|
|
115
|
+
static async loadComponents(importURLs) {
|
|
116
|
+
const dedupedURLs = [...new Set(importURLs)];
|
|
117
|
+
const modules = await Promise.all(
|
|
118
|
+
dedupedURLs.map(async (url) => {
|
|
119
|
+
if (!url) return void 0;
|
|
120
|
+
return import(
|
|
121
|
+
/* @vite-ignore */
|
|
122
|
+
resolvePublicHref(url)
|
|
123
|
+
);
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
return new Map(dedupedURLs.map((url, i) => [url, modules[i]]));
|
|
127
|
+
}
|
|
128
|
+
static async handleComponents(importURLs) {
|
|
129
|
+
const modulesMap = await this.loadComponents(importURLs);
|
|
130
|
+
const originalImportURLs = __vormaClientGlobal.get("importURLs");
|
|
131
|
+
const exportKeys = __vormaClientGlobal.get("exportKeys") ?? [];
|
|
132
|
+
const newActiveComponents = originalImportURLs.map(
|
|
133
|
+
(url, i) => {
|
|
134
|
+
const module = modulesMap.get(url);
|
|
135
|
+
const key = exportKeys[i] ?? "default";
|
|
136
|
+
return module?.[key] ?? null;
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
if (!jsonDeepEquals(
|
|
140
|
+
newActiveComponents,
|
|
141
|
+
__vormaClientGlobal.get("activeComponents")
|
|
142
|
+
)) {
|
|
143
|
+
__vormaClientGlobal.set("activeComponents", newActiveComponents);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
static async handleErrorBoundaryComponent(importURLs) {
|
|
147
|
+
const modulesMap = await this.loadComponents(importURLs);
|
|
148
|
+
const originalImportURLs = __vormaClientGlobal.get("importURLs");
|
|
149
|
+
const errorIdx = getEffectiveErrorData().index;
|
|
150
|
+
if (errorIdx != null) {
|
|
151
|
+
const errorModuleURL = originalImportURLs[errorIdx];
|
|
152
|
+
let errorComponent;
|
|
153
|
+
if (errorModuleURL) {
|
|
154
|
+
const errorModule = modulesMap.get(errorModuleURL);
|
|
155
|
+
const errorKeys = __vormaClientGlobal.get("errorExportKeys");
|
|
156
|
+
const errorKey = errorKeys ? errorKeys[errorIdx] : null;
|
|
157
|
+
if (errorKey && errorModule) {
|
|
158
|
+
errorComponent = errorModule[errorKey];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const newErrorBoundary = errorComponent ?? __vormaClientGlobal.get("defaultErrorBoundary");
|
|
162
|
+
const currentErrorBoundary = __vormaClientGlobal.get(
|
|
163
|
+
"activeErrorBoundary"
|
|
164
|
+
);
|
|
165
|
+
if (currentErrorBoundary !== newErrorBoundary) {
|
|
166
|
+
__vormaClientGlobal.set(
|
|
167
|
+
"activeErrorBoundary",
|
|
168
|
+
newErrorBoundary
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// internal/framework/_typescript/client/src/utils/logging.ts
|
|
176
|
+
function logInfo(message, ...optionalParams) {
|
|
177
|
+
console.log("Vorma:", message, ...optionalParams);
|
|
178
|
+
}
|
|
179
|
+
function logError(message, ...optionalParams) {
|
|
180
|
+
console.error("Vorma:", message, ...optionalParams);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// internal/framework/_typescript/client/src/utils/errors.ts
|
|
184
|
+
function isAbortError(error) {
|
|
185
|
+
return error instanceof Error && error.name === "AbortError";
|
|
186
|
+
}
|
|
187
|
+
function panic(msg) {
|
|
188
|
+
logError("Panic");
|
|
189
|
+
throw new Error(msg ?? "panic");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// internal/framework/_typescript/client/src/client_loaders.ts
|
|
193
|
+
function setClientLoadersState(clr) {
|
|
194
|
+
if (clr) {
|
|
195
|
+
__vormaClientGlobal.set("clientLoadersData", clr.data ?? []);
|
|
196
|
+
__vormaClientGlobal.set(
|
|
197
|
+
"outermostClientErrorIdx",
|
|
198
|
+
clr.errorMessage ? clr.data.length - 1 : void 0
|
|
199
|
+
);
|
|
200
|
+
__vormaClientGlobal.set("outermostClientError", clr.errorMessage);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function deriveAndSetErrorState() {
|
|
204
|
+
const effectiveErrData = getEffectiveErrorData();
|
|
205
|
+
__vormaClientGlobal.set("outermostErrorIdx", effectiveErrData.index);
|
|
206
|
+
__vormaClientGlobal.set("outermostError", effectiveErrData.error);
|
|
207
|
+
}
|
|
208
|
+
async function setupClientLoaders() {
|
|
209
|
+
const clientLoadersResult = await runWaitFns(
|
|
210
|
+
{
|
|
211
|
+
hasRootData: __vormaClientGlobal.get("hasRootData"),
|
|
212
|
+
importURLs: __vormaClientGlobal.get("importURLs"),
|
|
213
|
+
loadersData: __vormaClientGlobal.get("loadersData"),
|
|
214
|
+
matchedPatterns: __vormaClientGlobal.get("matchedPatterns"),
|
|
215
|
+
params: __vormaClientGlobal.get("params"),
|
|
216
|
+
splatValues: __vormaClientGlobal.get("splatValues")
|
|
217
|
+
},
|
|
218
|
+
__vormaClientGlobal.get("buildID"),
|
|
219
|
+
new AbortController().signal
|
|
220
|
+
);
|
|
221
|
+
setClientLoadersState(clientLoadersResult);
|
|
222
|
+
deriveAndSetErrorState();
|
|
223
|
+
}
|
|
224
|
+
async function __registerClientLoaderPattern(pattern) {
|
|
225
|
+
registerPattern(__vormaClientGlobal.get("patternRegistry"), pattern);
|
|
226
|
+
}
|
|
227
|
+
async function findPartialMatchesOnClient(pathname) {
|
|
228
|
+
const patternToWaitFnMap = __vormaClientGlobal.get("patternToWaitFnMap");
|
|
229
|
+
if (Object.keys(patternToWaitFnMap).length === 0) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
const patternRegistry = __vormaClientGlobal.get("patternRegistry");
|
|
233
|
+
const fullResult = findNestedMatches(patternRegistry, pathname);
|
|
234
|
+
if (fullResult) {
|
|
235
|
+
return fullResult;
|
|
236
|
+
}
|
|
237
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
238
|
+
for (let i = segments.length; i >= 0; i--) {
|
|
239
|
+
const partialPath = i === 0 ? "/" : "/" + segments.slice(0, i).join("/");
|
|
240
|
+
const result = findNestedMatches(patternRegistry, partialPath);
|
|
241
|
+
if (result) {
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
async function executeClientLoaders(json, buildID, signal, runningLoaders) {
|
|
248
|
+
await ComponentLoader.loadComponents(json.importURLs);
|
|
249
|
+
const matchedPatterns = json.matchedPatterns ?? [];
|
|
250
|
+
const patternToWaitFnMap = __vormaClientGlobal.get("patternToWaitFnMap");
|
|
251
|
+
const outermostServerErrorIdx = __vormaClientGlobal.get(
|
|
252
|
+
"outermostServerErrorIdx"
|
|
253
|
+
);
|
|
254
|
+
const loaderPromises = [];
|
|
255
|
+
const abortControllers = [];
|
|
256
|
+
let i = 0;
|
|
257
|
+
for (const pattern of matchedPatterns) {
|
|
258
|
+
if (outermostServerErrorIdx !== void 0 && i === outermostServerErrorIdx) {
|
|
259
|
+
loaderPromises.push(Promise.resolve());
|
|
260
|
+
abortControllers.push(null);
|
|
261
|
+
i++;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (runningLoaders?.has(pattern)) {
|
|
265
|
+
loaderPromises.push(runningLoaders.get(pattern));
|
|
266
|
+
abortControllers.push(null);
|
|
267
|
+
} else if (patternToWaitFnMap[pattern]) {
|
|
268
|
+
const controller = new AbortController();
|
|
269
|
+
abortControllers.push(controller);
|
|
270
|
+
if (signal.aborted) {
|
|
271
|
+
controller.abort();
|
|
272
|
+
} else {
|
|
273
|
+
signal.addEventListener("abort", () => controller.abort(), {
|
|
274
|
+
once: true
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
const serverDataPromise = Promise.resolve({
|
|
278
|
+
matchedPatterns: json.matchedPatterns,
|
|
279
|
+
loaderData: json.loadersData[i],
|
|
280
|
+
rootData: json.hasRootData ? json.loadersData[0] : null,
|
|
281
|
+
buildID
|
|
282
|
+
});
|
|
283
|
+
const loaderPromise = patternToWaitFnMap[pattern]({
|
|
284
|
+
params: json.params || {},
|
|
285
|
+
splatValues: json.splatValues || [],
|
|
286
|
+
serverDataPromise,
|
|
287
|
+
signal: controller.signal
|
|
288
|
+
});
|
|
289
|
+
loaderPromises.push(loaderPromise);
|
|
290
|
+
} else {
|
|
291
|
+
loaderPromises.push(Promise.resolve());
|
|
292
|
+
abortControllers.push(null);
|
|
293
|
+
}
|
|
294
|
+
i++;
|
|
295
|
+
}
|
|
296
|
+
const wrappedPromises = loaderPromises.map(async (promise, index) => {
|
|
297
|
+
return promise.catch((error) => {
|
|
298
|
+
if (!isAbortError(error)) {
|
|
299
|
+
for (let j = index + 1; j < abortControllers.length; j++) {
|
|
300
|
+
abortControllers[j]?.abort();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
throw error;
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
const results = await Promise.allSettled(wrappedPromises);
|
|
307
|
+
const data = [];
|
|
308
|
+
let errorMessage;
|
|
309
|
+
for (let i2 = 0; i2 < results.length; i2++) {
|
|
310
|
+
const result = results[i2];
|
|
311
|
+
if (!result) {
|
|
312
|
+
data.push(void 0);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (result.status === "fulfilled") {
|
|
316
|
+
data.push(result.value);
|
|
317
|
+
} else {
|
|
318
|
+
if (!isAbortError(result.reason)) {
|
|
319
|
+
const pattern = matchedPatterns[i2];
|
|
320
|
+
logError(
|
|
321
|
+
`Client loader error for pattern ${pattern}:`,
|
|
322
|
+
result.reason
|
|
323
|
+
);
|
|
324
|
+
errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
325
|
+
}
|
|
326
|
+
data.push(void 0);
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return { data, errorMessage };
|
|
331
|
+
}
|
|
332
|
+
async function runWaitFns(json, buildID, signal) {
|
|
333
|
+
return executeClientLoaders(json, buildID, signal);
|
|
334
|
+
}
|
|
335
|
+
async function completeClientLoaders(json, buildID, runningLoaders, signal) {
|
|
336
|
+
return executeClientLoaders(json, buildID, signal, runningLoaders);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// internal/framework/_typescript/client/src/events.ts
|
|
340
|
+
var VORMA_ROUTE_CHANGE_EVENT_KEY = "vorma:route-change";
|
|
341
|
+
var addRouteChangeListener = makeListenerAdder(
|
|
342
|
+
VORMA_ROUTE_CHANGE_EVENT_KEY
|
|
343
|
+
);
|
|
344
|
+
function dispatchRouteChangeEvent(detail) {
|
|
345
|
+
window.dispatchEvent(
|
|
346
|
+
new CustomEvent(VORMA_ROUTE_CHANGE_EVENT_KEY, { detail })
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
var STATUS_EVENT_KEY = "vorma:status";
|
|
350
|
+
function dispatchStatusEvent(detail) {
|
|
351
|
+
window.dispatchEvent(new CustomEvent(STATUS_EVENT_KEY, { detail }));
|
|
352
|
+
}
|
|
353
|
+
var addStatusListener = makeListenerAdder(STATUS_EVENT_KEY);
|
|
354
|
+
var BUILD_ID_EVENT_KEY = "vorma:build-id";
|
|
355
|
+
function dispatchBuildIDEvent(detail) {
|
|
356
|
+
window.dispatchEvent(new CustomEvent(BUILD_ID_EVENT_KEY, { detail }));
|
|
357
|
+
}
|
|
358
|
+
var addBuildIDListener = makeListenerAdder(BUILD_ID_EVENT_KEY);
|
|
359
|
+
var LOCATION_EVENT_KEY = "vorma:location";
|
|
360
|
+
function dispatchLocationEvent() {
|
|
361
|
+
window.dispatchEvent(new CustomEvent(LOCATION_EVENT_KEY));
|
|
362
|
+
}
|
|
363
|
+
var addLocationListener = makeListenerAdder(LOCATION_EVENT_KEY);
|
|
364
|
+
function makeListenerAdder(key) {
|
|
365
|
+
return function addListener(listener) {
|
|
366
|
+
window.addEventListener(key, listener);
|
|
367
|
+
return () => window.removeEventListener(key, listener);
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// node_modules/@babel/runtime/helpers/esm/extends.js
|
|
372
|
+
function _extends() {
|
|
373
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
374
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
375
|
+
var t = arguments[e];
|
|
376
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
377
|
+
}
|
|
378
|
+
return n;
|
|
379
|
+
}, _extends.apply(null, arguments);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// node_modules/history/index.js
|
|
383
|
+
var Action;
|
|
384
|
+
(function(Action2) {
|
|
385
|
+
Action2["Pop"] = "POP";
|
|
386
|
+
Action2["Push"] = "PUSH";
|
|
387
|
+
Action2["Replace"] = "REPLACE";
|
|
388
|
+
})(Action || (Action = {}));
|
|
389
|
+
var readOnly = true ? function(obj) {
|
|
390
|
+
return Object.freeze(obj);
|
|
391
|
+
} : function(obj) {
|
|
392
|
+
return obj;
|
|
393
|
+
};
|
|
394
|
+
function warning(cond, message) {
|
|
395
|
+
if (!cond) {
|
|
396
|
+
if (typeof console !== "undefined") console.warn(message);
|
|
397
|
+
try {
|
|
398
|
+
throw new Error(message);
|
|
399
|
+
} catch (e) {
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
var BeforeUnloadEventType = "beforeunload";
|
|
404
|
+
var PopStateEventType = "popstate";
|
|
405
|
+
function createBrowserHistory(options) {
|
|
406
|
+
if (options === void 0) {
|
|
407
|
+
options = {};
|
|
408
|
+
}
|
|
409
|
+
var _options = options, _options$window = _options.window, window2 = _options$window === void 0 ? document.defaultView : _options$window;
|
|
410
|
+
var globalHistory = window2.history;
|
|
411
|
+
function getIndexAndLocation() {
|
|
412
|
+
var _window$location = window2.location, pathname = _window$location.pathname, search = _window$location.search, hash = _window$location.hash;
|
|
413
|
+
var state = globalHistory.state || {};
|
|
414
|
+
return [state.idx, readOnly({
|
|
415
|
+
pathname,
|
|
416
|
+
search,
|
|
417
|
+
hash,
|
|
418
|
+
state: state.usr || null,
|
|
419
|
+
key: state.key || "default"
|
|
420
|
+
})];
|
|
421
|
+
}
|
|
422
|
+
var blockedPopTx = null;
|
|
423
|
+
function handlePop() {
|
|
424
|
+
if (blockedPopTx) {
|
|
425
|
+
blockers.call(blockedPopTx);
|
|
426
|
+
blockedPopTx = null;
|
|
427
|
+
} else {
|
|
428
|
+
var nextAction = Action.Pop;
|
|
429
|
+
var _getIndexAndLocation = getIndexAndLocation(), nextIndex = _getIndexAndLocation[0], nextLocation = _getIndexAndLocation[1];
|
|
430
|
+
if (blockers.length) {
|
|
431
|
+
if (nextIndex != null) {
|
|
432
|
+
var delta = index - nextIndex;
|
|
433
|
+
if (delta) {
|
|
434
|
+
blockedPopTx = {
|
|
435
|
+
action: nextAction,
|
|
436
|
+
location: nextLocation,
|
|
437
|
+
retry: function retry() {
|
|
438
|
+
go(delta * -1);
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
go(delta);
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
true ? warning(
|
|
445
|
+
false,
|
|
446
|
+
// TODO: Write up a doc that explains our blocking strategy in
|
|
447
|
+
// detail and link to it here so people can understand better what
|
|
448
|
+
// is going on and how to avoid it.
|
|
449
|
+
"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
|
|
450
|
+
) : void 0;
|
|
451
|
+
}
|
|
452
|
+
} else {
|
|
453
|
+
applyTx(nextAction);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
window2.addEventListener(PopStateEventType, handlePop);
|
|
458
|
+
var action = Action.Pop;
|
|
459
|
+
var _getIndexAndLocation2 = getIndexAndLocation(), index = _getIndexAndLocation2[0], location2 = _getIndexAndLocation2[1];
|
|
460
|
+
var listeners = createEvents();
|
|
461
|
+
var blockers = createEvents();
|
|
462
|
+
if (index == null) {
|
|
463
|
+
index = 0;
|
|
464
|
+
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
465
|
+
idx: index
|
|
466
|
+
}), "");
|
|
467
|
+
}
|
|
468
|
+
function createHref(to) {
|
|
469
|
+
return typeof to === "string" ? to : createPath(to);
|
|
470
|
+
}
|
|
471
|
+
function getNextLocation(to, state) {
|
|
472
|
+
if (state === void 0) {
|
|
473
|
+
state = null;
|
|
474
|
+
}
|
|
475
|
+
return readOnly(_extends({
|
|
476
|
+
pathname: location2.pathname,
|
|
477
|
+
hash: "",
|
|
478
|
+
search: ""
|
|
479
|
+
}, typeof to === "string" ? parsePath(to) : to, {
|
|
480
|
+
state,
|
|
481
|
+
key: createKey()
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
function getHistoryStateAndUrl(nextLocation, index2) {
|
|
485
|
+
return [{
|
|
486
|
+
usr: nextLocation.state,
|
|
487
|
+
key: nextLocation.key,
|
|
488
|
+
idx: index2
|
|
489
|
+
}, createHref(nextLocation)];
|
|
490
|
+
}
|
|
491
|
+
function allowTx(action2, location3, retry) {
|
|
492
|
+
return !blockers.length || (blockers.call({
|
|
493
|
+
action: action2,
|
|
494
|
+
location: location3,
|
|
495
|
+
retry
|
|
496
|
+
}), false);
|
|
497
|
+
}
|
|
498
|
+
function applyTx(nextAction) {
|
|
499
|
+
action = nextAction;
|
|
500
|
+
var _getIndexAndLocation3 = getIndexAndLocation();
|
|
501
|
+
index = _getIndexAndLocation3[0];
|
|
502
|
+
location2 = _getIndexAndLocation3[1];
|
|
503
|
+
listeners.call({
|
|
504
|
+
action,
|
|
505
|
+
location: location2
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function push(to, state) {
|
|
509
|
+
var nextAction = Action.Push;
|
|
510
|
+
var nextLocation = getNextLocation(to, state);
|
|
511
|
+
function retry() {
|
|
512
|
+
push(to, state);
|
|
513
|
+
}
|
|
514
|
+
if (allowTx(nextAction, nextLocation, retry)) {
|
|
515
|
+
var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1), historyState = _getHistoryStateAndUr[0], url = _getHistoryStateAndUr[1];
|
|
516
|
+
try {
|
|
517
|
+
globalHistory.pushState(historyState, "", url);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
window2.location.assign(url);
|
|
520
|
+
}
|
|
521
|
+
applyTx(nextAction);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function replace(to, state) {
|
|
525
|
+
var nextAction = Action.Replace;
|
|
526
|
+
var nextLocation = getNextLocation(to, state);
|
|
527
|
+
function retry() {
|
|
528
|
+
replace(to, state);
|
|
529
|
+
}
|
|
530
|
+
if (allowTx(nextAction, nextLocation, retry)) {
|
|
531
|
+
var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index), historyState = _getHistoryStateAndUr2[0], url = _getHistoryStateAndUr2[1];
|
|
532
|
+
globalHistory.replaceState(historyState, "", url);
|
|
533
|
+
applyTx(nextAction);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function go(delta) {
|
|
537
|
+
globalHistory.go(delta);
|
|
538
|
+
}
|
|
539
|
+
var history2 = {
|
|
540
|
+
get action() {
|
|
541
|
+
return action;
|
|
542
|
+
},
|
|
543
|
+
get location() {
|
|
544
|
+
return location2;
|
|
545
|
+
},
|
|
546
|
+
createHref,
|
|
547
|
+
push,
|
|
548
|
+
replace,
|
|
549
|
+
go,
|
|
550
|
+
back: function back() {
|
|
551
|
+
go(-1);
|
|
552
|
+
},
|
|
553
|
+
forward: function forward() {
|
|
554
|
+
go(1);
|
|
555
|
+
},
|
|
556
|
+
listen: function listen(listener) {
|
|
557
|
+
return listeners.push(listener);
|
|
558
|
+
},
|
|
559
|
+
block: function block(blocker) {
|
|
560
|
+
var unblock = blockers.push(blocker);
|
|
561
|
+
if (blockers.length === 1) {
|
|
562
|
+
window2.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
563
|
+
}
|
|
564
|
+
return function() {
|
|
565
|
+
unblock();
|
|
566
|
+
if (!blockers.length) {
|
|
567
|
+
window2.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
return history2;
|
|
573
|
+
}
|
|
574
|
+
function promptBeforeUnload(event) {
|
|
575
|
+
event.preventDefault();
|
|
576
|
+
event.returnValue = "";
|
|
577
|
+
}
|
|
578
|
+
function createEvents() {
|
|
579
|
+
var handlers = [];
|
|
580
|
+
return {
|
|
581
|
+
get length() {
|
|
582
|
+
return handlers.length;
|
|
583
|
+
},
|
|
584
|
+
push: function push(fn) {
|
|
585
|
+
handlers.push(fn);
|
|
586
|
+
return function() {
|
|
587
|
+
handlers = handlers.filter(function(handler) {
|
|
588
|
+
return handler !== fn;
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
},
|
|
592
|
+
call: function call(arg) {
|
|
593
|
+
handlers.forEach(function(fn) {
|
|
594
|
+
return fn && fn(arg);
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function createKey() {
|
|
600
|
+
return Math.random().toString(36).substr(2, 8);
|
|
601
|
+
}
|
|
602
|
+
function createPath(_ref) {
|
|
603
|
+
var _ref$pathname = _ref.pathname, pathname = _ref$pathname === void 0 ? "/" : _ref$pathname, _ref$search = _ref.search, search = _ref$search === void 0 ? "" : _ref$search, _ref$hash = _ref.hash, hash = _ref$hash === void 0 ? "" : _ref$hash;
|
|
604
|
+
if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
605
|
+
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
606
|
+
return pathname;
|
|
607
|
+
}
|
|
608
|
+
function parsePath(path) {
|
|
609
|
+
var parsedPath = {};
|
|
610
|
+
if (path) {
|
|
611
|
+
var hashIndex = path.indexOf("#");
|
|
612
|
+
if (hashIndex >= 0) {
|
|
613
|
+
parsedPath.hash = path.substr(hashIndex);
|
|
614
|
+
path = path.substr(0, hashIndex);
|
|
615
|
+
}
|
|
616
|
+
var searchIndex = path.indexOf("?");
|
|
617
|
+
if (searchIndex >= 0) {
|
|
618
|
+
parsedPath.search = path.substr(searchIndex);
|
|
619
|
+
path = path.substr(0, searchIndex);
|
|
620
|
+
}
|
|
621
|
+
if (path) {
|
|
622
|
+
parsedPath.pathname = path;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return parsedPath;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// internal/framework/_typescript/client/src/scroll_state_manager.ts
|
|
629
|
+
var ScrollStateManager = class {
|
|
630
|
+
STORAGE_KEY = "__vorma__scrollStateMap";
|
|
631
|
+
PAGE_REFRESH_KEY = "__vorma__pageRefreshScrollState";
|
|
632
|
+
MAX_ENTRIES = 50;
|
|
633
|
+
saveState(key, state) {
|
|
634
|
+
const map = this.getMap();
|
|
635
|
+
map.set(key, state);
|
|
636
|
+
if (map.size > this.MAX_ENTRIES) {
|
|
637
|
+
const firstKey = map.keys().next().value;
|
|
638
|
+
if (firstKey) map.delete(firstKey);
|
|
639
|
+
}
|
|
640
|
+
this.saveMap(map);
|
|
641
|
+
}
|
|
642
|
+
getState(key) {
|
|
643
|
+
return this.getMap().get(key);
|
|
644
|
+
}
|
|
645
|
+
savePageRefreshState() {
|
|
646
|
+
const state = {
|
|
647
|
+
x: window.scrollX,
|
|
648
|
+
y: window.scrollY,
|
|
649
|
+
unix: Date.now(),
|
|
650
|
+
href: window.location.href
|
|
651
|
+
};
|
|
652
|
+
sessionStorage.setItem(this.PAGE_REFRESH_KEY, JSON.stringify(state));
|
|
653
|
+
}
|
|
654
|
+
restorePageRefreshState() {
|
|
655
|
+
const stored = sessionStorage.getItem(this.PAGE_REFRESH_KEY);
|
|
656
|
+
if (!stored) return;
|
|
657
|
+
try {
|
|
658
|
+
const state = JSON.parse(stored);
|
|
659
|
+
if (state.href === window.location.href && Date.now() - state.unix < 5e3) {
|
|
660
|
+
sessionStorage.removeItem(this.PAGE_REFRESH_KEY);
|
|
661
|
+
window.requestAnimationFrame(() => {
|
|
662
|
+
__applyScrollState({ x: state.x, y: state.y });
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
} catch {
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
getMap() {
|
|
669
|
+
const stored = sessionStorage.getItem(this.STORAGE_KEY);
|
|
670
|
+
if (!stored) return /* @__PURE__ */ new Map();
|
|
671
|
+
try {
|
|
672
|
+
return new Map(JSON.parse(stored));
|
|
673
|
+
} catch {
|
|
674
|
+
return /* @__PURE__ */ new Map();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
saveMap(map) {
|
|
678
|
+
sessionStorage.setItem(
|
|
679
|
+
this.STORAGE_KEY,
|
|
680
|
+
JSON.stringify(Array.from(map.entries()))
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var scrollStateManager = new ScrollStateManager();
|
|
685
|
+
function __applyScrollState(state) {
|
|
686
|
+
if (!state) {
|
|
687
|
+
const id = window.location.hash.slice(1);
|
|
688
|
+
if (id) {
|
|
689
|
+
document.getElementById(id)?.scrollIntoView();
|
|
690
|
+
}
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if ("hash" in state) {
|
|
694
|
+
if (state.hash) {
|
|
695
|
+
document.getElementById(state.hash)?.scrollIntoView();
|
|
696
|
+
}
|
|
697
|
+
} else {
|
|
698
|
+
window.scrollTo(state.x, state.y);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function saveScrollState() {
|
|
702
|
+
const lastKnownLocation = HistoryManager.getLastKnownLocation();
|
|
703
|
+
scrollStateManager.saveState(lastKnownLocation.key, {
|
|
704
|
+
x: window.scrollX,
|
|
705
|
+
y: window.scrollY
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// internal/framework/_typescript/client/src/history/history.ts
|
|
710
|
+
var HistoryManager = class {
|
|
711
|
+
static instance;
|
|
712
|
+
static lastKnownLocation;
|
|
713
|
+
static getInstance() {
|
|
714
|
+
if (!this.instance) {
|
|
715
|
+
this.instance = createBrowserHistory();
|
|
716
|
+
this.lastKnownLocation = this.instance.location;
|
|
717
|
+
}
|
|
718
|
+
return this.instance;
|
|
719
|
+
}
|
|
720
|
+
static getLastKnownLocation() {
|
|
721
|
+
return this.lastKnownLocation;
|
|
722
|
+
}
|
|
723
|
+
static updateLastKnownLocation(location2) {
|
|
724
|
+
this.lastKnownLocation = location2;
|
|
725
|
+
}
|
|
726
|
+
static init() {
|
|
727
|
+
const instance = this.getInstance();
|
|
728
|
+
instance.listen(customHistoryListener);
|
|
729
|
+
this.setManualScrollRestoration();
|
|
730
|
+
}
|
|
731
|
+
static setManualScrollRestoration() {
|
|
732
|
+
if (history.scrollRestoration && history.scrollRestoration !== "manual") {
|
|
733
|
+
history.scrollRestoration = "manual";
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
async function customHistoryListener({
|
|
738
|
+
action,
|
|
739
|
+
location: location2
|
|
740
|
+
}) {
|
|
741
|
+
const lastKnownLocation = HistoryManager.getLastKnownLocation();
|
|
742
|
+
if (location2.key !== lastKnownLocation.key) {
|
|
743
|
+
dispatchLocationEvent();
|
|
744
|
+
}
|
|
745
|
+
const popWithinSameDoc = action === "POP" && location2.pathname === lastKnownLocation.pathname && location2.search === lastKnownLocation.search;
|
|
746
|
+
const removingHash = popWithinSameDoc && lastKnownLocation.hash && !location2.hash;
|
|
747
|
+
const addingHash = popWithinSameDoc && !lastKnownLocation.hash && location2.hash;
|
|
748
|
+
const updatingHash = popWithinSameDoc && location2.hash;
|
|
749
|
+
if (!popWithinSameDoc) {
|
|
750
|
+
saveScrollState();
|
|
751
|
+
}
|
|
752
|
+
let navigationSucceeded = true;
|
|
753
|
+
if (action === "POP") {
|
|
754
|
+
const newHash = location2.hash.slice(1);
|
|
755
|
+
if (addingHash || updatingHash) {
|
|
756
|
+
__applyScrollState({ hash: newHash });
|
|
757
|
+
}
|
|
758
|
+
if (removingHash) {
|
|
759
|
+
const stored = scrollStateManager.getState(location2.key);
|
|
760
|
+
__applyScrollState(stored ?? { x: 0, y: 0 });
|
|
761
|
+
}
|
|
762
|
+
if (!popWithinSameDoc) {
|
|
763
|
+
const result = await navigationStateManager.navigate({
|
|
764
|
+
href: window.location.href,
|
|
765
|
+
navigationType: "browserHistory",
|
|
766
|
+
scrollStateToRestore: scrollStateManager.getState(location2.key)
|
|
767
|
+
});
|
|
768
|
+
if (!result.didNavigate) {
|
|
769
|
+
navigationSucceeded = false;
|
|
770
|
+
logError(
|
|
771
|
+
"Browser POP navigation failed, attempting hard reload of the destination."
|
|
772
|
+
);
|
|
773
|
+
window.location.reload();
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (navigationSucceeded) {
|
|
778
|
+
HistoryManager.updateLastKnownLocation(location2);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// internal/framework/_typescript/client/src/redirects/redirects.ts
|
|
783
|
+
import {
|
|
784
|
+
getHrefDetails,
|
|
785
|
+
getIsGETRequest
|
|
786
|
+
} from "vorma/kit/url";
|
|
787
|
+
|
|
788
|
+
// internal/framework/_typescript/client/src/hard_reload.ts
|
|
789
|
+
var VORMA_HARD_RELOAD_QUERY_PARAM = "vorma_reload";
|
|
790
|
+
|
|
791
|
+
// internal/framework/_typescript/client/src/redirects/redirects.ts
|
|
792
|
+
function getBuildIDFromResponse(response) {
|
|
793
|
+
return response?.headers.get("X-Vorma-Build-Id") || "";
|
|
794
|
+
}
|
|
795
|
+
function parseFetchResponseForRedirectData(reqInit, res) {
|
|
796
|
+
const latestBuildID = getBuildIDFromResponse(res);
|
|
797
|
+
const vormaReloadTarget = res.headers.get("X-Vorma-Reload");
|
|
798
|
+
if (vormaReloadTarget) {
|
|
799
|
+
const newURL2 = new URL(vormaReloadTarget, window.location.href);
|
|
800
|
+
const hrefDetails2 = getHrefDetails(newURL2.href);
|
|
801
|
+
if (!hrefDetails2.isHTTP) {
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
return {
|
|
805
|
+
hrefDetails: hrefDetails2,
|
|
806
|
+
status: "should",
|
|
807
|
+
href: vormaReloadTarget,
|
|
808
|
+
shouldRedirectStrategy: "hard",
|
|
809
|
+
latestBuildID
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
if (res.redirected) {
|
|
813
|
+
const newURL2 = new URL(res.url, window.location.href);
|
|
814
|
+
const hrefDetails2 = getHrefDetails(newURL2.href);
|
|
815
|
+
if (!hrefDetails2.isHTTP) {
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
const isCurrent = newURL2.href === window.location.href;
|
|
819
|
+
if (isCurrent) {
|
|
820
|
+
return { hrefDetails: hrefDetails2, status: "did", href: newURL2.href };
|
|
821
|
+
}
|
|
822
|
+
const wasGETRequest = getIsGETRequest(reqInit);
|
|
823
|
+
if (!wasGETRequest) {
|
|
824
|
+
logInfo("Not a GET request. No way to handle.");
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
hrefDetails: hrefDetails2,
|
|
829
|
+
status: "should",
|
|
830
|
+
href: newURL2.href,
|
|
831
|
+
shouldRedirectStrategy: hrefDetails2.isInternal ? "soft" : "hard",
|
|
832
|
+
latestBuildID
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
const clientRedirectHeader = res.headers.get("X-Client-Redirect");
|
|
836
|
+
if (!clientRedirectHeader) {
|
|
837
|
+
return null;
|
|
838
|
+
}
|
|
839
|
+
const newURL = new URL(clientRedirectHeader, window.location.href);
|
|
840
|
+
const hrefDetails = getHrefDetails(newURL.href);
|
|
841
|
+
if (!hrefDetails.isHTTP) {
|
|
842
|
+
return null;
|
|
843
|
+
}
|
|
844
|
+
return {
|
|
845
|
+
hrefDetails,
|
|
846
|
+
status: "should",
|
|
847
|
+
href: hrefDetails.absoluteURL,
|
|
848
|
+
shouldRedirectStrategy: hrefDetails.isInternal ? "soft" : "hard",
|
|
849
|
+
latestBuildID
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
async function effectuateRedirectDataResult(redirectData, redirectCount, originalProps) {
|
|
853
|
+
if (redirectData.status !== "should") {
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
const navEntries = navigationStateManager.getNavigations().entries();
|
|
857
|
+
for (const [key, nav] of navEntries) {
|
|
858
|
+
if (nav.type === "redirect" || nav.type === "revalidation") {
|
|
859
|
+
nav.control.abortController?.abort();
|
|
860
|
+
navigationStateManager.removeNavigation(key);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (redirectData.shouldRedirectStrategy === "hard") {
|
|
864
|
+
if (!redirectData.hrefDetails.isHTTP) return null;
|
|
865
|
+
if (redirectData.hrefDetails.isExternal) {
|
|
866
|
+
window.location.href = redirectData.href;
|
|
867
|
+
} else {
|
|
868
|
+
const url = new URL(redirectData.href, window.location.href);
|
|
869
|
+
url.searchParams.set(
|
|
870
|
+
VORMA_HARD_RELOAD_QUERY_PARAM,
|
|
871
|
+
redirectData.latestBuildID
|
|
872
|
+
);
|
|
873
|
+
window.location.href = url.href;
|
|
874
|
+
}
|
|
875
|
+
return {
|
|
876
|
+
hrefDetails: redirectData.hrefDetails,
|
|
877
|
+
status: "did",
|
|
878
|
+
href: redirectData.href
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
if (redirectData.shouldRedirectStrategy === "soft") {
|
|
882
|
+
await navigationStateManager.navigate({
|
|
883
|
+
href: redirectData.href,
|
|
884
|
+
navigationType: "redirect",
|
|
885
|
+
redirectCount: redirectCount + 1,
|
|
886
|
+
state: originalProps?.state,
|
|
887
|
+
replace: originalProps?.replace,
|
|
888
|
+
scrollToTop: originalProps?.scrollToTop
|
|
889
|
+
});
|
|
890
|
+
return {
|
|
891
|
+
hrefDetails: redirectData.hrefDetails,
|
|
892
|
+
status: "did",
|
|
893
|
+
href: redirectData.href
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
return null;
|
|
897
|
+
}
|
|
898
|
+
async function handleRedirects(props) {
|
|
899
|
+
const MAX_REDIRECTS = 10;
|
|
900
|
+
const redirectCount = props.redirectCount || 0;
|
|
901
|
+
if (redirectCount >= MAX_REDIRECTS) {
|
|
902
|
+
logError("Too many redirects");
|
|
903
|
+
return { redirectData: null, response: void 0 };
|
|
904
|
+
}
|
|
905
|
+
const bodyParentObj = {};
|
|
906
|
+
const isGET = getIsGETRequest(props.requestInit);
|
|
907
|
+
if (props.requestInit && (props.requestInit.body !== void 0 || !isGET)) {
|
|
908
|
+
if (props.requestInit.body instanceof FormData || typeof props.requestInit.body === "string") {
|
|
909
|
+
bodyParentObj.body = props.requestInit.body;
|
|
910
|
+
} else {
|
|
911
|
+
bodyParentObj.body = JSON.stringify(props.requestInit.body);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const headers = new Headers(props.requestInit?.headers);
|
|
915
|
+
headers.set("X-Accepts-Client-Redirect", "1");
|
|
916
|
+
bodyParentObj.headers = headers;
|
|
917
|
+
const finalRequestInit = {
|
|
918
|
+
signal: props.abortController.signal,
|
|
919
|
+
...props.requestInit,
|
|
920
|
+
...bodyParentObj
|
|
921
|
+
};
|
|
922
|
+
const res = await fetch(props.url, finalRequestInit);
|
|
923
|
+
let redirectData = parseFetchResponseForRedirectData(finalRequestInit, res);
|
|
924
|
+
return { redirectData, response: res };
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// internal/framework/_typescript/client/src/head_elements/head_elements.ts
|
|
928
|
+
function getStartAndEndComments(type) {
|
|
929
|
+
const startMarker = `data-vorma="${type}-start"`;
|
|
930
|
+
const endMarker = `data-vorma="${type}-end"`;
|
|
931
|
+
const start = findComment(startMarker);
|
|
932
|
+
const end = findComment(endMarker);
|
|
933
|
+
return { startComment: start, endComment: end };
|
|
934
|
+
}
|
|
935
|
+
function findComment(matchingText) {
|
|
936
|
+
const walker = document.createTreeWalker(
|
|
937
|
+
document.head,
|
|
938
|
+
NodeFilter.SHOW_COMMENT,
|
|
939
|
+
{
|
|
940
|
+
acceptNode(node) {
|
|
941
|
+
return node.nodeValue?.trim() === matchingText.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
);
|
|
945
|
+
return walker.nextNode();
|
|
946
|
+
}
|
|
947
|
+
function updateHeadEls(type, blocks) {
|
|
948
|
+
const { startComment, endComment } = getStartAndEndComments(type);
|
|
949
|
+
if (!startComment || !endComment || !endComment.parentNode) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
const parent = endComment.parentNode;
|
|
953
|
+
const currentNodes = [];
|
|
954
|
+
let nodePtr = startComment.nextSibling;
|
|
955
|
+
while (nodePtr != null && nodePtr !== endComment) {
|
|
956
|
+
currentNodes.push(nodePtr);
|
|
957
|
+
nodePtr = nodePtr.nextSibling;
|
|
958
|
+
}
|
|
959
|
+
const currentElements = currentNodes.filter(
|
|
960
|
+
(node) => node.nodeType === Node.ELEMENT_NODE
|
|
961
|
+
);
|
|
962
|
+
const newElements = [];
|
|
963
|
+
const newElementFingerprints = /* @__PURE__ */ new Map();
|
|
964
|
+
for (const block of blocks) {
|
|
965
|
+
if (!block.tag) {
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
const newEl = document.createElement(block.tag);
|
|
969
|
+
if (block.attributesKnownSafe) {
|
|
970
|
+
for (const key of Object.keys(block.attributesKnownSafe)) {
|
|
971
|
+
const value = block.attributesKnownSafe[key];
|
|
972
|
+
if (value === null || value === void 0) {
|
|
973
|
+
panic(
|
|
974
|
+
`Attribute value for '${key}' in tag '${block.tag}' cannot be null or undefined.`
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
newEl.setAttribute(key, value);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (block.booleanAttributes) {
|
|
981
|
+
for (const key of block.booleanAttributes) {
|
|
982
|
+
newEl.setAttribute(key, "");
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (block.dangerousInnerHTML) {
|
|
986
|
+
newEl.innerHTML = block.dangerousInnerHTML;
|
|
987
|
+
}
|
|
988
|
+
const fingerprint = createElementFingerprint(newEl);
|
|
989
|
+
if (newElementFingerprints.has(fingerprint)) {
|
|
990
|
+
const elementToRemove = newElementFingerprints.get(fingerprint);
|
|
991
|
+
if (elementToRemove) {
|
|
992
|
+
const indexToRemove = newElements.indexOf(elementToRemove);
|
|
993
|
+
if (indexToRemove > -1) {
|
|
994
|
+
newElements.splice(indexToRemove, 1);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
newElements.push(newEl);
|
|
999
|
+
newElementFingerprints.set(fingerprint, newEl);
|
|
1000
|
+
}
|
|
1001
|
+
const currentElementsMap = /* @__PURE__ */ new Map();
|
|
1002
|
+
for (const el of currentElements) {
|
|
1003
|
+
const fingerprint = createElementFingerprint(el);
|
|
1004
|
+
if (!currentElementsMap.has(fingerprint)) {
|
|
1005
|
+
currentElementsMap.set(fingerprint, []);
|
|
1006
|
+
}
|
|
1007
|
+
currentElementsMap.get(fingerprint)?.push(el);
|
|
1008
|
+
}
|
|
1009
|
+
const finalElements = [];
|
|
1010
|
+
const usedCurrentElements = /* @__PURE__ */ new Set();
|
|
1011
|
+
for (const newEl of newElements) {
|
|
1012
|
+
const fingerprint = createElementFingerprint(newEl);
|
|
1013
|
+
const matchingCurrentElementsList = currentElementsMap.get(fingerprint) || [];
|
|
1014
|
+
const matchingElement = matchingCurrentElementsList.find(
|
|
1015
|
+
(el) => !usedCurrentElements.has(el)
|
|
1016
|
+
);
|
|
1017
|
+
if (matchingElement) {
|
|
1018
|
+
usedCurrentElements.add(matchingElement);
|
|
1019
|
+
finalElements.push(matchingElement);
|
|
1020
|
+
} else {
|
|
1021
|
+
finalElements.push(newEl);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
const desiredPositions = /* @__PURE__ */ new Map();
|
|
1025
|
+
finalElements.forEach((el, index) => {
|
|
1026
|
+
desiredPositions.set(el, index);
|
|
1027
|
+
});
|
|
1028
|
+
const remainingCurrentElements = new Set(currentElements);
|
|
1029
|
+
for (const currentElement of currentElements) {
|
|
1030
|
+
if (!usedCurrentElements.has(currentElement)) {
|
|
1031
|
+
parent.removeChild(currentElement);
|
|
1032
|
+
remainingCurrentElements.delete(currentElement);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
let lastProcessedElement = null;
|
|
1036
|
+
for (let i = 0; i < finalElements.length; i++) {
|
|
1037
|
+
const element = finalElements[i];
|
|
1038
|
+
if (!element) {
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
const isExistingElement = usedCurrentElements.has(element);
|
|
1042
|
+
if (isExistingElement) {
|
|
1043
|
+
const nextElementInDOM = lastProcessedElement ? lastProcessedElement.nextElementSibling : startComment.nextElementSibling;
|
|
1044
|
+
if (nextElementInDOM !== element) {
|
|
1045
|
+
parent.insertBefore(element, nextElementInDOM || endComment);
|
|
1046
|
+
}
|
|
1047
|
+
remainingCurrentElements.delete(element);
|
|
1048
|
+
lastProcessedElement = element;
|
|
1049
|
+
} else {
|
|
1050
|
+
const insertBefore = lastProcessedElement ? lastProcessedElement.nextSibling : startComment.nextSibling;
|
|
1051
|
+
parent.insertBefore(element, insertBefore || endComment);
|
|
1052
|
+
lastProcessedElement = element;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function createElementFingerprint(element) {
|
|
1057
|
+
const attributes = [];
|
|
1058
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
1059
|
+
const attr = element.attributes[i];
|
|
1060
|
+
if (!attr) {
|
|
1061
|
+
continue;
|
|
1062
|
+
}
|
|
1063
|
+
const value = element.hasAttribute(attr.name) && attr.value === "" ? "" : attr.value;
|
|
1064
|
+
attributes.push(`${attr.name}="${value}"`);
|
|
1065
|
+
}
|
|
1066
|
+
attributes.sort();
|
|
1067
|
+
return `${element.tagName.toUpperCase()}|${attributes.join(",")}|${(element.innerHTML || "").trim()}`;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// internal/framework/_typescript/client/src/rendering.ts
|
|
1071
|
+
async function __reRenderApp(props) {
|
|
1072
|
+
const shouldUseViewTransitions = __vormaClientGlobal.get("useViewTransitions") && !!document.startViewTransition && props.navigationType !== "prefetch" && props.navigationType !== "revalidation";
|
|
1073
|
+
if (shouldUseViewTransitions) {
|
|
1074
|
+
const transition = document.startViewTransition(async () => {
|
|
1075
|
+
await __reRenderAppInner(props);
|
|
1076
|
+
});
|
|
1077
|
+
await transition.finished;
|
|
1078
|
+
} else {
|
|
1079
|
+
await __reRenderAppInner(props);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
async function __reRenderAppInner(props) {
|
|
1083
|
+
const { json, navigationType, runHistoryOptions } = props;
|
|
1084
|
+
const stateKeys = [
|
|
1085
|
+
"outermostServerError",
|
|
1086
|
+
"outermostServerErrorIdx",
|
|
1087
|
+
"errorExportKeys",
|
|
1088
|
+
"matchedPatterns",
|
|
1089
|
+
"loadersData",
|
|
1090
|
+
"importURLs",
|
|
1091
|
+
"exportKeys",
|
|
1092
|
+
"hasRootData",
|
|
1093
|
+
"params",
|
|
1094
|
+
"splatValues"
|
|
1095
|
+
];
|
|
1096
|
+
for (const key of stateKeys) {
|
|
1097
|
+
__vormaClientGlobal.set(key, json[key]);
|
|
1098
|
+
}
|
|
1099
|
+
deriveAndSetErrorState();
|
|
1100
|
+
await ComponentLoader.handleComponents(json.importURLs);
|
|
1101
|
+
await ComponentLoader.handleErrorBoundaryComponent(json.importURLs);
|
|
1102
|
+
let scrollStateToDispatch;
|
|
1103
|
+
if (runHistoryOptions) {
|
|
1104
|
+
const { href, scrollStateToRestore, replace, scrollToTop } = runHistoryOptions;
|
|
1105
|
+
const hash = href.split("#")[1];
|
|
1106
|
+
const history2 = HistoryManager.getInstance();
|
|
1107
|
+
if (navigationType === "userNavigation" || navigationType === "redirect") {
|
|
1108
|
+
const target = new URL(href, window.location.href).href;
|
|
1109
|
+
const current = new URL(window.location.href).href;
|
|
1110
|
+
if (target !== current && !replace) {
|
|
1111
|
+
history2.push(href, runHistoryOptions.state);
|
|
1112
|
+
} else {
|
|
1113
|
+
history2.replace(href, runHistoryOptions.state);
|
|
1114
|
+
}
|
|
1115
|
+
scrollStateToDispatch = hash ? { hash } : scrollToTop !== false ? { x: 0, y: 0 } : void 0;
|
|
1116
|
+
}
|
|
1117
|
+
if (navigationType === "browserHistory") {
|
|
1118
|
+
scrollStateToDispatch = scrollStateToRestore ?? (hash ? { hash } : void 0);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
if (json.title !== void 0) {
|
|
1122
|
+
const tempTxt = document.createElement("textarea");
|
|
1123
|
+
tempTxt.innerHTML = json.title?.dangerousInnerHTML || "";
|
|
1124
|
+
if (document.title !== tempTxt.value) {
|
|
1125
|
+
document.title = tempTxt.value;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
if (json.cssBundles) {
|
|
1129
|
+
AssetManager.applyCSS(json.cssBundles);
|
|
1130
|
+
}
|
|
1131
|
+
dispatchRouteChangeEvent({ __scrollState: scrollStateToDispatch });
|
|
1132
|
+
if (json.metaHeadEls !== void 0) {
|
|
1133
|
+
updateHeadEls("meta", json.metaHeadEls ?? []);
|
|
1134
|
+
}
|
|
1135
|
+
if (json.restHeadEls !== void 0) {
|
|
1136
|
+
updateHeadEls("rest", json.restHeadEls ?? []);
|
|
1137
|
+
}
|
|
1138
|
+
props.onFinish();
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// internal/framework/_typescript/client/src/client.ts
|
|
1142
|
+
var NavigationStateManager = class {
|
|
1143
|
+
_navigations = /* @__PURE__ */ new Map();
|
|
1144
|
+
_submissions = /* @__PURE__ */ new Map();
|
|
1145
|
+
lastDispatchedStatus = null;
|
|
1146
|
+
dispatchStatusEventDebounced;
|
|
1147
|
+
REVALIDATION_COALESCE_MS = 8;
|
|
1148
|
+
constructor() {
|
|
1149
|
+
this.dispatchStatusEventDebounced = debounce(() => {
|
|
1150
|
+
this.dispatchStatusEvent();
|
|
1151
|
+
}, 8);
|
|
1152
|
+
}
|
|
1153
|
+
async navigate(props) {
|
|
1154
|
+
const control = this.beginNavigation(props);
|
|
1155
|
+
try {
|
|
1156
|
+
const result = await control.promise;
|
|
1157
|
+
if (!result) {
|
|
1158
|
+
return { didNavigate: false };
|
|
1159
|
+
}
|
|
1160
|
+
const targetUrl = new URL(props.href, window.location.href).href;
|
|
1161
|
+
const entry = this._navigations.get(targetUrl);
|
|
1162
|
+
if (!entry) {
|
|
1163
|
+
return { didNavigate: false };
|
|
1164
|
+
}
|
|
1165
|
+
if (entry.intent === "navigate" || entry.intent === "revalidate") {
|
|
1166
|
+
const now = Date.now();
|
|
1167
|
+
lastTriggeredNavOrRevalidateTimestampMS = now;
|
|
1168
|
+
}
|
|
1169
|
+
await this.processNavigationResult(result, entry);
|
|
1170
|
+
if (entry.intent === "none" && entry.type === "prefetch") {
|
|
1171
|
+
return { didNavigate: false };
|
|
1172
|
+
}
|
|
1173
|
+
} catch (error) {
|
|
1174
|
+
const targetUrl = new URL(props.href, window.location.href).href;
|
|
1175
|
+
this.deleteNavigation(targetUrl);
|
|
1176
|
+
if (!isAbortError(error)) {
|
|
1177
|
+
logError("Navigate error:", error);
|
|
1178
|
+
}
|
|
1179
|
+
return { didNavigate: false };
|
|
1180
|
+
}
|
|
1181
|
+
return { didNavigate: true };
|
|
1182
|
+
}
|
|
1183
|
+
beginNavigation(props) {
|
|
1184
|
+
const existing = this._navigations.get(
|
|
1185
|
+
new URL(props.href, window.location.href).href
|
|
1186
|
+
);
|
|
1187
|
+
switch (props.navigationType) {
|
|
1188
|
+
case "userNavigation":
|
|
1189
|
+
return this.beginUserNavigation(props, existing);
|
|
1190
|
+
case "prefetch":
|
|
1191
|
+
return this.beginPrefetch(props, existing);
|
|
1192
|
+
case "revalidation":
|
|
1193
|
+
return this.beginRevalidation(props);
|
|
1194
|
+
case "browserHistory":
|
|
1195
|
+
case "redirect":
|
|
1196
|
+
default:
|
|
1197
|
+
return this.createNavigation(props, "navigate");
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
beginUserNavigation(props, existing) {
|
|
1201
|
+
const targetUrl = new URL(props.href, window.location.href).href;
|
|
1202
|
+
this.abortAllNavigationsExcept(targetUrl);
|
|
1203
|
+
if (existing) {
|
|
1204
|
+
if (existing.type === "prefetch") {
|
|
1205
|
+
this.upgradeNavigation(targetUrl, {
|
|
1206
|
+
type: "userNavigation",
|
|
1207
|
+
intent: "navigate",
|
|
1208
|
+
scrollToTop: props.scrollToTop,
|
|
1209
|
+
replace: props.replace,
|
|
1210
|
+
state: props.state
|
|
1211
|
+
});
|
|
1212
|
+
return existing.control;
|
|
1213
|
+
}
|
|
1214
|
+
return existing.control;
|
|
1215
|
+
}
|
|
1216
|
+
return this.createNavigation(props, "navigate");
|
|
1217
|
+
}
|
|
1218
|
+
beginPrefetch(props, existing) {
|
|
1219
|
+
const targetUrl = new URL(props.href, window.location.href).href;
|
|
1220
|
+
if (existing) {
|
|
1221
|
+
return existing.control;
|
|
1222
|
+
}
|
|
1223
|
+
const currentUrl = new URL(window.location.href);
|
|
1224
|
+
const targetUrlObj = new URL(targetUrl);
|
|
1225
|
+
currentUrl.hash = "";
|
|
1226
|
+
targetUrlObj.hash = "";
|
|
1227
|
+
if (currentUrl.href === targetUrlObj.href) {
|
|
1228
|
+
return {
|
|
1229
|
+
abortController: new AbortController(),
|
|
1230
|
+
promise: Promise.resolve(void 0)
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
return this.createNavigation(props, "none");
|
|
1234
|
+
}
|
|
1235
|
+
beginRevalidation(props) {
|
|
1236
|
+
const currentUrl = window.location.href;
|
|
1237
|
+
const existing = this._navigations.get(currentUrl);
|
|
1238
|
+
if (existing?.type === "revalidation" && Date.now() - existing.startTime < this.REVALIDATION_COALESCE_MS) {
|
|
1239
|
+
return existing.control;
|
|
1240
|
+
}
|
|
1241
|
+
for (const [key, nav] of this._navigations.entries()) {
|
|
1242
|
+
if (nav.type === "revalidation") {
|
|
1243
|
+
nav.control.abortController?.abort();
|
|
1244
|
+
this.deleteNavigation(key);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return this.createNavigation(
|
|
1248
|
+
{ ...props, href: currentUrl },
|
|
1249
|
+
"revalidate"
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
createNavigation(props, intent) {
|
|
1253
|
+
const controller = new AbortController();
|
|
1254
|
+
const targetUrl = new URL(props.href, window.location.href).href;
|
|
1255
|
+
const entry = {
|
|
1256
|
+
control: {
|
|
1257
|
+
abortController: controller,
|
|
1258
|
+
promise: this.fetchRouteData(controller, props).catch(
|
|
1259
|
+
(error) => {
|
|
1260
|
+
this.deleteNavigation(targetUrl);
|
|
1261
|
+
throw error;
|
|
1262
|
+
}
|
|
1263
|
+
)
|
|
1264
|
+
},
|
|
1265
|
+
type: props.navigationType,
|
|
1266
|
+
intent,
|
|
1267
|
+
phase: "fetching",
|
|
1268
|
+
startTime: Date.now(),
|
|
1269
|
+
targetUrl,
|
|
1270
|
+
originUrl: window.location.href,
|
|
1271
|
+
scrollToTop: props.scrollToTop,
|
|
1272
|
+
replace: props.replace,
|
|
1273
|
+
state: props.state
|
|
1274
|
+
};
|
|
1275
|
+
this.setNavigation(targetUrl, entry);
|
|
1276
|
+
return entry.control;
|
|
1277
|
+
}
|
|
1278
|
+
upgradeNavigation(href, updates) {
|
|
1279
|
+
const existing = this._navigations.get(href);
|
|
1280
|
+
if (!existing) return;
|
|
1281
|
+
this.setNavigation(href, {
|
|
1282
|
+
...existing,
|
|
1283
|
+
...updates
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
transitionPhase(href, phase) {
|
|
1287
|
+
const existing = this._navigations.get(href);
|
|
1288
|
+
if (!existing) return;
|
|
1289
|
+
this.setNavigation(href, {
|
|
1290
|
+
...existing,
|
|
1291
|
+
phase
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
canSkipServerFetch(targetUrl) {
|
|
1295
|
+
const routeManifest = __vormaClientGlobal.get("routeManifest");
|
|
1296
|
+
if (!routeManifest) {
|
|
1297
|
+
return { canSkip: false };
|
|
1298
|
+
}
|
|
1299
|
+
const patternRegistry = __vormaClientGlobal.get("patternRegistry");
|
|
1300
|
+
if (!patternRegistry) {
|
|
1301
|
+
return { canSkip: false };
|
|
1302
|
+
}
|
|
1303
|
+
const patternToWaitFnMap = __vormaClientGlobal.get("patternToWaitFnMap") || {};
|
|
1304
|
+
const url = new URL(targetUrl);
|
|
1305
|
+
const matchResult = findNestedMatches2(patternRegistry, url.pathname);
|
|
1306
|
+
if (!matchResult) {
|
|
1307
|
+
return { canSkip: false };
|
|
1308
|
+
}
|
|
1309
|
+
const clientModuleMap = __vormaClientGlobal.get("clientModuleMap") || {};
|
|
1310
|
+
const currentMatchedPatterns = __vormaClientGlobal.get("matchedPatterns") || [];
|
|
1311
|
+
const currentParams = __vormaClientGlobal.get("params") || {};
|
|
1312
|
+
const currentSplatValues = __vormaClientGlobal.get("splatValues") || [];
|
|
1313
|
+
const currentLoadersData = __vormaClientGlobal.get("loadersData") || [];
|
|
1314
|
+
for (const pattern of currentMatchedPatterns) {
|
|
1315
|
+
const hasServerLoader = routeManifest[pattern] === 1;
|
|
1316
|
+
if (hasServerLoader) {
|
|
1317
|
+
const stillMatched = matchResult.matches.some(
|
|
1318
|
+
(m) => m.registeredPattern.originalPattern === pattern
|
|
1319
|
+
);
|
|
1320
|
+
if (!stillMatched) {
|
|
1321
|
+
return { canSkip: false };
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
for (const m of matchResult.matches) {
|
|
1326
|
+
const pattern = m.registeredPattern.originalPattern;
|
|
1327
|
+
const hasClientLoader = !!patternToWaitFnMap[pattern];
|
|
1328
|
+
const wasAlreadyMatched = currentMatchedPatterns.includes(pattern);
|
|
1329
|
+
if (hasClientLoader && !wasAlreadyMatched) {
|
|
1330
|
+
return { canSkip: false };
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
let outermostLoaderIndex = -1;
|
|
1334
|
+
for (let i = matchResult.matches.length - 1; i >= 0; i--) {
|
|
1335
|
+
const match = matchResult.matches[i];
|
|
1336
|
+
if (!match) continue;
|
|
1337
|
+
const pattern = match.registeredPattern.originalPattern;
|
|
1338
|
+
const hasServerLoader = routeManifest[pattern] === 1;
|
|
1339
|
+
const hasClientLoader = !!patternToWaitFnMap[pattern];
|
|
1340
|
+
if (hasServerLoader || hasClientLoader) {
|
|
1341
|
+
outermostLoaderIndex = i;
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
const currentUrlObj = new URL(window.location.href);
|
|
1346
|
+
const currentParamsSorted = Array.from(
|
|
1347
|
+
currentUrlObj.searchParams.entries()
|
|
1348
|
+
).sort();
|
|
1349
|
+
const targetParamsSorted = Array.from(
|
|
1350
|
+
url.searchParams.entries()
|
|
1351
|
+
).sort();
|
|
1352
|
+
const searchChanged = !jsonDeepEquals2(
|
|
1353
|
+
currentParamsSorted,
|
|
1354
|
+
targetParamsSorted
|
|
1355
|
+
);
|
|
1356
|
+
if (searchChanged && outermostLoaderIndex !== -1) {
|
|
1357
|
+
return { canSkip: false };
|
|
1358
|
+
}
|
|
1359
|
+
if (outermostLoaderIndex !== -1) {
|
|
1360
|
+
const outermostMatch = matchResult.matches[outermostLoaderIndex];
|
|
1361
|
+
if (outermostMatch) {
|
|
1362
|
+
for (const seg of outermostMatch.registeredPattern.normalizedSegments) {
|
|
1363
|
+
if (seg.segType === "dynamic") {
|
|
1364
|
+
const paramName = seg.normalizedVal.substring(1);
|
|
1365
|
+
if (matchResult.params[paramName] !== currentParams[paramName]) {
|
|
1366
|
+
return { canSkip: false };
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
const hasSplat = outermostMatch.registeredPattern.lastSegType === "splat";
|
|
1371
|
+
if (hasSplat) {
|
|
1372
|
+
if (!jsonDeepEquals2(
|
|
1373
|
+
matchResult.splatValues,
|
|
1374
|
+
currentSplatValues
|
|
1375
|
+
)) {
|
|
1376
|
+
return { canSkip: false };
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const importURLs = [];
|
|
1382
|
+
const exportKeys = [];
|
|
1383
|
+
const loadersData = [];
|
|
1384
|
+
for (let i = 0; i < matchResult.matches.length; i++) {
|
|
1385
|
+
const match = matchResult.matches[i];
|
|
1386
|
+
if (!match) continue;
|
|
1387
|
+
const pattern = match.registeredPattern.originalPattern;
|
|
1388
|
+
const moduleInfo = clientModuleMap[pattern];
|
|
1389
|
+
if (!moduleInfo) {
|
|
1390
|
+
return { canSkip: false };
|
|
1391
|
+
}
|
|
1392
|
+
importURLs.push(moduleInfo.importURL);
|
|
1393
|
+
exportKeys.push(moduleInfo.exportKey);
|
|
1394
|
+
const hasServerLoader = routeManifest[pattern] === 1;
|
|
1395
|
+
if (!hasServerLoader) {
|
|
1396
|
+
loadersData.push(void 0);
|
|
1397
|
+
} else {
|
|
1398
|
+
const currentPatternIndex = currentMatchedPatterns.indexOf(pattern);
|
|
1399
|
+
if (currentPatternIndex === -1) {
|
|
1400
|
+
return { canSkip: false };
|
|
1401
|
+
}
|
|
1402
|
+
loadersData.push(currentLoadersData[currentPatternIndex]);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return {
|
|
1406
|
+
canSkip: true,
|
|
1407
|
+
matchResult,
|
|
1408
|
+
importURLs,
|
|
1409
|
+
exportKeys,
|
|
1410
|
+
loadersData
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
async fetchRouteData(controller, props) {
|
|
1414
|
+
try {
|
|
1415
|
+
const url = new URL(props.href, window.location.href);
|
|
1416
|
+
if (props.navigationType !== "revalidation" && props.navigationType !== "action") {
|
|
1417
|
+
const skipCheck = this.canSkipServerFetch(url.href);
|
|
1418
|
+
if (skipCheck.canSkip && skipCheck.matchResult) {
|
|
1419
|
+
const { importURLs, exportKeys, loadersData } = skipCheck;
|
|
1420
|
+
const json2 = {
|
|
1421
|
+
matchedPatterns: skipCheck.matchResult.matches.map(
|
|
1422
|
+
(m) => m.registeredPattern.originalPattern
|
|
1423
|
+
),
|
|
1424
|
+
loadersData,
|
|
1425
|
+
importURLs,
|
|
1426
|
+
exportKeys,
|
|
1427
|
+
hasRootData: __vormaClientGlobal.get("hasRootData"),
|
|
1428
|
+
params: skipCheck.matchResult.params,
|
|
1429
|
+
splatValues: skipCheck.matchResult.splatValues,
|
|
1430
|
+
deps: [],
|
|
1431
|
+
cssBundles: [],
|
|
1432
|
+
outermostServerError: void 0,
|
|
1433
|
+
outermostServerErrorIdx: void 0,
|
|
1434
|
+
errorExportKeys: [],
|
|
1435
|
+
title: void 0,
|
|
1436
|
+
metaHeadEls: void 0,
|
|
1437
|
+
restHeadEls: void 0,
|
|
1438
|
+
activeComponents: void 0
|
|
1439
|
+
};
|
|
1440
|
+
const response2 = new Response(JSON.stringify(json2), {
|
|
1441
|
+
status: 200,
|
|
1442
|
+
headers: {
|
|
1443
|
+
"Content-Type": "application/json",
|
|
1444
|
+
"X-Vorma-Build-Id": __vormaClientGlobal.get("buildID") || "1"
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
const currentClientLoadersData = __vormaClientGlobal.get("clientLoadersData") || [];
|
|
1448
|
+
const patternToWaitFnMap2 = __vormaClientGlobal.get("patternToWaitFnMap") || {};
|
|
1449
|
+
const runningLoaders2 = /* @__PURE__ */ new Map();
|
|
1450
|
+
for (let i = 0; i < json2.matchedPatterns.length; i++) {
|
|
1451
|
+
const pattern = json2.matchedPatterns[i];
|
|
1452
|
+
if (!pattern) continue;
|
|
1453
|
+
if (patternToWaitFnMap2[pattern]) {
|
|
1454
|
+
const currentMatchedPatterns = __vormaClientGlobal.get("matchedPatterns") || [];
|
|
1455
|
+
const currentPatternIndex = currentMatchedPatterns.indexOf(pattern);
|
|
1456
|
+
if (currentPatternIndex !== -1 && currentClientLoadersData[currentPatternIndex] !== void 0) {
|
|
1457
|
+
runningLoaders2.set(
|
|
1458
|
+
pattern,
|
|
1459
|
+
Promise.resolve(
|
|
1460
|
+
currentClientLoadersData[currentPatternIndex]
|
|
1461
|
+
)
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
const waitFnPromise2 = completeClientLoaders(
|
|
1467
|
+
json2,
|
|
1468
|
+
__vormaClientGlobal.get("buildID") || "1",
|
|
1469
|
+
runningLoaders2,
|
|
1470
|
+
controller.signal
|
|
1471
|
+
);
|
|
1472
|
+
return {
|
|
1473
|
+
response: response2,
|
|
1474
|
+
props,
|
|
1475
|
+
json: json2,
|
|
1476
|
+
cssBundlePromises: [],
|
|
1477
|
+
waitFnPromise: waitFnPromise2
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
url.searchParams.set(
|
|
1482
|
+
"vorma_json",
|
|
1483
|
+
__vormaClientGlobal.get("buildID") || "1"
|
|
1484
|
+
);
|
|
1485
|
+
if (props.navigationType === "revalidation") {
|
|
1486
|
+
const deploymentID = __vormaClientGlobal.get("deploymentID");
|
|
1487
|
+
if (deploymentID) {
|
|
1488
|
+
url.searchParams.set("dpl", deploymentID);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
const serverPromise = handleRedirects({
|
|
1492
|
+
abortController: controller,
|
|
1493
|
+
url,
|
|
1494
|
+
isPrefetch: props.navigationType === "prefetch",
|
|
1495
|
+
redirectCount: props.redirectCount
|
|
1496
|
+
}).then(async (result) => {
|
|
1497
|
+
if (result.response && result.response.ok && !result.redirectData?.status) {
|
|
1498
|
+
const json2 = await result.response.json();
|
|
1499
|
+
return { ...result, json: json2 };
|
|
1500
|
+
}
|
|
1501
|
+
return { ...result, json: void 0 };
|
|
1502
|
+
});
|
|
1503
|
+
const pathname = url.pathname;
|
|
1504
|
+
const matchResult = await findPartialMatchesOnClient(pathname);
|
|
1505
|
+
const patternToWaitFnMap = __vormaClientGlobal.get("patternToWaitFnMap");
|
|
1506
|
+
const runningLoaders = /* @__PURE__ */ new Map();
|
|
1507
|
+
if (matchResult) {
|
|
1508
|
+
const { params, splatValues, matches } = matchResult;
|
|
1509
|
+
for (let i = 0; i < matches.length; i++) {
|
|
1510
|
+
const match = matches[i];
|
|
1511
|
+
if (!match) continue;
|
|
1512
|
+
const pattern = match.registeredPattern.originalPattern;
|
|
1513
|
+
const loaderFn = patternToWaitFnMap[pattern];
|
|
1514
|
+
if (loaderFn) {
|
|
1515
|
+
const serverDataPromise = serverPromise.then(
|
|
1516
|
+
({
|
|
1517
|
+
response: response2,
|
|
1518
|
+
json: json2
|
|
1519
|
+
}) => {
|
|
1520
|
+
if (!response2 || !response2.ok || !json2) {
|
|
1521
|
+
return {
|
|
1522
|
+
matchedPatterns: [],
|
|
1523
|
+
loaderData: void 0,
|
|
1524
|
+
rootData: null,
|
|
1525
|
+
buildID: "1"
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
const serverIdx = json2.matchedPatterns?.indexOf(pattern);
|
|
1529
|
+
const loaderData = serverIdx !== -1 && serverIdx !== void 0 ? json2.loadersData[serverIdx] : void 0;
|
|
1530
|
+
const rootData = json2.hasRootData ? json2.loadersData[0] : null;
|
|
1531
|
+
const buildID2 = getBuildIDFromResponse(response2) || "1";
|
|
1532
|
+
return {
|
|
1533
|
+
matchedPatterns: json2.matchedPatterns || [],
|
|
1534
|
+
loaderData,
|
|
1535
|
+
rootData,
|
|
1536
|
+
buildID: buildID2
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
).catch(() => ({
|
|
1540
|
+
matchedPatterns: [],
|
|
1541
|
+
loaderData: void 0,
|
|
1542
|
+
rootData: null,
|
|
1543
|
+
buildID: "1"
|
|
1544
|
+
}));
|
|
1545
|
+
const loaderPromise = loaderFn({
|
|
1546
|
+
params,
|
|
1547
|
+
splatValues,
|
|
1548
|
+
serverDataPromise,
|
|
1549
|
+
signal: controller.signal
|
|
1550
|
+
});
|
|
1551
|
+
runningLoaders.set(pattern, loaderPromise);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
const { redirectData, response, json } = await serverPromise;
|
|
1556
|
+
const redirected = redirectData?.status === "did";
|
|
1557
|
+
const responseNotOK = !response?.ok && response?.status !== 304;
|
|
1558
|
+
if (redirected || !response) {
|
|
1559
|
+
controller.abort();
|
|
1560
|
+
return void 0;
|
|
1561
|
+
}
|
|
1562
|
+
if (responseNotOK) {
|
|
1563
|
+
controller.abort();
|
|
1564
|
+
throw new Error(`Fetch failed with status ${response.status}`);
|
|
1565
|
+
}
|
|
1566
|
+
if (redirectData?.status === "should") {
|
|
1567
|
+
controller.abort();
|
|
1568
|
+
return { response, redirectData, props };
|
|
1569
|
+
}
|
|
1570
|
+
if (!json) {
|
|
1571
|
+
controller.abort();
|
|
1572
|
+
throw new Error("No JSON response");
|
|
1573
|
+
}
|
|
1574
|
+
const depsToPreload = import.meta.env.DEV ? [...new Set(json.importURLs)] : json.deps;
|
|
1575
|
+
for (const dep of depsToPreload ?? []) {
|
|
1576
|
+
if (dep) AssetManager.preloadModule(dep);
|
|
1577
|
+
}
|
|
1578
|
+
const buildID = getBuildIDFromResponse(response);
|
|
1579
|
+
const waitFnPromise = completeClientLoaders(
|
|
1580
|
+
json,
|
|
1581
|
+
buildID,
|
|
1582
|
+
runningLoaders,
|
|
1583
|
+
controller.signal
|
|
1584
|
+
);
|
|
1585
|
+
const cssBundlePromises = [];
|
|
1586
|
+
for (const bundle of json.cssBundles ?? []) {
|
|
1587
|
+
cssBundlePromises.push(AssetManager.preloadCSS(bundle));
|
|
1588
|
+
}
|
|
1589
|
+
return { response, json, props, cssBundlePromises, waitFnPromise };
|
|
1590
|
+
} catch (error) {
|
|
1591
|
+
if (!isAbortError(error)) {
|
|
1592
|
+
logError("Navigation failed", error);
|
|
1593
|
+
}
|
|
1594
|
+
throw error;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
async processNavigationResult(result, entry) {
|
|
1598
|
+
try {
|
|
1599
|
+
if (!result) return;
|
|
1600
|
+
if ("redirectData" in result) {
|
|
1601
|
+
if (entry.type === "prefetch" && entry.intent === "none") {
|
|
1602
|
+
this.deleteNavigation(entry.targetUrl);
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
this.deleteNavigation(entry.targetUrl);
|
|
1606
|
+
await effectuateRedirectDataResult(
|
|
1607
|
+
result.redirectData,
|
|
1608
|
+
result.props.redirectCount || 0,
|
|
1609
|
+
result.props
|
|
1610
|
+
);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
if (!("json" in result)) {
|
|
1614
|
+
logError("Invalid navigation result: no JSON or redirect");
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const currentBuildID = __vormaClientGlobal.get("buildID");
|
|
1618
|
+
const responseBuildID = getBuildIDFromResponse(result.response);
|
|
1619
|
+
if (responseBuildID === currentBuildID) {
|
|
1620
|
+
const clientModuleMap = __vormaClientGlobal.get("clientModuleMap") || {};
|
|
1621
|
+
const matchedPatterns = result.json.matchedPatterns || [];
|
|
1622
|
+
const importURLs = result.json.importURLs || [];
|
|
1623
|
+
const exportKeys = result.json.exportKeys || [];
|
|
1624
|
+
const errorExportKeys = result.json.errorExportKeys || [];
|
|
1625
|
+
for (let i = 0; i < matchedPatterns.length; i++) {
|
|
1626
|
+
const pattern = matchedPatterns[i];
|
|
1627
|
+
const importURL = importURLs[i];
|
|
1628
|
+
const exportKey = exportKeys[i];
|
|
1629
|
+
const errorExportKey = errorExportKeys[i];
|
|
1630
|
+
if (pattern && importURL) {
|
|
1631
|
+
clientModuleMap[pattern] = {
|
|
1632
|
+
importURL,
|
|
1633
|
+
exportKey: exportKey || "default",
|
|
1634
|
+
errorExportKey: errorExportKey || ""
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
__vormaClientGlobal.set("clientModuleMap", clientModuleMap);
|
|
1639
|
+
if (result.json.cssBundles && result.json.cssBundles.length > 0) {
|
|
1640
|
+
AssetManager.applyCSS(result.json.cssBundles);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
if (entry.type === "revalidation") {
|
|
1644
|
+
const currentUrl = window.location.href;
|
|
1645
|
+
if (currentUrl !== entry.originUrl) {
|
|
1646
|
+
this.deleteNavigation(entry.targetUrl);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
this.transitionPhase(entry.targetUrl, "waiting");
|
|
1651
|
+
if (!this._navigations.has(entry.targetUrl)) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
const oldID = __vormaClientGlobal.get("buildID");
|
|
1655
|
+
const newID = getBuildIDFromResponse(result.response);
|
|
1656
|
+
if (newID && newID !== oldID) {
|
|
1657
|
+
dispatchBuildIDEvent({ newID, oldID });
|
|
1658
|
+
}
|
|
1659
|
+
const clientLoadersResult = await result.waitFnPromise;
|
|
1660
|
+
setClientLoadersState(clientLoadersResult);
|
|
1661
|
+
if (result.cssBundlePromises.length > 0) {
|
|
1662
|
+
try {
|
|
1663
|
+
await Promise.all(result.cssBundlePromises);
|
|
1664
|
+
} catch (error) {
|
|
1665
|
+
logError("Error preloading CSS bundles:", error);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
if (entry.intent === "none") {
|
|
1669
|
+
this.transitionPhase(entry.targetUrl, "complete");
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (entry.type === "revalidation" && window.location.href !== entry.originUrl) {
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
this.transitionPhase(entry.targetUrl, "rendering");
|
|
1676
|
+
try {
|
|
1677
|
+
await __reRenderApp({
|
|
1678
|
+
json: result.json,
|
|
1679
|
+
navigationType: entry.type,
|
|
1680
|
+
runHistoryOptions: entry.intent === "navigate" ? {
|
|
1681
|
+
href: entry.targetUrl,
|
|
1682
|
+
scrollStateToRestore: result.props.scrollStateToRestore,
|
|
1683
|
+
replace: entry.replace || result.props.replace,
|
|
1684
|
+
scrollToTop: entry.scrollToTop,
|
|
1685
|
+
state: entry.state
|
|
1686
|
+
} : void 0,
|
|
1687
|
+
onFinish: () => {
|
|
1688
|
+
this.transitionPhase(entry.targetUrl, "complete");
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
} catch (error) {
|
|
1692
|
+
this.transitionPhase(entry.targetUrl, "complete");
|
|
1693
|
+
if (!isAbortError(error)) {
|
|
1694
|
+
logError("Error completing navigation", error);
|
|
1695
|
+
}
|
|
1696
|
+
throw error;
|
|
1697
|
+
}
|
|
1698
|
+
} finally {
|
|
1699
|
+
if (!(entry.type === "prefetch" && entry.intent === "none")) {
|
|
1700
|
+
this.deleteNavigation(entry.targetUrl);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
async submit(url, requestInit, options) {
|
|
1705
|
+
const abortController = new AbortController();
|
|
1706
|
+
const submissionKey = options?.dedupeKey ? `submission:${options.dedupeKey}` : Symbol("submission");
|
|
1707
|
+
if (typeof submissionKey === "string") {
|
|
1708
|
+
const existing = this._submissions.get(submissionKey);
|
|
1709
|
+
if (existing) {
|
|
1710
|
+
existing.control.abortController?.abort("deduped");
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
const entry = {
|
|
1714
|
+
control: {
|
|
1715
|
+
abortController,
|
|
1716
|
+
promise: Promise.resolve()
|
|
1717
|
+
},
|
|
1718
|
+
startTime: Date.now(),
|
|
1719
|
+
skipGlobalLoadingIndicator: options?.skipGlobalLoadingIndicator
|
|
1720
|
+
};
|
|
1721
|
+
this._submissions.set(submissionKey, entry);
|
|
1722
|
+
this.scheduleStatusUpdate();
|
|
1723
|
+
try {
|
|
1724
|
+
const urlToUse = new URL(url, window.location.href);
|
|
1725
|
+
const headers = new Headers(requestInit?.headers);
|
|
1726
|
+
const deploymentID = __vormaClientGlobal.get("deploymentID");
|
|
1727
|
+
if (deploymentID) {
|
|
1728
|
+
headers.set("x-deployment-id", deploymentID);
|
|
1729
|
+
}
|
|
1730
|
+
const finalRequestInit = {
|
|
1731
|
+
...requestInit,
|
|
1732
|
+
headers,
|
|
1733
|
+
signal: abortController.signal
|
|
1734
|
+
};
|
|
1735
|
+
const { redirectData, response } = await handleRedirects({
|
|
1736
|
+
abortController,
|
|
1737
|
+
url: urlToUse,
|
|
1738
|
+
isPrefetch: false,
|
|
1739
|
+
redirectCount: 0,
|
|
1740
|
+
requestInit: finalRequestInit
|
|
1741
|
+
});
|
|
1742
|
+
const oldID = __vormaClientGlobal.get("buildID");
|
|
1743
|
+
const newID = getBuildIDFromResponse(response);
|
|
1744
|
+
if (newID && newID !== oldID) {
|
|
1745
|
+
dispatchBuildIDEvent({ newID, oldID });
|
|
1746
|
+
}
|
|
1747
|
+
if (!response || !response.ok) {
|
|
1748
|
+
return {
|
|
1749
|
+
success: false,
|
|
1750
|
+
error: String(response?.status || "unknown")
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
if (redirectData?.status === "should") {
|
|
1754
|
+
await effectuateRedirectDataResult(redirectData, 0);
|
|
1755
|
+
return { success: true, data: void 0 };
|
|
1756
|
+
}
|
|
1757
|
+
const data = await response.json();
|
|
1758
|
+
const isGET = getIsGETRequest2(requestInit);
|
|
1759
|
+
const redirected = redirectData?.status === "did";
|
|
1760
|
+
if (!isGET && !redirected && options?.revalidate !== false) {
|
|
1761
|
+
await revalidate();
|
|
1762
|
+
}
|
|
1763
|
+
return { success: true, data };
|
|
1764
|
+
} catch (error) {
|
|
1765
|
+
if (isAbortError(error)) {
|
|
1766
|
+
return { success: false, error: "Aborted" };
|
|
1767
|
+
}
|
|
1768
|
+
logError(error);
|
|
1769
|
+
return {
|
|
1770
|
+
success: false,
|
|
1771
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
1772
|
+
};
|
|
1773
|
+
} finally {
|
|
1774
|
+
this._submissions.delete(submissionKey);
|
|
1775
|
+
this.scheduleStatusUpdate();
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
setNavigation(key, entry) {
|
|
1779
|
+
this._navigations.set(key, entry);
|
|
1780
|
+
this.scheduleStatusUpdate();
|
|
1781
|
+
}
|
|
1782
|
+
deleteNavigation(key) {
|
|
1783
|
+
const result = this._navigations.delete(key);
|
|
1784
|
+
if (result) {
|
|
1785
|
+
this.scheduleStatusUpdate();
|
|
1786
|
+
}
|
|
1787
|
+
return result;
|
|
1788
|
+
}
|
|
1789
|
+
removeNavigation(key) {
|
|
1790
|
+
this.deleteNavigation(key);
|
|
1791
|
+
}
|
|
1792
|
+
getNavigation(key) {
|
|
1793
|
+
return this._navigations.get(key);
|
|
1794
|
+
}
|
|
1795
|
+
hasNavigation(key) {
|
|
1796
|
+
return this._navigations.has(key);
|
|
1797
|
+
}
|
|
1798
|
+
getNavigationsSize() {
|
|
1799
|
+
return this._navigations.size;
|
|
1800
|
+
}
|
|
1801
|
+
getNavigations() {
|
|
1802
|
+
return this._navigations;
|
|
1803
|
+
}
|
|
1804
|
+
abortAllNavigationsExcept(excludeHref) {
|
|
1805
|
+
for (const [href, nav] of this._navigations.entries()) {
|
|
1806
|
+
if (href !== excludeHref) {
|
|
1807
|
+
nav.control.abortController?.abort();
|
|
1808
|
+
this.deleteNavigation(href);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
getStatus() {
|
|
1813
|
+
const navigations = Array.from(this._navigations.values());
|
|
1814
|
+
const submissions = Array.from(this._submissions.values());
|
|
1815
|
+
const isNavigating = navigations.some(
|
|
1816
|
+
(nav) => nav.intent === "navigate" && nav.phase !== "complete"
|
|
1817
|
+
);
|
|
1818
|
+
const isRevalidating = navigations.some(
|
|
1819
|
+
(nav) => nav.type === "revalidation" && nav.phase !== "complete"
|
|
1820
|
+
);
|
|
1821
|
+
const isSubmitting = submissions.some(
|
|
1822
|
+
(x) => !x.skipGlobalLoadingIndicator
|
|
1823
|
+
);
|
|
1824
|
+
return { isNavigating, isSubmitting, isRevalidating };
|
|
1825
|
+
}
|
|
1826
|
+
clearAll() {
|
|
1827
|
+
for (const nav of this._navigations.values()) {
|
|
1828
|
+
nav.control.abortController?.abort();
|
|
1829
|
+
}
|
|
1830
|
+
this._navigations.clear();
|
|
1831
|
+
for (const sub of this._submissions.values()) {
|
|
1832
|
+
sub.control.abortController?.abort();
|
|
1833
|
+
}
|
|
1834
|
+
this._submissions.clear();
|
|
1835
|
+
this.scheduleStatusUpdate();
|
|
1836
|
+
}
|
|
1837
|
+
scheduleStatusUpdate() {
|
|
1838
|
+
this.dispatchStatusEventDebounced();
|
|
1839
|
+
}
|
|
1840
|
+
dispatchStatusEvent() {
|
|
1841
|
+
const newStatus = this.getStatus();
|
|
1842
|
+
if (jsonDeepEquals2(this.lastDispatchedStatus, newStatus)) {
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
this.lastDispatchedStatus = newStatus;
|
|
1846
|
+
dispatchStatusEvent(newStatus);
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
var navigationStateManager = new NavigationStateManager();
|
|
1850
|
+
async function vormaNavigate(href, options) {
|
|
1851
|
+
const url = new URL(href, window.location.href);
|
|
1852
|
+
if (options?.search !== void 0) {
|
|
1853
|
+
url.search = options.search;
|
|
1854
|
+
}
|
|
1855
|
+
if (options?.hash !== void 0) {
|
|
1856
|
+
url.hash = options.hash;
|
|
1857
|
+
}
|
|
1858
|
+
await navigationStateManager.navigate({
|
|
1859
|
+
href: url.href,
|
|
1860
|
+
navigationType: "userNavigation",
|
|
1861
|
+
replace: options?.replace,
|
|
1862
|
+
scrollToTop: options?.scrollToTop,
|
|
1863
|
+
state: options?.state
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
var lastTriggeredNavOrRevalidateTimestampMS = Date.now();
|
|
1867
|
+
function getLastTriggeredNavOrRevalidateTimestampMS() {
|
|
1868
|
+
return lastTriggeredNavOrRevalidateTimestampMS;
|
|
1869
|
+
}
|
|
1870
|
+
async function revalidate() {
|
|
1871
|
+
await navigationStateManager.navigate({
|
|
1872
|
+
href: window.location.href,
|
|
1873
|
+
navigationType: "revalidation"
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
async function submit(url, requestInit, options) {
|
|
1877
|
+
return navigationStateManager.submit(url, requestInit, options);
|
|
1878
|
+
}
|
|
1879
|
+
function getStatus() {
|
|
1880
|
+
return navigationStateManager.getStatus();
|
|
1881
|
+
}
|
|
1882
|
+
function getLocation() {
|
|
1883
|
+
return {
|
|
1884
|
+
pathname: window.location.pathname,
|
|
1885
|
+
search: window.location.search,
|
|
1886
|
+
hash: window.location.hash,
|
|
1887
|
+
state: HistoryManager.getInstance().location.state
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
function getBuildID() {
|
|
1891
|
+
return __vormaClientGlobal.get("buildID");
|
|
1892
|
+
}
|
|
1893
|
+
function getRootEl() {
|
|
1894
|
+
return document.getElementById("vorma-root");
|
|
1895
|
+
}
|
|
1896
|
+
function getHistoryInstance() {
|
|
1897
|
+
return HistoryManager.getInstance();
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// internal/framework/_typescript/client/src/error_boundary.ts
|
|
1901
|
+
var defaultErrorBoundary = (props) => {
|
|
1902
|
+
return "Route Error: " + props.error;
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
// internal/framework/_typescript/client/src/global_loading_indicator/global_loading_indicator.ts
|
|
1906
|
+
var DEFAULT_DELAY = 12;
|
|
1907
|
+
function resolveIncludes(config, includesOption) {
|
|
1908
|
+
const isArray = Array.isArray(config.include);
|
|
1909
|
+
return isArray && config.include?.includes(includesOption);
|
|
1910
|
+
}
|
|
1911
|
+
function setupGlobalLoadingIndicator(config) {
|
|
1912
|
+
let gliDebounceStartTimer = null;
|
|
1913
|
+
let gliDebounceStopTimer = null;
|
|
1914
|
+
const includesAll = !config.include || config.include === "all";
|
|
1915
|
+
const pc = {
|
|
1916
|
+
includesAll,
|
|
1917
|
+
includesNavigations: resolveIncludes(config, "navigations") || includesAll,
|
|
1918
|
+
includesSubmissions: resolveIncludes(config, "submissions") || includesAll,
|
|
1919
|
+
includesRevalidations: resolveIncludes(config, "revalidations") || includesAll,
|
|
1920
|
+
startDelayMS: config.startDelayMS ?? DEFAULT_DELAY,
|
|
1921
|
+
stopDelayMS: config.stopDelayMS ?? DEFAULT_DELAY
|
|
1922
|
+
};
|
|
1923
|
+
function clearStartTimer() {
|
|
1924
|
+
if (gliDebounceStartTimer) {
|
|
1925
|
+
window.clearTimeout(gliDebounceStartTimer);
|
|
1926
|
+
gliDebounceStartTimer = null;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function clearStopTimer() {
|
|
1930
|
+
if (gliDebounceStopTimer) {
|
|
1931
|
+
window.clearTimeout(gliDebounceStopTimer);
|
|
1932
|
+
gliDebounceStopTimer = null;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
function clearTimers() {
|
|
1936
|
+
clearStartTimer();
|
|
1937
|
+
clearStopTimer();
|
|
1938
|
+
}
|
|
1939
|
+
function handleStatusChange(e) {
|
|
1940
|
+
const shouldBeWorking = getIsWorking(pc, e);
|
|
1941
|
+
if (shouldBeWorking) {
|
|
1942
|
+
clearStopTimer();
|
|
1943
|
+
if (!gliDebounceStartTimer) {
|
|
1944
|
+
gliDebounceStartTimer = window.setTimeout(() => {
|
|
1945
|
+
gliDebounceStartTimer = null;
|
|
1946
|
+
if (!config.isRunning() && getIsWorking(pc)) {
|
|
1947
|
+
config.start();
|
|
1948
|
+
}
|
|
1949
|
+
}, pc.startDelayMS);
|
|
1950
|
+
}
|
|
1951
|
+
} else {
|
|
1952
|
+
clearStartTimer();
|
|
1953
|
+
if (!gliDebounceStopTimer) {
|
|
1954
|
+
gliDebounceStopTimer = window.setTimeout(() => {
|
|
1955
|
+
gliDebounceStopTimer = null;
|
|
1956
|
+
if (config.isRunning() && !getIsWorking(pc)) {
|
|
1957
|
+
config.stop();
|
|
1958
|
+
}
|
|
1959
|
+
}, pc.stopDelayMS);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
handleStatusChange();
|
|
1964
|
+
const removeStatusListenerCallback = addStatusListener(handleStatusChange);
|
|
1965
|
+
return () => {
|
|
1966
|
+
removeStatusListenerCallback();
|
|
1967
|
+
clearTimers();
|
|
1968
|
+
if (config.isRunning()) {
|
|
1969
|
+
config.stop();
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
function getIsWorking(pc, e) {
|
|
1974
|
+
const status = e?.detail ?? getStatus();
|
|
1975
|
+
if (pc.includesAll) {
|
|
1976
|
+
return status.isNavigating || status.isSubmitting || status.isRevalidating;
|
|
1977
|
+
}
|
|
1978
|
+
if (pc.includesNavigations && status.isNavigating) {
|
|
1979
|
+
return true;
|
|
1980
|
+
}
|
|
1981
|
+
if (pc.includesSubmissions && status.isSubmitting) {
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1984
|
+
if (pc.includesRevalidations && status.isRevalidating) {
|
|
1985
|
+
return true;
|
|
1986
|
+
}
|
|
1987
|
+
return false;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
// internal/framework/_typescript/client/src/hmr/hmr.ts
|
|
1991
|
+
import { debounce as debounce2 } from "vorma/kit/debounce";
|
|
1992
|
+
var devTimeSetupClientLoadersDebounced = () => Promise.resolve();
|
|
1993
|
+
var hmrRevalidateSet;
|
|
1994
|
+
var __runClientLoadersAfterHMRUpdate = () => {
|
|
1995
|
+
};
|
|
1996
|
+
function initHMR() {
|
|
1997
|
+
if (import.meta.env.DEV) {
|
|
1998
|
+
window.__waveRevalidate = revalidate;
|
|
1999
|
+
devTimeSetupClientLoadersDebounced = debounce2(async () => {
|
|
2000
|
+
await setupClientLoaders();
|
|
2001
|
+
dispatchRouteChangeEvent({});
|
|
2002
|
+
}, 10);
|
|
2003
|
+
__runClientLoadersAfterHMRUpdate = (importMeta, pattern) => {
|
|
2004
|
+
if (hmrRevalidateSet === void 0) {
|
|
2005
|
+
hmrRevalidateSet = /* @__PURE__ */ new Set();
|
|
2006
|
+
}
|
|
2007
|
+
if (import.meta.env.DEV && import.meta.hot) {
|
|
2008
|
+
const thisURL = new URL(importMeta.url, location.href);
|
|
2009
|
+
thisURL.search = "";
|
|
2010
|
+
const thisPathname = thisURL.pathname;
|
|
2011
|
+
const alreadyRegistered = hmrRevalidateSet.has(thisPathname);
|
|
2012
|
+
if (alreadyRegistered) {
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
hmrRevalidateSet.add(thisPathname);
|
|
2016
|
+
import.meta.hot.on("vite:afterUpdate", (props) => {
|
|
2017
|
+
for (const update of props.updates) {
|
|
2018
|
+
if (update.type === "js-update") {
|
|
2019
|
+
const updateURL = new URL(
|
|
2020
|
+
update.path,
|
|
2021
|
+
location.href
|
|
2022
|
+
);
|
|
2023
|
+
updateURL.search = "";
|
|
2024
|
+
if (updateURL.pathname === thisURL.pathname) {
|
|
2025
|
+
if (__vormaClientGlobal.get("matchedPatterns").includes(pattern)) {
|
|
2026
|
+
logInfo(
|
|
2027
|
+
"Refreshing client loaders due to change in pattern:",
|
|
2028
|
+
pattern
|
|
2029
|
+
);
|
|
2030
|
+
devTimeSetupClientLoadersDebounced();
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
// internal/framework/_typescript/client/src/init_client.ts
|
|
2042
|
+
import {
|
|
2043
|
+
createPatternRegistry,
|
|
2044
|
+
registerPattern as registerPattern2
|
|
2045
|
+
} from "vorma/kit/matcher/register";
|
|
2046
|
+
async function initClient(options) {
|
|
2047
|
+
initHMR();
|
|
2048
|
+
window.addEventListener("beforeunload", () => {
|
|
2049
|
+
scrollStateManager.savePageRefreshState();
|
|
2050
|
+
});
|
|
2051
|
+
__vormaClientGlobal.set("vormaAppConfig", options.vormaAppConfig);
|
|
2052
|
+
const clientModuleMap = {};
|
|
2053
|
+
const initialMatchedPatterns = __vormaClientGlobal.get("matchedPatterns") || [];
|
|
2054
|
+
const initialImportURLs = __vormaClientGlobal.get("importURLs") || [];
|
|
2055
|
+
const initialExportKeys = __vormaClientGlobal.get("exportKeys") || [];
|
|
2056
|
+
const initialErrorExportKeys = __vormaClientGlobal.get("errorExportKeys") || [];
|
|
2057
|
+
for (let i = 0; i < initialMatchedPatterns.length; i++) {
|
|
2058
|
+
const pattern = initialMatchedPatterns[i];
|
|
2059
|
+
const importURL = initialImportURLs[i];
|
|
2060
|
+
const exportKey = initialExportKeys[i];
|
|
2061
|
+
const errorExportKey = initialErrorExportKeys[i];
|
|
2062
|
+
if (pattern && importURL) {
|
|
2063
|
+
clientModuleMap[pattern] = {
|
|
2064
|
+
importURL,
|
|
2065
|
+
exportKey: exportKey || "default",
|
|
2066
|
+
errorExportKey: errorExportKey || ""
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
__vormaClientGlobal.set("clientModuleMap", clientModuleMap);
|
|
2071
|
+
const patternRegistry = createPatternRegistry({
|
|
2072
|
+
dynamicParamPrefixRune: options.vormaAppConfig.loadersDynamicRune,
|
|
2073
|
+
splatSegmentRune: options.vormaAppConfig.loadersSplatRune,
|
|
2074
|
+
explicitIndexSegment: options.vormaAppConfig.loadersExplicitIndexSegment
|
|
2075
|
+
});
|
|
2076
|
+
__vormaClientGlobal.set("patternRegistry", patternRegistry);
|
|
2077
|
+
const manifestURL = __vormaClientGlobal.get("routeManifestURL");
|
|
2078
|
+
if (manifestURL) {
|
|
2079
|
+
fetch(manifestURL).then((response) => response.json()).then((manifest) => {
|
|
2080
|
+
__vormaClientGlobal.set("routeManifest", manifest);
|
|
2081
|
+
for (const pattern of Object.keys(manifest)) {
|
|
2082
|
+
registerPattern2(patternRegistry, pattern);
|
|
2083
|
+
}
|
|
2084
|
+
}).catch((error) => {
|
|
2085
|
+
console.warn("Failed to load route manifest:", error);
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
if (options.defaultErrorBoundary) {
|
|
2089
|
+
__vormaClientGlobal.set(
|
|
2090
|
+
"defaultErrorBoundary",
|
|
2091
|
+
options.defaultErrorBoundary
|
|
2092
|
+
);
|
|
2093
|
+
} else {
|
|
2094
|
+
__vormaClientGlobal.set("defaultErrorBoundary", defaultErrorBoundary);
|
|
2095
|
+
}
|
|
2096
|
+
if (options.useViewTransitions) {
|
|
2097
|
+
__vormaClientGlobal.set("useViewTransitions", true);
|
|
2098
|
+
}
|
|
2099
|
+
HistoryManager.init();
|
|
2100
|
+
const url = new URL(window.location.href);
|
|
2101
|
+
if (url.searchParams.has(VORMA_HARD_RELOAD_QUERY_PARAM)) {
|
|
2102
|
+
url.searchParams.delete(VORMA_HARD_RELOAD_QUERY_PARAM);
|
|
2103
|
+
HistoryManager.getInstance().replace(url.href);
|
|
2104
|
+
}
|
|
2105
|
+
const importURLs = __vormaClientGlobal.get("importURLs");
|
|
2106
|
+
await ComponentLoader.handleComponents(importURLs);
|
|
2107
|
+
await setupClientLoaders();
|
|
2108
|
+
await ComponentLoader.handleErrorBoundaryComponent(importURLs);
|
|
2109
|
+
options.renderFn();
|
|
2110
|
+
scrollStateManager.restorePageRefreshState();
|
|
2111
|
+
window.addEventListener(
|
|
2112
|
+
"touchstart",
|
|
2113
|
+
() => {
|
|
2114
|
+
__vormaClientGlobal.set("isTouchDevice", true);
|
|
2115
|
+
},
|
|
2116
|
+
{ once: true }
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
// internal/framework/_typescript/client/src/links.ts
|
|
2121
|
+
import { getAnchorDetailsFromEvent, getHrefDetails as getHrefDetails2 } from "vorma/kit/url";
|
|
2122
|
+
function __getPrefetchHandlers(input) {
|
|
2123
|
+
const hrefDetails = getHrefDetails2(input.href);
|
|
2124
|
+
if (!hrefDetails.isHTTP) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
const { relativeURL } = hrefDetails;
|
|
2128
|
+
if (!relativeURL || hrefDetails.isExternal) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
let timer;
|
|
2132
|
+
let prefetchStarted = false;
|
|
2133
|
+
const delayMs = input.delayMs ?? 100;
|
|
2134
|
+
async function prefetch(e) {
|
|
2135
|
+
if (prefetchStarted) return;
|
|
2136
|
+
prefetchStarted = true;
|
|
2137
|
+
if (input.beforeBegin) {
|
|
2138
|
+
await input.beforeBegin(e);
|
|
2139
|
+
}
|
|
2140
|
+
const fullUrl = new URL(relativeURL, window.location.href);
|
|
2141
|
+
if (input.search !== void 0) fullUrl.search = input.search;
|
|
2142
|
+
if (input.hash !== void 0) fullUrl.hash = input.hash;
|
|
2143
|
+
await navigationStateManager.navigate({
|
|
2144
|
+
href: fullUrl.href,
|
|
2145
|
+
navigationType: "prefetch",
|
|
2146
|
+
state: input.state
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
function start(e) {
|
|
2150
|
+
if (prefetchStarted) return;
|
|
2151
|
+
timer = window.setTimeout(() => prefetch(e), delayMs);
|
|
2152
|
+
}
|
|
2153
|
+
function stop() {
|
|
2154
|
+
if (timer) {
|
|
2155
|
+
clearTimeout(timer);
|
|
2156
|
+
timer = void 0;
|
|
2157
|
+
}
|
|
2158
|
+
const targetUrl = new URL(relativeURL, window.location.href).href;
|
|
2159
|
+
const nav = navigationStateManager.getNavigation(targetUrl);
|
|
2160
|
+
if (nav && nav.type === "prefetch" && nav.intent === "none") {
|
|
2161
|
+
nav.control.abortController?.abort();
|
|
2162
|
+
navigationStateManager.removeNavigation(targetUrl);
|
|
2163
|
+
}
|
|
2164
|
+
prefetchStarted = false;
|
|
2165
|
+
}
|
|
2166
|
+
async function onClick(e) {
|
|
2167
|
+
if (e.defaultPrevented) return;
|
|
2168
|
+
const anchorDetails = getAnchorDetailsFromEvent(
|
|
2169
|
+
e
|
|
2170
|
+
);
|
|
2171
|
+
if (!anchorDetails) return;
|
|
2172
|
+
const { isEligibleForDefaultPrevention, isInternal } = anchorDetails;
|
|
2173
|
+
if (!isEligibleForDefaultPrevention || !isInternal) return;
|
|
2174
|
+
if (isJustAHashChange(anchorDetails)) {
|
|
2175
|
+
saveScrollState();
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
e.preventDefault();
|
|
2179
|
+
if (timer) {
|
|
2180
|
+
clearTimeout(timer);
|
|
2181
|
+
timer = void 0;
|
|
2182
|
+
}
|
|
2183
|
+
if (input.beforeBegin && !prefetchStarted) {
|
|
2184
|
+
await input.beforeBegin(e);
|
|
2185
|
+
}
|
|
2186
|
+
if (input.beforeRender) {
|
|
2187
|
+
await input.beforeRender(e);
|
|
2188
|
+
}
|
|
2189
|
+
await vormaNavigate(relativeURL, {
|
|
2190
|
+
scrollToTop: input.scrollToTop,
|
|
2191
|
+
replace: input.replace,
|
|
2192
|
+
search: input.search,
|
|
2193
|
+
hash: input.hash,
|
|
2194
|
+
state: input.state
|
|
2195
|
+
});
|
|
2196
|
+
if (input.afterRender) {
|
|
2197
|
+
await input.afterRender(e);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return {
|
|
2201
|
+
...hrefDetails,
|
|
2202
|
+
start,
|
|
2203
|
+
stop,
|
|
2204
|
+
onClick
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
function __makeLinkOnClickFn(callbacks) {
|
|
2208
|
+
return async (e) => {
|
|
2209
|
+
if (e.defaultPrevented) return;
|
|
2210
|
+
const anchorDetails = getAnchorDetailsFromEvent(
|
|
2211
|
+
e
|
|
2212
|
+
);
|
|
2213
|
+
if (!anchorDetails) return;
|
|
2214
|
+
const { anchor, isEligibleForDefaultPrevention, isInternal } = anchorDetails;
|
|
2215
|
+
if (!anchor) return;
|
|
2216
|
+
if (isJustAHashChange(anchorDetails)) {
|
|
2217
|
+
saveScrollState();
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
if (isEligibleForDefaultPrevention && isInternal) {
|
|
2221
|
+
e.preventDefault();
|
|
2222
|
+
await callbacks.beforeBegin?.(e);
|
|
2223
|
+
const control = navigationStateManager.beginNavigation({
|
|
2224
|
+
href: anchor.href,
|
|
2225
|
+
navigationType: "userNavigation",
|
|
2226
|
+
scrollToTop: callbacks.scrollToTop,
|
|
2227
|
+
replace: callbacks.replace,
|
|
2228
|
+
state: callbacks.state
|
|
2229
|
+
});
|
|
2230
|
+
if (!control.promise) return;
|
|
2231
|
+
const res = await control.promise;
|
|
2232
|
+
if (!res) {
|
|
2233
|
+
const targetUrl2 = new URL(anchor.href, window.location.href).href;
|
|
2234
|
+
navigationStateManager.removeNavigation(targetUrl2);
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2237
|
+
await callbacks.beforeRender?.(e);
|
|
2238
|
+
const targetUrl = new URL(anchor.href, window.location.href).href;
|
|
2239
|
+
const entry = navigationStateManager.getNavigation(targetUrl);
|
|
2240
|
+
if (entry) {
|
|
2241
|
+
await navigationStateManager["processNavigationResult"](
|
|
2242
|
+
res,
|
|
2243
|
+
entry
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
await callbacks.afterRender?.(e);
|
|
2247
|
+
}
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2250
|
+
function isJustAHashChange(anchorDetails) {
|
|
2251
|
+
if (!anchorDetails) return false;
|
|
2252
|
+
const { pathname, search, hash } = new URL(
|
|
2253
|
+
anchorDetails.anchor.href,
|
|
2254
|
+
window.location.href
|
|
2255
|
+
);
|
|
2256
|
+
return !!(hash && pathname === window.location.pathname && search === window.location.search);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
// internal/framework/_typescript/client/src/static_route_defs/route_def_helpers.ts
|
|
2260
|
+
function route(pattern, importPromise, componentKey, errorBoundaryKey) {
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
// internal/framework/_typescript/client/src/vorma_app_helpers/vorma_app_helpers.ts
|
|
2264
|
+
import { serializeToSearchParams } from "vorma/kit/json";
|
|
2265
|
+
function buildQueryURL(vormaAppConfig, props) {
|
|
2266
|
+
return buildURL({ vormaAppConfig, props, type: "query" });
|
|
2267
|
+
}
|
|
2268
|
+
function buildMutationURL(vormaAppConfig, props) {
|
|
2269
|
+
return buildURL({ vormaAppConfig, props, type: "mutation" });
|
|
2270
|
+
}
|
|
2271
|
+
function resolveBody(props) {
|
|
2272
|
+
const { input } = props;
|
|
2273
|
+
if (input == null || typeof input === "string" || input instanceof Blob || input instanceof FormData || input instanceof URLSearchParams || input instanceof ReadableStream || input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {
|
|
2274
|
+
return input;
|
|
2275
|
+
}
|
|
2276
|
+
return JSON.stringify(input);
|
|
2277
|
+
}
|
|
2278
|
+
function buildURL(opts) {
|
|
2279
|
+
const base_path = stripTrailingSlash(
|
|
2280
|
+
opts.vormaAppConfig.actionsRouterMountRoot
|
|
2281
|
+
);
|
|
2282
|
+
const resolved_path = __resolvePath(opts);
|
|
2283
|
+
const url = new URL(base_path + resolved_path, getCurrentOrigin());
|
|
2284
|
+
if (opts.type === "query" && opts.props.input) {
|
|
2285
|
+
url.search = serializeToSearchParams(opts.props.input).toString();
|
|
2286
|
+
}
|
|
2287
|
+
return url;
|
|
2288
|
+
}
|
|
2289
|
+
function __resolvePath(opts) {
|
|
2290
|
+
const { props, vormaAppConfig } = opts;
|
|
2291
|
+
let path = props.pattern;
|
|
2292
|
+
let dynamicParamPrefixRune = vormaAppConfig.actionsDynamicRune;
|
|
2293
|
+
let splatSegmentRune = vormaAppConfig.actionsSplatRune;
|
|
2294
|
+
if (opts.type === "loader") {
|
|
2295
|
+
dynamicParamPrefixRune = vormaAppConfig.loadersDynamicRune;
|
|
2296
|
+
splatSegmentRune = vormaAppConfig.loadersSplatRune;
|
|
2297
|
+
}
|
|
2298
|
+
if ("params" in props && props.params) {
|
|
2299
|
+
for (const [key, value] of Object.entries(props.params)) {
|
|
2300
|
+
path = path.replace(
|
|
2301
|
+
`${dynamicParamPrefixRune}${key}`,
|
|
2302
|
+
String(value)
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
if ("splatValues" in props && props.splatValues) {
|
|
2307
|
+
const splatPath = props.splatValues.join("/");
|
|
2308
|
+
path = path.replace(splatSegmentRune, splatPath);
|
|
2309
|
+
}
|
|
2310
|
+
if (opts.type === "loader" && vormaAppConfig.loadersExplicitIndexSegment) {
|
|
2311
|
+
const indexSegment = `/${vormaAppConfig.loadersExplicitIndexSegment}`;
|
|
2312
|
+
if (path.endsWith(indexSegment)) {
|
|
2313
|
+
path = path.slice(0, -indexSegment.length) || "/";
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
return path;
|
|
2317
|
+
}
|
|
2318
|
+
function getCurrentOrigin() {
|
|
2319
|
+
return new URL(window.location.href).origin;
|
|
2320
|
+
}
|
|
2321
|
+
function stripTrailingSlash(path) {
|
|
2322
|
+
return path.endsWith("/") ? path.slice(0, -1) : path;
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
// internal/framework/_typescript/client/src/ui_lib_impl_helpers/link_components.ts
|
|
2326
|
+
function linkPropsToPrefetchObj(props) {
|
|
2327
|
+
if (!props.href || props.prefetch !== "intent") {
|
|
2328
|
+
return void 0;
|
|
2329
|
+
}
|
|
2330
|
+
return __getPrefetchHandlers({
|
|
2331
|
+
href: props.href,
|
|
2332
|
+
delayMs: props.prefetchDelayMs,
|
|
2333
|
+
beforeBegin: props.beforeBegin,
|
|
2334
|
+
beforeRender: props.beforeRender,
|
|
2335
|
+
afterRender: props.afterRender,
|
|
2336
|
+
scrollToTop: props.scrollToTop,
|
|
2337
|
+
replace: props.replace,
|
|
2338
|
+
state: props.state
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
function linkPropsToOnClickFn(props) {
|
|
2342
|
+
return __makeLinkOnClickFn({
|
|
2343
|
+
beforeBegin: props.beforeBegin,
|
|
2344
|
+
beforeRender: props.beforeRender,
|
|
2345
|
+
afterRender: props.afterRender,
|
|
2346
|
+
scrollToTop: props.scrollToTop,
|
|
2347
|
+
replace: props.replace,
|
|
2348
|
+
state: props.state
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
var standardCamelHandlerKeys = {
|
|
2352
|
+
onPointerEnter: "onPointerEnter",
|
|
2353
|
+
onFocus: "onFocus",
|
|
2354
|
+
onPointerLeave: "onPointerLeave",
|
|
2355
|
+
onBlur: "onBlur",
|
|
2356
|
+
onTouchCancel: "onTouchCancel",
|
|
2357
|
+
onClick: "onClick"
|
|
2358
|
+
};
|
|
2359
|
+
function __makeFinalLinkProps(props, keys = standardCamelHandlerKeys) {
|
|
2360
|
+
const prefetchObj = linkPropsToPrefetchObj(props);
|
|
2361
|
+
return {
|
|
2362
|
+
dataExternal: prefetchObj?.isExternal || void 0,
|
|
2363
|
+
onPointerEnter: (e) => {
|
|
2364
|
+
prefetchObj?.start(e);
|
|
2365
|
+
if (isFn(props[keys.onPointerEnter])) {
|
|
2366
|
+
props[keys.onPointerEnter](e);
|
|
2367
|
+
}
|
|
2368
|
+
},
|
|
2369
|
+
onFocus: (e) => {
|
|
2370
|
+
prefetchObj?.start(e);
|
|
2371
|
+
if (isFn(props[keys.onFocus])) {
|
|
2372
|
+
props[keys.onFocus](e);
|
|
2373
|
+
}
|
|
2374
|
+
},
|
|
2375
|
+
onPointerLeave: (e) => {
|
|
2376
|
+
if (!__vormaClientGlobal.get("isTouchDevice")) {
|
|
2377
|
+
prefetchObj?.stop();
|
|
2378
|
+
}
|
|
2379
|
+
if (isFn(props[keys.onPointerLeave])) {
|
|
2380
|
+
props[keys.onPointerLeave](e);
|
|
2381
|
+
}
|
|
2382
|
+
},
|
|
2383
|
+
onBlur: (e) => {
|
|
2384
|
+
prefetchObj?.stop();
|
|
2385
|
+
if (isFn(props[keys.onBlur])) {
|
|
2386
|
+
props[keys.onBlur](e);
|
|
2387
|
+
}
|
|
2388
|
+
},
|
|
2389
|
+
onTouchCancel: (e) => {
|
|
2390
|
+
prefetchObj?.stop();
|
|
2391
|
+
if (isFn(props[keys.onTouchCancel])) {
|
|
2392
|
+
props[keys.onTouchCancel](e);
|
|
2393
|
+
}
|
|
2394
|
+
},
|
|
2395
|
+
onClick: async (e) => {
|
|
2396
|
+
if (isFn(props[keys.onClick])) {
|
|
2397
|
+
props[keys.onClick](e);
|
|
2398
|
+
}
|
|
2399
|
+
if (prefetchObj) {
|
|
2400
|
+
await prefetchObj.onClick(e);
|
|
2401
|
+
} else {
|
|
2402
|
+
await linkPropsToOnClickFn(props)(e);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
function isFn(fn) {
|
|
2408
|
+
return typeof fn === "function";
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// internal/framework/_typescript/client/src/ui_lib_impl_helpers/typed_navigate.ts
|
|
2412
|
+
function makeTypedNavigate(vormaAppConfig) {
|
|
2413
|
+
return async function typedNavigate(options) {
|
|
2414
|
+
const {
|
|
2415
|
+
pattern,
|
|
2416
|
+
params,
|
|
2417
|
+
splatValues,
|
|
2418
|
+
replace,
|
|
2419
|
+
scrollToTop,
|
|
2420
|
+
search,
|
|
2421
|
+
hash,
|
|
2422
|
+
state
|
|
2423
|
+
} = options;
|
|
2424
|
+
const href = __resolvePath({
|
|
2425
|
+
vormaAppConfig,
|
|
2426
|
+
type: "loader",
|
|
2427
|
+
props: {
|
|
2428
|
+
pattern,
|
|
2429
|
+
...params && { params },
|
|
2430
|
+
...splatValues && { splatValues }
|
|
2431
|
+
}
|
|
2432
|
+
});
|
|
2433
|
+
return vormaNavigate(href, {
|
|
2434
|
+
replace,
|
|
2435
|
+
scrollToTop,
|
|
2436
|
+
search,
|
|
2437
|
+
hash,
|
|
2438
|
+
state
|
|
2439
|
+
});
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
// internal/framework/_typescript/client/src/window_focus_revalidation/window_focus_revalidation.ts
|
|
2444
|
+
import { addOnWindowFocusListener } from "vorma/kit/listeners";
|
|
2445
|
+
function revalidateOnWindowFocus(options) {
|
|
2446
|
+
const staleTimeMS = options?.staleTimeMS ?? 5e3;
|
|
2447
|
+
return addOnWindowFocusListener(() => {
|
|
2448
|
+
const status = getStatus();
|
|
2449
|
+
if (!status.isNavigating && !status.isSubmitting && !status.isRevalidating) {
|
|
2450
|
+
if (Date.now() - getLastTriggeredNavOrRevalidateTimestampMS() < staleTimeMS) {
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
revalidate();
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
export {
|
|
2458
|
+
__applyScrollState,
|
|
2459
|
+
__getPrefetchHandlers,
|
|
2460
|
+
__makeFinalLinkProps,
|
|
2461
|
+
__makeLinkOnClickFn,
|
|
2462
|
+
__registerClientLoaderPattern,
|
|
2463
|
+
__resolvePath,
|
|
2464
|
+
__runClientLoadersAfterHMRUpdate,
|
|
2465
|
+
__vormaClientGlobal,
|
|
2466
|
+
addBuildIDListener,
|
|
2467
|
+
addLocationListener,
|
|
2468
|
+
addRouteChangeListener,
|
|
2469
|
+
addStatusListener,
|
|
2470
|
+
buildMutationURL,
|
|
2471
|
+
buildQueryURL,
|
|
2472
|
+
defaultErrorBoundary,
|
|
2473
|
+
getBuildID,
|
|
2474
|
+
getHistoryInstance,
|
|
2475
|
+
getLocation,
|
|
2476
|
+
getRootEl,
|
|
2477
|
+
getRouterData,
|
|
2478
|
+
getStatus,
|
|
2479
|
+
initClient,
|
|
2480
|
+
makeTypedNavigate,
|
|
2481
|
+
resolveBody,
|
|
2482
|
+
revalidate,
|
|
2483
|
+
revalidateOnWindowFocus,
|
|
2484
|
+
route,
|
|
2485
|
+
setupGlobalLoadingIndicator,
|
|
2486
|
+
submit,
|
|
2487
|
+
vormaNavigate
|
|
2488
|
+
};
|
|
2489
|
+
//# sourceMappingURL=index.js.map
|