tailwindcss 0.0.0-insiders.c834da4 → 0.0.0-insiders.c8bf2d4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cli/build/plugin.js +30 -25
- package/lib/cli/index.js +231 -10
- package/lib/cli.js +4 -236
- package/lib/corePluginList.js +2 -0
- package/lib/corePlugins.js +216 -4
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +5 -1
- package/lib/index.js +4 -46
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +7 -2
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/expandTailwindAtRules.js +30 -5
- package/lib/lib/generateRules.js +92 -56
- package/lib/lib/offsets.js +19 -0
- package/lib/lib/setupContextUtils.js +84 -37
- package/lib/lib/setupTrackingContext.js +25 -4
- package/lib/lib/sharedState.js +19 -1
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +47 -0
- package/lib/oxide/cli/build/plugin.js +364 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +220 -0
- package/lib/oxide/cli/init/index.js +35 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/util/color.js +16 -2
- package/lib/util/dataTypes.js +19 -1
- package/lib/util/formatVariantSelector.js +151 -103
- package/lib/util/negateValue.js +2 -2
- package/lib/util/pluginUtils.js +5 -24
- package/lib/util/prefixSelector.js +22 -8
- package/package.json +26 -15
- package/peers/index.js +108 -173
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/plugin.js +12 -7
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -231
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +117 -4
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +4 -0
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +8 -2
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/generateRules.js +106 -56
- package/src/lib/offsets.js +22 -0
- package/src/lib/setupContextUtils.js +90 -41
- package/src/lib/setupTrackingContext.js +31 -6
- package/src/lib/sharedState.js +17 -0
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +436 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +212 -0
- package/src/oxide/cli/init/index.ts +32 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +18 -0
- package/src/util/formatVariantSelector.js +204 -122
- package/src/util/negateValue.js +1 -1
- package/src/util/pluginUtils.js +10 -29
- package/src/util/prefixSelector.js +28 -10
- package/stubs/defaultConfig.stub.js +3 -0
- package/types/config.d.ts +11 -1
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +5 -2
- package/CHANGELOG.md +0 -2352
- package/lib/cli/shared.js +0 -12
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "help", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>help
|
|
8
|
+
});
|
|
9
|
+
const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../../../../package.json"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function help({ message , usage , commands , options }) {
|
|
16
|
+
let indent = 2;
|
|
17
|
+
// Render header
|
|
18
|
+
console.log();
|
|
19
|
+
console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
|
|
20
|
+
// Render message
|
|
21
|
+
if (message) {
|
|
22
|
+
console.log();
|
|
23
|
+
for (let msg of message.split("\n")){
|
|
24
|
+
console.log(msg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Render usage
|
|
28
|
+
if (usage && usage.length > 0) {
|
|
29
|
+
console.log();
|
|
30
|
+
console.log("Usage:");
|
|
31
|
+
for (let example of usage){
|
|
32
|
+
console.log(" ".repeat(indent), example);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Render commands
|
|
36
|
+
if (commands && commands.length > 0) {
|
|
37
|
+
console.log();
|
|
38
|
+
console.log("Commands:");
|
|
39
|
+
for (let command of commands){
|
|
40
|
+
console.log(" ".repeat(indent), command);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Render options
|
|
44
|
+
if (options) {
|
|
45
|
+
let groupedOptions = {};
|
|
46
|
+
for (let [key, value] of Object.entries(options)){
|
|
47
|
+
if (typeof value === "object") {
|
|
48
|
+
groupedOptions[key] = {
|
|
49
|
+
...value,
|
|
50
|
+
flags: [
|
|
51
|
+
key
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
groupedOptions[value].flags.push(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log();
|
|
59
|
+
console.log("Options:");
|
|
60
|
+
for (let { flags , description , deprecated } of Object.values(groupedOptions)){
|
|
61
|
+
if (deprecated) continue;
|
|
62
|
+
if (flags.length === 1) {
|
|
63
|
+
console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
|
|
64
|
+
} else {
|
|
65
|
+
console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
console.log();
|
|
70
|
+
}
|
|
@@ -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;
|
package/lib/util/color.js
CHANGED
|
@@ -24,8 +24,8 @@ 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
30
|
var _match_, _match__toString;
|
|
31
31
|
if (typeof value !== "string") {
|
|
@@ -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
|
}
|
|
@@ -94,5 +105,8 @@ function parseColor(value, { loose =false } = {}) {
|
|
|
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
|
}
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -79,6 +79,9 @@ function number(value) {
|
|
|
79
79
|
function percentage(value) {
|
|
80
80
|
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
|
|
81
81
|
}
|
|
82
|
+
// Please refer to MDN when updating this list:
|
|
83
|
+
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
|
|
84
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
|
|
82
85
|
let lengthUnits = [
|
|
83
86
|
"cm",
|
|
84
87
|
"mm",
|
|
@@ -92,10 +95,25 @@ let lengthUnits = [
|
|
|
92
95
|
"ch",
|
|
93
96
|
"rem",
|
|
94
97
|
"lh",
|
|
98
|
+
"rlh",
|
|
95
99
|
"vw",
|
|
96
100
|
"vh",
|
|
97
101
|
"vmin",
|
|
98
|
-
"vmax"
|
|
102
|
+
"vmax",
|
|
103
|
+
"vb",
|
|
104
|
+
"vi",
|
|
105
|
+
"svw",
|
|
106
|
+
"svh",
|
|
107
|
+
"lvw",
|
|
108
|
+
"lvh",
|
|
109
|
+
"dvw",
|
|
110
|
+
"dvh",
|
|
111
|
+
"cqw",
|
|
112
|
+
"cqh",
|
|
113
|
+
"cqi",
|
|
114
|
+
"cqb",
|
|
115
|
+
"cqmin",
|
|
116
|
+
"cqmax"
|
|
99
117
|
];
|
|
100
118
|
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
|
|
101
119
|
function length(value) {
|