@@ -68,12 +68,12 @@ export class Protofier {
68
68
} else if ( value instanceof SassNumber ) {
69
69
result . value = { case : 'number' , value : this . protofyNumber ( value ) } ;
70
70
} else if ( value instanceof SassColor ) {
71
- const channels = value . channels ;
71
+ const channels = value . channelsOrNull ;
72
72
const color = create ( proto . Value_ColorSchema , {
73
73
channel1 : channels . get ( 0 ) as number ,
74
74
channel2 : channels . get ( 1 ) as number ,
75
75
channel3 : channels . get ( 2 ) as number ,
76
- alpha : value . alpha ,
76
+ alpha : value . isChannelMissing ( 'alpha' ) ? undefined : value . alpha ,
77
77
space : value . space ,
78
78
} ) ;
79
79
result . value = { case : 'color' , value : color } ;
@@ -236,6 +236,11 @@ export class Protofier {
236
236
237
237
case 'color' : {
238
238
const color = value . value . value ;
239
+ const channel1 = color . channel1 ?? null ;
240
+ const channel2 = color . channel2 ?? null ;
241
+ const channel3 = color . channel3 ?? null ;
242
+ const alpha = color . alpha ?? null ;
243
+ const space = color . space as KnownColorSpace ;
239
244
switch ( color . space . toLowerCase ( ) ) {
240
245
case 'rgb' :
241
246
case 'srgb' :
@@ -245,60 +250,60 @@ export class Protofier {
245
250
case 'prophoto-rgb' :
246
251
case 'rec2020' :
247
252
return new SassColor ( {
248
- red : color . channel1 ,
249
- green : color . channel2 ,
250
- blue : color . channel3 ,
251
- alpha : color . alpha ,
252
- space : color . space as KnownColorSpace ,
253
+ red : channel1 ,
254
+ green : channel2 ,
255
+ blue : channel3 ,
256
+ alpha,
257
+ space,
253
258
} ) ;
254
259
255
260
case 'hsl' :
256
261
return new SassColor ( {
257
- hue : color . channel1 ,
258
- saturation : color . channel2 ,
259
- lightness : color . channel3 ,
260
- alpha : color . alpha ,
261
- space : 'hsl' ,
262
+ hue : channel1 ,
263
+ saturation : channel2 ,
264
+ lightness : channel3 ,
265
+ alpha,
266
+ space,
262
267
} ) ;
263
268
264
269
case 'hwb' :
265
270
return new SassColor ( {
266
- hue : color . channel1 ,
267
- whiteness : color . channel2 ,
268
- blackness : color . channel3 ,
269
- alpha : color . alpha ,
270
- space : 'hwb' ,
271
+ hue : channel1 ,
272
+ whiteness : channel2 ,
273
+ blackness : channel3 ,
274
+ alpha,
275
+ space,
271
276
} ) ;
272
277
273
278
case 'lab' :
274
279
case 'oklab' :
275
280
return new SassColor ( {
276
- lightness : color . channel1 ,
277
- a : color . channel2 ,
278
- b : color . channel3 ,
279
- alpha : color . alpha ,
280
- space : color . space as KnownColorSpace ,
281
+ lightness : channel1 ,
282
+ a : channel2 ,
283
+ b : channel3 ,
284
+ alpha,
285
+ space,
281
286
} ) ;
282
287
283
288
case 'lch' :
284
289
case 'oklch' :
285
290
return new SassColor ( {
286
- lightness : color . channel1 ,
287
- chroma : color . channel2 ,
288
- hue : color . channel3 ,
289
- alpha : color . alpha ,
290
- space : color . space as KnownColorSpace ,
291
+ lightness : channel1 ,
292
+ chroma : channel2 ,
293
+ hue : channel3 ,
294
+ alpha,
295
+ space,
291
296
} ) ;
292
297
293
298
case 'xyz' :
294
299
case 'xyz-d65' :
295
300
case 'xyz-d50' :
296
301
return new SassColor ( {
297
- x : color . channel1 ,
298
- y : color . channel2 ,
299
- z : color . channel3 ,
300
- alpha : color . alpha ,
301
- space : color . space as KnownColorSpace ,
302
+ x : channel1 ,
303
+ y : channel2 ,
304
+ z : channel3 ,
305
+ alpha,
306
+ space,
302
307
} ) ;
303
308
304
309
default :
0 commit comments