tailwindcss 0.0.0-insiders.d2b53cd → 0.0.0-insiders.d2fdf9e

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 (143) hide show
  1. package/CHANGELOG.md +364 -2
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +306 -203
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +10 -1
  14. package/lib/corePlugins.js +1835 -1760
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +18 -15
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +145 -126
  26. package/lib/lib/generateRules.js +403 -103
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +43 -35
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +83 -65
  32. package/lib/lib/setupContextUtils.js +315 -204
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -5
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +19 -9
  40. package/lib/public/colors.js +241 -241
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +11 -15
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +11 -7
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +4 -4
  62. package/lib/util/normalizeConfig.js +84 -45
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +34 -165
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +115 -66
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +39 -40
  81. package/peers/index.js +11511 -10819
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/generate-types.js +52 -0
  86. package/src/cli-peer-dependencies.js +7 -1
  87. package/src/cli.js +164 -30
  88. package/src/corePluginList.js +1 -1
  89. package/src/corePlugins.js +540 -535
  90. package/src/css/preflight.css +19 -13
  91. package/src/featureFlags.js +5 -5
  92. package/src/index.js +14 -6
  93. package/src/lib/cacheInvalidation.js +52 -0
  94. package/src/lib/collapseAdjacentRules.js +21 -2
  95. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  96. package/src/lib/defaultExtractor.js +192 -0
  97. package/src/lib/detectNesting.js +22 -3
  98. package/src/lib/evaluateTailwindFunctions.js +24 -7
  99. package/src/lib/expandApplyAtRules.js +442 -154
  100. package/src/lib/expandTailwindAtRules.js +79 -37
  101. package/src/lib/generateRules.js +400 -83
  102. package/src/lib/normalizeTailwindDirectives.js +7 -1
  103. package/src/lib/partitionApplyAtRules.js +52 -0
  104. package/src/lib/regex.js +74 -0
  105. package/src/lib/resolveDefaultsAtRules.js +35 -10
  106. package/src/lib/setupContextUtils.js +273 -112
  107. package/src/lib/setupTrackingContext.js +12 -7
  108. package/src/lib/sharedState.js +42 -4
  109. package/src/lib/substituteScreenAtRules.js +6 -3
  110. package/src/postcss-plugins/nesting/README.md +42 -0
  111. package/src/postcss-plugins/nesting/index.js +13 -0
  112. package/src/postcss-plugins/nesting/plugin.js +80 -0
  113. package/src/processTailwindFeatures.js +14 -2
  114. package/src/util/buildMediaQuery.js +14 -18
  115. package/src/util/cloneNodes.js +14 -1
  116. package/src/util/color.js +31 -14
  117. package/src/util/dataTypes.js +56 -16
  118. package/src/util/defaults.js +6 -0
  119. package/src/util/formatVariantSelector.js +213 -0
  120. package/src/util/getAllConfigs.js +7 -0
  121. package/src/util/isValidArbitraryValue.js +61 -0
  122. package/src/util/log.js +10 -6
  123. package/src/util/nameClass.js +1 -1
  124. package/src/util/normalizeConfig.js +32 -3
  125. package/src/util/normalizeScreens.js +45 -0
  126. package/src/util/parseBoxShadowValue.js +72 -0
  127. package/src/util/pluginUtils.js +15 -138
  128. package/src/util/prefixSelector.js +7 -8
  129. package/src/util/resolveConfig.js +97 -15
  130. package/src/util/splitAtTopLevelOnly.js +71 -0
  131. package/src/util/toPath.js +23 -1
  132. package/src/util/transformThemeValue.js +24 -7
  133. package/src/util/validateConfig.js +13 -0
  134. package/stubs/defaultConfig.stub.js +47 -17
  135. package/types/config.d.ts +325 -0
  136. package/types/generated/.gitkeep +0 -0
  137. package/types/generated/colors.d.ts +276 -0
  138. package/types/generated/corePluginList.d.ts +1 -0
  139. package/types/index.d.ts +1 -0
  140. package/types.d.ts +1 -0
  141. package/lib/lib/setupWatchingContext.js +0 -284
  142. package/nesting/plugin.js +0 -41
  143. package/src/lib/setupWatchingContext.js +0 -304
@@ -7,42 +7,44 @@ var _dlv = _interopRequireDefault(require("dlv"));
7
7
  var _didyoumean = _interopRequireDefault(require("didyoumean"));
8
8
  var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
9
9
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
10
+ var _normalizeScreens = require("../util/normalizeScreens");
10
11
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
11
12
  var _toPath = require("../util/toPath");
13
+ var _withAlphaVariable = require("../util/withAlphaVariable");
12
14
  function _interopRequireDefault(obj) {
13
15
  return obj && obj.__esModule ? obj : {
14
16
  default: obj
15
17
  };
16
18
  }
17
19
  function isObject(input) {
18
- return typeof input === 'object' && input !== null;
20
+ return typeof input === "object" && input !== null;
19
21
  }
