diff options
Diffstat (limited to 'apps/workflowengine/src/helpers')
-rw-r--r-- | apps/workflowengine/src/helpers/api.js | 23 | ||||
-rw-r--r-- | apps/workflowengine/src/helpers/validators.js | 21 | ||||
-rw-r--r-- | apps/workflowengine/src/helpers/window.js | 30 |
3 files changed, 34 insertions, 40 deletions
diff --git a/apps/workflowengine/src/helpers/api.js b/apps/workflowengine/src/helpers/api.js index 9cad63f7d6b..c91bbb5f75c 100644 --- a/apps/workflowengine/src/helpers/api.js +++ b/apps/workflowengine/src/helpers/api.js @@ -1,25 +1,6 @@ /** - * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Julius Härtl <jus@bitgrid.net> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import { loadState } from '@nextcloud/initial-state' diff --git a/apps/workflowengine/src/helpers/validators.js b/apps/workflowengine/src/helpers/validators.js index b177da67889..0f2ca9e41b7 100644 --- a/apps/workflowengine/src/helpers/validators.js +++ b/apps/workflowengine/src/helpers/validators.js @@ -1,23 +1,6 @@ /** - * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ const regexRegex = /^\/(.*)\/([gui]{0,3})$/ diff --git a/apps/workflowengine/src/helpers/window.js b/apps/workflowengine/src/helpers/window.js new file mode 100644 index 00000000000..9538c4706d0 --- /dev/null +++ b/apps/workflowengine/src/helpers/window.js @@ -0,0 +1,30 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import wrap from '@vue/web-component-wrapper' +import Vue from 'vue' + +/** + * + * @param VueComponent {Object} The Vue component to turn into a Web Components custom element. + * @param customElementId {string} The element name, it must be unique. Recommended pattern oca-$appid-(checks|operations)-$use_case, example: oca-my_app-checks-request_user_agent + */ +function registerCustomElement(VueComponent, customElementId) { + const WrappedComponent = wrap(Vue, VueComponent) + if (window.customElements.get(customElementId)) { + console.error('Custom element with ID ' + customElementId + ' is already defined!') + throw new Error('Custom element with ID ' + customElementId + ' is already defined!') + } + window.customElements.define(customElementId, WrappedComponent) + + // In Vue 2, wrap doesn't support disabling shadow :( + // Disable with a hack + Object.defineProperty(WrappedComponent.prototype, 'attachShadow', { value() { return this } }) + Object.defineProperty(WrappedComponent.prototype, 'shadowRoot', { get() { return this } }) + + return customElementId +} + +export { registerCustomElement } |