tailwindcss 0.0.0-oxide-insiders.667eac5 → 0.0.0-oxide-insiders.8e60a3c
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/lib/corePlugins.js +19 -1
- package/lib/lib/generateRules.js +10 -4
- package/lib/plugin.js +50 -0
- package/package.json +3 -3
- package/src/corePlugins.js +24 -1
- package/src/lib/generateRules.js +12 -4
- package/src/plugin.js +60 -0
package/lib/corePlugins.js
CHANGED
|
@@ -232,7 +232,25 @@ let variantPlugins = {
|
|
|
232
232
|
let result = (0, _dataTypes.normalize)(typeof value === "function" ? value(extra) : value);
|
|
233
233
|
if (!result.includes("&")) result = "&" + result;
|
|
234
234
|
let [a, b] = fn("", extra);
|
|
235
|
-
|
|
235
|
+
let start = null;
|
|
236
|
+
let end = null;
|
|
237
|
+
let quotes = 0;
|
|
238
|
+
for(let i = 0; i < result.length; ++i){
|
|
239
|
+
let c = result[i];
|
|
240
|
+
if (c === "&") {
|
|
241
|
+
start = i;
|
|
242
|
+
} else if (c === "'" || c === '"') {
|
|
243
|
+
quotes += 1;
|
|
244
|
+
} else if (start !== null && c === " " && !quotes) {
|
|
245
|
+
end = i;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (start !== null && end === null) {
|
|
249
|
+
end = result.length;
|
|
250
|
+
}
|
|
251
|
+
// Basically this but can handle quotes:
|
|
252
|
+
// result.replace(/&(\S+)?/g, (_, pseudo = '') => a + pseudo + b)
|
|
253
|
+
return result.slice(0, start) + a + result.slice(start + 1, end) + b + result.slice(end);
|
|
236
254
|
}, {
|
|
237
255
|
values: Object.fromEntries(pseudoVariants)
|
|
238
256
|
});
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -198,10 +198,16 @@ function applyVariant(variant, matches, context) {
|
|
|
198
198
|
};
|
|
199
199
|
// Retrieve "modifier"
|
|
200
200
|
{
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(variant, "/");
|
|
202
|
+
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
203
|
+
// In this case 1/10 is a value but /20 is a modifier
|
|
204
|
+
if (modifiers.length > 1) {
|
|
205
|
+
baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
|
|
206
|
+
modifiers = modifiers.slice(-1);
|
|
207
|
+
}
|
|
208
|
+
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
209
|
+
variant = baseVariant;
|
|
210
|
+
args.modifier = modifiers[0];
|
|
205
211
|
if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
|
|
206
212
|
return [];
|
|
207
213
|
}
|
package/lib/plugin.js
CHANGED
|
@@ -37,6 +37,56 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
37
37
|
}
|
|
38
38
|
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
39
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
|
+
},
|
|
40
90
|
_sharedState.env.DEBUG && function(root) {
|
|
41
91
|
console.timeEnd("JIT TOTAL");
|
|
42
92
|
console.log("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "0.0.0-oxide-insiders.
|
|
3
|
+
"version": "0.0.0-oxide-insiders.8e60a3c",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"postcss": "^8.0.9"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tailwindcss/oxide": "0.0.0-oxide-insiders.
|
|
73
|
+
"@tailwindcss/oxide": "0.0.0-oxide-insiders.8e60a3c",
|
|
74
74
|
"arg": "^5.0.2",
|
|
75
75
|
"browserslist": "^4.21.4",
|
|
76
76
|
"chokidar": "^3.5.3",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"fast-glob": "^3.2.12",
|
|
82
82
|
"glob-parent": "^6.0.2",
|
|
83
83
|
"is-glob": "^4.0.3",
|
|
84
|
-
"lightningcss": "^1.
|
|
84
|
+
"lightningcss": "^1.18.0",
|
|
85
85
|
"lilconfig": "^2.0.6",
|
|
86
86
|
"micromatch": "^4.0.5",
|
|
87
87
|
"normalize-path": "^3.0.0",
|
package/src/corePlugins.js
CHANGED
|
@@ -168,7 +168,30 @@ export let variantPlugins = {
|
|
|
168
168
|
if (!result.includes('&')) result = '&' + result
|
|
169
169
|
|
|
170
170
|
let [a, b] = fn('', extra)
|
|
171
|
-
|
|
171
|
+
|
|
172
|
+
let start = null
|
|
173
|
+
let end = null
|
|
174
|
+
let quotes = 0
|
|
175
|
+
|
|
176
|
+
for (let i = 0; i < result.length; ++i) {
|
|
177
|
+
let c = result[i]
|
|
178
|
+
if (c === '&') {
|
|
179
|
+
start = i
|
|
180
|
+
} else if (c === "'" || c === '"') {
|
|
181
|
+
quotes += 1
|
|
182
|
+
} else if (start !== null && c === ' ' && !quotes) {
|
|
183
|
+
end = i
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (start !== null && end === null) {
|
|
188
|
+
end = result.length
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Basically this but can handle quotes:
|
|
192
|
+
// result.replace(/&(\S+)?/g, (_, pseudo = '') => a + pseudo + b)
|
|
193
|
+
|
|
194
|
+
return result.slice(0, start) + a + result.slice(start + 1, end) + b + result.slice(end)
|
|
172
195
|
},
|
|
173
196
|
{ values: Object.fromEntries(pseudoVariants) }
|
|
174
197
|
)
|
package/src/lib/generateRules.js
CHANGED
|
@@ -152,10 +152,18 @@ function applyVariant(variant, matches, context) {
|
|
|
152
152
|
|
|
153
153
|
// Retrieve "modifier"
|
|
154
154
|
{
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
let [baseVariant, ...modifiers] = splitAtTopLevelOnly(variant, '/')
|
|
156
|
+
|
|
157
|
+
// This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
|
|
158
|
+
// In this case 1/10 is a value but /20 is a modifier
|
|
159
|
+
if (modifiers.length > 1) {
|
|
160
|
+
baseVariant = baseVariant + '/' + modifiers.slice(0, -1).join('/')
|
|
161
|
+
modifiers = modifiers.slice(-1)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (modifiers.length && !context.variantMap.has(variant)) {
|
|
165
|
+
variant = baseVariant
|
|
166
|
+
args.modifier = modifiers[0]
|
|
159
167
|
|
|
160
168
|
if (!flagEnabled(context.tailwindConfig, 'generalizedModifiers')) {
|
|
161
169
|
return []
|
package/src/plugin.js
CHANGED
|
@@ -34,6 +34,66 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
34
34
|
|
|
35
35
|
processTailwindFeatures(context)(root, result)
|
|
36
36
|
},
|
|
37
|
+
env.OXIDE &&
|
|
38
|
+
function lightningCssPlugin(_root, result) {
|
|
39
|
+
let postcss = require('postcss')
|
|
40
|
+
let lightningcss = require('lightningcss')
|
|
41
|
+
let browserslist = require('browserslist')
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
let transformed = lightningcss.transform({
|
|
45
|
+
filename: result.opts.from,
|
|
46
|
+
code: Buffer.from(result.root.toString()),
|
|
47
|
+
minify: false,
|
|
48
|
+
sourceMap: !!result.map,
|
|
49
|
+
inputSourceMap: result.map ? result.map.toString() : undefined,
|
|
50
|
+
targets:
|
|
51
|
+
typeof process !== 'undefined' && process.env.JEST_WORKER_ID
|
|
52
|
+
? { chrome: 106 << 16 }
|
|
53
|
+
: lightningcss.browserslistToTargets(
|
|
54
|
+
browserslist(require('../package.json').browserslist)
|
|
55
|
+
),
|
|
56
|
+
|
|
57
|
+
drafts: {
|
|
58
|
+
nesting: true,
|
|
59
|
+
customMedia: true,
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
result.map = Object.assign(result.map ?? {}, {
|
|
64
|
+
toJSON() {
|
|
65
|
+
return transformed.map.toJSON()
|
|
66
|
+
},
|
|
67
|
+
toString() {
|
|
68
|
+
return transformed.map.toString()
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
result.root = postcss.parse(transformed.code.toString('utf8'))
|
|
73
|
+
} catch (err) {
|
|
74
|
+
if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID) {
|
|
75
|
+
let lines = err.source.split('\n')
|
|
76
|
+
err = new Error(
|
|
77
|
+
[
|
|
78
|
+
'Error formatting using Lightning CSS:',
|
|
79
|
+
'',
|
|
80
|
+
...[
|
|
81
|
+
'```css',
|
|
82
|
+
...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
|
|
83
|
+
' '.repeat(err.loc.column - 1) + '^-- ' + err.toString(),
|
|
84
|
+
...lines.slice(err.loc.line, err.loc.line + 2),
|
|
85
|
+
'```',
|
|
86
|
+
],
|
|
87
|
+
].join('\n')
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (Error.captureStackTrace) {
|
|
92
|
+
Error.captureStackTrace(err, lightningCssPlugin)
|
|
93
|
+
}
|
|
94
|
+
throw err
|
|
95
|
+
}
|
|
96
|
+
},
|
|
37
97
|
env.DEBUG &&
|
|
38
98
|
function (root) {
|
|
39
99
|
console.timeEnd('JIT TOTAL')
|