From f322c119667ebe3dc874b13bdb14cb2ff70f0440 Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:38:07 +0300 Subject: [PATCH 1/7] Add `App.hasPlugin` --- packages/app/src/app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/app/src/app.js b/packages/app/src/app.js index 869e5e38..ac3b0c98 100644 --- a/packages/app/src/app.js +++ b/packages/app/src/app.js @@ -118,6 +118,16 @@ export class App { return this.worlds.getWorld(label) } + /** + * Checks whether a plugin has been registered. + * + * @param {TypeId} pluginId + * @returns {boolean} + */ + hasPlugin(pluginId) { + return this.plugins.hasTypeId(pluginId) + } + /** * Creates a world by label. * From 63d466f0a07d47ce8f69f29d265ca541fca4a9b7 Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:38:55 +0300 Subject: [PATCH 2/7] Add plugin dependency tracking --- packages/app/src/app.js | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/app/src/app.js b/packages/app/src/app.js index ac3b0c98..96f0db12 100644 --- a/packages/app/src/app.js +++ b/packages/app/src/app.js @@ -30,17 +30,17 @@ export class PluginRegistry { } /** - * @param {TypeId} plugin + * @param {TypeId} pluginId */ - hasTypeId(plugin) { - this.names.has(plugin) + hasTypeId(pluginId) { + return this.names.has(pluginId) } /** - * @param {Plugin} plugin + * @param {TypeId} pluginId */ - has(plugin) { - this.hasTypeId(plugin.name()) + has(pluginId) { + return this.hasTypeId(pluginId) } /** @@ -51,6 +51,28 @@ export class PluginRegistry { this.list[i].register(app) } } + + /** + * Validates that registered plugins only require plugins that already exist. + * + * @param {App} app + */ + assertDependencies(app) { + for (let i = 0; i < this.list.length; i++) { + const plugin = this.list[i] + const pluginId = plugin.name() + const requires = plugin.requires() + + for (let j = 0; j < requires.length; j++) { + const requiredId = requires[j] + + assertTrue( + app.hasPlugin(requiredId), + `The plugin \`${pluginId}\` requires \`${requiredId}\`, but it is not registered.` + ) + } + } + } } export class App { @@ -212,6 +234,7 @@ export class App { */ run() { this.plugins.register(this) + this.plugins.assertDependencies(this) this.applyComponentHooks() this.applyResourceAliases() this.flushResources() @@ -400,6 +423,15 @@ export class Plugin { */ register(_app) { } + /** + * Returns the type ids of plugins required by this plugin. + * + * @returns {TypeId[]} + */ + requires() { + return [] + } + /** * @returns {TypeId} */ From d4678ab85be2480a02e3cefa4821bb48f7848e2a Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:47:20 +0300 Subject: [PATCH 3/7] Add plugin finish method --- packages/app/src/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/app/src/app.js b/packages/app/src/app.js index 96f0db12..95f31fe5 100644 --- a/packages/app/src/app.js +++ b/packages/app/src/app.js @@ -52,6 +52,15 @@ export class PluginRegistry { } } + /** + * @param {App} app + */ + finish(app) { + for (let i = 0; i < this.list.length; i++) { + this.list[i].finish(app) + } + } + /** * Validates that registered plugins only require plugins that already exist. * @@ -226,6 +235,7 @@ export class App { * {@link App.defaultWorld}, {@link App.setComponentHooks}, * {@link App.setResourceAlias}, * {@link App.setResource} and {@link App.setResourceByTypeId}. + * Invokes registered plugin finish callbacks after dependency validation and before queued hooks and resources are applied. * Applies queued resource aliases to every world before the runner starts. * Applies queued component hooks to every world before the runner starts. * Flushes any resources staged through {@link App.setResource} into their target worlds before the runner starts. @@ -235,6 +245,7 @@ export class App { run() { this.plugins.register(this) this.plugins.assertDependencies(this) + this.plugins.finish(this) this.applyComponentHooks() this.applyResourceAliases() this.flushResources() @@ -423,6 +434,11 @@ export class Plugin { */ register(_app) { } + /** + * @param {App} _app + */ + finish(_app) { } + /** * Returns the type ids of plugins required by this plugin. * From ac18a08c45c0799fb48bda21fb644276b7db4a21 Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Fri, 4 Sep 2026 20:28:15 +0300 Subject: [PATCH 4/7] Add required dependencies to plugins --- packages/animation/src/plugin.js | 9 +++++- packages/asset/src/plugins/asset.js | 8 +++++- packages/asset/src/plugins/assetServer.js | 8 +++++- packages/asset/src/plugins/exporter.js | 7 ++++- packages/asset/src/plugins/importer.js | 7 ++++- packages/audio/src/plugin.js | 9 +++++- packages/broadphase/src/plugin.js | 9 +++++- packages/color/src/plugin.js | 7 +++++ packages/command/src/plugin.js | 6 ++++ packages/core/src/plugin.js | 6 ++++ packages/damping/src/plugin.js | 13 ++++++++- packages/device/src/plugin.js | 7 +++++ packages/diagnostic/src/entitycount.js | 10 +++++-- packages/diagnostic/src/fpsdebugger.js | 8 ++++++ packages/emitter/src/plugin.js | 24 +++++++++++++++- packages/event/src/plugin.js | 6 ++++ packages/geometry/src/plugin.js | 8 ++++++ packages/gizmo/src/plugins/2d.js | 17 ++++++++++- packages/gizmo/src/plugins/3d.js | 15 +++++++++- packages/gravity/src/plugin.js | 28 +++++++++++++++++-- packages/hierarchy/src/plugin.js | 7 +++++ packages/integrator/src/plugins/euler.js | 13 ++++++++- packages/integrator/src/plugins/verlet.js | 9 +++++- packages/keyboard/src/plugin.js | 9 +++++- packages/math/src/plugin.js | 7 +++++ packages/mouse/src/plugin.js | 11 ++++++-- packages/movable/src/plugins/three.js | 9 +++++- packages/movable/src/plugins/two.js | 9 +++++- packages/name/src/plugin.js | 7 +++++ packages/narrowphase/src/plugin.js | 9 +++++- packages/physics/src/plugins/debugger.js | 19 ++++++++++++- packages/physics/src/plugins/plugin.js | 8 +++++- packages/profiler/src/plugin.js | 8 ++++++ packages/render-canvas2d/src/plugin.js | 9 +++++- packages/render-canvas2d/src/plugins/index.js | 16 ++++++++++- packages/render-core/src/plugin.js | 15 +++++++++- packages/render-core/src/plugins/material.js | 15 +++++++++- packages/render-webgl/src/plugin.js | 15 +++++++++- packages/render-webgl/src/plugins/index.js | 21 ++++++++++++-- packages/scene/src/plugin.js | 9 +++++- packages/storage/src/plugin.js | 7 +++++ packages/time/src/plugin.js | 7 +++++ packages/touch/src/plugin.js | 9 +++++- packages/transform/src/plugins/remote.js | 24 +++++++++++++++- packages/transform/src/plugins/transform.js | 13 ++++++++- packages/tween/src/plugin.js | 7 ++++- packages/window-dom/src/plugin.js | 8 +++++- packages/window/src/plugin.js | 15 +++++++++- 48 files changed, 487 insertions(+), 40 deletions(-) diff --git a/packages/animation/src/plugin.js b/packages/animation/src/plugin.js index b602af1f..d1db0c41 100644 --- a/packages/animation/src/plugin.js +++ b/packages/animation/src/plugin.js @@ -1,12 +1,15 @@ import { App, Plugin } from '@wimaengine/app' import { AssetPlugin, Assets } from '@wimaengine/asset' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' +import { TimePlugin } from '@wimaengine/time' import { AnimationClip } from './assets' import { AnimationPlayer, dropAnimationPlayer } from './components' import { AnimationClipAssets } from './resources' import { advanceAnimationPlayers, applyAnimations, registerAnimationTypes } from './systems' +import { typeid } from '@wimaengine/type' export class AnimationPlugin extends Plugin { @@ -27,4 +30,8 @@ export class AnimationPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: applyAnimations }) .setResourceAlias(typeidGeneric(Assets, [AnimationClip]), AnimationClipAssets) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(TimePlugin)] + } } diff --git a/packages/asset/src/plugins/asset.js b/packages/asset/src/plugins/asset.js index cacec8b4..5346022d 100644 --- a/packages/asset/src/plugins/asset.js +++ b/packages/asset/src/plugins/asset.js @@ -1,10 +1,12 @@ /** @import { Constructor } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EventPlugin } from '@wimaengine/event' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeid, typeidGeneric } from '@wimaengine/type' import { Assets } from '../resources' +import { AssetServerPlugin } from './assetServer' import { registerAssetTypes, registerAssetOnAssetServer, unloadDroppedAssets, updateAssetChannel, updateAssetEvents } from '../systems' /** @@ -91,6 +93,10 @@ export class AssetPlugin extends Plugin { } } + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } + name() { return typeidGeneric(AssetPlugin, [this.asset]) } diff --git a/packages/asset/src/plugins/assetServer.js b/packages/asset/src/plugins/assetServer.js index 1d7dd16d..ca404456 100644 --- a/packages/asset/src/plugins/assetServer.js +++ b/packages/asset/src/plugins/assetServer.js @@ -1,6 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EventPlugin } from '@wimaengine/event' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { AssetLoadFail, AssetLoadSuccess, AssetSaveSuccess } from '../events' import { AssetServer } from '../resources' import { updateAssets, logFailedLoads, registerAssetServerTypes } from '../systems' @@ -34,4 +36,8 @@ export class AssetServerPlugin extends Plugin { }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: logFailedLoads }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/asset/src/plugins/exporter.js b/packages/asset/src/plugins/exporter.js index 8eb5f6aa..21b2e61c 100644 --- a/packages/asset/src/plugins/exporter.js +++ b/packages/asset/src/plugins/exporter.js @@ -1,8 +1,9 @@ /** @import {Constructor} from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Exporter } from '../core' +import { AssetServerPlugin } from './assetServer' import { registerAssetExporterOnAssetServer } from '../systems' /** @@ -48,6 +49,10 @@ export class AssetExporterPlugin extends Plugin { }) } + requires() { + return [typeid(CorePlugin), typeid(AssetServerPlugin)] + } + name() { return typeidGeneric(AssetExporterPlugin, [this.asset]) } diff --git a/packages/asset/src/plugins/importer.js b/packages/asset/src/plugins/importer.js index 7e8d1860..b0b84c71 100644 --- a/packages/asset/src/plugins/importer.js +++ b/packages/asset/src/plugins/importer.js @@ -1,8 +1,9 @@ /** @import {Constructor} from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Importer } from '../core' +import { AssetServerPlugin } from './assetServer' import { registerAssetImporterOnAssetServer } from '../systems' /** @@ -49,6 +50,10 @@ export class AssetImporterPlugin extends Plugin { }) } + requires() { + return [typeid(CorePlugin), typeid(AssetServerPlugin)] + } + name() { return typeidGeneric(AssetImporterPlugin, [this.asset]) } diff --git a/packages/audio/src/plugin.js b/packages/audio/src/plugin.js index b7d396db..d762cf41 100644 --- a/packages/audio/src/plugin.js +++ b/packages/audio/src/plugin.js @@ -1,13 +1,16 @@ import { App, Plugin } from '@wimaengine/app' import { AssetImporterPlugin, AssetPlugin, Assets } from '@wimaengine/asset' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' +import { TimePlugin } from '@wimaengine/time' import { Audio } from './assets' import { AudioPlayer, AudioOscillator, removeAudioPlayerSink, removeOscillatorSink } from './components' import { AudioAdded, AudioDropped, AudioModified } from './events' import { AudioCommands, AudioImporter, AudioAssets, AudioGraph } from './resources' import { playAudio, playOscillators, registerAudioTypes } from './systems' +import { typeid } from '@wimaengine/type' export class AudioPlugin extends Plugin { @@ -58,4 +61,8 @@ export class AudioPlugin extends Plugin { } } } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(TimePlugin)] + } } diff --git a/packages/broadphase/src/plugin.js b/packages/broadphase/src/plugin.js index 44f7c233..0dbc22c8 100644 --- a/packages/broadphase/src/plugin.js +++ b/packages/broadphase/src/plugin.js @@ -1,6 +1,9 @@ /** @import {Broadphasable2D} from './resources'*/ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { CollisionPairs, Broadphase2D } from './resources' import { getCollisionPairs, registerBroadphaseTypes2D, updateBroadphase2D } from './systems' @@ -31,6 +34,10 @@ export class Broadphase2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: getCollisionPairs }) .registerSystem({ schedule: AppSchedule.Update, system: updateBroadphase2D }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin)] + } } /** diff --git a/packages/color/src/plugin.js b/packages/color/src/plugin.js index 617eea8b..0a593aee 100644 --- a/packages/color/src/plugin.js +++ b/packages/color/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { registerColorTypes } from './systems' export class ColorPlugin extends Plugin { @@ -10,4 +13,8 @@ export class ColorPlugin extends Plugin { register(app) { app.registerSystem({ schedule: AppSchedule.Startup, system: registerColorTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/command/src/plugin.js b/packages/command/src/plugin.js index 9b1ce0c9..22ca8862 100644 --- a/packages/command/src/plugin.js +++ b/packages/command/src/plugin.js @@ -1,8 +1,10 @@ /** @import { App } from '@wimaengine/app' */ import { Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { CommandQueue } from './resources' import { executeCommands } from './systems' +import { typeid } from '@wimaengine/type' export class CommandsPlugin extends Plugin { @@ -23,4 +25,8 @@ export class CommandsPlugin extends Plugin { system: executeCommands }) } + + requires() { + return [typeid(CorePlugin)] + } } diff --git a/packages/core/src/plugin.js b/packages/core/src/plugin.js index 7bb1ca32..c1ead7d6 100644 --- a/packages/core/src/plugin.js +++ b/packages/core/src/plugin.js @@ -1,8 +1,10 @@ /** @import { App } from '@wimaengine/app' */ import { Plugin } from '@wimaengine/app' import { SchedulerBuilder } from '@wimaengine/schedule' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule, CoreSystems, MainWorld, defaultRunner } from './core' import { registerCoreTypes, registerPrimitiveTypes } from './systems' +import { typeid } from '@wimaengine/type' export class CorePlugin extends Plugin { @@ -83,4 +85,8 @@ export class CorePlugin extends Plugin { system: registerPrimitiveTypes }) } + + requires() { + return [typeid(ReflectPlugin)] + } } diff --git a/packages/damping/src/plugin.js b/packages/damping/src/plugin.js index 7c143ced..44eaa0b5 100644 --- a/packages/damping/src/plugin.js +++ b/packages/damping/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { Movable2DPlugin, Movable3DPlugin } from '@wimaengine/movable' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { Linear2DDamping, Angular2DDamping, Linear3DDamping, Angular3DDamping } from './resources' import { dampenRotation2D, dampenRotation3D, dampenVelocity2D, dampenVelocity3D, registerDamping2DTypes, registerDamping3DTypes } from './systems' @@ -16,6 +19,10 @@ export class Damping2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: dampenVelocity2D }) .registerSystem({ schedule: AppSchedule.Update, system: dampenRotation2D }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(Movable2DPlugin)] + } } export class Damping3DPlugin extends Plugin { @@ -31,4 +38,8 @@ export class Damping3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: dampenVelocity3D }) .registerSystem({ schedule: AppSchedule.Update, system: dampenRotation3D }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(Movable3DPlugin)] + } } diff --git a/packages/device/src/plugin.js b/packages/device/src/plugin.js index f99ba945..6a617cec 100644 --- a/packages/device/src/plugin.js +++ b/packages/device/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { Browser, PlatformOS } from './core' import { Device } from './resources' import { registerDeviceTypes } from './systems' @@ -51,4 +54,8 @@ export class DevicePlugin extends Plugin { device.browser = Browser.Safari } } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/diagnostic/src/entitycount.js b/packages/diagnostic/src/entitycount.js index 26c6077a..cc728f57 100644 --- a/packages/diagnostic/src/entitycount.js +++ b/packages/diagnostic/src/entitycount.js @@ -1,8 +1,10 @@ -import { App } from '@wimaengine/app' +import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { World, EntityHandle, Query } from '@wimaengine/ecs' +import { typeid } from '@wimaengine/type' -export class EntityCountDiagnosticPlugin { +export class EntityCountDiagnosticPlugin extends Plugin { /** * @param {App} app @@ -12,6 +14,10 @@ export class EntityCountDiagnosticPlugin { .registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: setUpUI }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateEntityCount }) } + + requires() { + return [typeid(CorePlugin)] + } } /** diff --git a/packages/diagnostic/src/fpsdebugger.js b/packages/diagnostic/src/fpsdebugger.js index c2de1fee..51963731 100644 --- a/packages/diagnostic/src/fpsdebugger.js +++ b/packages/diagnostic/src/fpsdebugger.js @@ -1,9 +1,13 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' import { TimerMode, VirtualClock } from '@wimaengine/time' import { RAFTimer } from './resources' import { registerFpsDebuggerTypes } from './systems' +import { typeid } from '@wimaengine/type' +import { TimePlugin } from '@wimaengine/time' export class FPSDebugger extends Plugin { @@ -18,6 +22,10 @@ export class FPSDebugger extends Plugin { .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateFPSCounter }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateRAFTimer }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(TimePlugin)] + } } /** diff --git a/packages/emitter/src/plugin.js b/packages/emitter/src/plugin.js index e576fa04..1bb36c53 100644 --- a/packages/emitter/src/plugin.js +++ b/packages/emitter/src/plugin.js @@ -1,6 +1,10 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { CommandsPlugin } from '@wimaengine/command' +import { TimePlugin } from '@wimaengine/time' +import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' import { despawnParticles, emitParticles2D, emitParticles3D } from './systems' +import { typeid } from '@wimaengine/type' export class Emitter2DPlugin extends Plugin { @@ -13,6 +17,15 @@ export class Emitter2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: emitParticles2D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(CommandsPlugin), + typeid(TimePlugin), + typeid(Transform2DPlugin) + ] + } } export class Emitter3DPlugin extends Plugin { @@ -26,4 +39,13 @@ export class Emitter3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: emitParticles3D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(CommandsPlugin), + typeid(TimePlugin), + typeid(Transform3DPlugin) + ] + } } diff --git a/packages/event/src/plugin.js b/packages/event/src/plugin.js index 3883b018..9655a8ca 100644 --- a/packages/event/src/plugin.js +++ b/packages/event/src/plugin.js @@ -1,6 +1,8 @@ /** @import { Constructor } from '@wimaengine/type'*/ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Events } from './core' @@ -61,6 +63,10 @@ export class EventPlugin extends Plugin { } } + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } + name() { return typeidGeneric(EventPlugin, [this.event]) } diff --git a/packages/geometry/src/plugin.js b/packages/geometry/src/plugin.js index 682b42ca..6a63d102 100644 --- a/packages/geometry/src/plugin.js +++ b/packages/geometry/src/plugin.js @@ -1,5 +1,9 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { registerGeometryTypes } from './systems' export class GeometryPlugin extends Plugin { @@ -10,4 +14,8 @@ export class GeometryPlugin extends Plugin { register(app) { app.registerSystem({ schedule: AppSchedule.Startup, system: registerGeometryTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin)] + } } diff --git a/packages/gizmo/src/plugins/2d.js b/packages/gizmo/src/plugins/2d.js index d9d238ae..563b5d06 100644 --- a/packages/gizmo/src/plugins/2d.js +++ b/packages/gizmo/src/plugins/2d.js @@ -1,9 +1,14 @@ /** @import { Constructor } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { ColorPlugin } from '@wimaengine/color' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' +import { WindowPlugin } from '@wimaengine/window' import { Gizmo2D, GizmoSettings } from '../core' import { genenerateDrawGizmo2Dsystem, registerGizmo2DTypes } from '../systems' +import { typeid } from '@wimaengine/type' /** * @template T @@ -46,6 +51,16 @@ export class Gizmo2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: genenerateDrawGizmo2Dsystem(label) }) } + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(ColorPlugin), + typeid(MathPlugin), + typeid(WindowPlugin) + ] + } + name() { return typeidGeneric(Gizmo2DPlugin, [this.label]) } diff --git a/packages/gizmo/src/plugins/3d.js b/packages/gizmo/src/plugins/3d.js index 5f7febfa..d5da6d0c 100644 --- a/packages/gizmo/src/plugins/3d.js +++ b/packages/gizmo/src/plugins/3d.js @@ -1,9 +1,13 @@ /** @import { Constructor } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { ColorPlugin } from '@wimaengine/color' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { Gizmo3D, GizmoSettings } from '../core' import { genenerateDrawGizmo3Dsystem, registerGizmo3DTypes } from '../systems' +import { typeid } from '@wimaengine/type' /** * @template T @@ -46,6 +50,15 @@ export class Gizmo3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: genenerateDrawGizmo3Dsystem(label) }) } + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(ColorPlugin), + typeid(MathPlugin) + ] + } + name() { return typeidGeneric(Gizmo3DPlugin, [this.label]) } diff --git a/packages/gravity/src/plugin.js b/packages/gravity/src/plugin.js index 18c06150..47125b8d 100644 --- a/packages/gravity/src/plugin.js +++ b/packages/gravity/src/plugin.js @@ -1,6 +1,10 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' -import { Vector2, Vector3 } from '@wimaengine/math' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { Vector2, Vector3, MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { Movable2DPlugin, Movable3DPlugin } from '@wimaengine/movable' +import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' +import { typeid } from '@wimaengine/type' import { Gravity2D, Gravity3D } from './resources' import { applyGravity2D, applyGravity3D, registerGravity2DTypes, registerGravity3DTypes } from './systems' @@ -29,6 +33,16 @@ export class Gravity2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, system: registerGravity2DTypes }) .registerSystem({ schedule: AppSchedule.Update, system: applyGravity2D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(MathPlugin), + typeid(Movable2DPlugin), + typeid(NarrowPhase2DPlugin) + ] + } } export class Gravity3DPlugin extends Plugin { @@ -56,6 +70,16 @@ export class Gravity3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, system: registerGravity3DTypes }) .registerSystem({ schedule: AppSchedule.Update, system: applyGravity3D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(MathPlugin), + typeid(Movable3DPlugin), + typeid(NarrowPhase2DPlugin) + ] + } } /** diff --git a/packages/hierarchy/src/plugin.js b/packages/hierarchy/src/plugin.js index d33871be..18cde360 100644 --- a/packages/hierarchy/src/plugin.js +++ b/packages/hierarchy/src/plugin.js @@ -1,6 +1,9 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { typeid } from '@wimaengine/type' import { Children, Parent } from './components' import { addSelfToChildren, despawnChildren, addSelfToParent, removeSelfFromParent } from './hooks' import { registerHierarchyTypes } from './systems' @@ -24,4 +27,8 @@ export class HierarchyPlugin extends Plugin { )) .registerSystem({ schedule: AppSchedule.Startup, system: registerHierarchyTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/integrator/src/plugins/euler.js b/packages/integrator/src/plugins/euler.js index 2fb371b0..54548556 100644 --- a/packages/integrator/src/plugins/euler.js +++ b/packages/integrator/src/plugins/euler.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { Movable2DPlugin, Movable3DPlugin } from '@wimaengine/movable' +import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' +import { typeid } from '@wimaengine/type' import { updateAngularEuler2D, updateOrientationEuler2D, @@ -23,6 +26,10 @@ export class EulerIntegrator2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: updateOrientationEuler2D }) .registerSystem({ schedule: AppSchedule.Update, system: updateAngularEuler2D }) } + + requires() { + return [typeid(CorePlugin), typeid(Movable2DPlugin), typeid(Transform2DPlugin)] + } } export class EulerIntegrator3DPlugin extends Plugin { @@ -37,4 +44,8 @@ export class EulerIntegrator3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: updateOrientationEuler3D }) .registerSystem({ schedule: AppSchedule.Update, system: updateAngularEuler3D }) } + + requires() { + return [typeid(CorePlugin), typeid(Movable3DPlugin), typeid(Transform3DPlugin)] + } } diff --git a/packages/integrator/src/plugins/verlet.js b/packages/integrator/src/plugins/verlet.js index f714d2f1..985da915 100644 --- a/packages/integrator/src/plugins/verlet.js +++ b/packages/integrator/src/plugins/verlet.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { Movable2DPlugin } from '@wimaengine/movable' +import { Transform2DPlugin } from '@wimaengine/transform' +import { typeid } from '@wimaengine/type' import { updatePositionVerlet2D, updateOrientationVerlet2D } from '../systems' export class VerletIntegrator2DPlugin extends Plugin { @@ -12,4 +15,8 @@ export class VerletIntegrator2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, system: updatePositionVerlet2D }) .registerSystem({ schedule: AppSchedule.Update, system: updateOrientationVerlet2D }) } + + requires() { + return [typeid(CorePlugin), typeid(Movable2DPlugin), typeid(Transform2DPlugin)] + } } diff --git a/packages/keyboard/src/plugin.js b/packages/keyboard/src/plugin.js index 7611e8a7..0769d4ef 100644 --- a/packages/keyboard/src/plugin.js +++ b/packages/keyboard/src/plugin.js @@ -1,12 +1,15 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { KeyUp, KeyDown } from '@wimaengine/window' +import { WindowPlugin } from '@wimaengine/window' import { KeyCode } from './core' import { Keyboard } from './resources' import { registerKeyboardTypes } from './systems' +import { typeid } from '@wimaengine/type' export class KeyboardPlugin extends Plugin { @@ -19,6 +22,10 @@ export class KeyboardPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerKeyboardTypes }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateKeyBoard }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(WindowPlugin)] + } } /** diff --git a/packages/math/src/plugin.js b/packages/math/src/plugin.js index 0a2b9412..f367e2a8 100644 --- a/packages/math/src/plugin.js +++ b/packages/math/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { registerMathTypes } from './systems' export class MathPlugin extends Plugin { @@ -10,4 +13,8 @@ export class MathPlugin extends Plugin { register(app) { app.registerSystem({ schedule: AppSchedule.Startup, system: registerMathTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/mouse/src/plugin.js b/packages/mouse/src/plugin.js index c7f06d14..e830d9c2 100644 --- a/packages/mouse/src/plugin.js +++ b/packages/mouse/src/plugin.js @@ -1,13 +1,16 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' -import { Vector2 } from '@wimaengine/math' +import { MathPlugin, Vector2 } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { PointerDown, PointerMove, PointerUp } from '@wimaengine/window' +import { WindowPlugin } from '@wimaengine/window' import { MouseButton } from './core' import { Mouse, MouseButtons } from './resources' import { registerMouseTypes } from './systems' +import { typeid } from '@wimaengine/type' export class MousePlugin extends Plugin { @@ -23,6 +26,10 @@ export class MousePlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateMouse }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateMouseButtons }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin), typeid(WindowPlugin)] + } } /** diff --git a/packages/movable/src/plugins/three.js b/packages/movable/src/plugins/three.js index fc6cfe66..c1fa5348 100644 --- a/packages/movable/src/plugins/three.js +++ b/packages/movable/src/plugins/three.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { registerMovable3DTypes } from '../systems' export class Movable3DPlugin extends Plugin { @@ -11,4 +14,8 @@ export class Movable3DPlugin extends Plugin { app .registerSystem({ schedule: AppSchedule.Startup, system: registerMovable3DTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin)] + } } diff --git a/packages/movable/src/plugins/two.js b/packages/movable/src/plugins/two.js index 66f332d3..513f064d 100644 --- a/packages/movable/src/plugins/two.js +++ b/packages/movable/src/plugins/two.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { registerMovable2DTypes } from '../systems' export class Movable2DPlugin extends Plugin { @@ -11,4 +14,8 @@ export class Movable2DPlugin extends Plugin { app .registerSystem({ schedule: AppSchedule.Startup, system: registerMovable2DTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin)] + } } diff --git a/packages/name/src/plugin.js b/packages/name/src/plugin.js index f5f0e485..a372935e 100644 --- a/packages/name/src/plugin.js +++ b/packages/name/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { registerNameTypes } from './systems' export class NamePlugin extends Plugin { @@ -11,4 +14,8 @@ export class NamePlugin extends Plugin { app .registerSystem({ schedule: AppSchedule.Startup, system: registerNameTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/narrowphase/src/plugin.js b/packages/narrowphase/src/plugin.js index 66863263..95ed292f 100644 --- a/packages/narrowphase/src/plugin.js +++ b/packages/narrowphase/src/plugin.js @@ -1,6 +1,9 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { PhysicsProperties } from './components' import { physicspropertiesAddHook } from './hooks' import { Contacts, SATNarrowphase2D } from './resources' @@ -30,4 +33,8 @@ export class NarrowPhase2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, system: registerNarrowphase2DTypes }) .registerSystem({ schedule: AppSchedule.Update, system: getSATContacts }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(MathPlugin)] + } } diff --git a/packages/physics/src/plugins/debugger.js b/packages/physics/src/plugins/debugger.js index ed150b0a..a5b15fe3 100644 --- a/packages/physics/src/plugins/debugger.js +++ b/packages/physics/src/plugins/debugger.js @@ -1,6 +1,11 @@ /** @import {EntityHandle} from '@wimaengine/ecs' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { Broadphase2DPlugin } from '@wimaengine/broadphase' +import { Movable2DPlugin } from '@wimaengine/movable' +import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' +import { Transform2DPlugin } from '@wimaengine/transform' +import { WindowPlugin } from '@wimaengine/window' import { drawArms, drawBounds, @@ -9,6 +14,7 @@ import { drawShapes, drawVelocity } from '../systems' +import { typeid } from '@wimaengine/type' export class Physics2DDebuggerPlugin extends Plugin { @@ -40,6 +46,17 @@ export class Physics2DDebuggerPlugin extends Plugin { if (options.drawPosition) app.registerSystem({ schedule: AppSchedule.Update, system: drawPosition }) if (options.drawVelocity) app.registerSystem({ schedule: AppSchedule.Update, system: drawVelocity }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(WindowPlugin), + typeid(Broadphase2DPlugin), + typeid(NarrowPhase2DPlugin), + typeid(Transform2DPlugin), + typeid(Movable2DPlugin) + ] + } } /** diff --git a/packages/physics/src/plugins/plugin.js b/packages/physics/src/plugins/plugin.js index 53f56ba3..b800871a 100644 --- a/packages/physics/src/plugins/plugin.js +++ b/packages/physics/src/plugins/plugin.js @@ -1,9 +1,11 @@ import { App, Plugin } from '@wimaengine/app' import { Broadphase2DPlugin, NaiveBroadphase2D } from '@wimaengine/broadphase' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { EulerIntegrator2DPlugin } from '@wimaengine/integrator' import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' +import { Transform2DPlugin } from '@wimaengine/transform' import { collisionResponse, updateBodies, updateBounds } from '../systems' +import { typeid } from '@wimaengine/type' // TODO: Convert to a plugin group export class Physics2DPlugin extends Plugin { @@ -42,6 +44,10 @@ export class Physics2DPlugin extends Plugin { .registerPlugin(this.narrowphase) .registerSystem({ schedule: AppSchedule.Update, system: collisionResponse }) } + + requires() { + return [typeid(CorePlugin), typeid(Transform2DPlugin)] + } } /** diff --git a/packages/profiler/src/plugin.js b/packages/profiler/src/plugin.js index f0feca1d..d09782aa 100644 --- a/packages/profiler/src/plugin.js +++ b/packages/profiler/src/plugin.js @@ -1,10 +1,14 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { warn } from '@wimaengine/logger' +import { ReflectPlugin } from '@wimaengine/reflect' import { TimerMode, VirtualClock } from '@wimaengine/time' import { Profiler, ProfilerTimer } from './resources' import { registerProfilerTypes } from './systems' +import { typeid } from '@wimaengine/type' +import { TimePlugin } from '@wimaengine/time' export class ProfilerPlugin extends Plugin { @@ -19,6 +23,10 @@ export class ProfilerPlugin extends Plugin { app.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateProfileViewer }) app.registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: updateProfileTimer }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(TimePlugin)] + } } /** diff --git a/packages/render-canvas2d/src/plugin.js b/packages/render-canvas2d/src/plugin.js index 64e23719..b01376c9 100644 --- a/packages/render-canvas2d/src/plugin.js +++ b/packages/render-canvas2d/src/plugin.js @@ -1,9 +1,12 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { TextureCache, BasicMaterial } from '@wimaengine/render-core' +import { ReflectPlugin } from '@wimaengine/reflect' import { renderBasicMaterial } from './core' import { Canvas2DMaterialPlugin } from './plugins' import { clearCanvas2d, registerCanvas2DTypes } from './systems' +import { WindowPlugin } from '@wimaengine/window' +import { typeid } from '@wimaengine/type' export class Canvas2DRendererPlugin extends Plugin { @@ -24,4 +27,8 @@ export class Canvas2DRendererPlugin extends Plugin { update:renderBasicMaterial })) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(WindowPlugin)] + } } diff --git a/packages/render-canvas2d/src/plugins/index.js b/packages/render-canvas2d/src/plugins/index.js index b7641596..da9c659c 100644 --- a/packages/render-canvas2d/src/plugins/index.js +++ b/packages/render-canvas2d/src/plugins/index.js @@ -2,9 +2,13 @@ /** @import { Canvas2DFunction } from '../types' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { Material } from '@wimaengine/render-core' +import { RenderCorePlugin } from '@wimaengine/render-core' +import { WindowPlugin } from '@wimaengine/window' +import { Transform2DPlugin } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' +import { Canvas2DRendererPlugin } from '../plugin' import { genrender } from '../systems' /** @@ -47,6 +51,16 @@ export class Canvas2DMaterialPlugin extends Plugin { }) } + requires() { + return [ + typeid(CorePlugin), + typeid(Canvas2DRendererPlugin), + typeid(RenderCorePlugin), + typeid(Transform2DPlugin), + typeid(WindowPlugin) + ] + } + name() { return typeidGeneric(Canvas2DMaterialPlugin, [this.material]) } diff --git a/packages/render-core/src/plugin.js b/packages/render-core/src/plugin.js index 8d1c6e16..10540d21 100644 --- a/packages/render-core/src/plugin.js +++ b/packages/render-core/src/plugin.js @@ -1,7 +1,10 @@ import { App, Plugin } from '@wimaengine/app' import { AssetImporterPlugin, AssetPlugin, Assets } from '@wimaengine/asset' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { ColorPlugin } from '@wimaengine/color' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { Mesh, Shader, Image, BasicMaterial } from './assets' import { @@ -26,6 +29,7 @@ import { import { MaterialInstancePlugin } from './plugins' import { BasicMaterialAssets, ImageAssets, ImageImporter, MeshAssets } from './resources' import { registerRenderCoreTypes } from './systems' +import { typeid } from '@wimaengine/type' export class RenderCorePlugin extends Plugin { @@ -83,4 +87,13 @@ export class RenderCorePlugin extends Plugin { .setResourceAlias(typeidGeneric(Assets, [Mesh]), MeshAssets) .setResourceAlias(typeidGeneric(Assets, [BasicMaterial]), BasicMaterialAssets) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(ColorPlugin), + typeid(MathPlugin) + ] + } } diff --git a/packages/render-core/src/plugins/material.js b/packages/render-core/src/plugins/material.js index 91994ef3..4d6562e2 100644 --- a/packages/render-core/src/plugins/material.js +++ b/packages/render-core/src/plugins/material.js @@ -1,11 +1,14 @@ /** @import { Constructor, TypeId } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeid, typeidGeneric } from '@wimaengine/type' import { Material } from '../assets' import { dropMaterialInstance, MaterialInstance } from '../components' import { genBinRenderables2D, genBinRenderables3D, registerMaterialTypes } from '../systems' +import { RenderCorePlugin } from '../plugin' +import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' /** * @template {Material} T @@ -64,6 +67,16 @@ export class MaterialInstancePlugin extends Plugin { }) } + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(RenderCorePlugin), + typeid(Transform2DPlugin), + typeid(Transform3DPlugin) + ] + } + /** * @returns {TypeId} */ diff --git a/packages/render-webgl/src/plugin.js b/packages/render-webgl/src/plugin.js index 14333019..b1d78bcd 100644 --- a/packages/render-webgl/src/plugin.js +++ b/packages/render-webgl/src/plugin.js @@ -1,13 +1,17 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EntityHandle, Query, World } from '@wimaengine/ecs' import { warn } from '@wimaengine/logger' import { MeshAttribute, ProgramCache, BasicMaterial } from '@wimaengine/render-core' +import { ReflectPlugin } from '@wimaengine/reflect' import { MainWindow, Window, Windows } from '@wimaengine/window' import { WebglMaterialPlugin } from './plugins' import { AttributeMap, ClearColor, MeshCache, UBOCache, WebglProgramCache } from './resources' import { basicMaterial3DFragment, basicMaterial3DVertex } from './shaders' import { disposeDroppedMeshes, queueMeshes, registerWebglTypes } from './systems' +import { RenderCorePlugin } from '@wimaengine/render-core' +import { typeid } from '@wimaengine/type' +import { WindowPlugin } from '@wimaengine/window' export class WebglRendererPlugin extends Plugin { @@ -35,6 +39,15 @@ export class WebglRendererPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.PostMain, system: disposeDroppedMeshes }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.PostMain, system: queueMeshes }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(RenderCorePlugin), + typeid(WindowPlugin) + ] + } } /** diff --git a/packages/render-webgl/src/plugins/index.js b/packages/render-webgl/src/plugins/index.js index 5669b20f..91e8ce6b 100644 --- a/packages/render-webgl/src/plugins/index.js +++ b/packages/render-webgl/src/plugins/index.js @@ -1,16 +1,20 @@ /** @import {Constructor} from '@wimaengine/type' */ /** @import {UniformBind} from '@wimaengine/render-core' */ -import { App } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { App, Plugin } from '@wimaengine/app' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { Material } from '@wimaengine/render-core' +import { RenderCorePlugin } from '@wimaengine/render-core' +import { WindowPlugin } from '@wimaengine/window' +import { Transform3DPlugin } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' +import { WebglRendererPlugin } from '../plugin' import { genRegisterBuffer, genRender, genRenderPipeline } from '../systems' /** * @template {Material & UniformBind} T */ -export class WebglMaterialPlugin { +export class WebglMaterialPlugin extends Plugin { /** * @readonly @@ -38,6 +42,7 @@ export class WebglMaterialPlugin { vertex3d, material }) { + super() this.vertex3d = vertex3d this.fragment3d = fragment3d this.material = material @@ -70,6 +75,16 @@ export class WebglMaterialPlugin { }) } + requires() { + return [ + typeid(CorePlugin), + typeid(WebglRendererPlugin), + typeid(RenderCorePlugin), + typeid(Transform3DPlugin), + typeid(WindowPlugin) + ] + } + name() { return typeidGeneric(WebglMaterialPlugin, [this.material]) } diff --git a/packages/scene/src/plugin.js b/packages/scene/src/plugin.js index e6ea31b1..152933c3 100644 --- a/packages/scene/src/plugin.js +++ b/packages/scene/src/plugin.js @@ -1,7 +1,9 @@ import { App, Plugin } from '@wimaengine/app' import { AssetExporterPlugin, AssetImporterPlugin, AssetPlugin, Assets } from '@wimaengine/asset' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { HierarchyPlugin } from '@wimaengine/hierarchy' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { Scene } from './assets' import { SceneInstance } from './components' @@ -9,6 +11,7 @@ import { SceneAdded, SceneDropped, SceneModified } from './events' import { initSceneInstance, dropSceneInstance } from './hooks' import { JSONSceneExporter, JSONSceneImporter, SceneAssets, SceneSpawner } from './resources' import { registerSceneTypes, spawnScenes } from './systems' +import { typeid } from '@wimaengine/type' export class ScenePlugin extends Plugin { @@ -42,4 +45,8 @@ export class ScenePlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.End, system: spawnScenes }) .setResourceAlias(typeidGeneric(Assets, [Scene]), SceneAssets) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(HierarchyPlugin)] + } } diff --git a/packages/storage/src/plugin.js b/packages/storage/src/plugin.js index 761e043c..704bfedc 100644 --- a/packages/storage/src/plugin.js +++ b/packages/storage/src/plugin.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { Session, Storage, Cookies } from './resources' import { registerStorageTypes } from './systems' @@ -15,4 +18,8 @@ export class StoragePlugin extends Plugin { .setResource(new Cookies()) .registerSystem({ schedule: AppSchedule.Startup, system: registerStorageTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } diff --git a/packages/time/src/plugin.js b/packages/time/src/plugin.js index f30d39e4..1bfa87fa 100644 --- a/packages/time/src/plugin.js +++ b/packages/time/src/plugin.js @@ -1,9 +1,12 @@ import { App, Plugin } from '@wimaengine/app' +import { CorePlugin } from '@wimaengine/core' +import { ReflectPlugin } from '@wimaengine/reflect' import { AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Clock } from './clock' import { VirtualClock } from './resource' import { registerTimeTypes, updateTimers } from './systems' +import { typeid } from '@wimaengine/type' export class TimePlugin extends Plugin { @@ -17,6 +20,10 @@ export class TimePlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateVirtualClock }) .registerSystem({ schedule: AppSchedule.Update, systemGroup: CoreSystems.Start, system: updateTimers }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin)] + } } /** diff --git a/packages/touch/src/plugin.js b/packages/touch/src/plugin.js index dce2fa35..fc7711f9 100644 --- a/packages/touch/src/plugin.js +++ b/packages/touch/src/plugin.js @@ -1,12 +1,15 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeidGeneric } from '@wimaengine/type' import { PointerCancel, PointerDown, PointerMove, PointerUp } from '@wimaengine/window' +import { WindowPlugin } from '@wimaengine/window' import { TouchPointer } from './core' import { Touches } from './resources' import { registerTouchTypes } from './systems' +import { typeid } from '@wimaengine/type' export class TouchPlugin extends Plugin { @@ -19,6 +22,10 @@ export class TouchPlugin extends Plugin { .setResource(new Touches()) .registerSystem({ schedule: AppSchedule.Startup, systemGroup: CoreSystems.Start, system: registerTouchTypes }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(WindowPlugin)] + } } /** diff --git a/packages/transform/src/plugins/remote.js b/packages/transform/src/plugins/remote.js index 8ddf7b4a..f42c237d 100644 --- a/packages/transform/src/plugins/remote.js +++ b/packages/transform/src/plugins/remote.js @@ -1,5 +1,9 @@ import { Plugin, App } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { MathPlugin } from '@wimaengine/math' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' +import { Transform2DPlugin, Transform3DPlugin } from './transform' import { registerRemoteTransform2DTypes, registerRemoteTransform3DTypes, transformRemote2D, transformRemote3D } from '../systems' export class RemoteTransform2DPlugin extends Plugin { @@ -12,6 +16,15 @@ export class RemoteTransform2DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, system: registerRemoteTransform2DTypes }) .registerSystem({ schedule: AppSchedule.Update, system: transformRemote2D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(MathPlugin), + typeid(Transform2DPlugin) + ] + } } export class RemoteTransform3DPlugin extends Plugin { @@ -24,4 +37,13 @@ export class RemoteTransform3DPlugin extends Plugin { .registerSystem({ schedule: AppSchedule.Startup, system: registerRemoteTransform3DTypes }) .registerSystem({ schedule: AppSchedule.Update, system: transformRemote3D }) } + + requires() { + return [ + typeid(CorePlugin), + typeid(ReflectPlugin), + typeid(MathPlugin), + typeid(Transform3DPlugin) + ] + } } diff --git a/packages/transform/src/plugins/transform.js b/packages/transform/src/plugins/transform.js index 46528e75..f2cdff57 100644 --- a/packages/transform/src/plugins/transform.js +++ b/packages/transform/src/plugins/transform.js @@ -1,5 +1,8 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' +import { HierarchyPlugin } from '@wimaengine/hierarchy' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { propagateTransform2D, propagateTransform3D, registerTransform2DTypes, registerTransform3DTypes, synctransform2D, synctransform3D } from '../systems' export class TransformSystems { } @@ -30,6 +33,10 @@ export class Transform2DPlugin extends Plugin { after: [synctransform2D] }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(HierarchyPlugin)] + } } export class Transform3DPlugin extends Plugin { @@ -55,4 +62,8 @@ export class Transform3DPlugin extends Plugin { after: [synctransform3D] }) } + + requires() { + return [typeid(CorePlugin), typeid(ReflectPlugin), typeid(HierarchyPlugin)] + } } diff --git a/packages/tween/src/plugin.js b/packages/tween/src/plugin.js index 0e720e54..e16d4a29 100644 --- a/packages/tween/src/plugin.js +++ b/packages/tween/src/plugin.js @@ -1,8 +1,9 @@ /** @import {TweenLerp} from './typedef' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule } from '@wimaengine/core' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { Vector2, Quaternion, Vector3, Rotary } from '@wimaengine/math' import { Orientation2D, Orientation3D, Position2D, Position3D, Scale2D, Scale3D } from '@wimaengine/transform' +import { TimePlugin } from '@wimaengine/time' import { typeid, typeidGeneric } from '@wimaengine/type' import { Position2DTween, @@ -129,6 +130,10 @@ export class TweenPlugin extends Plugin { }) } + requires() { + return [typeid(CorePlugin), typeid(TimePlugin)] + } + name() { return typeidGeneric(TweenPlugin, [this.component]) } diff --git a/packages/window-dom/src/plugin.js b/packages/window-dom/src/plugin.js index 7a92d787..3ad23410 100644 --- a/packages/window-dom/src/plugin.js +++ b/packages/window-dom/src/plugin.js @@ -1,9 +1,11 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' import { Window } from '@wimaengine/window' +import { WindowPlugin } from '@wimaengine/window' import { closeWindow, openWindow } from './hooks' import { resizeWindow } from './systems' +import { typeid } from '@wimaengine/type' export class DOMWindowPlugin extends Plugin { @@ -19,4 +21,8 @@ export class DOMWindowPlugin extends Plugin { system: resizeWindow }) } + + requires() { + return [typeid(CorePlugin), typeid(WindowPlugin)] + } } diff --git a/packages/window/src/plugin.js b/packages/window/src/plugin.js index df82166f..c516312c 100644 --- a/packages/window/src/plugin.js +++ b/packages/window/src/plugin.js @@ -1,8 +1,10 @@ /** @import {WindowOptions} from './components' */ import { App, Plugin } from '@wimaengine/app' import { EntityCommands } from '@wimaengine/commands' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CommandsPlugin } from '@wimaengine/command' +import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EventPlugin } from '@wimaengine/event' +import { ReflectPlugin } from '@wimaengine/reflect' import { Window, MainWindow } from './components' import { FileDrag, @@ -21,6 +23,7 @@ import { } from './events' import { Windows } from './resources' import { registerWindowTypes } from './systems' +import { typeid } from '@wimaengine/type' export class WindowPlugin extends Plugin { @@ -97,6 +100,16 @@ export class WindowPlugin extends Plugin { if (this.initPrimaryWindow) app.registerSystem({ schedule: AppSchedule.Startup, system: initPrimaryWindow(this.primaryWindowOptions) }) } + + requires() { + const requires = [typeid(CorePlugin), typeid(ReflectPlugin)] + + if (this.initPrimaryWindow) { + requires.push(typeid(CommandsPlugin)) + } + + return requires + } } /** From 81884db32efcfb9454c4a1b0d89e167d365ca50f Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Fri, 4 Sep 2026 20:29:27 +0300 Subject: [PATCH 5/7] Add tests for `App` --- packages/app/tests/app.test.js | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 packages/app/tests/app.test.js diff --git a/packages/app/tests/app.test.js b/packages/app/tests/app.test.js new file mode 100644 index 00000000..b9e39665 --- /dev/null +++ b/packages/app/tests/app.test.js @@ -0,0 +1,97 @@ +import { test, describe } from "vitest"; +import { strictEqual, throws } from "node:assert"; +import { App, Plugin } from "../src"; +import { typeid } from "@wimaengine/type"; + +class ProvidedPlugin extends Plugin { } + +class ChildPlugin extends Plugin { + requires() { + return [typeid(ProvidedPlugin)] + } +} + +class ProviderBootstrapPlugin extends Plugin { + register(app) { + app.registerPlugin(new ProvidedPlugin()) + } +} + +class ParentPlugin extends Plugin { + register(app) { + app.registerPlugin(new ChildPlugin()) + } +} + +class BootstrapPlugin extends Plugin { + register(app) { + app.registerPlugin(new ProviderBootstrapPlugin()) + } +} + +class MissingPlugin extends Plugin { } + +class MissingDependencyPlugin extends Plugin { + requires() { + return [typeid(MissingPlugin)] + } +} + +class FinishResource { } + +class FinishPlugin extends Plugin { + finish(app) { + strictEqual(app.initialized, false) + app.setResource(finishResource) + } +} + +const finishResource = new FinishResource() + +describe("Testing `App` plugin registry behavior", () => { + test("`App.hasPlugin` checks by type id", () => { + const app = new App() + + app.registerPlugin(new ParentPlugin()) + + strictEqual(app.hasPlugin(typeid(ParentPlugin)), true) + strictEqual(app.hasPlugin(typeid(ProvidedPlugin)), false) + }) + + test("`App.run` validates plugins registered during registration", () => { + const app = new App() + + app + .registerPlugin(new ParentPlugin()) + .registerPlugin(new BootstrapPlugin()) + .setRunner(() => {}) + .run() + + strictEqual(app.hasPlugin(typeid(ProvidedPlugin)), true) + strictEqual(app.hasPlugin(typeid(ChildPlugin)), true) + }) + + test("`App.run` throws when a plugin dependency is missing", () => { + const app = new App() + + app + .registerPlugin(new MissingDependencyPlugin()) + .setRunner(() => {}) + + throws(() => app.run(), /requires .* but it is not registered/) + }) + + test("`Plugin.finish` runs after dependencies are checked and before resources are flushed", () => { + const app = new App() + const world = class DefaultWorld { } + + app + .setWorld(world) + .defaultWorld(world) + .setRunner(() => {}) + .registerPlugin(new FinishPlugin()) + .run() + + strictEqual(app.getWorld(world).getResource(FinishResource), finishResource) + }) +}) From 49dcfbdedade1a2682dec537fb502c8811dc7f4c Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Sun, 6 Sep 2026 00:09:16 +0300 Subject: [PATCH 6/7] Include plugin registration stack traces for duplicate plugin errors --- packages/app/src/app.js | 91 ++++++++++++++++++++++++++++++++-- packages/app/tests/app.test.js | 57 ++++++++++++++++++++- 2 files changed, 144 insertions(+), 4 deletions(-) diff --git a/packages/app/src/app.js b/packages/app/src/app.js index 95f31fe5..58704fd0 100644 --- a/packages/app/src/app.js +++ b/packages/app/src/app.js @@ -21,12 +21,40 @@ export class PluginRegistry { */ names = new Set() + /** + * Tracks the parent plugin for nested registrations. + * + * @type {Map} + */ + parents = new Map() + + /** + * Tracks the active plugin registration stack. + * + * @type {TypeId[]} + */ + stack = [] + /** * @param {Plugin} plugin */ add(plugin) { + const pluginId = plugin.name() + + if (this.names.has(pluginId)) { + throw new Error(`The plugin \`${pluginId}\` is already registered.${formatRegistrationTrace(this, pluginId)}`) + } + + const parentId = this.stack[this.stack.length - 1] + this.list.push(plugin) - this.names.add(plugin.name()) + this.names.add(pluginId) + + if (parentId === undefined) { + this.parents.delete(pluginId) + } else { + this.parents.set(pluginId, parentId) + } } /** @@ -43,12 +71,27 @@ export class PluginRegistry { return this.hasTypeId(pluginId) } + /** + * @param {TypeId} pluginId + */ + enter(pluginId) { + this.stack.push(pluginId) + } + + leave() { + this.stack.pop() + } + /** * @param {App} app */ register(app) { for (let i = 0; i < this.list.length; i++) { - this.list[i].register(app) + const plugin = this.list[i] + + this.enter(plugin.name()) + plugin.register(app) + this.leave() } } @@ -57,7 +100,11 @@ export class PluginRegistry { */ finish(app) { for (let i = 0; i < this.list.length; i++) { - this.list[i].finish(app) + const plugin = this.list[i] + + this.enter(plugin.name()) + plugin.finish(app) + this.leave() } } @@ -512,3 +559,41 @@ export class PluginGroup extends Plugin { } } } + +/** + * Formats the registration chain for error output. + * + * @param {PluginRegistry} registry + * @param {TypeId} pluginId + * @returns {string} + */ +function formatRegistrationTrace(registry, pluginId) { + const chain = [] + let current = pluginId + + while (current !== undefined) { + chain.push(current) + current = registry.parents.get(current) + } + + chain.reverse() + + if (!chain.length) { + return '' + } + + const lines = ['Plugin registration stack:'] + + for (let i = 0; i < chain.length; i++) { + const currentId = chain[i] + const parentId = chain[i - 1] + + if (parentId === undefined) { + lines.push(`- \`${currentId}\` registered directly on the app`) + } else { + lines.push(`- \`${currentId}\` registered by \`${parentId}\``) + } + } + + return `\n\n${lines.join('\n')}` +} diff --git a/packages/app/tests/app.test.js b/packages/app/tests/app.test.js index b9e39665..f8ea2304 100644 --- a/packages/app/tests/app.test.js +++ b/packages/app/tests/app.test.js @@ -1,5 +1,5 @@ import { test, describe } from "vitest"; -import { strictEqual, throws } from "node:assert"; +import { ok, strictEqual, throws } from "node:assert"; import { App, Plugin } from "../src"; import { typeid } from "@wimaengine/type"; @@ -71,6 +71,38 @@ describe("Testing `App` plugin registry behavior", () => { strictEqual(app.hasPlugin(typeid(ChildPlugin)), true) }) + test("`App.registerPlugin` reports a duplicate plugin registered by another plugin", () => { + const app = new App() + const parent = new ParentPlugin() + + parent.register = (app) => { + app.registerPlugin(new ChildPlugin()) + app.registerPlugin(new ChildPlugin()) + } + + let error + + try { + app + .registerPlugin(parent) + .setRunner(() => {}) + .run() + } catch (caught) { + error = caught + } + + ok(error instanceof Error) + + const message = error.message + const parentId = typeid(ParentPlugin) + const childId = typeid(ChildPlugin) + + ok(message.includes(`The plugin \`${childId}\` is already registered.`)) + ok(message.includes("Plugin registration stack:")) + ok(message.includes(`- \`${parentId}\` registered directly on the app`)) + ok(message.includes(`- \`${childId}\` registered by \`${parentId}\``)) + }) + test("`App.run` throws when a plugin dependency is missing", () => { const app = new App() @@ -81,6 +113,29 @@ describe("Testing `App` plugin registry behavior", () => { throws(() => app.run(), /requires .* but it is not registered/) }) + test("`App.registerPlugin` reports a duplicate plugin registered on app", () => { + const app = new App() + + let error + + try { + app + .registerPlugin(new ChildPlugin()) + .registerPlugin(new ChildPlugin()) + } catch (caught) { + error = caught + } + + ok(error instanceof Error) + + const message = error.message + const childId = typeid(ChildPlugin) + + ok(message.includes(`The plugin \`${childId}\` is already registered.`)) + ok(message.includes("Plugin registration stack:")) + ok(message.includes(`- \`${childId}\` registered directly on the app`)) + }) + test("`Plugin.finish` runs after dependencies are checked and before resources are flushed", () => { const app = new App() const world = class DefaultWorld { } From d5eec2aeedfd4ad93c27779953267263466c04df Mon Sep 17 00:00:00 2001 From: waynemwashuma <94756970+waynemwashuma@users.noreply.github.com> Date: Sun, 6 Sep 2026 00:12:41 +0300 Subject: [PATCH 7/7] Lint files --- packages/animation/src/plugin.js | 3 +-- packages/app/src/app.js | 1 + packages/asset/src/plugins/asset.js | 1 - packages/asset/src/plugins/exporter.js | 2 +- packages/asset/src/plugins/importer.js | 2 +- packages/audio/src/plugin.js | 3 +-- packages/color/src/plugin.js | 3 +-- packages/command/src/plugin.js | 5 ++--- packages/core/src/plugin.js | 4 ++-- packages/device/src/plugin.js | 3 +-- packages/diagnostic/src/entitycount.js | 3 +-- packages/diagnostic/src/fpsdebugger.js | 8 +++----- packages/emitter/src/plugin.js | 4 ++-- packages/event/src/plugin.js | 3 +-- packages/geometry/src/plugin.js | 3 +-- packages/gizmo/src/plugins/2d.js | 5 ++--- packages/gizmo/src/plugins/3d.js | 5 ++--- packages/gravity/src/plugin.js | 2 +- packages/hierarchy/src/plugin.js | 5 ++--- packages/keyboard/src/plugin.js | 6 ++---- packages/math/src/plugin.js | 3 +-- packages/mouse/src/plugin.js | 6 ++---- packages/name/src/plugin.js | 3 +-- packages/physics/src/plugins/debugger.js | 4 ++-- packages/physics/src/plugins/plugin.js | 2 +- packages/profiler/src/plugin.js | 8 +++----- packages/render-canvas2d/src/plugin.js | 6 +++--- packages/render-canvas2d/src/plugins/index.js | 5 ++--- packages/render-core/src/plugin.js | 5 ++--- packages/render-core/src/plugins/material.js | 4 ++-- packages/render-webgl/src/plugin.js | 8 +++----- packages/render-webgl/src/plugins/index.js | 5 ++--- packages/scene/src/plugin.js | 3 +-- packages/storage/src/plugin.js | 3 +-- packages/time/src/plugin.js | 7 +++---- packages/touch/src/plugin.js | 6 ++---- packages/transform/src/plugins/remote.js | 2 +- packages/tween/src/plugin.js | 2 +- packages/window-dom/src/plugin.js | 5 ++--- packages/window/src/plugin.js | 4 ++-- 40 files changed, 65 insertions(+), 97 deletions(-) diff --git a/packages/animation/src/plugin.js b/packages/animation/src/plugin.js index d1db0c41..e4b11925 100644 --- a/packages/animation/src/plugin.js +++ b/packages/animation/src/plugin.js @@ -3,13 +3,12 @@ import { AssetPlugin, Assets } from '@wimaengine/asset' import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' import { TimePlugin } from '@wimaengine/time' +import { typeidGeneric, typeid } from '@wimaengine/type' import { AnimationClip } from './assets' import { AnimationPlayer, dropAnimationPlayer } from './components' import { AnimationClipAssets } from './resources' import { advanceAnimationPlayers, applyAnimations, registerAnimationTypes } from './systems' -import { typeid } from '@wimaengine/type' export class AnimationPlugin extends Plugin { diff --git a/packages/app/src/app.js b/packages/app/src/app.js index 58704fd0..51f03e7c 100644 --- a/packages/app/src/app.js +++ b/packages/app/src/app.js @@ -37,6 +37,7 @@ export class PluginRegistry { /** * @param {Plugin} plugin + * @throws When a dublicate plugin is registered. */ add(plugin) { const pluginId = plugin.name() diff --git a/packages/asset/src/plugins/asset.js b/packages/asset/src/plugins/asset.js index 5346022d..f585b967 100644 --- a/packages/asset/src/plugins/asset.js +++ b/packages/asset/src/plugins/asset.js @@ -6,7 +6,6 @@ import { EventPlugin } from '@wimaengine/event' import { ReflectPlugin } from '@wimaengine/reflect' import { typeid, typeidGeneric } from '@wimaengine/type' import { Assets } from '../resources' -import { AssetServerPlugin } from './assetServer' import { registerAssetTypes, registerAssetOnAssetServer, unloadDroppedAssets, updateAssetChannel, updateAssetEvents } from '../systems' /** diff --git a/packages/asset/src/plugins/exporter.js b/packages/asset/src/plugins/exporter.js index 21b2e61c..ee1cc821 100644 --- a/packages/asset/src/plugins/exporter.js +++ b/packages/asset/src/plugins/exporter.js @@ -3,8 +3,8 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Exporter } from '../core' -import { AssetServerPlugin } from './assetServer' import { registerAssetExporterOnAssetServer } from '../systems' +import { AssetServerPlugin } from './assetServer' /** * @template T diff --git a/packages/asset/src/plugins/importer.js b/packages/asset/src/plugins/importer.js index b0b84c71..d0e42af5 100644 --- a/packages/asset/src/plugins/importer.js +++ b/packages/asset/src/plugins/importer.js @@ -3,8 +3,8 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Importer } from '../core' -import { AssetServerPlugin } from './assetServer' import { registerAssetImporterOnAssetServer } from '../systems' +import { AssetServerPlugin } from './assetServer' /** * @template T diff --git a/packages/audio/src/plugin.js b/packages/audio/src/plugin.js index d762cf41..81ebcd9d 100644 --- a/packages/audio/src/plugin.js +++ b/packages/audio/src/plugin.js @@ -3,14 +3,13 @@ import { AssetImporterPlugin, AssetPlugin, Assets } from '@wimaengine/asset' import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' import { TimePlugin } from '@wimaengine/time' +import { typeidGeneric, typeid } from '@wimaengine/type' import { Audio } from './assets' import { AudioPlayer, AudioOscillator, removeAudioPlayerSink, removeOscillatorSink } from './components' import { AudioAdded, AudioDropped, AudioModified } from './events' import { AudioCommands, AudioImporter, AudioAssets, AudioGraph } from './resources' import { playAudio, playOscillators, registerAudioTypes } from './systems' -import { typeid } from '@wimaengine/type' export class AudioPlugin extends Plugin { diff --git a/packages/color/src/plugin.js b/packages/color/src/plugin.js index 0a593aee..3a9378f4 100644 --- a/packages/color/src/plugin.js +++ b/packages/color/src/plugin.js @@ -1,7 +1,6 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { registerColorTypes } from './systems' diff --git a/packages/command/src/plugin.js b/packages/command/src/plugin.js index 22ca8862..6d194889 100644 --- a/packages/command/src/plugin.js +++ b/packages/command/src/plugin.js @@ -1,10 +1,9 @@ /** @import { App } from '@wimaengine/app' */ import { Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' +import { typeid } from '@wimaengine/type' import { CommandQueue } from './resources' import { executeCommands } from './systems' -import { typeid } from '@wimaengine/type' export class CommandsPlugin extends Plugin { diff --git a/packages/core/src/plugin.js b/packages/core/src/plugin.js index c1ead7d6..d78bebfc 100644 --- a/packages/core/src/plugin.js +++ b/packages/core/src/plugin.js @@ -1,10 +1,10 @@ /** @import { App } from '@wimaengine/app' */ import { Plugin } from '@wimaengine/app' -import { SchedulerBuilder } from '@wimaengine/schedule' import { ReflectPlugin } from '@wimaengine/reflect' +import { SchedulerBuilder } from '@wimaengine/schedule' +import { typeid } from '@wimaengine/type' import { AppSchedule, CoreSystems, MainWorld, defaultRunner } from './core' import { registerCoreTypes, registerPrimitiveTypes } from './systems' -import { typeid } from '@wimaengine/type' export class CorePlugin extends Plugin { diff --git a/packages/device/src/plugin.js b/packages/device/src/plugin.js index 6a617cec..f9ac915e 100644 --- a/packages/device/src/plugin.js +++ b/packages/device/src/plugin.js @@ -1,7 +1,6 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { Browser, PlatformOS } from './core' import { Device } from './resources' diff --git a/packages/diagnostic/src/entitycount.js b/packages/diagnostic/src/entitycount.js index cc728f57..01d33e60 100644 --- a/packages/diagnostic/src/entitycount.js +++ b/packages/diagnostic/src/entitycount.js @@ -1,6 +1,5 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' import { World, EntityHandle, Query } from '@wimaengine/ecs' import { typeid } from '@wimaengine/type' diff --git a/packages/diagnostic/src/fpsdebugger.js b/packages/diagnostic/src/fpsdebugger.js index 51963731..943348d3 100644 --- a/packages/diagnostic/src/fpsdebugger.js +++ b/packages/diagnostic/src/fpsdebugger.js @@ -1,13 +1,11 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { ReflectPlugin } from '@wimaengine/reflect' -import { TimerMode, VirtualClock } from '@wimaengine/time' +import { TimerMode, VirtualClock, TimePlugin } from '@wimaengine/time' +import { typeid } from '@wimaengine/type' import { RAFTimer } from './resources' import { registerFpsDebuggerTypes } from './systems' -import { typeid } from '@wimaengine/type' -import { TimePlugin } from '@wimaengine/time' export class FPSDebugger extends Plugin { diff --git a/packages/emitter/src/plugin.js b/packages/emitter/src/plugin.js index 1bb36c53..0d7726cb 100644 --- a/packages/emitter/src/plugin.js +++ b/packages/emitter/src/plugin.js @@ -1,10 +1,10 @@ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CorePlugin } from '@wimaengine/core' import { CommandsPlugin } from '@wimaengine/command' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { TimePlugin } from '@wimaengine/time' import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' -import { despawnParticles, emitParticles2D, emitParticles3D } from './systems' import { typeid } from '@wimaengine/type' +import { despawnParticles, emitParticles2D, emitParticles3D } from './systems' export class Emitter2DPlugin extends Plugin { diff --git a/packages/event/src/plugin.js b/packages/event/src/plugin.js index 9655a8ca..c3210f40 100644 --- a/packages/event/src/plugin.js +++ b/packages/event/src/plugin.js @@ -1,9 +1,8 @@ /** @import { Constructor } from '@wimaengine/type'*/ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule, CoreSystems } from '@wimaengine/core' import { typeid, typeidGeneric } from '@wimaengine/type' import { Events } from './core' import { makeEventClear, registerEventTypes } from './systems' diff --git a/packages/geometry/src/plugin.js b/packages/geometry/src/plugin.js index 6a63d102..61282f17 100644 --- a/packages/geometry/src/plugin.js +++ b/packages/geometry/src/plugin.js @@ -1,8 +1,7 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { MathPlugin } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { registerGeometryTypes } from './systems' diff --git a/packages/gizmo/src/plugins/2d.js b/packages/gizmo/src/plugins/2d.js index 563b5d06..57f9a391 100644 --- a/packages/gizmo/src/plugins/2d.js +++ b/packages/gizmo/src/plugins/2d.js @@ -1,14 +1,13 @@ /** @import { Constructor } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ColorPlugin } from '@wimaengine/color' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { MathPlugin } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' +import { typeidGeneric, typeid } from '@wimaengine/type' import { WindowPlugin } from '@wimaengine/window' import { Gizmo2D, GizmoSettings } from '../core' import { genenerateDrawGizmo2Dsystem, registerGizmo2DTypes } from '../systems' -import { typeid } from '@wimaengine/type' /** * @template T diff --git a/packages/gizmo/src/plugins/3d.js b/packages/gizmo/src/plugins/3d.js index d5da6d0c..e0873629 100644 --- a/packages/gizmo/src/plugins/3d.js +++ b/packages/gizmo/src/plugins/3d.js @@ -1,13 +1,12 @@ /** @import { Constructor } from '@wimaengine/type' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CorePlugin } from '@wimaengine/core' import { ColorPlugin } from '@wimaengine/color' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { MathPlugin } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' +import { typeidGeneric, typeid } from '@wimaengine/type' import { Gizmo3D, GizmoSettings } from '../core' import { genenerateDrawGizmo3Dsystem, registerGizmo3DTypes } from '../systems' -import { typeid } from '@wimaengine/type' /** * @template T diff --git a/packages/gravity/src/plugin.js b/packages/gravity/src/plugin.js index 47125b8d..9d77a1fc 100644 --- a/packages/gravity/src/plugin.js +++ b/packages/gravity/src/plugin.js @@ -1,9 +1,9 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CorePlugin } from '@wimaengine/core' import { Vector2, Vector3, MathPlugin } from '@wimaengine/math' -import { ReflectPlugin } from '@wimaengine/reflect' import { Movable2DPlugin, Movable3DPlugin } from '@wimaengine/movable' import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeid } from '@wimaengine/type' import { Gravity2D, Gravity3D } from './resources' import { applyGravity2D, applyGravity3D, registerGravity2DTypes, registerGravity3DTypes } from './systems' diff --git a/packages/hierarchy/src/plugin.js b/packages/hierarchy/src/plugin.js index 18cde360..27f589e6 100644 --- a/packages/hierarchy/src/plugin.js +++ b/packages/hierarchy/src/plugin.js @@ -1,8 +1,7 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' import { typeid } from '@wimaengine/type' import { Children, Parent } from './components' import { addSelfToChildren, despawnChildren, addSelfToParent, removeSelfFromParent } from './hooks' diff --git a/packages/keyboard/src/plugin.js b/packages/keyboard/src/plugin.js index 0769d4ef..3b444dda 100644 --- a/packages/keyboard/src/plugin.js +++ b/packages/keyboard/src/plugin.js @@ -3,13 +3,11 @@ import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' -import { KeyUp, KeyDown } from '@wimaengine/window' -import { WindowPlugin } from '@wimaengine/window' +import { typeidGeneric, typeid } from '@wimaengine/type' +import { KeyUp, KeyDown, WindowPlugin } from '@wimaengine/window' import { KeyCode } from './core' import { Keyboard } from './resources' import { registerKeyboardTypes } from './systems' -import { typeid } from '@wimaengine/type' export class KeyboardPlugin extends Plugin { diff --git a/packages/math/src/plugin.js b/packages/math/src/plugin.js index f367e2a8..8bdcae22 100644 --- a/packages/math/src/plugin.js +++ b/packages/math/src/plugin.js @@ -1,7 +1,6 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { registerMathTypes } from './systems' diff --git a/packages/mouse/src/plugin.js b/packages/mouse/src/plugin.js index e830d9c2..07f94aa8 100644 --- a/packages/mouse/src/plugin.js +++ b/packages/mouse/src/plugin.js @@ -4,13 +4,11 @@ import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' import { MathPlugin, Vector2 } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' -import { PointerDown, PointerMove, PointerUp } from '@wimaengine/window' -import { WindowPlugin } from '@wimaengine/window' +import { typeidGeneric, typeid } from '@wimaengine/type' +import { PointerDown, PointerMove, PointerUp, WindowPlugin } from '@wimaengine/window' import { MouseButton } from './core' import { Mouse, MouseButtons } from './resources' import { registerMouseTypes } from './systems' -import { typeid } from '@wimaengine/type' export class MousePlugin extends Plugin { diff --git a/packages/name/src/plugin.js b/packages/name/src/plugin.js index a372935e..5c20e420 100644 --- a/packages/name/src/plugin.js +++ b/packages/name/src/plugin.js @@ -1,7 +1,6 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { registerNameTypes } from './systems' diff --git a/packages/physics/src/plugins/debugger.js b/packages/physics/src/plugins/debugger.js index a5b15fe3..60c238a1 100644 --- a/packages/physics/src/plugins/debugger.js +++ b/packages/physics/src/plugins/debugger.js @@ -1,10 +1,11 @@ /** @import {EntityHandle} from '@wimaengine/ecs' */ import { App, Plugin } from '@wimaengine/app' -import { AppSchedule, CorePlugin } from '@wimaengine/core' import { Broadphase2DPlugin } from '@wimaengine/broadphase' +import { AppSchedule, CorePlugin } from '@wimaengine/core' import { Movable2DPlugin } from '@wimaengine/movable' import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' import { Transform2DPlugin } from '@wimaengine/transform' +import { typeid } from '@wimaengine/type' import { WindowPlugin } from '@wimaengine/window' import { drawArms, @@ -14,7 +15,6 @@ import { drawShapes, drawVelocity } from '../systems' -import { typeid } from '@wimaengine/type' export class Physics2DDebuggerPlugin extends Plugin { diff --git a/packages/physics/src/plugins/plugin.js b/packages/physics/src/plugins/plugin.js index b800871a..0fc6fa04 100644 --- a/packages/physics/src/plugins/plugin.js +++ b/packages/physics/src/plugins/plugin.js @@ -4,8 +4,8 @@ import { AppSchedule, CorePlugin } from '@wimaengine/core' import { EulerIntegrator2DPlugin } from '@wimaengine/integrator' import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase' import { Transform2DPlugin } from '@wimaengine/transform' -import { collisionResponse, updateBodies, updateBounds } from '../systems' import { typeid } from '@wimaengine/type' +import { collisionResponse, updateBodies, updateBounds } from '../systems' // TODO: Convert to a plugin group export class Physics2DPlugin extends Plugin { diff --git a/packages/profiler/src/plugin.js b/packages/profiler/src/plugin.js index d09782aa..75b3511d 100644 --- a/packages/profiler/src/plugin.js +++ b/packages/profiler/src/plugin.js @@ -1,14 +1,12 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { warn } from '@wimaengine/logger' import { ReflectPlugin } from '@wimaengine/reflect' -import { TimerMode, VirtualClock } from '@wimaengine/time' +import { TimerMode, VirtualClock, TimePlugin } from '@wimaengine/time' +import { typeid } from '@wimaengine/type' import { Profiler, ProfilerTimer } from './resources' import { registerProfilerTypes } from './systems' -import { typeid } from '@wimaengine/type' -import { TimePlugin } from '@wimaengine/time' export class ProfilerPlugin extends Plugin { diff --git a/packages/render-canvas2d/src/plugin.js b/packages/render-canvas2d/src/plugin.js index b01376c9..90bfe112 100644 --- a/packages/render-canvas2d/src/plugin.js +++ b/packages/render-canvas2d/src/plugin.js @@ -1,12 +1,12 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' -import { TextureCache, BasicMaterial } from '@wimaengine/render-core' import { ReflectPlugin } from '@wimaengine/reflect' +import { TextureCache, BasicMaterial } from '@wimaengine/render-core' +import { typeid } from '@wimaengine/type' +import { WindowPlugin } from '@wimaengine/window' import { renderBasicMaterial } from './core' import { Canvas2DMaterialPlugin } from './plugins' import { clearCanvas2d, registerCanvas2DTypes } from './systems' -import { WindowPlugin } from '@wimaengine/window' -import { typeid } from '@wimaengine/type' export class Canvas2DRendererPlugin extends Plugin { diff --git a/packages/render-canvas2d/src/plugins/index.js b/packages/render-canvas2d/src/plugins/index.js index da9c659c..3dc70c73 100644 --- a/packages/render-canvas2d/src/plugins/index.js +++ b/packages/render-canvas2d/src/plugins/index.js @@ -3,11 +3,10 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' -import { Material } from '@wimaengine/render-core' -import { RenderCorePlugin } from '@wimaengine/render-core' -import { WindowPlugin } from '@wimaengine/window' +import { Material, RenderCorePlugin } from '@wimaengine/render-core' import { Transform2DPlugin } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' +import { WindowPlugin } from '@wimaengine/window' import { Canvas2DRendererPlugin } from '../plugin' import { genrender } from '../systems' diff --git a/packages/render-core/src/plugin.js b/packages/render-core/src/plugin.js index 10540d21..6477e06e 100644 --- a/packages/render-core/src/plugin.js +++ b/packages/render-core/src/plugin.js @@ -1,11 +1,11 @@ import { App, Plugin } from '@wimaengine/app' import { AssetImporterPlugin, AssetPlugin, Assets } from '@wimaengine/asset' +import { ColorPlugin } from '@wimaengine/color' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' -import { ColorPlugin } from '@wimaengine/color' import { MathPlugin } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' +import { typeidGeneric, typeid } from '@wimaengine/type' import { Mesh, Shader, Image, BasicMaterial } from './assets' import { BasicMaterialInstance, @@ -29,7 +29,6 @@ import { import { MaterialInstancePlugin } from './plugins' import { BasicMaterialAssets, ImageAssets, ImageImporter, MeshAssets } from './resources' import { registerRenderCoreTypes } from './systems' -import { typeid } from '@wimaengine/type' export class RenderCorePlugin extends Plugin { diff --git a/packages/render-core/src/plugins/material.js b/packages/render-core/src/plugins/material.js index 4d6562e2..07f6194a 100644 --- a/packages/render-core/src/plugins/material.js +++ b/packages/render-core/src/plugins/material.js @@ -3,12 +3,12 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' import { ReflectPlugin } from '@wimaengine/reflect' +import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' import { Material } from '../assets' import { dropMaterialInstance, MaterialInstance } from '../components' -import { genBinRenderables2D, genBinRenderables3D, registerMaterialTypes } from '../systems' import { RenderCorePlugin } from '../plugin' -import { Transform2DPlugin, Transform3DPlugin } from '@wimaengine/transform' +import { genBinRenderables2D, genBinRenderables3D, registerMaterialTypes } from '../systems' /** * @template {Material} T diff --git a/packages/render-webgl/src/plugin.js b/packages/render-webgl/src/plugin.js index b1d78bcd..b735639f 100644 --- a/packages/render-webgl/src/plugin.js +++ b/packages/render-webgl/src/plugin.js @@ -2,16 +2,14 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EntityHandle, Query, World } from '@wimaengine/ecs' import { warn } from '@wimaengine/logger' -import { MeshAttribute, ProgramCache, BasicMaterial } from '@wimaengine/render-core' import { ReflectPlugin } from '@wimaengine/reflect' -import { MainWindow, Window, Windows } from '@wimaengine/window' +import { MeshAttribute, ProgramCache, BasicMaterial, RenderCorePlugin } from '@wimaengine/render-core' +import { typeid } from '@wimaengine/type' +import { MainWindow, Window, Windows, WindowPlugin } from '@wimaengine/window' import { WebglMaterialPlugin } from './plugins' import { AttributeMap, ClearColor, MeshCache, UBOCache, WebglProgramCache } from './resources' import { basicMaterial3DFragment, basicMaterial3DVertex } from './shaders' import { disposeDroppedMeshes, queueMeshes, registerWebglTypes } from './systems' -import { RenderCorePlugin } from '@wimaengine/render-core' -import { typeid } from '@wimaengine/type' -import { WindowPlugin } from '@wimaengine/window' export class WebglRendererPlugin extends Plugin { diff --git a/packages/render-webgl/src/plugins/index.js b/packages/render-webgl/src/plugins/index.js index 91e8ce6b..6d3837eb 100644 --- a/packages/render-webgl/src/plugins/index.js +++ b/packages/render-webgl/src/plugins/index.js @@ -3,11 +3,10 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' -import { Material } from '@wimaengine/render-core' -import { RenderCorePlugin } from '@wimaengine/render-core' -import { WindowPlugin } from '@wimaengine/window' +import { Material, RenderCorePlugin } from '@wimaengine/render-core' import { Transform3DPlugin } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' +import { WindowPlugin } from '@wimaengine/window' import { WebglRendererPlugin } from '../plugin' import { genRegisterBuffer, genRender, genRenderPipeline } from '../systems' diff --git a/packages/scene/src/plugin.js b/packages/scene/src/plugin.js index 152933c3..8c5b81e7 100644 --- a/packages/scene/src/plugin.js +++ b/packages/scene/src/plugin.js @@ -4,14 +4,13 @@ import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' import { HierarchyPlugin } from '@wimaengine/hierarchy' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' +import { typeidGeneric, typeid } from '@wimaengine/type' import { Scene } from './assets' import { SceneInstance } from './components' import { SceneAdded, SceneDropped, SceneModified } from './events' import { initSceneInstance, dropSceneInstance } from './hooks' import { JSONSceneExporter, JSONSceneImporter, SceneAssets, SceneSpawner } from './resources' import { registerSceneTypes, spawnScenes } from './systems' -import { typeid } from '@wimaengine/type' export class ScenePlugin extends Plugin { diff --git a/packages/storage/src/plugin.js b/packages/storage/src/plugin.js index 704bfedc..bd245431 100644 --- a/packages/storage/src/plugin.js +++ b/packages/storage/src/plugin.js @@ -1,7 +1,6 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' +import { CorePlugin, AppSchedule } from '@wimaengine/core' import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule } from '@wimaengine/core' import { typeid } from '@wimaengine/type' import { Session, Storage, Cookies } from './resources' import { registerStorageTypes } from './systems' diff --git a/packages/time/src/plugin.js b/packages/time/src/plugin.js index 1bfa87fa..865f8b57 100644 --- a/packages/time/src/plugin.js +++ b/packages/time/src/plugin.js @@ -1,12 +1,11 @@ import { App, Plugin } from '@wimaengine/app' -import { CorePlugin } from '@wimaengine/core' -import { ReflectPlugin } from '@wimaengine/reflect' -import { AppSchedule, CoreSystems } from '@wimaengine/core' +import { CorePlugin, AppSchedule, CoreSystems } from '@wimaengine/core' import { World } from '@wimaengine/ecs' +import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { Clock } from './clock' import { VirtualClock } from './resource' import { registerTimeTypes, updateTimers } from './systems' -import { typeid } from '@wimaengine/type' export class TimePlugin extends Plugin { diff --git a/packages/touch/src/plugin.js b/packages/touch/src/plugin.js index fc7711f9..cdc351cf 100644 --- a/packages/touch/src/plugin.js +++ b/packages/touch/src/plugin.js @@ -3,13 +3,11 @@ import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { World } from '@wimaengine/ecs' import { Events } from '@wimaengine/event' import { ReflectPlugin } from '@wimaengine/reflect' -import { typeidGeneric } from '@wimaengine/type' -import { PointerCancel, PointerDown, PointerMove, PointerUp } from '@wimaengine/window' -import { WindowPlugin } from '@wimaengine/window' +import { typeidGeneric, typeid } from '@wimaengine/type' +import { PointerCancel, PointerDown, PointerMove, PointerUp, WindowPlugin } from '@wimaengine/window' import { TouchPointer } from './core' import { Touches } from './resources' import { registerTouchTypes } from './systems' -import { typeid } from '@wimaengine/type' export class TouchPlugin extends Plugin { diff --git a/packages/transform/src/plugins/remote.js b/packages/transform/src/plugins/remote.js index f42c237d..a68d3332 100644 --- a/packages/transform/src/plugins/remote.js +++ b/packages/transform/src/plugins/remote.js @@ -3,8 +3,8 @@ import { AppSchedule, CorePlugin } from '@wimaengine/core' import { MathPlugin } from '@wimaengine/math' import { ReflectPlugin } from '@wimaengine/reflect' import { typeid } from '@wimaengine/type' -import { Transform2DPlugin, Transform3DPlugin } from './transform' import { registerRemoteTransform2DTypes, registerRemoteTransform3DTypes, transformRemote2D, transformRemote3D } from '../systems' +import { Transform2DPlugin, Transform3DPlugin } from './transform' export class RemoteTransform2DPlugin extends Plugin { diff --git a/packages/tween/src/plugin.js b/packages/tween/src/plugin.js index e16d4a29..1be37ec0 100644 --- a/packages/tween/src/plugin.js +++ b/packages/tween/src/plugin.js @@ -2,8 +2,8 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CorePlugin } from '@wimaengine/core' import { Vector2, Quaternion, Vector3, Rotary } from '@wimaengine/math' -import { Orientation2D, Orientation3D, Position2D, Position3D, Scale2D, Scale3D } from '@wimaengine/transform' import { TimePlugin } from '@wimaengine/time' +import { Orientation2D, Orientation3D, Position2D, Position3D, Scale2D, Scale3D } from '@wimaengine/transform' import { typeid, typeidGeneric } from '@wimaengine/type' import { Position2DTween, diff --git a/packages/window-dom/src/plugin.js b/packages/window-dom/src/plugin.js index 3ad23410..fb3093b3 100644 --- a/packages/window-dom/src/plugin.js +++ b/packages/window-dom/src/plugin.js @@ -1,11 +1,10 @@ import { App, Plugin } from '@wimaengine/app' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { ComponentHooks } from '@wimaengine/ecs' -import { Window } from '@wimaengine/window' -import { WindowPlugin } from '@wimaengine/window' +import { typeid } from '@wimaengine/type' +import { Window, WindowPlugin } from '@wimaengine/window' import { closeWindow, openWindow } from './hooks' import { resizeWindow } from './systems' -import { typeid } from '@wimaengine/type' export class DOMWindowPlugin extends Plugin { diff --git a/packages/window/src/plugin.js b/packages/window/src/plugin.js index c516312c..8108aaa8 100644 --- a/packages/window/src/plugin.js +++ b/packages/window/src/plugin.js @@ -1,10 +1,11 @@ /** @import {WindowOptions} from './components' */ import { App, Plugin } from '@wimaengine/app' -import { EntityCommands } from '@wimaengine/commands' import { CommandsPlugin } from '@wimaengine/command' +import { EntityCommands } from '@wimaengine/commands' import { AppSchedule, CoreSystems, CorePlugin } from '@wimaengine/core' import { EventPlugin } from '@wimaengine/event' import { ReflectPlugin } from '@wimaengine/reflect' +import { typeid } from '@wimaengine/type' import { Window, MainWindow } from './components' import { FileDrag, @@ -23,7 +24,6 @@ import { } from './events' import { Windows } from './resources' import { registerWindowTypes } from './systems' -import { typeid } from '@wimaengine/type' export class WindowPlugin extends Plugin {