@tanstack/vue-router 1.167.1 → 1.167.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Asset.js +107 -151
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Body.js +15 -24
- package/dist/esm/Body.js.map +1 -1
- package/dist/esm/CatchBoundary.js +112 -130
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +59 -29
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +29 -23
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +21 -16
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Html.js +42 -61
- package/dist/esm/Html.js.map +1 -1
- package/dist/esm/Match.js +238 -319
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +127 -170
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +50 -65
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +31 -36
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +79 -101
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -29
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +146 -164
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +27 -34
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +90 -92
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +92 -123
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +16 -118
- package/dist/esm/index.js +18 -119
- package/dist/esm/lazyRouteComponent.js +69 -82
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +364 -385
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +16 -11
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +30 -40
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +20 -15
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +196 -174
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +11 -11
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +10 -7
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +39 -50
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +29 -43
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +29 -32
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +11 -13
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +12 -15
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +47 -65
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +24 -32
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.js +243 -287
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +12 -11
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +12 -14
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +6 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +27 -35
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +18 -24
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +13 -12
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +9 -8
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +18 -22
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +13 -12
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +59 -38
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/Asset.js
CHANGED
|
@@ -1,157 +1,113 @@
|
|
|
1
|
+
import { useRouter } from "./useRouter.js";
|
|
1
2
|
import * as Vue from "vue";
|
|
2
3
|
import { createVNode, mergeProps } from "vue";
|
|
3
4
|
import { isServer } from "@tanstack/router-core/isServer";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
document.title = newTitle;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return () => Vue.h("title", {}, props.children);
|
|
28
|
-
}
|
|
5
|
+
//#region src/Asset.tsx
|
|
6
|
+
var Title = Vue.defineComponent({
|
|
7
|
+
name: "Title",
|
|
8
|
+
props: { children: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: ""
|
|
11
|
+
} },
|
|
12
|
+
setup(props) {
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
if (!(isServer ?? router.isServer)) {
|
|
15
|
+
Vue.onMounted(() => {
|
|
16
|
+
if (props.children) document.title = props.children;
|
|
17
|
+
});
|
|
18
|
+
Vue.watch(() => props.children, (newTitle) => {
|
|
19
|
+
if (newTitle) document.title = newTitle;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return () => Vue.h("title", {}, props.children);
|
|
23
|
+
}
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
innerHTML: props.children
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
const {
|
|
105
|
-
src: _src,
|
|
106
|
-
...rest
|
|
107
|
-
} = props.attrs || {};
|
|
108
|
-
return Vue.h("script", {
|
|
109
|
-
...rest,
|
|
110
|
-
"data-allow-mismatch": true,
|
|
111
|
-
innerHTML: ""
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (props.attrs?.src && typeof props.attrs.src === "string") {
|
|
115
|
-
return Vue.h("script", props.attrs);
|
|
116
|
-
}
|
|
117
|
-
if (typeof props.children === "string") {
|
|
118
|
-
return Vue.h("script", {
|
|
119
|
-
...props.attrs,
|
|
120
|
-
innerHTML: props.children
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
25
|
+
var Script = Vue.defineComponent({
|
|
26
|
+
name: "Script",
|
|
27
|
+
props: {
|
|
28
|
+
attrs: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: () => ({})
|
|
31
|
+
},
|
|
32
|
+
children: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: void 0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setup(props) {
|
|
38
|
+
const router = useRouter();
|
|
39
|
+
const dataScript = typeof props.attrs?.type === "string" && props.attrs.type !== "" && props.attrs.type !== "text/javascript" && props.attrs.type !== "module";
|
|
40
|
+
if (!(isServer ?? router.isServer)) Vue.onMounted(() => {
|
|
41
|
+
if (dataScript) return;
|
|
42
|
+
const attrs = props.attrs;
|
|
43
|
+
const children = props.children;
|
|
44
|
+
if (attrs?.src) {
|
|
45
|
+
const normSrc = (() => {
|
|
46
|
+
try {
|
|
47
|
+
const base = document.baseURI || window.location.href;
|
|
48
|
+
return new URL(attrs.src, base).href;
|
|
49
|
+
} catch {
|
|
50
|
+
return attrs.src;
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
if (Array.from(document.querySelectorAll("script[src]")).find((el) => el.src === normSrc)) return;
|
|
54
|
+
const script = document.createElement("script");
|
|
55
|
+
for (const [key, value] of Object.entries(attrs)) if (value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
|
|
56
|
+
document.head.appendChild(script);
|
|
57
|
+
} else if (typeof children === "string") {
|
|
58
|
+
const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
|
|
59
|
+
const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
|
|
60
|
+
if (Array.from(document.querySelectorAll("script:not([src])")).find((el) => {
|
|
61
|
+
if (!(el instanceof HTMLScriptElement)) return false;
|
|
62
|
+
const sType = el.getAttribute("type") ?? "text/javascript";
|
|
63
|
+
const sNonce = el.getAttribute("nonce") ?? void 0;
|
|
64
|
+
return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
|
|
65
|
+
})) return;
|
|
66
|
+
const script = document.createElement("script");
|
|
67
|
+
script.textContent = children;
|
|
68
|
+
if (attrs) {
|
|
69
|
+
for (const [key, value] of Object.entries(attrs)) if (value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
|
|
70
|
+
}
|
|
71
|
+
document.head.appendChild(script);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return () => {
|
|
75
|
+
if (!(isServer ?? router.isServer)) {
|
|
76
|
+
if (dataScript && typeof props.children === "string") return Vue.h("script", {
|
|
77
|
+
...props.attrs,
|
|
78
|
+
"data-allow-mismatch": true,
|
|
79
|
+
innerHTML: props.children
|
|
80
|
+
});
|
|
81
|
+
const { src: _src, ...rest } = props.attrs || {};
|
|
82
|
+
return Vue.h("script", {
|
|
83
|
+
...rest,
|
|
84
|
+
"data-allow-mismatch": true,
|
|
85
|
+
innerHTML: ""
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (props.attrs?.src && typeof props.attrs.src === "string") return Vue.h("script", props.attrs);
|
|
89
|
+
if (typeof props.children === "string") return Vue.h("script", {
|
|
90
|
+
...props.attrs,
|
|
91
|
+
innerHTML: props.children
|
|
92
|
+
});
|
|
93
|
+
return null;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
126
96
|
});
|
|
127
|
-
function Asset({
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
case "link":
|
|
140
|
-
return createVNode("link", attrs, null);
|
|
141
|
-
case "style":
|
|
142
|
-
return createVNode("style", mergeProps(attrs, {
|
|
143
|
-
"innerHTML": children
|
|
144
|
-
}), null);
|
|
145
|
-
case "script":
|
|
146
|
-
return Vue.h(Script, {
|
|
147
|
-
attrs,
|
|
148
|
-
children
|
|
149
|
-
});
|
|
150
|
-
default:
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
97
|
+
function Asset({ tag, attrs, children }) {
|
|
98
|
+
switch (tag) {
|
|
99
|
+
case "title": return Vue.h(Title, { children });
|
|
100
|
+
case "meta": return createVNode("meta", attrs, null);
|
|
101
|
+
case "link": return createVNode("link", attrs, null);
|
|
102
|
+
case "style": return createVNode("style", mergeProps(attrs, { "innerHTML": children }), null);
|
|
103
|
+
case "script": return Vue.h(Script, {
|
|
104
|
+
attrs,
|
|
105
|
+
children
|
|
106
|
+
});
|
|
107
|
+
default: return null;
|
|
108
|
+
}
|
|
153
109
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=Asset.js.map
|
|
110
|
+
//#endregion
|
|
111
|
+
export { Asset };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=Asset.js.map
|
package/dist/esm/Asset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Asset.js","sources":["../../src/Asset.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\ninterface ScriptAttrs {\n [key: string]: string | boolean | undefined\n src?: string\n}\n\nconst Title = Vue.defineComponent({\n name: 'Title',\n props: {\n children: {\n type: String,\n default: '',\n },\n },\n setup(props) {\n const router = useRouter()\n\n if (!(isServer ?? router.isServer)) {\n Vue.onMounted(() => {\n if (props.children) {\n document.title = props.children\n }\n })\n\n Vue.watch(\n () => props.children,\n (newTitle) => {\n if (newTitle) {\n document.title = newTitle\n }\n },\n )\n }\n\n return () => Vue.h('title', {}, props.children)\n },\n})\n\nconst Script = Vue.defineComponent({\n name: 'Script',\n props: {\n attrs: {\n type: Object as Vue.PropType<ScriptAttrs>,\n default: () => ({}),\n },\n children: {\n type: String,\n default: undefined,\n },\n },\n setup(props) {\n const router = useRouter()\n const dataScript =\n typeof props.attrs?.type === 'string' &&\n props.attrs.type !== '' &&\n props.attrs.type !== 'text/javascript' &&\n props.attrs.type !== 'module'\n\n if (!(isServer ?? router.isServer)) {\n Vue.onMounted(() => {\n if (dataScript) return\n\n const attrs = props.attrs\n const children = props.children\n\n if (attrs?.src) {\n const normSrc = (() => {\n try {\n const base = document.baseURI || window.location.href\n return new URL(attrs.src, base).href\n } catch {\n return attrs.src\n }\n })()\n const existingScript = Array.from(\n document.querySelectorAll('script[src]'),\n ).find((el) => (el as HTMLScriptElement).src === normSrc)\n\n if (existingScript) {\n return\n }\n\n const script = document.createElement('script')\n\n for (const [key, value] of Object.entries(attrs)) {\n if (value !== undefined && value !== false) {\n script.setAttribute(\n key,\n typeof value === 'boolean' ? '' : String(value),\n )\n }\n }\n\n document.head.appendChild(script)\n } else if (typeof children === 'string') {\n const typeAttr =\n typeof attrs?.type === 'string' ? attrs.type : 'text/javascript'\n const nonceAttr =\n typeof attrs?.nonce === 'string' ? attrs.nonce : undefined\n const existingScript = Array.from(\n document.querySelectorAll('script:not([src])'),\n ).find((el) => {\n if (!(el instanceof HTMLScriptElement)) return false\n const sType = el.getAttribute('type') ?? 'text/javascript'\n const sNonce = el.getAttribute('nonce') ?? undefined\n return (\n el.textContent === children &&\n sType === typeAttr &&\n sNonce === nonceAttr\n )\n })\n\n if (existingScript) {\n return\n }\n\n const script = document.createElement('script')\n script.textContent = children\n\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n if (value !== undefined && value !== false) {\n script.setAttribute(\n key,\n typeof value === 'boolean' ? '' : String(value),\n )\n }\n }\n }\n\n document.head.appendChild(script)\n }\n })\n }\n\n return () => {\n if (!(isServer ?? router.isServer)) {\n if (dataScript && typeof props.children === 'string') {\n return Vue.h('script', {\n ...props.attrs,\n 'data-allow-mismatch': true,\n innerHTML: props.children,\n })\n }\n\n const { src: _src, ...rest } = props.attrs || {}\n return Vue.h('script', {\n ...rest,\n 'data-allow-mismatch': true,\n innerHTML: '',\n })\n }\n\n if (props.attrs?.src && typeof props.attrs.src === 'string') {\n return Vue.h('script', props.attrs)\n }\n\n if (typeof props.children === 'string') {\n return Vue.h('script', {\n ...props.attrs,\n innerHTML: props.children,\n })\n }\n\n return null\n }\n },\n})\n\nexport function Asset({ tag, attrs, children }: RouterManagedTag): any {\n switch (tag) {\n case 'title':\n return Vue.h(Title, { children: children })\n case 'meta':\n return <meta {...attrs} />\n case 'link':\n return <link {...attrs} />\n case 'style':\n return <style {...attrs} innerHTML={children} />\n case 'script':\n return Vue.h(Script, { attrs, children: children })\n default:\n return null\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"Asset.js","names":["Vue","isServer","useRouter","Title","defineComponent","name","props","children","type","String","default","setup","router","onMounted","document","title","watch","newTitle","h","Script","attrs","Object","undefined","dataScript","src","normSrc","base","baseURI","window","location","href","URL","existingScript","Array","from","querySelectorAll","find","el","script","createElement","key","value","entries","setAttribute","head","appendChild","typeAttr","nonceAttr","nonce","HTMLScriptElement","sType","getAttribute","sNonce","textContent","innerHTML","_src","rest","Asset","tag","_createVNode","_mergeProps"],"sources":["../../src/Asset.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\ninterface ScriptAttrs {\n [key: string]: string | boolean | undefined\n src?: string\n}\n\nconst Title = Vue.defineComponent({\n name: 'Title',\n props: {\n children: {\n type: String,\n default: '',\n },\n },\n setup(props) {\n const router = useRouter()\n\n if (!(isServer ?? router.isServer)) {\n Vue.onMounted(() => {\n if (props.children) {\n document.title = props.children\n }\n })\n\n Vue.watch(\n () => props.children,\n (newTitle) => {\n if (newTitle) {\n document.title = newTitle\n }\n },\n )\n }\n\n return () => Vue.h('title', {}, props.children)\n },\n})\n\nconst Script = Vue.defineComponent({\n name: 'Script',\n props: {\n attrs: {\n type: Object as Vue.PropType<ScriptAttrs>,\n default: () => ({}),\n },\n children: {\n type: String,\n default: undefined,\n },\n },\n setup(props) {\n const router = useRouter()\n const dataScript =\n typeof props.attrs?.type === 'string' &&\n props.attrs.type !== '' &&\n props.attrs.type !== 'text/javascript' &&\n props.attrs.type !== 'module'\n\n if (!(isServer ?? router.isServer)) {\n Vue.onMounted(() => {\n if (dataScript) return\n\n const attrs = props.attrs\n const children = props.children\n\n if (attrs?.src) {\n const normSrc = (() => {\n try {\n const base = document.baseURI || window.location.href\n return new URL(attrs.src, base).href\n } catch {\n return attrs.src\n }\n })()\n const existingScript = Array.from(\n document.querySelectorAll('script[src]'),\n ).find((el) => (el as HTMLScriptElement).src === normSrc)\n\n if (existingScript) {\n return\n }\n\n const script = document.createElement('script')\n\n for (const [key, value] of Object.entries(attrs)) {\n if (value !== undefined && value !== false) {\n script.setAttribute(\n key,\n typeof value === 'boolean' ? '' : String(value),\n )\n }\n }\n\n document.head.appendChild(script)\n } else if (typeof children === 'string') {\n const typeAttr =\n typeof attrs?.type === 'string' ? attrs.type : 'text/javascript'\n const nonceAttr =\n typeof attrs?.nonce === 'string' ? attrs.nonce : undefined\n const existingScript = Array.from(\n document.querySelectorAll('script:not([src])'),\n ).find((el) => {\n if (!(el instanceof HTMLScriptElement)) return false\n const sType = el.getAttribute('type') ?? 'text/javascript'\n const sNonce = el.getAttribute('nonce') ?? undefined\n return (\n el.textContent === children &&\n sType === typeAttr &&\n sNonce === nonceAttr\n )\n })\n\n if (existingScript) {\n return\n }\n\n const script = document.createElement('script')\n script.textContent = children\n\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n if (value !== undefined && value !== false) {\n script.setAttribute(\n key,\n typeof value === 'boolean' ? '' : String(value),\n )\n }\n }\n }\n\n document.head.appendChild(script)\n }\n })\n }\n\n return () => {\n if (!(isServer ?? router.isServer)) {\n if (dataScript && typeof props.children === 'string') {\n return Vue.h('script', {\n ...props.attrs,\n 'data-allow-mismatch': true,\n innerHTML: props.children,\n })\n }\n\n const { src: _src, ...rest } = props.attrs || {}\n return Vue.h('script', {\n ...rest,\n 'data-allow-mismatch': true,\n innerHTML: '',\n })\n }\n\n if (props.attrs?.src && typeof props.attrs.src === 'string') {\n return Vue.h('script', props.attrs)\n }\n\n if (typeof props.children === 'string') {\n return Vue.h('script', {\n ...props.attrs,\n innerHTML: props.children,\n })\n }\n\n return null\n }\n },\n})\n\nexport function Asset({ tag, attrs, children }: RouterManagedTag): any {\n switch (tag) {\n case 'title':\n return Vue.h(Title, { children: children })\n case 'meta':\n return <meta {...attrs} />\n case 'link':\n return <link {...attrs} />\n case 'style':\n return <style {...attrs} innerHTML={children} />\n case 'script':\n return Vue.h(Script, { attrs, children: children })\n default:\n return null\n }\n}\n"],"mappings":";;;;;AAUA,IAAMG,QAAQH,IAAII,gBAAgB;CAChCC,MAAM;CACNC,OAAO,EACLC,UAAU;EACRC,MAAMC;EACNC,SAAS;EACX,EACD;CACDC,MAAML,OAAO;EACX,MAAMM,SAASV,WAAW;AAE1B,MAAI,EAAED,YAAYW,OAAOX,WAAW;AAClCD,OAAIa,gBAAgB;AAClB,QAAIP,MAAMC,SACRO,UAASC,QAAQT,MAAMC;KAEzB;AAEFP,OAAIgB,YACIV,MAAMC,WACXU,aAAa;AACZ,QAAIA,SACFH,UAASC,QAAQE;KAGtB;;AAGH,eAAajB,IAAIkB,EAAE,SAAS,EAAE,EAAEZ,MAAMC,SAAS;;CAElD,CAAC;AAEF,IAAMY,SAASnB,IAAII,gBAAgB;CACjCC,MAAM;CACNC,OAAO;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AK,QACH,QAAO1D,IAAIkB,EAAEf,OAAO,EAAYI,UAAU,CAAC;EAC7C,KAAK,OACH,QAAAoD,YAAA,QAAiBvC,OAAK,KAAA;EACxB,KAAK,OACH,QAAAuC,YAAA,QAAiBvC,OAAK,KAAA;EACxB,KAAK,QACH,QAAAuC,YAAA,SAAAC,WAAkBxC,OAAK,EAAA,aAAab,UAAQ,CAAA,EAAA,KAAA;EAC9C,KAAK,SACH,QAAOP,IAAIkB,EAAEC,QAAQ;GAAEC;GAAiBb;GAAU,CAAC;EACrD,QACE,QAAO"}
|
package/dist/esm/Body.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}, Vue.h("div", {
|
|
14
|
-
"data-allow-mismatch": ""
|
|
15
|
-
}, children)));
|
|
16
|
-
}
|
|
17
|
-
return Vue.h("div", {
|
|
18
|
-
"data-allow-mismatch": ""
|
|
19
|
-
}, children);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
2
|
+
//#region src/Body.tsx
|
|
3
|
+
var Body = Vue.defineComponent({
|
|
4
|
+
name: "Body",
|
|
5
|
+
setup(_, { slots }) {
|
|
6
|
+
const isServer = typeof window === "undefined";
|
|
7
|
+
return () => {
|
|
8
|
+
const children = slots.default?.();
|
|
9
|
+
if (isServer) return Vue.h("body", {}, Vue.h("div", { id: "__app" }, Vue.h("div", { "data-allow-mismatch": "" }, children)));
|
|
10
|
+
return Vue.h("div", { "data-allow-mismatch": "" }, children);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
22
13
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=Body.js.map
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Body };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Body.js.map
|
package/dist/esm/Body.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Body.js","sources":["../../src/Body.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\nexport const Body = Vue.defineComponent({\n name: 'Body',\n setup(_, { slots }) {\n const isServer = typeof window === 'undefined'\n\n return () => {\n const children = slots.default?.()\n\n if (isServer) {\n return Vue.h(\n 'body',\n {},\n Vue.h(\n 'div',\n { id: '__app' },\n Vue.h('div', { 'data-allow-mismatch': '' }, children),\n ),\n )\n }\n\n return Vue.h('div', { 'data-allow-mismatch': '' }, children)\n }\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"Body.js","names":["Vue","Body","defineComponent","name","setup","_","slots","isServer","window","children","default","h","id"],"sources":["../../src/Body.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\nexport const Body = Vue.defineComponent({\n name: 'Body',\n setup(_, { slots }) {\n const isServer = typeof window === 'undefined'\n\n return () => {\n const children = slots.default?.()\n\n if (isServer) {\n return Vue.h(\n 'body',\n {},\n Vue.h(\n 'div',\n { id: '__app' },\n Vue.h('div', { 'data-allow-mismatch': '' }, children),\n ),\n )\n }\n\n return Vue.h('div', { 'data-allow-mismatch': '' }, children)\n }\n },\n})\n"],"mappings":";;AAEA,IAAaC,OAAOD,IAAIE,gBAAgB;CACtCC,MAAM;CACNC,MAAMC,GAAG,EAAEC,SAAS;EAClB,MAAMC,WAAW,OAAOC,WAAW;AAEnC,eAAa;GACX,MAAMC,WAAWH,MAAMI,WAAW;AAElC,OAAIH,SACF,QAAOP,IAAIW,EACT,QACA,EAAE,EACFX,IAAIW,EACF,OACA,EAAEC,IAAI,SAAS,EACfZ,IAAIW,EAAE,OAAO,EAAE,uBAAuB,IAAI,EAAEF,SAC9C,CACF,CAAC;AAGH,UAAOT,IAAIW,EAAE,OAAO,EAAE,uBAAuB,IAAI,EAAEF,SAAS;;;CAGjE,CAAC"}
|
|
@@ -1,136 +1,118 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return Array.isArray(fallbackContent) && fallbackContent.length === 1 ? fallbackContent[0] : fallbackContent;
|
|
40
|
-
}
|
|
41
|
-
const defaultContent = slots.default && slots.default();
|
|
42
|
-
return Array.isArray(defaultContent) && defaultContent.length === 1 ? defaultContent[0] : defaultContent;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
2
|
+
//#region src/CatchBoundary.tsx
|
|
3
|
+
var VueErrorBoundary = Vue.defineComponent({
|
|
4
|
+
name: "VueErrorBoundary",
|
|
5
|
+
props: {
|
|
6
|
+
onError: Function,
|
|
7
|
+
resetKey: [String, Number]
|
|
8
|
+
},
|
|
9
|
+
emits: ["catch"],
|
|
10
|
+
setup(props, { slots }) {
|
|
11
|
+
const error = Vue.ref(null);
|
|
12
|
+
const resetFn = Vue.ref(null);
|
|
13
|
+
const reset = () => {
|
|
14
|
+
error.value = null;
|
|
15
|
+
};
|
|
16
|
+
Vue.watch(() => props.resetKey, (newKey, oldKey) => {
|
|
17
|
+
if (newKey !== oldKey && error.value) reset();
|
|
18
|
+
});
|
|
19
|
+
Vue.onErrorCaptured((err) => {
|
|
20
|
+
if (err instanceof Promise || err && typeof err.then === "function") return false;
|
|
21
|
+
error.value = err;
|
|
22
|
+
resetFn.value = reset;
|
|
23
|
+
if (props.onError) props.onError(err);
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
return () => {
|
|
27
|
+
if (error.value && slots.fallback) {
|
|
28
|
+
const fallbackContent = slots.fallback({
|
|
29
|
+
error: error.value,
|
|
30
|
+
reset
|
|
31
|
+
});
|
|
32
|
+
return Array.isArray(fallbackContent) && fallbackContent.length === 1 ? fallbackContent[0] : fallbackContent;
|
|
33
|
+
}
|
|
34
|
+
const defaultContent = slots.default && slots.default();
|
|
35
|
+
return Array.isArray(defaultContent) && defaultContent.length === 1 ? defaultContent[0] : defaultContent;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
45
38
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
39
|
+
var CatchBoundaryWrapper = Vue.defineComponent({
|
|
40
|
+
name: "CatchBoundary",
|
|
41
|
+
inheritAttrs: false,
|
|
42
|
+
props: [
|
|
43
|
+
"getResetKey",
|
|
44
|
+
"children",
|
|
45
|
+
"errorComponent",
|
|
46
|
+
"onCatch"
|
|
47
|
+
],
|
|
48
|
+
setup(props) {
|
|
49
|
+
const resetKey = Vue.computed(() => props.getResetKey());
|
|
50
|
+
return () => {
|
|
51
|
+
return Vue.h(VueErrorBoundary, {
|
|
52
|
+
resetKey: resetKey.value,
|
|
53
|
+
onError: props.onCatch
|
|
54
|
+
}, {
|
|
55
|
+
default: () => props.children,
|
|
56
|
+
fallback: ({ error, reset }) => {
|
|
57
|
+
if (props.errorComponent) return Vue.h(props.errorComponent, {
|
|
58
|
+
error,
|
|
59
|
+
reset
|
|
60
|
+
});
|
|
61
|
+
return Vue.h(ErrorComponent, {
|
|
62
|
+
error,
|
|
63
|
+
reset
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
}
|
|
76
69
|
});
|
|
77
70
|
function CatchBoundary(props) {
|
|
78
|
-
|
|
71
|
+
return Vue.h(CatchBoundaryWrapper, props);
|
|
79
72
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
style: {
|
|
122
|
-
fontSize: ".7em",
|
|
123
|
-
border: "1px solid red",
|
|
124
|
-
borderRadius: ".25rem",
|
|
125
|
-
padding: ".3rem",
|
|
126
|
-
color: "red",
|
|
127
|
-
overflow: "auto"
|
|
128
|
-
}
|
|
129
|
-
}, [props.error?.message ? Vue.h("code", {}, props.error.message) : null])]) : null]);
|
|
130
|
-
}
|
|
73
|
+
var ErrorComponent = Vue.defineComponent({
|
|
74
|
+
name: "ErrorComponent",
|
|
75
|
+
props: {
|
|
76
|
+
error: Object,
|
|
77
|
+
reset: Function
|
|
78
|
+
},
|
|
79
|
+
setup(props) {
|
|
80
|
+
const show = Vue.ref(process.env.NODE_ENV !== "production");
|
|
81
|
+
const toggleShow = () => {
|
|
82
|
+
show.value = !show.value;
|
|
83
|
+
};
|
|
84
|
+
return () => Vue.h("div", { style: {
|
|
85
|
+
padding: ".5rem",
|
|
86
|
+
maxWidth: "100%"
|
|
87
|
+
} }, [
|
|
88
|
+
Vue.h("div", { style: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
gap: ".5rem"
|
|
92
|
+
} }, [Vue.h("strong", { style: { fontSize: "1rem" } }, "Something went wrong!"), Vue.h("button", {
|
|
93
|
+
style: {
|
|
94
|
+
appearance: "none",
|
|
95
|
+
fontSize: ".6em",
|
|
96
|
+
border: "1px solid currentColor",
|
|
97
|
+
padding: ".1rem .2rem",
|
|
98
|
+
fontWeight: "bold",
|
|
99
|
+
borderRadius: ".25rem"
|
|
100
|
+
},
|
|
101
|
+
onClick: toggleShow
|
|
102
|
+
}, show.value ? "Hide Error" : "Show Error")]),
|
|
103
|
+
Vue.h("div", { style: { height: ".25rem" } }),
|
|
104
|
+
show.value ? Vue.h("div", {}, [Vue.h("pre", { style: {
|
|
105
|
+
fontSize: ".7em",
|
|
106
|
+
border: "1px solid red",
|
|
107
|
+
borderRadius: ".25rem",
|
|
108
|
+
padding: ".3rem",
|
|
109
|
+
color: "red",
|
|
110
|
+
overflow: "auto"
|
|
111
|
+
} }, [props.error?.message ? Vue.h("code", {}, props.error.message) : null])]) : null
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
131
114
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
//# sourceMappingURL=CatchBoundary.js.map
|
|
115
|
+
//#endregion
|
|
116
|
+
export { CatchBoundary, ErrorComponent };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=CatchBoundary.js.map
|