This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

311
node_modules/pixi.js/lib/ticker/Ticker.d.ts generated vendored Normal file
View File

@@ -0,0 +1,311 @@
/**
* A callback which can be added to a ticker.
* ```js
* ticker.add(() => {
* // do something every frame
* });
* ```
* @memberof ticker
*/
export type TickerCallback<T> = (this: T, ticker: Ticker) => any;
/**
* {@link ticker.Ticker|Tickers} provide periodic callbacks based on the system clock.
* Your game update logic will generally be run in response to a tick once per frame.
* You can have multiple tickers in use at one time.
* ```js
* import { Ticker } from 'pixi.js';
*
* const callback = (ticker: Ticker) => {
* // do something on the next animation frame
* };
*
* // create a ticker
* const ticker = new Ticker();
*
* // register the callback and start the ticker
* ticker.add(callback);
* ticker.start();
* ```
*
* You can always use the {@link ticker.Ticker.shared|shared} ticker that Pixi renders with by default.
* ```js
* Ticker.shared.add(callback);
* ```
* @namespace ticker
*/
/**
* A Ticker class that runs an update loop that other objects listen to.
*
* This class is composed around listeners meant for execution on the next requested animation frame.
* Animation frames are requested only when necessary, e.g. When the ticker is started and the emitter has listeners.
* @class
* @memberof ticker
*/
export declare class Ticker {
/**
* Target frames per millisecond.
* @static
*/
static targetFPMS: number;
/** The private shared ticker instance */
private static _shared;
/** The private system ticker instance */
private static _system;
/**
* Whether or not this ticker should invoke the method
* {@link ticker.Ticker#start|start} automatically when a listener is added.
*/
autoStart: boolean;
/**
* Scalar time value from last frame to this frame.
* This value is capped by setting {@link ticker.Ticker#minFPS|minFPS}
* and is scaled with {@link ticker.Ticker#speed|speed}.
* **Note:** The cap may be exceeded by scaling.
*/
deltaTime: number;
/**
* Scalar time elapsed in milliseconds from last frame to this frame.
* This value is capped by setting {@link ticker.Ticker#minFPS|minFPS}
* and is scaled with {@link ticker.Ticker#speed|speed}.
* **Note:** The cap may be exceeded by scaling.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
* Defaults to target frame time
* @default 16.66
*/
deltaMS: number;
/**
* Time elapsed in milliseconds from last frame to this frame.
* Opposed to what the scalar {@link ticker.Ticker#deltaTime|deltaTime}
* is based, this value is neither capped nor scaled.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
* Defaults to target frame time
* @default 16.66
*/
elapsedMS: number;
/**
* The last time {@link ticker.Ticker#update|update} was invoked.
* This value is also reset internally outside of invoking
* update, but only when a new animation frame is requested.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
*/
lastTime: number;
/**
* Factor of current {@link ticker.Ticker#deltaTime|deltaTime}.
* @example
* // Scales ticker.deltaTime to what would be
* // the equivalent of approximately 120 FPS
* ticker.speed = 2;
*/
speed: number;
/**
* Whether or not this ticker has been started.
* `true` if {@link ticker.Ticker#start|start} has been called.
* `false` if {@link ticker.Ticker#stop|Stop} has been called.
* While `false`, this value may change to `true` in the
* event of {@link ticker.Ticker#autoStart|autoStart} being `true`
* and a listener is added.
*/
started: boolean;
/** The first listener. All new listeners added are chained on this. */
private _head;
/** Internal current frame request ID */
private _requestId;
/**
* Internal value managed by minFPS property setter and getter.
* This is the maximum allowed milliseconds between updates.
*/
private _maxElapsedMS;
/**
* Internal value managed by minFPS property setter and getter.
* This is the minimum allowed milliseconds between updates.
*/
private _minElapsedMS;
/** If enabled, deleting is disabled.*/
private _protected;
/** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */
private _lastFrame;
/**
* Internal tick method bound to ticker instance.
* This is because in early 2015, Function.bind
* is still 60% slower in high performance scenarios.
* Also separating frame requests from update method
* so listeners may be called at any time and with
* any animation API, just invoke ticker.update(time).
* @param time - Time since last tick.
*/
private readonly _tick;
constructor();
/**
* Conditionally requests a new animation frame.
* If a frame has not already been requested, and if the internal
* emitter has listeners, a new frame is requested.
* @private
*/
private _requestIfNeeded;
/**
* Conditionally cancels a pending animation frame.
* @private
*/
private _cancelIfNeeded;
/**
* Conditionally requests a new animation frame.
* If the ticker has been started it checks if a frame has not already
* been requested, and if the internal emitter has listeners. If these
* conditions are met, a new frame is requested. If the ticker has not
* been started, but autoStart is `true`, then the ticker starts now,
* and continues with the previous conditions to request a new frame.
* @private
*/
private _startIfPossible;
/**
* Register a handler for tick events. Calls continuously unless
* it is removed or the ticker is stopped.
* @param fn - The listener function to be added for updates
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
add<T = any>(fn: TickerCallback<T>, context?: T, priority?: number): this;
/**
* Add a handler for the tick event which is only execute once.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
addOnce<T = any>(fn: TickerCallback<T>, context?: T, priority?: number): this;
/**
* Internally adds the event handler so that it can be sorted by priority.
* Priority allows certain handler (user, AnimatedSprite, Interaction) to be run
* before the rendering.
* @private
* @param listener - Current listener being added.
* @returns This instance of a ticker
*/
private _addListener;
/**
* Removes any handlers matching the function and context parameters.
* If no handlers are left after removing, then it cancels the animation frame.
* @param fn - The listener function to be removed
* @param context - The listener context to be removed
* @returns This instance of a ticker
*/
remove<T = any>(fn: TickerCallback<T>, context?: T): this;
/**
* The number of listeners on this ticker, calculated by walking through linked list
* @readonly
* @member {number}
*/
get count(): number;
/** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */
start(): void;
/** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */
stop(): void;
/** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */
destroy(): void;
/**
* Triggers an update. An update entails setting the
* current {@link ticker.Ticker#elapsedMS|elapsedMS},
* the current {@link ticker.Ticker#deltaTime|deltaTime},
* invoking all listeners with current deltaTime,
* and then finally setting {@link ticker.Ticker#lastTime|lastTime}
* with the value of currentTime that was provided.
* This method will be called automatically by animation
* frame callbacks if the ticker instance has been started
* and listeners are added.
* @param {number} [currentTime=performance.now()] - the current time of execution
*/
update(currentTime?: number): void;
/**
* The frames per second at which this ticker is running.
* The default is approximately 60 in most modern browsers.
* **Note:** This does not factor in the value of
* {@link ticker.Ticker#speed|speed}, which is specific
* to scaling {@link ticker.Ticker#deltaTime|deltaTime}.
* @member {number}
* @readonly
*/
get FPS(): number;
/**
* Manages the maximum amount of milliseconds allowed to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This value is used to cap {@link ticker.Ticker#deltaTime|deltaTime},
* but does not effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* When setting this property it is clamped to a value between
* `0` and `Ticker.targetFPMS * 1000`.
* @member {number}
* @default 10
*/
get minFPS(): number;
set minFPS(fps: number);
/**
* Manages the minimum amount of milliseconds required to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This will effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
* Otherwise it will be at least `minFPS`
* @member {number}
* @default 0
*/
get maxFPS(): number;
set maxFPS(fps: number);
/**
* The shared ticker instance used by {@link AnimatedSprite} and by
* {@link VideoResource} to update animation frames / video textures.
*
* It may also be used by {@link Application} if created with the `sharedTicker` option property set to true.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.
* @example
* import { Ticker } from 'pixi.js';
*
* const ticker = Ticker.shared;
* // Set this to prevent starting this ticker when listeners are added.
* // By default this is true only for the Ticker.shared instance.
* ticker.autoStart = false;
*
* // FYI, call this to ensure the ticker is stopped. It should be stopped
* // if you have not attempted to render anything yet.
* ticker.stop();
*
* // Call this when you are ready for a running shared ticker.
* ticker.start();
* @example
* import { autoDetectRenderer, Container } from 'pixi.js';
*
* // You may use the shared ticker to render...
* const renderer = autoDetectRenderer();
* const stage = new Container();
* document.body.appendChild(renderer.view);
* ticker.add((time) => renderer.render(stage));
*
* // Or you can just update it manually.
* ticker.autoStart = false;
* ticker.stop();
* const animate = (time) => {
* ticker.update(time);
* renderer.render(stage);
* requestAnimationFrame(animate);
* };
* animate(performance.now());
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get shared(): Ticker;
/**
* The system ticker instance used by {@link BasePrepare} for core timing
* functionality that shouldn't usually need to be paused, unlike the `shared`
* ticker which drives visual animations and rendering which may want to be paused.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get system(): Ticker;
}

401
node_modules/pixi.js/lib/ticker/Ticker.js generated vendored Normal file
View File

@@ -0,0 +1,401 @@
'use strict';
var _const = require('./const.js');
var TickerListener = require('./TickerListener.js');
"use strict";
const _Ticker = class _Ticker {
constructor() {
/**
* Whether or not this ticker should invoke the method
* {@link ticker.Ticker#start|start} automatically when a listener is added.
*/
this.autoStart = false;
/**
* Scalar time value from last frame to this frame.
* This value is capped by setting {@link ticker.Ticker#minFPS|minFPS}
* and is scaled with {@link ticker.Ticker#speed|speed}.
* **Note:** The cap may be exceeded by scaling.
*/
this.deltaTime = 1;
/**
* The last time {@link ticker.Ticker#update|update} was invoked.
* This value is also reset internally outside of invoking
* update, but only when a new animation frame is requested.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
*/
this.lastTime = -1;
/**
* Factor of current {@link ticker.Ticker#deltaTime|deltaTime}.
* @example
* // Scales ticker.deltaTime to what would be
* // the equivalent of approximately 120 FPS
* ticker.speed = 2;
*/
this.speed = 1;
/**
* Whether or not this ticker has been started.
* `true` if {@link ticker.Ticker#start|start} has been called.
* `false` if {@link ticker.Ticker#stop|Stop} has been called.
* While `false`, this value may change to `true` in the
* event of {@link ticker.Ticker#autoStart|autoStart} being `true`
* and a listener is added.
*/
this.started = false;
/** Internal current frame request ID */
this._requestId = null;
/**
* Internal value managed by minFPS property setter and getter.
* This is the maximum allowed milliseconds between updates.
*/
this._maxElapsedMS = 100;
/**
* Internal value managed by minFPS property setter and getter.
* This is the minimum allowed milliseconds between updates.
*/
this._minElapsedMS = 0;
/** If enabled, deleting is disabled.*/
this._protected = false;
/** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */
this._lastFrame = -1;
this._head = new TickerListener.TickerListener(null, null, Infinity);
this.deltaMS = 1 / _Ticker.targetFPMS;
this.elapsedMS = 1 / _Ticker.targetFPMS;
this._tick = (time) => {
this._requestId = null;
if (this.started) {
this.update(time);
if (this.started && this._requestId === null && this._head.next) {
this._requestId = requestAnimationFrame(this._tick);
}
}
};
}
/**
* Conditionally requests a new animation frame.
* If a frame has not already been requested, and if the internal
* emitter has listeners, a new frame is requested.
* @private
*/
_requestIfNeeded() {
if (this._requestId === null && this._head.next) {
this.lastTime = performance.now();
this._lastFrame = this.lastTime;
this._requestId = requestAnimationFrame(this._tick);
}
}
/**
* Conditionally cancels a pending animation frame.
* @private
*/
_cancelIfNeeded() {
if (this._requestId !== null) {
cancelAnimationFrame(this._requestId);
this._requestId = null;
}
}
/**
* Conditionally requests a new animation frame.
* If the ticker has been started it checks if a frame has not already
* been requested, and if the internal emitter has listeners. If these
* conditions are met, a new frame is requested. If the ticker has not
* been started, but autoStart is `true`, then the ticker starts now,
* and continues with the previous conditions to request a new frame.
* @private
*/
_startIfPossible() {
if (this.started) {
this._requestIfNeeded();
} else if (this.autoStart) {
this.start();
}
}
/**
* Register a handler for tick events. Calls continuously unless
* it is removed or the ticker is stopped.
* @param fn - The listener function to be added for updates
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
add(fn, context, priority = _const.UPDATE_PRIORITY.NORMAL) {
return this._addListener(new TickerListener.TickerListener(fn, context, priority));
}
/**
* Add a handler for the tick event which is only execute once.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
addOnce(fn, context, priority = _const.UPDATE_PRIORITY.NORMAL) {
return this._addListener(new TickerListener.TickerListener(fn, context, priority, true));
}
/**
* Internally adds the event handler so that it can be sorted by priority.
* Priority allows certain handler (user, AnimatedSprite, Interaction) to be run
* before the rendering.
* @private
* @param listener - Current listener being added.
* @returns This instance of a ticker
*/
_addListener(listener) {
let current = this._head.next;
let previous = this._head;
if (!current) {
listener.connect(previous);
} else {
while (current) {
if (listener.priority > current.priority) {
listener.connect(previous);
break;
}
previous = current;
current = current.next;
}
if (!listener.previous) {
listener.connect(previous);
}
}
this._startIfPossible();
return this;
}
/**
* Removes any handlers matching the function and context parameters.
* If no handlers are left after removing, then it cancels the animation frame.
* @param fn - The listener function to be removed
* @param context - The listener context to be removed
* @returns This instance of a ticker
*/
remove(fn, context) {
let listener = this._head.next;
while (listener) {
if (listener.match(fn, context)) {
listener = listener.destroy();
} else {
listener = listener.next;
}
}
if (!this._head.next) {
this._cancelIfNeeded();
}
return this;
}
/**
* The number of listeners on this ticker, calculated by walking through linked list
* @readonly
* @member {number}
*/
get count() {
if (!this._head) {
return 0;
}
let count = 0;
let current = this._head;
while (current = current.next) {
count++;
}
return count;
}
/** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */
start() {
if (!this.started) {
this.started = true;
this._requestIfNeeded();
}
}
/** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */
stop() {
if (this.started) {
this.started = false;
this._cancelIfNeeded();
}
}
/** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */
destroy() {
if (!this._protected) {
this.stop();
let listener = this._head.next;
while (listener) {
listener = listener.destroy(true);
}
this._head.destroy();
this._head = null;
}
}
/**
* Triggers an update. An update entails setting the
* current {@link ticker.Ticker#elapsedMS|elapsedMS},
* the current {@link ticker.Ticker#deltaTime|deltaTime},
* invoking all listeners with current deltaTime,
* and then finally setting {@link ticker.Ticker#lastTime|lastTime}
* with the value of currentTime that was provided.
* This method will be called automatically by animation
* frame callbacks if the ticker instance has been started
* and listeners are added.
* @param {number} [currentTime=performance.now()] - the current time of execution
*/
update(currentTime = performance.now()) {
let elapsedMS;
if (currentTime > this.lastTime) {
elapsedMS = this.elapsedMS = currentTime - this.lastTime;
if (elapsedMS > this._maxElapsedMS) {
elapsedMS = this._maxElapsedMS;
}
elapsedMS *= this.speed;
if (this._minElapsedMS) {
const delta = currentTime - this._lastFrame | 0;
if (delta < this._minElapsedMS) {
return;
}
this._lastFrame = currentTime - delta % this._minElapsedMS;
}
this.deltaMS = elapsedMS;
this.deltaTime = this.deltaMS * _Ticker.targetFPMS;
const head = this._head;
let listener = head.next;
while (listener) {
listener = listener.emit(this);
}
if (!head.next) {
this._cancelIfNeeded();
}
} else {
this.deltaTime = this.deltaMS = this.elapsedMS = 0;
}
this.lastTime = currentTime;
}
/**
* The frames per second at which this ticker is running.
* The default is approximately 60 in most modern browsers.
* **Note:** This does not factor in the value of
* {@link ticker.Ticker#speed|speed}, which is specific
* to scaling {@link ticker.Ticker#deltaTime|deltaTime}.
* @member {number}
* @readonly
*/
get FPS() {
return 1e3 / this.elapsedMS;
}
/**
* Manages the maximum amount of milliseconds allowed to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This value is used to cap {@link ticker.Ticker#deltaTime|deltaTime},
* but does not effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* When setting this property it is clamped to a value between
* `0` and `Ticker.targetFPMS * 1000`.
* @member {number}
* @default 10
*/
get minFPS() {
return 1e3 / this._maxElapsedMS;
}
set minFPS(fps) {
const minFPS = Math.min(this.maxFPS, fps);
const minFPMS = Math.min(Math.max(0, minFPS) / 1e3, _Ticker.targetFPMS);
this._maxElapsedMS = 1 / minFPMS;
}
/**
* Manages the minimum amount of milliseconds required to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This will effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
* Otherwise it will be at least `minFPS`
* @member {number}
* @default 0
*/
get maxFPS() {
if (this._minElapsedMS) {
return Math.round(1e3 / this._minElapsedMS);
}
return 0;
}
set maxFPS(fps) {
if (fps === 0) {
this._minElapsedMS = 0;
} else {
const maxFPS = Math.max(this.minFPS, fps);
this._minElapsedMS = 1 / (maxFPS / 1e3);
}
}
/**
* The shared ticker instance used by {@link AnimatedSprite} and by
* {@link VideoResource} to update animation frames / video textures.
*
* It may also be used by {@link Application} if created with the `sharedTicker` option property set to true.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.
* @example
* import { Ticker } from 'pixi.js';
*
* const ticker = Ticker.shared;
* // Set this to prevent starting this ticker when listeners are added.
* // By default this is true only for the Ticker.shared instance.
* ticker.autoStart = false;
*
* // FYI, call this to ensure the ticker is stopped. It should be stopped
* // if you have not attempted to render anything yet.
* ticker.stop();
*
* // Call this when you are ready for a running shared ticker.
* ticker.start();
* @example
* import { autoDetectRenderer, Container } from 'pixi.js';
*
* // You may use the shared ticker to render...
* const renderer = autoDetectRenderer();
* const stage = new Container();
* document.body.appendChild(renderer.view);
* ticker.add((time) => renderer.render(stage));
*
* // Or you can just update it manually.
* ticker.autoStart = false;
* ticker.stop();
* const animate = (time) => {
* ticker.update(time);
* renderer.render(stage);
* requestAnimationFrame(animate);
* };
* animate(performance.now());
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get shared() {
if (!_Ticker._shared) {
const shared = _Ticker._shared = new _Ticker();
shared.autoStart = true;
shared._protected = true;
}
return _Ticker._shared;
}
/**
* The system ticker instance used by {@link BasePrepare} for core timing
* functionality that shouldn't usually need to be paused, unlike the `shared`
* ticker which drives visual animations and rendering which may want to be paused.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get system() {
if (!_Ticker._system) {
const system = _Ticker._system = new _Ticker();
system.autoStart = true;
system._protected = true;
}
return _Ticker._system;
}
};
/**
* Target frames per millisecond.
* @static
*/
_Ticker.targetFPMS = 0.06;
let Ticker = _Ticker;
exports.Ticker = Ticker;
//# sourceMappingURL=Ticker.js.map

