tailwindcss 0.0.0-oxide-insiders.a7fe2fe → 0.0.0-oxide-insiders.759a8c2

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.
Files changed (108) hide show
  1. package/lib/cli/build/deps.js +34 -18
  2. package/lib/cli/build/index.js +45 -12
  3. package/lib/cli/build/plugin.js +273 -90
  4. package/lib/cli/build/utils.js +56 -24
  5. package/lib/cli/build/watching.js +156 -38
  6. package/lib/cli/help/index.js +61 -16
  7. package/lib/cli/index.js +121 -62
  8. package/lib/cli/init/index.js +47 -23
  9. package/lib/cli-peer-dependencies.js +23 -13
  10. package/lib/cli.js +5 -1
  11. package/lib/corePluginList.js +7 -4
  12. package/lib/corePlugins.js +855 -386
  13. package/lib/featureFlags.js +43 -18
  14. package/lib/lib/cacheInvalidation.js +78 -30
  15. package/lib/lib/collapseAdjacentRules.js +46 -23
  16. package/lib/lib/collapseDuplicateDeclarations.js +70 -27
  17. package/lib/lib/content.js +134 -41
  18. package/lib/lib/defaultExtractor.js +201 -96
  19. package/lib/lib/detectNesting.js +38 -12
  20. package/lib/lib/evaluateTailwindFunctions.js +192 -103
  21. package/lib/lib/expandApplyAtRules.js +488 -181
  22. package/lib/lib/expandTailwindAtRules.js +240 -70
  23. package/lib/lib/findAtConfigPath.js +34 -15
  24. package/lib/lib/generateRules.js +775 -353
  25. package/lib/lib/getModuleDependencies.js +67 -29
  26. package/lib/lib/load-config.js +27 -17
  27. package/lib/lib/normalizeTailwindDirectives.js +73 -27
  28. package/lib/lib/offsets.js +227 -62
  29. package/lib/lib/partitionApplyAtRules.js +53 -29
  30. package/lib/lib/regex.js +50 -28
  31. package/lib/lib/remap-bitfield.js +86 -9
  32. package/lib/lib/resolveDefaultsAtRules.js +123 -53
  33. package/lib/lib/setupContextUtils.js +1117 -584
  34. package/lib/lib/setupTrackingContext.js +149 -58
  35. package/lib/lib/sharedState.js +71 -23
  36. package/lib/lib/substituteScreenAtRules.js +19 -9
  37. package/lib/oxide/cli/build/deps.js +46 -23
  38. package/lib/oxide/cli/build/index.js +44 -12
  39. package/lib/oxide/cli/build/plugin.js +271 -89
  40. package/lib/oxide/cli/build/utils.js +55 -24
  41. package/lib/oxide/cli/build/watching.js +153 -36
  42. package/lib/oxide/cli/help/index.js +60 -16
  43. package/lib/oxide/cli/index.js +128 -67
  44. package/lib/oxide/cli/init/index.js +40 -19
  45. package/lib/oxide/cli.js +3 -2
  46. package/lib/plugin.js +58 -31
  47. package/lib/postcss-plugins/nesting/index.js +13 -7
  48. package/lib/postcss-plugins/nesting/plugin.js +65 -20
  49. package/lib/processTailwindFeatures.js +41 -10
  50. package/lib/public/colors.js +25 -16
  51. package/lib/public/create-plugin.js +11 -6
  52. package/lib/public/default-config.js +12 -6
  53. package/lib/public/default-theme.js +12 -6
  54. package/lib/public/load-config.js +9 -5
  55. package/lib/public/resolve-config.js +10 -6
  56. package/lib/util/applyImportantSelector.js +28 -17
  57. package/lib/util/bigSign.js +9 -6
  58. package/lib/util/buildMediaQuery.js +19 -10
  59. package/lib/util/cloneDeep.js +19 -9
  60. package/lib/util/cloneNodes.js +29 -14
  61. package/lib/util/color.js +87 -47
  62. package/lib/util/colorNames.js +752 -0
  63. package/lib/util/configurePlugins.js +18 -9
  64. package/lib/util/createPlugin.js +17 -8
  65. package/lib/util/createUtilityPlugin.js +30 -16
  66. package/lib/util/dataTypes.js +189 -38
  67. package/lib/util/defaults.js +21 -9
  68. package/lib/util/escapeClassName.js +15 -9
  69. package/lib/util/escapeCommas.js +9 -6
  70. package/lib/util/flattenColorPalette.js +11 -7
  71. package/lib/util/formatVariantSelector.js +209 -60
  72. package/lib/util/getAllConfigs.js +44 -35
  73. package/lib/util/hashConfig.js +12 -8
  74. package/lib/util/isKeyframeRule.js +10 -7
  75. package/lib/util/isPlainObject.js +14 -9
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +45 -14
  77. package/lib/util/log.js +20 -9
  78. package/lib/util/nameClass.js +31 -10
  79. package/lib/util/negateValue.js +28 -10
  80. package/lib/util/normalizeConfig.js +242 -63
  81. package/lib/util/normalizeScreens.js +145 -70
  82. package/lib/util/parseAnimationValue.js +64 -14
  83. package/lib/util/parseBoxShadowValue.js +63 -14
  84. package/lib/util/parseDependency.js +39 -13
  85. package/lib/util/parseGlob.js +25 -8
  86. package/lib/util/parseObjectStyles.js +29 -18
  87. package/lib/util/pluginUtils.js +196 -77
  88. package/lib/util/prefixSelector.js +31 -12
  89. package/lib/util/pseudoElements.js +116 -34
  90. package/lib/util/removeAlphaVariables.js +23 -8
  91. package/lib/util/resolveConfig.js +224 -105
  92. package/lib/util/resolveConfigPath.js +45 -15
  93. package/lib/util/responsive.js +10 -6
  94. package/lib/util/splitAtTopLevelOnly.js +46 -10
  95. package/lib/util/tap.js +11 -7
  96. package/lib/util/toColorValue.js +10 -7
  97. package/lib/util/toPath.js +28 -8
  98. package/lib/util/transformThemeValue.js +49 -14
  99. package/lib/util/validateConfig.js +25 -15
  100. package/lib/util/validateFormalSyntax.js +14 -6
  101. package/lib/util/withAlphaVariable.js +54 -30
  102. package/package.json +18 -22
  103. package/peers/index.js +57849 -43101
  104. package/src/lib/expandTailwindAtRules.js +1 -1
  105. package/src/lib/setupTrackingContext.js +1 -1
  106. package/src/util/color.js +1 -1
  107. package/src/util/colorNames.js +150 -0
  108. package/src/util/pseudoElements.js +4 -4
