tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a

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 (190) hide show
  1. package/CHANGELOG.md +526 -2
  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/build/deps.js +54 -0
  11. package/lib/cli/build/index.js +44 -0
  12. package/lib/cli/build/plugin.js +335 -0
  13. package/lib/cli/build/utils.js +78 -0
  14. package/lib/cli/build/watching.js +113 -0
  15. package/lib/cli/help/index.js +71 -0
  16. package/lib/cli/index.js +18 -0
  17. package/lib/cli/init/index.js +46 -0
  18. package/lib/cli/shared.js +12 -0
  19. package/lib/cli-peer-dependencies.js +20 -7
  20. package/lib/cli.js +91 -569
  21. package/lib/constants.js +27 -20
  22. package/lib/corePluginList.js +16 -4
  23. package/lib/corePlugins.js +2247 -1873
  24. package/lib/css/preflight.css +20 -9
  25. package/lib/featureFlags.js +37 -23
  26. package/lib/index.js +28 -12
  27. package/lib/lib/cacheInvalidation.js +90 -0
  28. package/lib/lib/collapseAdjacentRules.js +27 -9
  29. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  30. package/lib/lib/content.js +167 -0
  31. package/lib/lib/defaultExtractor.js +236 -0
  32. package/lib/lib/detectNesting.js +21 -3
  33. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  34. package/lib/lib/expandApplyAtRules.js +439 -160
  35. package/lib/lib/expandTailwindAtRules.js +141 -151
  36. package/lib/lib/findAtConfigPath.js +44 -0
  37. package/lib/lib/generateRules.js +572 -105
  38. package/lib/lib/getModuleDependencies.js +11 -8
  39. package/lib/lib/normalizeTailwindDirectives.js +45 -33
  40. package/lib/lib/offsets.js +217 -0
  41. package/lib/lib/partitionApplyAtRules.js +56 -0
  42. package/lib/lib/regex.js +60 -0
  43. package/lib/lib/resolveDefaultsAtRules.js +114 -81
  44. package/lib/lib/setupContextUtils.js +777 -385
  45. package/lib/lib/setupTrackingContext.js +43 -71
  46. package/lib/lib/sharedState.js +49 -18
  47. package/lib/lib/substituteScreenAtRules.js +13 -8
  48. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  49. package/lib/postcss-plugins/nesting/index.js +19 -0
  50. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  51. package/lib/processTailwindFeatures.js +36 -21
  52. package/lib/public/colors.js +250 -252
  53. package/lib/public/create-plugin.js +6 -4
  54. package/lib/public/default-config.js +7 -5
  55. package/lib/public/default-theme.js +7 -5
  56. package/lib/public/resolve-config.js +8 -5
  57. package/lib/util/bigSign.js +4 -1
  58. package/lib/util/buildMediaQuery.js +18 -24
  59. package/lib/util/cloneDeep.js +7 -6
  60. package/lib/util/cloneNodes.js +21 -3
  61. package/lib/util/color.js +54 -40
  62. package/lib/util/configurePlugins.js +5 -2
  63. package/lib/util/createPlugin.js +6 -6
  64. package/lib/util/createUtilityPlugin.js +11 -13
  65. package/lib/util/dataTypes.js +137 -100
  66. package/lib/util/defaults.js +10 -1
  67. package/lib/util/escapeClassName.js +7 -4
  68. package/lib/util/escapeCommas.js +5 -2
  69. package/lib/util/flattenColorPalette.js +9 -12
  70. package/lib/util/formatVariantSelector.js +285 -0
  71. package/lib/util/getAllConfigs.js +27 -8
  72. package/lib/util/hashConfig.js +6 -3
  73. package/lib/util/isKeyframeRule.js +5 -2
  74. package/lib/util/isPlainObject.js +5 -2
  75. package/lib/util/isValidArbitraryValue.js +72 -0
  76. package/lib/util/log.js +44 -22
  77. package/lib/util/nameClass.js +20 -8
  78. package/lib/util/negateValue.js +23 -6
  79. package/lib/util/normalizeConfig.js +267 -0
  80. package/lib/util/normalizeScreens.js +170 -0
  81. package/lib/util/parseAnimationValue.js +42 -40
  82. package/lib/util/parseBoxShadowValue.js +84 -0
  83. package/lib/util/parseDependency.js +38 -56
  84. package/lib/util/parseGlob.js +34 -0
  85. package/lib/util/parseObjectStyles.js +11 -8
  86. package/lib/util/pluginUtils.js +171 -189
  87. package/lib/util/prefixSelector.js +10 -10
  88. package/lib/util/removeAlphaVariables.js +29 -0
  89. package/lib/util/resolveConfig.js +92 -126
  90. package/lib/util/resolveConfigPath.js +11 -9
  91. package/lib/util/responsive.js +8 -5
  92. package/lib/util/splitAtTopLevelOnly.js +43 -0
  93. package/lib/util/tap.js +4 -1
  94. package/lib/util/toColorValue.js +5 -3
  95. package/lib/util/toPath.js +24 -3
  96. package/lib/util/transformThemeValue.js +49 -31
  97. package/lib/util/validateConfig.js +24 -0
  98. package/lib/util/validateFormalSyntax.js +24 -0
  99. package/lib/util/withAlphaVariable.js +23 -15
  100. package/nesting/index.js +2 -12
  101. package/package.json +48 -46
  102. package/peers/index.js +14817 -12471
  103. package/plugin.d.ts +11 -0
  104. package/plugin.js +2 -1
  105. package/resolveConfig.d.ts +3 -0
  106. package/resolveConfig.js +2 -1
  107. package/scripts/create-plugin-list.js +2 -2
  108. package/scripts/generate-types.js +105 -0
  109. package/scripts/release-channel.js +18 -0
  110. package/scripts/release-notes.js +21 -0
  111. package/scripts/type-utils.js +27 -0
  112. package/src/cli/build/deps.js +56 -0
  113. package/src/cli/build/index.js +45 -0
  114. package/src/cli/build/plugin.js +397 -0
  115. package/src/cli/build/utils.js +76 -0
  116. package/src/cli/build/watching.js +134 -0
  117. package/src/cli/help/index.js +70 -0
  118. package/src/cli/index.js +3 -0
  119. package/src/cli/init/index.js +50 -0
  120. package/src/cli/shared.js +5 -0
  121. package/src/cli-peer-dependencies.js +7 -1
  122. package/src/cli.js +26 -565
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +905 -615
  125. package/src/css/preflight.css +20 -9
  126. package/src/featureFlags.js +26 -10
  127. package/src/index.js +19 -6
  128. package/src/lib/cacheInvalidation.js +52 -0
  129. package/src/lib/collapseAdjacentRules.js +21 -2
  130. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  131. package/src/lib/content.js +205 -0
  132. package/src/lib/defaultExtractor.js +211 -0
  133. package/src/lib/detectNesting.js +22 -3
  134. package/src/lib/evaluateTailwindFunctions.js +84 -10
  135. package/src/lib/expandApplyAtRules.js +488 -153
  136. package/src/lib/expandTailwindAtRules.js +94 -106
  137. package/src/lib/findAtConfigPath.js +50 -0
  138. package/src/lib/generateRules.js +589 -67
  139. package/src/lib/normalizeTailwindDirectives.js +10 -3
  140. package/src/lib/offsets.js +270 -0
  141. package/src/lib/partitionApplyAtRules.js +52 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/resolveDefaultsAtRules.js +98 -60
  144. package/src/lib/setupContextUtils.js +737 -246
  145. package/src/lib/setupTrackingContext.js +16 -54
  146. package/src/lib/sharedState.js +44 -7
  147. package/src/lib/substituteScreenAtRules.js +6 -3
  148. package/src/postcss-plugins/nesting/README.md +42 -0
  149. package/src/postcss-plugins/nesting/index.js +13 -0
  150. package/src/postcss-plugins/nesting/plugin.js +80 -0
  151. package/src/processTailwindFeatures.js +17 -2
  152. package/src/public/colors.js +4 -9
  153. package/src/util/buildMediaQuery.js +14 -16
  154. package/src/util/cloneNodes.js +19 -2
  155. package/src/util/color.js +31 -14
  156. package/src/util/createUtilityPlugin.js +2 -2
  157. package/src/util/dataTypes.js +57 -21
  158. package/src/util/defaults.js +6 -0
  159. package/src/util/formatVariantSelector.js +319 -0
  160. package/src/util/getAllConfigs.js +19 -0
  161. package/src/util/isValidArbitraryValue.js +61 -0
  162. package/src/util/log.js +23 -22
  163. package/src/util/nameClass.js +6 -2
  164. package/src/util/negateValue.js +14 -4
  165. package/src/util/normalizeConfig.js +282 -0
  166. package/src/util/normalizeScreens.js +140 -0
  167. package/src/util/parseBoxShadowValue.js +72 -0
  168. package/src/util/parseDependency.js +37 -42
  169. package/src/util/parseGlob.js +24 -0
  170. package/src/util/pluginUtils.js +144 -152
  171. package/src/util/prefixSelector.js +7 -8
  172. package/src/util/removeAlphaVariables.js +24 -0
  173. package/src/util/resolveConfig.js +82 -81
  174. package/src/util/splitAtTopLevelOnly.js +45 -0
  175. package/src/util/toPath.js +23 -1
  176. package/src/util/transformThemeValue.js +33 -8
  177. package/src/util/validateConfig.js +13 -0
  178. package/src/util/validateFormalSyntax.js +34 -0
  179. package/src/util/withAlphaVariable.js +1 -1
  180. package/stubs/defaultConfig.stub.js +173 -93
  181. package/stubs/simpleConfig.stub.js +1 -1
  182. package/types/config.d.ts +361 -0
  183. package/types/generated/.gitkeep +0 -0
  184. package/types/generated/colors.d.ts +276 -0
  185. package/types/generated/corePluginList.d.ts +1 -0
  186. package/types/generated/default-theme.d.ts +342 -0
  187. package/types/index.d.ts +7 -0
  188. package/lib/lib/setupWatchingContext.js +0 -284
  189. package/nesting/plugin.js +0 -41
  190. package/src/lib/setupWatchingContext.js +0 -306
