commit fa9de52a94ebde25abdee9adf135244931ebcd8c Author: Michael Telatynski <7t3chguy@gmail.com> Date: Mon Jan 27 10:07:35 2025 +0000 Initial runtime Modules work diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 0000000000..4464820095 --- /dev/null +++ b/modules/README.md @@ -0,0 +1,2 @@ +Example and modules we maintain live here. +Each module may have multiple components, e.g. element-web + synapse, which are structured in subdirectories therein. diff --git a/modules/opendesk/README.md b/modules/opendesk/README.md new file mode 100644 index 0000000000..a5fd105d0a --- /dev/null +++ b/modules/opendesk/README.md @@ -0,0 +1 @@ +Example module to load all the nordeck opendesk legacy modules & deprecated customisations as a single modern module. diff --git a/modules/opendesk/element-web/package.json b/modules/opendesk/element-web/package.json new file mode 100644 index 0000000000..33838f0eea --- /dev/null +++ b/modules/opendesk/element-web/package.json @@ -0,0 +1,26 @@ +{ + "name": "nordeck-plugin", + "private": true, + "version": "0.0.0", + "type": "module", + "sideEffects": [ + "**/*.css" + ], + "devDependencies": { + "@element-hq/element-web-module-api": "^0.1.0", + "@nordeck/element-web-guest-module": "^2.0.0", + "@nordeck/element-web-opendesk-module": "^0.5.0", + "@nordeck/element-web-widget-lifecycle-module": "^1.0.1", + "@nordeck/element-web-widget-toggles-module": "^0.1.0", + "@types/node": "^22.10.7", + "@types/react": "^18", + "@vitejs/plugin-react": "^4.3.4", + "react": "^18.0.0", + "react-dom": "^18.0.0", + "rollup-plugin-external-globals": "^0.13.0", + "typescript": "^5.7.3", + "typescript-plugin-css-modules": "^5.1.0", + "vite": "^6.0.11", + "vite-plugin-node-polyfills": "^0.23.0" + } +} diff --git a/modules/opendesk/element-web/src/index.ts b/modules/opendesk/element-web/src/index.ts new file mode 100644 index 0000000000..a84736686e --- /dev/null +++ b/modules/opendesk/element-web/src/index.ts @@ -0,0 +1,29 @@ +/* +Copyright 2025 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +import { Module, Api, ModuleFactory } from "@element-hq/element-web-module-api"; +import NordeckOpendeskModule from "@nordeck/element-web-opendesk-module"; +import GuestModule from "@nordeck/element-web-guest-module"; +import WidgetLifecycleModule from "@nordeck/element-web-widget-lifecycle-module"; +import WidgetTogglesModule from "@nordeck/element-web-widget-toggles-module"; +import { ComponentVisibilityCustomisations } from "@nordeck/element-web-guest-module/customisations/ComponentVisibility"; + +class OpendeskModule implements Module { + public static readonly moduleApiVersion = "^0.1.0"; + + public constructor(private api: Api) {} + + public async load(): Promise { + this.api._registerLegacyModule(NordeckOpendeskModule); + this.api._registerLegacyModule(GuestModule); + this.api._registerLegacyModule(WidgetLifecycleModule); + this.api._registerLegacyModule(WidgetTogglesModule); + this.api._registerLegacyComponentVisibilityCustomisations(ComponentVisibilityCustomisations); + } +} + +export default OpendeskModule satisfies ModuleFactory; diff --git a/modules/opendesk/element-web/tsconfig.json b/modules/opendesk/element-web/tsconfig.json new file mode 100644 index 0000000000..3847e92f35 --- /dev/null +++ b/modules/opendesk/element-web/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "lib", + "declaration": true + }, + "include": ["src"] +} diff --git a/modules/opendesk/element-web/vite.config.ts b/modules/opendesk/element-web/vite.config.ts new file mode 100644 index 0000000000..019aa4e2e0 --- /dev/null +++ b/modules/opendesk/element-web/vite.config.ts @@ -0,0 +1,45 @@ +/* +Copyright 2025 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { nodePolyfills } from "vite-plugin-node-polyfills"; +import externalGlobals from "rollup-plugin-external-globals"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export default defineConfig({ + build: { + lib: { + entry: resolve(__dirname, "src/index.ts"), + name: "element-web-plugin-opendesk-nordeck", + fileName: "index", + formats: ["es"], + }, + outDir: "lib", + target: "esnext", + sourcemap: true, + rollupOptions: { + external: ["react", "@matrix-org/react-sdk-module-api"], + }, + }, + plugins: [ + react(), + nodePolyfills({ + include: ["events"], + }), + externalGlobals({ + // Reuse React from the host app + react: "window.React", + }), + ], + define: { + process: { env: {} }, + }, +});