tailwindcss 0.0.0-insiders.bbafc8e → 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 (198) 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 -95
  31. package/preflight.css +383 -0
  32. package/theme.css +453 -0
  33. package/CHANGELOG.md +0 -2084
  34. package/base.css +0 -1
  35. package/colors.js +0 -2
  36. package/components.css +0 -1
  37. package/defaultConfig.js +0 -2
  38. package/defaultTheme.js +0 -2
  39. package/lib/cli-peer-dependencies.js +0 -15
  40. package/lib/cli.js +0 -741
  41. package/lib/constants.js +0 -37
  42. package/lib/corePluginList.js +0 -178
  43. package/lib/corePlugins.js +0 -3587
  44. package/lib/css/LICENSE +0 -25
  45. package/lib/css/preflight.css +0 -367
  46. package/lib/featureFlags.js +0 -59
  47. package/lib/index.js +0 -41
  48. package/lib/lib/cacheInvalidation.js +0 -69
  49. package/lib/lib/collapseAdjacentRules.js +0 -54
  50. package/lib/lib/collapseDuplicateDeclarations.js +0 -80
  51. package/lib/lib/defaultExtractor.js +0 -44
  52. package/lib/lib/detectNesting.js +0 -34
  53. package/lib/lib/evaluateTailwindFunctions.js +0 -171
  54. package/lib/lib/expandApplyAtRules.js +0 -433
  55. package/lib/lib/expandTailwindAtRules.js +0 -262
  56. package/lib/lib/generateRules.js +0 -631
  57. package/lib/lib/getModuleDependencies.js +0 -48
  58. package/lib/lib/normalizeTailwindDirectives.js +0 -84
  59. package/lib/lib/partitionApplyAtRules.js +0 -53
  60. package/lib/lib/resolveDefaultsAtRules.js +0 -143
  61. package/lib/lib/setupContextUtils.js +0 -859
  62. package/lib/lib/setupTrackingContext.js +0 -171
  63. package/lib/lib/sharedState.js +0 -52
  64. package/lib/lib/substituteScreenAtRules.js +0 -27
  65. package/lib/postcss-plugins/nesting/README.md +0 -42
  66. package/lib/postcss-plugins/nesting/index.js +0 -17
  67. package/lib/postcss-plugins/nesting/plugin.js +0 -85
  68. package/lib/processTailwindFeatures.js +0 -59
  69. package/lib/public/colors.js +0 -329
  70. package/lib/public/create-plugin.js +0 -13
  71. package/lib/public/default-config.js +0 -14
  72. package/lib/public/default-theme.js +0 -14
  73. package/lib/public/resolve-config.js +0 -19
  74. package/lib/util/bigSign.js +0 -8
  75. package/lib/util/buildMediaQuery.js +0 -20
  76. package/lib/util/cloneDeep.js +0 -19
  77. package/lib/util/cloneNodes.js +0 -25
  78. package/lib/util/color.js +0 -99
  79. package/lib/util/configurePlugins.js +0 -18
  80. package/lib/util/createPlugin.js +0 -29
  81. package/lib/util/createUtilityPlugin.js +0 -49
  82. package/lib/util/dataTypes.js +0 -233
  83. package/lib/util/defaults.js +0 -22
  84. package/lib/util/escapeClassName.js +0 -19
  85. package/lib/util/escapeCommas.js +0 -8
  86. package/lib/util/flattenColorPalette.js +0 -17
  87. package/lib/util/formatVariantSelector.js +0 -186
  88. package/lib/util/getAllConfigs.js +0 -29
  89. package/lib/util/hashConfig.js +0 -16
  90. package/lib/util/isKeyframeRule.js +0 -8
  91. package/lib/util/isPlainObject.js +0 -12
  92. package/lib/util/isValidArbitraryValue.js +0 -64
  93. package/lib/util/log.js +0 -51
  94. package/lib/util/nameClass.js +0 -32
  95. package/lib/util/negateValue.js +0 -19
  96. package/lib/util/normalizeConfig.js +0 -240
  97. package/lib/util/normalizeScreens.js +0 -59
  98. package/lib/util/parseAnimationValue.js +0 -89
  99. package/lib/util/parseBoxShadowValue.js +0 -117
  100. package/lib/util/parseDependency.js +0 -63
  101. package/lib/util/parseObjectStyles.js +0 -31
  102. package/lib/util/pluginUtils.js +0 -179
  103. package/lib/util/prefixSelector.js +0 -20
  104. package/lib/util/resolveConfig.js +0 -255
  105. package/lib/util/resolveConfigPath.js +0 -51
  106. package/lib/util/responsive.js +0 -19
  107. package/lib/util/tap.js +0 -9
  108. package/lib/util/toColorValue.js +0 -8
  109. package/lib/util/toPath.js +0 -14
  110. package/lib/util/transformThemeValue.js +0 -59
  111. package/lib/util/withAlphaVariable.js +0 -67
  112. package/nesting/index.js +0 -2
  113. package/peers/index.js +0 -75077
  114. package/plugin.js +0 -2
  115. package/prettier.config.js +0 -19
  116. package/resolveConfig.js +0 -2
  117. package/screens.css +0 -1
  118. package/scripts/create-plugin-list.js +0 -10
  119. package/scripts/install-integrations.js +0 -27
  120. package/scripts/rebuildFixtures.js +0 -68
  121. package/src/cli-peer-dependencies.js +0 -9
  122. package/src/cli.js +0 -815
  123. package/src/constants.js +0 -17
  124. package/src/corePluginList.js +0 -1
  125. package/src/corePlugins.js +0 -2365
  126. package/src/css/LICENSE +0 -25
  127. package/src/css/preflight.css +0 -367
  128. package/src/featureFlags.js +0 -54
  129. package/src/index.js +0 -42
  130. package/src/lib/cacheInvalidation.js +0 -52
  131. package/src/lib/collapseAdjacentRules.js +0 -54
  132. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  133. package/src/lib/defaultExtractor.js +0 -50
  134. package/src/lib/detectNesting.js +0 -39
  135. package/src/lib/evaluateTailwindFunctions.js +0 -198
  136. package/src/lib/expandApplyAtRules.js +0 -480
  137. package/src/lib/expandTailwindAtRules.js +0 -292
  138. package/src/lib/generateRules.js +0 -623
  139. package/src/lib/getModuleDependencies.js +0 -39
  140. package/src/lib/normalizeTailwindDirectives.js +0 -84
  141. package/src/lib/partitionApplyAtRules.js +0 -52
  142. package/src/lib/resolveDefaultsAtRules.js +0 -146
  143. package/src/lib/setupContextUtils.js +0 -883
  144. package/src/lib/setupTrackingContext.js +0 -183
  145. package/src/lib/sharedState.js +0 -48
  146. package/src/lib/substituteScreenAtRules.js +0 -19
  147. package/src/postcss-plugins/nesting/README.md +0 -42
  148. package/src/postcss-plugins/nesting/index.js +0 -13
  149. package/src/postcss-plugins/nesting/plugin.js +0 -80
  150. package/src/processTailwindFeatures.js +0 -58
  151. package/src/public/colors.js +0 -300
  152. package/src/public/create-plugin.js +0 -2
  153. package/src/public/default-config.js +0 -4
  154. package/src/public/default-theme.js +0 -4
  155. package/src/public/resolve-config.js +0 -7
  156. package/src/util/bigSign.js +0 -3
  157. package/src/util/buildMediaQuery.js +0 -20
  158. package/src/util/cloneDeep.js +0 -11
  159. package/src/util/cloneNodes.js +0 -24
  160. package/src/util/color.js +0 -69
  161. package/src/util/configurePlugins.js +0 -23
  162. package/src/util/createPlugin.js +0 -27
  163. package/src/util/createUtilityPlugin.js +0 -37
  164. package/src/util/dataTypes.js +0 -248
  165. package/src/util/defaults.js +0 -17
  166. package/src/util/escapeClassName.js +0 -8
  167. package/src/util/escapeCommas.js +0 -3
  168. package/src/util/flattenColorPalette.js +0 -13
  169. package/src/util/formatVariantSelector.js +0 -196
  170. package/src/util/getAllConfigs.js +0 -19
  171. package/src/util/hashConfig.js +0 -5
  172. package/src/util/isKeyframeRule.js +0 -3
  173. package/src/util/isPlainObject.js +0 -8
  174. package/src/util/isValidArbitraryValue.js +0 -61
  175. package/src/util/log.js +0 -29
  176. package/src/util/nameClass.js +0 -26
  177. package/src/util/negateValue.js +0 -16
  178. package/src/util/normalizeConfig.js +0 -270
  179. package/src/util/normalizeScreens.js +0 -45
  180. package/src/util/parseAnimationValue.js +0 -68
  181. package/src/util/parseBoxShadowValue.js +0 -119
  182. package/src/util/parseDependency.js +0 -49
  183. package/src/util/parseObjectStyles.js +0 -19
  184. package/src/util/pluginUtils.js +0 -192
  185. package/src/util/prefixSelector.js +0 -14
  186. package/src/util/resolveConfig.js +0 -269
  187. package/src/util/resolveConfigPath.js +0 -55
  188. package/src/util/responsive.js +0 -10
  189. package/src/util/tap.js +0 -4
  190. package/src/util/toColorValue.js +0 -3
  191. package/src/util/toPath.js +0 -26
  192. package/src/util/transformThemeValue.js +0 -52
  193. package/src/util/withAlphaVariable.js +0 -49
  194. package/stubs/defaultConfig.stub.js +0 -950
  195. package/stubs/defaultPostCssConfig.stub.js +0 -6
  196. package/stubs/simpleConfig.stub.js +0 -7
  197. package/tailwind.css +0 -5
  198. package/variants.css +0 -1
