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

Merge feature.color-4 into main #330

Merged
merged 33 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9a06ccd
Fetch matching feature branches (#169)
nex3 Dec 14, 2022
d283b3c
Run tests on pushes to feature branches (#171)
nex3 Dec 14, 2022
1454d0a
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Jan 18, 2023
058353e
Poke CI
nex3 Jan 24, 2023
69c4e5e
Poke CI
nex3 Jan 25, 2023
435a181
Make compiler-version -dev
nex3 Jan 26, 2023
7937793
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Jan 27, 2023
50ee2c1
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Aug 2, 2023
275a1a2
Merge branch 'main' of github.com:sass/embedded-host-node into merge-…
nex3 Aug 21, 2023
2b88a8b
Merge pull request #243 from sass/merge-main
nex3 Aug 21, 2023
ec75b8f
Merge branch 'main' of github.com:sass/embedded-host-node into featur…
nex3 Oct 6, 2023
9438f2a
Merge pull request #256 from sass/merge
nex3 Oct 6, 2023
1a1aba0
Merge remote-tracking branch 'origin/main' into merge-main
nex3 Nov 17, 2023
6eda68d
Merge pull request #262 from sass/merge-main
nex3 Nov 17, 2023
8c82e53
[Color 4] Add support for CSS Color Level 4. (#259)
jgerigmeyer Nov 17, 2023
c19bf85
Merge branch 'main' of github.com:sass/embedded-host-node into merge-…
nex3 Mar 27, 2024
00524d8
Update colorjs.io
nex3 Mar 27, 2024
6cdf30a
Reformat
nex3 Mar 27, 2024
1c136de
Merge pull request #277 from sass/merge-main
nex3 Mar 27, 2024
fef63f3
[Color 4] Update behavior to match latest specs (#278)
nex3 Apr 10, 2024
0823b1c
Merge remote-tracking branch 'origin/main' into merge-main
nex3 Apr 11, 2024
a843bd5
Add new deprecations
nex3 Apr 11, 2024
625e11d
Merge pull request #284 from sass/merge-main
nex3 Apr 12, 2024
6e9368e
Fix test regression caused by node fixing CVE-2024-27980 (#286)
ntkme Apr 12, 2024
7d44ff3
Add a method parameter to toGamut (#288)
nex3 Apr 19, 2024
07af8d6
Merge remote-tracking branch 'origin/main' into merge-main
nex3 May 30, 2024
3d9c234
Merge pull request #302 from sass/merge-main
nex3 May 30, 2024
62d5f3f
Merge branch 'main' of github.com:sass/embedded-host-node into featur…
nex3 Aug 12, 2024
d2a3cbc
Fix style issues
nex3 Aug 12, 2024
21c99cb
Merge pull request #324 from sass/merge
nex3 Aug 13, 2024
9f10f60
Merge branch 'main' of github.com:sass/embedded-host-node into featur…
nex3 Sep 11, 2024
ddff73f
Merge pull request #329 from sass/merge-main
nex3 Sep 12, 2024
e146240
Remove -dev from embedded protocol
nex3 Sep 13, 2024
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
104 changes: 79 additions & 25 deletions lib/src/protofier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as proto from './vendor/embedded_sass_pb';
import * as utils from './utils';
import {FunctionRegistry} from './function-registry';
import {SassArgumentList} from './value/argument-list';
import {SassColor} from './value/color';
import {KnownColorSpace, SassColor} from './value/color';
import {SassFunction} from './value/function';
import {ListSeparator, SassList} from './value/list';
import {SassMap} from './value/map';
Expand Down Expand Up @@ -68,13 +68,15 @@ export class Protofier {
} else if (value instanceof SassNumber) {
result.value = {case: 'number', value: this.protofyNumber(value)};
} else if (value instanceof SassColor) {
if (value.hasCalculatedHsl) {
const color = create(proto.Value_HslColorSchema, value);
result.value = {case: 'hslColor', value: color};
} else {
const color = create(proto.Value_RgbColorSchema, value);
result.value = {case: 'rgbColor', value: color};
}
const channels = value.channels;
const color = create(proto.Value_ColorSchema, {
channel1: channels.get(0) as number,
channel2: channels.get(1) as number,
channel3: channels.get(2) as number,
alpha: value.alpha,
space: value.space,
});
result.value = {case: 'color', value: color};
} else if (value instanceof SassList) {
const list = create(proto.Value_ListSchema, {
separator: this.protofySeparator(value.separator),
Expand Down Expand Up @@ -232,24 +234,76 @@ export class Protofier {
return this.deprotofyNumber(value.value.value);
}

case 'rgbColor': {
case 'color': {
const color = value.value.value;
return new SassColor({
red: color.red,
green: color.green,
blue: color.blue,
alpha: color.alpha,
});
}

case 'hslColor': {
const color = value.value.value;
return new SassColor({
hue: color.hue,
saturation: color.saturation,
lightness: color.lightness,
alpha: color.alpha,
});
switch (color.space.toLowerCase()) {
case 'rgb':
case 'srgb':
case 'srgb-linear':
case 'display-p3':
case 'a98-rgb':
case 'prophoto-rgb':
case 'rec2020':
return new SassColor({
red: color.channel1,
green: color.channel2,
blue: color.channel3,
alpha: color.alpha,
space: color.space as KnownColorSpace,
});

case 'hsl':
return new SassColor({
hue: color.channel1,
saturation: color.channel2,
lightness: color.channel3,
alpha: color.alpha,
space: 'hsl',
});

case 'hwb':
return new SassColor({
hue: color.channel1,
whiteness: color.channel2,
blackness: color.channel3,
alpha: color.alpha,
space: 'hwb',
});

case 'lab':
case 'oklab':
return new SassColor({
lightness: color.channel1,
a: color.channel2,
b: color.channel3,
alpha: color.alpha,
space: color.space as KnownColorSpace,
});

case 'lch':
case 'oklch':
return new SassColor({
lightness: color.channel1,
chroma: color.channel2,
hue: color.channel3,
alpha: color.alpha,
space: color.space as KnownColorSpace,
});

case 'xyz':
case 'xyz-d65':
case 'xyz-d50':
return new SassColor({
x: color.channel1,
y: color.channel2,
z: color.channel3,
alpha: color.alpha,
space: color.space as KnownColorSpace,
});

default:
throw utils.compilerError(`Unknown color space "${color.space}".`);
}
}

case 'list': {
Expand Down
Loading