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

@pixi/utils

Package Overview
Dependencies
Maintainers
3
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/utils - npm Package Compare versions

Comparing version 5.0.0-alpha.3 to 5.0.0-rc

273

lib/utils.es.js
/*!
* @pixi/utils - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/utils - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

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

*/
import ismobilejs from 'ismobilejs';
import removeArrayItems from 'remove-array-items';
import eventemitter3 from 'eventemitter3';
import earcut from 'earcut';
export { default as isMobile } from 'ismobilejs';
export { default as removeItems } from 'remove-array-items';
export { default as EventEmitter } from 'eventemitter3';
export { default as earcut } from 'earcut';
import { settings } from '@pixi/settings';
import { BLEND_MODES } from '@pixi/constants';
import { settings as settings$1 } from '@pixi/settings';
import _url from 'url';

@@ -75,11 +75,22 @@

var mixins$1 = ({
mixin: mixin,
delayMixin: delayMixin,
performMixins: performMixins
mixin: mixin,
delayMixin: delayMixin,
performMixins: performMixins
});
/**
* The prefix that denotes a URL is for a retina asset.
*
* @static
* @name RETINA_PREFIX
* @memberof PIXI.settings
* @type {RegExp}
* @default /@([0-9\.]+)x/
* @example `@2x`
*/
settings.RETINA_PREFIX = /@([0-9\.]+)x/;
var saidHello = false;
var VERSION = '5.0.0-alpha.3';
var VERSION = '5.0.0-rc';

@@ -218,2 +229,20 @@ /**

/**
* Converts a hex string to a hex color number.
*
* @memberof PIXI.utils
* @function string2hex
* @param {string} The string color that starts with #
* @return {number} hex - Number in hex
*/
function string2hex(string)
{
if (typeof string === 'string' && string[0] === '#')
{
string = string.substr(1);
}
return parseInt(string, 16);
}
/**
* Converts a color as an [R, G, B] array to a hex number

@@ -435,7 +464,70 @@ *

// Taken from the bit-twiddle package
/**
* Rounds to next power of two.
*
* @function isPow2
* @memberof PIXI.utils
* @param {number} v input value
* @return {number}
*/
function nextPow2(v)
{
v += v === 0;
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v + 1;
}
/**
* Checks if a number is a power of two.
*
* @function isPow2
* @memberof PIXI.utils
* @param {number} v input value
* @return {boolean} `true` if value is power of two
*/
function isPow2(v)
{
return !(v & (v - 1)) && (!!v);
}
/**
* Computes ceil of log base 2
*
* @function log2
* @memberof PIXI.utils
* @param {number} v input value
* @return {number} logarithm base 2
*/
function log2(v)
{
var r = (v > 0xFFFF) << 4;
v >>>= r;
var shift = (v > 0xFF) << 3;
v >>>= shift; r |= shift;
shift = (v > 0xF) << 2;
v >>>= shift; r |= shift;
shift = (v > 0x3) << 1;
v >>>= shift; r |= shift;
return r | (v >> 1);
}
/**
* @todo Describe property usage
*
* @static
* @name ProgramCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -447,4 +539,6 @@ var ProgramCache = {};

*
* @static
* @name TextureCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -456,4 +550,6 @@ var TextureCache = Object.create(null);

*
* @static
* @name BaseTextureCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -505,5 +601,4 @@

*
* @memberof PIXI
* @memberof PIXI.utils
* @function trimCanvas
* @private
* @param {HTMLCanvasElement} canvas - the canvas to trim

@@ -530,2 +625,3 @@ * @returns {object} Trim data

};
var data = null;
var i;

@@ -576,7 +672,9 @@ var x;

width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
if (bound.top !== null)
{
width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
data = context.getImageData(bound.left, bound.top, width, height);
}
var data = context.getImageData(bound.left, bound.top, width, height);
return {

@@ -590,3 +688,3 @@ height: height,

/**
* Creates a Canvas element of the given size.
* Creates a Canvas element of the given size to be used as a target for rendering to.
*

@@ -612,3 +710,3 @@ * @class

this.resolution = resolution || settings$1.RESOLUTION;
this.resolution = resolution || settings.RESOLUTION;

@@ -690,6 +788,4 @@ this.resize(width, height);

* @static
* @constant
* @name DATA_URI
* @constant {RegExp|string} DATA_URI
* @memberof PIXI
* @type {RegExp|string}
* @example data:image/png;base64

@@ -702,7 +798,8 @@ */

*
* @typedef {object} PIXI.utils~DecomposedDataUri
* @property {mediaType} Media type, eg. `image`
* @property {subType} Sub type, eg. `png`
* @property {encoding} Data encoding, eg. `base64`
* @property {data} The actual data
* @memberof PIXI.utils
* @typedef {object} DecomposedDataUri
* @property {string} mediaType Media type, eg. `image`
* @property {string} subType Sub type, eg. `png`
* @property {string} encoding Data encoding, eg. `base64`
* @property {string} data The actual data
*/

@@ -717,3 +814,3 @@

* @param {string} dataUri - the data URI to check
* @return {PIXI.utils~DecomposedDataUri|undefined} The decomposed data uri or undefined
* @return {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined
*/

@@ -787,15 +884,2 @@ function decomposeDataUri(dataUri)

/**
* The prefix that denotes a URL is for a retina asset.
*
* @static
* @constant
* @name RETINA_PREFIX
* @memberof PIXI
* @type {RegExp}
* @example `@2x`
* @default /@([0-9\.]+)x/
*/
settings$1.RETINA_PREFIX = /@([0-9\.]+)x/;
/**
* get the resolution / device pixel ratio of an asset by looking for the prefix

@@ -812,3 +896,3 @@ * used by spritesheets and image urls

{
var resolution = settings$1.RETINA_PREFIX.exec(url);
var resolution = settings.RETINA_PREFIX.exec(url);

@@ -823,3 +907,63 @@ if (resolution)

// A map of warning messages already fired
var warnings = {};
/**
* Helper for warning developers about deprecated features & settings.
* A stack track for warnings is given; useful for tracking-down where
* deprecated methods/properties/classes are being used within the code.
*
* @memberof PIXI.utils
* @function deprecation
* @param {string} version - The version where the feature became deprecated
* @param {string} message - Message should include what is deprecated, where, and the new solution
* @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack
* this is mostly to ignore internal deprecation calls.
*/
function deprecation(version, message, ignoreDepth)
{
if ( ignoreDepth === void 0 ) ignoreDepth = 3;
// Ignore duplicat
if (warnings[message])
{
return;
}
/* eslint-disable no-console */
var stack = new Error().stack;
// Handle IE < 10 and Safari < 6
if (typeof stack === 'undefined')
{
console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version));
}
else
{
// chop off the stack trace which includes PixiJS internal calls
stack = stack.split('\n').splice(ignoreDepth).join('\n');
if (console.groupCollapsed)
{
console.groupCollapsed(
'%cPixiJS Deprecation Warning: %c%s',
'color:#614108;background:#fffbe6',
'font-weight:normal;color:#614108;background:#fffbe6',
(message + "\nDeprecated since v" + version)
);
console.warn(stack);
console.groupEnd();
}
else
{
console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version));
console.warn(stack);
}
}
/* eslint-enable no-console */
warnings[message] = true;
}
/**
* Generalized convenience utilities for PIXI.

@@ -843,38 +987,3 @@ * @example

/**
* @see {@link https://github.com/kaimallea/isMobile}
*
* @memberof PIXI.utils
* @function isMobile
* @type {Object}
*/
/**
* @see {@link https://github.com/mreinstein/remove-array-items}
*
* @memberof PIXI.utils
* @function removeItems
* @type {Object}
*/
/**
* @see {@link https://github.com/primus/eventemitter3}
*
* @memberof PIXI.utils
* @class EventEmitter
* @type {EventEmitter}
*/
/**
* @namespace PIXI.utils.mixins
*/
/**
* @see {@link https://github.com/mapbox/earcut}
*
* @memberof PIXI.utils
* @function earcut
* @param {number[]} vertices - A flat array of vertex coordinates
* @param {number[]} [holes] - An array of hole indices
* @param {number} [dimensions=2] The number of coordinates per vertex in the input array
* @return {number[]} Triangulated polygon
*/
export { ismobilejs as isMobile, removeArrayItems as removeItems, eventemitter3 as EventEmitter, mixins$1 as mixins, earcut, skipHello, sayHello, isWebGLSupported, hex2rgb, hex2string, rgb2hex, premultiplyBlendMode, correctBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba, createIndicesForQuads, uid, sign, CanvasRenderTarget, ProgramCache, TextureCache, BaseTextureCache, destroyTextureCache, clearTextureCache, trimCanvas, decomposeDataUri, determineCrossOrigin, getResolutionOfUrl, DATA_URI };
export { mixins$1 as mixins, skipHello, sayHello, isWebGLSupported, hex2rgb, hex2string, string2hex, rgb2hex, premultiplyBlendMode, correctBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba, createIndicesForQuads, uid, sign, nextPow2, isPow2, log2, CanvasRenderTarget, ProgramCache, TextureCache, BaseTextureCache, destroyTextureCache, clearTextureCache, trimCanvas, decomposeDataUri, determineCrossOrigin, getResolutionOfUrl, DATA_URI, deprecation };
//# sourceMappingURL=utils.es.js.map
/*!
* @pixi/utils - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/utils - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -18,4 +18,4 @@ * @pixi/utils is licensed under the MIT License.

var earcut = _interopDefault(require('earcut'));
var settings = require('@pixi/settings');
var constants = require('@pixi/constants');
var settings = require('@pixi/settings');
var _url = _interopDefault(require('url'));

@@ -81,11 +81,22 @@

var mixins$1 = ({
mixin: mixin,
delayMixin: delayMixin,
performMixins: performMixins
mixin: mixin,
delayMixin: delayMixin,
performMixins: performMixins
});
/**
* The prefix that denotes a URL is for a retina asset.
*
* @static
* @name RETINA_PREFIX
* @memberof PIXI.settings
* @type {RegExp}
* @default /@([0-9\.]+)x/
* @example `@2x`
*/
settings.settings.RETINA_PREFIX = /@([0-9\.]+)x/;
var saidHello = false;
var VERSION = '5.0.0-alpha.3';
var VERSION = '5.0.0-rc';

