@appartmint/tsm-mint 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=16;function u(s){const e=s.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/);if(e){let t=e[1];t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);const r=parseInt(t.substring(0,2),c),a=parseInt(t.substring(2,4),c),i=parseInt(t.substring(4,6),c);return o({r,g:a,b:i})}const n=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)?(?:,\s*(\d(?:\.\d*)?)\s*\))?/);if(n){const t=parseInt(n[1]),r=parseInt(n[2]),a=parseInt(n[3]),i=n[4]?parseFloat(n[4]):void 0;return o({r:t,g:r,b:a,a:i})}throw new Error(`Invalid color: ${s}`)}function o({r:s,g:e,b:n,a:t}){return t===0?262:!isNaN(s)&&!isNaN(e)&&!isNaN(n)?Math.round((s*299+e*587+n*144)/1e3):-1}exports.getLuminance=u;exports.getLuminanceRGBA=o;
@@ -0,0 +1,8 @@
1
+ export interface RGBA {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ a?: number;
6
+ }
7
+ export declare function getLuminance(color: string): number;
8
+ export declare function getLuminanceRGBA({ r, g, b, a }: RGBA): number;
@@ -0,0 +1,22 @@
1
+ function o(n) {
2
+ const e = n.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/);
3
+ if (e) {
4
+ let s = e[1];
5
+ s.length === 3 && (s = s[0] + s[0] + s[1] + s[1] + s[2] + s[2]);
6
+ const r = parseInt(s.substring(0, 2), 16), a = parseInt(s.substring(2, 4), 16), c = parseInt(s.substring(4, 6), 16);
7
+ return i({ r, g: a, b: c });
8
+ }
9
+ const t = n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)?(?:,\s*(\d(?:\.\d*)?)\s*\))?/);
10
+ if (t) {
11
+ const s = parseInt(t[1]), r = parseInt(t[2]), a = parseInt(t[3]), c = t[4] ? parseFloat(t[4]) : void 0;
12
+ return i({ r: s, g: r, b: a, a: c });
13
+ }
14
+ throw new Error(`Invalid color: ${n}`);
15
+ }
16
+ function i({ r: n, g: e, b: t, a: s }) {
17
+ return s === 0 ? 262 : !isNaN(n) && !isNaN(e) && !isNaN(t) ? Math.round((n * 299 + e * 587 + t * 144) / 1e3) : -1;
18
+ }
19
+ export {
20
+ o as getLuminance,
21
+ i as getLuminanceRGBA
22
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appartmint/tsm-mint",
3
3
  "author": "App Art Mint LLC",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "TypeScript Modules from App Art Mint LLC",