From 36a36272ed2811c9cd2dc0f8f7561e1559e89f13 Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Sat, 17 Aug 2024 18:09:20 +0200 Subject: [PATCH 1/2] fix(image): optimize getImageSize --- build.config.js | 1 + package-lock.json | 135 ++++++++++ package.json | 2 + src/runtime/components/BoosterImage/Base.vue | 242 ++++++++---------- .../components/BoosterImage/utils/image.js | 1 + .../components/BoosterPicture/Base.vue | 169 ++++++------ .../components/BoosterPicture/Source.vue | 96 +++---- src/runtime/utils/description.js | 7 +- src/tmpl/plugin.tmpl.js | 51 ++-- 9 files changed, 397 insertions(+), 307 deletions(-) diff --git a/build.config.js b/build.config.js index 4b87aef1a0..2d905f89c0 100644 --- a/build.config.js +++ b/build.config.js @@ -7,6 +7,7 @@ export default { 'hash-sum', 'probe-image-size', 'vue3-lazy-hydration', + 'node-cache', // package '@nuxt/image', diff --git a/package-lock.json b/package-lock.json index 250bfece3e..918d7b2a2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "htmlparser2": "9.1.0", "image-meta": "0.2.1", "mime-types": "2.1.35", + "node-cache": "^5.1.2", "pathe": "1.1.2", "sort-css-media-queries": "2.3.0", "vue3-lazy-hydration": "1.2.1" @@ -57,6 +58,7 @@ "vite-svg-loader": "5.1.0", "vitepress": "1.3.2", "vitest": "2.0.5", + "vue-tsc": "^2.0.29", "wicg-inert": "3.1.3" } }, @@ -7759,6 +7761,35 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/@volar/language-core": { + "version": "2.4.0-alpha.18", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.0-alpha.18.tgz", + "integrity": "sha512-JAYeJvYQQROmVRtSBIczaPjP3DX4QW1fOqW1Ebs0d3Y3EwSNRglz03dSv0Dm61dzd0Yx3WgTW3hndDnTQqgmyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/source-map": "2.4.0-alpha.18" + } + }, + "node_modules/@volar/source-map": { + "version": "2.4.0-alpha.18", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.0-alpha.18.tgz", + "integrity": "sha512-MTeCV9MUwwsH0sNFiZwKtFrrVZUK6p8ioZs3xFzHc2cvDXHWlYN3bChdQtwKX+FY2HG6H3CfAu1pKijolzIQ8g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@volar/typescript": { + "version": "2.4.0-alpha.18", + "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.0-alpha.18.tgz", + "integrity": "sha512-sXh5Y8sqGUkgxpMWUGvRXggxYHAVxg0Pa1C42lQZuPDrW6vHJPR0VCK8Sr7WJsAW530HuNQT/ZIskmXtxjybMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.0-alpha.18", + "path-browserify": "^1.0.1", + "vscode-uri": "^3.0.8" + } + }, "node_modules/@voxpelli/config-array-find-files": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@voxpelli/config-array-find-files/-/config-array-find-files-0.1.2.tgz", @@ -7941,6 +7972,17 @@ "@vue/shared": "3.4.35" } }, + "node_modules/@vue/compiler-vue2": { + "version": "2.7.16", + "resolved": "https://registry.npmjs.org/@vue/compiler-vue2/-/compiler-vue2-2.7.16.tgz", + "integrity": "sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==", + "dev": true, + "license": "MIT", + "dependencies": { + "de-indent": "^1.0.2", + "he": "^1.2.0" + } + }, "node_modules/@vue/devtools-api": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.3.7.tgz", @@ -8027,6 +8069,31 @@ "rfdc": "^1.4.1" } }, + "node_modules/@vue/language-core": { + "version": "2.0.29", + "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-2.0.29.tgz", + "integrity": "sha512-o2qz9JPjhdoVj8D2+9bDXbaI4q2uZTHQA/dbyZT4Bj1FR9viZxDJnLcKVHfxdn6wsOzRgpqIzJEEmSSvgMvDTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "~2.4.0-alpha.18", + "@vue/compiler-dom": "^3.4.0", + "@vue/compiler-vue2": "^2.7.16", + "@vue/shared": "^3.4.0", + "computeds": "^0.0.1", + "minimatch": "^9.0.3", + "muggle-string": "^0.4.1", + "path-browserify": "^1.0.1" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@vue/reactivity": { "version": "3.4.35", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.35.tgz", @@ -10073,6 +10140,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/computeds": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/computeds/-/computeds-0.0.1.tgz", + "integrity": "sha512-7CEBgcMjVmitjYo5q8JTJVra6X5mQ20uTThdK+0kR7UEaDrAWEQcRiBtWJzga4eRpP6afNwwLsX2SET2JhVB1Q==", + "dev": true, + "license": "MIT" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -10826,6 +10900,13 @@ } } }, + "node_modules/de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", + "dev": true, + "license": "MIT" + }, "node_modules/debounce": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", @@ -13763,6 +13844,16 @@ "node": ">= 0.4" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, "node_modules/hookable": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", @@ -16389,6 +16480,13 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "license": "MIT" }, + "node_modules/muggle-string": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.4.1.tgz", + "integrity": "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==", + "dev": true, + "license": "MIT" + }, "node_modules/nanoid": { "version": "5.0.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.7.tgz", @@ -17020,6 +17118,18 @@ "devOptional": true, "license": "MIT" }, + "node_modules/node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "license": "MIT", + "dependencies": { + "clone": "2.x" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -18106,6 +18216,13 @@ "node": ">= 0.8" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, "node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -25143,6 +25260,24 @@ "dev": true, "license": "MIT" }, + "node_modules/vue-tsc": { + "version": "2.0.29", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-2.0.29.tgz", + "integrity": "sha512-MHhsfyxO3mYShZCGYNziSbc63x7cQ5g9kvijV7dRe1TTXBRLxXyL0FnXWpUF1xII2mJ86mwYpYsUmMwkmerq7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/typescript": "~2.4.0-alpha.18", + "@vue/language-core": "2.0.29", + "semver": "^7.5.4" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": ">=5.0.0" + } + }, "node_modules/vue3-lazy-hydration": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/vue3-lazy-hydration/-/vue3-lazy-hydration-1.2.1.tgz", diff --git a/package.json b/package.json index 5187e6a6b3..bf2e1dce02 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "htmlparser2": "9.1.0", "image-meta": "0.2.1", "mime-types": "2.1.35", + "node-cache": "^5.1.2", "pathe": "1.1.2", "sort-css-media-queries": "2.3.0", "vue3-lazy-hydration": "1.2.1" @@ -99,6 +100,7 @@ "vite-svg-loader": "5.1.0", "vitepress": "1.3.2", "vitest": "2.0.5", + "vue-tsc": "^2.0.29", "wicg-inert": "3.1.3" } } diff --git a/src/runtime/components/BoosterImage/Base.vue b/src/runtime/components/BoosterImage/Base.vue index 752564215c..10786d1cdf 100644 --- a/src/runtime/components/BoosterImage/Base.vue +++ b/src/runtime/components/BoosterImage/Base.vue @@ -16,7 +16,7 @@ /> -