@master/css 2.0.0-rc.45 → 2.0.0-rc.47

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.
@@ -2,4 +2,9 @@
2
2
 
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
 
5
+ function getDefaultExportFromCjs (x) {
6
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
+ }
8
+
5
9
  exports.commonjsGlobal = commonjsGlobal;
10
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -1,3 +1,7 @@
1
1
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
2
 
3
- export { commonjsGlobal };
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
7
+ export { commonjsGlobal, getDefaultExportFromCjs };
package/dist/common.cjs CHANGED
@@ -101,7 +101,7 @@ const VALUE_UNITS = [
101
101
  ];
102
102
  const UNIT_REGEX = /^([+-.]?\d+(\.?\d+)?)(%|cm|mm|q|in|pt|pc|px|em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cqw|cqh|cqi|cqb|cqmin|cqmax|deg|grad|rad|turn|s|ms|hz|khz|dpi|dpcm|dppx|x|fr|db|st)?$/;
103
103
  const IMAGE_VALUE_REGEX = /(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\(.*\)/;
104
- const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla)\(.*\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
104
+ const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla|light-dark)\(.*\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
105
105
  const NUMBER_VALUE_REGEX = /(?:[\d.]|(?:max|min|calc|clamp)\([^|]*\))/;
106
106
  const OFFICIAL_URL = new URL('https://rc.css.master.co');
107
107
  const CLASS_ATTRIBUTES = [
package/dist/common.mjs CHANGED
@@ -99,7 +99,7 @@ const VALUE_UNITS = [
99
99
  ];
100
100
  const UNIT_REGEX = /^([+-.]?\d+(\.?\d+)?)(%|cm|mm|q|in|pt|pc|px|em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cqw|cqh|cqi|cqb|cqmin|cqmax|deg|grad|rad|turn|s|ms|hz|khz|dpi|dpcm|dppx|x|fr|db|st)?$/;
101
101
  const IMAGE_VALUE_REGEX = /(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\(.*\)/;
102
- const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla)\(.*\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
102
+ const COLOR_VALUE_REGEX = /(?:#|(?:color|color-contrast|color-mix|hwb|lab|lch|oklab|oklch|rgb|rgba|hsl|hsla|light-dark)\(.*\)|(?:\$colors)(?![a-zA-Z0-9-]))/;
103
103
  const NUMBER_VALUE_REGEX = /(?:[\d.]|(?:max|min|calc|clamp)\([^|]*\))/;
104
104
  const OFFICIAL_URL = new URL('https://rc.css.master.co');
105
105
  const CLASS_ATTRIBUTES = [
@@ -334,6 +334,9 @@ const functions = {
334
334
  oklch: {
335
335
  unit: ''
336
336
  },
337
+ 'light-dark': {
338
+ unit: ''
339
+ },
337
340
  clamp: {
338
341
  unit: ''
339
342
  },
@@ -332,6 +332,9 @@ const functions = {
332
332
  oklch: {
333
333
  unit: ''
334
334
  },
335
+ 'light-dark': {
336
+ unit: ''
337
+ },
335
338
  clamp: {
336
339
  unit: ''
337
340
  },
@@ -10,48 +10,32 @@ import type { PropertiesHyphen } from 'csstype';
10
10
  import type { Rule, SyntaxDefinition, ValueComponent } from '../rule';
11
11
  declare const config: Config;
12
12
  export { config, at, selectors, utilities, syntaxes, functions, animations, variables, modes };
13
- export type VariableValue = number | string | false | Array<number | string>;
13
+ export type VariableValue = number | string | false | (number | string)[];
14
14
  export type VariableDefinition = {
15
15
  [key in '' | `@${string}` | string]?: VariableValue | VariableDefinition;
16
16
  } | VariableValue;
17
- export type CSSKeyframes = {
18
- [key in 'from' | 'to' | string]: PropertiesHyphen;
19
- };
20
- export type AnimationDefinitions = {
21
- [key: string]: CSSKeyframes;
22
- };
23
- export type SelectorDefinitions = {
24
- [key: string]: string | string[];
25
- };
26
- export type AtDefinitions = {
17
+ export type CSSKeyframes = Record<'from' | 'to' | string, PropertiesHyphen>;
18
+ export type AnimationDefinitions = Record<string, CSSKeyframes>;
19
+ export type SelectorDefinitions = Record<string, string | string[]>;
20
+ export interface AtDefinitions {
27
21
  [key: string]: number | string | AtDefinitions;
28
- };
29
- export type StyleDefinitions = {
22
+ }
23
+ export interface StyleDefinitions {
30
24
  [key: string]: string | StyleDefinitions;
31
- };
32
- export type SyntaxDefinitions = {
33
- [key in keyof typeof syntaxes | string]?: SyntaxDefinition;
34
- };
25
+ }
26
+ export type SyntaxDefinitions = Partial<Record<keyof typeof syntaxes | string, SyntaxDefinition>>;
35
27
  export type VariableDefinitions = {
36
28
  [key in keyof typeof syntaxes]?: VariableDefinition;
37
- } & {
38
- [key: string]: VariableDefinition;
39
- };
29
+ } & Record<string, VariableDefinition>;
40
30
  export type UtilityDefinitions = {
41
31
  [key in keyof typeof utilities]?: PropertiesHyphen;
42
- } & {
43
- [key: string]: PropertiesHyphen;
44
- };
45
- export type ModeDefinitions = {
46
- [key: string]: 'class' | 'media' | 'host' | false;
47
- };
32
+ } & Record<string, PropertiesHyphen>;
33
+ export type ModeDefinitions = Record<string, 'class' | 'media' | 'host' | false>;
48
34
  export interface FunctionDefinition {
49
35
  unit?: string;
50
36
  transform?(this: Rule, value: string, bypassVariableNames: string[]): string | ValueComponent[];
51
37
  }
52
- export type FunctionDefinitions = {
53
- [key: string]: FunctionDefinition;
54
- };
38
+ export type FunctionDefinitions = Record<string, FunctionDefinition>;
55
39
  export interface Config {
56
40
  extends?: (Config | any)[];
57
41
  styles?: StyleDefinitions;
@@ -1,3 +1,3 @@
1
- export type ConfigStyles = {
1
+ export interface ConfigStyles {
2
2
  [key: string]: string | ConfigStyles;
3
- };
3
+ }
@@ -1,265 +1,5 @@
1
- declare const variables: {
2
- gray: {
3
- 5: string;
4
- 10: string;
5
- 20: string;
6
- 30: string;
7
- 40: string;
8
- 50: string;
9
- 60: string;
10
- 70: string;
11
- 80: string;
12
- 90: string;
13
- 95: string;
14
- };
15
- slate: {
16
- 5: string;
17
- 10: string;
18
- 20: string;
19
- 30: string;
20
- 40: string;
21
- 50: string;
22
- 60: string;
23
- 70: string;
24
- 80: string;
25
- 90: string;
26
- 95: string;
27
- };
28
- brown: {
29
- 5: string;
30
- 10: string;
31
- 20: string;
32
- 30: string;
33
- 40: string;
34
- 50: string;
35
- 60: string;
36
- 70: string;
37
- 80: string;
38
- 90: string;
39
- 95: string;
40
- };
41
- orange: {
42
- 5: string;
43
- 10: string;
44
- 20: string;
45
- 30: string;
46
- 40: string;
47
- 50: string;
48
- 60: string;
49
- 70: string;
50
- 80: string;
51
- 90: string;
52
- 95: string;
53
- };
54
- amber: {
55
- 5: string;
56
- 10: string;
57
- 20: string;
58
- 30: string;
59
- 40: string;
60
- 50: string;
61
- 60: string;
62
- 70: string;
63
- 80: string;
64
- 90: string;
65
- 95: string;
66
- };
67
- yellow: {
68
- 5: string;
69
- 10: string;
70
- 20: string;
71
- 30: string;
72
- 40: string;
73
- 50: string;
74
- 60: string;
75
- 70: string;
76
- 80: string;
77
- 90: string;
78
- 95: string;
79
- };
80
- lime: {
81
- 5: string;
82
- 10: string;
83
- 20: string;
84
- 30: string;
85
- 40: string;
86
- 50: string;
87
- 60: string;
88
- 70: string;
89
- 80: string;
90
- 90: string;
91
- 95: string;
92
- };
93
- green: {
94
- 5: string;
95
- 10: string;
96
- 20: string;
97
- 30: string;
98
- 40: string;
99
- 50: string;
100
- 60: string;
101
- 70: string;
102
- 80: string;
103
- 90: string;
104
- 95: string;
105
- };
106
- beryl: {
107
- 5: string;
108
- 10: string;
109
- 20: string;
110
- 30: string;
111
- 40: string;
112
- 50: string;
113
- 60: string;
114
- 70: string;
115
- 80: string;
116
- 90: string;
117
- 95: string;
118
- };
119
- teal: {
120
- 5: string;
121
- 10: string;
122
- 20: string;
123
- 30: string;
124
- 40: string;
125
- 50: string;
126
- 60: string;
127
- 70: string;
128
- 80: string;
129
- 90: string;
130
- 95: string;
131
- };
132
- cyan: {
133
- 5: string;
134
- 10: string;
135
- 20: string;
136
- 30: string;
137
- 40: string;
138
- 50: string;
139
- 60: string;
140
- 70: string;
141
- 80: string;
142
- 90: string;
143
- 95: string;
144
- };
145
- sky: {
146
- 5: string;
147
- 10: string;
148
- 20: string;
149
- 30: string;
150
- 40: string;
151
- 50: string;
152
- 60: string;
153
- 70: string;
154
- 80: string;
155
- 90: string;
156
- 95: string;
157
- };
158
- blue: {
159
- 5: string;
160
- 10: string;
161
- 20: string;
162
- 30: string;
163
- 40: string;
164
- 50: string;
165
- 60: string;
166
- 70: string;
167
- 80: string;
168
- 90: string;
169
- 95: string;
170
- };
171
- indigo: {
172
- 5: string;
173
- 10: string;
174
- 20: string;
175
- 30: string;
176
- 40: string;
177
- 50: string;
178
- 60: string;
179
- 70: string;
180
- 80: string;
181
- 90: string;
182
- 95: string;
183
- };
184
- violet: {
185
- 5: string;
186
- 10: string;
187
- 20: string;
188
- 30: string;
189
- 40: string;
190
- 50: string;
191
- 60: string;
192
- 70: string;
193
- 80: string;
194
- 90: string;
195
- 95: string;
196
- };
197
- purple: {
198
- 5: string;
199
- 10: string;
200
- 20: string;
201
- 30: string;
202
- 40: string;
203
- 50: string;
204
- 60: string;
205
- 70: string;
206
- 80: string;
207
- 90: string;
208
- 95: string;
209
- };
210
- fuchsia: {
211
- 5: string;
212
- 10: string;
213
- 20: string;
214
- 30: string;
215
- 40: string;
216
- 50: string;
217
- 60: string;
218
- 70: string;
219
- 80: string;
220
- 90: string;
221
- 95: string;
222
- };
223
- pink: {
224
- 5: string;
225
- 10: string;
226
- 20: string;
227
- 30: string;
228
- 40: string;
229
- 50: string;
230
- 60: string;
231
- 70: string;
232
- 80: string;
233
- 90: string;
234
- 95: string;
235
- };
236
- crimson: {
237
- 5: string;
238
- 10: string;
239
- 20: string;
240
- 30: string;
241
- 40: string;
242
- 50: string;
243
- 60: string;
244
- 70: string;
245
- 80: string;
246
- 90: string;
247
- 95: string;
248
- };
249
- red: {
250
- 5: string;
251
- 10: string;
252
- 20: string;
253
- 30: string;
254
- 40: string;
255
- 50: string;
256
- 60: string;
257
- 70: string;
258
- 80: string;
259
- 90: string;
260
- 95: string;
261
- };
262
- } & {
1
+ import colors from '@master/colors';
2
+ declare const _variables: {
263
3
  full: string;
264
4
  fit: string;
265
5
  max: string;
@@ -703,4 +443,5 @@ declare const variables: {
703
443
  };
704
444
  };
705
445
  };
446
+ declare const variables: (typeof colors & typeof _variables);
706
447
  export default variables;
package/dist/core.cjs CHANGED
@@ -80,7 +80,7 @@ class MasterCSS {
80
80
  if (variables) {
81
81
  const unexecutedAliasVariable = {};
82
82
  const resolveVariable = (variableDefinition, name, mode)=>{
83
- if (!variableDefinition === undefined || variableDefinition === null) return;
83
+ if (variableDefinition === undefined || variableDefinition === null) return;
84
84
  const addVariable = (name, variable, replacedMode, alpha)=>{
85
85
  if (variable === undefined) return;
86
86
  const flatName = name.join('-');
@@ -545,7 +545,7 @@ class MasterCSS {
545
545
  for(let index = 0; index < sheet.cssRules.length; index++){
546
546
  const eachCSSRule = sheet.cssRules[index];
547
547
  if (eachCSSRule === firstNative.cssRule) {
548
- for(let i = 0; i < rule.natives.length; i++){
548
+ for (const {} of rule.natives){
549
549
  sheet.deleteRule(index);
550
550
  }
551
551
  break;
@@ -879,8 +879,7 @@ class MasterCSS {
879
879
  if (sheet) {
880
880
  let cssRule;
881
881
  if (initializing) {
882
- for(let i = 0; i < sheet.cssRules.length; i++){
883
- const eachCSSRule = sheet.cssRules[i];
882
+ for (const eachCSSRule of sheet.cssRules){
884
883
  if (eachCSSRule.constructor.name === 'CSSKeyframesRule' && eachCSSRule.name === eachKeyframeName) {
885
884
  cssRule = eachCSSRule;
886
885
  break;
@@ -1025,6 +1024,7 @@ class MasterCSS {
1025
1024
  cssRule: variableCSSRule,
1026
1025
  get text () {
1027
1026
  const properties = [];
1027
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
1028
1028
  for(let i = 0; i < variableCSSRule.style.length; i++){
1029
1029
  const property = variableCSSRule.style[i];
1030
1030
  properties.push(property + ':' + variableCSSRule.style.getPropertyValue(property));
package/dist/core.d.ts CHANGED
@@ -1,28 +1,26 @@
1
1
  import { Rule, type NativeRule, type RegisteredRule } from './rule';
2
2
  import type { Config, AnimationDefinitions } from './config';
3
3
  import './types/global';
4
- type VariableCommon = {
4
+ interface VariableCommon {
5
5
  usage?: number;
6
6
  group?: string;
7
7
  name: string;
8
8
  key: string;
9
- modes?: {
10
- [mode: string]: TypeVariable;
11
- };
12
- };
13
- export type StringVariable = {
9
+ modes?: Record<string, TypeVariable>;
10
+ }
11
+ export interface StringVariable {
14
12
  type: 'string';
15
13
  value: string;
16
- };
17
- export type NumberVariable = {
14
+ }
15
+ export interface NumberVariable {
18
16
  type: 'number';
19
17
  value: number;
20
- };
21
- export type ColorVariable = {
18
+ }
19
+ export interface ColorVariable {
22
20
  type: 'color';
23
21
  value: string;
24
22
  space: 'rgb' | 'hsl';
25
- };
23
+ }
26
24
  export type TypeVariable = StringVariable | NumberVariable | ColorVariable;
27
25
  export type Variable = TypeVariable & VariableCommon;
28
26
  export default class MasterCSS {
package/dist/core.mjs CHANGED
@@ -76,7 +76,7 @@ class MasterCSS {
76
76
  if (variables) {
77
77
  const unexecutedAliasVariable = {};
78
78
  const resolveVariable = (variableDefinition, name, mode)=>{
79
- if (!variableDefinition === undefined || variableDefinition === null) return;
79
+ if (variableDefinition === undefined || variableDefinition === null) return;
80
80
  const addVariable = (name, variable, replacedMode, alpha)=>{
81
81
  if (variable === undefined) return;
82
82
  const flatName = name.join('-');
@@ -541,7 +541,7 @@ class MasterCSS {
541
541
  for(let index = 0; index < sheet.cssRules.length; index++){
542
542
  const eachCSSRule = sheet.cssRules[index];
543
543
  if (eachCSSRule === firstNative.cssRule) {
544
- for(let i = 0; i < rule.natives.length; i++){
544
+ for (const {} of rule.natives){
545
545
  sheet.deleteRule(index);
546
546
  }
547
547
  break;
@@ -875,8 +875,7 @@ class MasterCSS {
875
875
  if (sheet) {
876
876
  let cssRule;
877
877
  if (initializing) {
878
- for(let i = 0; i < sheet.cssRules.length; i++){
879
- const eachCSSRule = sheet.cssRules[i];
878
+ for (const eachCSSRule of sheet.cssRules){
880
879
  if (eachCSSRule.constructor.name === 'CSSKeyframesRule' && eachCSSRule.name === eachKeyframeName) {
881
880
  cssRule = eachCSSRule;
882
881
  break;
@@ -1021,6 +1020,7 @@ class MasterCSS {
1021
1020
  cssRule: variableCSSRule,
1022
1021
  get text () {
1023
1022
  const properties = [];
1023
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
1024
1024
  for(let i = 0; i < variableCSSRule.style.length; i++){
1025
1025
  const property = variableCSSRule.style[i];
1026
1026
  properties.push(property + ':' + variableCSSRule.style.getPropertyValue(property));
package/dist/layer.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Layer;
4
- (function(Layer) {
3
+ var Layer = /*#__PURE__*/ function(Layer) {
5
4
  /**
6
5
  * utility classes
7
6
  * @example block, inline
@@ -22,7 +21,7 @@ var Layer;
22
21
  * normal
23
22
  * @example grid-cols
24
23
  */ Layer[Layer["Normal"] = 0] = "Normal";
25
- })(Layer || (Layer = {}));
26
- var Layer$1 = Layer;
24
+ return Layer;
25
+ }(Layer || {});
27
26
 
28
- module.exports = Layer$1;
27
+ module.exports = Layer;
package/dist/layer.mjs CHANGED
@@ -1,5 +1,4 @@
1
- var Layer;
2
- (function(Layer) {
1
+ var Layer = /*#__PURE__*/ function(Layer) {
3
2
  /**
4
3
  * utility classes
5
4
  * @example block, inline
@@ -20,7 +19,7 @@ var Layer;
20
19
  * normal
21
20
  * @example grid-cols
22
21
  */ Layer[Layer["Normal"] = 0] = "Normal";
23
- })(Layer || (Layer = {}));
24
- var Layer$1 = Layer;
22
+ return Layer;
23
+ }(Layer || {});
25
24
 
26
- export { Layer$1 as default };
25
+ export { Layer as default };
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- require('./css-escape2.cjs');
4
- var cssEscape = require('../_virtual/css-escape.cjs');
3
+ var _commonjsHelpers = require('../_virtual/_commonjsHelpers.cjs');
4
+ var cssEscape$1 = require('./css-escape2.cjs');
5
5
 
6
+ var cssEscapeExports = cssEscape$1.__require();
7
+ var cssEscape = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(cssEscapeExports);
6
8
 
7
-
8
- module.exports = cssEscape.__exports;
9
+ module.exports = cssEscape;
@@ -1,2 +1,7 @@
1
- import './css-escape2.mjs';
2
- export { __exports as default } from '../_virtual/css-escape.mjs';
1
+ import { getDefaultExportFromCjs } from '../_virtual/_commonjsHelpers.mjs';
2
+ import { __require as requireCssEscape } from './css-escape2.mjs';
3
+
4
+ var cssEscapeExports = requireCssEscape();
5
+ var cssEscape = /*@__PURE__*/getDefaultExportFromCjs(cssEscapeExports);
6
+
7
+ export { cssEscape as default };
@@ -1,68 +1,76 @@
1
1
  'use strict';
2
2
 
3
3
  var _commonjsHelpers = require('../_virtual/_commonjsHelpers.cjs');
4
+ var cssEscape = require('../_virtual/css-escape.cjs');
4
5
 
5
- (()=>{
6
- const root = typeof _commonjsHelpers.commonjsGlobal !== 'undefined' ? _commonjsHelpers.commonjsGlobal : window;
7
- if (!root.CSS && !root.CSS?.escape) {
8
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
9
- const cssEscape = function(value) {
10
- if (arguments.length == 0) {
11
- throw new TypeError('`CSS.escape` requires an argument.');
12
- }
13
- const string = String(value);
14
- const length = string.length;
15
- let index = -1;
16
- let result = '';
17
- let codeUnit;
18
- const firstCodeUnit = string.charCodeAt(0);
19
- if (// If the character is the first character and is a `-` (U+002D), and
20
- // there is no second character, […]
21
- length == 1 && firstCodeUnit == 0x002D) {
22
- return '\\' + string;
23
- }
24
- while(++index < length){
25
- codeUnit = string.charCodeAt(index);
26
- // Note: there’s no need to special-case astral symbols, surrogate
27
- // pairs, or lone surrogates.
28
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
29
- // (U+FFFD).
30
- if (codeUnit == 0x0000) {
31
- result += '\uFFFD';
32
- continue;
33
- }
34
- if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
35
- // U+007F, […]
36
- codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
37
- // (U+0030 to U+0039), […]
38
- index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
39
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
40
- index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
41
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
42
- result += '\\' + codeUnit.toString(16) + ' ';
43
- continue;
44
- }
45
- // If the character is not handled by one of the above syntaxes and is
46
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
47
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
48
- // U+005A), or [a-z] (U+0061 to U+007A), […]
49
- if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
50
- // the character itself
51
- result += string.charAt(index);
52
- continue;
53
- }
54
- // Otherwise, the escaped character.
55
- // https://drafts.csswg.org/cssom/#escape-a-character
56
- result += '\\' + string.charAt(index);
57
- }
58
- return result;
59
- };
60
- if (!root.CSS) {
61
- root.CSS = {};
62
- }
63
- root.CSS.escape = cssEscape;
64
- globalThis.CSS.escape = cssEscape;
65
- }
66
- })();
6
+ var hasRequiredCssEscape;
67
7
 
68
- module.exports = undefined;
8
+ function requireCssEscape () {
9
+ if (hasRequiredCssEscape) return cssEscape.__exports;
10
+ hasRequiredCssEscape = 1;
11
+ (()=>{
12
+ const root = typeof _commonjsHelpers.commonjsGlobal !== 'undefined' ? _commonjsHelpers.commonjsGlobal : window;
13
+ if (!root.CSS && !root.CSS?.escape) {
14
+ // https://drafts.csswg.org/cssom/#serialize-an-identifier
15
+ const cssEscape = function(value) {
16
+ if (arguments.length == 0) {
17
+ throw new TypeError('`CSS.escape` requires an argument.');
18
+ }
19
+ const string = String(value);
20
+ const length = string.length;
21
+ let index = -1;
22
+ let result = '';
23
+ let codeUnit;
24
+ const firstCodeUnit = string.charCodeAt(0);
25
+ if (// If the character is the first character and is a `-` (U+002D), and
26
+ // there is no second character, […]
27
+ length == 1 && firstCodeUnit == 0x002D) {
28
+ return '\\' + string;
29
+ }
30
+ while(++index < length){
31
+ codeUnit = string.charCodeAt(index);
32
+ // Note: there’s no need to special-case astral symbols, surrogate
33
+ // pairs, or lone surrogates.
34
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
35
+ // (U+FFFD).
36
+ if (codeUnit == 0x0000) {
37
+ result += '\uFFFD';
38
+ continue;
39
+ }
40
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
41
+ // U+007F, […]
42
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
43
+ // (U+0030 to U+0039), […]
44
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
45
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
46
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
47
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
48
+ result += '\\' + codeUnit.toString(16) + ' ';
49
+ continue;
50
+ }
51
+ // If the character is not handled by one of the above syntaxes and is
52
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
53
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
54
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
55
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
56
+ // the character itself
57
+ result += string.charAt(index);
58
+ continue;
59
+ }
60
+ // Otherwise, the escaped character.
61
+ // https://drafts.csswg.org/cssom/#escape-a-character
62
+ result += '\\' + string.charAt(index);
63
+ }
64
+ return result;
65
+ };
66
+ if (!root.CSS) {
67
+ root.CSS = {};
68
+ }
69
+ root.CSS.escape = cssEscape;
70
+ globalThis.CSS.escape = cssEscape;
71
+ }
72
+ })();
73
+ return cssEscape.__exports;
74
+ }
75
+
76
+ exports.__require = requireCssEscape;
@@ -1,64 +1,74 @@
1
1
  import { commonjsGlobal } from '../_virtual/_commonjsHelpers.mjs';
2
+ import { __exports as cssEscape } from '../_virtual/css-escape.mjs';
2
3
 
3
- (()=>{
4
- const root = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : window;
5
- if (!root.CSS && !root.CSS?.escape) {
6
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
7
- const cssEscape = function(value) {
8
- if (arguments.length == 0) {
9
- throw new TypeError('`CSS.escape` requires an argument.');
10
- }
11
- const string = String(value);
12
- const length = string.length;
13
- let index = -1;
14
- let result = '';
15
- let codeUnit;
16
- const firstCodeUnit = string.charCodeAt(0);
17
- if (// If the character is the first character and is a `-` (U+002D), and
18
- // there is no second character, […]
19
- length == 1 && firstCodeUnit == 0x002D) {
20
- return '\\' + string;
21
- }
22
- while(++index < length){
23
- codeUnit = string.charCodeAt(index);
24
- // Note: there’s no need to special-case astral symbols, surrogate
25
- // pairs, or lone surrogates.
26
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
27
- // (U+FFFD).
28
- if (codeUnit == 0x0000) {
29
- result += '\uFFFD';
30
- continue;
31
- }
32
- if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
33
- // U+007F, […]
34
- codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
35
- // (U+0030 to U+0039), […]
36
- index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
37
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
38
- index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
39
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
40
- result += '\\' + codeUnit.toString(16) + ' ';
41
- continue;
42
- }
43
- // If the character is not handled by one of the above syntaxes and is
44
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
45
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
46
- // U+005A), or [a-z] (U+0061 to U+007A), […]
47
- if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
48
- // the character itself
49
- result += string.charAt(index);
50
- continue;
51
- }
52
- // Otherwise, the escaped character.
53
- // https://drafts.csswg.org/cssom/#escape-a-character
54
- result += '\\' + string.charAt(index);
55
- }
56
- return result;
57
- };
58
- if (!root.CSS) {
59
- root.CSS = {};
60
- }
61
- root.CSS.escape = cssEscape;
62
- globalThis.CSS.escape = cssEscape;
63
- }
64
- })();
4
+ var hasRequiredCssEscape;
5
+
6
+ function requireCssEscape () {
7
+ if (hasRequiredCssEscape) return cssEscape;
8
+ hasRequiredCssEscape = 1;
9
+ (()=>{
10
+ const root = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : window;
11
+ if (!root.CSS && !root.CSS?.escape) {
12
+ // https://drafts.csswg.org/cssom/#serialize-an-identifier
13
+ const cssEscape = function(value) {
14
+ if (arguments.length == 0) {
15
+ throw new TypeError('`CSS.escape` requires an argument.');
16
+ }
17
+ const string = String(value);
18
+ const length = string.length;
19
+ let index = -1;
20
+ let result = '';
21
+ let codeUnit;
22
+ const firstCodeUnit = string.charCodeAt(0);
23
+ if (// If the character is the first character and is a `-` (U+002D), and
24
+ // there is no second character, […]
25
+ length == 1 && firstCodeUnit == 0x002D) {
26
+ return '\\' + string;
27
+ }
28
+ while(++index < length){
29
+ codeUnit = string.charCodeAt(index);
30
+ // Note: there’s no need to special-case astral symbols, surrogate
31
+ // pairs, or lone surrogates.
32
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
33
+ // (U+FFFD).
34
+ if (codeUnit == 0x0000) {
35
+ result += '\uFFFD';
36
+ continue;
37
+ }
38
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
39
+ // U+007F, […]
40
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
41
+ // (U+0030 to U+0039), […]
42
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
43
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
44
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
45
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
46
+ result += '\\' + codeUnit.toString(16) + ' ';
47
+ continue;
48
+ }
49
+ // If the character is not handled by one of the above syntaxes and is
50
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
51
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
52
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
53
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
54
+ // the character itself
55
+ result += string.charAt(index);
56
+ continue;
57
+ }
58
+ // Otherwise, the escaped character.
59
+ // https://drafts.csswg.org/cssom/#escape-a-character
60
+ result += '\\' + string.charAt(index);
61
+ }
62
+ return result;
63
+ };
64
+ if (!root.CSS) {
65
+ root.CSS = {};
66
+ }
67
+ root.CSS.escape = cssEscape;
68
+ globalThis.CSS.escape = cssEscape;
69
+ }
70
+ })();
71
+ return cssEscape;
72
+ }
73
+
74
+ export { requireCssEscape as __require };
package/dist/rule.cjs CHANGED
@@ -31,7 +31,6 @@ class Rule {
31
31
  for (const eachValueComponent of valueComponents){
32
32
  switch(eachValueComponent.type){
33
33
  case 'function':
34
- // eslint-disable-next-line no-case-declarations
35
34
  const functionDefinition = functions && functions[eachValueComponent.name];
36
35
  if (functionDefinition?.transform && !eachValueComponent.bypassTransform) {
37
36
  const result = functionDefinition.transform.call(this, this.resolveValue(eachValueComponent.children, functionDefinition.unit ?? unit, bypassVariableNames, bypassParsing || eachValueComponent.name === 'calc'), bypassVariableNames);
@@ -42,7 +41,6 @@ class Rule {
42
41
  break;
43
42
  // todo: 應挪到 parseValues 階段處理才能支援 variables: { x: 'calc(20vw-30px)' } 這種情況,並且解析上可能會比較合理、精簡
44
43
  case 'variable':
45
- // eslint-disable-next-line no-case-declarations
46
44
  const variable = this.css.variables[eachValueComponent.name];
47
45
  if (variable) {
48
46
  const handleVariable = (normalHandler, varHandler)=>{
@@ -94,7 +92,6 @@ class Rule {
94
92
  });
95
93
  break;
96
94
  case 'color':
97
- // eslint-disable-next-line no-case-declarations
98
95
  const alpha = eachValueComponent.alpha ? '/' + eachValueComponent.alpha : '';
99
96
  handleVariable((variable)=>{
100
97
  currentValue += eachValueComponent.text = `${variable['space']}(${variable.value}${alpha})`;
@@ -515,7 +512,6 @@ class Rule {
515
512
  switch(featureName){
516
513
  case 'max-width':
517
514
  case 'min-width':
518
- // eslint-disable-next-line no-case-declarations
519
515
  if (typeof viewport === 'number') {
520
516
  atComponents.push({
521
517
  type: 'feature',
package/dist/rule.d.ts CHANGED
@@ -97,7 +97,7 @@ export interface Rule extends RegisteredRule {
97
97
  stateToken: string;
98
98
  atToken: string;
99
99
  hasWhere: boolean;
100
- valueComponents: Array<ValueComponent>;
100
+ valueComponents: ValueComponent[];
101
101
  }
102
102
  export interface RegisteredRule {
103
103
  id: string;
@@ -138,17 +138,15 @@ export interface NativeRule {
138
138
  text: string;
139
139
  cssRule?: CSSRule;
140
140
  }
141
- export type MediaFeatureComponent = {
141
+ export interface MediaFeatureComponent {
142
142
  type: string;
143
143
  tokenType?: string;
144
144
  operator?: string;
145
145
  value: number;
146
146
  unit: string;
147
- };
147
+ }
148
148
  export interface MediaQuery {
149
149
  token: string;
150
- features: {
151
- [key: string]: MediaFeatureComponent;
152
- };
150
+ features: Record<string, MediaFeatureComponent>;
153
151
  type?: string;
154
152
  }
package/dist/rule.mjs CHANGED
@@ -29,7 +29,6 @@ class Rule {
29
29
  for (const eachValueComponent of valueComponents){
30
30
  switch(eachValueComponent.type){
31
31
  case 'function':
32
- // eslint-disable-next-line no-case-declarations
33
32
  const functionDefinition = functions && functions[eachValueComponent.name];
34
33
  if (functionDefinition?.transform && !eachValueComponent.bypassTransform) {
35
34
  const result = functionDefinition.transform.call(this, this.resolveValue(eachValueComponent.children, functionDefinition.unit ?? unit, bypassVariableNames, bypassParsing || eachValueComponent.name === 'calc'), bypassVariableNames);
@@ -40,7 +39,6 @@ class Rule {
40
39
  break;
41
40
  // todo: 應挪到 parseValues 階段處理才能支援 variables: { x: 'calc(20vw-30px)' } 這種情況,並且解析上可能會比較合理、精簡
42
41
  case 'variable':
43
- // eslint-disable-next-line no-case-declarations
44
42
  const variable = this.css.variables[eachValueComponent.name];
45
43
  if (variable) {
46
44
  const handleVariable = (normalHandler, varHandler)=>{
@@ -92,7 +90,6 @@ class Rule {
92
90
  });
93
91
  break;
94
92
  case 'color':
95
- // eslint-disable-next-line no-case-declarations
96
93
  const alpha = eachValueComponent.alpha ? '/' + eachValueComponent.alpha : '';
97
94
  handleVariable((variable)=>{
98
95
  currentValue += eachValueComponent.text = `${variable['space']}(${variable.value}${alpha})`;
@@ -513,7 +510,6 @@ class Rule {
513
510
  switch(featureName){
514
511
  case 'max-width':
515
512
  case 'min-width':
516
- // eslint-disable-next-line no-case-declarations
517
513
  if (typeof viewport === 'number') {
518
514
  atComponents.push({
519
515
  type: 'feature',
@@ -47,8 +47,7 @@ function extendConfig(...configs) {
47
47
  at: {},
48
48
  variables: {}
49
49
  };
50
- for(let i = 0; i < formattedConfigs.length; i++){
51
- const currentFormattedConfig = formattedConfigs[i];
50
+ for (const currentFormattedConfig of formattedConfigs){
52
51
  for(const key in currentFormattedConfig){
53
52
  switch(key){
54
53
  case 'animations':
@@ -45,8 +45,7 @@ function extendConfig(...configs) {
45
45
  at: {},
46
46
  variables: {}
47
47
  };
48
- for(let i = 0; i < formattedConfigs.length; i++){
49
- const currentFormattedConfig = formattedConfigs[i];
48
+ for (const currentFormattedConfig of formattedConfigs){
50
49
  for(const key in currentFormattedConfig){
51
50
  switch(key){
52
51
  case 'animations':
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint src"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.0","@master/normal.css":"^3.1.0","@techor/extend":"^3.0.23","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.45"},"version":"2.0.0-rc.45"}
1
+ {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.0","@master/normal.css":"^3.1.0","@techor/extend":"^3.1.7","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.47"},"version":"2.0.0-rc.47"}