tailwindcss 0.0.0-insiders.bb4f5da → 0.0.0-insiders.bbc2f3f

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 (215) hide show
  1. package/README.md +16 -13
  2. package/dist/chunk-5C7JPVMO.mjs +10 -0
  3. package/dist/chunk-AZANAYY2.mjs +1 -0
  4. package/dist/chunk-V2K3XTS4.mjs +1 -0
  5. package/dist/colors-b_6i0Oi7.d.ts +295 -0
  6. package/dist/colors.d.mts +295 -0
  7. package/dist/colors.d.ts +5 -0
  8. package/dist/colors.js +1 -0
  9. package/dist/colors.mjs +1 -0
  10. package/dist/default-theme.d.mts +1147 -0
  11. package/dist/default-theme.d.ts +1147 -0
  12. package/dist/default-theme.js +1 -0
  13. package/dist/default-theme.mjs +1 -0
  14. package/dist/flatten-color-palette.d.mts +6 -0
  15. package/dist/flatten-color-palette.d.ts +6 -0
  16. package/dist/flatten-color-palette.js +1 -0
  17. package/dist/flatten-color-palette.mjs +1 -0
  18. package/dist/lib.d.mts +260 -0
  19. package/dist/lib.d.ts +3 -0
  20. package/dist/lib.js +33 -0
  21. package/dist/lib.mjs +24 -0
  22. package/dist/plugin.d.mts +11 -0
  23. package/dist/plugin.d.ts +104 -0
  24. package/dist/plugin.js +1 -0
  25. package/dist/plugin.mjs +1 -0
  26. package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
  27. package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
  28. package/dist/types-B254mqw1.d.mts +98 -0
  29. package/index.css +865 -0
  30. package/package.json +73 -98
  31. package/preflight.css +383 -0
  32. package/theme.css +453 -0
  33. package/CHANGELOG.md +0 -2130
  34. package/base.css +0 -1
  35. package/colors.d.ts +0 -3
  36. package/colors.js +0 -2
  37. package/components.css +0 -1
  38. package/defaultConfig.d.ts +0 -3
  39. package/defaultConfig.js +0 -2
  40. package/defaultTheme.d.ts +0 -3
  41. package/defaultTheme.js +0 -2
  42. package/lib/cli-peer-dependencies.js +0 -16
  43. package/lib/cli.js +0 -798
  44. package/lib/constants.js +0 -37
  45. package/lib/corePluginList.js +0 -179
  46. package/lib/corePlugins.js +0 -3634
  47. package/lib/css/LICENSE +0 -25
  48. package/lib/css/preflight.css +0 -360
  49. package/lib/featureFlags.js +0 -59
  50. package/lib/index.js +0 -41
  51. package/lib/lib/cacheInvalidation.js +0 -69
  52. package/lib/lib/collapseAdjacentRules.js +0 -57
  53. package/lib/lib/collapseDuplicateDeclarations.js +0 -80
  54. package/lib/lib/defaultExtractor.js +0 -171
  55. package/lib/lib/detectNesting.js +0 -34
  56. package/lib/lib/evaluateTailwindFunctions.js +0 -171
  57. package/lib/lib/expandApplyAtRules.js +0 -485
  58. package/lib/lib/expandTailwindAtRules.js +0 -262
  59. package/lib/lib/generateRules.js +0 -672
  60. package/lib/lib/getModuleDependencies.js +0 -48
  61. package/lib/lib/normalizeTailwindDirectives.js +0 -84
  62. package/lib/lib/partitionApplyAtRules.js +0 -53
  63. package/lib/lib/regex.js +0 -53
  64. package/lib/lib/resolveDefaultsAtRules.js +0 -143
  65. package/lib/lib/setupContextUtils.js +0 -908
  66. package/lib/lib/setupTrackingContext.js +0 -174
  67. package/lib/lib/sharedState.js +0 -52
  68. package/lib/lib/substituteScreenAtRules.js +0 -27
  69. package/lib/postcss-plugins/nesting/README.md +0 -42
  70. package/lib/postcss-plugins/nesting/index.js +0 -17
  71. package/lib/postcss-plugins/nesting/plugin.js +0 -85
  72. package/lib/processTailwindFeatures.js +0 -59
  73. package/lib/public/colors.js +0 -329
  74. package/lib/public/create-plugin.js +0 -13
  75. package/lib/public/default-config.js +0 -14
  76. package/lib/public/default-theme.js +0 -14
  77. package/lib/public/resolve-config.js +0 -19
  78. package/lib/util/bigSign.js +0 -8
  79. package/lib/util/buildMediaQuery.js +0 -20
  80. package/lib/util/cloneDeep.js +0 -19
  81. package/lib/util/cloneNodes.js +0 -25
  82. package/lib/util/color.js +0 -95
  83. package/lib/util/configurePlugins.js +0 -18
  84. package/lib/util/createPlugin.js +0 -29
  85. package/lib/util/createUtilityPlugin.js +0 -49
  86. package/lib/util/dataTypes.js +0 -242
  87. package/lib/util/defaults.js +0 -22
  88. package/lib/util/escapeClassName.js +0 -19
  89. package/lib/util/escapeCommas.js +0 -8
  90. package/lib/util/flattenColorPalette.js +0 -17
  91. package/lib/util/formatVariantSelector.js +0 -196
  92. package/lib/util/getAllConfigs.js +0 -29
  93. package/lib/util/hashConfig.js +0 -16
  94. package/lib/util/isKeyframeRule.js +0 -8
  95. package/lib/util/isPlainObject.js +0 -12
  96. package/lib/util/isValidArbitraryValue.js +0 -64
  97. package/lib/util/log.js +0 -51
  98. package/lib/util/nameClass.js +0 -32
  99. package/lib/util/negateValue.js +0 -19
  100. package/lib/util/normalizeConfig.js +0 -233
  101. package/lib/util/normalizeScreens.js +0 -59
  102. package/lib/util/parseAnimationValue.js +0 -89
  103. package/lib/util/parseBoxShadowValue.js +0 -76
  104. package/lib/util/parseDependency.js +0 -63
  105. package/lib/util/parseObjectStyles.js +0 -31
  106. package/lib/util/pluginUtils.js +0 -179
  107. package/lib/util/prefixSelector.js +0 -20
  108. package/lib/util/resolveConfig.js +0 -255
  109. package/lib/util/resolveConfigPath.js +0 -51
  110. package/lib/util/responsive.js +0 -19
  111. package/lib/util/splitAtTopLevelOnly.js +0 -72
  112. package/lib/util/tap.js +0 -9
  113. package/lib/util/toColorValue.js +0 -8
  114. package/lib/util/toPath.js +0 -14
  115. package/lib/util/transformThemeValue.js +0 -59
  116. package/lib/util/validateConfig.js +0 -21
  117. package/lib/util/withAlphaVariable.js +0 -67
  118. package/nesting/index.js +0 -2
  119. package/peers/index.js +0 -75881
  120. package/plugin.d.ts +0 -6
  121. package/plugin.js +0 -2
  122. package/prettier.config.js +0 -19
  123. package/resolveConfig.js +0 -2
  124. package/screens.css +0 -1
  125. package/scripts/create-plugin-list.js +0 -10
  126. package/scripts/generate-types.js +0 -52
  127. package/scripts/install-integrations.js +0 -27
  128. package/scripts/rebuildFixtures.js +0 -68
  129. package/src/cli-peer-dependencies.js +0 -11
  130. package/src/cli.js +0 -883
  131. package/src/constants.js +0 -17
  132. package/src/corePluginList.js +0 -1
  133. package/src/corePlugins.js +0 -2409
  134. package/src/css/LICENSE +0 -25
  135. package/src/css/preflight.css +0 -360
  136. package/src/featureFlags.js +0 -54
  137. package/src/index.js +0 -42
  138. package/src/lib/cacheInvalidation.js +0 -52
  139. package/src/lib/collapseAdjacentRules.js +0 -58
  140. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  141. package/src/lib/defaultExtractor.js +0 -180
  142. package/src/lib/detectNesting.js +0 -39
  143. package/src/lib/evaluateTailwindFunctions.js +0 -198
  144. package/src/lib/expandApplyAtRules.js +0 -539
  145. package/src/lib/expandTailwindAtRules.js +0 -292
  146. package/src/lib/generateRules.js +0 -672
  147. package/src/lib/getModuleDependencies.js +0 -39
  148. package/src/lib/normalizeTailwindDirectives.js +0 -84
  149. package/src/lib/partitionApplyAtRules.js +0 -52
  150. package/src/lib/regex.js +0 -74
  151. package/src/lib/resolveDefaultsAtRules.js +0 -146
  152. package/src/lib/setupContextUtils.js +0 -945
  153. package/src/lib/setupTrackingContext.js +0 -187
  154. package/src/lib/sharedState.js +0 -48
  155. package/src/lib/substituteScreenAtRules.js +0 -19
  156. package/src/postcss-plugins/nesting/README.md +0 -42
  157. package/src/postcss-plugins/nesting/index.js +0 -13
  158. package/src/postcss-plugins/nesting/plugin.js +0 -80
  159. package/src/processTailwindFeatures.js +0 -58
  160. package/src/public/colors.js +0 -300
  161. package/src/public/create-plugin.js +0 -2
  162. package/src/public/default-config.js +0 -4
  163. package/src/public/default-theme.js +0 -4
  164. package/src/public/resolve-config.js +0 -7
  165. package/src/util/bigSign.js +0 -3
  166. package/src/util/buildMediaQuery.js +0 -20
  167. package/src/util/cloneDeep.js +0 -11
  168. package/src/util/cloneNodes.js +0 -24
  169. package/src/util/color.js +0 -73
  170. package/src/util/configurePlugins.js +0 -23
  171. package/src/util/createPlugin.js +0 -27
  172. package/src/util/createUtilityPlugin.js +0 -37
  173. package/src/util/dataTypes.js +0 -256
  174. package/src/util/defaults.js +0 -17
  175. package/src/util/escapeClassName.js +0 -8
  176. package/src/util/escapeCommas.js +0 -3
  177. package/src/util/flattenColorPalette.js +0 -13
  178. package/src/util/formatVariantSelector.js +0 -207
  179. package/src/util/getAllConfigs.js +0 -19
  180. package/src/util/hashConfig.js +0 -5
  181. package/src/util/isKeyframeRule.js +0 -3
  182. package/src/util/isPlainObject.js +0 -8
  183. package/src/util/isValidArbitraryValue.js +0 -61
  184. package/src/util/log.js +0 -29
  185. package/src/util/nameClass.js +0 -26
  186. package/src/util/negateValue.js +0 -16
  187. package/src/util/normalizeConfig.js +0 -262
  188. package/src/util/normalizeScreens.js +0 -45
  189. package/src/util/parseAnimationValue.js +0 -68
  190. package/src/util/parseBoxShadowValue.js +0 -72
  191. package/src/util/parseDependency.js +0 -49
  192. package/src/util/parseObjectStyles.js +0 -19
  193. package/src/util/pluginUtils.js +0 -192
  194. package/src/util/prefixSelector.js +0 -14
  195. package/src/util/resolveConfig.js +0 -269
  196. package/src/util/resolveConfigPath.js +0 -55
  197. package/src/util/responsive.js +0 -10
  198. package/src/util/splitAtTopLevelOnly.js +0 -71
  199. package/src/util/tap.js +0 -4
  200. package/src/util/toColorValue.js +0 -3
  201. package/src/util/toPath.js +0 -26
  202. package/src/util/transformThemeValue.js +0 -52
  203. package/src/util/validateConfig.js +0 -13
  204. package/src/util/withAlphaVariable.js +0 -49
  205. package/stubs/defaultConfig.stub.js +0 -953
  206. package/stubs/defaultPostCssConfig.stub.js +0 -6
  207. package/stubs/simpleConfig.stub.js +0 -7
  208. package/tailwind.css +0 -5
  209. package/types/config.d.ts +0 -323
  210. package/types/generated/.gitkeep +0 -0
  211. package/types/generated/colors.d.ts +0 -276
  212. package/types/generated/corePluginList.d.ts +0 -1
  213. package/types/index.d.ts +0 -1
  214. package/types.d.ts +0 -1
  215. package/variants.css +0 -1