@@ -1,21 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
- value: !0
4
- }), Object.defineProperty(exports, "default", {
5
- enumerable: !0,
6
- get: ()=>_default
3
+ value: true
7
4
  });
8
- const _dlv = _interopRequireDefault(require("dlv")), _didyoumean = _interopRequireDefault(require("didyoumean")), _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue")), _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")), _normalizeScreens = require("../util/normalizeScreens"), _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery")), _toPath = require("../util/toPath"), _withAlphaVariable = require("../util/withAlphaVariable"), _pluginUtils = require("../util/pluginUtils"), _log = _interopRequireDefault(require("../util/log"));
9
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
12
+ const _didyoumean = /*#__PURE__*/ _interop_require_default(require("didyoumean"));
13
+ const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
14
+ const _postcssvalueparser = /*#__PURE__*/ _interop_require_default(require("postcss-value-parser"));
15
+ const _normalizeScreens = require("../util/normalizeScreens");
16
+ const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
17
+ const _toPath = require("../util/toPath");
18
+ const _withAlphaVariable = require("../util/withAlphaVariable");
19
+ const _pluginUtils = require("../util/pluginUtils");
20
+ const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
21
+ function _interop_require_default(obj) {
10
22
  return obj && obj.__esModule ? obj : {
11
23
  default: obj
12
24
  };
13
25
  }
14
26
  function isObject(input) {
15
- return "object" == typeof input && null !== input;
27
+ return typeof input === "object" && input !== null;
28
+ }
29
+ function findClosestExistingPath(theme, path) {
30
+ let parts = (0, _toPath.toPath)(path);
31
+ do {
32
+ parts.pop();
33
+ if ((0, _dlv.default)(theme, parts) !== undefined) break;
34
+ }while (parts.length);
35
+ return parts.length ? parts : undefined;
16
36
  }
