tailwindcss 0.0.0-oxide-insiders.f49b054 → 0.0.0-oxide.1

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 (286) hide show
  1. package/dist/chunk-J6HTTNZH.mjs +5017 -0
  2. package/dist/cli.d.mts +2 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +5446 -0
  5. package/dist/cli.mjs +438 -0
  6. package/dist/lib.d.mts +244 -0
  7. package/dist/lib.d.ts +244 -0
  8. package/dist/lib.js +4947 -0
  9. package/dist/lib.mjs +1 -0
  10. package/index.css +4 -4
  11. package/package.json +36 -106
  12. package/preflight.css +404 -0
  13. package/theme.css +468 -0
  14. package/LICENSE +0 -21
  15. package/README.md +0 -41
  16. package/base.css +0 -1
  17. package/colors.d.ts +0 -3
  18. package/colors.js +0 -2
  19. package/components.css +0 -1
  20. package/defaultConfig.d.ts +0 -3
  21. package/defaultConfig.js +0 -2
  22. package/defaultTheme.d.ts +0 -4
  23. package/defaultTheme.js +0 -2
  24. package/lib/cli/build/deps.js +0 -62
  25. package/lib/cli/build/index.js +0 -54
  26. package/lib/cli/build/plugin.js +0 -383
  27. package/lib/cli/build/utils.js +0 -88
  28. package/lib/cli/build/watching.js +0 -182
  29. package/lib/cli/help/index.js +0 -73
  30. package/lib/cli/index.js +0 -230
  31. package/lib/cli/init/index.js +0 -67
  32. package/lib/cli-peer-dependencies.js +0 -36
  33. package/lib/cli.js +0 -7
  34. package/lib/corePluginList.js +0 -187
  35. package/lib/corePlugins.js +0 -4173
  36. package/lib/css/LICENSE +0 -25
  37. package/lib/css/preflight.css +0 -375
  38. package/lib/featureFlags.js +0 -83
  39. package/lib/index.js +0 -2
  40. package/lib/lib/cacheInvalidation.js +0 -92
  41. package/lib/lib/collapseAdjacentRules.js +0 -61
  42. package/lib/lib/collapseDuplicateDeclarations.js +0 -85
  43. package/lib/lib/content.js +0 -202
  44. package/lib/lib/defaultExtractor.js +0 -243
  45. package/lib/lib/detectNesting.js +0 -45
  46. package/lib/lib/evaluateTailwindFunctions.js +0 -238
  47. package/lib/lib/expandApplyAtRules.js +0 -534
  48. package/lib/lib/expandTailwindAtRules.js +0 -274
  49. package/lib/lib/findAtConfigPath.js +0 -46
  50. package/lib/lib/generateRules.js +0 -882
  51. package/lib/lib/getModuleDependencies.js +0 -99
  52. package/lib/lib/handleImportAtRules.js +0 -49
  53. package/lib/lib/load-config.js +0 -42
  54. package/lib/lib/normalizeTailwindDirectives.js +0 -91
  55. package/lib/lib/offsets.js +0 -306
  56. package/lib/lib/partitionApplyAtRules.js +0 -58
  57. package/lib/lib/regex.js +0 -74
  58. package/lib/lib/remap-bitfield.js +0 -89
  59. package/lib/lib/resolveDefaultsAtRules.js +0 -165
  60. package/lib/lib/setupContextUtils.js +0 -1255
  61. package/lib/lib/setupTrackingContext.js +0 -165
  62. package/lib/lib/sharedState.js +0 -87
  63. package/lib/lib/substituteScreenAtRules.js +0 -31
  64. package/lib/oxide/cli/build/deps.js +0 -89
  65. package/lib/oxide/cli/build/index.js +0 -53
  66. package/lib/oxide/cli/build/plugin.js +0 -354
  67. package/lib/oxide/cli/build/utils.js +0 -87
  68. package/lib/oxide/cli/build/watching.js +0 -179
  69. package/lib/oxide/cli/help/index.js +0 -72
  70. package/lib/oxide/cli/index.js +0 -214
  71. package/lib/oxide/cli/init/index.js +0 -56
  72. package/lib/oxide/cli.js +0 -5
  73. package/lib/oxide/postcss-plugin.js +0 -2
  74. package/lib/plugin.js +0 -100
  75. package/lib/postcss-plugins/nesting/README.md +0 -42
  76. package/lib/postcss-plugins/nesting/index.js +0 -21
  77. package/lib/postcss-plugins/nesting/plugin.js +0 -89
  78. package/lib/processTailwindFeatures.js +0 -64
  79. package/lib/public/colors.js +0 -355
  80. package/lib/public/create-plugin.js +0 -17
  81. package/lib/public/default-config.js +0 -18
  82. package/lib/public/default-theme.js +0 -18
  83. package/lib/public/load-config.js +0 -12
  84. package/lib/public/resolve-config.js +0 -24
  85. package/lib/util/applyImportantSelector.js +0 -36
  86. package/lib/util/bigSign.js +0 -13
  87. package/lib/util/buildMediaQuery.js +0 -27
  88. package/lib/util/cloneDeep.js +0 -22
  89. package/lib/util/cloneNodes.js +0 -34
  90. package/lib/util/color.js +0 -116
  91. package/lib/util/colorNames.js +0 -752
  92. package/lib/util/configurePlugins.js +0 -23
  93. package/lib/util/createPlugin.js +0 -32
  94. package/lib/util/createUtilityPlugin.js +0 -53
  95. package/lib/util/dataTypes.js +0 -304
  96. package/lib/util/defaults.js +0 -27
  97. package/lib/util/escapeClassName.js +0 -24
  98. package/lib/util/escapeCommas.js +0 -13
  99. package/lib/util/flattenColorPalette.js +0 -18
  100. package/lib/util/formatVariantSelector.js +0 -263
  101. package/lib/util/getAllConfigs.js +0 -52
  102. package/lib/util/hashConfig.js +0 -21
  103. package/lib/util/isKeyframeRule.js +0 -13
  104. package/lib/util/isPlainObject.js +0 -17
  105. package/lib/util/isSyntacticallyValidPropertyValue.js +0 -74
  106. package/lib/util/log.js +0 -61
  107. package/lib/util/nameClass.js +0 -49
  108. package/lib/util/negateValue.js +0 -36
  109. package/lib/util/normalizeConfig.js +0 -304
  110. package/lib/util/normalizeScreens.js +0 -178
  111. package/lib/util/parseAnimationValue.js +0 -93
  112. package/lib/util/parseBoxShadowValue.js +0 -88
  113. package/lib/util/parseDependency.js +0 -47
  114. package/lib/util/parseGlob.js +0 -36
  115. package/lib/util/parseObjectStyles.js +0 -36
  116. package/lib/util/pluginUtils.js +0 -276
  117. package/lib/util/prefixSelector.js +0 -39
  118. package/lib/util/pseudoElements.js +0 -229
  119. package/lib/util/removeAlphaVariables.js +0 -31
  120. package/lib/util/resolveConfig.js +0 -256
  121. package/lib/util/resolveConfigPath.js +0 -70
  122. package/lib/util/responsive.js +0 -24
  123. package/lib/util/splitAtTopLevelOnly.js +0 -51
  124. package/lib/util/tap.js +0 -14
  125. package/lib/util/toColorValue.js +0 -13
  126. package/lib/util/toPath.js +0 -32
  127. package/lib/util/transformThemeValue.js +0 -73
  128. package/lib/util/validateConfig.js +0 -43
  129. package/lib/util/validateFormalSyntax.js +0 -26
  130. package/lib/util/withAlphaVariable.js +0 -79
  131. package/lib/value-parser/LICENSE +0 -22
  132. package/lib/value-parser/README.md +0 -3
  133. package/lib/value-parser/index.d.js +0 -2
  134. package/lib/value-parser/index.js +0 -22
  135. package/lib/value-parser/parse.js +0 -259
  136. package/lib/value-parser/stringify.js +0 -38
  137. package/lib/value-parser/unit.js +0 -86
  138. package/lib/value-parser/walk.js +0 -16
  139. package/loadConfig.d.ts +0 -4
  140. package/loadConfig.js +0 -2
  141. package/nesting/index.js +0 -2
  142. package/peers/index.js +0 -96294
  143. package/plugin.d.ts +0 -11
  144. package/plugin.js +0 -2
  145. package/prettier.config.js +0 -19
  146. package/resolveConfig.d.ts +0 -12
  147. package/resolveConfig.js +0 -2
  148. package/screens.css +0 -1
  149. package/scripts/create-plugin-list.js +0 -10
  150. package/scripts/generate-types.js +0 -105
  151. package/scripts/release-channel.js +0 -18
  152. package/scripts/release-notes.js +0 -21
  153. package/scripts/swap-engines.js +0 -40
  154. package/scripts/type-utils.js +0 -27
  155. package/src/cli/build/deps.js +0 -56
  156. package/src/cli/build/index.js +0 -49
  157. package/src/cli/build/plugin.js +0 -451
  158. package/src/cli/build/utils.js +0 -76
  159. package/src/cli/build/watching.js +0 -229
  160. package/src/cli/help/index.js +0 -70
  161. package/src/cli/index.js +0 -216
  162. package/src/cli/init/index.js +0 -84
  163. package/src/cli-peer-dependencies.js +0 -15
  164. package/src/cli.js +0 -7
  165. package/src/corePluginList.js +0 -1
  166. package/src/corePlugins.js +0 -2849
  167. package/src/css/LICENSE +0 -25
  168. package/src/css/preflight.css +0 -375
  169. package/src/featureFlags.js +0 -70
  170. package/src/index.js +0 -1
  171. package/src/lib/cacheInvalidation.js +0 -52
  172. package/src/lib/collapseAdjacentRules.js +0 -58
  173. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  174. package/src/lib/content.js +0 -235
  175. package/src/lib/defaultExtractor.js +0 -217
  176. package/src/lib/detectNesting.js +0 -47
  177. package/src/lib/evaluateTailwindFunctions.js +0 -272
  178. package/src/lib/expandApplyAtRules.js +0 -613
  179. package/src/lib/expandTailwindAtRules.js +0 -283
  180. package/src/lib/findAtConfigPath.js +0 -48
  181. package/src/lib/generateRules.js +0 -927
  182. package/src/lib/getModuleDependencies.js +0 -79
  183. package/src/lib/handleImportAtRules.js +0 -33
  184. package/src/lib/load-config.ts +0 -31
  185. package/src/lib/normalizeTailwindDirectives.js +0 -86
  186. package/src/lib/offsets.js +0 -373
  187. package/src/lib/partitionApplyAtRules.js +0 -52
  188. package/src/lib/regex.js +0 -74
  189. package/src/lib/remap-bitfield.js +0 -82
  190. package/src/lib/resolveDefaultsAtRules.js +0 -163
  191. package/src/lib/setupContextUtils.js +0 -1327
  192. package/src/lib/setupTrackingContext.js +0 -171
  193. package/src/lib/sharedState.js +0 -61
  194. package/src/lib/substituteScreenAtRules.js +0 -19
  195. package/src/oxide/cli/build/deps.ts +0 -91
  196. package/src/oxide/cli/build/index.ts +0 -47
  197. package/src/oxide/cli/build/plugin.ts +0 -419
  198. package/src/oxide/cli/build/utils.ts +0 -74
  199. package/src/oxide/cli/build/watching.ts +0 -225
  200. package/src/oxide/cli/help/index.ts +0 -69
  201. package/src/oxide/cli/index.ts +0 -204
  202. package/src/oxide/cli/init/index.ts +0 -64
  203. package/src/oxide/cli.ts +0 -1
  204. package/src/oxide/postcss-plugin.ts +0 -1
  205. package/src/plugin.js +0 -109
  206. package/src/postcss-plugins/nesting/README.md +0 -42
  207. package/src/postcss-plugins/nesting/index.js +0 -13
  208. package/src/postcss-plugins/nesting/plugin.js +0 -80
  209. package/src/processTailwindFeatures.js +0 -58
  210. package/src/public/colors.js +0 -322
  211. package/src/public/create-plugin.js +0 -2
  212. package/src/public/default-config.js +0 -4
  213. package/src/public/default-theme.js +0 -4
  214. package/src/public/load-config.js +0 -2
  215. package/src/public/resolve-config.js +0 -7
  216. package/src/util/applyImportantSelector.js +0 -27
  217. package/src/util/bigSign.js +0 -3
  218. package/src/util/buildMediaQuery.js +0 -22
  219. package/src/util/cloneDeep.js +0 -11
  220. package/src/util/cloneNodes.js +0 -28
  221. package/src/util/color.js +0 -88
  222. package/src/util/colorNames.js +0 -150
  223. package/src/util/configurePlugins.js +0 -23
  224. package/src/util/createPlugin.js +0 -27
  225. package/src/util/createUtilityPlugin.js +0 -37
  226. package/src/util/dataTypes.js +0 -292
  227. package/src/util/defaults.js +0 -17
  228. package/src/util/escapeClassName.js +0 -8
  229. package/src/util/escapeCommas.js +0 -3
  230. package/src/util/flattenColorPalette.js +0 -13
  231. package/src/util/formatVariantSelector.js +0 -316
  232. package/src/util/getAllConfigs.js +0 -45
  233. package/src/util/hashConfig.js +0 -5
  234. package/src/util/isKeyframeRule.js +0 -3
  235. package/src/util/isPlainObject.js +0 -8
  236. package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
  237. package/src/util/log.js +0 -29
  238. package/src/util/nameClass.js +0 -30
  239. package/src/util/negateValue.js +0 -24
  240. package/src/util/normalizeConfig.js +0 -335
  241. package/src/util/normalizeScreens.js +0 -140
  242. package/src/util/parseAnimationValue.js +0 -68
  243. package/src/util/parseBoxShadowValue.js +0 -72
  244. package/src/util/parseDependency.js +0 -44
  245. package/src/util/parseGlob.js +0 -24
  246. package/src/util/parseObjectStyles.js +0 -19
  247. package/src/util/pluginUtils.js +0 -291
  248. package/src/util/prefixSelector.js +0 -32
  249. package/src/util/pseudoElements.js +0 -170
  250. package/src/util/removeAlphaVariables.js +0 -24
  251. package/src/util/resolveConfig.js +0 -277
  252. package/src/util/resolveConfigPath.js +0 -66
  253. package/src/util/responsive.js +0 -10
  254. package/src/util/splitAtTopLevelOnly.js +0 -52
  255. package/src/util/tap.js +0 -4
  256. package/src/util/toColorValue.js +0 -3
  257. package/src/util/toPath.js +0 -26
  258. package/src/util/transformThemeValue.js +0 -62
  259. package/src/util/validateConfig.js +0 -33
  260. package/src/util/validateFormalSyntax.js +0 -34
  261. package/src/util/withAlphaVariable.js +0 -49
  262. package/src/value-parser/LICENSE +0 -22
  263. package/src/value-parser/README.md +0 -3
  264. package/src/value-parser/index.d.ts +0 -177
  265. package/src/value-parser/index.js +0 -28
  266. package/src/value-parser/parse.js +0 -303
  267. package/src/value-parser/stringify.js +0 -41
  268. package/src/value-parser/unit.js +0 -118
  269. package/src/value-parser/walk.js +0 -18
  270. package/stubs/.gitignore +0 -1
  271. package/stubs/.prettierrc.json +0 -6
  272. package/stubs/config.full.js +0 -991
  273. package/stubs/config.simple.js +0 -7
  274. package/stubs/postcss.config.cjs +0 -6
  275. package/stubs/postcss.config.js +0 -6
  276. package/stubs/tailwind.config.cjs +0 -2
  277. package/stubs/tailwind.config.js +0 -2
  278. package/stubs/tailwind.config.ts +0 -3
  279. package/tailwind.css +0 -5
  280. package/types/config.d.ts +0 -368
  281. package/types/generated/.gitkeep +0 -0
  282. package/types/generated/colors.d.ts +0 -298
  283. package/types/generated/corePluginList.d.ts +0 -1
  284. package/types/generated/default-theme.d.ts +0 -372
  285. package/types/index.d.ts +0 -7
  286. package/variants.css +0 -1
