@tbela99/css-parser 1.6.1 → 1.6.3
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/CHANGELOG.md +119 -2
- package/README.md +1 -0
- package/dist/index-umd-web.js +1214 -247
- package/dist/index.cjs +1214 -247
- package/dist/index.d.ts +71 -6
- package/dist/lib/ast/features/prefix.js +9 -1
- package/dist/lib/ast/features/shorthand.js +1 -1
- package/dist/lib/ast/math/expression.js +156 -1
- package/dist/lib/ast/transform/compute.js +4 -8
- package/dist/lib/ast/types.js +12 -0
- package/dist/lib/parser/declaration/list.js +8 -10
- package/dist/lib/parser/parse.js +2 -9
- package/dist/lib/parser/tokenize.js +50 -18
- package/dist/lib/parser/utils/at-rule-font-feature-values.js +1 -1
- package/dist/lib/parser/utils/at-rule-media.js +66 -0
- package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
- package/dist/lib/parser/utils/base64.js +14 -0
- package/dist/lib/parser/utils/declaration.js +7 -14
- package/dist/lib/parser/utils/eq.js +6 -0
- package/dist/lib/parser/utils/hash.js +1 -0
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/parser/utils/text.js +16 -0
- package/dist/lib/renderer/render.js +18 -4
- package/dist/lib/renderer/sourcemap/lib/codec.js +5 -0
- package/dist/lib/renderer/sourcemap/sourcemap.js +35 -5
- package/dist/lib/syntax/color/alpha.js +57 -22
- package/dist/lib/syntax/color/color-mix.js +18 -18
- package/dist/lib/syntax/color/srgb.js +10 -5
- package/dist/lib/syntax/color/utils/components.js +1 -1
- package/dist/lib/syntax/color/utils/distance.js +2 -2
- package/dist/lib/syntax/color/utils/matrix.js +1 -0
- package/dist/lib/syntax/color/xyz.js +5 -0
- package/dist/lib/syntax/color/xyzd50.js +17 -0
- package/dist/lib/syntax/syntax.js +549 -13
- package/dist/lib/validation/config.js +26 -0
- package/dist/lib/validation/match.js +16 -4
- package/dist/node.js +8 -14
- package/dist/web.js +8 -14
- package/package.json +1 -1
|
@@ -198,6 +198,300 @@ const pseudoAliasMap = {
|
|
|
198
198
|
":-moz-ui-valid": ":user-valid",
|
|
199
199
|
"::-moz-selection": "::selection",
|
|
200
200
|
};
|
|
201
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
|
|
202
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
|
|
203
|
+
// export const webkitExtensions = new Set([
|
|
204
|
+
// "-webkit-app-region",
|
|
205
|
+
// "-webkit-border-horizontal-spacing",
|
|
206
|
+
// "-webkit-border-vertical-spacing",
|
|
207
|
+
// "-webkit-box-reflect",
|
|
208
|
+
// "-webkit-column-axis",
|
|
209
|
+
// "-webkit-column-progression",
|
|
210
|
+
// "-webkit-cursor-visibility",
|
|
211
|
+
// "-webkit-font-smoothing",
|
|
212
|
+
// "-webkit-hyphenate-limit-after",
|
|
213
|
+
// "-webkit-hyphenate-limit-before",
|
|
214
|
+
// "-webkit-hyphenate-limit-lines",
|
|
215
|
+
// "-webkit-line-align",
|
|
216
|
+
// "-webkit-line-box-contain",
|
|
217
|
+
// "-webkit-line-clamp",
|
|
218
|
+
// "-webkit-line-grid",
|
|
219
|
+
// "-webkit-line-snap",
|
|
220
|
+
// "-webkit-locale",
|
|
221
|
+
// "-webkit-logical-height",
|
|
222
|
+
// "-webkit-logical-width",
|
|
223
|
+
// "-webkit-margin-after",
|
|
224
|
+
// "-webkit-margin-before",
|
|
225
|
+
// "-webkit-mask-box-image-outset",
|
|
226
|
+
// "-webkit-mask-box-image-repeat",
|
|
227
|
+
// "-webkit-mask-box-image-slice",
|
|
228
|
+
// "-webkit-mask-box-image-source",
|
|
229
|
+
// "-webkit-mask-box-image-width",
|
|
230
|
+
// "-webkit-mask-box-image",
|
|
231
|
+
// "-webkit-mask-composite",
|
|
232
|
+
// "-webkit-mask-position-x",
|
|
233
|
+
// "-webkit-mask-position-y",
|
|
234
|
+
// "-webkit-mask-repeat-x",
|
|
235
|
+
// "-webkit-mask-repeat-y",
|
|
236
|
+
// "-webkit-mask-source-type",
|
|
237
|
+
// "-webkit-max-logical-height",
|
|
238
|
+
// "-webkit-max-logical-width",
|
|
239
|
+
// "-webkit-min-logical-height",
|
|
240
|
+
// "-webkit-min-logical-width",
|
|
241
|
+
// "-webkit-nbsp-mode",
|
|
242
|
+
// "-webkit-match-parent",
|
|
243
|
+
// "-webkit-perspective-origin-x",
|
|
244
|
+
// "-webkit-perspective-origin-y",
|
|
245
|
+
// "-webkit-rtl-ordering",
|
|
246
|
+
// "-webkit-tap-highlight-color",
|
|
247
|
+
// "-webkit-text-decoration-skip",
|
|
248
|
+
// "-webkit-text-decorations-in-effect",
|
|
249
|
+
// "-webkit-text-fill-color",
|
|
250
|
+
// "-webkit-text-security",
|
|
251
|
+
// "-webkit-text-stroke-color",
|
|
252
|
+
// "-webkit-text-stroke-width",
|
|
253
|
+
// "-webkit-text-stroke",
|
|
254
|
+
// "-webkit-text-zoom",
|
|
255
|
+
// "-webkit-touch-callout",
|
|
256
|
+
// "-webkit-transform-origin-x",
|
|
257
|
+
// "-webkit-transform-origin-y",
|
|
258
|
+
// "-webkit-transform-origin-z",
|
|
259
|
+
// "-webkit-user-drag",
|
|
260
|
+
// "-webkit-user-modify",
|
|
261
|
+
// "-webkit-border-after",
|
|
262
|
+
// "-webkit-border-after-color",
|
|
263
|
+
// "-webkit-border-after-style",
|
|
264
|
+
// "-webkit-border-after-width",
|
|
265
|
+
// "-webkit-border-before",
|
|
266
|
+
// "-webkit-border-before-color",
|
|
267
|
+
// "-webkit-border-before-style",
|
|
268
|
+
// "-webkit-border-before-width",
|
|
269
|
+
// "-webkit-border-end",
|
|
270
|
+
// "-webkit-border-end-color",
|
|
271
|
+
// "-webkit-border-end-style",
|
|
272
|
+
// "-webkit-border-end-width",
|
|
273
|
+
// "-webkit-border-start",
|
|
274
|
+
// "-webkit-border-start-color",
|
|
275
|
+
// "-webkit-border-start-style",
|
|
276
|
+
// "-webkit-border-start-width",
|
|
277
|
+
// "-webkit-box-align",
|
|
278
|
+
// "-webkit-box-direction",
|
|
279
|
+
// "-webkit-box-flex-group",
|
|
280
|
+
// "-webkit-box-flex",
|
|
281
|
+
// "-webkit-box-lines",
|
|
282
|
+
// "-webkit-box-ordinal-group",
|
|
283
|
+
// "-webkit-box-orient",
|
|
284
|
+
// "-webkit-box-pack",
|
|
285
|
+
// "-webkit-column-break-after",
|
|
286
|
+
// "-webkit-column-break-before",
|
|
287
|
+
// "-webkit-column-break-inside",
|
|
288
|
+
// "-webkit-font-feature-settings",
|
|
289
|
+
// "-webkit-hyphenate-character",
|
|
290
|
+
// "-webkit-initial-letter",
|
|
291
|
+
// "-webkit-margin-end",
|
|
292
|
+
// "-webkit-margin-start",
|
|
293
|
+
// "-webkit-padding-after",
|
|
294
|
+
// "-webkit-padding-before",
|
|
295
|
+
// "-webkit-padding-end",
|
|
296
|
+
// "-webkit-padding-start",
|
|
297
|
+
// "-webkit-fill-available",
|
|
298
|
+
// ":-webkit-animating-full-screen-transition",
|
|
299
|
+
// ":-webkit-any",
|
|
300
|
+
// ":-webkit-any-link",
|
|
301
|
+
// ":-webkit-autofill",
|
|
302
|
+
// ":-webkit-autofill-strong-password",
|
|
303
|
+
// ":-webkit-drag",
|
|
304
|
+
// ":-webkit-full-page-media",
|
|
305
|
+
// ":-webkit-full-screen*",
|
|
306
|
+
// ":-webkit-full-screen-ancestor",
|
|
307
|
+
// ":-webkit-full-screen-document",
|
|
308
|
+
// ":-webkit-full-screen-controls-hidden",
|
|
309
|
+
// "::-webkit-file-upload-button*",
|
|
310
|
+
// "::-webkit-inner-spin-button",
|
|
311
|
+
// "::-webkit-input-placeholder",
|
|
312
|
+
// "::-webkit-meter-bar",
|
|
313
|
+
// "::-webkit-meter-even-less-good-value",
|
|
314
|
+
// "::-webkit-meter-inner-element",
|
|
315
|
+
// "::-webkit-meter-optimum-value",
|
|
316
|
+
// "::-webkit-meter-suboptimum-value",
|
|
317
|
+
// "::-webkit-progress-bar",
|
|
318
|
+
// "::-webkit-progress-inner-element",
|
|
319
|
+
// "::-webkit-progress-value",
|
|
320
|
+
// "::-webkit-search-cancel-button",
|
|
321
|
+
// "::-webkit-search-results-button",
|
|
322
|
+
// "::-webkit-slider-runnable-track",
|
|
323
|
+
// "::-webkit-slider-thumb",
|
|
324
|
+
// "-webkit-animation",
|
|
325
|
+
// "-webkit-device-pixel-ratio",
|
|
326
|
+
// "-webkit-transform-2d",
|
|
327
|
+
// "-webkit-transform-3d",
|
|
328
|
+
// "-webkit-transition",
|
|
329
|
+
// "::-webkit-scrollbar",
|
|
330
|
+
// "::-webkit-scrollbar-button",
|
|
331
|
+
// "::-webkit-scrollbar",
|
|
332
|
+
// "::-webkit-scrollbar-thumb",
|
|
333
|
+
// "::-webkit-scrollbar-track",
|
|
334
|
+
// "::-webkit-scrollbar-track-piece",
|
|
335
|
+
// "::-webkit-scrollbar:vertical",
|
|
336
|
+
// "::-webkit-scrollbar-corner ",
|
|
337
|
+
// "::-webkit-resizer",
|
|
338
|
+
// ":vertical",
|
|
339
|
+
// ":horizontal",
|
|
340
|
+
// ]);
|
|
341
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
|
|
342
|
+
// export const mozExtensions = new Set([
|
|
343
|
+
// "-moz-box-align",
|
|
344
|
+
// "-moz-box-direction",
|
|
345
|
+
// "-moz-box-flex",
|
|
346
|
+
// "-moz-box-ordinal-group",
|
|
347
|
+
// "-moz-box-orient",
|
|
348
|
+
// "-moz-box-pack",
|
|
349
|
+
// "-moz-float-edge",
|
|
350
|
+
// "-moz-force-broken-image-icon",
|
|
351
|
+
// "-moz-image-region",
|
|
352
|
+
// "-moz-orient",
|
|
353
|
+
// "-moz-osx-font-smoothing",
|
|
354
|
+
// "-moz-user-focus",
|
|
355
|
+
// "-moz-user-input",
|
|
356
|
+
// "-moz-user-modify",
|
|
357
|
+
// "-moz-animation",
|
|
358
|
+
// "-moz-animation-delay",
|
|
359
|
+
// "-moz-animation-direction",
|
|
360
|
+
// "-moz-animation-duration",
|
|
361
|
+
// "-moz-animation-fill-mode",
|
|
362
|
+
// "-moz-animation-iteration-count",
|
|
363
|
+
// "-moz-animation-name",
|
|
364
|
+
// "-moz-animation-play-state",
|
|
365
|
+
// "-moz-animation-timing-function",
|
|
366
|
+
// "-moz-appearance",
|
|
367
|
+
// "-moz-backface-visibility",
|
|
368
|
+
// "-moz-background-clip",
|
|
369
|
+
// "-moz-background-origin",
|
|
370
|
+
// "-moz-background-inline-policy",
|
|
371
|
+
// "-moz-background-size",
|
|
372
|
+
// "-moz-border-end",
|
|
373
|
+
// "-moz-border-end-color",
|
|
374
|
+
// "-moz-border-end-style",
|
|
375
|
+
// "-moz-border-end-width",
|
|
376
|
+
// "-moz-border-image",
|
|
377
|
+
// "-moz-border-start",
|
|
378
|
+
// "-moz-border-start-color",
|
|
379
|
+
// "-moz-border-start-style",
|
|
380
|
+
// "-moz-border-start-width",
|
|
381
|
+
// "-moz-box-sizing",
|
|
382
|
+
// "clip-path",
|
|
383
|
+
// "-moz-column-count",
|
|
384
|
+
// "-moz-column-fill",
|
|
385
|
+
// "-moz-column-gap",
|
|
386
|
+
// "-moz-column-width",
|
|
387
|
+
// "-moz-column-rule",
|
|
388
|
+
// "-moz-column-rule-width",
|
|
389
|
+
// "-moz-column-rule-style",
|
|
390
|
+
// "-moz-column-rule-color",
|
|
391
|
+
// "filter",
|
|
392
|
+
// "-moz-font-feature-settings",
|
|
393
|
+
// "-moz-font-language-override",
|
|
394
|
+
// "-moz-hyphens",
|
|
395
|
+
// "-moz-margin-end",
|
|
396
|
+
// "-moz-margin-start",
|
|
397
|
+
// "mask",
|
|
398
|
+
// "-moz-opacity",
|
|
399
|
+
// "-moz-outline",
|
|
400
|
+
// "-moz-outline-color",
|
|
401
|
+
// "-moz-outline-offset",
|
|
402
|
+
// "-moz-outline-style",
|
|
403
|
+
// "-moz-outline-width",
|
|
404
|
+
// "-moz-padding-end",
|
|
405
|
+
// "-moz-padding-start",
|
|
406
|
+
// "-moz-perspective",
|
|
407
|
+
// "-moz-perspective-origin",
|
|
408
|
+
// "pointer-events",
|
|
409
|
+
// "-moz-tab-size",
|
|
410
|
+
// "-moz-text-align-last",
|
|
411
|
+
// "-moz-text-decoration-color",
|
|
412
|
+
// "-moz-text-decoration-line",
|
|
413
|
+
// "-moz-text-decoration-style",
|
|
414
|
+
// "-moz-text-size-adjust",
|
|
415
|
+
// "-moz-transform",
|
|
416
|
+
// "-moz-transform-origin",
|
|
417
|
+
// "-moz-transform-style",
|
|
418
|
+
// "-moz-transition",
|
|
419
|
+
// "-moz-transition-delay",
|
|
420
|
+
// "-moz-transition-duration",
|
|
421
|
+
// "-moz-transition-property",
|
|
422
|
+
// "-moz-transition-timing-function",
|
|
423
|
+
// "-moz-user-select",
|
|
424
|
+
// "-moz-initial",
|
|
425
|
+
// "-moz-appearance",
|
|
426
|
+
// "-moz-linear-gradient",
|
|
427
|
+
// "-moz-radial-gradient",
|
|
428
|
+
// "-moz-element",
|
|
429
|
+
// "-moz-image-rect",
|
|
430
|
+
// "::-moz-anonymous-block",
|
|
431
|
+
// "::-moz-anonymous-positioned-block",
|
|
432
|
+
// ":-moz-any",
|
|
433
|
+
// ":-moz-any-link",
|
|
434
|
+
// ":-moz-broken",
|
|
435
|
+
// "::-moz-canvas",
|
|
436
|
+
// "::-moz-color-swatch",
|
|
437
|
+
// "::-moz-cell-content",
|
|
438
|
+
// ":-moz-drag-over",
|
|
439
|
+
// ":-moz-first-node",
|
|
440
|
+
// "::-moz-focus-inner",
|
|
441
|
+
// "::-moz-focus-outer",
|
|
442
|
+
// ":-moz-full-screen",
|
|
443
|
+
// ":-moz-full-screen-ancestor",
|
|
444
|
+
// ":-moz-handler-blocked",
|
|
445
|
+
// ":-moz-handler-crashed",
|
|
446
|
+
// ":-moz-handler-disabled",
|
|
447
|
+
// "::-moz-inline-table",
|
|
448
|
+
// ":-moz-last-node",
|
|
449
|
+
// "::-moz-list-bullet",
|
|
450
|
+
// "::-moz-list-number",
|
|
451
|
+
// ":-moz-loading",
|
|
452
|
+
// ":-moz-locale-dir",
|
|
453
|
+
// ":-moz-locale-dir",
|
|
454
|
+
// ":-moz-lwtheme",
|
|
455
|
+
// ":-moz-lwtheme-brighttext",
|
|
456
|
+
// ":-moz-lwtheme-darktext",
|
|
457
|
+
// "::-moz-meter-bar",
|
|
458
|
+
// ":-moz-native-anonymous",
|
|
459
|
+
// ":-moz-only-whitespace",
|
|
460
|
+
// "::-moz-pagebreak",
|
|
461
|
+
// "::-moz-pagecontent",
|
|
462
|
+
// ":-moz-placeholder",
|
|
463
|
+
// "::-moz-placeholder",
|
|
464
|
+
// "::-moz-progress-bar",
|
|
465
|
+
// "::-moz-range-progress",
|
|
466
|
+
// "::-moz-range-thumb",
|
|
467
|
+
// "::-moz-range-track",
|
|
468
|
+
// ":-moz-read-only",
|
|
469
|
+
// ":-moz-read-write",
|
|
470
|
+
// "::-moz-scrolled-canvas",
|
|
471
|
+
// "::-moz-scrolled-content",
|
|
472
|
+
// "::-moz-selection",
|
|
473
|
+
// ":-moz-submit-invalid",
|
|
474
|
+
// ":-moz-suppressed",
|
|
475
|
+
// "::-moz-svg-foreign-content",
|
|
476
|
+
// "::-moz-table",
|
|
477
|
+
// "::-moz-table-cell",
|
|
478
|
+
// "::-moz-table-column",
|
|
479
|
+
// "::-moz-table-column-group",
|
|
480
|
+
// "::-moz-table-outer",
|
|
481
|
+
// "::-moz-table-row",
|
|
482
|
+
// "::-moz-table-row-group",
|
|
483
|
+
// ":-moz-ui-invalid",
|
|
484
|
+
// ":-moz-ui-valid",
|
|
485
|
+
// ":-moz-user-disabled",
|
|
486
|
+
// "::-moz-viewport",
|
|
487
|
+
// "::-moz-viewport-scroll",
|
|
488
|
+
// ":-moz-window-inactive",
|
|
489
|
+
// "-moz-device-pixel-ratio",
|
|
490
|
+
// "-moz-os-version",
|
|
491
|
+
// "-moz-touch-enabled",
|
|
492
|
+
// "-moz-windows-glass",
|
|
493
|
+
// "-moz-alt-content",
|
|
494
|
+
// ]);
|
|
201
495
|
// renamed standard properties
|
|
202
496
|
const renamedStandardProperties = new Map([["color-adjust", "print-color-adjust"]]);
|
|
203
497
|
function isLength(dimension) {
|
|
@@ -215,6 +509,34 @@ function isTime(dimension) {
|
|
|
215
509
|
function isFrequency(dimension) {
|
|
216
510
|
return "unit" in dimension && frequencyUnits.includes(dimension.unit.toLowerCase());
|
|
217
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
* Is color space
|
|
514
|
+
* @param token
|
|
515
|
+
* @returns
|
|
516
|
+
*/
|
|
517
|
+
// export function isColorspace(token: Token): boolean {
|
|
518
|
+
// return (
|
|
519
|
+
// token.typ === EnumToken.IdenTokenType &&
|
|
520
|
+
// [
|
|
521
|
+
// "srgb",
|
|
522
|
+
// "srgb-linear",
|
|
523
|
+
// "lab",
|
|
524
|
+
// "oklab",
|
|
525
|
+
// "lch",
|
|
526
|
+
// "oklch",
|
|
527
|
+
// "xyz",
|
|
528
|
+
// "xyz-d50",
|
|
529
|
+
// "xyz-d65",
|
|
530
|
+
// "display-p3",
|
|
531
|
+
// "a98-rgb",
|
|
532
|
+
// "prophoto-rgb",
|
|
533
|
+
// "rec2020",
|
|
534
|
+
// "rgb",
|
|
535
|
+
// "hsl",
|
|
536
|
+
// "hwb",
|
|
537
|
+
// ].includes((token as IdentToken).val.toLowerCase())
|
|
538
|
+
// );
|
|
539
|
+
// }
|
|
218
540
|
/**
|
|
219
541
|
* Reduce color stops
|
|
220
542
|
* @param stops
|
|
@@ -412,6 +734,26 @@ function isPolarColorspace(token) {
|
|
|
412
734
|
return (token.typ === EnumToken.IdenTokenType &&
|
|
413
735
|
["hsl", "hwb", "lch", "oklch"].some((t) => equalsIgnoreCase(t, token.val)));
|
|
414
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Is hue interpolation method
|
|
739
|
+
* @param token
|
|
740
|
+
* @returns
|
|
741
|
+
*/
|
|
742
|
+
// export function isHueInterpolationMethod(token: Token | Token[]): boolean {
|
|
743
|
+
// if (!Array.isArray(token)) {
|
|
744
|
+
// return token.typ == EnumToken.IdenTokenType && "hue" === (token as IdentToken).val?.toLowerCase?.();
|
|
745
|
+
// }
|
|
746
|
+
//
|
|
747
|
+
// if (token.length != 2 || token[0].typ != EnumToken.IdenTokenType || token[1].typ != EnumToken.IdenTokenType) {
|
|
748
|
+
// return false;
|
|
749
|
+
// }
|
|
750
|
+
//
|
|
751
|
+
// return (
|
|
752
|
+
// ["shorter", "longer", "increasing", "decreasing"].some((t) =>
|
|
753
|
+
// equalsIgnoreCase(t, (token[0] as IdentToken).val ?? ""),
|
|
754
|
+
// ) && "hue" === (token[1] as IdentToken).val?.toLowerCase?.()
|
|
755
|
+
// );
|
|
756
|
+
// }
|
|
415
757
|
/**
|
|
416
758
|
* Is ident color
|
|
417
759
|
* @param token
|
|
@@ -422,6 +764,12 @@ function isIdentColor(token) {
|
|
|
422
764
|
[ColorType.SYS, ColorType.DPSYS, ColorType.LIT].includes(token.kin) &&
|
|
423
765
|
isIdent(token.val));
|
|
424
766
|
}
|
|
767
|
+
// export function isPercentageToken(token: Token): boolean {
|
|
768
|
+
// return (
|
|
769
|
+
// token.typ == EnumToken.PercentageTokenType ||
|
|
770
|
+
// (token.typ == EnumToken.NumberTokenType && (token as NumberToken).val == 0)
|
|
771
|
+
// );
|
|
772
|
+
// }
|
|
425
773
|
function isColor(token, errors) {
|
|
426
774
|
if (token.typ == EnumToken.WildCardFunctionTokenType) {
|
|
427
775
|
return true;
|
|
@@ -685,21 +1033,33 @@ function isColor(token, errors) {
|
|
|
685
1033
|
return true;
|
|
686
1034
|
}
|
|
687
1035
|
else {
|
|
688
|
-
//
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
1036
|
+
// const keywords: string[] = ["from", "none"];
|
|
1037
|
+
//
|
|
1038
|
+
// // @ts-ignore
|
|
1039
|
+
// if (
|
|
1040
|
+
// ["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].some((t) =>
|
|
1041
|
+
// equalsIgnoreCase(t, (token as ColorToken).val),
|
|
1042
|
+
// )
|
|
1043
|
+
// ) {
|
|
1044
|
+
// // @ts-ignore
|
|
1045
|
+
// keywords.push("alpha");
|
|
1046
|
+
//
|
|
1047
|
+
// for (const keyword of (token as ColorToken).val.slice(-3).split("")) {
|
|
1048
|
+
// keywords.push(keyword);
|
|
1049
|
+
// }
|
|
1050
|
+
// }
|
|
693
1051
|
// @ts-ignore
|
|
694
1052
|
for (const v of token.chi) {
|
|
695
|
-
if (v.typ == EnumToken.IdenTokenType) {
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1053
|
+
// if (v.typ == EnumToken.IdenTokenType) {
|
|
1054
|
+
// continue;
|
|
1055
|
+
// }
|
|
1056
|
+
// if (
|
|
1057
|
+
// v.typ === EnumToken.MathFunctionTokenType ||
|
|
1058
|
+
// v.typ === EnumToken.WildCardFunctionTokenType ||
|
|
1059
|
+
// colorsFunc.includes(v.val)
|
|
1060
|
+
// ) {
|
|
1061
|
+
// continue;
|
|
1062
|
+
// }
|
|
703
1063
|
}
|
|
704
1064
|
}
|
|
705
1065
|
return true;
|
|
@@ -845,6 +1205,44 @@ function isNonPrintable(codepoint) {
|
|
|
845
1205
|
codepoint == 0x7f ||
|
|
846
1206
|
(codepoint >= 0xe && codepoint <= 0x1f));
|
|
847
1207
|
}
|
|
1208
|
+
// export function isURLToken(str: string): boolean {
|
|
1209
|
+
// let i: number = -1;
|
|
1210
|
+
// let c: number;
|
|
1211
|
+
//
|
|
1212
|
+
// while (++i < str.length) {
|
|
1213
|
+
// c = str.charCodeAt(i) as number;
|
|
1214
|
+
//
|
|
1215
|
+
// // single quote or double quote or start parenthesis or close parenthesis
|
|
1216
|
+
// if (isNonPrintable(c) || c == 0x27 || c == 0x22 || c == 0x28 || c == 0x29) {
|
|
1217
|
+
// return false;
|
|
1218
|
+
// }
|
|
1219
|
+
//
|
|
1220
|
+
// // valid escape
|
|
1221
|
+
// if (c == REVERSE_SOLIDUS) {
|
|
1222
|
+
// i++;
|
|
1223
|
+
//
|
|
1224
|
+
// if (i >= str.length) {
|
|
1225
|
+
// return false;
|
|
1226
|
+
// }
|
|
1227
|
+
//
|
|
1228
|
+
// c = str.charCodeAt(i) as number;
|
|
1229
|
+
//
|
|
1230
|
+
// // c is not '\n' or '\r' or '\f'
|
|
1231
|
+
// if (c == 0x6e || c == 0x72 || c == 0x66) {
|
|
1232
|
+
// return false;
|
|
1233
|
+
// }
|
|
1234
|
+
//
|
|
1235
|
+
// continue;
|
|
1236
|
+
// }
|
|
1237
|
+
//
|
|
1238
|
+
// // is white space
|
|
1239
|
+
// if (c == 0x20 || c == 0x09) {
|
|
1240
|
+
// break;
|
|
1241
|
+
// }
|
|
1242
|
+
// }
|
|
1243
|
+
//
|
|
1244
|
+
// return i == str.length;
|
|
1245
|
+
// }
|
|
848
1246
|
function isPseudo(name) {
|
|
849
1247
|
return (name.charAt(0) == ":" &&
|
|
850
1248
|
((name.endsWith("(") && isIdent(name.charAt(1) == ":" ? name.slice(2, -1) : name.slice(1, -1))) ||
|
|
@@ -853,6 +1251,94 @@ function isPseudo(name) {
|
|
|
853
1251
|
function isHash(name) {
|
|
854
1252
|
return name.charAt(0) == "#" && isIdentStart(name.charCodeAt(1));
|
|
855
1253
|
}
|
|
1254
|
+
// export const isNumber = memoize(function (name: string): boolean {
|
|
1255
|
+
// let codepoint: number = name.charCodeAt(0) as number;
|
|
1256
|
+
// let i: number = 0;
|
|
1257
|
+
// const j: number = name.length;
|
|
1258
|
+
//
|
|
1259
|
+
// if (j == 1 && !isDigit(codepoint)) {
|
|
1260
|
+
// return false;
|
|
1261
|
+
// }
|
|
1262
|
+
//
|
|
1263
|
+
// // '+' '-'
|
|
1264
|
+
// if ([0x2b, 0x2d].includes(codepoint)) {
|
|
1265
|
+
// i++;
|
|
1266
|
+
// }
|
|
1267
|
+
//
|
|
1268
|
+
// // consume digits
|
|
1269
|
+
// while (i < j) {
|
|
1270
|
+
// codepoint = name.charCodeAt(i) as number;
|
|
1271
|
+
//
|
|
1272
|
+
// if (isDigit(codepoint)) {
|
|
1273
|
+
// i++;
|
|
1274
|
+
// continue;
|
|
1275
|
+
// }
|
|
1276
|
+
//
|
|
1277
|
+
// // '.' 'E' 'e'
|
|
1278
|
+
// if (codepoint == 0x2e || codepoint == 0x45 || codepoint == 0x65) {
|
|
1279
|
+
// break;
|
|
1280
|
+
// }
|
|
1281
|
+
//
|
|
1282
|
+
// return false;
|
|
1283
|
+
// }
|
|
1284
|
+
//
|
|
1285
|
+
// // '.'
|
|
1286
|
+
// if (codepoint == 0x2e) {
|
|
1287
|
+
// if (!isDigit(name.charCodeAt(++i) as number)) {
|
|
1288
|
+
// return false;
|
|
1289
|
+
// }
|
|
1290
|
+
// }
|
|
1291
|
+
//
|
|
1292
|
+
// while (i < j) {
|
|
1293
|
+
// codepoint = name.charCodeAt(i) as number;
|
|
1294
|
+
//
|
|
1295
|
+
// if (isDigit(codepoint)) {
|
|
1296
|
+
// i++;
|
|
1297
|
+
// continue;
|
|
1298
|
+
// }
|
|
1299
|
+
//
|
|
1300
|
+
// // 'E' 'e'
|
|
1301
|
+
// if (codepoint == 0x45 || codepoint == 0x65) {
|
|
1302
|
+
// i++;
|
|
1303
|
+
// break;
|
|
1304
|
+
// }
|
|
1305
|
+
//
|
|
1306
|
+
// return false;
|
|
1307
|
+
// }
|
|
1308
|
+
//
|
|
1309
|
+
// // 'E' 'e'
|
|
1310
|
+
// if (codepoint == 0x45 || codepoint == 0x65) {
|
|
1311
|
+
// // if (i == j) {
|
|
1312
|
+
// // return false;
|
|
1313
|
+
// // }
|
|
1314
|
+
//
|
|
1315
|
+
// codepoint = name.charCodeAt(i + 1) as number;
|
|
1316
|
+
//
|
|
1317
|
+
// // '+' '-'
|
|
1318
|
+
// // if ([0x2b, 0x2d].includes(codepoint)) {
|
|
1319
|
+
// // i++;
|
|
1320
|
+
// // }
|
|
1321
|
+
//
|
|
1322
|
+
// codepoint = name.charCodeAt(i + 1) as number;
|
|
1323
|
+
//
|
|
1324
|
+
// if (!isDigit(codepoint)) {
|
|
1325
|
+
// return false;
|
|
1326
|
+
// }
|
|
1327
|
+
// }
|
|
1328
|
+
//
|
|
1329
|
+
// // while (++i < j) {
|
|
1330
|
+
// // codepoint = name.charCodeAt(i) as number;
|
|
1331
|
+
//
|
|
1332
|
+
// // if (!isDigit(codepoint)) {
|
|
1333
|
+
// // return false;
|
|
1334
|
+
// // }
|
|
1335
|
+
// // }
|
|
1336
|
+
//
|
|
1337
|
+
// return true;
|
|
1338
|
+
// }) as (name: string) => boolean;
|
|
1339
|
+
// export function isPercentage(name: string) {
|
|
1340
|
+
// return name.endsWith("%") && isNumber(name.slice(0, -1));
|
|
1341
|
+
// }
|
|
856
1342
|
function isFlex(dimension) {
|
|
857
1343
|
return "unit" in dimension && "fr" == dimension.unit.toLowerCase();
|
|
858
1344
|
}
|
|
@@ -907,9 +1393,33 @@ function parseDimension(name) {
|
|
|
907
1393
|
}
|
|
908
1394
|
return dimension;
|
|
909
1395
|
}
|
|
1396
|
+
// export function isHexColor(name: string): boolean {
|
|
1397
|
+
// if (name.charAt(0) != "#" || ![4, 5, 7, 9].includes(name.length)) {
|
|
1398
|
+
// return false;
|
|
1399
|
+
// }
|
|
1400
|
+
//
|
|
1401
|
+
// for (let chr of name.slice(1)) {
|
|
1402
|
+
// let codepoint: number = chr.charCodeAt(0) as number;
|
|
1403
|
+
//
|
|
1404
|
+
// if (
|
|
1405
|
+
// !isDigit(codepoint) &&
|
|
1406
|
+
// // A-F
|
|
1407
|
+
// !(codepoint >= 0x41 && codepoint <= 0x46) &&
|
|
1408
|
+
// // a-f
|
|
1409
|
+
// !(codepoint >= 0x61 && codepoint <= 0x66)
|
|
1410
|
+
// ) {
|
|
1411
|
+
// return false;
|
|
1412
|
+
// }
|
|
1413
|
+
// }
|
|
1414
|
+
//
|
|
1415
|
+
// return true;
|
|
1416
|
+
// }
|
|
910
1417
|
function isFunction(name) {
|
|
911
1418
|
return name.endsWith("(") && isIdent(name.slice(0, -1));
|
|
912
1419
|
}
|
|
1420
|
+
// export function isAtKeyword(name: string): boolean {
|
|
1421
|
+
// return name.charCodeAt(0) == 0x40 && isIdent(name.slice(1));
|
|
1422
|
+
// }
|
|
913
1423
|
function isNewLine(codepoint) {
|
|
914
1424
|
// \n \r \f \v
|
|
915
1425
|
return (codepoint == 0xa ||
|
|
@@ -930,6 +1440,32 @@ function isWhiteSpace(codepoint) {
|
|
|
930
1440
|
codepoint == 0x2028 ||
|
|
931
1441
|
codepoint == 0x2029);
|
|
932
1442
|
}
|
|
1443
|
+
// export function isValue(token: Token) {
|
|
1444
|
+
// if (token == null) {
|
|
1445
|
+
// return false;
|
|
1446
|
+
// }
|
|
1447
|
+
//
|
|
1448
|
+
// return (
|
|
1449
|
+
// token.typ === EnumToken.IdenTokenType ||
|
|
1450
|
+
// token.typ === EnumToken.DimensionTokenType ||
|
|
1451
|
+
// token.typ === EnumToken.LengthTokenType ||
|
|
1452
|
+
// token.typ === EnumToken.AngleTokenType ||
|
|
1453
|
+
// token.typ === EnumToken.FlexTokenType ||
|
|
1454
|
+
// token.typ === EnumToken.TimeTokenType ||
|
|
1455
|
+
// token.typ === EnumToken.ResolutionTokenType ||
|
|
1456
|
+
// token.typ === EnumToken.FrequencyTokenType ||
|
|
1457
|
+
// token.typ === EnumToken.NumberTokenType ||
|
|
1458
|
+
// token.typ === EnumToken.ColorTokenType ||
|
|
1459
|
+
// token.typ === EnumToken.FunctionTokenType ||
|
|
1460
|
+
// token.typ === EnumToken.UrlFunctionTokenType ||
|
|
1461
|
+
// token.typ === EnumToken.GridTemplateFuncTokenType ||
|
|
1462
|
+
// token.typ === EnumToken.ImageFunctionTokenType ||
|
|
1463
|
+
// token.typ === EnumToken.TimelineFunctionTokenType ||
|
|
1464
|
+
// token.typ === EnumToken.TimingFunctionTokenType ||
|
|
1465
|
+
// token.typ === EnumToken.MathFunctionTokenType ||
|
|
1466
|
+
// token.typ === EnumToken.TransformFunctionTokenType
|
|
1467
|
+
// );
|
|
1468
|
+
// }
|
|
933
1469
|
// https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#absolute_length_units
|
|
934
1470
|
/**
|
|
935
1471
|
* Convert length to px
|
|
@@ -9,6 +9,32 @@ function getSyntaxConfig() {
|
|
|
9
9
|
// @ts-expect-error
|
|
10
10
|
return config;
|
|
11
11
|
}
|
|
12
|
+
// export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
|
|
13
|
+
// // @ts-expect-error
|
|
14
|
+
// let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
|
|
15
|
+
//
|
|
16
|
+
// const keys: string[] = Array.isArray(key) ? key : [key];
|
|
17
|
+
//
|
|
18
|
+
// for (let i = 0; i < keys.length; i++) {
|
|
19
|
+
// key = keys[i];
|
|
20
|
+
//
|
|
21
|
+
// if (!(key in obj)) {
|
|
22
|
+
// if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
|
|
23
|
+
// const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
|
|
24
|
+
//
|
|
25
|
+
// if (matches != null) {
|
|
26
|
+
// key = matches[1] + matches[3];
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// // @ts-expect-error
|
|
32
|
+
// obj = obj[key];
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// // @ts-expect-error
|
|
36
|
+
// return obj?.syntax ?? null;
|
|
37
|
+
// }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
|
|
12
38
|
function findNode(group, key) {
|
|
13
39
|
// @ts-expect-error
|
|
14
40
|
let obj = config[group];
|