Skip to content

Commit e6089ee

Browse files
Merge pull request #50428 from nextcloud/backport/50320/stable31
[stable31] fix(theming): remove node-vibrant dependency and usage (was moved to backend)
2 parents abab62b + 56a57e9 commit e6089ee

12 files changed

+43
-669
lines changed

apps/theming/src/components/BackgroundSettings.vue

+4-45
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,12 @@
7878
</template>
7979

8080
<script>
81-
import { generateFilePath, generateRemoteUrl, generateUrl } from '@nextcloud/router'
82-
import { getCurrentUser } from '@nextcloud/auth'
81+
import { generateFilePath, generateUrl } from '@nextcloud/router'
8382
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
8483
import { loadState } from '@nextcloud/initial-state'
85-
import { Palette } from 'node-vibrant/lib/color.js'
8684
import axios from '@nextcloud/axios'
8785
import debounce from 'debounce'
8886
import NcColorPicker from '@nextcloud/vue/dist/Components/NcColorPicker.js'
89-
import Vibrant from 'node-vibrant'
9087

9188
import Check from 'vue-material-design-icons/Check.vue'
9289
import ImageEdit from 'vue-material-design-icons/ImageEdit.vue'
@@ -217,9 +214,9 @@ export default {
217214
this.update(result.data)
218215
},
219216

220-
async setFile(path, color = null) {
217+
async setFile(path) {
221218
this.loading = 'custom'
222-
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path, color })
219+
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path })
223220
this.update(result.data)
224221
},
225222

@@ -264,45 +261,7 @@ export default {
264261
}
265262

266263
this.loading = 'custom'
267-
268-
// Extract primary color from image
269-
let response = null
270-
let color = null
271-
try {
272-
const fileUrl = generateRemoteUrl('dav/files/' + getCurrentUser().uid + path)
273-
response = await axios.get(fileUrl, { responseType: 'blob' })
274-
const blobUrl = URL.createObjectURL(response.data)
275-
const palette = await this.getColorPaletteFromBlob(blobUrl)
276-
277-
// DarkVibrant is accessible AND visually pleasing
278-
// Vibrant is not accessible enough and others are boring
279-
color = palette?.DarkVibrant?.hex
280-
this.setFile(path, color)
281-
282-
// Log data
283-
console.debug('Extracted colour', color, 'from custom image', path, palette)
284-
} catch (error) {
285-
this.setFile(path)
286-
console.error('Unable to extract colour from custom image', { error, path, response, color })
287-
}
288-
},
289-
290-
/**
291-
* Extract a Vibrant color palette from a blob URL
292-
*
293-
* @param {string} blobUrl the blob URL
294-
* @return {Promise<Palette>}
295-
*/
296-
getColorPaletteFromBlob(blobUrl) {
297-
return new Promise((resolve, reject) => {
298-
const vibrant = new Vibrant(blobUrl)
299-
vibrant.getPalette((error, palette) => {
300-
if (error) {
301-
reject(error)
302-
}
303-
resolve(palette)
304-
})
305-
})
264+
this.setFile(path)
306265
},
307266
},
308267
}

dist/core-common.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dav-settings-personal-availability.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dav-settings-personal-availability.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-webauthn.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-webauthn.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/theming-personal-theming.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/theming-personal-theming.js.license