1
node_modules/pixi.js/lib/ticker/Ticker.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

399
node_modules/pixi.js/lib/ticker/Ticker.mjs generated vendored Normal file
View File

@@ -0,0 +1,399 @@
import { UPDATE_PRIORITY } from './const.mjs';
import { TickerListener } from './TickerListener.mjs';
"use strict";
const _Ticker = class _Ticker {
constructor() {
/**
* Whether or not this ticker should invoke the method
* {@link ticker.Ticker#start|start} automatically when a listener is added.
*/
this.autoStart = false;
/**
* Scalar time value from last frame to this frame.
* This value is capped by setting {@link ticker.Ticker#minFPS|minFPS}
* and is scaled with {@link ticker.Ticker#speed|speed}.
* **Note:** The cap may be exceeded by scaling.
*/
this.deltaTime = 1;
/**
* The last time {@link ticker.Ticker#update|update} was invoked.
* This value is also reset internally outside of invoking
* update, but only when a new animation frame is requested.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
*/
this.lastTime = -1;
/**
* Factor of current {@link ticker.Ticker#deltaTime|deltaTime}.
* @example
* // Scales ticker.deltaTime to what would be
* // the equivalent of approximately 120 FPS
* ticker.speed = 2;
*/
this.speed = 1;
/**
* Whether or not this ticker has been started.
* `true` if {@link ticker.Ticker#start|start} has been called.
* `false` if {@link ticker.Ticker#stop|Stop} has been called.
* While `false`, this value may change to `true` in the
* event of {@link ticker.Ticker#autoStart|autoStart} being `true`
* and a listener is added.
*/
this.started = false;
/** Internal current frame request ID */
this._requestId = null;
/**
* Internal value managed by minFPS property setter and getter.
* This is the maximum allowed milliseconds between updates.
*/
this._maxElapsedMS = 100;
/**
* Internal value managed by minFPS property setter and getter.
* This is the minimum allowed milliseconds between updates.
*/
this._minElapsedMS = 0;
/** If enabled, deleting is disabled.*/
this._protected = false;
/** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */
this._lastFrame = -1;
this._head = new TickerListener(null, null, Infinity);
this.deltaMS = 1 / _Ticker.targetFPMS;
this.elapsedMS = 1 / _Ticker.targetFPMS;
this._tick = (time) => {
this._requestId = null;
if (this.started) {
this.update(time);
if (this.started && this._requestId === null && this._head.next) {
this._requestId = requestAnimationFrame(this._tick);
}
}
};
}
/**
* Conditionally requests a new animation frame.
* If a frame has not already been requested, and if the internal
* emitter has listeners, a new frame is requested.
* @private
*/
_requestIfNeeded() {
if (this._requestId === null && this._head.next) {
this.lastTime = performance.now();
this._lastFrame = this.lastTime;
this._requestId = requestAnimationFrame(this._tick);
}
}
/**
* Conditionally cancels a pending animation frame.
* @private
*/
_cancelIfNeeded() {
if (this._requestId !== null) {
cancelAnimationFrame(this._requestId);
this._requestId = null;
}
}
/**
* Conditionally requests a new animation frame.
* If the ticker has been started it checks if a frame has not already
* been requested, and if the internal emitter has listeners. If these
* conditions are met, a new frame is requested. If the ticker has not
* been started, but autoStart is `true`, then the ticker starts now,
* and continues with the previous conditions to request a new frame.
* @private
*/
_startIfPossible() {
if (this.started) {
this._requestIfNeeded();
} else if (this.autoStart) {
this.start();
}
}
/**
* Register a handler for tick events. Calls continuously unless
* it is removed or the ticker is stopped.
* @param fn - The listener function to be added for updates
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
add(fn, context, priority = UPDATE_PRIORITY.NORMAL) {
return this._addListener(new TickerListener(fn, context, priority));
}
/**
* Add a handler for the tick event which is only execute once.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param {number} [priority=UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns This instance of a ticker
*/
addOnce(fn, context, priority = UPDATE_PRIORITY.NORMAL) {
return this._addListener(new TickerListener(fn, context, priority, true));
}
/**
* Internally adds the event handler so that it can be sorted by priority.
* Priority allows certain handler (user, AnimatedSprite, Interaction) to be run
* before the rendering.
* @private
* @param listener - Current listener being added.
* @returns This instance of a ticker
*/
_addListener(listener) {
let current = this._head.next;
let previous = this._head;
if (!current) {
listener.connect(previous);
} else {
while (current) {
if (listener.priority > current.priority) {
listener.connect(previous);
break;
}
previous = current;
current = current.next;
}
if (!listener.previous) {
listener.connect(previous);
}
}
this._startIfPossible();
return this;
}
/**
* Removes any handlers matching the function and context parameters.
* If no handlers are left after removing, then it cancels the animation frame.
* @param fn - The listener function to be removed
* @param context - The listener context to be removed
* @returns This instance of a ticker
*/
remove(fn, context) {
let listener = this._head.next;
while (listener) {
if (listener.match(fn, context)) {
listener = listener.destroy();
} else {
listener = listener.next;
}
}
if (!this._head.next) {
this._cancelIfNeeded();
}
return this;
}
/**
* The number of listeners on this ticker, calculated by walking through linked list
* @readonly
* @member {number}
*/
get count() {
if (!this._head) {
return 0;
}
let count = 0;
let current = this._head;
while (current = current.next) {
count++;
}
return count;
}
/** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */
start() {
if (!this.started) {
this.started = true;
this._requestIfNeeded();
}
}
/** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */
stop() {
if (this.started) {
this.started = false;
this._cancelIfNeeded();
}
}
/** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */
destroy() {
if (!this._protected) {
this.stop();
let listener = this._head.next;
while (listener) {
listener = listener.destroy(true);
}
this._head.destroy();
this._head = null;
}
}
/**
* Triggers an update. An update entails setting the
* current {@link ticker.Ticker#elapsedMS|elapsedMS},
* the current {@link ticker.Ticker#deltaTime|deltaTime},
* invoking all listeners with current deltaTime,
* and then finally setting {@link ticker.Ticker#lastTime|lastTime}
* with the value of currentTime that was provided.
* This method will be called automatically by animation
* frame callbacks if the ticker instance has been started
* and listeners are added.
* @param {number} [currentTime=performance.now()] - the current time of execution
*/
update(currentTime = performance.now()) {
let elapsedMS;
if (currentTime > this.lastTime) {
elapsedMS = this.elapsedMS = currentTime - this.lastTime;
if (elapsedMS > this._maxElapsedMS) {
elapsedMS = this._maxElapsedMS;
}
elapsedMS *= this.speed;
if (this._minElapsedMS) {
const delta = currentTime - this._lastFrame | 0;
if (delta < this._minElapsedMS) {
return;
}
this._lastFrame = currentTime - delta % this._minElapsedMS;
}
this.deltaMS = elapsedMS;
this.deltaTime = this.deltaMS * _Ticker.targetFPMS;
const head = this._head;
let listener = head.next;
while (listener) {
listener = listener.emit(this);
}
if (!head.next) {
this._cancelIfNeeded();
}
} else {
this.deltaTime = this.deltaMS = this.elapsedMS = 0;
}
this.lastTime = currentTime;
}
/**
* The frames per second at which this ticker is running.
* The default is approximately 60 in most modern browsers.
* **Note:** This does not factor in the value of
* {@link ticker.Ticker#speed|speed}, which is specific
* to scaling {@link ticker.Ticker#deltaTime|deltaTime}.
* @member {number}
* @readonly
*/
get FPS() {
return 1e3 / this.elapsedMS;
}
/**
* Manages the maximum amount of milliseconds allowed to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This value is used to cap {@link ticker.Ticker#deltaTime|deltaTime},
* but does not effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* When setting this property it is clamped to a value between
* `0` and `Ticker.targetFPMS * 1000`.
* @member {number}
* @default 10
*/
get minFPS() {
return 1e3 / this._maxElapsedMS;
}
set minFPS(fps) {
const minFPS = Math.min(this.maxFPS, fps);
const minFPMS = Math.min(Math.max(0, minFPS) / 1e3, _Ticker.targetFPMS);
this._maxElapsedMS = 1 / minFPMS;
}
/**
* Manages the minimum amount of milliseconds required to
* elapse between invoking {@link ticker.Ticker#update|update}.
* This will effect the measured value of {@link ticker.Ticker#FPS|FPS}.
* If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
* Otherwise it will be at least `minFPS`
* @member {number}
* @default 0
*/
get maxFPS() {
if (this._minElapsedMS) {
return Math.round(1e3 / this._minElapsedMS);
}
return 0;
}
set maxFPS(fps) {
if (fps === 0) {
this._minElapsedMS = 0;
} else {
const maxFPS = Math.max(this.minFPS, fps);
this._minElapsedMS = 1 / (maxFPS / 1e3);
}
}
/**
* The shared ticker instance used by {@link AnimatedSprite} and by
* {@link VideoResource} to update animation frames / video textures.
*
* It may also be used by {@link Application} if created with the `sharedTicker` option property set to true.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.
* @example
* import { Ticker } from 'pixi.js';
*
* const ticker = Ticker.shared;
* // Set this to prevent starting this ticker when listeners are added.
* // By default this is true only for the Ticker.shared instance.
* ticker.autoStart = false;
*
* // FYI, call this to ensure the ticker is stopped. It should be stopped
* // if you have not attempted to render anything yet.
* ticker.stop();
*
* // Call this when you are ready for a running shared ticker.
* ticker.start();
* @example
* import { autoDetectRenderer, Container } from 'pixi.js';
*
* // You may use the shared ticker to render...
* const renderer = autoDetectRenderer();
* const stage = new Container();
* document.body.appendChild(renderer.view);
* ticker.add((time) => renderer.render(stage));
*
* // Or you can just update it manually.
* ticker.autoStart = false;
* ticker.stop();
* const animate = (time) => {
* ticker.update(time);
* renderer.render(stage);
* requestAnimationFrame(animate);
* };
* animate(performance.now());
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get shared() {
if (!_Ticker._shared) {
const shared = _Ticker._shared = new _Ticker();
shared.autoStart = true;
shared._protected = true;
}
return _Ticker._shared;
}
/**
* The system ticker instance used by {@link BasePrepare} for core timing
* functionality that shouldn't usually need to be paused, unlike the `shared`
* ticker which drives visual animations and rendering which may want to be paused.
*
* The property {@link ticker.Ticker#autoStart|autoStart} is set to `true` for this instance.
* @member {ticker.Ticker}
* @readonly
* @static
*/
static get system() {
if (!_Ticker._system) {
const system = _Ticker._system = new _Ticker();
system.autoStart = true;
system._protected = true;
}
return _Ticker._system;
}
};
/**
* Target frames per millisecond.
* @static
*/
_Ticker.targetFPMS = 0.06;
let Ticker = _Ticker;
export { Ticker };
//# sourceMappingURL=Ticker.mjs.map

