Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/app

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/app - npm Package Compare versions

Comparing version 5.2.4 to 5.3.0

362

dist/app.js
/*!
* @pixi/app - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/app - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -30,105 +30,122 @@ * @pixi/app is licensed under the MIT License.

*/
var Application = function Application(options)
{
var this$1 = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
var Application = /** @class */ (function () {
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
* @param {object} [options] - The optional renderer parameters.
* @param {boolean} [options.autoStart=true] - Automatically starts the rendering after the construction.
* **Note**: Setting this parameter to false does NOT stop the shared ticker even if you set
* options.sharedTicker to true in case that it is already started. Stop it by your own.
* @param {number} [options.width=800] - The width of the renderers view.
* @param {number} [options.height=600] - The height of the renderers view.
* @param {HTMLCanvasElement} [options.view] - The canvas to use as a view, optional.
* @param {boolean} [options.transparent=false] - If the render view is transparent.
* @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for
* resolutions other than 1.
* @param {boolean} [options.antialias=false] - Sets antialias
* @param {boolean} [options.preserveDrawingBuffer=false] - Enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the WebGL context.
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2.
* @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present, this
* option only is available when using **pixi.js-legacy** or **@pixi/canvas-renderer** modules, otherwise
* it is ignored.
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card. **(WebGL only)**.
* @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.Ticker.shared, `false` to create new ticker.
* If set to false, you cannot register a handler to occur before anything that runs on the shared ticker.
* The system ticker will always run before both the shared ticker and the app ticker.
* @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.Loader.shared, `false` to create new Loader.
* @param {Window|HTMLElement} [options.resizeTo] - Element to automatically resize stage to.
*/
this.renderer = core.autoDetectRenderer(options);
function Application(options) {
var _this = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
*/
this.renderer = core.autoDetectRenderer(options);
/**
* The root display container that's rendered.
* @member {PIXI.Container}
*/
this.stage = new display.Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(_this, options);
});
}
/**
* The root display container that's rendered.
* @member {PIXI.Container}
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
this.stage = new display.Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(this$1, options);
Application.registerPlugin = function (plugin) {
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function () {
// TODO: Since CanvasRenderer has not been converted this function thinks it takes DisplayObject & PIXI.DisplayObject
// This can be fixed when CanvasRenderer is converted.
this.renderer.render(this.stage);
};
Object.defineProperty(Application.prototype, "view", {
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
get: function () {
return this.renderer.view;
},
enumerable: false,
configurable: true
});
};
var prototypeAccessors = { view: { configurable: true },screen: { configurable: true } };
/**
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
Application.registerPlugin = function registerPlugin (plugin)
{
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function render ()
{
this.renderer.render(this.stage);
};
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
prototypeAccessors.view.get = function ()
{
return this.renderer.view;
};
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
prototypeAccessors.screen.get = function ()
{
return this.renderer.screen;
};
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function destroy (removeView, stageOptions)
{
var this$1 = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(this$1);
Object.defineProperty(Application.prototype, "screen", {
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
get: function () {
return this.renderer.screen;
},
enumerable: false,
configurable: true
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
this._options = null;
};
Object.defineProperties( Application.prototype, prototypeAccessors );
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] - Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function (removeView, stageOptions) {
var _this = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(_this);
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
};
return Application;
}());
/**

@@ -141,3 +158,2 @@ * @memberof PIXI.Application

*/
/**

@@ -156,75 +172,105 @@ * Collection of installed plugins.

*/
var ResizePlugin = function ResizePlugin () {};
ResizePlugin.init = function init (options)
{
var this$1 = this;
var ResizePlugin = /** @class */ (function () {
function ResizePlugin() {
}
/**
* The element or window to resize the application to.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
* Initialize the plugin with scope of application instance
* @static
* @private
* @param {object} [options] - See application options
*/
Object.defineProperty(this, 'resizeTo',
{
set: function set(dom)
{
window.removeEventListener('resize', this.resize);
ResizePlugin.init = function (options) {
var _this = this;
/**
* The HTML element or window to automatically resize the
* renderer's view element to match width and height.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
*/
Object.defineProperty(this, 'resizeTo', {
set: function (dom) {
window.removeEventListener('resize', this.queueResize);
this._resizeTo = dom;
if (dom)
{
window.addEventListener('resize', this.resize);
if (dom) {
window.addEventListener('resize', this.queueResize);
this.resize();
}
},
get: function get()
{
get: function () {
return this._resizeTo;
},
});
/**
* If `resizeTo` is set, calling this function
* will resize to the width and height of that element.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (this$1._resizeTo)
{
/**
* Resize is throttled, so it's
* safe to call this multiple times per frame and it'll
* only be called once.
* @method PIXI.Application#queueResize
*/
this.queueResize = function () {
if (!_this._resizeTo) {
return;
}
_this.cancelResize();
// // Throttle resize events per raf
_this._resizeId = requestAnimationFrame(function () { return _this.resize(); });
};
/**
* Cancel the resize queue.
* @method PIXI.Application#cancelResize
* @private
*/
this.cancelResize = function () {
if (_this._resizeId) {
cancelAnimationFrame(_this._resizeId);
_this._resizeId = null;
}
};
/**
* Execute an immediate resize on the renderer, this is not
* throttled and can be expensive to call many times in a row.
* Will resize only if `resizeTo` property is set.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (!_this._resizeTo) {
return;
}
// clear queue resize
_this.cancelResize();
var width;
var height;
// Resize to the window
if (this$1._resizeTo === window)
{
this$1.renderer.resize(
window.innerWidth,
window.innerHeight
);
if (_this._resizeTo === window) {
width = window.innerWidth;
height = window.innerHeight;
}
// Resize to other HTML entities
else
{
this$1.renderer.resize(
this$1._resizeTo.clientWidth,
this$1._resizeTo.clientHeight
);
else {
var _a = _this._resizeTo, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
width = clientWidth;
height = clientHeight;
}
}
_this.renderer.resize(width, height);
};
// On resize
this._resizeId = null;
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function () {
this.cancelResize();
this.cancelResize = null;
this.queueResize = null;
this.resizeTo = null;
this.resize = null;
};
return ResizePlugin;
}());
// On resize
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function destroy ()
{
this.resizeTo = null;
this.resize = null;
};
Application.registerPlugin(ResizePlugin);

@@ -231,0 +277,0 @@

/*!
* @pixi/app - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/app - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -8,3 +8,3 @@ * @pixi/app is licensed under the MIT License.

*/
this.PIXI=this.PIXI||{};var _pixi_app=function(e,i,r){"use strict";var t=function e(t){var n=this;t=Object.assign({forceCanvas:!1},t),this.renderer=r.autoDetectRenderer(t),this.stage=new i.Container,e._plugins.forEach(function(e){e.init.call(n,t)})},n={view:{configurable:!0},screen:{configurable:!0}};t.registerPlugin=function(e){t._plugins.push(e)},t.prototype.render=function(){this.renderer.render(this.stage)},n.view.get=function(){return this.renderer.view},n.screen.get=function(){return this.renderer.screen},t.prototype.destroy=function(e,i){var r=this,n=t._plugins.slice(0);n.reverse(),n.forEach(function(e){e.destroy.call(r)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(e),this.renderer=null,this._options=null},Object.defineProperties(t.prototype,n),t._plugins=[];var s=function(){};return s.init=function(e){var i=this;Object.defineProperty(this,"resizeTo",{set:function(e){window.removeEventListener("resize",this.resize),this._resizeTo=e,e&&(window.addEventListener("resize",this.resize),this.resize())},get:function(){return this._resizeTo}}),this.resize=function(){i._resizeTo&&(i._resizeTo===window?i.renderer.resize(window.innerWidth,window.innerHeight):i.renderer.resize(i._resizeTo.clientWidth,i._resizeTo.clientHeight))},this._resizeTo=null,this.resizeTo=e.resizeTo||null},s.destroy=function(){this.resizeTo=null,this.resize=null},t.registerPlugin(s),e.Application=t,e}({},PIXI,PIXI);Object.assign(this.PIXI,_pixi_app);
this.PIXI=this.PIXI||{};var _pixi_app=function(e,i,n){"use strict";var t=function(){function e(t){var r=this;t=Object.assign({forceCanvas:!1},t),this.renderer=n.autoDetectRenderer(t),this.stage=new i.Container,e._plugins.forEach(function(e){e.init.call(r,t)})}return e.registerPlugin=function(i){e._plugins.push(i)},e.prototype.render=function(){this.renderer.render(this.stage)},Object.defineProperty(e.prototype,"view",{get:function(){return this.renderer.view},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screen",{get:function(){return this.renderer.screen},enumerable:!1,configurable:!0}),e.prototype.destroy=function(i,n){var t=this,r=e._plugins.slice(0);r.reverse(),r.forEach(function(e){e.destroy.call(t)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(i),this.renderer=null},e}();t._plugins=[];var r=function(){function e(){}return e.init=function(e){var i=this;Object.defineProperty(this,"resizeTo",{set:function(e){window.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(window.addEventListener("resize",this.queueResize),this.resize())},get:function(){return this._resizeTo}}),this.queueResize=function(){i._resizeTo&&(i.cancelResize(),i._resizeId=requestAnimationFrame(function(){return i.resize()}))},this.cancelResize=function(){i._resizeId&&(cancelAnimationFrame(i._resizeId),i._resizeId=null)},this.resize=function(){if(i._resizeTo){var e,n;if(i.cancelResize(),i._resizeTo===window)e=window.innerWidth,n=window.innerHeight;else{var t=i._resizeTo;e=t.clientWidth,n=t.clientHeight}i.renderer.resize(e,n)}},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null},e.destroy=function(){this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null},e}();return t.registerPlugin(r),e.Application=t,e}({},PIXI,PIXI);Object.assign(this.PIXI,_pixi_app);
//# sourceMappingURL=app.min.js.map
/*!
* @pixi/app - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/app - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -29,105 +29,122 @@ * @pixi/app is licensed under the MIT License.

*/
var Application = function Application(options)
{
var this$1 = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
var Application = /** @class */ (function () {
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
* @param {object} [options] - The optional renderer parameters.
* @param {boolean} [options.autoStart=true] - Automatically starts the rendering after the construction.
* **Note**: Setting this parameter to false does NOT stop the shared ticker even if you set
* options.sharedTicker to true in case that it is already started. Stop it by your own.
* @param {number} [options.width=800] - The width of the renderers view.
* @param {number} [options.height=600] - The height of the renderers view.
* @param {HTMLCanvasElement} [options.view] - The canvas to use as a view, optional.
* @param {boolean} [options.transparent=false] - If the render view is transparent.
* @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for
* resolutions other than 1.
* @param {boolean} [options.antialias=false] - Sets antialias
* @param {boolean} [options.preserveDrawingBuffer=false] - Enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the WebGL context.
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2.
* @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present, this
* option only is available when using **pixi.js-legacy** or **@pixi/canvas-renderer** modules, otherwise
* it is ignored.
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card. **(WebGL only)**.
* @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.Ticker.shared, `false` to create new ticker.
* If set to false, you cannot register a handler to occur before anything that runs on the shared ticker.
* The system ticker will always run before both the shared ticker and the app ticker.
* @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.Loader.shared, `false` to create new Loader.
* @param {Window|HTMLElement} [options.resizeTo] - Element to automatically resize stage to.
*/
this.renderer = autoDetectRenderer(options);
function Application(options) {
var _this = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
*/
this.renderer = autoDetectRenderer(options);
/**
* The root display container that's rendered.
* @member {PIXI.Container}
*/
this.stage = new Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(_this, options);
});
}
/**
* The root display container that's rendered.
* @member {PIXI.Container}
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
this.stage = new Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(this$1, options);
Application.registerPlugin = function (plugin) {
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function () {
// TODO: Since CanvasRenderer has not been converted this function thinks it takes DisplayObject & PIXI.DisplayObject
// This can be fixed when CanvasRenderer is converted.
this.renderer.render(this.stage);
};
Object.defineProperty(Application.prototype, "view", {
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
get: function () {
return this.renderer.view;
},
enumerable: false,
configurable: true
});
};
var prototypeAccessors = { view: { configurable: true },screen: { configurable: true } };
/**
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
Application.registerPlugin = function registerPlugin (plugin)
{
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function render ()
{
this.renderer.render(this.stage);
};
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
prototypeAccessors.view.get = function ()
{
return this.renderer.view;
};
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
prototypeAccessors.screen.get = function ()
{
return this.renderer.screen;
};
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function destroy (removeView, stageOptions)
{
var this$1 = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(this$1);
Object.defineProperty(Application.prototype, "screen", {
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
get: function () {
return this.renderer.screen;
},
enumerable: false,
configurable: true
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
this._options = null;
};
Object.defineProperties( Application.prototype, prototypeAccessors );
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] - Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function (removeView, stageOptions) {
var _this = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(_this);
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
};
return Application;
}());
/**

@@ -140,3 +157,2 @@ * @memberof PIXI.Application

*/
/**

@@ -155,75 +171,105 @@ * Collection of installed plugins.

*/
var ResizePlugin = function ResizePlugin () {};
ResizePlugin.init = function init (options)
{
var this$1 = this;
var ResizePlugin = /** @class */ (function () {
function ResizePlugin() {
}
/**
* The element or window to resize the application to.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
* Initialize the plugin with scope of application instance
* @static
* @private
* @param {object} [options] - See application options
*/
Object.defineProperty(this, 'resizeTo',
{
set: function set(dom)
{
window.removeEventListener('resize', this.resize);
ResizePlugin.init = function (options) {
var _this = this;
/**
* The HTML element or window to automatically resize the
* renderer's view element to match width and height.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
*/
Object.defineProperty(this, 'resizeTo', {
set: function (dom) {
window.removeEventListener('resize', this.queueResize);
this._resizeTo = dom;
if (dom)
{
window.addEventListener('resize', this.resize);
if (dom) {
window.addEventListener('resize', this.queueResize);
this.resize();
}
},
get: function get()
{
get: function () {
return this._resizeTo;
},
});
/**
* If `resizeTo` is set, calling this function
* will resize to the width and height of that element.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (this$1._resizeTo)
{
/**
* Resize is throttled, so it's
* safe to call this multiple times per frame and it'll
* only be called once.
* @method PIXI.Application#queueResize
*/
this.queueResize = function () {
if (!_this._resizeTo) {
return;
}
_this.cancelResize();
// // Throttle resize events per raf
_this._resizeId = requestAnimationFrame(function () { return _this.resize(); });
};
/**
* Cancel the resize queue.
* @method PIXI.Application#cancelResize
* @private
*/
this.cancelResize = function () {
if (_this._resizeId) {
cancelAnimationFrame(_this._resizeId);
_this._resizeId = null;
}
};
/**
* Execute an immediate resize on the renderer, this is not
* throttled and can be expensive to call many times in a row.
* Will resize only if `resizeTo` property is set.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (!_this._resizeTo) {
return;
}
// clear queue resize
_this.cancelResize();
var width;
var height;
// Resize to the window
if (this$1._resizeTo === window)
{
this$1.renderer.resize(
window.innerWidth,
window.innerHeight
);
if (_this._resizeTo === window) {
width = window.innerWidth;
height = window.innerHeight;
}
// Resize to other HTML entities
else
{
this$1.renderer.resize(
this$1._resizeTo.clientWidth,
this$1._resizeTo.clientHeight
);
else {
var _a = _this._resizeTo, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
width = clientWidth;
height = clientHeight;
}
}
_this.renderer.resize(width, height);
};
// On resize
this._resizeId = null;
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function () {
this.cancelResize();
this.cancelResize = null;
this.queueResize = null;
this.resizeTo = null;
this.resize = null;
};
return ResizePlugin;
}());
// On resize
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function destroy ()
{
this.resizeTo = null;
this.resize = null;
};
Application.registerPlugin(ResizePlugin);

@@ -230,0 +276,0 @@

/*!
* @pixi/app - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/app - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -33,105 +33,122 @@ * @pixi/app is licensed under the MIT License.

*/
var Application = function Application(options)
{
var this$1 = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
var Application = /** @class */ (function () {
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
* @param {object} [options] - The optional renderer parameters.
* @param {boolean} [options.autoStart=true] - Automatically starts the rendering after the construction.
* **Note**: Setting this parameter to false does NOT stop the shared ticker even if you set
* options.sharedTicker to true in case that it is already started. Stop it by your own.
* @param {number} [options.width=800] - The width of the renderers view.
* @param {number} [options.height=600] - The height of the renderers view.
* @param {HTMLCanvasElement} [options.view] - The canvas to use as a view, optional.
* @param {boolean} [options.transparent=false] - If the render view is transparent.
* @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for
* resolutions other than 1.
* @param {boolean} [options.antialias=false] - Sets antialias
* @param {boolean} [options.preserveDrawingBuffer=false] - Enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the WebGL context.
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2.
* @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present, this
* option only is available when using **pixi.js-legacy** or **@pixi/canvas-renderer** modules, otherwise
* it is ignored.
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card. **(WebGL only)**.
* @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.Ticker.shared, `false` to create new ticker.
* If set to false, you cannot register a handler to occur before anything that runs on the shared ticker.
* The system ticker will always run before both the shared ticker and the app ticker.
* @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.Loader.shared, `false` to create new Loader.
* @param {Window|HTMLElement} [options.resizeTo] - Element to automatically resize stage to.
*/
this.renderer = core.autoDetectRenderer(options);
function Application(options) {
var _this = this;
// The default options
options = Object.assign({
forceCanvas: false,
}, options);
/**
* WebGL renderer if available, otherwise CanvasRenderer.
* @member {PIXI.Renderer|PIXI.CanvasRenderer}
*/
this.renderer = core.autoDetectRenderer(options);
/**
* The root display container that's rendered.
* @member {PIXI.Container}
*/
this.stage = new display.Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(_this, options);
});
}
/**
* The root display container that's rendered.
* @member {PIXI.Container}
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
this.stage = new display.Container();
// install plugins here
Application._plugins.forEach(function (plugin) {
plugin.init.call(this$1, options);
Application.registerPlugin = function (plugin) {
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function () {
// TODO: Since CanvasRenderer has not been converted this function thinks it takes DisplayObject & PIXI.DisplayObject
// This can be fixed when CanvasRenderer is converted.
this.renderer.render(this.stage);
};
Object.defineProperty(Application.prototype, "view", {
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
get: function () {
return this.renderer.view;
},
enumerable: false,
configurable: true
});
};
var prototypeAccessors = { view: { configurable: true },screen: { configurable: true } };
/**
* Register a middleware plugin for the application
* @static
* @param {PIXI.Application.Plugin} plugin - Plugin being installed
*/
Application.registerPlugin = function registerPlugin (plugin)
{
Application._plugins.push(plugin);
};
/**
* Render the current stage.
*/
Application.prototype.render = function render ()
{
this.renderer.render(this.stage);
};
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
prototypeAccessors.view.get = function ()
{
return this.renderer.view;
};
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
prototypeAccessors.screen.get = function ()
{
return this.renderer.screen;
};
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function destroy (removeView, stageOptions)
{
var this$1 = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(this$1);
Object.defineProperty(Application.prototype, "screen", {
/**
* Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
* @member {PIXI.Rectangle}
* @readonly
*/
get: function () {
return this.renderer.screen;
},
enumerable: false,
configurable: true
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
this._options = null;
};
Object.defineProperties( Application.prototype, prototypeAccessors );
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] - Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function (removeView, stageOptions) {
var _this = this;
// Destroy plugins in the opposite order
// which they were constructed
var plugins = Application._plugins.slice(0);
plugins.reverse();
plugins.forEach(function (plugin) {
plugin.destroy.call(_this);
});
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
};
return Application;
}());
/**

@@ -144,3 +161,2 @@ * @memberof PIXI.Application

*/
/**

@@ -159,75 +175,105 @@ * Collection of installed plugins.

*/
var ResizePlugin = function ResizePlugin () {};
ResizePlugin.init = function init (options)
{
var this$1 = this;
var ResizePlugin = /** @class */ (function () {
function ResizePlugin() {
}
/**
* The element or window to resize the application to.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
* Initialize the plugin with scope of application instance
* @static
* @private
* @param {object} [options] - See application options
*/
Object.defineProperty(this, 'resizeTo',
{
set: function set(dom)
{
window.removeEventListener('resize', this.resize);
ResizePlugin.init = function (options) {
var _this = this;
/**
* The HTML element or window to automatically resize the
* renderer's view element to match width and height.
* @type {Window|HTMLElement}
* @name resizeTo
* @memberof PIXI.Application#
*/
Object.defineProperty(this, 'resizeTo', {
set: function (dom) {
window.removeEventListener('resize', this.queueResize);
this._resizeTo = dom;
if (dom)
{
window.addEventListener('resize', this.resize);
if (dom) {
window.addEventListener('resize', this.queueResize);
this.resize();
}
},
get: function get()
{
get: function () {
return this._resizeTo;
},
});
/**
* If `resizeTo` is set, calling this function
* will resize to the width and height of that element.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (this$1._resizeTo)
{
/**
* Resize is throttled, so it's
* safe to call this multiple times per frame and it'll
* only be called once.
* @method PIXI.Application#queueResize
*/
this.queueResize = function () {
if (!_this._resizeTo) {
return;
}
_this.cancelResize();
// // Throttle resize events per raf
_this._resizeId = requestAnimationFrame(function () { return _this.resize(); });
};
/**
* Cancel the resize queue.
* @method PIXI.Application#cancelResize
* @private
*/
this.cancelResize = function () {
if (_this._resizeId) {
cancelAnimationFrame(_this._resizeId);
_this._resizeId = null;
}
};
/**
* Execute an immediate resize on the renderer, this is not
* throttled and can be expensive to call many times in a row.
* Will resize only if `resizeTo` property is set.
* @method PIXI.Application#resize
*/
this.resize = function () {
if (!_this._resizeTo) {
return;
}
// clear queue resize
_this.cancelResize();
var width;
var height;
// Resize to the window
if (this$1._resizeTo === window)
{
this$1.renderer.resize(
window.innerWidth,
window.innerHeight
);
if (_this._resizeTo === window) {
width = window.innerWidth;
height = window.innerHeight;
}
// Resize to other HTML entities
else
{
this$1.renderer.resize(
this$1._resizeTo.clientWidth,
this$1._resizeTo.clientHeight
);
else {
var _a = _this._resizeTo, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
width = clientWidth;
height = clientHeight;
}
}
_this.renderer.resize(width, height);
};
// On resize
this._resizeId = null;
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function () {
this.cancelResize();
this.cancelResize = null;
this.queueResize = null;
this.resizeTo = null;
this.resize = null;
};
return ResizePlugin;
}());
// On resize
this._resizeTo = null;
this.resizeTo = options.resizeTo || null;
};
/**
* Clean up the ticker, scoped to application
* @static
* @private
*/
ResizePlugin.destroy = function destroy ()
{
this.resizeTo = null;
this.resize = null;
};
Application.registerPlugin(ResizePlugin);

@@ -234,0 +280,0 @@

{
"name": "@pixi/app",
"version": "5.2.4",
"version": "5.3.0",
"main": "lib/app.js",

@@ -27,10 +27,10 @@ "module": "lib/app.es.js",

"dependencies": {
"@pixi/core": "5.2.4",
"@pixi/display": "5.2.4"
"@pixi/core": "5.3.0",
"@pixi/display": "5.3.0"
},
"devDependencies": {
"@pixi/canvas-renderer": "5.2.4",
"@pixi/utils": "5.2.4"
"@pixi/canvas-renderer": "5.3.0",
"@pixi/utils": "5.3.0"
},
"gitHead": "71c6b3b2061af4a4f3a95a265d46e933b8befc2c"
"gitHead": "a9b7b32a9c0aeb3d9c42ef04b2c2a39be1cd0880"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc