Socket
Socket
Sign inDemoInstall

onecolor

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onecolor - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

15

lib/one.js

@@ -1,13 +0,12 @@

/*global window*/
/*global one*/
/**
* @namespace one One.com global JavaScript namespace.
* @exports window.one as one
* @exports one
*/
if (typeof window !== 'undefined') {
window.one = window.one || {};
} else {
var one = {};
if (typeof one === 'undefined') {
one = {
include: function () {}
};
}
one.include = one.exclude = function () {}; // Ignore these in development mode

@@ -35,10 +35,10 @@ /*global one*/

one.color = function (obj) {
function color(obj) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
if (obj[0].length === 4) {
// Assumed 4 element int RGB array from canvas with all channels [0;255]
return new one.color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
return new color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
} else {
// Assumed destringified array from one.color.JSON()
return new one.color[obj[0]](obj.slice(1, obj.length));
return new color[obj[0]](obj.slice(1, obj.length));
}

@@ -55,6 +55,6 @@ } else if (obj.charCodeAt) {

thirdChannelDivisor = (matchCssSyntax[7] || hasHue) ? 100 : 255;
if (!(colorSpaceName in one.color)) {
if (typeof color[colorSpaceName] === 'undefined') {
throw new Error("one.color." + colorSpaceName + " is not installed.");
}
return new one.color[colorSpaceName](
return new color[colorSpaceName](
parseFloat(matchCssSyntax[2]) / firstChannelDivisor,

@@ -74,3 +74,3 @@ parseFloat(matchCssSyntax[4]) / secondChannelDivisor,

if (hexMatch) {
return new one.color.RGB(
return new color.RGB(
parseInt(hexMatch[1], 16) / 255,

@@ -85,10 +85,10 @@ parseInt(hexMatch[2], 16) / 255,

// Strange integer representation sometimes returned by document.queryCommandValue in some browser...
return new one.color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
return new color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
}
return false;
};
}
/*jslint evil:true*/
one.color.installColorSpace = function (colorSpaceName, propertyNames, config) {
one.color[colorSpaceName] = new Function(propertyNames.join(","),
color.installColorSpace = function (colorSpaceName, propertyNames, config) {
color[colorSpaceName] = new Function(propertyNames.join(","),
// Allow passing an array to the constructor:

@@ -115,5 +115,5 @@ "if (Object.prototype.toString.apply(" + propertyNames[0] + ") === '[object Array]') {" +

);
one.color[colorSpaceName].propertyNames = propertyNames;
color[colorSpaceName].propertyNames = propertyNames;
var prototype = one.color[colorSpaceName].prototype;
var prototype = color[colorSpaceName].prototype;

@@ -154,3 +154,3 @@ ['valueOf', 'hex', 'css', 'cssa'].forEach(function (methodName) {

if (matchFromColorSpace) {
one.color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
} else {

@@ -192,8 +192,8 @@ prototype[propertyName] = config[propertyName];

obj[sourceColorSpaceName.toLowerCase()] = new Function("return this.rgb()." + sourceColorSpaceName.toLowerCase() + "();"); // Fallback
one.color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
obj[propertyName] = new Function("value", "isDelta", "return this." + sourceColorSpaceName.toLowerCase() + "()." + propertyName + "(value, isDelta);");
});
for (var prop in obj) {
if (obj.hasOwnProperty(prop) && one.color[targetColorSpaceName].prototype[prop] === undefined) {
one.color[targetColorSpaceName].prototype[prop] = obj[prop];
if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {
color[targetColorSpaceName].prototype[prop] = obj[prop];
}

@@ -210,2 +210,4 @@ }

};
one.color = color;
}());

@@ -212,0 +214,0 @@

@@ -1,15 +0,14 @@

/*global window*/
/*global one*/
/**
* @namespace one One.com global JavaScript namespace.
* @exports window.one as one
* @exports one
*/
if (typeof window !== 'undefined') {
window.one = window.one || {};
} else {
var one = {};
if (typeof one === 'undefined') {
one = {
include: function () {}
};
}
one.include = one.exclude = function () {}; // Ignore these in development mode
/*global one*/

@@ -48,10 +47,10 @@

one.color = function (obj) {
function color(obj) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
if (obj[0].length === 4) {
// Assumed 4 element int RGB array from canvas with all channels [0;255]
return new one.color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
return new color.RGB(obj[0] / 255, obj[1] / 255, obj[2] / 255, obj[3] / 255);
} else {
// Assumed destringified array from one.color.JSON()
return new one.color[obj[0]](obj.slice(1, obj.length));
return new color[obj[0]](obj.slice(1, obj.length));
}

@@ -68,6 +67,6 @@ } else if (obj.charCodeAt) {

thirdChannelDivisor = (matchCssSyntax[7] || hasHue) ? 100 : 255;
if (!(colorSpaceName in one.color)) {
if (typeof color[colorSpaceName] === 'undefined') {
throw new Error("one.color." + colorSpaceName + " is not installed.");
}
return new one.color[colorSpaceName](
return new color[colorSpaceName](
parseFloat(matchCssSyntax[2]) / firstChannelDivisor,

@@ -87,3 +86,3 @@ parseFloat(matchCssSyntax[4]) / secondChannelDivisor,

if (hexMatch) {
return new one.color.RGB(
return new color.RGB(
parseInt(hexMatch[1], 16) / 255,

@@ -98,10 +97,10 @@ parseInt(hexMatch[2], 16) / 255,

// Strange integer representation sometimes returned by document.queryCommandValue in some browser...
return new one.color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
return new color.RGB((obj & 0xFF) / 255, ((obj & 0xFF00) >> 8) / 255, ((obj & 0xFF0000) >> 16) / 255);
}
return false;
};
}
/*jslint evil:true*/
one.color.installColorSpace = function (colorSpaceName, propertyNames, config) {
one.color[colorSpaceName] = new Function(propertyNames.join(","),
color.installColorSpace = function (colorSpaceName, propertyNames, config) {
color[colorSpaceName] = new Function(propertyNames.join(","),
// Allow passing an array to the constructor:

@@ -128,5 +127,5 @@ "if (Object.prototype.toString.apply(" + propertyNames[0] + ") === '[object Array]') {" +

);
one.color[colorSpaceName].propertyNames = propertyNames;
color[colorSpaceName].propertyNames = propertyNames;
var prototype = one.color[colorSpaceName].prototype;
var prototype = color[colorSpaceName].prototype;

@@ -167,3 +166,3 @@ ['valueOf', 'hex', 'css', 'cssa'].forEach(function (methodName) {

if (matchFromColorSpace) {
one.color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
color[matchFromColorSpace[1].toUpperCase()].prototype[colorSpaceName.toLowerCase()] = config[propertyName];
} else {

@@ -205,8 +204,8 @@ prototype[propertyName] = config[propertyName];

obj[sourceColorSpaceName.toLowerCase()] = new Function("return this.rgb()." + sourceColorSpaceName.toLowerCase() + "();"); // Fallback
one.color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
color[sourceColorSpaceName].propertyNames.forEach(function (propertyName, i) {
obj[propertyName] = new Function("value", "isDelta", "return this." + sourceColorSpaceName.toLowerCase() + "()." + propertyName + "(value, isDelta);");
});
for (var prop in obj) {
if (obj.hasOwnProperty(prop) && one.color[targetColorSpaceName].prototype[prop] === undefined) {
one.color[targetColorSpaceName].prototype[prop] = obj[prop];
if (obj.hasOwnProperty(prop) && color[targetColorSpaceName].prototype[prop] === undefined) {
color[targetColorSpaceName].prototype[prop] = obj[prop];
}

@@ -223,2 +222,4 @@ }

};
one.color = color;
}());

@@ -225,0 +226,0 @@

@@ -1,1 +0,1 @@

if(typeof window!=="undefined"){window.one=window.one||{}}else{var one={}}one.include=one.exclude=function(){};(function(){var d=[],b=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,a=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,c=new RegExp("^(rgb|hsl|hsv)a?\\("+b.source+","+b.source+","+b.source+"(?:,"+a.source+")?\\)$","i");one.color=function(l){if(Object.prototype.toString.apply(l)==="[object Array]"){if(l[0].length===4){return new one.color.RGB(l[0]/255,l[1]/255,l[2]/255,l[3]/255)}else{return new one.color[l[0]](l.slice(1,l.length))}}else{if(l.charCodeAt){var i=l.match(c);if(i){var m=i[1].toUpperCase(),k=typeof i[8]==="undefined"?i[8]:parseFloat(i[8]),e=m[0]==="H",g=i[3]?100:(e?360:255),h=(i[5]||e)?100:255,j=(i[7]||e)?100:255;if(!(m in one.color)){throw new Error("one.color."+m+" is not installed.")}return new one.color[m](parseFloat(i[2])/g,parseFloat(i[4])/h,parseFloat(i[6])/j,k)}if(l.length<6){l=l.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3")}var f=l.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(f){return new one.color.RGB(parseInt(f[1],16)/255,parseInt(f[2],16)/255,parseInt(f[3],16)/255)}}else{if(typeof l==="object"&&l.isColor){return l}else{if(!isNaN(l)){return new one.color.RGB((l&255)/255,((l&65280)>>8)/255,((l&16711680)>>16)/255)}}}}return false};one.color.installColorSpace=function(k,h,j){one.color[k]=new Function(h.join(","),"if (Object.prototype.toString.apply("+h[0]+") === '[object Array]') {"+h.map(function(l,m){return l+"="+h[0]+"["+m+"];"}).reverse().join("")+"}if ("+h.filter(function(l){return l!=="alpha"}).map(function(l){return"isNaN("+l+")"}).join("||")+'){throw new Error("[one.color.'+k+']: Invalid color: ("+'+h.join('+","+')+'+")");}'+h.map(function(l){if(l==="hue"){return"this._hue=hue<0?hue-Math.floor(hue):hue%1"}else{if(l==="alpha"){return"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);"}else{return"this._"+l+"="+l+"<0?0:("+l+">1?1:"+l+")"}}}).join(";")+";");one.color[k].propertyNames=h;var i=one.color[k].prototype;["valueOf","hex","css","cssa"].forEach(function(l){i[l]=i[l]||(k==="RGB"?i.hex:new Function("return this.rgb()."+l+"();"))});i.isColor=true;i.equals=function(n,m){if(typeof m==="undefined"){m=1e-10}n=n[k.toLowerCase()]();for(var l=0;l<h.length;l=l+1){if(Math.abs(this["_"+h[l]]-n["_"+h[l]])>m){return false}}return true};i.toJSON=new Function("return ['"+k+"', "+h.map(function(l){return"this._"+l},this).join(", ")+"];");for(var g in j){if(j.hasOwnProperty(g)){var f=g.match(/^from(.*)$/);if(f){one.color[f[1].toUpperCase()].prototype[k.toLowerCase()]=j[g]}else{i[g]=j[g]}}}i[k.toLowerCase()]=function(){return this};i.toString=new Function('return "[one.color.'+k+':"+'+h.map(function(l,m){return'" '+h[m]+'="+this._'+l}).join("+")+'+"]";');h.forEach(function(l,m){i[l]=new Function("value","isDelta","if (typeof value === 'undefined') {return this._"+l+";}if (isDelta) {return new this.constructor("+h.map(function(o,n){return"this._"+o+(l===o?"+value":"")}).join(", ")+");}return new this.constructor("+h.map(function(o,n){return l===o?"value":"this._"+o}).join(", ")+");")});function e(m,l){var n={};n[l.toLowerCase()]=new Function("return this.rgb()."+l.toLowerCase()+"();");one.color[l].propertyNames.forEach(function(p,q){n[p]=new Function("value","isDelta","return this."+l.toLowerCase()+"()."+p+"(value, isDelta);")});for(var o in n){if(n.hasOwnProperty(o)&&one.color[m].prototype[o]===undefined){one.color[m].prototype[o]=n[o]}}}d.forEach(function(l){e(k,l);e(l,k)});d.push(k)}}());(function(){var a=Math.round;one.color.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var b=(a(255*this._red)*65536+a(255*this._green)*256+a(255*this._blue)).toString(16);return"#"+("00000".substr(0,6-b.length))+b},css:function(){return"rgb("+a(255*this._red)+","+a(255*this._green)+","+a(255*this._blue)+")"},cssa:function(){return"rgba("+a(255*this._red)+","+a(255*this._green)+","+a(255*this._blue)+","+this._alpha+")"}})}());one.color.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var h=this._hue,g=this._saturation,l=this._value,e=Math.min(5,Math.floor(h*6)),j=h*6-e,b=l*(1-g),a=l*(1-j*g),m=l*(1-(1-j)*g),c,d,k;switch(e){case 0:c=l;d=m;k=b;break;case 1:c=a;d=l;k=b;break;case 2:c=b;d=l;k=m;break;case 3:c=b;d=a;k=l;break;case 4:c=m;d=b;k=l;break;case 5:c=l;d=b;k=a;break}return new one.color.RGB(c,d,k,this._alpha)},hsl:function(){var b=(2-this._saturation)*this._value,a=this._saturation*this._value,d=b<=1?b:(2-b),c;if(d<1e-9){c=0}else{c=a/d}return new one.color.HSL(this._hue,c,b/2,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,h=this._blue,f=Math.max(a,b,h),c=Math.min(a,b,h),i=f-c,e,d=(f===0)?0:(i/f),g=f;if(i===0){e=0}else{switch(f){case a:e=(b-h)/i/6+(b<h?1:0);break;case b:e=(h-a)/i/6+1/3;break;case h:e=(a-b)/i/6+2/3;break}}return new one.color.HSV(e,d,g,this._alpha)}});one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*((a<=1)?a:2-a),c;if(a+b<1e-9){c=0}else{c=(2*b)/(a+b)}return new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}});if(typeof module!=="undefined"){module.exports=one.color};
if(typeof one==="undefined"){one={include:function(){}}}(function(){var e=[],c=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,b=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,d=new RegExp("^(rgb|hsl|hsv)a?\\("+c.source+","+c.source+","+c.source+"(?:,"+b.source+")?\\)$","i");function a(m){if(Object.prototype.toString.apply(m)==="[object Array]"){if(m[0].length===4){return new a.RGB(m[0]/255,m[1]/255,m[2]/255,m[3]/255)}else{return new a[m[0]](m.slice(1,m.length))}}else{if(m.charCodeAt){var j=m.match(d);if(j){var n=j[1].toUpperCase(),l=typeof j[8]==="undefined"?j[8]:parseFloat(j[8]),f=n[0]==="H",h=j[3]?100:(f?360:255),i=(j[5]||f)?100:255,k=(j[7]||f)?100:255;if(typeof a[n]==="undefined"){throw new Error("one.color."+n+" is not installed.")}return new a[n](parseFloat(j[2])/h,parseFloat(j[4])/i,parseFloat(j[6])/k,l)}if(m.length<6){m=m.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3")}var g=m.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(g){return new a.RGB(parseInt(g[1],16)/255,parseInt(g[2],16)/255,parseInt(g[3],16)/255)}}else{if(typeof m==="object"&&m.isColor){return m}else{if(!isNaN(m)){return new a.RGB((m&255)/255,((m&65280)>>8)/255,((m&16711680)>>16)/255)}}}}return false}a.installColorSpace=function(l,i,k){a[l]=new Function(i.join(","),"if (Object.prototype.toString.apply("+i[0]+") === '[object Array]') {"+i.map(function(m,n){return m+"="+i[0]+"["+n+"];"}).reverse().join("")+"}if ("+i.filter(function(m){return m!=="alpha"}).map(function(m){return"isNaN("+m+")"}).join("||")+'){throw new Error("[one.color.'+l+']: Invalid color: ("+'+i.join('+","+')+'+")");}'+i.map(function(m){if(m==="hue"){return"this._hue=hue<0?hue-Math.floor(hue):hue%1"}else{if(m==="alpha"){return"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);"}else{return"this._"+m+"="+m+"<0?0:("+m+">1?1:"+m+")"}}}).join(";")+";");a[l].propertyNames=i;var j=a[l].prototype;["valueOf","hex","css","cssa"].forEach(function(m){j[m]=j[m]||(l==="RGB"?j.hex:new Function("return this.rgb()."+m+"();"))});j.isColor=true;j.equals=function(o,n){if(typeof n==="undefined"){n=1e-10}o=o[l.toLowerCase()]();for(var m=0;m<i.length;m=m+1){if(Math.abs(this["_"+i[m]]-o["_"+i[m]])>n){return false}}return true};j.toJSON=new Function("return ['"+l+"', "+i.map(function(m){return"this._"+m},this).join(", ")+"];");for(var h in k){if(k.hasOwnProperty(h)){var g=h.match(/^from(.*)$/);if(g){a[g[1].toUpperCase()].prototype[l.toLowerCase()]=k[h]}else{j[h]=k[h]}}}j[l.toLowerCase()]=function(){return this};j.toString=new Function('return "[one.color.'+l+':"+'+i.map(function(m,n){return'" '+i[n]+'="+this._'+m}).join("+")+'+"]";');i.forEach(function(m,n){j[m]=new Function("value","isDelta","if (typeof value === 'undefined') {return this._"+m+";}if (isDelta) {return new this.constructor("+i.map(function(p,o){return"this._"+p+(m===p?"+value":"")}).join(", ")+");}return new this.constructor("+i.map(function(p,o){return m===p?"value":"this._"+p}).join(", ")+");")});function f(n,m){var o={};o[m.toLowerCase()]=new Function("return this.rgb()."+m.toLowerCase()+"();");a[m].propertyNames.forEach(function(q,r){o[q]=new Function("value","isDelta","return this."+m.toLowerCase()+"()."+q+"(value, isDelta);")});for(var p in o){if(o.hasOwnProperty(p)&&a[n].prototype[p]===undefined){a[n].prototype[p]=o[p]}}}e.forEach(function(m){f(l,m);f(m,l)});e.push(l)};one.color=a}());(function(){var a=Math.round;one.color.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var b=(a(255*this._red)*65536+a(255*this._green)*256+a(255*this._blue)).toString(16);return"#"+("00000".substr(0,6-b.length))+b},css:function(){return"rgb("+a(255*this._red)+","+a(255*this._green)+","+a(255*this._blue)+")"},cssa:function(){return"rgba("+a(255*this._red)+","+a(255*this._green)+","+a(255*this._blue)+","+this._alpha+")"}})}());one.color.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var h=this._hue,g=this._saturation,l=this._value,e=Math.min(5,Math.floor(h*6)),j=h*6-e,b=l*(1-g),a=l*(1-j*g),m=l*(1-(1-j)*g),c,d,k;switch(e){case 0:c=l;d=m;k=b;break;case 1:c=a;d=l;k=b;break;case 2:c=b;d=l;k=m;break;case 3:c=b;d=a;k=l;break;case 4:c=m;d=b;k=l;break;case 5:c=l;d=b;k=a;break}return new one.color.RGB(c,d,k,this._alpha)},hsl:function(){var b=(2-this._saturation)*this._value,a=this._saturation*this._value,d=b<=1?b:(2-b),c;if(d<1e-9){c=0}else{c=a/d}return new one.color.HSL(this._hue,c,b/2,this._alpha)},fromRgb:function(){var a=this._red,b=this._green,h=this._blue,f=Math.max(a,b,h),c=Math.min(a,b,h),i=f-c,e,d=(f===0)?0:(i/f),g=f;if(i===0){e=0}else{switch(f){case a:e=(b-h)/i/6+(b<h?1:0);break;case b:e=(h-a)/i/6+1/3;break;case h:e=(a-b)/i/6+2/3;break}}return new one.color.HSV(e,d,g,this._alpha)}});one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*((a<=1)?a:2-a),c;if(a+b<1e-9){c=0}else{c=(2*b)/(a+b)}return new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}});if(typeof module!=="undefined"){module.exports=one.color};

@@ -5,7 +5,7 @@ {

"repository": "git@github.com:One-com/one-color.git",
"version": "2.0.3",
"version": "2.0.4",
"maintainers": [
{
"name": "Peter Müller",
"email": "pm@one.com"
"email": "munter@fumle.dk"
},

@@ -12,0 +12,0 @@ {

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