1
node_modules/pixi.js/lib/ticker/Ticker.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

56
node_modules/pixi.js/lib/ticker/TickerListener.d.ts generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import type { Ticker, TickerCallback } from './Ticker';
/**
* Internal class for handling the priority sorting of ticker handlers.
* @private
* @class
*/
export declare class TickerListener<T = any> {
/** The current priority. */
priority: number;
/** The next item in chain. */
next: TickerListener;
/** The previous item in chain. */
previous: TickerListener;
/** The handler function to execute. */
private _fn;
/** The calling to execute. */
private _context;
/** If this should only execute once. */
private readonly _once;
/** `true` if this listener has been destroyed already. */
private _destroyed;
/**
* Constructor
* @private
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param priority - The priority for emitting
* @param once - If the handler should fire once
*/
constructor(fn: TickerCallback<T>, context?: T, priority?: number, once?: boolean);
/**
* Simple compare function to figure out if a function and context match.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @returns `true` if the listener match the arguments
*/
match(fn: TickerCallback<T>, context?: any): boolean;
/**
* Emit by calling the current function.
* @param ticker - The ticker emitting.
* @returns Next ticker
*/
emit(ticker: Ticker): TickerListener;
/**
* Connect to the list.
* @param previous - Input node, previous listener
*/
connect(previous: TickerListener): void;
/**
* Destroy and don't use after this.
* @param hard - `true` to remove the `next` reference, this
* is considered a hard destroy. Soft destroy maintains the next reference.
* @returns The listener to redirect while emitting or removing.
*/
destroy(hard?: boolean): TickerListener;
}

