tailwindcss 0.0.0-insiders.4e21639 → 0.0.0-insiders.4e62334

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 (157) hide show
  1. package/CHANGELOG.md +435 -3
  2. package/LICENSE +1 -2
  3. package/README.md +13 -6
  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 +4 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +20 -7
  11. package/lib/cli.js +460 -259
  12. package/lib/constants.js +27 -20
  13. package/lib/corePluginList.js +9 -3
  14. package/lib/corePlugins.js +1840 -1753
  15. package/lib/css/preflight.css +8 -9
  16. package/lib/featureFlags.js +29 -20
  17. package/lib/index.js +22 -11
  18. package/lib/lib/cacheInvalidation.js +90 -0
  19. package/lib/lib/collapseAdjacentRules.js +27 -9
  20. package/lib/lib/collapseDuplicateDeclarations.js +58 -4
  21. package/lib/lib/defaultExtractor.js +231 -0
  22. package/lib/lib/detectNesting.js +13 -10
  23. package/lib/lib/evaluateTailwindFunctions.js +119 -52
  24. package/lib/lib/expandApplyAtRules.js +440 -161
  25. package/lib/lib/expandTailwindAtRules.js +130 -128
  26. package/lib/lib/generateRules.js +410 -171
  27. package/lib/lib/getModuleDependencies.js +11 -8
  28. package/lib/lib/normalizeTailwindDirectives.js +43 -32
  29. package/lib/lib/offsets.js +199 -0
  30. package/lib/lib/partitionApplyAtRules.js +56 -0
  31. package/lib/lib/regex.js +60 -0
  32. package/lib/lib/resolveDefaultsAtRules.js +91 -55
  33. package/lib/lib/setupContextUtils.js +453 -347
  34. package/lib/lib/setupTrackingContext.js +52 -44
  35. package/lib/lib/sharedState.js +48 -9
  36. package/lib/lib/substituteScreenAtRules.js +13 -8
  37. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  38. package/lib/postcss-plugins/nesting/index.js +19 -0
  39. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  40. package/lib/processTailwindFeatures.js +36 -25
  41. package/lib/public/colors.js +247 -245
  42. package/lib/public/create-plugin.js +6 -4
  43. package/lib/public/default-config.js +7 -5
  44. package/lib/public/default-theme.js +7 -5
  45. package/lib/public/resolve-config.js +8 -5
  46. package/lib/util/bigSign.js +4 -1
  47. package/lib/util/buildMediaQuery.js +16 -25
  48. package/lib/util/cloneDeep.js +7 -6
  49. package/lib/util/cloneNodes.js +21 -3
  50. package/lib/util/color.js +54 -40
  51. package/lib/util/configurePlugins.js +4 -1
  52. package/lib/util/createPlugin.js +6 -6
  53. package/lib/util/createUtilityPlugin.js +12 -14
  54. package/lib/util/dataTypes.js +119 -102
  55. package/lib/util/defaults.js +10 -1
  56. package/lib/util/escapeClassName.js +7 -4
  57. package/lib/util/escapeCommas.js +5 -2
  58. package/lib/util/flattenColorPalette.js +9 -12
  59. package/lib/util/formatVariantSelector.js +223 -40
  60. package/lib/util/getAllConfigs.js +27 -8
  61. package/lib/util/hashConfig.js +6 -3
  62. package/lib/util/isKeyframeRule.js +5 -2
  63. package/lib/util/isPlainObject.js +5 -2
  64. package/lib/util/isValidArbitraryValue.js +72 -0
  65. package/lib/util/log.js +22 -12
  66. package/lib/util/nameClass.js +17 -8
  67. package/lib/util/negateValue.js +22 -7
  68. package/lib/util/normalizeConfig.js +99 -54
  69. package/lib/util/normalizeScreens.js +73 -0
  70. package/lib/util/parseAnimationValue.js +42 -40
  71. package/lib/util/parseBoxShadowValue.js +30 -23
  72. package/lib/util/parseDependency.js +18 -15
  73. package/lib/util/parseObjectStyles.js +10 -7
  74. package/lib/util/pluginUtils.js +51 -42
  75. package/lib/util/prefixSelector.js +10 -8
  76. package/lib/util/removeAlphaVariables.js +29 -0
  77. package/lib/util/resolveConfig.js +91 -66
  78. package/lib/util/resolveConfigPath.js +11 -9
  79. package/lib/util/responsive.js +8 -5
  80. package/lib/util/splitAtTopLevelOnly.js +43 -0
  81. package/lib/util/tap.js +4 -1
  82. package/lib/util/toColorValue.js +5 -3
  83. package/lib/util/toPath.js +24 -3
  84. package/lib/util/transformThemeValue.js +37 -29
  85. package/lib/util/validateConfig.js +24 -0
  86. package/lib/util/withAlphaVariable.js +23 -15
  87. package/nesting/index.js +2 -12
  88. package/package.json +43 -43
  89. package/peers/index.js +11543 -8114
  90. package/plugin.d.ts +11 -0
  91. package/plugin.js +2 -1
  92. package/resolveConfig.d.ts +3 -0
  93. package/resolveConfig.js +2 -1
  94. package/scripts/generate-types.js +105 -0
  95. package/scripts/type-utils.js +27 -0
  96. package/src/cli-peer-dependencies.js +7 -1
  97. package/src/cli.js +293 -36
  98. package/src/corePluginList.js +1 -1
  99. package/src/corePlugins.js +428 -285
  100. package/src/css/preflight.css +8 -9
  101. package/src/featureFlags.js +9 -5
  102. package/src/index.js +14 -6
  103. package/src/lib/cacheInvalidation.js +52 -0
  104. package/src/lib/collapseAdjacentRules.js +21 -2
  105. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  106. package/src/lib/defaultExtractor.js +208 -0
  107. package/src/lib/evaluateTailwindFunctions.js +84 -10
  108. package/src/lib/expandApplyAtRules.js +488 -153
  109. package/src/lib/expandTailwindAtRules.js +82 -80
  110. package/src/lib/generateRules.js +352 -120
  111. package/src/lib/normalizeTailwindDirectives.js +7 -1
  112. package/src/lib/offsets.js +239 -0
  113. package/src/lib/partitionApplyAtRules.js +52 -0
  114. package/src/lib/regex.js +74 -0
  115. package/src/lib/resolveDefaultsAtRules.js +59 -17
  116. package/src/lib/setupContextUtils.js +337 -174
  117. package/src/lib/setupTrackingContext.js +13 -8
  118. package/src/lib/sharedState.js +42 -4
  119. package/src/lib/substituteScreenAtRules.js +6 -3
  120. package/src/postcss-plugins/nesting/README.md +42 -0
  121. package/src/postcss-plugins/nesting/index.js +13 -0
  122. package/src/postcss-plugins/nesting/plugin.js +80 -0
  123. package/src/processTailwindFeatures.js +12 -2
  124. package/src/util/buildMediaQuery.js +14 -18
  125. package/src/util/cloneNodes.js +19 -2
  126. package/src/util/color.js +31 -14
  127. package/src/util/dataTypes.js +28 -19
  128. package/src/util/defaults.js +6 -0
  129. package/src/util/formatVariantSelector.js +237 -23
  130. package/src/util/getAllConfigs.js +19 -0
  131. package/src/util/isValidArbitraryValue.js +61 -0
  132. package/src/util/log.js +11 -7
  133. package/src/util/nameClass.js +1 -1
  134. package/src/util/negateValue.js +10 -2
  135. package/src/util/normalizeConfig.js +16 -3
  136. package/src/util/normalizeScreens.js +45 -0
  137. package/src/util/parseBoxShadowValue.js +4 -3
  138. package/src/util/pluginUtils.js +14 -2
  139. package/src/util/prefixSelector.js +7 -5
  140. package/src/util/removeAlphaVariables.js +24 -0
  141. package/src/util/resolveConfig.js +71 -17
  142. package/src/util/splitAtTopLevelOnly.js +45 -0
  143. package/src/util/toPath.js +23 -1
  144. package/src/util/transformThemeValue.js +13 -3
  145. package/src/util/validateConfig.js +13 -0
  146. package/src/util/withAlphaVariable.js +1 -1
  147. package/stubs/defaultConfig.stub.js +24 -3
  148. package/stubs/simpleConfig.stub.js +1 -0
  149. package/types/config.d.ts +334 -0
  150. package/types/generated/.gitkeep +0 -0
  151. package/types/generated/colors.d.ts +276 -0
  152. package/types/generated/corePluginList.d.ts +1 -0
  153. package/types/generated/default-theme.d.ts +331 -0
  154. package/types/index.d.ts +7 -0
  155. package/lib/lib/setupWatchingContext.js +0 -288
  156. package/nesting/plugin.js +0 -41
  157. package/src/lib/setupWatchingContext.js +0 -311