@@ -0,0 +1,342 @@
1
+ import { Config } from '../../types'
2
+ type CSSDeclarationList = Record<string, string>
3
+ export type DefaultTheme = Config['theme'] & {
4
+ screens: Record<'sm' | 'md' | 'lg' | 'xl' | '2xl', string>
5
+ columns: Record<
6
+ | '1'
7
+ | '2'
8
+ | '3'
9
+ | '4'
10
+ | '5'
11
+ | '6'
12
+ | '7'
13
+ | '8'
14
+ | '9'
15
+ | '10'
16
+ | '11'
17
+ | '12'
18
+ | 'auto'
19
+ | '3xs'
20
+ | '2xs'
21
+ | 'xs'
22
+ | 'sm'
23
+ | 'md'
24
+ | 'lg'
25
+ | 'xl'
26
+ | '2xl'
27
+ | '3xl'
28
+ | '4xl'
29
+ | '5xl'
30
+ | '6xl'
31
+ | '7xl',
32
+ string
33
+ >
34
+ spacing: Record<
35
+ | '0'
36
+ | '1'
37
+ | '2'
38
+ | '3'
39
+ | '4'
40
+ | '5'
41
+ | '6'
42
+ | '7'
43
+ | '8'
44
+ | '9'
45
+ | '10'
46
+ | '11'
47
+ | '12'
48
+ | '14'
49
+ | '16'
50
+ | '20'
51
+ | '24'
52
+ | '28'
53
+ | '32'
54
+ | '36'
55
+ | '40'
56
+ | '44'
57
+ | '48'
58
+ | '52'
59
+ | '56'
60
+ | '60'
61
+ | '64'
62
+ | '72'
63
+ | '80'
64
+ | '96'
65
+ | 'px'
66
+ | '0.5'
67
+ | '1.5'
68
+ | '2.5'
69
+ | '3.5',
70
+ string
71
+ >
72
+ animation: Record<'none' | 'spin' | 'ping' | 'pulse' | 'bounce', string>
73
+ aria: Record<
74
+ | 'checked'
75
+ | 'disabled'
76
+ | 'expanded'
77
+ | 'hidden'
78
+ | 'pressed'
79
+ | 'readonly'
80
+ | 'required'
81
+ | 'selected',
82
+ string
83
+ >
84
+ aspectRatio: Record<'auto' | 'square' | 'video', string>
85
+ backgroundImage: Record<
86
+ | 'none'
87
+ | 'gradient-to-t'
88
+ | 'gradient-to-tr'
89
+ | 'gradient-to-r'
90
+ | 'gradient-to-br'
91
+ | 'gradient-to-b'
92
+ | 'gradient-to-bl'
93
+ | 'gradient-to-l'
94
+ | 'gradient-to-tl',
95
+ string
96
+ >
97
+ backgroundPosition: Record<
98
+ | 'bottom'
99
+ | 'center'
100
+ | 'left'
101
+ | 'left-bottom'
102
+ | 'left-top'
103
+ | 'right'
104
+ | 'right-bottom'
105
+ | 'right-top'
106
+ | 'top',
107
+ string
108
+ >
109
+ backgroundSize: Record<'auto' | 'cover' | 'contain', string>
110
+ blur: Record<'0' | 'none' | 'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | '3xl', string>
111
+ brightness: Record<
112
+ '0' | '50' | '75' | '90' | '95' | '100' | '105' | '110' | '125' | '150' | '200',
113
+ string
114
+ >
115
+ borderRadius: Record<
116
+ 'none' | 'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full',
117
+ string
118
+ >
119
+ borderWidth: Record<'0' | '2' | '4' | '8' | 'DEFAULT', string>
120
+ boxShadow: Record<'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | 'inner' | 'none', string>
121
+ contrast: Record<'0' | '50' | '75' | '100' | '125' | '150' | '200', string>
122
+ content: Record<'none', string>
123
+ cursor: Record<
124
+ | 'auto'
125
+ | 'default'
126
+ | 'pointer'
127
+ | 'wait'
128
+ | 'text'
129
+ | 'move'
130
+ | 'help'
131
+ | 'not-allowed'
132
+ | 'none'
133
+ | 'context-menu'
134
+ | 'progress'
135
+ | 'cell'
136
+ | 'crosshair'
137
+ | 'vertical-text'
138
+ | 'alias'
139
+ | 'copy'
140
+ | 'no-drop'
141
+ | 'grab'
142
+ | 'grabbing'
143
+ | 'all-scroll'
144
+ | 'col-resize'
145
+ | 'row-resize'
146
+ | 'n-resize'
147
+ | 'e-resize'
148
+ | 's-resize'
149
+ | 'w-resize'
150
+ | 'ne-resize'
151
+ | 'nw-resize'
152
+ | 'se-resize'
153
+ | 'sw-resize'
154
+ | 'ew-resize'
155
+ | 'ns-resize'
156
+ | 'nesw-resize'
157
+ | 'nwse-resize'
158
+ | 'zoom-in'
159
+ | 'zoom-out',
160
+ string
161
+ >
162
+ dropShadow: Record<'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | 'none', string | string[]>
163
+ grayscale: Record<'0' | 'DEFAULT', string>
164
+ hueRotate: Record<'0' | '15' | '30' | '60' | '90' | '180', string>
165
+ invert: Record<'0' | 'DEFAULT', string>
166
+ flex: Record<'1' | 'auto' | 'initial' | 'none', string>
167
+ flexGrow: Record<'0' | 'DEFAULT', string>
168
+ flexShrink: Record<'0' | 'DEFAULT', string>
169
+ fontFamily: Record<'sans' | 'serif' | 'mono', string[]>
170
+ fontSize: Record<
171
+ | 'xs'
172
+ | 'sm'
173
+ | 'base'
174
+ | 'lg'
175
+ | 'xl'
176
+ | '2xl'
177
+ | '3xl'
178
+ | '4xl'
179
+ | '5xl'
180
+ | '6xl'
181
+ | '7xl'
182
+ | '8xl'
183
+ | '9xl',
184
+ [string, { lineHeight: string }]
185
+ >
186
+ fontWeight: Record<
187
+ | 'thin'
188
+ | 'extralight'
189
+ | 'light'
190
+ | 'normal'
191
+ | 'medium'
192
+ | 'semibold'
193
+ | 'bold'
194
+ | 'extrabold'
195
+ | 'black',
196
+ string
197
+ >
198
+ gridAutoColumns: Record<'auto' | 'min' | 'max' | 'fr', string>
199
+ gridAutoRows: Record<'auto' | 'min' | 'max' | 'fr', string>
200
+ gridColumn: Record<
201
+ | 'auto'
202
+ | 'span-1'
203
+ | 'span-2'
204
+ | 'span-3'
205
+ | 'span-4'
206
+ | 'span-5'
207
+ | 'span-6'
208
+ | 'span-7'
209
+ | 'span-8'
210
+ | 'span-9'
211
+ | 'span-10'
212
+ | 'span-11'
213
+ | 'span-12'
214
+ | 'span-full',
215
+ string
216
+ >
217
+ gridColumnEnd: Record<
218
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | 'auto',
219
+ string
220
+ >
221
+ gridColumnStart: Record<
222
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | 'auto',
223
+ string
224
+ >
225
+ gridRow: Record<
226
+ 'auto' | 'span-1' | 'span-2' | 'span-3' | 'span-4' | 'span-5' | 'span-6' | 'span-full',
227
+ string
228
+ >
229
+ gridRowStart: Record<'1' | '2' | '3' | '4' | '5' | '6' | '7' | 'auto', string>
230
+ gridRowEnd: Record<'1' | '2' | '3' | '4' | '5' | '6' | '7' | 'auto', string>
231
+ gridTemplateColumns: Record<
232
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | 'none',
233
+ string
234
+ >
235
+ gridTemplateRows: Record<'1' | '2' | '3' | '4' | '5' | '6' | 'none', string>
236
+ keyframes: Record<'spin' | 'ping' | 'pulse' | 'bounce', Record<string, CSSDeclarationList>>
237
+ letterSpacing: Record<'tighter' | 'tight' | 'normal' | 'wide' | 'wider' | 'widest', string>
238
+ lineHeight: Record<
239
+ | '3'
240
+ | '4'
241
+ | '5'
242
+ | '6'
243
+ | '7'
244
+ | '8'
245
+ | '9'
246
+ | '10'
247
+ | 'none'
248
+ | 'tight'
249
+ | 'snug'
250
+ | 'normal'
251
+ | 'relaxed'
252
+ | 'loose',
253
+ string
254
+ >
255
+ listStyleType: Record<'none' | 'disc' | 'decimal', string>
256
+ minHeight: Record<'0' | 'full' | 'screen' | 'min' | 'max' | 'fit', string>
257
+ minWidth: Record<'0' | 'full' | 'min' | 'max' | 'fit', string>
258
+ objectPosition: Record<
259
+ | 'bottom'
260
+ | 'center'
261
+ | 'left'
262
+ | 'left-bottom'
263
+ | 'left-top'
264
+ | 'right'
265
+ | 'right-bottom'
266
+ | 'right-top'
267
+ | 'top',
268
+ string
269
+ >
270
+ opacity: Record<
271
+ | '0'
272
+ | '5'
273
+ | '10'
274
+ | '20'
275
+ | '25'
276
+ | '30'
277
+ | '40'
278
+ | '50'
279
+ | '60'
280
+ | '70'
281
+ | '75'
282
+ | '80'
283
+ | '90'
284
+ | '95'
285
+ | '100',
286
+ string
287
+ >
288
+ order: Record<
289
+ | '1'
290
+ | '2'
291
+ | '3'
292
+ | '4'
293
+ | '5'
294
+ | '6'
295
+ | '7'
296
+ | '8'
297
+ | '9'
298
+ | '10'
299
+ | '11'
300
+ | '12'
301
+ | 'first'
302
+ | 'last'
303
+ | 'none',
304
+ string
305
+ >
306
+ outlineOffset: Record<'0' | '1' | '2' | '4' | '8', string>
307
+ outlineWidth: Record<'0' | '1' | '2' | '4' | '8', string>
308
+ ringOffsetWidth: Record<'0' | '1' | '2' | '4' | '8', string>
309
+ ringWidth: Record<'0' | '1' | '2' | '4' | '8' | 'DEFAULT', string>
310
+ rotate: Record<'0' | '1' | '2' | '3' | '6' | '12' | '45' | '90' | '180', string>
311
+ saturate: Record<'0' | '50' | '100' | '150' | '200', string>
312
+ scale: Record<'0' | '50' | '75' | '90' | '95' | '100' | '105' | '110' | '125' | '150', string>
313
+ sepia: Record<'0' | 'DEFAULT', string>
314
+ skew: Record<'0' | '1' | '2' | '3' | '6' | '12', string>
315
+ strokeWidth: Record<'0' | '1' | '2', string>
316
+ textDecorationThickness: Record<'0' | '1' | '2' | '4' | '8' | 'auto' | 'from-font', string>
317
+ textUnderlineOffset: Record<'0' | '1' | '2' | '4' | '8' | 'auto', string>
318
+ transformOrigin: Record<
319
+ | 'center'
320
+ | 'top'
321
+ | 'top-right'
322
+ | 'right'
323
+ | 'bottom-right'
324
+ | 'bottom'
325
+ | 'bottom-left'
326
+ | 'left'
327
+ | 'top-left',
328
+ string
329
+ >
330
+ transitionDelay: Record<'75' | '100' | '150' | '200' | '300' | '500' | '700' | '1000', string>
331
+ transitionDuration: Record<
332
+ '75' | '100' | '150' | '200' | '300' | '500' | '700' | '1000' | 'DEFAULT',
333
+ string
334
+ >
335
+ transitionProperty: Record<
336
+ 'none' | 'all' | 'DEFAULT' | 'colors' | 'opacity' | 'shadow' | 'transform',
337
+ string
338
+ >
339
+ transitionTimingFunction: Record<'DEFAULT' | 'linear' | 'in' | 'out' | 'in-out', string>
340
+ willChange: Record<'auto' | 'scroll' | 'contents' | 'transform', string>
341
+ zIndex: Record<'0' | '10' | '20' | '30' | '40' | '50' | 'auto', string>
342
+ }
@@ -0,0 +1,7 @@
1
+ import { PluginCreator } from 'postcss'
2
+ import type { Config } from './config.d'
3
+
4
+ declare const plugin: PluginCreator<string | Config | { config: string | Config }>
5
+
6
+ export { Config }
7
+ export default plugin
@@ -1,284 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = setupWatchingContext;
6
- var _fs = _interopRequireDefault(require("fs"));
7
- var _path = _interopRequireDefault(require("path"));
8
- var _tmp = _interopRequireDefault(require("tmp"));
9
- var _chokidar = _interopRequireDefault(require("chokidar"));
10
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
11
- var _quickLru = _interopRequireDefault(require("quick-lru"));
12
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
13
- var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
14
- var _log = _interopRequireDefault(require("../util/log"));
15
- var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
16
- var _resolveConfig = _interopRequireDefault(require("../public/resolve-config"));
17
- var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
18
- var _setupContextUtils = require("./setupContextUtils");
19
- function _interopRequireDefault(obj) {
20
- return obj && obj.__esModule ? obj : {
21
- default: obj
22
- };
23
- }
24
- // This is used to trigger rebuilds. Just updating the timestamp
25
- // is significantly faster than actually writing to the file (10x).
26
- function touch(filename) {
27
- let time = new Date();
28
- try {
29
- _fs.default.utimesSync(filename, time, time);
30
- } catch (err) {
31
- _fs.default.closeSync(_fs.default.openSync(filename, 'w'));
32
- }
33
- }
34
- let watchers = new WeakMap();
35
- function getWatcher(context) {
36
- if (watchers.has(context)) {
37
- return watchers.get(context);
38
- }
39
- return null;
40
- }
41
- function setWatcher(context, watcher) {
42
- return watchers.set(context, watcher);
43
- }
44
- let touchFiles = new WeakMap();
45
- function getTouchFile(context) {
46
- if (touchFiles.has(context)) {
47
- return touchFiles.get(context);
48
- }
49
- return null;
50
- }
51
- function setTouchFile(context, touchFile) {
52
- return touchFiles.set(context, touchFile);
53
- }
54
- let configPaths = new WeakMap();
55
- function getConfigPath(context, configOrPath) {
56
- if (!configPaths.has(context)) {
57
- configPaths.set(context, (0, _resolveConfigPath).default(configOrPath));
58
- }
59
- return configPaths.get(context);
60
- }
61
- function rebootWatcher(context, configPath, configDependencies, candidateFiles) {
62
- let touchFile = getTouchFile(context);
63
- if (touchFile === null) {
64
- touchFile = _tmp.default.fileSync().name;
65
- setTouchFile(context, touchFile);
66
- touch(touchFile);
67
- }
68
- let watcher = getWatcher(context);
69
- Promise.resolve(watcher ? watcher.close() : null).then(()=>{
70
- _log.default.info([
71
- 'Tailwind CSS is watching for changes...',
72
- 'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds',
73
- ]);
74
- watcher = _chokidar.default.watch([
75
- ...candidateFiles,
76
- ...configDependencies
77
- ], {
78
- ignoreInitial: true
79
- });
80
- setWatcher(context, watcher);
81
- watcher.on('add', (file)=>{
82
- let changedFile = _path.default.resolve('.', file);
83
- let content = _fs.default.readFileSync(changedFile, 'utf8');
84
- let extension = _path.default.extname(changedFile).slice(1);
85
- context.changedContent.push({
86
- content,
87
- extension
88
- });
89
- touch(touchFile);
90
- });
91
- watcher.on('change', (file)=>{
92
- // If it was a config dependency, touch the config file to trigger a new context.
93
- // This is not really that clean of a solution but it's the fastest, because we
94
- // can do a very quick check on each build to see if the config has changed instead
95
- // of having to get all of the module dependencies and check every timestamp each
96
- // time.
97
- if (configDependencies.has(file)) {
98
- for (let dependency of configDependencies){
99
- delete require.cache[require.resolve(dependency)];
100
- }
101
- touch(configPath);
102
- } else {
103
- let changedFile = _path.default.resolve('.', file);
104
- let content = _fs.default.readFileSync(changedFile, 'utf8');
105
- let extension = _path.default.extname(changedFile).slice(1);
106
- context.changedContent.push({
107
- content,
108
- extension
109
- });
110
- touch(touchFile);
111
- }
112
- });
113
- watcher.on('unlink', (file)=>{
114
- // Touch the config file if any of the dependencies are deleted.
115
- if (configDependencies.has(file)) {
116
- for (let dependency of configDependencies){
117
- delete require.cache[require.resolve(dependency)];
118
- }
119
- touch(configPath);
120
- }
121
- });
122
- });
123
- }
124
- let configPathCache = new _quickLru.default({
125
- maxSize: 100
126
- });
127
- let configDependenciesCache = new WeakMap();
128
- function getConfigDependencies(context) {
129
- if (!configDependenciesCache.has(context)) {
130
- configDependenciesCache.set(context, new Set());
131
- }
132
- return configDependenciesCache.get(context);
133
- }
134
- let candidateFilesCache = new WeakMap();
135
- function getCandidateFiles(context, tailwindConfig) {
136
- if (candidateFilesCache.has(context)) {
137
- return candidateFilesCache.get(context);
138
- }
139
- let candidateFiles = tailwindConfig.content.content.filter((item)=>typeof item === 'string'
140
- ).map((contentPath)=>(0, _normalizePath).default(contentPath)
141
- );
142
- return candidateFilesCache.set(context, candidateFiles).get(context);
143
- }
144
- // Get the config object based on a path
145
- function getTailwindConfig(configOrPath) {
146
- let userConfigPath = (0, _resolveConfigPath).default(configOrPath);
147
- if (userConfigPath !== null) {
148
- let [prevConfig, prevModified = -Infinity, prevConfigHash] = configPathCache.get(userConfigPath) || [];
149
- let modified = _fs.default.statSync(userConfigPath).mtimeMs;
150
- // It hasn't changed (based on timestamp)
151
- if (modified <= prevModified) {
152
- return [
153
- prevConfig,
154
- userConfigPath,
155
- prevConfigHash,
156
- [
157
- userConfigPath
158
- ]
159
- ];
160
- }
161
- // It has changed (based on timestamp), or first run
162
- delete require.cache[userConfigPath];
163
- let newConfig = (0, _resolveConfig).default(require(userConfigPath));
164
- let newHash = (0, _hashConfig).default(newConfig);
165
- configPathCache.set(userConfigPath, [
166
- newConfig,
167
- modified,
168
- newHash
169
- ]);
170
- return [
171
- newConfig,
172
- userConfigPath,
173
- newHash,
174
- [
175
- userConfigPath
176
- ]
177
- ];
178
- }
179
- // It's a plain object, not a path
180
- let newConfig = (0, _resolveConfig).default(configOrPath.config === undefined ? configOrPath : configOrPath.config);
181
- return [
182
- newConfig,
183
- null,
184
- (0, _hashConfig).default(newConfig),
185
- []
186
- ];
187
- }
188
- function resolvedChangedContent(context, candidateFiles) {
189
- let changedContent = context.tailwindConfig.content.content.filter((item)=>typeof item.raw === 'string'
190
- ).concat(context.tailwindConfig.content.safelist).concat(context.safelist()).map(({ raw , extension })=>({
191
- content: raw,
192
- extension
193
- })
194
- );
195
- for (let changedFile of resolveChangedFiles(context, candidateFiles)){
196
- let content = _fs.default.readFileSync(changedFile, 'utf8');
197
- let extension = _path.default.extname(changedFile).slice(1);
198
- changedContent.push({
199
- content,
200
- extension
201
- });
202
- }
203
- return changedContent;
204
- }
205
- let scannedContentCache = new WeakMap();
206
- function resolveChangedFiles(context, candidateFiles) {
207
- let changedFiles = new Set();
208
- // If we're not set up and watching files ourselves, we need to do
209
- // the work of grabbing all of the template files for candidate
210
- // detection.
211
- if (!scannedContentCache.has(context)) {
212
- let files = _fastGlob.default.sync(candidateFiles);
213
- for (let file of files){
214
- changedFiles.add(file);
215
- }
216
- scannedContentCache.set(context, true);
217
- }
218
- return changedFiles;
219
- }
220
- function setupWatchingContext(configOrPath) {
221
- return ({ tailwindDirectives , registerDependency })=>{
222
- return (root, result)=>{
223
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
224
- let contextDependencies = new Set(configDependencies);
225
- // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
226
- // to be dependencies of the context. Can reuse the context even if they change.
227
- // We may want to think about `@layer` being part of this trigger too, but it's tough
228
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
229
- // in another file since independent sources are effectively isolated.
230
- if (tailwindDirectives.size > 0) {
231
- // Add current css file as a context dependencies.
232
- contextDependencies.add(result.opts.from);
233
- // Add all css @import dependencies as context dependencies.
234
- for (let message of result.messages){
235
- if (message.type === 'dependency') {
236
- contextDependencies.add(message.file);
237
- }
238
- }
239
- }
240
- let [context, isNewContext] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
241
- let candidateFiles = getCandidateFiles(context, tailwindConfig);
242
- let contextConfigDependencies = getConfigDependencies(context);
243
- for (let file of configDependencies){
244
- registerDependency({
245
- type: 'dependency',
246
- file
247
- });
248
- }
249
- context.disposables.push((oldContext)=>{
250
- let watcher = getWatcher(oldContext);
251
- if (watcher !== null) {
252
- watcher.close();
253
- }
254
- });
255
- let configPath = getConfigPath(context, configOrPath);
256
- if (configPath !== null) {
257
- for (let dependency of (0, _getModuleDependencies).default(configPath)){
258
- if (dependency.file === configPath) {
259
- continue;
260
- }
261
- contextConfigDependencies.add(dependency.file);
262
- }
263
- }
264
- if (isNewContext) {
265
- rebootWatcher(context, configPath, contextConfigDependencies, candidateFiles);
266
- }
267
- // Register our temp file as a dependency — we write to this file
268
- // to trigger rebuilds.
269
- let touchFile = getTouchFile(context);
270
- if (touchFile) {
271
- registerDependency({
272
- type: 'dependency',
273
- file: touchFile
274
- });
275
- }
276
- if (tailwindDirectives.size > 0) {
277
- for (let changedContent of resolvedChangedContent(context, candidateFiles)){
278
- context.changedContent.push(changedContent);
279
- }
280
- }
281
- return context;
282
- };
283
- };
284
- }
package/nesting/plugin.js DELETED
@@ -1,41 +0,0 @@
1
- let postcss = require('postcss')
2
- let postcssNested = require('postcss-nested')
3
-
4
- module.exports = function nesting(opts = postcssNested) {
5
- return (root, result) => {
6
- root.walkAtRules('screen', (rule) => {
7
- rule.name = 'media'
8
- rule.params = `screen(${rule.params})`
9
- })
10
-
11
- root.walkAtRules('apply', (rule) => {
12
- rule.before(postcss.decl({ prop: '__apply', value: rule.params, source: rule.source }))
13
- rule.remove()
14
- })
15
-
16
- let plugin = (() => {
17
- if (typeof opts === 'function') {
18
- return opts
19
- }
20
-
21
- if (typeof opts === 'string') {
22
- return require(opts)
23
- }
24
-
25
- if (Object.keys(opts).length <= 0) {
26
- return postcssNested
27
- }
28
-
29
- throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.')
30
- })()
31
-
32
- postcss([plugin]).process(root, result.opts).sync()
33
-
34
- root.walkDecls('__apply', (decl) => {
35
- decl.before(postcss.atRule({ name: 'apply', params: decl.value, source: decl.source }))
36
- decl.remove()
37
- })
38
-
39
- return root
40
- }
41
- }