tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd

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 (238) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +15 -7
  3. package/colors.d.ts +3 -0
  4. package/colors.js +2 -304
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -4
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -4
  9. package/lib/cli/build/deps.js +54 -0
  10. package/lib/cli/build/index.js +52 -0
  11. package/lib/cli/build/plugin.js +376 -0
  12. package/lib/cli/build/utils.js +78 -0
  13. package/lib/cli/build/watching.js +180 -0
  14. package/lib/cli/help/index.js +71 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +61 -0
  17. package/lib/cli-peer-dependencies.js +22 -14
  18. package/lib/cli.js +4 -762
  19. package/lib/corePluginList.js +182 -5
  20. package/lib/corePlugins.js +4109 -2952
  21. package/lib/css/preflight.css +24 -9
  22. package/lib/featureFlags.js +68 -50
  23. package/lib/index.js +5 -30
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +52 -36
  26. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  27. package/lib/lib/content.js +177 -0
  28. package/lib/lib/defaultExtractor.js +241 -0
  29. package/lib/lib/detectNesting.js +39 -17
  30. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  31. package/lib/lib/expandApplyAtRules.js +503 -221
  32. package/lib/lib/expandTailwindAtRules.js +255 -243
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +831 -317
  35. package/lib/lib/getModuleDependencies.js +93 -49
  36. package/lib/lib/load-config.js +36 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  38. package/lib/lib/offsets.js +304 -0
  39. package/lib/lib/partitionApplyAtRules.js +56 -0
  40. package/lib/lib/regex.js +60 -0
  41. package/lib/lib/remap-bitfield.js +87 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  43. package/lib/lib/setupContextUtils.js +1197 -685
  44. package/lib/lib/setupTrackingContext.js +150 -177
  45. package/lib/lib/sharedState.js +70 -21
  46. package/lib/lib/substituteScreenAtRules.js +26 -28
  47. package/lib/oxide/cli/build/deps.js +81 -0
  48. package/lib/oxide/cli/build/index.js +51 -0
  49. package/lib/oxide/cli/build/plugin.js +373 -0
  50. package/lib/oxide/cli/build/utils.js +77 -0
  51. package/lib/oxide/cli/build/watching.js +177 -0
  52. package/lib/oxide/cli/help/index.js +70 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +50 -0
  55. package/lib/oxide/cli.js +5 -0
  56. package/lib/oxide/postcss-plugin.js +2 -0
  57. package/lib/plugin.js +98 -0
  58. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  59. package/lib/postcss-plugins/nesting/index.js +19 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  61. package/lib/processTailwindFeatures.js +58 -56
  62. package/lib/public/colors.js +353 -0
  63. package/lib/public/create-plugin.js +15 -0
  64. package/lib/public/default-config.js +16 -0
  65. package/lib/public/default-theme.js +16 -0
  66. package/lib/public/load-config.js +10 -0
  67. package/lib/public/resolve-config.js +22 -0
  68. package/lib/util/applyImportantSelector.js +22 -0
  69. package/lib/util/bigSign.js +7 -6
  70. package/lib/util/buildMediaQuery.js +21 -32
  71. package/lib/util/cloneDeep.js +16 -14
  72. package/lib/util/cloneNodes.js +29 -15
  73. package/lib/util/color.js +104 -66
  74. package/lib/util/configurePlugins.js +17 -15
  75. package/lib/util/createPlugin.js +23 -26
  76. package/lib/util/createUtilityPlugin.js +46 -46
  77. package/lib/util/dataTypes.js +266 -0
  78. package/lib/util/defaults.js +20 -15
  79. package/lib/util/escapeClassName.js +18 -17
  80. package/lib/util/escapeCommas.js +7 -6
  81. package/lib/util/flattenColorPalette.js +13 -12
  82. package/lib/util/formatVariantSelector.js +341 -0
  83. package/lib/util/getAllConfigs.js +44 -18
  84. package/lib/util/hashConfig.js +15 -12
  85. package/lib/util/isKeyframeRule.js +7 -6
  86. package/lib/util/isPlainObject.js +11 -11
  87. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  88. package/lib/util/log.js +52 -33
  89. package/lib/util/nameClass.js +35 -29
  90. package/lib/util/negateValue.js +31 -17
  91. package/lib/util/normalizeConfig.js +294 -0
  92. package/lib/util/normalizeScreens.js +170 -0
  93. package/lib/util/parseAnimationValue.js +85 -54
  94. package/lib/util/parseBoxShadowValue.js +84 -0
  95. package/lib/util/parseDependency.js +41 -70
  96. package/lib/util/parseGlob.js +34 -0
  97. package/lib/util/parseObjectStyles.js +30 -24
  98. package/lib/util/pluginUtils.js +234 -288
  99. package/lib/util/prefixSelector.js +33 -19
  100. package/lib/util/removeAlphaVariables.js +29 -0
  101. package/lib/util/resolveConfig.js +221 -256
  102. package/lib/util/resolveConfigPath.js +55 -48
  103. package/lib/util/responsive.js +18 -14
  104. package/lib/util/splitAtTopLevelOnly.js +49 -0
  105. package/lib/util/tap.js +8 -7
  106. package/lib/util/toColorValue.js +7 -6
  107. package/lib/util/toPath.js +27 -8
  108. package/lib/util/transformThemeValue.js +67 -28
  109. package/lib/util/validateConfig.js +24 -0
  110. package/lib/util/validateFormalSyntax.js +24 -0
  111. package/lib/util/withAlphaVariable.js +67 -57
  112. package/loadConfig.d.ts +4 -0
  113. package/loadConfig.js +2 -0
  114. package/nesting/index.js +2 -12
  115. package/package.json +69 -66
  116. package/peers/index.js +76328 -84169
  117. package/plugin.d.ts +11 -0
  118. package/plugin.js +1 -2
  119. package/resolveConfig.d.ts +12 -0
  120. package/resolveConfig.js +2 -7
  121. package/scripts/create-plugin-list.js +2 -2
  122. package/scripts/generate-types.js +105 -0
  123. package/scripts/release-channel.js +18 -0
  124. package/scripts/release-notes.js +21 -0
  125. package/scripts/swap-engines.js +40 -0
  126. package/scripts/type-utils.js +27 -0
  127. package/src/cli/build/deps.js +56 -0
  128. package/src/cli/build/index.js +49 -0
  129. package/src/cli/build/plugin.js +444 -0
  130. package/src/cli/build/utils.js +76 -0
  131. package/src/cli/build/watching.js +229 -0
  132. package/src/cli/help/index.js +70 -0
  133. package/src/cli/index.js +216 -0
  134. package/src/cli/init/index.js +79 -0
  135. package/src/cli-peer-dependencies.js +7 -1
  136. package/src/cli.js +4 -756
  137. package/src/corePluginList.js +1 -1
  138. package/src/corePlugins.js +2526 -1956
  139. package/src/css/preflight.css +24 -9
  140. package/src/featureFlags.js +33 -10
  141. package/src/index.js +4 -33
  142. package/src/lib/cacheInvalidation.js +52 -0
  143. package/src/lib/collapseAdjacentRules.js +21 -2
  144. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  145. package/src/lib/content.js +208 -0
  146. package/src/lib/defaultExtractor.js +217 -0
  147. package/src/lib/detectNesting.js +30 -3
  148. package/src/lib/evaluateTailwindFunctions.js +84 -10
  149. package/src/lib/expandApplyAtRules.js +509 -153
  150. package/src/lib/expandTailwindAtRules.js +125 -104
  151. package/src/lib/findAtConfigPath.js +48 -0
  152. package/src/lib/generateRules.js +678 -70
  153. package/src/lib/getModuleDependencies.js +70 -30
  154. package/src/lib/load-config.ts +27 -0
  155. package/src/lib/normalizeTailwindDirectives.js +10 -3
  156. package/src/lib/offsets.js +373 -0
  157. package/src/lib/partitionApplyAtRules.js +52 -0
  158. package/src/lib/regex.js +74 -0
  159. package/src/lib/remap-bitfield.js +82 -0
  160. package/src/lib/resolveDefaultsAtRules.js +105 -47
  161. package/src/lib/setupContextUtils.js +848 -247
  162. package/src/lib/setupTrackingContext.js +53 -64
  163. package/src/lib/sharedState.js +60 -6
  164. package/src/lib/substituteScreenAtRules.js +6 -3
  165. package/src/oxide/cli/build/deps.ts +91 -0
  166. package/src/oxide/cli/build/index.ts +47 -0
  167. package/src/oxide/cli/build/plugin.ts +442 -0
  168. package/src/oxide/cli/build/utils.ts +74 -0
  169. package/src/oxide/cli/build/watching.ts +225 -0
  170. package/src/oxide/cli/help/index.ts +69 -0
  171. package/src/oxide/cli/index.ts +204 -0
  172. package/src/oxide/cli/init/index.ts +59 -0
  173. package/src/oxide/cli.ts +1 -0
  174. package/src/oxide/postcss-plugin.ts +1 -0
  175. package/src/plugin.js +107 -0
  176. package/src/postcss-plugins/nesting/README.md +42 -0
  177. package/src/postcss-plugins/nesting/index.js +13 -0
  178. package/src/postcss-plugins/nesting/plugin.js +80 -0
  179. package/src/processTailwindFeatures.js +18 -3
  180. package/src/public/colors.js +322 -0
  181. package/src/public/create-plugin.js +2 -0
  182. package/src/public/default-config.js +4 -0
  183. package/src/public/default-theme.js +4 -0
  184. package/src/public/load-config.js +2 -0
  185. package/src/public/resolve-config.js +7 -0
  186. package/src/util/applyImportantSelector.js +19 -0
  187. package/src/util/buildMediaQuery.js +14 -16
  188. package/src/util/cloneNodes.js +19 -2
  189. package/src/util/color.js +43 -11
  190. package/src/util/createUtilityPlugin.js +2 -11
  191. package/src/util/dataTypes.js +281 -0
  192. package/src/util/defaults.js +6 -0
  193. package/src/util/formatVariantSelector.js +412 -0
  194. package/src/util/getAllConfigs.js +21 -2
  195. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  196. package/src/util/log.js +23 -22
  197. package/src/util/nameClass.js +6 -2
  198. package/src/util/negateValue.js +15 -5
  199. package/src/util/normalizeConfig.js +318 -0
  200. package/src/util/normalizeScreens.js +140 -0
  201. package/src/util/parseAnimationValue.js +7 -1
  202. package/src/util/parseBoxShadowValue.js +72 -0
  203. package/src/util/parseDependency.js +37 -38
  204. package/src/util/parseGlob.js +24 -0
  205. package/src/util/pluginUtils.js +219 -219
  206. package/src/util/prefixSelector.js +30 -13
  207. package/src/util/removeAlphaVariables.js +24 -0
  208. package/src/util/resolveConfig.js +86 -91
  209. package/src/util/resolveConfigPath.js +12 -1
  210. package/src/util/splitAtTopLevelOnly.js +52 -0
  211. package/src/util/toPath.js +23 -1
  212. package/src/util/transformThemeValue.js +33 -8
  213. package/src/util/validateConfig.js +13 -0
  214. package/src/util/validateFormalSyntax.js +34 -0
  215. package/src/util/withAlphaVariable.js +14 -9
  216. package/stubs/.gitignore +1 -0
  217. package/stubs/.prettierrc.json +6 -0
  218. package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
  219. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  220. package/stubs/postcss.config.js +6 -0
  221. package/stubs/tailwind.config.cjs +2 -0
  222. package/stubs/tailwind.config.js +2 -0
  223. package/stubs/tailwind.config.ts +3 -0
  224. package/types/config.d.ts +373 -0
  225. package/types/generated/.gitkeep +0 -0
  226. package/types/generated/colors.d.ts +298 -0
  227. package/types/generated/corePluginList.d.ts +1 -0
  228. package/types/generated/default-theme.d.ts +347 -0
  229. package/types/index.d.ts +7 -0
  230. package/CHANGELOG.md +0 -1742
  231. package/lib/constants.js +0 -37
  232. package/lib/lib/setupWatchingContext.js +0 -331
  233. package/nesting/plugin.js +0 -41
  234. package/scripts/install-integrations.js +0 -27
  235. package/scripts/rebuildFixtures.js +0 -68
  236. package/src/constants.js +0 -17
  237. package/src/lib/setupWatchingContext.js +0 -307
  238. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -1,289 +1,254 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = resolveConfig;