-66
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,19 @@ SPDX-License-Identifier: BSD-3-Clause
55
SPDX-License-Identifier: AGPL-3.0-or-later
66
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
77
SPDX-FileCopyrightText: xiaokai <kexiaokai@gmail.com>
8-
SPDX-FileCopyrightText: qs developers
98
SPDX-FileCopyrightText: inherits developers
109
SPDX-FileCopyrightText: escape-html developers
11-
SPDX-FileCopyrightText: defunctzombie
1210
SPDX-FileCopyrightText: debounce developers
13-
SPDX-FileCopyrightText: akfish
1411
SPDX-FileCopyrightText: Varun A P
1512
SPDX-FileCopyrightText: Tobias Koppers @sokra
1613
SPDX-FileCopyrightText: T. Jameson Little <t.jameson.little@gmail.com>
1714
SPDX-FileCopyrightText: Roman Shtylman <shtylman@gmail.com>
1815
SPDX-FileCopyrightText: Rob Cresswell <robcresswell@pm.me>
19-
SPDX-FileCopyrightText: Raynos <raynos2@gmail.com>
2016
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
2117
SPDX-FileCopyrightText: Matt Zabriskie
22-
SPDX-FileCopyrightText: Mathias Bynens
2318
SPDX-FileCopyrightText: Joyent
24-
SPDX-FileCopyrightText: Jordan Harband <ljharb@gmail.com>
25-
SPDX-FileCopyrightText: Jordan Harband
2619
SPDX-FileCopyrightText: John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)
27-
SPDX-FileCopyrightText: John-David Dalton <john.david.dalton@gmail.com>
2820
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
29-
SPDX-FileCopyrightText: James Halliday
3021
SPDX-FileCopyrightText: Hiroki Osame
3122
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
3223
SPDX-FileCopyrightText: GitHub Inc.
@@ -83,27 +74,15 @@ This file is generated from multiple sources. Included packages:
8374
- base64-js
8475
- version: 1.5.1
8576
- license: MIT
86-
- call-bind
87-
- version: 1.0.7
88-
- license: MIT
8977
- css-loader
9078
- version: 7.1.2
9179
- license: MIT
9280
- debounce
9381
- version: 2.2.0
9482
- license: MIT
95-
- define-data-property
96-
- version: 1.1.4
97-
- license: MIT
9883
- dompurify
9984
- version: 3.1.7
10085
- license: (MPL-2.0 OR Apache-2.0)
101-
- es-define-property
102-
- version: 1.0.0
103-
- license: MIT
104-
- es-errors
105-
- version: 1.3.0
106-
- license: MIT
10786
- escape-html
10887
- version: 1.0.3
10988
- license: MIT
@@ -113,48 +92,18 @@ This file is generated from multiple sources. Included packages:
11392
- focus-trap
11493
- version: 7.6.0
11594
- license: MIT
116-
- function-bind
117-
- version: 1.1.2
118-
- license: MIT
119-
- get-intrinsic
120-
- version: 1.2.4
121-
- license: MIT
122-
- gopd
123-
- version: 1.0.1
124-
- license: MIT
125-
- has-property-descriptors
126-
- version: 1.0.2
127-
- license: MIT
128-
- has-proto
129-
- version: 1.0.3
130-
- license: MIT
131-
- has-symbols
132-
- version: 1.0.3
133-
- license: MIT
134-
- hasown
135-
- version: 2.0.2
136-
- license: MIT
13795
- ieee754
13896
- version: 1.2.1
13997
- license: BSD-3-Clause
14098
- lodash.get
14199
- version: 4.4.2
142100
- license: MIT
143-
- lodash
144-
- version: 4.17.21
145-
- license: MIT
146101
- node-gettext
147102
- version: 3.0.0
148103
- license: MIT
149104
- buffer
150105
- version: 6.0.3
151106
- license: MIT
152-
- node-vibrant
153-
- version: 3.1.6
154-
- license: MIT
155-
- object-inspect
156-
- version: 1.13.2
157-
- license: MIT
158107
- inherits
159108
- version: 2.0.3
160109
- license: ISC
@@ -167,18 +116,6 @@ This file is generated from multiple sources. Included packages:
167116
- process
168117
- version: 0.11.10
169118
- license: MIT
170-
- punycode
171-
- version: 1.4.1
172-
- license: MIT
173-
- qs
174-
- version: 6.13.0
175-
- license: BSD-3-Clause
176-
- set-function-length
177-
- version: 1.2.2
178-
- license: MIT
179-
- side-channel
180-
- version: 1.0.6
181-
- license: MIT
182119
- style-loader
183120
- version: 4.0.0
184121
- license: MIT
@@ -188,9 +125,6 @@ This file is generated from multiple sources. Included packages:
188125
- toastify-js
189126
- version: 1.12.0
190127
- license: MIT
191-
- url
192-
- version: 0.11.4
193-
- license: MIT
194128
- vue-color
195129
- version: 2.8.1
196130
- license: MIT

dist/theming-personal-theming.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)