diff --git a/README.md b/README.md index c23f2b6..4d63dd7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # vue-router Navigation API Router And finally, the back and forward browser buttons detected. + +This branch using this [feat: add navigation-api router](https://github.com/vuejs/router/pull/2551) PR. + +Now the `vue-router` supports the [Navigation API](https://wicg.github.io/navigation-api/) and you can use the browser back and forward buttons. + +Now we can use native view or vue transitions, to switch between the transition modes, just add or remove the `viewTransition: true,` line in the `createClientRouter` call, refresh the page and navigate with the header links or back and forward browser buttons. + +You can also switch between Navigation API and Web History API router by adding or removing the `navigationApi` option or use Firefox or Safari that don't support the Navigation API. + +Unexpected result, using the [dom-navigation](https://github.com/virtualstate/navigation?tab=readme-ov-file#polyfill) polyfill, we are able to detect the back and forward buttons in Firefox (Safari not yet tested), but the navigation not being fired, so the view is not changing. + +If you want to enable or disable the `dom-navigation` polyfill, just add or remove the script module in the index.html page. diff --git a/index.html b/index.html index b614ca9..b5a83dc 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,9 @@ Vite + Vue + TS +
diff --git a/package.json b/package.json index c17fc53..85f17f6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "vue": "^3.5.21", - "vue-router": "^4.5.1" + "vue-router": "https://pkg.pr.new/vue-router@11632e0" }, "devDependencies": { "@antfu/eslint-config": "^5.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 665c753..8ec847d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^3.5.21 version: 3.5.21(typescript@5.9.2) vue-router: - specifier: ^4.5.1 - version: 4.5.1(vue@3.5.21(typescript@5.9.2)) + specifier: https://pkg.pr.new/vue-router@11632e0 + version: https://pkg.pr.new/vue-router@11632e0(vue@3.5.21(typescript@5.9.2)) devDependencies: '@antfu/eslint-config': specifier: ^5.2.2 @@ -38,7 +38,7 @@ importers: version: 5.9.2 unplugin-vue-router: specifier: ^0.15.0 - version: 0.15.0(@vue/compiler-sfc@3.5.21)(typescript@5.9.2)(vue-router@4.5.1(vue@3.5.21(typescript@5.9.2)))(vue@3.5.21(typescript@5.9.2)) + version: 0.15.0(@vue/compiler-sfc@3.5.21)(typescript@5.9.2)(vue-router@https://pkg.pr.new/vue-router@11632e0(vue@3.5.21(typescript@5.9.2)))(vue@3.5.21(typescript@5.9.2)) vite: specifier: ^7.1.4 version: 7.1.4(jiti@2.5.1)(yaml@2.8.1) @@ -395,8 +395,8 @@ packages: '@jridgewell/trace-mapping@0.3.30': resolution: {integrity: sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q==} - '@napi-rs/wasm-runtime@1.0.3': - resolution: {integrity: sha512-rZxtMsLwjdXkMUGC3WwsPwLNVqVqnTJT6MNIB6e+5fhMcSCPP0AOsNWuMQ5mdCq6HNjs/ZeWAEchpqeprqBD2Q==} + '@napi-rs/wasm-runtime@1.0.5': + resolution: {integrity: sha512-TBr9Cf9onSAS2LQ2+QHx6XcC6h9+RIzJgbqG3++9TUZSH204AwEy5jg3BTQ0VATsyoGj4ee49tN/y6rvaOOtcg==} '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} @@ -410,12 +410,8 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@oxc-project/runtime@0.82.3': - resolution: {integrity: sha512-LNh5GlJvYHAnMurO+EyA8jJwN1rki7l3PSHuosDh2I7h00T6/u9rCkUjg/SvPmT1CZzvhuW0y+gf7jcqUy/Usg==} - engines: {node: '>=6.9.0'} - - '@oxc-project/types@0.82.3': - resolution: {integrity: sha512-6nCUxBnGX0c6qfZW5MaF6/fmu5dHJDMiMPaioKHKs5mi5+8/FHQ7WGjgQIz1zxpmceMYfdIXkOaLYE+ejbuOtA==} + '@oxc-project/types@0.89.0': + resolution: {integrity: sha512-yuo+ECPIW5Q9mSeNmCDC2im33bfKuwW18mwkaHMQh8KakHYDzj4ci/q7wxf2qS3dMlVVCIyrs3kFtH5LmnlYnw==} '@pkgr/core@0.2.9': resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==} @@ -424,81 +420,94 @@ packages: '@quansync/fs@0.1.5': resolution: {integrity: sha512-lNS9hL2aS2NZgNW7BBj+6EBl4rOf8l+tQ0eRY6JWCI8jI2kc53gSoqbjojU0OnAWhzoXiOjFyGsHcDGePB3lhA==} - '@rolldown/binding-android-arm64@1.0.0-beta.35': - resolution: {integrity: sha512-zVTg0544Ib1ldJSWwjy8URWYHlLFJ98rLnj+2FIj5fRs4KqGKP4VgH/pVUbXNGxeLFjItie6NSK1Un7nJixneQ==} + '@rolldown/binding-android-arm64@1.0.0-beta.38': + resolution: {integrity: sha512-AE3HFQrjWCKLFZD1Vpiy+qsqTRwwoil1oM5WsKPSmfQ5fif/A+ZtOZetF32erZdsR7qyvns6qHEteEsF6g6rsQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@rolldown/binding-darwin-arm64@1.0.0-beta.35': - resolution: {integrity: sha512-WPy0qx22CABTKDldEExfpYHWHulRoPo+m/YpyxP+6ODUPTQexWl8Wp12fn1CVP0xi0rOBj7ugs6+kKMAJW56wQ==} + '@rolldown/binding-darwin-arm64@1.0.0-beta.38': + resolution: {integrity: sha512-RaoWOKc0rrFsVmKOjQpebMY6c6/I7GR1FBc25v7L/R7NlM0166mUotwGEv7vxu7ruXH4SJcFeVrfADFUUXUmmQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@rolldown/binding-darwin-x64@1.0.0-beta.35': - resolution: {integrity: sha512-3k1TabJafF/GgNubXMkfp93d5p30SfIMOmQ5gm1tFwO+baMxxVPwDs3FDvSl+feCWwXxBA+bzemgkaDlInmp1Q==} + '@rolldown/binding-darwin-x64@1.0.0-beta.38': + resolution: {integrity: sha512-Ymojqc2U35iUc8NFU2XX1WQPfBRRHN6xHcrxAf9WS8BFFBn8pDrH5QPvH1tYs3lDkw6UGGbanr1RGzARqdUp1g==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@rolldown/binding-freebsd-x64@1.0.0-beta.35': - resolution: {integrity: sha512-GAiapN5YyIocnBVNEiOxMfWO9NqIeEKKWohj1sPLGc61P+9N1meXOOCiAPbLU+adXq0grtbYySid+Or7f2q+Mg==} + '@rolldown/binding-freebsd-x64@1.0.0-beta.38': + resolution: {integrity: sha512-0ermTQ//WzSI0nOL3z/LUWMNiE9xeM5cLGxjewPFEexqxV/0uM8/lNp9QageQ8jfc/VO1OURsGw34HYO5PaL8w==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.35': - resolution: {integrity: sha512-okPKKIE73qkUMvq7dxDyzD0VIysdV4AirHqjf8tGTjuNoddUAl3WAtMYbuZCEKJwUyI67UINKO1peFVlYEb+8w==} + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.38': + resolution: {integrity: sha512-GADxzVUTCTp6EWI52831A29Tt7PukFe94nhg/SUsfkI33oTiNQtPxyLIT/3oRegizGuPSZSlrdBurkjDwxyEUQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.35': - resolution: {integrity: sha512-Nky8Q2cxyKVkEETntrvcmlzNir5khQbDfX3PflHPbZY7XVZalllRqw7+MW5vn+jTsk5BfKVeLsvrF4344IU55g==} + '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.38': + resolution: {integrity: sha512-SKO7Exl5Yem/OSNoA5uLHzyrptUQ8Hg70kHDxuwEaH0+GUg+SQe9/7PWmc4hFKBMrJGdQtii8WZ0uIz9Dofg5Q==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-arm64-musl@1.0.0-beta.35': - resolution: {integrity: sha512-8aHpWVSfZl3Dy2VNFG9ywmlCPAJx45g0z+qdOeqmYceY7PBAT4QGzii9ig1hPb1pY8K45TXH44UzQwr2fx352Q==} + '@rolldown/binding-linux-arm64-musl@1.0.0-beta.38': + resolution: {integrity: sha512-SOo6+WqhXPBaShLxLT0eCgH17d3Yu1lMAe4mFP0M9Bvr/kfMSOPQXuLxBcbBU9IFM9w3N6qP9xWOHO+oUJvi8Q==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-x64-gnu@1.0.0-beta.35': - resolution: {integrity: sha512-1r1Ac/vTcm1q4kRiX/NB6qtorF95PhjdCxKH3Z5pb+bWMDZnmcz18fzFlT/3C6Qpj/ZqUF+EUrG4QEDXtVXGgg==} + '@rolldown/binding-linux-x64-gnu@1.0.0-beta.38': + resolution: {integrity: sha512-yvsQ3CyrodOX+lcoi+lejZGCOvJZa9xTsNB8OzpMDmHeZq3QzJfpYjXSAS6vie70fOkLVJb77UqYO193Cl8XBQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-linux-x64-musl@1.0.0-beta.35': - resolution: {integrity: sha512-AFl1LnuhUBDfX2j+cE6DlVGROv4qG7GCPDhR1kJqi2+OuXGDkeEjqRvRQOFErhKz1ckkP/YakvN7JheLJ2PKHQ==} + '@rolldown/binding-linux-x64-musl@1.0.0-beta.38': + resolution: {integrity: sha512-84qzKMwUwikfYeOuJ4Kxm/3z15rt0nFGGQArHYIQQNSTiQdxGHxOkqXtzPFqrVfBJUdxBAf+jYzR1pttFJuWyg==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-openharmony-arm64@1.0.0-beta.35': - resolution: {integrity: sha512-Tuwb8vPs+TVJlHhyLik+nwln/burvIgaPDgg6wjNZ23F1ttjZi0w0rQSZfAgsX4jaUbylwCETXQmTp3w6vcJMw==} + '@rolldown/binding-openharmony-arm64@1.0.0-beta.38': + resolution: {integrity: sha512-QrNiWlce01DYH0rL8K3yUBu+lNzY+B0DyCbIc2Atan6/S6flxOL0ow5DLQvMamOI/oKhrJ4xG+9MkMb9dDHbLQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@rolldown/binding-wasm32-wasi@1.0.0-beta.35': - resolution: {integrity: sha512-rG0OozgqNUYcpu50MpICMlJflexRVtQfjlN9QYf6hoel46VvY0FbKGwBKoeUp2K5D4i8lV04DpEMfTZlzRjeiA==} + '@rolldown/binding-wasm32-wasi@1.0.0-beta.38': + resolution: {integrity: sha512-fnLtHyjwEsG4/aNV3Uv3Qd1ZbdH+CopwJNoV0RgBqrcQB8V6/Qdikd5JKvnO23kb3QvIpP+dAMGZMv1c2PJMzw==} engines: {node: '>=14.0.0'} cpu: [wasm32] - '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.35': - resolution: {integrity: sha512-WeOfAZrycFo9+ZqTDp3YDCAOLolymtKGwImrr9n+OW0lpwI2UKyKXbAwGXRhydAYbfrNmuqWyfyoAnLh3X9Hjg==} + '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.38': + resolution: {integrity: sha512-19cTfnGedem+RY+znA9J6ARBOCEFD4YSjnx0p5jiTm9tR6pHafRfFIfKlTXhun+NL0WWM/M0eb2IfPPYUa8+wg==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.35': - resolution: {integrity: sha512-XkLT7ikKGiUDvLh7qtJHRukbyyP1BIrD1xb7A+w4PjIiOKeOH8NqZ+PBaO4plT7JJnLxx+j9g/3B7iylR1nTFQ==} + '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.38': + resolution: {integrity: sha512-HcICm4YzFJZV+fI0O0bFLVVlsWvRNo/AB9EfUXvNYbtAxakCnQZ15oq22deFdz6sfi9Y4/SagH2kPU723dhCFA==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [ia32] os: [win32] - '@rolldown/binding-win32-x64-msvc@1.0.0-beta.35': - resolution: {integrity: sha512-rftASFKVzjbcQHTCYHaBIDrnQFzbeV50tm4hVugG3tPjd435RHZC2pbeGV5IPdKEqyJSuurM/GfbV3kLQ3LY/A==} + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.38': + resolution: {integrity: sha512-4Qx6cgEPXLb0XsCyLoQcUgYBpfL0sjugftob+zhUH0EOk/NVCAIT+h0NJhY+jn7pFpeKxhNMqhvTNx3AesxIAQ==} + engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] '@rolldown/pluginutils@1.0.0-beta.29': resolution: {integrity: sha512-NIJgOsMjbxAXvoGq/X0gD7VPMQ8j9g0BiDaNjVNVjvl+iKXxL3Jre0v31RmBYeLEmkbj2s02v8vFTbUXi5XS2Q==} - '@rolldown/pluginutils@1.0.0-beta.35': - resolution: {integrity: sha512-slYrCpoxJUqzFDDNlvrOYRazQUNRvWPjXA17dAOISY3rDMxX6k8K4cj2H+hEYMHF81HO3uNd5rHVigAWRM5dSg==} + '@rolldown/pluginutils@1.0.0-beta.38': + resolution: {integrity: sha512-N/ICGKleNhA5nc9XXQG/kkKHJ7S55u0x0XUJbbkmdCnFuoRkM1Il12q9q0eX19+M7KKUEPw/daUPIRnxhcxAIw==} '@rollup/rollup-android-arm-eabi@4.50.1': resolution: {integrity: sha512-HJXwzoZN4eYTdD8bVV22DN8gsPCAj3V20NHKOs8ezfXanGpmVPR7kalUHd+Y31IJp9stdB87VKPFbsGY3H/2ag==} @@ -611,8 +620,8 @@ packages: peerDependencies: eslint: '>=9.0.0' - '@tybys/wasm-util@0.10.0': - resolution: {integrity: sha512-VyyPYFlOMNylG45GoAe0xDoLwWuowvf92F9kySqzYh8vmYm7D2u4iUJKa1tOUpS70Ku13ASrOkS4ScXFsTaCNQ==} + '@tybys/wasm-util@0.10.1': + resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==} '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -1725,8 +1734,9 @@ packages: vue-tsc: optional: true - rolldown@1.0.0-beta.35: - resolution: {integrity: sha512-gJATyqcsJe0Cs8RMFO8XgFjfTc0lK1jcSvirDQDSIfsJE+vt53QH/Ob+OBSJsXb98YtZXHfP/bHpELpPwCprow==} + rolldown@1.0.0-beta.38: + resolution: {integrity: sha512-58frPNX55Je1YsyrtPJv9rOSR3G5efUZpRqok94Efsj0EUa8dnqJV3BldShyI7A+bVPleucOtzXHwVpJRcR0kQ==} + engines: {node: ^20.19.0 || >=22.12.0} hasBin: true rollup@4.50.1: @@ -1881,6 +1891,7 @@ packages: unplugin-vue-router@0.15.0: resolution: {integrity: sha512-PyGehCjd9Ny9h+Uer4McbBjjib3lHihcyUEILa7pHKl6+rh8N7sFyw4ZkV+N30Oq2zmIUG7iKs3qpL0r+gXAaQ==} + version: 0.15.0 peerDependencies: '@vue/compiler-sfc': ^3.5.17 vue-router: ^4.5.1 @@ -1953,8 +1964,9 @@ packages: peerDependencies: eslint: ^8.57.0 || ^9.0.0 - vue-router@4.5.1: - resolution: {integrity: sha512-ogAF3P97NPm8fJsE4by9dwSYtDwXIY1nFY9T6DyQnGHd1E2Da94w9JIolpe42LJGIl0DwOHBi8TcRPlPGwbTtw==} + vue-router@https://pkg.pr.new/vue-router@11632e0: + resolution: {tarball: https://pkg.pr.new/vue-router@11632e0} + version: 4.5.1 peerDependencies: vue: ^3.2.0 @@ -2297,11 +2309,11 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@napi-rs/wasm-runtime@1.0.3': + '@napi-rs/wasm-runtime@1.0.5': dependencies: '@emnapi/core': 1.5.0 '@emnapi/runtime': 1.5.0 - '@tybys/wasm-util': 0.10.0 + '@tybys/wasm-util': 0.10.1 optional: true '@nodelib/fs.scandir@2.1.5': @@ -2316,9 +2328,7 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.1 - '@oxc-project/runtime@0.82.3': {} - - '@oxc-project/types@0.82.3': {} + '@oxc-project/types@0.89.0': {} '@pkgr/core@0.2.9': {} @@ -2326,53 +2336,53 @@ snapshots: dependencies: quansync: 0.2.11 - '@rolldown/binding-android-arm64@1.0.0-beta.35': + '@rolldown/binding-android-arm64@1.0.0-beta.38': optional: true - '@rolldown/binding-darwin-arm64@1.0.0-beta.35': + '@rolldown/binding-darwin-arm64@1.0.0-beta.38': optional: true - '@rolldown/binding-darwin-x64@1.0.0-beta.35': + '@rolldown/binding-darwin-x64@1.0.0-beta.38': optional: true - '@rolldown/binding-freebsd-x64@1.0.0-beta.35': + '@rolldown/binding-freebsd-x64@1.0.0-beta.38': optional: true - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.35': + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.38': optional: true - '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.35': + '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.38': optional: true - '@rolldown/binding-linux-arm64-musl@1.0.0-beta.35': + '@rolldown/binding-linux-arm64-musl@1.0.0-beta.38': optional: true - '@rolldown/binding-linux-x64-gnu@1.0.0-beta.35': + '@rolldown/binding-linux-x64-gnu@1.0.0-beta.38': optional: true - '@rolldown/binding-linux-x64-musl@1.0.0-beta.35': + '@rolldown/binding-linux-x64-musl@1.0.0-beta.38': optional: true - '@rolldown/binding-openharmony-arm64@1.0.0-beta.35': + '@rolldown/binding-openharmony-arm64@1.0.0-beta.38': optional: true - '@rolldown/binding-wasm32-wasi@1.0.0-beta.35': + '@rolldown/binding-wasm32-wasi@1.0.0-beta.38': dependencies: - '@napi-rs/wasm-runtime': 1.0.3 + '@napi-rs/wasm-runtime': 1.0.5 optional: true - '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.35': + '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.38': optional: true - '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.35': + '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.38': optional: true - '@rolldown/binding-win32-x64-msvc@1.0.0-beta.35': + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.38': optional: true '@rolldown/pluginutils@1.0.0-beta.29': {} - '@rolldown/pluginutils@1.0.0-beta.35': {} + '@rolldown/pluginutils@1.0.0-beta.38': {} '@rollup/rollup-android-arm-eabi@4.50.1': optional: true @@ -2447,7 +2457,7 @@ snapshots: estraverse: 5.3.0 picomatch: 4.0.3 - '@tybys/wasm-util@0.10.0': + '@tybys/wasm-util@0.10.1': dependencies: tslib: 2.8.1 optional: true @@ -3779,7 +3789,7 @@ snapshots: reusify@1.1.0: {} - rolldown-plugin-dts@0.15.10(rolldown@1.0.0-beta.35)(typescript@5.9.2)(vue-tsc@3.0.6(typescript@5.9.2)): + rolldown-plugin-dts@0.15.10(rolldown@1.0.0-beta.38)(typescript@5.9.2)(vue-tsc@3.0.6(typescript@5.9.2)): dependencies: '@babel/generator': 7.28.3 '@babel/parser': 7.28.4 @@ -3789,7 +3799,7 @@ snapshots: debug: 4.4.1 dts-resolver: 2.1.2 get-tsconfig: 4.10.1 - rolldown: 1.0.0-beta.35 + rolldown: 1.0.0-beta.38 optionalDependencies: typescript: 5.9.2 vue-tsc: 3.0.6(typescript@5.9.2) @@ -3797,27 +3807,26 @@ snapshots: - oxc-resolver - supports-color - rolldown@1.0.0-beta.35: + rolldown@1.0.0-beta.38: dependencies: - '@oxc-project/runtime': 0.82.3 - '@oxc-project/types': 0.82.3 - '@rolldown/pluginutils': 1.0.0-beta.35 + '@oxc-project/types': 0.89.0 + '@rolldown/pluginutils': 1.0.0-beta.38 ansis: 4.1.0 optionalDependencies: - '@rolldown/binding-android-arm64': 1.0.0-beta.35 - '@rolldown/binding-darwin-arm64': 1.0.0-beta.35 - '@rolldown/binding-darwin-x64': 1.0.0-beta.35 - '@rolldown/binding-freebsd-x64': 1.0.0-beta.35 - '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.35 - '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.35 - '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.35 - '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.35 - '@rolldown/binding-linux-x64-musl': 1.0.0-beta.35 - '@rolldown/binding-openharmony-arm64': 1.0.0-beta.35 - '@rolldown/binding-wasm32-wasi': 1.0.0-beta.35 - '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.35 - '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.35 - '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.35 + '@rolldown/binding-android-arm64': 1.0.0-beta.38 + '@rolldown/binding-darwin-arm64': 1.0.0-beta.38 + '@rolldown/binding-darwin-x64': 1.0.0-beta.38 + '@rolldown/binding-freebsd-x64': 1.0.0-beta.38 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.38 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.38 + '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.38 + '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.38 + '@rolldown/binding-linux-x64-musl': 1.0.0-beta.38 + '@rolldown/binding-openharmony-arm64': 1.0.0-beta.38 + '@rolldown/binding-wasm32-wasi': 1.0.0-beta.38 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.38 + '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.38 + '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.38 rollup@4.50.1: dependencies: @@ -3930,8 +3939,8 @@ snapshots: diff: 8.0.2 empathic: 2.0.0 hookable: 5.5.3 - rolldown: 1.0.0-beta.35 - rolldown-plugin-dts: 0.15.10(rolldown@1.0.0-beta.35)(typescript@5.9.2)(vue-tsc@3.0.6(typescript@5.9.2)) + rolldown: 1.0.0-beta.38 + rolldown-plugin-dts: 0.15.10(rolldown@1.0.0-beta.38)(typescript@5.9.2)(vue-tsc@3.0.6(typescript@5.9.2)) semver: 7.7.2 tinyexec: 1.0.1 tinyglobby: 0.2.15 @@ -3987,7 +3996,7 @@ snapshots: pathe: 2.0.3 picomatch: 4.0.3 - unplugin-vue-router@0.15.0(@vue/compiler-sfc@3.5.21)(typescript@5.9.2)(vue-router@4.5.1(vue@3.5.21(typescript@5.9.2)))(vue@3.5.21(typescript@5.9.2)): + unplugin-vue-router@0.15.0(@vue/compiler-sfc@3.5.21)(typescript@5.9.2)(vue-router@https://pkg.pr.new/vue-router@11632e0(vue@3.5.21(typescript@5.9.2)))(vue@3.5.21(typescript@5.9.2)): dependencies: '@vue-macros/common': 3.0.0-beta.16(vue@3.5.21(typescript@5.9.2)) '@vue/compiler-sfc': 3.5.21 @@ -4007,7 +4016,7 @@ snapshots: unplugin-utils: 0.2.5 yaml: 2.8.1 optionalDependencies: - vue-router: 4.5.1(vue@3.5.21(typescript@5.9.2)) + vue-router: https://pkg.pr.new/vue-router@11632e0(vue@3.5.21(typescript@5.9.2)) transitivePeerDependencies: - typescript - vue @@ -4058,7 +4067,7 @@ snapshots: transitivePeerDependencies: - supports-color - vue-router@4.5.1(vue@3.5.21(typescript@5.9.2)): + vue-router@https://pkg.pr.new/vue-router@11632e0(vue@3.5.21(typescript@5.9.2)): dependencies: '@vue/devtools-api': 6.6.4 vue: 3.5.21(typescript@5.9.2) diff --git a/src/App.vue b/src/App.vue index d5890cc..728c09e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,31 +1,144 @@ + + + + diff --git a/src/main.ts b/src/main.ts index 0caceaf..fa80b48 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,29 +1,61 @@ import { createApp } from 'vue' -import { createRouter, createWebHistory } from 'vue-router' +import { createModernRouter, createRouter, createWebHistory } from 'vue-router' import { routes } from 'vue-router/auto-routes' import App from './App.vue' -import { createNavigationApiHistory } from './navigationApiHistory.ts' // eslint-disable-next-line no-console console.log(window.navigation) -const history = window.navigation - ? createNavigationApiHistory() - : createWebHistory() - -const router = createRouter({ - history, - routes, +const router = createModernRouter({ + legacy: { + factory(transitionMode) { + return createRouter({ + enableScrollManagement: true, + focusManagement: true, + history: createWebHistory(), + routes, + }, transitionMode) + }, + }, + navigationApi: { + options: { + location: '', + routes, + }, + }, + viewTransition: true, }) -history.listen((to, from, info) => { -// eslint-disable-next-line no-console - console.log(`History: ${from} => ${to} => ${info.type}`) +router.enableViewTransition({ + onStart(transition) { + // eslint-disable-next-line no-console + console.log('View transition started', transition) + }, + onFinished(transition) { + // eslint-disable-next-line no-console + console.log('View transition finished', transition) + }, + onAborted(transition) { + // eslint-disable-next-line no-console + console.log('View transition aborted', transition) + }, }) +const app = createApp(App) +app.use(router) + router.afterEach((to, from) => { -// eslint-disable-next-line no-console - console.log(`Navigation to ${to.meta} from ${from?.fullPath}`) + // eslint-disable-next-line no-console + console.log(`AfterEach to ${to.fullPath} from ${from?.fullPath}`) }) -createApp(App).use(router).mount('#app') +app.mount('#app') + +/* router.beforeEach((to, from, _) => { + // eslint-disable-next-line no-console + console.log(`BeforeEach to ${to.fullPath} from ${from?.fullPath}`) +}) */ +router.isReady().then(() => { + // eslint-disable-next-line no-console + console.log('router is ready') +}) diff --git a/src/pages/b.vue b/src/pages/b.vue index d285c7f..0a6acca 100644 --- a/src/pages/b.vue +++ b/src/pages/b.vue @@ -1,5 +1,37 @@ + + diff --git a/src/pages/scroll-restoration.vue b/src/pages/scroll-restoration.vue new file mode 100644 index 0000000..fed6750 --- /dev/null +++ b/src/pages/scroll-restoration.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/typed-router.d.ts b/typed-router.d.ts index 6e5e9d2..f379ad9 100644 --- a/typed-router.d.ts +++ b/typed-router.d.ts @@ -21,6 +21,7 @@ declare module 'vue-router/auto-routes' { '/': RouteRecordInfo<'/', '/', Record, Record>, '/a': RouteRecordInfo<'/a', '/a', Record, Record>, '/b': RouteRecordInfo<'/b', '/b', Record, Record>, + '/scroll-restoration': RouteRecordInfo<'/scroll-restoration', '/scroll-restoration', Record, Record>, } /** @@ -46,6 +47,10 @@ declare module 'vue-router/auto-routes' { routes: '/b' views: never } + 'src/pages/scroll-restoration.vue': { + routes: '/scroll-restoration' + views: never + } } /**