tailwindcss 3.2.3 → 3.2.5
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/CHANGELOG.md +56 -1
- package/README.md +1 -1
- package/lib/cli/build/index.js +5 -1
- package/lib/cli/build/plugin.js +50 -34
- package/lib/cli/build/watching.js +6 -3
- package/lib/cli/index.js +231 -10
- package/lib/cli/init/index.js +2 -2
- package/lib/cli.js +4 -226
- package/lib/corePlugins.js +45 -27
- package/lib/featureFlags.js +8 -8
- package/lib/index.js +4 -46
- package/lib/lib/collapseAdjacentRules.js +2 -2
- package/lib/lib/collapseDuplicateDeclarations.js +2 -2
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +10 -5
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/evaluateTailwindFunctions.js +4 -4
- package/lib/lib/expandApplyAtRules.js +2 -2
- package/lib/lib/expandTailwindAtRules.js +35 -9
- package/lib/lib/findAtConfigPath.js +3 -3
- package/lib/lib/generateRules.js +105 -50
- package/lib/lib/offsets.js +88 -1
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +4 -4
- package/lib/lib/setupContextUtils.js +122 -79
- 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/postcss-plugins/nesting/plugin.js +2 -2
- package/lib/util/cloneNodes.js +2 -2
- package/lib/util/color.js +20 -6
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +26 -2
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +3 -3
- package/lib/util/formatVariantSelector.js +171 -105
- package/lib/util/getAllConfigs.js +2 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +2 -2
- package/lib/util/negateValue.js +2 -2
- package/lib/util/normalizeConfig.js +36 -22
- package/lib/util/pluginUtils.js +38 -40
- package/lib/util/prefixSelector.js +22 -8
- package/lib/util/resolveConfig.js +8 -10
- package/oxide-node-api-shim/index.js +21 -0
- package/oxide-node-api-shim/package.json +5 -0
- package/package.json +32 -19
- package/peers/index.js +61 -42
- package/resolveConfig.d.ts +11 -2
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/index.js +6 -2
- package/src/cli/build/plugin.js +31 -9
- package/src/cli/build/watching.js +6 -3
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -220
- package/src/corePlugins.js +31 -3
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandTailwindAtRules.js +37 -6
- package/src/lib/generateRules.js +90 -28
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +99 -56
- 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 +29 -4
- package/src/util/formatVariantSelector.js +215 -122
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +18 -0
- package/src/util/pluginUtils.js +22 -19
- package/src/util/prefixSelector.js +28 -10
- package/src/util/resolveConfig.js +0 -2
- package/stubs/defaultConfig.stub.js +149 -165
- package/types/config.d.ts +7 -2
- package/types/generated/default-theme.d.ts +77 -77
- 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
|
@@ -32,7 +32,7 @@ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedStat
|
|
|
32
32
|
const _toPath = require("../util/toPath");
|
|
33
33
|
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
34
34
|
const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("../util/negateValue"));
|
|
35
|
-
const
|
|
35
|
+
const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
|
|
36
36
|
const _generateRules = require("./generateRules");
|
|
37
37
|
const _cacheInvalidationJs = require("./cacheInvalidation.js");
|
|
38
38
|
const _offsetsJs = require("./offsets.js");
|
|
@@ -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);
|
|
@@ -281,26 +295,20 @@ function parseVariant(variant) {
|
|
|
281
295
|
return context.tailwindConfig.prefix + identifier;
|
|
282
296
|
}
|
|
283
297
|
function resolveThemeValue(path, defaultValue, opts = {}) {
|
|
284
|
-
|
|
285
|
-
|
|
298
|
+
let parts = (0, _toPath.toPath)(path);
|
|
299
|
+
let value = getConfigValue([
|
|
286
300
|
"theme",
|
|
287
|
-
|
|
288
|
-
...subPaths
|
|
301
|
+
...parts
|
|
289
302
|
], defaultValue);
|
|
290
|
-
return (0, _transformThemeValue.default)(
|
|
303
|
+
return (0, _transformThemeValue.default)(parts[0])(value, opts);
|
|
291
304
|
}
|
|
292
|
-
const theme = Object.assign((path, defaultValue = undefined)=>resolveThemeValue(path, defaultValue), {
|
|
293
|
-
withAlpha: (path, opacityValue)=>resolveThemeValue(path, undefined, {
|
|
294
|
-
opacityValue
|
|
295
|
-
})
|
|
296
|
-
});
|
|
297
305
|
let variantIdentifier = 0;
|
|
298
306
|
let api = {
|
|
299
307
|
postcss: _postcss.default,
|
|
300
308
|
prefix: applyConfiguredPrefix,
|
|
301
309
|
e: _escapeClassName.default,
|
|
302
310
|
config: getConfigValue,
|
|
303
|
-
theme,
|
|
311
|
+
theme: resolveThemeValue,
|
|
304
312
|
corePlugins: (path)=>{
|
|
305
313
|
if (Array.isArray(tailwindConfig.corePlugins)) {
|
|
306
314
|
return tailwindConfig.corePlugins.includes(path);
|
|
@@ -430,7 +438,7 @@ function parseVariant(variant) {
|
|
|
430
438
|
return [];
|
|
431
439
|
}
|
|
432
440
|
}
|
|
433
|
-
if (!(0,
|
|
441
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
434
442
|
return [];
|
|
435
443
|
}
|
|
436
444
|
let extras = {
|
|
@@ -496,7 +504,7 @@ function parseVariant(variant) {
|
|
|
496
504
|
return [];
|
|
497
505
|
}
|
|
498
506
|
}
|
|
499
|
-
if (!(0,
|
|
507
|
+
if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
|
|
500
508
|
return [];
|
|
501
509
|
}
|
|
502
510
|
let extras = {
|
|
@@ -565,14 +573,14 @@ function parseVariant(variant) {
|
|
|
565
573
|
context.variantOptions.set(variantName, options);
|
|
566
574
|
},
|
|
567
575
|
matchVariant (variant, variantFn, options) {
|
|
568
|
-
var
|
|
576
|
+
var _options_id;
|
|
569
577
|
// A unique identifier that "groups" these variants together.
|
|
570
578
|
// This is for internal use only which is why it is not present in the types
|
|
571
|
-
let id = (
|
|
579
|
+
let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
|
|
572
580
|
let isSpecial = variant === "@";
|
|
573
581
|
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
574
|
-
var
|
|
575
|
-
for (let [key, value] of Object.entries((
|
|
582
|
+
var _options_values;
|
|
583
|
+
for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
|
|
576
584
|
if (key === "DEFAULT") continue;
|
|
577
585
|
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
|
|
578
586
|
return variantFn(value, modifiersEnabled ? {
|
|
@@ -589,15 +597,15 @@ function parseVariant(variant) {
|
|
|
589
597
|
variantInfo: VARIANT_INFO.Base
|
|
590
598
|
});
|
|
591
599
|
}
|
|
592
|
-
var
|
|
593
|
-
let hasDefault = "DEFAULT" in ((
|
|
600
|
+
var _options_values1;
|
|
601
|
+
let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
|
|
594
602
|
api.addVariant(variant, ({ args , container })=>{
|
|
595
603
|
if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
|
|
596
604
|
return null;
|
|
597
605
|
}
|
|
598
606
|
var // (JetBrains) plugins.
|
|
599
|
-
|
|
600
|
-
return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (
|
|
607
|
+
_args_value;
|
|
608
|
+
return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", modifiersEnabled ? {
|
|
601
609
|
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
602
610
|
container
|
|
603
611
|
} : {
|
|
@@ -622,24 +630,28 @@ function getFileModifiedMap(context) {
|
|
|
622
630
|
}
|
|
623
631
|
function trackModified(files, fileModifiedMap) {
|
|
624
632
|
let changed = false;
|
|
633
|
+
let mtimesToCommit = new Map();
|
|
625
634
|
for (let file of files){
|
|
626
|
-
var
|
|
635
|
+
var _fs_statSync;
|
|
627
636
|
if (!file) continue;
|
|
628
637
|
let parsed = _url.default.parse(file);
|
|
629
638
|
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, "") : parsed.href;
|
|
630
639
|
pathname = parsed.search ? pathname.replace(parsed.search, "") : pathname;
|
|
631
|
-
let newModified = (
|
|
640
|
+
let newModified = (_fs_statSync = _fs.default.statSync(decodeURIComponent(pathname), {
|
|
632
641
|
throwIfNoEntry: false
|
|
633
|
-
})) === null ||
|
|
642
|
+
})) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
|
|
634
643
|
if (!newModified) {
|
|
635
644
|
continue;
|
|
636
645
|
}
|
|
637
646
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
638
647
|
changed = true;
|
|
639
648
|
}
|
|
640
|
-
|
|
649
|
+
mtimesToCommit.set(file, newModified);
|
|
641
650
|
}
|
|
642
|
-
return
|
|
651
|
+
return [
|
|
652
|
+
changed,
|
|
653
|
+
mtimesToCommit
|
|
654
|
+
];
|
|
643
655
|
}
|
|
644
656
|
function extractVariantAtRules(node) {
|
|
645
657
|
node.walkAtRules((atRule)=>{
|
|
@@ -774,8 +786,8 @@ function registerPlugins(plugins, context) {
|
|
|
774
786
|
variantFunction
|
|
775
787
|
]));
|
|
776
788
|
}
|
|
777
|
-
var
|
|
778
|
-
let safelist = ((
|
|
789
|
+
var _context_tailwindConfig_safelist;
|
|
790
|
+
let safelist = ((_context_tailwindConfig_safelist = context.tailwindConfig.safelist) !== null && _context_tailwindConfig_safelist !== void 0 ? _context_tailwindConfig_safelist : []).filter(Boolean);
|
|
779
791
|
if (safelist.length > 0) {
|
|
780
792
|
let checks = [];
|
|
781
793
|
for (let value of safelist){
|
|
@@ -803,8 +815,8 @@ function registerPlugins(plugins, context) {
|
|
|
803
815
|
for (let util of classList){
|
|
804
816
|
let utils = Array.isArray(util) ? (()=>{
|
|
805
817
|
let [utilName, options] = util;
|
|
806
|
-
var
|
|
807
|
-
let values = Object.keys((
|
|
818
|
+
var _options_values;
|
|
819
|
+
let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
|
|
808
820
|
let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
|
|
809
821
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
810
822
|
// This is the normal negated version
|
|
@@ -871,8 +883,8 @@ function registerPlugins(plugins, context) {
|
|
|
871
883
|
}
|
|
872
884
|
}
|
|
873
885
|
}
|
|
874
|
-
var
|
|
875
|
-
let darkClassName = (
|
|
886
|
+
var _context_tailwindConfig_darkMode, _concat_;
|
|
887
|
+
let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode : "media")[1]) !== null && _concat_ !== void 0 ? _concat_ : "dark";
|
|
876
888
|
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
877
889
|
// that don't exist on their own. This will result in them "not existing" and
|
|
878
890
|
// sorting could be weird since you still require them in order to make the
|
|
@@ -897,8 +909,8 @@ function registerPlugins(plugins, context) {
|
|
|
897
909
|
sortedClassNames.set(rule.raws.tailwind.candidate, idx++);
|
|
898
910
|
}
|
|
899
911
|
return classes.map((className)=>{
|
|
900
|
-
var
|
|
901
|
-
let order = (
|
|
912
|
+
var _sortedClassNames_get;
|
|
913
|
+
let order = (_sortedClassNames_get = sortedClassNames.get(className)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : null;
|
|
902
914
|
let parasiteIndex = parasiteUtilities.indexOf(className);
|
|
903
915
|
if (order === null && parasiteIndex !== -1) {
|
|
904
916
|
// This will make sure that it is at the very beginning of the
|
|
@@ -914,21 +926,40 @@ function registerPlugins(plugins, context) {
|
|
|
914
926
|
};
|
|
915
927
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
916
928
|
// ['uppercase', 'lowercase', ...]
|
|
917
|
-
context.getClassList = function getClassList() {
|
|
929
|
+
context.getClassList = function getClassList(options = {}) {
|
|
918
930
|
let output = [];
|
|
919
931
|
for (let util of classList){
|
|
920
932
|
if (Array.isArray(util)) {
|
|
921
|
-
|
|
933
|
+
var _utilOptions_types;
|
|
934
|
+
let [utilName, utilOptions] = util;
|
|
922
935
|
let negativeClasses = [];
|
|
923
|
-
var
|
|
924
|
-
|
|
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 : {})){
|
|
925
948
|
// Ignore undefined and null values
|
|
926
949
|
if (value == null) {
|
|
927
950
|
continue;
|
|
928
951
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
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);
|
|
932
963
|
}
|
|
933
964
|
}
|
|
934
965
|
output.push(...negativeClasses);
|
|
@@ -943,11 +974,11 @@ function registerPlugins(plugins, context) {
|
|
|
943
974
|
let result = [];
|
|
944
975
|
for (let [name, options] of context.variantOptions.entries()){
|
|
945
976
|
if (options.variantInfo === VARIANT_INFO.Base) continue;
|
|
946
|
-
var
|
|
977
|
+
var _options_values;
|
|
947
978
|
result.push({
|
|
948
979
|
name,
|
|
949
980
|
isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
|
|
950
|
-
values: Object.keys((
|
|
981
|
+
values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
|
|
951
982
|
hasDash: name !== "@",
|
|
952
983
|
selectors ({ modifier , value } = {}) {
|
|
953
984
|
let candidate = "__TAILWIND_PLACEHOLDER__";
|
|
@@ -960,17 +991,17 @@ function registerPlugins(plugins, context) {
|
|
|
960
991
|
]
|
|
961
992
|
});
|
|
962
993
|
let before = container.toString();
|
|
963
|
-
var
|
|
964
|
-
let fns = ((
|
|
994
|
+
var _context_variantMap_get;
|
|
995
|
+
let fns = ((_context_variantMap_get = context.variantMap.get(name)) !== null && _context_variantMap_get !== void 0 ? _context_variantMap_get : []).flatMap(([_, fn])=>fn);
|
|
965
996
|
let formatStrings = [];
|
|
966
997
|
for (let fn of fns){
|
|
967
|
-
var
|
|
998
|
+
var _options_values;
|
|
968
999
|
let localFormatStrings = [];
|
|
969
|
-
var
|
|
1000
|
+
var _options_values_value;
|
|
970
1001
|
let api = {
|
|
971
1002
|
args: {
|
|
972
1003
|
modifier,
|
|
973
|
-
value: (
|
|
1004
|
+
value: (_options_values_value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[value]) !== null && _options_values_value !== void 0 ? _options_values_value : value
|
|
974
1005
|
},
|
|
975
1006
|
separator: context.tailwindConfig.separator,
|
|
976
1007
|
modifySelectors (modifierFunction) {
|
|
@@ -1044,15 +1075,23 @@ function registerPlugins(plugins, context) {
|
|
|
1044
1075
|
manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
|
|
1045
1076
|
});
|
|
1046
1077
|
}
|
|
1047
|
-
var
|
|
1048
|
-
let
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1078
|
+
var _options_values1;
|
|
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());
|
|
1054
1093
|
if (manualFormatStrings.length > 0) {
|
|
1055
|
-
result.push((0, _formatVariantSelector.formatVariantSelector)("&"
|
|
1094
|
+
result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
|
|
1056
1095
|
}
|
|
1057
1096
|
return result;
|
|
1058
1097
|
}
|
|
@@ -1098,13 +1137,15 @@ function registerPlugins(plugins, context) {
|
|
|
1098
1137
|
markInvalidUtilityCandidate(context, candidate);
|
|
1099
1138
|
}
|
|
1100
1139
|
function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
|
|
1140
|
+
var _tailwindConfig_blocklist;
|
|
1101
1141
|
let context = {
|
|
1102
1142
|
disposables: [],
|
|
1103
1143
|
ruleCache: new Set(),
|
|
1104
1144
|
candidateRuleCache: new Map(),
|
|
1105
1145
|
classCache: new Map(),
|
|
1106
1146
|
applyClassCache: new Map(),
|
|
1107
|
-
|
|
1147
|
+
// Seed the not class cache with the blocklist (which is only strings)
|
|
1148
|
+
notClassCache: new Set((_tailwindConfig_blocklist = tailwindConfig.blocklist) !== null && _tailwindConfig_blocklist !== void 0 ? _tailwindConfig_blocklist : []),
|
|
1108
1149
|
postCssNodeCache: new Map(),
|
|
1109
1150
|
candidateRuleMap: new Map(),
|
|
1110
1151
|
tailwindConfig,
|
|
@@ -1139,13 +1180,14 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1139
1180
|
// If there's already a context in the cache and we don't need to
|
|
1140
1181
|
// reset the context, return the cached context.
|
|
1141
1182
|
if (existingContext) {
|
|
1142
|
-
let contextDependenciesChanged = trackModified([
|
|
1183
|
+
let [contextDependenciesChanged, mtimesToCommit] = trackModified([
|
|
1143
1184
|
...contextDependencies
|
|
1144
1185
|
], getFileModifiedMap(existingContext));
|
|
1145
1186
|
if (!contextDependenciesChanged && !cssDidChange) {
|
|
1146
1187
|
return [
|
|
1147
1188
|
existingContext,
|
|
1148
|
-
false
|
|
1189
|
+
false,
|
|
1190
|
+
mtimesToCommit
|
|
1149
1191
|
];
|
|
1150
1192
|
}
|
|
1151
1193
|
}
|
|
@@ -1176,7 +1218,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1176
1218
|
Object.assign(context2, {
|
|
1177
1219
|
userConfigPath
|
|
1178
1220
|
});
|
|
1179
|
-
trackModified([
|
|
1221
|
+
let [, mtimesToCommit1] = trackModified([
|
|
1180
1222
|
...contextDependencies
|
|
1181
1223
|
], getFileModifiedMap(context2));
|
|
1182
1224
|
// ---
|
|
@@ -1189,6 +1231,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1189
1231
|
contextSourcesMap.get(context2).add(sourcePath);
|
|
1190
1232
|
return [
|
|
1191
1233
|
context2,
|
|
1192
|
-
true
|
|
1234
|
+
true,
|
|
1235
|
+
mtimesToCommit1
|
|
1193
1236
|
];
|
|
1194
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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "build", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>build
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
const _plugin = require("./plugin");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async function build(args, configs) {
|
|
18
|
+
let input = args["--input"];
|
|
19
|
+
let shouldWatch = args["--watch"];
|
|
20
|
+
// TODO: Deprecate this in future versions
|
|
21
|
+
if (!input && args["_"][1]) {
|
|
22
|
+
console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
|
|
23
|
+
input = args["--input"] = args["_"][1];
|
|
24
|
+
}
|
|
25
|
+
if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
|
|
26
|
+
console.error(`Specified input file ${args["--input"]} does not exist.`);
|
|
27
|
+
process.exit(9);
|
|
28
|
+
}
|
|
29
|
+
if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
|
|
30
|
+
console.error(`Specified config file ${args["--config"]} does not exist.`);
|
|
31
|
+
process.exit(9);
|
|
32
|
+
}
|
|
33
|
+
// TODO: Reference the @config path here if exists
|
|
34
|
+
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
|
|
35
|
+
let processor = await (0, _plugin.createProcessor)(args, configPath);
|
|
36
|
+
if (shouldWatch) {
|
|
37
|
+
// Abort the watcher if stdin is closed to avoid zombie processes
|
|
38
|
+
// You can disable this behavior with --watch=always
|
|
39
|
+
if (args["--watch"] !== "always") {
|
|
40
|
+
process.stdin.on("end", ()=>process.exit(0));
|
|
41
|
+
}
|
|
42
|
+
process.stdin.resume();
|
|
43
|
+
await processor.watch();
|
|
44
|
+
} else {
|
|
45
|
+
await processor.build();
|
|
46
|
+
}
|
|
47
|
+
}
|