From bd85ddaa2ebe9b02c08b8b0fd4e07b87b52be236 Mon Sep 17 00:00:00 2001 From: Robert Boes <2871897+RobertBoes@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:01:52 +0200 Subject: [PATCH 1/3] Implement unhead for Vue 3 and its playground --- package-lock.json | 81 +++++++++- packages/core/package.json | 4 +- packages/core/src/head.ts | 147 ------------------ packages/core/src/index.ts | 4 +- packages/core/src/types.ts | 7 +- packages/vue3/src/app.ts | 21 +-- packages/vue3/src/createInertiaApp.ts | 17 +- packages/vue3/src/head.ts | 132 ---------------- packages/vue3/src/index.ts | 1 - packages/vue3/src/types.ts | 3 +- playgrounds/vue3/package.json | 1 + .../vue3/resources/js/Pages/Article.vue | 6 +- playgrounds/vue3/resources/js/Pages/Form.vue | 7 +- playgrounds/vue3/resources/js/Pages/Home.vue | 13 +- playgrounds/vue3/resources/js/Pages/Login.vue | 6 +- playgrounds/vue3/resources/js/Pages/User.vue | 6 +- playgrounds/vue3/resources/js/Pages/Users.vue | 6 +- playgrounds/vue3/resources/js/app.ts | 6 +- playgrounds/vue3/resources/js/ssr.ts | 8 +- 19 files changed, 147 insertions(+), 329 deletions(-) delete mode 100644 packages/core/src/head.ts delete mode 100644 packages/vue3/src/head.ts diff --git a/package-lock.json b/package-lock.json index 1fd9eaf1f..cc4e4cfd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1252,6 +1252,53 @@ "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", "dev": true }, + "node_modules/@unhead/dom": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@unhead/dom/-/dom-1.9.16.tgz", + "integrity": "sha512-aZIAnnc89Csi1vV4mtlHYI765B7m1yuaXUuQiYHwr6glE9FLyy2X87CzEci4yPH/YbkKm0bGQRfcxXq6Eq0W7g==", + "dependencies": { + "@unhead/schema": "1.9.16", + "@unhead/shared": "1.9.16" + }, + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, + "node_modules/@unhead/schema": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@unhead/schema/-/schema-1.9.16.tgz", + "integrity": "sha512-V2BshX+I6D2wN4ys5so8RQDUgsggsxW9FVBiuQi4h8oPWtHclogxzDiHa5BH2TgvNIoUxLnLYNAShMGipmVuUw==", + "dependencies": { + "hookable": "^5.5.3", + "zhead": "^2.2.4" + }, + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, + "node_modules/@unhead/shared": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@unhead/shared/-/shared-1.9.16.tgz", + "integrity": "sha512-pfJnArULCY+GBr7OtYyyxihRiQLkT31TpyK6nUKIwyax4oNOGyhNfk0RFzNq16BwLg60d1lrc5bd5mZGbfClMA==", + "dependencies": { + "@unhead/schema": "1.9.16" + }, + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, + "node_modules/@unhead/ssr": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@unhead/ssr/-/ssr-1.9.16.tgz", + "integrity": "sha512-8R1qt4VAemX4Iun/l7DnUBJqmxA/KaUSc2+/hRYPJYOopXdCWkoaxC1K1ROX2vbRF7qmjdU5ik/a27kSPN94gg==", + "dependencies": { + "@unhead/schema": "1.9.16", + "@unhead/shared": "1.9.16" + }, + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, "node_modules/@vitejs/plugin-react": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-3.1.0.tgz", @@ -2471,6 +2518,11 @@ "he": "bin/he" } }, + "node_modules/hookable": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", + "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==" + }, "node_modules/ignore-walk": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-5.0.1.tgz", @@ -4408,6 +4460,20 @@ "optional": true, "peer": true }, + "node_modules/unhead": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/unhead/-/unhead-1.9.16.tgz", + "integrity": "sha512-FOoXkuRNDwt7PUaNE0LXNCb6RCz4vTpkGymz4tJ8rcaG5uUJ0lxGK536hzCFwFw3Xkp3n+tkt2yCcbAZE/FOvA==", + "dependencies": { + "@unhead/dom": "1.9.16", + "@unhead/schema": "1.9.16", + "@unhead/shared": "1.9.16", + "hookable": "^5.5.3" + }, + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -5312,15 +5378,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/zhead": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/zhead/-/zhead-2.2.4.tgz", + "integrity": "sha512-8F0OI5dpWIA5IGG5NHUg9staDwz/ZPxZtvGVf01j7vHqSyZ0raHY+78atOVxRqb73AotX22uV1pXt3gYSstGag==", + "funding": { + "url": "https://github.com/sponsors/harlan-zw" + } + }, "packages/core": { "name": "@inertiajs/core", "version": "1.2.0", "license": "MIT", "dependencies": { + "@unhead/ssr": "^1.9.16", "axios": "^1.6.0", "deepmerge": "^4.0.0", "nprogress": "^0.2.0", - "qs": "^6.9.0" + "qs": "^6.9.0", + "unhead": "^1.9.16" }, "devDependencies": { "@types/deepmerge": "^2.2.0", @@ -6170,9 +6246,10 @@ "postcss": "^8.4.31", "tailwindcss": "^3.2.4", "typescript": "^4.9.4", + "unhead": "^1.9.16", "vite": "^4.5.3", "vue": "^3.3.4", - "vue-tsc": "^2.0.22" + "vue-tsc": "^2.0.0" } }, "playgrounds/vue3/node_modules/@vitejs/plugin-vue": { diff --git a/packages/core/package.json b/packages/core/package.json index 5b684f74d..d80a7ec37 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -50,10 +50,12 @@ "prepublishOnly": "npm run build" }, "dependencies": { + "@unhead/ssr": "^1.9.16", "axios": "^1.6.0", "deepmerge": "^4.0.0", "nprogress": "^0.2.0", - "qs": "^6.9.0" + "qs": "^6.9.0", + "unhead": "^1.9.16" }, "devDependencies": { "@types/deepmerge": "^2.2.0", diff --git a/packages/core/src/head.ts b/packages/core/src/head.ts deleted file mode 100644 index 1cc90b575..000000000 --- a/packages/core/src/head.ts +++ /dev/null @@ -1,147 +0,0 @@ -import debounce from './debounce' - -const Renderer = { - buildDOMElement(tag: string): ChildNode { - const template = document.createElement('template') - template.innerHTML = tag - const node = template.content.firstChild as Element - - if (!tag.startsWith('