From 0b5f5197353c9d5156af127a925795582816f8d5 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 20 Mar 2021 15:10:16 +0100 Subject: [PATCH] Encapsulated the external modal from spawning and administrating windows --- client/app/{index.scss => AppMain.scss} | 0 client/app/EntryPointPopoutModal.ts | 3 - client/app/entry-points/AppMain.ts | 4 + .../{index.ts => entry-points/ModalWindow.ts} | 4 +- loader/app/targets/maifest-target.ts | 2 +- loader/exports/loader.d.ts | 5 +- package-lock.json | 6 +- package.json | 5 +- shared/css/static/modal.scss | 1 - shared/js/devel_main.ts | 25 -- shared/js/entry-points/MainApp.ts | 1 + shared/js/entry-points/ModalWindow.ts | 1 + shared/js/i18n/localize.ts | 2 +- shared/js/main.tsx | 2 +- shared/js/settings.ts | 12 +- shared/js/ui/react-elements/Button.tsx | 15 +- .../external-modal/Controller.ts | 169 -------------- .../external-modal/IPCMessage.ts | 47 ---- .../external-modal/PopoutController.ts | 89 ------- .../external-modal/PopoutEntrypoint.ts | 89 ------- .../ui/react-elements/external-modal/index.ts | 17 -- .../js/ui/react-elements/modal/Controller.ts | 16 +- .../js/ui/react-elements/modal/Definitions.ts | 2 + .../js/ui/react-elements/modal/Renderer.scss | 21 ++ .../js/ui/react-elements/modal/Renderer.tsx | 3 +- .../modal/external/Controller.ts | 219 ++++++++++++++++++ .../modal/external/Definitions.ts | 38 +++ .../modal/external/renderer/Controller.ts | 106 +++++++++ .../modal/external/renderer/EntryPoint.ts | 93 ++++++++ .../external/renderer}/ModalRenderer.scss | 8 +- .../external/renderer}/ModalRenderer.tsx | 2 +- .../react-elements/modal/internal/index.tsx | 2 +- shared/js/ui/windows/WindowManager.ts | 50 ++++ web/app/ExternalModalFactory.ts | 155 ------------- web/app/UnloadHandler.ts | 4 +- web/app/WebWindowManager.ts | 197 ++++++++++++++++ web/app/entry-points/AppMain.ts | 14 ++ web/app/entry-points/ModalWindow.ts | 4 + web/app/hooks/{Dns.ts => DNS.ts} | 0 web/app/hooks/ExternalModal.ts | 12 - web/app/hooks/WindowManager.ts | 10 + web/app/hooks/index.ts | 5 +- web/app/index-external.ts | 4 - web/app/index.ts | 14 -- webpack-client.config.ts | 7 +- webpack-web.config.ts | 4 +- webpack.config.ts | 3 +- webpack/ManifestPlugin.ts | 23 +- 48 files changed, 830 insertions(+), 685 deletions(-) rename client/app/{index.scss => AppMain.scss} (100%) delete mode 100644 client/app/EntryPointPopoutModal.ts create mode 100644 client/app/entry-points/AppMain.ts rename client/app/{index.ts => entry-points/ModalWindow.ts} (54%) delete mode 100644 shared/js/devel_main.ts create mode 100644 shared/js/entry-points/MainApp.ts create mode 100644 shared/js/entry-points/ModalWindow.ts delete mode 100644 shared/js/ui/react-elements/external-modal/Controller.ts delete mode 100644 shared/js/ui/react-elements/external-modal/IPCMessage.ts delete mode 100644 shared/js/ui/react-elements/external-modal/PopoutController.ts delete mode 100644 shared/js/ui/react-elements/external-modal/PopoutEntrypoint.ts delete mode 100644 shared/js/ui/react-elements/external-modal/index.ts create mode 100644 shared/js/ui/react-elements/modal/external/Controller.ts create mode 100644 shared/js/ui/react-elements/modal/external/Definitions.ts create mode 100644 shared/js/ui/react-elements/modal/external/renderer/Controller.ts create mode 100644 shared/js/ui/react-elements/modal/external/renderer/EntryPoint.ts rename shared/js/ui/react-elements/{external-modal => modal/external/renderer}/ModalRenderer.scss (57%) rename shared/js/ui/react-elements/{external-modal => modal/external/renderer}/ModalRenderer.tsx (97%) create mode 100644 shared/js/ui/windows/WindowManager.ts delete mode 100644 web/app/ExternalModalFactory.ts create mode 100644 web/app/WebWindowManager.ts create mode 100644 web/app/entry-points/AppMain.ts create mode 100644 web/app/entry-points/ModalWindow.ts rename web/app/hooks/{Dns.ts => DNS.ts} (100%) delete mode 100644 web/app/hooks/ExternalModal.ts create mode 100644 web/app/hooks/WindowManager.ts delete mode 100644 web/app/index-external.ts delete mode 100644 web/app/index.ts diff --git a/client/app/index.scss b/client/app/AppMain.scss similarity index 100% rename from client/app/index.scss rename to client/app/AppMain.scss diff --git a/client/app/EntryPointPopoutModal.ts b/client/app/EntryPointPopoutModal.ts deleted file mode 100644 index ea540cf6..00000000 --- a/client/app/EntryPointPopoutModal.ts +++ /dev/null @@ -1,3 +0,0 @@ -window.__native_client_init_shared(__webpack_require__); - -import "tc-shared/ui/react-elements/external-modal/PopoutEntrypoint"; \ No newline at end of file diff --git a/client/app/entry-points/AppMain.ts b/client/app/entry-points/AppMain.ts new file mode 100644 index 00000000..b248c848 --- /dev/null +++ b/client/app/entry-points/AppMain.ts @@ -0,0 +1,4 @@ +window.__native_client_init_shared(__webpack_require__); + +import "../AppMain.scss"; +import "tc-shared/entry-points/MainApp"; \ No newline at end of file diff --git a/client/app/index.ts b/client/app/entry-points/ModalWindow.ts similarity index 54% rename from client/app/index.ts rename to client/app/entry-points/ModalWindow.ts index 091fd57e..0c08ce71 100644 --- a/client/app/index.ts +++ b/client/app/entry-points/ModalWindow.ts @@ -1,4 +1,2 @@ window.__native_client_init_shared(__webpack_require__); - -import "./index.scss"; -import "tc-shared/main"; \ No newline at end of file +import "tc-shared/entry-points/ModalWindow"; \ No newline at end of file diff --git a/loader/app/targets/maifest-target.ts b/loader/app/targets/maifest-target.ts index d53e7a63..f4e0a0a7 100644 --- a/loader/app/targets/maifest-target.ts +++ b/loader/app/targets/maifest-target.ts @@ -10,7 +10,7 @@ export default class implements ApplicationLoader { function: async taskId => { await loadManifest(); - const entryChunk = getUrlParameter("chunk"); + const entryChunk = getUrlParameter("loader-chunk"); if(!entryChunk) { loader.critical_error("Missing entry chunk parameter"); throw "Missing entry chunk parameter"; diff --git a/loader/exports/loader.d.ts b/loader/exports/loader.d.ts index 51ac6e9d..7d28d717 100644 --- a/loader/exports/loader.d.ts +++ b/loader/exports/loader.d.ts @@ -24,7 +24,7 @@ export let config: Config; export type Task = { name: string, priority: number, /* tasks with the same priority will be executed in sync */ - function: () => Promise + function: (taskId: number) => Promise }; export enum Stage { /* @@ -86,4 +86,5 @@ export type SourcePath = string | DependSource | string[]; export type ErrorHandler = (message: string, detail: string) => void; export function critical_error(message: string, detail?: string); export function critical_error_handler(handler?: ErrorHandler, override?: boolean); -export function hide_overlay(); \ No newline at end of file +export function hide_overlay(); +export function setCurrentTaskName(taskId: number, name: string); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d2a6b819..e701dc44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19305,9 +19305,9 @@ } }, "webpack-svg-sprite-generator": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/webpack-svg-sprite-generator/-/webpack-svg-sprite-generator-5.0.2.tgz", - "integrity": "sha512-i3b4aKgy2VZI7uYYEteKvnv3+mRtG+UfFSCYvnvoGs4dLJ++pDwbGGZL1XaYXN8qbePsHD88JQEvhfkChtx3aw==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/webpack-svg-sprite-generator/-/webpack-svg-sprite-generator-5.0.4.tgz", + "integrity": "sha512-j+Bl44VoF/Jv0pz0qfU/zeomoVUmWWZ0CGpaHdLH7xwHiCK4xCB2E+xaaSYSDRxoyNZNJEKESOIX+BzKCW4QYg==", "dev": true }, "webrtc-adapter": { diff --git a/package.json b/package.json index d146d363..12f47605 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "webpack-web": "webpack --config webpack-web.config.js", "webpack-client": "webpack --config webpack-client.config.js", "generate-i18n-gtranslate": "node shared/generate_i18n_gtranslate.js", - "dev-server": "npm run compile-project-base && webpack serve --config webpack-web.config.js" + "dev-server": "npm run compile-project-base && webpack serve --config webpack-web.config.js", + "dev-server-client": "npm run compile-project-base && webpack serve --config webpack-client.config.js" }, "author": "TeaSpeak (WolverinDEV)", "license": "ISC", @@ -85,7 +86,7 @@ "webpack-bundle-analyzer": "^3.6.1", "webpack-cli": "^4.5.0", "webpack-dev-server": "^3.11.2", - "webpack-svg-sprite-generator": "^5.0.2", + "webpack-svg-sprite-generator": "^5.0.4", "zip-webpack-plugin": "^4.0.1" }, "repository": { diff --git a/shared/css/static/modal.scss b/shared/css/static/modal.scss index abc5abb0..80a65d7e 100644 --- a/shared/css/static/modal.scss +++ b/shared/css/static/modal.scss @@ -2,7 +2,6 @@ @import "mixin"; :global { - .modal { color: #999999; /* base color */ diff --git a/shared/js/devel_main.ts b/shared/js/devel_main.ts deleted file mode 100644 index 38190583..00000000 --- a/shared/js/devel_main.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as loader from "tc-loader"; -import {Stage} from "tc-loader"; - -import * as ipc from "./ipc/BrowserIPC"; -import * as i18n from "./i18n/localize"; - -import "./proto"; - - -console.error("Hello World from devel main"); -loader.register_task(Stage.JAVASCRIPT_INITIALIZING, { - name: "setup", - priority: 10, - function: async () => { - await i18n.initialize(); - ipc.setupIpcHandler(); - } -}); - -loader.register_task(Stage.LOADED, { - name: "invoke", - priority: 10, - function: async () => { - } -}); \ No newline at end of file diff --git a/shared/js/entry-points/MainApp.ts b/shared/js/entry-points/MainApp.ts new file mode 100644 index 00000000..fff46740 --- /dev/null +++ b/shared/js/entry-points/MainApp.ts @@ -0,0 +1 @@ +import "../main"; \ No newline at end of file diff --git a/shared/js/entry-points/ModalWindow.ts b/shared/js/entry-points/ModalWindow.ts new file mode 100644 index 00000000..31eb60b8 --- /dev/null +++ b/shared/js/entry-points/ModalWindow.ts @@ -0,0 +1 @@ +import "../ui/react-elements/modal/external/renderer/EntryPoint"; \ No newline at end of file diff --git a/shared/js/i18n/localize.ts b/shared/js/i18n/localize.ts index 5d4a0aeb..f8bf002f 100644 --- a/shared/js/i18n/localize.ts +++ b/shared/js/i18n/localize.ts @@ -316,7 +316,7 @@ export function select_translation(repository: TranslationRepository, entry: Rep } /* ATTENTION: This method is called before most other library initialisations! */ -export async function initialize() { +export async function initializeI18N() { const rcfg = config.repository_config(); /* initialize */ const cfg = config.translation_config(); diff --git a/shared/js/main.tsx b/shared/js/main.tsx index 0fd27e80..f9d3d699 100644 --- a/shared/js/main.tsx +++ b/shared/js/main.tsx @@ -59,7 +59,7 @@ assertMainApplication(); let preventWelcomeUI = false; async function initialize() { try { - await i18n.initialize(); + await i18n.initializeI18N(); } catch(error) { console.error(tr("Failed to initialized the translation system!\nError: %o"), error); loader.critical_error("Failed to setup the translation system"); diff --git a/shared/js/settings.ts b/shared/js/settings.ts index 8e078e67..94e377b3 100644 --- a/shared/js/settings.ts +++ b/shared/js/settings.ts @@ -275,16 +275,10 @@ export namespace AppParameters { description: "Peer address of the apps core", }; - export const KEY_MODAL_IDENTITY_CODE: RegistryKey = { - key: "modal-identify", + export const KEY_MODAL_IPC_CHANNEL: RegistryKey = { + key: "modal-channel", valueType: "string", - description: "An authentication code used to register the new process as the modal" - }; - - export const KEY_MODAL_TARGET: RegistryKey = { - key: "modal-target", - valueType: "string", - description: "Target modal unique id which should be loaded" + description: "The modal IPC channel id for communication with the controller" }; export const KEY_LOAD_DUMMY_ERROR: ValuedRegistryKey = { diff --git a/shared/js/ui/react-elements/Button.tsx b/shared/js/ui/react-elements/Button.tsx index c5cb9142..03f70822 100644 --- a/shared/js/ui/react-elements/Button.tsx +++ b/shared/js/ui/react-elements/Button.tsx @@ -1,5 +1,6 @@ import {ReactComponentBase} from "tc-shared/ui/react-elements/ReactComponentBase"; import * as React from "react"; +import {joinClassList} from "tc-shared/ui/react-elements/Helper"; const cssStyle = require("./Button.scss"); @@ -21,12 +22,14 @@ export interface ButtonState { disabled?: boolean } -export class Button extends ReactComponentBase { - protected defaultState(): ButtonState { - return { +export class Button extends React.Component { + constructor(props) { + super(props); + + this.state = { disabled: undefined - }; - } + } + }; render() { if(this.props.hidden) @@ -34,7 +37,7 @@ export class Button extends ReactComponentBase { return (