Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix UMD build #349

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions dist/chroma-light.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
*/

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory());
})(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.chroma = {}));
})(this, (function (exports) { 'use strict';

function limit (x, low, high) {
if ( high === void 0 ) high = 1;
Expand Down Expand Up @@ -183,16 +183,15 @@
};

// this gets updated automatically
var version = '2.6.0';
var version = '2.6.1-0';

var chroma = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) ));
return new (Function.prototype.bind.apply( Color, [ null ].concat( args) ));
};

chroma.Color = Color;
chroma.version = version;

var rnd = function (a) { return Math.round(a * 100) / 100; };
Expand Down Expand Up @@ -270,7 +269,7 @@
return [h, s, l];
};

var round$4 = Math.round;
var round$3 = Math.round;

/*
* supported arguments:
Expand All @@ -289,18 +288,16 @@
if (mode.substr(0, 3) == 'hsl') {
return hsl2css(rgb2hsl(rgba), mode);
}
rgba[0] = round$4(rgba[0]);
rgba[1] = round$4(rgba[1]);
rgba[2] = round$4(rgba[2]);
rgba[0] = round$3(rgba[0]);
rgba[1] = round$3(rgba[1]);
rgba[2] = round$3(rgba[2]);
if (mode === 'rgba' || (rgba.length > 3 && rgba[3] < 1)) {
rgba[3] = rgba.length > 3 ? rgba[3] : 1;
mode = 'rgba';
}
return (mode + "(" + (rgba.slice(0, mode === 'rgb' ? 3 : 4).join(',')) + ")");
};

var round$3 = Math.round;

var hsl2rgb = function () {
var assign;

Expand Down Expand Up @@ -330,7 +327,7 @@
else if (3 * t3[i] < 2) { c[i] = t1 + (t2 - t1) * (2 / 3 - t3[i]) * 6; }
else { c[i] = t1; }
}
(assign = [round$3(c[0] * 255), round$3(c[1] * 255), round$3(c[2] * 255)], r = assign[0], g = assign[1], b = assign[2]);
(assign = [c[0] * 255, c[1] * 255, c[2] * 255], r = assign[0], g = assign[1], b = assign[2]);
}
if (args.length > 3) {
// keep alpha channel
Expand Down Expand Up @@ -409,6 +406,9 @@
hsl[1] *= 0.01;
hsl[2] *= 0.01;
var rgb$4 = hsl2rgb(hsl);
for (var i$4 = 0; i$4 < 3; i$4++) {
rgb$4[i$4] = round$2(rgb$4[i$4]);
}
rgb$4[3] = 1;
return rgb$4;
}
Expand All @@ -419,6 +419,9 @@
hsl$1[1] *= 0.01;
hsl$1[2] *= 0.01;
var rgb$5 = hsl2rgb(hsl$1);
for (var i$5 = 0; i$5 < 3; i$5++) {
rgb$5[i$5] = round$2(rgb$5[i$5]);
}
rgb$5[3] = +m[4]; // default alpha = 1
return rgb$5;
}
Expand Down Expand Up @@ -1076,9 +1079,19 @@
}
}

chroma.mix = chroma.interpolate = mix;
chroma.valid = valid;
Object.assign(chroma, {
Color: Color,
valid: valid,
mix: mix,
interpolate: mix
});

exports.Color = Color;
exports.default = chroma;
exports.interpolate = mix;
exports.mix = mix;
exports.valid = valid;

return chroma;
Object.defineProperty(exports, '__esModule', { value: true });

}));
2 changes: 1 addition & 1 deletion dist/chroma-light.min.cjs

Large diffs are not rendered by default.

75 changes: 50 additions & 25 deletions dist/chroma.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
*/

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.chroma = factory());
})(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.chroma = {}));
})(this, (function (exports) { 'use strict';

function limit (x, low, high) {
if ( low === void 0 ) low = 0;
Expand Down Expand Up @@ -190,16 +190,15 @@
};

// this gets updated automatically
var version = '2.6.0';
var version = '2.6.1-0';

var chroma = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return new (Function.prototype.bind.apply( chroma.Color, [ null ].concat( args) ));
return new (Function.prototype.bind.apply( Color, [ null ].concat( args) ));
};

chroma.Color = Color;
chroma.version = version;

var cmyk2rgb = function () {
Expand Down Expand Up @@ -343,7 +342,7 @@
return [h, s, l];
};

var round$6 = Math.round;
var round$5 = Math.round;

/*
* supported arguments:
Expand All @@ -362,18 +361,16 @@
if (mode.substr(0, 3) == 'hsl') {
return hsl2css(rgb2hsl$1(rgba), mode);
}
rgba[0] = round$6(rgba[0]);
rgba[1] = round$6(rgba[1]);
rgba[2] = round$6(rgba[2]);
rgba[0] = round$5(rgba[0]);
rgba[1] = round$5(rgba[1]);
rgba[2] = round$5(rgba[2]);
if (mode === 'rgba' || (rgba.length > 3 && rgba[3] < 1)) {
rgba[3] = rgba.length > 3 ? rgba[3] : 1;
mode = 'rgba';
}
return (mode + "(" + (rgba.slice(0, mode === 'rgb' ? 3 : 4).join(',')) + ")");
};

var round$5 = Math.round;

var hsl2rgb = function () {
var assign;

Expand Down Expand Up @@ -403,7 +400,7 @@
else if (3 * t3[i] < 2) { c[i] = t1 + (t2 - t1) * (2 / 3 - t3[i]) * 6; }
else { c[i] = t1; }
}
(assign = [round$5(c[0] * 255), round$5(c[1] * 255), round$5(c[2] * 255)], r = assign[0], g = assign[1], b = assign[2]);
(assign = [c[0] * 255, c[1] * 255, c[2] * 255], r = assign[0], g = assign[1], b = assign[2]);
}
if (args.length > 3) {
// keep alpha channel
Expand Down Expand Up @@ -482,6 +479,9 @@
hsl[1] *= 0.01;
hsl[2] *= 0.01;
var rgb$4 = hsl2rgb(hsl);
for (var i$4 = 0; i$4 < 3; i$4++) {
rgb$4[i$4] = round$4(rgb$4[i$4]);
}
rgb$4[3] = 1;
return rgb$4;
}
Expand All @@ -492,6 +492,9 @@
hsl$1[1] *= 0.01;
hsl$1[2] *= 0.01;
var rgb$5 = hsl2rgb(hsl$1);
for (var i$5 = 0; i$5 < 3; i$5++) {
rgb$5[i$5] = round$4(rgb$5[i$5]);
}
rgb$5[3] = +m[4]; // default alpha = 1
return rgb$5;
}
Expand Down Expand Up @@ -3362,26 +3365,48 @@
}

Object.assign(chroma, {
analyze: analyze,
average: average,
bezier: bezier$1,
blend: blend,
cubehelix: cubehelix,
mix: mix,
interpolate: mix,
random: random$1,
scale: scale,
analyze: analyze,
brewer: colorbrewer,
Color: Color,
colors: w3cx11,
contrast: contrast,
cubehelix: cubehelix,
deltaE: deltaE,
distance: distance,
input: input,
interpolate: mix,
limits: limits,
valid: valid,
mix: mix,
random: random$1,
scale: scale,
scales: scales,
input: input,
colors: w3cx11,
brewer: colorbrewer
valid: valid
});

return chroma;
exports.Color = Color;
exports.analyze = analyze;
exports.average = average;
exports.bezier = bezier$1;
exports.blend = blend;
exports.brewer = colorbrewer;
exports.colors = w3cx11;
exports.contrast = contrast;
exports.cubehelix = cubehelix;
exports.default = chroma;
exports.deltaE = deltaE;
exports.distance = distance;
exports.input = input;
exports.interpolate = mix;
exports.limits = limits;
exports.mix = mix;
exports.random = random$1;
exports.scale = scale;
exports.scales = scales;
exports.valid = valid;

Object.defineProperty(exports, '__esModule', { value: true });

}));
2 changes: 1 addition & 1 deletion dist/chroma.min.cjs

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
import chroma from './src/chroma.js';

// feel free to comment out anything to rollup
// a smaller chroma.js built
// a smaller chroma.js bundle
import chroma from './src/chroma.js';

// io --> convert colors
import './src/io/cmyk/index.js';
import './src/io/css/index.js';
import './src/io/gl/index.js';
import './src/io/hcg/index.js';
import './src/io/hex/index.js';
import './src/io/hsi/index.js';
import './src/io/hsl/index.js';
import './src/io/hsv/index.js';
import './src/io/lab/index.js';
import './src/io/lch/index.js';
import './src/io/named/index.js';
import './src/io/num/index.js';
import './src/io/rgb/index.js';
import './src/io/temp/index.js';
import './src/io/oklab/index.js';
import './src/io/oklch/index.js';

// operators --> modify existing Colors
import './src/ops/alpha.js';
Expand Down Expand Up @@ -117,3 +101,19 @@ export {
scales,
valid
};

export * from './src/io/cmyk/index.js';
export * from './src/io/css/index.js';
export * from './src/io/gl/index.js';
export * from './src/io/hcg/index.js';
export * from './src/io/hex/index.js';
export * from './src/io/hsi/index.js';
export * from './src/io/hsl/index.js';
export * from './src/io/hsv/index.js';
export * from './src/io/lab/index.js';
export * from './src/io/lch/index.js';
export * from './src/io/num/index.js';
export * from './src/io/rgb/index.js';
export * from './src/io/temp/index.js';
export * from './src/io/oklab/index.js';
export * from './src/io/oklch/index.js';
Loading