92
node_modules/pixi.js/lib/ticker/TickerListener.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
'use strict';
"use strict";
class TickerListener {
/**
* Constructor
* @private
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param priority - The priority for emitting
* @param once - If the handler should fire once
*/
constructor(fn, context = null, priority = 0, once = false) {
/** The next item in chain. */
this.next = null;
/** The previous item in chain. */
this.previous = null;
/** `true` if this listener has been destroyed already. */
this._destroyed = false;
this._fn = fn;
this._context = context;
this.priority = priority;
this._once = once;
}
/**
* Simple compare function to figure out if a function and context match.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @returns `true` if the listener match the arguments
*/
match(fn, context = null) {
return this._fn === fn && this._context === context;
}
/**
* Emit by calling the current function.
* @param ticker - The ticker emitting.
* @returns Next ticker
*/
emit(ticker) {
if (this._fn) {
if (this._context) {
this._fn.call(this._context, ticker);
} else {
this._fn(ticker);
}
}
const redirect = this.next;
if (this._once) {
this.destroy(true);
}
if (this._destroyed) {
this.next = null;
}
return redirect;
}
/**
* Connect to the list.
* @param previous - Input node, previous listener
*/
connect(previous) {
this.previous = previous;
if (previous.next) {
previous.next.previous = this;
}
this.next = previous.next;
previous.next = this;
}
/**
* Destroy and don't use after this.
* @param hard - `true` to remove the `next` reference, this
* is considered a hard destroy. Soft destroy maintains the next reference.
* @returns The listener to redirect while emitting or removing.
*/
destroy(hard = false) {
this._destroyed = true;
this._fn = null;
this._context = null;
if (this.previous) {
this.previous.next = this.next;
}
if (this.next) {
this.next.previous = this.previous;
}
const redirect = this.next;
this.next = hard ? null : redirect;
this.previous = null;
return redirect;
}
}
exports.TickerListener = TickerListener;
//# sourceMappingURL=TickerListener.js.map

