Initial runtime Modules work

This commit is contained in:
Michael Telatynski
2025-01-27 10:07:35 +00:00
commit fa9de52a94
6 changed files with 111 additions and 0 deletions
+2
View File
@@ -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.
+1
View File
@@ -0,0 +1 @@
Example module to load all the nordeck opendesk legacy modules & deprecated customisations as a single modern module.
+26
View File
@@ -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"
}
}
+29
View File
@@ -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<void> {
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;
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"declaration": true
},
"include": ["src"]
}
@@ -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: {} },
},
});