tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -1,192 +1,171 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = _default;
7
-
8
6
  var _dlv = _interopRequireDefault(require("dlv"));
9
-
10
7
  var _didyoumean = _interopRequireDefault(require("didyoumean"));
11
-
12
8
  var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
13
-
14
9
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
15
-
10
+ var _normalizeScreens = require("../util/normalizeScreens");
16
11
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
17
-
18
12
  var _toPath = require("../util/toPath");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
13
+ function _interopRequireDefault(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
22
18
  function isObject(input) {
23
- return typeof input === 'object' && input !== null;
19
+ return typeof input === 'object' && input !== null;
24
20
  }
25
-
26
21
  function findClosestExistingPath(theme, path) {
27
- let parts = (0, _toPath.toPath)(path);
28
-
29
- do {
30
- parts.pop();
31
- if ((0, _dlv.default)(theme, parts) !== undefined) break;
32
- } while (parts.length);
33
-
34
- return parts.length ? parts : undefined;
22
+ let parts = (0, _toPath).toPath(path);
23
+ do {
24
+ parts.pop();
25
+ if ((0, _dlv).default(theme, parts) !== undefined) break;
26
+ }while (parts.length)
27
+ return parts.length ? parts : undefined;
35
28
  }
36
-
37
29
  function pathToString(path) {
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
- }, '');
30
+ if (typeof path === 'string') return path;
31
+ return path.reduce((acc, cur, i)=>{
32
+ if (cur.includes('.')) return `${acc}[${cur}]`;
33
+ return i === 0 ? cur : `${acc}.${cur}`;
34
+ }, '');
43
35
  }
44
-
45
36
  function list(items) {
46
- return items.map(key => `'${key}'`).join(', ');
37
+ return items.map((key)=>`'${key}'`
38
+ ).join(', ');
47
39
  }
48
-
49
40
  function listKeys(obj) {
50
- return list(Object.keys(obj));
41
+ return list(Object.keys(obj));
51
42
  }
52
-
53
43
  function validatePath(config, path, defaultValue) {
54
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
55
- const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
56
- const value = (0, _dlv.default)(config.theme, pathString, defaultValue);
57
-
58
- if (value === undefined) {
59
- let error = `'${pathString}' does not exist in your theme config.`;
60
- const parentSegments = pathSegments.slice(0, -1);
61
- const parentValue = (0, _dlv.default)(config.theme, parentSegments);
62
-
63
- if (isObject(parentValue)) {
64
- const validKeys = Object.keys(parentValue).filter(key => validatePath(config, [...parentSegments, key]).isValid);
65
- const suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
66
-
67
- if (suggestion) {
68
- error += ` Did you mean '${pathToString([...parentSegments, suggestion])}'?`;
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
-
75
- if (closestPath) {
76
- const closestValue = (0, _dlv.default)(config.theme, closestPath);
77
-
78
- if (isObject(closestValue)) {
79
- error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
44
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
45
+ const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
46
+ const value = (0, _dlv).default(config.theme, pathString, defaultValue);
47
+ if (value === undefined) {
48
+ let error = `'${pathString}' does not exist in your theme config.`;
49
+ const parentSegments = pathSegments.slice(0, -1);
50
+ const parentValue = (0, _dlv).default(config.theme, parentSegments);
51
+ if (isObject(parentValue)) {
52
+ const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
53
+ ...parentSegments,
54
+ key
55
+ ]).isValid
56
+ );
57
+ const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
58
+ if (suggestion) {
59
+ error += ` Did you mean '${pathToString([
60
+ ...parentSegments,
61
+ suggestion
62
+ ])}'?`;
63
+ } else if (validKeys.length > 0) {
64
+ error += ` '${pathToString(parentSegments)}' has the following valid keys: ${list(validKeys)}`;
65
+ }
80
66
  } else {
81
- error += ` '${pathToString(closestPath)}' is not an object.`;
67
+ const closestPath = findClosestExistingPath(config.theme, pathString);
68
+ if (closestPath) {
69
+ const closestValue = (0, _dlv).default(config.theme, closestPath);
70
+ if (isObject(closestValue)) {
71
+ error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
72
+ } else {
73
+ error += ` '${pathToString(closestPath)}' is not an object.`;
74
+ }
75
+ } else {
76
+ error += ` Your theme has the following top-level keys: ${listKeys(config.theme)}`;
77
+ }
82
78
  }
83
- } else {
84
- error += ` Your theme has the following top-level keys: ${listKeys(config.theme)}`;
85
- }
79
+ return {
80
+ isValid: false,
81
+ error
82
+ };
86
83
  }
87
-
88
- return {
89
- isValid: false,
90
- error
91
- };
92
- }
93
-
94
- if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
95
- let error = `'${pathString}' was found but does not resolve to a string.`;
96
-
97
- if (isObject(value)) {
98
- let validKeys = Object.keys(value).filter(key => validatePath(config, [...pathSegments, key]).isValid);
99
-
100
- if (validKeys.length) {
101
- error += ` Did you mean something like '${pathToString([...pathSegments, validKeys[0]])}'?`;
102
- }
84
+ if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
85
+ let error = `'${pathString}' was found but does not resolve to a string.`;
86
+ if (isObject(value)) {
87
+ let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
88
+ ...pathSegments,
89
+ key
90
+ ]).isValid
91
+ );
92
+ if (validKeys.length) {
93
+ error += ` Did you mean something like '${pathToString([
94
+ ...pathSegments,
95
+ validKeys[0]
96
+ ])}'?`;
97
+ }
98
+ }
99
+ return {
100
+ isValid: false,
101
+ error
102
+ };
103
103
  }