7
-
8
- var _negateValue = _interopRequireDefault(require("./negateValue"));
9
-
10
- var _corePluginList = _interopRequireDefault(require("../corePluginList"));
11
-
12
- var _configurePlugins = _interopRequireDefault(require("./configurePlugins"));
13
-
14
- var _defaultConfig = _interopRequireDefault(require("../../stubs/defaultConfig.stub"));
15
-
16
- var _colors = _interopRequireDefault(require("../../colors"));
17
-
18
- var _log = _interopRequireDefault(require("./log"));
19
-
20
- var _defaults = require("./defaults");
21
-
22
- var _toPath = require("./toPath");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function isFunction(input) {
27
- return typeof input === 'function';
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>resolveConfig
8
+ });
9
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
10
+ const _corePluginList = /*#__PURE__*/ _interopRequireDefault(require("../corePluginList"));
11
+ const _configurePlugins = /*#__PURE__*/ _interopRequireDefault(require("./configurePlugins"));
12
+ const _colors = /*#__PURE__*/ _interopRequireDefault(require("../public/colors"));
13
+ const _defaults = require("./defaults");
14
+ const _toPath = require("./toPath");
15
+ const _normalizeConfig = require("./normalizeConfig");
16
+ const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("./isPlainObject"));
17
+ const _cloneDeep = require("./cloneDeep");
18
+ const _pluginUtils = require("./pluginUtils");
19
+ const _withAlphaVariable = require("./withAlphaVariable");
20
+ const _toColorValue = /*#__PURE__*/ _interopRequireDefault(require("./toColorValue"));
21
+ function _interopRequireDefault(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
28
25
  }
