tailwindcss 0.0.0-insiders.c834da4 → 0.0.0-insiders.c8bf2d4
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/plugin.js +30 -25
- package/lib/cli/index.js +231 -10
- package/lib/cli.js +4 -236
- package/lib/corePluginList.js +2 -0
- package/lib/corePlugins.js +216 -4
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +5 -1
- package/lib/index.js +4 -46
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +7 -2
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/expandTailwindAtRules.js +30 -5
- package/lib/lib/generateRules.js +92 -56
- package/lib/lib/offsets.js +19 -0
- package/lib/lib/setupContextUtils.js +84 -37
- package/lib/lib/setupTrackingContext.js +25 -4
- package/lib/lib/sharedState.js +19 -1
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +47 -0
- package/lib/oxide/cli/build/plugin.js +364 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +220 -0
- package/lib/oxide/cli/init/index.js +35 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/util/color.js +16 -2
- package/lib/util/dataTypes.js +19 -1
- package/lib/util/formatVariantSelector.js +151 -103
- package/lib/util/negateValue.js +2 -2
- package/lib/util/pluginUtils.js +5 -24
- package/lib/util/prefixSelector.js +22 -8
- package/package.json +26 -15
- package/peers/index.js +108 -173
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/plugin.js +12 -7
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -231
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +117 -4
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +4 -0
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +8 -2
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/generateRules.js +106 -56
- package/src/lib/offsets.js +22 -0
- package/src/lib/setupContextUtils.js +90 -41
- package/src/lib/setupTrackingContext.js +31 -6
- package/src/lib/sharedState.js +17 -0
- 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 +436 -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 +212 -0
- package/src/oxide/cli/init/index.ts +32 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +18 -0
- package/src/util/formatVariantSelector.js +204 -122
- package/src/util/negateValue.js +1 -1
- package/src/util/pluginUtils.js +10 -29
- package/src/util/prefixSelector.js +28 -10
- package/stubs/defaultConfig.stub.js +3 -0
- package/types/config.d.ts +11 -1
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +5 -2
- package/CHANGELOG.md +0 -2352
- package/lib/cli/shared.js +0 -12
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
package/lib/lib/generateRules.js
CHANGED
|
@@ -162,12 +162,12 @@ function applyImportant(matches, classCandidate) {
|
|
|
162
162
|
]
|
|
163
163
|
});
|
|
164
164
|
container.walkRules((r)=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
let ast = (0, _postcssSelectorParser.default)().astSync(r.selector);
|
|
166
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
167
|
+
ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
|
|
168
|
+
// Update all instances of the base candidate to include the important marker
|
|
169
|
+
(0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
|
|
170
|
+
r.selector = ast.toString();
|
|
171
171
|
r.walkDecls((d)=>d.important = true);
|
|
172
172
|
});
|
|
173
173
|
result.push([
|
|
@@ -198,10 +198,16 @@ function applyVariant(variant, matches, context) {
|
|
|
198
198
|
};
|
|
199
199
|
// Retrieve "modifier"
|
|
200
200
|
{
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(variant, "/");
|
|
202
|
+
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
203
|
+
// In this case 1/10 is a value but /20 is a modifier
|
|
204
|
+
if (modifiers.length > 1) {
|
|
205
|
+
baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
|
|
206
|
+
modifiers = modifiers.slice(-1);
|
|
207
|
+
}
|
|
208
|
+
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
209
|
+
variant = baseVariant;
|
|
210
|
+
args.modifier = modifiers[0];
|
|
205
211
|
if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
|
|
206
212
|
return [];
|
|
207
213
|
}
|
|
@@ -216,9 +222,9 @@ function applyVariant(variant, matches, context) {
|
|
|
216
222
|
// But we don't want:
|
|
217
223
|
// @-[200px] (`-` is incorrect)
|
|
218
224
|
// group[:hover] (`-` is missing)
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
221
|
-
let [, char, seperator, value] =
|
|
225
|
+
let match = /(.)(-?)\[(.*)\]/g.exec(variant);
|
|
226
|
+
if (match) {
|
|
227
|
+
let [, char, seperator, value] = match;
|
|
222
228
|
// @-[200px] case
|
|
223
229
|
if (char === "@" && seperator === "-") return [];
|
|
224
230
|
// group[:hover] case
|
|
@@ -243,6 +249,7 @@ function applyVariant(variant, matches, context) {
|
|
|
243
249
|
]);
|
|
244
250
|
}
|
|
245
251
|
if (context.variantMap.has(variant)) {
|
|
252
|
+
let isArbitraryVariant = isArbitraryValue(variant);
|
|
246
253
|
let variantFunctionTuples = context.variantMap.get(variant).slice();
|
|
247
254
|
let result = [];
|
|
248
255
|
for (let [meta, rule] of matches){
|
|
@@ -299,7 +306,10 @@ function applyVariant(variant, matches, context) {
|
|
|
299
306
|
clone.append(wrapper);
|
|
300
307
|
},
|
|
301
308
|
format (selectorFormat) {
|
|
302
|
-
collectedFormats.push(
|
|
309
|
+
collectedFormats.push({
|
|
310
|
+
format: selectorFormat,
|
|
311
|
+
isArbitraryVariant
|
|
312
|
+
});
|
|
303
313
|
},
|
|
304
314
|
args
|
|
305
315
|
});
|
|
@@ -322,7 +332,10 @@ function applyVariant(variant, matches, context) {
|
|
|
322
332
|
continue;
|
|
323
333
|
}
|
|
324
334
|
if (typeof ruleWithVariant === "string") {
|
|
325
|
-
collectedFormats.push(
|
|
335
|
+
collectedFormats.push({
|
|
336
|
+
format: ruleWithVariant,
|
|
337
|
+
isArbitraryVariant
|
|
338
|
+
});
|
|
326
339
|
}
|
|
327
340
|
if (ruleWithVariant === null) {
|
|
328
341
|
continue;
|
|
@@ -358,7 +371,10 @@ function applyVariant(variant, matches, context) {
|
|
|
358
371
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
359
372
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
360
373
|
// format: .foo &
|
|
361
|
-
collectedFormats.push(
|
|
374
|
+
collectedFormats.push({
|
|
375
|
+
format: modified.replace(rebuiltBase, "&"),
|
|
376
|
+
isArbitraryVariant
|
|
377
|
+
});
|
|
362
378
|
rule.selector = before;
|
|
363
379
|
});
|
|
364
380
|
}
|
|
@@ -375,8 +391,7 @@ function applyVariant(variant, matches, context) {
|
|
|
375
391
|
{
|
|
376
392
|
...meta,
|
|
377
393
|
sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
|
|
378
|
-
collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
|
|
379
|
-
isArbitraryVariant: isArbitraryValue(variant)
|
|
394
|
+
collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
|
|
380
395
|
},
|
|
381
396
|
clone.nodes[0]
|
|
382
397
|
];
|
|
@@ -713,55 +728,76 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
713
728
|
matches = applyVariant(variant, matches, context);
|
|
714
729
|
}
|
|
715
730
|
for (let match of matches){
|
|
716
|
-
let isValid = true;
|
|
717
731
|
match[1].raws.tailwind = {
|
|
718
732
|
...match[1].raws.tailwind,
|
|
719
733
|
candidate
|
|
720
734
|
};
|
|
721
735
|
// Apply final format selector
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
if (inKeyframes(rule)) return;
|
|
732
|
-
var _context_tailwindConfig_separator;
|
|
733
|
-
let selectorOptions = {
|
|
734
|
-
selector: rule.selector,
|
|
735
|
-
candidate: original,
|
|
736
|
-
base: candidate.split(new RegExp(`\\${(_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":"}(?![^[]*\\])`)).pop(),
|
|
737
|
-
isArbitraryVariant: match[0].isArbitraryVariant,
|
|
738
|
-
context
|
|
739
|
-
};
|
|
740
|
-
try {
|
|
741
|
-
rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, selectorOptions);
|
|
742
|
-
} catch {
|
|
743
|
-
// The selector we produced is invalid
|
|
744
|
-
// This could be because:
|
|
745
|
-
// - A bug exists
|
|
746
|
-
// - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
|
|
747
|
-
// - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
|
|
748
|
-
// Either way the build will fail because of this
|
|
749
|
-
// We would rather that the build pass "silently" given that this could
|
|
750
|
-
// happen because of picking up invalid things when scanning content
|
|
751
|
-
// So we'll throw out the candidate instead
|
|
752
|
-
isValid = false;
|
|
753
|
-
return false;
|
|
754
|
-
}
|
|
755
|
-
});
|
|
756
|
-
match[1] = container.nodes[0];
|
|
757
|
-
}
|
|
758
|
-
if (!isValid) {
|
|
736
|
+
match = applyFinalFormat(match, {
|
|
737
|
+
context,
|
|
738
|
+
candidate,
|
|
739
|
+
original
|
|
740
|
+
});
|
|
741
|
+
// Skip rules with invalid selectors
|
|
742
|
+
// This will cause the candidate to be added to the "not class"
|
|
743
|
+
// cache skipping it entirely for future builds
|
|
744
|
+
if (match === null) {
|
|
759
745
|
continue;
|
|
760
746
|
}
|
|
761
747
|
yield match;
|
|
762
748
|
}
|
|
763
749
|
}
|
|
764
750
|
}
|
|
751
|
+
function applyFinalFormat(match, { context , candidate , original }) {
|
|
752
|
+
if (!match[0].collectedFormats) {
|
|
753
|
+
return match;
|
|
754
|
+
}
|
|
755
|
+
let isValid = true;
|
|
756
|
+
let finalFormat;
|
|
757
|
+
try {
|
|
758
|
+
finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
|
|
759
|
+
context,
|
|
760
|
+
candidate
|
|
761
|
+
});
|
|
762
|
+
} catch {
|
|
763
|
+
// The format selector we produced is invalid
|
|
764
|
+
// This could be because:
|
|
765
|
+
// - A bug exists
|
|
766
|
+
// - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
|
|
767
|
+
// - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
|
|
768
|
+
// Either way the build will fail because of this
|
|
769
|
+
// We would rather that the build pass "silently" given that this could
|
|
770
|
+
// happen because of picking up invalid things when scanning content
|
|
771
|
+
// So we'll throw out the candidate instead
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
let container = _postcss.default.root({
|
|
775
|
+
nodes: [
|
|
776
|
+
match[1].clone()
|
|
777
|
+
]
|
|
778
|
+
});
|
|
779
|
+
container.walkRules((rule)=>{
|
|
780
|
+
if (inKeyframes(rule)) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
try {
|
|
784
|
+
rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
|
|
785
|
+
candidate: original,
|
|
786
|
+
context
|
|
787
|
+
});
|
|
788
|
+
} catch {
|
|
789
|
+
// If this selector is invalid we also want to skip it
|
|
790
|
+
// But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
|
|
791
|
+
isValid = false;
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
if (!isValid) {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
match[1] = container.nodes[0];
|
|
799
|
+
return match;
|
|
800
|
+
}
|
|
765
801
|
function inKeyframes(rule) {
|
|
766
802
|
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
767
803
|
}
|
package/lib/lib/offsets.js
CHANGED
|
@@ -97,6 +97,7 @@ class Offsets {
|
|
|
97
97
|
* @param {VariantOption} options
|
|
98
98
|
* @returns {RuleOffset}
|
|
99
99
|
*/ applyVariantOffset(rule, variant, options) {
|
|
100
|
+
options.variant = variant.variants;
|
|
100
101
|
return {
|
|
101
102
|
...rule,
|
|
102
103
|
layer: "variants",
|
|
@@ -166,11 +167,29 @@ class Offsets {
|
|
|
166
167
|
if (a.layer !== b.layer) {
|
|
167
168
|
return this.layerPositions[a.layer] - this.layerPositions[b.layer];
|
|
168
169
|
}
|
|
170
|
+
// When sorting the `variants` layer, we need to sort based on the parent layer as well within
|
|
171
|
+
// this variants layer.
|
|
172
|
+
if (a.parentLayer !== b.parentLayer) {
|
|
173
|
+
return this.layerPositions[a.parentLayer] - this.layerPositions[b.parentLayer];
|
|
174
|
+
}
|
|
169
175
|
// Sort based on the sorting function
|
|
170
176
|
for (let aOptions of a.options){
|
|
171
177
|
for (let bOptions of b.options){
|
|
172
178
|
if (aOptions.id !== bOptions.id) continue;
|
|
173
179
|
if (!aOptions.sort || !bOptions.sort) continue;
|
|
180
|
+
var _max;
|
|
181
|
+
let maxFnVariant = (_max = max([
|
|
182
|
+
aOptions.variant,
|
|
183
|
+
bOptions.variant
|
|
184
|
+
])) !== null && _max !== void 0 ? _max : 0n;
|
|
185
|
+
// Create a mask of 0s from bits 1..N where N represents the mask of the Nth bit
|
|
186
|
+
let mask = ~(maxFnVariant | maxFnVariant - 1n);
|
|
187
|
+
let aVariantsAfterFn = a.variants & mask;
|
|
188
|
+
let bVariantsAfterFn = b.variants & mask;
|
|
189
|
+
// If the variants the same, we _can_ sort them
|
|
190
|
+
if (aVariantsAfterFn !== bVariantsAfterFn) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
174
193
|
let result = aOptions.sort({
|
|
175
194
|
value: aOptions.value,
|
|
176
195
|
modifier: aOptions.modifier
|
|
@@ -113,27 +113,41 @@ function normalizeOptionTypes({ type ="any" , ...options }) {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
function parseVariantFormatString(input) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
/** @type {string[]} */ let parts = [];
|
|
117
|
+
// When parsing whitespace around special characters are insignificant
|
|
118
|
+
// However, _inside_ of a variant they could be
|
|
119
|
+
// Because the selector could look like this
|
|
120
|
+
// @media { &[data-name="foo bar"] }
|
|
121
|
+
// This is why we do not skip whitespace
|
|
122
|
+
let current = "";
|
|
123
|
+
let depth = 0;
|
|
124
|
+
for(let idx = 0; idx < input.length; idx++){
|
|
125
|
+
let char = input[idx];
|
|
126
|
+
if (char === "\\") {
|
|
127
|
+
// Escaped characters are not special
|
|
128
|
+
current += "\\" + input[++idx];
|
|
129
|
+
} else if (char === "{") {
|
|
130
|
+
// Nested rule: start
|
|
131
|
+
++depth;
|
|
132
|
+
parts.push(current.trim());
|
|
133
|
+
current = "";
|
|
129
134
|
} else if (char === "}") {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
;
|
|
135
|
+
// Nested rule: end
|
|
136
|
+
if (--depth < 0) {
|
|
137
|
+
throw new Error(`Your { and } are unbalanced.`);
|
|
133
138
|
}
|
|
139
|
+
parts.push(current.trim());
|
|
140
|
+
current = "";
|
|
141
|
+
} else {
|
|
142
|
+
// Normal character
|
|
143
|
+
current += char;
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
|
-
|
|
146
|
+
if (current.length > 0) {
|
|
147
|
+
parts.push(current.trim());
|
|
148
|
+
}
|
|
149
|
+
parts = parts.filter((part)=>part !== "");
|
|
150
|
+
return parts;
|
|
137
151
|
}
|
|
138
152
|
function insertInto(list, value, { before =[] } = {}) {
|
|
139
153
|
before = [].concat(before);
|
|
@@ -616,6 +630,7 @@ function getFileModifiedMap(context) {
|
|
|
616
630
|
}
|
|
617
631
|
function trackModified(files, fileModifiedMap) {
|
|
618
632
|
let changed = false;
|
|
633
|
+
let mtimesToCommit = new Map();
|
|
619
634
|
for (let file of files){
|
|
620
635
|
var _fs_statSync;
|
|
621
636
|
if (!file) continue;
|
|
@@ -631,9 +646,12 @@ function trackModified(files, fileModifiedMap) {
|
|
|
631
646
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
632
647
|
changed = true;
|
|
633
648
|
}
|
|
634
|
-
|
|
649
|
+
mtimesToCommit.set(file, newModified);
|
|
635
650
|
}
|
|
636
|
-
return
|
|
651
|
+
return [
|
|
652
|
+
changed,
|
|
653
|
+
mtimesToCommit
|
|
654
|
+
];
|
|
637
655
|
}
|
|
638
656
|
function extractVariantAtRules(node) {
|
|
639
657
|
node.walkAtRules((atRule)=>{
|
|
@@ -908,21 +926,40 @@ function registerPlugins(plugins, context) {
|
|
|
908
926
|
};
|
|
909
927
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
910
928
|
// ['uppercase', 'lowercase', ...]
|
|
911
|
-
context.getClassList = function getClassList() {
|
|
929
|
+
context.getClassList = function getClassList(options = {}) {
|
|
912
930
|
let output = [];
|
|
913
931
|
for (let util of classList){
|
|
914
932
|
if (Array.isArray(util)) {
|
|
915
|
-
|
|
933
|
+
var _utilOptions_types;
|
|
934
|
+
let [utilName, utilOptions] = util;
|
|
916
935
|
let negativeClasses = [];
|
|
917
|
-
var
|
|
918
|
-
|
|
936
|
+
var _utilOptions_modifiers;
|
|
937
|
+
let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
|
|
938
|
+
if (utilOptions === null || utilOptions === void 0 ? void 0 : (_utilOptions_types = utilOptions.types) === null || _utilOptions_types === void 0 ? void 0 : _utilOptions_types.some(({ type })=>type === "color")) {
|
|
939
|
+
var _context_tailwindConfig_theme_opacity;
|
|
940
|
+
modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
|
|
941
|
+
}
|
|
942
|
+
let metadata = {
|
|
943
|
+
modifiers
|
|
944
|
+
};
|
|
945
|
+
let includeMetadata = options.includeMetadata && modifiers.length > 0;
|
|
946
|
+
var _utilOptions_values;
|
|
947
|
+
for (let [key, value] of Object.entries((_utilOptions_values = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.values) !== null && _utilOptions_values !== void 0 ? _utilOptions_values : {})){
|
|
919
948
|
// Ignore undefined and null values
|
|
920
949
|
if (value == null) {
|
|
921
950
|
continue;
|
|
922
951
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
952
|
+
let cls = (0, _nameClass.formatClass)(utilName, key);
|
|
953
|
+
output.push(includeMetadata ? [
|
|
954
|
+
cls,
|
|
955
|
+
metadata
|
|
956
|
+
] : cls);
|
|
957
|
+
if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
958
|
+
let cls1 = (0, _nameClass.formatClass)(utilName, `-${key}`);
|
|
959
|
+
negativeClasses.push(includeMetadata ? [
|
|
960
|
+
cls1,
|
|
961
|
+
metadata
|
|
962
|
+
] : cls1);
|
|
926
963
|
}
|
|
927
964
|
}
|
|
928
965
|
output.push(...negativeClasses);
|
|
@@ -1039,14 +1076,22 @@ function registerPlugins(plugins, context) {
|
|
|
1039
1076
|
});
|
|
1040
1077
|
}
|
|
1041
1078
|
var _options_values1;
|
|
1042
|
-
let
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1079
|
+
let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
|
|
1080
|
+
formatStrings = formatStrings.map((format)=>format.map((str)=>({
|
|
1081
|
+
format: str,
|
|
1082
|
+
isArbitraryVariant
|
|
1083
|
+
})));
|
|
1084
|
+
manualFormatStrings = manualFormatStrings.map((format)=>({
|
|
1085
|
+
format,
|
|
1086
|
+
isArbitraryVariant
|
|
1087
|
+
}));
|
|
1088
|
+
let opts = {
|
|
1089
|
+
candidate,
|
|
1090
|
+
context
|
|
1091
|
+
};
|
|
1092
|
+
let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
|
|
1048
1093
|
if (manualFormatStrings.length > 0) {
|
|
1049
|
-
result.push((0, _formatVariantSelector.formatVariantSelector)("&"
|
|
1094
|
+
result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
|
|
1050
1095
|
}
|
|
1051
1096
|
return result;
|
|
1052
1097
|
}
|
|
@@ -1135,13 +1180,14 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1135
1180
|
// If there's already a context in the cache and we don't need to
|
|
1136
1181
|
// reset the context, return the cached context.
|
|
1137
1182
|
if (existingContext) {
|
|
1138
|
-
let contextDependenciesChanged = trackModified([
|
|
1183
|
+
let [contextDependenciesChanged, mtimesToCommit] = trackModified([
|
|
1139
1184
|
...contextDependencies
|
|
1140
1185
|
], getFileModifiedMap(existingContext));
|
|
1141
1186
|
if (!contextDependenciesChanged && !cssDidChange) {
|
|
1142
1187
|
return [
|
|
1143
1188
|
existingContext,
|
|
1144
|
-
false
|
|
1189
|
+
false,
|
|
1190
|
+
mtimesToCommit
|
|
1145
1191
|
];
|
|
1146
1192
|
}
|
|
1147
1193
|
}
|
|
@@ -1172,7 +1218,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1172
1218
|
Object.assign(context2, {
|
|
1173
1219
|
userConfigPath
|
|
1174
1220
|
});
|
|
1175
|
-
trackModified([
|
|
1221
|
+
let [, mtimesToCommit1] = trackModified([
|
|
1176
1222
|
...contextDependencies
|
|
1177
1223
|
], getFileModifiedMap(context2));
|
|
1178
1224
|
// ---
|
|
@@ -1185,6 +1231,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1185
1231
|
contextSourcesMap.get(context2).add(sourcePath);
|
|
1186
1232
|
return [
|
|
1187
1233
|
context2,
|
|
1188
|
-
true
|
|
1234
|
+
true,
|
|
1235
|
+
mtimesToCommit1
|
|
1189
1236
|
];
|
|
1190
1237
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
4
|
value: true
|
|
@@ -111,7 +112,8 @@ function setupTrackingContext(configOrPath) {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
|
-
let [context] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
115
|
+
let [context, , mTimesToCommit] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
116
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
115
117
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
116
118
|
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
117
119
|
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
@@ -119,15 +121,28 @@ function setupTrackingContext(configOrPath) {
|
|
|
119
121
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
120
122
|
// in another file since independent sources are effectively isolated.
|
|
121
123
|
if (tailwindDirectives.size > 0) {
|
|
122
|
-
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
123
124
|
// Add template paths as postcss dependencies.
|
|
124
125
|
for (let contentPath of candidateFiles){
|
|
125
126
|
for (let dependency of (0, _parseDependency.default)(contentPath)){
|
|
126
127
|
registerDependency(dependency);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
let [changedContent, contentMTimesToCommit] = (0, _contentJs.resolvedChangedContent)(context, candidateFiles, fileModifiedMap);
|
|
131
|
+
for (let content of changedContent){
|
|
132
|
+
context.changedContent.push(content);
|
|
133
|
+
}
|
|
134
|
+
// Add the mtimes of the content files to the commit list
|
|
135
|
+
// We can overwrite the existing values because unconditionally
|
|
136
|
+
// This is because:
|
|
137
|
+
// 1. Most of the files here won't be in the map yet
|
|
138
|
+
// 2. If they are that means it's a context dependency
|
|
139
|
+
// and we're reading this after the context. This means
|
|
140
|
+
// that the mtime we just read is strictly >= the context
|
|
141
|
+
// mtime. Unless the user / os is doing something weird
|
|
142
|
+
// in which the mtime would be going backwards. If that
|
|
143
|
+
// happens there's already going to be problems.
|
|
144
|
+
for (let [path, mtime] of contentMTimesToCommit.entries()){
|
|
145
|
+
mTimesToCommit.set(path, mtime);
|
|
131
146
|
}
|
|
132
147
|
}
|
|
133
148
|
for (let file of configDependencies){
|
|
@@ -136,6 +151,12 @@ function setupTrackingContext(configOrPath) {
|
|
|
136
151
|
file
|
|
137
152
|
});
|
|
138
153
|
}
|
|
154
|
+
// "commit" the new modified time for all context deps
|
|
155
|
+
// We do this here because we want content tracking to
|
|
156
|
+
// read the "old" mtime even when it's a context dependency.
|
|
157
|
+
for (let [path1, mtime1] of mTimesToCommit.entries()){
|
|
158
|
+
fileModifiedMap.set(path1, mtime1);
|
|
159
|
+
}
|
|
139
160
|
return context;
|
|
140
161
|
};
|
|
141
162
|
};
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -18,9 +18,18 @@ _export(exports, {
|
|
|
18
18
|
NONE: ()=>NONE,
|
|
19
19
|
resolveDebug: ()=>resolveDebug
|
|
20
20
|
});
|
|
21
|
+
const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../package.json"));
|
|
22
|
+
function _interopRequireDefault(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let OXIDE_DEFAULT_ENABLED = _packageJson.default.tailwindcss.engine === "oxide";
|
|
21
28
|
const env = {
|
|
22
29
|
NODE_ENV: process.env.NODE_ENV,
|
|
23
|
-
DEBUG: resolveDebug(process.env.DEBUG)
|
|
30
|
+
DEBUG: resolveDebug(process.env.DEBUG),
|
|
31
|
+
ENGINE: _packageJson.default.tailwindcss.engine,
|
|
32
|
+
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED)
|
|
24
33
|
};
|
|
25
34
|
const contextMap = new Map();
|
|
26
35
|
const configContextMap = new Map();
|
|
@@ -28,6 +37,15 @@ const contextSourcesMap = new Map();
|
|
|
28
37
|
const sourceHashMap = new Map();
|
|
29
38
|
const NOT_ON_DEMAND = new String("*");
|
|
30
39
|
const NONE = Symbol("__NONE__");
|
|
40
|
+
function resolveBoolean(value, defaultValue) {
|
|
41
|
+
if (value === undefined) {
|
|
42
|
+
return defaultValue;
|
|
43
|
+
}
|
|
44
|
+
if (value === "0" || value === "false") {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
31
49
|
function resolveDebug(debug) {
|
|
32
50
|
if (debug === undefined) {
|
|
33
51
|
return false;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
lazyLightningCss: ()=>lazyLightningCss,
|
|
13
|
+
lightningcss: ()=>lightningcss,
|
|
14
|
+
loadPostcss: ()=>loadPostcss,
|
|
15
|
+
loadPostcssImport: ()=>loadPostcssImport
|
|
16
|
+
});
|
|
17
|
+
const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../../package.json"));
|
|
18
|
+
const _browserslist = /*#__PURE__*/ _interopRequireDefault(require("browserslist"));
|
|
19
|
+
const _index = require("../../../../peers/index");
|
|
20
|
+
function _interopRequireDefault(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function lazyLightningCss() {
|
|
26
|
+
// TODO: Make this lazy/bundled
|
|
27
|
+
return require("lightningcss");
|
|
28
|
+
}
|
|
29
|
+
let lightningCss;
|
|
30
|
+
function loadLightningCss() {
|
|
31
|
+
if (lightningCss) {
|
|
32
|
+
return lightningCss;
|
|
33
|
+
}
|
|
34
|
+
// Try to load a local version first
|
|
35
|
+
try {
|
|
36
|
+
return lightningCss = require("lightningcss");
|
|
37
|
+
} catch {}
|
|
38
|
+
return lightningCss = lazyLightningCss();
|
|
39
|
+
}
|
|
40
|
+
async function lightningcss(shouldMinify, result) {
|
|
41
|
+
let css = loadLightningCss();
|
|
42
|
+
try {
|
|
43
|
+
let transformed = css.transform({
|
|
44
|
+
filename: result.opts.from || "input.css",
|
|
45
|
+
code: Buffer.from(result.css, "utf-8"),
|
|
46
|
+
minify: shouldMinify,
|
|
47
|
+
sourceMap: !!result.map,
|
|
48
|
+
inputSourceMap: result.map ? result.map.toString() : undefined,
|
|
49
|
+
targets: css.browserslistToTargets((0, _browserslist.default)(_packageJson.default.browserslist)),
|
|
50
|
+
drafts: {
|
|
51
|
+
nesting: true
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return Object.assign(result, {
|
|
55
|
+
css: transformed.code.toString("utf8"),
|
|
56
|
+
map: result.map ? Object.assign(result.map, {
|
|
57
|
+
toString () {
|
|
58
|
+
return transformed.map.toString();
|
|
59
|
+
}
|
|
60
|
+
}) : result.map
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error("Unable to use Lightning CSS. Using raw version instead.");
|
|
64
|
+
console.error(err);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function loadPostcss() {
|
|
69
|
+
// Try to load a local `postcss` version first
|
|
70
|
+
try {
|
|
71
|
+
return require("postcss");
|
|
72
|
+
} catch {}
|
|
73
|
+
return (0, _index.lazyPostcss)();
|
|
74
|
+
}
|
|
75
|
+
function loadPostcssImport() {
|
|
76
|
+
// Try to load a local `postcss-import` version first
|
|
77
|
+
try {
|
|
78
|
+
return require("postcss-import");
|
|
79
|
+
} catch {}
|
|
80
|
+
return (0, _index.lazyPostcssImport)();
|
|
81
|
+
}
|