@tanstack/vue-router 1.141.2 → 1.141.4
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/CatchBoundary.d.ts +4 -2
- package/dist/esm/CatchBoundary.js +29 -28
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ScriptOnce.js +1 -3
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +0 -9
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +6 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/source/CatchBoundary.d.ts +4 -2
- package/dist/source/CatchBoundary.jsx +23 -22
- package/dist/source/CatchBoundary.jsx.map +1 -1
- package/dist/source/ScriptOnce.jsx +2 -2
- package/dist/source/ScriptOnce.jsx.map +1 -1
- package/dist/source/Scripts.jsx +0 -9
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +11 -11
- package/dist/source/Transitioner.jsx.map +1 -1
- package/package.json +2 -2
- package/src/CatchBoundary.tsx +35 -32
- package/src/ScriptOnce.tsx +1 -3
- package/src/Scripts.tsx +0 -11
- package/src/Transitioner.tsx +16 -11
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ErrorRouteComponent } from './route.js';
|
|
2
2
|
import * as Vue from 'vue';
|
|
3
|
-
|
|
3
|
+
type CatchBoundaryProps = {
|
|
4
4
|
getResetKey: () => number | string;
|
|
5
5
|
children: Vue.VNode;
|
|
6
6
|
errorComponent?: ErrorRouteComponent | Vue.Component;
|
|
7
7
|
onCatch?: (error: Error) => void;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function CatchBoundary(props: CatchBoundaryProps): Vue.VNode<Vue.RendererNode, Vue.RendererElement, {
|
|
9
10
|
[key: string]: any;
|
|
10
11
|
}>;
|
|
11
12
|
export declare const ErrorComponent: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
@@ -17,3 +18,4 @@ export declare const ErrorComponent: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
|
17
18
|
error: ObjectConstructor;
|
|
18
19
|
reset: FunctionConstructor;
|
|
19
20
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|
|
21
|
+
export {};
|
|
@@ -43,38 +43,39 @@ const VueErrorBoundary = Vue.defineComponent({
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
error,
|
|
65
|
-
reset
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return Vue.h(ErrorComponent, {
|
|
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, {
|
|
69
64
|
error,
|
|
70
65
|
reset
|
|
71
66
|
});
|
|
72
67
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
return Vue.h(ErrorComponent, {
|
|
69
|
+
error,
|
|
70
|
+
reset
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
function CatchBoundary(props) {
|
|
78
|
+
return Vue.h(CatchBoundaryWrapper, props);
|
|
78
79
|
}
|
|
79
80
|
const ErrorComponent = Vue.defineComponent({
|
|
80
81
|
name: "ErrorComponent",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatchBoundary.js","sources":["../../src/CatchBoundary.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport type { ErrorRouteComponent } from './route'\n\ninterface ErrorComponentProps {\n error: Error\n reset: () => void\n}\n\nconst VueErrorBoundary = Vue.defineComponent({\n name: 'VueErrorBoundary',\n props: {\n onError: Function,\n resetKey: [String, Number],\n },\n emits: ['catch'],\n setup(props, { slots }) {\n const error = Vue.ref<Error | null>(null)\n const resetFn = Vue.ref<(() => void) | null>(null)\n\n const reset = () => {\n error.value = null\n }\n\n Vue.watch(\n () => props.resetKey,\n (newKey, oldKey) => {\n if (newKey !== oldKey && error.value) {\n reset()\n }\n },\n )\n\n Vue.onErrorCaptured((err: Error) => {\n if (\n err instanceof Promise ||\n (err && typeof (err as any).then === 'function')\n ) {\n return false\n }\n\n error.value = err\n resetFn.value = reset\n\n if (props.onError) {\n props.onError(err)\n }\n\n return false\n })\n\n return () => {\n if (error.value && slots.fallback) {\n const fallbackContent = slots.fallback({\n error: error.value,\n reset,\n })\n return Array.isArray(fallbackContent) && fallbackContent.length === 1\n ? fallbackContent[0]\n : fallbackContent\n }\n\n const defaultContent = slots.default && slots.default()\n return Array.isArray(defaultContent) && defaultContent.length === 1\n ? defaultContent[0]\n : defaultContent\n }\n },\n})\n\
|
|
1
|
+
{"version":3,"file":"CatchBoundary.js","sources":["../../src/CatchBoundary.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport type { ErrorRouteComponent } from './route'\n\ninterface ErrorComponentProps {\n error: Error\n reset: () => void\n}\n\ntype CatchBoundaryProps = {\n getResetKey: () => number | string\n children: Vue.VNode\n errorComponent?: ErrorRouteComponent | Vue.Component\n onCatch?: (error: Error) => void\n}\n\nconst VueErrorBoundary = Vue.defineComponent({\n name: 'VueErrorBoundary',\n props: {\n onError: Function,\n resetKey: [String, Number],\n },\n emits: ['catch'],\n setup(props, { slots }) {\n const error = Vue.ref<Error | null>(null)\n const resetFn = Vue.ref<(() => void) | null>(null)\n\n const reset = () => {\n error.value = null\n }\n\n Vue.watch(\n () => props.resetKey,\n (newKey, oldKey) => {\n if (newKey !== oldKey && error.value) {\n reset()\n }\n },\n )\n\n Vue.onErrorCaptured((err: Error) => {\n if (\n err instanceof Promise ||\n (err && typeof (err as any).then === 'function')\n ) {\n return false\n }\n\n error.value = err\n resetFn.value = reset\n\n if (props.onError) {\n props.onError(err)\n }\n\n return false\n })\n\n return () => {\n if (error.value && slots.fallback) {\n const fallbackContent = slots.fallback({\n error: error.value,\n reset,\n })\n return Array.isArray(fallbackContent) && fallbackContent.length === 1\n ? fallbackContent[0]\n : fallbackContent\n }\n\n const defaultContent = slots.default && slots.default()\n return Array.isArray(defaultContent) && defaultContent.length === 1\n ? defaultContent[0]\n : defaultContent\n }\n },\n})\n\nconst CatchBoundaryWrapper = Vue.defineComponent({\n name: 'CatchBoundary',\n inheritAttrs: false,\n props: ['getResetKey', 'children', 'errorComponent', 'onCatch'] as any,\n setup(props: CatchBoundaryProps) {\n const resetKey = Vue.computed(() => props.getResetKey())\n\n return () => {\n return Vue.h(\n VueErrorBoundary,\n {\n resetKey: resetKey.value,\n onError: props.onCatch,\n },\n {\n default: () => props.children,\n fallback: ({ error, reset }: ErrorComponentProps) => {\n if (props.errorComponent) {\n return Vue.h(props.errorComponent, { error, reset })\n }\n return Vue.h(ErrorComponent, { error, reset })\n },\n },\n )\n }\n },\n})\n\nexport function CatchBoundary(props: CatchBoundaryProps) {\n return Vue.h(CatchBoundaryWrapper, props as any)\n}\n\nexport const ErrorComponent = Vue.defineComponent({\n name: 'ErrorComponent',\n props: {\n error: Object,\n reset: Function,\n },\n setup(props) {\n const show = Vue.ref(process.env.NODE_ENV !== 'production')\n\n const toggleShow = () => {\n show.value = !show.value\n }\n\n return () =>\n Vue.h('div', { style: { padding: '.5rem', maxWidth: '100%' } }, [\n Vue.h(\n 'div',\n { style: { display: 'flex', alignItems: 'center', gap: '.5rem' } },\n [\n Vue.h(\n 'strong',\n { style: { fontSize: '1rem' } },\n 'Something went wrong!',\n ),\n Vue.h(\n 'button',\n {\n style: {\n appearance: 'none',\n fontSize: '.6em',\n border: '1px solid currentColor',\n padding: '.1rem .2rem',\n fontWeight: 'bold',\n borderRadius: '.25rem',\n },\n onClick: toggleShow,\n },\n show.value ? 'Hide Error' : 'Show Error',\n ),\n ],\n ),\n Vue.h('div', { style: { height: '.25rem' } }),\n show.value\n ? Vue.h('div', {}, [\n Vue.h(\n 'pre',\n {\n style: {\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.3rem',\n color: 'red',\n overflow: 'auto',\n },\n },\n [\n props.error?.message\n ? Vue.h('code', {}, props.error.message)\n : null,\n ],\n ),\n ])\n : null,\n ])\n },\n})\n"],"names":["VueErrorBoundary","Vue","defineComponent","name","props","onError","Function","resetKey","String","Number","emits","setup","slots","error","ref","resetFn","reset","value","watch","newKey","oldKey","onErrorCaptured","err","Promise","then","fallback","fallbackContent","Array","isArray","length","defaultContent","default","CatchBoundaryWrapper","inheritAttrs","computed","getResetKey","h","onCatch","children","errorComponent","ErrorComponent","CatchBoundary","Object","show","process","env","NODE_ENV","toggleShow","style","padding","maxWidth","display","alignItems","gap","fontSize","appearance","border","fontWeight","borderRadius","onClick","height","color","overflow","message"],"mappings":";AAeA,MAAMA,mBAAmBC,IAAIC,gBAAgB;AAAA,EAC3CC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,SAASC;AAAAA,IACTC,UAAU,CAACC,QAAQC,MAAM;AAAA;EAE3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,UAAU;AAAA,MAAO;AAAA,OAC5B,uBACF,GACArD,IAAImC,EACF,UACA;AAAA,MACEY,OAAO;AAAA,QACLO,YAAY;AAAA,QACZD,UAAU;AAAA,QACVE,QAAQ;AAAA,QACRP,SAAS;AAAA,QACTQ,YAAY;AAAA,QACZC,cAAc;AAAA;MAEhBC,SAASZ;AAAAA,IACX,GACAJ,KAAK1B,QAAQ,eAAe,YAC9B,CAAC,CAEL,GACAhB,IAAImC,EAAE,OAAO;AAAA,MAAEY,OAAO;AAAA,QAAEY,QAAQ;AAAA,MAAS;AAAA,KAAG,GAC5CjB,KAAK1B,QACDhB,IAAImC,EAAE,OAAO,CAAA,GAAI,CACfnC,IAAImC,EACF,OACA;AAAA,MACEY,OAAO;AAAA,QACLM,UAAU;AAAA,QACVE,QAAQ;AAAA,QACRE,cAAc;AAAA,QACdT,SAAS;AAAA,QACTY,OAAO;AAAA,QACPC,UAAU;AAAA,MACZ;AAAA,IACF,GACA,CACE1D,MAAMS,OAAOkD,UACT9D,IAAImC,EAAE,QAAQ,CAAA,GAAIhC,MAAMS,MAAMkD,OAAO,IACrC,IAAI,CAEZ,CAAC,CACF,IACD,IAAI,CACT;AAAA,EACL;AACF,CAAC;"}
|
package/dist/esm/ScriptOnce.js
CHANGED
|
@@ -14,8 +14,7 @@ const ScriptOnce = Vue.defineComponent({
|
|
|
14
14
|
if (router.isServer) {
|
|
15
15
|
return () => createVNode("script", {
|
|
16
16
|
"nonce": router.options.ssr?.nonce,
|
|
17
|
-
"
|
|
18
|
-
"innerHTML": props.children
|
|
17
|
+
"innerHTML": props.children + ";document.currentScript.remove()"
|
|
19
18
|
}, null);
|
|
20
19
|
}
|
|
21
20
|
const mounted = Vue.ref(false);
|
|
@@ -28,7 +27,6 @@ const ScriptOnce = Vue.defineComponent({
|
|
|
28
27
|
}
|
|
29
28
|
return createVNode("script", {
|
|
30
29
|
"nonce": router.options.ssr?.nonce,
|
|
31
|
-
"class": "$tsr",
|
|
32
30
|
"data-allow-mismatch": true,
|
|
33
31
|
"innerHTML": ""
|
|
34
32
|
}, null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useRouter } from './useRouter'\n\nexport const ScriptOnce = Vue.defineComponent({\n name: 'ScriptOnce',\n props: {\n children: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n if (router.isServer) {\n return () => (\n <script\n nonce={router.options.ssr?.nonce}\n
|
|
1
|
+
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useRouter } from './useRouter'\n\nexport const ScriptOnce = Vue.defineComponent({\n name: 'ScriptOnce',\n props: {\n children: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n if (router.isServer) {\n return () => (\n <script\n nonce={router.options.ssr?.nonce}\n innerHTML={props.children + ';document.currentScript.remove()'}\n />\n )\n }\n\n const mounted = Vue.ref(false)\n Vue.onMounted(() => {\n mounted.value = true\n })\n\n return () => {\n if (mounted.value) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n data-allow-mismatch\n innerHTML=\"\"\n />\n )\n }\n },\n})\n"],"names":["ScriptOnce","Vue","defineComponent","name","props","children","type","String","required","setup","router","useRouter","isServer","_createVNode","options","ssr","nonce","mounted","ref","onMounted","value"],"mappings":";;;MAGaA,aAAaC,IAAIC,gBAAgB;AAAA,EAC5CC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,UAAU;AAAA,MACRC,MAAMC;AAAAA,MACNC,UAAU;AAAA,IACZ;AAAA;EAEFC,MAAML,OAAO;AACX,UAAMM,SAASC,UAAS;AAExB,QAAID,OAAOE,UAAU;AACnB,aAAO,MAAAC,YAAA,UAAA;AAAA,QAAA,SAEIH,OAAOI,QAAQC,KAAKC;AAAAA,QAAK,aACrBZ,MAAMC,WAAW;AAAA,SAAkC,IAAA;AAAA,IAGpE;AAEA,UAAMY,UAAUhB,IAAIiB,IAAI,KAAK;AAC7BjB,QAAIkB,UAAU,MAAM;AAClBF,cAAQG,QAAQ;AAAA,IAClB,CAAC;AAED,WAAO,MAAM;AACX,UAAIH,QAAQG,OAAO;AACjB,eAAO;AAAA,MACT;AAEA,aAAAP,YAAA,UAAA;AAAA,QAAA,SAEWH,OAAOI,QAAQC,KAAKC;AAAAA,QAAK,uBAAA;AAAA,QAAA,aAAA;AAAA,MAAA,GAAA,IAAA;AAAA,IAKtC;AAAA,EACF;AACF,CAAC;"}
|
package/dist/esm/Scripts.js
CHANGED
|
@@ -3,7 +3,6 @@ import { createVNode, Fragment, mergeProps } from "vue";
|
|
|
3
3
|
import { Asset } from "./Asset.js";
|
|
4
4
|
import { useRouterState } from "./useRouterState.js";
|
|
5
5
|
import { useRouter } from "./useRouter.js";
|
|
6
|
-
const VUE_DEFER_SCRIPT = "self.$_TSR_DEFER=true";
|
|
7
6
|
const Scripts = Vue.defineComponent({
|
|
8
7
|
name: "Scripts",
|
|
9
8
|
setup() {
|
|
@@ -51,13 +50,6 @@ const Scripts = Vue.defineComponent({
|
|
|
51
50
|
return () => {
|
|
52
51
|
const allScripts = [];
|
|
53
52
|
if (router.serverSsr) {
|
|
54
|
-
allScripts.push({
|
|
55
|
-
tag: "script",
|
|
56
|
-
attrs: {
|
|
57
|
-
nonce
|
|
58
|
-
},
|
|
59
|
-
children: VUE_DEFER_SCRIPT
|
|
60
|
-
});
|
|
61
53
|
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
62
54
|
if (serverBufferedScript) {
|
|
63
55
|
allScripts.push(serverBufferedScript);
|
|
@@ -75,7 +67,6 @@ const Scripts = Vue.defineComponent({
|
|
|
75
67
|
tag: "script",
|
|
76
68
|
attrs: {
|
|
77
69
|
nonce,
|
|
78
|
-
class: "$tsr",
|
|
79
70
|
id: "$tsr-stream-barrier",
|
|
80
71
|
"data-allow-mismatch": true
|
|
81
72
|
},
|
package/dist/esm/Scripts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\
|
|
1
|
+
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = Vue.defineComponent({\n name: 'Scripts',\n setup() {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n\n const assetScripts = useRouterState({\n select: (state) => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: { ...asset.attrs, nonce },\n children: asset.children,\n } as RouterManagedTag)\n }),\n )\n\n return assetScripts\n },\n })\n\n const scripts = useRouterState({\n select: (state) => ({\n scripts: (\n state.matches\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script' as const,\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\n }),\n })\n\n const mounted = Vue.ref(false)\n Vue.onMounted(() => {\n mounted.value = true\n })\n\n return () => {\n const allScripts: Array<RouterManagedTag> = []\n\n if (router.serverSsr) {\n const serverBufferedScript = router.serverSsr.takeBufferedScripts()\n if (serverBufferedScript) {\n allScripts.push(serverBufferedScript)\n }\n } else if (router.ssr && !mounted.value) {\n allScripts.push({\n tag: 'script',\n attrs: { nonce, 'data-allow-mismatch': true },\n children: '',\n } as RouterManagedTag)\n\n allScripts.push({\n tag: 'script',\n attrs: {\n nonce,\n id: '$tsr-stream-barrier',\n 'data-allow-mismatch': true,\n },\n children: '',\n } as RouterManagedTag)\n\n for (const asset of assetScripts.value) {\n allScripts.push({\n tag: 'script',\n attrs: {\n ...asset.attrs,\n 'data-allow-mismatch': true,\n },\n children: '',\n } as RouterManagedTag)\n }\n }\n\n for (const script of scripts.value.scripts) {\n allScripts.push(script as RouterManagedTag)\n }\n\n if (mounted.value || router.serverSsr) {\n for (const asset of assetScripts.value) {\n allScripts.push(asset)\n }\n }\n\n return (\n <>\n {allScripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n }\n },\n})\n"],"names":["Scripts","Vue","defineComponent","name","setup","router","useRouter","nonce","options","ssr","assetScripts","useRouterState","select","state","manifest","matches","map","match","looseRoutesById","routeId","forEach","route","routes","id","assets","filter","d","tag","asset","push","attrs","children","scripts","flat","Boolean","script","mounted","ref","onMounted","value","allScripts","serverSsr","serverBufferedScript","takeBufferedScripts","_createVNode","_Fragment","i","Asset","_mergeProps"],"mappings":";;;;;MAMaA,UAAUC,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AACN,UAAMC,SAASC,UAAS;AACxB,UAAMC,QAAQF,OAAOG,QAAQC,KAAKF;AAElC,UAAMG,eAAeC,eAAe;AAAA,MAClCC,QAASC,WAAU;AACjB,cAAMH,gBAAwC,CAAA;AAC9C,cAAMI,WAAWT,OAAOI,KAAKK;AAE7B,YAAI,CAACA,UAAU;AACb,iBAAO,CAAA;AAAA,QACT;AAEAD,cAAME,QACHC,IAAKC,WAAUZ,OAAOa,gBAAgBD,MAAME,OAAO,CAAE,EACrDC,QAASC,WACRP,SAASQ,OAAOD,MAAME,EAAE,GAAGC,QACvBC,OAAQC,OAAMA,EAAEC,QAAQ,QAAQ,EACjCP,QAASQ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AASlB,aAAa6B,OAAO;AACtCC,qBAAWX,KAAK;AAAA,YACdF,KAAK;AAAA,YACLG,OAAO;AAAA,cACL,GAAGF,MAAME;AAAAA,cACT,uBAAuB;AAAA;YAEzBC,UAAU;AAAA,UACZ,CAAqB;AAAA,QACvB;AAAA,MACF;AAEA,iBAAWI,UAAUH,QAAQO,MAAMP,SAAS;AAC1CQ,mBAAWX,KAAKM,MAA0B;AAAA,MAC5C;AAEA,UAAIC,QAAQG,SAASlC,OAAOoC,WAAW;AACrC,mBAAWb,SAASlB,aAAa6B,OAAO;AACtCC,qBAAWX,KAAKD,KAAK;AAAA,QACvB;AAAA,MACF;AAEA,aAAAgB,YAAAC,iBAEKL,WAAWxB,IAAI,CAACY,OAAOkB,MAACF,YAAAG,OAAAC,WACZpB,OAAK;AAAA,QAAA,OAAO,eAAeA,MAAMD,GAAG,IAAImB,CAAC;AAAA,MAAE,CAAA,GAAA,IAAA,CACvD,CAAC,CAAA;AAAA,IAGR;AAAA,EACF;AACF,CAAC;"}
|
package/dist/esm/Transitioner.js
CHANGED
|
@@ -50,8 +50,13 @@ function useTransitionerSetup() {
|
|
|
50
50
|
fn();
|
|
51
51
|
endTransition();
|
|
52
52
|
};
|
|
53
|
+
const originalStartViewTransition = router.__tsrOriginalStartViewTransition ?? router.startViewTransition;
|
|
54
|
+
router.__tsrOriginalStartViewTransition = originalStartViewTransition;
|
|
53
55
|
router.startViewTransition = (fn) => {
|
|
54
|
-
|
|
56
|
+
return originalStartViewTransition?.(async () => {
|
|
57
|
+
await fn();
|
|
58
|
+
await Vue.nextTick();
|
|
59
|
+
});
|
|
55
60
|
};
|
|
56
61
|
let unsubscribe;
|
|
57
62
|
Vue.onMounted(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\n// Track mount state per router to avoid double-loading\nlet mountLoadForRouter = { router: null as any, mounted: false }\n\n/**\n * Composable that sets up router transition logic.\n * This is called from MatchesContent to set up:\n * - router.startTransition\n * - router.startViewTransition\n * - History subscription\n * - Router event watchers\n *\n * Must be called during component setup phase.\n */\nexport function useTransitionerSetup() {\n const router = useRouter()\n\n // Skip on server - no transitions needed\n if (router.isServer) {\n return\n }\n\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n // Track if we're in a transition - using a ref to track async transitions\n const isTransitioning = Vue.ref(false)\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(() => isLoading.value)\n\n const isAnyPending = Vue.computed(\n () => isLoading.value || isTransitioning.value || hasPendingMatches.value,\n )\n const previousIsAnyPending = usePrevious(() => isAnyPending.value)\n\n const isPagePending = Vue.computed(\n () => isLoading.value || hasPendingMatches.value,\n )\n const previousIsPagePending = usePrevious(() => isPagePending.value)\n\n // Implement startTransition similar to React/Solid\n // Vue doesn't have a native useTransition like React 18, so we simulate it\n // We also update the router state's isTransitioning flag so useMatch can check it\n router.startTransition = (fn: () => void | Promise<void>) => {\n isTransitioning.value = true\n // Also update the router state so useMatch knows we're transitioning\n try {\n router.__store.setState((s) => ({ ...s, isTransitioning: true }))\n } catch {\n // Ignore errors if component is unmounted\n }\n\n // Helper to end the transition\n const endTransition = () => {\n // Use nextTick to ensure Vue has processed all reactive updates\n Vue.nextTick(() => {\n try {\n isTransitioning.value = false\n router.__store.setState((s) => ({ ...s, isTransitioning: false }))\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n }\n\n // Execute the function synchronously\n // The function internally may call startViewTransition which schedules async work\n // via document.startViewTransition, but we don't need to wait for it here\n // because Vue's reactivity will trigger re-renders when state changes\n fn()\n\n // End the transition on next tick to allow Vue to process reactive updates\n endTransition()\n }\n\n // For Vue, we need to completely override startViewTransition because Vue's\n // async rendering doesn't work well with the View Transitions API's requirement\n // for synchronous DOM updates. The browser expects the DOM to be updated\n // when the callback promise resolves, but Vue updates asynchronously.\n //\n // Our approach: Skip the actual view transition animation but still update state.\n // This ensures navigation works correctly even without the visual transition.\n // In the future, we could explore using viewTransition.captured like vue-view-transitions does.\n router.startViewTransition = (fn: () => Promise<void>) => {\n // Just run the callback directly without wrapping in document.startViewTransition\n // This ensures the state updates happen and Vue can render them normally\n fn()\n }\n\n // Subscribe to location changes\n // and try to load the new location\n let unsubscribe: (() => void) | undefined\n\n Vue.onMounted(() => {\n unsubscribe = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n })\n\n // Track if component is mounted to prevent updates after unmount\n const isMounted = Vue.ref(false)\n\n Vue.onMounted(() => {\n isMounted.value = true\n })\n\n Vue.onUnmounted(() => {\n isMounted.value = false\n if (unsubscribe) {\n unsubscribe()\n }\n })\n\n // Try to load the initial location\n Vue.onMounted(() => {\n if (\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n\n // Setup watchers for emitting events\n // All watchers check isMounted to prevent updates after unmount\n Vue.watch(\n () => isLoading.value,\n (newValue) => {\n if (!isMounted.value) return\n try {\n if (previousIsLoading.value.previous && !newValue) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n },\n )\n\n Vue.watch(isPagePending, (newValue) => {\n if (!isMounted.value) return\n try {\n // emit onBeforeRouteMount\n if (previousIsPagePending.value.previous && !newValue) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n\n Vue.watch(isAnyPending, (newValue) => {\n if (!isMounted.value) return\n try {\n // The router was pending and now it's not\n if (previousIsAnyPending.value.previous && !newValue) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n}\n\n/**\n * @deprecated Use useTransitionerSetup() composable instead.\n * This component is kept for backwards compatibility but the setup logic\n * has been moved to useTransitionerSetup() for better SSR hydration.\n */\nexport const Transitioner = Vue.defineComponent({\n name: 'Transitioner',\n setup() {\n useTransitionerSetup()\n return () => null\n },\n})\n"],"names":["mountLoadForRouter","router","mounted","useTransitionerSetup","useRouter","isServer","isLoading","useRouterState","select","isTransitioning","Vue","ref","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","value","isAnyPending","computed","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","__store","setState","endTransition","nextTick","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","href","commitLocation","replace","isMounted","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","getLocationChangeInfo","changeInfo","resolvedLocation","location","hrefChanged","handleHashScroll","defineComponent","name","setup"],"mappings":";;;;;AAWA,IAAIA,qBAAqB;AAAA,EAAEC,QAAQ;AAAA,EAAaC,SAAS;AAAM;AAYxD,SAASC,uBAAuB;AACrC,QAAMF,SAASG,UAAS;AAGxB,MAAIH,OAAOI,UAAU;AACnB;AAAA,EACF;AA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AA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CACF;AAEApC,MAAIkD,MAAMpC,eAAgBqC,cAAa;AACrC,QAAI,CAACT,UAAUhC,MAAO;AACtB,QAAI;AAEF,UAAIK,sBAAsBL,MAAM0C,YAAY,CAACD,UAAU;AACrD5D,eAAO8D,KAAK;AAAA,UACVC,MAAM;AAAA,UACN,GAAGC,sBAAsBhE,OAAO6C,KAAK;AAAA,QACvC,CAAC;AAAA,MACH;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CAAC;AAEDpC,MAAIkD,MAAMvC,cAAewC,cAAa;AACpC,QAAI,CAACT,UAAUhC,MAAO;AACtB,QAAI;AAEF,UAAIG,qBAAqBH,MAAM0C,YAAY,CAACD,UAAU;AACpD,cAAMK,aAAaD,sBAAsBhE,OAAO6C,KAAK;AACrD7C,eAAO8D,KAAK;AAAA,UACVC,MAAM;AAAA,UACN,GAAGE;AAAAA,QACL,CAAC;AAEDjE,eAAO2B,QAAQC,SAAUhB,QAAO;AAAA,UAC9B,GAAGA;AAAAA,UACHI,QAAQ;AAAA,UACRkD,kBAAkBtD,EAAEuD;AAAAA,QACtB,EAAE;AAEF,YAAIF,WAAWG,aAAa;AAC1BC,2BAAiBrE,MAAM;AAAA,QACzB;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CAAC;AACH;AAO4BS,IAAI6D,gBAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,QAAQ;AACNtE,yBAAoB;AACpB,WAAO,MAAM;AAAA,EACf;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\n// Track mount state per router to avoid double-loading\nlet mountLoadForRouter = { router: null as any, mounted: false }\n\n/**\n * Composable that sets up router transition logic.\n * This is called from MatchesContent to set up:\n * - router.startTransition\n * - router.startViewTransition\n * - History subscription\n * - Router event watchers\n *\n * Must be called during component setup phase.\n */\nexport function useTransitionerSetup() {\n const router = useRouter()\n\n // Skip on server - no transitions needed\n if (router.isServer) {\n return\n }\n\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n // Track if we're in a transition - using a ref to track async transitions\n const isTransitioning = Vue.ref(false)\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(() => isLoading.value)\n\n const isAnyPending = Vue.computed(\n () => isLoading.value || isTransitioning.value || hasPendingMatches.value,\n )\n const previousIsAnyPending = usePrevious(() => isAnyPending.value)\n\n const isPagePending = Vue.computed(\n () => isLoading.value || hasPendingMatches.value,\n )\n const previousIsPagePending = usePrevious(() => isPagePending.value)\n\n // Implement startTransition similar to React/Solid\n // Vue doesn't have a native useTransition like React 18, so we simulate it\n // We also update the router state's isTransitioning flag so useMatch can check it\n router.startTransition = (fn: () => void | Promise<void>) => {\n isTransitioning.value = true\n // Also update the router state so useMatch knows we're transitioning\n try {\n router.__store.setState((s) => ({ ...s, isTransitioning: true }))\n } catch {\n // Ignore errors if component is unmounted\n }\n\n // Helper to end the transition\n const endTransition = () => {\n // Use nextTick to ensure Vue has processed all reactive updates\n Vue.nextTick(() => {\n try {\n isTransitioning.value = false\n router.__store.setState((s) => ({ ...s, isTransitioning: false }))\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n }\n\n // Execute the function synchronously\n // The function internally may call startViewTransition which schedules async work\n // via document.startViewTransition, but we don't need to wait for it here\n // because Vue's reactivity will trigger re-renders when state changes\n fn()\n\n // End the transition on next tick to allow Vue to process reactive updates\n endTransition()\n }\n\n // Vue updates DOM asynchronously (next tick). The View Transitions API expects the\n // update callback promise to resolve only after the DOM has been updated.\n // Wrap the router-core implementation to await a Vue flush before resolving.\n const originalStartViewTransition:\n | undefined\n | ((fn: () => Promise<void>) => void) =\n (router as any).__tsrOriginalStartViewTransition ??\n router.startViewTransition\n\n ;(router as any).__tsrOriginalStartViewTransition =\n originalStartViewTransition\n\n router.startViewTransition = (fn: () => Promise<void>) => {\n return originalStartViewTransition?.(async () => {\n await fn()\n await Vue.nextTick()\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n let unsubscribe: (() => void) | undefined\n\n Vue.onMounted(() => {\n unsubscribe = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n })\n\n // Track if component is mounted to prevent updates after unmount\n const isMounted = Vue.ref(false)\n\n Vue.onMounted(() => {\n isMounted.value = true\n })\n\n Vue.onUnmounted(() => {\n isMounted.value = false\n if (unsubscribe) {\n unsubscribe()\n }\n })\n\n // Try to load the initial location\n Vue.onMounted(() => {\n if (\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n\n // Setup watchers for emitting events\n // All watchers check isMounted to prevent updates after unmount\n Vue.watch(\n () => isLoading.value,\n (newValue) => {\n if (!isMounted.value) return\n try {\n if (previousIsLoading.value.previous && !newValue) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n },\n )\n\n Vue.watch(isPagePending, (newValue) => {\n if (!isMounted.value) return\n try {\n // emit onBeforeRouteMount\n if (previousIsPagePending.value.previous && !newValue) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n\n Vue.watch(isAnyPending, (newValue) => {\n if (!isMounted.value) return\n try {\n // The router was pending and now it's not\n if (previousIsAnyPending.value.previous && !newValue) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n } catch {\n // Ignore errors if component is unmounted\n }\n })\n}\n\n/**\n * @deprecated Use useTransitionerSetup() composable instead.\n * This component is kept for backwards compatibility but the setup logic\n * has been moved to useTransitionerSetup() for better SSR hydration.\n */\nexport const Transitioner = Vue.defineComponent({\n name: 'Transitioner',\n setup() {\n useTransitionerSetup()\n return () => null\n },\n})\n"],"names":["mountLoadForRouter","router","mounted","useTransitionerSetup","useRouter","isServer","isLoading","useRouterState","select","isTransitioning","Vue","ref","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","value","isAnyPending","computed","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","__store","setState","endTransition","nextTick","originalStartViewTransition","__tsrOriginalStartViewTransition","startViewTransition","unsubscribe","onMounted","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","href","commitLocation","replace","isMounted","onUnmounted","window","ssr","tryLoad","err","console","error","watch","newValue","previous","emit","type","getLocationChangeInfo","changeInfo","resolvedLocation","location","hrefChanged","handleHashScroll","defineComponent","name","setup"],"mappings":";;;;;AAWA,IAAIA,qBAAqB;AAAA,EAAEC,QAAQ;AAAA,EAAaC,SAAS;AAAM;AAYxD,SAASC,uBAAuB;AACrC,QAAMF,SAASG,UAAS;AAGxB,MAAIH,OAAOI,UAAU;AACnB;AAAA,EACF;AAEA,QAAMC,YAAYC,eAAe;AAAA,IAC/BC,QAAQA,CAAC;AAAA,MAAEF,WAAAA;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;AAAA,UACN,GAAGC,sBAAsBlE,OAAO+C,KAAK;AAAA,QACvC,CAAC;AAAA,MACH;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CACF;AAEAtC,MAAIoD,MAAMtC,eAAgBuC,cAAa;AACrC,QAAI,CAACT,UAAUlC,MAAO;AACtB,QAAI;AAEF,UAAIK,sBAAsBL,MAAM4C,YAAY,CAACD,UAAU;AACrD9D,eAAOgE,KAAK;AAAA,UACVC,MAAM;AAAA,UACN,GAAGC,sBAAsBlE,OAAO+C,KAAK;AAAA,QACvC,CAAC;AAAA,MACH;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CAAC;AAEDtC,MAAIoD,MAAMzC,cAAe0C,cAAa;AACpC,QAAI,CAACT,UAAUlC,MAAO;AACtB,QAAI;AAEF,UAAIG,qBAAqBH,MAAM4C,YAAY,CAACD,UAAU;AACpD,cAAMK,aAAaD,sBAAsBlE,OAAO+C,KAAK;AACrD/C,eAAOgE,KAAK;AAAA,UACVC,MAAM;AAAA,UACN,GAAGE;AAAAA,QACL,CAAC;AAEDnE,eAAO2B,QAAQC,SAAUhB,QAAO;AAAA,UAC9B,GAAGA;AAAAA,UACHI,QAAQ;AAAA,UACRoD,kBAAkBxD,EAAEyD;AAAAA,QACtB,EAAE;AAEF,YAAIF,WAAWG,aAAa;AAC1BC,2BAAiBvE,MAAM;AAAA,QACzB;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IACN;AAAA,EAEJ,CAAC;AACH;AAO4BS,IAAI+D,gBAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,QAAQ;AACNxE,yBAAoB;AACpB,WAAO,MAAM;AAAA,EACf;AACF,CAAC;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
2
|
import type { ErrorRouteComponent } from './route';
|
|
3
|
-
|
|
3
|
+
type CatchBoundaryProps = {
|
|
4
4
|
getResetKey: () => number | string;
|
|
5
5
|
children: Vue.VNode;
|
|
6
6
|
errorComponent?: ErrorRouteComponent | Vue.Component;
|
|
7
7
|
onCatch?: (error: Error) => void;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function CatchBoundary(props: CatchBoundaryProps): Vue.VNode<Vue.RendererNode, Vue.RendererElement, {
|
|
9
10
|
[key: string]: any;
|
|
10
11
|
}>;
|
|
11
12
|
export declare const ErrorComponent: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
@@ -17,3 +18,4 @@ export declare const ErrorComponent: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
|
17
18
|
error: ObjectConstructor;
|
|
18
19
|
reset: FunctionConstructor;
|
|
19
20
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|
|
21
|
+
export {};
|
|
@@ -46,29 +46,30 @@ const VueErrorBoundary = Vue.defineComponent({
|
|
|
46
46
|
};
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
|
+
const CatchBoundaryWrapper = Vue.defineComponent({
|
|
50
|
+
name: 'CatchBoundary',
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
props: ['getResetKey', 'children', 'errorComponent', 'onCatch'],
|
|
53
|
+
setup(props) {
|
|
54
|
+
const resetKey = Vue.computed(() => props.getResetKey());
|
|
55
|
+
return () => {
|
|
56
|
+
return Vue.h(VueErrorBoundary, {
|
|
57
|
+
resetKey: resetKey.value,
|
|
58
|
+
onError: props.onCatch,
|
|
59
|
+
}, {
|
|
60
|
+
default: () => props.children,
|
|
61
|
+
fallback: ({ error, reset }) => {
|
|
62
|
+
if (props.errorComponent) {
|
|
63
|
+
return Vue.h(props.errorComponent, { error, reset });
|
|
64
|
+
}
|
|
65
|
+
return Vue.h(ErrorComponent, { error, reset });
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
49
71
|
export function CatchBoundary(props) {
|
|
50
|
-
|
|
51
|
-
name: 'CatchBoundaryWrapper',
|
|
52
|
-
inheritAttrs: false,
|
|
53
|
-
setup() {
|
|
54
|
-
const resetKey = Vue.computed(() => props.getResetKey());
|
|
55
|
-
return () => {
|
|
56
|
-
return Vue.h(VueErrorBoundary, {
|
|
57
|
-
resetKey: resetKey.value,
|
|
58
|
-
onError: props.onCatch,
|
|
59
|
-
}, {
|
|
60
|
-
default: () => props.children,
|
|
61
|
-
fallback: ({ error, reset }) => {
|
|
62
|
-
if (props.errorComponent) {
|
|
63
|
-
return Vue.h(props.errorComponent, { error, reset });
|
|
64
|
-
}
|
|
65
|
-
return Vue.h(ErrorComponent, { error, reset });
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
return Vue.h(CatchBoundaryWrapper);
|
|
72
|
+
return Vue.h(CatchBoundaryWrapper, props);
|
|
72
73
|
}
|
|
73
74
|
export const ErrorComponent = Vue.defineComponent({
|
|
74
75
|
name: 'ErrorComponent',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatchBoundary.jsx","sourceRoot":"","sources":["../../src/CatchBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"CatchBoundary.jsx","sourceRoot":"","sources":["../../src/CatchBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAe1B,MAAM,gBAAgB,GAAG,GAAG,CAAC,eAAe,CAAC;IAC3C,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE;QACL,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;KAC3B;IACD,KAAK,EAAE,CAAC,OAAO,CAAC;IAChB,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAe,IAAI,CAAC,CAAA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C,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK;gBACR,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE;oBACf,GAAG,CAAC,CAAC,CACH,KAAK,EACL;wBACE,KAAK,EAAE;4BACL,QAAQ,EAAE,MAAM;4BAChB,MAAM,EAAE,eAAe;4BACvB,YAAY,EAAE,QAAQ;4BACtB,OAAO,EAAE,OAAO;4BAChB,KAAK,EAAE,KAAK;4BACZ,QAAQ,EAAE,MAAM;yBACjB;qBACF,EACD;wBACE,KAAK,CAAC,KAAK,EAAE,OAAO;4BAClB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;4BACxC,CAAC,CAAC,IAAI;qBACT,CACF;iBACF,CAAC;gBACJ,CAAC,CAAC,IAAI;SACT,CAAC,CAAA;IACN,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -11,7 +11,7 @@ export const ScriptOnce = Vue.defineComponent({
|
|
|
11
11
|
setup(props) {
|
|
12
12
|
const router = useRouter();
|
|
13
13
|
if (router.isServer) {
|
|
14
|
-
return () => (<script nonce={router.options.ssr?.nonce}
|
|
14
|
+
return () => (<script nonce={router.options.ssr?.nonce} innerHTML={props.children + ';document.currentScript.remove()'}/>);
|
|
15
15
|
}
|
|
16
16
|
const mounted = Vue.ref(false);
|
|
17
17
|
Vue.onMounted(() => {
|
|
@@ -21,7 +21,7 @@ export const ScriptOnce = Vue.defineComponent({
|
|
|
21
21
|
if (mounted.value) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
return (<script nonce={router.options.ssr?.nonce}
|
|
24
|
+
return (<script nonce={router.options.ssr?.nonce} data-allow-mismatch innerHTML=""/>);
|
|
25
25
|
};
|
|
26
26
|
},
|
|
27
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOnce.jsx","sourceRoot":"","sources":["../../src/ScriptOnce.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,CAAC;IAC5C,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf;KACF;IACD,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAE1B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,GAAG,EAAE,CAAC,CACX,CAAC,MAAM,CACL,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CACjC,
|
|
1
|
+
{"version":3,"file":"ScriptOnce.jsx","sourceRoot":"","sources":["../../src/ScriptOnce.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,eAAe,CAAC;IAC5C,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf;KACF;IACD,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAE1B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,GAAG,EAAE,CAAC,CACX,CAAC,MAAM,CACL,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CACjC,SAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,kCAAkC,CAAC,EAC/D,CACH,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC9B,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;YACjB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,CACL,CAAC,MAAM,CACL,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CACjC,mBAAmB,CACnB,SAAS,CAAC,EAAE,EACZ,CACH,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/dist/source/Scripts.jsx
CHANGED
|
@@ -2,9 +2,6 @@ import * as Vue from 'vue';
|
|
|
2
2
|
import { Asset } from './Asset';
|
|
3
3
|
import { useRouterState } from './useRouterState';
|
|
4
4
|
import { useRouter } from './useRouter';
|
|
5
|
-
// Script that sets the defer flag for Vue - must run BEFORE TSR bootstrap script
|
|
6
|
-
// This prevents $_TSR.c() from removing scripts until Vue hydration is complete
|
|
7
|
-
const VUE_DEFER_SCRIPT = 'self.$_TSR_DEFER=true';
|
|
8
5
|
export const Scripts = Vue.defineComponent({
|
|
9
6
|
name: 'Scripts',
|
|
10
7
|
setup() {
|
|
@@ -53,11 +50,6 @@ export const Scripts = Vue.defineComponent({
|
|
|
53
50
|
return () => {
|
|
54
51
|
const allScripts = [];
|
|
55
52
|
if (router.serverSsr) {
|
|
56
|
-
allScripts.push({
|
|
57
|
-
tag: 'script',
|
|
58
|
-
attrs: { nonce },
|
|
59
|
-
children: VUE_DEFER_SCRIPT,
|
|
60
|
-
});
|
|
61
53
|
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
62
54
|
if (serverBufferedScript) {
|
|
63
55
|
allScripts.push(serverBufferedScript);
|
|
@@ -73,7 +65,6 @@ export const Scripts = Vue.defineComponent({
|
|
|
73
65
|
tag: 'script',
|
|
74
66
|
attrs: {
|
|
75
67
|
nonce,
|
|
76
|
-
class: '$tsr',
|
|
77
68
|
id: '$tsr-stream-barrier',
|
|
78
69
|
'data-allow-mismatch': true,
|
|
79
70
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scripts.jsx","sourceRoot":"","sources":["../../src/Scripts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,
|
|
1
|
+
{"version":3,"file":"Scripts.jsx","sourceRoot":"","sources":["../../src/Scripts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,eAAe,CAAC;IACzC,IAAI,EAAE,SAAS;IACf,KAAK;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAA;QAEvC,MAAM,YAAY,GAAG,cAAc,CAAC;YAClC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,MAAM,YAAY,GAA4B,EAAE,CAAA;gBAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAA;gBAErC,IAAI,CAAC,QAAQ,EAAE,CAAC;oB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AED,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACtC,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;oBACvC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACxB,CAAC;YACH,CAAC;YAED,OAAO,CACL,EACE;UAAA,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,eAAe,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAAG,CAC3D,CAAC,CACJ;QAAA,GAAG,CACJ,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -68,18 +68,18 @@ export function useTransitionerSetup() {
|
|
|
68
68
|
// End the transition on next tick to allow Vue to process reactive updates
|
|
69
69
|
endTransition();
|
|
70
70
|
};
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// In the future, we could explore using viewTransition.captured like vue-view-transitions does.
|
|
71
|
+
// Vue updates DOM asynchronously (next tick). The View Transitions API expects the
|
|
72
|
+
// update callback promise to resolve only after the DOM has been updated.
|
|
73
|
+
// Wrap the router-core implementation to await a Vue flush before resolving.
|
|
74
|
+
const originalStartViewTransition = router.__tsrOriginalStartViewTransition ??
|
|
75
|
+
router.startViewTransition;
|
|
76
|
+
router.__tsrOriginalStartViewTransition =
|
|
77
|
+
originalStartViewTransition;
|
|
79
78
|
router.startViewTransition = (fn) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
return originalStartViewTransition?.(async () => {
|
|
80
|
+
await fn();
|
|
81
|
+
await Vue.nextTick();
|
|
82
|
+
});
|
|
83
83
|
};
|
|
84
84
|
// Subscribe to location changes
|
|
85
85
|
// and try to load the new location
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transitioner.jsx","sourceRoot":"","sources":["../../src/Transitioner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,uDAAuD;AACvD,IAAI,kBAAkB,GAAG,EAAE,MAAM,EAAE,IAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhE;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,yCAAyC;IACzC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAM;IACR,CAAC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC;QAC/B,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;KACrC,CAAC,CAAA;IAEF,0EAA0E;IAC1E,MAAM,eAAe,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAEtC,8BAA8B;IAC9B,MAAM,iBAAiB,GAAG,cAAc,CAAC;QACvC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;KAC7D,CAAC,CAAA;IAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAE5D,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,CAC/B,GAA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,EAAE,CAAC;oBAC3B,gBAAgB,CAAC,MAAM,CAAC,CAAA;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC,eAAe,CAAC;IAC9C,IAAI,EAAE,cAAc;IACpB,KAAK;QACH,oBAAoB,EAAE,CAAA;QACtB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA;IACnB,CAAC;CACF,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-router",
|
|
3
|
-
"version": "1.141.
|
|
3
|
+
"version": "1.141.4",
|
|
4
4
|
"description": "Modern and scalable routing for Vue applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"tiny-invariant": "^1.3.3",
|
|
63
63
|
"tiny-warning": "^1.0.3",
|
|
64
64
|
"@tanstack/history": "1.141.0",
|
|
65
|
-
"@tanstack/router-core": "1.141.
|
|
65
|
+
"@tanstack/router-core": "1.141.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/CatchBoundary.tsx
CHANGED
|
@@ -6,6 +6,13 @@ interface ErrorComponentProps {
|
|
|
6
6
|
reset: () => void
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
type CatchBoundaryProps = {
|
|
10
|
+
getResetKey: () => number | string
|
|
11
|
+
children: Vue.VNode
|
|
12
|
+
errorComponent?: ErrorRouteComponent | Vue.Component
|
|
13
|
+
onCatch?: (error: Error) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
const VueErrorBoundary = Vue.defineComponent({
|
|
10
17
|
name: 'VueErrorBoundary',
|
|
11
18
|
props: {
|
|
@@ -67,40 +74,36 @@ const VueErrorBoundary = Vue.defineComponent({
|
|
|
67
74
|
},
|
|
68
75
|
})
|
|
69
76
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
errorComponent
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
fallback: ({ error, reset }: ErrorComponentProps) => {
|
|
92
|
-
if (props.errorComponent) {
|
|
93
|
-
return Vue.h(props.errorComponent, { error, reset })
|
|
94
|
-
}
|
|
95
|
-
return Vue.h(ErrorComponent, { error, reset })
|
|
96
|
-
},
|
|
77
|
+
const CatchBoundaryWrapper = Vue.defineComponent({
|
|
78
|
+
name: 'CatchBoundary',
|
|
79
|
+
inheritAttrs: false,
|
|
80
|
+
props: ['getResetKey', 'children', 'errorComponent', 'onCatch'] as any,
|
|
81
|
+
setup(props: CatchBoundaryProps) {
|
|
82
|
+
const resetKey = Vue.computed(() => props.getResetKey())
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
return Vue.h(
|
|
86
|
+
VueErrorBoundary,
|
|
87
|
+
{
|
|
88
|
+
resetKey: resetKey.value,
|
|
89
|
+
onError: props.onCatch,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
default: () => props.children,
|
|
93
|
+
fallback: ({ error, reset }: ErrorComponentProps) => {
|
|
94
|
+
if (props.errorComponent) {
|
|
95
|
+
return Vue.h(props.errorComponent, { error, reset })
|
|
96
|
+
}
|
|
97
|
+
return Vue.h(ErrorComponent, { error, reset })
|
|
97
98
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
})
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
export function CatchBoundary(props: CatchBoundaryProps) {
|
|
106
|
+
return Vue.h(CatchBoundaryWrapper, props as any)
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
export const ErrorComponent = Vue.defineComponent({
|
package/src/ScriptOnce.tsx
CHANGED
|
@@ -16,8 +16,7 @@ export const ScriptOnce = Vue.defineComponent({
|
|
|
16
16
|
return () => (
|
|
17
17
|
<script
|
|
18
18
|
nonce={router.options.ssr?.nonce}
|
|
19
|
-
|
|
20
|
-
innerHTML={props.children}
|
|
19
|
+
innerHTML={props.children + ';document.currentScript.remove()'}
|
|
21
20
|
/>
|
|
22
21
|
)
|
|
23
22
|
}
|
|
@@ -35,7 +34,6 @@ export const ScriptOnce = Vue.defineComponent({
|
|
|
35
34
|
return (
|
|
36
35
|
<script
|
|
37
36
|
nonce={router.options.ssr?.nonce}
|
|
38
|
-
class="$tsr"
|
|
39
37
|
data-allow-mismatch
|
|
40
38
|
innerHTML=""
|
|
41
39
|
/>
|
package/src/Scripts.tsx
CHANGED
|
@@ -4,10 +4,6 @@ import { useRouterState } from './useRouterState'
|
|
|
4
4
|
import { useRouter } from './useRouter'
|
|
5
5
|
import type { RouterManagedTag } from '@tanstack/router-core'
|
|
6
6
|
|
|
7
|
-
// Script that sets the defer flag for Vue - must run BEFORE TSR bootstrap script
|
|
8
|
-
// This prevents $_TSR.c() from removing scripts until Vue hydration is complete
|
|
9
|
-
const VUE_DEFER_SCRIPT = 'self.$_TSR_DEFER=true'
|
|
10
|
-
|
|
11
7
|
export const Scripts = Vue.defineComponent({
|
|
12
8
|
name: 'Scripts',
|
|
13
9
|
setup() {
|
|
@@ -68,12 +64,6 @@ export const Scripts = Vue.defineComponent({
|
|
|
68
64
|
const allScripts: Array<RouterManagedTag> = []
|
|
69
65
|
|
|
70
66
|
if (router.serverSsr) {
|
|
71
|
-
allScripts.push({
|
|
72
|
-
tag: 'script',
|
|
73
|
-
attrs: { nonce },
|
|
74
|
-
children: VUE_DEFER_SCRIPT,
|
|
75
|
-
} as RouterManagedTag)
|
|
76
|
-
|
|
77
67
|
const serverBufferedScript = router.serverSsr.takeBufferedScripts()
|
|
78
68
|
if (serverBufferedScript) {
|
|
79
69
|
allScripts.push(serverBufferedScript)
|
|
@@ -89,7 +79,6 @@ export const Scripts = Vue.defineComponent({
|
|
|
89
79
|
tag: 'script',
|
|
90
80
|
attrs: {
|
|
91
81
|
nonce,
|
|
92
|
-
class: '$tsr',
|
|
93
82
|
id: '$tsr-stream-barrier',
|
|
94
83
|
'data-allow-mismatch': true,
|
|
95
84
|
},
|
package/src/Transitioner.tsx
CHANGED
|
@@ -88,18 +88,23 @@ export function useTransitionerSetup() {
|
|
|
88
88
|
endTransition()
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
// Vue updates DOM asynchronously (next tick). The View Transitions API expects the
|
|
92
|
+
// update callback promise to resolve only after the DOM has been updated.
|
|
93
|
+
// Wrap the router-core implementation to await a Vue flush before resolving.
|
|
94
|
+
const originalStartViewTransition:
|
|
95
|
+
| undefined
|
|
96
|
+
| ((fn: () => Promise<void>) => void) =
|
|
97
|
+
(router as any).__tsrOriginalStartViewTransition ??
|
|
98
|
+
router.startViewTransition
|
|
99
|
+
|
|
100
|
+
;(router as any).__tsrOriginalStartViewTransition =
|
|
101
|
+
originalStartViewTransition
|
|
102
|
+
|
|
99
103
|
router.startViewTransition = (fn: () => Promise<void>) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
return originalStartViewTransition?.(async () => {
|
|
105
|
+
await fn()
|
|
106
|
+
await Vue.nextTick()
|
|
107
|
+
})
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
// Subscribe to location changes
|