tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.6bf5e56

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.
Files changed (176) hide show
  1. package/CHANGELOG.md +379 -3
  2. package/LICENSE +1 -2
  3. package/README.md +12 -8
  4. package/colors.d.ts +3 -0
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultTheme.d.ts +4 -0
  7. package/lib/cli/build/deps.js +54 -0
  8. package/lib/cli/build/index.js +48 -0
  9. package/lib/cli/build/plugin.js +367 -0
  10. package/lib/cli/build/utils.js +78 -0
  11. package/lib/cli/build/watching.js +178 -0
  12. package/lib/cli/help/index.js +71 -0
  13. package/lib/cli/index.js +18 -0
  14. package/lib/cli/init/index.js +46 -0
  15. package/lib/cli/shared.js +13 -0
  16. package/lib/cli-peer-dependencies.js +20 -7
  17. package/lib/cli.js +107 -611
  18. package/lib/constants.js +27 -20
  19. package/lib/corePluginList.js +6 -3
  20. package/lib/corePlugins.js +2064 -1811
  21. package/lib/css/preflight.css +5 -5
  22. package/lib/featureFlags.js +31 -22
  23. package/lib/index.js +28 -10
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +27 -9
  26. package/lib/lib/collapseDuplicateDeclarations.js +12 -9
  27. package/lib/lib/content.js +176 -0
  28. package/lib/lib/defaultExtractor.js +225 -31
  29. package/lib/lib/detectNesting.js +13 -10
  30. package/lib/lib/evaluateTailwindFunctions.js +118 -55
  31. package/lib/lib/expandApplyAtRules.js +439 -190
  32. package/lib/lib/expandTailwindAtRules.js +151 -134
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +454 -187
  35. package/lib/lib/getModuleDependencies.js +11 -8
  36. package/lib/lib/normalizeTailwindDirectives.js +36 -32
  37. package/lib/lib/offsets.js +217 -0
  38. package/lib/lib/partitionApplyAtRules.js +56 -0
  39. package/lib/lib/regex.js +60 -0
  40. package/lib/lib/resolveDefaultsAtRules.js +89 -67
  41. package/lib/lib/setupContextUtils.js +667 -376
  42. package/lib/lib/setupTrackingContext.js +38 -67
  43. package/lib/lib/sharedState.js +27 -14
  44. package/lib/lib/substituteScreenAtRules.js +11 -9
  45. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  46. package/lib/postcss-plugins/nesting/index.js +19 -0
  47. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  48. package/lib/processTailwindFeatures.js +35 -25
  49. package/lib/public/colors.js +247 -245
  50. package/lib/public/create-plugin.js +6 -4
  51. package/lib/public/default-config.js +7 -5
  52. package/lib/public/default-theme.js +7 -5
  53. package/lib/public/resolve-config.js +8 -5
  54. package/lib/util/bigSign.js +4 -1
  55. package/lib/util/buildMediaQuery.js +11 -6
  56. package/lib/util/cloneDeep.js +7 -6
  57. package/lib/util/cloneNodes.js +21 -3
  58. package/lib/util/color.js +53 -54
  59. package/lib/util/configurePlugins.js +5 -2
  60. package/lib/util/createPlugin.js +6 -6
  61. package/lib/util/createUtilityPlugin.js +12 -14
  62. package/lib/util/dataTypes.js +119 -110
  63. package/lib/util/defaults.js +4 -1
  64. package/lib/util/escapeClassName.js +7 -4
  65. package/lib/util/escapeCommas.js +5 -2
  66. package/lib/util/flattenColorPalette.js +9 -12
  67. package/lib/util/formatVariantSelector.js +184 -85
  68. package/lib/util/getAllConfigs.js +27 -8
  69. package/lib/util/hashConfig.js +6 -3
  70. package/lib/util/isKeyframeRule.js +5 -2
  71. package/lib/util/isPlainObject.js +5 -2
  72. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
  73. package/lib/util/log.js +20 -14
  74. package/lib/util/nameClass.js +20 -9
  75. package/lib/util/negateValue.js +23 -8
  76. package/lib/util/normalizeConfig.js +116 -72
  77. package/lib/util/normalizeScreens.js +120 -11
  78. package/lib/util/parseAnimationValue.js +42 -40
  79. package/lib/util/parseBoxShadowValue.js +30 -23
  80. package/lib/util/parseDependency.js +38 -56
  81. package/lib/util/parseGlob.js +34 -0
  82. package/lib/util/parseObjectStyles.js +11 -8
  83. package/lib/util/pluginUtils.js +147 -50
  84. package/lib/util/prefixSelector.js +10 -8
  85. package/lib/util/removeAlphaVariables.js +29 -0
  86. package/lib/util/resolveConfig.js +97 -85
  87. package/lib/util/resolveConfigPath.js +11 -9
  88. package/lib/util/responsive.js +8 -5
  89. package/lib/util/splitAtTopLevelOnly.js +43 -0
  90. package/lib/util/tap.js +4 -1
  91. package/lib/util/toColorValue.js +5 -3
  92. package/lib/util/toPath.js +20 -4
  93. package/lib/util/transformThemeValue.js +37 -29
  94. package/lib/util/validateConfig.js +24 -0
  95. package/lib/util/validateFormalSyntax.js +24 -0
  96. package/lib/util/withAlphaVariable.js +23 -15
  97. package/nesting/index.js +2 -12
  98. package/package.json +47 -42
  99. package/peers/index.js +11381 -7950
  100. package/plugin.d.ts +11 -0
  101. package/resolveConfig.d.ts +12 -0
  102. package/scripts/generate-types.js +105 -0
  103. package/scripts/release-channel.js +18 -0
  104. package/scripts/release-notes.js +21 -0
  105. package/scripts/type-utils.js +27 -0
  106. package/src/cli/build/deps.js +56 -0
  107. package/src/cli/build/index.js +49 -0
  108. package/src/cli/build/plugin.js +439 -0
  109. package/src/cli/build/utils.js +76 -0
  110. package/src/cli/build/watching.js +227 -0
  111. package/src/cli/help/index.js +70 -0
  112. package/src/cli/index.js +3 -0
  113. package/src/cli/init/index.js +50 -0
  114. package/src/cli/shared.js +6 -0
  115. package/src/cli-peer-dependencies.js +7 -1
  116. package/src/cli.js +50 -629
  117. package/src/corePluginList.js +1 -1
  118. package/src/corePlugins.js +532 -217
  119. package/src/css/preflight.css +5 -5
  120. package/src/featureFlags.js +15 -9
  121. package/src/index.js +20 -1
  122. package/src/lib/cacheInvalidation.js +52 -0
  123. package/src/lib/collapseAdjacentRules.js +21 -2
  124. package/src/lib/content.js +212 -0
  125. package/src/lib/defaultExtractor.js +196 -33
  126. package/src/lib/evaluateTailwindFunctions.js +78 -7
  127. package/src/lib/expandApplyAtRules.js +482 -183
  128. package/src/lib/expandTailwindAtRules.js +106 -85
  129. package/src/lib/findAtConfigPath.js +48 -0
  130. package/src/lib/generateRules.js +418 -129
  131. package/src/lib/normalizeTailwindDirectives.js +1 -0
  132. package/src/lib/offsets.js +270 -0
  133. package/src/lib/partitionApplyAtRules.js +52 -0
  134. package/src/lib/regex.js +74 -0
  135. package/src/lib/resolveDefaultsAtRules.js +51 -30
  136. package/src/lib/setupContextUtils.js +556 -208
  137. package/src/lib/setupTrackingContext.js +11 -48
  138. package/src/lib/sharedState.js +5 -0
  139. package/src/postcss-plugins/nesting/README.md +42 -0
  140. package/src/postcss-plugins/nesting/index.js +13 -0
  141. package/src/postcss-plugins/nesting/plugin.js +80 -0
  142. package/src/processTailwindFeatures.js +8 -0
  143. package/src/util/buildMediaQuery.js +5 -3
  144. package/src/util/cloneNodes.js +19 -2
  145. package/src/util/color.js +25 -21
  146. package/src/util/dataTypes.js +29 -21
  147. package/src/util/formatVariantSelector.js +184 -61
  148. package/src/util/getAllConfigs.js +19 -0
  149. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  150. package/src/util/log.js +8 -8
  151. package/src/util/nameClass.js +4 -0
  152. package/src/util/negateValue.js +11 -3
  153. package/src/util/normalizeConfig.js +44 -6
  154. package/src/util/normalizeScreens.js +99 -4
  155. package/src/util/parseBoxShadowValue.js +4 -3
  156. package/src/util/parseDependency.js +37 -42
  157. package/src/util/parseGlob.js +24 -0
  158. package/src/util/pluginUtils.js +132 -10
  159. package/src/util/prefixSelector.js +7 -5
  160. package/src/util/removeAlphaVariables.js +24 -0
  161. package/src/util/resolveConfig.js +70 -32
  162. package/src/util/splitAtTopLevelOnly.js +45 -0
  163. package/src/util/toPath.js +1 -1
  164. package/src/util/transformThemeValue.js +13 -3
  165. package/src/util/validateConfig.js +13 -0
  166. package/src/util/validateFormalSyntax.js +34 -0
  167. package/src/util/withAlphaVariable.js +1 -1
  168. package/stubs/defaultConfig.stub.js +23 -20
  169. package/stubs/simpleConfig.stub.js +1 -0
  170. package/types/config.d.ts +362 -0
  171. package/types/generated/.gitkeep +0 -0
  172. package/types/generated/colors.d.ts +276 -0
  173. package/types/generated/corePluginList.d.ts +1 -0
  174. package/types/generated/default-theme.d.ts +342 -0
  175. package/types/index.d.ts +7 -0
  176. package/nesting/plugin.js +0 -41
