tailwindcss 3.2.4 → 3.2.6
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 +51 -1
- package/README.md +1 -1
- package/lib/cli/build/index.js +5 -1
- package/lib/cli/build/plugin.js +39 -34
- 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 +34 -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 +121 -80
- 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 +22 -22
- package/lib/util/pluginUtils.js +38 -40
- package/lib/util/prefixSelector.js +22 -8
- package/lib/util/resolveConfig.js +8 -10
- package/package.json +30 -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 +14 -9
- 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 +35 -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 +97 -55
- 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/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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
7
|
+
const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
|
|
8
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
9
|
+
const _build = require("./build");
|
|
10
|
+
const _help = require("./help");
|
|
11
|
+
const _init = require("./init");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function isESM() {
|
|
18
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
+
try {
|
|
20
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
+
return pkg.type && pkg.type === "module";
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let configs = isESM() ? {
|
|
27
|
+
tailwind: "tailwind.config.cjs"
|
|
28
|
+
} : {
|
|
29
|
+
tailwind: "tailwind.config.js"
|
|
30
|
+
};
|
|
31
|
+
// ---
|
|
32
|
+
function oneOf(...options) {
|
|
33
|
+
return Object.assign((value = true)=>{
|
|
34
|
+
for (let option of options){
|
|
35
|
+
let parsed = option(value);
|
|
36
|
+
if (parsed === value) {
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
throw new Error("...");
|
|
41
|
+
}, {
|
|
42
|
+
manualParsing: true
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
let commands = {
|
|
46
|
+
init: {
|
|
47
|
+
run: _init.init,
|
|
48
|
+
args: {
|
|
49
|
+
"--full": {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
description: `Initialize a full \`${configs.tailwind}\` file`
|
|
52
|
+
},
|
|
53
|
+
"-f": "--full"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
build: {
|
|
57
|
+
run: _build.build,
|
|
58
|
+
args: {
|
|
59
|
+
"--input": {
|
|
60
|
+
type: String,
|
|
61
|
+
description: "Input file"
|
|
62
|
+
},
|
|
63
|
+
"--output": {
|
|
64
|
+
type: String,
|
|
65
|
+
description: "Output file"
|
|
66
|
+
},
|
|
67
|
+
"--watch": {
|
|
68
|
+
type: oneOf(String, Boolean),
|
|
69
|
+
description: "Watch for changes and rebuild as needed"
|
|
70
|
+
},
|
|
71
|
+
"--poll": {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
description: "Use polling instead of filesystem events when watching"
|
|
74
|
+
},
|
|
75
|
+
"--content": {
|
|
76
|
+
type: String,
|
|
77
|
+
description: "Content paths to use for removing unused classes"
|
|
78
|
+
},
|
|
79
|
+
"--minify": {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
description: "Minify the output"
|
|
82
|
+
},
|
|
83
|
+
"--config": {
|
|
84
|
+
type: String,
|
|
85
|
+
description: "Path to a custom config file"
|
|
86
|
+
},
|
|
87
|
+
"-c": "--config",
|
|
88
|
+
"-i": "--input",
|
|
89
|
+
"-o": "--output",
|
|
90
|
+
"-m": "--minify",
|
|
91
|
+
"-w": "--watch",
|
|
92
|
+
"-p": "--poll"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
let sharedFlags = {
|
|
97
|
+
"--help": {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
description: "Display usage information"
|
|
100
|
+
},
|
|
101
|
+
"-h": "--help"
|
|
102
|
+
};
|
|
103
|
+
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
104
|
+
(0, _help.help)({
|
|
105
|
+
usage: [
|
|
106
|
+
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
|
107
|
+
"tailwindcss init [--full] [options...]"
|
|
108
|
+
],
|
|
109
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
110
|
+
options: {
|
|
111
|
+
...commands.build.args,
|
|
112
|
+
...sharedFlags
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
|
|
118
|
+
if (commands[command] === undefined) {
|
|
119
|
+
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
120
|
+
// TODO: Deprecate this in future versions
|
|
121
|
+
// Check if non-existing command, might be a file.
|
|
122
|
+
command = "build";
|
|
123
|
+
} else {
|
|
124
|
+
(0, _help.help)({
|
|
125
|
+
message: `Invalid command: ${command}`,
|
|
126
|
+
usage: [
|
|
127
|
+
"tailwindcss <command> [options]"
|
|
128
|
+
],
|
|
129
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
130
|
+
options: sharedFlags
|
|
131
|
+
});
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Execute command
|
|
136
|
+
let { args: flags , run } = commands[command];
|
|
137
|
+
let args = (()=>{
|
|
138
|
+
try {
|
|
139
|
+
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
140
|
+
...flags,
|
|
141
|
+
...sharedFlags
|
|
142
|
+
}).filter(([_key, value])=>{
|
|
143
|
+
var _value_type;
|
|
144
|
+
return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
|
145
|
+
}).map(([key, value])=>[
|
|
146
|
+
key,
|
|
147
|
+
typeof value === "object" ? value.type : value
|
|
148
|
+
])), {
|
|
149
|
+
permissive: true
|
|
150
|
+
});
|
|
151
|
+
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
152
|
+
for(let i = result["_"].length - 1; i >= 0; --i){
|
|
153
|
+
let flag = result["_"][i];
|
|
154
|
+
if (!flag.startsWith("-")) continue;
|
|
155
|
+
let [flagName, flagValue] = flag.split("=");
|
|
156
|
+
let handler = flags[flagName];
|
|
157
|
+
// Resolve flagName & handler
|
|
158
|
+
while(typeof handler === "string"){
|
|
159
|
+
flagName = handler;
|
|
160
|
+
handler = flags[handler];
|
|
161
|
+
}
|
|
162
|
+
if (!handler) continue;
|
|
163
|
+
let args = [];
|
|
164
|
+
let offset = i + 1;
|
|
165
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
166
|
+
if (flagValue === undefined) {
|
|
167
|
+
// Parse args for current flag
|
|
168
|
+
while(result["_"][offset] && !result["_"][offset].startsWith("-")){
|
|
169
|
+
args.push(result["_"][offset++]);
|
|
170
|
+
}
|
|
171
|
+
// Cleanup manually parsed flags + args
|
|
172
|
+
result["_"].splice(i, 1 + args.length);
|
|
173
|
+
// No args were provided, use default value defined in handler
|
|
174
|
+
// One arg was provided, use that directly
|
|
175
|
+
// Multiple args were provided so pass them all in an array
|
|
176
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
177
|
+
} else {
|
|
178
|
+
// Remove the whole flag from the args array
|
|
179
|
+
result["_"].splice(i, 1);
|
|
180
|
+
}
|
|
181
|
+
// Set the resolved value in the `result` object
|
|
182
|
+
result[flagName] = handler.type(flagValue, flagName);
|
|
183
|
+
}
|
|
184
|
+
// Ensure that the `command` is always the first argument in the `args`.
|
|
185
|
+
// This is important so that we don't have to check if a default command
|
|
186
|
+
// (build) was used or not from within each plugin.
|
|
187
|
+
//
|
|
188
|
+
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
189
|
+
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
190
|
+
if (result["_"][0] !== command) {
|
|
191
|
+
result["_"].unshift(command);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
} catch (err) {
|
|
195
|
+
if (err.code === "ARG_UNKNOWN_OPTION") {
|
|
196
|
+
(0, _help.help)({
|
|
197
|
+
message: err.message,
|
|
198
|
+
usage: [
|
|
199
|
+
"tailwindcss <command> [options]"
|
|
200
|
+
],
|
|
201
|
+
options: sharedFlags
|
|
202
|
+
});
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
if (args["--help"]) {
|
|
209
|
+
(0, _help.help)({
|
|
210
|
+
options: {
|
|
211
|
+
...flags,
|
|
212
|
+
...sharedFlags
|
|
213
|
+
},
|
|
214
|
+
usage: [
|
|
215
|
+
`tailwindcss ${command} [options]`
|
|
216
|
+
]
|
|
217
|
+
});
|
|
218
|
+
process.exit(0);
|
|
219
|
+
}
|
|
220
|
+
run(args, configs);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "init", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>init
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function init(args, configs) {
|
|
17
|
+
let messages = [];
|
|
18
|
+
var _args___;
|
|
19
|
+
let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./${configs.tailwind}`);
|
|
20
|
+
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
21
|
+
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
22
|
+
} else {
|
|
23
|
+
let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../../../../stubs/simpleConfig.stub.js"), "utf8");
|
|
24
|
+
// Change colors import
|
|
25
|
+
stubFile = stubFile.replace("../colors", "tailwindcss/colors");
|
|
26
|
+
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
|
|
27
|
+
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
28
|
+
}
|
|
29
|
+
if (messages.length > 0) {
|
|
30
|
+
console.log();
|
|
31
|
+
for (let message of messages){
|
|
32
|
+
console.log(message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/lib/oxide/cli.js
ADDED
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _setupTrackingContext = /*#__PURE__*/ _interopRequireDefault(require("./lib/setupTrackingContext"));
|
|
6
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
|
|
7
|
+
const _sharedState = require("./lib/sharedState");
|
|
8
|
+
const _findAtConfigPath = require("./lib/findAtConfigPath");
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : {
|
|
11
|
+
default: obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
module.exports = function tailwindcss(configOrPath) {
|
|
15
|
+
return {
|
|
16
|
+
postcssPlugin: "tailwindcss",
|
|
17
|
+
plugins: [
|
|
18
|
+
_sharedState.env.DEBUG && function(root) {
|
|
19
|
+
console.log("\n");
|
|
20
|
+
console.time("JIT TOTAL");
|
|
21
|
+
return root;
|
|
22
|
+
},
|
|
23
|
+
function(root, result) {
|
|
24
|
+
var _findAtConfigPath1;
|
|
25
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
26
|
+
// path for the file being processed
|
|
27
|
+
configOrPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : configOrPath;
|
|
28
|
+
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
29
|
+
if (root.type === "document") {
|
|
30
|
+
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
31
|
+
for (const root1 of roots){
|
|
32
|
+
if (root1.type === "root") {
|
|
33
|
+
(0, _processTailwindFeatures.default)(context)(root1, result);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
39
|
+
},
|
|
40
|
+
_sharedState.env.OXIDE && function lightningCssPlugin(_root, result) {
|
|
41
|
+
let postcss = require("postcss");
|
|
42
|
+
let lightningcss = require("lightningcss");
|
|
43
|
+
let browserslist = require("browserslist");
|
|
44
|
+
try {
|
|
45
|
+
let transformed = lightningcss.transform({
|
|
46
|
+
filename: result.opts.from,
|
|
47
|
+
code: Buffer.from(result.root.toString()),
|
|
48
|
+
minify: false,
|
|
49
|
+
sourceMap: !!result.map,
|
|
50
|
+
inputSourceMap: result.map ? result.map.toString() : undefined,
|
|
51
|
+
targets: typeof process !== "undefined" && process.env.JEST_WORKER_ID ? {
|
|
52
|
+
chrome: 106 << 16
|
|
53
|
+
} : lightningcss.browserslistToTargets(browserslist(require("../package.json").browserslist)),
|
|
54
|
+
drafts: {
|
|
55
|
+
nesting: true,
|
|
56
|
+
customMedia: true
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var _result_map;
|
|
60
|
+
result.map = Object.assign((_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : {}, {
|
|
61
|
+
toJSON () {
|
|
62
|
+
return transformed.map.toJSON();
|
|
63
|
+
},
|
|
64
|
+
toString () {
|
|
65
|
+
return transformed.map.toString();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
result.root = postcss.parse(transformed.code.toString("utf8"));
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) {
|
|
71
|
+
let lines = err.source.split("\n");
|
|
72
|
+
err = new Error([
|
|
73
|
+
"Error formatting using Lightning CSS:",
|
|
74
|
+
"",
|
|
75
|
+
...[
|
|
76
|
+
"```css",
|
|
77
|
+
...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
|
|
78
|
+
" ".repeat(err.loc.column - 1) + "^-- " + err.toString(),
|
|
79
|
+
...lines.slice(err.loc.line, err.loc.line + 2),
|
|
80
|
+
"```"
|
|
81
|
+
]
|
|
82
|
+
].join("\n"));
|
|
83
|
+
}
|
|
84
|
+
if (Error.captureStackTrace) {
|
|
85
|
+
Error.captureStackTrace(err, lightningCssPlugin);
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
_sharedState.env.DEBUG && function(root) {
|
|
91
|
+
console.timeEnd("JIT TOTAL");
|
|
92
|
+
console.log("\n");
|
|
93
|
+
return root;
|
|
94
|
+
}
|
|
95
|
+
].filter(Boolean)
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
module.exports.postcss = true;
|
|
@@ -28,8 +28,8 @@ function nesting(opts = _postcssNested.default) {
|
|
|
28
28
|
rule.remove();
|
|
29
29
|
});
|
|
30
30
|
let plugin = (()=>{
|
|
31
|
-
var
|
|
32
|
-
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (
|
|
31
|
+
var _opts_hasOwnProperty;
|
|
32
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
|
|
33
33
|
return opts;
|
|
34
34
|
}
|
|
35
35
|
if (typeof opts === "string") {
|
package/lib/util/cloneNodes.js
CHANGED
|
@@ -8,11 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
});
|
|
9
9
|
function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
10
10
|
return nodes.map((node)=>{
|
|
11
|
-
var
|
|
11
|
+
var _node_raws_tailwind;
|
|
12
12
|
let cloned = node.clone();
|
|
13
13
|
// We always want override the source map
|
|
14
14
|
// except when explicitly told not to
|
|
15
|
-
let shouldOverwriteSource = ((
|
|
15
|
+
let shouldOverwriteSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) !== true || !cloned.source;
|
|
16
16
|
if (source !== undefined && shouldOverwriteSource) {
|
|
17
17
|
cloned.source = source;
|
|
18
18
|
if ("walk" in cloned) {
|
package/lib/util/color.js
CHANGED
|
@@ -24,10 +24,10 @@ let VALUE = /(?:\d+|\d*\.\d+)%?/;
|
|
|
24
24
|
let SEP = /(?:\s*,\s*|\s+)/;
|
|
25
25
|
let ALPHA_SEP = /\s*[,/]\s*/;
|
|
26
26
|
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/;
|
|
27
|
-
let RGB = new RegExp(`^(
|
|
28
|
-
let HSL = new RegExp(`^(
|
|
27
|
+
let RGB = new RegExp(`^(rgba?)\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
|
|
28
|
+
let HSL = new RegExp(`^(hsla?)\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
|
|
29
29
|
function parseColor(value, { loose =false } = {}) {
|
|
30
|
-
var
|
|
30
|
+
var _match_, _match__toString;
|
|
31
31
|
if (typeof value !== "string") {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
@@ -70,8 +70,8 @@ function parseColor(value, { loose =false } = {}) {
|
|
|
70
70
|
alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
var
|
|
74
|
-
let match = (
|
|
73
|
+
var _value_match;
|
|
74
|
+
let match = (_value_match = value.match(RGB)) !== null && _value_match !== void 0 ? _value_match : value.match(HSL);
|
|
75
75
|
if (match === null) {
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
@@ -80,6 +80,17 @@ function parseColor(value, { loose =false } = {}) {
|
|
|
80
80
|
match[3],
|
|
81
81
|
match[4]
|
|
82
82
|
].filter(Boolean).map((v)=>v.toString());
|
|
83
|
+
// rgba(var(--my-color), 0.1)
|
|
84
|
+
// hsla(var(--my-color), 0.1)
|
|
85
|
+
if (color.length === 2 && color[0].startsWith("var(")) {
|
|
86
|
+
return {
|
|
87
|
+
mode: match[1],
|
|
88
|
+
color: [
|
|
89
|
+
color[0]
|
|
90
|
+
],
|
|
91
|
+
alpha: color[1]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
83
94
|
if (!loose && color.length !== 3) {
|
|
84
95
|
return null;
|
|
85
96
|
}
|
|
@@ -89,10 +100,13 @@ function parseColor(value, { loose =false } = {}) {
|
|
|
89
100
|
return {
|
|
90
101
|
mode: match[1],
|
|
91
102
|
color,
|
|
92
|
-
alpha: (
|
|
103
|
+
alpha: (_match_ = match[5]) === null || _match_ === void 0 ? void 0 : (_match__toString = _match_.toString) === null || _match__toString === void 0 ? void 0 : _match__toString.call(_match_)
|
|
93
104
|
};
|
|
94
105
|
}
|
|
95
106
|
function formatColor({ mode , color , alpha }) {
|
|
96
107
|
let hasAlpha = alpha !== undefined;
|
|
108
|
+
if (mode === "rgba" || mode === "hsla") {
|
|
109
|
+
return `${mode}(${color.join(", ")}${hasAlpha ? `, ${alpha}` : ""})`;
|
|
110
|
+
}
|
|
97
111
|
return `${mode}(${color.join(" ")}${hasAlpha ? ` / ${alpha}` : ""})`;
|
|
98
112
|
}
|
|
@@ -26,7 +26,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
26
26
|
let group = Array.isArray(utilityVariation[0]) ? utilityVariation : [
|
|
27
27
|
utilityVariation
|
|
28
28
|
];
|
|
29
|
-
var
|
|
29
|
+
var _theme;
|
|
30
30
|
matchUtilities(group.reduce((obj, [classPrefix, properties])=>{
|
|
31
31
|
return Object.assign(obj, {
|
|
32
32
|
[classPrefix]: (value)=>{
|
|
@@ -44,7 +44,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
44
44
|
});
|
|
45
45
|
}, {}), {
|
|
46
46
|
...options,
|
|
47
|
-
values: filterDefault ? Object.fromEntries(Object.entries((
|
|
47
|
+
values: filterDefault ? Object.fromEntries(Object.entries((_theme = theme(themeKey)) !== null && _theme !== void 0 ? _theme : {}).filter(([modifier])=>modifier !== "DEFAULT")) : theme(themeKey)
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
};
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -38,6 +38,8 @@ let cssFunctions = [
|
|
|
38
38
|
function isCSSFunction(value) {
|
|
39
39
|
return cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.*\\)`).test(value));
|
|
40
40
|
}
|
|
41
|
+
const placeholder = "--tw-placeholder";
|
|
42
|
+
const placeholderRe = new RegExp(placeholder, "g");
|
|
41
43
|
function normalize(value, isRoot = true) {
|
|
42
44
|
// Keep raw strings if it starts with `url(`
|
|
43
45
|
if (value.includes("url(")) {
|
|
@@ -57,7 +59,11 @@ function normalize(value, isRoot = true) {
|
|
|
57
59
|
// Add spaces around operators inside math functions like calc() that do not follow an operator
|
|
58
60
|
// or '('.
|
|
59
61
|
value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
|
|
60
|
-
|
|
62
|
+
let vars = [];
|
|
63
|
+
return match.replace(/var\((--.+?)[,)]/g, (match, g1)=>{
|
|
64
|
+
vars.push(g1);
|
|
65
|
+
return match.replace(g1, placeholder);
|
|
66
|
+
}).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(placeholderRe, ()=>vars.shift());
|
|
61
67
|
});
|
|
62
68
|
return value;
|
|
63
69
|
}
|
|
@@ -70,6 +76,9 @@ function number(value) {
|
|
|
70
76
|
function percentage(value) {
|
|
71
77
|
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
|
|
72
78
|
}
|
|
79
|
+
// Please refer to MDN when updating this list:
|
|
80
|
+
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
|
|
81
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
|
|
73
82
|
let lengthUnits = [
|
|
74
83
|
"cm",
|
|
75
84
|
"mm",
|
|
@@ -83,10 +92,25 @@ let lengthUnits = [
|
|
|
83
92
|
"ch",
|
|
84
93
|
"rem",
|
|
85
94
|
"lh",
|
|
95
|
+
"rlh",
|
|
86
96
|
"vw",
|
|
87
97
|
"vh",
|
|
88
98
|
"vmin",
|
|
89
|
-
"vmax"
|
|
99
|
+
"vmax",
|
|
100
|
+
"vb",
|
|
101
|
+
"vi",
|
|
102
|
+
"svw",
|
|
103
|
+
"svh",
|
|
104
|
+
"lvw",
|
|
105
|
+
"lvh",
|
|
106
|
+
"dvw",
|
|
107
|
+
"dvh",
|
|
108
|
+
"cqw",
|
|
109
|
+
"cqh",
|
|
110
|
+
"cqi",
|
|
111
|
+
"cqb",
|
|
112
|
+
"cqmin",
|
|
113
|
+
"cqmax"
|
|
90
114
|
];
|
|
91
115
|
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
|
|
92
116
|
function length(value) {
|
package/lib/util/defaults.js
CHANGED
|
@@ -9,14 +9,14 @@ Object.defineProperty(exports, "defaults", {
|
|
|
9
9
|
function defaults(target, ...sources) {
|
|
10
10
|
for (let source of sources){
|
|
11
11
|
for(let k in source){
|
|
12
|
-
var
|
|
13
|
-
if (!(target === null || target === void 0 ? void 0 : (
|
|
12
|
+
var _target_hasOwnProperty;
|
|
13
|
+
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty = target.hasOwnProperty) === null || _target_hasOwnProperty === void 0 ? void 0 : _target_hasOwnProperty.call(target, k))) {
|
|
14
14
|
target[k] = source[k];
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
for (let k1 of Object.getOwnPropertySymbols(source)){
|
|
18
|
-
var
|
|
19
|
-
if (!(target === null || target === void 0 ? void 0 : (
|
|
18
|
+
var _target_hasOwnProperty1;
|
|
19
|
+
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty1 = target.hasOwnProperty) === null || _target_hasOwnProperty1 === void 0 ? void 0 : _target_hasOwnProperty1.call(target, k1))) {
|
|
20
20
|
target[k1] = source[k1];
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -14,9 +14,9 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function escapeClassName(className) {
|
|
17
|
-
var
|
|
17
|
+
var _node_raws;
|
|
18
18
|
let node = _postcssSelectorParser.default.className();
|
|
19
19
|
node.value = className;
|
|
20
|
-
var
|
|
21
|
-
return (0, _escapeCommas.default)((
|
|
20
|
+
var _node_raws_value;
|
|
21
|
+
return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
|
|
22
22
|
}
|