@@ -224,2 +235,20 @@ /**

/**
* Converts a hex string to a hex color number.
*
* @memberof PIXI.utils
* @function string2hex
* @param {string} The string color that starts with #
* @return {number} hex - Number in hex
*/
function string2hex(string)
{
if (typeof string === 'string' && string[0] === '#')
{
string = string.substr(1);
}
return parseInt(string, 16);
}
/**
* Converts a color as an [R, G, B] array to a hex number

@@ -441,7 +470,70 @@ *

// Taken from the bit-twiddle package
/**
* Rounds to next power of two.
*
* @function isPow2
* @memberof PIXI.utils
* @param {number} v input value
* @return {number}
*/
function nextPow2(v)
{
v += v === 0;
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v + 1;
}
/**
* Checks if a number is a power of two.
*
* @function isPow2
* @memberof PIXI.utils
* @param {number} v input value
* @return {boolean} `true` if value is power of two
*/
function isPow2(v)
{
return !(v & (v - 1)) && (!!v);
}
/**
* Computes ceil of log base 2
*
* @function log2
* @memberof PIXI.utils
* @param {number} v input value
* @return {number} logarithm base 2
*/
function log2(v)
{
var r = (v > 0xFFFF) << 4;
v >>>= r;
var shift = (v > 0xFF) << 3;
v >>>= shift; r |= shift;
shift = (v > 0xF) << 2;
v >>>= shift; r |= shift;
shift = (v > 0x3) << 1;
v >>>= shift; r |= shift;
return r | (v >> 1);
}
/**
* @todo Describe property usage
*
* @static
* @name ProgramCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -453,4 +545,6 @@ var ProgramCache = {};

*
* @static
* @name TextureCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -462,4 +556,6 @@ var TextureCache = Object.create(null);

*
* @static
* @name BaseTextureCache
* @memberof PIXI.utils
* @private
* @type {Object}
*/

@@ -511,5 +607,4 @@

*
* @memberof PIXI
* @memberof PIXI.utils
* @function trimCanvas
* @private
* @param {HTMLCanvasElement} canvas - the canvas to trim

@@ -536,2 +631,3 @@ * @returns {object} Trim data

};
var data = null;
var i;

@@ -582,7 +678,9 @@ var x;