File diff suppressed because one or more lines are too long

90
node_modules/pixi.js/lib/ticker/TickerListener.mjs generated vendored Normal file
View File

@@ -0,0 +1,90 @@
"use strict";
class TickerListener {
/**
* Constructor
* @private
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @param priority - The priority for emitting
* @param once - If the handler should fire once
*/
constructor(fn, context = null, priority = 0, once = false) {
/** The next item in chain. */
this.next = null;
/** The previous item in chain. */
this.previous = null;
/** `true` if this listener has been destroyed already. */
this._destroyed = false;
this._fn = fn;
this._context = context;
this.priority = priority;
this._once = once;
}
/**
* Simple compare function to figure out if a function and context match.
* @param fn - The listener function to be added for one update
* @param context - The listener context
* @returns `true` if the listener match the arguments
*/
match(fn, context = null) {
return this._fn === fn && this._context === context;
}
/**
* Emit by calling the current function.
* @param ticker - The ticker emitting.
* @returns Next ticker
*/
emit(ticker) {
if (this._fn) {
if (this._context) {
this._fn.call(this._context, ticker);
} else {
this._fn(ticker);
}
}
const redirect = this.next;
if (this._once) {
this.destroy(true);
}
if (this._destroyed) {
this.next = null;
}
return redirect;
}
/**
* Connect to the list.
* @param previous - Input node, previous listener
*/
connect(previous) {
this.previous = previous;
if (previous.next) {
previous.next.previous = this;
}
this.next = previous.next;
previous.next = this;
}
/**
* Destroy and don't use after this.
* @param hard - `true` to remove the `next` reference, this
* is considered a hard destroy. Soft destroy maintains the next reference.
* @returns The listener to redirect while emitting or removing.
*/
destroy(hard = false) {
this._destroyed = true;
this._fn = null;
this._context = null;
if (this.previous) {
this.previous.next = this.next;
}
if (this.next) {
this.next.previous = this.previous;
}
const redirect = this.next;
this.next = hard ? null : redirect;
this.previous = null;
return redirect;
}
}
export { TickerListener };
//# sourceMappingURL=TickerListener.mjs.map

