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

Revert "ScriptType handlers type fix" #6125

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 15 additions & 13 deletions src/framework/script/script-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,37 +356,39 @@ class ScriptType extends EventHandler {
}

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

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

/**
* Called for enabled (running state) scripts on each tick.
*
* @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.
*/
update(dt) {}

/**
* Called for enabled (running state) scripts on each tick, after update.
*
* @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.
*/
postUpdate(dt) {}

/**
* Called when a ScriptType that already exists in the registry
* @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.
*/
swap(old) {}
}

export { ScriptType };
31 changes: 31 additions & 0 deletions utils/types-fixup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,34 @@ import { BoundingBox } from '../../core/shape/bounding-box.js';
import { Texture } from '../../platform/graphics/texture.js';
`;
fs.writeFileSync(path, dts);

path = './types/framework/script/script-type.d.ts';
dts = fs.readFileSync(path, 'utf8');
dts = dts.replace('get enabled(): boolean;', `get enabled(): boolean;
/**
* Called when script is about to run for the first time.
*/
initialize?(): void;
/**
* Called after all initialize methods are executed in the same tick or enabling chain of actions.
*/
postInitialize?(): void;
/**
* Called for enabled (running state) scripts on each tick.
* @param dt - The delta time in seconds since the last frame.
*/
update?(dt: number): void;
/**
* Called for enabled (running state) scripts on each tick, after update.
* @param dt - The delta time in seconds since the last frame.
*/
postUpdate?(dt: number): void;
/**
* 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 scriptType to copy data to the new instance.
*/
swap?(old: ScriptType): void;
`);
fs.writeFileSync(path, dts);