Skip to content

Commit

Permalink
Revert "Add Script alias (#6237)" (#6355)
Browse files Browse the repository at this point in the history
This reverts commit dd65f24.
marklundin authored May 13, 2024

Verified

This commit was signed with the committer’s verified signature.
schlosna David Schlosnagle
1 parent e1d77b9 commit d39421f
Showing 12 changed files with 578 additions and 584 deletions.
3 changes: 0 additions & 3 deletions src/deprecated/deprecated.js
Original file line number Diff line number Diff line change
@@ -126,9 +126,6 @@ import { basisInitialize } from '../framework/handlers/basis.js';
import { LitShader } from '../scene/shader-lib/programs/lit-shader.js';
import { Geometry } from '../scene/geometry/geometry.js';

// ScriptType alias
export { Script as ScriptType } from '../framework/script/script.js';

// CORE
export const LINEBATCH_WORLD = 0;
export const LINEBATCH_OVERLAY = 1;
44 changes: 22 additions & 22 deletions src/framework/components/script/component.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ import { Entity } from '../../entity.js';
*/
class ScriptComponent extends Component {
/**
* Fired when a {@link Script} instance is created and attached to the script component.
* Fired when a {@link ScriptType} instance is created and attached to the script component.
* This event is available in two forms. They are as follows:
*
* 1. `create` - Fired when a script instance is created. The name of the script type and the
@@ -40,7 +40,7 @@ class ScriptComponent extends Component {
static EVENT_CREATE = 'create';

/**
* Fired when a {@link Script} instance is destroyed and removed from the script component.
* Fired when a {@link ScriptType} instance is destroyed and removed from the script component.
* This event is available in two forms. They are as follows:
*
* 1. `destroy` - Fired when a script instance is destroyed. The name of the script type and
@@ -109,7 +109,7 @@ class ScriptComponent extends Component {
static EVENT_STATE = 'state';

/**
* Fired when the index of a {@link Script} instance is changed in the script component.
* Fired when the index of a {@link ScriptType} instance is changed in the script component.
* This event is available in two forms. They are as follows:
*
* 1. `move` - Fired when a script instance is moved. The name of the script type, the script
@@ -130,7 +130,7 @@ class ScriptComponent extends Component {
static EVENT_MOVE = 'move';

/**
* Fired when a {@link Script} instance had an exception. The handler is passed the script
* Fired when a {@link ScriptType} instance had an exception. The handler is passed the script
* instance, the exception and the method name that the exception originated from.
*
* @event
@@ -154,7 +154,7 @@ class ScriptComponent extends Component {
/**
* Holds all script instances for this component.
*
* @type {import('../../script/script.js').Script[]}
* @type {import('../../script/script-type.js').ScriptType[]}
* @private
*/
this._scripts = [];
@@ -191,7 +191,7 @@ class ScriptComponent extends Component {
* An array of all script instances attached to an entity. This array is read-only and should
* not be modified by developer.
*
* @type {import('../../script/script.js').Script[]}
* @type {import('../../script/script-type.js').ScriptType[]}
*/
set scripts(value) {
this._scriptsData = value;
@@ -546,8 +546,8 @@ class ScriptComponent extends Component {
/**
* Detect if script is attached to an entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If script is attached to an entity.
* @example
* if (entity.script.has('playerController')) {
@@ -570,9 +570,9 @@ class ScriptComponent extends Component {
/**
* Get a script instance (if attached).
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @returns {import('../../script/script.js').Script|null} If script is attached, the
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - 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.script.get('playerController');
@@ -594,8 +594,8 @@ class ScriptComponent extends Component {
/**
* Create a script instance and attach to an entity script component.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @param {object} [args] - Object with arguments for a script.
* @param {boolean} [args.enabled] - If script instance is enabled after creation. Defaults to
* true.
@@ -605,9 +605,9 @@ class ScriptComponent extends Component {
* 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 {import('../../script/script.js').Script|null} Returns an instance of a
* {@link Script} if successfully attached to an entity, or null if it failed because a
* script with a same name has already been added or if the {@link Script} cannot be found
* @returns {import('../../script/script-type.js').ScriptType|null} Returns an instance of a
* {@link ScriptType} if successfully attached to an entity, or null if it failed because a
* script with a same name has already been added or if the {@link ScriptType} cannot be found
* by name in the {@link ScriptRegistry}.
* @example
* entity.script.create('playerController', {
@@ -699,8 +699,8 @@ class ScriptComponent extends Component {
/**
* Destroy the script instance that is attached to an entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If it was successfully destroyed.
* @example
* entity.script.destroy('playerController');
@@ -756,8 +756,8 @@ class ScriptComponent extends Component {
/**
* Swap the script instance.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @returns {boolean} If it was successfully swapped.
* @private
*/
@@ -927,8 +927,8 @@ class ScriptComponent extends Component {
/**
* Move script instance to different position to alter update order of scripts within entity.
*
* @param {string|typeof import('../../script/script.js').Script} nameOrType - The
* name or type of {@link Script}.
* @param {string|typeof import('../../script/script-type.js').ScriptType} nameOrType - The
* name or type of {@link ScriptType}.
* @param {number} ind - New position index.
* @returns {boolean} If it was successfully moved.
* @example
8 changes: 4 additions & 4 deletions src/framework/entity.js
Original file line number Diff line number Diff line change
@@ -400,8 +400,8 @@ class Entity extends GraphNode {
/**
* Search the entity and all of its descendants for the first script instance of specified type.
*
* @param {string|typeof import('./script/script.js').Script} nameOrType - The name or type of {@link Script}.
* @returns {import('./script/script.js').Script|undefined} A script instance of specified type, if the entity or any of its descendants
* @param {string|typeof import('./script/script-type.js').ScriptType} nameOrType - The name or type of {@link ScriptType}.
* @returns {import('./script/script-type.js').ScriptType|undefined} A script instance of specified type, if the entity or any of its descendants
* has one. Returns undefined otherwise.
* @example
* // Get the first found "playerController" instance in the hierarchy tree that starts with this entity
@@ -415,8 +415,8 @@ class Entity extends GraphNode {
/**
* Search the entity and all of its descendants for all script instances of specified type.
*
* @param {string|typeof import('./script/script.js').Script} nameOrType - The name or type of {@link Script}.
* @returns {import('./script/script.js').Script[]} All script instances of specified type in the entity or any of its
* @param {string|typeof import('./script/script-type.js').ScriptType} nameOrType - The name or type of {@link ScriptType}.
* @returns {import('./script/script-type.js').ScriptType[]} All script instances of specified type in the entity or any of its
* descendants. Returns empty array if none found.
* @example
* // Get all "playerController" instances in the hierarchy tree that starts with this entity
6 changes: 3 additions & 3 deletions src/framework/handlers/script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { platform } from '../../core/platform.js';
import { script } from '../script.js';
import { Script } from '../script/script.js';
import { ScriptType } from '../script/script-type.js';
import { ScriptTypes } from '../script/script-types.js';
import { registerScript } from '../script/script-create.js';
import { registerScript } from '../script/script.js';
import { ResourceLoader } from './loader.js';

import { ResourceHandler } from './handler.js';
@@ -154,7 +154,7 @@ class ScriptHandler extends ResourceHandler {

for (const key in module) {
const scriptClass = module[key];
const extendsScriptType = scriptClass.prototype instanceof Script;
const extendsScriptType = scriptClass.prototype instanceof ScriptType;

if (extendsScriptType) {

6 changes: 3 additions & 3 deletions src/framework/script/script-attributes.js
Original file line number Diff line number Diff line change
@@ -150,16 +150,16 @@ function rawToValue(app, args, value, old) {

/**
* Container of Script Attribute definitions. Implements an interface to add/remove attributes and
* store their definition for a {@link Script}. Note: An instance of ScriptAttributes is
* created automatically by each {@link Script}.
* store their definition for a {@link ScriptType}. Note: An instance of ScriptAttributes is
* created automatically by each {@link ScriptType}.
*
* @category Script
*/
class ScriptAttributes {
/**
* Create a new ScriptAttributes instance.
*
* @param {typeof import('./script.js').Script} scriptType - Script Type that attributes relate to.
* @param {typeof import('./script-type.js').ScriptType} scriptType - Script Type that attributes relate to.
*/
constructor(scriptType) {
this.scriptType = scriptType;
148 changes: 0 additions & 148 deletions src/framework/script/script-create.js

This file was deleted.

36 changes: 18 additions & 18 deletions src/framework/script/script-registry.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { EventHandler } from '../../core/event-handler.js';

/**
* Container for all {@link Script}s that are available to this application. Note that
* Container for all {@link ScriptType}s that are available to this application. Note that
* PlayCanvas scripts can access the Script Registry from inside the application with
* {@link AppBase#scripts}.
*
* @category Script
*/
class ScriptRegistry extends EventHandler {
/**
* @type {Object<string, typeof import('./script.js').Script>}
* @type {Object<string, typeof import('./script-type.js').ScriptType>}
* @private
*/
_scripts = {};

/**
* @type {typeof import('./script.js').Script[]}
* @type {typeof import('./script-type.js').ScriptType[]}
* @private
*/
_list = [];
@@ -37,12 +37,12 @@ class ScriptRegistry extends EventHandler {
}

/**
* Add {@link Script} to registry. Note: when {@link createScript} is called, it will add
* the {@link Script} to the registry automatically. If a script already exists in
* Add {@link ScriptType} to registry. Note: when {@link createScript} is called, it will add
* the {@link ScriptType} to the registry automatically. If a script already exists in
* registry, and the new script has a `swap` method defined, it will perform code hot swapping
* automatically in async manner.
*
* @param {typeof import('./script.js').Script} script - Script Type that is created
* @param {typeof import('./script-type.js').ScriptType} script - Script Type that is created
* using {@link createScript}.
* @returns {boolean} True if added for the first time or false if script already exists.
* @example
@@ -146,10 +146,10 @@ class ScriptRegistry extends EventHandler {
}

/**
* Remove {@link Script}.
* Remove {@link ScriptType}.
*
* @param {string|typeof import('./script.js').Script} nameOrType - The name or type
* of {@link Script}.
* @param {string|typeof import('./script-type.js').ScriptType} nameOrType - The name or type
* of {@link ScriptType}.
* @returns {boolean} True if removed or False if already not in registry.
* @example
* app.scripts.remove('playerController');
@@ -178,10 +178,10 @@ class ScriptRegistry extends EventHandler {
}

/**
* Get {@link Script} by name.
* Get {@link ScriptType} by name.
*
* @param {string} name - Name of a {@link Script}.
* @returns {typeof import('./script.js').Script} The Script Type if it exists in the
* @param {string} name - Name of a {@link ScriptType}.
* @returns {typeof import('./script-type.js').ScriptType} The Script Type if it exists in the
* registry or null otherwise.
* @example
* var PlayerController = app.scripts.get('playerController');
@@ -191,11 +191,11 @@ class ScriptRegistry extends EventHandler {
}

/**
* Check if a {@link Script} with the specified name is in the registry.
* Check if a {@link ScriptType} with the specified name is in the registry.
*
* @param {string|typeof import('./script.js').Script} nameOrType - The name or type
* of {@link Script}.
* @returns {boolean} True if {@link Script} is in registry.
* @param {string|typeof import('./script-type.js').ScriptType} nameOrType - The name or type
* of {@link ScriptType}.
* @returns {boolean} True if {@link ScriptType} is in registry.
* @example
* if (app.scripts.has('playerController')) {
* // playerController is in pc.ScriptRegistry
@@ -212,9 +212,9 @@ class ScriptRegistry extends EventHandler {
}

/**
* Get list of all {@link Script}s from registry.
* Get list of all {@link ScriptType}s from registry.
*
* @returns {Array<typeof import('./script.js').Script>} list of all {@link Script}s
* @returns {Array<typeof import('./script-type.js').ScriptType>} list of all {@link ScriptType}s
* in registry.
* @example
* // logs array of all Script Type names available in registry
393 changes: 393 additions & 0 deletions src/framework/script/script-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,393 @@
import { Debug } from '../../core/debug.js';
import { EventHandler } from '../../core/event-handler.js';

import { SCRIPT_INITIALIZE, SCRIPT_POST_INITIALIZE } from './constants.js';
import { ScriptAttributes } from './script-attributes.js';

const funcNameRegex = new RegExp('^\\s*function(?:\\s|\\s*\\/\\*.*\\*\\/\\s*)+([^\\(\\s\\/]*)\\s*');

/**
* Represents the type of a script. It is returned by {@link createScript}. Also referred to as
* Script Type.
*
* The type is to be extended using its JavaScript prototype. There is a list of methods that will
* be executed by the engine on instances of this type, such as:
*
* - `initialize`
* - `postInitialize`
* - `update`
* - `postUpdate`
* - `swap`
*
* `initialize` and `postInitialize` - are called (if defined) when a script is about to run for
* the first time - `postInitialize` will run after all `initialize` methods are executed in the
* same tick or enabling chain of actions.
*
* `update` and `postUpdate` - are called (if defined) for enabled (running state) scripts on each
* tick.
*
* `swap` - is called when a ScriptType that already exists in the registry gets redefined. If the
* new ScriptType has a `swap` method in its prototype, then it will be executed to perform hot-
* reload at runtime.
*
* @category Script
*/
class ScriptType extends EventHandler {
/**
* Fired when a script instance becomes enabled.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('enable', () => {
* // Script Instance is now enabled
* });
* };
*/
static EVENT_ENABLE = 'enable';

/**
* Fired when a script instance becomes disabled.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('disable', () => {
* // Script Instance is now disabled
* });
* };
*/
static EVENT_DISABLE = 'disable';

/**
* Fired when a script instance changes state to enabled or disabled. The handler is passed a
* boolean parameter that states whether the script instance is now enabled or disabled.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('state', (enabled) => {
* console.log(`Script Instance is now ${enabled ? 'enabled' : 'disabled'}`);
* });
* };
*/
static EVENT_STATE = 'state';

/**
* Fired when a script instance is destroyed and removed from component.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('destroy', () => {
* // no longer part of the entity
* // this is a good place to clean up allocated resources used by the script
* });
* };
*/
static EVENT_DESTROY = 'destroy';

/**
* Fired when script attributes have changed. This event is available in two forms. They are as follows:
*
* 1. `attr` - Fired for any attribute change. The handler is passed the name of the attribute
* that changed, the value of the attribute before the change and the value of the attribute
* after the change.
* 2. `attr:[name]` - Fired for a specific attribute change. The handler is passed the value of
* the attribute before the change and the value of the attribute after the change.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('attr', (name, newValue, oldValue) => {
* console.log(`Attribute '${name}' changed from '${oldValue}' to '${newValue}'`);
* });
* };
* @example
* PlayerController.prototype.initialize = function () {
* this.on('attr:speed', (newValue, oldValue) => {
* console.log(`Attribute 'speed' changed from '${oldValue}' to '${newValue}'`);
* });
* };
*/
static EVENT_ATTR = 'attr';

/**
* Fired when a script instance had an exception. The script instance will be automatically
* disabled. The handler is passed an {@link Error} object containing the details of the
* exception and the name of the method that threw the exception.
*
* @event
* @example
* PlayerController.prototype.initialize = function () {
* this.on('error', (err, method) => {
* // caught an exception
* console.log(err.stack);
* });
* };
*/
static EVENT_ERROR = 'error';

/**
* The {@link AppBase} that the instance of this type belongs to.
*
* @type {import('../app-base.js').AppBase}
*/
app;

/**
* The {@link Entity} that the instance of this type belongs to.
*
* @type {import('../entity.js').Entity}
*/
entity;

/** @private */
_enabled;

/** @private */
_enabledOld;

/** @private */
_initialized;

/** @private */
_postInitialized;

/** @private */
__destroyed;

/** @private */
__attributes;

/** @private */
__attributesRaw;

/** @private */
__scriptType;

/**
* The order in the script component that the methods of this script instance will run
* relative to other script instances in the component.
*
* @type {number}
* @private
*/
__executionOrder;

/**
* Create a new ScriptType instance.
*
* @param {object} args - The input arguments object.
* @param {import('../app-base.js').AppBase} args.app - The {@link AppBase} that is running the
* script.
* @param {import('../entity.js').Entity} args.entity - The {@link Entity} that the script is
* attached to.
*/
constructor(args) {
super();
this.initScriptType(args);
}

/**
* True if the instance of this type is in running state. False when script is not running,
* because the Entity or any of its parents are disabled or the {@link ScriptComponent} is
* disabled or the Script Instance is disabled. When disabled no update methods will be called
* on each tick. initialize and postInitialize methods will run once when the script instance
* is in `enabled` state during app tick.
*
* @type {boolean}
*/
set enabled(value) {
this._enabled = !!value;

if (this.enabled === this._enabledOld) return;

this._enabledOld = this.enabled;
this.fire(this.enabled ? 'enable' : 'disable');
this.fire('state', this.enabled);

// initialize script if not initialized yet and script is enabled
if (!this._initialized && this.enabled) {
this._initialized = true;

this.__initializeAttributes(true);

if (this.initialize)
this.entity.script._scriptMethod(this, SCRIPT_INITIALIZE);
}

// post initialize script if not post initialized yet and still enabled
// (initialize might have disabled the script so check this.enabled again)
// Warning: Do not do this if the script component is currently being enabled
// because in this case post initialize must be called after all the scripts
// in the script component have been initialized first
if (this._initialized && !this._postInitialized && this.enabled && !this.entity.script._beingEnabled) {
this._postInitialized = true;

if (this.postInitialize)
this.entity.script._scriptMethod(this, SCRIPT_POST_INITIALIZE);
}
}

get enabled() {
return this._enabled && !this._destroyed && this.entity.script.enabled && this.entity.enabled;
}

/**
* @param {{entity: import('../entity.js').Entity, app: import('../app-base.js').AppBase}} args -
* The entity and app.
* @private
*/
initScriptType(args) {
const script = this.constructor; // get script type, i.e. function (class)
Debug.assert(args && args.app && args.entity, `script [${script.__name}] has missing arguments in constructor`);

this.app = args.app;
this.entity = args.entity;

this._enabled = typeof args.enabled === 'boolean' ? args.enabled : true;
this._enabledOld = this.enabled;

this.__destroyed = false;
this.__attributes = { };
this.__attributesRaw = args.attributes || { }; // need at least an empty object to make sure default attributes are initialized
this.__scriptType = script;
this.__executionOrder = -1;
}

/**
* Name of a Script Type.
*
* @type {string}
* @private
*/
static __name = null; // Will be assigned when calling createScript or registerScript.

/**
* @param {*} constructorFn - The constructor function of the script type.
* @returns {string} The script name.
* @private
*/
static __getScriptName(constructorFn) {
if (typeof constructorFn !== 'function') return undefined;
if ('name' in Function.prototype) return constructorFn.name;
if (constructorFn === Function || constructorFn === Function.prototype.constructor) return 'Function';
const match = ('' + constructorFn).match(funcNameRegex);
return match ? match[1] : undefined;
}

/**
* Name of a Script Type.
*
* @type {string|null}
*/
static get scriptName() {
return this.__name;
}

/**
* The interface to define attributes for Script Types. Refer to {@link ScriptAttributes}.
*
* @type {ScriptAttributes}
* @example
* var PlayerController = pc.createScript('playerController');
*
* PlayerController.attributes.add('speed', {
* type: 'number',
* title: 'Speed',
* placeholder: 'km/h',
* default: 22.2
* });
*/
static get attributes() {
if (!this.hasOwnProperty('__attributes')) this.__attributes = new ScriptAttributes(this);
return this.__attributes;
}

/**
* @param {boolean} [force] - Set to true to force initialization of the attributes.
* @private
*/
__initializeAttributes(force) {
if (!force && !this.__attributesRaw)
return;

// set attributes values
for (const key in this.__scriptType.attributes.index) {
if (this.__attributesRaw && this.__attributesRaw.hasOwnProperty(key)) {
this[key] = this.__attributesRaw[key];
} else if (!this.__attributes.hasOwnProperty(key)) {
if (this.__scriptType.attributes.index[key].hasOwnProperty('default')) {
this[key] = this.__scriptType.attributes.index[key].default;
} else {
this[key] = null;
}
}
}

this.__attributesRaw = null;
}

/**
* Shorthand function to extend Script Type prototype with list of methods.
*
* @param {object} methods - Object with methods, where key - is name of method, and value - is function.
* @example
* var PlayerController = pc.createScript('playerController');
*
* PlayerController.extend({
* initialize: function () {
* // called once on initialize
* },
* update: function (dt) {
* // called each tick
* }
* });
*/
static extend(methods) {
for (const key in methods) {
if (!methods.hasOwnProperty(key))
continue;

this.prototype[key] = methods[key];
}
}

/**
* @function
* @name ScriptType#[initialize]
* @description Called when script is about to run for the first time.
*/

/**
* @function
* @name ScriptType#[postInitialize]
* @description Called after all initialize methods are executed in the same tick or enabling chain of actions.
*/

/**
* @function
* @name ScriptType#[update]
* @description Called for enabled (running state) scripts on each tick.
* @param {number} dt - The delta time in seconds since the last frame.
*/

/**
* @function
* @name ScriptType#[postUpdate]
* @description Called for enabled (running state) scripts on each tick, after update.
* @param {number} dt - The delta time in seconds since the last frame.
*/

/**
* @function
* @name ScriptType#[swap]
* @description Called when a ScriptType that already exists in the registry
* gets redefined. If the new ScriptType has a `swap` method in its prototype,
* then it will be executed to perform hot-reload at runtime.
* @param {ScriptType} old - Old instance of the scriptType to copy data to the new instance.
*/
}

export { ScriptType };
502 changes: 127 additions & 375 deletions src/framework/script/script.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -360,10 +360,10 @@ export { ElementInput, ElementInputEvent, ElementMouseEvent, ElementSelectEvent,
export { JsonStandardMaterialParser } from './framework/parsers/material/json-standard-material.js';

// FRAMEWORK /SCRIPTS
export { createScript, registerScript, getReservedScriptNames } from './framework/script/script-create.js';
export { createScript, registerScript, getReservedScriptNames } from './framework/script/script.js';
export { ScriptAttributes } from './framework/script/script-attributes.js';
export { ScriptRegistry } from './framework/script/script-registry.js';
export { Script } from './framework/script/script.js';
export { ScriptType } from './framework/script/script-type.js';

// FRAMEWORK / LOCALIZATION
export { I18n } from './framework/i18n/i18n.js';
2 changes: 1 addition & 1 deletion test/framework/entity.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createScript } from '../../src/framework/script/script-create.js';
import { createScript } from '../../src/framework/script/script.js';
import { Color } from '../../src/core/math/color.js';

import { AnimComponent } from '../../src/framework/components/anim/component.js';
10 changes: 5 additions & 5 deletions utils/plugins/rollup-types-fixup.mjs
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ import { Texture } from '../../platform/graphics/texture.js';
`
}
}, {
path: `${TYPES_PATH}/framework/script/script.d.ts`,
path: `${TYPES_PATH}/framework/script/script-type.d.ts`,
replacement: {
from: 'get enabled(): boolean;',
to: `get enabled(): boolean;
@@ -232,12 +232,12 @@ import { Texture } from '../../platform/graphics/texture.js';
*/
postUpdate?(dt: number): void;
/**
* Called when a Script that already exists in the registry gets redefined. If the new
* Script has a \`swap\` method in its prototype, then it will be executed to perform
* Called when a ScriptType that already exists in the registry gets redefined. If the new
* ScriptType has a \`swap\` method in its prototype, then it will be executed to perform
* hot-reload at runtime.
* @param old - Old instance of the script to copy data to the new instance.
* @param old - Old instance of the scriptType to copy data to the new instance.
*/
swap?(old: Script): void;
swap?(old: ScriptType): void;
`
}
}];

0 comments on commit d39421f

Please sign in to comment.