@tanstack/vue-router 1.167.1 → 1.167.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/esm/Asset.js +107 -151
  2. package/dist/esm/Asset.js.map +1 -1
  3. package/dist/esm/Body.js +15 -24
  4. package/dist/esm/Body.js.map +1 -1
  5. package/dist/esm/CatchBoundary.js +112 -130
  6. package/dist/esm/CatchBoundary.js.map +1 -1
  7. package/dist/esm/ClientOnly.js +59 -29
  8. package/dist/esm/ClientOnly.js.map +1 -1
  9. package/dist/esm/HeadContent.dev.js +29 -23
  10. package/dist/esm/HeadContent.dev.js.map +1 -1
  11. package/dist/esm/HeadContent.js +21 -16
  12. package/dist/esm/HeadContent.js.map +1 -1
  13. package/dist/esm/Html.js +42 -61
  14. package/dist/esm/Html.js.map +1 -1
  15. package/dist/esm/Match.js +238 -319
  16. package/dist/esm/Match.js.map +1 -1
  17. package/dist/esm/Matches.js +127 -170
  18. package/dist/esm/Matches.js.map +1 -1
  19. package/dist/esm/RouterProvider.js +50 -65
  20. package/dist/esm/RouterProvider.js.map +1 -1
  21. package/dist/esm/ScriptOnce.js +31 -36
  22. package/dist/esm/ScriptOnce.js.map +1 -1
  23. package/dist/esm/Scripts.js +79 -101
  24. package/dist/esm/Scripts.js.map +1 -1
  25. package/dist/esm/ScrollRestoration.js +25 -29
  26. package/dist/esm/ScrollRestoration.js.map +1 -1
  27. package/dist/esm/Transitioner.js +146 -164
  28. package/dist/esm/Transitioner.js.map +1 -1
  29. package/dist/esm/awaited.js +27 -34
  30. package/dist/esm/awaited.js.map +1 -1
  31. package/dist/esm/fileRoute.js +90 -92
  32. package/dist/esm/fileRoute.js.map +1 -1
  33. package/dist/esm/headContentUtils.js +92 -123
  34. package/dist/esm/headContentUtils.js.map +1 -1
  35. package/dist/esm/index.dev.js +16 -118
  36. package/dist/esm/index.js +18 -119
  37. package/dist/esm/lazyRouteComponent.js +69 -82
  38. package/dist/esm/lazyRouteComponent.js.map +1 -1
  39. package/dist/esm/link.js +364 -385
  40. package/dist/esm/link.js.map +1 -1
  41. package/dist/esm/matchContext.js +16 -11
  42. package/dist/esm/matchContext.js.map +1 -1
  43. package/dist/esm/not-found.js +30 -40
  44. package/dist/esm/not-found.js.map +1 -1
  45. package/dist/esm/renderRouteNotFound.js +20 -15
  46. package/dist/esm/renderRouteNotFound.js.map +1 -1
  47. package/dist/esm/route.js +196 -174
  48. package/dist/esm/route.js.map +1 -1
  49. package/dist/esm/router.js +11 -11
  50. package/dist/esm/router.js.map +1 -1
  51. package/dist/esm/routerContext.js +10 -7
  52. package/dist/esm/routerContext.js.map +1 -1
  53. package/dist/esm/scroll-restoration.js +39 -50
  54. package/dist/esm/scroll-restoration.js.map +1 -1
  55. package/dist/esm/ssr/RouterClient.js +29 -43
  56. package/dist/esm/ssr/RouterClient.js.map +1 -1
  57. package/dist/esm/ssr/RouterServer.js +29 -32
  58. package/dist/esm/ssr/RouterServer.js.map +1 -1
  59. package/dist/esm/ssr/client.js +1 -4
  60. package/dist/esm/ssr/defaultRenderHandler.js +11 -13
  61. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  62. package/dist/esm/ssr/defaultStreamHandler.js +12 -15
  63. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  64. package/dist/esm/ssr/renderRouterToStream.js +47 -65
  65. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  66. package/dist/esm/ssr/renderRouterToString.js +24 -32
  67. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  68. package/dist/esm/ssr/server.js +3 -10
  69. package/dist/esm/useBlocker.js +243 -287
  70. package/dist/esm/useBlocker.js.map +1 -1
  71. package/dist/esm/useCanGoBack.js +6 -5
  72. package/dist/esm/useCanGoBack.js.map +1 -1
  73. package/dist/esm/useLoaderData.js +12 -11
  74. package/dist/esm/useLoaderData.js.map +1 -1
  75. package/dist/esm/useLoaderDeps.js +12 -14
  76. package/dist/esm/useLoaderDeps.js.map +1 -1
  77. package/dist/esm/useLocation.js +6 -7
  78. package/dist/esm/useLocation.js.map +1 -1
  79. package/dist/esm/useMatch.js +27 -35
  80. package/dist/esm/useMatch.js.map +1 -1
  81. package/dist/esm/useNavigate.js +18 -24
  82. package/dist/esm/useNavigate.js.map +1 -1
  83. package/dist/esm/useParams.js +13 -12
  84. package/dist/esm/useParams.js.map +1 -1
  85. package/dist/esm/useRouteContext.js +9 -8
  86. package/dist/esm/useRouteContext.js.map +1 -1
  87. package/dist/esm/useRouter.js +9 -8
  88. package/dist/esm/useRouter.js.map +1 -1
  89. package/dist/esm/useRouterState.js +18 -22
  90. package/dist/esm/useRouterState.js.map +1 -1
  91. package/dist/esm/useSearch.js +13 -12
  92. package/dist/esm/useSearch.js.map +1 -1
  93. package/dist/esm/utils.js +59 -38
  94. package/dist/esm/utils.js.map +1 -1
  95. package/package.json +3 -3
  96. package/dist/esm/index.dev.js.map +0 -1
  97. package/dist/esm/index.js.map +0 -1
  98. package/dist/esm/ssr/client.js.map +0 -1
  99. 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
