Skip to content

Commit

Permalink
embedded empty script handler to remove types fixup (#6123)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd authored Mar 7, 2024
1 parent d31a723 commit 67a55f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 46 deletions.
28 changes: 13 additions & 15 deletions src/framework/script/script-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,39 +356,37 @@ class ScriptType extends EventHandler {
}

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

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

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

/**
* @function
* @name ScriptType#[postUpdate]
* @description Called for enabled (running state) scripts on each tick, after update.
* 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) {}

/**
* @function
* @name ScriptType#[swap]
* @description Called when a ScriptType that already exists in the registry
* 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: 0 additions & 31 deletions utils/types-fixup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -525,34 +525,3 @@ 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);

0 comments on commit 67a55f5

Please sign in to comment.