tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.956419c
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 +384 -3
- package/LICENSE +1 -2
- package/README.md +12 -8
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +239 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +4 -740
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +2064 -1811
- package/lib/css/preflight.css +5 -5
- package/lib/featureFlags.js +31 -22
- package/lib/index.js +4 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +225 -31
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +118 -55
- package/lib/lib/expandApplyAtRules.js +439 -190
- package/lib/lib/expandTailwindAtRules.js +151 -134
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +454 -187
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +36 -32
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -67
- package/lib/lib/setupContextUtils.js +667 -376
- package/lib/lib/setupTrackingContext.js +38 -67
- package/lib/lib/sharedState.js +27 -14
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/oxide/cli.d.js +1 -0
- package/lib/oxide/cli.js +2 -0
- package/lib/oxide/postcss-plugin.d.js +1 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +48 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +35 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +11 -6
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -110
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +184 -85
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
- package/lib/util/log.js +20 -14
- package/lib/util/nameClass.js +20 -9
- package/lib/util/negateValue.js +23 -8
- package/lib/util/normalizeConfig.js +116 -72
- package/lib/util/normalizeScreens.js +120 -11
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +147 -50
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -85
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +50 -45
- package/peers/index.js +11381 -7950
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +234 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -810
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +532 -217
- package/src/css/preflight.css +5 -5
- package/src/featureFlags.js +15 -9
- package/src/index.js +4 -27
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +196 -33
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +482 -183
- package/src/lib/expandTailwindAtRules.js +106 -85
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +418 -129
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +51 -30
- package/src/lib/setupContextUtils.js +556 -208
- package/src/lib/setupTrackingContext.js +11 -48
- package/src/lib/sharedState.js +5 -0
- package/src/oxide/cli.d.ts +0 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.d.ts +0 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +47 -0
- 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 +8 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +29 -21
- package/src/util/formatVariantSelector.js +184 -61
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +44 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +167 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +362 -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/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/nesting/plugin.js +0 -41
|
@@ -2,19 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
6
|
+
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
7
|
+
// source path), or set up a new one (including setting up watchers and registering
|
|
8
|
+
// plugins) then return it
|
|
9
|
+
"default", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: ()=>setupTrackingContext
|
|
12
|
+
});
|
|
13
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
14
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
15
|
+
const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
|
|
16
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
17
|
+
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
|
|
18
|
+
const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
19
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
20
|
+
const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
|
|
21
|
+
const _validateConfigJs = require("../util/validateConfig.js");
|
|
22
|
+
const _contentJs = require("./content.js");
|
|
18
23
|
function _interopRequireDefault(obj) {
|
|
19
24
|
return obj && obj.__esModule ? obj : {
|
|
20
25
|
default: obj
|
|
@@ -28,18 +33,15 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
28
33
|
if (candidateFilesCache.has(context)) {
|
|
29
34
|
return candidateFilesCache.get(context);
|
|
30
35
|
}
|
|
31
|
-
let candidateFiles =
|
|
32
|
-
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
33
|
-
);
|
|
36
|
+
let candidateFiles = (0, _contentJs.parseCandidateFiles)(context, tailwindConfig);
|
|
34
37
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
35
38
|
}
|
|
36
39
|
// Get the config object based on a path
|
|
37
40
|
function getTailwindConfig(configOrPath) {
|
|
38
|
-
let userConfigPath = (0, _resolveConfigPath
|
|
41
|
+
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
39
42
|
if (userConfigPath !== null) {
|
|
40
43
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
41
|
-
let newDeps = (0, _getModuleDependencies
|
|
42
|
-
);
|
|
44
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map((dep)=>dep.file);
|
|
43
45
|
let modified = false;
|
|
44
46
|
let newModified = new Map();
|
|
45
47
|
for (let file of newDeps){
|
|
@@ -62,8 +64,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
62
64
|
for (let file1 of newDeps){
|
|
63
65
|
delete require.cache[file1];
|
|
64
66
|
}
|
|
65
|
-
let newConfig = (0, _resolveConfig
|
|
66
|
-
|
|
67
|
+
let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
|
|
68
|
+
newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
|
|
69
|
+
let newHash = (0, _hashConfig.default)(newConfig);
|
|
67
70
|
configPathCache.set(userConfigPath, [
|
|
68
71
|
newConfig,
|
|
69
72
|
newHash,
|
|
@@ -78,48 +81,17 @@ function getTailwindConfig(configOrPath) {
|
|
|
78
81
|
];
|
|
79
82
|
}
|
|
80
83
|
// It's a plain object, not a path
|
|
81
|
-
let
|
|
84
|
+
let newConfig1 = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
85
|
+
newConfig1 = (0, _validateConfigJs.validateConfig)(newConfig1);
|
|
82
86
|
return [
|
|
83
|
-
|
|
87
|
+
newConfig1,
|
|
84
88
|
null,
|
|
85
|
-
(0, _hashConfig
|
|
89
|
+
(0, _hashConfig.default)(newConfig1),
|
|
86
90
|
[]
|
|
87
91
|
];
|
|
88
92
|
}
|
|
89
|
-
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
90
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
|
|
91
|
-
).map(({ raw , extension ='html' })=>({
|
|
92
|
-
content: raw,
|
|
93
|
-
extension
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
|
|
97
|
-
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
98
|
-
let extension = _path.default.extname(changedFile).slice(1);
|
|
99
|
-
changedContent.push({
|
|
100
|
-
content,
|
|
101
|
-
extension
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return changedContent;
|
|
105
|
-
}
|
|
106
|
-
function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
107
|
-
let changedFiles = new Set();
|
|
108
|
-
_sharedState.env.DEBUG && console.time('Finding changed files');
|
|
109
|
-
let files = _fastGlob.default.sync(candidateFiles);
|
|
110
|
-
for (let file of files){
|
|
111
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
|
|
112
|
-
let modified = _fs.default.statSync(file).mtimeMs;
|
|
113
|
-
if (modified > prevModified) {
|
|
114
|
-
changedFiles.add(file);
|
|
115
|
-
fileModifiedMap.set(file, modified);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
_sharedState.env.DEBUG && console.timeEnd('Finding changed files');
|
|
119
|
-
return changedFiles;
|
|
120
|
-
}
|
|
121
93
|
function setupTrackingContext(configOrPath) {
|
|
122
|
-
return ({ tailwindDirectives , registerDependency
|
|
94
|
+
return ({ tailwindDirectives , registerDependency })=>{
|
|
123
95
|
return (root, result)=>{
|
|
124
96
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
125
97
|
let contextDependencies = new Set(configDependencies);
|
|
@@ -129,39 +101,38 @@ function setupTrackingContext(configOrPath) {
|
|
|
129
101
|
// being part of this trigger too, but it's tough because it's impossible
|
|
130
102
|
// for a layer in one file to end up in the actual @tailwind rule in
|
|
131
103
|
// another file since independent sources are effectively isolated.
|
|
132
|
-
if (tailwindDirectives.size > 0
|
|
104
|
+
if (tailwindDirectives.size > 0) {
|
|
133
105
|
// Add current css file as a context dependencies.
|
|
134
106
|
contextDependencies.add(result.opts.from);
|
|
135
107
|
// Add all css @import dependencies as context dependencies.
|
|
136
108
|
for (let message of result.messages){
|
|
137
|
-
if (message.type ===
|
|
109
|
+
if (message.type === "dependency") {
|
|
138
110
|
contextDependencies.add(message.file);
|
|
139
111
|
}
|
|
140
112
|
}
|
|
141
113
|
}
|
|
142
|
-
let [context] = (0, _setupContextUtils
|
|
114
|
+
let [context] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
143
115
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
144
116
|
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
145
117
|
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
146
118
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
147
119
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
148
120
|
// in another file since independent sources are effectively isolated.
|
|
149
|
-
if (tailwindDirectives.size > 0
|
|
150
|
-
let fileModifiedMap = (0, _setupContextUtils
|
|
121
|
+
if (tailwindDirectives.size > 0) {
|
|
122
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
151
123
|
// Add template paths as postcss dependencies.
|
|
152
|
-
for (let
|
|
153
|
-
let dependency
|
|
154
|
-
if (dependency) {
|
|
124
|
+
for (let contentPath of candidateFiles){
|
|
125
|
+
for (let dependency of (0, _parseDependency.default)(contentPath)){
|
|
155
126
|
registerDependency(dependency);
|
|
156
127
|
}
|
|
157
128
|
}
|
|
158
|
-
for (let changedContent of resolvedChangedContent(context, candidateFiles, fileModifiedMap)){
|
|
129
|
+
for (let changedContent of (0, _contentJs.resolvedChangedContent)(context, candidateFiles, fileModifiedMap)){
|
|
159
130
|
context.changedContent.push(changedContent);
|
|
160
131
|
}
|
|
161
132
|
}
|
|
162
133
|
for (let file of configDependencies){
|
|
163
134
|
registerDependency({
|
|
164
|
-
type:
|
|
135
|
+
type: "dependency",
|
|
165
136
|
file
|
|
166
137
|
});
|
|
167
138
|
}
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,28 +2,42 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
env: ()=>env,
|
|
13
|
+
contextMap: ()=>contextMap,
|
|
14
|
+
configContextMap: ()=>configContextMap,
|
|
15
|
+
contextSourcesMap: ()=>contextSourcesMap,
|
|
16
|
+
sourceHashMap: ()=>sourceHashMap,
|
|
17
|
+
NOT_ON_DEMAND: ()=>NOT_ON_DEMAND,
|
|
18
|
+
NONE: ()=>NONE,
|
|
19
|
+
resolveDebug: ()=>resolveDebug
|
|
20
|
+
});
|
|
7
21
|
const env = {
|
|
8
22
|
NODE_ENV: process.env.NODE_ENV,
|
|
9
|
-
DEBUG: resolveDebug(process.env.DEBUG)
|
|
23
|
+
DEBUG: resolveDebug(process.env.DEBUG),
|
|
24
|
+
OXIDE: process.env.OXIDE
|
|
10
25
|
};
|
|
11
|
-
exports.env = env;
|
|
12
26
|
const contextMap = new Map();
|
|
13
|
-
exports.contextMap = contextMap;
|
|
14
27
|
const configContextMap = new Map();
|
|
15
|
-
exports.configContextMap = configContextMap;
|
|
16
28
|
const contextSourcesMap = new Map();
|
|
17
|
-
|
|
29
|
+
const sourceHashMap = new Map();
|
|
30
|
+
const NOT_ON_DEMAND = new String("*");
|
|
31
|
+
const NONE = Symbol("__NONE__");
|
|
18
32
|
function resolveDebug(debug) {
|
|
19
33
|
if (debug === undefined) {
|
|
20
34
|
return false;
|
|
21
35
|
}
|
|
22
36
|
// Environment variables are strings, so convert to boolean
|
|
23
|
-
if (debug ===
|
|
37
|
+
if (debug === "true" || debug === "1") {
|
|
24
38
|
return true;
|
|
25
39
|
}
|
|
26
|
-
if (debug ===
|
|
40
|
+
if (debug === "false" || debug === "0") {
|
|
27
41
|
return false;
|
|
28
42
|
}
|
|
29
43
|
// Keep the debug convention into account:
|
|
@@ -31,17 +45,16 @@ function resolveDebug(debug) {
|
|
|
31
45
|
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
32
46
|
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
33
47
|
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
34
|
-
if (debug ===
|
|
48
|
+
if (debug === "*") {
|
|
35
49
|
return true;
|
|
36
50
|
}
|
|
37
|
-
let debuggers = debug.split(
|
|
38
|
-
);
|
|
51
|
+
let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
|
|
39
52
|
// Ignoring tailwindcss
|
|
40
|
-
if (debuggers.includes(
|
|
53
|
+
if (debuggers.includes("-tailwindcss")) {
|
|
41
54
|
return false;
|
|
42
55
|
}
|
|
43
56
|
// Including tailwindcss
|
|
44
|
-
if (debuggers.includes(
|
|
57
|
+
if (debuggers.includes("tailwindcss")) {
|
|
45
58
|
return true;
|
|
46
59
|
}
|
|
47
60
|
return false;
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _normalizeScreens = require("../util/normalizeScreens");
|
|
10
|
+
const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
8
11
|
function _interopRequireDefault(obj) {
|
|
9
12
|
return obj && obj.__esModule ? obj : {
|
|
10
13
|
default: obj
|
|
@@ -12,16 +15,15 @@ function _interopRequireDefault(obj) {
|
|
|
12
15
|
}
|
|
13
16
|
function _default({ tailwindConfig: { theme } }) {
|
|
14
17
|
return function(css) {
|
|
15
|
-
css.walkAtRules(
|
|
18
|
+
css.walkAtRules("screen", (atRule)=>{
|
|
16
19
|
let screen = atRule.params;
|
|
17
|
-
let screens = (0, _normalizeScreens
|
|
18
|
-
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
-
);
|
|
20
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
|
|
21
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
20
22
|
if (!screenDefinition) {
|
|
21
23
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
22
24
|
}
|
|
23
|
-
atRule.name =
|
|
24
|
-
atRule.params = (0, _buildMediaQuery
|
|
25
|
+
atRule.name = "media";
|
|
26
|
+
atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
29
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/oxide/cli.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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 ref;
|
|
25
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
26
|
+
// path for the file being processed
|
|
27
|
+
configOrPath = (ref = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && ref !== void 0 ? ref : 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.DEBUG && function(root) {
|
|
41
|
+
console.timeEnd("JIT TOTAL");
|
|
42
|
+
console.log("\n");
|
|
43
|
+
return root;
|
|
44
|
+
}
|
|
45
|
+
].filter(Boolean)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
module.exports.postcss = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tailwindcss/nesting
|
|
2
2
|
|
|
3
|
-
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/
|
|
3
|
+
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
|
|
4
4
|
|
|
5
5
|
Add it to your PostCSS configuration, somewhere before Tailwind itself:
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
|
|
20
20
|
|
|
21
|
-
If you'd rather use [postcss-nesting](https://github.com/
|
|
21
|
+
If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
npm install postcss-nesting
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _plugin = require("./plugin");
|
|
10
|
+
const _default = Object.assign(function(opts) {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: "tailwindcss/nesting",
|
|
13
|
+
Once (root, { result }) {
|
|
14
|
+
return (0, _plugin.nesting)(opts)(root, result);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
postcss: true
|
|
19
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "nesting", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>nesting
|
|
8
|
+
});
|
|
9
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
10
|
+
const _postcssNested = /*#__PURE__*/ _interopRequireDefault(require("postcss-nested"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function nesting(opts = _postcssNested.default) {
|
|
17
|
+
return (root, result)=>{
|
|
18
|
+
root.walkAtRules("screen", (rule)=>{
|
|
19
|
+
rule.name = "media";
|
|
20
|
+
rule.params = `screen(${rule.params})`;
|
|
21
|
+
});
|
|
22
|
+
root.walkAtRules("apply", (rule)=>{
|
|
23
|
+
rule.before(_postcss.default.decl({
|
|
24
|
+
prop: "__apply",
|
|
25
|
+
value: rule.params,
|
|
26
|
+
source: rule.source
|
|
27
|
+
}));
|
|
28
|
+
rule.remove();
|
|
29
|
+
});
|
|
30
|
+
let plugin = (()=>{
|
|
31
|
+
var ref;
|
|
32
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, "postcssPlugin"))) {
|
|
33
|
+
return opts;
|
|
34
|
+
}
|
|
35
|
+
if (typeof opts === "string") {
|
|
36
|
+
return require(opts);
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(opts).length <= 0) {
|
|
39
|
+
return _postcssNested.default;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
|
|
42
|
+
})();
|
|
43
|
+
(0, _postcss.default)([
|
|
44
|
+
plugin
|
|
45
|
+
]).process(root, result.opts).sync();
|
|
46
|
+
root.walkDecls("__apply", (decl)=>{
|
|
47
|
+
decl.before(_postcss.default.atRule({
|
|
48
|
+
name: "apply",
|
|
49
|
+
params: decl.value,
|
|
50
|
+
source: decl.source
|
|
51
|
+
}));
|
|
52
|
+
decl.remove();
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
56
|
+
* This is done because running process() on the AST will set the "clean"
|
|
57
|
+
* flag on all nodes, which we don't want.
|
|
58
|
+
*
|
|
59
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
60
|
+
*
|
|
61
|
+
* This is guarded because the PostCSS API is not public
|
|
62
|
+
* and may change in future versions of PostCSS.
|
|
63
|
+
*
|
|
64
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
65
|
+
*
|
|
66
|
+
* @param {import('postcss').Node} node
|
|
67
|
+
*/ function markDirty(node) {
|
|
68
|
+
if (!("markDirty" in node)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Traverse the tree down to the leaf nodes
|
|
72
|
+
if (node.nodes) {
|
|
73
|
+
node.nodes.forEach((n)=>markDirty(n));
|
|
74
|
+
}
|
|
75
|
+
// If it's a leaf node mark it as dirty
|
|
76
|
+
// We do this here because marking a node as dirty
|
|
77
|
+
// will walk up the tree and mark all parents as dirty
|
|
78
|
+
// resulting in a lot of unnecessary work if we did this
|
|
79
|
+
// for every single node
|
|
80
|
+
if (!node.nodes) {
|
|
81
|
+
node.markDirty();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
markDirty(root);
|
|
85
|
+
return root;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>processTailwindFeatures
|
|
8
|
+
});
|
|
9
|
+
const _normalizeTailwindDirectives = /*#__PURE__*/ _interopRequireDefault(require("./lib/normalizeTailwindDirectives"));
|
|
10
|
+
const _expandTailwindAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/expandTailwindAtRules"));
|
|
11
|
+
const _expandApplyAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/expandApplyAtRules"));
|
|
12
|
+
const _evaluateTailwindFunctions = /*#__PURE__*/ _interopRequireDefault(require("./lib/evaluateTailwindFunctions"));
|
|
13
|
+
const _substituteScreenAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/substituteScreenAtRules"));
|
|
14
|
+
const _resolveDefaultsAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
15
|
+
const _collapseAdjacentRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
16
|
+
const _collapseDuplicateDeclarations = /*#__PURE__*/ _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
17
|
+
const _partitionApplyAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
18
|
+
const _detectNesting = /*#__PURE__*/ _interopRequireDefault(require("./lib/detectNesting"));
|
|
19
|
+
const _setupContextUtils = require("./lib/setupContextUtils");
|
|
20
|
+
const _featureFlags = require("./featureFlags");
|
|
17
21
|
function _interopRequireDefault(obj) {
|
|
18
22
|
return obj && obj.__esModule ? obj : {
|
|
19
23
|
default: obj
|
|
@@ -21,32 +25,38 @@ function _interopRequireDefault(obj) {
|
|
|
21
25
|
}
|
|
22
26
|
function processTailwindFeatures(setupContext) {
|
|
23
27
|
return function(root, result) {
|
|
24
|
-
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives
|
|
25
|
-
(0, _detectNesting
|
|
28
|
+
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
|
|
29
|
+
(0, _detectNesting.default)()(root, result);
|
|
30
|
+
// Partition apply rules that are found in the css
|
|
31
|
+
// itself.
|
|
32
|
+
(0, _partitionApplyAtRules.default)()(root, result);
|
|
26
33
|
let context = setupContext({
|
|
27
34
|
tailwindDirectives,
|
|
28
35
|
applyDirectives,
|
|
29
36
|
registerDependency (dependency) {
|
|
30
37
|
result.messages.push({
|
|
31
|
-
plugin:
|
|
38
|
+
plugin: "tailwindcss",
|
|
32
39
|
parent: result.opts.from,
|
|
33
40
|
...dependency
|
|
34
41
|
});
|
|
35
42
|
},
|
|
36
43
|
createContext (tailwindConfig, changedContent) {
|
|
37
|
-
return (0, _setupContextUtils
|
|
44
|
+
return (0, _setupContextUtils.createContext)(tailwindConfig, changedContent, root);
|
|
38
45
|
}
|
|
39
46
|
})(root, result);
|
|
40
|
-
if (context.tailwindConfig.separator ===
|
|
47
|
+
if (context.tailwindConfig.separator === "-") {
|
|
41
48
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
42
49
|
}
|
|
43
|
-
(0, _featureFlags
|
|
44
|
-
(0, _expandTailwindAtRules
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(0,
|
|
48
|
-
(0,
|
|
49
|
-
(0,
|
|
50
|
-
(0,
|
|
50
|
+
(0, _featureFlags.issueFlagNotices)(context.tailwindConfig);
|
|
51
|
+
(0, _expandTailwindAtRules.default)(context)(root, result);
|
|
52
|
+
// Partition apply rules that are generated by
|
|
53
|
+
// addComponents, addUtilities and so on.
|
|
54
|
+
(0, _partitionApplyAtRules.default)()(root, result);
|
|
55
|
+
(0, _expandApplyAtRules.default)(context)(root, result);
|
|
56
|
+
(0, _evaluateTailwindFunctions.default)(context)(root, result);
|
|
57
|
+
(0, _substituteScreenAtRules.default)(context)(root, result);
|
|
58
|
+
(0, _resolveDefaultsAtRules.default)(context)(root, result);
|
|
59
|
+
(0, _collapseAdjacentRules.default)(context)(root, result);
|
|
60
|
+
(0, _collapseDuplicateDeclarations.default)(context)(root, result);
|
|
51
61
|
};
|
|
52
62
|
}
|