tailwindcss 0.0.0-insiders.ea139f2 → 0.0.0-insiders.ea4e1cd
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/LICENSE +1 -2
- package/README.md +15 -7
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +54 -0
- package/lib/cli/build/plugin.js +378 -0
- package/lib/cli/build/utils.js +88 -0
- package/lib/cli/build/watching.js +182 -0
- package/lib/cli/help/index.js +73 -0
- package/lib/cli/index.js +230 -0
- package/lib/cli/init/index.js +63 -0
- package/lib/cli-peer-dependencies.js +28 -7
- package/lib/cli.js +4 -703
- package/lib/corePluginList.js +12 -3
- package/lib/corePlugins.js +2373 -1863
- package/lib/css/preflight.css +10 -8
- package/lib/featureFlags.js +49 -26
- package/lib/index.js +1 -31
- package/lib/lib/cacheInvalidation.js +92 -0
- package/lib/lib/collapseAdjacentRules.js +30 -10
- package/lib/lib/collapseDuplicateDeclarations.js +60 -4
- package/lib/lib/content.js +181 -0
- package/lib/lib/defaultExtractor.js +243 -0
- package/lib/lib/detectNesting.js +21 -10
- package/lib/lib/evaluateTailwindFunctions.js +115 -50
- package/lib/lib/expandApplyAtRules.js +467 -161
- package/lib/lib/expandTailwindAtRules.js +160 -133
- package/lib/lib/findAtConfigPath.js +46 -0
- package/lib/lib/generateRules.js +553 -200
- package/lib/lib/getModuleDependencies.js +88 -37
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +46 -33
- package/lib/lib/offsets.js +306 -0
- package/lib/lib/partitionApplyAtRules.js +58 -0
- package/lib/lib/regex.js +74 -0
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +98 -58
- package/lib/lib/setupContextUtils.js +773 -321
- package/lib/lib/setupTrackingContext.js +70 -75
- package/lib/lib/sharedState.js +78 -10
- package/lib/lib/substituteScreenAtRules.js +14 -10
- package/lib/oxide/cli/build/deps.js +89 -0
- package/lib/oxide/cli/build/index.js +53 -0
- package/lib/oxide/cli/build/plugin.js +375 -0
- package/lib/oxide/cli/build/utils.js +87 -0
- package/lib/oxide/cli/build/watching.js +179 -0
- package/lib/oxide/cli/help/index.js +72 -0
- package/lib/oxide/cli/index.js +214 -0
- package/lib/oxide/cli/init/index.js +52 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +21 -0
- package/lib/postcss-plugins/nesting/plugin.js +89 -0
- package/lib/processTailwindFeatures.js +39 -26
- package/lib/public/colors.js +272 -246
- package/lib/public/create-plugin.js +9 -5
- package/lib/public/default-config.js +10 -6
- package/lib/public/default-theme.js +10 -6
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +11 -6
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +6 -1
- package/lib/util/buildMediaQuery.js +13 -6
- package/lib/util/cloneDeep.js +9 -6
- package/lib/util/cloneNodes.js +23 -3
- package/lib/util/color.js +70 -38
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +7 -2
- package/lib/util/createPlugin.js +8 -6
- package/lib/util/createUtilityPlugin.js +16 -16
- package/lib/util/dataTypes.js +173 -108
- package/lib/util/defaults.js +14 -3
- package/lib/util/escapeClassName.js +13 -8
- package/lib/util/escapeCommas.js +7 -2
- package/lib/util/flattenColorPalette.js +11 -12
- package/lib/util/formatVariantSelector.js +228 -151
- package/lib/util/getAllConfigs.js +33 -12
- package/lib/util/hashConfig.js +9 -4
- package/lib/util/isKeyframeRule.js +7 -2
- package/lib/util/isPlainObject.js +7 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
- package/lib/util/log.js +27 -13
- package/lib/util/nameClass.js +27 -10
- package/lib/util/negateValue.js +25 -8
- package/lib/util/normalizeConfig.js +139 -65
- package/lib/util/normalizeScreens.js +131 -11
- package/lib/util/parseAnimationValue.js +44 -40
- package/lib/util/parseBoxShadowValue.js +34 -23
- package/lib/util/parseDependency.js +39 -55
- package/lib/util/parseGlob.js +36 -0
- package/lib/util/parseObjectStyles.js +15 -10
- package/lib/util/pluginUtils.js +159 -69
- package/lib/util/prefixSelector.js +30 -12
- package/lib/util/pseudoElements.js +229 -0
- package/lib/util/removeAlphaVariables.js +31 -0
- package/lib/util/resolveConfig.js +97 -75
- package/lib/util/resolveConfigPath.js +30 -12
- package/lib/util/responsive.js +11 -6
- package/lib/util/splitAtTopLevelOnly.js +51 -0
- package/lib/util/tap.js +6 -1
- package/lib/util/toColorValue.js +7 -3
- package/lib/util/toPath.js +26 -3
- package/lib/util/transformThemeValue.js +40 -30
- package/lib/util/validateConfig.js +37 -0
- package/lib/util/validateFormalSyntax.js +26 -0
- package/lib/util/withAlphaVariable.js +27 -15
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/nesting/index.js +2 -12
- package/package.json +66 -57
- package/peers/index.js +75964 -55560
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/swap-engines.js +40 -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 +444 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +229 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +216 -0
- package/src/cli/init/index.js +79 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -765
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +786 -306
- package/src/css/preflight.css +10 -8
- package/src/featureFlags.js +21 -5
- package/src/index.js +1 -34
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/content.js +208 -0
- package/src/lib/defaultExtractor.js +217 -0
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +79 -8
- package/src/lib/expandApplyAtRules.js +515 -153
- package/src/lib/expandTailwindAtRules.js +115 -86
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +545 -147
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +31 -0
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +373 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +59 -17
- package/src/lib/setupContextUtils.js +701 -175
- package/src/lib/setupTrackingContext.js +51 -62
- package/src/lib/sharedState.js +58 -7
- 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 +442 -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 +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -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 +12 -2
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +44 -12
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +51 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +264 -144
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +57 -5
- package/src/util/normalizeScreens.js +105 -7
- 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 +123 -24
- package/src/util/prefixSelector.js +30 -10
- package/src/util/pseudoElements.js +170 -0
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +74 -26
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +26 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +206 -166
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +368 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +298 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +371 -0
- package/types/index.d.ts +7 -0
- package/CHANGELOG.md +0 -1843
- package/lib/constants.js +0 -37
- package/lib/lib/setupWatchingContext.js +0 -288
- package/nesting/plugin.js +0 -41
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/constants.js +0 -17
- package/src/lib/setupWatchingContext.js +0 -311
- /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
|
@@ -2,45 +2,135 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function
|
|
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
|
+
formatVariantSelector: function() {
|
|
13
|
+
return formatVariantSelector;
|
|
14
|
+
},
|
|
15
|
+
eliminateIrrelevantSelectors: function() {
|
|
16
|
+
return eliminateIrrelevantSelectors;
|
|
17
|
+
},
|
|
18
|
+
finalizeSelector: function() {
|
|
19
|
+
return finalizeSelector;
|
|
20
|
+
},
|
|
21
|
+
handleMergePseudo: function() {
|
|
22
|
+
return handleMergePseudo;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
26
|
+
const _unesc = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser/dist/util/unesc"));
|
|
27
|
+
const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
|
|
28
|
+
const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
|
|
29
|
+
const _pseudoElements = require("./pseudoElements");
|
|
30
|
+
function _interop_require_default(obj) {
|
|
13
31
|
return obj && obj.__esModule ? obj : {
|
|
14
32
|
default: obj
|
|
15
33
|
};
|
|
16
34
|
}
|
|
17
|
-
let MERGE =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
/** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
|
|
36
|
+
function formatVariantSelector(formats, { context , candidate }) {
|
|
37
|
+
var _context_tailwindConfig_prefix;
|
|
38
|
+
let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
|
|
39
|
+
// Parse the format selector into an AST
|
|
40
|
+
let parsedFormats = formats.map((format)=>{
|
|
41
|
+
let ast = (0, _postcssselectorparser.default)().astSync(format.format);
|
|
42
|
+
return {
|
|
43
|
+
...format,
|
|
44
|
+
ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
// We start with the candidate selector
|
|
48
|
+
let formatAst = _postcssselectorparser.default.root({
|
|
49
|
+
nodes: [
|
|
50
|
+
_postcssselectorparser.default.selector({
|
|
51
|
+
nodes: [
|
|
52
|
+
_postcssselectorparser.default.className({
|
|
53
|
+
value: (0, _escapeClassName.default)(candidate)
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
// And iteratively merge each format selector into the candidate selector
|
|
60
|
+
for (let { ast } of parsedFormats){
|
|
61
|
+
[formatAst, ast] = handleMergePseudo(formatAst, ast);
|
|
62
|
+
// 2. Merge the format selector into the current selector AST
|
|
63
|
+
ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
|
|
64
|
+
// 3. Keep going!
|
|
65
|
+
formatAst = ast;
|
|
66
|
+
}
|
|
67
|
+
return formatAst;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Given any node in a selector this gets the "simple" selector it's a part of
|
|
71
|
+
* A simple selector is just a list of nodes without any combinators
|
|
72
|
+
* Technically :is(), :not(), :has(), etc… can have combinators but those are nested
|
|
73
|
+
* inside the relevant node and won't be picked up so they're fine to ignore
|
|
74
|
+
*
|
|
75
|
+
* @param {Node} node
|
|
76
|
+
* @returns {Node[]}
|
|
77
|
+
**/ function simpleSelectorForNode(node) {
|
|
78
|
+
/** @type {Node[]} */ let nodes = [];
|
|
79
|
+
// Walk backwards until we hit a combinator node (or the start)
|
|
80
|
+
while(node.prev() && node.prev().type !== "combinator"){
|
|
81
|
+
node = node.prev();
|
|
82
|
+
}
|
|
83
|
+
// Now record all non-combinator nodes until we hit one (or the end)
|
|
84
|
+
while(node && node.type !== "combinator"){
|
|
85
|
+
nodes.push(node);
|
|
86
|
+
node = node.next();
|
|
87
|
+
}
|
|
88
|
+
return nodes;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resorts the nodes in a selector to ensure they're in the correct order
|
|
92
|
+
* Tags go before classes, and pseudo classes go after classes
|
|
93
|
+
*
|
|
94
|
+
* @param {Selector} sel
|
|
95
|
+
* @returns {Selector}
|
|
96
|
+
**/ function resortSelector(sel) {
|
|
97
|
+
sel.sort((a, b)=>{
|
|
98
|
+
if (a.type === "tag" && b.type === "class") {
|
|
99
|
+
return -1;
|
|
100
|
+
} else if (a.type === "class" && b.type === "tag") {
|
|
101
|
+
return 1;
|
|
102
|
+
} else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
|
|
103
|
+
return -1;
|
|
104
|
+
} else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
|
|
105
|
+
return 1;
|
|
35
106
|
}
|
|
36
|
-
|
|
107
|
+
return sel.index(a) - sel.index(b);
|
|
108
|
+
});
|
|
109
|
+
return sel;
|
|
110
|
+
}
|
|
111
|
+
function eliminateIrrelevantSelectors(sel, base) {
|
|
112
|
+
let hasClassesMatchingCandidate = false;
|
|
113
|
+
sel.walk((child)=>{
|
|
114
|
+
if (child.type === "class" && child.value === base) {
|
|
115
|
+
hasClassesMatchingCandidate = true;
|
|
116
|
+
return false // Stop walking
|
|
117
|
+
;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (!hasClassesMatchingCandidate) {
|
|
121
|
+
sel.remove();
|
|
37
122
|
}
|
|
38
|
-
|
|
123
|
+
// We do NOT recursively eliminate sub selectors that don't have the base class
|
|
124
|
+
// as this is NOT a safe operation. For example, if we have:
|
|
125
|
+
// `.space-x-2 > :not([hidden]) ~ :not([hidden])`
|
|
126
|
+
// We cannot remove the [hidden] from the :not() because it would change the
|
|
127
|
+
// meaning of the selector.
|
|
128
|
+
// TODO: Can we do this for :matches, :is, and :where?
|
|
39
129
|
}
|
|
40
|
-
function finalizeSelector(
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
let separator = (
|
|
130
|
+
function finalizeSelector(current, formats, { context , candidate , base }) {
|
|
131
|
+
var _context_tailwindConfig;
|
|
132
|
+
var _context_tailwindConfig_separator;
|
|
133
|
+
let separator = (_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":";
|
|
44
134
|
// Split by the separator, but ignore the separator inside square brackets:
|
|
45
135
|
//
|
|
46
136
|
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
@@ -48,12 +138,9 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
|
|
|
48
138
|
// │ │ │ ╰── We will not split here
|
|
49
139
|
// ╰──┴─────┴─────────────── We will split here
|
|
50
140
|
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
55
|
-
}
|
|
56
|
-
format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
|
|
141
|
+
base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
|
|
142
|
+
// Parse the selector into an AST
|
|
143
|
+
let selector = (0, _postcssselectorparser.default)().astSync(current);
|
|
57
144
|
// Normalize escaped classes, e.g.:
|
|
58
145
|
//
|
|
59
146
|
// The idea would be to replace the escaped `base` in the selector with the
|
|
@@ -65,122 +152,112 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
|
|
|
65
152
|
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
66
153
|
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
67
154
|
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
155
|
+
selector.walkClasses((node)=>{
|
|
156
|
+
if (node.raws && node.value.includes(base)) {
|
|
157
|
+
node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
// Remove extraneous selectors that do not include the base candidate
|
|
161
|
+
selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
|
|
162
|
+
// If there are no formats that means there were no variants added to the candidate
|
|
163
|
+
// so we can just return the selector as-is
|
|
164
|
+
let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
|
|
165
|
+
context,
|
|
166
|
+
candidate
|
|
167
|
+
}) : formats;
|
|
168
|
+
if (formatAst === null) {
|
|
169
|
+
return selector.toString();
|
|
170
|
+
}
|
|
171
|
+
let simpleStart = _postcssselectorparser.default.comment({
|
|
172
|
+
value: "/*__simple__*/"
|
|
173
|
+
});
|
|
174
|
+
let simpleEnd = _postcssselectorparser.default.comment({
|
|
175
|
+
value: "/*__simple__*/"
|
|
176
|
+
});
|
|
76
177
|
// We can safely replace the escaped base now, since the `base` section is
|
|
77
178
|
// now in a normalized escaped value.
|
|
78
|
-
|
|
179
|
+
selector.walkClasses((node)=>{
|
|
180
|
+
if (node.value !== base) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
let parent = node.parent;
|
|
184
|
+
let formatNodes = formatAst.nodes[0].nodes;
|
|
185
|
+
// Perf optimization: if the parent is a single class we can just replace it and be done
|
|
186
|
+
if (parent.nodes.length === 1) {
|
|
187
|
+
node.replaceWith(...formatNodes);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
let simpleSelector = simpleSelectorForNode(node);
|
|
191
|
+
parent.insertBefore(simpleSelector[0], simpleStart);
|
|
192
|
+
parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
|
|
193
|
+
for (let child of formatNodes){
|
|
194
|
+
parent.insertBefore(simpleSelector[0], child.clone());
|
|
195
|
+
}
|
|
196
|
+
node.remove();
|
|
197
|
+
// Re-sort the simple selector to ensure it's in the correct order
|
|
198
|
+
simpleSelector = simpleSelectorForNode(simpleStart);
|
|
199
|
+
let firstNode = parent.index(simpleStart);
|
|
200
|
+
parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssselectorparser.default.selector({
|
|
201
|
+
nodes: simpleSelector
|
|
202
|
+
})).nodes);
|
|
203
|
+
simpleStart.remove();
|
|
204
|
+
simpleEnd.remove();
|
|
205
|
+
});
|
|
79
206
|
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// This will make sure to move pseudo's to the correct spot (the end for
|
|
89
|
-
// pseudo elements) because otherwise the selector will never work
|
|
90
|
-
// anyway.
|
|
91
|
-
//
|
|
92
|
-
// E.g.:
|
|
93
|
-
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
94
|
-
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
95
|
-
//
|
|
96
|
-
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
97
|
-
function collectPseudoElements(selector) {
|
|
98
|
-
let nodes = [];
|
|
99
|
-
for (let node of selector.nodes){
|
|
100
|
-
if (isPseudoElement(node)) {
|
|
101
|
-
nodes.push(node);
|
|
102
|
-
selector.removeChild(node);
|
|
103
|
-
}
|
|
104
|
-
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
105
|
-
nodes.push(...collectPseudoElements(node));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return nodes;
|
|
109
|
-
}
|
|
110
|
-
let pseudoElements = collectPseudoElements(selector2);
|
|
111
|
-
if (pseudoElements.length > 0) {
|
|
112
|
-
selector2.nodes.push(pseudoElements.sort(sortSelector));
|
|
113
|
-
}
|
|
114
|
-
return selector2;
|
|
115
|
-
});
|
|
116
|
-
}).processSync(selector1);
|
|
117
|
-
}
|
|
118
|
-
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
119
|
-
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
120
|
-
// this distinction was not present in older versions of the W3C spec, most
|
|
121
|
-
// browsers support both syntaxes for the original pseudo-elements.
|
|
122
|
-
let pseudoElementsBC = [
|
|
123
|
-
':before',
|
|
124
|
-
':after',
|
|
125
|
-
':first-line',
|
|
126
|
-
':first-letter'
|
|
127
|
-
];
|
|
128
|
-
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
129
|
-
let pseudoElementExceptions = [
|
|
130
|
-
'::file-selector-button'
|
|
131
|
-
];
|
|
132
|
-
// This will make sure to move pseudo's to the correct spot (the end for
|
|
133
|
-
// pseudo elements) because otherwise the selector will never work
|
|
134
|
-
// anyway.
|
|
135
|
-
//
|
|
136
|
-
// E.g.:
|
|
137
|
-
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
138
|
-
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
139
|
-
//
|
|
140
|
-
// `::before:hover` doesn't work, which means that we can make it work
|
|
141
|
-
// for you by flipping the order.
|
|
142
|
-
function sortSelector(a, z) {
|
|
143
|
-
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
144
|
-
// them in the same order.
|
|
145
|
-
if (a.type !== 'pseudo' && z.type !== 'pseudo') {
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
// If one of them is a combinator, we need to keep it in the same order
|
|
149
|
-
// because that means it will start a new "section" in the selector.
|
|
150
|
-
if (a.type === 'combinator' ^ z.type === 'combinator') {
|
|
151
|
-
return 0;
|
|
152
|
-
}
|
|
153
|
-
// One of the items is a pseudo and the other one isn't. Let's move
|
|
154
|
-
// the pseudo to the right.
|
|
155
|
-
if (a.type === 'pseudo' ^ z.type === 'pseudo') {
|
|
156
|
-
return (a.type === 'pseudo') - (z.type === 'pseudo');
|
|
157
|
-
}
|
|
158
|
-
// Both are pseudo's, move the pseudo elements (except for
|
|
159
|
-
// ::file-selector-button) to the right.
|
|
160
|
-
return isPseudoElement(a) - isPseudoElement(z);
|
|
161
|
-
}
|
|
162
|
-
function isPseudoElement(node) {
|
|
163
|
-
if (node.type !== 'pseudo') return false;
|
|
164
|
-
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
165
|
-
return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
|
|
207
|
+
selector.walkPseudos((p)=>{
|
|
208
|
+
if (p.value === MERGE) {
|
|
209
|
+
p.replaceWith(p.nodes);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
// Move pseudo elements to the end of the selector (if necessary)
|
|
213
|
+
selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
|
|
214
|
+
return selector.toString();
|
|
166
215
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
target += char;
|
|
177
|
-
} else if (char === '(') {
|
|
178
|
-
target += char;
|
|
179
|
-
count++;
|
|
180
|
-
} else if (char === ')') {
|
|
181
|
-
if (--count < 0) break; // unbalanced
|
|
182
|
-
target += char;
|
|
216
|
+
function handleMergePseudo(selector, format) {
|
|
217
|
+
/** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
|
|
218
|
+
// Find all :merge() pseudo-classes in `selector`
|
|
219
|
+
selector.walkPseudos((pseudo)=>{
|
|
220
|
+
if (pseudo.value === MERGE) {
|
|
221
|
+
merges.push({
|
|
222
|
+
pseudo,
|
|
223
|
+
value: pseudo.nodes[0].toString()
|
|
224
|
+
});
|
|
183
225
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
226
|
+
});
|
|
227
|
+
// Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
|
|
228
|
+
format.walkPseudos((pseudo)=>{
|
|
229
|
+
if (pseudo.value !== MERGE) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
let value = pseudo.nodes[0].toString();
|
|
233
|
+
// Does `selector` contain a :merge() pseudo-class with the same value?
|
|
234
|
+
let existing = merges.find((merge)=>merge.value === value);
|
|
235
|
+
// Nope so there's nothing to do
|
|
236
|
+
if (!existing) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// Everything after `:merge()` up to the next combinator is what is attached to the merged selector
|
|
240
|
+
let attachments = [];
|
|
241
|
+
let next = pseudo.next();
|
|
242
|
+
while(next && next.type !== "combinator"){
|
|
243
|
+
attachments.push(next);
|
|
244
|
+
next = next.next();
|
|
245
|
+
}
|
|
246
|
+
let combinator = next;
|
|
247
|
+
existing.pseudo.parent.insertAfter(existing.pseudo, _postcssselectorparser.default.selector({
|
|
248
|
+
nodes: attachments.map((node)=>node.clone())
|
|
249
|
+
}));
|
|
250
|
+
pseudo.remove();
|
|
251
|
+
attachments.forEach((node)=>node.remove());
|
|
252
|
+
// What about this case:
|
|
253
|
+
// :merge(.group):focus > &
|
|
254
|
+
// :merge(.group):hover &
|
|
255
|
+
if (combinator && combinator.type === "combinator") {
|
|
256
|
+
combinator.remove();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return [
|
|
260
|
+
selector,
|
|
261
|
+
format
|
|
262
|
+
];
|
|
186
263
|
}
|
|
@@ -2,25 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getAllConfigs;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _configfull = /*#__PURE__*/ _interop_require_default(require("../../stubs/config.full.js"));
|
|
12
|
+
const _featureFlags = require("../featureFlags");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
9
14
|
return obj && obj.__esModule ? obj : {
|
|
10
15
|
default: obj
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
18
|
function getAllConfigs(config) {
|
|
14
|
-
var
|
|
15
|
-
const configs = ((
|
|
16
|
-
|
|
17
|
-
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
|
|
18
|
-
);
|
|
19
|
+
var _config_presets;
|
|
20
|
+
const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
|
|
21
|
+
_configfull.default
|
|
22
|
+
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
19
23
|
const features = {
|
|
24
|
+
// Add experimental configs here...
|
|
25
|
+
respectDefaultRingColorOpacity: {
|
|
26
|
+
theme: {
|
|
27
|
+
ringColor: ({ theme })=>({
|
|
28
|
+
DEFAULT: "#3b82f67f",
|
|
29
|
+
...theme("colors")
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
disableColorOpacityUtilitiesByDefault: {
|
|
34
|
+
corePlugins: {
|
|
35
|
+
backgroundOpacity: false,
|
|
36
|
+
borderOpacity: false,
|
|
37
|
+
divideOpacity: false,
|
|
38
|
+
placeholderOpacity: false,
|
|
39
|
+
ringOpacity: false,
|
|
40
|
+
textOpacity: false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
20
43
|
};
|
|
21
|
-
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags
|
|
22
|
-
).map((feature)=>features[feature]
|
|
23
|
-
);
|
|
44
|
+
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
|
|
24
45
|
return [
|
|
25
46
|
config,
|
|
26
47
|
...experimentals,
|
package/lib/util/hashConfig.js
CHANGED
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
function
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return hashConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _objecthash = /*#__PURE__*/ _interop_require_default(require("object-hash"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
8
13
|
return obj && obj.__esModule ? obj : {
|
|
9
14
|
default: obj
|
|
10
15
|
};
|
|
11
16
|
}
|
|
12
17
|
function hashConfig(config) {
|
|
13
|
-
return (0,
|
|
18
|
+
return (0, _objecthash.default)(config, {
|
|
14
19
|
ignoreUnknown: true
|
|
15
20
|
});
|
|
16
21
|
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return isKeyframeRule;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
6
11
|
function isKeyframeRule(rule) {
|
|
7
|
-
return rule.parent && rule.parent.type ===
|
|
12
|
+
return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
|
|
8
13
|
}
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return isPlainObject;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
6
11
|
function isPlainObject(value) {
|
|
7
|
-
if (Object.prototype.toString.call(value) !==
|
|
12
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
8
13
|
return false;
|
|
9
14
|
}
|
|
10
15
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -2,45 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
5
|
+
Object.defineProperty(exports, // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
6
|
+
// values don't count, and brackets inside quotes also don't count.
|
|
7
|
+
//
|
|
8
|
+
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
9
|
+
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
10
|
+
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
11
|
+
"default", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return isSyntacticallyValidPropertyValue;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
6
17
|
let matchingBrackets = new Map([
|
|
7
18
|
[
|
|
8
|
-
|
|
9
|
-
|
|
19
|
+
"{",
|
|
20
|
+
"}"
|
|
10
21
|
],
|
|
11
22
|
[
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
"[",
|
|
24
|
+
"]"
|
|
14
25
|
],
|
|
15
26
|
[
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
27
|
+
"(",
|
|
28
|
+
")"
|
|
29
|
+
]
|
|
19
30
|
]);
|
|
20
31
|
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
21
32
|
v,
|
|
22
33
|
k
|
|
23
|
-
]
|
|
24
|
-
));
|
|
34
|
+
]));
|
|
25
35
|
let quotes = new Set([
|
|
26
36
|
'"',
|
|
27
37
|
"'",
|
|
28
|
-
|
|
38
|
+
"`"
|
|
29
39
|
]);
|
|
30
|
-
function
|
|
40
|
+
function isSyntacticallyValidPropertyValue(value) {
|
|
31
41
|
let stack = [];
|
|
32
42
|
let inQuotes = false;
|
|
33
43
|
for(let i = 0; i < value.length; i++){
|
|
34
44
|
let char = value[i];
|
|
35
|
-
if (char ===
|
|
45
|
+
if (char === ":" && !inQuotes && stack.length === 0) {
|
|
36
46
|
return false;
|
|
37
47
|
}
|
|
38
48
|
// Non-escaped quotes allow us to "allow" anything in between
|
|
39
|
-
if (quotes.has(char) && value[i - 1] !==
|
|
49
|
+
if (quotes.has(char) && value[i - 1] !== "\\") {
|
|
40
50
|
inQuotes = !inQuotes;
|
|
41
51
|
}
|
|
42
52
|
if (inQuotes) continue;
|
|
43
|
-
if (value[i - 1] ===
|
|
53
|
+
if (value[i - 1] === "\\") continue; // Escaped
|
|
44
54
|
if (matchingBrackets.has(char)) {
|
|
45
55
|
stack.push(char);
|
|
46
56
|
} else if (inverseMatchingBrackets.has(char)) {
|