tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.7f555c4

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