tailwindcss 0.0.0-insiders.ea80db2 → 0.0.0-insiders.eae2b7a

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 (213) hide show
  1. package/README.md +13 -9
  2. package/defaultTheme.d.ts +2 -1
  3. package/index.css +5 -0
  4. package/lib/cli/build/index.js +57 -0
  5. package/lib/cli/build/plugin.js +427 -0
  6. package/lib/cli/build/utils.js +88 -0
  7. package/lib/cli/build/watching.js +182 -0
  8. package/lib/cli/help/index.js +73 -0
  9. package/lib/cli/index.js +231 -0
  10. package/lib/cli/init/index.js +63 -0
  11. package/lib/cli.js +1 -759
  12. package/lib/corePluginList.js +12 -3
  13. package/lib/corePlugins.js +2308 -1739
  14. package/lib/css/preflight.css +13 -5
  15. package/lib/featureFlags.js +50 -25
  16. package/lib/index.js +1 -40
  17. package/lib/lib/cacheInvalidation.js +48 -25
  18. package/lib/lib/collapseAdjacentRules.js +17 -10
  19. package/lib/lib/collapseDuplicateDeclarations.js +13 -8
  20. package/lib/lib/content.js +207 -0
  21. package/lib/lib/defaultExtractor.js +232 -33
  22. package/lib/lib/detectNesting.js +21 -10
  23. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  24. package/lib/lib/expandApplyAtRules.js +316 -215
  25. package/lib/lib/expandTailwindAtRules.js +167 -115
  26. package/lib/lib/findAtConfigPath.js +46 -0
  27. package/lib/lib/generateRules.js +444 -211
  28. package/lib/lib/getModuleDependencies.js +88 -37
  29. package/lib/lib/handleImportAtRules.js +50 -0
  30. package/lib/lib/load-config.js +42 -0
  31. package/lib/lib/normalizeTailwindDirectives.js +29 -39
  32. package/lib/lib/offsets.js +306 -0
  33. package/lib/lib/partitionApplyAtRules.js +13 -8
  34. package/lib/lib/regex.js +74 -0
  35. package/lib/lib/remap-bitfield.js +89 -0
  36. package/lib/lib/resolveDefaultsAtRules.js +96 -74
  37. package/lib/lib/setupContextUtils.js +672 -300
  38. package/lib/lib/setupTrackingContext.js +63 -68
  39. package/lib/lib/sharedState.js +44 -17
  40. package/lib/lib/substituteScreenAtRules.js +14 -10
  41. package/lib/plugin.js +160 -0
  42. package/lib/postcss-plugins/nesting/README.md +2 -2
  43. package/lib/postcss-plugins/nesting/index.js +10 -6
  44. package/lib/postcss-plugins/nesting/plugin.js +24 -20
  45. package/lib/processTailwindFeatures.js +34 -29
  46. package/lib/public/colors.js +272 -246
  47. package/lib/public/create-plugin.js +9 -5
  48. package/lib/public/default-config.js +10 -6
  49. package/lib/public/default-theme.js +10 -6
  50. package/lib/public/load-config.js +12 -0
  51. package/lib/public/resolve-config.js +11 -6
  52. package/lib/util/applyImportantSelector.js +36 -0
  53. package/lib/util/bigSign.js +6 -1
  54. package/lib/util/buildMediaQuery.js +13 -6
  55. package/lib/util/cloneDeep.js +9 -6
  56. package/lib/util/cloneNodes.js +12 -3
  57. package/lib/util/color.js +66 -50
  58. package/lib/util/colorNames.js +752 -0
  59. package/lib/util/configurePlugins.js +7 -2
  60. package/lib/util/createPlugin.js +8 -5
  61. package/lib/util/createUtilityPlugin.js +13 -9
  62. package/lib/util/dataTypes.js +182 -111
  63. package/lib/util/defaults.js +12 -7
  64. package/lib/util/escapeClassName.js +13 -8
  65. package/lib/util/escapeCommas.js +7 -2
  66. package/lib/util/flattenColorPalette.js +11 -10
  67. package/lib/util/formatVariantSelector.js +228 -151
  68. package/lib/util/getAllConfigs.js +33 -12
  69. package/lib/util/hashConfig.js +9 -4
  70. package/lib/util/isKeyframeRule.js +7 -2
  71. package/lib/util/isPlainObject.js +7 -2
  72. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  73. package/lib/util/log.js +40 -13
  74. package/lib/util/nameClass.js +27 -10
  75. package/lib/util/negateValue.js +25 -8
  76. package/lib/util/normalizeConfig.js +155 -87
  77. package/lib/util/normalizeScreens.js +127 -8
  78. package/lib/util/parseAnimationValue.js +44 -40
  79. package/lib/util/parseBoxShadowValue.js +33 -62
  80. package/lib/util/parseDependency.js +39 -55
  81. package/lib/util/parseGlob.js +36 -0
  82. package/lib/util/parseObjectStyles.js +15 -10
  83. package/lib/util/pluginUtils.js +154 -59
  84. package/lib/util/prefixSelector.js +29 -10
  85. package/lib/util/pseudoElements.js +209 -0
  86. package/lib/util/removeAlphaVariables.js +31 -0
  87. package/lib/util/resolveConfig.js +96 -95
  88. package/lib/util/resolveConfigPath.js +29 -10
  89. package/lib/util/responsive.js +11 -6
  90. package/lib/util/splitAtTopLevelOnly.js +51 -0
  91. package/lib/util/tap.js +6 -1
  92. package/lib/util/toColorValue.js +7 -2
  93. package/lib/util/toPath.js +22 -4
  94. package/lib/util/transformThemeValue.js +40 -26
  95. package/lib/util/validateConfig.js +48 -0
  96. package/lib/util/validateFormalSyntax.js +26 -0
  97. package/lib/util/withAlphaVariable.js +27 -15
  98. package/lib/value-parser/LICENSE +22 -0
  99. package/lib/value-parser/README.md +3 -0
  100. package/lib/value-parser/index.d.js +2 -0
  101. package/lib/value-parser/index.js +22 -0
  102. package/lib/value-parser/parse.js +259 -0
  103. package/lib/value-parser/stringify.js +38 -0
  104. package/lib/value-parser/unit.js +86 -0
  105. package/lib/value-parser/walk.js +16 -0
  106. package/loadConfig.d.ts +4 -0
  107. package/loadConfig.js +2 -0
  108. package/package.json +54 -52
  109. package/plugin.d.ts +10 -5
  110. package/resolveConfig.d.ts +12 -0
  111. package/scripts/generate-types.js +53 -0
  112. package/scripts/release-channel.js +18 -0
  113. package/scripts/release-notes.js +21 -0
  114. package/scripts/type-utils.js +27 -0
  115. package/src/cli/build/index.js +53 -0
  116. package/src/cli/build/plugin.js +465 -0
  117. package/src/cli/build/utils.js +76 -0
  118. package/src/cli/build/watching.js +229 -0
  119. package/src/cli/help/index.js +70 -0
  120. package/src/cli/index.js +217 -0
  121. package/src/cli/init/index.js +79 -0
  122. package/src/cli.js +1 -836
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +576 -106
  125. package/src/css/preflight.css +13 -5
  126. package/src/featureFlags.js +17 -3
  127. package/src/index.js +1 -42
  128. package/src/lib/collapseAdjacentRules.js +5 -1
  129. package/src/lib/content.js +240 -0
  130. package/src/lib/defaultExtractor.js +202 -35
  131. package/src/lib/detectNesting.js +9 -1
  132. package/src/lib/evaluateTailwindFunctions.js +82 -8
  133. package/src/lib/expandApplyAtRules.js +322 -189
  134. package/src/lib/expandTailwindAtRules.js +82 -59
  135. package/src/lib/findAtConfigPath.js +48 -0
  136. package/src/lib/generateRules.js +413 -132
  137. package/src/lib/getModuleDependencies.js +70 -30
  138. package/src/lib/handleImportAtRules.js +34 -0
  139. package/src/lib/load-config.ts +31 -0
  140. package/src/lib/normalizeTailwindDirectives.js +0 -27
  141. package/src/lib/offsets.js +373 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/remap-bitfield.js +82 -0
  144. package/src/lib/resolveDefaultsAtRules.js +53 -36
  145. package/src/lib/setupContextUtils.js +570 -151
  146. package/src/lib/setupTrackingContext.js +44 -58
  147. package/src/lib/sharedState.js +13 -4
  148. package/src/plugin.js +128 -0
  149. package/src/postcss-plugins/nesting/README.md +2 -2
  150. package/src/public/colors.js +22 -0
  151. package/src/public/default-config.js +1 -1
  152. package/src/public/default-theme.js +2 -2
  153. package/src/public/load-config.js +2 -0
  154. package/src/util/applyImportantSelector.js +27 -0
  155. package/src/util/buildMediaQuery.js +5 -3
  156. package/src/util/cloneNodes.js +5 -1
  157. package/src/util/color.js +34 -17
  158. package/src/util/colorNames.js +150 -0
  159. package/src/util/dataTypes.js +67 -23
  160. package/src/util/formatVariantSelector.js +264 -144
  161. package/src/util/getAllConfigs.js +21 -2
  162. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  163. package/src/util/log.js +25 -1
  164. package/src/util/nameClass.js +4 -0
  165. package/src/util/negateValue.js +11 -3
  166. package/src/util/normalizeConfig.js +78 -20
  167. package/src/util/normalizeScreens.js +99 -4
  168. package/src/util/parseBoxShadowValue.js +3 -50
  169. package/src/util/parseDependency.js +37 -42
  170. package/src/util/parseGlob.js +24 -0
  171. package/src/util/pluginUtils.js +118 -23
  172. package/src/util/prefixSelector.js +28 -10
  173. package/src/util/pseudoElements.js +167 -0
  174. package/src/util/removeAlphaVariables.js +24 -0
  175. package/src/util/resolveConfig.js +70 -62
  176. package/src/util/resolveConfigPath.js +12 -1
  177. package/src/util/splitAtTopLevelOnly.js +52 -0
  178. package/src/util/toPath.js +1 -1
  179. package/src/util/transformThemeValue.js +13 -3
  180. package/src/util/validateConfig.js +36 -0
  181. package/src/util/validateFormalSyntax.js +34 -0
  182. package/src/util/withAlphaVariable.js +1 -1
  183. package/src/value-parser/LICENSE +22 -0
  184. package/src/value-parser/README.md +3 -0
  185. package/src/value-parser/index.d.ts +177 -0
  186. package/src/value-parser/index.js +28 -0
  187. package/src/value-parser/parse.js +303 -0
  188. package/src/value-parser/stringify.js +41 -0
  189. package/src/value-parser/unit.js +118 -0
  190. package/src/value-parser/walk.js +18 -0
  191. package/stubs/.gitignore +1 -0
  192. package/stubs/.prettierrc.json +6 -0
  193. package/stubs/{defaultConfig.stub.js → config.full.js} +215 -165
  194. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -1
  195. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  196. package/stubs/postcss.config.js +5 -0
  197. package/stubs/tailwind.config.cjs +2 -0
  198. package/stubs/tailwind.config.js +2 -0
  199. package/stubs/tailwind.config.ts +3 -0
  200. package/types/config.d.ts +102 -56
  201. package/types/generated/colors.d.ts +22 -0
  202. package/types/generated/corePluginList.d.ts +1 -1
  203. package/types/generated/default-theme.d.ts +372 -0
  204. package/types/index.d.ts +7 -1
  205. package/CHANGELOG.md +0 -2099
  206. package/lib/cli-peer-dependencies.js +0 -15
  207. package/lib/constants.js +0 -37
  208. package/peers/index.js +0 -75156
  209. package/scripts/install-integrations.js +0 -27
  210. package/scripts/rebuildFixtures.js +0 -68
  211. package/src/cli-peer-dependencies.js +0 -9
  212. package/src/constants.js +0 -17
  213. package/types.d.ts +0 -1
