From 6aaffe20d9bf3fbc76c046ad72722f77b6ea9384 Mon Sep 17 00:00:00 2001 From: PeekabooSteam Date: Tue, 12 Sep 2023 19:04:52 +0100 Subject: [PATCH] Plugin (not) work. --- client/app.js | 4 ++++ client/package-lock.json | 20 ++++++++++++++++++++ client/package.json | 1 + client/src/index.ts | 5 +++-- client/src/indexapp.ts | 13 ------------- client/src/olympusapp.ts | 1 + 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/client/app.js b/client/app.js index 651c2b73..1631c683 100644 --- a/client/app.js +++ b/client/app.js @@ -19,6 +19,10 @@ app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); +if ( !fs.existsSync( "./src/_importedplugins" ) ) { + fs.mkdirSync( "./src/_importedplugins" ); +} + app.use('/', indexRouter); app.use('/api/atc', atcRouter); app.use('/api/airbases', airbasesRouter); diff --git a/client/package-lock.json b/client/package-lock.json index 95dcb9ea..c137234a 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -38,6 +38,7 @@ "leaflet-path-drag": "*", "leaflet.nauticscale": "^1.1.0", "nodemon": "^2.0.20", + "requirejs": "^2.3.6", "sortablejs": "^1.15.0", "tsify": "^5.0.4", "typescript": "^4.9.4", @@ -6776,6 +6777,19 @@ "node": ">=0.10.0" } }, + "node_modules/requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", + "dev": true, + "bin": { + "r_js": "bin/r.js", + "r.js": "bin/r.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -13000,6 +13014,12 @@ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", + "dev": true + }, "resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", diff --git a/client/package.json b/client/package.json index d3df3e95..fcf651cc 100644 --- a/client/package.json +++ b/client/package.json @@ -40,6 +40,7 @@ "leaflet-path-drag": "*", "leaflet.nauticscale": "^1.1.0", "nodemon": "^2.0.20", + "requirejs": "^2.3.6", "sortablejs": "^1.15.0", "tsify": "^5.0.4", "typescript": "^4.9.4", diff --git a/client/src/index.ts b/client/src/index.ts index 347bab58..865cf2ef 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -11,7 +11,6 @@ import { FeatureSwitches } from "./features/featureswitches"; import { LogPanel } from "./panels/logpanel"; import { getConfig, getPaused, setAddress, setCredentials, setPaused, startUpdate, toggleDemoEnabled } from "./server/server"; import { UnitDataTable } from "./atc/unitdatatable"; -import { keyEventWasInInput } from "./other/utils"; import { Popup } from "./popups/popup"; import { Dropdown } from "./controls/dropdown"; import { HotgroupPanel } from "./panels/hotgrouppanel"; @@ -21,9 +20,9 @@ import { ServerStatusPanel } from "./panels/serverstatuspanel"; import { WeaponsManager } from "./weapon/weaponsmanager"; import { IndexApp } from "./indexapp"; import { ShortcutKeyboard } from "./shortcut/shortcut"; -import { ShortcutManager } from "./shortcut/shortcutmanager"; import { OlympusApp } from "./olympusapp"; + var map: Map; var unitsManager: UnitsManager; @@ -118,6 +117,8 @@ function setup() { /* Setup event handlers */ setupEvents( indexApp ); + indexApp.start(); + } function readConfig(config: any) { diff --git a/client/src/indexapp.ts b/client/src/indexapp.ts index 55c589b9..d6779b2c 100644 --- a/client/src/indexapp.ts +++ b/client/src/indexapp.ts @@ -1,5 +1,4 @@ import { FeatureSwitches } from "./features/featureswitches"; -import { Map } from "./map/map"; import { MissionHandler } from "./mission/missionhandler"; import { IOlympusApp, OlympusApp } from "./olympusapp"; import { ConnectionStatusPanel } from "./panels/connectionstatuspanel"; @@ -10,8 +9,6 @@ import { Panel } from "./panels/panel"; import { ServerStatusPanel } from "./panels/serverstatuspanel"; import { UnitControlPanel } from "./panels/unitcontrolpanel"; import { UnitInfoPanel } from "./panels/unitinfopanel"; -import { PluginManager } from "./plugin/pluginmanager"; -import { PluginHelloWorld } from "./plugins/helloworld/pluginhelloworld"; import { Popup } from "./popups/popup"; import { UnitsManager } from "./unit/unitsmanager"; @@ -35,8 +32,6 @@ export interface IIndexAppPanels { export class IndexApp extends OlympusApp { - #pluginManager!: PluginManager; - constructor( config:IIndexApp ) { super( config ); @@ -58,14 +53,6 @@ export class IndexApp extends OlympusApp { Object.values( this.getPanelsManager().getAll() ).forEach( ( panel:Panel ) => { panel.setOlympusApp( this ); }); - - // Plugins - this.#pluginManager = new PluginManager( this ); - - // Manual loading for now - this.getMap().whenReady( () => { - this.#pluginManager.add( "helloWorld", new PluginHelloWorld( this ) ); - }); } diff --git a/client/src/olympusapp.ts b/client/src/olympusapp.ts index 7665fd7b..d444cceb 100644 --- a/client/src/olympusapp.ts +++ b/client/src/olympusapp.ts @@ -6,6 +6,7 @@ import { PanelsManager } from "./panels/panelsmanager"; import { ShortcutManager } from "./shortcut/shortcutmanager"; import { UnitsManager } from "./unit/unitsmanager"; + export interface IOlympusApp { featureSwitches: FeatureSwitches; map: Map,