Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM Scripts #5764

Closed
wants to merge 146 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
f520c67
Preliminary support for ES Modules
marklundin Oct 18, 2023
40c664c
Fixed linting issues
marklundin Oct 18, 2023
fe3efec
Modified the ES Script format API. Added swap method
marklundin Oct 23, 2023
9d24a07
Added HMR 'swap' to ES Modules
marklundin Oct 26, 2023
274309d
Adding ASSET_BASE_URL to support module importing
marklundin Oct 26, 2023
4841323
Added CORS flag to `npm run serve`
marklundin Oct 26, 2023
e768312
Added _ASSET_BASE_URL fix for dev time
marklundin Oct 26, 2023
2a96c0c
Updated ESModule* naming convention to ScriptESM*
marklundin Oct 26, 2023
762d18d
Fixed missing imports
marklundin Oct 27, 2023
f1696af
removed uneccessary cache
marklundin Oct 27, 2023
6ef4dd1
Cleaned up module specifier import
marklundin Oct 27, 2023
d51230a
Added custom module import script + linting
marklundin Oct 30, 2023
52c3471
Fixed issue with swapped modules being destroyed. Linting issues
marklundin Oct 30, 2023
cb05191
Added module import as template literal. See https://github.com/playc…
marklundin Oct 30, 2023
02fb662
Added correct attributes assignment logic
marklundin Oct 31, 2023
6c4c68b
Prevent module component iterating over all modules
marklundin Oct 31, 2023
e3b9d1e
Script ESM Modules can now be re-ordered in a component
marklundin Nov 1, 2023
9f3ff07
Better documentation. Fixed few edge cases with default values
marklundin Nov 3, 2023
4e6b960
Added examples
marklundin Nov 3, 2023
3dc7ae3
added todo flag to cloning
marklundin Nov 3, 2023
7f0955c
changed naming to EsmScript
marklundin Nov 3, 2023
762caa1
Merge branch 'main' into esmodules
marklundin Nov 3, 2023
1a30002
Fix linting
marklundin Nov 3, 2023
a66fe79
Nested attributes now copy over to modules with same hierarchy
marklundin Nov 6, 2023
9e2da68
Merge branch 'main' into esmodules
marklundin Nov 6, 2023
bd3e347
removed dead code
marklundin Nov 7, 2023
35c93e6
Fixed the ESM Script Component Systems 'clone' method
marklundin Nov 7, 2023
1d45873
Fixed issue that now normalizes module path
marklundin Nov 8, 2023
a659d03
Removed render component on earthtile example
marklundin Nov 8, 2023
a56c825
updated component iteration to use for of loop
marklundin Nov 8, 2023
99c5b1f
documentation update
marklundin Nov 9, 2023
b9f3eee
Merge branch 'main' into esmodules
marklundin Nov 9, 2023
ddd4199
added better documentation for `isValidAttributeDefinition`
marklundin Nov 9, 2023
24a646f
Merge branch 'main' into esmodules
marklundin Nov 9, 2023
fafd773
Fixed types error
marklundin Nov 9, 2023
ecc3e3d
Addresses PR comments
marklundin Nov 10, 2023
eafe253
Merge branch 'main' into esmodules
marklundin Nov 10, 2023
ee0bd96
Updated example
marklundin Nov 10, 2023
61990a4
Adding ignore to documentation
marklundin Nov 10, 2023
2cd077e
added ignore
marklundin Nov 10, 2023
893e2bf
Removed dynamic import and HMR swapping
marklundin Nov 15, 2023
96e3272
Providing new Esm Script Type base class
marklundin Nov 17, 2023
ad9dd97
Fixed linting/types issues
marklundin Nov 17, 2023
673aa2c
Confetti now extends base class
marklundin Nov 21, 2023
177de66
Implemented PR feedback
marklundin Nov 21, 2023
806201f
Added appEntity shorthand
marklundin Nov 21, 2023
8fa2b26
Prevent redundant object creation in update methods
marklundin Nov 21, 2023
d429201
Implemented clone method
marklundin Nov 21, 2023
0b76ad7
Removed Earthatile ESM example
marklundin Nov 21, 2023
1392a62
fixed clone issue
marklundin Nov 21, 2023
22eacf3
Testing nested scripts
marklundin Nov 21, 2023
97649b3
correct imports
marklundin Nov 21, 2023
8244e2b
Fixed issue with late initialized entities
marklundin Nov 21, 2023
d6db607
Added base test classes
marklundin Nov 23, 2023
c4049e1
test fixes
marklundin Nov 23, 2023
e0aa409
additional test
marklundin Nov 23, 2023
443304a
Attributes now correctly resolve arrays and nested props
marklundin Nov 28, 2023
b047e98
merged esmscript test json
marklundin Nov 28, 2023
99cca3f
included esm script tests
marklundin Nov 28, 2023
e34ca79
linting fixes
marklundin Nov 28, 2023
3639e17
Added iniitialize
marklundin Nov 29, 2023
ef57d6c
Adding more tests
marklundin Nov 30, 2023
9e011cb
Merge branch 'main' into esmodules
marklundin Nov 30, 2023
9a02061
Raise an error if a module with the same name is added
marklundin Nov 30, 2023
fe34450
Ensured esm modules are added in correct order
marklundin Dec 1, 2023
633533e
More tests
marklundin Dec 1, 2023
0c0b8cc
Consistent 'ESM Script' naming
marklundin Dec 1, 2023
500e6cd
removed redundant scene
marklundin Dec 1, 2023
22db44d
Moving tests to ESM
marklundin Dec 1, 2023
ef4f2be
Removed redundant NAME field from examples. Sorted imports.
marklundin Dec 1, 2023
0429a3c
documentation improvement.
marklundin Dec 1, 2023
d1ce21f
fixed casing issues
marklundin Dec 1, 2023
9186e18
doc updates. removed some redundant code
marklundin Dec 1, 2023
dad139d
updated docs
marklundin Dec 1, 2023
e1cd169
Merge branch 'esmodules' into esmscript-tests
marklundin Dec 1, 2023
6dd758f
Adding initialize tests
marklundin Dec 1, 2023
b76978d
Fix for undefined attributes in class def
marklundin Dec 4, 2023
381caa5
Merge branch 'esmodules' into esmscript-tests
marklundin Dec 4, 2023
291ba3a
Merge branch 'main' into esmodules
marklundin Dec 4, 2023
230e412
Merge branch 'esmodules' into esmscript-tests
marklundin Dec 4, 2023
0710453
Ported more test over to ES6
marklundin Dec 4, 2023
bff3bb0
Moving tests to ESM
marklundin Dec 1, 2023
009ced3
Adding initialize tests
marklundin Dec 1, 2023
9b5f29a
Ported more test over to ES6
marklundin Dec 4, 2023
a1b8672
Merge branch 'esmscript-tests' into esmodules
marklundin Dec 4, 2023
b2559d3
Add new ESM scripts and update EsmScriptComponent
marklundin Dec 5, 2023
0c04a7f
remove esm test from es5 tests dir
marklundin Dec 5, 2023
444d967
Added scene initialization tests
marklundin Dec 5, 2023
24d1866
Tests: Attribute checks
marklundin Dec 5, 2023
944a020
Added better warning/messaging w/ tests
marklundin Dec 5, 2023
f48643a
Simplified attribute population
marklundin Dec 6, 2023
4c5321b
Enabled attributes test
marklundin Dec 6, 2023
db59d0f
linting fixes
marklundin Dec 6, 2023
c032b26
shimming console.error in tests to remove noise
marklundin Dec 6, 2023
cae0aea
Merge branch 'main' into esmodules
marklundin Dec 6, 2023
daeace9
Add experiemental api warning
marklundin Dec 6, 2023
47ca448
Restrict to `warnOnce`
marklundin Dec 6, 2023
0522633
Doc fixes
marklundin Dec 6, 2023
4fe02bb
doc updates
marklundin Dec 6, 2023
c05ed1a
Jsdoc fixes as per @kungfooman feedbabackl
marklundin Dec 7, 2023
d0982e1
Added OrbitCamera ES Modules example. Removed Hello script Modules ex…
marklundin Dec 7, 2023
6e8bc0c
Added clamping without events
marklundin Dec 7, 2023
5789b07
removed redundant scripts from rollup
marklundin Dec 7, 2023
407903a
removed legacy code from karma tests
marklundin Dec 7, 2023
118e376
Fixed types issues
marklundin Dec 7, 2023
8ea742b
docs + destroy test
marklundin Dec 7, 2023
84c5c67
Attribute definition now a static class member
marklundin Dec 8, 2023
aa2688b
removed redundant attribute Map
marklundin Dec 8, 2023
9a70f07
linting fix
marklundin Dec 8, 2023
bba2a7d
Adde enable/disable tests
marklundin Dec 8, 2023
902d533
Updated orbit example with new static member attribute definition
marklundin Dec 9, 2023
9937fa4
lint fixes
marklundin Dec 11, 2023
7c6e1cc
Added script cache in preload
marklundin Dec 11, 2023
36cbd0f
Removed redundant addComponent
marklundin Dec 11, 2023
6f55849
removed redundant tests
marklundin Dec 11, 2023
880579a
fix lint
marklundin Dec 11, 2023
8f67918
removed unnecessary attr export
marklundin Dec 11, 2023
3da4293
removed redundant exports
marklundin Dec 11, 2023
3953e8d
removed unnecessary export. jsdoc fixes
marklundin Dec 12, 2023
440a145
updated tests to use synchronous calls
marklundin Dec 12, 2023
de693ae
Changed compile time asset lookup to use runtime path
marklundin Dec 12, 2023
1731a4b
removed dead code in tests
marklundin Dec 12, 2023
a083eab
Merge branch 'main' into esmodules
marklundin Dec 12, 2023
89eb9b5
script cache is now scoped to the app
marklundin Dec 12, 2023
97740a3
removed redundant export
marklundin Dec 12, 2023
4bd907d
Update scripts/camera/orbit/orbit-camera-input-mouse.mjs
marklundin Dec 14, 2023
af90e32
Update scripts/camera/orbit/orbit-camera-input-mouse.mjs
marklundin Dec 14, 2023
271b76c
Update scripts/camera/orbit/orbit-camera-input-touch.mjs
marklundin Dec 14, 2023
333606f
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 14, 2023
aff2085
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 14, 2023
fdcf4d0
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 14, 2023
70c9b88
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 14, 2023
ec3af91
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
8e4918f
Update src/framework/components/esmscript/system.js
marklundin Dec 15, 2023
1810d22
Update src/framework/components/esmscript/system.js
marklundin Dec 15, 2023
f12188b
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
9042dae
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
0099dc8
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
3f83c35
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
cee0c70
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
22cf09f
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
972e7c4
Update scripts/camera/orbit/orbit-camera.mjs
marklundin Dec 15, 2023
c4153dd
lint fix
marklundin Dec 15, 2023
c552ee8
attributes are now correctly cloned, not assigned
marklundin Jan 2, 2024
79ca774
ensure deep equal test
marklundin Jan 2, 2024
026f33f
Scripts now have their own `enabled` prop. Removed component level co…
marklundin Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,965 changes: 499 additions & 6,466 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"docs": "jsdoc -c conf-api.json",
"typedocs": "typedoc",
"lint": "eslint --ext .js,.mjs extras scripts src test utils rollup.config.mjs",
"serve": "serve build -l 51000",
"serve": "serve build -l 51000 -C",
"test": "mocha --recursive --require test/fixtures.mjs",
"test:coverage": "c8 npm test",
"test:karma": "karma start tests/karma.conf.cjs -- --single-run --release",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ function buildTarget(buildType, moduleFormat) {
values: {
...sdkVersion,
_DEBUG: 1,
_PROFILER: 1
_PROFILER: 1,
_ASSET_BASE_URL: JSON.stringify(process.env.ASSET_BASE_URL) || false
marklundin marked this conversation as resolved.
Show resolved Hide resolved
},
keepLines: true
},
Expand Down
5 changes: 4 additions & 1 deletion src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ZoneComponentSystem } from './components/zone/system.js';
import { CameraComponentSystem } from './components/camera/system.js';
import { LightComponentSystem } from './components/light/system.js';
import { ScriptComponentSystem } from './components/script/system.js';

