From 92acc949b7c8b79710434344bf555df3acb09928 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Fri, 22 Sep 2023 11:19:55 +0200 Subject: [PATCH] fix: use Vike.PageContext --- pnpm-lock.yaml | 93 +++++++-------------- vike-react/package.json | 5 +- vike-react/renderer/+config.ts | 4 +- vike-react/renderer/PageContextProvider.tsx | 2 +- vike-react/renderer/getPageElement.tsx | 2 +- vike-react/renderer/onRenderClient.tsx | 2 +- vike-react/renderer/onRenderHtml.tsx | 4 +- vike-react/renderer/types.ts | 27 ++---- 8 files changed, 48 insertions(+), 91 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce8bc6f2..bbd8677c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,9 +82,6 @@ importers: vite: specifier: ^4.3.8 version: 4.3.8(@types/node@18.15.3) - vite-plugin-ssr: - specifier: ^0.4.141 - version: 0.4.141(vite@4.3.8) devDependencies: '@brillout/release-me': specifier: ^0.1.7 @@ -107,6 +104,9 @@ importers: typescript: specifier: ^5.0.2 version: 5.0.2 + vite-plugin-ssr: + specifier: ^0.4.142 + version: 0.4.142(vite@4.3.8) packages: @@ -337,15 +337,12 @@ packages: /@brillout/import@0.2.3: resolution: {integrity: sha512-1T8WlD75eeFSMrptGy8jiLHmfHgMmSjWvLOIUvHmSVZt+6k0eQqYUoK4KbmE4T9pVLIfxvZSOm2D68VEqKRHRw==} - dev: false /@brillout/json-serializer@0.5.6: resolution: {integrity: sha512-48u+Wthh0muDueyooi/Or59DDFCPitnuCN9OkMWoj7MQAbDn5pS/cVBB7ds6ENmtC1Qb0spI4PfKZxQSBEkubg==} - dev: false /@brillout/picocolors@1.0.9: resolution: {integrity: sha512-Lt/W5JsA75hcDJ2cOAlE4TqSMl6c9K+rXGRo/cU2fApnmhbRcNdkR4UHQDAwtWfZyUKWaxdwSui+jp+74J1pZg==} - dev: false /@brillout/release-me@0.1.7: resolution: {integrity: sha512-8zvrKzrAGa3hl6DqQuFzqNCnRUl3W2TePUhbi9Kd1X53AoPGqJ9du1zfAuxHRR7j2TXaVfLj/zBDtNrHQDndZA==} @@ -360,13 +357,11 @@ packages: /@brillout/require-shim@0.1.2: resolution: {integrity: sha512-3I4LRHnVZXoSAsEoni5mosq9l6eiJED58d9V954W4CIZ88AUfYBanWGBGbJG3NztaRTpFHEA6wB3Hn93BmmJdg==} - dev: false /@brillout/vite-plugin-import-build@0.2.18: resolution: {integrity: sha512-sedZNrqIboHCeSnN7hwo34xRyP8egfMHcifixQ2YGNnQVb93884drTVE3b0vlSGz7LWumVDochKuHdWQljup9A==} dependencies: '@brillout/import': 0.2.3 - dev: false /@esbuild/android-arm64@0.17.19: resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==} @@ -374,7 +369,6 @@ packages: cpu: [arm64] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/android-arm@0.17.19: @@ -383,7 +377,6 @@ packages: cpu: [arm] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/android-x64@0.17.19: @@ -392,7 +385,6 @@ packages: cpu: [x64] os: [android] requiresBuild: true - dev: false optional: true /@esbuild/darwin-arm64@0.17.19: @@ -401,7 +393,6 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true - dev: false optional: true /@esbuild/darwin-x64@0.17.19: @@ -410,7 +401,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: false optional: true /@esbuild/freebsd-arm64@0.17.19: @@ -419,7 +409,6 @@ packages: cpu: [arm64] os: [freebsd] requiresBuild: true - dev: false optional: true /@esbuild/freebsd-x64@0.17.19: @@ -428,7 +417,6 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true - dev: false optional: true /@esbuild/linux-arm64@0.17.19: @@ -437,7 +425,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-arm@0.17.19: @@ -446,7 +433,6 @@ packages: cpu: [arm] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-ia32@0.17.19: @@ -455,7 +441,6 @@ packages: cpu: [ia32] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-loong64@0.17.19: @@ -464,7 +449,6 @@ packages: cpu: [loong64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-mips64el@0.17.19: @@ -473,7 +457,6 @@ packages: cpu: [mips64el] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-ppc64@0.17.19: @@ -482,7 +465,6 @@ packages: cpu: [ppc64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-riscv64@0.17.19: @@ -491,7 +473,6 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-s390x@0.17.19: @@ -500,7 +481,6 @@ packages: cpu: [s390x] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/linux-x64@0.17.19: @@ -509,7 +489,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false optional: true /@esbuild/netbsd-x64@0.17.19: @@ -518,7 +497,6 @@ packages: cpu: [x64] os: [netbsd] requiresBuild: true - dev: false optional: true /@esbuild/openbsd-x64@0.17.19: @@ -527,7 +505,6 @@ packages: cpu: [x64] os: [openbsd] requiresBuild: true - dev: false optional: true /@esbuild/sunos-x64@0.17.19: @@ -536,7 +513,6 @@ packages: cpu: [x64] os: [sunos] requiresBuild: true - dev: false optional: true /@esbuild/win32-arm64@0.17.19: @@ -545,7 +521,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: false optional: true /@esbuild/win32-ia32@0.17.19: @@ -554,7 +529,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: false optional: true /@esbuild/win32-x64@0.17.19: @@ -563,7 +537,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: false optional: true /@hutson/parse-repository-url@3.0.2: @@ -611,12 +584,10 @@ packages: dependencies: '@nodelib/fs.stat': 2.0.5 run-parallel: 1.2.0 - dev: false /@nodelib/fs.stat@2.0.5: resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} engines: {node: '>= 8'} - dev: false /@nodelib/fs.walk@1.2.8: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} @@ -624,11 +595,9 @@ packages: dependencies: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 - dev: false /@polka/url@1.0.0-next.21: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} - dev: false /@types/minimist@1.2.2: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} @@ -686,7 +655,6 @@ packages: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} hasBin: true - dev: false /add-stream@1.0.0: resolution: {integrity: sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==} @@ -728,7 +696,6 @@ packages: engines: {node: '>=8'} dependencies: fill-range: 7.0.1 - dev: false /browserslist@4.21.5: resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==} @@ -743,12 +710,10 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: false /cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} - dev: false /camelcase-keys@6.2.2: resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} @@ -1046,7 +1011,6 @@ packages: /es-module-lexer@1.3.0: resolution: {integrity: sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==} - dev: false /esbuild@0.17.19: resolution: {integrity: sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==} @@ -1076,7 +1040,6 @@ packages: '@esbuild/win32-arm64': 0.17.19 '@esbuild/win32-ia32': 0.17.19 '@esbuild/win32-x64': 0.17.19 - dev: false /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} @@ -1110,13 +1073,11 @@ packages: glob-parent: 5.1.2 merge2: 1.4.1 micromatch: 4.0.5 - dev: false /fastq@1.15.0: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} dependencies: reusify: 1.0.4 - dev: false /fetch-blob@3.2.0: resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} @@ -1131,7 +1092,6 @@ packages: engines: {node: '>=8'} dependencies: to-regex-range: 5.0.1 - dev: false /find-up@2.1.0: resolution: {integrity: sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==} @@ -1160,7 +1120,6 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true - dev: false optional: true /function-bind@1.1.1: @@ -1233,7 +1192,6 @@ packages: engines: {node: '>= 6'} dependencies: is-glob: 4.0.3 - dev: false /globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} @@ -1315,7 +1273,6 @@ packages: /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} - dev: false /is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} @@ -1327,12 +1284,10 @@ packages: engines: {node: '>=0.10.0'} dependencies: is-extglob: 2.1.1 - dev: false /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} - dev: false /is-obj@2.0.0: resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==} @@ -1498,7 +1453,6 @@ packages: /merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} - dev: false /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} @@ -1506,7 +1460,6 @@ packages: dependencies: braces: 3.0.2 picomatch: 2.3.1 - dev: false /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} @@ -1539,7 +1492,6 @@ packages: /mrmime@1.0.1: resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} engines: {node: '>=10'} - dev: false /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} @@ -1549,7 +1501,6 @@ packages: resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - dev: false /neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} @@ -1706,7 +1657,6 @@ packages: /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - dev: false /pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} @@ -1725,7 +1675,6 @@ packages: nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 - dev: false /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} @@ -1738,7 +1687,6 @@ packages: /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - dev: false /quick-lru@4.0.1: resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} @@ -1847,7 +1795,6 @@ packages: /reusify@1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: false /rollup@3.22.0: resolution: {integrity: sha512-imsigcWor5Y/dC0rz2q0bBt9PabcL3TORry2hAa6O6BuMvY71bqHyfReAz5qyAqiQATD1m70qdntqBfBQjVWpQ==} @@ -1855,13 +1802,11 @@ packages: hasBin: true optionalDependencies: fsevents: 2.3.2 - dev: false /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 - dev: false /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -1916,19 +1861,16 @@ packages: '@polka/url': 1.0.0-next.21 mrmime: 1.0.1 totalist: 3.0.0 - dev: false /source-map-js@1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} - dev: false /source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} dependencies: buffer-from: 1.1.2 source-map: 0.6.1 - dev: false /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} @@ -2056,12 +1998,10 @@ packages: engines: {node: '>=8.0'} dependencies: is-number: 7.0.0 - dev: false /totalist@3.0.0: resolution: {integrity: sha512-eM+pCBxXO/njtF7vdFsHuqb+ElbxqtI4r5EAvk6grfAFyJ6IvWlSkfZ5T9ozC6xWw3Fj1fGoSmrl0gUs46JVIw==} engines: {node: '>=6'} - dev: false /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -2148,6 +2088,32 @@ packages: vite: 4.3.8(@types/node@18.15.3) dev: false + /vite-plugin-ssr@0.4.142(vite@4.3.8): + resolution: {integrity: sha512-ZDgpocnTEUmhYxGgMah8ZNK1Sfy5CFVcdXu+Ll3zRtGIPyWT5vYvASs2BLYEneqantHpde2b31Khzb0hxmP62w==} + engines: {node: '>=16.0.0'} + hasBin: true + peerDependencies: + react-streaming: '>=0.3.5' + vite: '>=3.1.0' + peerDependenciesMeta: + react-streaming: + optional: true + dependencies: + '@brillout/import': 0.2.3 + '@brillout/json-serializer': 0.5.6 + '@brillout/picocolors': 1.0.9 + '@brillout/require-shim': 0.1.2 + '@brillout/vite-plugin-import-build': 0.2.18 + acorn: 8.8.2 + cac: 6.7.14 + es-module-lexer: 1.3.0 + esbuild: 0.17.19 + fast-glob: 3.2.12 + sirv: 2.0.2 + source-map-support: 0.5.21 + vite: 4.3.8(@types/node@18.15.3) + dev: true + /vite@4.3.8(@types/node@18.15.3): resolution: {integrity: sha512-uYB8PwN7hbMrf4j1xzGDk/lqjsZvCDbt/JC5dyfxc19Pg8kRm14LinK/uq+HSLNswZEoKmweGdtpbnxRtrAXiQ==} engines: {node: ^14.18.0 || >=16.0.0} @@ -2179,7 +2145,6 @@ packages: rollup: 3.22.0 optionalDependencies: fsevents: 2.3.2 - dev: false /web-streams-polyfill@3.2.1: resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} diff --git a/vike-react/package.json b/vike-react/package.json index 8fd7d56d..f7af2a19 100644 --- a/vike-react/package.json +++ b/vike-react/package.json @@ -21,7 +21,7 @@ "react": "18.x.x", "react-dom": "18.x.x", "vite": "^4.3.8", - "vite-plugin-ssr": "^0.4.141" + "vite-plugin-ssr": "^0.4.142" }, "devDependencies": { "@brillout/release-me": "^0.1.7", @@ -30,7 +30,8 @@ "@types/react-dom": "^18.0.3", "react": "^18.0.0", "react-dom": "^18.0.0", - "typescript": "^5.0.2" + "typescript": "^5.0.2", + "vite-plugin-ssr": "^0.4.142" }, "typesVersions": { "*": { diff --git a/vike-react/renderer/+config.ts b/vike-react/renderer/+config.ts index ccd3ef15..9745bde1 100644 --- a/vike-react/renderer/+config.ts +++ b/vike-react/renderer/+config.ts @@ -58,7 +58,9 @@ export default { import type { Component } from './types' declare global { namespace VikePackages { - export interface ConfigVikeReact { + interface ConfigVikeReact { + /** The page's root React component */ + Page?: Component /** React element rendered and appended into <head></head> */ Head?: Component /** A component, usually common to several pages, that wraps the root component `Page` */ diff --git a/vike-react/renderer/PageContextProvider.tsx b/vike-react/renderer/PageContextProvider.tsx index 69af5631..a7829ac8 100644 --- a/vike-react/renderer/PageContextProvider.tsx +++ b/vike-react/renderer/PageContextProvider.tsx @@ -2,8 +2,8 @@ export { PageContextProvider } export { usePageContext } import React, { useContext } from 'react' -import { PageContext } from './types' import { getGlobalObject } from './utils/getGlobalObject.js' +import type { PageContext } from 'vite-plugin-ssr/types' const { Context } = getGlobalObject('PageContextProvider.ts', { Context: React.createContext(undefined as never) diff --git a/vike-react/renderer/getPageElement.tsx b/vike-react/renderer/getPageElement.tsx index 6b7d46e4..17c0015e 100644 --- a/vike-react/renderer/getPageElement.tsx +++ b/vike-react/renderer/getPageElement.tsx @@ -1,8 +1,8 @@ export { getPageElement } -import type { PageContext } from './types' import React from 'react' import { PageContextProvider } from './PageContextProvider.js' +import type { PageContext } from 'vite-plugin-ssr/types' function getPageElement(pageContext: PageContext): JSX.Element { const Layout = pageContext.config.Layout ?? PassThrough diff --git a/vike-react/renderer/onRenderClient.tsx b/vike-react/renderer/onRenderClient.tsx index 0b37d498..f5e7b32e 100644 --- a/vike-react/renderer/onRenderClient.tsx +++ b/vike-react/renderer/onRenderClient.tsx @@ -2,7 +2,7 @@ export default onRenderClient import ReactDOM from 'react-dom/client' import { getTitle } from './getTitle.js' -import type { PageContextClient } from './types' +import type { PageContextClient } from 'vite-plugin-ssr/types' import { getPageElement } from './getPageElement.js' let root: ReactDOM.Root diff --git a/vike-react/renderer/onRenderHtml.tsx b/vike-react/renderer/onRenderHtml.tsx index 70d36391..2f4fa967 100644 --- a/vike-react/renderer/onRenderHtml.tsx +++ b/vike-react/renderer/onRenderHtml.tsx @@ -2,13 +2,13 @@ export default onRenderHtml import { renderToString } from 'react-dom/server' import { escapeInject, dangerouslySkipEscape } from 'vite-plugin-ssr/server' +import type { PageContext } from 'vite-plugin-ssr/types' import { getTitle } from './getTitle.js' import { getPageElement } from './getPageElement.js' -import type { PageContextServer } from './types' import { PageContextProvider } from './PageContextProvider.js' import React from 'react' -async function onRenderHtml(pageContext: PageContextServer) { +async function onRenderHtml(pageContext: PageContext) { let pageHtml = '' if (!!pageContext.Page) { const page = getPageElement(pageContext) diff --git a/vike-react/renderer/types.ts b/vike-react/renderer/types.ts index 3b274ce7..30d7b788 100644 --- a/vike-react/renderer/types.ts +++ b/vike-react/renderer/types.ts @@ -1,27 +1,16 @@ -export type { PageContextServer } -export type { PageContextClient } -export type { PageContext } -export type { PageProps } -export type { Page } export type { Component } -import type { - PageContextBuiltInServer, - PageContextBuiltInClientWithClientRouting as PageContextBuiltInClient -} from 'vite-plugin-ssr/types' import type { ReactElement } from 'react' // type Component = (props: Record) => ReactElement type Component = (props: any) => ReactElement -type Page = (pageProps: PageProps) => ReactElement -type PageProps = Record - -export type PageContextCommon = { - Page: Page - pageProps?: PageProps +declare global { + namespace Vike { + interface PageContext { + /** The page's root React component */ + Page?: Component + pageProps: Record + } + } } - -type PageContextServer = PageContextBuiltInServer & PageContextCommon -type PageContextClient = PageContextBuiltInClient & PageContextCommon -type PageContext = PageContextClient | PageContextServer