package/plugin.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { Config, PluginCreator } from './types/config'
2
+ type Plugin = {
3
+ withOptions<T>(
4
+ plugin: (options: T) => PluginCreator,
5
+ config?: (options: T) => Config
6
+ ): { (options: T): { handler: PluginCreator; config?: Config }; __isOptionsFunction: true }
7
+ (plugin: PluginCreator, config?: Config): { handler: PluginCreator; config?: Config }
8
+ }
9
+
10
+ declare const plugin: Plugin
11
+ export = plugin
package/plugin.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/create-plugin').default
1
+ let createPlugin = require('./lib/public/create-plugin')
2
+ module.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default
@@ -0,0 +1,3 @@
1
+ import type { Config } from './types/config'
2
+ declare function resolveConfig(config: Config): Config
3
+ export = resolveConfig
package/resolveConfig.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/resolve-config').default
1
+ let resolveConfig = require('./lib/public/resolve-config')
2
+ module.exports = (resolveConfig.__esModule ? resolveConfig : { default: resolveConfig }).default
@@ -0,0 +1,105 @@
1
+ import prettier from 'prettier'
2
+ import { corePlugins } from '../src/corePlugins'
3
+ import colors from '../src/public/colors'
4
+ import defaultTheme from '../src/public/default-theme'
5
+ import fs from 'fs'
6
+ import path from 'path'
7
+ import * as types from './type-utils'
8
+
9
+ fs.writeFileSync(
10
+ path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
11
+ `export type CorePluginList = ${Object.keys(corePlugins)
12
+ .map((p) => `'${p}'`)
13
+ .join(' | ')}`
14
+ )
15
+
16
+ let colorsWithoutDeprecatedColors = Object.fromEntries(
17
+ Object.entries(Object.getOwnPropertyDescriptors(colors))
18
+ .filter(([_, { value }]) => {
19
+ return typeof value !== 'undefined'
20
+ })
21
+ .map(([name, definition]) => [name, definition.value])
22
+ )
23
+
24
+ let deprecatedColors = Object.entries(Object.getOwnPropertyDescriptors(colors))
25
+ .filter(([_, { value }]) => {
26
+ return typeof value === 'undefined'
27
+ })
28
+ .map(([name, definition]) => {
29
+ let warn = console.warn
30
+ let messages = []
31
+ console.warn = (...args) => messages.push(args.pop())
32
+ definition.get()
33
+ console.warn = warn
34
+ let message = messages.join(' ').trim()
35
+ let newColor = message.match(/renamed to `(.*)`/)[1]
36
+ return `/** @deprecated ${message} */${name}: DefaultColors['${newColor}'],`
37
+ })
38
+ .join('\n')
39
+
40
+ fs.writeFileSync(
41
+ path.join(process.cwd(), 'types', 'generated', 'colors.d.ts'),
42
+ prettier.format(
43
+ `export interface DefaultColors { ${JSON.stringify(colorsWithoutDeprecatedColors).slice(
44
+ 1,
45
+ -1
46
+ )}\n${deprecatedColors}\n}`,
47
+ {
48
+ semi: false,
49
+ singleQuote: true,
50
+ printWidth: 100,
51
+ parser: 'typescript',
52
+ }
53
+ )
54
+ )
55
+
56
+ const defaultThemeTypes = Object.entries(defaultTheme)
57
+ .map(([name, value]) => {
58
+ // Special cases for slightly more accurate types
59
+ if (name === 'keyframes') {
60
+ return [name, `Record<${types.forKeys(value)}, Record<string, CSSDeclarationList>>`]
61
+ }
62
+
63
+ if (name === 'fontSize') {
64
+ return [name, `Record<${types.forKeys(value)}, [string, { lineHeight: string }]>`]
65
+ }
66
+
67
+ // General cases
68
+ if (typeof value === 'string') {
69
+ return [name, `string`]
70
+ }
71
+
72
+ if (typeof value === 'function') {
73
+ return [name, null]
74
+ }
75
+
76
+ if (typeof value === 'object') {
77
+ if (Object.keys(value).length === 0) {
78
+ return [name, null]
79
+ }
80
+
81
+ return [name, types.forValue(value)]
82
+ }
83
+
84
+ return [name, `unknown`]
85
+ })
86
+ .filter(([, type]) => type !== null)
87
+ .map(([name, type]) => `${name}: ${type}`)
88
+ .join('\n')
89
+
90
+ fs.writeFileSync(
91
+ path.join(process.cwd(), 'types', 'generated', 'default-theme.d.ts'),
92
+ prettier.format(
93
+ `
94
+ import { Config } from '../../types'
95
+ type CSSDeclarationList = Record<string, string>
96
+ export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} }
97
+ `,
98
+ {
99
+ semi: false,
100
+ singleQuote: true,
101
+ printWidth: 100,
102
+ parser: 'typescript',
103
+ }
104
+ )
105
+ )
@@ -0,0 +1,27 @@
1
+ export function union(types) {
2
+ return [...new Set(types)].join(' | ')
3
+ }
4
+
5
+ export function unionValues(values) {
6
+ return union(values.map(forValue))
7
+ }
8
+
9
+ export function forKeys(value) {
10
+ return union(Object.keys(value).map((key) => `'${key}'`))
11
+ }
12
+
13
+ export function forValue(value) {
14
+ if (Array.isArray(value)) {
15
+ return `(${unionValues(value)})[]`
16
+ }
17
+
18
+ if (typeof value === 'object') {
19
+ return `Record<${forKeys(value)}, ${unionValues(Object.values(value))}>`
20
+ }
21
+
22
+ if (typeof value === 'string') {
23
+ return `string`
24
+ }
25
+
26
+ return `any`
27
+ }
@@ -1,4 +1,10 @@
1
- export let postcss = require('postcss')
1
+ export function lazyPostcss() {
2
+ return require('postcss')
3
+ }
4
+
5
+ export function lazyPostcssImport() {
6
+ return require('postcss-import')
7
+ }
2
8
 
3
9
  export function lazyAutoprefixer() {
4
10
  return require('autoprefixer')