tailwindcss 0.0.0-insiders.ea10bb9 → 0.0.0-insiders.ea4e1cd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +20 -10
- package/lib/cli/build/plugin.js +86 -70
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +16 -12
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +222 -10
- package/lib/cli/init/index.js +29 -12
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +4 -226
- package/lib/corePluginList.js +7 -1
- package/lib/corePlugins.js +348 -75
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +27 -15
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +5 -3
- package/lib/lib/collapseDuplicateDeclarations.js +12 -10
- package/lib/lib/content.js +34 -30
- package/lib/lib/defaultExtractor.js +15 -8
- package/lib/lib/detectNesting.js +10 -2
- package/lib/lib/evaluateTailwindFunctions.js +22 -20
- package/lib/lib/expandApplyAtRules.js +43 -35
- package/lib/lib/expandTailwindAtRules.js +46 -19
- package/lib/lib/findAtConfigPath.js +9 -7
- package/lib/lib/generateRules.js +157 -92
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +93 -4
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +28 -24
- package/lib/lib/setupContextUtils.js +190 -131
- package/lib/lib/setupTrackingContext.js +49 -26
- package/lib/lib/sharedState.js +37 -10
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/oxide/cli/build/deps.js +89 -0
- package/lib/oxide/cli/build/index.js +53 -0
- package/lib/oxide/cli/build/plugin.js +375 -0
- package/lib/oxide/cli/build/utils.js +87 -0
- package/lib/oxide/cli/build/watching.js +179 -0
- package/lib/oxide/cli/help/index.js +72 -0
- package/lib/oxide/cli/index.js +214 -0
- package/lib/oxide/cli/init/index.js +52 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +14 -12
- package/lib/public/colors.js +49 -25
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +5 -3
- package/lib/util/color.js +30 -12
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +7 -5
- package/lib/util/dataTypes.js +74 -17
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +10 -8
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +138 -160
- package/lib/util/getAllConfigs.js +8 -6
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +8 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +4 -2
- package/lib/util/normalizeConfig.js +28 -27
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +54 -54
- package/lib/util/prefixSelector.js +27 -11
- package/lib/util/pseudoElements.js +229 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +17 -15
- package/lib/util/resolveConfigPath.js +26 -10
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +10 -2
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +16 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +45 -37
- package/peers/index.js +63324 -46417
- package/resolveConfig.d.ts +11 -2
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/index.js +13 -9
- package/src/cli/build/plugin.js +42 -32
- package/src/cli/build/watching.js +4 -2
- package/src/cli/index.js +216 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +4 -220
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +207 -32
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +6 -0
- package/src/index.js +1 -47
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandApplyAtRules.js +8 -1
- package/src/lib/expandTailwindAtRules.js +36 -7
- package/src/lib/generateRules.js +124 -42
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +31 -0
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +103 -54
- package/src/lib/setupTrackingContext.js +36 -11
- package/src/lib/sharedState.js +15 -4
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +442 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +18 -3
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +33 -4
- package/src/util/formatVariantSelector.js +160 -163
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +2 -1
- package/src/util/pluginUtils.js +16 -31
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +170 -0
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +13 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +183 -146
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +15 -9
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +108 -79
- package/CHANGELOG.md +0 -2336
- package/lib/cli/shared.js +0 -12
- package/lib/constants.js +0 -44
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
- package/src/constants.js +0 -17
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/lib/lib/offsets.js
CHANGED
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "Offsets", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return Offsets;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const _bigSign = /*#__PURE__*/
|
|
11
|
-
|
|
12
|
+
const _bigSign = /*#__PURE__*/ _interop_require_default(require("../util/bigSign"));
|
|
13
|
+
const _remapbitfield = require("./remap-bitfield.js");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
12
15
|
return obj && obj.__esModule ? obj : {
|
|
13
16
|
default: obj
|
|
14
17
|
};
|
|
@@ -96,6 +99,7 @@ class Offsets {
|
|
|
96
99
|
* @param {VariantOption} options
|
|
97
100
|
* @returns {RuleOffset}
|
|
98
101
|
*/ applyVariantOffset(rule, variant, options) {
|
|
102
|
+
options.variant = variant.variants;
|
|
99
103
|
return {
|
|
100
104
|
...rule,
|
|
101
105
|
layer: "variants",
|
|
@@ -153,7 +157,7 @@ class Offsets {
|
|
|
153
157
|
this.reservedVariantBits += BigInt(fnCount);
|
|
154
158
|
return {
|
|
155
159
|
...this.create("variants"),
|
|
156
|
-
variants:
|
|
160
|
+
variants: this.variantOffsets.get(variant)
|
|
157
161
|
};
|
|
158
162
|
}
|
|
159
163
|
/**
|
|
@@ -165,11 +169,29 @@ class Offsets {
|
|
|
165
169
|
if (a.layer !== b.layer) {
|
|
166
170
|
return this.layerPositions[a.layer] - this.layerPositions[b.layer];
|
|
167
171
|
}
|
|
172
|
+
// When sorting the `variants` layer, we need to sort based on the parent layer as well within
|
|
173
|
+
// this variants layer.
|
|
174
|
+
if (a.parentLayer !== b.parentLayer) {
|
|
175
|
+
return this.layerPositions[a.parentLayer] - this.layerPositions[b.parentLayer];
|
|
176
|
+
}
|
|
168
177
|
// Sort based on the sorting function
|
|
169
178
|
for (let aOptions of a.options){
|
|
170
179
|
for (let bOptions of b.options){
|
|
171
180
|
if (aOptions.id !== bOptions.id) continue;
|
|
172
181
|
if (!aOptions.sort || !bOptions.sort) continue;
|
|
182
|
+
var _max;
|
|
183
|
+
let maxFnVariant = (_max = max([
|
|
184
|
+
aOptions.variant,
|
|
185
|
+
bOptions.variant
|
|
186
|
+
])) !== null && _max !== void 0 ? _max : 0n;
|
|
187
|
+
// Create a mask of 0s from bits 1..N where N represents the mask of the Nth bit
|
|
188
|
+
let mask = ~(maxFnVariant | maxFnVariant - 1n);
|
|
189
|
+
let aVariantsAfterFn = a.variants & mask;
|
|
190
|
+
let bVariantsAfterFn = b.variants & mask;
|
|
191
|
+
// If the variants the same, we _can_ sort them
|
|
192
|
+
if (aVariantsAfterFn !== bVariantsAfterFn) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
173
195
|
let result = aOptions.sort({
|
|
174
196
|
value: aOptions.value,
|
|
175
197
|
modifier: aOptions.modifier
|
|
@@ -196,10 +218,57 @@ class Offsets {
|
|
|
196
218
|
return a.index - b.index;
|
|
197
219
|
}
|
|
198
220
|
/**
|
|
221
|
+
* Arbitrary variants are recorded in the order they're encountered.
|
|
222
|
+
* This means that the order is not stable between environments and sets of content files.
|
|
223
|
+
*
|
|
224
|
+
* In order to make the order stable, we need to remap the arbitrary variant offsets to
|
|
225
|
+
* be in alphabetical order starting from the offset of the first arbitrary variant.
|
|
226
|
+
*/ recalculateVariantOffsets() {
|
|
227
|
+
// Sort the variants by their name
|
|
228
|
+
let variants = Array.from(this.variantOffsets.entries()).filter(([v])=>v.startsWith("[")).sort(([a], [z])=>fastCompare(a, z));
|
|
229
|
+
// Sort the list of offsets
|
|
230
|
+
// This is not necessarily a discrete range of numbers which is why
|
|
231
|
+
// we're using sort instead of creating a range from min/max
|
|
232
|
+
let newOffsets = variants.map(([, offset])=>offset).sort((a, z)=>(0, _bigSign.default)(a - z));
|
|
233
|
+
// Create a map from the old offsets to the new offsets in the new sort order
|
|
234
|
+
/** @type {[bigint, bigint][]} */ let mapping = variants.map(([, oldOffset], i)=>[
|
|
235
|
+
oldOffset,
|
|
236
|
+
newOffsets[i]
|
|
237
|
+
]);
|
|
238
|
+
// Remove any variants that will not move letting us skip
|
|
239
|
+
// remapping if everything happens to be in order
|
|
240
|
+
return mapping.filter(([a, z])=>a !== z);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @template T
|
|
244
|
+
* @param {[RuleOffset, T][]} list
|
|
245
|
+
* @returns {[RuleOffset, T][]}
|
|
246
|
+
*/ remapArbitraryVariantOffsets(list) {
|
|
247
|
+
let mapping = this.recalculateVariantOffsets();
|
|
248
|
+
// No arbitrary variants? Nothing to do.
|
|
249
|
+
// Everyhing already in order? Nothing to do.
|
|
250
|
+
if (mapping.length === 0) {
|
|
251
|
+
return list;
|
|
252
|
+
}
|
|
253
|
+
// Remap every variant offset in the list
|
|
254
|
+
return list.map((item)=>{
|
|
255
|
+
let [offset, rule] = item;
|
|
256
|
+
offset = {
|
|
257
|
+
...offset,
|
|
258
|
+
variants: (0, _remapbitfield.remapBitfield)(offset.variants, mapping)
|
|
259
|
+
};
|
|
260
|
+
return [
|
|
261
|
+
offset,
|
|
262
|
+
rule
|
|
263
|
+
];
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
199
267
|
* @template T
|
|
200
268
|
* @param {[RuleOffset, T][]} list
|
|
201
269
|
* @returns {[RuleOffset, T][]}
|
|
202
270
|
*/ sort(list) {
|
|
271
|
+
list = this.remapArbitraryVariantOffsets(list);
|
|
203
272
|
return list.sort(([a], [b])=>(0, _bigSign.default)(this.compare(a, b)));
|
|
204
273
|
}
|
|
205
274
|
}
|
|
@@ -215,3 +284,23 @@ class Offsets {
|
|
|
215
284
|
}
|
|
216
285
|
return max;
|
|
217
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* A fast ASCII order string comparison function.
|
|
289
|
+
*
|
|
290
|
+
* Using `.sort()` without a custom compare function is faster
|
|
291
|
+
* But you can only use that if you're sorting an array of
|
|
292
|
+
* only strings. If you're sorting strings inside objects
|
|
293
|
+
* or arrays, you need must use a custom compare function.
|
|
294
|
+
*
|
|
295
|
+
* @param {string} a
|
|
296
|
+
* @param {string} b
|
|
297
|
+
*/ function fastCompare(a, b) {
|
|
298
|
+
let aLen = a.length;
|
|
299
|
+
let bLen = b.length;
|
|
300
|
+
let minLen = aLen < bLen ? aLen : bLen;
|
|
301
|
+
for(let i = 0; i < minLen; i++){
|
|
302
|
+
let cmp = a.charCodeAt(i) - b.charCodeAt(i);
|
|
303
|
+
if (cmp !== 0) return cmp;
|
|
304
|
+
}
|
|
305
|
+
return aLen - bLen;
|
|
306
|
+
}
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandApplyAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function partitionRules(root) {
|
|
10
12
|
if (!root.walkAtRules) return;
|
package/lib/lib/regex.js
CHANGED
|
@@ -9,13 +9,27 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
pattern: ()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
pattern: function() {
|
|
13
|
+
return pattern;
|
|
14
|
+
},
|
|
15
|
+
withoutCapturing: function() {
|
|
16
|
+
return withoutCapturing;
|
|
17
|
+
},
|
|
18
|
+
any: function() {
|
|
19
|
+
return any;
|
|
20
|
+
},
|
|
21
|
+
optional: function() {
|
|
22
|
+
return optional;
|
|
23
|
+
},
|
|
24
|
+
zeroOrMore: function() {
|
|
25
|
+
return zeroOrMore;
|
|
26
|
+
},
|
|
27
|
+
nestedBrackets: function() {
|
|
28
|
+
return nestedBrackets;
|
|
29
|
+
},
|
|
30
|
+
escape: function() {
|
|
31
|
+
return escape;
|
|
32
|
+
}
|
|
19
33
|
});
|
|
20
34
|
const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g;
|
|
21
35
|
const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* We must remap all the old bits to new bits for each set variant
|
|
4
|
+
* Only arbitrary variants are considered as those are the only
|
|
5
|
+
* ones that need to be re-sorted at this time
|
|
6
|
+
*
|
|
7
|
+
* An iterated process that removes and sets individual bits simultaneously
|
|
8
|
+
* will not work because we may have a new bit that is also a later old bit
|
|
9
|
+
* This means that we would be removing a previously set bit which we don't
|
|
10
|
+
* want to do
|
|
11
|
+
*
|
|
12
|
+
* For example (assume `bN` = `1<<N`)
|
|
13
|
+
* Given the "total" mapping `[[b1, b3], [b2, b4], [b3, b1], [b4, b2]]`
|
|
14
|
+
* The mapping is "total" because:
|
|
15
|
+
* 1. Every input and output is accounted for
|
|
16
|
+
* 2. All combinations are unique
|
|
17
|
+
* 3. No one input maps to multiple outputs and vice versa
|
|
18
|
+
* And, given an offset with all bits set:
|
|
19
|
+
* V = b1 | b2 | b3 | b4
|
|
20
|
+
*
|
|
21
|
+
* Let's explore the issue with removing and setting bits simultaneously:
|
|
22
|
+
* V & ~b1 | b3 = b2 | b3 | b4
|
|
23
|
+
* V & ~b2 | b4 = b3 | b4
|
|
24
|
+
* V & ~b3 | b1 = b1 | b4
|
|
25
|
+
* V & ~b4 | b2 = b1 | b2
|
|
26
|
+
*
|
|
27
|
+
* As you can see, we end up with the wrong result.
|
|
28
|
+
* This is because we're removing a bit that was previously set.
|
|
29
|
+
* And, thus the final result is missing b3 and b4.
|
|
30
|
+
*
|
|
31
|
+
* Now, let's explore the issue with removing the bits first:
|
|
32
|
+
* V & ~b1 = b2 | b3 | b4
|
|
33
|
+
* V & ~b2 = b3 | b4
|
|
34
|
+
* V & ~b3 = b4
|
|
35
|
+
* V & ~b4 = 0
|
|
36
|
+
*
|
|
37
|
+
* And then setting the bits:
|
|
38
|
+
* V | b3 = b3
|
|
39
|
+
* V | b4 = b3 | b4
|
|
40
|
+
* V | b1 = b1 | b3 | b4
|
|
41
|
+
* V | b2 = b1 | b2 | b3 | b4
|
|
42
|
+
*
|
|
43
|
+
* We get the correct result because we're not removing any bits that were
|
|
44
|
+
* previously set thus properly remapping the bits to the new order
|
|
45
|
+
*
|
|
46
|
+
* To collect this into a single operation that can be done simultaneously
|
|
47
|
+
* we must first create a mask for the old bits that are set and a mask for
|
|
48
|
+
* the new bits that are set. Then we can remove the old bits and set the new
|
|
49
|
+
* bits simultaneously in a "single" operation like so:
|
|
50
|
+
* OldMask = b1 | b2 | b3 | b4
|
|
51
|
+
* NewMask = b3 | b4 | b1 | b2
|
|
52
|
+
*
|
|
53
|
+
* So this:
|
|
54
|
+
* V & ~oldMask | newMask
|
|
55
|
+
*
|
|
56
|
+
* Expands to this:
|
|
57
|
+
* V & ~b1 & ~b2 & ~b3 & ~b4 | b3 | b4 | b1 | b2
|
|
58
|
+
*
|
|
59
|
+
* Which becomes this:
|
|
60
|
+
* b1 | b2 | b3 | b4
|
|
61
|
+
*
|
|
62
|
+
* Which is the correct result!
|
|
63
|
+
*
|
|
64
|
+
* @param {bigint} num
|
|
65
|
+
* @param {[bigint, bigint][]} mapping
|
|
66
|
+
*/ "use strict";
|
|
67
|
+
Object.defineProperty(exports, "__esModule", {
|
|
68
|
+
value: true
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "remapBitfield", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return remapBitfield;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
function remapBitfield(num, mapping) {
|
|
77
|
+
// Create masks for the old and new bits that are set
|
|
78
|
+
let oldMask = 0n;
|
|
79
|
+
let newMask = 0n;
|
|
80
|
+
for (let [oldBit, newBit] of mapping){
|
|
81
|
+
if (num & oldBit) {
|
|
82
|
+
oldMask = oldMask | oldBit;
|
|
83
|
+
newMask = newMask | newBit;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Remove all old bits
|
|
87
|
+
// Set all new bits
|
|
88
|
+
return num & ~oldMask | newMask;
|
|
89
|
+
}
|
|
@@ -9,20 +9,24 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
elementSelectorParser: ()
|
|
13
|
-
|
|
12
|
+
elementSelectorParser: function() {
|
|
13
|
+
return elementSelectorParser;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return resolveDefaultsAtRules;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const _postcss = /*#__PURE__*/
|
|
16
|
-
const
|
|
19
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
20
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
17
21
|
const _featureFlags = require("../featureFlags");
|
|
18
|
-
function
|
|
22
|
+
function _interop_require_default(obj) {
|
|
19
23
|
return obj && obj.__esModule ? obj : {
|
|
20
24
|
default: obj
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
let getNode = {
|
|
24
28
|
id (node) {
|
|
25
|
-
return
|
|
29
|
+
return _postcssselectorparser.default.attribute({
|
|
26
30
|
attribute: "id",
|
|
27
31
|
operator: "=",
|
|
28
32
|
value: node.value,
|
|
@@ -60,14 +64,14 @@ function minimumImpactSelector(nodes) {
|
|
|
60
64
|
let combinatorIdx = rest.findIndex((n)=>n.type === "combinator" && n.value === ">");
|
|
61
65
|
if (combinatorIdx !== -1) {
|
|
62
66
|
rest.splice(0, combinatorIdx);
|
|
63
|
-
rest.unshift(
|
|
67
|
+
rest.unshift(_postcssselectorparser.default.universal());
|
|
64
68
|
}
|
|
65
69
|
return [
|
|
66
70
|
bestNode,
|
|
67
71
|
...rest.reverse()
|
|
68
72
|
].join("").trim();
|
|
69
73
|
}
|
|
70
|
-
let elementSelectorParser = (0,
|
|
74
|
+
let elementSelectorParser = (0, _postcssselectorparser.default)((selectors)=>{
|
|
71
75
|
return selectors.map((s)=>{
|
|
72
76
|
let nodes = s.split((n)=>n.type === "combinator" && n.value === " ").pop();
|
|
73
77
|
return minimumImpactSelector(nodes);
|
|
@@ -99,8 +103,8 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
99
103
|
if ((0, _featureFlags.flagEnabled)(tailwindConfig, "optimizeUniversalDefaults")) {
|
|
100
104
|
for (let universal of universals){
|
|
101
105
|
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
102
|
-
var
|
|
103
|
-
let rules = (
|
|
106
|
+
var _variableNodeMap_get;
|
|
107
|
+
let rules = (_variableNodeMap_get = variableNodeMap.get(universal.params)) !== null && _variableNodeMap_get !== void 0 ? _variableNodeMap_get : [];
|
|
104
108
|
for (let rule of rules){
|
|
105
109
|
for (let selector of extractElementSelector(rule.selector)){
|
|
106
110
|
// If selector contains a vendor prefix after a pseudo element or class,
|
|
@@ -108,8 +112,8 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
108
112
|
// a single rule will cause browsers that do not understand the
|
|
109
113
|
// vendor prefix to throw out the whole rule
|
|
110
114
|
let selectorGroupName = selector.includes(":-") || selector.includes("::-") ? selector : "__DEFAULT__";
|
|
111
|
-
var
|
|
112
|
-
let selectors = (
|
|
115
|
+
var _selectorGroups_get;
|
|
116
|
+
let selectors = (_selectorGroups_get = selectorGroups.get(selectorGroupName)) !== null && _selectorGroups_get !== void 0 ? _selectorGroups_get : new Set();
|
|
113
117
|
selectorGroups.set(selectorGroupName, selectors);
|
|
114
118
|
selectors.add(selector);
|
|
115
119
|
}
|
|
@@ -119,12 +123,12 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
119
123
|
universal.remove();
|
|
120
124
|
continue;
|
|
121
125
|
}
|
|
122
|
-
for (let [,
|
|
126
|
+
for (let [, selectors] of selectorGroups){
|
|
123
127
|
let universalRule = _postcss.default.rule({
|
|
124
128
|
source: universal.source
|
|
125
129
|
});
|
|
126
130
|
universalRule.selectors = [
|
|
127
|
-
...
|
|
131
|
+
...selectors
|
|
128
132
|
];
|
|
129
133
|
universalRule.append(universal.nodes.map((node)=>node.clone()));
|
|
130
134
|
universal.before(universalRule);
|
|
@@ -133,29 +137,29 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
133
137
|
universal.remove();
|
|
134
138
|
}
|
|
135
139
|
} else if (universals.size) {
|
|
136
|
-
let
|
|
140
|
+
let universalRule = _postcss.default.rule({
|
|
137
141
|
selectors: [
|
|
138
142
|
"*",
|
|
139
143
|
"::before",
|
|
140
144
|
"::after"
|
|
141
145
|
]
|
|
142
146
|
});
|
|
143
|
-
for (let
|
|
144
|
-
|
|
145
|
-
if (!
|
|
146
|
-
|
|
147
|
+
for (let universal of universals){
|
|
148
|
+
universalRule.append(universal.nodes);
|
|
149
|
+
if (!universalRule.parent) {
|
|
150
|
+
universal.before(universalRule);
|
|
147
151
|
}
|
|
148
|
-
if (!
|
|
149
|
-
|
|
152
|
+
if (!universalRule.source) {
|
|
153
|
+
universalRule.source = universal.source;
|
|
150
154
|
}
|
|
151
|
-
|
|
155
|
+
universal.remove();
|
|
152
156
|
}
|
|
153
|
-
let backdropRule =
|
|
157
|
+
let backdropRule = universalRule.clone({
|
|
154
158
|
selectors: [
|
|
155
159
|
"::backdrop"
|
|
156
160
|
]
|
|
157
161
|
});
|
|
158
|
-
|
|
162
|
+
universalRule.after(backdropRule);
|
|
159
163
|
}
|
|
160
164
|
};
|
|
161
165
|
}
|