width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
if (bound.top !== null)
{
width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
data = context.getImageData(bound.left, bound.top, width, height);
}
var data = context.getImageData(bound.left, bound.top, width, height);
return {

@@ -596,3 +694,3 @@ height: height,

/**
* Creates a Canvas element of the given size.
* Creates a Canvas element of the given size to be used as a target for rendering to.
*

@@ -695,6 +793,4 @@ * @class

* @static
* @constant
* @name DATA_URI
* @constant {RegExp|string} DATA_URI
* @memberof PIXI
* @type {RegExp|string}
* @example data:image/png;base64

@@ -707,7 +803,8 @@ */

*
* @typedef {object} PIXI.utils~DecomposedDataUri
* @property {mediaType} Media type, eg. `image`
* @property {subType} Sub type, eg. `png`
* @property {encoding} Data encoding, eg. `base64`
* @property {data} The actual data
* @memberof PIXI.utils
* @typedef {object} DecomposedDataUri
* @property {string} mediaType Media type, eg. `image`
* @property {string} subType Sub type, eg. `png`
* @property {string} encoding Data encoding, eg. `base64`
* @property {string} data The actual data
*/

@@ -722,3 +819,3 @@

* @param {string} dataUri - the data URI to check
* @return {PIXI.utils~DecomposedDataUri|undefined} The decomposed data uri or undefined
* @return {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined
*/

@@ -792,15 +889,2 @@ function decomposeDataUri(dataUri)

/**
* The prefix that denotes a URL is for a retina asset.
*
* @static
* @constant
* @name RETINA_PREFIX
* @memberof PIXI
* @type {RegExp}
* @example `@2x`
* @default /@([0-9\.]+)x/
*/
settings.settings.RETINA_PREFIX = /@([0-9\.]+)x/;
/**
* get the resolution / device pixel ratio of an asset by looking for the prefix

@@ -827,3 +911,63 @@ * used by spritesheets and image urls

// A map of warning messages already fired
var warnings = {};
/**
* Helper for warning developers about deprecated features & settings.
* A stack track for warnings is given; useful for tracking-down where
* deprecated methods/properties/classes are being used within the code.
*
* @memberof PIXI.utils
* @function deprecation
* @param {string} version - The version where the feature became deprecated
* @param {string} message - Message should include what is deprecated, where, and the new solution
* @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack
* this is mostly to ignore internal deprecation calls.
*/
function deprecation(version, message, ignoreDepth)
{
if ( ignoreDepth === void 0 ) ignoreDepth = 3;
// Ignore duplicat
if (warnings[message])
{
return;
}
/* eslint-disable no-console */
var stack = new Error().stack;
// Handle IE < 10 and Safari < 6
if (typeof stack === 'undefined')
{
console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version));
}
else
{
// chop off the stack trace which includes PixiJS internal calls
stack = stack.split('\n').splice(ignoreDepth).join('\n');
if (console.groupCollapsed)
{
console.groupCollapsed(
'%cPixiJS Deprecation Warning: %c%s',
'color:#614108;background:#fffbe6',
'font-weight:normal;color:#614108;background:#fffbe6',
(message + "\nDeprecated since v" + version)
);
console.warn(stack);
console.groupEnd();
}
else
{
console.warn('PixiJS Deprecation Warning: ', (message + "\nDeprecated since v" + version));
console.warn(stack);
}
}
/* eslint-enable no-console */
warnings[message] = true;
}
/**
* Generalized convenience utilities for PIXI.

@@ -847,42 +991,7 @@ * @example

/**
* @see {@link https://github.com/kaimallea/isMobile}
*
* @memberof PIXI.utils
* @function isMobile
* @type {Object}
*/
/**
* @see {@link https://github.com/mreinstein/remove-array-items}
*
* @memberof PIXI.utils
* @function removeItems
* @type {Object}
*/
/**
* @see {@link https://github.com/primus/eventemitter3}
*
* @memberof PIXI.utils
* @class EventEmitter
* @type {EventEmitter}
*/
/**
* @namespace PIXI.utils.mixins
*/
/**
* @see {@link https://github.com/mapbox/earcut}
*
* @memberof PIXI.utils
* @function earcut
* @param {number[]} vertices - A flat array of vertex coordinates
* @param {number[]} [holes] - An array of hole indices
* @param {number} [dimensions=2] The number of coordinates per vertex in the input array
* @return {number[]} Triangulated polygon
*/
exports.isMobile = ismobilejs;
exports.removeItems = removeArrayItems;
exports.EventEmitter = eventemitter3;
exports.earcut = earcut;
exports.mixins = mixins$1;
exports.earcut = earcut;
exports.skipHello = skipHello;

@@ -893,2 +1002,3 @@ exports.sayHello = sayHello;

exports.hex2string = hex2string;
exports.string2hex = string2hex;
exports.rgb2hex = rgb2hex;

@@ -903,2 +1013,5 @@ exports.premultiplyBlendMode = premultiplyBlendMode;

exports.sign = sign;
exports.nextPow2 = nextPow2;
exports.isPow2 = isPow2;
exports.log2 = log2;
exports.CanvasRenderTarget = CanvasRenderTarget;

@@ -915,2 +1028,3 @@ exports.ProgramCache = ProgramCache;

exports.DATA_URI = DATA_URI;
exports.deprecation = deprecation;
//# sourceMappingURL=utils.js.map
{
"name": "@pixi/utils",
"version": "5.0.0-alpha.3",
"version": "5.0.0-rc",
"main": "lib/utils.js",
"module": "lib/utils.es.js",
"description": "PixiJS Application",
"description": "Collection of utilities used by PixiJS",
"author": "Mat Groves",

@@ -28,7 +28,7 @@ "contributors": [

"dependencies": {
"@pixi/constants": "^5.0.0-alpha.3",
"@pixi/settings": "^5.0.0-alpha.3",
"@pixi/constants": "^5.0.0-rc",
"@pixi/settings": "^5.0.0-rc",
"earcut": "^2.1.3",
"eventemitter3": "^2.0.0",
"ismobilejs": "^0.4.0",
"ismobilejs": "^0.5.1",
"remove-array-items": "^1.0.0",

@@ -38,4 +38,5 @@ "url": "^0.11.0"

"devDependencies": {
"floss": "^2.1.3"
}
"floss": "^2.1.5"
},
"gitHead": "9026a1bbca9a9d86b7a3b6d5eb4fa2c3145c2b85"
}

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