tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce
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 +380 -1
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +3 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +311 -213
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +11 -1
- package/lib/corePlugins.js +1895 -1773
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +22 -16
- package/lib/index.js +17 -8
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +30 -14
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +187 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +40 -24
- package/lib/lib/expandApplyAtRules.js +414 -157
- package/lib/lib/expandTailwindAtRules.js +156 -151
- package/lib/lib/generateRules.js +402 -68
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +45 -36
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +105 -90
- package/lib/lib/setupContextUtils.js +416 -291
- package/lib/lib/setupTrackingContext.js +60 -56
- package/lib/lib/sharedState.js +38 -15
- package/lib/lib/substituteScreenAtRules.js +9 -6
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +21 -9
- package/lib/public/colors.js +244 -248
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +13 -17
- package/lib/util/dataTypes.js +114 -74
- package/lib/util/defaults.js +6 -0
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -4
- package/lib/util/formatVariantSelector.js +194 -0
- package/lib/util/getAllConfigs.js +13 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +35 -19
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +5 -3
- package/lib/util/normalizeConfig.js +233 -0
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +76 -0
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +67 -170
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +123 -133
- package/lib/util/resolveConfigPath.js +17 -18
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +72 -0
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +42 -34
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +19 -19
- package/nesting/index.js +2 -12
- package/package.json +41 -42
- package/peers/index.js +11539 -10859
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +174 -41
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +641 -596
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +16 -10
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +192 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +24 -7
- package/src/lib/expandApplyAtRules.js +442 -154
- package/src/lib/expandTailwindAtRules.js +91 -65
- package/src/lib/generateRules.js +409 -43
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +74 -53
- package/src/lib/setupContextUtils.js +388 -208
- package/src/lib/setupTrackingContext.js +15 -12
- package/src/lib/sharedState.js +42 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +17 -2
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +56 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +213 -0
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +2 -2
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +262 -0
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +51 -147
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +108 -79
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +24 -7
- package/src/util/validateConfig.js +13 -0
- package/stubs/defaultConfig.stub.js +157 -94
- package/stubs/simpleConfig.stub.js +0 -1
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types.d.ts +1 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
|
@@ -8,19 +8,44 @@ var _corePluginList = _interopRequireDefault(require("../corePluginList"));
|
|
|
8
8
|
var _configurePlugins = _interopRequireDefault(require("./configurePlugins"));
|
|
9
9
|
var _defaultConfigStub = _interopRequireDefault(require("../../stubs/defaultConfig.stub"));
|
|
10
10
|
var _colors = _interopRequireDefault(require("../public/colors"));
|
|
11
|
-
var _log = _interopRequireDefault(require("./log"));
|
|
12
11
|
var _defaults = require("./defaults");
|
|
13
12
|
var _toPath = require("./toPath");
|
|
13
|
+
var _normalizeConfig = require("./normalizeConfig");
|
|
14
|
+
var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
|
|
15
|
+
var _cloneDeep = require("./cloneDeep");
|
|
16
|
+
var _withAlphaVariable = require("./withAlphaVariable");
|
|
17
|
+
function resolveConfig(configs) {
|
|
18
|
+
let allConfigs = [
|
|
19
|
+
...extractPluginConfigs(configs),
|
|
20
|
+
{
|
|
21
|
+
prefix: "",
|
|
22
|
+
important: false,
|
|
23
|
+
separator: ":",
|
|
24
|
+
variantOrder: _defaultConfigStub.default.variantOrder
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
var ref, ref1;
|
|
28
|
+
return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
|
|
29
|
+
theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
|
|
30
|
+
return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
|
|
31
|
+
})))),
|
|
32
|
+
corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
|
|
33
|
+
)),
|
|
34
|
+
plugins: resolvePluginLists(configs.map((c)=>{
|
|
35
|
+
return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
|
|
36
|
+
}))
|
|
37
|
+
}, ...allConfigs));
|
|
38
|
+
}
|
|
14
39
|
function _interopRequireDefault(obj) {
|
|
15
40
|
return obj && obj.__esModule ? obj : {
|
|
16
41
|
default: obj
|
|
17
42
|
};
|
|
18
43
|
}
|
|
19
44
|
function isFunction(input) {
|
|
20
|
-
return typeof input ===
|
|
45
|
+
return typeof input === "function";
|
|
21
46
|
}
|
|
22
47
|
function isObject(input) {
|
|
23
|
-
return typeof input ===
|
|
48
|
+
return typeof input === "object" && input !== null;
|
|
24
49
|
}
|
|
25
50
|
function mergeWith(target, ...sources) {
|
|
26
51
|
let customizer = sources.pop();
|
|
@@ -43,22 +68,45 @@ function mergeWith(target, ...sources) {
|
|
|
43
68
|
const configUtils = {
|
|
44
69
|
colors: _colors.default,
|
|
45
70
|
negative (scale) {
|
|
46
|
-
|
|
47
|
-
).
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
// TODO: Log that this function isn't really needed anymore?
|
|
72
|
+
return Object.keys(scale).filter((key)=>scale[key] !== "0"
|
|
73
|
+
).reduce((negativeScale, key)=>{
|
|
74
|
+
let negativeValue = (0, _negateValue).default(scale[key]);
|
|
75
|
+
if (negativeValue !== undefined) {
|
|
76
|
+
negativeScale[`-${key}`] = negativeValue;
|
|
77
|
+
}
|
|
78
|
+
return negativeScale;
|
|
79
|
+
}, {});
|
|
53
80
|
},
|
|
54
81
|
breakpoints (screens) {
|
|
55
|
-
return Object.keys(screens).filter((key)=>typeof screens[key] ===
|
|
82
|
+
return Object.keys(screens).filter((key)=>typeof screens[key] === "string"
|
|
56
83
|
).reduce((breakpoints, key)=>({
|
|
57
84
|
...breakpoints,
|
|
58
85
|
[`screen-${key}`]: screens[key]
|
|
59
86
|
})
|
|
60
|
-
, {
|
|
61
|
-
|
|
87
|
+
, {});
|
|
88
|
+
},
|
|
89
|
+
rgb (property) {
|
|
90
|
+
if (!property.startsWith("--")) {
|
|
91
|
+
throw new Error("The rgb() helper requires a custom property name to be passed as the first argument.");
|
|
92
|
+
}
|
|
93
|
+
return ({ opacityValue })=>{
|
|
94
|
+
if (opacityValue === undefined || opacityValue === 1) {
|
|
95
|
+
return `rgb(var(${property}) / 1.0)`;
|
|
96
|
+
}
|
|
97
|
+
return `rgb(var(${property}) / ${opacityValue})`;
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
hsl (property) {
|
|
101
|
+
if (!property.startsWith("--")) {
|
|
102
|
+
throw new Error("The hsl() helper requires a custom property name to be passed as the first argument.");
|
|
103
|
+
}
|
|
104
|
+
return ({ opacityValue })=>{
|
|
105
|
+
if (opacityValue === undefined || opacityValue === 1) {
|
|
106
|
+
return `hsl(var(${property}) / 1)`;
|
|
107
|
+
}
|
|
108
|
+
return `hsl(var(${property}) / ${opacityValue})`;
|
|
109
|
+
};
|
|
62
110
|
}
|
|
63
111
|
};
|
|
64
112
|
function value(valueToResolve, ...args) {
|
|
@@ -83,34 +131,32 @@ function collectExtends(items) {
|
|
|
83
131
|
mergedValue
|
|
84
132
|
];
|
|
85
133
|
});
|
|
86
|
-
}, {
|
|
87
|
-
});
|
|
134
|
+
}, {});
|
|
88
135
|
}
|
|
89
136
|
function mergeThemes(themes) {
|
|
90
137
|
return {
|
|
91
138
|
...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme)
|
|
92
|
-
, {
|
|
93
|
-
}),
|
|
139
|
+
, {}),
|
|
94
140
|
// In order to resolve n config objects, we combine all of their `extend` properties
|
|
95
141
|
// into arrays instead of objects so they aren't overridden.
|
|
96
142
|
extend: collectExtends(themes)
|
|
97
143
|
};
|
|
98
144
|
}
|
|
99
|
-
function mergeExtensionCustomizer(merged,
|
|
145
|
+
function mergeExtensionCustomizer(merged, value1) {
|
|
100
146
|
// When we have an array of objects, we do want to merge it
|
|
101
147
|
if (Array.isArray(merged) && isObject(merged[0])) {
|
|
102
|
-
return merged.concat(
|
|
148
|
+
return merged.concat(value1);
|
|
103
149
|
}
|
|
104
150
|
// When the incoming value is an array, and the existing config is an object, prepend the existing object
|
|
105
|
-
if (Array.isArray(
|
|
151
|
+
if (Array.isArray(value1) && isObject(value1[0]) && isObject(merged)) {
|
|
106
152
|
return [
|
|
107
153
|
merged,
|
|
108
|
-
...
|
|
154
|
+
...value1
|
|
109
155
|
];
|
|
110
156
|
}
|
|
111
157
|
// Override arrays (for example for font-families, box-shadows, ...)
|
|
112
|
-
if (Array.isArray(
|
|
113
|
-
return
|
|
158
|
+
if (Array.isArray(value1)) {
|
|
159
|
+
return value1;
|
|
114
160
|
}
|
|
115
161
|
// Execute default behaviour
|
|
116
162
|
return undefined;
|
|
@@ -119,11 +165,9 @@ function mergeExtensions({ extend , ...theme }) {
|
|
|
119
165
|
return mergeWith(theme, extend, (themeValue, extensions)=>{
|
|
120
166
|
// The `extend` property is an array, so we need to check if it contains any functions
|
|
121
167
|
if (!isFunction(themeValue) && !extensions.some(isFunction)) {
|
|
122
|
-
return mergeWith({
|
|
123
|
-
}, themeValue, ...extensions, mergeExtensionCustomizer);
|
|
168
|
+
return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
|
|
124
169
|
}
|
|
125
|
-
return (resolveThemePath, utils)=>mergeWith({
|
|
126
|
-
}, ...[
|
|
170
|
+
return (resolveThemePath, utils)=>mergeWith({}, ...[
|
|
127
171
|
themeValue,
|
|
128
172
|
...extensions
|
|
129
173
|
].map((e)=>value(e, resolveThemePath, utils)
|
|
@@ -131,28 +175,60 @@ function mergeExtensions({ extend , ...theme }) {
|
|
|
131
175
|
;
|
|
132
176
|
});
|
|
133
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
*
|
|
180
|
+
* @param {string} key
|
|
181
|
+
* @return {Iterable<string[] & {alpha: string | undefined}>}
|
|
182
|
+
*/ function* toPaths(key) {
|
|
183
|
+
let path = (0, _toPath).toPath(key);
|
|
184
|
+
if (path.length === 0) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
yield path;
|
|
188
|
+
if (Array.isArray(key)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
let pattern = /^(.*?)\s*\/\s*([^/]+)$/;
|
|
192
|
+
let matches = key.match(pattern);
|
|
193
|
+
if (matches !== null) {
|
|
194
|
+
let [, prefix, alpha] = matches;
|
|
195
|
+
let newPath = (0, _toPath).toPath(prefix);
|
|
196
|
+
newPath.alpha = alpha;
|
|
197
|
+
yield newPath;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
134
200
|
function resolveFunctionKeys(object) {
|
|
201
|
+
// theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
|
|
135
202
|
const resolvePath = (key, defaultValue)=>{
|
|
136
|
-
const path
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
203
|
+
for (const path of toPaths(key)){
|
|
204
|
+
let index = 0;
|
|
205
|
+
let val = object;
|
|
206
|
+
while(val !== undefined && val !== null && index < path.length){
|
|
207
|
+
val = val[path[index++]];
|
|
208
|
+
let shouldResolveAsFn = isFunction(val) && (path.alpha === undefined || index < path.length - 1);
|
|
209
|
+
val = shouldResolveAsFn ? val(resolvePath, configUtils) : val;
|
|
210
|
+
}
|
|
211
|
+
if (val !== undefined) {
|
|
212
|
+
if (path.alpha !== undefined) {
|
|
213
|
+
return (0, _withAlphaVariable).withAlphaValue(val, path.alpha);
|
|
214
|
+
}
|
|
215
|
+
if ((0, _isPlainObject).default(val)) {
|
|
216
|
+
return (0, _cloneDeep).cloneDeep(val);
|
|
217
|
+
}
|
|
218
|
+
return val;
|
|
219
|
+
}
|
|
142
220
|
}
|
|
143
|
-
return
|
|
221
|
+
return defaultValue;
|
|
144
222
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
resolvePath
|
|
148
|
-
|
|
149
|
-
return Object.keys(object).reduce((resolved, key)=>{
|
|
150
|
-
return {
|
|
151
|
-
...resolved,
|
|
152
|
-
[key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
|
|
153
|
-
};
|
|
154
|
-
}, {
|
|
223
|
+
// colors.red.500/50
|
|
224
|
+
Object.assign(resolvePath, {
|
|
225
|
+
theme: resolvePath,
|
|
226
|
+
...configUtils
|
|
155
227
|
});
|
|
228
|
+
return Object.keys(object).reduce((resolved, key)=>{
|
|
229
|
+
resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key];
|
|
230
|
+
return resolved;
|
|
231
|
+
}, {});
|
|
156
232
|
}
|
|
157
233
|
function extractPluginConfigs(configs) {
|
|
158
234
|
let allConfigs = [];
|
|
@@ -161,8 +237,8 @@ function extractPluginConfigs(configs) {
|
|
|
161
237
|
...allConfigs,
|
|
162
238
|
config
|
|
163
239
|
];
|
|
164
|
-
var
|
|
165
|
-
const plugins = (
|
|
240
|
+
var ref2;
|
|
241
|
+
const plugins = (ref2 = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref2 !== void 0 ? ref2 : [];
|
|
166
242
|
if (plugins.length === 0) {
|
|
167
243
|
return;
|
|
168
244
|
}
|
|
@@ -174,8 +250,7 @@ function extractPluginConfigs(configs) {
|
|
|
174
250
|
allConfigs = [
|
|
175
251
|
...allConfigs,
|
|
176
252
|
...extractPluginConfigs([
|
|
177
|
-
(ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {
|
|
178
|
-
}
|
|
253
|
+
(ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {}
|
|
179
254
|
])
|
|
180
255
|
];
|
|
181
256
|
});
|
|
@@ -206,88 +281,3 @@ function resolvePluginLists(pluginLists) {
|
|
|
206
281
|
}, []);
|
|
207
282
|
return result;
|
|
208
283
|
}
|
|
209
|
-
function resolveConfig(configs) {
|
|
210
|
-
let allConfigs = [
|
|
211
|
-
...extractPluginConfigs(configs),
|
|
212
|
-
{
|
|
213
|
-
prefix: '',
|
|
214
|
-
important: false,
|
|
215
|
-
separator: ':',
|
|
216
|
-
variantOrder: _defaultConfigStub.default.variantOrder
|
|
217
|
-
},
|
|
218
|
-
];
|
|
219
|
-
var ref, ref1;
|
|
220
|
-
return normalizeConfig((0, _defaults).defaults({
|
|
221
|
-
theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
|
|
222
|
-
return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {
|
|
223
|
-
};
|
|
224
|
-
})))),
|
|
225
|
-
corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
|
|
226
|
-
)),
|
|
227
|
-
plugins: resolvePluginLists(configs.map((c)=>{
|
|
228
|
-
return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
|
|
229
|
-
}))
|
|
230
|
-
}, ...allConfigs));
|
|
231
|
-
}
|
|
232
|
-
let warnedAbout = new Set();
|
|
233
|
-
function normalizeConfig(config) {
|
|
234
|
-
var ref, ref1, ref2, ref3, ref4, ref5;
|
|
235
|
-
if (!warnedAbout.has('purge-deprecation') && config.hasOwnProperty('purge')) {
|
|
236
|
-
_log.default.warn([
|
|
237
|
-
'The `purge` option in your tailwind.config.js file has been deprecated.',
|
|
238
|
-
'Please rename this to `content` instead.',
|
|
239
|
-
]);
|
|
240
|
-
warnedAbout.add('purge-deprecation');
|
|
241
|
-
}
|
|
242
|
-
config.content = {
|
|
243
|
-
content: (()=>{
|
|
244
|
-
let { content , purge } = config;
|
|
245
|
-
if (Array.isArray(purge)) return purge;
|
|
246
|
-
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
|
|
247
|
-
if (Array.isArray(content)) return content;
|
|
248
|
-
if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
|
|
249
|
-
return [];
|
|
250
|
-
})(),
|
|
251
|
-
safelist: (()=>{
|
|
252
|
-
let { content , purge } = config;
|
|
253
|
-
let [safelistKey, safelistPaths] = (()=>{
|
|
254
|
-
var ref;
|
|
255
|
-
if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return [
|
|
256
|
-
'content.safelist',
|
|
257
|
-
content.safelist
|
|
258
|
-
];
|
|
259
|
-
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return [
|
|
260
|
-
'purge.safelist',
|
|
261
|
-
purge.safelist
|
|
262
|
-
];
|
|
263
|
-
if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return [
|
|
264
|
-
'purge.options.safelist',
|
|
265
|
-
purge.options.safelist
|
|
266
|
-
];
|
|
267
|
-
return [
|
|
268
|
-
null,
|
|
269
|
-
[]
|
|
270
|
-
];
|
|
271
|
-
})();
|
|
272
|
-
return safelistPaths.map((content)=>{
|
|
273
|
-
if (typeof content === 'string') {
|
|
274
|
-
return {
|
|
275
|
-
raw: content,
|
|
276
|
-
extension: 'html'
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
if (content instanceof RegExp) {
|
|
280
|
-
throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found 'regex'.`);
|
|
281
|
-
}
|
|
282
|
-
throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found '${typeof content}'.`);
|
|
283
|
-
});
|
|
284
|
-
})(),
|
|
285
|
-
extract: ((ref = config.content) === null || ref === void 0 ? void 0 : ref.extract) || ((ref1 = config.purge) === null || ref1 === void 0 ? void 0 : ref1.extract) || {
|
|
286
|
-
},
|
|
287
|
-
options: ((ref2 = config.content) === null || ref2 === void 0 ? void 0 : ref2.options) || ((ref3 = config.purge) === null || ref3 === void 0 ? void 0 : ref3.options) || {
|
|
288
|
-
},
|
|
289
|
-
transform: ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : ref4.transform) || ((ref5 = config.purge) === null || ref5 === void 0 ? void 0 : ref5.transform) || {
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
return config;
|
|
293
|
-
}
|
|
@@ -5,20 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = resolveConfigPath;
|
|
6
6
|
var _fs = _interopRequireDefault(require("fs"));
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function isObject(value) {
|
|
14
|
-
return typeof value === 'object' && value !== null;
|
|
15
|
-
}
|
|
16
|
-
function isEmpty(obj) {
|
|
17
|
-
return Object.keys(obj).length === 0;
|
|
18
|
-
}
|
|
19
|
-
function isString(value) {
|
|
20
|
-
return typeof value === 'string' || value instanceof String;
|
|
21
|
-
}
|
|
22
8
|
function resolveConfigPath(pathOrConfig) {
|
|
23
9
|
// require('tailwindcss')({ theme: ..., variants: ... })
|
|
24
10
|
if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
|
|
@@ -38,15 +24,28 @@ function resolveConfigPath(pathOrConfig) {
|
|
|
38
24
|
}
|
|
39
25
|
// require('tailwindcss')
|
|
40
26
|
for (const configFile of [
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
"./tailwind.config.js",
|
|
28
|
+
"./tailwind.config.cjs"
|
|
43
29
|
]){
|
|
44
30
|
try {
|
|
45
31
|
const configPath = _path.default.resolve(configFile);
|
|
46
32
|
_fs.default.accessSync(configPath);
|
|
47
33
|
return configPath;
|
|
48
|
-
} catch (err) {
|
|
49
|
-
}
|
|
34
|
+
} catch (err) {}
|
|
50
35
|
}
|
|
51
36
|
return null;
|
|
52
37
|
}
|
|
38
|
+
function _interopRequireDefault(obj) {
|
|
39
|
+
return obj && obj.__esModule ? obj : {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function isObject(value) {
|
|
44
|
+
return typeof value === "object" && value !== null;
|
|
45
|
+
}
|
|
46
|
+
function isEmpty(obj) {
|
|
47
|
+
return Object.keys(obj).length === 0;
|
|
48
|
+
}
|
|
49
|
+
function isString(value) {
|
|
50
|
+
return typeof value === "string" || value instanceof String;
|
|
51
|
+
}
|
package/lib/util/responsive.js
CHANGED
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = responsive;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
7
|
var _cloneNodes = _interopRequireDefault(require("./cloneNodes"));
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
8
|
function responsive(rules) {
|
|
14
9
|
return _postcss.default.atRule({
|
|
15
|
-
name:
|
|
10
|
+
name: "responsive"
|
|
16
11
|
}).append((0, _cloneNodes).default(Array.isArray(rules) ? rules : [
|
|
17
12
|
rules
|
|
18
13
|
]));
|
|
19
14
|
}
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.splitAtTopLevelOnly = splitAtTopLevelOnly;
|
|
6
|
+
var regex = _interopRequireWildcard(require("../lib/regex"));
|
|
7
|
+
function _interopRequireWildcard(obj) {
|
|
8
|
+
if (obj && obj.__esModule) {
|
|
9
|
+
return obj;
|
|
10
|
+
} else {
|
|
11
|
+
var newObj = {};
|
|
12
|
+
if (obj != null) {
|
|
13
|
+
for(var key in obj){
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
15
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
16
|
+
if (desc.get || desc.set) {
|
|
17
|
+
Object.defineProperty(newObj, key, desc);
|
|
18
|
+
} else {
|
|
19
|
+
newObj[key] = obj[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
newObj.default = obj;
|
|
25
|
+
return newObj;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function* splitAtTopLevelOnly(input, separator) {
|
|
29
|
+
let SPECIALS = new RegExp(`[(){}\\[\\]${regex.escape(separator)}]`, "g");
|
|
30
|
+
let depth = 0;
|
|
31
|
+
let lastIndex = 0;
|
|
32
|
+
let found = false;
|
|
33
|
+
let separatorIndex = 0;
|
|
34
|
+
let separatorStart = 0;
|
|
35
|
+
let separatorLength = separator.length;
|
|
36
|
+
// Find all paren-like things & character
|
|
37
|
+
// And only split on commas if they're top-level
|
|
38
|
+
for (let match of input.matchAll(SPECIALS)){
|
|
39
|
+
let matchesSeparator = match[0] === separator[separatorIndex];
|
|
40
|
+
let atEndOfSeparator = separatorIndex === separatorLength - 1;
|
|
41
|
+
let matchesFullSeparator = matchesSeparator && atEndOfSeparator;
|
|
42
|
+
if (match[0] === "(") depth++;
|
|
43
|
+
if (match[0] === ")") depth--;
|
|
44
|
+
if (match[0] === "[") depth++;
|
|
45
|
+
if (match[0] === "]") depth--;
|
|
46
|
+
if (match[0] === "{") depth++;
|
|
47
|
+
if (match[0] === "}") depth--;
|
|
48
|
+
if (matchesSeparator && depth === 0) {
|
|
49
|
+
if (separatorStart === 0) {
|
|
50
|
+
separatorStart = match.index;
|
|
51
|
+
}
|
|
52
|
+
separatorIndex++;
|
|
53
|
+
}
|
|
54
|
+
if (matchesFullSeparator && depth === 0) {
|
|
55
|
+
found = true;
|
|
56
|
+
yield input.substring(lastIndex, separatorStart);
|
|
57
|
+
lastIndex = separatorStart + separatorLength;
|
|
58
|
+
}
|
|
59
|
+
if (separatorIndex === separatorLength) {
|
|
60
|
+
separatorIndex = 0;
|
|
61
|
+
separatorStart = 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Provide the last segment of the string if available
|
|
65
|
+
// Otherwise the whole string since no `char`s were found
|
|
66
|
+
// This mirrors the behavior of string.split()
|
|
67
|
+
if (found) {
|
|
68
|
+
yield input.substring(lastIndex);
|
|
69
|
+
} else {
|
|
70
|
+
yield input;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/lib/util/toColorValue.js
CHANGED
|
@@ -4,6 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = toColorValue;
|
|
6
6
|
function toColorValue(maybeFunction) {
|
|
7
|
-
return typeof maybeFunction ===
|
|
8
|
-
}) : maybeFunction;
|
|
7
|
+
return typeof maybeFunction === "function" ? maybeFunction({}) : maybeFunction;
|
|
9
8
|
}
|
package/lib/util/toPath.js
CHANGED
|
@@ -5,5 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.toPath = toPath;
|
|
6
6
|
function toPath(path) {
|
|
7
7
|
if (Array.isArray(path)) return path;
|
|
8
|
-
|
|
8
|
+
let openBrackets = path.split("[").length - 1;
|
|
9
|
+
let closedBrackets = path.split("]").length - 1;
|
|
10
|
+
if (openBrackets !== closedBrackets) {
|
|
11
|
+
throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
|
|
12
|
+
}
|
|
13
|
+
return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean);
|
|
9
14
|
}
|
|
@@ -4,50 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = transformThemeValue;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
7
|
function transformThemeValue(themeSection) {
|
|
13
8
|
if ([
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
"fontSize",
|
|
10
|
+
"outline"
|
|
16
11
|
].includes(themeSection)) {
|
|
17
|
-
return (value)=>
|
|
18
|
-
|
|
12
|
+
return (value)=>{
|
|
13
|
+
if (typeof value === "function") value = value({});
|
|
14
|
+
if (Array.isArray(value)) value = value[0];
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
19
17
|
}
|
|
20
18
|
if ([
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
"fontFamily",
|
|
20
|
+
"boxShadow",
|
|
21
|
+
"transitionProperty",
|
|
22
|
+
"transitionDuration",
|
|
23
|
+
"transitionDelay",
|
|
24
|
+
"transitionTimingFunction",
|
|
25
|
+
"backgroundImage",
|
|
26
|
+
"backgroundSize",
|
|
27
|
+
"backgroundColor",
|
|
28
|
+
"cursor",
|
|
29
|
+
"animation",
|
|
32
30
|
].includes(themeSection)) {
|
|
33
|
-
return (value)=>
|
|
34
|
-
|
|
31
|
+
return (value)=>{
|
|
32
|
+
if (typeof value === "function") value = value({});
|
|
33
|
+
if (Array.isArray(value)) value = value.join(", ");
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
35
36
|
}
|
|
36
37
|
// For backwards compatibility reasons, before we switched to underscores
|
|
37
38
|
// instead of commas for arbitrary values.
|
|
38
39
|
if ([
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"gridTemplateColumns",
|
|
41
|
+
"gridTemplateRows",
|
|
42
|
+
"objectPosition"
|
|
42
43
|
].includes(themeSection)) {
|
|
43
|
-
return (value)=>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}) : value
|
|
49
|
-
;
|
|
44
|
+
return (value)=>{
|
|
45
|
+
if (typeof value === "function") value = value({});
|
|
46
|
+
if (typeof value === "string") value = _postcss.default.list.comma(value).join(" ");
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
50
49
|
}
|
|
51
|
-
return (value)=>
|
|
52
|
-
|
|
50
|
+
return (value, opts = {})=>{
|
|
51
|
+
if (typeof value === "function") {
|
|
52
|
+
value = value(opts);
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function _interopRequireDefault(obj) {
|
|
58
|
+
return obj && obj.__esModule ? obj : {
|
|
59
|
+
default: obj
|
|
60
|
+
};
|
|
53
61
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.validateConfig = validateConfig;
|
|
6
|
+
var _log = _interopRequireDefault(require("./log"));
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function validateConfig(config) {
|
|
13
|
+
if (config.content.files.length === 0) {
|
|
14
|
+
_log.default.warn("content-problems", [
|
|
15
|
+
"The `content` option in your Tailwind CSS configuration is missing or empty.",
|
|
16
|
+
"Configure your content sources or your generated CSS will be missing styles.",
|
|
17
|
+
"https://tailwindcss.com/docs/content-configuration",
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}
|