File diff suppressed because one or more lines are too long

35
node_modules/pixi.js/lib/ticker/const.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/**
* Represents the update priorities used by internal Pixi classes when registered with
* the {@link ticker.Ticker} object. Higher priority items are updated first and lower
* priority items, such as render, should go later.
* @static
* @enum {number}
* @memberof ticker
*/
export declare enum UPDATE_PRIORITY {
/**
* Highest priority used for interaction events in {@link EventSystem}
* @default 50
*/
INTERACTION = 50,
/**
* High priority updating, used by {@link AnimatedSprite}
* @default 25
*/
HIGH = 25,
/**
* Default priority for ticker events, see {@link Ticker#add}.
* @default 0
*/
NORMAL = 0,
/**
* Low priority used for {@link Application} rendering.
* @default -25
*/
LOW = -25,
/**
* Lowest priority used for {@link BasePrepare} utility.
* @default -50
*/
UTILITY = -50
}

14
node_modules/pixi.js/lib/ticker/const.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
'use strict';
"use strict";
var UPDATE_PRIORITY = /* @__PURE__ */ ((UPDATE_PRIORITY2) => {
UPDATE_PRIORITY2[UPDATE_PRIORITY2["INTERACTION"] = 50] = "INTERACTION";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["HIGH"] = 25] = "HIGH";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["NORMAL"] = 0] = "NORMAL";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["LOW"] = -25] = "LOW";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["UTILITY"] = -50] = "UTILITY";
return UPDATE_PRIORITY2;
})(UPDATE_PRIORITY || {});
exports.UPDATE_PRIORITY = UPDATE_PRIORITY;
//# sourceMappingURL=const.js.map