import { ScriptESMComponentSystem } from './components/script-esm/system.js';
import { RenderHandler } from './handlers/render.js';
import { AnimationHandler } from './handlers/animation.js';
import { AnimClipHandler } from './handlers/anim-clip.js';
Expand All @@ -44,6 +44,7 @@ import { BinaryHandler } from './handlers/binary.js';
import { ContainerHandler } from './handlers/container.js';
import { CssHandler } from './handlers/css.js';
import { CubemapHandler } from './handlers/cubemap.js';
import { ScriptESMHandler } from './handlers/script-esm.js';
import { FolderHandler } from './handlers/folder.js';
import { FontHandler } from './handlers/font.js';
import { HierarchyHandler } from './handlers/hierarchy.js';
Expand Down Expand Up @@ -168,6 +169,7 @@ class Application extends AppBase {
CameraComponentSystem,
LightComponentSystem,
script.legacy ? ScriptLegacyComponentSystem : ScriptComponentSystem,
ScriptESMComponentSystem,
AudioSourceComponentSystem,
SoundComponentSystem,
AudioListenerComponentSystem,
Expand Down Expand Up @@ -196,6 +198,7 @@ class Application extends AppBase {
TextHandler,
JsonHandler,
AudioHandler,
ScriptESMHandler,
ScriptHandler,
SceneHandler,
CubemapHandler,
Expand Down
8 changes: 8 additions & 0 deletions src/framework/components/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class ComponentSystemRegistry extends EventHandler {
*/
element;

/**
* Gets the {@link ScriptESMComponentSystem} from the registry.
*
* @type {import('./script-esm/system.js').ScriptESMComponentSystem|undefined}
* @readonly
*/
esmodule;

/**
* Gets the {@link JointComponentSystem} from the registry.
*
Expand Down
327 changes: 327 additions & 0 deletions src/framework/components/script-esm/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
import { pcImport } from '../../handlers/script-esm.js';
import { Debug } from '../../../core/debug.js';
import { Component } from '../component.js';

/**
* The ScriptESMComponent allows you to extend the functionality of an Entity by attaching your own
* ESM module to the Entity. For more
* details on scripting see [Scripting](https://developer.playcanvas.com/user-manual/scripting/).
*
* @augments Component
*/
class ScriptESMComponent extends Component {
/**
* Create a new ScriptESMComponent instance.
*
* @param {import('./system.js').ScriptESMComponentSystem} system - The ComponentSystem that
* created this Component.
* @param {Entity} entity - The Entity that this Component is attached to.
*/
constructor(system, entity) {
super(system, entity);

/**
* Holds all module instances for this component.
* @private
*/

this.modules = new Map();


this.moduleAttributes = new Map();

}

/**
* Fired when Component becomes enabled. Note: this event does not take in account entity or
* any of its parent enabled state.
*
* @event ScriptESMComponent#enable
* @example
* entity.script.on('enable', function () {
* // component is enabled
* });
*/

/**
* Fired when Component becomes disabled. Note: this event does not take in account entity or
* any of its parent enabled state.
*
* @event ScriptESMComponent#disable
* @example
* entity.script.on('disable', function () {
* // component is disabled
* });
*/

/**
* Fired when Component changes state to enabled or disabled. Note: this event does not take in
* account entity or any of its parent enabled state.
*
* @event ScriptESMComponent#state
* @param {boolean} enabled - True if now enabled, False if disabled.
* @example
* entity.script.on('state', function (enabled) {
* // component changed state
* });
*/

/**
* Fired when Component is removed from entity.
*
* @event ScriptESMComponent#remove
* @example
* entity.script.on('remove', function () {
* // entity has no more script component
* });
*/

/**
* Fired when an esm script instance is created and attached to component.
*
* @event ScriptESMComponent#create
* @param {string} name - The name of the Script Type.
* @param {import('../../script/script-type.js').ScriptType} scriptInstance - The instance of
* the {@link ScriptType} that has been created.
* @example
* entity.script.on('create', function (name, scriptInstance) {
* // new script instance added to component
* });
*/

/**
* Fired when an esm script instance is created and attached to component.
*
* @event ScriptComponent#create:[name]
* @param {import('../../script/script-type.js').ScriptType} scriptInstance - The instance of
* the {@link ScriptType} that has been created.
* @example
* entity.script.on('create:playerController', function (scriptInstance) {
* // new script instance 'playerController' is added to component
* });
*/

/**
* Fired when a script instance is destroyed and removed from component.
*
* @event ScriptESMComponent#destroy
* @param {string} name - The name of the Script Type.
* @param {import('../../script/script-type.js').ScriptType} scriptInstance - The instance of
* the {@link ScriptType} that has been destroyed.
* @example
* entity.script.on('destroy', function (name, scriptInstance) {
* // script instance has been destroyed and removed from component
* });
*/

/**
* Fired when a script instance is destroyed and removed from component.
*
* @event ScriptESMComponent#destroy:[name]
* @param {import('../../script/script-type.js').ScriptType} scriptInstance - The instance of
* the {@link ScriptType} that has been destroyed.
* @example
* entity.script.on('destroy:playerController', function (scriptInstance) {
* // script instance 'playerController' has been destroyed and removed from component
* });
*/

/**
* Fired when a script instance had an exception.
*
* @event ScriptESMComponent#error
* @param {import('../../script/script-type.js').ScriptType} scriptInstance - The instance of
* the {@link ScriptType} that raised the exception.
* @param {Error} err - Native JS Error object with details of an error.
* @param {string} method - The method of the script instance that the exception originated from.
* @example
* entity.script.on('error', function (scriptInstance, err, method) {
* // script instance caught an exception
* });
*/

_onBeforeRemove() {
this.modules.forEach(({ moduleInstance }) => {
this.destroy(moduleInstance);
});
}

_onInitialize() {
this.modules.forEach(({ moduleInstance }) => {
moduleInstance.initialize?.();
});
}

_onUpdate(dt) {
this.modules.forEach(({ moduleInstance }) => {
moduleInstance.update?.(dt);
});
}

/**
* When an entity is cloned and it has entity script attributes that point to other entities in
* the same subtree that is cloned, then we want the new script attributes to point at the
* cloned entities. This method remaps the script attributes for this entity and it assumes
* that this entity is the result of the clone operation.
*
* @param {ScriptESMComponent} oldScriptComponent - The source script component that belongs to
* the entity that was being cloned.
* @param {object} duplicatedIdsMap - A dictionary with guid-entity values that contains the
* entities that were cloned.
* @private
*/
resolveDuplicatedEntityReferenceProperties(oldScriptComponent, duplicatedIdsMap) {

// TODO - run over old script component, any entities found, re-point them
}

/**
* Detect if script is attached to an entity.
*
* @param {string} moduleSpecifier - The module specifier to search for
* @returns {boolean} If script is attached to an entity.
* @example
* if (entity.module.has('path/to/module.mjs')) {
* // entity has script
* }
*/
has(moduleSpecifier) {
return this.modules.has(moduleSpecifier);
}

/**
* Get a script instance (if attached).
*
* @param {string} moduleSpecifier - The
* name or type of {@link ScriptType}.
* @returns {import('../../script/script-type.js').ScriptType|null} If script is attached, the
* instance is returned. Otherwise null is returned.
* @example
* const controller = entity.module.get('module');
*/
get(moduleSpecifier) {
return this.modules.get(moduleSpecifier);
}

/**
* Create a script instance and attach to an entity script component.
*
* @param {string} moduleSpecifier - The module specifier used to import the ES module.
* @param {object} [args] - Object with arguments for a script.
* @param {boolean} [args.enabled] - If script instance is enabled after creation. Defaults to
* true.
* @param {object} [args.attributes] - Object with values for attributes (if any), where key is
* name of an attribute.
* @param {boolean} [args.preloading] - If script instance is created during preload. If true,
* script and attributes must be initialized manually. Defaults to false.
* @param {number} [args.ind] - The index where to insert the script instance at. Defaults to
* -1, which means append it at the end.
* @returns {*} Returns an instance of a
* ES Module if successfully attached to an entity, or null if the import fails
* @example
* entity.module.create('moduleSpecifier', {
* attributes: {
* speed: 4
* }
* });
*/
create(moduleSpecifier, args) {

const { attributes: definedAttributes } = args;

let finalUrl = moduleSpecifier;

// #if _ASSET_BASE_URL
// eslint-disable-next-line no-undef
finalUrl = $_ASSET_BASE_URL + this.system.app.assets.prefix + moduleSpecifier;
// #endif
marklundin marked this conversation as resolved.
Show resolved Hide resolved

pcImport(this.system.app, finalUrl).then(({ default: ModuleClass, attributes }) => {

this.addModule(moduleSpecifier, ModuleClass, attributes, definedAttributes);

}).catch((err) => {
Debug.error(`module '${moduleSpecifier}' does not exist`);
return null;
});

}

addModule(moduleSpecifier, ModuleClass, attributes, definedAttributes) {

if (!ModuleClass)
throw new Error(`Please check your exports. The module '${moduleSpecifier}' does not contain a default export`);

if (typeof ModuleClass !== 'function')
throw new Error(`The module '${moduleSpecifier}' does not export a class or a function`);

if (!attributes) Debug.warn(`The module '${moduleSpecifier}' does not export any attributes`);

const moduleInstance = new ModuleClass(this.entity, attributes);

// Assign attributes to module instance
Object.entries(attributes).forEach(([attributeName, { value }]) => {
moduleInstance[attributeName] = definedAttributes[attributeName];
});

// Retrieve any previous instance associated with the module specifier
const previousModuleInstance = this.modules.get(moduleSpecifier)?.moduleInstance;
const isHMREnabled = moduleInstance.swap && typeof moduleInstance.swap === 'function';

this.fire('create', moduleSpecifier, moduleInstance);
this.fire('create:' + moduleSpecifier, moduleInstance);

// Check if an existing module exists, ie. if this is a candidate to swap
if (previousModuleInstance) {

// Copy intrinsic state
moduleInstance.enabled = previousModuleInstance.enabled;

// Copy explicit state
if (isHMREnabled)
moduleInstance.swap(previousModuleInstance);

// destroy previous module
previousModuleInstance.destroy();

} else if (moduleInstance.enabled || !Object.hasOwn(moduleInstance, 'enabled')) {
moduleInstance.initialize(definedAttributes);
}

if (isHMREnabled) {
this.system.app.assets.once(`load:url:${this.system.app.assets.prefix + moduleSpecifier}`, (asset) => {
const NewModuleClass = asset.resource;
this.addModule(moduleSpecifier, NewModuleClass, attributes);
});
}

this.modules.set(moduleSpecifier, { ModuleClass, attributes, moduleInstance });

return moduleInstance;
}


/**
* Destroy the script instance that is attached to an entity.
*
* @param {string} moduleSpecifier - The
* name or type of {@link ScriptType}.
* @returns {boolean} If it was successfully destroyed.
* @example
* entity.script.destroy('playerController');
*/
destroy(moduleSpecifier) {

const module = this.modules.get(moduleSpecifier);

if (module) {
module.destroy();
this.modules.delete(moduleSpecifier);
return true;
}

return false;
}
}

export { ScriptESMComponent };
Loading