- import { useRouter } from "./useRouter.js";
5
- const Title = Vue.defineComponent({
6
- name: "Title",
7
- props: {
8
- children: {
9
- type: String,
10
- default: ""
11
- }
12
- },
13
- setup(props) {
14
- const router = useRouter();
15
- if (!(isServer ?? router.isServer)) {
16
- Vue.onMounted(() => {
17
- if (props.children) {
18
- document.title = props.children;
19
- }
20
- });
21
- Vue.watch(() => props.children, (newTitle) => {
22
- if (newTitle) {
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
- const Script = Vue.defineComponent({
31
- name: "Script",
32
- props: {
33
- attrs: {
34
- type: Object,
35
- default: () => ({})
36
- },
37
- children: {
38
- type: String,
39
- default: void 0
40
- }
41
- },
42
- setup(props) {
43
- const router = useRouter();
44
- const dataScript = typeof props.attrs?.type === "string" && props.attrs.type !== "" && props.attrs.type !== "text/javascript" && props.attrs.type !== "module";
45
- if (!(isServer ?? router.isServer)) {
46
- Vue.onMounted(() => {
47
- if (dataScript) return;
48
- const attrs = props.attrs;
49
- const children = props.children;
50
- if (attrs?.src) {
51
- const normSrc = (() => {
52
- try {
53
- const base = document.baseURI || window.location.href;
54
- return new URL(attrs.src, base).href;
55
- } catch {
56
- return attrs.src;
57
- }
58
- })();
59
- const existingScript = Array.from(document.querySelectorAll("script[src]")).find((el) => el.src === normSrc);
60
- if (existingScript) {
61
- return;
62
- }
63
- const script = document.createElement("script");
64
- for (const [key, value] of Object.entries(attrs)) {
65
- if (value !== void 0 && value !== false) {
66
- script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
67
- }
68
- }
69
- document.head.appendChild(script);
70
- } else if (typeof children === "string") {
71
- const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
72
- const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
73
- const existingScript = Array.from(document.querySelectorAll("script:not([src])")).find((el) => {
74
- if (!(el instanceof HTMLScriptElement)) return false;
75
- const sType = el.getAttribute("type") ?? "text/javascript";
76
- const sNonce = el.getAttribute("nonce") ?? void 0;
77
- return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
78
- });
79
- if (existingScript) {
80
- return;
81
- }
82
- const script = document.createElement("script");
83
- script.textContent = children;
84
- if (attrs) {
85
- for (const [key, value] of Object.entries(attrs)) {
86
- if (value !== void 0 && value !== false) {
87
- script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
88
- }
89
- }
90
- }
91
- document.head.appendChild(script);
92
- }
93
- });
94
- }
95
- return () => {
96
- if (!(isServer ?? router.isServer)) {
97
- if (dataScript && typeof props.children === "string") {
98
- return Vue.h("script", {
99
- ...props.attrs,
100
- "data-allow-mismatch": true,
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
- tag,
129
- attrs,
130
- children
131
- }) {
132
- switch (tag) {
133
- case "title":
134
- return Vue.h(Title, {
135
- children
136
- });
137
- case "meta":
138
- return createVNode("meta", attrs, null);
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
- export {
155
- Asset
156
- };
157
- //# sourceMappingURL=Asset.js.map
110
+ //#endregion
111
+ export { Asset };
112
+
113
+ //# sourceMappingURL=Asset.js.map
@@ -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"],"names":["Title","Vue","defineComponent","name","props","children","type","String","default","setup","router","useRouter","isServer","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"],"mappings":";;;;AAUA,MAAMA,QAAQC,IAAIC,gBAAgB;AAAA,EAChCC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,UAAU;AAAA,MACRC,MAAMC;AAAAA,MACNC,SAAS;AAAA,IACX;AAAA;EAEFC,MAAML,OAAO;AACX,UAAMM,SAASC,UAAS;AAExB,QAAI,EAAEC,YAAYF,OAAOE,WAAW;AAClCX,UAAIY,UAAU,MAAM;AAClB,YAAIT,MAAMC,UAAU;AAClBS,mBAASC,QAAQX,MAAMC;AAAAA,QACzB;AAAA,MACF,CAAC;AAEDJ,UAAIe,MACF,MAAMZ,MAAMC,UACXY,cAAa;AACZ,YAAIA,UAAU;AACZH,mBAASC,QAAQE;AAAAA,QACnB;AAAA,MACF,CACF;AAAA,IACF;AAEA,WAAO,MAAMhB,IAAIiB,EAAE,SAAS,CAAA,GAAId,MAAMC,QAAQ;AAAA,EAChD;AACF,CAAC;AAED,MAAMc,SAASlB,IAAIC,gBAAgB;AAAA,EACjCC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLgB,OAAO;AAAA,MACLd,MAAMe;AAAAA,MACNb,SAASA,OAAO,CAAA;AAAA;IAElBH,UAAU;AAAA,MACRC,MAAMC;AAAAA,MACNC,SAASc;AAAAA,IACX;AAAA;EA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D,eAAOvB,IAAIiB,EAAE,UAAUd,MAAMgB,KAAK;AAAA,MACpC;AAEA,UAAI,OAAOhB,MAAMC,aAAa,UAAU;AACtC,eAAOJ,IAAIiB,EAAE,UAAU;AAAA,UACrB,GAAGd,MAAMgB;AAAAA,UACTkC,WAAWlD,MAAMC;AAAAA,QACnB,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF,CAAC;AAEM,SAASoD,MAAM;AAAA,EAAEC;AAAAA,EAAKtC;AAAAA,EAAOf;AAA2B,GAAQ;AACrE,UAAQqD,KAAG;AAAA,IACT,KAAK;AACH,aAAOzD,IAAIiB,EAAElB,OAAO;AAAA,QAAEK;AAAAA,MAAmB,CAAC;AAAA,IAC5C,KAAK;AACH,aAAAsD,oBAAiBvC,OAAK,IAAA;AAAA,IACxB,KAAK;AACH,aAAAuC,oBAAiBvC,OAAK,IAAA;AAAA,IACxB,KAAK;AACH,aAAAuC,YAAA,SAAAC,WAAkBxC,OAAK;AAAA,QAAA,aAAaf;AAAAA,MAAQ,CAAA,GAAA,IAAA;AAAA,IAC9C,KAAK;AACH,aAAOJ,IAAIiB,EAAEC,QAAQ;AAAA,QAAEC;AAAAA,QAAOf;AAAAA,MAAmB,CAAC;AAAA,IACpD;AACE,aAAO;AAAA,EACX;AACF;"}
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,IA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AClB,CAAC;AAGJ,UAAO;;;CAGZ,CAAC;AAEF,SAAgBkD,MAAM,EAAEC,KAAKtC,OAAOb,YAAmC;AACrE,SAAQmD,KAAR;EACE,KAAK,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
- const Body = Vue.defineComponent({
3
- name: "Body",
4
- setup(_, {
5
- slots
6
- }) {
7
- const isServer = typeof window === "undefined";
8
- return () => {
9
- const children = slots.default?.();
10
- if (isServer) {
11
- return Vue.h("body", {}, Vue.h("div", {
12
- id: "__app"
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
- export {
24
- Body
25
- };
26
- //# sourceMappingURL=Body.js.map
14
+ //#endregion
15
+ export { Body };
16
+
17
+ //# sourceMappingURL=Body.js.map
@@ -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"],"names":["Body","Vue","defineComponent","name","setup","_","slots","isServer","window","children","default","h","id"],"mappings":";MAEaA,OAAOC,IAAIC,gBAAgB;AAAA,EACtCC,MAAM;AAAA,EACNC,MAAMC,GAAG;AAAA,IAAEC;AAAAA,EAAM,GAAG;AAClB,UAAMC,WAAW,OAAOC,WAAW;AAEnC,WAAO,MAAM;AACX,YAAMC,WAAWH,MAAMI,UAAO;AAE9B,UAAIH,UAAU;AACZ,eAAON,IAAIU,EACT,QACA,CAAA,GACAV,IAAIU,EACF,OACA;AAAA,UAAEC,IAAI;AAAA,QAAQ,GACdX,IAAIU,EAAE,OAAO;AAAA,UAAE,uBAAuB;AAAA,QAAG,GAAGF,QAAQ,CACtD,CACF;AAAA,MACF;AAEA,aAAOR,IAAIU,EAAE,OAAO;AAAA,QAAE,uBAAuB;AAAA,SAAMF,QAAQ;AAAA,IAC7D;AAAA,EACF;AACF,CAAC;"}
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
- const VueErrorBoundary = Vue.defineComponent({
3
- name: "VueErrorBoundary",
4
- props: {
5
- onError: Function,
6
- resetKey: [String, Number]
7
- },
8
- emits: ["catch"],
9
- setup(props, {
10
- slots
11
- }) {
12
- const error = Vue.ref(null);
13
- const resetFn = Vue.ref(null);
14
- const reset = () => {
15
- error.value = null;
16
- };
17
- Vue.watch(() => props.resetKey, (newKey, oldKey) => {
18
- if (newKey !== oldKey && error.value) {
19
- reset();
20
- }
21
- });
22
- Vue.onErrorCaptured((err) => {
23
- if (err instanceof Promise || err && typeof err.then === "function") {
24
- return false;
25
- }
26
- error.value = err;
27
- resetFn.value = reset;
28
- if (props.onError) {
29
- props.onError(err);
30
- }
31
- return false;
32
- });
33
- return () => {
34
- if (error.value && slots.fallback) {
35
- const fallbackContent = slots.fallback({
36
- error: error.value,
37
- reset
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
- const CatchBoundaryWrapper = Vue.defineComponent({
47
- name: "CatchBoundary",
48
- inheritAttrs: false,
49
- props: ["getResetKey", "children", "errorComponent", "onCatch"],
50
- setup(props) {
51
- const resetKey = Vue.computed(() => props.getResetKey());
52
- return () => {
53
- return Vue.h(VueErrorBoundary, {
54
- resetKey: resetKey.value,
55
- onError: props.onCatch
56
- }, {
57
- default: () => props.children,
58
- fallback: ({
59
- error,
60
- reset
61
- }) => {
62
- if (props.errorComponent) {
63
- return Vue.h(props.errorComponent, {
64
- error,
65
- reset
66
- });
67
- }
68
- return Vue.h(ErrorComponent, {
69
- error,
70
- reset
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
- return Vue.h(CatchBoundaryWrapper, props);
71
+ return Vue.h(CatchBoundaryWrapper, props);
79
72
  }
80
- const ErrorComponent = Vue.defineComponent({
81
- name: "ErrorComponent",
82
- props: {
83
- error: Object,
84
- reset: Function
85
- },
86
- setup(props) {
87
- const show = Vue.ref(process.env.NODE_ENV !== "production");
88
- const toggleShow = () => {
89
- show.value = !show.value;
90
- };
91
- return () => Vue.h("div", {
92
- style: {
93
- padding: ".5rem",
94
- maxWidth: "100%"
95
- }
96
- }, [Vue.h("div", {
97
- style: {
98
- display: "flex",
99
- alignItems: "center",
100
- gap: ".5rem"
101
- }
102
- }, [Vue.h("strong", {
103
- style: {
104
- fontSize: "1rem"
105
- }
106
- }, "Something went wrong!"), Vue.h("button", {
107
- style: {
108
- appearance: "none",
109
- fontSize: ".6em",
110
- border: "1px solid currentColor",
111
- padding: ".1rem .2rem",
112
- fontWeight: "bold",
113
- borderRadius: ".25rem"
114
- },
115
- onClick: toggleShow
116
- }, show.value ? "Hide Error" : "Show Error")]), Vue.h("div", {
117
- style: {
118
- height: ".25rem"
119
- }
120
- }), show.value ? Vue.h("div", {}, [Vue.h("pre", {
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
- export {
133
- CatchBoundary,
134
- ErrorComponent
135
- };
136
- //# sourceMappingURL=CatchBoundary.js.map
115
+ //#endregion
116
+ export { CatchBoundary, ErrorComponent };
117
+
118
+ //# sourceMappingURL=CatchBoundary.js.map