tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2

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 (112) hide show
  1. package/lib/cli/build/deps.js +10 -18
  2. package/lib/cli/build/index.js +10 -41
  3. package/lib/cli/build/plugin.js +87 -268
  4. package/lib/cli/build/utils.js +18 -40
  5. package/lib/cli/build/watching.js +35 -151
  6. package/lib/cli/help/index.js +15 -58
  7. package/lib/cli/index.js +61 -120
  8. package/lib/cli/init/index.js +21 -43
  9. package/lib/cli-peer-dependencies.js +13 -15
  10. package/lib/cli.js +1 -5
  11. package/lib/corePluginList.js +3 -4
  12. package/lib/corePlugins.js +394 -857
  13. package/lib/featureFlags.js +14 -34
  14. package/lib/index.js +1 -5
  15. package/lib/lib/cacheInvalidation.js +29 -75
  16. package/lib/lib/collapseAdjacentRules.js +22 -43
  17. package/lib/lib/collapseDuplicateDeclarations.js +27 -68
  18. package/lib/lib/content.js +37 -126
  19. package/lib/lib/defaultExtractor.js +96 -199
  20. package/lib/lib/detectNesting.js +12 -36
  21. package/lib/lib/evaluateTailwindFunctions.js +101 -188
  22. package/lib/lib/expandApplyAtRules.js +177 -482
  23. package/lib/lib/expandTailwindAtRules.js +69 -237
  24. package/lib/lib/findAtConfigPath.js +13 -30
  25. package/lib/lib/generateRules.js +349 -765
  26. package/lib/lib/getModuleDependencies.js +27 -63
  27. package/lib/lib/load-config.js +16 -24
  28. package/lib/lib/normalizeTailwindDirectives.js +26 -70
  29. package/lib/lib/offsets.js +61 -224
  30. package/lib/lib/partitionApplyAtRules.js +29 -51
  31. package/lib/lib/regex.js +22 -30
  32. package/lib/lib/remap-bitfield.js +9 -84
  33. package/lib/lib/resolveDefaultsAtRules.js +50 -116
  34. package/lib/lib/setupContextUtils.js +576 -1099
  35. package/lib/lib/setupTrackingContext.js +54 -143
  36. package/lib/lib/sharedState.js +15 -59
  37. package/lib/lib/substituteScreenAtRules.js +8 -16
  38. package/lib/oxide/cli/build/deps.js +17 -32
  39. package/lib/oxide/cli/build/index.js +10 -40
  40. package/lib/oxide/cli/build/plugin.js +87 -267
  41. package/lib/oxide/cli/build/utils.js +18 -39
  42. package/lib/oxide/cli/build/watching.js +34 -149
  43. package/lib/oxide/cli/help/index.js +15 -57
  44. package/lib/oxide/cli/index.js +66 -127
  45. package/lib/oxide/cli/init/index.js +17 -36
  46. package/lib/oxide/cli.js +2 -3
  47. package/lib/plugin.js +30 -57
  48. package/lib/postcss-plugins/nesting/index.js +6 -10
  49. package/lib/postcss-plugins/nesting/plugin.js +17 -60
  50. package/lib/processTailwindFeatures.js +8 -37
  51. package/lib/public/colors.js +15 -22
  52. package/lib/public/create-plugin.js +5 -8
  53. package/lib/public/default-config.js +5 -9
  54. package/lib/public/default-theme.js +5 -9
  55. package/lib/public/load-config.js +4 -6
  56. package/lib/public/resolve-config.js +4 -6
  57. package/lib/util/applyImportantSelector.js +15 -24
  58. package/lib/util/bigSign.js +6 -7
  59. package/lib/util/buildMediaQuery.js +10 -17
  60. package/lib/util/cloneDeep.js +9 -17
  61. package/lib/util/cloneNodes.js +14 -27
  62. package/lib/util/color.js +45 -81
  63. package/lib/util/configurePlugins.js +9 -16
  64. package/lib/util/createPlugin.js +8 -15
  65. package/lib/util/createUtilityPlugin.js +15 -27
  66. package/lib/util/dataTypes.js +23 -144
  67. package/lib/util/defaults.js +9 -19
  68. package/lib/util/escapeClassName.js +6 -10
  69. package/lib/util/escapeCommas.js +6 -7
  70. package/lib/util/flattenColorPalette.js +6 -8
  71. package/lib/util/formatVariantSelector.js +49 -190
  72. package/lib/util/getAllConfigs.js +35 -42
  73. package/lib/util/hashConfig.js +6 -8
  74. package/lib/util/isKeyframeRule.js +6 -7
  75. package/lib/util/isPlainObject.js +8 -11
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +13 -42
  77. package/lib/util/log.js +7 -14
  78. package/lib/util/nameClass.js +6 -21
  79. package/lib/util/negateValue.js +10 -26
  80. package/lib/util/normalizeConfig.js +63 -240
  81. package/lib/util/normalizeScreens.js +70 -137
  82. package/lib/util/parseAnimationValue.js +13 -61
  83. package/lib/util/parseBoxShadowValue.js +12 -57
  84. package/lib/util/parseDependency.js +13 -37
  85. package/lib/util/parseGlob.js +7 -22
  86. package/lib/util/parseObjectStyles.js +17 -26
  87. package/lib/util/pluginUtils.js +69 -176
  88. package/lib/util/prefixSelector.js +11 -28
  89. package/lib/util/pseudoElements.js +29 -105
  90. package/lib/util/removeAlphaVariables.js +8 -21
  91. package/lib/util/resolveConfig.js +103 -220
  92. package/lib/util/resolveConfigPath.js +12 -38
  93. package/lib/util/responsive.js +4 -6
  94. package/lib/util/splitAtTopLevelOnly.js +10 -44
  95. package/lib/util/tap.js +6 -8
  96. package/lib/util/toColorValue.js +6 -7
  97. package/lib/util/toPath.js +8 -26
  98. package/lib/util/transformThemeValue.js +12 -45
  99. package/lib/util/validateConfig.js +14 -22
  100. package/lib/util/validateFormalSyntax.js +5 -11
  101. package/lib/util/withAlphaVariable.js +28 -48
  102. package/package.json +3 -3
  103. package/peers/index.js +14 -16
  104. package/src/cli/build/plugin.js +1 -1
  105. package/src/cli.js +1 -1
  106. package/src/corePlugins.js +16 -17
  107. package/src/featureFlags.js +2 -3
  108. package/src/index.js +1 -5
  109. package/src/lib/expandTailwindAtRules.js +2 -2
  110. package/src/lib/sharedState.js +0 -15
  111. package/src/oxide/cli/build/plugin.ts +1 -1
  112. package/src/plugin.js +1 -1
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
3
+ value: !0
4
+ }), function(target, all) {
6
5
  for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
6
+ enumerable: !0,
8
7
  get: all[name]
9
8
  });