@@ -1,248 +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
- return value.replace(
46
- /(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
47
- '$1 $2 '
48
- )
49
- }
50
-
51
- export function url(value) {
52
- return value.startsWith('url(')
53
- }
54
-
55
- export function number(value) {
56
- return !isNaN(Number(value)) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?`).test(value))
57
- }
58
-
59
- export function percentage(value) {
60
- return /%$/g.test(value) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(value))
61
- }
62
-
63
- let lengthUnits = [
64
- 'cm',
65
- 'mm',
66
- 'Q',
67
- 'in',
68
- 'pc',
69
- 'pt',
70
- 'px',
71
- 'em',
72
- 'ex',
73
- 'ch',
74
- 'rem',
75
- 'lh',
76
- 'vw',
77
- 'vh',
78
- 'vmin',
79
- 'vmax',
80
- ]
81
- let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
82
- export function length(value) {
83
- return value.split(UNDERSCORE).every((part) => {
84
- return (
85
- part === '0' ||
86
- new RegExp(`${lengthUnitsPattern}$`).test(part) ||
87
- cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part))
88
- )
89
- })
90
- }
91
-
92
- let lineWidths = new Set(['thin', 'medium', 'thick'])
93
- export function lineWidth(value) {
94
- return lineWidths.has(value)
95
- }
96
-
97
- export function shadow(value) {
98
- let parsedShadows = parseBoxShadowValue(normalize(value))
99
-
100
- for (let parsedShadow of parsedShadows) {
101
- if (!parsedShadow.valid) {
102
- return false
103
- }
104
- }
105
-
106
- return true
107
- }
108
-
109
- export function color(value) {
110
- let colors = 0
111
-
112
- let result = value.split(UNDERSCORE).every((part) => {
113
- part = normalize(part)
114
-
115
- if (part.startsWith('var(')) return true
116
- if (parseColor(part) !== null) return colors++, true
117
-
118
- return false
119
- })
120
-
121
- if (!result) return false
122
- return colors > 0
123
- }
124
-
125
- export function image(value) {
126
- let images = 0
127
- let result = value.split(COMMA).every((part) => {
128
- part = normalize(part)
129
-
130
- if (part.startsWith('var(')) return true
131
- if (
132
- url(part) ||
133
- gradient(part) ||
134
- ['element(', 'image(', 'cross-fade(', 'image-set('].some((fn) => part.startsWith(fn))
135
- ) {
136
- images++
137
- return true
138
- }
139
-
140
- return false
141
- })
142
-
143
- if (!result) return false
144
- return images > 0
145
- }
146
-
147
- let gradientTypes = new Set([
148
- 'linear-gradient',
149
- 'radial-gradient',
150
- 'repeating-linear-gradient',
151
- 'repeating-radial-gradient',
152
- 'conic-gradient',
153
- ])
154
- export function gradient(value) {
155
- value = normalize(value)
156
-
157
- for (let type of gradientTypes) {
158
- if (value.startsWith(`${type}(`)) {
159
- return true
160
- }
161
- }
162
- return false
163
- }
164
-
165
- let validPositions = new Set(['center', 'top', 'right', 'bottom', 'left'])
166
- export function position(value) {
167
- let positions = 0
168
- let result = value.split(UNDERSCORE).every((part) => {
169
- part = normalize(part)
170
-
171
- if (part.startsWith('var(')) return true
172
- if (validPositions.has(part) || length(part) || percentage(part)) {
173
- positions++
174
- return true
175
- }
176
-
177
- return false
178
- })
179
-
180
- if (!result) return false
181
- return positions > 0
182
- }
183
-
184
- export function familyName(value) {
185
- let fonts = 0
186
- let result = value.split(COMMA).every((part) => {
187
- part = normalize(part)
188
-
189
- if (part.startsWith('var(')) return true
190
-
191
- // If it contains spaces, then it should be quoted
192
- if (part.includes(' ')) {
193
- if (!/(['"])([^"']+)\1/g.test(part)) {
194
- return false
195
- }
196
- }
197
-
198
- // If it starts with a number, it's invalid
199
- if (/^\d/g.test(part)) {
200
- return false
201
- }
202
-
203
- fonts++
204
-
205
- return true
206
- })
207
-
208
- if (!result) return false
209
- return fonts > 0
210
- }
211
-
212
- let genericNames = new Set([
213
- 'serif',
214
- 'sans-serif',
215
- 'monospace',
216
- 'cursive',
217
- 'fantasy',
218
- 'system-ui',
219
- 'ui-serif',
220
- 'ui-sans-serif',
221
- 'ui-monospace',
222
- 'ui-rounded',
223
- 'math',
224
- 'emoji',
225
- 'fangsong',
226
- ])
227
- export function genericName(value) {
228
- return genericNames.has(value)
229
- }
230
-
231
- let absoluteSizes = new Set([
232
- 'xx-small',
233
- 'x-small',
234
- 'small',
235
- 'medium',
236
- 'large',
237
- 'x-large',
238
- 'x-large',
239
- 'xxx-large',
240
- ])
241
- export function absoluteSize(value) {
242
- return absoluteSizes.has(value)
243
- }
244
-
245
- let relativeSizes = new Set(['larger', 'smaller'])
246
- export function relativeSize(value) {
247
- return relativeSizes.has(value)
248
- }
@@ -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,196 +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 separator = context?.tailwindConfig?.separator ?? ':'
34
-
35
- // Split by the separator, but ignore the separator inside square brackets:
36
- //
37
- // E.g.: dark:lg:hover:[paint-order:markers]
38
- // ┬ ┬ ┬ ┬
39
- // │ │ │ ╰── We will not split here
40
- // ╰──┴─────┴─────────────── We will split here
41
- //
42
- let splitter = new RegExp(`\\${separator}(?![^[]*\\])`)
43
- let base = candidate.split(splitter).pop()
44
-
45
- if (context?.tailwindConfig?.prefix) {
46
- format = prefixSelector(context.tailwindConfig.prefix, format)
47
- }
48
-
49
- format = format.replace(PARENT, `.${escapeClassName(candidate)}`)
50
-
51
- // Normalize escaped classes, e.g.:
52
- //
53
- // The idea would be to replace the escaped `base` in the selector with the
54
- // `format`. However, in css you can escape the same selector in a few
55
- // different ways. This would result in different strings and therefore we
56
- // can't replace it properly.
57
- //
58
- // base: bg-[rgb(255,0,0)]
59
- // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
60
- // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
61
- //
62
- selector = selectorParser((selectors) => {
63
- return selectors.walkClasses((node) => {
64
- if (node.raws && node.value.includes(base)) {
65
- node.raws.value = escapeClassName(unescape(node.raws.value))
66
- }
67
-
68
- return node
69
- })
70
- }).processSync(selector)
71
-
72
- // We can safely replace the escaped base now, since the `base` section is
73
- // now in a normalized escaped value.
74
- selector = selector.replace(`.${escapeClassName(base)}`, format)
75
-
76
- // Remove unnecessary pseudo selectors that we used as placeholders
77
- return selectorParser((selectors) => {
78
- return selectors.map((selector) => {
79
- selector.walkPseudos((p) => {
80
- if (selectorFunctions.has(p.value)) {
81
- p.replaceWith(p.nodes)
82
- }
83
-
84
- return p
85
- })
86
-
87
- // This will make sure to move pseudo's to the correct spot (the end for
88
- // pseudo elements) because otherwise the selector will never work
89
- // anyway.
90
- //
91
- // E.g.:
92
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
93
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
94
- //
95
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
96
- function collectPseudoElements(selector) {
97
- let nodes = []
98
-
99
- for (let node of selector.nodes) {
100
- if (isPseudoElement(node)) {
101
- nodes.push(node)
102
- selector.removeChild(node)
103
- }
104
-
105
- if (node?.nodes) {
106
- nodes.push(...collectPseudoElements(node))
107
- }
108
- }
109
-
110
- return nodes
111
- }
112
-
113
- let pseudoElements = collectPseudoElements(selector)
114
- if (pseudoElements.length > 0) {
115
- selector.nodes.push(pseudoElements.sort(sortSelector))
116
- }
117
-
118
- return selector
119
- })
120
- }).processSync(selector)
121
- }
122
-
123
- // Note: As a rule, double colons (::) should be used instead of a single colon
124
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
125
- // this distinction was not present in older versions of the W3C spec, most
126
- // browsers support both syntaxes for the original pseudo-elements.
127
- let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter']
128
-
129
- // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
130
- let pseudoElementExceptions = ['::file-selector-button']
131
-
132
- // This will make sure to move pseudo's to the correct spot (the end for
133
- // pseudo elements) because otherwise the selector will never work
134
- // anyway.
135
- //
136
- // E.g.:
137
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
138
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
139
- //
140
- // `::before:hover` doesn't work, which means that we can make it work
141
- // for you by flipping the order.
142
- function sortSelector(a, z) {
143
- // Both nodes are non-pseudo's so we can safely ignore them and keep
144
- // them in the same order.
145
- if (a.type !== 'pseudo' && z.type !== 'pseudo') {
146
- return 0
147
- }
148
-
149
- // If one of them is a combinator, we need to keep it in the same order
150
- // because that means it will start a new "section" in the selector.
151
- if ((a.type === 'combinator') ^ (z.type === 'combinator')) {
152
- return 0
153
- }
154
-
155
- // One of the items is a pseudo and the other one isn't. Let's move
156
- // the pseudo to the right.
157
- if ((a.type === 'pseudo') ^ (z.type === 'pseudo')) {
158
- return (a.type === 'pseudo') - (z.type === 'pseudo')
159
- }
160
-
161
- // Both are pseudo's, move the pseudo elements (except for
162
- // ::file-selector-button) to the right.
163
- return isPseudoElement(a) - isPseudoElement(z)
164
- }
165
-
166
- function isPseudoElement(node) {
167
- if (node.type !== 'pseudo') return false
168
- if (pseudoElementExceptions.includes(node.value)) return false
169
-
170
- return node.value.startsWith('::') || pseudoElementsBC.includes(node.value)
171
- }
172
-
173
- function resolveFunctionArgument(haystack, needle, arg) {
174
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle)
175
- if (startIdx === -1) return null
176
-
177
- // Start inside the `(`
178
- startIdx += needle.length + 1
179
-
180
- let target = ''
181
- let count = 0
182
-
183
- for (let char of haystack.slice(startIdx)) {
184
- if (char !== '(' && char !== ')') {
185
- target += char
186
- } else if (char === '(') {
187
- target += char
188
- count++
189
- } else if (char === ')') {
190
- if (--count < 0) break // unbalanced
191
- target += char
192
- }
193
- }
194
-
195
- return target
196
- }
@@ -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
- }