@stylexjs/babel-plugin 0.14.3 → 0.15.1
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/lib/index.js +2533 -915
- package/lib/shared/common-types.d.ts +1 -0
- package/lib/shared/common-types.js.flow +1 -0
- package/lib/shared/messages.d.ts +1 -0
- package/lib/shared/messages.js.flow +1 -0
- package/lib/shared/types/index.js.flow +1 -1
- package/lib/shared/utils/object-utils.js.flow +1 -1
- package/lib/utils/ast-helpers.d.ts +37 -0
- package/lib/utils/ast-helpers.js.flow +44 -0
- package/lib/utils/state-manager.d.ts +2 -16
- package/lib/utils/state-manager.js.flow +1 -18
- package/package.json +5 -4
package/lib/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var t = require('@babel/types');
|
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var url$1 = require('url');
|
|
7
|
-
var require$$0 = require('assert');
|
|
8
7
|
var importMetaResolve = require('@dual-bundle/import-meta-resolve');
|
|
8
|
+
var require$$0 = require('assert');
|
|
9
9
|
var core = require('@babel/core');
|
|
10
10
|
var traverse = require('@babel/traverse');
|
|
11
11
|
var stylex = require('@stylexjs/stylex');
|
|
@@ -35,127 +35,98 @@ const defaultMessage = expected => (value, name) => name ? `Expected (${name}) t
|
|
|
35
35
|
const defaultUnionMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected}` : expected;
|
|
36
36
|
const defaultObjectMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected} but:` : expected;
|
|
37
37
|
const indent = str => str.split('\n').filter(line => !line.trim().startsWith('But got:')).map(line => line.includes(', but got') ? line.replace(/, but got.+$/, '') : line).map(line => line.trim()[0] === '-' ? line : `- ${line}`).map(line => `\n\t${line}`).join('');
|
|
38
|
-
const string =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
38
|
+
const string = (message = defaultMessage('a string')) => (value, name) => {
|
|
39
|
+
if (typeof value !== 'string') {
|
|
40
|
+
return new Error(message(value, name));
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
46
43
|
};
|
|
47
|
-
const nullish =
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const nullish = (message = defaultMessage('`null` or `undefined`')) => (value, name) => value == null ? value : new Error(message(value, name));
|
|
45
|
+
const boolean = (message = defaultMessage('a boolean')) => (value, name) => {
|
|
46
|
+
if (typeof value !== 'boolean') {
|
|
47
|
+
return new Error(message(value, name));
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
50
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
return value;
|
|
58
|
-
};
|
|
51
|
+
const literal = (expected, message = defaultMessage(`the literal ${JSON.stringify(expected)}`)) => (value, name) => {
|
|
52
|
+
if (value === expected) {
|
|
53
|
+
return expected;
|
|
54
|
+
}
|
|
55
|
+
return new Error(message(value, name));
|
|
59
56
|
};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
return (value, name) => {
|
|
63
|
-
if (value === expected) {
|
|
64
|
-
return expected;
|
|
65
|
-
}
|
|
57
|
+
const array = (check, message = defaultMessage('an array')) => (value, name = 'array') => {
|
|
58
|
+
if (!Array.isArray(value)) {
|
|
66
59
|
return new Error(message(value, name));
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
const validated = value.map((item, i) => check(item, name ? `${name}[${i}]` : undefined));
|
|
77
|
-
const errors = validated.filter(item => item instanceof Error);
|
|
78
|
-
if (errors.length > 0) {
|
|
79
|
-
const errMessageList = errors.map(item => '\t' + item.message).join('\n');
|
|
80
|
-
return new Error(`Failed to validate ${name}:\n${errMessageList}`);
|
|
81
|
-
}
|
|
82
|
-
return validated.filter(item => !(item instanceof Error));
|
|
83
|
-
};
|
|
60
|
+
}
|
|
61
|
+
const validated = value.map((item, i) => check(item, name ? `${name}[${i}]` : undefined));
|
|
62
|
+
const errors = validated.filter(item => item instanceof Error);
|
|
63
|
+
if (errors.length > 0) {
|
|
64
|
+
const errMessageList = errors.map(item => '\t' + item.message).join('\n');
|
|
65
|
+
return new Error(`Failed to validate ${name}:\n${errMessageList}`);
|
|
66
|
+
}
|
|
67
|
+
return validated.filter(item => !(item instanceof Error));
|
|
84
68
|
};
|
|
85
|
-
const object =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return `\t- Expected "${key}": to be ${msg}`;
|
|
103
|
-
}).join('\n');
|
|
104
|
-
return new Error(`${message(value, name)}\n${objectDescription}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
105
|
-
}
|
|
106
|
-
result[key] = item;
|
|
69
|
+
const object = (shape, message = defaultMessage('an object where:')) => (value, name) => {
|
|
70
|
+
if (typeof value !== 'object' || value == null) {
|
|
71
|
+
return new Error(message(value, name));
|
|
72
|
+
}
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const key in shape) {
|
|
75
|
+
const check = shape[key];
|
|
76
|
+
const item = check(value[key], name ? `${name}.${key}` : `obj.${key}`);
|
|
77
|
+
if (item instanceof Error) {
|
|
78
|
+
const objectDescription = Object.entries(shape).map(([key, check]) => {
|
|
79
|
+
let msg = check(Symbol()).message;
|
|
80
|
+
if (msg.includes('\n')) {
|
|
81
|
+
msg = indent(indent(msg)).split('\n').slice(1).join('\n');
|
|
82
|
+
}
|
|
83
|
+
return `\t- Expected "${key}": to be ${msg}`;
|
|
84
|
+
}).join('\n');
|
|
85
|
+
return new Error(`${message(value, name)}\n${objectDescription}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
107
86
|
}
|
|
108
|
-
|
|
109
|
-
}
|
|
87
|
+
result[key] = item;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
110
90
|
};
|
|
111
|
-
const objectOf =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (item instanceof Error) {
|
|
121
|
-
return new Error(`${message(value, name)}${indent(item.message)}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
122
|
-
}
|
|
123
|
-
result[key] = item;
|
|
91
|
+
const objectOf = (check, message = defaultObjectMessage('an object')) => (value, name) => {
|
|
92
|
+
if (typeof value !== 'object' || value == null) {
|
|
93
|
+
return new Error(message(value, name));
|
|
94
|
+
}
|
|
95
|
+
const result = {};
|
|
96
|
+
for (const key in value) {
|
|
97
|
+
const item = check(value[key], name ? `${name}.${key}` : `With the key '${key}':`);
|
|
98
|
+
if (item instanceof Error) {
|
|
99
|
+
return new Error(`${message(value, name)}${indent(item.message)}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
124
100
|
}
|
|
125
|
-
|
|
126
|
-
}
|
|
101
|
+
result[key] = item;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
127
104
|
};
|
|
128
|
-
const unionOf =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
140
|
-
};
|
|
105
|
+
const unionOf = (a, b, message = defaultUnionMessage('one of')) => (value, name) => {
|
|
106
|
+
const resultA = a(value);
|
|
107
|
+
if (!(resultA instanceof Error)) {
|
|
108
|
+
return resultA;
|
|
109
|
+
}
|
|
110
|
+
const resultB = b(value);
|
|
111
|
+
if (!(resultB instanceof Error)) {
|
|
112
|
+
return resultB;
|
|
113
|
+
}
|
|
114
|
+
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
141
115
|
};
|
|
142
|
-
const unionOf3 =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}${indent(resultC.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
158
|
-
};
|
|
116
|
+
const unionOf3 = (a, b, c, message = defaultUnionMessage('one of')) => (value, name) => {
|
|
117
|
+
const resultA = a(value);
|
|
118
|
+
if (!(resultA instanceof Error)) {
|
|
119
|
+
return resultA;
|
|
120
|
+
}
|
|
121
|
+
const resultB = b(value);
|
|
122
|
+
if (!(resultB instanceof Error)) {
|
|
123
|
+
return resultB;
|
|
124
|
+
}
|
|
125
|
+
const resultC = c(value);
|
|
126
|
+
if (!(resultC instanceof Error)) {
|
|
127
|
+
return resultC;
|
|
128
|
+
}
|
|
129
|
+
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}${indent(resultC.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
159
130
|
};
|
|
160
131
|
const logAndDefault = (check, value, def, name) => {
|
|
161
132
|
const result = check(value, name);
|
|
@@ -170,7 +141,7 @@ function getDefaultExportFromCjs (x) {
|
|
|
170
141
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
171
142
|
}
|
|
172
143
|
|
|
173
|
-
var lib$
|
|
144
|
+
var lib$2 = {};
|
|
174
145
|
|
|
175
146
|
var importInjector = {};
|
|
176
147
|
|
|
@@ -636,11 +607,11 @@ function requireImportInjector () {
|
|
|
636
607
|
return importInjector;
|
|
637
608
|
}
|
|
638
609
|
|
|
639
|
-
var hasRequiredLib$
|
|
610
|
+
var hasRequiredLib$2;
|
|
640
611
|
|
|
641
|
-
function requireLib$
|
|
642
|
-
if (hasRequiredLib$
|
|
643
|
-
hasRequiredLib$
|
|
612
|
+
function requireLib$2 () {
|
|
613
|
+
if (hasRequiredLib$2) return lib$2;
|
|
614
|
+
hasRequiredLib$2 = 1;
|
|
644
615
|
(function (exports) {
|
|
645
616
|
|
|
646
617
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -678,11 +649,126 @@ function requireLib$1 () {
|
|
|
678
649
|
}
|
|
679
650
|
|
|
680
651
|
|
|
681
|
-
} (lib$
|
|
682
|
-
return lib$
|
|
652
|
+
} (lib$2));
|
|
653
|
+
return lib$2;
|
|
683
654
|
}
|
|
684
655
|
|
|
685
|
-
var libExports$
|
|
656
|
+
var libExports$2 = requireLib$2();
|
|
657
|
+
|
|
658
|
+
function hoistExpression(path, astExpression) {
|
|
659
|
+
const programStatementPath = getProgramStatement(path);
|
|
660
|
+
if (programStatementPath == null) {
|
|
661
|
+
return astExpression;
|
|
662
|
+
}
|
|
663
|
+
const hoistedIdent = path.scope.generateUidIdentifier();
|
|
664
|
+
programStatementPath.insertBefore(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(hoistedIdent, astExpression)]));
|
|
665
|
+
return hoistedIdent;
|
|
666
|
+
}
|
|
667
|
+
function pathReplaceHoisted(path, astExpression) {
|
|
668
|
+
if (isProgramLevel(path)) {
|
|
669
|
+
path.replaceWith(astExpression);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const programStatementPath = getProgramStatement(path);
|
|
673
|
+
if (programStatementPath == null) {
|
|
674
|
+
path.replaceWith(astExpression);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const nameIdent = path.scope.generateUidIdentifier('styles');
|
|
678
|
+
programStatementPath.insertBefore(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(nameIdent, astExpression)]));
|
|
679
|
+
path.replaceWith(nameIdent);
|
|
680
|
+
}
|
|
681
|
+
function getProgramPath(path) {
|
|
682
|
+
let programPath = path;
|
|
683
|
+
while (programPath != null && !programPath.isProgram()) {
|
|
684
|
+
if (programPath.parentPath) {
|
|
685
|
+
programPath = programPath.parentPath;
|
|
686
|
+
} else {
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return programPath;
|
|
691
|
+
}
|
|
692
|
+
function addNamedImport(statementPath, as, from, options) {
|
|
693
|
+
const identifier = libExports$2.addNamed(statementPath, as, from, options);
|
|
694
|
+
const programPath = getProgramPath(statementPath);
|
|
695
|
+
if (programPath == null) {
|
|
696
|
+
return identifier;
|
|
697
|
+
}
|
|
698
|
+
const bodyPath = programPath.get('body');
|
|
699
|
+
let targetImportIndex = -1;
|
|
700
|
+
for (let i = 0; i < bodyPath.length; i++) {
|
|
701
|
+
const statement = bodyPath[i];
|
|
702
|
+
if (statement.isImportDeclaration()) {
|
|
703
|
+
targetImportIndex = i;
|
|
704
|
+
if (statement.node.specifiers.find(s => s.type === 'ImportSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (targetImportIndex === -1) {
|
|
710
|
+
return identifier;
|
|
711
|
+
}
|
|
712
|
+
const lastImport = bodyPath[targetImportIndex];
|
|
713
|
+
if (lastImport == null) {
|
|
714
|
+
return identifier;
|
|
715
|
+
}
|
|
716
|
+
const importName = statementPath.scope.generateUidIdentifier(as);
|
|
717
|
+
lastImport.insertAfter(t__namespace.variableDeclaration('var', [t__namespace.variableDeclarator(importName, identifier)]));
|
|
718
|
+
return importName;
|
|
719
|
+
}
|
|
720
|
+
function addDefaultImport(statementPath, from, options) {
|
|
721
|
+
const identifier = libExports$2.addDefault(statementPath, from, options);
|
|
722
|
+
const programPath = getProgramPath(statementPath);
|
|
723
|
+
if (programPath == null) {
|
|
724
|
+
return identifier;
|
|
725
|
+
}
|
|
726
|
+
const bodyPath = programPath.get('body');
|
|
727
|
+
let targetImportIndex = -1;
|
|
728
|
+
for (let i = 0; i < bodyPath.length; i++) {
|
|
729
|
+
const statement = bodyPath[i];
|
|
730
|
+
if (statement.isImportDeclaration()) {
|
|
731
|
+
targetImportIndex = i;
|
|
732
|
+
if (statement.node.specifiers.find(s => s.type === 'ImportDefaultSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (targetImportIndex === -1) {
|
|
738
|
+
return identifier;
|
|
739
|
+
}
|
|
740
|
+
const lastImport = bodyPath[targetImportIndex];
|
|
741
|
+
if (lastImport == null) {
|
|
742
|
+
return identifier;
|
|
743
|
+
}
|
|
744
|
+
const importName = statementPath.scope.generateUidIdentifier('inject');
|
|
745
|
+
lastImport.insertAfter(t__namespace.variableDeclaration('var', [t__namespace.variableDeclarator(importName, identifier)]));
|
|
746
|
+
return importName;
|
|
747
|
+
}
|
|
748
|
+
function isProgramLevel(path) {
|
|
749
|
+
let programPath = path;
|
|
750
|
+
if (programPath.isStatement() && programPath?.parentPath?.isProgram()) {
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
while (programPath.parentPath != null) {
|
|
754
|
+
const parentPath = programPath.parentPath;
|
|
755
|
+
if (programPath.isStatement() && !programPath.parentPath?.isProgram() && !programPath.parentPath?.isExportDeclaration()) {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
if (programPath.isFunction()) {
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
programPath = parentPath;
|
|
762
|
+
}
|
|
763
|
+
return true;
|
|
764
|
+
}
|
|
765
|
+
function getProgramStatement(path) {
|
|
766
|
+
let programPath = path;
|
|
767
|
+
while (programPath.parentPath != null && !programPath.parentPath.isProgram() && programPath.parentPath != null) {
|
|
768
|
+
programPath = programPath.parentPath;
|
|
769
|
+
}
|
|
770
|
+
return programPath;
|
|
771
|
+
}
|
|
686
772
|
|
|
687
773
|
const CheckModuleResolution = unionOf3(object({
|
|
688
774
|
type: literal('commonJS'),
|
|
@@ -707,24 +793,24 @@ const checkRuntimeInjection = unionOf3(boolean(), string(), object({
|
|
|
707
793
|
}));
|
|
708
794
|
const DEFAULT_INJECT_PATH = '@stylexjs/stylex/lib/stylex-inject';
|
|
709
795
|
class StateManager {
|
|
710
|
-
importPaths =
|
|
711
|
-
stylexImport =
|
|
712
|
-
stylexPropsImport =
|
|
713
|
-
stylexAttrsImport =
|
|
714
|
-
stylexCreateImport =
|
|
715
|
-
stylexIncludeImport =
|
|
716
|
-
stylexFirstThatWorksImport =
|
|
717
|
-
stylexKeyframesImport =
|
|
718
|
-
stylexPositionTryImport =
|
|
719
|
-
stylexDefineVarsImport =
|
|
720
|
-
stylexDefineConstsImport =
|
|
721
|
-
stylexCreateThemeImport =
|
|
722
|
-
stylexTypesImport =
|
|
723
|
-
stylexViewTransitionClassImport =
|
|
796
|
+
importPaths = new Set();
|
|
797
|
+
stylexImport = new Set();
|
|
798
|
+
stylexPropsImport = new Set();
|
|
799
|
+
stylexAttrsImport = new Set();
|
|
800
|
+
stylexCreateImport = new Set();
|
|
801
|
+
stylexIncludeImport = new Set();
|
|
802
|
+
stylexFirstThatWorksImport = new Set();
|
|
803
|
+
stylexKeyframesImport = new Set();
|
|
804
|
+
stylexPositionTryImport = new Set();
|
|
805
|
+
stylexDefineVarsImport = new Set();
|
|
806
|
+
stylexDefineConstsImport = new Set();
|
|
807
|
+
stylexCreateThemeImport = new Set();
|
|
808
|
+
stylexTypesImport = new Set();
|
|
809
|
+
stylexViewTransitionClassImport = new Set();
|
|
724
810
|
injectImportInserted = null;
|
|
725
|
-
styleMap =
|
|
726
|
-
styleVars =
|
|
727
|
-
styleVarsToKeep =
|
|
811
|
+
styleMap = new Map();
|
|
812
|
+
styleVars = new Map();
|
|
813
|
+
styleVarsToKeep = new Set();
|
|
728
814
|
inStyleXCreate = false;
|
|
729
815
|
constructor(state) {
|
|
730
816
|
this._state = state;
|
|
@@ -740,6 +826,7 @@ class StateManager {
|
|
|
740
826
|
const enableFontSizePxToRem = logAndDefault(boolean(), options.enableFontSizePxToRem ?? false, false, 'options.enableFontSizePxToRem');
|
|
741
827
|
const enableInlinedConditionalMerge = logAndDefault(boolean(), options.enableInlinedConditionalMerge ?? true, true, 'options.enableInlinedConditionalMerge');
|
|
742
828
|
const enableMinifiedKeys = logAndDefault(boolean(), options.enableMinifiedKeys ?? true, true, 'options.enableMinifiedKeys');
|
|
829
|
+
const enableMediaQueryOrder = logAndDefault(boolean(), options.enableMediaQueryOrder ?? false, false, 'options.enableMediaQueryOrder');
|
|
743
830
|
const enableLegacyValueFlipping = logAndDefault(boolean(), options.enableLegacyValueFlipping ?? false, false, 'options.enableLegacyValueFlipping');
|
|
744
831
|
const enableLogicalStylesPolyfill = logAndDefault(boolean(), options.enableLogicalStylesPolyfill ?? false, false, 'options.enableLogicalStylesPolyfill');
|
|
745
832
|
const test = logAndDefault(boolean(), options.test ?? false, false, 'options.test');
|
|
@@ -752,8 +839,7 @@ class StateManager {
|
|
|
752
839
|
const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
|
|
753
840
|
const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? false, false, 'options.treeshakeCompensation');
|
|
754
841
|
const aliasesOption = logAndDefault(unionOf(nullish(), objectOf(unionOf(string(), array(string())))), options.aliases, null, 'options.aliases');
|
|
755
|
-
const aliases = aliasesOption == null ? aliasesOption : Object.fromEntries(Object.entries(aliasesOption).map(
|
|
756
|
-
let [key, value] = _ref;
|
|
842
|
+
const aliases = aliasesOption == null ? aliasesOption : Object.fromEntries(Object.entries(aliasesOption).map(([key, value]) => {
|
|
757
843
|
if (typeof value === 'string') {
|
|
758
844
|
return [key, [value]];
|
|
759
845
|
}
|
|
@@ -771,6 +857,7 @@ class StateManager {
|
|
|
771
857
|
enableFontSizePxToRem,
|
|
772
858
|
enableInlinedConditionalMerge,
|
|
773
859
|
enableMinifiedKeys,
|
|
860
|
+
enableMediaQueryOrder,
|
|
774
861
|
enableLegacyValueFlipping,
|
|
775
862
|
enableLogicalStylesPolyfill,
|
|
776
863
|
importSources,
|
|
@@ -818,62 +905,6 @@ class StateManager {
|
|
|
818
905
|
from: runInj
|
|
819
906
|
} : runInj || null;
|
|
820
907
|
}
|
|
821
|
-
addNamedImport(statementPath, as, from, options) {
|
|
822
|
-
const identifier = libExports$1.addNamed(statementPath, as, from, options);
|
|
823
|
-
const programPath = getProgramPath(statementPath);
|
|
824
|
-
if (programPath == null) {
|
|
825
|
-
return identifier;
|
|
826
|
-
}
|
|
827
|
-
const bodyPath = programPath.get('body');
|
|
828
|
-
let targetImportIndex = -1;
|
|
829
|
-
for (let i = 0; i < bodyPath.length; i++) {
|
|
830
|
-
const statement = bodyPath[i];
|
|
831
|
-
if (statement.isImportDeclaration()) {
|
|
832
|
-
targetImportIndex = i;
|
|
833
|
-
if (statement.node.specifiers.find(s => s.type === 'ImportSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
if (targetImportIndex === -1) {
|
|
839
|
-
return identifier;
|
|
840
|
-
}
|
|
841
|
-
const lastImport = bodyPath[targetImportIndex];
|
|
842
|
-
if (lastImport == null) {
|
|
843
|
-
return identifier;
|
|
844
|
-
}
|
|
845
|
-
const importName = statementPath.scope.generateUidIdentifier(as);
|
|
846
|
-
lastImport.insertAfter(t__namespace.variableDeclaration('var', [t__namespace.variableDeclarator(importName, identifier)]));
|
|
847
|
-
return importName;
|
|
848
|
-
}
|
|
849
|
-
addDefaultImport(statementPath, from, options) {
|
|
850
|
-
const identifier = libExports$1.addDefault(statementPath, from, options);
|
|
851
|
-
const programPath = getProgramPath(statementPath);
|
|
852
|
-
if (programPath == null) {
|
|
853
|
-
return identifier;
|
|
854
|
-
}
|
|
855
|
-
const bodyPath = programPath.get('body');
|
|
856
|
-
let targetImportIndex = -1;
|
|
857
|
-
for (let i = 0; i < bodyPath.length; i++) {
|
|
858
|
-
const statement = bodyPath[i];
|
|
859
|
-
if (statement.isImportDeclaration()) {
|
|
860
|
-
targetImportIndex = i;
|
|
861
|
-
if (statement.node.specifiers.find(s => s.type === 'ImportDefaultSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
862
|
-
break;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
if (targetImportIndex === -1) {
|
|
867
|
-
return identifier;
|
|
868
|
-
}
|
|
869
|
-
const lastImport = bodyPath[targetImportIndex];
|
|
870
|
-
if (lastImport == null) {
|
|
871
|
-
return identifier;
|
|
872
|
-
}
|
|
873
|
-
const importName = statementPath.scope.generateUidIdentifier('inject');
|
|
874
|
-
lastImport.insertAfter(t__namespace.variableDeclaration('var', [t__namespace.variableDeclarator(importName, identifier)]));
|
|
875
|
-
return importName;
|
|
876
|
-
}
|
|
877
908
|
get opts() {
|
|
878
909
|
return {
|
|
879
910
|
...this.options
|
|
@@ -1001,9 +1032,9 @@ class StateManager {
|
|
|
1001
1032
|
from,
|
|
1002
1033
|
as
|
|
1003
1034
|
} = runtimeInjection;
|
|
1004
|
-
injectName = as != null ?
|
|
1035
|
+
injectName = as != null ? addNamedImport(statementPath, as, from, {
|
|
1005
1036
|
nameHint: 'inject'
|
|
1006
|
-
}) :
|
|
1037
|
+
}) : addDefaultImport(statementPath, from, {
|
|
1007
1038
|
nameHint: 'inject'
|
|
1008
1039
|
});
|
|
1009
1040
|
this.injectImportInserted = injectName;
|
|
@@ -1076,24 +1107,6 @@ const addFileExtension = (importedFilePath, sourceFile) => {
|
|
|
1076
1107
|
return importedFilePath + fileExtension;
|
|
1077
1108
|
};
|
|
1078
1109
|
const matchesFileSuffix = allowedSuffix => filename => ['', ...EXTENSIONS].some(extension => filename.endsWith(`${allowedSuffix}${extension}`));
|
|
1079
|
-
const getProgramPath = path => {
|
|
1080
|
-
let programPath = path;
|
|
1081
|
-
while (programPath != null && !programPath.isProgram()) {
|
|
1082
|
-
if (programPath.parentPath) {
|
|
1083
|
-
programPath = programPath.parentPath;
|
|
1084
|
-
} else {
|
|
1085
|
-
return null;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
return programPath;
|
|
1089
|
-
};
|
|
1090
|
-
const getProgramStatement = path => {
|
|
1091
|
-
let programPath = path;
|
|
1092
|
-
while (programPath.parentPath != null && !programPath.parentPath.isProgram() && programPath.parentPath != null) {
|
|
1093
|
-
programPath = programPath.parentPath;
|
|
1094
|
-
}
|
|
1095
|
-
return programPath;
|
|
1096
|
-
};
|
|
1097
1110
|
function getRelativePath(from, to) {
|
|
1098
1111
|
const relativePath = path.relative(path.parse(from).dir, to);
|
|
1099
1112
|
return formatRelativePath(toPosixPath(relativePath));
|
|
@@ -1229,8 +1242,7 @@ function readRequires(path, state) {
|
|
|
1229
1242
|
}
|
|
1230
1243
|
}
|
|
1231
1244
|
|
|
1232
|
-
function murmurhash2_32_gc(str) {
|
|
1233
|
-
let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1245
|
+
function murmurhash2_32_gc(str, seed = 0) {
|
|
1234
1246
|
let l = str.length,
|
|
1235
1247
|
h = seed ^ l,
|
|
1236
1248
|
i = 0,
|
|
@@ -1280,6 +1292,7 @@ const defaultOptions = {
|
|
|
1280
1292
|
enableDevClassNames: false,
|
|
1281
1293
|
enableDebugDataProp: true,
|
|
1282
1294
|
enableFontSizePxToRem: false,
|
|
1295
|
+
enableMediaQueryOrder: false,
|
|
1283
1296
|
enableLegacyValueFlipping: false,
|
|
1284
1297
|
enableLogicalStylesPolyfill: false,
|
|
1285
1298
|
enableMinifiedKeys: true,
|
|
@@ -2014,12 +2027,12 @@ function requireUnit () {
|
|
|
2014
2027
|
return unit;
|
|
2015
2028
|
}
|
|
2016
2029
|
|
|
2017
|
-
var lib;
|
|
2018
|
-
var hasRequiredLib;
|
|
2030
|
+
var lib$1;
|
|
2031
|
+
var hasRequiredLib$1;
|
|
2019
2032
|
|
|
2020
|
-
function requireLib () {
|
|
2021
|
-
if (hasRequiredLib) return lib;
|
|
2022
|
-
hasRequiredLib = 1;
|
|
2033
|
+
function requireLib$1 () {
|
|
2034
|
+
if (hasRequiredLib$1) return lib$1;
|
|
2035
|
+
hasRequiredLib$1 = 1;
|
|
2023
2036
|
var parse = requireParse();
|
|
2024
2037
|
var walk = requireWalk();
|
|
2025
2038
|
var stringify = requireStringify();
|
|
@@ -2047,12 +2060,12 @@ function requireLib () {
|
|
|
2047
2060
|
|
|
2048
2061
|
ValueParser.stringify = stringify;
|
|
2049
2062
|
|
|
2050
|
-
lib = ValueParser;
|
|
2051
|
-
return lib;
|
|
2063
|
+
lib$1 = ValueParser;
|
|
2064
|
+
return lib$1;
|
|
2052
2065
|
}
|
|
2053
2066
|
|
|
2054
|
-
var libExports = requireLib();
|
|
2055
|
-
var parser = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
2067
|
+
var libExports$1 = requireLib$1();
|
|
2068
|
+
var parser = /*@__PURE__*/getDefaultExportFromCjs(libExports$1);
|
|
2056
2069
|
|
|
2057
2070
|
function printNode(node) {
|
|
2058
2071
|
switch (node.type) {
|
|
@@ -2331,25 +2344,2035 @@ const expansions$1 = {
|
|
|
2331
2344
|
...aliases
|
|
2332
2345
|
};
|
|
2333
2346
|
|
|
2334
|
-
const expansions = {
|
|
2335
|
-
'application-order': expansions$3,
|
|
2336
|
-
'property-specificity': expansions$1,
|
|
2337
|
-
'legacy-expand-shorthands': expansions$2
|
|
2338
|
-
};
|
|
2339
|
-
function flatMapExpandedShorthands(objEntry, options) {
|
|
2340
|
-
let [key, value] = objEntry;
|
|
2341
|
-
if (key.startsWith('var(') && key.endsWith(')')) {
|
|
2342
|
-
key = key.slice(4, -1);
|
|
2343
|
-
}
|
|
2344
|
-
const expansion = expansions[options.styleResolution ?? 'property-specificity'][key];
|
|
2345
|
-
if (expansion) {
|
|
2346
|
-
if (Array.isArray(value)) {
|
|
2347
|
-
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
|
2348
|
-
}
|
|
2349
|
-
return expansion(value);
|
|
2350
|
-
}
|
|
2351
|
-
return [[key, value]];
|
|
2352
|
-
}
|
|
2347
|
+
const expansions = {
|
|
2348
|
+
'application-order': expansions$3,
|
|
2349
|
+
'property-specificity': expansions$1,
|
|
2350
|
+
'legacy-expand-shorthands': expansions$2
|
|
2351
|
+
};
|
|
2352
|
+
function flatMapExpandedShorthands(objEntry, options) {
|
|
2353
|
+
let [key, value] = objEntry;
|
|
2354
|
+
if (key.startsWith('var(') && key.endsWith(')')) {
|
|
2355
|
+
key = key.slice(4, -1);
|
|
2356
|
+
}
|
|
2357
|
+
const expansion = expansions[options.styleResolution ?? 'property-specificity'][key];
|
|
2358
|
+
if (expansion) {
|
|
2359
|
+
if (Array.isArray(value)) {
|
|
2360
|
+
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
|
2361
|
+
}
|
|
2362
|
+
return expansion(value);
|
|
2363
|
+
}
|
|
2364
|
+
return [[key, value]];
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
var lib = {};
|
|
2368
|
+
|
|
2369
|
+
var tokenParser = {};
|
|
2370
|
+
|
|
2371
|
+
var tokenTypes = {};
|
|
2372
|
+
|
|
2373
|
+
var dist = {};
|
|
2374
|
+
|
|
2375
|
+
var hasRequiredDist;
|
|
2376
|
+
|
|
2377
|
+
function requireDist () {
|
|
2378
|
+
if (hasRequiredDist) return dist;
|
|
2379
|
+
hasRequiredDist = 1;
|
|
2380
|
+
(function (exports) {
|
|
2381
|
+
class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t;}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r;}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return [exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else {if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n));}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports.HashType.ID);const t=consumeIdentSequence(e,n);return [exports.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return [exports.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else {if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3);}for(o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+");}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return [exports.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return [exports.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports.TokenType=void 0,(c=exports.TokenType||(exports.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports.NumberType=void 0,(a=exports.NumberType||(exports.NumberType={})).Integer="integer",a.Number="number",exports.HashType=void 0,(u=exports.HashType||(exports.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e;}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1;}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1;}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1;}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return [exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else {if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t));}}}function checkIfCodePointsMatchURLIdent(e){return !(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint();}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const s=o.source.codePointAt(o.cursor);if(34===s||39===s||40===s||(11===(r=s??-1)||127===r||0<=r&&r<=8||14<=r&&r<=31)){consumeBadURL(n,o);const t=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===s){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint());}var r;}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return [exports.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return !(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??false,u=new Reader(c),d={onParseError:i?.onParseError??noop};return {nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return [exports.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return [exports.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return [exports.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else {if(e[0]===t&&!e[1])return [92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]));}for(let o=n;o<e.length;o++)0!==e[o]?isIdentCodePoint(e[o])||(o+=insertEscapedCharacter(e,o,e[o])):(e.splice(o,1,i),o++);return e}function insertEscapedCharacter(e,n,o){return e.splice(n,1,92,o),1}function insertEscapedCodePoint(e,n,o){const t=o.toString(16),r=[];for(const e of t)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(exports.TokenType);exports.ParseError=ParseError,exports.ParseErrorMessage=e,exports.ParseErrorWithToken=ParseErrorWithToken,exports.cloneTokens=function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))},exports.isToken=function isToken(e){return !!Array.isArray(e)&&(!(e.length<4)&&(!!d.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports.isTokenAtKeyword=function isTokenAtKeyword(e){return !!e&&e[0]===exports.TokenType.AtKeyword},exports.isTokenBadString=function isTokenBadString(e){return !!e&&e[0]===exports.TokenType.BadString},exports.isTokenBadURL=function isTokenBadURL(e){return !!e&&e[0]===exports.TokenType.BadURL},exports.isTokenCDC=function isTokenCDC(e){return !!e&&e[0]===exports.TokenType.CDC},exports.isTokenCDO=function isTokenCDO(e){return !!e&&e[0]===exports.TokenType.CDO},exports.isTokenCloseCurly=function isTokenCloseCurly(e){return !!e&&e[0]===exports.TokenType.CloseCurly},exports.isTokenCloseParen=function isTokenCloseParen(e){return !!e&&e[0]===exports.TokenType.CloseParen},exports.isTokenCloseSquare=function isTokenCloseSquare(e){return !!e&&e[0]===exports.TokenType.CloseSquare},exports.isTokenColon=function isTokenColon(e){return !!e&&e[0]===exports.TokenType.Colon},exports.isTokenComma=function isTokenComma(e){return !!e&&e[0]===exports.TokenType.Comma},exports.isTokenComment=function isTokenComment(e){return !!e&&e[0]===exports.TokenType.Comment},exports.isTokenDelim=function isTokenDelim(e){return !!e&&e[0]===exports.TokenType.Delim},exports.isTokenDimension=function isTokenDimension(e){return !!e&&e[0]===exports.TokenType.Dimension},exports.isTokenEOF=function isTokenEOF(e){return !!e&&e[0]===exports.TokenType.EOF},exports.isTokenFunction=function isTokenFunction(e){return !!e&&e[0]===exports.TokenType.Function},exports.isTokenHash=function isTokenHash(e){return !!e&&e[0]===exports.TokenType.Hash},exports.isTokenIdent=function isTokenIdent(e){return !!e&&e[0]===exports.TokenType.Ident},exports.isTokenNumber=function isTokenNumber(e){return !!e&&e[0]===exports.TokenType.Number},exports.isTokenNumeric=function isTokenNumeric(e){if(!e)return false;switch(e[0]){case exports.TokenType.Dimension:case exports.TokenType.Number:case exports.TokenType.Percentage:return true;default:return false}},exports.isTokenOpenCurly=function isTokenOpenCurly(e){return !!e&&e[0]===exports.TokenType.OpenCurly},exports.isTokenOpenParen=function isTokenOpenParen(e){return !!e&&e[0]===exports.TokenType.OpenParen},exports.isTokenOpenSquare=function isTokenOpenSquare(e){return !!e&&e[0]===exports.TokenType.OpenSquare},exports.isTokenPercentage=function isTokenPercentage(e){return !!e&&e[0]===exports.TokenType.Percentage},exports.isTokenSemicolon=function isTokenSemicolon(e){return !!e&&e[0]===exports.TokenType.Semicolon},exports.isTokenString=function isTokenString(e){return !!e&&e[0]===exports.TokenType.String},exports.isTokenURL=function isTokenURL(e){return !!e&&e[0]===exports.TokenType.URL},exports.isTokenUnicodeRange=function isTokenUnicodeRange(e){return !!e&&e[0]===exports.TokenType.UnicodeRange},exports.isTokenWhiteSpaceOrComment=function isTokenWhiteSpaceOrComment(e){if(!e)return false;switch(e[0]){case exports.TokenType.Whitespace:case exports.TokenType.Comment:return true;default:return false}},exports.isTokenWhitespace=function isTokenWhitespace(e){return !!e&&e[0]===exports.TokenType.Whitespace},exports.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports.TokenType.OpenParen:return [exports.TokenType.CloseParen,")",-1,-1,void 0];case exports.TokenType.CloseParen:return [exports.TokenType.OpenParen,"(",-1,-1,void 0];case exports.TokenType.OpenCurly:return [exports.TokenType.CloseCurly,"}",-1,-1,void 0];case exports.TokenType.CloseCurly:return [exports.TokenType.OpenCurly,"{",-1,-1,void 0];case exports.TokenType.OpenSquare:return [exports.TokenType.CloseSquare,"]",-1,-1,void 0];case exports.TokenType.CloseSquare:return [exports.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports.TokenType.OpenParen:return exports.TokenType.CloseParen;case exports.TokenType.CloseParen:return exports.TokenType.OpenParen;case exports.TokenType.OpenCurly:return exports.TokenType.CloseCurly;case exports.TokenType.CloseCurly:return exports.TokenType.OpenCurly;case exports.TokenType.OpenSquare:return exports.TokenType.CloseSquare;case exports.TokenType.CloseSquare:return exports.TokenType.OpenSquare;default:return null}},exports.mutateIdent=function mutateIdent(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=String.fromCodePoint(...serializeIdent(o));e[1]=t,e[4].value=n;},exports.mutateUnit=function mutateUnit(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=serializeIdent(o);101===t[0]&&insertEscapedCodePoint(t,0,t[0]);const r=String.fromCodePoint(...t),s="+"===e[4].signCharacter?e[4].signCharacter:"",i=e[4].value.toString();e[1]=`${s}${i}${r}`,e[4].unit=n;},exports.stringify=function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n},exports.tokenize=function tokenize(e,n){const o=tokenizer(e,n),t=[];for(;!o.endOfFile();)t.push(o.nextToken());return t.push(o.nextToken()),t},exports.tokenizer=tokenizer;
|
|
2382
|
+
} (dist));
|
|
2383
|
+
return dist;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
var hasRequiredTokenTypes;
|
|
2387
|
+
|
|
2388
|
+
function requireTokenTypes () {
|
|
2389
|
+
if (hasRequiredTokenTypes) return tokenTypes;
|
|
2390
|
+
hasRequiredTokenTypes = 1;
|
|
2391
|
+
|
|
2392
|
+
Object.defineProperty(tokenTypes, "__esModule", {
|
|
2393
|
+
value: true
|
|
2394
|
+
});
|
|
2395
|
+
tokenTypes.TokenList = void 0;
|
|
2396
|
+
var _cssTokenizer = requireDist();
|
|
2397
|
+
class TokenList {
|
|
2398
|
+
constructor(input) {
|
|
2399
|
+
const iterator = typeof input === 'string' ? (0, _cssTokenizer.tokenizer)({
|
|
2400
|
+
css: input
|
|
2401
|
+
}) : input;
|
|
2402
|
+
this.tokenIterator = iterator;
|
|
2403
|
+
this.consumedTokens = [];
|
|
2404
|
+
this.currentIndex = 0;
|
|
2405
|
+
this.isAtEnd = false;
|
|
2406
|
+
}
|
|
2407
|
+
consumeNextToken() {
|
|
2408
|
+
if (this.currentIndex < this.consumedTokens.length) {
|
|
2409
|
+
return this.consumedTokens[this.currentIndex++];
|
|
2410
|
+
}
|
|
2411
|
+
if (this.isAtEnd) {
|
|
2412
|
+
return null;
|
|
2413
|
+
}
|
|
2414
|
+
if (this.tokenIterator.endOfFile()) {
|
|
2415
|
+
this.isAtEnd = true;
|
|
2416
|
+
return null;
|
|
2417
|
+
}
|
|
2418
|
+
const token = this.tokenIterator.nextToken();
|
|
2419
|
+
this.consumedTokens.push(token);
|
|
2420
|
+
this.currentIndex++;
|
|
2421
|
+
if (this.tokenIterator.endOfFile()) {
|
|
2422
|
+
this.isAtEnd = true;
|
|
2423
|
+
}
|
|
2424
|
+
return token;
|
|
2425
|
+
}
|
|
2426
|
+
peek() {
|
|
2427
|
+
if (this.currentIndex < this.consumedTokens.length) {
|
|
2428
|
+
return this.consumedTokens[this.currentIndex];
|
|
2429
|
+
}
|
|
2430
|
+
if (this.isAtEnd || this.tokenIterator.endOfFile()) {
|
|
2431
|
+
return null;
|
|
2432
|
+
}
|
|
2433
|
+
const token = this.tokenIterator.nextToken();
|
|
2434
|
+
this.consumedTokens.push(token);
|
|
2435
|
+
return token;
|
|
2436
|
+
}
|
|
2437
|
+
get first() {
|
|
2438
|
+
return this.peek();
|
|
2439
|
+
}
|
|
2440
|
+
setCurrentIndex(newIndex) {
|
|
2441
|
+
if (newIndex < this.consumedTokens.length) {
|
|
2442
|
+
this.currentIndex = newIndex;
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
while (!this.isAtEnd && !this.tokenIterator.endOfFile() && this.consumedTokens.length <= newIndex) {
|
|
2446
|
+
const token = this.tokenIterator.nextToken();
|
|
2447
|
+
this.consumedTokens.push(token);
|
|
2448
|
+
if (this.tokenIterator.endOfFile()) {
|
|
2449
|
+
this.isAtEnd = true;
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
this.currentIndex = Math.min(newIndex, this.consumedTokens.length);
|
|
2453
|
+
}
|
|
2454
|
+
rewind(positions = 1) {
|
|
2455
|
+
this.currentIndex = Math.max(0, this.currentIndex - positions);
|
|
2456
|
+
}
|
|
2457
|
+
get isEmpty() {
|
|
2458
|
+
return this.isAtEnd || this.currentIndex >= this.consumedTokens.length && this.tokenIterator.endOfFile();
|
|
2459
|
+
}
|
|
2460
|
+
getAllTokens() {
|
|
2461
|
+
while (!this.isEmpty) {
|
|
2462
|
+
this.consumeNextToken();
|
|
2463
|
+
}
|
|
2464
|
+
return this.consumedTokens;
|
|
2465
|
+
}
|
|
2466
|
+
slice(start, end = this.currentIndex) {
|
|
2467
|
+
const initialIndex = this.currentIndex;
|
|
2468
|
+
if (start < 0 || end < start) {
|
|
2469
|
+
return [];
|
|
2470
|
+
}
|
|
2471
|
+
this.setCurrentIndex(start);
|
|
2472
|
+
const result = [];
|
|
2473
|
+
while (this.currentIndex < end) {
|
|
2474
|
+
const token = this.consumeNextToken();
|
|
2475
|
+
if (token == null) {
|
|
2476
|
+
break;
|
|
2477
|
+
}
|
|
2478
|
+
result.push(token);
|
|
2479
|
+
}
|
|
2480
|
+
this.setCurrentIndex(initialIndex);
|
|
2481
|
+
return result;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
tokenTypes.TokenList = TokenList;
|
|
2485
|
+
return tokenTypes;
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
var hasRequiredTokenParser;
|
|
2489
|
+
|
|
2490
|
+
function requireTokenParser () {
|
|
2491
|
+
if (hasRequiredTokenParser) return tokenParser;
|
|
2492
|
+
hasRequiredTokenParser = 1;
|
|
2493
|
+
|
|
2494
|
+
Object.defineProperty(tokenParser, "__esModule", {
|
|
2495
|
+
value: true
|
|
2496
|
+
});
|
|
2497
|
+
tokenParser.TokenParser = tokenParser.TokenOneOrMoreParsers = void 0;
|
|
2498
|
+
var _tokenTypes = requireTokenTypes();
|
|
2499
|
+
var _cssTokenizer = requireDist();
|
|
2500
|
+
class TokenParser {
|
|
2501
|
+
constructor(parser, label = 'UnknownParser') {
|
|
2502
|
+
this.run = parser;
|
|
2503
|
+
this.label = label;
|
|
2504
|
+
}
|
|
2505
|
+
parse(css) {
|
|
2506
|
+
const tokens = new _tokenTypes.TokenList(css);
|
|
2507
|
+
return this.run(tokens);
|
|
2508
|
+
}
|
|
2509
|
+
parseToEnd(css) {
|
|
2510
|
+
const tokens = new _tokenTypes.TokenList(css);
|
|
2511
|
+
const initialIndex = tokens.currentIndex;
|
|
2512
|
+
const output = this.run(tokens);
|
|
2513
|
+
if (output instanceof Error) {
|
|
2514
|
+
const consumedTokens = tokens.slice(initialIndex);
|
|
2515
|
+
tokens.setCurrentIndex(initialIndex);
|
|
2516
|
+
throw new Error(`Expected ${this.toString()} but got ${output.message}\n` + `Consumed tokens: ${consumedTokens.map(token => token[0]).join(', ')}`);
|
|
2517
|
+
}
|
|
2518
|
+
if (tokens.peek() != null) {
|
|
2519
|
+
const token = tokens.peek();
|
|
2520
|
+
if (token == null) {
|
|
2521
|
+
return output;
|
|
2522
|
+
}
|
|
2523
|
+
const consumedTokens = tokens.slice(initialIndex);
|
|
2524
|
+
throw new Error(`Expected end of input, got ${token[0]} instead\n` + `Consumed tokens: ${consumedTokens.map(token => token[0]).join(', ')}`);
|
|
2525
|
+
}
|
|
2526
|
+
return output;
|
|
2527
|
+
}
|
|
2528
|
+
map(f, label) {
|
|
2529
|
+
return new TokenParser(input => {
|
|
2530
|
+
const currentIndex = input.currentIndex;
|
|
2531
|
+
const result = this.run(input);
|
|
2532
|
+
if (result instanceof Error) {
|
|
2533
|
+
input.setCurrentIndex(currentIndex);
|
|
2534
|
+
return result;
|
|
2535
|
+
}
|
|
2536
|
+
return f(result);
|
|
2537
|
+
}, `${this.label}.map(${label ?? ''})`);
|
|
2538
|
+
}
|
|
2539
|
+
flatMap(f, label) {
|
|
2540
|
+
return new TokenParser(input => {
|
|
2541
|
+
const currentIndex = input.currentIndex;
|
|
2542
|
+
const output1 = this.run(input);
|
|
2543
|
+
if (output1 instanceof Error) {
|
|
2544
|
+
input.setCurrentIndex(currentIndex);
|
|
2545
|
+
return output1;
|
|
2546
|
+
}
|
|
2547
|
+
const secondParser = f(output1);
|
|
2548
|
+
const output2 = secondParser.run(input);
|
|
2549
|
+
if (output2 instanceof Error) {
|
|
2550
|
+
input.setCurrentIndex(currentIndex);
|
|
2551
|
+
return output2;
|
|
2552
|
+
}
|
|
2553
|
+
return output2;
|
|
2554
|
+
}, `${this.label}.flatMap(${label ?? ''})`);
|
|
2555
|
+
}
|
|
2556
|
+
or(parser2) {
|
|
2557
|
+
return new TokenParser(input => {
|
|
2558
|
+
const currentIndex = input.currentIndex;
|
|
2559
|
+
const output1 = this.run(input);
|
|
2560
|
+
if (output1 instanceof Error) {
|
|
2561
|
+
input.setCurrentIndex(currentIndex);
|
|
2562
|
+
const output2 = parser2.run(input);
|
|
2563
|
+
if (output2 instanceof Error) {
|
|
2564
|
+
input.setCurrentIndex(currentIndex);
|
|
2565
|
+
}
|
|
2566
|
+
return output2;
|
|
2567
|
+
}
|
|
2568
|
+
return output1;
|
|
2569
|
+
}, parser2.label === 'optional' ? `Optional<${this.label}>` : `OneOf<${this.label}, ${parser2.label}>`);
|
|
2570
|
+
}
|
|
2571
|
+
surroundedBy(prefix, suffix = prefix) {
|
|
2572
|
+
return TokenParser.sequence(prefix, this, suffix).map(([_prefix, value, _suffix]) => value);
|
|
2573
|
+
}
|
|
2574
|
+
skip(skipParser) {
|
|
2575
|
+
return this.flatMap(output => skipParser.map(() => output));
|
|
2576
|
+
}
|
|
2577
|
+
get optional() {
|
|
2578
|
+
return new TokenOptionalParser(this);
|
|
2579
|
+
}
|
|
2580
|
+
prefix(prefixParser) {
|
|
2581
|
+
return prefixParser.flatMap(() => this);
|
|
2582
|
+
}
|
|
2583
|
+
suffix(suffixParser) {
|
|
2584
|
+
return this.flatMap(output => suffixParser.map(() => output));
|
|
2585
|
+
}
|
|
2586
|
+
where(predicate, label = '') {
|
|
2587
|
+
return this.flatMap(output => {
|
|
2588
|
+
if (predicate(output)) {
|
|
2589
|
+
return TokenParser.always(output);
|
|
2590
|
+
}
|
|
2591
|
+
return TokenParser.never();
|
|
2592
|
+
}, label);
|
|
2593
|
+
}
|
|
2594
|
+
toString() {
|
|
2595
|
+
return this.label;
|
|
2596
|
+
}
|
|
2597
|
+
static never() {
|
|
2598
|
+
return new TokenParser(() => new Error('Never'), 'Never');
|
|
2599
|
+
}
|
|
2600
|
+
static always(output) {
|
|
2601
|
+
return new TokenParser(() => output, output === undefined ? 'optional' : `Always<${String(output)}>`);
|
|
2602
|
+
}
|
|
2603
|
+
static token(tokenType, label = tokenType) {
|
|
2604
|
+
return new TokenParser(input => {
|
|
2605
|
+
const currentIndex = input.currentIndex;
|
|
2606
|
+
const token = input.consumeNextToken();
|
|
2607
|
+
if (token == null) {
|
|
2608
|
+
input.setCurrentIndex(currentIndex);
|
|
2609
|
+
return new Error('Expected token');
|
|
2610
|
+
}
|
|
2611
|
+
if (token[0] !== tokenType) {
|
|
2612
|
+
input.setCurrentIndex(currentIndex);
|
|
2613
|
+
return new Error(`Expected token type ${tokenType}, got ${token[0]}`);
|
|
2614
|
+
}
|
|
2615
|
+
return token;
|
|
2616
|
+
}, label);
|
|
2617
|
+
}
|
|
2618
|
+
static string(str) {
|
|
2619
|
+
return TokenParser.tokens.Ident.map(token => token[4].value, '.value').where(value => value === str, `=== ${str}`);
|
|
2620
|
+
}
|
|
2621
|
+
static fn(name) {
|
|
2622
|
+
return TokenParser.tokens.Function.map(token => token[4].value, '.value').where(value => value === name, `=== ${name}`);
|
|
2623
|
+
}
|
|
2624
|
+
static tokens = {
|
|
2625
|
+
Comment: TokenParser.token(_cssTokenizer.TokenType.Comment, 'Comment'),
|
|
2626
|
+
AtKeyword: TokenParser.token(_cssTokenizer.TokenType.AtKeyword, 'AtKeyword'),
|
|
2627
|
+
BadString: TokenParser.token(_cssTokenizer.TokenType.BadString, 'BadString'),
|
|
2628
|
+
BadURL: TokenParser.token(_cssTokenizer.TokenType.BadURL, 'BadURL'),
|
|
2629
|
+
CDC: TokenParser.token(_cssTokenizer.TokenType.CDC, 'CDC'),
|
|
2630
|
+
CDO: TokenParser.token(_cssTokenizer.TokenType.CDO, 'CDO'),
|
|
2631
|
+
Colon: TokenParser.token(_cssTokenizer.TokenType.Colon, 'Colon'),
|
|
2632
|
+
Comma: TokenParser.token(_cssTokenizer.TokenType.Comma, 'Comma'),
|
|
2633
|
+
Delim: TokenParser.token(_cssTokenizer.TokenType.Delim, 'Delim'),
|
|
2634
|
+
Dimension: TokenParser.token(_cssTokenizer.TokenType.Dimension, 'Dimension'),
|
|
2635
|
+
EOF: TokenParser.token(_cssTokenizer.TokenType.EOF, 'EOF'),
|
|
2636
|
+
Function: TokenParser.token(_cssTokenizer.TokenType.Function, 'Function'),
|
|
2637
|
+
Hash: TokenParser.token(_cssTokenizer.TokenType.Hash, 'Hash'),
|
|
2638
|
+
Ident: TokenParser.token(_cssTokenizer.TokenType.Ident, 'Ident'),
|
|
2639
|
+
Number: TokenParser.token(_cssTokenizer.TokenType.Number, 'Number'),
|
|
2640
|
+
Percentage: TokenParser.token(_cssTokenizer.TokenType.Percentage, 'Percentage'),
|
|
2641
|
+
Semicolon: TokenParser.token(_cssTokenizer.TokenType.Semicolon, 'Semicolon'),
|
|
2642
|
+
String: TokenParser.token(_cssTokenizer.TokenType.String, 'String'),
|
|
2643
|
+
URL: TokenParser.token(_cssTokenizer.TokenType.URL, 'URL'),
|
|
2644
|
+
Whitespace: TokenParser.token(_cssTokenizer.TokenType.Whitespace, 'Whitespace'),
|
|
2645
|
+
OpenParen: TokenParser.token(_cssTokenizer.TokenType.OpenParen, 'OpenParen'),
|
|
2646
|
+
CloseParen: TokenParser.token(_cssTokenizer.TokenType.CloseParen, 'CloseParen'),
|
|
2647
|
+
OpenSquare: TokenParser.token(_cssTokenizer.TokenType.OpenSquare, 'OpenSquare'),
|
|
2648
|
+
CloseSquare: TokenParser.token(_cssTokenizer.TokenType.CloseSquare, 'CloseSquare'),
|
|
2649
|
+
OpenCurly: TokenParser.token(_cssTokenizer.TokenType.OpenCurly, 'OpenCurly'),
|
|
2650
|
+
CloseCurly: TokenParser.token(_cssTokenizer.TokenType.CloseCurly, 'CloseCurly'),
|
|
2651
|
+
UnicodeRange: TokenParser.token(_cssTokenizer.TokenType.UnicodeRange, 'UnicodeRange')
|
|
2652
|
+
};
|
|
2653
|
+
static oneOf(...parsers) {
|
|
2654
|
+
return new TokenParser(input => {
|
|
2655
|
+
const errors = [];
|
|
2656
|
+
const index = input.currentIndex;
|
|
2657
|
+
for (const parser of parsers) {
|
|
2658
|
+
const output = typeof parser === 'function' ? parser().run(input) : parser.run(input);
|
|
2659
|
+
if (!(output instanceof Error)) {
|
|
2660
|
+
return output;
|
|
2661
|
+
}
|
|
2662
|
+
input.setCurrentIndex(index);
|
|
2663
|
+
errors.push(output);
|
|
2664
|
+
}
|
|
2665
|
+
return new Error('No parser matched\n' + errors.map(err => '- ' + err.toString()).join('\n'));
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
static sequence(...parsers) {
|
|
2669
|
+
return new TokenParserSequence(parsers);
|
|
2670
|
+
}
|
|
2671
|
+
static setOf(...parsers) {
|
|
2672
|
+
return new TokenParserSet(parsers);
|
|
2673
|
+
}
|
|
2674
|
+
static zeroOrMore(parser) {
|
|
2675
|
+
return new TokenZeroOrMoreParsers(parser);
|
|
2676
|
+
}
|
|
2677
|
+
static oneOrMore(parser) {
|
|
2678
|
+
return new TokenOneOrMoreParsers(parser);
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
tokenParser.TokenParser = TokenParser;
|
|
2682
|
+
class TokenZeroOrMoreParsers extends TokenParser {
|
|
2683
|
+
constructor(parser, separator) {
|
|
2684
|
+
super(input => {
|
|
2685
|
+
const output = [];
|
|
2686
|
+
for (let i = 0; true; i++) {
|
|
2687
|
+
if (i > 0 && separator) {
|
|
2688
|
+
const currentIndex = input.currentIndex;
|
|
2689
|
+
const result = separator.run(input);
|
|
2690
|
+
if (result instanceof Error) {
|
|
2691
|
+
input.setCurrentIndex(currentIndex);
|
|
2692
|
+
return output;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
const currentIndex = input.currentIndex;
|
|
2696
|
+
const result = parser.run(input);
|
|
2697
|
+
if (result instanceof Error) {
|
|
2698
|
+
input.setCurrentIndex(currentIndex);
|
|
2699
|
+
return output;
|
|
2700
|
+
}
|
|
2701
|
+
output.push(result);
|
|
2702
|
+
}
|
|
2703
|
+
return output;
|
|
2704
|
+
}, `ZeroOrMore<${parser.label}>`);
|
|
2705
|
+
this.parser = parser;
|
|
2706
|
+
this.separator = separator;
|
|
2707
|
+
}
|
|
2708
|
+
separatedBy(separator) {
|
|
2709
|
+
const voidedSeparator = separator.map(() => undefined);
|
|
2710
|
+
const newSeparator = this.separator?.surroundedBy(voidedSeparator) ?? voidedSeparator;
|
|
2711
|
+
return new TokenZeroOrMoreParsers(this.parser, newSeparator);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
class TokenOneOrMoreParsers extends TokenParser {
|
|
2715
|
+
constructor(parser, separator) {
|
|
2716
|
+
super(input => {
|
|
2717
|
+
const output = [];
|
|
2718
|
+
for (let i = 0; true; i++) {
|
|
2719
|
+
if (i > 0 && separator) {
|
|
2720
|
+
const currentIndex = input.currentIndex;
|
|
2721
|
+
const result = separator.run(input);
|
|
2722
|
+
if (result instanceof Error) {
|
|
2723
|
+
input.setCurrentIndex(currentIndex);
|
|
2724
|
+
return output;
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
const currentIndex = input.currentIndex;
|
|
2728
|
+
const result = parser.run(input);
|
|
2729
|
+
if (result instanceof Error) {
|
|
2730
|
+
if (i === 0) {
|
|
2731
|
+
input.setCurrentIndex(currentIndex);
|
|
2732
|
+
return result;
|
|
2733
|
+
}
|
|
2734
|
+
return output;
|
|
2735
|
+
}
|
|
2736
|
+
output.push(result);
|
|
2737
|
+
}
|
|
2738
|
+
return output;
|
|
2739
|
+
}, `OneOrMore<${parser.label}>`);
|
|
2740
|
+
this.parser = parser;
|
|
2741
|
+
this.separator = separator;
|
|
2742
|
+
}
|
|
2743
|
+
separatedBy(separator) {
|
|
2744
|
+
const voidedSeparator = separator.map(() => undefined);
|
|
2745
|
+
const newSeparator = this.separator?.surroundedBy(voidedSeparator) ?? voidedSeparator;
|
|
2746
|
+
return new TokenOneOrMoreParsers(this.parser, newSeparator);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
tokenParser.TokenOneOrMoreParsers = TokenOneOrMoreParsers;
|
|
2750
|
+
class TokenParserSequence extends TokenParser {
|
|
2751
|
+
constructor(parsers, _separator) {
|
|
2752
|
+
const separator = _separator?.map(() => undefined);
|
|
2753
|
+
super(input => {
|
|
2754
|
+
const currentIndex = input.currentIndex;
|
|
2755
|
+
let failed = null;
|
|
2756
|
+
const output = parsers.map(_parser => {
|
|
2757
|
+
if (failed) {
|
|
2758
|
+
return new Error('already failed');
|
|
2759
|
+
}
|
|
2760
|
+
let parser = _parser;
|
|
2761
|
+
if (separator != null && input.currentIndex > currentIndex) {
|
|
2762
|
+
if (parser instanceof TokenOptionalParser) {
|
|
2763
|
+
parser = TokenParser.sequence(separator, parser.parser).map(([_separator, value]) => value).optional;
|
|
2764
|
+
} else {
|
|
2765
|
+
parser = TokenParser.sequence(separator, parser).map(([_separator, value]) => value);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
const result = parser.run(input);
|
|
2769
|
+
if (result instanceof Error) {
|
|
2770
|
+
failed = result;
|
|
2771
|
+
}
|
|
2772
|
+
return result;
|
|
2773
|
+
});
|
|
2774
|
+
if (failed) {
|
|
2775
|
+
const errorToReturn = failed;
|
|
2776
|
+
input.setCurrentIndex(currentIndex);
|
|
2777
|
+
return errorToReturn;
|
|
2778
|
+
}
|
|
2779
|
+
return output;
|
|
2780
|
+
}, `Sequence<${parsers.map(parser => parser.label).join(', ')}>`);
|
|
2781
|
+
this.parsers = parsers;
|
|
2782
|
+
this.separator = separator;
|
|
2783
|
+
}
|
|
2784
|
+
separatedBy(separator) {
|
|
2785
|
+
const newSeparator = this.separator?.surroundedBy(separator.map(() => undefined)) ?? separator.map(() => undefined);
|
|
2786
|
+
return new TokenParserSequence(this.parsers, newSeparator);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
class TokenOptionalParser extends TokenParser {
|
|
2790
|
+
constructor(parser) {
|
|
2791
|
+
super(parser.or(TokenParser.always(undefined)).run, `Optional<${parser.label}>`);
|
|
2792
|
+
this.parser = parser;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
class TokenParserSet extends TokenParser {
|
|
2796
|
+
constructor(_parsers, separator) {
|
|
2797
|
+
super(input => {
|
|
2798
|
+
const parsers = _parsers.map((parser, i) => [parser, i]).sort(([a], [b]) => {
|
|
2799
|
+
if (a instanceof TokenOptionalParser) {
|
|
2800
|
+
return 1;
|
|
2801
|
+
}
|
|
2802
|
+
if (b instanceof TokenOptionalParser) {
|
|
2803
|
+
return -1;
|
|
2804
|
+
}
|
|
2805
|
+
return 0;
|
|
2806
|
+
});
|
|
2807
|
+
const currentIndex = input.currentIndex;
|
|
2808
|
+
let failed = null;
|
|
2809
|
+
const output = [];
|
|
2810
|
+
const indices = new Set();
|
|
2811
|
+
for (let i = 0; i < parsers.length; i++) {
|
|
2812
|
+
let found = false;
|
|
2813
|
+
const errors = [];
|
|
2814
|
+
for (let j = 0; j < parsers.length; j++) {
|
|
2815
|
+
if (indices.has(j)) {
|
|
2816
|
+
continue;
|
|
2817
|
+
}
|
|
2818
|
+
let [parser, index] = parsers[j];
|
|
2819
|
+
if (separator != null && i > 0) {
|
|
2820
|
+
if (parser instanceof TokenOptionalParser) {
|
|
2821
|
+
parser = TokenParser.sequence(separator, parser.parser).map(([_separator, value]) => value).optional;
|
|
2822
|
+
} else {
|
|
2823
|
+
parser = TokenParser.sequence(separator, parser).map(([_separator, value]) => value);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
const currentIndex = input.currentIndex;
|
|
2827
|
+
const result = parser.run(input);
|
|
2828
|
+
if (result instanceof Error) {
|
|
2829
|
+
input.setCurrentIndex(currentIndex);
|
|
2830
|
+
errors.push(result);
|
|
2831
|
+
} else {
|
|
2832
|
+
found = true;
|
|
2833
|
+
output[index] = result;
|
|
2834
|
+
indices.add(j);
|
|
2835
|
+
break;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
if (found) {
|
|
2839
|
+
continue;
|
|
2840
|
+
} else {
|
|
2841
|
+
failed = new Error(`Expected one of ${parsers.map(parser => parser.toString()).join(', ')} but got ${errors.map(error => error.message).join(', ')}`);
|
|
2842
|
+
break;
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
if (failed instanceof Error) {
|
|
2846
|
+
input.setCurrentIndex(currentIndex);
|
|
2847
|
+
return failed;
|
|
2848
|
+
}
|
|
2849
|
+
return output;
|
|
2850
|
+
});
|
|
2851
|
+
this.parsers = _parsers;
|
|
2852
|
+
this.separator = separator;
|
|
2853
|
+
}
|
|
2854
|
+
separatedBy(separator) {
|
|
2855
|
+
const voidedSeparator = separator.map(() => undefined);
|
|
2856
|
+
const sep = this.separator?.surroundedBy(voidedSeparator) ?? voidedSeparator;
|
|
2857
|
+
return new TokenParserSet(this.parsers, sep);
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
return tokenParser;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
var properties = {};
|
|
2864
|
+
|
|
2865
|
+
var transform = {};
|
|
2866
|
+
|
|
2867
|
+
var transformFunction$1 = {};
|
|
2868
|
+
|
|
2869
|
+
var length$1 = {};
|
|
2870
|
+
|
|
2871
|
+
var hasRequiredLength;
|
|
2872
|
+
|
|
2873
|
+
function requireLength () {
|
|
2874
|
+
if (hasRequiredLength) return length$1;
|
|
2875
|
+
hasRequiredLength = 1;
|
|
2876
|
+
|
|
2877
|
+
Object.defineProperty(length$1, "__esModule", {
|
|
2878
|
+
value: true
|
|
2879
|
+
});
|
|
2880
|
+
length$1.UNITS_BASED_ON_VIEWPORT = length$1.UNITS_BASED_ON_FONT = length$1.UNITS_BASED_ON_CONTAINER = length$1.UNITS_BASED_ON_ABSOLUTE_UNITS = length$1.Length = void 0;
|
|
2881
|
+
var _tokenParser = requireTokenParser();
|
|
2882
|
+
const UNITS_BASED_ON_FONT = length$1.UNITS_BASED_ON_FONT = ['ch', 'em', 'ex', 'ic', 'lh', 'rem', 'rlh'];
|
|
2883
|
+
const UNITS_BASED_ON_VIEWPORT = length$1.UNITS_BASED_ON_VIEWPORT = ['vh', 'svh', 'lvh', 'dvh', 'vw', 'svw', 'lvw', 'dvw', 'vmin', 'svmin', 'lvmin', 'dvmin', 'vmax', 'svmax', 'lvmax', 'dvmax'];
|
|
2884
|
+
const UNITS_BASED_ON_CONTAINER = length$1.UNITS_BASED_ON_CONTAINER = ['cqw', 'cqi', 'cqh', 'cqb', 'cqmin', 'cqmax'];
|
|
2885
|
+
const UNITS_BASED_ON_ABSOLUTE_UNITS = length$1.UNITS_BASED_ON_ABSOLUTE_UNITS = ['px', 'cm', 'mm', 'in', 'pt'];
|
|
2886
|
+
class Length {
|
|
2887
|
+
constructor(value, unit) {
|
|
2888
|
+
this.value = value;
|
|
2889
|
+
this.unit = unit;
|
|
2890
|
+
}
|
|
2891
|
+
toString() {
|
|
2892
|
+
return `${this.value}${this.unit}`;
|
|
2893
|
+
}
|
|
2894
|
+
static UNITS = [...UNITS_BASED_ON_FONT, ...UNITS_BASED_ON_VIEWPORT, ...UNITS_BASED_ON_CONTAINER, ...UNITS_BASED_ON_ABSOLUTE_UNITS];
|
|
2895
|
+
static get parser() {
|
|
2896
|
+
const united = _tokenParser.TokenParser.tokens.Dimension.map(token => [token[4].value, token[4].unit]).where(tuple => Length.UNITS.includes(tuple[1])).map(([value, unit]) => new Length(value, unit));
|
|
2897
|
+
return _tokenParser.TokenParser.oneOf(united, _tokenParser.TokenParser.tokens.Number.map(token => token[4].value === 0 ? new Length(0, '') : null).where(value => value != null));
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
length$1.Length = Length;
|
|
2901
|
+
return length$1;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
var angle$1 = {};
|
|
2905
|
+
|
|
2906
|
+
var hasRequiredAngle;
|
|
2907
|
+
|
|
2908
|
+
function requireAngle () {
|
|
2909
|
+
if (hasRequiredAngle) return angle$1;
|
|
2910
|
+
hasRequiredAngle = 1;
|
|
2911
|
+
|
|
2912
|
+
Object.defineProperty(angle$1, "__esModule", {
|
|
2913
|
+
value: true
|
|
2914
|
+
});
|
|
2915
|
+
angle$1.Angle = void 0;
|
|
2916
|
+
var _tokenParser = requireTokenParser();
|
|
2917
|
+
class Angle {
|
|
2918
|
+
constructor(value, unit) {
|
|
2919
|
+
this.value = value;
|
|
2920
|
+
this.unit = unit;
|
|
2921
|
+
}
|
|
2922
|
+
toString() {
|
|
2923
|
+
return `${this.value}${this.unit}`;
|
|
2924
|
+
}
|
|
2925
|
+
static get parser() {
|
|
2926
|
+
const withUnit = _tokenParser.TokenParser.tokens.Dimension.map(v => v[4]).where(v => v.unit === 'deg' || v.unit === 'grad' || v.unit === 'rad' || v.unit === 'turn').map(v => new Angle(v.value, v.unit));
|
|
2927
|
+
return _tokenParser.TokenParser.oneOf(withUnit, _tokenParser.TokenParser.tokens.Number.map(v => v[4].value === 0 ? new Angle(0, 'deg') : null).where(v => v != null));
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
angle$1.Angle = Angle;
|
|
2931
|
+
return angle$1;
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
var commonTypes = {};
|
|
2935
|
+
|
|
2936
|
+
var hasRequiredCommonTypes;
|
|
2937
|
+
|
|
2938
|
+
function requireCommonTypes () {
|
|
2939
|
+
if (hasRequiredCommonTypes) return commonTypes;
|
|
2940
|
+
hasRequiredCommonTypes = 1;
|
|
2941
|
+
|
|
2942
|
+
Object.defineProperty(commonTypes, "__esModule", {
|
|
2943
|
+
value: true
|
|
2944
|
+
});
|
|
2945
|
+
commonTypes.unset = commonTypes.revert = commonTypes.numberOrPercentage = commonTypes.initial = commonTypes.inherit = commonTypes.cssWideKeywords = commonTypes.auto = commonTypes.Percentage = commonTypes.CssVariable = void 0;
|
|
2946
|
+
var _tokenParser = requireTokenParser();
|
|
2947
|
+
var _cssTokenizer = requireDist();
|
|
2948
|
+
const cssWideKeywords = commonTypes.cssWideKeywords = _tokenParser.TokenParser.tokens.Ident.map(v => v[4].value).where(v => v === 'inherit' || v === 'initial' || v === 'unset' || v === 'revert');
|
|
2949
|
+
commonTypes.inherit = cssWideKeywords.where(v => v === 'inherit');
|
|
2950
|
+
commonTypes.initial = cssWideKeywords.where(v => v === 'initial');
|
|
2951
|
+
commonTypes.unset = cssWideKeywords.where(v => v === 'unset');
|
|
2952
|
+
commonTypes.revert = cssWideKeywords.where(v => v === 'revert');
|
|
2953
|
+
commonTypes.auto = _tokenParser.TokenParser.token(_cssTokenizer.TokenType.Ident).map(v => v[4].value).where(v => v === 'auto');
|
|
2954
|
+
class CssVariable {
|
|
2955
|
+
constructor(name) {
|
|
2956
|
+
this.name = name;
|
|
2957
|
+
}
|
|
2958
|
+
toString() {
|
|
2959
|
+
return `var(${this.name})`;
|
|
2960
|
+
}
|
|
2961
|
+
static parse = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'var'), _tokenParser.TokenParser.tokens.Ident.map(v => v[4].value).where(v => v.startsWith('--')), _tokenParser.TokenParser.tokens.CloseParen).map(([_, name, __]) => new CssVariable(name));
|
|
2962
|
+
}
|
|
2963
|
+
commonTypes.CssVariable = CssVariable;
|
|
2964
|
+
class Percentage {
|
|
2965
|
+
constructor(value) {
|
|
2966
|
+
this.value = value;
|
|
2967
|
+
}
|
|
2968
|
+
toString() {
|
|
2969
|
+
return `${this.value}%`;
|
|
2970
|
+
}
|
|
2971
|
+
static get parser() {
|
|
2972
|
+
return _tokenParser.TokenParser.token(_cssTokenizer.TokenType.Percentage).map(v => new Percentage(v[4].value));
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
commonTypes.Percentage = Percentage;
|
|
2976
|
+
commonTypes.numberOrPercentage = _tokenParser.TokenParser.oneOf(Percentage.parser, _tokenParser.TokenParser.token(_cssTokenizer.TokenType.Number).map(v => v[4].signCharacter === '-' ? -v[4].value : v[4].value));
|
|
2977
|
+
return commonTypes;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
var lengthPercentage$1 = {};
|
|
2981
|
+
|
|
2982
|
+
var hasRequiredLengthPercentage;
|
|
2983
|
+
|
|
2984
|
+
function requireLengthPercentage () {
|
|
2985
|
+
if (hasRequiredLengthPercentage) return lengthPercentage$1;
|
|
2986
|
+
hasRequiredLengthPercentage = 1;
|
|
2987
|
+
|
|
2988
|
+
Object.defineProperty(lengthPercentage$1, "__esModule", {
|
|
2989
|
+
value: true
|
|
2990
|
+
});
|
|
2991
|
+
lengthPercentage$1.lengthPercentage = void 0;
|
|
2992
|
+
var _tokenParser = requireTokenParser();
|
|
2993
|
+
var _length = requireLength();
|
|
2994
|
+
var _commonTypes = requireCommonTypes();
|
|
2995
|
+
lengthPercentage$1.lengthPercentage = _tokenParser.TokenParser.oneOf(_commonTypes.Percentage.parser, _length.Length.parser);
|
|
2996
|
+
return lengthPercentage$1;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
var hasRequiredTransformFunction;
|
|
3000
|
+
|
|
3001
|
+
function requireTransformFunction () {
|
|
3002
|
+
if (hasRequiredTransformFunction) return transformFunction$1;
|
|
3003
|
+
hasRequiredTransformFunction = 1;
|
|
3004
|
+
|
|
3005
|
+
Object.defineProperty(transformFunction$1, "__esModule", {
|
|
3006
|
+
value: true
|
|
3007
|
+
});
|
|
3008
|
+
transformFunction$1.TranslateAxis = transformFunction$1.Translate3d = transformFunction$1.Translate = transformFunction$1.TransformFunction = transformFunction$1.SkewAxis = transformFunction$1.Skew = transformFunction$1.ScaleAxis = transformFunction$1.Scale3d = transformFunction$1.Scale = transformFunction$1.RotateXYZ = transformFunction$1.Rotate3d = transformFunction$1.Rotate = transformFunction$1.Perspective = transformFunction$1.Matrix3d = transformFunction$1.Matrix = void 0;
|
|
3009
|
+
var _length = requireLength();
|
|
3010
|
+
var _tokenParser = requireTokenParser();
|
|
3011
|
+
var _angle = requireAngle();
|
|
3012
|
+
var _commonTypes = requireCommonTypes();
|
|
3013
|
+
var _lengthPercentage = requireLengthPercentage();
|
|
3014
|
+
class TransformFunction {
|
|
3015
|
+
static get parser() {
|
|
3016
|
+
return _tokenParser.TokenParser.oneOf(Matrix.parser, Matrix3d.parser, Perspective.parser, Rotate.parser, RotateXYZ.parser, Rotate3d.parser, Scale.parser, Scale3d.parser, ScaleAxis.parser, Skew.parser, SkewAxis.parser, Translate3d.parser, Translate.parser, TranslateAxis.parser);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
transformFunction$1.TransformFunction = TransformFunction;
|
|
3020
|
+
class Matrix extends TransformFunction {
|
|
3021
|
+
constructor(a, b, c, d, tx, ty) {
|
|
3022
|
+
super();
|
|
3023
|
+
this.a = a;
|
|
3024
|
+
this.b = b;
|
|
3025
|
+
this.c = c;
|
|
3026
|
+
this.d = d;
|
|
3027
|
+
this.tx = tx;
|
|
3028
|
+
this.ty = ty;
|
|
3029
|
+
}
|
|
3030
|
+
toString() {
|
|
3031
|
+
return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
|
|
3032
|
+
}
|
|
3033
|
+
static get parser() {
|
|
3034
|
+
const sixNumbers = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value)).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3035
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.fn('matrix'), sixNumbers, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, [a, b, c, d, tx, ty], _closeParen]) => new Matrix(a, b, c, d, tx, ty));
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
transformFunction$1.Matrix = Matrix;
|
|
3039
|
+
class Matrix3d extends TransformFunction {
|
|
3040
|
+
constructor(args) {
|
|
3041
|
+
super();
|
|
3042
|
+
this.args = args;
|
|
3043
|
+
}
|
|
3044
|
+
toString() {
|
|
3045
|
+
return `matrix3d(${this.args.join(', ')})`;
|
|
3046
|
+
}
|
|
3047
|
+
static get parser() {
|
|
3048
|
+
const number = _tokenParser.TokenParser.tokens.Number.map(v => v[4].value);
|
|
3049
|
+
const fourNumbers = _tokenParser.TokenParser.sequence(number, number, number, number).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3050
|
+
const sixteenNumbers = _tokenParser.TokenParser.sequence(fourNumbers, fourNumbers, fourNumbers, fourNumbers).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([f1, f2, f3, f4]) => [...f1, ...f2, ...f3, ...f4]);
|
|
3051
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'matrix3d'), sixteenNumbers, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, args]) => new Matrix3d(args));
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
transformFunction$1.Matrix3d = Matrix3d;
|
|
3055
|
+
class Perspective extends TransformFunction {
|
|
3056
|
+
constructor(length) {
|
|
3057
|
+
super();
|
|
3058
|
+
this.length = length;
|
|
3059
|
+
}
|
|
3060
|
+
toString() {
|
|
3061
|
+
return `perspective(${this.length.toString()})`;
|
|
3062
|
+
}
|
|
3063
|
+
static get parser() {
|
|
3064
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'perspective'), _length.Length.parser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, length]) => new Perspective(length));
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
transformFunction$1.Perspective = Perspective;
|
|
3068
|
+
class Rotate extends TransformFunction {
|
|
3069
|
+
constructor(angle) {
|
|
3070
|
+
super();
|
|
3071
|
+
this.angle = angle;
|
|
3072
|
+
}
|
|
3073
|
+
toString() {
|
|
3074
|
+
return `rotate(${this.angle.toString()})`;
|
|
3075
|
+
}
|
|
3076
|
+
static get parser() {
|
|
3077
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'rotate'), _angle.Angle.parser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, angle]) => new Rotate(angle));
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
transformFunction$1.Rotate = Rotate;
|
|
3081
|
+
class RotateXYZ extends TransformFunction {
|
|
3082
|
+
constructor(x, axis) {
|
|
3083
|
+
super();
|
|
3084
|
+
this.x = x;
|
|
3085
|
+
this.axis = axis;
|
|
3086
|
+
}
|
|
3087
|
+
toString() {
|
|
3088
|
+
return `rotate${this.axis}(${this.x.toString()})`;
|
|
3089
|
+
}
|
|
3090
|
+
static get parser() {
|
|
3091
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.fn('rotateX').map(() => 'X'), _tokenParser.TokenParser.fn('rotateY').map(() => 'Y'), _tokenParser.TokenParser.fn('rotateZ').map(() => 'Z')), _angle.Angle.parser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([axis, x]) => new RotateXYZ(x, axis));
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
transformFunction$1.RotateXYZ = RotateXYZ;
|
|
3095
|
+
class Rotate3d extends TransformFunction {
|
|
3096
|
+
constructor(x, y, z, angle) {
|
|
3097
|
+
super();
|
|
3098
|
+
this.x = x;
|
|
3099
|
+
this.y = y;
|
|
3100
|
+
this.z = z;
|
|
3101
|
+
this.angle = angle;
|
|
3102
|
+
}
|
|
3103
|
+
toString() {
|
|
3104
|
+
const {
|
|
3105
|
+
x,
|
|
3106
|
+
y,
|
|
3107
|
+
z
|
|
3108
|
+
} = this;
|
|
3109
|
+
switch (true) {
|
|
3110
|
+
case x === 1 && y === 0 && z === 0:
|
|
3111
|
+
return `rotateX(${this.angle.toString()})`;
|
|
3112
|
+
case x === 0 && y === 1 && z === 0:
|
|
3113
|
+
return `rotateY(${this.angle.toString()})`;
|
|
3114
|
+
case x === 0 && y === 0 && z === 1:
|
|
3115
|
+
return `rotateZ(${this.angle.toString()})`;
|
|
3116
|
+
default:
|
|
3117
|
+
return `rotate3d(${this.x}, ${this.y}, ${this.z}, ${this.angle.toString()})`;
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
static get parser() {
|
|
3121
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'rotate3d'), _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _tokenParser.TokenParser.tokens.Number.map(v => v[4].value), _angle.Angle.parser).separatedBy(_tokenParser.TokenParser.tokens.Comma.skip(_tokenParser.TokenParser.tokens.Whitespace.optional)), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [x, y, z, angle]]) => new Rotate3d(x, y, z, angle));
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
transformFunction$1.Rotate3d = Rotate3d;
|
|
3125
|
+
class Scale extends TransformFunction {
|
|
3126
|
+
constructor(sx, sy) {
|
|
3127
|
+
super();
|
|
3128
|
+
this.sx = sx;
|
|
3129
|
+
this.sy = sy ?? undefined;
|
|
3130
|
+
}
|
|
3131
|
+
toString() {
|
|
3132
|
+
const {
|
|
3133
|
+
sx,
|
|
3134
|
+
sy
|
|
3135
|
+
} = this;
|
|
3136
|
+
if (sy == null) {
|
|
3137
|
+
return `scale(${sx.toString()})`;
|
|
3138
|
+
}
|
|
3139
|
+
return `scale(${sx.toString()}, ${sy.toString()})`;
|
|
3140
|
+
}
|
|
3141
|
+
static get parser() {
|
|
3142
|
+
const scalesXY = _tokenParser.TokenParser.sequence(_commonTypes.numberOrPercentage.map(v => v instanceof _commonTypes.Percentage ? v.value / 100 : v), _commonTypes.numberOrPercentage.map(v => v instanceof _commonTypes.Percentage ? v.value / 100 : v).optional).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3143
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'scale'), scalesXY, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [sx, sy]]) => new Scale(sx, sy));
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
transformFunction$1.Scale = Scale;
|
|
3147
|
+
class Scale3d extends TransformFunction {
|
|
3148
|
+
constructor(sx, sy, sz) {
|
|
3149
|
+
super();
|
|
3150
|
+
this.sx = sx;
|
|
3151
|
+
this.sy = sy;
|
|
3152
|
+
this.sz = sz;
|
|
3153
|
+
}
|
|
3154
|
+
toString() {
|
|
3155
|
+
return `scale3d(${this.sx.toString()}, ${this.sy.toString()}, ${this.sz.toString()})`;
|
|
3156
|
+
}
|
|
3157
|
+
static get parser() {
|
|
3158
|
+
const numberOrPercentageAsNumber = _commonTypes.numberOrPercentage.map(v => v instanceof _commonTypes.Percentage ? v.value / 100 : v);
|
|
3159
|
+
const args = _tokenParser.TokenParser.sequence(numberOrPercentageAsNumber, numberOrPercentageAsNumber, numberOrPercentageAsNumber).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3160
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.fn('scale3d'), args, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [sx, sy, sz]]) => new Scale3d(sx, sy, sz));
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
transformFunction$1.Scale3d = Scale3d;
|
|
3164
|
+
class ScaleAxis extends TransformFunction {
|
|
3165
|
+
constructor(s, axis) {
|
|
3166
|
+
super();
|
|
3167
|
+
this.s = s;
|
|
3168
|
+
this.axis = axis;
|
|
3169
|
+
}
|
|
3170
|
+
toString() {
|
|
3171
|
+
return `scale${this.axis}(${this.s.toString()})`;
|
|
3172
|
+
}
|
|
3173
|
+
static get parser() {
|
|
3174
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.fn('scaleX').map(() => 'X'), _tokenParser.TokenParser.fn('scaleY').map(() => 'Y'), _tokenParser.TokenParser.fn('scaleZ').map(() => 'Z')), _commonTypes.numberOrPercentage.map(v => v instanceof _commonTypes.Percentage ? v.value / 100 : v), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([axis, s]) => new ScaleAxis(s, axis));
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
transformFunction$1.ScaleAxis = ScaleAxis;
|
|
3178
|
+
class Skew extends TransformFunction {
|
|
3179
|
+
constructor(ax, ay) {
|
|
3180
|
+
super();
|
|
3181
|
+
this.ax = ax;
|
|
3182
|
+
this.ay = ay ?? undefined;
|
|
3183
|
+
}
|
|
3184
|
+
toString() {
|
|
3185
|
+
const {
|
|
3186
|
+
ax,
|
|
3187
|
+
ay
|
|
3188
|
+
} = this;
|
|
3189
|
+
if (ay == null) {
|
|
3190
|
+
return `skew(${ax.toString()})`;
|
|
3191
|
+
}
|
|
3192
|
+
return `skew(${ax.toString()}, ${ay.toString()})`;
|
|
3193
|
+
}
|
|
3194
|
+
static get parser() {
|
|
3195
|
+
const args = _tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.sequence(_angle.Angle.parser, _angle.Angle.parser).separatedBy(_tokenParser.TokenParser.tokens.Comma.skip(_tokenParser.TokenParser.tokens.Whitespace.optional)), _angle.Angle.parser).map(arg => {
|
|
3196
|
+
if (Array.isArray(arg)) {
|
|
3197
|
+
return arg;
|
|
3198
|
+
}
|
|
3199
|
+
return [arg, null];
|
|
3200
|
+
});
|
|
3201
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'skew'), args, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [ax, ay]]) => new Skew(ax, ay));
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
transformFunction$1.Skew = Skew;
|
|
3205
|
+
class SkewAxis extends TransformFunction {
|
|
3206
|
+
constructor(a, axis) {
|
|
3207
|
+
super();
|
|
3208
|
+
this.a = a;
|
|
3209
|
+
this.axis = axis;
|
|
3210
|
+
}
|
|
3211
|
+
toString() {
|
|
3212
|
+
return `skew${this.axis}(${this.a.toString()})`;
|
|
3213
|
+
}
|
|
3214
|
+
static get parser() {
|
|
3215
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.fn('skewX').map(() => 'X'), _tokenParser.TokenParser.fn('skewY').map(() => 'Y')), _angle.Angle.parser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([axis, a]) => new SkewAxis(a, axis));
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
transformFunction$1.SkewAxis = SkewAxis;
|
|
3219
|
+
class Translate extends TransformFunction {
|
|
3220
|
+
constructor(tx, ty) {
|
|
3221
|
+
super();
|
|
3222
|
+
this.tx = tx;
|
|
3223
|
+
this.ty = ty ?? undefined;
|
|
3224
|
+
}
|
|
3225
|
+
toString() {
|
|
3226
|
+
const {
|
|
3227
|
+
tx,
|
|
3228
|
+
ty
|
|
3229
|
+
} = this;
|
|
3230
|
+
if (ty == null) {
|
|
3231
|
+
return `translate(${tx.toString()})`;
|
|
3232
|
+
}
|
|
3233
|
+
return `translate(${tx.toString()}, ${ty.toString()})`;
|
|
3234
|
+
}
|
|
3235
|
+
static get parser() {
|
|
3236
|
+
const oneArg = _lengthPercentage.lengthPercentage;
|
|
3237
|
+
const twoArgs = _tokenParser.TokenParser.sequence(_lengthPercentage.lengthPercentage, _lengthPercentage.lengthPercentage).separatedBy(_tokenParser.TokenParser.tokens.Comma.skip(_tokenParser.TokenParser.tokens.Whitespace.optional));
|
|
3238
|
+
const args = _tokenParser.TokenParser.oneOf(twoArgs, oneArg).map(arg => {
|
|
3239
|
+
if (Array.isArray(arg)) {
|
|
3240
|
+
return arg;
|
|
3241
|
+
}
|
|
3242
|
+
return [arg, null];
|
|
3243
|
+
});
|
|
3244
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'translate'), args, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [tx, ty]]) => new Translate(tx, ty));
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
transformFunction$1.Translate = Translate;
|
|
3248
|
+
class Translate3d extends TransformFunction {
|
|
3249
|
+
constructor(tx, ty, tz) {
|
|
3250
|
+
super();
|
|
3251
|
+
this.tx = tx;
|
|
3252
|
+
this.ty = ty;
|
|
3253
|
+
this.tz = tz;
|
|
3254
|
+
}
|
|
3255
|
+
toString() {
|
|
3256
|
+
return `translate3d(${this.tx.toString()}, ${this.ty.toString()}, ${this.tz.toString()})`;
|
|
3257
|
+
}
|
|
3258
|
+
static get parser() {
|
|
3259
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(v => v[4].value).where(v => v === 'translate3d'), _tokenParser.TokenParser.sequence(_lengthPercentage.lengthPercentage, _lengthPercentage.lengthPercentage, _length.Length.parser).separatedBy(_tokenParser.TokenParser.tokens.Comma.skip(_tokenParser.TokenParser.tokens.Whitespace.optional)), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, [tx, ty, tz]]) => new Translate3d(tx, ty, tz));
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
transformFunction$1.Translate3d = Translate3d;
|
|
3263
|
+
class TranslateAxis extends TransformFunction {
|
|
3264
|
+
constructor(t, axis) {
|
|
3265
|
+
super();
|
|
3266
|
+
this.t = t;
|
|
3267
|
+
this.axis = axis;
|
|
3268
|
+
}
|
|
3269
|
+
toString() {
|
|
3270
|
+
return `translate${this.axis}(${this.t.toString()})`;
|
|
3271
|
+
}
|
|
3272
|
+
static get parser() {
|
|
3273
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.fn('translateX').map(() => 'X'), _tokenParser.TokenParser.fn('translateY').map(() => 'Y'), _tokenParser.TokenParser.fn('translateZ').map(() => 'Z')), _lengthPercentage.lengthPercentage, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([axis, t]) => new TranslateAxis(t, axis));
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
transformFunction$1.TranslateAxis = TranslateAxis;
|
|
3277
|
+
return transformFunction$1;
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
var hasRequiredTransform;
|
|
3281
|
+
|
|
3282
|
+
function requireTransform () {
|
|
3283
|
+
if (hasRequiredTransform) return transform;
|
|
3284
|
+
hasRequiredTransform = 1;
|
|
3285
|
+
|
|
3286
|
+
Object.defineProperty(transform, "__esModule", {
|
|
3287
|
+
value: true
|
|
3288
|
+
});
|
|
3289
|
+
transform.Transform = void 0;
|
|
3290
|
+
var _tokenParser = requireTokenParser();
|
|
3291
|
+
var _transformFunction = requireTransformFunction();
|
|
3292
|
+
class Transform {
|
|
3293
|
+
constructor(value) {
|
|
3294
|
+
this.value = value;
|
|
3295
|
+
}
|
|
3296
|
+
toString() {
|
|
3297
|
+
return this.value.join(' ');
|
|
3298
|
+
}
|
|
3299
|
+
static get parse() {
|
|
3300
|
+
return _tokenParser.TokenParser.oneOrMore(_transformFunction.TransformFunction.parser).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(value => new Transform(value));
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
transform.Transform = Transform;
|
|
3304
|
+
return transform;
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
var boxShadow = {};
|
|
3308
|
+
|
|
3309
|
+
var color$1 = {};
|
|
3310
|
+
|
|
3311
|
+
var alphaValue = {};
|
|
3312
|
+
|
|
3313
|
+
var hasRequiredAlphaValue;
|
|
3314
|
+
|
|
3315
|
+
function requireAlphaValue () {
|
|
3316
|
+
if (hasRequiredAlphaValue) return alphaValue;
|
|
3317
|
+
hasRequiredAlphaValue = 1;
|
|
3318
|
+
|
|
3319
|
+
Object.defineProperty(alphaValue, "__esModule", {
|
|
3320
|
+
value: true
|
|
3321
|
+
});
|
|
3322
|
+
alphaValue.AlphaValue = void 0;
|
|
3323
|
+
var _tokenParser = requireTokenParser();
|
|
3324
|
+
class AlphaValue {
|
|
3325
|
+
constructor(value) {
|
|
3326
|
+
this.value = value;
|
|
3327
|
+
}
|
|
3328
|
+
toString() {
|
|
3329
|
+
return this.value.toString();
|
|
3330
|
+
}
|
|
3331
|
+
static parser = _tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.tokens.Percentage.map(v => new AlphaValue((v[4].signCharacter === '-' ? -1 : 1) * v[4].value / 100)), _tokenParser.TokenParser.tokens.Number.map(v => new AlphaValue((v[4].signCharacter === '-' ? -1 : 1) * v[4].value)));
|
|
3332
|
+
}
|
|
3333
|
+
alphaValue.AlphaValue = AlphaValue;
|
|
3334
|
+
return alphaValue;
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
var hasRequiredColor;
|
|
3338
|
+
|
|
3339
|
+
function requireColor () {
|
|
3340
|
+
if (hasRequiredColor) return color$1;
|
|
3341
|
+
hasRequiredColor = 1;
|
|
3342
|
+
|
|
3343
|
+
Object.defineProperty(color$1, "__esModule", {
|
|
3344
|
+
value: true
|
|
3345
|
+
});
|
|
3346
|
+
color$1.Rgba = color$1.Rgb = color$1.Oklch = color$1.Oklab = color$1.NamedColor = color$1.Lch = color$1.Hsla = color$1.Hsl = color$1.HashColor = color$1.Color = void 0;
|
|
3347
|
+
var _tokenParser = requireTokenParser();
|
|
3348
|
+
var _alphaValue = requireAlphaValue();
|
|
3349
|
+
var _angle = requireAngle();
|
|
3350
|
+
var _commonTypes = requireCommonTypes();
|
|
3351
|
+
class Color {
|
|
3352
|
+
static get parser() {
|
|
3353
|
+
return _tokenParser.TokenParser.oneOf(NamedColor.parser, HashColor.parser, Rgb.parser, Rgba.parser, Hsl.parser, Hsla.parser, Lch.parser, Oklch.parser, Oklab.parser);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
color$1.Color = Color;
|
|
3357
|
+
class NamedColor extends Color {
|
|
3358
|
+
constructor(value) {
|
|
3359
|
+
super();
|
|
3360
|
+
this.value = value;
|
|
3361
|
+
}
|
|
3362
|
+
toString() {
|
|
3363
|
+
return this.value;
|
|
3364
|
+
}
|
|
3365
|
+
static parser = _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value).where(str => ['aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'transparent', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'].includes(str)).map(value => new NamedColor(value));
|
|
3366
|
+
}
|
|
3367
|
+
color$1.NamedColor = NamedColor;
|
|
3368
|
+
class HashColor extends Color {
|
|
3369
|
+
constructor(value) {
|
|
3370
|
+
super();
|
|
3371
|
+
this.value = value;
|
|
3372
|
+
}
|
|
3373
|
+
toString() {
|
|
3374
|
+
return `#${this.value}`;
|
|
3375
|
+
}
|
|
3376
|
+
get r() {
|
|
3377
|
+
return parseInt(this.value.slice(0, 2), 16);
|
|
3378
|
+
}
|
|
3379
|
+
get g() {
|
|
3380
|
+
return parseInt(this.value.slice(2, 4), 16);
|
|
3381
|
+
}
|
|
3382
|
+
get b() {
|
|
3383
|
+
return parseInt(this.value.slice(4, 6), 16);
|
|
3384
|
+
}
|
|
3385
|
+
get a() {
|
|
3386
|
+
return this.value.length === 8 ? parseInt(this.value.slice(6, 8), 16) / 255 : 1;
|
|
3387
|
+
}
|
|
3388
|
+
static get parser() {
|
|
3389
|
+
return _tokenParser.TokenParser.tokens.Hash.map(token => token[4].value).where(value => [3, 6, 8].includes(value.length) && /^[0-9a-fA-F]+$/.test(value)).map(value => new HashColor(value));
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
color$1.HashColor = HashColor;
|
|
3393
|
+
const rgbNumberParser = _tokenParser.TokenParser.tokens.Number.map(token => token[4].value).where(value => value >= 0 && value <= 255);
|
|
3394
|
+
const alphaAsNumber = _alphaValue.AlphaValue.parser.map(alpha => alpha.value);
|
|
3395
|
+
const slashParser = _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(value => value === '/').surroundedBy(_tokenParser.TokenParser.tokens.Whitespace);
|
|
3396
|
+
class Rgb extends Color {
|
|
3397
|
+
constructor(r, g, b) {
|
|
3398
|
+
super();
|
|
3399
|
+
this.r = r;
|
|
3400
|
+
this.g = g;
|
|
3401
|
+
this.b = b;
|
|
3402
|
+
}
|
|
3403
|
+
toString() {
|
|
3404
|
+
return `rgb(${this.r},${this.g},${this.b})`;
|
|
3405
|
+
}
|
|
3406
|
+
static get parser() {
|
|
3407
|
+
const rgbCommaSeparated = _tokenParser.TokenParser.sequence(rgbNumberParser, rgbNumberParser, rgbNumberParser).separatedBy(_tokenParser.TokenParser.tokens.Comma).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3408
|
+
const commaParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'rgb'), rgbCommaSeparated, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, [r, g, b], _closeParen]) => new Rgb(r, g, b));
|
|
3409
|
+
const spaceSeparatedRGB = _tokenParser.TokenParser.sequence(rgbNumberParser, rgbNumberParser, rgbNumberParser).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).surroundedBy(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3410
|
+
const spaceParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'rgb'), spaceSeparatedRGB, _tokenParser.TokenParser.tokens.CloseParen).map(([_fn, [r, g, b], _closeParen]) => new Rgb(r, g, b));
|
|
3411
|
+
return _tokenParser.TokenParser.oneOf(commaParser, spaceParser);
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
color$1.Rgb = Rgb;
|
|
3415
|
+
class Rgba extends Color {
|
|
3416
|
+
constructor(r, g, b, a) {
|
|
3417
|
+
super();
|
|
3418
|
+
this.r = r;
|
|
3419
|
+
this.g = g;
|
|
3420
|
+
this.b = b;
|
|
3421
|
+
this.a = a;
|
|
3422
|
+
}
|
|
3423
|
+
toString() {
|
|
3424
|
+
return `rgba(${this.r},${this.g},${this.b},${this.a})`;
|
|
3425
|
+
}
|
|
3426
|
+
static get parser() {
|
|
3427
|
+
const commaParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'rgba'), rgbNumberParser, _tokenParser.TokenParser.tokens.Comma, rgbNumberParser, _tokenParser.TokenParser.tokens.Comma, rgbNumberParser, _tokenParser.TokenParser.tokens.Comma, alphaAsNumber, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, r, _comma, g, _comma2, b, _comma3, a, _closeParen]) => new Rgba(r, g, b, a));
|
|
3428
|
+
const spaceParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'rgb'), _tokenParser.TokenParser.tokens.Whitespace.optional, rgbNumberParser, _tokenParser.TokenParser.tokens.Whitespace, rgbNumberParser, _tokenParser.TokenParser.tokens.Whitespace, rgbNumberParser, slashParser, alphaAsNumber, _tokenParser.TokenParser.tokens.Whitespace.optional, _tokenParser.TokenParser.tokens.CloseParen).map(([_fn, _preSpace, r, _space, g, _space2, b, _slash, a, _postSpace, _closeParen]) => new Rgba(r, g, b, a));
|
|
3429
|
+
return _tokenParser.TokenParser.oneOf(commaParser, spaceParser);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
color$1.Rgba = Rgba;
|
|
3433
|
+
class Hsl extends Color {
|
|
3434
|
+
constructor(h, s, l) {
|
|
3435
|
+
super();
|
|
3436
|
+
this.h = h;
|
|
3437
|
+
this.s = s;
|
|
3438
|
+
this.l = l;
|
|
3439
|
+
}
|
|
3440
|
+
toString() {
|
|
3441
|
+
return `hsl(${this.h.toString()},${this.s.toString()},${this.l.toString()})`;
|
|
3442
|
+
}
|
|
3443
|
+
static get parser() {
|
|
3444
|
+
const commaParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'hsl'), _angle.Angle.parser, _tokenParser.TokenParser.tokens.Comma, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Comma, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(tokens => new Hsl(tokens[1], tokens[3], tokens[5]));
|
|
3445
|
+
const spaceParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'hsl'), _angle.Angle.parser, _tokenParser.TokenParser.tokens.Whitespace, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Whitespace, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Whitespace, _tokenParser.TokenParser.tokens.CloseParen).map(tokens => new Hsl(tokens[1], tokens[3], tokens[5]));
|
|
3446
|
+
return _tokenParser.TokenParser.oneOf(commaParser, spaceParser);
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
color$1.Hsl = Hsl;
|
|
3450
|
+
class Hsla extends Color {
|
|
3451
|
+
constructor(h, s, l, a) {
|
|
3452
|
+
super();
|
|
3453
|
+
this.h = h;
|
|
3454
|
+
this.s = s;
|
|
3455
|
+
this.l = l;
|
|
3456
|
+
this.a = a;
|
|
3457
|
+
}
|
|
3458
|
+
toString() {
|
|
3459
|
+
return `hsla(${this.h.toString()},${this.s.toString()},${this.l.toString()},${this.a})`;
|
|
3460
|
+
}
|
|
3461
|
+
static get parser() {
|
|
3462
|
+
const commaParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'hsla'), _angle.Angle.parser, _tokenParser.TokenParser.tokens.Comma, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Comma, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Comma, alphaAsNumber, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, h, _comma, s, _comma2, l, _comma3, a, _closeParen]) => new Hsla(h, s, l, a));
|
|
3463
|
+
const spaceParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'hsl'), _angle.Angle.parser, _tokenParser.TokenParser.tokens.Whitespace, _commonTypes.Percentage.parser, _tokenParser.TokenParser.tokens.Whitespace, _commonTypes.Percentage.parser, slashParser, alphaAsNumber, _tokenParser.TokenParser.tokens.Whitespace.optional, _tokenParser.TokenParser.tokens.CloseParen).map(([_fn, h, _space, s, _space2, l, _slash, a, _postSpace, _closeParen]) => new Hsla(h, s, l, a));
|
|
3464
|
+
return _tokenParser.TokenParser.oneOf(commaParser, spaceParser);
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
color$1.Hsla = Hsla;
|
|
3468
|
+
class Lch extends Color {
|
|
3469
|
+
constructor(l, c, h, alpha) {
|
|
3470
|
+
super();
|
|
3471
|
+
this.l = l;
|
|
3472
|
+
this.c = c;
|
|
3473
|
+
this.h = h;
|
|
3474
|
+
this.alpha = alpha;
|
|
3475
|
+
}
|
|
3476
|
+
toString() {
|
|
3477
|
+
return `lch(${this.l} ${this.c} ${this.h.toString()}${this.alpha ? ` / ${this.alpha}` : ''})`;
|
|
3478
|
+
}
|
|
3479
|
+
static get parser() {
|
|
3480
|
+
const l = _tokenParser.TokenParser.oneOf(_commonTypes.Percentage.parser.map(p => p.value), _tokenParser.TokenParser.tokens.Number.map(token => token[4].value).where(value => value >= 0), _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value).where(value => value === 'none').map(() => 0));
|
|
3481
|
+
const c = _tokenParser.TokenParser.oneOf(_commonTypes.Percentage.parser.map(p => 150 * p.value / 100), _tokenParser.TokenParser.tokens.Number.map(token => token[4].value).where(value => value >= 0));
|
|
3482
|
+
const h = _tokenParser.TokenParser.oneOf(_angle.Angle.parser, _tokenParser.TokenParser.tokens.Number.map(token => token[4].value));
|
|
3483
|
+
const a = _tokenParser.TokenParser.sequence(slashParser, alphaAsNumber).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([_, a]) => a);
|
|
3484
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'lch'), _tokenParser.TokenParser.sequence(l, c, h).separatedBy(_tokenParser.TokenParser.tokens.Whitespace), a.suffix(_tokenParser.TokenParser.tokens.Whitespace.optional).optional, _tokenParser.TokenParser.tokens.CloseParen).map(([_fn, [l, c, h], a, _closeParen]) => new Lch(l, c, h, a));
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
color$1.Lch = Lch;
|
|
3488
|
+
class Oklch extends Color {
|
|
3489
|
+
constructor(l, c, h, alpha) {
|
|
3490
|
+
super();
|
|
3491
|
+
this.l = l;
|
|
3492
|
+
this.c = c;
|
|
3493
|
+
this.h = h;
|
|
3494
|
+
this.alpha = alpha;
|
|
3495
|
+
}
|
|
3496
|
+
toString() {
|
|
3497
|
+
return `oklch(${this.l} ${this.c} ${this.h.toString()}${this.alpha ? ` / ${this.alpha}` : ''})`;
|
|
3498
|
+
}
|
|
3499
|
+
static get parser() {
|
|
3500
|
+
const lc = _tokenParser.TokenParser.oneOf(alphaAsNumber, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value).where(value => value === 'none').map(() => 0)).prefix(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3501
|
+
const h = _tokenParser.TokenParser.oneOf(_angle.Angle.parser, lc.map(num => new _angle.Angle(num * 360, 'deg')));
|
|
3502
|
+
const a = _tokenParser.TokenParser.sequence(slashParser, alphaAsNumber).map(([_, a]) => a);
|
|
3503
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'oklch'), lc, _tokenParser.TokenParser.tokens.Whitespace, lc, _tokenParser.TokenParser.tokens.Whitespace, h, a.suffix(_tokenParser.TokenParser.tokens.Whitespace.optional).optional, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, l, _comma, c, _comma2, h, a, _closeParen]) => new Lch(l, c, h, a));
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
color$1.Oklch = Oklch;
|
|
3507
|
+
class Oklab extends Color {
|
|
3508
|
+
constructor(l, a, b, alpha) {
|
|
3509
|
+
super();
|
|
3510
|
+
this.l = l;
|
|
3511
|
+
this.a = a;
|
|
3512
|
+
this.b = b;
|
|
3513
|
+
this.alpha = alpha;
|
|
3514
|
+
}
|
|
3515
|
+
toString() {
|
|
3516
|
+
return `oklab(${this.l} ${this.a} ${this.b}${this.alpha ? ` / ${this.alpha}` : ''})`;
|
|
3517
|
+
}
|
|
3518
|
+
static get parser() {
|
|
3519
|
+
const lab = _tokenParser.TokenParser.oneOf(alphaAsNumber, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value).where(value => value === 'none').map(() => 0)).prefix(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3520
|
+
const a = _tokenParser.TokenParser.sequence(slashParser, alphaAsNumber).map(([_, a]) => a);
|
|
3521
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(token => token[4].value).where(value => value === 'oklab'), lab, _tokenParser.TokenParser.tokens.Whitespace, lab, _tokenParser.TokenParser.tokens.Whitespace, lab, a.suffix(_tokenParser.TokenParser.tokens.Whitespace.optional).optional, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_fn, l, _comma, a, _comma2, b, alpha, _closeParen]) => new Oklab(l, a, b, alpha));
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
color$1.Oklab = Oklab;
|
|
3525
|
+
return color$1;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
var hasRequiredBoxShadow;
|
|
3529
|
+
|
|
3530
|
+
function requireBoxShadow () {
|
|
3531
|
+
if (hasRequiredBoxShadow) return boxShadow;
|
|
3532
|
+
hasRequiredBoxShadow = 1;
|
|
3533
|
+
|
|
3534
|
+
Object.defineProperty(boxShadow, "__esModule", {
|
|
3535
|
+
value: true
|
|
3536
|
+
});
|
|
3537
|
+
boxShadow.BoxShadowList = boxShadow.BoxShadow = void 0;
|
|
3538
|
+
var _tokenParser = requireTokenParser();
|
|
3539
|
+
var _length = requireLength();
|
|
3540
|
+
var _color = requireColor();
|
|
3541
|
+
class BoxShadow {
|
|
3542
|
+
constructor(offsetX, offsetY, blurRadius, spreadRadius, color, inset = false) {
|
|
3543
|
+
this.offsetX = offsetX;
|
|
3544
|
+
this.offsetY = offsetY;
|
|
3545
|
+
this.blurRadius = blurRadius;
|
|
3546
|
+
this.spreadRadius = spreadRadius;
|
|
3547
|
+
this.color = color;
|
|
3548
|
+
this.inset = inset;
|
|
3549
|
+
}
|
|
3550
|
+
static get parse() {
|
|
3551
|
+
const outerShadow = _tokenParser.TokenParser.sequence(_length.Length.parser, _length.Length.parser, _length.Length.parser.optional, _length.Length.parser.optional, _color.Color.parser).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([offsetX, offsetY, blurRadius, spreadRadius, color]) => new BoxShadow(offsetX, offsetY, blurRadius ?? new _length.Length(0, 'px'), spreadRadius ?? new _length.Length(0, 'px'), color));
|
|
3552
|
+
const insetShadow = _tokenParser.TokenParser.sequence(outerShadow, _tokenParser.TokenParser.string('inset')).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([shadow, _inset]) => new BoxShadow(shadow.offsetX, shadow.offsetY, shadow.blurRadius, shadow.spreadRadius, shadow.color, true));
|
|
3553
|
+
return _tokenParser.TokenParser.oneOf(insetShadow, outerShadow);
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
boxShadow.BoxShadow = BoxShadow;
|
|
3557
|
+
class BoxShadowList {
|
|
3558
|
+
constructor(shadows) {
|
|
3559
|
+
this.shadows = shadows;
|
|
3560
|
+
}
|
|
3561
|
+
static get parse() {
|
|
3562
|
+
return _tokenParser.TokenParser.oneOrMore(BoxShadow.parse).separatedBy(_tokenParser.TokenParser.tokens.Comma.surroundedBy(_tokenParser.TokenParser.tokens.Whitespace.optional)).map(shadows => new BoxShadowList(shadows));
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
boxShadow.BoxShadowList = BoxShadowList;
|
|
3566
|
+
return boxShadow;
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3569
|
+
var borderRadius = {};
|
|
3570
|
+
|
|
3571
|
+
var hasRequiredBorderRadius;
|
|
3572
|
+
|
|
3573
|
+
function requireBorderRadius () {
|
|
3574
|
+
if (hasRequiredBorderRadius) return borderRadius;
|
|
3575
|
+
hasRequiredBorderRadius = 1;
|
|
3576
|
+
|
|
3577
|
+
Object.defineProperty(borderRadius, "__esModule", {
|
|
3578
|
+
value: true
|
|
3579
|
+
});
|
|
3580
|
+
borderRadius.BorderRadiusShorthand = borderRadius.BorderRadiusIndividual = void 0;
|
|
3581
|
+
var _tokenParser = requireTokenParser();
|
|
3582
|
+
var _lengthPercentage = requireLengthPercentage();
|
|
3583
|
+
class BorderRadiusIndividual {
|
|
3584
|
+
constructor(horizontal, vertical) {
|
|
3585
|
+
this.horizontal = horizontal;
|
|
3586
|
+
this.vertical = vertical ?? horizontal;
|
|
3587
|
+
}
|
|
3588
|
+
toString() {
|
|
3589
|
+
const horizontal = this.horizontal.toString();
|
|
3590
|
+
const vertical = this.vertical.toString();
|
|
3591
|
+
if (horizontal === vertical) {
|
|
3592
|
+
return horizontal;
|
|
3593
|
+
}
|
|
3594
|
+
return `${horizontal} ${vertical}`;
|
|
3595
|
+
}
|
|
3596
|
+
static get parse() {
|
|
3597
|
+
return _tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.sequence(_lengthPercentage.lengthPercentage, _lengthPercentage.lengthPercentage).separatedBy(_tokenParser.TokenParser.tokens.Whitespace), _lengthPercentage.lengthPercentage.map(p => [p, p])).map(([horizontal, vertical]) => new BorderRadiusIndividual(horizontal, vertical));
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
borderRadius.BorderRadiusIndividual = BorderRadiusIndividual;
|
|
3601
|
+
class BorderRadiusShorthand {
|
|
3602
|
+
constructor(horizontalTopLeft, horizontalTopRight = horizontalTopLeft, horizontalBottomRight = horizontalTopLeft, horizontalBottomLeft = horizontalTopRight, verticalTopLeft = horizontalTopLeft, verticalTopRight = verticalTopLeft, verticalBottomRight = verticalTopLeft, verticalBottomLeft = verticalTopRight) {
|
|
3603
|
+
this.horizontalTopLeft = horizontalTopLeft;
|
|
3604
|
+
this.horizontalTopRight = horizontalTopRight;
|
|
3605
|
+
this.horizontalBottomRight = horizontalBottomRight;
|
|
3606
|
+
this.horizontalBottomLeft = horizontalBottomLeft;
|
|
3607
|
+
this.verticalTopLeft = verticalTopLeft;
|
|
3608
|
+
this.verticalTopRight = verticalTopRight;
|
|
3609
|
+
this.verticalBottomRight = verticalBottomRight;
|
|
3610
|
+
this.verticalBottomLeft = verticalBottomLeft;
|
|
3611
|
+
}
|
|
3612
|
+
toString() {
|
|
3613
|
+
const horizontalTopLeft = this.horizontalTopLeft.toString();
|
|
3614
|
+
const horizontalTopRight = this.horizontalTopRight.toString();
|
|
3615
|
+
const horizontalBottomRight = this.horizontalBottomRight.toString();
|
|
3616
|
+
const horizontalBottomLeft = this.horizontalBottomLeft.toString();
|
|
3617
|
+
let pStr = `${horizontalTopLeft} ${horizontalTopRight} ${horizontalBottomRight} ${horizontalBottomLeft}`;
|
|
3618
|
+
if (horizontalTopLeft === horizontalTopRight && horizontalTopRight === horizontalBottomRight && horizontalBottomRight === horizontalBottomLeft) {
|
|
3619
|
+
pStr = horizontalTopLeft;
|
|
3620
|
+
} else if (horizontalTopLeft === horizontalBottomRight && horizontalTopRight === horizontalBottomLeft) {
|
|
3621
|
+
pStr = `${horizontalTopLeft} ${horizontalTopRight}`;
|
|
3622
|
+
} else if (horizontalTopRight === horizontalBottomLeft) {
|
|
3623
|
+
pStr = `${horizontalTopLeft} ${horizontalTopRight} ${horizontalBottomRight}`;
|
|
3624
|
+
}
|
|
3625
|
+
const verticalTopLeft = this.verticalTopLeft.toString();
|
|
3626
|
+
const verticalTopRight = this.verticalTopRight.toString();
|
|
3627
|
+
const verticalBottomRight = this.verticalBottomRight.toString();
|
|
3628
|
+
const verticalBottomLeft = this.verticalBottomLeft.toString();
|
|
3629
|
+
let sStr = `${horizontalTopLeft} ${horizontalTopRight} ${horizontalBottomRight} ${horizontalBottomLeft}`;
|
|
3630
|
+
if (verticalTopLeft === verticalTopRight && verticalTopRight === verticalBottomRight && verticalBottomRight === verticalBottomLeft) {
|
|
3631
|
+
sStr = verticalTopLeft;
|
|
3632
|
+
} else if (verticalTopLeft === verticalBottomRight && verticalTopRight === verticalBottomLeft) {
|
|
3633
|
+
sStr = `${verticalTopLeft} ${verticalTopRight}`;
|
|
3634
|
+
} else if (verticalTopRight === verticalBottomLeft) {
|
|
3635
|
+
sStr = `${verticalTopLeft} ${verticalTopRight} ${verticalBottomRight}`;
|
|
3636
|
+
}
|
|
3637
|
+
if (pStr === sStr) {
|
|
3638
|
+
return pStr;
|
|
3639
|
+
}
|
|
3640
|
+
return `${pStr} / ${sStr}`;
|
|
3641
|
+
}
|
|
3642
|
+
static get parse() {
|
|
3643
|
+
const spaceSeparatedRadii = _tokenParser.TokenParser.sequence(_lengthPercentage.lengthPercentage, _lengthPercentage.lengthPercentage.prefix(_tokenParser.TokenParser.tokens.Whitespace).optional, _lengthPercentage.lengthPercentage.prefix(_tokenParser.TokenParser.tokens.Whitespace).optional, _lengthPercentage.lengthPercentage.prefix(_tokenParser.TokenParser.tokens.Whitespace).optional).map(([topLeft, topRight = topLeft, bottomRight = topLeft, bottomLeft = topRight]) => [topLeft, topRight, bottomRight, bottomLeft]);
|
|
3644
|
+
const assymtricBorder = _tokenParser.TokenParser.sequence(spaceSeparatedRadii, spaceSeparatedRadii).separatedBy(_tokenParser.TokenParser.tokens.Delim.map(delim => delim[4].value).where(d => d === '/').surroundedBy(_tokenParser.TokenParser.tokens.Whitespace)).map(([pRadii, sRadii = pRadii]) => new BorderRadiusShorthand(...pRadii, ...sRadii));
|
|
3645
|
+
return _tokenParser.TokenParser.oneOf(assymtricBorder, spaceSeparatedRadii.map(borders => new BorderRadiusShorthand(...borders)));
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
borderRadius.BorderRadiusShorthand = BorderRadiusShorthand;
|
|
3649
|
+
return borderRadius;
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
var hasRequiredProperties;
|
|
3653
|
+
|
|
3654
|
+
function requireProperties () {
|
|
3655
|
+
if (hasRequiredProperties) return properties;
|
|
3656
|
+
hasRequiredProperties = 1;
|
|
3657
|
+
(function (exports) {
|
|
3658
|
+
|
|
3659
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3660
|
+
value: true
|
|
3661
|
+
});
|
|
3662
|
+
Object.defineProperty(exports, "BorderRadiusIndividual", {
|
|
3663
|
+
enumerable: true,
|
|
3664
|
+
get: function () {
|
|
3665
|
+
return _borderRadius.BorderRadiusIndividual;
|
|
3666
|
+
}
|
|
3667
|
+
});
|
|
3668
|
+
Object.defineProperty(exports, "BorderRadiusShorthand", {
|
|
3669
|
+
enumerable: true,
|
|
3670
|
+
get: function () {
|
|
3671
|
+
return _borderRadius.BorderRadiusShorthand;
|
|
3672
|
+
}
|
|
3673
|
+
});
|
|
3674
|
+
Object.defineProperty(exports, "BoxShadow", {
|
|
3675
|
+
enumerable: true,
|
|
3676
|
+
get: function () {
|
|
3677
|
+
return _boxShadow.BoxShadow;
|
|
3678
|
+
}
|
|
3679
|
+
});
|
|
3680
|
+
Object.defineProperty(exports, "BoxShadowList", {
|
|
3681
|
+
enumerable: true,
|
|
3682
|
+
get: function () {
|
|
3683
|
+
return _boxShadow.BoxShadowList;
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
Object.defineProperty(exports, "Transform", {
|
|
3687
|
+
enumerable: true,
|
|
3688
|
+
get: function () {
|
|
3689
|
+
return _transform.Transform;
|
|
3690
|
+
}
|
|
3691
|
+
});
|
|
3692
|
+
var _transform = requireTransform();
|
|
3693
|
+
var _boxShadow = requireBoxShadow();
|
|
3694
|
+
var _borderRadius = requireBorderRadius();
|
|
3695
|
+
} (properties));
|
|
3696
|
+
return properties;
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3699
|
+
var mediaQueryTransform = {};
|
|
3700
|
+
|
|
3701
|
+
var mediaQuery = {};
|
|
3702
|
+
|
|
3703
|
+
var calc = {};
|
|
3704
|
+
|
|
3705
|
+
var calcConstant = {};
|
|
3706
|
+
|
|
3707
|
+
var hasRequiredCalcConstant;
|
|
3708
|
+
|
|
3709
|
+
function requireCalcConstant () {
|
|
3710
|
+
if (hasRequiredCalcConstant) return calcConstant;
|
|
3711
|
+
hasRequiredCalcConstant = 1;
|
|
3712
|
+
|
|
3713
|
+
Object.defineProperty(calcConstant, "__esModule", {
|
|
3714
|
+
value: true
|
|
3715
|
+
});
|
|
3716
|
+
calcConstant.calcConstant = calcConstant.allCalcConstants = void 0;
|
|
3717
|
+
var _tokenParser = requireTokenParser();
|
|
3718
|
+
calcConstant.allCalcConstants = ['pi', 'e', 'infinity', '-infinity', 'NaN'];
|
|
3719
|
+
calcConstant.calcConstant = _tokenParser.TokenParser.oneOf(_tokenParser.TokenParser.string('pi'), _tokenParser.TokenParser.string('e'), _tokenParser.TokenParser.string('infinity'), _tokenParser.TokenParser.string('-infinity'), _tokenParser.TokenParser.string('NaN'));
|
|
3720
|
+
return calcConstant;
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
var hasRequiredCalc;
|
|
3724
|
+
|
|
3725
|
+
function requireCalc () {
|
|
3726
|
+
if (hasRequiredCalc) return calc;
|
|
3727
|
+
hasRequiredCalc = 1;
|
|
3728
|
+
|
|
3729
|
+
Object.defineProperty(calc, "__esModule", {
|
|
3730
|
+
value: true
|
|
3731
|
+
});
|
|
3732
|
+
calc.valueParser = calc.Calc = void 0;
|
|
3733
|
+
var _calcConstant = requireCalcConstant();
|
|
3734
|
+
var _commonTypes = requireCommonTypes();
|
|
3735
|
+
var _tokenParser = requireTokenParser();
|
|
3736
|
+
const valueParser = calc.valueParser = _tokenParser.TokenParser.oneOf(_calcConstant.calcConstant, _tokenParser.TokenParser.tokens.Number.map(number => number[4].value), _tokenParser.TokenParser.tokens.Dimension.map(dimension => dimension[4]), _commonTypes.Percentage.parser);
|
|
3737
|
+
const composeAddAndSubtraction = valuesAndOperators => {
|
|
3738
|
+
if (valuesAndOperators.length === 1) {
|
|
3739
|
+
if (typeof valuesAndOperators[0] === 'string') {
|
|
3740
|
+
if (_calcConstant.allCalcConstants.includes(valuesAndOperators[0])) {
|
|
3741
|
+
return valuesAndOperators[0];
|
|
3742
|
+
}
|
|
3743
|
+
throw new Error('Invalid operator');
|
|
3744
|
+
}
|
|
3745
|
+
return valuesAndOperators[0];
|
|
3746
|
+
}
|
|
3747
|
+
const firstOperator = valuesAndOperators.findIndex(op => op === '+' || op === '-');
|
|
3748
|
+
if (firstOperator === -1) {
|
|
3749
|
+
throw new Error('No valid operator found');
|
|
3750
|
+
}
|
|
3751
|
+
const left = valuesAndOperators.slice(0, firstOperator);
|
|
3752
|
+
const right = valuesAndOperators.slice(firstOperator + 1);
|
|
3753
|
+
if (valuesAndOperators[firstOperator] === '+') {
|
|
3754
|
+
return {
|
|
3755
|
+
type: '+',
|
|
3756
|
+
left: composeAddAndSubtraction(left),
|
|
3757
|
+
right: composeAddAndSubtraction(right)
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
return {
|
|
3761
|
+
type: '-',
|
|
3762
|
+
left: composeAddAndSubtraction(left),
|
|
3763
|
+
right: composeAddAndSubtraction(right)
|
|
3764
|
+
};
|
|
3765
|
+
};
|
|
3766
|
+
const splitByMultiplicationOrDivision = valuesAndOperators => {
|
|
3767
|
+
if (valuesAndOperators.length === 1) {
|
|
3768
|
+
if (typeof valuesAndOperators[0] === 'string') {
|
|
3769
|
+
throw new Error('Invalid operator');
|
|
3770
|
+
}
|
|
3771
|
+
return valuesAndOperators[0];
|
|
3772
|
+
}
|
|
3773
|
+
const firstOperator = valuesAndOperators.findIndex(op => op === '*' || op === '/');
|
|
3774
|
+
if (firstOperator === -1) {
|
|
3775
|
+
return composeAddAndSubtraction(valuesAndOperators);
|
|
3776
|
+
}
|
|
3777
|
+
const left = valuesAndOperators.slice(0, firstOperator);
|
|
3778
|
+
const right = valuesAndOperators.slice(firstOperator + 1);
|
|
3779
|
+
if (valuesAndOperators[firstOperator] === '*') {
|
|
3780
|
+
return {
|
|
3781
|
+
type: '*',
|
|
3782
|
+
left: composeAddAndSubtraction(left),
|
|
3783
|
+
right: splitByMultiplicationOrDivision(right)
|
|
3784
|
+
};
|
|
3785
|
+
}
|
|
3786
|
+
return {
|
|
3787
|
+
type: '/',
|
|
3788
|
+
left: composeAddAndSubtraction(left),
|
|
3789
|
+
right: splitByMultiplicationOrDivision(right)
|
|
3790
|
+
};
|
|
3791
|
+
};
|
|
3792
|
+
let operationsParser;
|
|
3793
|
+
const parenthesizedParser = _tokenParser.TokenParser.tokens.OpenParen.skip(_tokenParser.TokenParser.tokens.Whitespace.optional).flatMap(() => operationsParser.skip(_tokenParser.TokenParser.tokens.Whitespace.optional).skip(_tokenParser.TokenParser.tokens.CloseParen)).map(expr => ({
|
|
3794
|
+
type: 'group',
|
|
3795
|
+
expr
|
|
3796
|
+
}));
|
|
3797
|
+
operationsParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.oneOf(valueParser, parenthesizedParser), _tokenParser.TokenParser.zeroOrMore(_tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Delim.map(delim => delim[4].value).where(delim => delim === '*' || delim === '/' || delim === '+' || delim === '-'), _tokenParser.TokenParser.oneOf(valueParser, parenthesizedParser)).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional)).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional)).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([firstValue, restOfTheValues]) => {
|
|
3798
|
+
if (restOfTheValues == null || restOfTheValues.length === 0) {
|
|
3799
|
+
return firstValue;
|
|
3800
|
+
}
|
|
3801
|
+
const valuesAndOperators = [firstValue, ...restOfTheValues.flat()];
|
|
3802
|
+
return splitByMultiplicationOrDivision(valuesAndOperators);
|
|
3803
|
+
});
|
|
3804
|
+
class Calc {
|
|
3805
|
+
constructor(value) {
|
|
3806
|
+
this.value = value;
|
|
3807
|
+
}
|
|
3808
|
+
toString() {
|
|
3809
|
+
return `calc(${calcValueToString(this.value)})`;
|
|
3810
|
+
}
|
|
3811
|
+
static get parser() {
|
|
3812
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Function.map(func => func[4].value).where(func => func === 'calc'), _tokenParser.TokenParser.oneOf(operationsParser, valueParser), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_, value, _closeParen]) => new Calc(value));
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
calc.Calc = Calc;
|
|
3816
|
+
function calcValueToString(value) {
|
|
3817
|
+
if (typeof value === 'number') {
|
|
3818
|
+
return value.toString();
|
|
3819
|
+
}
|
|
3820
|
+
if (typeof value === 'string') {
|
|
3821
|
+
return value;
|
|
3822
|
+
}
|
|
3823
|
+
if (value != null && typeof value === 'object' && 'expr' in value) {
|
|
3824
|
+
const group = value;
|
|
3825
|
+
return '(' + calcValueToString(group.expr) + ')';
|
|
3826
|
+
}
|
|
3827
|
+
if (value != null && typeof value === 'object' && 'left' in value && 'right' in value && typeof value.type === 'string') {
|
|
3828
|
+
const opNode = value;
|
|
3829
|
+
return [calcValueToString(opNode.left), opNode.type, calcValueToString(opNode.right)].join(' ');
|
|
3830
|
+
}
|
|
3831
|
+
if (value != null && typeof value === 'object' && 'value' in value && 'unit' in value) {
|
|
3832
|
+
const d = value;
|
|
3833
|
+
return `${d.value}${d.unit}`;
|
|
3834
|
+
}
|
|
3835
|
+
return String(value);
|
|
3836
|
+
}
|
|
3837
|
+
return calc;
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
var messages$1 = {};
|
|
3841
|
+
|
|
3842
|
+
var hasRequiredMessages;
|
|
3843
|
+
|
|
3844
|
+
function requireMessages () {
|
|
3845
|
+
if (hasRequiredMessages) return messages$1;
|
|
3846
|
+
hasRequiredMessages = 1;
|
|
3847
|
+
|
|
3848
|
+
Object.defineProperty(messages$1, "__esModule", {
|
|
3849
|
+
value: true
|
|
3850
|
+
});
|
|
3851
|
+
messages$1.MediaQueryErrors = void 0;
|
|
3852
|
+
messages$1.MediaQueryErrors = {
|
|
3853
|
+
SYNTAX_ERROR: 'Invalid media query syntax.',
|
|
3854
|
+
UNBALANCED_PARENS: 'Unbalanced parentheses in media query.'
|
|
3855
|
+
};
|
|
3856
|
+
return messages$1;
|
|
3857
|
+
}
|
|
3858
|
+
|
|
3859
|
+
var hasRequiredMediaQuery;
|
|
3860
|
+
|
|
3861
|
+
function requireMediaQuery () {
|
|
3862
|
+
if (hasRequiredMediaQuery) return mediaQuery;
|
|
3863
|
+
hasRequiredMediaQuery = 1;
|
|
3864
|
+
|
|
3865
|
+
Object.defineProperty(mediaQuery, "__esModule", {
|
|
3866
|
+
value: true
|
|
3867
|
+
});
|
|
3868
|
+
mediaQuery.MediaQuery = void 0;
|
|
3869
|
+
mediaQuery.validateMediaQuery = validateMediaQuery;
|
|
3870
|
+
var _tokenParser = requireTokenParser();
|
|
3871
|
+
var _calc = requireCalc();
|
|
3872
|
+
var _messages = requireMessages();
|
|
3873
|
+
function adjustDimension(dimension, op, eq, isMaxWidth = false) {
|
|
3874
|
+
let adjustedValue = dimension.value;
|
|
3875
|
+
const epsilon = 0.01;
|
|
3876
|
+
if (eq !== '=') {
|
|
3877
|
+
if (isMaxWidth) {
|
|
3878
|
+
adjustedValue -= epsilon;
|
|
3879
|
+
} else {
|
|
3880
|
+
adjustedValue += epsilon;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
return {
|
|
3884
|
+
...dimension,
|
|
3885
|
+
value: adjustedValue
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
const basicMediaTypeParser = _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').where(key => key === 'screen' || key === 'print' || key === 'all');
|
|
3889
|
+
const mediaKeywordParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.string('not').optional, _tokenParser.TokenParser.string('only').optional, basicMediaTypeParser).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([not, only, keyword]) => ({
|
|
3890
|
+
type: 'media-keyword',
|
|
3891
|
+
key: keyword,
|
|
3892
|
+
not: not === 'not',
|
|
3893
|
+
only: only === 'only'
|
|
3894
|
+
}));
|
|
3895
|
+
const mediaWordRuleParser = _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen).where(key => key === 'color' || key === 'monochrome' || key === 'grid' || key === 'color-index').map(key => ({
|
|
3896
|
+
type: 'word-rule',
|
|
3897
|
+
keyValue: key
|
|
3898
|
+
}));
|
|
3899
|
+
const mediaRuleValueParser = _tokenParser.TokenParser.oneOf(_calc.Calc.parser.map(calc => calc.toString()), _tokenParser.TokenParser.tokens.Dimension.map(token => token[4]), _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value), _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Number.map(token => token[4].value), _tokenParser.TokenParser.tokens.Delim.where(token => token[4].value === '/').map(() => '/'), _tokenParser.TokenParser.tokens.Number.map(token => token[4].value)).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional), _tokenParser.TokenParser.tokens.Number.map(token => token[4].value));
|
|
3900
|
+
const simplePairParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue'), _tokenParser.TokenParser.tokens.Colon, mediaRuleValueParser, _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_openParen, key, _colon, value, _closeParen]) => ({
|
|
3901
|
+
type: 'pair',
|
|
3902
|
+
key,
|
|
3903
|
+
value
|
|
3904
|
+
}));
|
|
3905
|
+
const mediaInequalityRuleParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').where(val => val === 'width' || val === 'height'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '>' || val === '<'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '=').optional, _tokenParser.TokenParser.tokens.Dimension.map(token => token[4]), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_openParen, key, op, eq, dimension, _closeParen]) => {
|
|
3906
|
+
const finalKey = op === '>' ? `min-${key}` : `max-${key}`;
|
|
3907
|
+
const isMaxWidth = finalKey.startsWith('max-');
|
|
3908
|
+
const adjustedDimension = adjustDimension(dimension, op, eq, isMaxWidth);
|
|
3909
|
+
return {
|
|
3910
|
+
type: 'pair',
|
|
3911
|
+
key: finalKey,
|
|
3912
|
+
value: adjustedDimension
|
|
3913
|
+
};
|
|
3914
|
+
});
|
|
3915
|
+
const mediaInequalityRuleParserReversed = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.Dimension.map(token => token[4]), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '>' || val === '<'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '=').optional, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').where(val => val === 'width' || val === 'height'), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_openParen, dimension, op, eq, key, _closeParen]) => {
|
|
3916
|
+
const finalKey = op === '>' ? `max-${key}` : `min-${key}`;
|
|
3917
|
+
const isMaxWidth = finalKey.startsWith('max-');
|
|
3918
|
+
const adjustedDimension = adjustDimension(dimension, op, eq, isMaxWidth);
|
|
3919
|
+
return {
|
|
3920
|
+
type: 'pair',
|
|
3921
|
+
key: finalKey,
|
|
3922
|
+
value: adjustedDimension
|
|
3923
|
+
};
|
|
3924
|
+
});
|
|
3925
|
+
const combinedInequalityParser = _tokenParser.TokenParser.oneOf(mediaInequalityRuleParser, mediaInequalityRuleParserReversed);
|
|
3926
|
+
const doubleInequalityRuleParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.Dimension.map(token => token[4]), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '>' || val === '<'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '=').optional, _tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').where(val => val === 'width' || val === 'height'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '>' || val === '<'), _tokenParser.TokenParser.tokens.Delim.map(token => token[4].value).where(val => val === '=').optional, _tokenParser.TokenParser.tokens.Dimension.map(token => token[4]), _tokenParser.TokenParser.tokens.CloseParen).separatedBy(_tokenParser.TokenParser.tokens.Whitespace.optional).map(([_openParen, lower, op, eq, key, op2, eq2, upper, _closeParen]) => {
|
|
3927
|
+
const lowerKey = op === '>' ? `max-${key}` : `min-${key}`;
|
|
3928
|
+
const upperKey = op2 === '>' ? `min-${key}` : `max-${key}`;
|
|
3929
|
+
const lowerIsMaxWidth = lowerKey.startsWith('max-');
|
|
3930
|
+
const upperIsMaxWidth = upperKey.startsWith('max-');
|
|
3931
|
+
const lowerValue = adjustDimension(lower, op, eq, lowerIsMaxWidth);
|
|
3932
|
+
const upperValue = adjustDimension(upper, op2, eq2, upperIsMaxWidth);
|
|
3933
|
+
return {
|
|
3934
|
+
type: 'and',
|
|
3935
|
+
rules: [{
|
|
3936
|
+
type: 'pair',
|
|
3937
|
+
key: lowerKey,
|
|
3938
|
+
value: lowerValue
|
|
3939
|
+
}, {
|
|
3940
|
+
type: 'pair',
|
|
3941
|
+
key: upperKey,
|
|
3942
|
+
value: upperValue
|
|
3943
|
+
}]
|
|
3944
|
+
};
|
|
3945
|
+
});
|
|
3946
|
+
const mediaAndRulesParser = _tokenParser.TokenParser.oneOrMore(_tokenParser.TokenParser.oneOf(mediaKeywordParser, () => mediaOrRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => mediaAndRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => notParser, doubleInequalityRuleParser, combinedInequalityParser, simplePairParser, mediaWordRuleParser)).separatedBy(_tokenParser.TokenParser.string('and').surroundedBy(_tokenParser.TokenParser.tokens.Whitespace)).where(rules => Array.isArray(rules) && rules.length > 1).map(rules => rules.length === 1 ? rules[0] : {
|
|
3947
|
+
type: 'and',
|
|
3948
|
+
rules
|
|
3949
|
+
});
|
|
3950
|
+
const mediaOrRulesParser = _tokenParser.TokenParser.oneOrMore(_tokenParser.TokenParser.oneOf(mediaKeywordParser, () => mediaOrRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => mediaAndRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => notParser, doubleInequalityRuleParser, combinedInequalityParser, simplePairParser, mediaWordRuleParser)).separatedBy(_tokenParser.TokenParser.string('or').surroundedBy(_tokenParser.TokenParser.tokens.Whitespace)).where(rules => rules.length > 1).map(rules => rules.length === 1 ? rules[0] : {
|
|
3951
|
+
type: 'or',
|
|
3952
|
+
rules
|
|
3953
|
+
});
|
|
3954
|
+
let notParser;
|
|
3955
|
+
const getNormalRuleParser = () => _tokenParser.TokenParser.oneOf(() => basicMediaTypeParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen).map(keyword => ({
|
|
3956
|
+
type: 'media-keyword',
|
|
3957
|
+
key: keyword,
|
|
3958
|
+
not: false
|
|
3959
|
+
})), mediaAndRulesParser, mediaOrRulesParser, simplePairParser, mediaWordRuleParser, () => notParser, () => mediaOrRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => mediaAndRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen)).skip(_tokenParser.TokenParser.tokens.Whitespace.optional);
|
|
3960
|
+
notParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.string('not'), _tokenParser.TokenParser.tokens.Whitespace, getNormalRuleParser(), _tokenParser.TokenParser.tokens.CloseParen).map(([_openParen, _not, _space, rule, _closeParen]) => ({
|
|
3961
|
+
type: 'not',
|
|
3962
|
+
rule
|
|
3963
|
+
}));
|
|
3964
|
+
function isNumericLength(val) {
|
|
3965
|
+
return typeof val === 'object' && val !== null && !Array.isArray(val) && typeof val.value === 'number' && typeof val.unit === 'string' && (val.type === 'integer' || val.type === 'number');
|
|
3966
|
+
}
|
|
3967
|
+
function mergeIntervalsForAnd(rules) {
|
|
3968
|
+
const epsilon = 0.01;
|
|
3969
|
+
const dimensions = ['width', 'height'];
|
|
3970
|
+
const intervals = {
|
|
3971
|
+
width: [],
|
|
3972
|
+
height: []
|
|
3973
|
+
};
|
|
3974
|
+
for (const rule of rules) {
|
|
3975
|
+
if (rule.type === 'not' && rule.rule.type === 'and') {
|
|
3976
|
+
const inner = rule.rule.rules;
|
|
3977
|
+
if (inner.length === 2) {
|
|
3978
|
+
const [left, right] = inner;
|
|
3979
|
+
const leftBranch = mergeIntervalsForAnd([...rules.filter(r => r !== rule), {
|
|
3980
|
+
type: 'not',
|
|
3981
|
+
rule: left
|
|
3982
|
+
}]);
|
|
3983
|
+
const rightBranch = mergeIntervalsForAnd([...rules.filter(r => r !== rule), {
|
|
3984
|
+
type: 'not',
|
|
3985
|
+
rule: right
|
|
3986
|
+
}]);
|
|
3987
|
+
return [{
|
|
3988
|
+
type: 'or',
|
|
3989
|
+
rules: [leftBranch, rightBranch].filter(branch => branch.length > 0).map(branch => branch.length === 1 ? branch[0] : {
|
|
3990
|
+
type: 'and',
|
|
3991
|
+
rules: branch
|
|
3992
|
+
})
|
|
3993
|
+
}];
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
for (const rule of rules) {
|
|
3998
|
+
for (const dim of dimensions) {
|
|
3999
|
+
if (rule.type === 'pair' && (rule.key === `min-${dim}` || rule.key === `max-${dim}`) && isNumericLength(rule.value)) {
|
|
4000
|
+
const val = rule.value;
|
|
4001
|
+
intervals[dim].push(rule.key === `min-${dim}` ? [val.value, Infinity] : [-Infinity, val.value]);
|
|
4002
|
+
break;
|
|
4003
|
+
} else if (rule.type === 'not' && rule.rule && rule.rule.type === 'pair' && (rule.rule.key === `min-${dim}` || rule.rule.key === `max-${dim}`) && isNumericLength(rule.rule.value)) {
|
|
4004
|
+
const val = rule.rule.value;
|
|
4005
|
+
if (rule.rule.key === `min-${dim}`) {
|
|
4006
|
+
intervals[dim].push([-Infinity, val.value - epsilon]);
|
|
4007
|
+
} else {
|
|
4008
|
+
intervals[dim].push([val.value + epsilon, Infinity]);
|
|
4009
|
+
}
|
|
4010
|
+
break;
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
if (!(rule.type === 'pair' && (rule.key === 'min-width' || rule.key === 'max-width' || rule.key === 'min-height' || rule.key === 'max-height') && isNumericLength(rule.value) || rule.type === 'not' && rule.rule && rule.rule.type === 'pair' && (rule.rule.key === 'min-width' || rule.rule.key === 'max-width' || rule.rule.key === 'min-height' || rule.rule.key === 'max-height') && isNumericLength(rule.rule.value))) {
|
|
4014
|
+
return rules;
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
const result = [];
|
|
4018
|
+
for (const dim of dimensions) {
|
|
4019
|
+
const dimIntervals = intervals[dim];
|
|
4020
|
+
if (dimIntervals.length === 0) continue;
|
|
4021
|
+
let lower = -Infinity;
|
|
4022
|
+
let upper = Infinity;
|
|
4023
|
+
for (const [l, u] of dimIntervals) {
|
|
4024
|
+
if (l > lower) lower = l;
|
|
4025
|
+
if (u < upper) upper = u;
|
|
4026
|
+
}
|
|
4027
|
+
if (lower > upper) {
|
|
4028
|
+
return [];
|
|
4029
|
+
}
|
|
4030
|
+
if (lower !== -Infinity) {
|
|
4031
|
+
result.push({
|
|
4032
|
+
type: 'pair',
|
|
4033
|
+
key: `min-${dim}`,
|
|
4034
|
+
value: {
|
|
4035
|
+
value: lower,
|
|
4036
|
+
unit: 'px',
|
|
4037
|
+
type: 'integer'
|
|
4038
|
+
}
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
if (upper !== Infinity) {
|
|
4042
|
+
result.push({
|
|
4043
|
+
type: 'pair',
|
|
4044
|
+
key: `max-${dim}`,
|
|
4045
|
+
value: {
|
|
4046
|
+
value: upper,
|
|
4047
|
+
unit: 'px',
|
|
4048
|
+
type: 'integer'
|
|
4049
|
+
}
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
return result.length > 0 ? result : rules;
|
|
4054
|
+
}
|
|
4055
|
+
function mergeAndSimplifyRanges(rules) {
|
|
4056
|
+
try {
|
|
4057
|
+
return mergeIntervalsForAnd(rules);
|
|
4058
|
+
} catch (e) {
|
|
4059
|
+
return rules;
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
class MediaQuery {
|
|
4063
|
+
constructor(queries) {
|
|
4064
|
+
this.queries = MediaQuery.normalize(queries);
|
|
4065
|
+
}
|
|
4066
|
+
toString() {
|
|
4067
|
+
return `@media ${this.#toString(this.queries, true)}`;
|
|
4068
|
+
}
|
|
4069
|
+
#toString(queries, isTopLevel = false) {
|
|
4070
|
+
switch (queries.type) {
|
|
4071
|
+
case 'media-keyword':
|
|
4072
|
+
{
|
|
4073
|
+
const prefix = queries.not ? 'not ' : queries.only ? 'only ' : '';
|
|
4074
|
+
return prefix + queries.key;
|
|
4075
|
+
}
|
|
4076
|
+
case 'word-rule':
|
|
4077
|
+
return `(${queries.keyValue})`;
|
|
4078
|
+
case 'pair':
|
|
4079
|
+
{
|
|
4080
|
+
const {
|
|
4081
|
+
key,
|
|
4082
|
+
value
|
|
4083
|
+
} = queries;
|
|
4084
|
+
if (Array.isArray(value)) {
|
|
4085
|
+
return `(${key}: ${value[0]} / ${value[2]})`;
|
|
4086
|
+
}
|
|
4087
|
+
if (typeof value === 'string') {
|
|
4088
|
+
return `(${key}: ${value})`;
|
|
4089
|
+
}
|
|
4090
|
+
if (value != null && typeof value === 'object' && typeof value.value === 'number' && typeof value.unit === 'string') {
|
|
4091
|
+
const len = value;
|
|
4092
|
+
return `(${key}: ${len.value}${len.unit})`;
|
|
4093
|
+
}
|
|
4094
|
+
if (value != null && typeof value.toString === 'function') {
|
|
4095
|
+
return `(${key}: ${value.toString()})`;
|
|
4096
|
+
}
|
|
4097
|
+
throw new Error(`cannot serialize media-pair value for key "${key}": ${String(value)}`);
|
|
4098
|
+
}
|
|
4099
|
+
case 'not':
|
|
4100
|
+
return queries.rule && (queries.rule.type === 'and' || queries.rule.type === 'or') ? `(not (${this.#toString(queries.rule)}))` : `(not ${this.#toString(queries.rule)})`;
|
|
4101
|
+
case 'and':
|
|
4102
|
+
return queries.rules.map(rule => this.#toString(rule)).join(' and ');
|
|
4103
|
+
case 'or':
|
|
4104
|
+
{
|
|
4105
|
+
const validRules = queries.rules.filter(r => !(r.type === 'or' && r.rules.length === 0));
|
|
4106
|
+
if (validRules.length === 0) return 'not all';
|
|
4107
|
+
if (validRules.length === 1) return this.#toString(validRules[0], isTopLevel);
|
|
4108
|
+
const formattedRules = validRules.map(rule => {
|
|
4109
|
+
if (rule.type === 'and' || rule.type === 'or') {
|
|
4110
|
+
const ruleString = this.#toString(rule);
|
|
4111
|
+
const result = !isTopLevel ? `(${ruleString})` : ruleString;
|
|
4112
|
+
return result;
|
|
4113
|
+
}
|
|
4114
|
+
return this.#toString(rule);
|
|
4115
|
+
});
|
|
4116
|
+
return isTopLevel ? formattedRules.join(', ') : formattedRules.join(' or ');
|
|
4117
|
+
}
|
|
4118
|
+
default:
|
|
4119
|
+
return '';
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
static normalize(rule) {
|
|
4123
|
+
switch (rule.type) {
|
|
4124
|
+
case 'and':
|
|
4125
|
+
{
|
|
4126
|
+
const flattened = [];
|
|
4127
|
+
for (const r of rule.rules) {
|
|
4128
|
+
const norm = MediaQuery.normalize(r);
|
|
4129
|
+
if (norm.type === 'and') {
|
|
4130
|
+
flattened.push(...norm.rules);
|
|
4131
|
+
} else {
|
|
4132
|
+
flattened.push(norm);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
const merged = mergeAndSimplifyRanges(flattened);
|
|
4136
|
+
if (merged.length === 0) return {
|
|
4137
|
+
type: 'media-keyword',
|
|
4138
|
+
key: 'all',
|
|
4139
|
+
not: true
|
|
4140
|
+
};
|
|
4141
|
+
return {
|
|
4142
|
+
type: 'and',
|
|
4143
|
+
rules: merged
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
case 'or':
|
|
4147
|
+
return {
|
|
4148
|
+
type: 'or',
|
|
4149
|
+
rules: rule.rules.map(r => MediaQuery.normalize(r))
|
|
4150
|
+
};
|
|
4151
|
+
case 'not':
|
|
4152
|
+
{
|
|
4153
|
+
const normalizedOperand = MediaQuery.normalize(rule.rule);
|
|
4154
|
+
if (normalizedOperand.type === 'media-keyword' && normalizedOperand.key === 'all' && normalizedOperand.not) {
|
|
4155
|
+
return {
|
|
4156
|
+
type: 'media-keyword',
|
|
4157
|
+
key: 'all',
|
|
4158
|
+
not: false
|
|
4159
|
+
};
|
|
4160
|
+
}
|
|
4161
|
+
if (normalizedOperand.type === 'not') {
|
|
4162
|
+
return MediaQuery.normalize(normalizedOperand.rule);
|
|
4163
|
+
}
|
|
4164
|
+
return {
|
|
4165
|
+
type: 'not',
|
|
4166
|
+
rule: normalizedOperand
|
|
4167
|
+
};
|
|
4168
|
+
}
|
|
4169
|
+
default:
|
|
4170
|
+
return rule;
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
static get parser() {
|
|
4174
|
+
const leadingNotParser = _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.Ident.map(token => token[4].value, '.stringValue').where(key => key === 'not'), _tokenParser.TokenParser.oneOf(() => mediaOrRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => mediaAndRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => notParser, combinedInequalityParser, simplePairParser, mediaWordRuleParser)).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([_not, queries]) => ({
|
|
4175
|
+
type: 'not',
|
|
4176
|
+
rule: queries
|
|
4177
|
+
}));
|
|
4178
|
+
const normalRuleParser = _tokenParser.TokenParser.oneOf(mediaAndRulesParser, mediaOrRulesParser, mediaKeywordParser, () => notParser, doubleInequalityRuleParser, combinedInequalityParser, simplePairParser, mediaWordRuleParser, () => mediaOrRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen), () => mediaAndRulesParser.surroundedBy(_tokenParser.TokenParser.tokens.OpenParen, _tokenParser.TokenParser.tokens.CloseParen));
|
|
4179
|
+
return _tokenParser.TokenParser.sequence(_tokenParser.TokenParser.tokens.AtKeyword.where(token => token[4].value === 'media'), _tokenParser.TokenParser.oneOrMore(_tokenParser.TokenParser.oneOf(leadingNotParser, normalRuleParser)).separatedBy(_tokenParser.TokenParser.tokens.Comma.surroundedBy(_tokenParser.TokenParser.tokens.Whitespace.optional))).separatedBy(_tokenParser.TokenParser.tokens.Whitespace).map(([_at, querySets]) => {
|
|
4180
|
+
const rule = querySets.length > 1 ? {
|
|
4181
|
+
type: 'or',
|
|
4182
|
+
rules: querySets
|
|
4183
|
+
} : querySets[0];
|
|
4184
|
+
return new MediaQuery(rule);
|
|
4185
|
+
});
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
mediaQuery.MediaQuery = MediaQuery;
|
|
4189
|
+
function _hasBalancedParens(str) {
|
|
4190
|
+
let count = 0;
|
|
4191
|
+
for (const char of Array.from(str)) {
|
|
4192
|
+
if (char === '(') count++;
|
|
4193
|
+
if (char === ')') count--;
|
|
4194
|
+
if (count < 0) return false;
|
|
4195
|
+
}
|
|
4196
|
+
return count === 0;
|
|
4197
|
+
}
|
|
4198
|
+
function validateMediaQuery(input) {
|
|
4199
|
+
if (!_hasBalancedParens(input)) {
|
|
4200
|
+
throw new Error(_messages.MediaQueryErrors.UNBALANCED_PARENS);
|
|
4201
|
+
}
|
|
4202
|
+
try {
|
|
4203
|
+
return MediaQuery.parser.parseToEnd(input);
|
|
4204
|
+
} catch (err) {
|
|
4205
|
+
throw new Error(_messages.MediaQueryErrors.SYNTAX_ERROR);
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
return mediaQuery;
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
var hasRequiredMediaQueryTransform;
|
|
4212
|
+
|
|
4213
|
+
function requireMediaQueryTransform () {
|
|
4214
|
+
if (hasRequiredMediaQueryTransform) return mediaQueryTransform;
|
|
4215
|
+
hasRequiredMediaQueryTransform = 1;
|
|
4216
|
+
|
|
4217
|
+
Object.defineProperty(mediaQueryTransform, "__esModule", {
|
|
4218
|
+
value: true
|
|
4219
|
+
});
|
|
4220
|
+
mediaQueryTransform.lastMediaQueryWinsTransform = lastMediaQueryWinsTransform;
|
|
4221
|
+
var _mediaQuery = requireMediaQuery();
|
|
4222
|
+
function lastMediaQueryWinsTransform(styles) {
|
|
4223
|
+
return dfsProcessQueries(styles, 0);
|
|
4224
|
+
}
|
|
4225
|
+
function combineMediaQueryWithNegations(current, negations) {
|
|
4226
|
+
if (negations.length === 0) {
|
|
4227
|
+
return current;
|
|
4228
|
+
}
|
|
4229
|
+
let combinedAst;
|
|
4230
|
+
if (current.queries.type === 'or') {
|
|
4231
|
+
combinedAst = {
|
|
4232
|
+
type: 'or',
|
|
4233
|
+
rules: current.queries.rules.map(rule => ({
|
|
4234
|
+
type: 'and',
|
|
4235
|
+
rules: [rule, ...negations.map(mq => ({
|
|
4236
|
+
type: 'not',
|
|
4237
|
+
rule: mq.queries
|
|
4238
|
+
}))]
|
|
4239
|
+
}))
|
|
4240
|
+
};
|
|
4241
|
+
} else {
|
|
4242
|
+
combinedAst = {
|
|
4243
|
+
type: 'and',
|
|
4244
|
+
rules: [current.queries, ...negations.map(mq => ({
|
|
4245
|
+
type: 'not',
|
|
4246
|
+
rule: mq.queries
|
|
4247
|
+
}))]
|
|
4248
|
+
};
|
|
4249
|
+
}
|
|
4250
|
+
return new _mediaQuery.MediaQuery(combinedAst);
|
|
4251
|
+
}
|
|
4252
|
+
function dfsProcessQueries(obj, depth) {
|
|
4253
|
+
if (Array.isArray(obj)) {
|
|
4254
|
+
return obj;
|
|
4255
|
+
}
|
|
4256
|
+
const result = {};
|
|
4257
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
4258
|
+
if (typeof value === 'object' && value !== null) {
|
|
4259
|
+
result[key] = dfsProcessQueries(value, depth + 1);
|
|
4260
|
+
} else {
|
|
4261
|
+
result[key] = value;
|
|
4262
|
+
}
|
|
4263
|
+
});
|
|
4264
|
+
if (depth >= 1 && Object.keys(result).some(key => key.startsWith('@media '))) {
|
|
4265
|
+
const mediaKeys = Object.keys(result).filter(key => key.startsWith('@media '));
|
|
4266
|
+
const negations = [];
|
|
4267
|
+
const accumulatedNegations = [];
|
|
4268
|
+
for (let i = mediaKeys.length - 1; i > 0; i--) {
|
|
4269
|
+
const mediaQuery = _mediaQuery.MediaQuery.parser.parseToEnd(mediaKeys[i]);
|
|
4270
|
+
negations.push(mediaQuery);
|
|
4271
|
+
accumulatedNegations.push([...negations]);
|
|
4272
|
+
}
|
|
4273
|
+
accumulatedNegations.reverse();
|
|
4274
|
+
accumulatedNegations.push([]);
|
|
4275
|
+
for (let i = 0; i < mediaKeys.length; i++) {
|
|
4276
|
+
const currentKey = mediaKeys[i];
|
|
4277
|
+
const currentValue = result[currentKey];
|
|
4278
|
+
const baseMediaQuery = _mediaQuery.MediaQuery.parser.parseToEnd(currentKey);
|
|
4279
|
+
const reversedNegations = [...accumulatedNegations[i]].reverse();
|
|
4280
|
+
const combinedQuery = combineMediaQueryWithNegations(baseMediaQuery, reversedNegations);
|
|
4281
|
+
const newMediaKey = combinedQuery.toString();
|
|
4282
|
+
delete result[currentKey];
|
|
4283
|
+
result[newMediaKey] = currentValue;
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
return result;
|
|
4287
|
+
}
|
|
4288
|
+
return mediaQueryTransform;
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
var hasRequiredLib;
|
|
4292
|
+
|
|
4293
|
+
function requireLib () {
|
|
4294
|
+
if (hasRequiredLib) return lib;
|
|
4295
|
+
hasRequiredLib = 1;
|
|
4296
|
+
(function (exports) {
|
|
4297
|
+
|
|
4298
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4299
|
+
value: true
|
|
4300
|
+
});
|
|
4301
|
+
Object.defineProperty(exports, "lastMediaQueryWinsTransform", {
|
|
4302
|
+
enumerable: true,
|
|
4303
|
+
get: function () {
|
|
4304
|
+
return _mediaQueryTransform.lastMediaQueryWinsTransform;
|
|
4305
|
+
}
|
|
4306
|
+
});
|
|
4307
|
+
exports.tokenParser = exports.properties = void 0;
|
|
4308
|
+
var _tokenParser = _interopRequireWildcard(requireTokenParser());
|
|
4309
|
+
exports.tokenParser = _tokenParser;
|
|
4310
|
+
var _properties = _interopRequireWildcard(requireProperties());
|
|
4311
|
+
exports.properties = _properties;
|
|
4312
|
+
var _mediaQueryTransform = requireMediaQueryTransform();
|
|
4313
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
4314
|
+
} (lib));
|
|
4315
|
+
return lib;
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4318
|
+
var libExports = requireLib();
|
|
4319
|
+
|
|
4320
|
+
const illegalArgumentLength = (fn, argLength) => `${fn}() should have ${argLength} argument${argLength === 1 ? '' : 's'}.`;
|
|
4321
|
+
const nonStaticValue = fn => `Only static values are allowed inside of a ${fn}() call.`;
|
|
4322
|
+
const nonStyleObject = fn => `${fn}() can only accept an object.`;
|
|
4323
|
+
const nonExportNamedDeclaration = fn => `The return value of ${fn}() must be bound to a named export.`;
|
|
4324
|
+
const unboundCallValue = fn => `${fn}() calls must be bound to a bare variable.`;
|
|
4325
|
+
const cannotGenerateHash = fn => `Unable to generate hash for ${fn}(). Check that the file has a valid extension and that unstable_moduleResolution is configured.`;
|
|
4326
|
+
const DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
4327
|
+
const ESCAPED_STYLEX_VALUE = 'Escaping a create() value is not allowed.';
|
|
4328
|
+
const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
|
|
4329
|
+
const ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
|
|
4330
|
+
const ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
|
|
4331
|
+
const ILLEGAL_NAMESPACE_VALUE = 'A StyleX namespace must be an object.';
|
|
4332
|
+
const INVALID_CONST_KEY = 'Keys in defineConsts() cannot start with "--".';
|
|
4333
|
+
const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
4334
|
+
const INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
|
|
4335
|
+
const INVALID_MEDIA_QUERY_SYNTAX = 'Invalid media query syntax.';
|
|
4336
|
+
const LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
|
|
4337
|
+
const LOCAL_ONLY = 'The return value of create() should not be exported.';
|
|
4338
|
+
const NON_OBJECT_KEYFRAME = 'Every frame within a keyframes() call must be an object.';
|
|
4339
|
+
const NON_CONTIGUOUS_VARS = 'All variables passed to firstThatWorks() must be contiguous.';
|
|
4340
|
+
const NO_OBJECT_SPREADS = 'Object spreads are not allowed in create() calls.';
|
|
4341
|
+
const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
|
|
4342
|
+
const ONLY_TOP_LEVEL = 'create() is only allowed at the root of a program.';
|
|
4343
|
+
const UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
4344
|
+
const POSITION_TRY_INVALID_PROPERTY = 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
|
|
4345
|
+
const VIEW_TRANSITION_CLASS_INVALID_PROPERTY = 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
|
|
4346
|
+
|
|
4347
|
+
var m = /*#__PURE__*/Object.freeze({
|
|
4348
|
+
__proto__: null,
|
|
4349
|
+
DUPLICATE_CONDITIONAL: DUPLICATE_CONDITIONAL,
|
|
4350
|
+
ESCAPED_STYLEX_VALUE: ESCAPED_STYLEX_VALUE,
|
|
4351
|
+
ILLEGAL_NAMESPACE_VALUE: ILLEGAL_NAMESPACE_VALUE,
|
|
4352
|
+
ILLEGAL_NESTED_PSEUDO: ILLEGAL_NESTED_PSEUDO,
|
|
4353
|
+
ILLEGAL_PROP_ARRAY_VALUE: ILLEGAL_PROP_ARRAY_VALUE,
|
|
4354
|
+
ILLEGAL_PROP_VALUE: ILLEGAL_PROP_VALUE,
|
|
4355
|
+
INVALID_CONST_KEY: INVALID_CONST_KEY,
|
|
4356
|
+
INVALID_MEDIA_QUERY_SYNTAX: INVALID_MEDIA_QUERY_SYNTAX,
|
|
4357
|
+
INVALID_PSEUDO: INVALID_PSEUDO,
|
|
4358
|
+
INVALID_PSEUDO_OR_AT_RULE: INVALID_PSEUDO_OR_AT_RULE,
|
|
4359
|
+
LINT_UNCLOSED_FUNCTION: LINT_UNCLOSED_FUNCTION,
|
|
4360
|
+
LOCAL_ONLY: LOCAL_ONLY,
|
|
4361
|
+
NON_CONTIGUOUS_VARS: NON_CONTIGUOUS_VARS,
|
|
4362
|
+
NON_OBJECT_KEYFRAME: NON_OBJECT_KEYFRAME,
|
|
4363
|
+
NO_OBJECT_SPREADS: NO_OBJECT_SPREADS,
|
|
4364
|
+
ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS,
|
|
4365
|
+
ONLY_TOP_LEVEL: ONLY_TOP_LEVEL,
|
|
4366
|
+
POSITION_TRY_INVALID_PROPERTY: POSITION_TRY_INVALID_PROPERTY,
|
|
4367
|
+
UNKNOWN_PROP_KEY: UNKNOWN_PROP_KEY,
|
|
4368
|
+
VIEW_TRANSITION_CLASS_INVALID_PROPERTY: VIEW_TRANSITION_CLASS_INVALID_PROPERTY,
|
|
4369
|
+
cannotGenerateHash: cannotGenerateHash,
|
|
4370
|
+
illegalArgumentLength: illegalArgumentLength,
|
|
4371
|
+
nonExportNamedDeclaration: nonExportNamedDeclaration,
|
|
4372
|
+
nonStaticValue: nonStaticValue,
|
|
4373
|
+
nonStyleObject: nonStyleObject,
|
|
4374
|
+
unboundCallValue: unboundCallValue
|
|
4375
|
+
});
|
|
2353
4376
|
|
|
2354
4377
|
function dashify(str) {
|
|
2355
4378
|
return str.replace(/(^|[a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
@@ -2499,61 +4522,6 @@ function normalizeZeroDimensions(ast, _) {
|
|
|
2499
4522
|
return ast;
|
|
2500
4523
|
}
|
|
2501
4524
|
|
|
2502
|
-
const illegalArgumentLength = (fn, argLength) => `${fn}() should have ${argLength} argument${argLength === 1 ? '' : 's'}.`;
|
|
2503
|
-
const nonStaticValue = fn => `Only static values are allowed inside of a ${fn}() call.`;
|
|
2504
|
-
const nonStyleObject = fn => `${fn}() can only accept an object.`;
|
|
2505
|
-
const nonExportNamedDeclaration = fn => `The return value of ${fn}() must be bound to a named export.`;
|
|
2506
|
-
const unboundCallValue = fn => `${fn}() calls must be bound to a bare variable.`;
|
|
2507
|
-
const cannotGenerateHash = fn => `Unable to generate hash for ${fn}(). Check that the file has a valid extension and that unstable_moduleResolution is configured.`;
|
|
2508
|
-
const DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
2509
|
-
const ESCAPED_STYLEX_VALUE = 'Escaping a create() value is not allowed.';
|
|
2510
|
-
const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
|
|
2511
|
-
const ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
|
|
2512
|
-
const ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
|
|
2513
|
-
const ILLEGAL_NAMESPACE_VALUE = 'A StyleX namespace must be an object.';
|
|
2514
|
-
const INVALID_CONST_KEY = 'Keys in defineConsts() cannot start with "--".';
|
|
2515
|
-
const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
2516
|
-
const INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
|
|
2517
|
-
const LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
|
|
2518
|
-
const LOCAL_ONLY = 'The return value of create() should not be exported.';
|
|
2519
|
-
const NON_OBJECT_KEYFRAME = 'Every frame within a keyframes() call must be an object.';
|
|
2520
|
-
const NON_CONTIGUOUS_VARS = 'All variables passed to firstThatWorks() must be contiguous.';
|
|
2521
|
-
const NO_OBJECT_SPREADS = 'Object spreads are not allowed in create() calls.';
|
|
2522
|
-
const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
|
|
2523
|
-
const ONLY_TOP_LEVEL = 'create() is only allowed at the root of a program.';
|
|
2524
|
-
const UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
2525
|
-
const POSITION_TRY_INVALID_PROPERTY = 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
|
|
2526
|
-
const VIEW_TRANSITION_CLASS_INVALID_PROPERTY = 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
|
|
2527
|
-
|
|
2528
|
-
var m = /*#__PURE__*/Object.freeze({
|
|
2529
|
-
__proto__: null,
|
|
2530
|
-
DUPLICATE_CONDITIONAL: DUPLICATE_CONDITIONAL,
|
|
2531
|
-
ESCAPED_STYLEX_VALUE: ESCAPED_STYLEX_VALUE,
|
|
2532
|
-
ILLEGAL_NAMESPACE_VALUE: ILLEGAL_NAMESPACE_VALUE,
|
|
2533
|
-
ILLEGAL_NESTED_PSEUDO: ILLEGAL_NESTED_PSEUDO,
|
|
2534
|
-
ILLEGAL_PROP_ARRAY_VALUE: ILLEGAL_PROP_ARRAY_VALUE,
|
|
2535
|
-
ILLEGAL_PROP_VALUE: ILLEGAL_PROP_VALUE,
|
|
2536
|
-
INVALID_CONST_KEY: INVALID_CONST_KEY,
|
|
2537
|
-
INVALID_PSEUDO: INVALID_PSEUDO,
|
|
2538
|
-
INVALID_PSEUDO_OR_AT_RULE: INVALID_PSEUDO_OR_AT_RULE,
|
|
2539
|
-
LINT_UNCLOSED_FUNCTION: LINT_UNCLOSED_FUNCTION,
|
|
2540
|
-
LOCAL_ONLY: LOCAL_ONLY,
|
|
2541
|
-
NON_CONTIGUOUS_VARS: NON_CONTIGUOUS_VARS,
|
|
2542
|
-
NON_OBJECT_KEYFRAME: NON_OBJECT_KEYFRAME,
|
|
2543
|
-
NO_OBJECT_SPREADS: NO_OBJECT_SPREADS,
|
|
2544
|
-
ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS: ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS,
|
|
2545
|
-
ONLY_TOP_LEVEL: ONLY_TOP_LEVEL,
|
|
2546
|
-
POSITION_TRY_INVALID_PROPERTY: POSITION_TRY_INVALID_PROPERTY,
|
|
2547
|
-
UNKNOWN_PROP_KEY: UNKNOWN_PROP_KEY,
|
|
2548
|
-
VIEW_TRANSITION_CLASS_INVALID_PROPERTY: VIEW_TRANSITION_CLASS_INVALID_PROPERTY,
|
|
2549
|
-
cannotGenerateHash: cannotGenerateHash,
|
|
2550
|
-
illegalArgumentLength: illegalArgumentLength,
|
|
2551
|
-
nonExportNamedDeclaration: nonExportNamedDeclaration,
|
|
2552
|
-
nonStaticValue: nonStaticValue,
|
|
2553
|
-
nonStyleObject: nonStyleObject,
|
|
2554
|
-
unboundCallValue: unboundCallValue
|
|
2555
|
-
});
|
|
2556
|
-
|
|
2557
4525
|
function detectUnclosedFns(ast, _) {
|
|
2558
4526
|
ast.walk(node => {
|
|
2559
4527
|
if (node.type === 'function' && node.unclosed) {
|
|
@@ -2580,10 +4548,9 @@ function convertCamelCasedValues(ast, key) {
|
|
|
2580
4548
|
}
|
|
2581
4549
|
|
|
2582
4550
|
const normalizers = [detectUnclosedFns, normalizeWhitespace, normalizeTimings, normalizeZeroDimensions, normalizeLeadingZero, normalizeQuotes, convertCamelCasedValues];
|
|
2583
|
-
function normalizeValue(value, key,
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
} = _ref;
|
|
4551
|
+
function normalizeValue(value, key, {
|
|
4552
|
+
enableFontSizePxToRem
|
|
4553
|
+
}) {
|
|
2587
4554
|
if (value == null) {
|
|
2588
4555
|
return value;
|
|
2589
4556
|
}
|
|
@@ -2640,177 +4607,53 @@ const logicalToPhysical$1 = {
|
|
|
2640
4607
|
'inline-end': 'right'
|
|
2641
4608
|
};
|
|
2642
4609
|
const legacyValuesPolyfill$1 = {
|
|
2643
|
-
float:
|
|
2644
|
-
|
|
2645
|
-
return [key, logicalToPhysical$1[val] ?? val];
|
|
2646
|
-
},
|
|
2647
|
-
clear: _ref2 => {
|
|
2648
|
-
let [key, val] = _ref2;
|
|
2649
|
-
return [key, logicalToPhysical$1[val] ?? val];
|
|
2650
|
-
}
|
|
4610
|
+
float: ([key, val]) => [key, logicalToPhysical$1[val] ?? val],
|
|
4611
|
+
clear: ([key, val]) => [key, logicalToPhysical$1[val] ?? val]
|
|
2651
4612
|
};
|
|
2652
4613
|
const inlinePropertyToLTR = {
|
|
2653
|
-
'margin-inline-start':
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
'
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
'
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
'
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
'
|
|
2670
|
-
|
|
2671
|
-
return ['border-left', val];
|
|
2672
|
-
},
|
|
2673
|
-
'border-inline-end': _ref8 => {
|
|
2674
|
-
let [_key, val] = _ref8;
|
|
2675
|
-
return ['border-right', val];
|
|
2676
|
-
},
|
|
2677
|
-
'border-inline-start-width': _ref9 => {
|
|
2678
|
-
let [_key, val] = _ref9;
|
|
2679
|
-
return ['border-left-width', val];
|
|
2680
|
-
},
|
|
2681
|
-
'border-inline-end-width': _ref0 => {
|
|
2682
|
-
let [_key, val] = _ref0;
|
|
2683
|
-
return ['border-right-width', val];
|
|
2684
|
-
},
|
|
2685
|
-
'border-inline-start-color': _ref1 => {
|
|
2686
|
-
let [_key, val] = _ref1;
|
|
2687
|
-
return ['border-left-color', val];
|
|
2688
|
-
},
|
|
2689
|
-
'border-inline-end-color': _ref10 => {
|
|
2690
|
-
let [_key, val] = _ref10;
|
|
2691
|
-
return ['border-right-color', val];
|
|
2692
|
-
},
|
|
2693
|
-
'border-inline-start-style': _ref11 => {
|
|
2694
|
-
let [_key, val] = _ref11;
|
|
2695
|
-
return ['border-left-style', val];
|
|
2696
|
-
},
|
|
2697
|
-
'border-inline-end-style': _ref12 => {
|
|
2698
|
-
let [_key, val] = _ref12;
|
|
2699
|
-
return ['border-right-style', val];
|
|
2700
|
-
},
|
|
2701
|
-
'border-start-start-radius': _ref13 => {
|
|
2702
|
-
let [_key, val] = _ref13;
|
|
2703
|
-
return ['border-top-left-radius', val];
|
|
2704
|
-
},
|
|
2705
|
-
'border-end-start-radius': _ref14 => {
|
|
2706
|
-
let [_key, val] = _ref14;
|
|
2707
|
-
return ['border-bottom-left-radius', val];
|
|
2708
|
-
},
|
|
2709
|
-
'border-start-end-radius': _ref15 => {
|
|
2710
|
-
let [_key, val] = _ref15;
|
|
2711
|
-
return ['border-top-right-radius', val];
|
|
2712
|
-
},
|
|
2713
|
-
'border-end-end-radius': _ref16 => {
|
|
2714
|
-
let [_key, val] = _ref16;
|
|
2715
|
-
return ['border-bottom-right-radius', val];
|
|
2716
|
-
},
|
|
2717
|
-
'inset-inline-start': _ref17 => {
|
|
2718
|
-
let [_key, val] = _ref17;
|
|
2719
|
-
return ['left', val];
|
|
2720
|
-
},
|
|
2721
|
-
'inset-inline-end': _ref18 => {
|
|
2722
|
-
let [_key, val] = _ref18;
|
|
2723
|
-
return ['right', val];
|
|
2724
|
-
}
|
|
4614
|
+
'margin-inline-start': ([_key, val]) => ['margin-left', val],
|
|
4615
|
+
'margin-inline-end': ([_key, val]) => ['margin-right', val],
|
|
4616
|
+
'padding-inline-start': ([_key, val]) => ['padding-left', val],
|
|
4617
|
+
'padding-inline-end': ([_key, val]) => ['padding-right', val],
|
|
4618
|
+
'border-inline-start': ([_key, val]) => ['border-left', val],
|
|
4619
|
+
'border-inline-end': ([_key, val]) => ['border-right', val],
|
|
4620
|
+
'border-inline-start-width': ([_key, val]) => ['border-left-width', val],
|
|
4621
|
+
'border-inline-end-width': ([_key, val]) => ['border-right-width', val],
|
|
4622
|
+
'border-inline-start-color': ([_key, val]) => ['border-left-color', val],
|
|
4623
|
+
'border-inline-end-color': ([_key, val]) => ['border-right-color', val],
|
|
4624
|
+
'border-inline-start-style': ([_key, val]) => ['border-left-style', val],
|
|
4625
|
+
'border-inline-end-style': ([_key, val]) => ['border-right-style', val],
|
|
4626
|
+
'border-start-start-radius': ([_key, val]) => ['border-top-left-radius', val],
|
|
4627
|
+
'border-end-start-radius': ([_key, val]) => ['border-bottom-left-radius', val],
|
|
4628
|
+
'border-start-end-radius': ([_key, val]) => ['border-top-right-radius', val],
|
|
4629
|
+
'border-end-end-radius': ([_key, val]) => ['border-bottom-right-radius', val],
|
|
4630
|
+
'inset-inline-start': ([_key, val]) => ['left', val],
|
|
4631
|
+
'inset-inline-end': ([_key, val]) => ['right', val]
|
|
2725
4632
|
};
|
|
2726
4633
|
const propertyToLTR = {
|
|
2727
|
-
'margin-start':
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
'
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
'
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
'
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
'
|
|
2748
|
-
let [_key, val] = _ref24;
|
|
2749
|
-
return ['border-right', val];
|
|
2750
|
-
},
|
|
2751
|
-
'border-start-width': _ref25 => {
|
|
2752
|
-
let [_key, val] = _ref25;
|
|
2753
|
-
return ['border-left-width', val];
|
|
2754
|
-
},
|
|
2755
|
-
'border-end-width': _ref26 => {
|
|
2756
|
-
let [_key, val] = _ref26;
|
|
2757
|
-
return ['border-right-width', val];
|
|
2758
|
-
},
|
|
2759
|
-
'border-start-color': _ref27 => {
|
|
2760
|
-
let [_key, val] = _ref27;
|
|
2761
|
-
return ['border-left-color', val];
|
|
2762
|
-
},
|
|
2763
|
-
'border-end-color': _ref28 => {
|
|
2764
|
-
let [_key, val] = _ref28;
|
|
2765
|
-
return ['border-right-color', val];
|
|
2766
|
-
},
|
|
2767
|
-
'border-start-style': _ref29 => {
|
|
2768
|
-
let [_key, val] = _ref29;
|
|
2769
|
-
return ['border-left-style', val];
|
|
2770
|
-
},
|
|
2771
|
-
'border-end-style': _ref30 => {
|
|
2772
|
-
let [_key, val] = _ref30;
|
|
2773
|
-
return ['border-right-style', val];
|
|
2774
|
-
},
|
|
2775
|
-
'border-top-start-radius': _ref31 => {
|
|
2776
|
-
let [_key, val] = _ref31;
|
|
2777
|
-
return ['border-top-left-radius', val];
|
|
2778
|
-
},
|
|
2779
|
-
'border-bottom-start-radius': _ref32 => {
|
|
2780
|
-
let [_key, val] = _ref32;
|
|
2781
|
-
return ['border-bottom-left-radius', val];
|
|
2782
|
-
},
|
|
2783
|
-
'border-top-end-radius': _ref33 => {
|
|
2784
|
-
let [_key, val] = _ref33;
|
|
2785
|
-
return ['border-top-right-radius', val];
|
|
2786
|
-
},
|
|
2787
|
-
'border-bottom-end-radius': _ref34 => {
|
|
2788
|
-
let [_key, val] = _ref34;
|
|
2789
|
-
return ['border-bottom-right-radius', val];
|
|
2790
|
-
},
|
|
2791
|
-
float: _ref35 => {
|
|
2792
|
-
let [key, val] = _ref35;
|
|
2793
|
-
return [key, logicalToPhysical$1[val] ?? val];
|
|
2794
|
-
},
|
|
2795
|
-
clear: _ref36 => {
|
|
2796
|
-
let [key, val] = _ref36;
|
|
2797
|
-
return [key, logicalToPhysical$1[val] ?? val];
|
|
2798
|
-
},
|
|
2799
|
-
start: _ref37 => {
|
|
2800
|
-
let [_key, val] = _ref37;
|
|
2801
|
-
return ['left', val];
|
|
2802
|
-
},
|
|
2803
|
-
end: _ref38 => {
|
|
2804
|
-
let [_key, val] = _ref38;
|
|
2805
|
-
return ['right', val];
|
|
2806
|
-
},
|
|
2807
|
-
'background-position': _ref39 => {
|
|
2808
|
-
let [key, val] = _ref39;
|
|
2809
|
-
return [key, val.split(' ').map(word => word === 'start' || word === 'insetInlineStart' ? 'left' : word === 'end' || word === 'insetInlineEnd' ? 'right' : word).join(' ')];
|
|
2810
|
-
}
|
|
4634
|
+
'margin-start': ([_key, val]) => ['margin-left', val],
|
|
4635
|
+
'margin-end': ([_key, val]) => ['margin-right', val],
|
|
4636
|
+
'padding-start': ([_key, val]) => ['padding-left', val],
|
|
4637
|
+
'padding-end': ([_key, val]) => ['padding-right', val],
|
|
4638
|
+
'border-start': ([_key, val]) => ['border-left', val],
|
|
4639
|
+
'border-end': ([_key, val]) => ['border-right', val],
|
|
4640
|
+
'border-start-width': ([_key, val]) => ['border-left-width', val],
|
|
4641
|
+
'border-end-width': ([_key, val]) => ['border-right-width', val],
|
|
4642
|
+
'border-start-color': ([_key, val]) => ['border-left-color', val],
|
|
4643
|
+
'border-end-color': ([_key, val]) => ['border-right-color', val],
|
|
4644
|
+
'border-start-style': ([_key, val]) => ['border-left-style', val],
|
|
4645
|
+
'border-end-style': ([_key, val]) => ['border-right-style', val],
|
|
4646
|
+
'border-top-start-radius': ([_key, val]) => ['border-top-left-radius', val],
|
|
4647
|
+
'border-bottom-start-radius': ([_key, val]) => ['border-bottom-left-radius', val],
|
|
4648
|
+
'border-top-end-radius': ([_key, val]) => ['border-top-right-radius', val],
|
|
4649
|
+
'border-bottom-end-radius': ([_key, val]) => ['border-bottom-right-radius', val],
|
|
4650
|
+
float: ([key, val]) => [key, logicalToPhysical$1[val] ?? val],
|
|
4651
|
+
clear: ([key, val]) => [key, logicalToPhysical$1[val] ?? val],
|
|
4652
|
+
start: ([_key, val]) => ['left', val],
|
|
4653
|
+
end: ([_key, val]) => ['right', val],
|
|
4654
|
+
'background-position': ([key, val]) => [key, val.split(' ').map(word => word === 'start' || word === 'insetInlineStart' ? 'left' : word === 'end' || word === 'insetInlineEnd' ? 'right' : word).join(' ')]
|
|
2811
4655
|
};
|
|
2812
|
-
function generateLTR(pair) {
|
|
2813
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
4656
|
+
function generateLTR(pair, options = defaultOptions) {
|
|
2814
4657
|
const {
|
|
2815
4658
|
enableLogicalStylesPolyfill,
|
|
2816
4659
|
styleResolution
|
|
@@ -2894,198 +4737,71 @@ const logicalToPhysical = {
|
|
|
2894
4737
|
'inline-end': 'left'
|
|
2895
4738
|
};
|
|
2896
4739
|
const legacyValuesPolyfill = {
|
|
2897
|
-
float:
|
|
2898
|
-
|
|
2899
|
-
return [key, logicalToPhysical[val] ?? val];
|
|
2900
|
-
},
|
|
2901
|
-
clear: _ref2 => {
|
|
2902
|
-
let [key, val] = _ref2;
|
|
2903
|
-
return [key, logicalToPhysical[val] ?? val];
|
|
2904
|
-
}
|
|
4740
|
+
float: ([key, val]) => [key, logicalToPhysical[val] ?? val],
|
|
4741
|
+
clear: ([key, val]) => [key, logicalToPhysical[val] ?? val]
|
|
2905
4742
|
};
|
|
2906
4743
|
const inlinePropertyToRTL = {
|
|
2907
|
-
'margin-inline-start':
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
'
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
'
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
'
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
'
|
|
2924
|
-
|
|
2925
|
-
return ['border-right', val];
|
|
2926
|
-
},
|
|
2927
|
-
'border-inline-end': _ref8 => {
|
|
2928
|
-
let [_key, val] = _ref8;
|
|
2929
|
-
return ['border-left', val];
|
|
2930
|
-
},
|
|
2931
|
-
'border-inline-start-width': _ref9 => {
|
|
2932
|
-
let [_key, val] = _ref9;
|
|
2933
|
-
return ['border-right-width', val];
|
|
2934
|
-
},
|
|
2935
|
-
'border-inline-end-width': _ref0 => {
|
|
2936
|
-
let [_key, val] = _ref0;
|
|
2937
|
-
return ['border-left-width', val];
|
|
2938
|
-
},
|
|
2939
|
-
'border-inline-start-color': _ref1 => {
|
|
2940
|
-
let [_key, val] = _ref1;
|
|
2941
|
-
return ['border-right-color', val];
|
|
2942
|
-
},
|
|
2943
|
-
'border-inline-end-color': _ref10 => {
|
|
2944
|
-
let [_key, val] = _ref10;
|
|
2945
|
-
return ['border-left-color', val];
|
|
2946
|
-
},
|
|
2947
|
-
'border-inline-start-style': _ref11 => {
|
|
2948
|
-
let [_key, val] = _ref11;
|
|
2949
|
-
return ['border-right-style', val];
|
|
2950
|
-
},
|
|
2951
|
-
'border-inline-end-style': _ref12 => {
|
|
2952
|
-
let [_key, val] = _ref12;
|
|
2953
|
-
return ['border-left-style', val];
|
|
2954
|
-
},
|
|
2955
|
-
'border-start-start-radius': _ref13 => {
|
|
2956
|
-
let [_key, val] = _ref13;
|
|
2957
|
-
return ['border-top-right-radius', val];
|
|
2958
|
-
},
|
|
2959
|
-
'border-end-start-radius': _ref14 => {
|
|
2960
|
-
let [_key, val] = _ref14;
|
|
2961
|
-
return ['border-bottom-right-radius', val];
|
|
2962
|
-
},
|
|
2963
|
-
'border-start-end-radius': _ref15 => {
|
|
2964
|
-
let [_key, val] = _ref15;
|
|
2965
|
-
return ['border-top-left-radius', val];
|
|
2966
|
-
},
|
|
2967
|
-
'border-end-end-radius': _ref16 => {
|
|
2968
|
-
let [_key, val] = _ref16;
|
|
2969
|
-
return ['border-bottom-left-radius', val];
|
|
2970
|
-
},
|
|
2971
|
-
'inset-inline-start': _ref17 => {
|
|
2972
|
-
let [_key, val] = _ref17;
|
|
2973
|
-
return ['right', val];
|
|
2974
|
-
},
|
|
2975
|
-
'inset-inline-end': _ref18 => {
|
|
2976
|
-
let [_key, val] = _ref18;
|
|
2977
|
-
return ['left', val];
|
|
2978
|
-
}
|
|
4744
|
+
'margin-inline-start': ([_key, val]) => ['margin-right', val],
|
|
4745
|
+
'margin-inline-end': ([_key, val]) => ['margin-left', val],
|
|
4746
|
+
'padding-inline-start': ([_key, val]) => ['padding-right', val],
|
|
4747
|
+
'padding-inline-end': ([_key, val]) => ['padding-left', val],
|
|
4748
|
+
'border-inline-start': ([_key, val]) => ['border-right', val],
|
|
4749
|
+
'border-inline-end': ([_key, val]) => ['border-left', val],
|
|
4750
|
+
'border-inline-start-width': ([_key, val]) => ['border-right-width', val],
|
|
4751
|
+
'border-inline-end-width': ([_key, val]) => ['border-left-width', val],
|
|
4752
|
+
'border-inline-start-color': ([_key, val]) => ['border-right-color', val],
|
|
4753
|
+
'border-inline-end-color': ([_key, val]) => ['border-left-color', val],
|
|
4754
|
+
'border-inline-start-style': ([_key, val]) => ['border-right-style', val],
|
|
4755
|
+
'border-inline-end-style': ([_key, val]) => ['border-left-style', val],
|
|
4756
|
+
'border-start-start-radius': ([_key, val]) => ['border-top-right-radius', val],
|
|
4757
|
+
'border-end-start-radius': ([_key, val]) => ['border-bottom-right-radius', val],
|
|
4758
|
+
'border-start-end-radius': ([_key, val]) => ['border-top-left-radius', val],
|
|
4759
|
+
'border-end-end-radius': ([_key, val]) => ['border-bottom-left-radius', val],
|
|
4760
|
+
'inset-inline-start': ([_key, val]) => ['right', val],
|
|
4761
|
+
'inset-inline-end': ([_key, val]) => ['left', val]
|
|
2979
4762
|
};
|
|
2980
4763
|
const propertyToRTL = {
|
|
2981
|
-
'margin-start':
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
'
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
'
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
'
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
'
|
|
3002
|
-
let [_key, val] = _ref24;
|
|
3003
|
-
return ['border-left', val];
|
|
3004
|
-
},
|
|
3005
|
-
'border-start-width': _ref25 => {
|
|
3006
|
-
let [_key, val] = _ref25;
|
|
3007
|
-
return ['border-right-width', val];
|
|
3008
|
-
},
|
|
3009
|
-
'border-end-width': _ref26 => {
|
|
3010
|
-
let [_key, val] = _ref26;
|
|
3011
|
-
return ['border-left-width', val];
|
|
3012
|
-
},
|
|
3013
|
-
'border-start-color': _ref27 => {
|
|
3014
|
-
let [_key, val] = _ref27;
|
|
3015
|
-
return ['border-right-color', val];
|
|
3016
|
-
},
|
|
3017
|
-
'border-end-color': _ref28 => {
|
|
3018
|
-
let [_key, val] = _ref28;
|
|
3019
|
-
return ['border-left-color', val];
|
|
3020
|
-
},
|
|
3021
|
-
'border-start-style': _ref29 => {
|
|
3022
|
-
let [_key, val] = _ref29;
|
|
3023
|
-
return ['border-right-style', val];
|
|
3024
|
-
},
|
|
3025
|
-
'border-end-style': _ref30 => {
|
|
3026
|
-
let [_key, val] = _ref30;
|
|
3027
|
-
return ['border-left-style', val];
|
|
3028
|
-
},
|
|
3029
|
-
'border-top-start-radius': _ref31 => {
|
|
3030
|
-
let [_key, val] = _ref31;
|
|
3031
|
-
return ['border-top-right-radius', val];
|
|
3032
|
-
},
|
|
3033
|
-
'border-bottom-start-radius': _ref32 => {
|
|
3034
|
-
let [_key, val] = _ref32;
|
|
3035
|
-
return ['border-bottom-right-radius', val];
|
|
3036
|
-
},
|
|
3037
|
-
'border-top-end-radius': _ref33 => {
|
|
3038
|
-
let [_key, val] = _ref33;
|
|
3039
|
-
return ['border-top-left-radius', val];
|
|
3040
|
-
},
|
|
3041
|
-
'border-bottom-end-radius': _ref34 => {
|
|
3042
|
-
let [_key, val] = _ref34;
|
|
3043
|
-
return ['border-bottom-left-radius', val];
|
|
3044
|
-
},
|
|
3045
|
-
float: _ref35 => {
|
|
3046
|
-
let [key, val] = _ref35;
|
|
3047
|
-
return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
|
|
3048
|
-
},
|
|
3049
|
-
clear: _ref36 => {
|
|
3050
|
-
let [key, val] = _ref36;
|
|
3051
|
-
return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
|
|
3052
|
-
},
|
|
3053
|
-
start: _ref37 => {
|
|
3054
|
-
let [_key, val] = _ref37;
|
|
3055
|
-
return ['right', val];
|
|
3056
|
-
},
|
|
3057
|
-
end: _ref38 => {
|
|
3058
|
-
let [_key, val] = _ref38;
|
|
3059
|
-
return ['left', val];
|
|
3060
|
-
},
|
|
3061
|
-
'background-position': _ref39 => {
|
|
3062
|
-
let [key, val] = _ref39;
|
|
4764
|
+
'margin-start': ([_key, val]) => ['margin-right', val],
|
|
4765
|
+
'margin-end': ([_key, val]) => ['margin-left', val],
|
|
4766
|
+
'padding-start': ([_key, val]) => ['padding-right', val],
|
|
4767
|
+
'padding-end': ([_key, val]) => ['padding-left', val],
|
|
4768
|
+
'border-start': ([_key, val]) => ['border-right', val],
|
|
4769
|
+
'border-end': ([_key, val]) => ['border-left', val],
|
|
4770
|
+
'border-start-width': ([_key, val]) => ['border-right-width', val],
|
|
4771
|
+
'border-end-width': ([_key, val]) => ['border-left-width', val],
|
|
4772
|
+
'border-start-color': ([_key, val]) => ['border-right-color', val],
|
|
4773
|
+
'border-end-color': ([_key, val]) => ['border-left-color', val],
|
|
4774
|
+
'border-start-style': ([_key, val]) => ['border-right-style', val],
|
|
4775
|
+
'border-end-style': ([_key, val]) => ['border-left-style', val],
|
|
4776
|
+
'border-top-start-radius': ([_key, val]) => ['border-top-right-radius', val],
|
|
4777
|
+
'border-bottom-start-radius': ([_key, val]) => ['border-bottom-right-radius', val],
|
|
4778
|
+
'border-top-end-radius': ([_key, val]) => ['border-top-left-radius', val],
|
|
4779
|
+
'border-bottom-end-radius': ([_key, val]) => ['border-bottom-left-radius', val],
|
|
4780
|
+
float: ([key, val]) => logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null,
|
|
4781
|
+
clear: ([key, val]) => logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null,
|
|
4782
|
+
start: ([_key, val]) => ['right', val],
|
|
4783
|
+
end: ([_key, val]) => ['left', val],
|
|
4784
|
+
'background-position': ([key, val]) => {
|
|
3063
4785
|
const words = val.split(' ');
|
|
3064
4786
|
if (!words.includes('start') && !words.includes('end')) {
|
|
3065
4787
|
return null;
|
|
3066
4788
|
}
|
|
3067
4789
|
return [key, words.map(word => word === 'start' || word === 'insetInlineStart' ? 'right' : word === 'end' || word === 'insetInlineEnd' ? 'left' : word).join(' ')];
|
|
3068
4790
|
},
|
|
3069
|
-
cursor:
|
|
3070
|
-
let [key, val] = _ref40;
|
|
3071
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
4791
|
+
cursor: ([key, val], options = defaultOptions) => {
|
|
3072
4792
|
if (!options.enableLegacyValueFlipping) {
|
|
3073
4793
|
return null;
|
|
3074
4794
|
}
|
|
3075
4795
|
return cursorFlip[val] != null ? [key, cursorFlip[val]] : null;
|
|
3076
4796
|
},
|
|
3077
|
-
'box-shadow':
|
|
3078
|
-
let [key, val] = _ref41;
|
|
3079
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
4797
|
+
'box-shadow': ([key, val], options = defaultOptions) => {
|
|
3080
4798
|
if (!options.enableLegacyValueFlipping) {
|
|
3081
4799
|
return null;
|
|
3082
4800
|
}
|
|
3083
4801
|
const rtlVal = flipShadow(val);
|
|
3084
4802
|
return rtlVal ? [key, rtlVal] : null;
|
|
3085
4803
|
},
|
|
3086
|
-
'text-shadow':
|
|
3087
|
-
let [key, val] = _ref42;
|
|
3088
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
4804
|
+
'text-shadow': ([key, val], options = defaultOptions) => {
|
|
3089
4805
|
if (!options.enableLegacyValueFlipping) {
|
|
3090
4806
|
return null;
|
|
3091
4807
|
}
|
|
@@ -3093,8 +4809,7 @@ const propertyToRTL = {
|
|
|
3093
4809
|
return rtlVal ? [key, rtlVal] : null;
|
|
3094
4810
|
}
|
|
3095
4811
|
};
|
|
3096
|
-
function generateRTL(pair) {
|
|
3097
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
4812
|
+
function generateRTL(pair, options = defaultOptions) {
|
|
3098
4813
|
const {
|
|
3099
4814
|
enableLogicalStylesPolyfill,
|
|
3100
4815
|
styleResolution
|
|
@@ -3659,8 +5374,7 @@ function buildNestedCSSRule(className, decls, pseudos, atRules, constRules) {
|
|
|
3659
5374
|
}
|
|
3660
5375
|
return combinedAtRules.reduce((acc, combinedAtRules) => `${combinedAtRules}{${acc}}`, `${selectorForAtRules}{${decls}}`);
|
|
3661
5376
|
}
|
|
3662
|
-
function generateCSSRule(className, key, value, pseudos, atRules, constRules) {
|
|
3663
|
-
let options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultOptions;
|
|
5377
|
+
function generateCSSRule(className, key, value, pseudos, atRules, constRules, options = defaultOptions) {
|
|
3664
5378
|
const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
|
|
3665
5379
|
const ltrPairs = pairs.map(pair => generateLTR(pair, options));
|
|
3666
5380
|
const ltrDecls = ltrPairs.map(pair => pair.join(':')).join(';');
|
|
@@ -3693,22 +5407,13 @@ function objFromEntries(entries) {
|
|
|
3693
5407
|
return retVal;
|
|
3694
5408
|
}
|
|
3695
5409
|
function objMapKeys(obj, mapper) {
|
|
3696
|
-
return objFromEntries(objEntries(obj).map(
|
|
3697
|
-
let [key, value] = _ref;
|
|
3698
|
-
return [mapper(key), value];
|
|
3699
|
-
}));
|
|
5410
|
+
return objFromEntries(objEntries(obj).map(([key, value]) => [mapper(key), value]));
|
|
3700
5411
|
}
|
|
3701
5412
|
function objMapEntry(obj, mapper) {
|
|
3702
|
-
return objFromEntries(objEntries(obj).map(
|
|
3703
|
-
let [key, value] = _ref2;
|
|
3704
|
-
return mapper([key, value]);
|
|
3705
|
-
}));
|
|
5413
|
+
return objFromEntries(objEntries(obj).map(([key, value]) => mapper([key, value])));
|
|
3706
5414
|
}
|
|
3707
5415
|
function objMap(obj, mapper) {
|
|
3708
|
-
return objFromEntries(objEntries(obj).map(
|
|
3709
|
-
let [key, value] = _ref3;
|
|
3710
|
-
return [key, mapper(value, key)];
|
|
3711
|
-
}));
|
|
5416
|
+
return objFromEntries(objEntries(obj).map(([key, value]) => [key, mapper(value, key)]));
|
|
3712
5417
|
}
|
|
3713
5418
|
class Pipe {
|
|
3714
5419
|
constructor(val) {
|
|
@@ -3725,8 +5430,7 @@ class Pipe {
|
|
|
3725
5430
|
}
|
|
3726
5431
|
}
|
|
3727
5432
|
const arraySort = (arr, fn) => [...arr].sort(fn);
|
|
3728
|
-
const arrayEquals =
|
|
3729
|
-
let equals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (a, b) => a === b;
|
|
5433
|
+
const arrayEquals = (arr1, arr2, equals = (a, b) => a === b) => {
|
|
3730
5434
|
if (arr1.length !== arr2.length) {
|
|
3731
5435
|
return false;
|
|
3732
5436
|
}
|
|
@@ -3771,8 +5475,7 @@ const stringComparator = (a, b) => {
|
|
|
3771
5475
|
return a.localeCompare(b);
|
|
3772
5476
|
};
|
|
3773
5477
|
|
|
3774
|
-
function convertStyleToClassName(objEntry, pseudos, atRules, constRules) {
|
|
3775
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : defaultOptions;
|
|
5478
|
+
function convertStyleToClassName(objEntry, pseudos, atRules, constRules, options = defaultOptions) {
|
|
3776
5479
|
const {
|
|
3777
5480
|
classNamePrefix = 'x',
|
|
3778
5481
|
debug = false,
|
|
@@ -3807,10 +5510,7 @@ function variableFallbacks(values) {
|
|
|
3807
5510
|
varValues = varValues.map(val => val.slice(4, -1));
|
|
3808
5511
|
return [...(valuesBeforeFirstVar.length > 0 ? valuesBeforeFirstVar.map(val => composeVars(...varValues, val)) : [composeVars(...varValues)]), ...valuesAfterLastVar];
|
|
3809
5512
|
}
|
|
3810
|
-
function composeVars() {
|
|
3811
|
-
for (var _len = arguments.length, vars = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3812
|
-
vars[_key] = arguments[_key];
|
|
3813
|
-
}
|
|
5513
|
+
function composeVars(...vars) {
|
|
3814
5514
|
const [first, ...rest] = vars;
|
|
3815
5515
|
if (rest.length > 0) {
|
|
3816
5516
|
return `var(${first},${composeVars(...rest)})`;
|
|
@@ -3890,7 +5590,13 @@ class PreRuleSet {
|
|
|
3890
5590
|
}
|
|
3891
5591
|
|
|
3892
5592
|
function flattenRawStyleObject(style, options) {
|
|
3893
|
-
|
|
5593
|
+
let processedStyle = style;
|
|
5594
|
+
try {
|
|
5595
|
+
processedStyle = options.enableMediaQueryOrder ? libExports.lastMediaQueryWinsTransform(style) : style;
|
|
5596
|
+
} catch (error) {
|
|
5597
|
+
throw new Error(INVALID_MEDIA_QUERY_SYNTAX);
|
|
5598
|
+
}
|
|
5599
|
+
return _flattenRawStyleObject(processedStyle, [], options);
|
|
3894
5600
|
}
|
|
3895
5601
|
function _flattenRawStyleObject(style, keyPath, options) {
|
|
3896
5602
|
const flattened = [];
|
|
@@ -3926,14 +5632,7 @@ function _flattenRawStyleObject(style, keyPath, options) {
|
|
|
3926
5632
|
}
|
|
3927
5633
|
}
|
|
3928
5634
|
}
|
|
3929
|
-
Object.entries(equivalentPairs).map(
|
|
3930
|
-
let [property, values] = _ref;
|
|
3931
|
-
return [property, [...new Set(values.filter(Boolean))]];
|
|
3932
|
-
}).map(_ref2 => {
|
|
3933
|
-
let [property, values] = _ref2;
|
|
3934
|
-
return [property, values.length === 0 ? null : values.length === 1 ? values[0] : values];
|
|
3935
|
-
}).forEach(_ref3 => {
|
|
3936
|
-
let [property, value] = _ref3;
|
|
5635
|
+
Object.entries(equivalentPairs).map(([property, values]) => [property, [...new Set(values.filter(Boolean))]]).map(([property, values]) => [property, values.length === 0 ? null : values.length === 1 ? values[0] : values]).forEach(([property, value]) => {
|
|
3937
5636
|
if (value === null) {
|
|
3938
5637
|
flattened.push([property, new NullPreRule()]);
|
|
3939
5638
|
} else {
|
|
@@ -3978,8 +5677,7 @@ function _flattenRawStyleObject(style, keyPath, options) {
|
|
|
3978
5677
|
return flattened;
|
|
3979
5678
|
}
|
|
3980
5679
|
|
|
3981
|
-
function validateNamespace(namespace) {
|
|
3982
|
-
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
5680
|
+
function validateNamespace(namespace, conditions = []) {
|
|
3983
5681
|
if (!isPlainObject(namespace)) {
|
|
3984
5682
|
throw new Error(ILLEGAL_NAMESPACE_VALUE);
|
|
3985
5683
|
}
|
|
@@ -4012,8 +5710,7 @@ function validateNamespace(namespace) {
|
|
|
4012
5710
|
throw new Error(ILLEGAL_PROP_VALUE);
|
|
4013
5711
|
}
|
|
4014
5712
|
}
|
|
4015
|
-
function validateConditionalStyles(val) {
|
|
4016
|
-
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
5713
|
+
function validateConditionalStyles(val, conditions = []) {
|
|
4017
5714
|
for (const key in val) {
|
|
4018
5715
|
const v = val[key];
|
|
4019
5716
|
if (!(key.startsWith('@') || key.startsWith(':') || key.startsWith('var(--') || key === 'default')) {
|
|
@@ -4042,8 +5739,7 @@ function validateConditionalStyles(val) {
|
|
|
4042
5739
|
}
|
|
4043
5740
|
}
|
|
4044
5741
|
|
|
4045
|
-
function styleXCreateSet(namespaces) {
|
|
4046
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
5742
|
+
function styleXCreateSet(namespaces, options = defaultOptions) {
|
|
4047
5743
|
const resolvedNamespaces = {};
|
|
4048
5744
|
const injectedStyles = {};
|
|
4049
5745
|
const namespaceToClassPaths = {};
|
|
@@ -4060,8 +5756,7 @@ function styleXCreateSet(namespaces) {
|
|
|
4060
5756
|
arr.unshift(curr);
|
|
4061
5757
|
return arr;
|
|
4062
5758
|
}, []);
|
|
4063
|
-
const compiledNamespaceTuples = flattenedNamespace.map(
|
|
4064
|
-
let [key, value] = _ref;
|
|
5759
|
+
const compiledNamespaceTuples = flattenedNamespace.map(([key, value]) => {
|
|
4065
5760
|
if (options.enableMinifiedKeys === true && !key.startsWith('--')) {
|
|
4066
5761
|
const hashedKey = createShortHash('<>' + key);
|
|
4067
5762
|
const displayKey = options.debug === true ? `${key}-k${hashedKey}` : `k${hashedKey}`;
|
|
@@ -4073,14 +5768,10 @@ function styleXCreateSet(namespaces) {
|
|
|
4073
5768
|
const namespaceObj = {};
|
|
4074
5769
|
for (const [key, value] of compiledNamespaceTuples) {
|
|
4075
5770
|
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
|
4076
|
-
classNameTuples.forEach(
|
|
4077
|
-
let [_className, _, classesToOriginalPath] = _ref2;
|
|
5771
|
+
classNameTuples.forEach(([_className, _, classesToOriginalPath]) => {
|
|
4078
5772
|
Object.assign(classPathsInNamespace, classesToOriginalPath);
|
|
4079
5773
|
});
|
|
4080
|
-
const classNames = classNameTuples.map(
|
|
4081
|
-
let [className] = _ref3;
|
|
4082
|
-
return className;
|
|
4083
|
-
});
|
|
5774
|
+
const classNames = classNameTuples.map(([className]) => className);
|
|
4084
5775
|
const uniqueClassNames = new Set(classNames);
|
|
4085
5776
|
const className = Array.from(uniqueClassNames).join(' ');
|
|
4086
5777
|
namespaceObj[key] = className !== '' ? className : null;
|
|
@@ -4259,13 +5950,10 @@ var stylexTypes = /*#__PURE__*/Object.freeze({
|
|
|
4259
5950
|
});
|
|
4260
5951
|
|
|
4261
5952
|
const SPLIT_TOKEN = '__$$__';
|
|
4262
|
-
function collectVarsByAtRule(key,
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
} = _ref;
|
|
4267
|
-
let collection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4268
|
-
let atRules = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
5953
|
+
function collectVarsByAtRule(key, {
|
|
5954
|
+
nameHash,
|
|
5955
|
+
value
|
|
5956
|
+
}, collection = {}, atRules = []) {
|
|
4269
5957
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
4270
5958
|
const val = typeof value === 'number' ? value.toString() : value;
|
|
4271
5959
|
const key = atRules.length === 0 ? 'default' : [...atRules].sort().join(SPLIT_TOKEN);
|
|
@@ -4350,24 +6038,18 @@ function styleXDefineVars(variables, options) {
|
|
|
4350
6038
|
value: value
|
|
4351
6039
|
};
|
|
4352
6040
|
});
|
|
4353
|
-
const themeVariablesObject = objMap(variablesMap,
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
} = _ref;
|
|
4357
|
-
return `var(--${nameHash})`;
|
|
4358
|
-
});
|
|
6041
|
+
const themeVariablesObject = objMap(variablesMap, ({
|
|
6042
|
+
nameHash
|
|
6043
|
+
}) => `var(--${nameHash})`);
|
|
4359
6044
|
const injectableStyles = constructCssVariablesString(variablesMap, varGroupHash);
|
|
4360
|
-
const injectableTypes = objMap(typedVariables, (
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
priority: 0
|
|
4369
|
-
};
|
|
4370
|
-
});
|
|
6045
|
+
const injectableTypes = objMap(typedVariables, ({
|
|
6046
|
+
initialValue: iv,
|
|
6047
|
+
syntax
|
|
6048
|
+
}, nameHash) => ({
|
|
6049
|
+
ltr: `@property --${nameHash} { syntax: "${syntax}"; inherits: true;${iv != null ? ` initial-value: ${iv}` : ''} }`,
|
|
6050
|
+
rtl: null,
|
|
6051
|
+
priority: 0
|
|
6052
|
+
}));
|
|
4371
6053
|
return [{
|
|
4372
6054
|
...themeVariablesObject,
|
|
4373
6055
|
__varGroupHash__: varGroupHash
|
|
@@ -4482,8 +6164,7 @@ function styleXCreateTheme(themeVars, variables, options) {
|
|
|
4482
6164
|
}, stylesToInject];
|
|
4483
6165
|
}
|
|
4484
6166
|
|
|
4485
|
-
function styleXKeyframes(frames) {
|
|
4486
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
6167
|
+
function styleXKeyframes(frames, options = defaultOptions) {
|
|
4487
6168
|
const {
|
|
4488
6169
|
classNamePrefix = 'x'
|
|
4489
6170
|
} = options;
|
|
@@ -4502,29 +6183,18 @@ function styleXKeyframes(frames) {
|
|
|
4502
6183
|
}];
|
|
4503
6184
|
}
|
|
4504
6185
|
function expandFrameShorthands(frame, options) {
|
|
4505
|
-
return objFromEntries(objEntries(frame).flatMap(pair => flatMapExpandedShorthands(pair, options).map(
|
|
4506
|
-
let [key, value] = _ref;
|
|
6186
|
+
return objFromEntries(objEntries(frame).flatMap(pair => flatMapExpandedShorthands(pair, options).map(([key, value]) => {
|
|
4507
6187
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
4508
6188
|
return [key, value];
|
|
4509
6189
|
}
|
|
4510
6190
|
return null;
|
|
4511
|
-
}).filter(Boolean)).filter(
|
|
4512
|
-
let [_key, value] = _ref2;
|
|
4513
|
-
return value != null;
|
|
4514
|
-
}));
|
|
6191
|
+
}).filter(Boolean)).filter(([_key, value]) => value != null));
|
|
4515
6192
|
}
|
|
4516
6193
|
function constructKeyframesObj(frames) {
|
|
4517
|
-
return objEntries(frames).map(
|
|
4518
|
-
let [key, value] = _ref3;
|
|
4519
|
-
return `${key}{${objEntries(value).map(_ref4 => {
|
|
4520
|
-
let [k, v] = _ref4;
|
|
4521
|
-
return `${k}:${v};`;
|
|
4522
|
-
}).join('')}}`;
|
|
4523
|
-
}).join('');
|
|
6194
|
+
return objEntries(frames).map(([key, value]) => `${key}{${objEntries(value).map(([k, v]) => `${k}:${v};`).join('')}}`).join('');
|
|
4524
6195
|
}
|
|
4525
6196
|
|
|
4526
|
-
function styleXPositionTry(styles) {
|
|
4527
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
6197
|
+
function styleXPositionTry(styles, options = defaultOptions) {
|
|
4528
6198
|
const {
|
|
4529
6199
|
classNamePrefix = 'x'
|
|
4530
6200
|
} = options;
|
|
@@ -4543,16 +6213,12 @@ function styleXPositionTry(styles) {
|
|
|
4543
6213
|
}];
|
|
4544
6214
|
}
|
|
4545
6215
|
function preprocessProperties$1(styles, options) {
|
|
4546
|
-
return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(
|
|
4547
|
-
let [key, value] = _ref;
|
|
6216
|
+
return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(([key, value]) => {
|
|
4548
6217
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
4549
6218
|
return [key, value];
|
|
4550
6219
|
}
|
|
4551
6220
|
return null;
|
|
4552
|
-
}).filter(Boolean)).filter(
|
|
4553
|
-
let [_key, value] = _ref2;
|
|
4554
|
-
return value != null;
|
|
4555
|
-
}));
|
|
6221
|
+
}).filter(Boolean)).filter(([_key, value]) => value != null));
|
|
4556
6222
|
}
|
|
4557
6223
|
function constructPositionTryObj(styles) {
|
|
4558
6224
|
return Object.keys(styles).sort().map(k => {
|
|
@@ -4562,10 +6228,7 @@ function constructPositionTryObj(styles) {
|
|
|
4562
6228
|
}
|
|
4563
6229
|
|
|
4564
6230
|
const isVar = arg => typeof arg === 'string' && arg.match(/^var\(--[a-zA-Z0-9-_]+\)$/);
|
|
4565
|
-
function stylexFirstThatWorks() {
|
|
4566
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4567
|
-
args[_key] = arguments[_key];
|
|
4568
|
-
}
|
|
6231
|
+
function stylexFirstThatWorks(...args) {
|
|
4569
6232
|
const firstVar = args.findIndex(isVar);
|
|
4570
6233
|
if (firstVar === -1) {
|
|
4571
6234
|
return [...args].reverse();
|
|
@@ -4582,12 +6245,11 @@ function stylexFirstThatWorks() {
|
|
|
4582
6245
|
return returnValue;
|
|
4583
6246
|
}
|
|
4584
6247
|
|
|
4585
|
-
function genFileBasedIdentifier(
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
} = _ref;
|
|
6248
|
+
function genFileBasedIdentifier({
|
|
6249
|
+
fileName,
|
|
6250
|
+
exportName,
|
|
6251
|
+
key
|
|
6252
|
+
}) {
|
|
4591
6253
|
return `${fileName}//${exportName}${key != null ? `.${key}` : ''}`;
|
|
4592
6254
|
}
|
|
4593
6255
|
|
|
@@ -4693,10 +6355,7 @@ function convertToTestStyles(obj, varName, state) {
|
|
|
4693
6355
|
}
|
|
4694
6356
|
|
|
4695
6357
|
function convertObjectToAST(obj) {
|
|
4696
|
-
return t__namespace.objectExpression(Object.entries(obj).map(
|
|
4697
|
-
let [key, value] = _ref;
|
|
4698
|
-
return t__namespace.objectProperty(canBeIdentifier(key) ? t__namespace.identifier(key) : t__namespace.stringLiteral(key), typeof value === 'string' ? t__namespace.stringLiteral(value) : typeof value === 'number' ? t__namespace.numericLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value));
|
|
4699
|
-
}));
|
|
6358
|
+
return t__namespace.objectExpression(Object.entries(obj).map(([key, value]) => t__namespace.objectProperty(canBeIdentifier(key) ? t__namespace.identifier(key) : t__namespace.stringLiteral(key), typeof value === 'string' ? t__namespace.stringLiteral(value) : typeof value === 'number' ? t__namespace.numericLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value))));
|
|
4700
6359
|
}
|
|
4701
6360
|
function removeObjectsWithSpreads(obj) {
|
|
4702
6361
|
return Object.fromEntries(Object.entries(obj).filter(Boolean));
|
|
@@ -4863,10 +6522,7 @@ function _evaluate(path, state) {
|
|
|
4863
6522
|
const identParams = params.filter(param => param.isIdentifier()).map(paramPath => paramPath.node.name);
|
|
4864
6523
|
if (body.isExpression() && identParams.length === params.length) {
|
|
4865
6524
|
const expr = body;
|
|
4866
|
-
return
|
|
4867
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4868
|
-
args[_key] = arguments[_key];
|
|
4869
|
-
}
|
|
6525
|
+
return (...args) => {
|
|
4870
6526
|
const identifierEntries = identParams.map((ident, index) => [ident, args[index]]);
|
|
4871
6527
|
const identifiersObj = Object.fromEntries(identifierEntries);
|
|
4872
6528
|
const result = evaluate(expr, state.traversalState, {
|
|
@@ -5291,8 +6947,7 @@ function _evaluate(path, state) {
|
|
|
5291
6947
|
}
|
|
5292
6948
|
deopt(path, state, UNSUPPORTED_EXPRESSION(path.node.type));
|
|
5293
6949
|
}
|
|
5294
|
-
function evaluateQuasis(path, quasis, state) {
|
|
5295
|
-
let raw = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
6950
|
+
function evaluateQuasis(path, quasis, state, raw = false) {
|
|
5296
6951
|
let str = '';
|
|
5297
6952
|
let i = 0;
|
|
5298
6953
|
const exprs = path.isTemplateLiteral() ? path.get('expressions') : path.isTaggedTemplateExpression() ? path.get('quasi').get('expressions') : [];
|
|
@@ -5306,12 +6961,10 @@ function evaluateQuasis(path, quasis, state) {
|
|
|
5306
6961
|
return str;
|
|
5307
6962
|
}
|
|
5308
6963
|
const importsForState = new WeakMap();
|
|
5309
|
-
function evaluate(path, traversalState
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
};
|
|
5314
|
-
let seen = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Map();
|
|
6964
|
+
function evaluate(path, traversalState, functions = {
|
|
6965
|
+
identifiers: {},
|
|
6966
|
+
memberExpressions: {}
|
|
6967
|
+
}, seen = new Map()) {
|
|
5315
6968
|
const addedImports = importsForState.get(traversalState) ?? new Set();
|
|
5316
6969
|
importsForState.set(traversalState, addedImports);
|
|
5317
6970
|
const state = {
|
|
@@ -5332,11 +6985,10 @@ function evaluate(path, traversalState) {
|
|
|
5332
6985
|
};
|
|
5333
6986
|
}
|
|
5334
6987
|
|
|
5335
|
-
function evaluateStyleXCreateArg(path, traversalState
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
};
|
|
6988
|
+
function evaluateStyleXCreateArg(path, traversalState, functions = {
|
|
6989
|
+
identifiers: {},
|
|
6990
|
+
memberExpressions: {}
|
|
6991
|
+
}) {
|
|
5340
6992
|
if (!path.isObjectExpression()) {
|
|
5341
6993
|
return evaluate(path, traversalState, functions);
|
|
5342
6994
|
}
|
|
@@ -5400,12 +7052,10 @@ function evaluateStyleXCreateArg(path, traversalState) {
|
|
|
5400
7052
|
fns
|
|
5401
7053
|
};
|
|
5402
7054
|
}
|
|
5403
|
-
function evaluatePartialObjectRecursively(path, traversalState
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
};
|
|
5408
|
-
let keyPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
7055
|
+
function evaluatePartialObjectRecursively(path, traversalState, functions = {
|
|
7056
|
+
identifiers: {},
|
|
7057
|
+
memberExpressions: {}
|
|
7058
|
+
}, keyPath = []) {
|
|
5409
7059
|
const obj = {};
|
|
5410
7060
|
const inlineStyles = {};
|
|
5411
7061
|
const props = path.get('properties');
|
|
@@ -5509,7 +7159,26 @@ function validateDynamicStyleParams(path, params) {
|
|
|
5509
7159
|
}
|
|
5510
7160
|
|
|
5511
7161
|
function isSafeToSkipNullCheck(expr) {
|
|
5512
|
-
|
|
7162
|
+
if (t__namespace.isTemplateLiteral(expr)) return true;
|
|
7163
|
+
if (t__namespace.isStringLiteral(expr) || t__namespace.isNumericLiteral(expr) || t__namespace.isBooleanLiteral(expr)) return true;
|
|
7164
|
+
if (t__namespace.isBinaryExpression(expr)) {
|
|
7165
|
+
return ['+', '-', '*', '/', '%', '**'].includes(expr.operator);
|
|
7166
|
+
}
|
|
7167
|
+
if (t__namespace.isUnaryExpression(expr)) {
|
|
7168
|
+
return ['-', '+'].includes(expr.operator);
|
|
7169
|
+
}
|
|
7170
|
+
if (t__namespace.isConditionalExpression(expr)) {
|
|
7171
|
+
return isSafeToSkipNullCheck(expr.consequent) && isSafeToSkipNullCheck(expr.alternate);
|
|
7172
|
+
}
|
|
7173
|
+
if (t__namespace.isLogicalExpression(expr)) {
|
|
7174
|
+
if (expr.operator === '??' || expr.operator === '||') {
|
|
7175
|
+
return isSafeToSkipNullCheck(expr.left) || isSafeToSkipNullCheck(expr.right);
|
|
7176
|
+
}
|
|
7177
|
+
if (expr.operator === '&&') {
|
|
7178
|
+
return isSafeToSkipNullCheck(expr.left) && isSafeToSkipNullCheck(expr.right);
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
return false;
|
|
5513
7182
|
}
|
|
5514
7183
|
function transformStyleXCreate(path, state) {
|
|
5515
7184
|
const {
|
|
@@ -5581,18 +7250,14 @@ function transformStyleXCreate(path, state) {
|
|
|
5581
7250
|
const plainObject = value;
|
|
5582
7251
|
const injectedInheritStyles = {};
|
|
5583
7252
|
if (fns != null) {
|
|
5584
|
-
const dynamicFnsNames = Object.values(fns)?.map(entry => Object.entries(entry[1]).map(
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
let {
|
|
5593
|
-
variableName,
|
|
5594
|
-
path
|
|
5595
|
-
} = _ref2;
|
|
7253
|
+
const dynamicFnsNames = Object.values(fns)?.map(entry => Object.entries(entry[1]).map(([variableName, obj]) => ({
|
|
7254
|
+
variableName,
|
|
7255
|
+
path: obj.path
|
|
7256
|
+
}))).flat();
|
|
7257
|
+
dynamicFnsNames.forEach(({
|
|
7258
|
+
variableName,
|
|
7259
|
+
path
|
|
7260
|
+
}) => {
|
|
5596
7261
|
const isPseudoElement = path.some(p => p.startsWith('::'));
|
|
5597
7262
|
injectedInheritStyles[variableName] = {
|
|
5598
7263
|
priority: 0,
|
|
@@ -5645,68 +7310,81 @@ function transformStyleXCreate(path, state) {
|
|
|
5645
7310
|
for (const [className, classPaths] of Object.entries(classPathsPerNamespace[key])) {
|
|
5646
7311
|
origClassPaths[className] = classPaths.join('_');
|
|
5647
7312
|
}
|
|
5648
|
-
let dynamicStyles = Object.entries(inlineStyles).map(
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
path: v.path.join('_')
|
|
5654
|
-
};
|
|
5655
|
-
});
|
|
7313
|
+
let dynamicStyles = Object.entries(inlineStyles).map(([_key, v]) => ({
|
|
7314
|
+
expression: v.originalExpression,
|
|
7315
|
+
key: v.path.slice(0, v.path.findIndex(p => !p.startsWith(':') && !p.startsWith('@')) + 1).join('_'),
|
|
7316
|
+
path: v.path.join('_')
|
|
7317
|
+
}));
|
|
5656
7318
|
if (state.options.styleResolution === 'legacy-expand-shorthands') {
|
|
5657
7319
|
dynamicStyles = legacyExpandShorthands(dynamicStyles);
|
|
5658
7320
|
}
|
|
5659
7321
|
if (t__namespace.isObjectExpression(prop.value)) {
|
|
5660
7322
|
const value = prop.value;
|
|
7323
|
+
let cssTagValue = t__namespace.booleanLiteral(true);
|
|
7324
|
+
const staticProps = [];
|
|
5661
7325
|
const conditionalProps = [];
|
|
5662
7326
|
value.properties.forEach(prop => {
|
|
5663
7327
|
if (!t__namespace.isObjectProperty(prop) || t__namespace.isPrivateName(prop.key)) {
|
|
5664
7328
|
return;
|
|
5665
7329
|
}
|
|
5666
7330
|
const objProp = prop;
|
|
5667
|
-
const propKey = objProp.key
|
|
5668
|
-
if (propKey == null
|
|
5669
|
-
|
|
7331
|
+
const propKey = t__namespace.isIdentifier(objProp.key) && !objProp.computed ? objProp.key.name : t__namespace.isStringLiteral(objProp.key) ? objProp.key.value : null;
|
|
7332
|
+
if (propKey == null) {
|
|
7333
|
+
staticProps.push(objProp);
|
|
7334
|
+
return;
|
|
7335
|
+
}
|
|
7336
|
+
if (propKey === '$$css') {
|
|
7337
|
+
cssTagValue = objProp.value;
|
|
5670
7338
|
return;
|
|
5671
7339
|
}
|
|
5672
7340
|
const classList = t__namespace.isStringLiteral(objProp.value) ? objProp.value.value.split(' ') : [];
|
|
7341
|
+
let isStatic = true;
|
|
5673
7342
|
const exprList = [];
|
|
5674
7343
|
classList.forEach(cls => {
|
|
5675
|
-
const expr = dynamicStyles.find(
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
} = _ref4;
|
|
5679
|
-
return origClassPaths[cls] === path;
|
|
5680
|
-
})?.expression;
|
|
7344
|
+
const expr = dynamicStyles.find(({
|
|
7345
|
+
path
|
|
7346
|
+
}) => origClassPaths[cls] === path)?.expression;
|
|
5681
7347
|
if (expr && !isSafeToSkipNullCheck(expr)) {
|
|
7348
|
+
isStatic = false;
|
|
5682
7349
|
exprList.push(t__namespace.conditionalExpression(t__namespace.binaryExpression('!=', expr, t__namespace.nullLiteral()), t__namespace.stringLiteral(cls), expr));
|
|
5683
7350
|
} else {
|
|
5684
7351
|
exprList.push(t__namespace.stringLiteral(cls));
|
|
5685
7352
|
}
|
|
5686
7353
|
});
|
|
5687
7354
|
const joined = exprList.length === 0 ? t__namespace.stringLiteral('') : exprList.reduce((acc, curr) => t__namespace.binaryExpression('+', acc, curr));
|
|
5688
|
-
|
|
7355
|
+
if (isStatic) {
|
|
7356
|
+
staticProps.push(t__namespace.objectProperty(objProp.key, joined));
|
|
7357
|
+
} else {
|
|
7358
|
+
conditionalProps.push(t__namespace.objectProperty(objProp.key, joined));
|
|
7359
|
+
}
|
|
5689
7360
|
});
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
7361
|
+
let staticObj = null;
|
|
7362
|
+
let conditionalObj = null;
|
|
7363
|
+
if (staticProps.length > 0) {
|
|
7364
|
+
staticProps.push(t__namespace.objectProperty(t__namespace.stringLiteral('$$css'), cssTagValue));
|
|
7365
|
+
staticObj = t__namespace.objectExpression(staticProps);
|
|
7366
|
+
}
|
|
7367
|
+
if (conditionalProps.length > 0) {
|
|
7368
|
+
conditionalProps.push(t__namespace.objectProperty(t__namespace.identifier('$$css'), cssTagValue));
|
|
7369
|
+
conditionalObj = t__namespace.objectExpression(conditionalProps);
|
|
7370
|
+
}
|
|
7371
|
+
let finalFnValue = t__namespace.objectExpression(Object.entries(inlineStyles).map(([key, val]) => t__namespace.objectProperty(t__namespace.stringLiteral(key), val.expression)));
|
|
7372
|
+
if (staticObj != null || conditionalObj != null) {
|
|
7373
|
+
finalFnValue = t__namespace.arrayExpression([staticObj && hoistExpression(path, staticObj), conditionalObj, finalFnValue].filter(Boolean));
|
|
7374
|
+
}
|
|
7375
|
+
prop.value = t__namespace.arrowFunctionExpression(params, finalFnValue);
|
|
5695
7376
|
}
|
|
5696
7377
|
}
|
|
5697
7378
|
}
|
|
5698
7379
|
return prop;
|
|
5699
7380
|
});
|
|
5700
7381
|
}
|
|
5701
|
-
const listOfStyles = Object.entries(injectedStyles).map(
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
}] = _ref6;
|
|
5706
|
-
return [key, rest, priority];
|
|
5707
|
-
});
|
|
7382
|
+
const listOfStyles = Object.entries(injectedStyles).map(([key, {
|
|
7383
|
+
priority,
|
|
7384
|
+
...rest
|
|
7385
|
+
}]) => [key, rest, priority]);
|
|
5708
7386
|
state.registerStyles(listOfStyles, path);
|
|
5709
|
-
path
|
|
7387
|
+
pathReplaceHoisted(path, resultAst);
|
|
5710
7388
|
if (Object.keys(injectedStyles).length === 0) {
|
|
5711
7389
|
return;
|
|
5712
7390
|
}
|
|
@@ -5717,10 +7395,6 @@ function validateStyleXCreate(path) {
|
|
|
5717
7395
|
if (path.parentPath == null || path.parentPath.isExpressionStatement()) {
|
|
5718
7396
|
throw path.buildCodeFrameError(messages.unboundCallValue('create'), SyntaxError);
|
|
5719
7397
|
}
|
|
5720
|
-
const nearestStatement = findNearestStatementAncestor(path);
|
|
5721
|
-
if (!nearestStatement.parentPath.isProgram() && !nearestStatement.parentPath.isExportNamedDeclaration()) {
|
|
5722
|
-
throw path.buildCodeFrameError(messages.ONLY_TOP_LEVEL, SyntaxError);
|
|
5723
|
-
}
|
|
5724
7398
|
if (path.node.arguments.length !== 1) {
|
|
5725
7399
|
throw path.buildCodeFrameError(messages.illegalArgumentLength('create', 1), SyntaxError);
|
|
5726
7400
|
}
|
|
@@ -5733,25 +7407,14 @@ function validateStyleXCreate(path) {
|
|
|
5733
7407
|
throw path.buildCodeFrameError(messages.NO_OBJECT_SPREADS, SyntaxError);
|
|
5734
7408
|
}
|
|
5735
7409
|
}
|
|
5736
|
-
function findNearestStatementAncestor(path) {
|
|
5737
|
-
if (path.isStatement()) {
|
|
5738
|
-
return path;
|
|
5739
|
-
}
|
|
5740
|
-
if (path.parentPath == null) {
|
|
5741
|
-
throw new Error('Unexpected Path found that is not part of the AST.');
|
|
5742
|
-
}
|
|
5743
|
-
return findNearestStatementAncestor(path.parentPath);
|
|
5744
|
-
}
|
|
5745
7410
|
function legacyExpandShorthands(dynamicStyles) {
|
|
5746
|
-
const expandedKeysToKeyPaths = dynamicStyles.flatMap((
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
} = _ref7;
|
|
7411
|
+
const expandedKeysToKeyPaths = dynamicStyles.flatMap(({
|
|
7412
|
+
key
|
|
7413
|
+
}, i) => {
|
|
5750
7414
|
return flatMapExpandedShorthands([key, 'p' + i], {
|
|
5751
7415
|
styleResolution: 'legacy-expand-shorthands'
|
|
5752
7416
|
});
|
|
5753
|
-
}).map(
|
|
5754
|
-
let [key, value] = _ref8;
|
|
7417
|
+
}).map(([key, value]) => {
|
|
5755
7418
|
if (typeof value !== 'string') {
|
|
5756
7419
|
return null;
|
|
5757
7420
|
}
|
|
@@ -5871,13 +7534,10 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
5871
7534
|
const listOfStyles = Object.entries({
|
|
5872
7535
|
...otherInjectedCSSRules,
|
|
5873
7536
|
...injectedStyles
|
|
5874
|
-
}).map(
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
}] = _ref;
|
|
5879
|
-
return [key, rest, priority];
|
|
5880
|
-
});
|
|
7537
|
+
}).map(([key, {
|
|
7538
|
+
priority,
|
|
7539
|
+
...rest
|
|
7540
|
+
}]) => [key, rest, priority]);
|
|
5881
7541
|
state.registerStyles(listOfStyles, variableDeclaratorPath);
|
|
5882
7542
|
}
|
|
5883
7543
|
}
|
|
@@ -5980,13 +7640,10 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
5980
7640
|
...injectedStylesSansKeyframes
|
|
5981
7641
|
};
|
|
5982
7642
|
callExpressionPath.replaceWith(convertObjectToAST(variablesObj));
|
|
5983
|
-
const listOfStyles = Object.entries(injectedStyles).map(
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
}] = _ref;
|
|
5988
|
-
return [key, rest, priority];
|
|
5989
|
-
});
|
|
7643
|
+
const listOfStyles = Object.entries(injectedStyles).map(([key, {
|
|
7644
|
+
priority,
|
|
7645
|
+
...rest
|
|
7646
|
+
}]) => [key, rest, priority]);
|
|
5990
7647
|
state.registerStyles(listOfStyles, variableDeclaratorPath);
|
|
5991
7648
|
}
|
|
5992
7649
|
}
|
|
@@ -6040,15 +7697,12 @@ function transformStyleXDefineConsts(callExpressionPath, state) {
|
|
|
6040
7697
|
exportId
|
|
6041
7698
|
});
|
|
6042
7699
|
callExpressionPath.replaceWith(convertObjectToAST(transformedJsOutput));
|
|
6043
|
-
const styles = Object.entries(jsOutput).map(
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
rtl: obj.rtl ?? null
|
|
6050
|
-
}, obj.priority];
|
|
6051
|
-
});
|
|
7700
|
+
const styles = Object.entries(jsOutput).map(([_, obj]) => [obj.constKey, {
|
|
7701
|
+
constKey: obj.constKey,
|
|
7702
|
+
constVal: obj.constVal,
|
|
7703
|
+
ltr: obj.ltr,
|
|
7704
|
+
rtl: obj.rtl ?? null
|
|
7705
|
+
}, obj.priority]);
|
|
6052
7706
|
state.registerStyles(styles);
|
|
6053
7707
|
}
|
|
6054
7708
|
}
|
|
@@ -6673,8 +8327,7 @@ function isCalleeMemberExpression(path, state) {
|
|
|
6673
8327
|
return node != null && node.callee != null && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'props' && state.stylexImport.has(node.callee.object.name);
|
|
6674
8328
|
}
|
|
6675
8329
|
|
|
6676
|
-
function styleXViewTransitionClass(styles) {
|
|
6677
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
|
|
8330
|
+
function styleXViewTransitionClass(styles, options = defaultOptions) {
|
|
6678
8331
|
const {
|
|
6679
8332
|
classNamePrefix = 'x'
|
|
6680
8333
|
} = options;
|
|
@@ -6690,28 +8343,18 @@ function styleXViewTransitionClass(styles) {
|
|
|
6690
8343
|
}];
|
|
6691
8344
|
}
|
|
6692
8345
|
function preprocessProperties(styles, options) {
|
|
6693
|
-
return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(
|
|
6694
|
-
let [key, value] = _ref;
|
|
8346
|
+
return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(([key, value]) => {
|
|
6695
8347
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
6696
8348
|
return [key, value];
|
|
6697
8349
|
}
|
|
6698
8350
|
return null;
|
|
6699
|
-
}).filter(Boolean)).filter(
|
|
6700
|
-
let [_key, value] = _ref2;
|
|
6701
|
-
return value != null;
|
|
6702
|
-
}));
|
|
8351
|
+
}).filter(Boolean)).filter(([_key, value]) => value != null));
|
|
6703
8352
|
}
|
|
6704
8353
|
function constructViewTransitionClassStyleStr(style) {
|
|
6705
|
-
return objEntries(style).map(
|
|
6706
|
-
let [k, v] = _ref3;
|
|
6707
|
-
return `${k}:${v};`;
|
|
6708
|
-
}).join('');
|
|
8354
|
+
return objEntries(style).map(([k, v]) => `${k}:${v};`).join('');
|
|
6709
8355
|
}
|
|
6710
8356
|
function constructFinalViewTransitionCSSStr(styles, className) {
|
|
6711
|
-
return objEntries(styles).map(
|
|
6712
|
-
let [k, v] = _ref4;
|
|
6713
|
-
return `${k}(*.${className}){${v}}`;
|
|
6714
|
-
}).join('');
|
|
8357
|
+
return objEntries(styles).map(([k, v]) => `${k}(*.${className}){${v}}`).join('');
|
|
6715
8358
|
}
|
|
6716
8359
|
|
|
6717
8360
|
function transformStyleXViewTransitionClass(path, state) {
|
|
@@ -6791,13 +8434,10 @@ function transformStyleXViewTransitionClass(path, state) {
|
|
|
6791
8434
|
rtl
|
|
6792
8435
|
}
|
|
6793
8436
|
};
|
|
6794
|
-
const listOfStyles = Object.entries(injectedStyles).map(
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
}] = _ref;
|
|
6799
|
-
return [key, rest, priority];
|
|
6800
|
-
});
|
|
8437
|
+
const listOfStyles = Object.entries(injectedStyles).map(([key, {
|
|
8438
|
+
priority,
|
|
8439
|
+
...rest
|
|
8440
|
+
}]) => [key, rest, priority]);
|
|
6801
8441
|
state.registerStyles(listOfStyles, path);
|
|
6802
8442
|
}
|
|
6803
8443
|
}
|
|
@@ -6911,10 +8551,7 @@ function styleXTransform() {
|
|
|
6911
8551
|
}
|
|
6912
8552
|
}
|
|
6913
8553
|
}
|
|
6914
|
-
const varsToKeepOld = new Set([...state.styleVarsToKeep.values()].map(
|
|
6915
|
-
let [varName, _namespaceName] = _ref;
|
|
6916
|
-
return varName;
|
|
6917
|
-
}));
|
|
8554
|
+
const varsToKeepOld = new Set([...state.styleVarsToKeep.values()].map(([varName, _namespaceName]) => varName));
|
|
6918
8555
|
state.styleVars.forEach((path, varName) => {
|
|
6919
8556
|
if (isExported(path)) {
|
|
6920
8557
|
return;
|
|
@@ -6938,13 +8575,7 @@ function styleXTransform() {
|
|
|
6938
8575
|
if (!namespacesToKeep.includes(keyAsString)) {
|
|
6939
8576
|
prop.remove();
|
|
6940
8577
|
} else {
|
|
6941
|
-
const allNullsToKeep = [...state.styleVarsToKeep.values()].filter(
|
|
6942
|
-
let [v, namespaceName] = _ref2;
|
|
6943
|
-
return v === varName && namespaceName === keyAsString;
|
|
6944
|
-
}).map(_ref3 => {
|
|
6945
|
-
let [_v, _namespaceName, nullPropsToKeep] = _ref3;
|
|
6946
|
-
return nullPropsToKeep;
|
|
6947
|
-
});
|
|
8578
|
+
const allNullsToKeep = [...state.styleVarsToKeep.values()].filter(([v, namespaceName]) => v === varName && namespaceName === keyAsString).map(([_v, _namespaceName, nullPropsToKeep]) => nullPropsToKeep);
|
|
6948
8579
|
if (!allNullsToKeep.includes(true)) {
|
|
6949
8580
|
const nullsToKeep = new Set(allNullsToKeep.filter(x => x !== true).flat());
|
|
6950
8581
|
const styleObject = prop.get('value');
|
|
@@ -7002,27 +8633,19 @@ function isExported(path) {
|
|
|
7002
8633
|
}
|
|
7003
8634
|
return isExported(path.parentPath);
|
|
7004
8635
|
}
|
|
7005
|
-
function processStylexRules(rules) {
|
|
7006
|
-
let useLayers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
8636
|
+
function processStylexRules(rules, useLayers = false) {
|
|
7007
8637
|
if (rules.length === 0) {
|
|
7008
8638
|
return '';
|
|
7009
8639
|
}
|
|
7010
|
-
const constantRules = rules.filter(
|
|
7011
|
-
|
|
7012
|
-
return ruleObj?.constKey != null && ruleObj?.constVal != null;
|
|
7013
|
-
});
|
|
7014
|
-
const nonConstantRules = rules.filter(_ref5 => {
|
|
7015
|
-
let [, ruleObj] = _ref5;
|
|
7016
|
-
return !(ruleObj?.constKey != null && ruleObj?.constVal != null);
|
|
7017
|
-
});
|
|
8640
|
+
const constantRules = rules.filter(([, ruleObj]) => ruleObj?.constKey != null && ruleObj?.constVal != null);
|
|
8641
|
+
const nonConstantRules = rules.filter(([, ruleObj]) => !(ruleObj?.constKey != null && ruleObj?.constVal != null));
|
|
7018
8642
|
const constsMap = new Map();
|
|
7019
8643
|
for (const [keyhash, ruleObj] of constantRules) {
|
|
7020
8644
|
const constVal = ruleObj.constVal;
|
|
7021
8645
|
const constName = `var(--${keyhash})`;
|
|
7022
8646
|
constsMap.set(constName, constVal);
|
|
7023
8647
|
}
|
|
7024
|
-
function resolveConstant(value) {
|
|
7025
|
-
let visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
|
|
8648
|
+
function resolveConstant(value, visited = new Set()) {
|
|
7026
8649
|
if (typeof value !== 'string') return value;
|
|
7027
8650
|
const regex = /var\((--[A-Za-z0-9_-]+)\)/g;
|
|
7028
8651
|
let result = value;
|
|
@@ -7047,13 +8670,11 @@ function processStylexRules(rules) {
|
|
|
7047
8670
|
for (const [key, value] of constsMap.entries()) {
|
|
7048
8671
|
constsMap.set(key, resolveConstant(value));
|
|
7049
8672
|
}
|
|
7050
|
-
const sortedRules = nonConstantRules.sort((
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
ltr: rule2
|
|
7056
|
-
}, secondPriority] = _ref7;
|
|
8673
|
+
const sortedRules = nonConstantRules.sort(([, {
|
|
8674
|
+
ltr: rule1
|
|
8675
|
+
}, firstPriority], [, {
|
|
8676
|
+
ltr: rule2
|
|
8677
|
+
}, secondPriority]) => {
|
|
7057
8678
|
const priorityComparison = firstPriority - secondPriority;
|
|
7058
8679
|
if (priorityComparison !== 0) return priorityComparison;
|
|
7059
8680
|
if (rule1.startsWith('@') && !rule2.startsWith('@')) {
|
|
@@ -7092,10 +8713,7 @@ function processStylexRules(rules) {
|
|
|
7092
8713
|
const header = useLayers ? '\n@layer ' + grouped.map((_, index) => `priority${index + 1}`).join(', ') + ';\n' : '';
|
|
7093
8714
|
const collectedCSS = grouped.map((group, index) => {
|
|
7094
8715
|
const pri = group[0][2];
|
|
7095
|
-
const collectedCSS = Array.from(new Map(group.map(
|
|
7096
|
-
let [a, b] = _ref8;
|
|
7097
|
-
return [a, b];
|
|
7098
|
-
})).values()).flatMap(rule => {
|
|
8716
|
+
const collectedCSS = Array.from(new Map(group.map(([a, b]) => [a, b])).values()).flatMap(rule => {
|
|
7099
8717
|
const {
|
|
7100
8718
|
ltr,
|
|
7101
8719
|
rtl
|