29
-
30
- function isObject(input) {
31
- return typeof input === 'object' && input !== null;
26
+ function isFunction(input) {
27
+ return typeof input === "function";
32
28
  }
33
-
34
29
  function mergeWith(target, ...sources) {
35
- let customizer = sources.pop();
36
-
37
- for (let source of sources) {
38
- for (let k in source) {
39
- let merged = customizer(target[k], source[k]);
40
-
41
- if (merged === undefined) {
42
- if (isObject(target[k]) && isObject(source[k])) {
43
- target[k] = mergeWith(target[k], source[k], customizer);
44
- } else {
45
- target[k] = source[k];
30
+ let customizer = sources.pop();
31
+ for (let source of sources){
32
+ for(let k in source){
33
+ let merged = customizer(target[k], source[k]);
34
+ if (merged === undefined) {
35
+ if ((0, _isPlainObject.default)(target[k]) && (0, _isPlainObject.default)(source[k])) {
36
+ target[k] = mergeWith({}, target[k], source[k], customizer);
37
+ } else {
38
+ target[k] = source[k];
39
+ }
40
+ } else {
41
+ target[k] = merged;
42
+ }
46
43
  }
47
- } else {
48
- target[k] = merged;
49
- }
50
44
  }
51
- }
52
-
53
- return target;
45
+ return target;
54
46
  }
55
-
56
47
  const configUtils = {
57
- colors: _colors.default,
58
-
59
- negative(scale) {
60
- return Object.keys(scale).filter(key => scale[key] !== '0').reduce((negativeScale, key) => ({ ...negativeScale,
61
- [`-${key}`]: (0, _negateValue.default)(scale[key])
62
- }), {});
63
- },
64
-
65
- breakpoints(screens) {
66
- return Object.keys(screens).filter(key => typeof screens[key] === 'string').reduce((breakpoints, key) => ({ ...breakpoints,
67
- [`screen-${key}`]: screens[key]
68
- }), {});
69
- }
70
-
48
+ colors: _colors.default,
49
+ negative (scale) {
50
+ // TODO: Log that this function isn't really needed anymore?
51
+ return Object.keys(scale).filter((key)=>scale[key] !== "0").reduce((negativeScale, key)=>{
52
+ let negativeValue = (0, _negateValue.default)(scale[key]);
53
+ if (negativeValue !== undefined) {
54
+ negativeScale[`-${key}`] = negativeValue;
55
+ }
56
+ return negativeScale;
57
+ }, {});
58
+ },
59
+ breakpoints (screens) {
60
+ return Object.keys(screens).filter((key)=>typeof screens[key] === "string").reduce((breakpoints, key)=>({
61
+ ...breakpoints,
62
+ [`screen-${key}`]: screens[key]
63
+ }), {});
64
+ }
71
65
  };
72
-
73
66
  function value(valueToResolve, ...args) {
74
- return isFunction(valueToResolve) ? valueToResolve(...args) : valueToResolve;
67
+ return isFunction(valueToResolve) ? valueToResolve(...args) : valueToResolve;
75
68
  }
76
-
77
69
  function collectExtends(items) {
78
- return items.reduce((merged, {
79
- extend
80
- }) => {
81
- return mergeWith(merged, extend, (mergedValue, extendValue) => {
82
- if (mergedValue === undefined) {
83
- return [extendValue];
84
- }
85
-
86
- if (Array.isArray(mergedValue)) {
87
- return [extendValue, ...mergedValue];
88
- }
89
-
90
- return [extendValue, mergedValue];
91
- });
92
- }, {});
70
+ return items.reduce((merged, { extend })=>{
71
+ return mergeWith(merged, extend, (mergedValue, extendValue)=>{
72
+ if (mergedValue === undefined) {
73
+ return [
74
+ extendValue
75
+ ];
76
+ }
77
+ if (Array.isArray(mergedValue)) {
78
+ return [
79
+ extendValue,
80
+ ...mergedValue
81
+ ];
82
+ }
83
+ return [
84
+ extendValue,
85
+ mergedValue
86
+ ];
87
+ });
88
+ }, {});
93
89
  }
94
-
95
90
  function mergeThemes(themes) {
96
- return { ...themes.reduce((merged, theme) => (0, _defaults.defaults)(merged, theme), {}),
97
- // In order to resolve n config objects, we combine all of their `extend` properties
98
- // into arrays instead of objects so they aren't overridden.
99
- extend: collectExtends(themes)
100
- };
91
+ return {
92
+ ...themes.reduce((merged, theme)=>(0, _defaults.defaults)(merged, theme), {}),
93
+ // In order to resolve n config objects, we combine all of their `extend` properties
94
+ // into arrays instead of objects so they aren't overridden.
95
+ extend: collectExtends(themes)
96
+ };
101
97
  }
102
-
103
98
  function mergeExtensionCustomizer(merged, value) {
104
- // When we have an array of objects, we do want to merge it
105
- if (Array.isArray(merged) && isObject(merged[0])) {
106
- return merged.concat(value);
107
- } // When the incoming value is an array, and the existing config is an object, prepend the existing object
108
-
109
-
110
- if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
111
- return [merged, ...value];
112
- } // Override arrays (for example for font-families, box-shadows, ...)
113
-
114
-
115
- if (Array.isArray(value)) {
116
- return value;
117
- } // Execute default behaviour
118
-
119
-
120
- return undefined;
99
+ // When we have an array of objects, we do want to merge it
100
+ if (Array.isArray(merged) && (0, _isPlainObject.default)(merged[0])) {
101
+ return merged.concat(value);
102
+ }
103
+ // When the incoming value is an array, and the existing config is an object, prepend the existing object
104
+ if (Array.isArray(value) && (0, _isPlainObject.default)(value[0]) && (0, _isPlainObject.default)(merged)) {
105
+ return [
106
+ merged,
107
+ ...value
108
+ ];
109
+ }
110
+ // Override arrays (for example for font-families, box-shadows, ...)
111
+ if (Array.isArray(value)) {
112
+ return value;
113
+ }
114
+ // Execute default behaviour
115
+ return undefined;
116
+ }
117
+ function mergeExtensions({ extend , ...theme }) {
118
+ return mergeWith(theme, extend, (themeValue, extensions)=>{
119
+ // The `extend` property is an array, so we need to check if it contains any functions
120
+ if (!isFunction(themeValue) && !extensions.some(isFunction)) {
121
+ return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
122
+ }
123
+ return (resolveThemePath, utils)=>mergeWith({}, ...[
124
+ themeValue,
125
+ ...extensions
126
+ ].map((e)=>value(e, resolveThemePath, utils)), mergeExtensionCustomizer);
127
+ });
121
128
  }
122
-
123
- function mergeExtensions({
124
- extend,
125
- ...theme
126
- }) {
127
- return mergeWith(theme, extend, (themeValue, extensions) => {
128
- // The `extend` property is an array, so we need to check if it contains any functions
129
- if (!isFunction(themeValue) && !extensions.some(isFunction)) {
130
- return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
129
+ /**
130
+ *
131
+ * @param {string} key
132
+ * @return {Iterable<string[] & {alpha: string | undefined}>}
133
+ */ function* toPaths(key) {
134
+ let path = (0, _toPath.toPath)(key);
135
+ if (path.length === 0) {
136
+ return;
137
+ }
138
+ yield path;
139
+ if (Array.isArray(key)) {
140
+ return;
141
+ }
142
+ let pattern = /^(.*?)\s*\/\s*([^/]+)$/;
143
+ let matches = key.match(pattern);
144
+ if (matches !== null) {
145
+ let [, prefix, alpha] = matches;
146
+ let newPath = (0, _toPath.toPath)(prefix);
147
+ newPath.alpha = alpha;
148
+ yield newPath;
131
149
  }
132
-
133
- return (resolveThemePath, utils) => mergeWith({}, ...[themeValue, ...extensions].map(e => value(e, resolveThemePath, utils)), mergeExtensionCustomizer);
134
- });
135
150
  }
136
-
137
151
  function resolveFunctionKeys(object) {
138
- const resolvePath = (key, defaultValue) => {
139
- const path = (0, _toPath.toPath)(key);
140
- let index = 0;
141
- let val = object;
142
-
143
- while (val !== undefined && val !== null && index < path.length) {
144
- val = val[path[index++]];
145
- val = isFunction(val) ? val(resolvePath, configUtils) : val;
146
- }
147
-
148
- return val === undefined ? defaultValue : val;
149
- };
150
-
151
- resolvePath.theme = resolvePath;
152
-
153
- for (let key in configUtils) {
154
- resolvePath[key] = configUtils[key];
155
- }
156
-
157
- return Object.keys(object).reduce((resolved, key) => {
158
- return { ...resolved,
159
- [key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
152
+ // theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
153
+ const resolvePath = (key, defaultValue)=>{
154
+ for (const path of toPaths(key)){
155
+ let index = 0;
156
+ let val = object;
157
+ while(val !== undefined && val !== null && index < path.length){
158
+ val = val[path[index++]];
159
+ let shouldResolveAsFn = isFunction(val) && (path.alpha === undefined || index <= path.length - 1);
160
+ val = shouldResolveAsFn ? val(resolvePath, configUtils) : val;
161
+ }
162
+ if (val !== undefined) {
163
+ if (path.alpha !== undefined) {
164
+ let normalized = (0, _pluginUtils.parseColorFormat)(val);
165
+ return (0, _withAlphaVariable.withAlphaValue)(normalized, path.alpha, (0, _toColorValue.default)(normalized));
166
+ }
167
+ if ((0, _isPlainObject.default)(val)) {
168
+ return (0, _cloneDeep.cloneDeep)(val);
169
+ }
170
+ return val;
171
+ }
172
+ }
173
+ return defaultValue;
160
174
  };
161
- }, {});
175
+ Object.assign(resolvePath, {
176
+ theme: resolvePath,
177
+ ...configUtils
178
+ });
179
+ return Object.keys(object).reduce((resolved, key)=>{
180
+ resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key];
181
+ return resolved;
182
+ }, {});
162
183
  }
163
-
164
184
  function extractPluginConfigs(configs) {
165
- let allConfigs = [];
166
- configs.forEach(config => {
167
- var _config$plugins;
168
-
169
- allConfigs = [...allConfigs, config];
170
- const plugins = (_config$plugins = config === null || config === void 0 ? void 0 : config.plugins) !== null && _config$plugins !== void 0 ? _config$plugins : [];
171
-
172
- if (plugins.length === 0) {
173
- return;
174
- }
175
-
176
- plugins.forEach(plugin => {
177
- var _plugin$config, _plugin;
178
-
179
- if (plugin.__isOptionsFunction) {
180
- plugin = plugin();
181
- }
182
-
183
- allConfigs = [...allConfigs, ...extractPluginConfigs([(_plugin$config = (_plugin = plugin) === null || _plugin === void 0 ? void 0 : _plugin.config) !== null && _plugin$config !== void 0 ? _plugin$config : {}])];
185
+ let allConfigs = [];
186
+ configs.forEach((config)=>{
187
+ allConfigs = [
188
+ ...allConfigs,
189
+ config
190
+ ];
191
+ var _config_plugins;
192
+ const plugins = (_config_plugins = config === null || config === void 0 ? void 0 : config.plugins) !== null && _config_plugins !== void 0 ? _config_plugins : [];
193
+ if (plugins.length === 0) {
194
+ return;
195
+ }
196
+ plugins.forEach((plugin)=>{
197
+ if (plugin.__isOptionsFunction) {
198
+ plugin = plugin();
199
+ }
200
+ var _plugin_config;
201
+ allConfigs = [
202
+ ...allConfigs,
203
+ ...extractPluginConfigs([
204
+ (_plugin_config = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && _plugin_config !== void 0 ? _plugin_config : {}
205
+ ])
206
+ ];
207
+ });
184
208
  });
185
- });
186
- return allConfigs;
209
+ return allConfigs;
187
210
  }
188
-
189
211
  function resolveCorePlugins(corePluginConfigs) {
190
- const result = [...corePluginConfigs].reduceRight((resolved, corePluginConfig) => {
191
- if (isFunction(corePluginConfig)) {
192
- return corePluginConfig({
193
- corePlugins: resolved
194
- });
195
- }
196
-
197
- return (0, _configurePlugins.default)(corePluginConfig, resolved);
198
- }, _corePluginList.default);
199
- return result;
212
+ const result = [
213
+ ...corePluginConfigs
214
+ ].reduceRight((resolved, corePluginConfig)=>{
215
+ if (isFunction(corePluginConfig)) {
216
+ return corePluginConfig({
217
+ corePlugins: resolved
218
+ });
219
+ }
220
+ return (0, _configurePlugins.default)(corePluginConfig, resolved);
221
+ }, _corePluginList.default);
222
+ return result;
200
223
  }
201
-
202
224
  function resolvePluginLists(pluginLists) {
203
- const result = [...pluginLists].reduceRight((resolved, pluginList) => {
204
- return [...resolved, ...pluginList];
205
- }, []);
206
- return result;
225
+ const result = [
226
+ ...pluginLists
227
+ ].reduceRight((resolved, pluginList)=>{
228
+ return [
229
+ ...resolved,
230
+ ...pluginList
231
+ ];
232
+ }, []);
233
+ return result;
207
234
  }
208
-
209
235
  function resolveConfig(configs) {
210
- let allConfigs = [...extractPluginConfigs(configs), {
211
- prefix: '',
212
- important: false,
213
- separator: ':',
214
- variantOrder: _defaultConfig.default.variantOrder
215
- }];
216
- return normalizeConfig((0, _defaults.defaults)({
217
- theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map(t => {
218
- var _t$theme;
219
-
220
- return (_t$theme = t === null || t === void 0 ? void 0 : t.theme) !== null && _t$theme !== void 0 ? _t$theme : {};
221
- })))),
222
- corePlugins: resolveCorePlugins(allConfigs.map(c => c.corePlugins)),
223
- plugins: resolvePluginLists(configs.map(c => {
224
- var _c$plugins;
225
-
226
- return (_c$plugins = c === null || c === void 0 ? void 0 : c.plugins) !== null && _c$plugins !== void 0 ? _c$plugins : [];
227
- }))
228
- }, ...allConfigs));
229
- }
230
-
231
- let warnedAbout = new Set();
232
-
233
- function normalizeConfig(config) {
234
- var _config$content, _config$purge, _config$content2, _config$purge2, _config$content3, _config$purge3;
235
-
236
- if (!warnedAbout.has('purge-deprecation') && config.hasOwnProperty('purge')) {
237
- _log.default.warn(['The `purge` option in your tailwind.config.js file has been deprecated.', 'Please rename this to `content` instead.']);
238
-
239
- warnedAbout.add('purge-deprecation');
240
- }
241
-
242
- config.content = {
243
- content: (() => {
244
- let {
245
- content,
246
- purge
247
- } = config;
248
- if (Array.isArray(purge)) return purge;
249
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
250
- if (Array.isArray(content)) return content;
251
- if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
252
- return [];
253
- })(),
254
- safelist: (() => {
255
- let {
256
- content,
257
- purge
258
- } = config;
259
-
260
- let [safelistKey, safelistPaths] = (() => {
261
- var _purge$options;
262
-
263
- if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return ['content.safelist', content.safelist];
264
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return ['purge.safelist', purge.safelist];
265
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : (_purge$options = purge.options) === null || _purge$options === void 0 ? void 0 : _purge$options.safelist)) return ['purge.options.safelist', purge.options.safelist];
266
- return [null, []];
267
- })();
268
-
269
- return safelistPaths.map(content => {
270
- if (typeof content === 'string') {
271
- return {
272
- raw: content,
273
- extension: 'html'
274
- };
275
- }
276
-
277
- if (content instanceof RegExp) {
278
- throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found 'regex'.`);
236
+ let allConfigs = [
237
+ ...extractPluginConfigs(configs),
238
+ {
239
+ prefix: "",
240
+ important: false,
241
+ separator: ":"
279
242
  }
280
-
281
- throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found '${typeof content}'.`);
282
- });
283
- })(),
284
- extract: ((_config$content = config.content) === null || _config$content === void 0 ? void 0 : _config$content.extract) || ((_config$purge = config.purge) === null || _config$purge === void 0 ? void 0 : _config$purge.extract) || {},
285
- options: ((_config$content2 = config.content) === null || _config$content2 === void 0 ? void 0 : _config$content2.options) || ((_config$purge2 = config.purge) === null || _config$purge2 === void 0 ? void 0 : _config$purge2.options) || {},
286
- transform: ((_config$content3 = config.content) === null || _config$content3 === void 0 ? void 0 : _config$content3.transform) || ((_config$purge3 = config.purge) === null || _config$purge3 === void 0 ? void 0 : _config$purge3.transform) || {}
287
- };
288
- return config;
289
- }
243
+ ];
244
+ var _t_theme, _c_plugins;
245
+ return (0, _normalizeConfig.normalizeConfig)((0, _defaults.defaults)({
246
+ theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
247
+ return (_t_theme = t === null || t === void 0 ? void 0 : t.theme) !== null && _t_theme !== void 0 ? _t_theme : {};
248
+ })))),
249
+ corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins)),
250
+ plugins: resolvePluginLists(configs.map((c)=>{
251
+ return (_c_plugins = c === null || c === void 0 ? void 0 : c.plugins) !== null && _c_plugins !== void 0 ? _c_plugins : [];
252
+ }))
253
+ }, ...allConfigs));
254
+ }
@@ -1,59 +1,66 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = resolveConfigPath;
7
-
8
- var _fs = _interopRequireDefault(require("fs"));
9
-
10
- var _path = _interopRequireDefault(require("path"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
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
+ default: ()=>resolveConfigPath,
13
+ resolveDefaultConfigPath: ()=>resolveDefaultConfigPath
14
+ });
15
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
16
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
17
+ function _interopRequireDefault(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ const defaultConfigFiles = [
23
+ "./tailwind.config.js",
24
+ "./tailwind.config.cjs",
25
+ "./tailwind.config.mjs",
26
+ "./tailwind.config.ts"
27
+ ];
14
28
  function isObject(value) {
15
- return typeof value === 'object' && value !== null;
29
+ return typeof value === "object" && value !== null;
16
30
  }
17
-
18
31
  function isEmpty(obj) {
19
- return Object.keys(obj).length === 0;
32
+ return Object.keys(obj).length === 0;
20
33
  }
21
-
22
34
  function isString(value) {
23
- return typeof value === 'string' || value instanceof String;
35
+ return typeof value === "string" || value instanceof String;
24
36
  }
25
-
26
37
  function resolveConfigPath(pathOrConfig) {
27
- // require('tailwindcss')({ theme: ..., variants: ... })
28
- if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
29
- return null;
30
- } // require('tailwindcss')({ config: 'custom-config.js' })
31
-
32
-
33
- if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isString(pathOrConfig.config)) {
34
- return _path.default.resolve(pathOrConfig.config);
35
- } // require('tailwindcss')({ config: { theme: ..., variants: ... } })
36
-
37
-
38
- if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isObject(pathOrConfig.config)) {
38
+ // require('tailwindcss')({ theme: ..., variants: ... })
39
+ if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
40
+ return null;
41
+ }
42
+ // require('tailwindcss')({ config: 'custom-config.js' })
43
+ if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isString(pathOrConfig.config)) {
44
+ return _path.default.resolve(pathOrConfig.config);
45
+ }
46
+ // require('tailwindcss')({ config: { theme: ..., variants: ... } })
47
+ if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isObject(pathOrConfig.config)) {
48
+ return null;
49
+ }
50
+ // require('tailwindcss')('custom-config.js')
51
+ if (isString(pathOrConfig)) {
52
+ return _path.default.resolve(pathOrConfig);
53
+ }
54
+ // require('tailwindcss')
55
+ return resolveDefaultConfigPath();
56
+ }
57
+ function resolveDefaultConfigPath() {
58
+ for (const configFile of defaultConfigFiles){
59
+ try {
60
+ const configPath = _path.default.resolve(configFile);
61
+ _fs.default.accessSync(configPath);
62
+ return configPath;
63
+ } catch (err) {}
64
+ }
39
65
  return null;
40
- } // require('tailwindcss')('custom-config.js')
41
-
42
-
43
- if (isString(pathOrConfig)) {
44
- return _path.default.resolve(pathOrConfig);
45
- } // require('tailwindcss')
46
-
47
-
48
- for (const configFile of ['./tailwind.config.js', './tailwind.config.cjs']) {
49
- try {
50
- const configPath = _path.default.resolve(configFile);
51
-
52
- _fs.default.accessSync(configPath);
53
-
54
- return configPath;
55
- } catch (err) {}
56
- }
57
-
58
- return null;
59
- }
66
+ }