17
37
  function pathToString(path) {
18
- return "string" == typeof path ? path : path.reduce((acc, cur, i)=>cur.includes(".") ? `${acc}[${cur}]` : 0 === i ? cur : `${acc}.${cur}`, "");
38
+ if (typeof path === "string") return path;
39
+ return path.reduce((acc, cur, i)=>{
40
+ if (cur.includes(".")) return `${acc}[${cur}]`;
41
+ return i === 0 ? cur : `${acc}.${cur}`;
42
+ }, "");
19
43
  }
20
44
  function list(items) {
21
45
  return items.map((key)=>`'${key}'`).join(", ");
@@ -23,89 +47,157 @@ function list(items) {
23
47
  function listKeys(obj) {
24
48
  return list(Object.keys(obj));
25
49
  }
50
+ function validatePath(config, path, defaultValue, themeOpts = {}) {
51
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, "");
52
+ const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
53
+ const value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
54
+ if (value === undefined) {
55
+ let error = `'${pathString}' does not exist in your theme config.`;
56
+ const parentSegments = pathSegments.slice(0, -1);
57
+ const parentValue = (0, _dlv.default)(config.theme, parentSegments);
58
+ if (isObject(parentValue)) {
59
+ const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
60
+ ...parentSegments,
61
+ key
62
+ ]).isValid);
63
+ const suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
64
+ if (suggestion) {
65
+ error += ` Did you mean '${pathToString([
66
+ ...parentSegments,
67
+ suggestion
68
+ ])}'?`;
69
+ } else if (validKeys.length > 0) {
70
+ error += ` '${pathToString(parentSegments)}' has the following valid keys: ${list(validKeys)}`;
71
+ }
72
+ } else {
73
+ const closestPath = findClosestExistingPath(config.theme, pathString);
74
+ if (closestPath) {
75
+ const closestValue = (0, _dlv.default)(config.theme, closestPath);
76
+ if (isObject(closestValue)) {
77
+ error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
78
+ } else {
79
+ error += ` '${pathToString(closestPath)}' is not an object.`;
80
+ }
81
+ } else {
82
+ error += ` Your theme has the following top-level keys: ${listKeys(config.theme)}`;
83
+ }
84
+ }
85
+ return {
86
+ isValid: false,
87
+ error
88
+ };
89
+ }
90
+ if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
91
+ let error = `'${pathString}' was found but does not resolve to a string.`;
92
+ if (isObject(value)) {
93
+ let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
94
+ ...pathSegments,
95
+ key
96
+ ]).isValid);
97
+ if (validKeys.length) {
98
+ error += ` Did you mean something like '${pathToString([
99
+ ...pathSegments,
100
+ validKeys[0]
101
+ ])}'?`;
102
+ }
103
+ }
104
+ return {
105
+ isValid: false,
106
+ error
107
+ };
108
+ }
109
+ const [themeSection] = pathSegments;
110
+ return {
111
+ isValid: true,
112
+ value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
113
+ };
114
+ }
115
+ function extractArgs(node, vNodes, functions) {
116
+ vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
117
+ let args = [
118
+ ""
119
+ ];
120
+ for (let vNode of vNodes){
121
+ if (vNode.type === "div" && vNode.value === ",") {
122
+ args.push("");
123
+ } else {
124
+ args[args.length - 1] += _postcssvalueparser.default.stringify(vNode);
125
+ }
126
+ }
127
+ return args;
128
+ }
129
+ function resolveVNode(node, vNode, functions) {
130
+ if (vNode.type === "function" && functions[vNode.value] !== undefined) {
131
+ let args = extractArgs(node, vNode.nodes, functions);
132
+ vNode.type = "word";
133
+ vNode.value = functions[vNode.value](node, ...args);
134
+ }
135
+ return vNode;
136
+ }
137
+ function resolveFunctions(node, input, functions) {
138
+ return (0, _postcssvalueparser.default)(input).walk((vNode)=>{
139
+ resolveVNode(node, vNode, functions);
140
+ }).toString();
141
+ }
26
142
  let nodeTypePropertyMap = {
27
143
  atrule: "params",
28
144
  decl: "value"
29
145
  };