@@ -2,19 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = getModuleDependencies;
6
- var _fs = _interopRequireDefault(require("fs"));
7
- var _path = _interopRequireDefault(require("path"));
8
- var _resolve = _interopRequireDefault(require("resolve"));
9
- var _detective = _interopRequireDefault(require("detective"));
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>getModuleDependencies
8
+ });
9
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
+ const _resolve = /*#__PURE__*/ _interopRequireDefault(require("resolve"));
12
+ const _detective = /*#__PURE__*/ _interopRequireDefault(require("detective"));
10
13
  function _interopRequireDefault(obj) {
11
14
  return obj && obj.__esModule ? obj : {
12
15
  default: obj
13
16
  };
14
17
  }
15
18
  function createModule(file) {
16
- const source = _fs.default.readFileSync(file, 'utf-8');
17
- const requires = (0, _detective).default(source);
19
+ const source = _fs.default.readFileSync(file, "utf-8");
20
+ const requires = (0, _detective.default)(source);
18
21
  return {
19
22
  file,
20
23
  requires
@@ -30,7 +33,7 @@ function getModuleDependencies(entryFile) {
30
33
  for (const mdl of modules){
31
34
  mdl.requires.filter((dep)=>{
32
35
  // Only track local modules, not node_modules
33
- return dep.startsWith('./') || dep.startsWith('../');
36
+ return dep.startsWith("./") || dep.startsWith("../");
34
37
  }).forEach((dep)=>{
35
38
  try {
36
39
  const basedir = _path.default.dirname(mdl.file);
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = normalizeTailwindDirectives;
6
- var _log = _interopRequireDefault(require("../util/log"));
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>normalizeTailwindDirectives
8
+ });
9
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
7
10
  function _interopRequireDefault(obj) {
8
11
  return obj && obj.__esModule ? obj : {
9
12
  default: obj
@@ -14,64 +17,65 @@ function normalizeTailwindDirectives(root) {
14
17
  let layerDirectives = new Set();
15
18
  let applyDirectives = new Set();
16
19
  root.walkAtRules((atRule)=>{
17
- if (atRule.name === 'apply') {
20
+ if (atRule.name === "apply") {
18
21
  applyDirectives.add(atRule);
19
22
  }
20
- if (atRule.name === 'import') {
23
+ if (atRule.name === "import") {
21
24
  if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
22
- atRule.name = 'tailwind';
23
- atRule.params = 'base';
25
+ atRule.name = "tailwind";
26
+ atRule.params = "base";
24
27
  } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
25
- atRule.name = 'tailwind';
26
- atRule.params = 'components';
28
+ atRule.name = "tailwind";
29
+ atRule.params = "components";
27
30
  } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
28
- atRule.name = 'tailwind';
29
- atRule.params = 'utilities';
31
+ atRule.name = "tailwind";
32
+ atRule.params = "utilities";
30
33
  } else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
31
- atRule.name = 'tailwind';
32
- atRule.params = 'variants';
34
+ atRule.name = "tailwind";
35
+ atRule.params = "variants";
33
36
  }
34
37
  }
35
- if (atRule.name === 'tailwind') {
36
- if (atRule.params === 'screens') {
37
- atRule.params = 'variants';
38
+ if (atRule.name === "tailwind") {
39
+ if (atRule.params === "screens") {
40
+ atRule.params = "variants";
38
41
  }
39
42
  tailwindDirectives.add(atRule.params);
40
43
  }
41
44
  if ([
42
- 'layer',
43
- 'responsive',
44
- 'variants'
45
+ "layer",
46
+ "responsive",
47
+ "variants"
45
48
  ].includes(atRule.name)) {
46
49
  if ([
47
- 'responsive',
48
- 'variants'
50
+ "responsive",
51
+ "variants"
49
52
  ].includes(atRule.name)) {
50
53
  _log.default.warn(`${atRule.name}-at-rule-deprecated`, [
51
54
  `The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
52
- `Use \`@layer utilities\` or \`@layer components\` instead.`,
55
+ `Use \`@layer utilities\` or \`@layer components\` instead.`,
56
+ "https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer"
53
57
  ]);
54
58
  }
55
59
  layerDirectives.add(atRule);
56
60
  }
57
61
  });
58
- if (!tailwindDirectives.has('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
62
+ if (!tailwindDirectives.has("base") || !tailwindDirectives.has("components") || !tailwindDirectives.has("utilities")) {
59
63
  for (let rule of layerDirectives){
60
- if (rule.name === 'layer' && [
61
- 'base',
62
- 'components',
63
- 'utilities'
64
+ if (rule.name === "layer" && [
65
+ "base",
66
+ "components",
67
+ "utilities"
64
68
  ].includes(rule.params)) {
65
69
  if (!tailwindDirectives.has(rule.params)) {
66
70
  throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
67
71
  }
68
- } else if (rule.name === 'responsive') {
69
- if (!tailwindDirectives.has('utilities')) {
70
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
72
+ } else if (rule.name === "responsive") {
73
+ if (!tailwindDirectives.has("utilities")) {
74
+ throw rule.error("`@responsive` is used but `@tailwind utilities` is missing.");
71
75
  }
72
- } else if (rule.name === 'variants') {
73
- if (!tailwindDirectives.has('utilities')) {
74
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
76
+ } else if (rule.name === "variants") {
77
+ if (!tailwindDirectives.has("utilities")) {
78
+ throw rule.error("`@variants` is used but `@tailwind utilities` is missing.");
75
79
  }
76
80
  }
77
81
  }
@@ -0,0 +1,217 @@
1
+ // @ts-check
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Offsets", {
7
+ enumerable: true,
8
+ get: ()=>Offsets
9
+ });
10
+ const _bigSign = /*#__PURE__*/ _interopRequireDefault(require("../util/bigSign"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ class Offsets {
17
+ constructor(){
18
+ /**
19
+ * Offsets for the next rule in a given layer
20
+ *
21
+ * @type {Record<Layer, bigint>}
22
+ */ this.offsets = {
23
+ defaults: 0n,
24
+ base: 0n,
25
+ components: 0n,
26
+ utilities: 0n,
27
+ variants: 0n,
28
+ user: 0n
29
+ };
30
+ /**
31
+ * Positions for a given layer
32
+ *
33
+ * @type {Record<Layer, bigint>}
34
+ */ this.layerPositions = {
35
+ defaults: 0n,
36
+ base: 1n,
37
+ components: 2n,
38
+ utilities: 3n,
39
+ // There isn't technically a "user" layer, but we need to give it a position
40
+ // Because it's used for ordering user-css from @apply
41
+ user: 4n,
42
+ variants: 5n
43
+ };
44
+ /**
45
+ * The total number of functions currently registered across all variants (including arbitrary variants)
46
+ *
47
+ * @type {bigint}
48
+ */ this.reservedVariantBits = 0n;
49
+ /**
50
+ * Positions for a given variant
51
+ *
52
+ * @type {Map<string, bigint>}
53
+ */ this.variantOffsets = new Map();
54
+ }
55
+ /**
56
+ * @param {Layer} layer
57
+ * @returns {RuleOffset}
58
+ */ create(layer) {
59
+ return {
60
+ layer,
61
+ parentLayer: layer,
62
+ arbitrary: 0n,
63
+ variants: 0n,
64
+ parallelIndex: 0n,
65
+ index: this.offsets[layer]++,
66
+ options: []
67
+ };
68
+ }
69
+ /**
70
+ * @returns {RuleOffset}
71
+ */ arbitraryProperty() {
72
+ return {
73
+ ...this.create("utilities"),
74
+ arbitrary: 1n
75
+ };
76
+ }
77
+ /**
78
+ * Get the offset for a variant
79
+ *
80
+ * @param {string} variant
81
+ * @param {number} index
82
+ * @returns {RuleOffset}
83
+ */ forVariant(variant, index = 0) {
84
+ let offset = this.variantOffsets.get(variant);
85
+ if (offset === undefined) {
86
+ throw new Error(`Cannot find offset for unknown variant ${variant}`);
87
+ }
88
+ return {
89
+ ...this.create("variants"),
90
+ variants: offset << BigInt(index)
91
+ };
92
+ }
93
+ /**
94
+ * @param {RuleOffset} rule
95
+ * @param {RuleOffset} variant
96
+ * @param {VariantOption} options
97
+ * @returns {RuleOffset}
98
+ */ applyVariantOffset(rule, variant, options) {
99
+ return {
100
+ ...rule,
101
+ layer: "variants",
102
+ parentLayer: rule.layer === "variants" ? rule.parentLayer : rule.layer,
103
+ variants: rule.variants | variant.variants,
104
+ options: options.sort ? [].concat(options, rule.options) : rule.options,
105
+ // TODO: Technically this is wrong. We should be handling parallel index on a per variant basis.
106
+ // We'll take the max of all the parallel indexes for now.
107
+ // @ts-ignore
108
+ parallelIndex: max([
109
+ rule.parallelIndex,
110
+ variant.parallelIndex
111
+ ])
112
+ };
113
+ }
114
+ /**
115
+ * @param {RuleOffset} offset
116
+ * @param {number} parallelIndex
117
+ * @returns {RuleOffset}
118
+ */ applyParallelOffset(offset, parallelIndex) {
119
+ return {
120
+ ...offset,
121
+ parallelIndex: BigInt(parallelIndex)
122
+ };
123
+ }
124
+ /**
125
+ * Each variant gets 1 bit per function / rule registered.
126
+ * This is because multiple variants can be applied to a single rule and we need to know which ones are present and which ones are not.
127
+ * Additionally, every unique group of variants is grouped together in the stylesheet.
128
+ *
129
+ * This grouping is order-independent. For instance, we do not differentiate between `hover:focus` and `focus:hover`.
130
+ *
131
+ * @param {string[]} variants
132
+ * @param {(name: string) => number} getLength
133
+ */ recordVariants(variants, getLength) {
134
+ for (let variant of variants){
135
+ this.recordVariant(variant, getLength(variant));
136
+ }
137
+ }
138
+ /**
139
+ * The same as `recordVariants` but for a single arbitrary variant at runtime.
140
+ * @param {string} variant
141
+ * @param {number} fnCount
142
+ *
143
+ * @returns {RuleOffset} The highest offset for this variant
144
+ */ recordVariant(variant, fnCount = 1) {
145
+ this.variantOffsets.set(variant, 1n << this.reservedVariantBits);
146
+ // Ensure space is reserved for each "function" in the parallel variant
147
+ // by offsetting the next variant by the number of parallel variants
148
+ // in the one we just added.
149
+ // Single functions that return parallel variants are NOT handled separately here
150
+ // They're offset by 1 (or the number of functions) as usual
151
+ // And each rule returned is tracked separately since the functions are evaluated lazily.
152
+ // @see `RuleOffset.parallelIndex`
153
+ this.reservedVariantBits += BigInt(fnCount);
154
+ return {
155
+ ...this.create("variants"),
156
+ variants: 1n << this.reservedVariantBits
157
+ };
158
+ }
159
+ /**
160
+ * @param {RuleOffset} a
161
+ * @param {RuleOffset} b
162
+ * @returns {bigint}
163
+ */ compare(a, b) {
164
+ // Sort layers together
165
+ if (a.layer !== b.layer) {
166
+ return this.layerPositions[a.layer] - this.layerPositions[b.layer];
167
+ }
168
+ // Sort based on the sorting function
169
+ for (let aOptions of a.options){
170
+ for (let bOptions of b.options){
171
+ if (aOptions.id !== bOptions.id) continue;
172
+ if (!aOptions.sort || !bOptions.sort) continue;
173
+ let result = aOptions.sort({
174
+ value: aOptions.value,
175
+ modifier: aOptions.modifier
176
+ }, {
177
+ value: bOptions.value,
178
+ modifier: bOptions.modifier
179
+ });
180
+ if (result !== 0) return result;
181
+ }
182
+ }
183
+ // Sort variants in the order they were registered
184
+ if (a.variants !== b.variants) {
185
+ return a.variants - b.variants;
186
+ }
187
+ // Make sure each rule returned by a parallel variant is sorted in ascending order
188
+ if (a.parallelIndex !== b.parallelIndex) {
189
+ return a.parallelIndex - b.parallelIndex;
190
+ }
191
+ // Always sort arbitrary properties after other utilities
192
+ if (a.arbitrary !== b.arbitrary) {
193
+ return a.arbitrary - b.arbitrary;
194
+ }
195
+ // Sort utilities, components, etc… in the order they were registered
196
+ return a.index - b.index;
197
+ }
198
+ /**
199
+ * @template T
200
+ * @param {[RuleOffset, T][]} list
201
+ * @returns {[RuleOffset, T][]}
202
+ */ sort(list) {
203
+ return list.sort(([a], [b])=>(0, _bigSign.default)(this.compare(a, b)));
204
+ }
205
+ }
206
+ /**
207
+ *
208
+ * @param {bigint[]} nums
209
+ * @returns {bigint|null}
210
+ */ function max(nums) {
211
+ let max = null;
212
+ for (const num of nums){
213
+ max = max !== null && max !== void 0 ? max : num;
214
+ max = max > num ? max : num;
215
+ }
216
+ return max;
217
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>expandApplyAtRules
8
+ });
9
+ function partitionRules(root) {
10
+ if (!root.walkAtRules) return;
11
+ let applyParents = new Set();
12
+ root.walkAtRules("apply", (rule)=>{
13
+ applyParents.add(rule.parent);
14
+ });
15
+ if (applyParents.size === 0) {
16
+ return;
17
+ }
18
+ for (let rule of applyParents){
19
+ let nodeGroups = [];
20
+ let lastGroup = [];
21
+ for (let node of rule.nodes){
22
+ if (node.type === "atrule" && node.name === "apply") {
23
+ if (lastGroup.length > 0) {
24
+ nodeGroups.push(lastGroup);
25
+ lastGroup = [];
26
+ }
27
+ nodeGroups.push([
28
+ node
29
+ ]);
30
+ } else {
31
+ lastGroup.push(node);
32
+ }
33
+ }
34
+ if (lastGroup.length > 0) {
35
+ nodeGroups.push(lastGroup);
36
+ }
37
+ if (nodeGroups.length === 1) {
38
+ continue;
39
+ }
40
+ for (let group of [
41
+ ...nodeGroups
42
+ ].reverse()){
43
+ let clone = rule.clone({
44
+ nodes: []
45
+ });
46
+ clone.append(group);
47
+ rule.after(clone);
48
+ }
49
+ rule.remove();
50
+ }
51
+ }
52
+ function expandApplyAtRules() {
53
+ return (root)=>{
54
+ partitionRules(root);
55
+ };
56
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ pattern: ()=>pattern,
13
+ withoutCapturing: ()=>withoutCapturing,
14
+ any: ()=>any,
15
+ optional: ()=>optional,
16
+ zeroOrMore: ()=>zeroOrMore,
17
+ nestedBrackets: ()=>nestedBrackets,
18
+ escape: ()=>escape
19
+ });
20
+ const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
21
+ const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
22
+ /**
23
+ * @param {string|RegExp|Array<string|RegExp>} source
24
+ */ function toSource(source) {
25
+ source = Array.isArray(source) ? source : [
26
+ source
27
+ ];
28
+ source = source.map((item)=>item instanceof RegExp ? item.source : item);
29
+ return source.join("");
30
+ }
31
+ function pattern(source) {
32
+ return new RegExp(toSource(source), "g");
33
+ }
34
+ function withoutCapturing(source) {
35
+ return new RegExp(`(?:${toSource(source)})`, "g");
36
+ }
37
+ function any(sources) {
38
+ return `(?:${sources.map(toSource).join("|")})`;
39
+ }
40
+ function optional(source) {
41
+ return `(?:${toSource(source)})?`;
42
+ }
43
+ function zeroOrMore(source) {
44
+ return `(?:${toSource(source)})*`;
45
+ }
46
+ function nestedBrackets(open, close, depth = 1) {
47
+ return withoutCapturing([
48
+ escape(open),
49
+ /[^\s]*/,
50
+ depth === 1 ? `[^${escape(open)}${escape(close)}\s]*` : any([
51
+ `[^${escape(open)}${escape(close)}\s]*`,
52
+ nestedBrackets(open, close, depth - 1)
53
+ ]),
54
+ /[^\s]*/,
55
+ escape(close)
56
+ ]);
57
+ }
58
+ function escape(string) {
59
+ return string && REGEX_HAS_SPECIAL.test(string) ? string.replace(REGEX_SPECIAL, "\\$&") : string || "";
60
+ }