1
node_modules/pixi.js/lib/ticker/const.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"const.js","sources":["../../src/ticker/const.ts"],"sourcesContent":["/**\n * Represents the update priorities used by internal Pixi classes when registered with\n * the {@link ticker.Ticker} object. Higher priority items are updated first and lower\n * priority items, such as render, should go later.\n * @static\n * @enum {number}\n * @memberof ticker\n */\nexport enum UPDATE_PRIORITY\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Highest priority used for interaction events in {@link EventSystem}\n * @default 50\n */\n INTERACTION = 50,\n /**\n * High priority updating, used by {@link AnimatedSprite}\n * @default 25\n */\n HIGH = 25,\n /**\n * Default priority for ticker events, see {@link Ticker#add}.\n * @default 0\n */\n NORMAL = 0,\n /**\n * Low priority used for {@link Application} rendering.\n * @default -25\n */\n LOW = -25,\n /**\n * Lowest priority used for {@link BasePrepare} utility.\n * @default -50\n */\n UTILITY = -50,\n}\n"],"names":["UPDATE_PRIORITY"],"mappings":";;;AAQY,IAAA,eAAA,qBAAAA,gBAAL,KAAA;AAOH,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,UAAO,EAAP,CAAA,GAAA,MAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,YAAS,CAAT,CAAA,GAAA,QAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,SAAM,CAAN,EAAA,CAAA,GAAA,KAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,aAAU,CAAV,EAAA,CAAA,GAAA,SAAA,CAAA;AA3BQ,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;;;"}