@@ -1,17 +1,61 @@
1
- "use strict";
1
+ /**
2
+ * @typedef {object} ScreenValue
3
+ * @property {number|undefined} min
4
+ * @property {number|undefined} max
5
+ * @property {string|undefined} raw
6
+ */ /**
7
+ * @typedef {object} Screen
8
+ * @property {string} name
9
+ * @property {boolean} not
10
+ * @property {ScreenValue[]} values
11
+ */ /**
12
+ * A function that normalizes the various forms that the screens object can be
13
+ * provided in.
14
+ *
15
+ * Input(s):
16
+ * - ['100px', '200px'] // Raw strings
17
+ * - { sm: '100px', md: '200px' } // Object with string values
18
+ * - { sm: { min: '100px' }, md: { max: '100px' } } // Object with object values
19
+ * - { sm: [{ min: '100px' }, { max: '200px' }] } // Object with object array (multiple values)
20
+ *
21
+ * Output(s):
22
+ * - [{ name: 'sm', values: [{ min: '100px', max: '200px' }] }] // List of objects, that contains multiple values
23
+ *
24
+ * @returns {Screen[]}
25
+ */ "use strict";
2
26
  Object.defineProperty(exports, "__esModule", {
3
27
  value: true
4
28
  });
5
- exports.normalizeScreens = normalizeScreens;
29
+ function _export(target, all) {
30
+ for(var name in all)Object.defineProperty(target, name, {
31
+ enumerable: true,
32
+ get: all[name]
33
+ });
34
+ }
35
+ _export(exports, {
36
+ normalizeScreens: function() {
37
+ return normalizeScreens;
38
+ },
39
+ isScreenSortable: function() {
40
+ return isScreenSortable;
41
+ },
42
+ compareScreens: function() {
43
+ return compareScreens;
44
+ },
45
+ toScreen: function() {
46
+ return toScreen;
47
+ }
48
+ });
6
49
  function normalizeScreens(screens, root = true) {
7
50
  if (Array.isArray(screens)) {
8
51
  return screens.map((screen)=>{
9
52
  if (root && Array.isArray(screen)) {
10
- throw new Error('The tuple syntax is not supported for `screens`.');
53
+ throw new Error("The tuple syntax is not supported for `screens`.");
11
54
  }
12
- if (typeof screen === 'string') {
55
+ if (typeof screen === "string") {
13
56
  return {
14
57
  name: screen.toString(),
58
+ not: false,
15
59
  values: [
16
60
  {
17
61
  min: screen,
@@ -22,9 +66,10 @@ function normalizeScreens(screens, root = true) {
22
66
  }
23
67
  let [name, options] = screen;
24
68
  name = name.toString();
25
- if (typeof options === 'string') {
69
+ if (typeof options === "string") {
26
70
  return {
27
71
  name,
72
+ not: false,
28
73
  values: [
29
74
  {
30
75
  min: options,
@@ -36,12 +81,13 @@ function normalizeScreens(screens, root = true) {
36
81
  if (Array.isArray(options)) {
37
82
  return {
38
83
  name,
39
- values: options.map((option)=>resolveValue(option)
40
- )
84
+ not: false,
85
+ values: options.map((option)=>resolveValue(option))
41
86
  };
42
87
  }
43
88
  return {
44
89
  name,
90
+ not: false,
45
91
  values: [
46
92
  resolveValue(options)
47
93
  ]
@@ -50,7 +96,80 @@ function normalizeScreens(screens, root = true) {
50
96
  }
51
97
  return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
52
98
  }
53
- function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {}) {
99
+ function isScreenSortable(screen) {
100
+ if (screen.values.length !== 1) {
101
+ return {
102
+ result: false,
103
+ reason: "multiple-values"
104
+ };
105
+ } else if (screen.values[0].raw !== undefined) {
106
+ return {
107
+ result: false,
108
+ reason: "raw-values"
109
+ };
110
+ } else if (screen.values[0].min !== undefined && screen.values[0].max !== undefined) {
111
+ return {
112
+ result: false,
113
+ reason: "min-and-max"
114
+ };
115
+ }
116
+ return {
117
+ result: true,
118
+ reason: null
119
+ };
120
+ }
121
+ function compareScreens(type, a, z) {
122
+ let aScreen = toScreen(a, type);
123
+ let zScreen = toScreen(z, type);
124
+ let aSorting = isScreenSortable(aScreen);
125
+ let bSorting = isScreenSortable(zScreen);
126
+ // These cases should never happen and indicate a bug in Tailwind CSS itself
127
+ if (aSorting.reason === "multiple-values" || bSorting.reason === "multiple-values") {
128
+ throw new Error("Attempted to sort a screen with multiple values. This should never happen. Please open a bug report.");
129
+ } else if (aSorting.reason === "raw-values" || bSorting.reason === "raw-values") {
130
+ throw new Error("Attempted to sort a screen with raw values. This should never happen. Please open a bug report.");
131
+ } else if (aSorting.reason === "min-and-max" || bSorting.reason === "min-and-max") {
132
+ throw new Error("Attempted to sort a screen with both min and max values. This should never happen. Please open a bug report.");
133
+ }
134
+ // Let the sorting begin
135
+ let { min: aMin , max: aMax } = aScreen.values[0];
136
+ let { min: zMin , max: zMax } = zScreen.values[0];
137
+ // Negating screens flip their behavior. Basically `not min-width` is `max-width`
138
+ if (a.not) [aMin, aMax] = [
139
+ aMax,
140
+ aMin
141
+ ];
142
+ if (z.not) [zMin, zMax] = [
143
+ zMax,
144
+ zMin
145
+ ];
146
+ aMin = aMin === undefined ? aMin : parseFloat(aMin);
147
+ aMax = aMax === undefined ? aMax : parseFloat(aMax);
148
+ zMin = zMin === undefined ? zMin : parseFloat(zMin);
149
+ zMax = zMax === undefined ? zMax : parseFloat(zMax);
150
+ let [aValue, zValue] = type === "min" ? [
151
+ aMin,
152
+ zMin
153
+ ] : [
154
+ zMax,
155
+ aMax
156
+ ];
157
+ return aValue - zValue;
158
+ }
159
+ function toScreen(value, type) {
160
+ if (typeof value === "object") {
161
+ return value;
162
+ }
163
+ return {
164
+ name: "arbitrary-screen",
165
+ values: [
166
+ {
167
+ [type]: value
168
+ }
169
+ ]
170
+ };
171
+ }
172
+ function resolveValue({ "min-width": _minWidth , min =_minWidth , max , raw } = {}) {
54
173
  return {
55
174
  min,
56
175
  max,
@@ -2,38 +2,43 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = parseAnimationValue;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseAnimationValue;
9
+ }
10
+ });
6
11
  const DIRECTIONS = new Set([
7
- 'normal',
8
- 'reverse',
9
- 'alternate',
10
- 'alternate-reverse'
12
+ "normal",
13
+ "reverse",
14
+ "alternate",
15
+ "alternate-reverse"
11
16
  ]);
12
17
  const PLAY_STATES = new Set([
13
- 'running',
14
- 'paused'
18
+ "running",
19
+ "paused"
15
20
  ]);
16
21
  const FILL_MODES = new Set([
17
- 'none',
18
- 'forwards',
19
- 'backwards',
20
- 'both'
22
+ "none",
23
+ "forwards",
24
+ "backwards",
25
+ "both"
21
26
  ]);
22
27
  const ITERATION_COUNTS = new Set([
23
- 'infinite'
28
+ "infinite"
24
29
  ]);
25
30
  const TIMINGS = new Set([
26
- 'linear',
27
- 'ease',
28
- 'ease-in',
29
- 'ease-out',
30
- 'ease-in-out',
31
- 'step-start',
32
- 'step-end',
31
+ "linear",
32
+ "ease",
33
+ "ease-in",
34
+ "ease-out",
35
+ "ease-in-out",
36
+ "step-start",
37
+ "step-end"
33
38
  ]);
34
39
  const TIMING_FNS = [
35
- 'cubic-bezier',
36
- 'steps'
40
+ "cubic-bezier",
41
+ "steps"
37
42
  ];
38
43
  const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
39
44
  ;
@@ -51,34 +56,33 @@ function parseAnimationValue(input) {
51
56
  let parts = value.split(SPACE);
52
57
  let seen = new Set();
53
58
  for (let part of parts){
54
- if (!seen.has('DIRECTIONS') && DIRECTIONS.has(part)) {
59
+ if (!seen.has("DIRECTIONS") && DIRECTIONS.has(part)) {
55
60
  result.direction = part;
56
- seen.add('DIRECTIONS');
57
- } else if (!seen.has('PLAY_STATES') && PLAY_STATES.has(part)) {
61
+ seen.add("DIRECTIONS");
62
+ } else if (!seen.has("PLAY_STATES") && PLAY_STATES.has(part)) {
58
63
  result.playState = part;
59
- seen.add('PLAY_STATES');
60
- } else if (!seen.has('FILL_MODES') && FILL_MODES.has(part)) {
64
+ seen.add("PLAY_STATES");
65
+ } else if (!seen.has("FILL_MODES") && FILL_MODES.has(part)) {
61
66
  result.fillMode = part;
62
- seen.add('FILL_MODES');
63
- } else if (!seen.has('ITERATION_COUNTS') && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
67
+ seen.add("FILL_MODES");
68
+ } else if (!seen.has("ITERATION_COUNTS") && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
64
69
  result.iterationCount = part;
65
- seen.add('ITERATION_COUNTS');
66
- } else if (!seen.has('TIMING_FUNCTION') && TIMINGS.has(part)) {
70
+ seen.add("ITERATION_COUNTS");
71
+ } else if (!seen.has("TIMING_FUNCTION") && TIMINGS.has(part)) {
67
72
  result.timingFunction = part;
68
- seen.add('TIMING_FUNCTION');
69
- } else if (!seen.has('TIMING_FUNCTION') && TIMING_FNS.some((f)=>part.startsWith(`${f}(`)
70
- )) {
73
+ seen.add("TIMING_FUNCTION");
74
+ } else if (!seen.has("TIMING_FUNCTION") && TIMING_FNS.some((f)=>part.startsWith(`${f}(`))) {
71
75
  result.timingFunction = part;
72
- seen.add('TIMING_FUNCTION');
73
- } else if (!seen.has('DURATION') && TIME.test(part)) {
76
+ seen.add("TIMING_FUNCTION");
77
+ } else if (!seen.has("DURATION") && TIME.test(part)) {
74
78
  result.duration = part;
75
- seen.add('DURATION');
76
- } else if (!seen.has('DELAY') && TIME.test(part)) {
79
+ seen.add("DURATION");
80
+ } else if (!seen.has("DELAY") && TIME.test(part)) {
77
81
  result.delay = part;
78
- seen.add('DELAY');
79
- } else if (!seen.has('NAME')) {
82
+ seen.add("DELAY");
83
+ } else if (!seen.has("NAME")) {
80
84
  result.name = part;
81
- seen.add('NAME');
85
+ seen.add("NAME");
82
86
  } else {
83
87
  if (!result.unknown) result.unknown = [];
84
88
  result.unknown.push(part);
@@ -2,62 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.parseBoxShadowValue = parseBoxShadowValue;
6
- exports.formatBoxShadowValue = formatBoxShadowValue;
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
+ parseBoxShadowValue: function() {
13
+ return parseBoxShadowValue;
14
+ },
15
+ formatBoxShadowValue: function() {
16
+ return formatBoxShadowValue;
17
+ }
18
+ });
19
+ const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
7
20
  let KEYWORDS = new Set([
8
- 'inset',
9
- 'inherit',
10
- 'initial',
11
- 'revert',
12
- 'unset'
21
+ "inset",
22
+ "inherit",
23
+ "initial",
24
+ "revert",
25
+ "unset"
13
26
  ]);
14
27
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
15
28
  ;
16
29
  let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
17
- let SPECIALS = /[(),]/g;
18
- /**
19
- * This splits a string on top-level commas.
20
- *
21
- * Regex doesn't support recursion (at least not the JS-flavored version).
22
- * So we have to use a tiny state machine to keep track of paren vs comma
23
- * placement. Before we'd only exclude commas from the inner-most nested
24
- * set of parens rather than any commas that were not contained in parens
25
- * at all which is the intended behavior here.
26
- *
27
- * Expected behavior:
28
- * var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
29
- * ─┬─ ┬ ┬ ┬
30
- * x x x ╰──────── Split because top-level
31
- * ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
32
- *
33
- * @param {string} input
34
- */ function* splitByTopLevelCommas(input) {
35
- SPECIALS.lastIndex = -1;
36
- let depth = 0;
37
- let lastIndex = 0;
38
- let found = false;
39
- // Find all parens & commas
40
- // And only split on commas if they're top-level
41
- for (let match of input.matchAll(SPECIALS)){
42
- if (match[0] === '(') depth++;
43
- if (match[0] === ')') depth--;
44
- if (match[0] === ',' && depth === 0) {
45
- found = true;
46
- yield input.substring(lastIndex, match.index);
47
- lastIndex = match.index + match[0].length;
48
- }
49
- }
50
- // Provide the last segment of the string if available
51
- // Otherwise the whole string since no commas were found
52
- // This mirrors the behavior of string.split()
53
- if (found) {
54
- yield input.substring(lastIndex);
55
- } else {
56
- yield input;
57
- }
58
- }
59
30
  function parseBoxShadowValue(input) {
60
- let shadows = Array.from(splitByTopLevelCommas(input));
31
+ let shadows = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, ",");
61
32
  return shadows.map((shadow)=>{
62
33
  let value = shadow.trim();
63
34
  let result = {
@@ -69,22 +40,22 @@ function parseBoxShadowValue(input) {
69
40
  // Reset index, since the regex is stateful.
70
41
  LENGTH.lastIndex = 0;
71
42
  // Keyword
72
- if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
43
+ if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
73
44
  result.keyword = part;
74
- seen.add('KEYWORD');
45
+ seen.add("KEYWORD");
75
46
  } else if (LENGTH.test(part)) {
76
- if (!seen.has('X')) {
47
+ if (!seen.has("X")) {
77
48
  result.x = part;
78
- seen.add('X');
79
- } else if (!seen.has('Y')) {
49
+ seen.add("X");
50
+ } else if (!seen.has("Y")) {
80
51
  result.y = part;
81
- seen.add('Y');
82
- } else if (!seen.has('BLUR')) {
52
+ seen.add("Y");
53
+ } else if (!seen.has("BLUR")) {
83
54
  result.blur = part;
84
- seen.add('BLUR');
85
- } else if (!seen.has('SPREAD')) {
55
+ seen.add("BLUR");
56
+ } else if (!seen.has("SPREAD")) {
86
57
  result.spread = part;
87
- seen.add('SPREAD');
58
+ seen.add("SPREAD");
88
59
  }
89
60
  } else {
90
61
  if (!result.color) {
@@ -112,6 +83,6 @@ function formatBoxShadowValue(shadows) {
112
83
  shadow.blur,
113
84
  shadow.spread,
114
85
  shadow.color
115
- ].filter(Boolean).join(' ');
116
- }).join(', ');
86
+ ].filter(Boolean).join(" ");
87
+ }).join(", ");
117
88
  }
@@ -1,63 +1,47 @@
1
- "use strict";
1
+ // @ts-check
2
+ /**
3
+ * @typedef {{type: 'dependency', file: string} | {type: 'dir-dependency', dir: string, glob: string}} Dependency
4
+ */ /**
5
+ *
6
+ * @param {import('../lib/content.js').ContentPath} contentPath
7
+ * @returns {Dependency[]}
8
+ */ "use strict";
2
9
  Object.defineProperty(exports, "__esModule", {
3
10
  value: true
4
11
  });
5
- exports.default = parseDependency;
6
- var _isGlob = _interopRequireDefault(require("is-glob"));
7
- var _globParent = _interopRequireDefault(require("glob-parent"));
8
- var _path = _interopRequireDefault(require("path"));
9
- function _interopRequireDefault(obj) {
10
- return obj && obj.__esModule ? obj : {
11
- default: obj
12
- };
13
- }
14
- // Based on `glob-base`
15
- // https://github.com/micromatch/glob-base/blob/master/index.js
16
- function parseGlob(pattern) {
17
- let glob = pattern;
18
- let base = (0, _globParent).default(pattern);
19
- if (base !== '.') {
20
- glob = pattern.substr(base.length);
21
- if (glob.charAt(0) === '/') {
22
- glob = glob.substr(1);
23
- }
24
- }
25
- if (glob.substr(0, 2) === './') {
26
- glob = glob.substr(2);
27
- }
28
- if (glob.charAt(0) === '/') {
29
- glob = glob.substr(1);
12
+ Object.defineProperty(exports, "default", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return parseDependency;
30
16
  }
31
- return {
32
- base,
33
- glob
34
- };
35
- }
36
- function parseDependency(normalizedFileOrGlob) {
37
- if (normalizedFileOrGlob.startsWith('!')) {
38
- return null;
17
+ });
18
+ function parseDependency(contentPath) {
19
+ if (contentPath.ignore) {
20
+ return [];
39
21
  }
40
- let message;
41
- if ((0, _isGlob).default(normalizedFileOrGlob)) {
42
- let { base , glob } = parseGlob(normalizedFileOrGlob);
43
- message = {
44
- type: 'dir-dependency',
45
- dir: _path.default.resolve(base),
46
- glob
47
- };
48
- } else {
49
- message = {
50
- type: 'dependency',
51
- file: _path.default.resolve(normalizedFileOrGlob)
52
- };
22
+ if (!contentPath.glob) {
23
+ return [
24
+ {
25
+ type: "dependency",
26
+ file: contentPath.base
27
+ }
28
+ ];
53
29
  }
54
- // rollup-plugin-postcss does not support dir-dependency messages
55
- // but directories can be watched in the same way as files
56
- if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
57
- message = {
58
- type: 'dependency',
59
- file: message.dir
60
- };
30
+ if (process.env.ROLLUP_WATCH === "true") {
31
+ // rollup-plugin-postcss does not support dir-dependency messages
32
+ // but directories can be watched in the same way as files
33
+ return [
34
+ {
35
+ type: "dependency",
36
+ file: contentPath.base
37
+ }
38
+ ];
61
39
  }
62
- return message;
40
+ return [
41
+ {
42
+ type: "dir-dependency",
43
+ dir: contentPath.base,
44
+ glob: contentPath.glob
45
+ }
46
+ ];
63
47
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "parseGlob", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseGlob;
9
+ }
10
+ });
11
+ const _globparent = /*#__PURE__*/ _interop_require_default(require("glob-parent"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function parseGlob(pattern) {
18
+ let glob = pattern;
19
+ let base = (0, _globparent.default)(pattern);
20
+ if (base !== ".") {
21
+ glob = pattern.substr(base.length);
22
+ if (glob.charAt(0) === "/") {
23
+ glob = glob.substr(1);
24
+ }
25
+ }
26
+ if (glob.substr(0, 2) === "./") {
27
+ glob = glob.substr(2);
28
+ }
29
+ if (glob.charAt(0) === "/") {
30
+ glob = glob.substr(1);
31
+ }
32
+ return {
33
+ base,
34
+ glob
35
+ };
36
+ }
@@ -2,11 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = parseObjectStyles;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _postcssNested = _interopRequireDefault(require("postcss-nested"));
8
- var _postcssJs = _interopRequireDefault(require("postcss-js"));
9
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseObjectStyles;
9
+ }
10
+ });
11
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12
+ const _postcssnested = /*#__PURE__*/ _interop_require_default(require("postcss-nested"));
13
+ const _postcssjs = /*#__PURE__*/ _interop_require_default(require("postcss-js"));
14
+ function _interop_require_default(obj) {
10
15
  return obj && obj.__esModule ? obj : {
11
16
  default: obj
12
17
  };
@@ -18,14 +23,14 @@ function parseObjectStyles(styles) {
18
23
  ]);
19
24
  }
20
25
  return styles.flatMap((style)=>{
21
- return (0, _postcss).default([
22
- (0, _postcssNested).default({
26
+ return (0, _postcss.default)([
27
+ (0, _postcssnested.default)({
23
28
  bubble: [
24
- 'screen'
29
+ "screen"
25
30
  ]
26
- }),
31
+ })
27
32
  ]).process(style, {
28
- parser: _postcssJs.default
33
+ parser: _postcssjs.default
29
34
  }).root.nodes;
30
35
  });
31
36
  }