@@ -1,256 +0,0 @@
1
- import { parseColor } from './color'
2
- import { parseBoxShadowValue } from './parseBoxShadowValue'
3
-
4
- let cssFunctions = ['min', 'max', 'clamp', 'calc']
5
-
6
- // Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
7
-
8
- let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
9
- let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
10
-
11
- // This is not a data type, but rather a function that can normalize the
12
- // correct values.
13
- export function normalize(value, isRoot = true) {
14
- // Keep raw strings if it starts with `url(`
15
- if (value.includes('url(')) {
16
- return value
17
- .split(/(url\(.*?\))/g)
18
- .filter(Boolean)
19
- .map((part) => {
20
- if (/^url\(.*?\)$/.test(part)) {
21
- return part
22
- }
23
-
24
- return normalize(part, false)
25
- })
26
- .join('')
27
- }
28
-
29
- // Convert `_` to ` `, except for escaped underscores `\_`
30
- value = value
31
- .replace(
32
- /([^\\])_+/g,
33
- (fullMatch, characterBefore) => characterBefore + ' '.repeat(fullMatch.length - 1)
34
- )
35
- .replace(/^_/g, ' ')
36
- .replace(/\\_/g, '_')
37
-
38
- // Remove leftover whitespace
39
- if (isRoot) {
40
- value = value.trim()
41
- }
42
-
43
- // Add spaces around operators inside calc() that do not follow an operator
44
- // or '('.
45
- value = value.replace(/calc\(.+\)/g, (match) => {
46
- return match.replace(
47
- /(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
48
- '$1 $2 '
49
- )
50
- })
51
-
52
- // Add spaces around some operators not inside calc() that do not follow an operator
53
- // or '('.
54
- return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, '$1 $2 ')
55
- }
56
-
57
- export function url(value) {
58
- return value.startsWith('url(')
59
- }
60
-
61
- export function number(value) {
62
- return !isNaN(Number(value)) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?`).test(value))
63
- }
64
-
65
- export function percentage(value) {
66
- return value.split(UNDERSCORE).every((part) => {
67
- return /%$/g.test(part) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(part))
68
- })
69
- }
70
-
71
- let lengthUnits = [
72
- 'cm',
73
- 'mm',
74
- 'Q',
75
- 'in',
76
- 'pc',
77
- 'pt',
78
- 'px',
79
- 'em',
80
- 'ex',
81
- 'ch',
82
- 'rem',
83
- 'lh',
84
- 'vw',
85
- 'vh',
86
- 'vmin',
87
- 'vmax',
88
- ]
89
- let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
90
- export function length(value) {
91
- return value.split(UNDERSCORE).every((part) => {
92
- return (
93
- part === '0' ||
94
- new RegExp(`${lengthUnitsPattern}$`).test(part) ||
95
- cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part))
96
- )
97
- })
98
- }
99
-
100
- let lineWidths = new Set(['thin', 'medium', 'thick'])
101
- export function lineWidth(value) {
102
- return lineWidths.has(value)
103
- }
104
-
105
- export function shadow(value) {
106
- let parsedShadows = parseBoxShadowValue(normalize(value))
107
-
108
- for (let parsedShadow of parsedShadows) {
109
- if (!parsedShadow.valid) {
110
- return false
111
- }
112
- }
113
-
114
- return true
115
- }
116
-
117
- export function color(value) {
118
- let colors = 0
119
-
120
- let result = value.split(UNDERSCORE).every((part) => {
121
- part = normalize(part)
122
-
123
- if (part.startsWith('var(')) return true
124
- if (parseColor(part, { loose: true }) !== null) return colors++, true
125
-
126
- return false
127
- })
128
-
129
- if (!result) return false
130
- return colors > 0
131
- }
132
-
133
- export function image(value) {
134
- let images = 0
135
- let result = value.split(COMMA).every((part) => {
136
- part = normalize(part)
137
-
138
- if (part.startsWith('var(')) return true
139
- if (
140
- url(part) ||
141
- gradient(part) ||
142
- ['element(', 'image(', 'cross-fade(', 'image-set('].some((fn) => part.startsWith(fn))
143
- ) {
144
- images++
145
- return true
146
- }
147
-
148
- return false
149
- })
150
-
151
- if (!result) return false
152
- return images > 0
153
- }
154
-
155
- let gradientTypes = new Set([
156
- 'linear-gradient',
157
- 'radial-gradient',
158
- 'repeating-linear-gradient',
159
- 'repeating-radial-gradient',
160
- 'conic-gradient',
161
- ])
162
- export function gradient(value) {
163
- value = normalize(value)
164
-
165
- for (let type of gradientTypes) {
166
- if (value.startsWith(`${type}(`)) {
167
- return true
168
- }
169
- }
170
- return false
171
- }
172
-
173
- let validPositions = new Set(['center', 'top', 'right', 'bottom', 'left'])
174
- export function position(value) {
175
- let positions = 0
176
- let result = value.split(UNDERSCORE).every((part) => {
177
- part = normalize(part)
178
-
179
- if (part.startsWith('var(')) return true
180
- if (validPositions.has(part) || length(part) || percentage(part)) {
181
- positions++
182
- return true
183
- }
184
-
185
- return false
186
- })
187
-
188
- if (!result) return false
189
- return positions > 0
190
- }
191
-
192
- export function familyName(value) {
193
- let fonts = 0
194
- let result = value.split(COMMA).every((part) => {
195
- part = normalize(part)
196
-
197
- if (part.startsWith('var(')) return true
198
-
199
- // If it contains spaces, then it should be quoted
200
- if (part.includes(' ')) {
201
- if (!/(['"])([^"']+)\1/g.test(part)) {
202
- return false
203
- }
204
- }
205
-
206
- // If it starts with a number, it's invalid
207
- if (/^\d/g.test(part)) {
208
- return false
209
- }
210
-
211
- fonts++
212
-
213
- return true
214
- })
215
-
216
- if (!result) return false
217
- return fonts > 0
218
- }
219
-
220
- let genericNames = new Set([
221
- 'serif',
222
- 'sans-serif',
223
- 'monospace',
224
- 'cursive',
225
- 'fantasy',
226
- 'system-ui',
227
- 'ui-serif',
228
- 'ui-sans-serif',
229
- 'ui-monospace',
230
- 'ui-rounded',
231
- 'math',
232
- 'emoji',
233
- 'fangsong',
234
- ])
235
- export function genericName(value) {
236
- return genericNames.has(value)
237
- }
238
-
239
- let absoluteSizes = new Set([
240
- 'xx-small',
241
- 'x-small',
242
- 'small',
243
- 'medium',
244
- 'large',
245
- 'x-large',
246
- 'x-large',
247
- 'xxx-large',
248
- ])
249
- export function absoluteSize(value) {
250
- return absoluteSizes.has(value)
251
- }
252
-
253
- let relativeSizes = new Set(['larger', 'smaller'])
254
- export function relativeSize(value) {
255
- return relativeSizes.has(value)
256
- }
@@ -1,17 +0,0 @@
1
- export function defaults(target, ...sources) {
2
- for (let source of sources) {
3
- for (let k in source) {
4
- if (!target?.hasOwnProperty?.(k)) {
5
- target[k] = source[k]
6
- }
7
- }
8
-
9
- for (let k of Object.getOwnPropertySymbols(source)) {
10
- if (!target?.hasOwnProperty?.(k)) {
11
- target[k] = source[k]
12
- }
13
- }
14
- }
15
-
16
- return target
17
- }
@@ -1,8 +0,0 @@
1
- import parser from 'postcss-selector-parser'
2
- import escapeCommas from './escapeCommas'
3
-
4
- export default function escapeClassName(className) {
5
- let node = parser.className()
6
- node.value = className
7
- return escapeCommas(node?.raws?.value ?? node.value)
8
- }
@@ -1,3 +0,0 @@
1
- export default function escapeCommas(className) {
2
- return className.replace(/\\,/g, '\\2c ')
3
- }
@@ -1,13 +0,0 @@
1
- const flattenColorPalette = (colors) =>
2
- Object.assign(
3
- {},
4
- ...Object.entries(colors ?? {}).flatMap(([color, values]) =>
5
- typeof values == 'object'
6
- ? Object.entries(flattenColorPalette(values)).map(([number, hex]) => ({
7
- [color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex,
8
- }))
9
- : [{ [`${color}`]: values }]
10
- )
11
- )
12
-
13
- export default flattenColorPalette
@@ -1,207 +0,0 @@
1
- import selectorParser from 'postcss-selector-parser'
2
- import unescape from 'postcss-selector-parser/dist/util/unesc'
3
- import escapeClassName from '../util/escapeClassName'
4
- import prefixSelector from '../util/prefixSelector'
5
-
6
- let MERGE = ':merge'
7
- let PARENT = '&'
8
-
9
- export let selectorFunctions = new Set([MERGE])
10
-
11
- export function formatVariantSelector(current, ...others) {
12
- for (let other of others) {
13
- let incomingValue = resolveFunctionArgument(other, MERGE)
14
- if (incomingValue !== null) {
15
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue)
16
- if (existingValue !== null) {
17
- let existingTarget = `${MERGE}(${incomingValue})`
18
- let splitIdx = other.indexOf(existingTarget)
19
- let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0]
20
-
21
- current = current.replace(existingTarget, existingTarget + addition)
22
- continue
23
- }
24
- }
25
-
26
- current = other.replace(PARENT, current)
27
- }
28
-
29
- return current
30
- }
31
-
32
- export function finalizeSelector(format, { selector, candidate, context }) {
33
- let ast = selectorParser().astSync(selector)
34
-
35
- let separator = context?.tailwindConfig?.separator ?? ':'
36
-
37
- // Split by the separator, but ignore the separator inside square brackets:
38
- //
39
- // E.g.: dark:lg:hover:[paint-order:markers]
40
- // ┬ ┬ ┬ ┬
41
- // │ │ │ ╰── We will not split here
42
- // ╰──┴─────┴─────────────── We will split here
43
- //
44
- let splitter = new RegExp(`\\${separator}(?![^[]*\\])`)
45
- let base = candidate.split(splitter).pop()
46
-
47
- if (context?.tailwindConfig?.prefix) {
48
- format = prefixSelector(context.tailwindConfig.prefix, format)
49
- }
50
-
51
- format = format.replace(PARENT, `.${escapeClassName(candidate)}`)
52
-
53
- let formatAst = selectorParser().astSync(format)
54
-
55
- // Remove extraneous selectors that do not include the base class/candidate being matched against
56
- // For example if we have a utility defined `.a, .b { color: red}`
57
- // And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
58
- ast.each((node) => {
59
- let hasClassesMatchingCandidate = node.some((n) => n.type === 'class' && n.value === base)
60
-
61
- if (!hasClassesMatchingCandidate) {
62
- node.remove()
63
- }
64
- })
65
-
66
- // Normalize escaped classes, e.g.:
67
- //
68
- // The idea would be to replace the escaped `base` in the selector with the
69
- // `format`. However, in css you can escape the same selector in a few
70
- // different ways. This would result in different strings and therefore we
71
- // can't replace it properly.
72
- //
73
- // base: bg-[rgb(255,0,0)]
74
- // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
75
- // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
76
- //
77
- ast.walkClasses((node) => {
78
- if (node.raws && node.value.includes(base)) {
79
- node.raws.value = escapeClassName(unescape(node.raws.value))
80
- }
81
- })
82
-
83
- // We can safely replace the escaped base now, since the `base` section is
84
- // now in a normalized escaped value.
85
- ast.walkClasses((node) => {
86
- if (node.value === base) {
87
- node.replaceWith(...formatAst.nodes)
88
- }
89
- })
90
-
91
- // This will make sure to move pseudo's to the correct spot (the end for
92
- // pseudo elements) because otherwise the selector will never work
93
- // anyway.
94
- //
95
- // E.g.:
96
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
97
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
98
- //
99
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
100
- function collectPseudoElements(selector) {
101
- let nodes = []
102
-
103
- for (let node of selector.nodes) {
104
- if (isPseudoElement(node)) {
105
- nodes.push(node)
106
- selector.removeChild(node)
107
- }
108
-
109
- if (node?.nodes) {
110
- nodes.push(...collectPseudoElements(node))
111
- }
112
- }
113
-
114
- return nodes
115
- }
116
-
117
- // Remove unnecessary pseudo selectors that we used as placeholders
118
- ast.each((selector) => {
119
- selector.walkPseudos((p) => {
120
- if (selectorFunctions.has(p.value)) {
121
- p.replaceWith(p.nodes)
122
- }
123
- })
124
-
125
- let pseudoElements = collectPseudoElements(selector)
126
- if (pseudoElements.length > 0) {
127
- selector.nodes.push(pseudoElements.sort(sortSelector))
128
- }
129
- })
130
-
131
- return ast.toString()
132
- }
133
-
134
- // Note: As a rule, double colons (::) should be used instead of a single colon
135
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
136
- // this distinction was not present in older versions of the W3C spec, most
137
- // browsers support both syntaxes for the original pseudo-elements.
138
- let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter']
139
-
140
- // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
141
- let pseudoElementExceptions = ['::file-selector-button']
142
-
143
- // This will make sure to move pseudo's to the correct spot (the end for
144
- // pseudo elements) because otherwise the selector will never work
145
- // anyway.
146
- //
147
- // E.g.:
148
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
149
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
150
- //
151
- // `::before:hover` doesn't work, which means that we can make it work
152
- // for you by flipping the order.
153
- function sortSelector(a, z) {
154
- // Both nodes are non-pseudo's so we can safely ignore them and keep
155
- // them in the same order.
156
- if (a.type !== 'pseudo' && z.type !== 'pseudo') {
157
- return 0
158
- }
159
-
160
- // If one of them is a combinator, we need to keep it in the same order
161
- // because that means it will start a new "section" in the selector.
162
- if ((a.type === 'combinator') ^ (z.type === 'combinator')) {
163
- return 0
164
- }
165
-
166
- // One of the items is a pseudo and the other one isn't. Let's move
167
- // the pseudo to the right.
168
- if ((a.type === 'pseudo') ^ (z.type === 'pseudo')) {
169
- return (a.type === 'pseudo') - (z.type === 'pseudo')
170
- }
171
-
172
- // Both are pseudo's, move the pseudo elements (except for
173
- // ::file-selector-button) to the right.
174
- return isPseudoElement(a) - isPseudoElement(z)
175
- }
176
-
177
- function isPseudoElement(node) {
178
- if (node.type !== 'pseudo') return false
179
- if (pseudoElementExceptions.includes(node.value)) return false
180
-
181
- return node.value.startsWith('::') || pseudoElementsBC.includes(node.value)
182
- }
183
-
184
- function resolveFunctionArgument(haystack, needle, arg) {
185
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle)
186
- if (startIdx === -1) return null
187
-
188
- // Start inside the `(`
189
- startIdx += needle.length + 1
190
-
191
- let target = ''
192
- let count = 0
193
-
194
- for (let char of haystack.slice(startIdx)) {
195
- if (char !== '(' && char !== ')') {
196
- target += char
197
- } else if (char === '(') {
198
- target += char
199
- count++
200
- } else if (char === ')') {
201
- if (--count < 0) break // unbalanced
202
- target += char
203
- }
204
- }
205
-
206
- return target
207
- }
@@ -1,19 +0,0 @@
1
- import defaultConfig from '../../stubs/defaultConfig.stub.js'
2
- import { flagEnabled } from '../featureFlags'
3
-
4
- export default function getAllConfigs(config) {
5
- const configs = (config?.presets ?? [defaultConfig])
6
- .slice()
7
- .reverse()
8
- .flatMap((preset) => getAllConfigs(preset instanceof Function ? preset() : preset))
9
-
10
- const features = {
11
- // Add experimental configs here...
12
- }
13
-
14
- const experimentals = Object.keys(features)
15
- .filter((feature) => flagEnabled(config, feature))
16
- .map((feature) => features[feature])
17
-
18
- return [config, ...experimentals, ...configs]
19
- }
@@ -1,5 +0,0 @@
1
- import hash from 'object-hash'
2
-
3
- export default function hashConfig(config) {
4
- return hash(config, { ignoreUnknown: true })
5
- }
@@ -1,3 +0,0 @@
1
- export default function isKeyframeRule(rule) {
2
- return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name)
3
- }
@@ -1,8 +0,0 @@
1
- export default function isPlainObject(value) {
2
- if (Object.prototype.toString.call(value) !== '[object Object]') {
3
- return false
4
- }
5
-
6
- const prototype = Object.getPrototypeOf(value)
7
- return prototype === null || prototype === Object.prototype
8
- }
@@ -1,61 +0,0 @@
1
- let matchingBrackets = new Map([
2
- ['{', '}'],
3
- ['[', ']'],
4
- ['(', ')'],
5
- ])
6
- let inverseMatchingBrackets = new Map(
7
- Array.from(matchingBrackets.entries()).map(([k, v]) => [v, k])
8
- )
9
-
10
- let quotes = new Set(['"', "'", '`'])
11
-
12
- // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
13
- // values don't count, and brackets inside quotes also don't count.
14
- //
15
- // E.g.: w-[this-is]w-[weird-and-invalid]
16
- // E.g.: w-[this-is\\]w-\\[weird-but-valid]
17
- // E.g.: content-['this-is-also-valid]-weirdly-enough']
18
- export default function isValidArbitraryValue(value) {
19
- let stack = []
20
- let inQuotes = false
21
-
22
- for (let i = 0; i < value.length; i++) {
23
- let char = value[i]
24
-
25
- if (char === ':' && !inQuotes && stack.length === 0) {
26
- return false
27
- }
28
-
29
- // Non-escaped quotes allow us to "allow" anything in between
30
- if (quotes.has(char) && value[i - 1] !== '\\') {
31
- inQuotes = !inQuotes
32
- }
33
-
34
- if (inQuotes) continue
35
- if (value[i - 1] === '\\') continue // Escaped
36
-
37
- if (matchingBrackets.has(char)) {
38
- stack.push(char)
39
- } else if (inverseMatchingBrackets.has(char)) {
40
- let inverse = inverseMatchingBrackets.get(char)
41
-
42
- // Nothing to pop from, therefore it is unbalanced
43
- if (stack.length <= 0) {
44
- return false
45
- }
46
-
47
- // Popped value must match the inverse value, otherwise it is unbalanced
48
- if (stack.pop() !== inverse) {
49
- return false
50
- }
51
- }
52
- }
53
-
54
- // If there is still something on the stack, it is also unbalanced
55
- if (stack.length > 0) {
56
- return false
57
- }
58
-
59
- // All good, totally balanced!
60
- return true
61
- }
package/src/util/log.js DELETED
@@ -1,29 +0,0 @@
1
- import colors from 'picocolors'
2
-
3
- let alreadyShown = new Set()
4
-
5
- function log(type, messages, key) {
6
- if (process.env.JEST_WORKER_ID !== undefined) return
7
-
8
- if (key && alreadyShown.has(key)) return
9
- if (key) alreadyShown.add(key)
10
-
11
- console.warn('')
12
- messages.forEach((message) => console.warn(type, '-', message))
13
- }
14
-
15
- export function dim(input) {
16
- return colors.dim(input)
17
- }
18
-
19
- export default {
20
- info(key, messages) {
21
- log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
22
- },
23
- warn(key, messages) {
24
- log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
25
- },
26
- risk(key, messages) {
27
- log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
28
- },
29
- }
@@ -1,26 +0,0 @@
1
- import escapeClassName from './escapeClassName'
2
- import escapeCommas from './escapeCommas'
3
-
4
- export function asClass(name) {
5
- return escapeCommas(`.${escapeClassName(name)}`)
6
- }
7
-
8
- export default function nameClass(classPrefix, key) {
9
- return asClass(formatClass(classPrefix, key))
10
- }
11
-
12
- export function formatClass(classPrefix, key) {
13
- if (key === 'DEFAULT') {
14
- return classPrefix
15
- }
16
-
17
- if (key === '-' || key === '-DEFAULT') {
18
- return `-${classPrefix}`
19
- }
20
-
21
- if (key.startsWith('-')) {
22
- return `-${classPrefix}${key}`
23
- }
24
-
25
- return `${classPrefix}-${key}`
26
- }
@@ -1,16 +0,0 @@
1
- export default function (value) {
2
- value = `${value}`
3
-
4
- if (value === '0') {
5
- return '0'
6
- }
7
-
8
- // Flip sign of numbers
9
- if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
10
- return value.replace(/^[+-]?/, (sign) => (sign === '-' ? '' : '-'))
11
- }
12
-
13
- if (value.includes('var(') || value.includes('calc(')) {
14
- return `calc(${value} * -1)`
15
- }
16
- }