From 9db6cb0953f263f13a6a7595c2661fa0a07d6f1b Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 17 Sep 2024 15:09:18 +0200 Subject: [PATCH] remove remaining webpack stuff Signed-off-by: Julien Veyssier --- .github/workflows/node.yml | 2 +- .nextcloudignore | 1 + makefile | 1 + package-lock.json | 27 +------------------ package.json | 3 +-- src/assistant.js | 42 ++++++++++++++---------------- src/imageGenerationReference.js | 10 ++----- src/speechToTextReference.js | 9 ++----- src/textGenerationReference.js | 10 ++----- webpack.js | 46 --------------------------------- 10 files changed, 30 insertions(+), 121 deletions(-) delete mode 100644 webpack.js diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 89585cb6..f71cc46d 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -72,7 +72,7 @@ jobs: npm ci npm run build --if-present - - name: Check webpack build changes + - name: Check build changes run: | bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)" diff --git a/.nextcloudignore b/.nextcloudignore index 88c92359..0993bf50 100644 --- a/.nextcloudignore +++ b/.nextcloudignore @@ -32,5 +32,6 @@ /renovate.json /stylelint.config.js /webpack.config.js +/vite.config.ts /webpack.js tests diff --git a/makefile b/makefile index a3d9bf28..ea432962 100644 --- a/makefile +++ b/makefile @@ -81,6 +81,7 @@ appstore: clean --exclude=/src \ --exclude=translationfiles \ --exclude=webpack.* \ + --exclude=/vite.* \ --exclude=stylelint.config.js \ --exclude=.eslintrc.js \ --exclude=.github \ diff --git a/package-lock.json b/package-lock.json index 08fbad42..10ee1985 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,8 +24,7 @@ "v-click-outside": "^3.2.0", "vue": "^2.7.12", "vue-clipboard2": "^0.3.3", - "vue-material-design-icons": "^5.1.2", - "vue2-audio-recorder": "^1.0.4" + "vue-material-design-icons": "^5.1.2" }, "devDependencies": { "@nextcloud/babel-config": "^1.0.0", @@ -9303,15 +9302,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lamejs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/lamejs/-/lamejs-1.2.1.tgz", - "integrity": "sha512-s7bxvjvYthw6oPLCm5pFxvA84wUROODB8jEO2+CE1adhKgrIvVOlmMgY8zyugxGrvRaDHNJanOiS21/emty6dQ==", - "license": "LGPL-3.0", - "dependencies": { - "use-strict": "1.0.1" - } - }, "node_modules/layerr": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/layerr/-/layerr-3.0.0.tgz", @@ -13808,12 +13798,6 @@ "dev": true, "license": "MIT" }, - "node_modules/use-strict": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/use-strict/-/use-strict-1.0.1.tgz", - "integrity": "sha512-IeiWvvEXfW5ltKVMkxq6FvNf2LojMKvB2OCeja6+ct24S1XOmQw2dGr2JyndwACWAGJva9B7yPHwAmeA9QCqAQ==", - "license": "ISC" - }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -14731,15 +14715,6 @@ "node": ">=10" } }, - "node_modules/vue2-audio-recorder": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/vue2-audio-recorder/-/vue2-audio-recorder-1.0.4.tgz", - "integrity": "sha512-Bi3jlzflqiY0wX5j+HLnZr//wMD85S6/NZa5oEPcPhWrbKLywKL06l9zpsCNQ/5t0dDDo7blM9gkfYzpdkARug==", - "license": "MIT", - "dependencies": { - "lamejs": "^1.2.0" - } - }, "node_modules/vue2-datepicker": { "version": "3.11.1", "resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-3.11.1.tgz", diff --git a/package.json b/package.json index 332c5f6e..088a6910 100644 --- a/package.json +++ b/package.json @@ -53,8 +53,7 @@ "v-click-outside": "^3.2.0", "vue": "^2.7.12", "vue-clipboard2": "^0.3.3", - "vue-material-design-icons": "^5.1.2", - "vue2-audio-recorder": "^1.0.4" + "vue-material-design-icons": "^5.1.2" }, "devDependencies": { "@nextcloud/babel-config": "^1.0.0", diff --git a/src/assistant.js b/src/assistant.js index 33b94d3d..06cba6a5 100644 --- a/src/assistant.js +++ b/src/assistant.js @@ -1,10 +1,6 @@ import { TASK_STATUS_STRING } from './constants.js' -// import { linkTo } from '@nextcloud/router' -// import { getRequestToken } from '@nextcloud/auth' import { showError } from '@nextcloud/dialogs' -// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -// __webpack_public_path__ = linkTo('assistant', 'js/') // eslint-disable-line window.assistantPollTimerId = null // TODO add param to lock on specific task type @@ -50,8 +46,8 @@ export async function openAssistantForm({ isInsideViewer = undefined, closeOnResult = false, actionButtons = undefined, customId = '', identifier = '', }) { - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') - const { default: AssistantTextProcessingModal } = await import(/* webpackChunkName: "assistant-modal-lazy" */'./components/AssistantTextProcessingModal.vue') + const { default: Vue } = await import('vue') + const { default: AssistantTextProcessingModal } = await import('./components/AssistantTextProcessingModal.vue') Vue.mixin({ methods: { t, n } }) // fallback to the last used one @@ -197,22 +193,22 @@ export async function cancelTaskPolling() { export async function getTask(taskId) { window.assistantAbortController = new AbortController() - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateOcsUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateOcsUrl } = await import('@nextcloud/router') const url = generateOcsUrl('taskprocessing/task/{taskId}', { taskId }) return axios.get(url, { signal: window.assistantAbortController.signal }) } export async function setNotifyReady(taskId) { - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateOcsUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateOcsUrl } = await import('@nextcloud/router') const url = generateOcsUrl('/apps/assistant/api/v1/task/{taskId}/notify', { taskId }) return axios.post(url, {}) } export async function cancelTask(taskId) { - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateOcsUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateOcsUrl } = await import('@nextcloud/router') const url = generateOcsUrl('taskprocessing/task/{taskId}', { taskId }) return axios.delete(url, {}) } @@ -228,8 +224,8 @@ export async function cancelTask(taskId) { */ export async function scheduleTask(appId, customId, taskType, inputs) { window.assistantAbortController = new AbortController() - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateOcsUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateOcsUrl } = await import('@nextcloud/router') saveLastSelectedTaskType(taskType) const url = generateOcsUrl('taskprocessing/schedule') const params = { @@ -242,8 +238,8 @@ export async function scheduleTask(appId, customId, taskType, inputs) { } async function saveLastSelectedTaskType(taskType) { - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateUrl } = await import('@nextcloud/router') const req = { values: { @@ -255,8 +251,8 @@ async function saveLastSelectedTaskType(taskType) { } async function getLastSelectedTaskType() { - const { default: axios } = await import(/* webpackChunkName: "axios-lazy" */'@nextcloud/axios') - const { generateUrl } = await import(/* webpackChunkName: "router-gen-lazy" */'@nextcloud/router') + const { default: axios } = await import('@nextcloud/axios') + const { generateUrl } = await import('@nextcloud/router') const req = { params: { @@ -316,10 +312,10 @@ async function showAssistantTaskResult(taskId) { * @return {Promise} */ export async function openAssistantTask(task, { isInsideViewer = undefined, actionButtons = undefined } = {}) { - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') + const { default: Vue } = await import('vue') Vue.mixin({ methods: { t, n } }) - const { showError } = await import(/* webpackChunkName: "dialogs-lazy" */'@nextcloud/dialogs') - const { default: AssistantTextProcessingModal } = await import(/* webpackChunkName: "assistant-modal-lazy" */'./components/AssistantTextProcessingModal.vue') + const { showError } = await import('@nextcloud/dialogs') + const { default: AssistantTextProcessingModal } = await import('./components/AssistantTextProcessingModal.vue') const modalId = 'assistantTextProcessingModal' const modalElement = document.createElement('div') @@ -432,8 +428,8 @@ export async function addAssistantMenuEntry() { menuEntry.id = 'assistant' headerRight.prepend(menuEntry) - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') - const { default: AssistantHeaderMenuEntry } = await import(/* webpackChunkName: "assistant-header-lazy" */'./components/AssistantHeaderMenuEntry.vue') + const { default: Vue } = await import('vue') + const { default: AssistantHeaderMenuEntry } = await import('./components/AssistantHeaderMenuEntry.vue') Vue.mixin({ methods: { t, n } }) const View = Vue.extend(AssistantHeaderMenuEntry) diff --git a/src/imageGenerationReference.js b/src/imageGenerationReference.js index 40ec91b2..cb852095 100644 --- a/src/imageGenerationReference.js +++ b/src/imageGenerationReference.js @@ -3,16 +3,10 @@ import { registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Components/NcRichText.js' -// import { linkTo } from '@nextcloud/router' -// import { getRequestToken } from '@nextcloud/auth' - -// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -// __webpack_public_path__ = linkTo('assistant', 'js/') // eslint-disable-line - registerCustomPickerElement('assistant_image_generation', async (el, { providerId, accessible }) => { - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') + const { default: Vue } = await import('vue') Vue.mixin({ methods: { t, n } }) - const { default: ImageResultCustomPickerElement } = await import(/* webpackChunkName: "reference-picker-lazy" */'./views/ImageResultCustomPickerElement.vue') + const { default: ImageResultCustomPickerElement } = await import('./views/ImageResultCustomPickerElement.vue') const Element = Vue.extend(ImageResultCustomPickerElement) const vueElement = new Element({ diff --git a/src/speechToTextReference.js b/src/speechToTextReference.js index 0cda4a80..9ee6667f 100644 --- a/src/speechToTextReference.js +++ b/src/speechToTextReference.js @@ -22,16 +22,11 @@ */ import { registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Components/NcRichText.js' -// import { linkTo } from '@nextcloud/router' -// import { getRequestToken } from '@nextcloud/auth' - -// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -// __webpack_public_path__ = linkTo('assistant', 'js/') // eslint-disable-line registerCustomPickerElement('assistant_speech_to_text', async (el, { providerId, accessible }) => { - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') + const { default: Vue } = await import('vue') Vue.mixin({ methods: { t, n } }) - const { default: TextResultCustomPickerElement } = await import(/* webpackChunkName: "reference-picker-lazy" */'./views/TextResultCustomPickerElement.vue') + const { default: TextResultCustomPickerElement } = await import('./views/TextResultCustomPickerElement.vue') const Element = Vue.extend(TextResultCustomPickerElement) const vueElement = new Element({ propsData: { diff --git a/src/textGenerationReference.js b/src/textGenerationReference.js index 6b23a6eb..28175080 100644 --- a/src/textGenerationReference.js +++ b/src/textGenerationReference.js @@ -3,16 +3,10 @@ import { registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/dist/Components/NcRichText.js' -// import { linkTo } from '@nextcloud/router' -// import { getRequestToken } from '@nextcloud/auth' - -// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -// __webpack_public_path__ = linkTo('assistant', 'js/') // eslint-disable-line - registerCustomPickerElement('assistant_text', async (el, { providerId, accessible }) => { - const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue') + const { default: Vue } = await import('vue') Vue.mixin({ methods: { t, n } }) - const { default: TextResultCustomPickerElement } = await import(/* webpackChunkName: "reference-picker-lazy" */'./views/TextResultCustomPickerElement.vue') + const { default: TextResultCustomPickerElement } = await import('./views/TextResultCustomPickerElement.vue') const Element = Vue.extend(TextResultCustomPickerElement) const vueElement = new Element({ propsData: { diff --git a/webpack.js b/webpack.js deleted file mode 100644 index 9523d716..00000000 --- a/webpack.js +++ /dev/null @@ -1,46 +0,0 @@ -const path = require('path') -const webpackConfig = require('@nextcloud/webpack-vue-config') -const ESLintPlugin = require('eslint-webpack-plugin') -const StyleLintPlugin = require('stylelint-webpack-plugin') - -const buildMode = process.env.NODE_ENV -const isDev = buildMode === 'development' -webpackConfig.devtool = isDev ? 'cheap-source-map' : 'source-map' -// webpackConfig.bail = false - -webpackConfig.stats = { - colors: true, - modules: false, -} - -const appId = 'assistant' -webpackConfig.entry = { - imageGenerationReference: { import: path.join(__dirname, 'src', 'imageGenerationReference.js'), filename: appId + '-imageGenerationReference.js' }, - textGenerationReference: { import: path.join(__dirname, 'src', 'textGenerationReference.js'), filename: appId + '-textGenerationReference.js' }, - speechToTextReference: { import: path.join(__dirname, 'src', 'speechToTextReference.js'), filename: appId + '-speechToTextReference.js' }, - personalSettings: { import: path.join(__dirname, 'src', 'personalSettings.js'), filename: appId + '-personalSettings.js' }, - adminSettings: { import: path.join(__dirname, 'src', 'adminSettings.js'), filename: appId + '-adminSettings.js' }, - main: { import: path.join(__dirname, 'src', 'main.js'), filename: appId + '-main.js' }, - assistantPage: { import: path.join(__dirname, 'src', 'assistantPage.js'), filename: appId + '-assistantPage.js' }, -} - -webpackConfig.plugins.push( - new ESLintPlugin({ - extensions: ['js', 'vue'], - files: 'src', - failOnError: !isDev, - }), -) -webpackConfig.plugins.push( - new StyleLintPlugin({ - files: 'src/**/*.{css,scss,vue}', - failOnError: !isDev, - }), -) - -webpackConfig.module.rules.push({ - test: /\.svg$/i, - type: 'asset/source', -}) - -module.exports = webpackConfig