10
- }
11
- _export(exports, {
9
+ }(exports, {
12
10
  updateAllClasses: ()=>updateAllClasses,
13
11
  asValue: ()=>asValue,
14
12
  parseColorFormat: ()=>parseColorFormat,
@@ -18,12 +16,7 @@ _export(exports, {
18
16
  coerceValue: ()=>coerceValue,
19
17
  getMatchingTypes: ()=>getMatchingTypes
20
18
  });
21
- const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
22
- const _withAlphaVariable = require("./withAlphaVariable");
23
- const _dataTypes = require("./dataTypes");
24
- const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
25
- const _validateFormalSyntax = require("./validateFormalSyntax");
26
- const _featureFlagsJs = require("../featureFlags.js");
19
+ const _escapeCommas = _interopRequireDefault(require("./escapeCommas")), _withAlphaVariable = require("./withAlphaVariable"), _dataTypes = require("./dataTypes"), _negateValue = _interopRequireDefault(require("./negateValue")), _validateFormalSyntax = require("./validateFormalSyntax"), _featureFlagsJs = require("../featureFlags.js");
27
20
  function _interopRequireDefault(obj) {
28
21
  return obj && obj.__esModule ? obj : {
29
22
  default: obj
@@ -31,109 +24,55 @@ function _interopRequireDefault(obj) {
31
24
  }
32
25
  function updateAllClasses(selectors, updateClass) {
33
26
  selectors.walkClasses((sel)=>{
34
- sel.value = updateClass(sel.value);
35
- if (sel.raws && sel.raws.value) {
36
- sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
37
- }
27
+ sel.value = updateClass(sel.value), sel.raws && sel.raws.value && (sel.raws.value = (0, _escapeCommas.default)(sel.raws.value));
38
28
  });
39
29
  }
40
30
  function resolveArbitraryValue(modifier, validate) {
41
- if (!isArbitraryValue(modifier)) {
42
- return undefined;
43
- }
31
+ if (!isArbitraryValue(modifier)) return;
44
32
  let value = modifier.slice(1, -1);
45
- if (!validate(value)) {
46
- return undefined;
47
- }
48
- return (0, _dataTypes.normalize)(value);
49
- }
50
- function asNegativeValue(modifier, lookup = {}, validate) {
51
- let positiveValue = lookup[modifier];
52
- if (positiveValue !== undefined) {
53
- return (0, _negateValue.default)(positiveValue);
54
- }
55
- if (isArbitraryValue(modifier)) {
56
- let resolved = resolveArbitraryValue(modifier, validate);
57
- if (resolved === undefined) {
58
- return undefined;
59
- }
60
- return (0, _negateValue.default)(resolved);
61
- }
33
+ if (validate(value)) return (0, _dataTypes.normalize)(value);
62
34
  }
63
- function asValue(modifier, options = {}, { validate =()=>true } = {}) {
35
+ function asValue(modifier, options = {}, { validate =()=>!0 } = {}) {
64
36
  var _options_values;
65
- let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
66
- if (value !== undefined) {
67
- return value;
68
- }
69
- if (options.supportsNegativeValues && modifier.startsWith("-")) {
70
- return asNegativeValue(modifier.slice(1), options.values, validate);
71
- }
72
- return resolveArbitraryValue(modifier, validate);
37
+ let value = null === (_options_values = options.values) || void 0 === _options_values ? void 0 : _options_values[modifier];
38
+ return void 0 !== value ? value : options.supportsNegativeValues && modifier.startsWith("-") ? function(modifier, lookup = {}, validate) {
39
+ let positiveValue = lookup[modifier];
40
+ if (void 0 !== positiveValue) return (0, _negateValue.default)(positiveValue);
41
+ if (isArbitraryValue(modifier)) {
42
+ let resolved = resolveArbitraryValue(modifier, validate);
43
+ if (void 0 === resolved) return;
44
+ return (0, _negateValue.default)(resolved);
45
+ }
46
+ }(modifier.slice(1), options.values, validate) : resolveArbitraryValue(modifier, validate);
73
47
  }
74
48
  function isArbitraryValue(input) {
75
49
  return input.startsWith("[") && input.endsWith("]");
76
50
  }
77
51
  function splitUtilityModifier(modifier) {
78
52
  let slashIdx = modifier.lastIndexOf("/");
79
- if (slashIdx === -1 || slashIdx === modifier.length - 1) {
80
- return [
81
- modifier,
82
- undefined
83
- ];
84
- }
85
- let arbitrary = isArbitraryValue(modifier);
86
- // The modifier could be of the form `[foo]/[bar]`
87
- // We want to handle this case properly
88
- // without affecting `[foo/bar]`
89
- if (arbitrary && !modifier.includes("]/[")) {
90
- return [
91
- modifier,
92
- undefined
93
- ];
94
- }
95
- return [
53
+ return -1 === slashIdx || slashIdx === modifier.length - 1 || isArbitraryValue(modifier) && !modifier.includes("]/[") ? [
54
+ modifier,
55
+ void 0
56
+ ] : [
96
57
  modifier.slice(0, slashIdx),
97
58
  modifier.slice(slashIdx + 1)
98
59
  ];
99
60
  }
100
61
  function parseColorFormat(value) {
101
- if (typeof value === "string" && value.includes("<alpha-value>")) {
102
- let oldValue = value;
103
- return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
104
- }
105
- return value;
62
+ return "string" == typeof value && value.includes("<alpha-value>") ? ({ opacityValue =1 })=>value.replace("<alpha-value>", opacityValue) : value;
106
63
  }
107
64
  function unwrapArbitraryModifier(modifier) {
108
- modifier = modifier.slice(1, -1);
109
- if (modifier.startsWith("--")) {
110
- modifier = `var(${modifier})`;
111
- }
112
- return modifier;
65
+ return (modifier = modifier.slice(1, -1)).startsWith("--") && (modifier = `var(${modifier})`), modifier;
113
66
  }
114
67
  function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
115
- var _options_values;
116
- if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
117
- var _options_values1;
118
- return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
119
- }
120
- // TODO: Hoist this up to getMatchingTypes or something
121
- // We do this here because we need the alpha value (if any)
68
+ var _options_values, _options_values1, _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity, _options_values_color;
69
+ if ((null === (_options_values = options.values) || void 0 === _options_values ? void 0 : _options_values[modifier]) !== void 0) return parseColorFormat(null === (_options_values1 = options.values) || void 0 === _options_values1 ? void 0 : _options_values1[modifier]);
122
70
  let [color, alpha] = splitUtilityModifier(modifier);
123
- if (alpha !== undefined) {
124
- var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
125
- var _options_values_color;
126
- let normalizedColor = (_options_values_color = (_options_values2 = options.values) === null || _options_values2 === void 0 ? void 0 : _options_values2[color]) !== null && _options_values_color !== void 0 ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
127
- if (normalizedColor === undefined) {
128
- return undefined;
129
- }
130
- normalizedColor = parseColorFormat(normalizedColor);
131
- if (isArbitraryValue(alpha)) {
132
- return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
133
- }
134
- if (((_tailwindConfig_theme = tailwindConfig.theme) === null || _tailwindConfig_theme === void 0 ? void 0 : (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) === null || _tailwindConfig_theme_opacity === void 0 ? void 0 : _tailwindConfig_theme_opacity[alpha]) === undefined) {
135
- return undefined;
136
- }
71
+ if (void 0 !== alpha) {
72
+ let normalizedColor = null !== (_options_values_color = null === (_options_values2 = options.values) || void 0 === _options_values2 ? void 0 : _options_values2[color]) && void 0 !== _options_values_color ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : void 0;
73
+ if (void 0 === normalizedColor) return;
74
+ if (normalizedColor = parseColorFormat(normalizedColor), isArbitraryValue(alpha)) return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
75
+ if ((null === (_tailwindConfig_theme = tailwindConfig.theme) || void 0 === _tailwindConfig_theme ? void 0 : null === (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) || void 0 === _tailwindConfig_theme_opacity ? void 0 : _tailwindConfig_theme_opacity[alpha]) === void 0) return;
137
76
  return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
138
77
  }
139
78
  return asValue(modifier, options, {
@@ -142,14 +81,12 @@ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
142
81
  }
143
82
  function asLookupValue(modifier, options = {}) {
144
83
  var _options_values;
145
- return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
84
+ return null === (_options_values = options.values) || void 0 === _options_values ? void 0 : _options_values[modifier];
146
85
  }
147
86
  function guess(validate) {
148
- return (modifier, options)=>{
149
- return asValue(modifier, options, {
87
+ return (modifier, options)=>asValue(modifier, options, {
150
88
  validate
151
89
  });
152
- };
153
90
  }
154
91
  let typeMap = {
155
92
  any: asValue,
@@ -168,97 +105,53 @@ let typeMap = {
168
105
  "relative-size": guess(_dataTypes.relativeSize),
169
106
  shadow: guess(_dataTypes.shadow),
170
107
  size: guess(_validateFormalSyntax.backgroundSize)
171
- };
172
- let supportedTypes = Object.keys(typeMap);
173
- function splitAtFirst(input, delim) {
174
- let idx = input.indexOf(delim);
175
- if (idx === -1) return [
176
- undefined,
177
- input
178
- ];
179
- return [
180
- input.slice(0, idx),
181
- input.slice(idx + 1)
182
- ];
183
- }
108
+ }, supportedTypes = Object.keys(typeMap);
184
109
  function coerceValue(types, modifier, options, tailwindConfig) {
185
- if (options.values && modifier in options.values) {
186
- for (let { type } of types !== null && types !== void 0 ? types : []){
187
- let result = typeMap[type](modifier, options, {
188
- tailwindConfig
189
- });
190
- if (result === undefined) {
191
- continue;
192
- }
193
- return [
194
- result,
195
- type,
196
- null
197
- ];
198
- }
110
+ if (options.values && modifier in options.values) for (let { type } of null != types ? types : []){
111
+ let result = typeMap[type](modifier, options, {
112
+ tailwindConfig
113
+ });
114
+ if (void 0 !== result) return [
115
+ result,
116
+ type,
117
+ null
118
+ ];
199
119
  }
200
120
  if (isArbitraryValue(modifier)) {
201
- let arbitraryValue = modifier.slice(1, -1);
202
- let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
203
- // It could be that this resolves to `url(https` which is not a valid
204
- // identifier. We currently only support "simple" words with dashes or
205
- // underscores. E.g.: family-name
206
- if (!/^[\w-_]+$/g.test(explicitType)) {
207
- value = arbitraryValue;
208
- } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
209
- return [];
210
- }
211
- if (value.length > 0 && supportedTypes.includes(explicitType)) {
212
- return [
213
- asValue(`[${value}]`, options),
214
- explicitType,
215
- null
216
- ];
217
- }
218
- }
219
- let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
220
- // Find first matching type
221
- for (let match of matches){
222
- return match;
121
+ let idx, arbitraryValue = modifier.slice(1, -1), [explicitType, value] = -1 === (idx = arbitraryValue.indexOf(":")) ? [
122
+ void 0,
123
+ arbitraryValue
124
+ ] : [
125
+ arbitraryValue.slice(0, idx),
126
+ arbitraryValue.slice(idx + 1)
127
+ ];
128
+ if (/^[\w-_]+$/g.test(explicitType)) {
129
+ if (void 0 !== explicitType && !supportedTypes.includes(explicitType)) return [];
130
+ } else value = arbitraryValue;
131
+ if (value.length > 0 && supportedTypes.includes(explicitType)) return [
132
+ asValue(`[${value}]`, options),
133
+ explicitType,
134
+ null
135
+ ];
223
136
  }
137
+ for (let match of getMatchingTypes(types, modifier, options, tailwindConfig))return match;
224
138
  return [];
225
139
  }
226
140
  function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
227
- let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
228
- let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
229
- let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
230
- if (!canUseUtilityModifier) {
231
- modifier = rawModifier;
232
- utilityModifier = undefined;
141
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers"), [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
142
+ if (modifiersEnabled && null != options.modifiers && ("any" === options.modifiers || "object" == typeof options.modifiers && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers)) || (modifier = rawModifier, utilityModifier = void 0), void 0 !== utilityModifier && "" === modifier && (modifier = "DEFAULT"), void 0 !== utilityModifier && "object" == typeof options.modifiers) {
143
+ var _options_modifiers, _options_modifiers_utilityModifier;
144
+ let configValue = null !== (_options_modifiers_utilityModifier = null === (_options_modifiers = options.modifiers) || void 0 === _options_modifiers ? void 0 : _options_modifiers[utilityModifier]) && void 0 !== _options_modifiers_utilityModifier ? _options_modifiers_utilityModifier : null;
145
+ null !== configValue ? utilityModifier = configValue : isArbitraryValue(utilityModifier) && (utilityModifier = unwrapArbitraryModifier(utilityModifier));
233
146
  }
234
- if (utilityModifier !== undefined && modifier === "") {
235
- modifier = "DEFAULT";
236
- }
237
- // Check the full value first
238
- // TODO: Move to asValue… somehow
239
- if (utilityModifier !== undefined) {
240
- if (typeof options.modifiers === "object") {
241
- var _options_modifiers;
242
- var _options_modifiers_utilityModifier;
243
- let configValue = (_options_modifiers_utilityModifier = (_options_modifiers = options.modifiers) === null || _options_modifiers === void 0 ? void 0 : _options_modifiers[utilityModifier]) !== null && _options_modifiers_utilityModifier !== void 0 ? _options_modifiers_utilityModifier : null;
244
- if (configValue !== null) {
245
- utilityModifier = configValue;
246
- } else if (isArbitraryValue(utilityModifier)) {
247
- utilityModifier = unwrapArbitraryModifier(utilityModifier);
248
- }
249
- }
250
- }
251
- for (let { type } of types !== null && types !== void 0 ? types : []){
147
+ for (let { type } of null != types ? types : []){
252
148
  let result = typeMap[type](modifier, options, {
253
149
  tailwindConfig
254
150
  });
255
- if (result === undefined) {
256
- continue;
257
- }
258
- yield [
151
+ void 0 !== result && (yield [
259
152
  result,
260
153
  type,
261
- utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
262
- ];
154
+ null != utilityModifier ? utilityModifier : null
155
+ ]);
263
156
  }
264
157
  }
@@ -1,37 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, /**
6
- * @template {string | import('postcss-selector-parser').Root} T
7
- *
8
- * Prefix all classes in the selector with the given prefix
9
- *
10
- * It can take either a string or a selector AST and will return the same type
11
- *
12
- * @param {string} prefix
13
- * @param {T} selector
14
- * @param {boolean} prependNegative
15
- * @returns {T}
16
- */ "default", {
17
- enumerable: true,
3
+ value: !0
4
+ }), Object.defineProperty(exports, "default", {
5
+ enumerable: !0,
18
6
  get: ()=>_default
19
7
  });
20
- const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
21
- function _interopRequireDefault(obj) {
8
+ const _postcssSelectorParser = function(obj) {
22
9
  return obj && obj.__esModule ? obj : {
23
10
  default: obj
24
11
  };
25
- }
26
- function _default(prefix, selector, prependNegative = false) {
27
- if (prefix === "") {
28
- return selector;
29
- }
30
- let ast = typeof selector === "string" ? (0, _postcssSelectorParser.default)().astSync(selector) : selector;
31
- ast.walkClasses((classSelector)=>{
32
- let baseClass = classSelector.value;
33
- let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
12
+ }(require("postcss-selector-parser"));
13
+ function _default(prefix, selector, prependNegative = !1) {
14
+ if ("" === prefix) return selector;
15
+ let ast = "string" == typeof selector ? (0, _postcssSelectorParser.default)().astSync(selector) : selector;
16
+ return ast.walkClasses((classSelector)=>{
17
+ let baseClass = classSelector.value, shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
34
18
  classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
35
- });
36
- return typeof selector === "string" ? ast.toString() : ast;
19
+ }), "string" == typeof selector ? ast.toString() : ast;
37
20
  }
@@ -1,23 +1,8 @@
1
- /** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ // There are some pseudo-elements that may or may not be:
2
- // **Actionable**
3
- // Zero or more user-action pseudo-classes may be attached to the pseudo-element itself
4
- // structural-pseudo-classes are NOT allowed but we don't make
5
- // The spec is not clear on whether this is allowed or not — but in practice it is.
6
- // **Terminal**
7
- // It MUST be placed at the end of a selector
8
- //
9
- // This is the required in the spec. However, some pseudo elements are not "terminal" because
10
- // they represent a "boundary piercing" that is compiled out by a build step.
11
- // **Jumpable**
12
- // Any terminal element may "jump" over combinators when moving to the end of the selector
13
- //
14
- // This is a backwards-compat quirk of :before and :after variants.
15
- /** @typedef {'terminal' | 'actionable' | 'jumpable'} PseudoProperty */ /** @type {Record<string, PseudoProperty[]>} */ "use strict";
1
+ "use strict";
16
2
  Object.defineProperty(exports, "__esModule", {
17
- value: true
18
- });
19
- Object.defineProperty(exports, "movePseudos", {
20
- enumerable: true,
3
+ value: !0
4
+ }), Object.defineProperty(exports, "movePseudos", {
5
+ enumerable: !0,
21
6
  get: ()=>movePseudos
22
7
  });
23
8
  let elementProperties = {
@@ -71,7 +56,6 @@ let elementProperties = {
71
56
  "::target-text": [
72
57
  "terminal"
73
58
  ],
74
- // other
75
59
  "::file-selector-button": [
76
60
  "terminal",
77
61
  "actionable"
@@ -80,7 +64,6 @@ let elementProperties = {
80
64
  "terminal",
81
65
  "actionable"
82
66
  ],
83
- // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
84
67
  "::-webkit-scrollbar": [
85
68
  "terminal",
86
69
  "actionable"
@@ -109,10 +92,6 @@ let elementProperties = {
109
92
  "terminal",
110
93
  "actionable"
111
94
  ],
112
- // Note: As a rule, double colons (::) should be used instead of a single colon
113
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
114
- // this distinction was not present in older versions of the W3C spec, most
115
- // browsers support both syntaxes for the original pseudo-elements.
116
95
  ":after": [
117
96
  "terminal",
118
97
  "jumpable"
@@ -129,95 +108,40 @@ let elementProperties = {
129
108
  "terminal",
130
109
  "jumpable"
131
110
  ],
132
- // The default value is used when the pseudo-element is not recognized
133
- // Because it's not recognized, we don't know if it's terminal or not
134
- // So we assume it can't be moved AND can have user-action pseudo classes attached to it
135
111
  __default__: [
136
112
  "actionable"
137
113
  ]
138
114
  };
139
115
  function movePseudos(sel) {
140
- let [pseudos] = movablePseudos(sel);
141
- // Remove all pseudo elements from their respective selectors
142
- pseudos.forEach(([sel, pseudo])=>sel.removeChild(pseudo));
143
- // Re-add them to the end of the selector in the correct order.
144
- // This moves terminal pseudo elements to the end of the
145
- // selector otherwise the selector will not be valid.
146
- //
147
- // Examples:
148
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
149
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
150
- //
151
- // The selector `::before:hover` does not work but we
152
- // can make it work for you by flipping the order.
153
- sel.nodes.push(...pseudos.map(([, pseudo])=>pseudo));
154
- return sel;
155
- }
156
- /** @typedef {[sel: Selector, pseudo: Pseudo, attachedTo: Pseudo | null]} MovablePseudo */ /** @typedef {[pseudos: MovablePseudo[], lastSeenElement: Pseudo | null]} MovablePseudosResult */ /**
157
- * @param {Selector} sel
158
- * @returns {MovablePseudosResult}
159
- */ function movablePseudos(sel) {
160
- /** @type {MovablePseudo[]} */ let buffer = [];
161
- /** @type {Pseudo | null} */ let lastSeenElement = null;
162
- for (let node of sel.nodes){
163
- if (node.type === "combinator") {
164
- buffer = buffer.filter(([, node])=>propertiesForPseudo(node).includes("jumpable"));
165
- lastSeenElement = null;
166
- } else if (node.type === "pseudo") {
167
- if (isMovablePseudoElement(node)) {
168
- lastSeenElement = node;
169
- buffer.push([
170
- sel,
171
- node,
172
- null
173
- ]);
174
- } else if (lastSeenElement && isAttachablePseudoClass(node, lastSeenElement)) {
175
- buffer.push([
176
- sel,
177
- node,
178
- lastSeenElement
179
- ]);
180
- } else {
181
- lastSeenElement = null;
182
- }
183
- var _node_nodes;
184
- for (let sub of (_node_nodes = node.nodes) !== null && _node_nodes !== void 0 ? _node_nodes : []){
116
+ let [pseudos] = function movablePseudos(sel) {
117
+ let buffer = [], lastSeenElement = null;
118
+ for (let node2 of sel.nodes)if ("combinator" === node2.type) buffer = buffer.filter(([, node])=>propertiesForPseudo(node).includes("jumpable")), lastSeenElement = null;
119
+ else if ("pseudo" === node2.type) {
120
+ var _node_nodes, node, node1, pseudo;
121
+ for (let sub of (isPseudoElement(node = node2) && propertiesForPseudo(node).includes("terminal") ? (lastSeenElement = node2, buffer.push([
122
+ sel,
123
+ node2,
124
+ null
125
+ ])) : lastSeenElement && (node1 = node2, pseudo = lastSeenElement, !("pseudo" !== node1.type || isPseudoElement(node1)) && propertiesForPseudo(pseudo).includes("actionable")) ? buffer.push([
126
+ sel,
127
+ node2,
128
+ lastSeenElement
129
+ ]) : lastSeenElement = null, null !== (_node_nodes = node2.nodes) && void 0 !== _node_nodes ? _node_nodes : [])){
185
130
  let [movable, lastSeenElementInSub] = movablePseudos(sub);
186
- lastSeenElement = lastSeenElementInSub || lastSeenElement;
187
- buffer.push(...movable);
131
+ lastSeenElement = lastSeenElementInSub || lastSeenElement, buffer.push(...movable);
188
132
  }
189
133
  }
190
- }
191
- return [
192
- buffer,
193
- lastSeenElement
194
- ];
195
- }
196
- /**
197
- * @param {Node} node
198
- * @returns {boolean}
199
- */ function isPseudoElement(node) {
200
- return node.value.startsWith("::") || elementProperties[node.value] !== undefined;
201
- }
202
- /**
203
- * @param {Node} node
204
- * @returns {boolean}
205
- */ function isMovablePseudoElement(node) {
206
- return isPseudoElement(node) && propertiesForPseudo(node).includes("terminal");
134
+ return [
135
+ buffer,
136
+ lastSeenElement
137
+ ];
138
+ }(sel);
139
+ return pseudos.forEach(([sel, pseudo])=>sel.removeChild(pseudo)), sel.nodes.push(...pseudos.map(([, pseudo])=>pseudo)), sel;
207
140
  }
208
- /**
209
- * @param {Node} node
210
- * @param {Pseudo} pseudo
211
- * @returns {boolean}
212
- */ function isAttachablePseudoClass(node, pseudo) {
213
- if (node.type !== "pseudo") return false;
214
- if (isPseudoElement(node)) return false;
215
- return propertiesForPseudo(pseudo).includes("actionable");
141
+ function isPseudoElement(node) {
142
+ return node.value.startsWith("::") || void 0 !== elementProperties[node.value];
216
143
  }
217
- /**
218
- * @param {Pseudo} pseudo
219
- * @returns {PseudoProperty[]}
220
- */ function propertiesForPseudo(pseudo) {
144
+ function propertiesForPseudo(pseudo) {
221
145
  var _elementProperties_pseudo_value;
222
- return (_elementProperties_pseudo_value = elementProperties[pseudo.value]) !== null && _elementProperties_pseudo_value !== void 0 ? _elementProperties_pseudo_value : elementProperties.__default__;
146
+ return null !== (_elementProperties_pseudo_value = elementProperties[pseudo.value]) && void 0 !== _elementProperties_pseudo_value ? _elementProperties_pseudo_value : elementProperties.__default__;
223
147
  }
@@ -1,29 +1,16 @@
1
- /**
2
- * This function removes any uses of CSS variables used as an alpha channel
3
- *
4
- * This is required for selectors like `:visited` which do not allow
5
- * changes in opacity or external control using CSS variables.
6
- *
7
- * @param {import('postcss').Container} container
8
- * @param {string[]} toRemove
9
- */ "use strict";
10
- Object.defineProperty(exports, "__esModule", {
11
- value: true
12
- });
13
- Object.defineProperty(exports, "removeAlphaVariables", {
14
- enumerable: true,
15
- get: ()=>removeAlphaVariables
16
- });
1
+ "use strict";
17
2
  function removeAlphaVariables(container, toRemove) {
18
3
  container.walkDecls((decl)=>{
19
4
  if (toRemove.includes(decl.prop)) {
20
5
  decl.remove();
21
6
  return;
22
7
  }
23
- for (let varName of toRemove){
24
- if (decl.value.includes(`/ var(${varName})`)) {
25
- decl.value = decl.value.replace(`/ var(${varName})`, "");
26
- }
27
- }
8
+ for (let varName of toRemove)decl.value.includes(`/ var(${varName})`) && (decl.value = decl.value.replace(`/ var(${varName})`, ""));
28
9
  });
29
10
  }
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: !0
13
+ }), Object.defineProperty(exports, "removeAlphaVariables", {
14
+ enumerable: !0,
15
+ get: ()=>removeAlphaVariables
16
+ });