12
node_modules/pixi.js/lib/ticker/const.mjs generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
var UPDATE_PRIORITY = /* @__PURE__ */ ((UPDATE_PRIORITY2) => {
UPDATE_PRIORITY2[UPDATE_PRIORITY2["INTERACTION"] = 50] = "INTERACTION";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["HIGH"] = 25] = "HIGH";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["NORMAL"] = 0] = "NORMAL";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["LOW"] = -25] = "LOW";
UPDATE_PRIORITY2[UPDATE_PRIORITY2["UTILITY"] = -50] = "UTILITY";
return UPDATE_PRIORITY2;
})(UPDATE_PRIORITY || {});
export { UPDATE_PRIORITY };
//# sourceMappingURL=const.mjs.map

1
node_modules/pixi.js/lib/ticker/const.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"const.mjs","sources":["../../src/ticker/const.ts"],"sourcesContent":["/**\n * Represents the update priorities used by internal Pixi classes when registered with\n * the {@link ticker.Ticker} object. Higher priority items are updated first and lower\n * priority items, such as render, should go later.\n * @static\n * @enum {number}\n * @memberof ticker\n */\nexport enum UPDATE_PRIORITY\n// eslint-disable-next-line @typescript-eslint/indent\n{\n /**\n * Highest priority used for interaction events in {@link EventSystem}\n * @default 50\n */\n INTERACTION = 50,\n /**\n * High priority updating, used by {@link AnimatedSprite}\n * @default 25\n */\n HIGH = 25,\n /**\n * Default priority for ticker events, see {@link Ticker#add}.\n * @default 0\n */\n NORMAL = 0,\n /**\n * Low priority used for {@link Application} rendering.\n * @default -25\n */\n LOW = -25,\n /**\n * Lowest priority used for {@link BasePrepare} utility.\n * @default -50\n */\n UTILITY = -50,\n}\n"],"names":["UPDATE_PRIORITY"],"mappings":";AAQY,IAAA,eAAA,qBAAAA,gBAAL,KAAA;AAOH,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,UAAO,EAAP,CAAA,GAAA,MAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,YAAS,CAAT,CAAA,GAAA,QAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,SAAM,CAAN,EAAA,CAAA,GAAA,KAAA,CAAA;AAKA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,aAAU,CAAV,EAAA,CAAA,GAAA,SAAA,CAAA;AA3BQ,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;;;"}

3
node_modules/pixi.js/lib/ticker/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export * from './const';
export * from './Ticker';
export * from './TickerListener';

12
node_modules/pixi.js/lib/ticker/index.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict';
var _const = require('./const.js');
var Ticker = require('./Ticker.js');
var TickerListener = require('./TickerListener.js');
"use strict";
exports.UPDATE_PRIORITY = _const.UPDATE_PRIORITY;
exports.Ticker = Ticker.Ticker;
exports.TickerListener = TickerListener.TickerListener;
//# sourceMappingURL=index.js.map

1
node_modules/pixi.js/lib/ticker/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}

6
node_modules/pixi.js/lib/ticker/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export { UPDATE_PRIORITY } from './const.mjs';
export { Ticker } from './Ticker.mjs';
export { TickerListener } from './TickerListener.mjs';
"use strict";
//# sourceMappingURL=index.mjs.map

1
node_modules/pixi.js/lib/ticker/index.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}