@@ -1,1255 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- isValidVariantFormatString: function() {
13
- return isValidVariantFormatString;
14
- },
15
- parseVariant: function() {
16
- return parseVariant;
17
- },
18
- getFileModifiedMap: function() {
19
- return getFileModifiedMap;
20
- },
21
- createContext: function() {
22
- return createContext;
23
- },
24
- getContext: function() {
25
- return getContext;
26
- }
27
- });
28
- const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
29
- const _url = /*#__PURE__*/ _interop_require_default(require("url"));
30
- const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
31
- const _dlv = /*#__PURE__*/ _interop_require_default(require("dlv"));
32
- const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
33
- const _transformThemeValue = /*#__PURE__*/ _interop_require_default(require("../util/transformThemeValue"));
34
- const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
35
- const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
36
- const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
37
- const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
38
- const _nameClass = /*#__PURE__*/ _interop_require_wildcard(require("../util/nameClass"));
39
- const _pluginUtils = require("../util/pluginUtils");
40
- const _corePlugins = require("../corePlugins");
41
- const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
42
- const _toPath = require("../util/toPath");
43
- const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
44
- const _negateValue = /*#__PURE__*/ _interop_require_default(require("../util/negateValue"));
45
- const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
46
- const _generateRules = require("./generateRules");
47
- const _cacheInvalidation = require("./cacheInvalidation.js");
48
- const _offsets = require("./offsets.js");
49
- const _featureFlags = require("../featureFlags.js");
50
- const _formatVariantSelector = require("../util/formatVariantSelector");
51
- function _interop_require_default(obj) {
52
- return obj && obj.__esModule ? obj : {
53
- default: obj
54
- };
55
- }
56
- function _getRequireWildcardCache(nodeInterop) {
57
- if (typeof WeakMap !== "function") return null;
58
- var cacheBabelInterop = new WeakMap();
59
- var cacheNodeInterop = new WeakMap();
60
- return (_getRequireWildcardCache = function(nodeInterop) {
61
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
62
- })(nodeInterop);
63
- }
64
- function _interop_require_wildcard(obj, nodeInterop) {
65
- if (!nodeInterop && obj && obj.__esModule) {
66
- return obj;
67
- }
68
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
69
- return {
70
- default: obj
71
- };
72
- }
73
- var cache = _getRequireWildcardCache(nodeInterop);
74
- if (cache && cache.has(obj)) {
75
- return cache.get(obj);
76
- }
77
- var newObj = {};
78
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
79
- for(var key in obj){
80
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
81
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
82
- if (desc && (desc.get || desc.set)) {
83
- Object.defineProperty(newObj, key, desc);
84
- } else {
85
- newObj[key] = obj[key];
86
- }
87
- }
88
- }
89
- newObj.default = obj;
90
- if (cache) {
91
- cache.set(obj, newObj);
92
- }
93
- return newObj;
94
- }
95
- const VARIANT_TYPES = {
96
- AddVariant: Symbol.for("ADD_VARIANT"),
97
- MatchVariant: Symbol.for("MATCH_VARIANT")
98
- };
99
- const VARIANT_INFO = {
100
- Base: 1 << 0,
101
- Dynamic: 1 << 1
102
- };
103
- function prefix(context, selector) {
104
- let prefix = context.tailwindConfig.prefix;
105
- return typeof prefix === "function" ? prefix(selector) : prefix + selector;
106
- }
107
- function normalizeOptionTypes({ type ="any" , ...options }) {
108
- let types = [].concat(type);
109
- return {
110
- ...options,
111
- types: types.map((type)=>{
112
- if (Array.isArray(type)) {
113
- return {
114
- type: type[0],
115
- ...type[1]
116
- };
117
- }
118
- return {
119
- type,
120
- preferOnConflict: false
121
- };
122
- })
123
- };
124
- }
125
- function parseVariantFormatString(input) {
126
- /** @type {string[]} */ let parts = [];
127
- // When parsing whitespace around special characters are insignificant
128
- // However, _inside_ of a variant they could be
129
- // Because the selector could look like this
130
- // @media { &[data-name="foo bar"] }
131
- // This is why we do not skip whitespace
132
- let current = "";
133
- let depth = 0;
134
- for(let idx = 0; idx < input.length; idx++){
135
- let char = input[idx];
136
- if (char === "\\") {
137
- // Escaped characters are not special
138
- current += "\\" + input[++idx];
139
- } else if (char === "{") {
140
- // Nested rule: start
141
- ++depth;
142
- parts.push(current.trim());
143
- current = "";
144
- } else if (char === "}") {
145
- // Nested rule: end
146
- if (--depth < 0) {
147
- throw new Error(`Your { and } are unbalanced.`);
148
- }
149
- parts.push(current.trim());
150
- current = "";
151
- } else {
152
- // Normal character
153
- current += char;
154
- }
155
- }
156
- if (current.length > 0) {
157
- parts.push(current.trim());
158
- }
159
- parts = parts.filter((part)=>part !== "");
160
- return parts;
161
- }
162
- function insertInto(list, value, { before =[] } = {}) {
163
- before = [].concat(before);
164
- if (before.length <= 0) {
165
- list.push(value);
166
- return;
167
- }
168
- let idx = list.length - 1;
169
- for (let other of before){
170
- let iidx = list.indexOf(other);
171
- if (iidx === -1) continue;
172
- idx = Math.min(idx, iidx);
173
- }
174
- list.splice(idx, 0, value);
175
- }
176
- function parseStyles(styles) {
177
- if (!Array.isArray(styles)) {
178
- return parseStyles([
179
- styles
180
- ]);
181
- }
182
- return styles.flatMap((style)=>{
183
- let isNode = !Array.isArray(style) && !(0, _isPlainObject.default)(style);
184
- return isNode ? style : (0, _parseObjectStyles.default)(style);
185
- });
186
- }
187
- function getClasses(selector, mutate) {
188
- let parser = (0, _postcssselectorparser.default)((selectors)=>{
189
- let allClasses = [];
190
- if (mutate) {
191
- mutate(selectors);
192
- }
193
- selectors.walkClasses((classNode)=>{
194
- allClasses.push(classNode.value);
195
- });
196
- return allClasses;
197
- });
198
- return parser.transformSync(selector);
199
- }
200
- function extractCandidates(node, state = {
201
- containsNonOnDemandable: false
202
- }, depth = 0) {
203
- let classes = [];
204
- // Handle normal rules
205
- if (node.type === "rule") {
206
- // Ignore everything inside a :not(...). This allows you to write code like
207
- // `div:not(.foo)`. If `.foo` is never found in your code, then we used to
208
- // not generated it. But now we will ignore everything inside a `:not`, so
209
- // that it still gets generated.
210
- function ignoreNot(selectors) {
211
- selectors.walkPseudos((pseudo)=>{
212
- if (pseudo.value === ":not") {
213
- pseudo.remove();
214
- }
215
- });
216
- }
217
- for (let selector of node.selectors){
218
- let classCandidates = getClasses(selector, ignoreNot);
219
- // At least one of the selectors contains non-"on-demandable" candidates.
220
- if (classCandidates.length === 0) {
221
- state.containsNonOnDemandable = true;
222
- }
223
- for (let classCandidate of classCandidates){
224
- classes.push(classCandidate);
225
- }
226
- }
227
- } else if (node.type === "atrule") {
228
- node.walkRules((rule)=>{
229
- for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
230
- classes.push(classCandidate);
231
- }
232
- });
233
- }
234
- if (depth === 0) {
235
- return [
236
- state.containsNonOnDemandable || classes.length === 0,
237
- classes
238
- ];
239
- }
240
- return classes;
241
- }
242
- function withIdentifiers(styles) {
243
- return parseStyles(styles).flatMap((node)=>{
244
- let nodeMap = new Map();
245
- let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
246
- // If this isn't "on-demandable", assign it a universal candidate to always include it.
247
- if (containsNonOnDemandableSelectors) {
248
- candidates.unshift(_sharedState.NOT_ON_DEMAND);
249
- }
250
- // However, it could be that it also contains "on-demandable" candidates.
251
- // E.g.: `span, .foo {}`, in that case it should still be possible to use
252
- // `@apply foo` for example.
253
- return candidates.map((c)=>{
254
- if (!nodeMap.has(node)) {
255
- nodeMap.set(node, node);
256
- }
257
- return [
258
- c,
259
- nodeMap.get(node)
260
- ];
261
- });
262
- });
263
- }
264
- function isValidVariantFormatString(format) {
265
- return format.startsWith("@") || format.includes("&");
266
- }
267
- function parseVariant(variant) {
268
- variant = variant.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
269
- let fns = parseVariantFormatString(variant).map((str)=>{
270
- if (!str.startsWith("@")) {
271
- return ({ format })=>format(str);
272
- }
273
- let [, name, params] = /@(.*?)( .+|[({].*)/g.exec(str);
274
- return ({ wrap })=>wrap(_postcss.default.atRule({
275
- name,
276
- params: params.trim()
277
- }));
278
- }).reverse();
279
- return (api)=>{
280
- for (let fn of fns){
281
- fn(api);
282
- }
283
- };
284
- }
285
- /**
286
- *
287
- * @param {any} tailwindConfig
288
- * @param {any} context
289
- * @param {object} param2
290
- * @param {Offsets} param2.offsets
291
- */ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
292
- function getConfigValue(path, defaultValue) {
293
- return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
294
- }
295
- function applyConfiguredPrefix(selector) {
296
- return (0, _prefixSelector.default)(tailwindConfig.prefix, selector);
297
- }
298
- function prefixIdentifier(identifier, options) {
299
- if (identifier === _sharedState.NOT_ON_DEMAND) {
300
- return _sharedState.NOT_ON_DEMAND;
301
- }
302
- if (!options.respectPrefix) {
303
- return identifier;
304
- }
305
- return context.tailwindConfig.prefix + identifier;
306
- }
307
- function resolveThemeValue(path, defaultValue, opts = {}) {
308
- let parts = (0, _toPath.toPath)(path);
309
- let value = getConfigValue([
310
- "theme",
311
- ...parts
312
- ], defaultValue);
313
- return (0, _transformThemeValue.default)(parts[0])(value, opts);
314
- }
315
- let variantIdentifier = 0;
316
- let api = {
317
- postcss: _postcss.default,
318
- prefix: applyConfiguredPrefix,
319
- e: _escapeClassName.default,
320
- config: getConfigValue,
321
- theme: resolveThemeValue,
322
- corePlugins: (path)=>{
323
- if (Array.isArray(tailwindConfig.corePlugins)) {
324
- return tailwindConfig.corePlugins.includes(path);
325
- }
326
- return getConfigValue([
327
- "corePlugins",
328
- path
329
- ], true);
330
- },
331
- variants: ()=>{
332
- // Preserved for backwards compatibility but not used in v3.0+
333
- return [];
334
- },
335
- addBase (base) {
336
- for (let [identifier, rule] of withIdentifiers(base)){
337
- let prefixedIdentifier = prefixIdentifier(identifier, {});
338
- let offset = offsets.create("base");
339
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
340
- context.candidateRuleMap.set(prefixedIdentifier, []);
341
- }
342
- context.candidateRuleMap.get(prefixedIdentifier).push([
343
- {
344
- sort: offset,
345
- layer: "base"
346
- },
347
- rule
348
- ]);
349
- }
350
- },
351
- /**
352
- * @param {string} group
353
- * @param {Record<string, string | string[]>} declarations
354
- */ addDefaults (group, declarations) {
355
- const groups = {
356
- [`@defaults ${group}`]: declarations
357
- };
358
- for (let [identifier, rule] of withIdentifiers(groups)){
359
- let prefixedIdentifier = prefixIdentifier(identifier, {});
360
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
361
- context.candidateRuleMap.set(prefixedIdentifier, []);
362
- }
363
- context.candidateRuleMap.get(prefixedIdentifier).push([
364
- {
365
- sort: offsets.create("defaults"),
366
- layer: "defaults"
367
- },
368
- rule
369
- ]);
370
- }
371
- },
372
- addComponents (components, options) {
373
- let defaultOptions = {
374
- preserveSource: false,
375
- respectPrefix: true,
376
- respectImportant: false
377
- };
378
- options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
379
- for (let [identifier, rule] of withIdentifiers(components)){
380
- let prefixedIdentifier = prefixIdentifier(identifier, options);
381
- classList.add(prefixedIdentifier);
382
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
383
- context.candidateRuleMap.set(prefixedIdentifier, []);
384
- }
385
- context.candidateRuleMap.get(prefixedIdentifier).push([
386
- {
387
- sort: offsets.create("components"),
388
- layer: "components",
389
- options
390
- },
391
- rule
392
- ]);
393
- }
394
- },
395
- addUtilities (utilities, options) {
396
- let defaultOptions = {
397
- preserveSource: false,
398
- respectPrefix: true,
399
- respectImportant: true
400
- };
401
- options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
402
- for (let [identifier, rule] of withIdentifiers(utilities)){
403
- let prefixedIdentifier = prefixIdentifier(identifier, options);
404
- classList.add(prefixedIdentifier);
405
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
406
- context.candidateRuleMap.set(prefixedIdentifier, []);
407
- }
408
- context.candidateRuleMap.get(prefixedIdentifier).push([
409
- {
410
- sort: offsets.create("utilities"),
411
- layer: "utilities",
412
- options
413
- },
414
- rule
415
- ]);
416
- }
417
- },
418
- matchUtilities: function(utilities, options) {
419
- let defaultOptions = {
420
- respectPrefix: true,
421
- respectImportant: true,
422
- modifiers: false
423
- };
424
- options = normalizeOptionTypes({
425
- ...defaultOptions,
426
- ...options
427
- });
428
- let offset = offsets.create("utilities");
429
- for(let identifier in utilities){
430
- let prefixedIdentifier = prefixIdentifier(identifier, options);
431
- let rule = utilities[identifier];
432
- classList.add([
433
- prefixedIdentifier,
434
- options
435
- ]);
436
- function wrapped(modifier, { isOnlyPlugin }) {
437
- let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
438
- if (value === undefined) {
439
- return [];
440
- }
441
- if (!options.types.some(({ type })=>type === coercedType)) {
442
- if (isOnlyPlugin) {
443
- _log.default.warn([
444
- `Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
445
- `You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
446
- ]);
447
- } else {
448
- return [];
449
- }
450
- }
451
- if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
452
- return [];
453
- }
454
- let extras = {
455
- get modifier () {
456
- if (!options.modifiers) {
457
- _log.default.warn(`modifier-used-without-options-for-${identifier}`, [
458
- "Your plugin must set `modifiers: true` in its options to support modifiers."
459
- ]);
460
- }
461
- return utilityModifier;
462
- }
463
- };
464
- let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
465
- let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
466
- [(0, _nameClass.default)(identifier, modifier)]: declaration
467
- }));
468
- return ruleSets;
469
- }
470
- let withOffsets = [
471
- {
472
- sort: offset,
473
- layer: "utilities",
474
- options
475
- },
476
- wrapped
477
- ];
478
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
479
- context.candidateRuleMap.set(prefixedIdentifier, []);
480
- }
481
- context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
482
- }
483
- },
484
- matchComponents: function(components, options) {
485
- let defaultOptions = {
486
- respectPrefix: true,
487
- respectImportant: false,
488
- modifiers: false
489
- };
490
- options = normalizeOptionTypes({
491
- ...defaultOptions,
492
- ...options
493
- });
494
- let offset = offsets.create("components");
495
- for(let identifier in components){
496
- let prefixedIdentifier = prefixIdentifier(identifier, options);
497
- let rule = components[identifier];
498
- classList.add([
499
- prefixedIdentifier,
500
- options
501
- ]);
502
- function wrapped(modifier, { isOnlyPlugin }) {
503
- let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
504
- if (value === undefined) {
505
- return [];
506
- }
507
- if (!options.types.some(({ type })=>type === coercedType)) {
508
- if (isOnlyPlugin) {
509
- _log.default.warn([
510
- `Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
511
- `You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
512
- ]);
513
- } else {
514
- return [];
515
- }
516
- }
517
- if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
518
- return [];
519
- }
520
- let extras = {
521
- get modifier () {
522
- if (!options.modifiers) {
523
- _log.default.warn(`modifier-used-without-options-for-${identifier}`, [
524
- "Your plugin must set `modifiers: true` in its options to support modifiers."
525
- ]);
526
- }
527
- return utilityModifier;
528
- }
529
- };
530
- let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
531
- let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
532
- [(0, _nameClass.default)(identifier, modifier)]: declaration
533
- }));
534
- return ruleSets;
535
- }
536
- let withOffsets = [
537
- {
538
- sort: offset,
539
- layer: "components",
540
- options
541
- },
542
- wrapped
543
- ];
544
- if (!context.candidateRuleMap.has(prefixedIdentifier)) {
545
- context.candidateRuleMap.set(prefixedIdentifier, []);
546
- }
547
- context.candidateRuleMap.get(prefixedIdentifier).push(withOffsets);
548
- }
549
- },
550
- addVariant (variantName, variantFunctions, options = {}) {
551
- variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
552
- if (typeof variantFunction !== "string") {
553
- // Safelist public API functions
554
- return (api = {})=>{
555
- let { args , modifySelectors , container , separator , wrap , format } = api;
556
- let result = variantFunction(Object.assign({
557
- modifySelectors,
558
- container,
559
- separator
560
- }, options.type === VARIANT_TYPES.MatchVariant && {
561
- args,
562
- wrap,
563
- format
564
- }));
565
- if (typeof result === "string" && !isValidVariantFormatString(result)) {
566
- throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
567
- }
568
- if (Array.isArray(result)) {
569
- return result.filter((variant)=>typeof variant === "string").map((variant)=>parseVariant(variant));
570
- }
571
- // result may be undefined with legacy variants that use APIs like `modifySelectors`
572
- // result may also be a postcss node if someone was returning the result from `modifySelectors`
573
- return result && typeof result === "string" && parseVariant(result)(api);
574
- };
575
- }
576
- if (!isValidVariantFormatString(variantFunction)) {
577
- throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
578
- }
579
- return parseVariant(variantFunction);
580
- });
581
- insertInto(variantList, variantName, options);
582
- variantMap.set(variantName, variantFunctions);
583
- context.variantOptions.set(variantName, options);
584
- },
585
- matchVariant (variant, variantFn, options) {
586
- var _options_id;
587
- // A unique identifier that "groups" these variants together.
588
- // This is for internal use only which is why it is not present in the types
589
- let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
590
- let isSpecial = variant === "@";
591
- let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
592
- var _options_values;
593
- for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
594
- if (key === "DEFAULT") continue;
595
- api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
596
- return variantFn(value, modifiersEnabled ? {
597
- modifier: args === null || args === void 0 ? void 0 : args.modifier,
598
- container
599
- } : {
600
- container
601
- });
602
- }, {
603
- ...options,
604
- value,
605
- id,
606
- type: VARIANT_TYPES.MatchVariant,
607
- variantInfo: VARIANT_INFO.Base
608
- });
609
- }
610
- var _options_values1;
611
- let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
612
- api.addVariant(variant, ({ args , container })=>{
613
- if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
614
- return null;
615
- }
616
- var // (JetBrains) plugins.
617
- _args_value;
618
- return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", modifiersEnabled ? {
619
- modifier: args === null || args === void 0 ? void 0 : args.modifier,
620
- container
621
- } : {
622
- container
623
- });
624
- }, {
625
- ...options,
626
- id,
627
- type: VARIANT_TYPES.MatchVariant,
628
- variantInfo: VARIANT_INFO.Dynamic
629
- });
630
- }
631
- };
632
- return api;
633
- }
634
- let fileModifiedMapCache = new WeakMap();
635
- function getFileModifiedMap(context) {
636
- if (!fileModifiedMapCache.has(context)) {
637
- fileModifiedMapCache.set(context, new Map());
638
- }
639
- return fileModifiedMapCache.get(context);
640
- }
641
- function trackModified(files, fileModifiedMap) {
642
- let changed = false;
643
- let mtimesToCommit = new Map();
644
- for (let file of files){
645
- var _fs_statSync;
646
- if (!file) continue;
647
- let parsed = _url.default.parse(file);
648
- let pathname = parsed.hash ? parsed.href.replace(parsed.hash, "") : parsed.href;
649
- pathname = parsed.search ? pathname.replace(parsed.search, "") : pathname;
650
- let newModified = (_fs_statSync = _fs.default.statSync(decodeURIComponent(pathname), {
651
- throwIfNoEntry: false
652
- })) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
653
- if (!newModified) {
654
- continue;
655
- }
656
- if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
657
- changed = true;
658
- }
659
- mtimesToCommit.set(file, newModified);
660
- }
661
- return [
662
- changed,
663
- mtimesToCommit
664
- ];
665
- }
666
- function extractVariantAtRules(node) {
667
- node.walkAtRules((atRule)=>{
668
- if ([
669
- "responsive",
670
- "variants"
671
- ].includes(atRule.name)) {
672
- extractVariantAtRules(atRule);
673
- atRule.before(atRule.nodes);
674
- atRule.remove();
675
- }
676
- });
677
- }
678
- function collectLayerPlugins(root) {
679
- let layerPlugins = [];
680
- root.each((node)=>{
681
- if (node.type === "atrule" && [
682
- "responsive",
683
- "variants"
684
- ].includes(node.name)) {
685
- node.name = "layer";
686
- node.params = "utilities";
687
- }
688
- });
689
- // Walk @layer rules and treat them like plugins
690
- root.walkAtRules("layer", (layerRule)=>{
691
- extractVariantAtRules(layerRule);
692
- if (layerRule.params === "base") {
693
- for (let node of layerRule.nodes){
694
- layerPlugins.push(function({ addBase }) {
695
- addBase(node, {
696
- respectPrefix: false
697
- });
698
- });
699
- }
700
- layerRule.remove();
701
- } else if (layerRule.params === "components") {
702
- for (let node of layerRule.nodes){
703
- layerPlugins.push(function({ addComponents }) {
704
- addComponents(node, {
705
- respectPrefix: false,
706
- preserveSource: true
707
- });
708
- });
709
- }
710
- layerRule.remove();
711
- } else if (layerRule.params === "utilities") {
712
- for (let node of layerRule.nodes){
713
- layerPlugins.push(function({ addUtilities }) {
714
- addUtilities(node, {
715
- respectPrefix: false,
716
- preserveSource: true
717
- });
718
- });
719
- }
720
- layerRule.remove();
721
- }
722
- });
723
- return layerPlugins;
724
- }
725
- function resolvePlugins(context, root) {
726
- let corePluginList = Object.entries({
727
- ..._corePlugins.variantPlugins,
728
- ..._corePlugins.corePlugins
729
- }).map(([name, plugin])=>{
730
- if (!context.tailwindConfig.corePlugins.includes(name)) {
731
- return null;
732
- }
733
- return plugin;
734
- }).filter(Boolean);
735
- let userPlugins = context.tailwindConfig.plugins.map((plugin)=>{
736
- if (plugin.__isOptionsFunction) {
737
- plugin = plugin();
738
- }
739
- return typeof plugin === "function" ? plugin : plugin.handler;
740
- });
741
- let layerPlugins = collectLayerPlugins(root);
742
- // TODO: This is a workaround for backwards compatibility, since custom variants
743
- // were historically sorted before screen/stackable variants.
744
- let beforeVariants = [
745
- _corePlugins.variantPlugins["pseudoElementVariants"],
746
- _corePlugins.variantPlugins["pseudoClassVariants"],
747
- _corePlugins.variantPlugins["ariaVariants"],
748
- _corePlugins.variantPlugins["dataVariants"]
749
- ];
750
- let afterVariants = [
751
- _corePlugins.variantPlugins["supportsVariants"],
752
- _corePlugins.variantPlugins["directionVariants"],
753
- _corePlugins.variantPlugins["reducedMotionVariants"],
754
- _corePlugins.variantPlugins["prefersContrastVariants"],
755
- _corePlugins.variantPlugins["darkVariants"],
756
- _corePlugins.variantPlugins["printVariant"],
757
- _corePlugins.variantPlugins["screenVariants"],
758
- _corePlugins.variantPlugins["orientationVariants"]
759
- ];
760
- return [
761
- ...corePluginList,
762
- ...beforeVariants,
763
- ...userPlugins,
764
- ...afterVariants,
765
- ...layerPlugins
766
- ];
767
- }
768
- function registerPlugins(plugins, context) {
769
- let variantList = [];
770
- let variantMap = new Map();
771
- context.variantMap = variantMap;
772
- let offsets = new _offsets.Offsets();
773
- context.offsets = offsets;
774
- let classList = new Set();
775
- let pluginApi = buildPluginApi(context.tailwindConfig, context, {
776
- variantList,
777
- variantMap,
778
- offsets,
779
- classList
780
- });
781
- for (let plugin of plugins){
782
- if (Array.isArray(plugin)) {
783
- for (let pluginItem of plugin){
784
- pluginItem(pluginApi);
785
- }
786
- } else {
787
- plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
788
- }
789
- }
790
- // Make sure to record bit masks for every variant
791
- offsets.recordVariants(variantList, (variant)=>variantMap.get(variant).length);
792
- // Build variantMap
793
- for (let [variantName, variantFunctions] of variantMap.entries()){
794
- context.variantMap.set(variantName, variantFunctions.map((variantFunction, idx)=>[
795
- offsets.forVariant(variantName, idx),
796
- variantFunction
797
- ]));
798
- }
799
- var _context_tailwindConfig_safelist;
800
- let safelist = ((_context_tailwindConfig_safelist = context.tailwindConfig.safelist) !== null && _context_tailwindConfig_safelist !== void 0 ? _context_tailwindConfig_safelist : []).filter(Boolean);
801
- if (safelist.length > 0) {
802
- let checks = [];
803
- for (let value of safelist){
804
- if (typeof value === "string") {
805
- context.changedContent.push({
806
- content: value,
807
- extension: "html"
808
- });
809
- continue;
810
- }
811
- if (value instanceof RegExp) {
812
- _log.default.warn("root-regex", [
813
- "Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
814
- "Update your `safelist` configuration to eliminate this warning.",
815
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
816
- ]);
817
- continue;
818
- }
819
- checks.push(value);
820
- }
821
- if (checks.length > 0) {
822
- let patternMatchingCount = new Map();
823
- let prefixLength = context.tailwindConfig.prefix.length;
824
- let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
825
- for (let util of classList){
826
- let utils = Array.isArray(util) ? (()=>{
827
- let [utilName, options] = util;
828
- var _options_values;
829
- let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
830
- let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
831
- if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
832
- // This is the normal negated version
833
- // e.g. `-inset-1` or `-tw-inset-1`
834
- classes = [
835
- ...classes,
836
- ...classes.map((cls)=>"-" + cls)
837
- ];
838
- // This is the negated version *after* the prefix
839
- // e.g. `tw--inset-1`
840
- // The prefix is already attached to util name
841
- // So we add the negative after the prefix
842
- classes = [
843
- ...classes,
844
- ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
845
- ];
846
- }
847
- if (options.types.some(({ type })=>type === "color")) {
848
- classes = [
849
- ...classes,
850
- ...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
851
- ];
852
- }
853
- if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
854
- classes = [
855
- ...classes,
856
- ...classes.map((cls)=>"!" + cls)
857
- ];
858
- }
859
- return classes;
860
- })() : [
861
- util
862
- ];
863
- for (let util of utils){
864
- for (let { pattern , variants =[] } of checks){
865
- // RegExp with the /g flag are stateful, so let's reset the last
866
- // index pointer to reset the state.
867
- pattern.lastIndex = 0;
868
- if (!patternMatchingCount.has(pattern)) {
869
- patternMatchingCount.set(pattern, 0);
870
- }
871
- if (!pattern.test(util)) continue;
872
- patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
873
- context.changedContent.push({
874
- content: util,
875
- extension: "html"
876
- });
877
- for (let variant of variants){
878
- context.changedContent.push({
879
- content: variant + context.tailwindConfig.separator + util,
880
- extension: "html"
881
- });
882
- }
883
- }
884
- }
885
- }
886
- for (let [regex, count] of patternMatchingCount.entries()){
887
- if (count !== 0) continue;
888
- _log.default.warn([
889
- `The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
890
- "Fix this pattern or remove it from your `safelist` configuration.",
891
- "https://tailwindcss.com/docs/content-configuration#safelisting-classes"
892
- ]);
893
- }
894
- }
895
- }
896
- var _context_tailwindConfig_darkMode, _concat_;
897
- let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode : "media")[1]) !== null && _concat_ !== void 0 ? _concat_ : "dark";
898
- // A list of utilities that are used by certain Tailwind CSS utilities but
899
- // that don't exist on their own. This will result in them "not existing" and
900
- // sorting could be weird since you still require them in order to make the
901
- // host utilities work properly. (Thanks Biology)
902
- let parasiteUtilities = [
903
- prefix(context, darkClassName),
904
- prefix(context, "group"),
905
- prefix(context, "peer")
906
- ];
907
- context.getClassOrder = function getClassOrder(classes) {
908
- // Sort classes so they're ordered in a deterministic manner
909
- let sorted = [
910
- ...classes
911
- ].sort((a, z)=>{
912
- if (a === z) return 0;
913
- if (a < z) return -1;
914
- return 1;
915
- });
916
- // Non-util classes won't be generated, so we default them to null
917
- let sortedClassNames = new Map(sorted.map((className)=>[
918
- className,
919
- null
920
- ]));
921
- // Sort all classes in order
922
- // Non-tailwind classes won't be generated and will be left as `null`
923
- let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
924
- rules = context.offsets.sort(rules);
925
- let idx = BigInt(parasiteUtilities.length);
926
- for (const [, rule] of rules){
927
- sortedClassNames.set(rule.raws.tailwind.candidate, idx++);
928
- }
929
- return classes.map((className)=>{
930
- var _sortedClassNames_get;
931
- let order = (_sortedClassNames_get = sortedClassNames.get(className)) !== null && _sortedClassNames_get !== void 0 ? _sortedClassNames_get : null;
932
- let parasiteIndex = parasiteUtilities.indexOf(className);
933
- if (order === null && parasiteIndex !== -1) {
934
- // This will make sure that it is at the very beginning of the
935
- // `components` layer which technically means 'before any
936
- // components'.
937
- order = BigInt(parasiteIndex);
938
- }
939
- return [
940
- className,
941
- order
942
- ];
943
- });
944
- };
945
- // Generate a list of strings for autocompletion purposes, e.g.
946
- // ['uppercase', 'lowercase', ...]
947
- context.getClassList = function getClassList(options = {}) {
948
- let output = [];
949
- for (let util of classList){
950
- if (Array.isArray(util)) {
951
- var _utilOptions_types;
952
- let [utilName, utilOptions] = util;
953
- let negativeClasses = [];
954
- var _utilOptions_modifiers;
955
- let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
956
- if (utilOptions === null || utilOptions === void 0 ? void 0 : (_utilOptions_types = utilOptions.types) === null || _utilOptions_types === void 0 ? void 0 : _utilOptions_types.some(({ type })=>type === "color")) {
957
- var _context_tailwindConfig_theme_opacity;
958
- modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
959
- }
960
- let metadata = {
961
- modifiers
962
- };
963
- let includeMetadata = options.includeMetadata && modifiers.length > 0;
964
- var _utilOptions_values;
965
- for (let [key, value] of Object.entries((_utilOptions_values = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.values) !== null && _utilOptions_values !== void 0 ? _utilOptions_values : {})){
966
- // Ignore undefined and null values
967
- if (value == null) {
968
- continue;
969
- }
970
- let cls = (0, _nameClass.formatClass)(utilName, key);
971
- output.push(includeMetadata ? [
972
- cls,
973
- metadata
974
- ] : cls);
975
- if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
976
- let cls = (0, _nameClass.formatClass)(utilName, `-${key}`);
977
- negativeClasses.push(includeMetadata ? [
978
- cls,
979
- metadata
980
- ] : cls);
981
- }
982
- }
983
- output.push(...negativeClasses);
984
- } else {
985
- output.push(util);
986
- }
987
- }
988
- return output;
989
- };
990
- // Generate a list of available variants with meta information of the type of variant.
991
- context.getVariants = function getVariants() {
992
- let result = [];
993
- for (let [name, options] of context.variantOptions.entries()){
994
- if (options.variantInfo === VARIANT_INFO.Base) continue;
995
- var _options_values;
996
- result.push({
997
- name,
998
- isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
999
- values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
1000
- hasDash: name !== "@",
1001
- selectors ({ modifier , value } = {}) {
1002
- let candidate = "__TAILWIND_PLACEHOLDER__";
1003
- let rule = _postcss.default.rule({
1004
- selector: `.${candidate}`
1005
- });
1006
- let container = _postcss.default.root({
1007
- nodes: [
1008
- rule.clone()
1009
- ]
1010
- });
1011
- let before = container.toString();
1012
- var _context_variantMap_get;
1013
- let fns = ((_context_variantMap_get = context.variantMap.get(name)) !== null && _context_variantMap_get !== void 0 ? _context_variantMap_get : []).flatMap(([_, fn])=>fn);
1014
- let formatStrings = [];
1015
- for (let fn of fns){
1016
- var _options_values;
1017
- let localFormatStrings = [];
1018
- var _options_values_value;
1019
- let api = {
1020
- args: {
1021
- modifier,
1022
- value: (_options_values_value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[value]) !== null && _options_values_value !== void 0 ? _options_values_value : value
1023
- },
1024
- separator: context.tailwindConfig.separator,
1025
- modifySelectors (modifierFunction) {
1026
- // Run the modifierFunction over each rule
1027
- container.each((rule)=>{
1028
- if (rule.type !== "rule") {
1029
- return;
1030
- }
1031
- rule.selectors = rule.selectors.map((selector)=>{
1032
- return modifierFunction({
1033
- get className () {
1034
- return (0, _generateRules.getClassNameFromSelector)(selector);
1035
- },
1036
- selector
1037
- });
1038
- });
1039
- });
1040
- return container;
1041
- },
1042
- format (str) {
1043
- localFormatStrings.push(str);
1044
- },
1045
- wrap (wrapper) {
1046
- localFormatStrings.push(`@${wrapper.name} ${wrapper.params} { & }`);
1047
- },
1048
- container
1049
- };
1050
- let ruleWithVariant = fn(api);
1051
- if (localFormatStrings.length > 0) {
1052
- formatStrings.push(localFormatStrings);
1053
- }
1054
- if (Array.isArray(ruleWithVariant)) {
1055
- for (let variantFunction of ruleWithVariant){
1056
- localFormatStrings = [];
1057
- variantFunction(api);
1058
- formatStrings.push(localFormatStrings);
1059
- }
1060
- }
1061
- }
1062
- // Reverse engineer the result of the `container`
1063
- let manualFormatStrings = [];
1064
- let after = container.toString();
1065
- if (before !== after) {
1066
- // Figure out all selectors
1067
- container.walkRules((rule)=>{
1068
- let modified = rule.selector;
1069
- // Rebuild the base selector, this is what plugin authors would do
1070
- // as well. E.g.: `${variant}${separator}${className}`.
1071
- // However, plugin authors probably also prepend or append certain
1072
- // classes, pseudos, ids, ...
1073
- let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
1074
- selectors.walkClasses((classNode)=>{
1075
- classNode.value = `${name}${context.tailwindConfig.separator}${classNode.value}`;
1076
- });
1077
- }).processSync(modified);
1078
- // Now that we know the original selector, the new selector, and
1079
- // the rebuild part in between, we can replace the part that plugin
1080
- // authors need to rebuild with `&`, and eventually store it in the
1081
- // collectedFormats. Similar to what `format('...')` would do.
1082
- //
1083
- // E.g.:
1084
- // variant: foo
1085
- // selector: .markdown > p
1086
- // modified (by plugin): .foo .foo\\:markdown > p
1087
- // rebuiltBase (internal): .foo\\:markdown > p
1088
- // format: .foo &
1089
- manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
1090
- });
1091
- // Figure out all atrules
1092
- container.walkAtRules((atrule)=>{
1093
- manualFormatStrings.push(`@${atrule.name} (${atrule.params}) { & }`);
1094
- });
1095
- }
1096
- var _options_values1;
1097
- let isArbitraryVariant = !(value in ((_options_values1 = options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {}));
1098
- formatStrings = formatStrings.map((format)=>format.map((str)=>({
1099
- format: str,
1100
- isArbitraryVariant
1101
- })));
1102
- manualFormatStrings = manualFormatStrings.map((format)=>({
1103
- format,
1104
- isArbitraryVariant
1105
- }));
1106
- let opts = {
1107
- candidate,
1108
- context
1109
- };
1110
- let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
1111
- if (manualFormatStrings.length > 0) {
1112
- result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
1113
- }
1114
- return result;
1115
- }
1116
- });
1117
- }
1118
- return result;
1119
- };
1120
- }
1121
- /**
1122
- * Mark as class as retroactively invalid
1123
- *
1124
- *
1125
- * @param {string} candidate
1126
- */ function markInvalidUtilityCandidate(context, candidate) {
1127
- if (!context.classCache.has(candidate)) {
1128
- return;
1129
- }
1130
- // Mark this as not being a real utility
1131
- context.notClassCache.add(candidate);
1132
- // Remove it from any candidate-specific caches
1133
- context.classCache.delete(candidate);
1134
- context.applyClassCache.delete(candidate);
1135
- context.candidateRuleMap.delete(candidate);
1136
- context.candidateRuleCache.delete(candidate);
1137
- // Ensure the stylesheet gets rebuilt
1138
- context.stylesheetCache = null;
1139
- }
1140
- /**
1141
- * Mark as class as retroactively invalid
1142
- *
1143
- * @param {import('postcss').Node} node
1144
- */ function markInvalidUtilityNode(context, node) {
1145
- let candidate = node.raws.tailwind.candidate;
1146
- if (!candidate) {
1147
- return;
1148
- }
1149
- for (const entry of context.ruleCache){
1150
- if (entry[1].raws.tailwind.candidate === candidate) {
1151
- context.ruleCache.delete(entry);
1152
- // context.postCssNodeCache.delete(node)
1153
- }
1154
- }
1155
- markInvalidUtilityCandidate(context, candidate);
1156
- }
1157
- function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
1158
- var _tailwindConfig_blocklist;
1159
- let context = {
1160
- disposables: [],
1161
- ruleCache: new Set(),
1162
- candidateRuleCache: new Map(),
1163
- classCache: new Map(),
1164
- applyClassCache: new Map(),
1165
- // Seed the not class cache with the blocklist (which is only strings)
1166
- notClassCache: new Set((_tailwindConfig_blocklist = tailwindConfig.blocklist) !== null && _tailwindConfig_blocklist !== void 0 ? _tailwindConfig_blocklist : []),
1167
- postCssNodeCache: new Map(),
1168
- candidateRuleMap: new Map(),
1169
- tailwindConfig,
1170
- changedContent: changedContent,
1171
- variantMap: new Map(),
1172
- stylesheetCache: null,
1173
- variantOptions: new Map(),
1174
- markInvalidUtilityCandidate: (candidate)=>markInvalidUtilityCandidate(context, candidate),
1175
- markInvalidUtilityNode: (node)=>markInvalidUtilityNode(context, node)
1176
- };
1177
- let resolvedPlugins = resolvePlugins(context, root);
1178
- registerPlugins(resolvedPlugins, context);
1179
- return context;
1180
- }
1181
- let contextMap = _sharedState.contextMap;
1182
- let configContextMap = _sharedState.configContextMap;
1183
- let contextSourcesMap = _sharedState.contextSourcesMap;
1184
- function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
1185
- let sourcePath = result.opts.from;
1186
- let isConfigFile = userConfigPath !== null;
1187
- _sharedState.env.DEBUG && console.log("Source path:", sourcePath);
1188
- let existingContext;
1189
- if (isConfigFile && contextMap.has(sourcePath)) {
1190
- existingContext = contextMap.get(sourcePath);
1191
- } else if (configContextMap.has(tailwindConfigHash)) {
1192
- let context = configContextMap.get(tailwindConfigHash);
1193
- contextSourcesMap.get(context).add(sourcePath);
1194
- contextMap.set(sourcePath, context);
1195
- existingContext = context;
1196
- }
1197
- let cssDidChange = (0, _cacheInvalidation.hasContentChanged)(sourcePath, root);
1198
- // If there's already a context in the cache and we don't need to
1199
- // reset the context, return the cached context.
1200
- if (existingContext) {
1201
- let [contextDependenciesChanged, mtimesToCommit] = trackModified([
1202
- ...contextDependencies
1203
- ], getFileModifiedMap(existingContext));
1204
- if (!contextDependenciesChanged && !cssDidChange) {
1205
- return [
1206
- existingContext,
1207
- false,
1208
- mtimesToCommit
1209
- ];
1210
- }
1211
- }
1212
- // If this source is in the context map, get the old context.
1213
- // Remove this source from the context sources for the old context,
1214
- // and clean up that context if no one else is using it. This can be
1215
- // called by many processes in rapid succession, so we check for presence
1216
- // first because the first process to run this code will wipe it out first.
1217
- if (contextMap.has(sourcePath)) {
1218
- let oldContext = contextMap.get(sourcePath);
1219
- if (contextSourcesMap.has(oldContext)) {
1220
- contextSourcesMap.get(oldContext).delete(sourcePath);
1221
- if (contextSourcesMap.get(oldContext).size === 0) {
1222
- contextSourcesMap.delete(oldContext);
1223
- for (let [tailwindConfigHash, context] of configContextMap){
1224
- if (context === oldContext) {
1225
- configContextMap.delete(tailwindConfigHash);
1226
- }
1227
- }
1228
- for (let disposable of oldContext.disposables.splice(0)){
1229
- disposable(oldContext);
1230
- }
1231
- }
1232
- }
1233
- }
1234
- _sharedState.env.DEBUG && console.log("Setting up new context...");
1235
- let context = createContext(tailwindConfig, [], root);
1236
- Object.assign(context, {
1237
- userConfigPath
1238
- });
1239
- let [, mtimesToCommit] = trackModified([
1240
- ...contextDependencies
1241
- ], getFileModifiedMap(context));
1242
- // ---
1243
- // Update all context tracking state
1244
- configContextMap.set(tailwindConfigHash, context);
1245
- contextMap.set(sourcePath, context);
1246
- if (!contextSourcesMap.has(context)) {
1247
- contextSourcesMap.set(context, new Set());
1248
- }
1249
- contextSourcesMap.get(context).add(sourcePath);
1250
- return [
1251
- context,
1252
- true,
1253
- mtimesToCommit
1254
- ];
1255
- }