1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", {
|
3 | value: true
|
4 | });
|
5 | Object.defineProperty(exports, "normalizeConfig", {
|
6 | enumerable: true,
|
7 | get: ()=>normalizeConfig
|
8 | });
|
9 | const _log = /*#__PURE__*/ _interopRequireWildcard(require("./log"));
|
10 | function _getRequireWildcardCache(nodeInterop) {
|
11 | if (typeof WeakMap !== "function") return null;
|
12 | var cacheBabelInterop = new WeakMap();
|
13 | var cacheNodeInterop = new WeakMap();
|
14 | return (_getRequireWildcardCache = function(nodeInterop) {
|
15 | return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
16 | })(nodeInterop);
|
17 | }
|
18 | function _interopRequireWildcard(obj, nodeInterop) {
|
19 | if (!nodeInterop && obj && obj.__esModule) {
|
20 | return obj;
|
21 | }
|
22 | if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
23 | return {
|
24 | default: obj
|
25 | };
|
26 | }
|
27 | var cache = _getRequireWildcardCache(nodeInterop);
|
28 | if (cache && cache.has(obj)) {
|
29 | return cache.get(obj);
|
30 | }
|
31 | var newObj = {};
|
32 | var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
33 | for(var key in obj){
|
34 | if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
35 | var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
36 | if (desc && (desc.get || desc.set)) {
|
37 | Object.defineProperty(newObj, key, desc);
|
38 | } else {
|
39 | newObj[key] = obj[key];
|
40 | }
|
41 | }
|
42 | }
|
43 | newObj.default = obj;
|
44 | if (cache) {
|
45 | cache.set(obj, newObj);
|
46 | }
|
47 | return newObj;
|
48 | }
|
49 | function normalizeConfig(config) {
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | let valid = (()=>{
|
65 |
|
66 | if (config.purge) {
|
67 | return false;
|
68 | }
|
69 |
|
70 | if (!config.content) {
|
71 | return false;
|
72 | }
|
73 |
|
74 | if (!Array.isArray(config.content) && !(typeof config.content === "object" && config.content !== null)) {
|
75 | return false;
|
76 | }
|
77 |
|
78 | if (Array.isArray(config.content)) {
|
79 | return config.content.every((path)=>{
|
80 |
|
81 | if (typeof path === "string") return true;
|
82 |
|
83 |
|
84 | if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
|
85 |
|
86 | if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
|
87 | return false;
|
88 | }
|
89 | return true;
|
90 | });
|
91 | }
|
92 |
|
93 | if (typeof config.content === "object" && config.content !== null) {
|
94 |
|
95 | if (Object.keys(config.content).some((key)=>![
|
96 | "files",
|
97 | "relative",
|
98 | "extract",
|
99 | "transform"
|
100 | ].includes(key))) {
|
101 | return false;
|
102 | }
|
103 |
|
104 | if (Array.isArray(config.content.files)) {
|
105 | if (!config.content.files.every((path)=>{
|
106 |
|
107 | if (typeof path === "string") return true;
|
108 |
|
109 |
|
110 | if (typeof (path === null || path === void 0 ? void 0 : path.raw) !== "string") return false;
|
111 |
|
112 | if ((path === null || path === void 0 ? void 0 : path.extension) && typeof (path === null || path === void 0 ? void 0 : path.extension) !== "string") {
|
113 | return false;
|
114 | }
|
115 | return true;
|
116 | })) {
|
117 | return false;
|
118 | }
|
119 |
|
120 | if (typeof config.content.extract === "object") {
|
121 | for (let value of Object.values(config.content.extract)){
|
122 | if (typeof value !== "function") {
|
123 | return false;
|
124 | }
|
125 | }
|
126 | } else if (!(config.content.extract === undefined || typeof config.content.extract === "function")) {
|
127 | return false;
|
128 | }
|
129 |
|
130 | if (typeof config.content.transform === "object") {
|
131 | for (let value1 of Object.values(config.content.transform)){
|
132 | if (typeof value1 !== "function") {
|
133 | return false;
|
134 | }
|
135 | }
|
136 | } else if (!(config.content.transform === undefined || typeof config.content.transform === "function")) {
|
137 | return false;
|
138 | }
|
139 |
|
140 | if (typeof config.content.relative !== "boolean" && typeof config.content.relative !== "undefined") {
|
141 | return false;
|
142 | }
|
143 | }
|
144 | return true;
|
145 | }
|
146 | return false;
|
147 | })();
|
148 | if (!valid) {
|
149 | _log.default.warn("purge-deprecation", [
|
150 | "The `purge`/`content` options have changed in Tailwind CSS v3.0.",
|
151 | "Update your configuration file to eliminate this warning.",
|
152 | "https://tailwindcss.com/docs/upgrade-guide#configure-content-sources"
|
153 | ]);
|
154 | }
|
155 |
|
156 | config.safelist = (()=>{
|
157 | var ref;
|
158 | let { content , purge , safelist } = config;
|
159 | if (Array.isArray(safelist)) return safelist;
|
160 | if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
|
161 | if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
|
162 | if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
|
163 | return [];
|
164 | })();
|
165 |
|
166 | config.blocklist = (()=>{
|
167 | let { blocklist } = config;
|
168 | if (Array.isArray(blocklist)) {
|
169 | if (blocklist.every((item)=>typeof item === "string")) {
|
170 | return blocklist;
|
171 | }
|
172 | _log.default.warn("blocklist-invalid", [
|
173 | "The `blocklist` option must be an array of strings.",
|
174 | "https://tailwindcss.com/docs/content-configuration#discarding-classes"
|
175 | ]);
|
176 | }
|
177 | return [];
|
178 | })();
|
179 |
|
180 | if (typeof config.prefix === "function") {
|
181 | _log.default.warn("prefix-function", [
|
182 | "As of Tailwind CSS v3.0, `prefix` cannot be a function.",
|
183 | "Update `prefix` in your configuration to be a string to eliminate this warning.",
|
184 | "https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function"
|
185 | ]);
|
186 | config.prefix = "";
|
187 | } else {
|
188 | var _prefix;
|
189 | config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : "";
|
190 | }
|
191 |
|
192 | config.content = {
|
193 | relative: (()=>{
|
194 | var ref;
|
195 | let { content } = config;
|
196 | if (content === null || content === void 0 ? void 0 : content.relative) {
|
197 | return content.relative;
|
198 | }
|
199 | var ref1;
|
200 | return (ref1 = (ref = config.future) === null || ref === void 0 ? void 0 : ref.relativeContentPathsByDefault) !== null && ref1 !== void 0 ? ref1 : false;
|
201 | })(),
|
202 | files: (()=>{
|
203 | let { content , purge } = config;
|
204 | if (Array.isArray(purge)) return purge;
|
205 | if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
|
206 | if (Array.isArray(content)) return content;
|
207 | if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
|
208 | if (Array.isArray(content === null || content === void 0 ? void 0 : content.files)) return content.files;
|
209 | return [];
|
210 | })(),
|
211 | extract: (()=>{
|
212 | let extract = (()=>{
|
213 | var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9;
|
214 | if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.extract) return config.purge.extract;
|
215 | if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.extract) return config.content.extract;
|
216 | if ((ref2 = config.purge) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.extract) === null || ref3 === void 0 ? void 0 : ref3.DEFAULT) return config.purge.extract.DEFAULT;
|
217 | if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.extract) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.extract.DEFAULT;
|
218 | if ((ref6 = config.purge) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.options) === null || ref7 === void 0 ? void 0 : ref7.extractors) return config.purge.options.extractors;
|
219 | if ((ref8 = config.content) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.options) === null || ref9 === void 0 ? void 0 : ref9.extractors) return config.content.options.extractors;
|
220 | return {};
|
221 | })();
|
222 | let extractors = {};
|
223 | let defaultExtractor = (()=>{
|
224 | var ref, ref1, ref2, ref3;
|
225 | if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref1 = ref.options) === null || ref1 === void 0 ? void 0 : ref1.defaultExtractor) {
|
226 | return config.purge.options.defaultExtractor;
|
227 | }
|
228 | if ((ref2 = config.content) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.options) === null || ref3 === void 0 ? void 0 : ref3.defaultExtractor) {
|
229 | return config.content.options.defaultExtractor;
|
230 | }
|
231 | return undefined;
|
232 | })();
|
233 | if (defaultExtractor !== undefined) {
|
234 | extractors.DEFAULT = defaultExtractor;
|
235 | }
|
236 |
|
237 | if (typeof extract === "function") {
|
238 | extractors.DEFAULT = extract;
|
239 | } else if (Array.isArray(extract)) {
|
240 | for (let { extensions , extractor } of extract !== null && extract !== void 0 ? extract : []){
|
241 | for (let extension of extensions){
|
242 | extractors[extension] = extractor;
|
243 | }
|
244 | }
|
245 | } else if (typeof extract === "object" && extract !== null) {
|
246 | Object.assign(extractors, extract);
|
247 | }
|
248 | return extractors;
|
249 | })(),
|
250 | transform: (()=>{
|
251 | let transform = (()=>{
|
252 | var ref, ref1, ref2, ref3, ref4, ref5;
|
253 | if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
|
254 | if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.transform) return config.content.transform;
|
255 | if ((ref2 = config.purge) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.transform) === null || ref3 === void 0 ? void 0 : ref3.DEFAULT) return config.purge.transform.DEFAULT;
|
256 | if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.transform) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.transform.DEFAULT;
|
257 | return {};
|
258 | })();
|
259 | let transformers = {};
|
260 | if (typeof transform === "function") {
|
261 | transformers.DEFAULT = transform;
|
262 | }
|
263 | if (typeof transform === "object" && transform !== null) {
|
264 | Object.assign(transformers, transform);
|
265 | }
|
266 | return transformers;
|
267 | })()
|
268 | };
|
269 |
|
270 |
|
271 | for (let file of config.content.files){
|
272 | if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
|
273 | _log.default.warn("invalid-glob-braces", [
|
274 | `The glob pattern ${(0, _log.dim)(file)} in your Tailwind CSS configuration is invalid.`,
|
275 | `Update it to ${(0, _log.dim)(file.replace(/{([^,]*?)}/g, "$1"))} to silence this warning.`
|
276 | ]);
|
277 | break;
|
278 | }
|
279 | }
|
280 | return config;
|
281 | }
|