From 326af3ab23967d825ada06f2ea628aaaf8fc936a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:38:23 +0000 Subject: [PATCH 1/4] build(deps-dev): bump vite from 5.0.4 to 5.0.5 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.4 to 5.0.5. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.0.5/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- package.json | 2 +- pnpm-lock.yaml | 112 ++++++++++++++++++++++++++++++--------------- popup/package.json | 2 +- 3 files changed, 76 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 670b319..349f92d 100644 --- a/package.json +++ b/package.json @@ -151,7 +151,7 @@ "rollup": "^4.9.5", "tsup": "^8.0.1", "typescript": "^5.3.3", - "vite": "^5.0.11", + "vite": "^5.0.5", "vitest": "^0.34.6", "webpack": "^5.89.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9da1671..7c2afdb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -91,8 +91,8 @@ importers: specifier: ^5.3.3 version: 5.3.3 vite: - specifier: ^5.0.11 - version: 5.0.11(@types/node@20.11.1) + specifier: ^5.0.5 + version: 5.0.5(@types/node@20.11.1) vitest: specifier: ^0.34.6 version: 0.34.6(jsdom@23.2.0) @@ -126,10 +126,10 @@ importers: version: 18.19.6 '@vitejs/plugin-vue': specifier: ^4.5.2 - version: 4.6.2(vite@5.0.11)(vue@3.4.13) + version: 4.6.2(vite@5.0.5)(vue@3.4.13) '@vitejs/plugin-vue-jsx': specifier: ^3.1.0 - version: 3.1.0(vite@5.0.11)(vue@3.4.13) + version: 3.1.0(vite@5.0.5)(vue@3.4.13) '@vue/eslint-config-prettier': specifier: ^8.0.0 version: 8.0.0(eslint@8.55.0)(prettier@3.1.1) @@ -164,11 +164,11 @@ importers: specifier: ~5.3.0 version: 5.3.2 vite: - specifier: ^5.0.10 - version: 5.0.11(@types/node@18.19.6) + specifier: ^5.0.5 + version: 5.0.5(@types/node@18.19.6) vite-plugin-vue-devtools: specifier: ^7.0.7 - version: 7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11) + version: 7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5) vue-tsc: specifier: ^1.8.25 version: 1.8.27(typescript@5.3.2) @@ -1579,7 +1579,7 @@ packages: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true - /@vitejs/plugin-vue-jsx@3.1.0(vite@5.0.11)(vue@3.4.13): + /@vitejs/plugin-vue-jsx@3.1.0(vite@5.0.5)(vue@3.4.13): resolution: {integrity: sha512-w9M6F3LSEU5kszVb9An2/MmXNxocAnUb3WhRr8bHlimhDrXNt6n6D2nJQR3UXpGlZHh/EsgouOHCsM8V3Ln+WA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -1589,20 +1589,20 @@ packages: '@babel/core': 7.23.7 '@babel/plugin-transform-typescript': 7.23.6(@babel/core@7.23.7) '@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.23.7) - vite: 5.0.11(@types/node@18.19.6) + vite: 5.0.5(@types/node@18.19.6) vue: 3.4.13(typescript@5.3.2) transitivePeerDependencies: - supports-color dev: true - /@vitejs/plugin-vue@4.6.2(vite@5.0.11)(vue@3.4.13): + /@vitejs/plugin-vue@4.6.2(vite@5.0.5)(vue@3.4.13): resolution: {integrity: sha512-kqf7SGFoG+80aZG6Pf+gsZIVvGSCKE98JbiWqcCV9cThtg91Jav0yvYFC9Zb+jKetNGF6ZKeoaxgZfND21fWKw==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: vite: ^4.0.0 || ^5.0.0 vue: ^3.2.25 dependencies: - vite: 5.0.11(@types/node@18.19.6) + vite: 5.0.5(@types/node@18.19.6) vue: 3.4.13(typescript@5.3.2) dev: true @@ -1720,7 +1720,7 @@ packages: '@vue/compiler-dom': 3.4.13 '@vue/shared': 3.4.13 - /@vue/devtools-core@7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11): + /@vue/devtools-core@7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5): resolution: {integrity: sha512-0QPg1GwweTIjcchJTDkchdR4pHl235eDmUpxJx57qCJMj2XikKzKEJvzNNAgABtWAiUNdW2trOSCkyQpPB8CTQ==} dependencies: '@vue/devtools-kit': 7.0.7 @@ -1731,9 +1731,9 @@ packages: image-meta: 0.2.0 mitt: 3.0.1 pathe: 1.1.1 - vite-dev-rpc: 0.1.4(vite@5.0.11) - vite-hot-client: 0.2.3(vite@5.0.11) - vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11) + vite-dev-rpc: 0.1.4(vite@5.0.5) + vite-hot-client: 0.2.3(vite@5.0.5) + vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5) transitivePeerDependencies: - '@nuxt/kit' - rollup @@ -5764,22 +5764,22 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /vite-dev-rpc@0.1.4(vite@5.0.11): + /vite-dev-rpc@0.1.4(vite@5.0.5): resolution: {integrity: sha512-6I/qF7EDGLQfm3DGdcbkZ7JRl3FIbaVgD1TqDWBaCosJ1QljLzNzDBmMEa7cYkEyAMxHDBqT7zJrOiuYlFYcAA==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 dependencies: birpc: 0.2.14 - vite: 5.0.11(@types/node@18.19.6) - vite-hot-client: 0.2.3(vite@5.0.11) + vite: 5.0.5(@types/node@18.19.6) + vite-hot-client: 0.2.3(vite@5.0.5) dev: true - /vite-hot-client@0.2.3(vite@5.0.11): + /vite-hot-client@0.2.3(vite@5.0.5): resolution: {integrity: sha512-rOGAV7rUlUHX89fP2p2v0A2WWvV3QMX2UYq0fRqsWSvFvev4atHWqjwGoKaZT1VTKyLGk533ecu3eyd0o59CAg==} peerDependencies: vite: ^2.6.0 || ^3.0.0 || ^4.0.0 || ^5.0.0-0 dependencies: - vite: 5.0.11(@types/node@18.19.6) + vite: 5.0.5(@types/node@18.19.6) dev: true /vite-node@0.34.6(@types/node@20.11.1): @@ -5804,7 +5804,7 @@ packages: - terser dev: true - /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11): + /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.4): resolution: {integrity: sha512-oPBPVGp6tBd5KdY/qY6lrbLXqrbHRG0hZLvEaJfiZ/GQfDB+szRuLHblQh1oi1Hhh8GeLit/50l4xfs2SA+TCA==} engines: {node: '>=14'} peerDependencies: @@ -5823,13 +5823,13 @@ packages: open: 9.1.0 picocolors: 1.0.0 sirv: 2.0.3 - vite: 5.0.11(@types/node@18.19.6) + vite: 5.0.4(@types/node@20.11.1) transitivePeerDependencies: - rollup - supports-color dev: true - /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.4): + /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5): resolution: {integrity: sha512-oPBPVGp6tBd5KdY/qY6lrbLXqrbHRG0hZLvEaJfiZ/GQfDB+szRuLHblQh1oi1Hhh8GeLit/50l4xfs2SA+TCA==} engines: {node: '>=14'} peerDependencies: @@ -5848,34 +5848,34 @@ packages: open: 9.1.0 picocolors: 1.0.0 sirv: 2.0.3 - vite: 5.0.4(@types/node@20.11.1) + vite: 5.0.5(@types/node@18.19.6) transitivePeerDependencies: - rollup - supports-color dev: true - /vite-plugin-vue-devtools@7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11): + /vite-plugin-vue-devtools@7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5): resolution: {integrity: sha512-kRTfQA1h6z0rA+MrnprLClvnUCCT/UQc8soWwRX7gIyfPKAer+GpZuY0y91teKdtGp+q25gk8NJvm/zYScEV5Q==} engines: {node: '>=v14.21.3'} peerDependencies: vite: ^3.1.0 || ^4.0.0-0 || ^5.0.0-0 dependencies: - '@vue/devtools-core': 7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11) + '@vue/devtools-core': 7.0.7(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5) '@vue/devtools-kit': 7.0.7 '@vue/devtools-shared': 7.0.7 birpc: 0.2.14 execa: 8.0.1 sirv: 2.0.4 - vite: 5.0.11(@types/node@18.19.6) - vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.11) - vite-plugin-vue-inspector: 4.0.2(vite@5.0.11) + vite: 5.0.5(@types/node@18.19.6) + vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.1)(rollup@4.9.5)(vite@5.0.5) + vite-plugin-vue-inspector: 4.0.2(vite@5.0.5) transitivePeerDependencies: - '@nuxt/kit' - rollup - supports-color dev: true - /vite-plugin-vue-inspector@4.0.2(vite@5.0.11): + /vite-plugin-vue-inspector@4.0.2(vite@5.0.5): resolution: {integrity: sha512-KPvLEuafPG13T7JJuQbSm5PwSxKFnVS965+MP1we2xGw9BPkkc/+LPix5MMWenpKWqtjr0ws8THrR+KuoDC8hg==} peerDependencies: vite: ^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 @@ -5889,12 +5889,12 @@ packages: '@vue/compiler-dom': 3.4.13 kolorist: 1.8.0 magic-string: 0.30.5 - vite: 5.0.11(@types/node@18.19.6) + vite: 5.0.5(@types/node@18.19.6) transitivePeerDependencies: - supports-color dev: true - /vite@5.0.11(@types/node@18.19.6): + /vite@5.0.11(@types/node@20.11.1): resolution: {integrity: sha512-XBMnDjZcNAw/G1gEiskiM1v6yzM4GE5aMGvhWTlHAYYhxb7S3/V1s3m2LDHa8Vh6yIWYYB0iJwsEaS523c4oYA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -5922,7 +5922,7 @@ packages: terser: optional: true dependencies: - '@types/node': 18.19.6 + '@types/node': 20.11.1 esbuild: 0.19.11 postcss: 8.4.33 rollup: 4.9.5 @@ -5930,8 +5930,8 @@ packages: fsevents: 2.3.3 dev: true - /vite@5.0.11(@types/node@20.11.1): - resolution: {integrity: sha512-XBMnDjZcNAw/G1gEiskiM1v6yzM4GE5aMGvhWTlHAYYhxb7S3/V1s3m2LDHa8Vh6yIWYYB0iJwsEaS523c4oYA==} + /vite@5.0.4(@types/node@20.11.1): + resolution: {integrity: sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -5960,14 +5960,50 @@ packages: dependencies: '@types/node': 20.11.1 esbuild: 0.19.11 + postcss: 8.4.32 + rollup: 4.9.5 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /vite@5.0.5(@types/node@18.19.6): + resolution: {integrity: sha512-OekeWqR9Ls56f3zd4CaxzbbS11gqYkEiBtnWFFgYR2WV8oPJRRKq0mpskYy/XaoCL3L7VINDhqqOMNDiYdGvGg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 18.19.6 + esbuild: 0.19.11 postcss: 8.4.33 rollup: 4.9.5 optionalDependencies: fsevents: 2.3.3 dev: true - /vite@5.0.4(@types/node@20.11.1): - resolution: {integrity: sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==} + /vite@5.0.5(@types/node@20.11.1): + resolution: {integrity: sha512-OekeWqR9Ls56f3zd4CaxzbbS11gqYkEiBtnWFFgYR2WV8oPJRRKq0mpskYy/XaoCL3L7VINDhqqOMNDiYdGvGg==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -5996,7 +6032,7 @@ packages: dependencies: '@types/node': 20.11.1 esbuild: 0.19.11 - postcss: 8.4.32 + postcss: 8.4.33 rollup: 4.9.5 optionalDependencies: fsevents: 2.3.3 diff --git a/popup/package.json b/popup/package.json index ecd93d8..a61be7d 100644 --- a/popup/package.json +++ b/popup/package.json @@ -32,7 +32,7 @@ "prettier": "^3.0.3", "tailwindcss": "^3.4.1", "typescript": "~5.3.0", - "vite": "^5.0.10", + "vite": "^5.0.5", "vite-plugin-vue-devtools": "^7.0.7", "vue-tsc": "^1.8.25" } From 049c8e468e8403cbe331722fbde24bbe1131da9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=B8=E6=BE=A4Morty=20Li?= Date: Tue, 30 Jan 2024 14:44:15 +0800 Subject: [PATCH 2/4] fix: force update with vite.config's option --- popup/src/App.vue | 33 ++++++++++++++++++------ popup/src/components/LayoutPreview.vue | 5 ++-- popup/src/utils.ts | 35 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 popup/src/utils.ts diff --git a/popup/src/App.vue b/popup/src/App.vue index cfdbe72..460fb34 100644 --- a/popup/src/App.vue +++ b/popup/src/App.vue @@ -21,6 +21,7 @@ :is-draggable="state.isDraggable" :image-url="state.layoutPreview.imageUrl" :opacity="state.layoutPreview.opacity" + :user-style="state.layoutPreview.style" /> @@ -28,28 +29,45 @@ +./utils diff --git a/popup/src/components/LayoutPreview.vue b/popup/src/components/LayoutPreview.vue index 1e0e993..f7e5b73 100644 --- a/popup/src/components/LayoutPreview.vue +++ b/popup/src/components/LayoutPreview.vue @@ -11,6 +11,7 @@ const props = defineProps<{ isDraggable: boolean imageUrl: string opacity: number + userStyle: StyleValue }>() const defaultStyle = computed(() => { @@ -20,8 +21,6 @@ const defaultStyle = computed(() => { } }) -const userStyle = window._unpluginOverlayLayout?.layoutPreview?.style || {} - const el = ref(null) const { style: dragStyle } = useDraggable(el) @@ -45,6 +44,6 @@ const controlStyle = computed(() => { }) const mergedStyle = computed(() => { - return [defaultStyle.value, userStyle, ...controlStyle.value] + return [defaultStyle.value, props.userStyle, ...controlStyle.value] }) diff --git a/popup/src/utils.ts b/popup/src/utils.ts new file mode 100644 index 0000000..308c492 --- /dev/null +++ b/popup/src/utils.ts @@ -0,0 +1,35 @@ +export function deepEqual(obj1: any, obj2: any, excludeProps: string[] = []): boolean { + // Check if both objects are of the same type + if (typeof obj1 !== typeof obj2) { + return false + } + + // Check if both objects are primitive types or null + if (obj1 == null || obj2 == null || typeof obj1 !== 'object') { + return obj1 === obj2 + } + + // Get the keys of the objects + const keys1 = Object.keys(obj1) + const keys2 = Object.keys(obj2) + + // Check if the number of keys is the same + if (keys1.length !== keys2.length) { + return false + } + + // Iterate through the keys and recursively compare the values + for (const key of keys1) { + // Check if the current key should be excluded + if (excludeProps.includes(key)) { + continue + } + + if (!deepEqual(obj1[key], obj2[key], excludeProps)) { + return false + } + } + + // If all comparisons passed, the objects are deep equal + return true +} From dea03d432c66c784e411c5df0e228ab5566db989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=B8=E6=BE=A4Morty=20Li?= Date: Tue, 30 Jan 2024 14:50:00 +0800 Subject: [PATCH 3/4] chore: fix test's missing props --- popup/src/components/LayoutPreview.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/popup/src/components/LayoutPreview.spec.ts b/popup/src/components/LayoutPreview.spec.ts index e6a4d1a..851b186 100644 --- a/popup/src/components/LayoutPreview.spec.ts +++ b/popup/src/components/LayoutPreview.spec.ts @@ -10,7 +10,8 @@ const mountElement = (props?: { isDraggable?: boolean; imageUrl?: string; opacit const defaultProps = { isDraggable: true, imageUrl: '', - opacity: 100 + opacity: 100, + userStyle: '' } return shallowMount(LayoutPreview, { props: { From 6bee20b89c4442f8ec6b4b11eeaaad41edff17a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=B8=E6=BE=A4Morty=20Li?= Date: Tue, 30 Jan 2024 14:55:01 +0800 Subject: [PATCH 4/4] chore: fix userStyle props error --- popup/src/components/LayoutPreview.spec.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/popup/src/components/LayoutPreview.spec.ts b/popup/src/components/LayoutPreview.spec.ts index 851b186..bedbdd9 100644 --- a/popup/src/components/LayoutPreview.spec.ts +++ b/popup/src/components/LayoutPreview.spec.ts @@ -6,7 +6,12 @@ beforeEach(() => { window._unpluginOverlayLayout = {} }) -const mountElement = (props?: { isDraggable?: boolean; imageUrl?: string; opacity?: number }) => { +const mountElement = (props?: { + isDraggable?: boolean + imageUrl?: string + opacity?: number + userStyle?: string +}) => { const defaultProps = { isDraggable: true, imageUrl: '', @@ -23,15 +28,12 @@ const mountElement = (props?: { isDraggable?: boolean; imageUrl?: string; opacit describe('LayoutPreview.vue', () => { it('global style config can work', () => { - const style = 'width: 20px' - window._unpluginOverlayLayout = { - layoutPreview: { - style - } - } + const userStyle = 'width: 20px' - const wrapper = mountElement() - expect(wrapper.attributes('style')).toContain(style) + const wrapper = mountElement({ + userStyle + }) + expect(wrapper.attributes('style')).toContain(userStyle) }) it('computes the style correctly', () => {