20
22
  function findClosestExistingPath(theme, path) {
21
23
  let parts = (0, _toPath).toPath(path);
22
24
  do {
23
25
  parts.pop();
24
26
  if ((0, _dlv).default(theme, parts) !== undefined) break;
25
- }while (parts.length)
27
+ }while (parts.length);
26
28
  return parts.length ? parts : undefined;
27
29
  }
28
30
  function pathToString(path) {
29
- if (typeof path === 'string') return path;
31
+ if (typeof path === "string") return path;
30
32
  return path.reduce((acc, cur, i)=>{
31
- if (cur.includes('.')) return `${acc}[${cur}]`;
33
+ if (cur.includes(".")) return `${acc}[${cur}]`;
32
34
  return i === 0 ? cur : `${acc}.${cur}`;
33
- }, '');
35
+ }, "");
34
36
  }
35
37
  function list(items) {
36
38
  return items.map((key)=>`'${key}'`
37
- ).join(', ');
39
+ ).join(", ");
38
40
  }
39
41
  function listKeys(obj) {
40
42
  return list(Object.keys(obj));
41
43
  }
42
- function validatePath(config, path, defaultValue) {
43
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
44
+ function validatePath(config, path, defaultValue, themeOpts = {}) {
45
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
44
46
  const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
45
- const value = (0, _dlv).default(config.theme, pathString, defaultValue);
47
+ const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
46
48
  if (value === undefined) {
47
49
  let error = `'${pathString}' does not exist in your theme config.`;
48
50
  const parentSegments = pathSegments.slice(0, -1);
@@ -80,7 +82,7 @@ function validatePath(config, path, defaultValue) {
80
82
  error
81
83
  };
82
84
  }
83
- if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
85
+ if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
84
86
  let error = `'${pathString}' was found but does not resolve to a string.`;
85
87
  if (isObject(value)) {
86
88
  let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
@@ -103,28 +105,28 @@ function validatePath(config, path, defaultValue) {
103
105
  const [themeSection] = pathSegments;
104
106
  return {
105
107
  isValid: true,
106
- value: (0, _transformThemeValue).default(themeSection)(value)
108
+ value: (0, _transformThemeValue).default(themeSection)(value, themeOpts)
107
109
  };
108
110
  }
109
111
  function extractArgs(node, vNodes, functions) {
110
112
  vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
111
113
  );
112
114
  let args = [
113
- ''
115
+ ""
114
116
  ];
115
- for (let vNode of vNodes){
116
- if (vNode.type === 'div' && vNode.value === ',') {
117
- args.push('');
117
+ for (let vNode1 of vNodes){
118
+ if (vNode1.type === "div" && vNode1.value === ",") {
119
+ args.push("");
118
120
  } else {
119
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
121
+ args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
120
122
  }
121
123
  }
122
124
  return args;
123
125
  }
124
126
  function resolveVNode(node, vNode, functions) {
125
- if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
127
+ if (vNode.type === "function" && functions[vNode.value] !== undefined) {
126
128
  let args = extractArgs(node, vNode.nodes, functions);
127
- vNode.type = 'word';
129
+ vNode.type = "word";
128
130
  vNode.value = functions[vNode.value](node, ...args);
129
131
  }
130
132
  return vNode;
@@ -135,24 +137,38 @@ function resolveFunctions(node, input, functions) {
135
137
  }).toString();
136
138
  }
137
139
  let nodeTypePropertyMap = {
138
- atrule: 'params',
139
- decl: 'value'
140
+ atrule: "params",
141
+ decl: "value"
140
142
  };
141
143
  function _default({ tailwindConfig: config }) {
142
144
  let functions = {
143
145
  theme: (node, path, ...defaultValue)=>{
144
- const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
146
+ let matches = path.match(/^([^\/\s]+)(?:\s*\/\s*([^\/\s]+))$/);
147
+ let alpha = undefined;
148
+ if (matches) {
149
+ path = matches[1];
150
+ alpha = matches[2];
151
+ }
152
+ let { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined, {
153
+ opacityValue: alpha
154
+ });
145
155
  if (!isValid) {
146
156
  throw node.error(error);
147
157
  }
158
+ if (alpha !== undefined) {
159
+ value = (0, _withAlphaVariable).withAlphaValue(value, alpha, value);
160
+ }
148
161
  return value;
149
162
  },
150
163
  screen: (node, screen)=>{
151
- screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
152
- if (config.theme.screens[screen] === undefined) {
164
+ screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
165
+ let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
166
+ let screenDefinition = screens.find(({ name })=>name === screen
167
+ );
168
+ if (!screenDefinition) {
153
169
  throw node.error(`The '${screen}' screen does not exist in your theme.`);
154
170
  }
155
- return (0, _buildMediaQuery).default(config.theme.screens[screen]);
171
+ return (0, _buildMediaQuery).default(screenDefinition);
156
172
  }
157
173
  };
158
174
  return (root)=>{