146
+ /**
147
+ * @param {string} path
148
+ * @returns {Iterable<[path: string, alpha: string|undefined]>}
149
+ */ function* toPaths(path) {
150
+ // Strip quotes from beginning and end of string
151
+ // This allows the alpha value to be present inside of quotes
152
+ path = path.replace(/^['"]+|['"]+$/g, "");
153
+ let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
154
+ let alpha = undefined;
155
+ yield [
156
+ path,
157
+ undefined
158
+ ];
159
+ if (matches) {
160
+ path = matches[1];
161
+ alpha = matches[2];
162
+ yield [
163
+ path,
164
+ alpha
165
+ ];
166
+ }
167
+ }
168
+ /**
169
+ *
170
+ * @param {any} config
171
+ * @param {string} path
172
+ * @param {any} defaultValue
173
+ */ function resolvePath(config, path, defaultValue) {
174
+ const results = Array.from(toPaths(path)).map(([path, alpha])=>{
175
+ return Object.assign(validatePath(config, path, defaultValue, {
176
+ opacityValue: alpha
177
+ }), {
178
+ resolvedPath: path,
179
+ alpha
180
+ });
181
+ });
182
+ var _results_find;
183
+ return (_results_find = results.find((result)=>result.isValid)) !== null && _results_find !== void 0 ? _results_find : results[0];
184
+ }
30
185
  function _default(context) {
31
- let config = context.tailwindConfig, functions = {
186
+ let config = context.tailwindConfig;
187
+ let functions = {
32
188
  theme: (node, path, ...defaultValue)=>{
33
- let { isValid , value , error , alpha } = function(config, path, defaultValue) {
34
- var _results_find;
35
- let results = Array.from(function*(path) {
36
- let alpha, matches = (path = path.replace(/^['"]+|['"]+$/g, "")).match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
37
- yield [
38
- path,
39
- void 0
40
- ], matches && (path = matches[1], alpha = matches[2], yield [
41
- path,
42
- alpha
43
- ]);
44
- }(path)).map(([path, alpha])=>Object.assign(function validatePath(config, path, defaultValue, themeOpts = {}) {
45
- let pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, ""), pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString), value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
46
- if (void 0 === value) {
47
- let error = `'${pathString}' does not exist in your theme config.`, parentSegments = pathSegments.slice(0, -1), parentValue = (0, _dlv.default)(config.theme, parentSegments);
48
- if (isObject(parentValue)) {
49
- let validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
50
- ...parentSegments,
51
- key
52
- ]).isValid), suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
53
- suggestion ? error += ` Did you mean '${pathToString([
54
- ...parentSegments,
55
- suggestion
56
- ])}'?` : validKeys.length > 0 && (error += ` '${pathToString(parentSegments)}' has the following valid keys: ${list(validKeys)}`);
57
- } else {
58
- let closestPath = function(theme, path) {
59
- let parts = (0, _toPath.toPath)(path);
60
- do if (parts.pop(), void 0 !== (0, _dlv.default)(theme, parts)) break;
61
- while (parts.length);
62
- return parts.length ? parts : void 0;
63
- }(config.theme, pathString);
64
- if (closestPath) {
65
- let closestValue = (0, _dlv.default)(config.theme, closestPath);
66
- isObject(closestValue) ? error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}` : error += ` '${pathToString(closestPath)}' is not an object.`;
67
- } else error += ` Your theme has the following top-level keys: ${listKeys(config.theme)}`;
68
- }
69
- return {
70
- isValid: !1,
71
- error
72
- };
73
- }
74
- if (!("string" == typeof value || "number" == typeof value || "function" == typeof value || value instanceof String || value instanceof Number || Array.isArray(value))) {
75
- let error = `'${pathString}' was found but does not resolve to a string.`;
76
- if (isObject(value)) {
77
- let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
78
- ...pathSegments,
79
- key
80
- ]).isValid);
81
- validKeys.length && (error += ` Did you mean something like '${pathToString([
82
- ...pathSegments,
83
- validKeys[0]
84
- ])}'?`);
85
- }
86
- return {
87
- isValid: !1,
88
- error
89
- };
90
- }
91
- let [themeSection] = pathSegments;
92
- return {
93
- isValid: !0,
94
- value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
95
- };
96
- }(config, path, defaultValue, {
97
- opacityValue: alpha
98
- }), {
99
- resolvedPath: path,
100
- alpha
101
- }));
102
- return null !== (_results_find = results.find((result)=>result.isValid)) && void 0 !== _results_find ? _results_find : results[0];
103
- }(config, path, defaultValue.length ? defaultValue : void 0);
189
+ let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
104
190
  if (!isValid) {
105
191
  var _parentNode_raws_tailwind;
106
- let parentNode = node.parent, candidate = null === (_parentNode_raws_tailwind = null == parentNode ? void 0 : parentNode.raws.tailwind) || void 0 === _parentNode_raws_tailwind ? void 0 : _parentNode_raws_tailwind.candidate;
107
- if (parentNode && void 0 !== candidate) {
108
- context.markInvalidUtilityNode(parentNode), parentNode.remove(), _log.default.warn("invalid-theme-key-in-class", [
192
+ let parentNode = node.parent;
193
+ let candidate = (_parentNode_raws_tailwind = parentNode === null || parentNode === void 0 ? void 0 : parentNode.raws.tailwind) === null || _parentNode_raws_tailwind === void 0 ? void 0 : _parentNode_raws_tailwind.candidate;
194
+ if (parentNode && candidate !== undefined) {
195
+ // Remove this utility from any caches
196
+ context.markInvalidUtilityNode(parentNode);
197
+ // Remove the CSS node from the markup
198
+ parentNode.remove();
199
+ // Show a warning
200
+ _log.default.warn("invalid-theme-key-in-class", [
109
201
  `The utility \`${candidate}\` contains an invalid theme value and was not generated.`
110
202
  ]);
111
203
  return;
@@ -113,35 +205,32 @@ function _default(context) {
113
205
  throw node.error(error);
114
206
  }
115
207
  let maybeColor = (0, _pluginUtils.parseColorFormat)(value);
116
- return (void 0 !== alpha || void 0 !== maybeColor && "function" == typeof maybeColor) && (void 0 === alpha && (alpha = 1.0), value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor)), value;
208
+ let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
209
+ if (alpha !== undefined || isColorFunction) {
210
+ if (alpha === undefined) {
211
+ alpha = 1.0;
212
+ }
213
+ value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor);
214
+ }
215
+ return value;
117
216
  },
118
217
  screen: (node, screen)=>{
119
218
  screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
120
- let screenDefinition = (0, _normalizeScreens.normalizeScreens)(config.theme.screens).find(({ name })=>name === screen);
121
- if (!screenDefinition) throw node.error(`The '${screen}' screen does not exist in your theme.`);
219
+ let screens = (0, _normalizeScreens.normalizeScreens)(config.theme.screens);
220
+ let screenDefinition = screens.find(({ name })=>name === screen);
221
+ if (!screenDefinition) {
222
+ throw node.error(`The '${screen}' screen does not exist in your theme.`);
223
+ }
122
224
  return (0, _buildMediaQuery.default)(screenDefinition);
123
225
  }
124
226
  };
125
227
  return (root)=>{
126
228
  root.walk((node)=>{
127
- var input;
128
229
  let property = nodeTypePropertyMap[node.type];
129
- void 0 !== property && (node[property] = (input = node[property], (0, _postcssValueParser.default)(input).walk((vNode)=>{
130
- (function resolveVNode(node, vNode, functions) {
131
- if ("function" === vNode.type && void 0 !== functions[vNode.value]) {
132
- let args = function(node, vNodes, functions) {
133
- vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
134
- let args = [
135
- ""
136
- ];
137
- for (let vNode of vNodes)"div" === vNode.type && "," === vNode.value ? args.push("") : args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
138
- return args;
139
- }(node, vNode.nodes, functions);
140
- vNode.type = "word", vNode.value = functions[vNode.value](node, ...args);
141
- }
142
- return vNode;
143
- })(node, vNode, functions);
144
- }).toString()));
230
+ if (property === undefined) {
231
+ return;
232
+ }
233
+ node[property] = resolveFunctions(node, node[property], functions);
145
234
  });
146
235
  };
147
236
  }