104
-
104
+ const [themeSection] = pathSegments;
105
105
  return {
106
- isValid: false,
107
- error
106
+ isValid: true,
107
+ value: (0, _transformThemeValue).default(themeSection)(value)
108
108
  };
109
- }
110
-
111
- const [themeSection] = pathSegments;
112
- return {
113
- isValid: true,
114
- value: (0, _transformThemeValue.default)(themeSection)(value)
115
- };
116
109
  }
117
-
118
110
  function extractArgs(node, vNodes, functions) {
119
- vNodes = vNodes.map(vNode => resolveVNode(node, vNode, functions));
120
- let args = [''];
121
-
122
- for (let vNode of vNodes) {
123
- if (vNode.type === 'div' && vNode.value === ',') {
124
- args.push('');
125
- } else {
126
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
111
+ vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
112
+ );
113
+ let args = [
114
+ ''
115
+ ];
116
+ for (let vNode1 of vNodes){
117
+ if (vNode1.type === 'div' && vNode1.value === ',') {
118
+ args.push('');
119
+ } else {
120
+ args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
121
+ }
127
122
  }
128
- }
129
-
130
- return args;
123
+ return args;
131
124
  }
132
-
133
125
  function resolveVNode(node, vNode, functions) {
134
- if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
135
- let args = extractArgs(node, vNode.nodes, functions);
136
- vNode.type = 'word';
137
- vNode.value = functions[vNode.value](node, ...args);
138
- }
139
-
140
- return vNode;
126
+ if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
127
+ let args = extractArgs(node, vNode.nodes, functions);
128
+ vNode.type = 'word';
129
+ vNode.value = functions[vNode.value](node, ...args);
130
+ }
131
+ return vNode;
141
132
  }
142
-
143
133
  function resolveFunctions(node, input, functions) {
144
- return (0, _postcssValueParser.default)(input).walk(vNode => {
145
- resolveVNode(node, vNode, functions);
146
- }).toString();
134
+ return (0, _postcssValueParser).default(input).walk((vNode)=>{
135
+ resolveVNode(node, vNode, functions);
136
+ }).toString();
147
137
  }
148
-
149
138
  let nodeTypePropertyMap = {
150
- atrule: 'params',
151
- decl: 'value'
139
+ atrule: 'params',
140
+ decl: 'value'
152
141
  };
153
-
154
- function _default({
155
- tailwindConfig: config
156
- }) {
157
- let functions = {
158
- theme: (node, path, ...defaultValue) => {
159
- const {
160
- isValid,
161
- value,
162
- error
163
- } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
164
-
165
- if (!isValid) {
166
- throw node.error(error);
167
- }
168
-
169
- return value;
170
- },
171
- screen: (node, screen) => {
172
- screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
173
-
174
- if (config.theme.screens[screen] === undefined) {
175
- throw node.error(`The '${screen}' screen does not exist in your theme.`);
176
- }
177
-
178
- return (0, _buildMediaQuery.default)(config.theme.screens[screen]);
179
- }
180
- };
181
- return root => {
182
- root.walk(node => {
183
- let property = nodeTypePropertyMap[node.type];
184
-
185
- if (property === undefined) {
186
- return;
187
- }
188
-
189
- node[property] = resolveFunctions(node, node[property], functions);
190
- });
191
- };
192
- }
142
+ function _default({ tailwindConfig: config }) {
143
+ let functions = {
144
+ theme: (node, path, ...defaultValue)=>{
145
+ const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
146
+ if (!isValid) {
147
+ throw node.error(error);
148
+ }
149
+ return value;
150
+ },
151
+ screen: (node, screen)=>{
152
+ screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
153
+ let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
154
+ let screenDefinition = screens.find(({ name })=>name === screen
155
+ );
156
+ if (!screenDefinition) {
157
+ throw node.error(`The '${screen}' screen does not exist in your theme.`);
158
+ }
159
+ return (0, _buildMediaQuery).default(screenDefinition);
160
+ }
161
+ };
162
+ return (root)=>{
163
+ root.walk((node)=>{
164
+ let property = nodeTypePropertyMap[node.type];
165
+ if (property === undefined) {
166
+ return;
167
+ }
168
+ node[property] = resolveFunctions(node, node[property], functions);
169
+ });
170
+ };
171
+ }