@oscarpalmer/atoms 0.190.0 → 0.192.0
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.
- package/dist/beacon.d.mts +6 -44
- package/dist/beacon.mjs +20 -67
- package/dist/color/constants.d.mts +82 -35
- package/dist/color/constants.mjs +106 -61
- package/dist/color/index.d.mts +3 -3
- package/dist/color/index.mjs +2 -2
- package/dist/color/instance.mjs +60 -35
- package/dist/color/misc/alpha.d.mts +1 -1
- package/dist/color/misc/alpha.mjs +12 -10
- package/dist/color/misc/format.d.mts +7 -0
- package/dist/color/misc/format.mjs +20 -0
- package/dist/color/misc/get.mjs +25 -25
- package/dist/color/misc/is.d.mts +0 -36
- package/dist/color/misc/is.mjs +22 -57
- package/dist/color/misc/state.d.mts +8 -6
- package/dist/color/misc/state.mjs +79 -88
- package/dist/color/models.d.mts +106 -6
- package/dist/color/space/hex.d.mts +3 -2
- package/dist/color/space/hex.mjs +22 -10
- package/dist/color/space/hsl.d.mts +3 -2
- package/dist/color/space/hsl.mjs +26 -14
- package/dist/color/space/hwb.d.mts +3 -2
- package/dist/color/space/hwb.mjs +20 -8
- package/dist/color/space/rgb.d.mts +3 -2
- package/dist/color/space/rgb.mjs +27 -15
- package/dist/herald.d.mts +2 -3
- package/dist/index.d.mts +139 -73
- package/dist/index.mjs +653 -477
- package/dist/internal/subscription.d.mts +52 -0
- package/dist/internal/subscription.mjs +127 -0
- package/dist/models.d.mts +5 -1
- package/package.json +4 -4
- package/src/beacon.ts +32 -117
- package/src/color/constants.ts +115 -66
- package/src/color/index.ts +26 -8
- package/src/color/instance.ts +113 -45
- package/src/color/misc/alpha.ts +18 -20
- package/src/color/misc/format.ts +29 -0
- package/src/color/misc/get.ts +31 -41
- package/src/color/misc/is.ts +31 -71
- package/src/color/misc/state.ts +165 -141
- package/src/color/models.ts +126 -5
- package/src/color/space/hex.ts +46 -18
- package/src/color/space/hsl.ts +44 -14
- package/src/color/space/hwb.ts +38 -8
- package/src/color/space/rgb.ts +48 -15
- package/src/herald.ts +1 -3
- package/src/index.ts +1 -0
- package/src/internal/subscription.ts +264 -0
- package/src/models.ts +5 -0
- package/src/string/fuzzy.ts +1 -1
- package/src/value/freeze.ts +2 -2
- package/src/value/shake.ts +1 -1
- package/src/value/transform.ts +1 -1
- package/dist/color/misc/index.d.mts +0 -7
- package/dist/color/misc/index.mjs +0 -15
- package/src/color/misc/index.ts +0 -29
package/dist/beacon.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Subscription } from "./internal/subscription.mjs";
|
|
1
2
|
//#region src/beacon.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
|
|
@@ -7,10 +8,6 @@ type Beacon<Value> = {
|
|
|
7
8
|
* Is the beacon active?
|
|
8
9
|
*/
|
|
9
10
|
get active(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Is the beacon closed?
|
|
12
|
-
*/
|
|
13
|
-
get closed(): boolean;
|
|
14
11
|
/**
|
|
15
12
|
* The observable that can be subscribed to
|
|
16
13
|
*/
|
|
@@ -20,9 +17,9 @@ type Beacon<Value> = {
|
|
|
20
17
|
*/
|
|
21
18
|
get value(): Value;
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
20
|
+
* Deactivate the beacon
|
|
24
21
|
*/
|
|
25
|
-
|
|
22
|
+
deactivate(): void;
|
|
26
23
|
/**
|
|
27
24
|
* Emit a new value
|
|
28
25
|
*
|
|
@@ -42,9 +39,6 @@ type Beacon<Value> = {
|
|
|
42
39
|
*/
|
|
43
40
|
finish(): void;
|
|
44
41
|
};
|
|
45
|
-
/**
|
|
46
|
-
* Options for Beacon
|
|
47
|
-
*/
|
|
48
42
|
type BeaconOptions<Value> = {
|
|
49
43
|
/**
|
|
50
44
|
* Method for comparing values for equality
|
|
@@ -62,13 +56,9 @@ type Observable<Value> = {
|
|
|
62
56
|
*/
|
|
63
57
|
get active(): boolean;
|
|
64
58
|
/**
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
get closed(): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Close the observable
|
|
59
|
+
* Deactivate the observable
|
|
70
60
|
*/
|
|
71
|
-
|
|
61
|
+
deactivate(): void;
|
|
72
62
|
/**
|
|
73
63
|
* Subscribe to value changes
|
|
74
64
|
*
|
|
@@ -86,9 +76,6 @@ type Observable<Value> = {
|
|
|
86
76
|
*/
|
|
87
77
|
subscribe(observer: Observer<Value>): Subscription;
|
|
88
78
|
};
|
|
89
|
-
/**
|
|
90
|
-
* An observer receives notifications from an observable
|
|
91
|
-
*/
|
|
92
79
|
type Observer<Value> = {
|
|
93
80
|
/**
|
|
94
81
|
* Callback for when the observable is completed
|
|
@@ -103,24 +90,6 @@ type Observer<Value> = {
|
|
|
103
90
|
*/
|
|
104
91
|
next?: (value: Value) => void;
|
|
105
92
|
};
|
|
106
|
-
type Subscription = {
|
|
107
|
-
/**
|
|
108
|
-
* Is the subscription active?
|
|
109
|
-
*/
|
|
110
|
-
get active(): boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Is the subscription closed?
|
|
113
|
-
*/
|
|
114
|
-
get closed(): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Close the subscription
|
|
117
|
-
*/
|
|
118
|
-
close(): void;
|
|
119
|
-
/**
|
|
120
|
-
* Unsubscribe from its observable
|
|
121
|
-
*/
|
|
122
|
-
unsubscribe(): void;
|
|
123
|
-
};
|
|
124
93
|
/**
|
|
125
94
|
* Create a new beacon
|
|
126
95
|
*
|
|
@@ -143,12 +112,5 @@ declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Valu
|
|
|
143
112
|
* @returns `true` if the value is an observable, otherwise `false`
|
|
144
113
|
*/
|
|
145
114
|
declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
|
|
146
|
-
/**
|
|
147
|
-
* Is the value a subscription?
|
|
148
|
-
*
|
|
149
|
-
* @param value Value to check
|
|
150
|
-
* @returns `true` if the value is a subscription, otherwise `false`
|
|
151
|
-
*/
|
|
152
|
-
declare function isSubscription(value: unknown): value is Subscription;
|
|
153
115
|
//#endregion
|
|
154
|
-
export { Beacon, BeaconOptions, Observable,
|
|
116
|
+
export { Beacon, BeaconOptions, Observable, beacon, isBeacon, isObservable };
|
package/dist/beacon.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { noop } from "./internal/function/misc.mjs";
|
|
2
2
|
import { isPlainObject } from "./internal/is.mjs";
|
|
3
|
+
import { clearSubscriptions, getSubscription, getSubscriptions } from "./internal/subscription.mjs";
|
|
3
4
|
//#region src/beacon.ts
|
|
4
5
|
/**
|
|
5
6
|
* Create a new beacon
|
|
@@ -13,11 +14,11 @@ function beacon(value, options) {
|
|
|
13
14
|
value,
|
|
14
15
|
active: true,
|
|
15
16
|
observable: void 0,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
options: getBeaconOptions(options),
|
|
18
|
+
subscriptions: getSubscriptions()
|
|
18
19
|
};
|
|
19
20
|
const instance = {
|
|
20
|
-
|
|
21
|
+
deactivate: () => {
|
|
21
22
|
finishBeacon(state, false);
|
|
22
23
|
},
|
|
23
24
|
emit: (value, finish) => {
|
|
@@ -39,10 +40,6 @@ function beacon(value, options) {
|
|
|
39
40
|
enumerable: true,
|
|
40
41
|
get: () => state.active
|
|
41
42
|
},
|
|
42
|
-
closed: {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: () => !state.active
|
|
45
|
-
},
|
|
46
43
|
observable: {
|
|
47
44
|
enumerable: true,
|
|
48
45
|
get: () => {
|
|
@@ -61,15 +58,9 @@ function beacon(value, options) {
|
|
|
61
58
|
function finishBeacon(state, emit) {
|
|
62
59
|
if (!state.active) return;
|
|
63
60
|
state.active = false;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const [subscription, observer] = entries[index];
|
|
68
|
-
if (emit) observer.complete?.();
|
|
69
|
-
subscription.close();
|
|
70
|
-
}
|
|
71
|
-
state.observable?.close();
|
|
72
|
-
state.observers.clear();
|
|
61
|
+
for (const [, observer] of state.subscriptions.values.to.any) if (emit) observer.complete?.();
|
|
62
|
+
clearSubscriptions(state.subscriptions);
|
|
63
|
+
state.observable?.deactivate();
|
|
73
64
|
state.observable = void 0;
|
|
74
65
|
}
|
|
75
66
|
function getBeaconOptions(input) {
|
|
@@ -115,29 +106,24 @@ function isBeaconInstance(name, value) {
|
|
|
115
106
|
function isObservable(value) {
|
|
116
107
|
return isBeaconInstance(NAME_OBSERVABLE, value);
|
|
117
108
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Is the value a subscription?
|
|
120
|
-
*
|
|
121
|
-
* @param value Value to check
|
|
122
|
-
* @returns `true` if the value is a subscription, otherwise `false`
|
|
123
|
-
*/
|
|
124
|
-
function isSubscription(value) {
|
|
125
|
-
return isBeaconInstance(NAME_SUBSCRIPTION, value);
|
|
126
|
-
}
|
|
127
109
|
function observe(beacon) {
|
|
128
110
|
const state = {
|
|
129
111
|
beacon,
|
|
130
112
|
active: beacon.active
|
|
131
113
|
};
|
|
132
114
|
const instance = {
|
|
133
|
-
|
|
115
|
+
deactivate: () => {
|
|
134
116
|
state.active = false;
|
|
135
117
|
},
|
|
136
118
|
subscribe(first, second, third) {
|
|
137
119
|
if (!beacon.active || !state.active) throw new Error(MESSAGE_OBSERVABLE);
|
|
138
120
|
const observer = getObserver(first, second, third);
|
|
139
|
-
const subscription =
|
|
140
|
-
|
|
121
|
+
const subscription = getSubscription({
|
|
122
|
+
isActive: () => beacon.active && state.active,
|
|
123
|
+
property: beaconSubscription,
|
|
124
|
+
subscriptions: beacon.subscriptions,
|
|
125
|
+
value: observer
|
|
126
|
+
});
|
|
141
127
|
observer.next?.(beacon.value);
|
|
142
128
|
return subscription;
|
|
143
129
|
}
|
|
@@ -150,42 +136,6 @@ function observe(beacon) {
|
|
|
150
136
|
active: {
|
|
151
137
|
enumerable: true,
|
|
152
138
|
get: () => beacon.active && state.active
|
|
153
|
-
},
|
|
154
|
-
closed: {
|
|
155
|
-
enumerable: true,
|
|
156
|
-
get: () => !beacon.active || !state.active
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return Object.freeze(instance);
|
|
160
|
-
}
|
|
161
|
-
function subscribe(observable) {
|
|
162
|
-
function unsubscribe() {
|
|
163
|
-
if (active) {
|
|
164
|
-
active = false;
|
|
165
|
-
observable.beacon.observers.delete(instance);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
let active = true;
|
|
169
|
-
const instance = {
|
|
170
|
-
close: () => {
|
|
171
|
-
unsubscribe();
|
|
172
|
-
},
|
|
173
|
-
unsubscribe: () => {
|
|
174
|
-
unsubscribe();
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
Object.defineProperties(instance, {
|
|
178
|
-
[KEY_BEACON]: {
|
|
179
|
-
enumerable: false,
|
|
180
|
-
value: NAME_SUBSCRIPTION
|
|
181
|
-
},
|
|
182
|
-
active: {
|
|
183
|
-
enumerable: true,
|
|
184
|
-
get: () => observable.beacon.active && observable.active && active
|
|
185
|
-
},
|
|
186
|
-
closed: {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: () => !observable.beacon.active || !observable.active || !active
|
|
189
139
|
}
|
|
190
140
|
});
|
|
191
141
|
return Object.freeze(instance);
|
|
@@ -196,7 +146,7 @@ function update(type, state, value, finish) {
|
|
|
196
146
|
if (state.options.equal(state.value, value)) return;
|
|
197
147
|
state.value = value;
|
|
198
148
|
}
|
|
199
|
-
for (const [, observer] of state.
|
|
149
|
+
for (const [, observer] of state.subscriptions.values.to.any) observer[type]?.(value);
|
|
200
150
|
if (finish === true) finishBeacon(state, true);
|
|
201
151
|
}
|
|
202
152
|
const KEY_BEACON = "$beacon";
|
|
@@ -204,8 +154,11 @@ const MESSAGE_BEACON = "Cannot retrieve observable from a closed beacon";
|
|
|
204
154
|
const MESSAGE_OBSERVABLE = "Cannot subscribe to a closed observable";
|
|
205
155
|
const NAME_BEACON = "beacon";
|
|
206
156
|
const NAME_OBSERVABLE = "observable";
|
|
207
|
-
const NAME_SUBSCRIPTION = "subscription";
|
|
208
157
|
const TYPE_ERROR = "error";
|
|
209
158
|
const TYPE_NEXT = "next";
|
|
159
|
+
const beaconSubscription = {
|
|
160
|
+
key: KEY_BEACON,
|
|
161
|
+
value: "subscription"
|
|
162
|
+
};
|
|
210
163
|
//#endregion
|
|
211
|
-
export { beacon, isBeacon, isObservable
|
|
164
|
+
export { beacon, isBeacon, isObservable };
|
|
@@ -1,37 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
|
|
2
2
|
//#region src/color/constants.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
declare const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
3
|
+
type ColorTypes = {
|
|
4
|
+
all: Set<'alpha' | ColorTypeExtended>;
|
|
5
|
+
hex: 'hex';
|
|
6
|
+
hexa: 'hexa';
|
|
7
|
+
hsl: 'hsl';
|
|
8
|
+
hsla: 'hsla';
|
|
9
|
+
hwb: 'hwb';
|
|
10
|
+
hwba: 'hwba';
|
|
11
|
+
rgb: 'rgb';
|
|
12
|
+
rgba: 'rgba';
|
|
13
|
+
};
|
|
14
|
+
declare const COLOR_ALPHA: {
|
|
15
|
+
fullHexShort: string;
|
|
16
|
+
fullHexLong: string;
|
|
17
|
+
name: string;
|
|
18
|
+
noneHex: string;
|
|
19
|
+
noneValue: number;
|
|
20
|
+
};
|
|
21
|
+
declare const COLOR_DEFAULTS: {
|
|
22
|
+
alpha: {
|
|
23
|
+
hex: string;
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
hexBlack: string;
|
|
27
|
+
hexWhite: string;
|
|
28
|
+
hsl: {
|
|
29
|
+
hue: number;
|
|
30
|
+
saturation: number;
|
|
31
|
+
lightness: number;
|
|
32
|
+
};
|
|
33
|
+
hwb: {
|
|
34
|
+
hue: number;
|
|
35
|
+
whiteness: number;
|
|
36
|
+
blackness: number;
|
|
37
|
+
};
|
|
38
|
+
rgb: {
|
|
39
|
+
blue: number;
|
|
40
|
+
green: number;
|
|
41
|
+
red: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
declare const COLOR_EXPRESSION: {
|
|
45
|
+
alphaHex: RegExp;
|
|
46
|
+
hexLong: RegExp;
|
|
47
|
+
hexShort: RegExp;
|
|
48
|
+
prefix: RegExp;
|
|
49
|
+
};
|
|
50
|
+
declare const COLOR_LENGTHS: {
|
|
51
|
+
hexLong: number;
|
|
52
|
+
hexShort: number;
|
|
53
|
+
};
|
|
54
|
+
declare const COLOR_KEYS: {
|
|
55
|
+
hsl: Array<keyof HSLColor>;
|
|
56
|
+
hsla: Array<keyof HSLAColor>;
|
|
57
|
+
hwb: Array<keyof HWBColor>;
|
|
58
|
+
hwba: Array<keyof HWBAColor>;
|
|
59
|
+
rgb: Array<keyof RGBColor>;
|
|
60
|
+
rgba: Array<keyof RGBAColor>;
|
|
61
|
+
};
|
|
62
|
+
declare const COLOR_MAX: {
|
|
63
|
+
degree: number;
|
|
64
|
+
hex: number;
|
|
65
|
+
percent: number;
|
|
66
|
+
};
|
|
67
|
+
declare const COLOR_PROPERTY: {
|
|
68
|
+
name: string;
|
|
69
|
+
subscription: string;
|
|
70
|
+
};
|
|
71
|
+
declare const COLOR_TYPE: ColorTypes;
|
|
72
|
+
declare const COLOR_SRGB: {
|
|
73
|
+
luminanceBlue: number;
|
|
74
|
+
luminanceExponent: number;
|
|
75
|
+
luminanceGreen: number;
|
|
76
|
+
luminanceMinimum: number;
|
|
77
|
+
luminanceModifier: number;
|
|
78
|
+
luminanceMultiplier: number;
|
|
79
|
+
luminanceOffset: number;
|
|
80
|
+
luminanceRed: number;
|
|
81
|
+
luminanceThreshold: number;
|
|
82
|
+
};
|
|
36
83
|
//#endregion
|
|
37
|
-
export {
|
|
84
|
+
export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_PROPERTY, COLOR_SRGB, COLOR_TYPE };
|
package/dist/color/constants.mjs
CHANGED
|
@@ -1,63 +1,108 @@
|
|
|
1
1
|
//#region src/color/constants.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
const COLOR_ALPHA = {
|
|
3
|
+
fullHexShort: "f",
|
|
4
|
+
fullHexLong: "ff",
|
|
5
|
+
name: "alpha",
|
|
6
|
+
noneHex: "00",
|
|
7
|
+
noneValue: 0
|
|
8
|
+
};
|
|
9
|
+
const COLOR_DEFAULTS = {
|
|
10
|
+
alpha: {
|
|
11
|
+
hex: COLOR_ALPHA.fullHexLong,
|
|
12
|
+
value: 100
|
|
13
|
+
},
|
|
14
|
+
hexBlack: "000000",
|
|
15
|
+
hexWhite: "ffffff",
|
|
16
|
+
hsl: {
|
|
17
|
+
hue: 0,
|
|
18
|
+
saturation: 0,
|
|
19
|
+
lightness: 0
|
|
20
|
+
},
|
|
21
|
+
hwb: {
|
|
22
|
+
hue: 0,
|
|
23
|
+
whiteness: 0,
|
|
24
|
+
blackness: 100
|
|
25
|
+
},
|
|
26
|
+
rgb: {
|
|
27
|
+
blue: 0,
|
|
28
|
+
green: 0,
|
|
29
|
+
red: 0
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const COLOR_EXPRESSION = {
|
|
33
|
+
alphaHex: /^([a-f0-9]{1,2})$/i,
|
|
34
|
+
hexLong: /^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?$/i,
|
|
35
|
+
hexShort: /^#?([a-f0-9]{3,4})$/i,
|
|
36
|
+
prefix: /^#/
|
|
37
|
+
};
|
|
38
|
+
const COLOR_LENGTHS = {
|
|
39
|
+
hexLong: 6,
|
|
40
|
+
hexShort: 3
|
|
41
|
+
};
|
|
42
|
+
const COLOR_KEYS = {
|
|
43
|
+
hsl: [
|
|
44
|
+
"hue",
|
|
45
|
+
"saturation",
|
|
46
|
+
"lightness"
|
|
47
|
+
],
|
|
48
|
+
hsla: [],
|
|
49
|
+
hwb: [
|
|
50
|
+
"hue",
|
|
51
|
+
"whiteness",
|
|
52
|
+
"blackness"
|
|
53
|
+
],
|
|
54
|
+
hwba: [],
|
|
55
|
+
rgb: [
|
|
56
|
+
"red",
|
|
57
|
+
"green",
|
|
58
|
+
"blue"
|
|
59
|
+
],
|
|
60
|
+
rgba: []
|
|
61
|
+
};
|
|
62
|
+
COLOR_KEYS.hsla = [...COLOR_KEYS.hsl, COLOR_ALPHA.name];
|
|
63
|
+
COLOR_KEYS.hwba = [...COLOR_KEYS.hwb, COLOR_ALPHA.name];
|
|
64
|
+
COLOR_KEYS.rgba = [...COLOR_KEYS.rgb, COLOR_ALPHA.name];
|
|
65
|
+
const COLOR_MAX = {
|
|
66
|
+
degree: 360,
|
|
67
|
+
hex: 255,
|
|
68
|
+
percent: 100
|
|
69
|
+
};
|
|
70
|
+
const COLOR_PROPERTY = {
|
|
71
|
+
name: "$color",
|
|
72
|
+
subscription: "subscription"
|
|
73
|
+
};
|
|
74
|
+
const COLOR_TYPE = {
|
|
75
|
+
all: void 0,
|
|
76
|
+
hex: "hex",
|
|
77
|
+
hexa: "hexa",
|
|
78
|
+
hsl: "hsl",
|
|
79
|
+
hsla: "hsla",
|
|
80
|
+
hwb: "hwb",
|
|
81
|
+
hwba: "hwba",
|
|
82
|
+
rgb: "rgb",
|
|
83
|
+
rgba: "rgba"
|
|
84
|
+
};
|
|
85
|
+
COLOR_TYPE.all = /* @__PURE__ */ new Set([
|
|
86
|
+
COLOR_ALPHA.name,
|
|
87
|
+
COLOR_TYPE.hex,
|
|
88
|
+
COLOR_TYPE.hexa,
|
|
89
|
+
COLOR_TYPE.hsl,
|
|
90
|
+
COLOR_TYPE.hsla,
|
|
91
|
+
COLOR_TYPE.hwb,
|
|
92
|
+
COLOR_TYPE.hwba,
|
|
93
|
+
COLOR_TYPE.rgb,
|
|
94
|
+
COLOR_TYPE.rgba
|
|
95
|
+
]);
|
|
96
|
+
const COLOR_SRGB = {
|
|
97
|
+
luminanceBlue: .0722,
|
|
98
|
+
luminanceExponent: 2.4,
|
|
99
|
+
luminanceGreen: .7152,
|
|
100
|
+
luminanceMinimum: .03928,
|
|
101
|
+
luminanceModifier: 1.055,
|
|
102
|
+
luminanceMultiplier: 12.92,
|
|
103
|
+
luminanceOffset: .055,
|
|
104
|
+
luminanceRed: .2126,
|
|
105
|
+
luminanceThreshold: .625
|
|
106
|
+
};
|
|
62
107
|
//#endregion
|
|
63
|
-
export {
|
|
108
|
+
export { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX, COLOR_PROPERTY, COLOR_SRGB, COLOR_TYPE };
|
package/dist/color/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
|
|
1
|
+
import { Color, ColorType, ColorTypeExtended, ColorValue, ColorValueExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
|
|
2
2
|
import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
|
|
3
|
-
import { isColor, isHexColor, isHslColor,
|
|
3
|
+
import { isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor } from "./misc/is.mjs";
|
|
4
4
|
import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
|
|
5
5
|
import { hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba } from "./space/hsl.mjs";
|
|
6
6
|
import { hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba } from "./space/hwb.mjs";
|
|
@@ -17,4 +17,4 @@ import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.
|
|
|
17
17
|
*/
|
|
18
18
|
declare function getColor(value: unknown): Color;
|
|
19
19
|
//#endregion
|
|
20
|
-
export { type Color, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, type RGBAColor, type RGBColor, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor,
|
|
20
|
+
export { type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, type RGBAColor, type RGBColor, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
|
package/dist/color/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
|
|
2
|
-
import { isColor, isHexColor, isHslColor,
|
|
2
|
+
import { isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor } from "./misc/is.mjs";
|
|
3
3
|
import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.mjs";
|
|
4
4
|
import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
|
|
5
5
|
import { hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba } from "./space/hsl.mjs";
|
|
@@ -19,4 +19,4 @@ function getColor(value) {
|
|
|
19
19
|
return isColor(value) ? value : color(value);
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
|
-
export { getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor,
|
|
22
|
+
export { getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
|