tailwindcss-injector 1.0.7 → 1.0.8-alpha.0
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.
- package/dist/postcss.cjs +24 -454
- package/dist/postcss.js +25 -455
- package/package.json +3 -3
package/dist/postcss.cjs
CHANGED
|
@@ -7,446 +7,16 @@ var _tailwindcssconfig = require('tailwindcss-config');
|
|
|
7
7
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
11
15
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
12
16
|
|
|
13
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
14
|
-
var _lazyMatch = () => {
|
|
15
|
-
var __lib__ = (() => {
|
|
16
|
-
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
17
|
-
for (var n in e) m(r, n, { get: e[n], enumerable: true });
|
|
18
|
-
}, H = (r, e, n, a) => {
|
|
19
|
-
if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, { get: () => e[t], enumerable: !(a = V(e, t)) || a.enumerable });
|
|
20
|
-
return r;
|
|
21
|
-
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
22
|
-
q(w, { default: () => re });
|
|
23
|
-
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
24
|
-
const e = /* @__PURE__ */ new Map();
|
|
25
|
-
return (n) => {
|
|
26
|
-
const a = e.get(n);
|
|
27
|
-
if (a) return a;
|
|
28
|
-
const t = r(n);
|
|
29
|
-
return e.set(n, t), t;
|
|
30
|
-
};
|
|
31
|
-
}, rr = (r, e, n = {}) => {
|
|
32
|
-
const a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
33
|
-
if (v(e)(a) && a.index === r.length) return a.output;
|
|
34
|
-
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
35
|
-
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
36
|
-
const n = {};
|
|
37
|
-
for (const a of r) {
|
|
38
|
-
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
39
|
-
const t = a.charCodeAt(0);
|
|
40
|
-
n[t] = true;
|
|
41
|
-
}
|
|
42
|
-
return (a) => {
|
|
43
|
-
const t = a.index, o = a.input;
|
|
44
|
-
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
45
|
-
const u = a.index;
|
|
46
|
-
if (u > t) {
|
|
47
|
-
if (!h(e) && !a.options.silent) {
|
|
48
|
-
const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
49
|
-
h(c) || a.output.push(c);
|
|
50
|
-
}
|
|
51
|
-
a.indexMax = Math.max(a.indexMax, a.index);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
55
|
-
}, nr = (r, e) => {
|
|
56
|
-
const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
57
|
-
return g((o) => {
|
|
58
|
-
t.lastIndex = o.index;
|
|
59
|
-
const u = t.exec(o.input);
|
|
60
|
-
if (u) {
|
|
61
|
-
if (!h(e) && !o.options.silent) {
|
|
62
|
-
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
63
|
-
h(s) || o.output.push(s);
|
|
64
|
-
}
|
|
65
|
-
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
66
|
-
} else return false;
|
|
67
|
-
});
|
|
68
|
-
}, ar = (r, e) => (n) => {
|
|
69
|
-
if (n.input.startsWith(r, n.index)) {
|
|
70
|
-
if (!h(e) && !n.options.silent) {
|
|
71
|
-
const t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
72
|
-
h(t) || n.output.push(t);
|
|
73
|
-
}
|
|
74
|
-
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
75
|
-
} else return false;
|
|
76
|
-
}, C = (r, e, n, a) => {
|
|
77
|
-
const t = v(r);
|
|
78
|
-
return g(_(M((o) => {
|
|
79
|
-
let u = 0;
|
|
80
|
-
for (; u < n; ) {
|
|
81
|
-
const s = o.index;
|
|
82
|
-
if (!t(o) || (u += 1, o.index === s)) break;
|
|
83
|
-
}
|
|
84
|
-
return u >= e;
|
|
85
|
-
})));
|
|
86
|
-
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
87
|
-
const n = r.map(v);
|
|
88
|
-
return g(_(M((a) => {
|
|
89
|
-
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
|
|
90
|
-
return true;
|
|
91
|
-
})));
|
|
92
|
-
}, l = (r, e) => {
|
|
93
|
-
const n = r.map(v);
|
|
94
|
-
return g(_((a) => {
|
|
95
|
-
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
|
|
96
|
-
return false;
|
|
97
|
-
}));
|
|
98
|
-
}, M = (r, e = false) => {
|
|
99
|
-
const n = v(r);
|
|
100
|
-
return (a) => {
|
|
101
|
-
const t = a.index, o = a.output.length, u = n(a);
|
|
102
|
-
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
103
|
-
};
|
|
104
|
-
}, _ = (r, e) => {
|
|
105
|
-
const n = v(r);
|
|
106
|
-
return n;
|
|
107
|
-
}, g = /* @__PURE__ */ (() => {
|
|
108
|
-
let r = 0;
|
|
109
|
-
return (e) => {
|
|
110
|
-
const n = v(e), a = r += 1;
|
|
111
|
-
return (t) => {
|
|
112
|
-
var o;
|
|
113
|
-
if (t.options.memoization === false) return n(t);
|
|
114
|
-
const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
115
|
-
if (c === false) return false;
|
|
116
|
-
if (W(c)) return t.index = c, true;
|
|
117
|
-
if (c) return t.index = c.index, _optionalChain([c, 'access', _2 => _2.output, 'optionalAccess', _3 => _3.length]) && t.output.push(...c.output), true;
|
|
118
|
-
{
|
|
119
|
-
const Z = t.output.length;
|
|
120
|
-
if (n(t)) {
|
|
121
|
-
const D = t.index, U = t.output.length;
|
|
122
|
-
if (U > Z) {
|
|
123
|
-
const ee = t.output.slice(Z, U);
|
|
124
|
-
s.set(u, { index: D, output: ee });
|
|
125
|
-
} else s.set(u, D);
|
|
126
|
-
return true;
|
|
127
|
-
} else return s.set(u, false), false;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
})(), E = (r) => {
|
|
132
|
-
let e;
|
|
133
|
-
return (n) => (e || (e = v(r())), e(n));
|
|
134
|
-
}, v = Y((r) => {
|
|
135
|
-
if (d(r)) return Q(r) ? E(r) : r;
|
|
136
|
-
if (b(r) || X(r)) return i(r);
|
|
137
|
-
if (A(r)) return x(r);
|
|
138
|
-
if (K(r)) return l(Object.values(r));
|
|
139
|
-
throw new Error("Invalid rule");
|
|
140
|
-
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
141
|
-
let e = "";
|
|
142
|
-
for (; r > 0; ) {
|
|
143
|
-
const n = (r - 1) % 26;
|
|
144
|
-
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
145
|
-
}
|
|
146
|
-
return e;
|
|
147
|
-
}, O = (r) => {
|
|
148
|
-
let e = 0;
|
|
149
|
-
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
150
|
-
return e;
|
|
151
|
-
}, S = (r, e) => {
|
|
152
|
-
if (e < r) return S(e, r);
|
|
153
|
-
const n = [];
|
|
154
|
-
for (; r <= e; ) n.push(r++);
|
|
155
|
-
return n;
|
|
156
|
-
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
157
|
-
const e = {};
|
|
158
|
-
return (n) => _nullishCoalesce(e[n], () => ( (e[n] = r(n))));
|
|
159
|
-
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, tr(Ar), f(Er), wr]), Pr = i("{", "(?:"), Or = i("}", ")"), Rr = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = z(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
160
|
-
const n = Array.isArray(r) ? r : [r];
|
|
161
|
-
if (!n.length) return false;
|
|
162
|
-
const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
163
|
-
return a.some((s) => s.test(o));
|
|
164
|
-
};
|
|
165
|
-
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
166
|
-
var re = $;
|
|
167
|
-
return J(w);
|
|
168
|
-
})();
|
|
169
|
-
return __lib__.default || __lib__;
|
|
170
|
-
};
|
|
171
|
-
var _match;
|
|
172
|
-
var zeptomatch = (path2, pattern) => {
|
|
173
|
-
if (!_match) {
|
|
174
|
-
_match = _lazyMatch();
|
|
175
|
-
_lazyMatch = null;
|
|
176
|
-
}
|
|
177
|
-
return _match(path2, pattern);
|
|
178
|
-
};
|
|
179
|
-
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
180
|
-
function normalizeWindowsPath(input = "") {
|
|
181
|
-
if (!input) {
|
|
182
|
-
return input;
|
|
183
|
-
}
|
|
184
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
185
|
-
}
|
|
186
|
-
var _UNC_REGEX = /^[/\\]{2}/;
|
|
187
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
188
|
-
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
189
|
-
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
190
|
-
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
191
|
-
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
192
|
-
var sep = "/";
|
|
193
|
-
var normalize = function(path2) {
|
|
194
|
-
if (path2.length === 0) {
|
|
195
|
-
return ".";
|
|
196
|
-
}
|
|
197
|
-
path2 = normalizeWindowsPath(path2);
|
|
198
|
-
const isUNCPath = path2.match(_UNC_REGEX);
|
|
199
|
-
const isPathAbsolute = isAbsolute(path2);
|
|
200
|
-
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
201
|
-
path2 = normalizeString(path2, !isPathAbsolute);
|
|
202
|
-
if (path2.length === 0) {
|
|
203
|
-
if (isPathAbsolute) {
|
|
204
|
-
return "/";
|
|
205
|
-
}
|
|
206
|
-
return trailingSeparator ? "./" : ".";
|
|
207
|
-
}
|
|
208
|
-
if (trailingSeparator) {
|
|
209
|
-
path2 += "/";
|
|
210
|
-
}
|
|
211
|
-
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
212
|
-
path2 += "/";
|
|
213
|
-
}
|
|
214
|
-
if (isUNCPath) {
|
|
215
|
-
if (!isPathAbsolute) {
|
|
216
|
-
return `//./${path2}`;
|
|
217
|
-
}
|
|
218
|
-
return `//${path2}`;
|
|
219
|
-
}
|
|
220
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
221
|
-
};
|
|
222
|
-
var join = function(...segments) {
|
|
223
|
-
let path2 = "";
|
|
224
|
-
for (const seg of segments) {
|
|
225
|
-
if (!seg) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (path2.length > 0) {
|
|
229
|
-
const pathTrailing = path2[path2.length - 1] === "/";
|
|
230
|
-
const segLeading = seg[0] === "/";
|
|
231
|
-
const both = pathTrailing && segLeading;
|
|
232
|
-
if (both) {
|
|
233
|
-
path2 += seg.slice(1);
|
|
234
|
-
} else {
|
|
235
|
-
path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
path2 += seg;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return normalize(path2);
|
|
242
|
-
};
|
|
243
|
-
function cwd() {
|
|
244
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
245
|
-
return process.cwd().replace(/\\/g, "/");
|
|
246
|
-
}
|
|
247
|
-
return "/";
|
|
248
|
-
}
|
|
249
|
-
var resolve = function(...arguments_) {
|
|
250
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
251
|
-
let resolvedPath = "";
|
|
252
|
-
let resolvedAbsolute = false;
|
|
253
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
254
|
-
const path2 = index >= 0 ? arguments_[index] : cwd();
|
|
255
|
-
if (!path2 || path2.length === 0) {
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
resolvedPath = `${path2}/${resolvedPath}`;
|
|
259
|
-
resolvedAbsolute = isAbsolute(path2);
|
|
260
|
-
}
|
|
261
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
262
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
263
|
-
return `/${resolvedPath}`;
|
|
264
|
-
}
|
|
265
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
266
|
-
};
|
|
267
|
-
function normalizeString(path2, allowAboveRoot) {
|
|
268
|
-
let res = "";
|
|
269
|
-
let lastSegmentLength = 0;
|
|
270
|
-
let lastSlash = -1;
|
|
271
|
-
let dots = 0;
|
|
272
|
-
let char = null;
|
|
273
|
-
for (let index = 0; index <= path2.length; ++index) {
|
|
274
|
-
if (index < path2.length) {
|
|
275
|
-
char = path2[index];
|
|
276
|
-
} else if (char === "/") {
|
|
277
|
-
break;
|
|
278
|
-
} else {
|
|
279
|
-
char = "/";
|
|
280
|
-
}
|
|
281
|
-
if (char === "/") {
|
|
282
|
-
if (lastSlash === index - 1 || dots === 1) ;
|
|
283
|
-
else if (dots === 2) {
|
|
284
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
285
|
-
if (res.length > 2) {
|
|
286
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
287
|
-
if (lastSlashIndex === -1) {
|
|
288
|
-
res = "";
|
|
289
|
-
lastSegmentLength = 0;
|
|
290
|
-
} else {
|
|
291
|
-
res = res.slice(0, lastSlashIndex);
|
|
292
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
293
|
-
}
|
|
294
|
-
lastSlash = index;
|
|
295
|
-
dots = 0;
|
|
296
|
-
continue;
|
|
297
|
-
} else if (res.length > 0) {
|
|
298
|
-
res = "";
|
|
299
|
-
lastSegmentLength = 0;
|
|
300
|
-
lastSlash = index;
|
|
301
|
-
dots = 0;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (allowAboveRoot) {
|
|
306
|
-
res += res.length > 0 ? "/.." : "..";
|
|
307
|
-
lastSegmentLength = 2;
|
|
308
|
-
}
|
|
309
|
-
} else {
|
|
310
|
-
if (res.length > 0) {
|
|
311
|
-
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
312
|
-
} else {
|
|
313
|
-
res = path2.slice(lastSlash + 1, index);
|
|
314
|
-
}
|
|
315
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
316
|
-
}
|
|
317
|
-
lastSlash = index;
|
|
318
|
-
dots = 0;
|
|
319
|
-
} else if (char === "." && dots !== -1) {
|
|
320
|
-
++dots;
|
|
321
|
-
} else {
|
|
322
|
-
dots = -1;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return res;
|
|
326
|
-
}
|
|
327
|
-
var isAbsolute = function(p) {
|
|
328
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
329
|
-
};
|
|
330
|
-
var toNamespacedPath = function(p) {
|
|
331
|
-
return normalizeWindowsPath(p);
|
|
332
|
-
};
|
|
333
|
-
var extname = function(p) {
|
|
334
|
-
if (p === "..") return "";
|
|
335
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
336
|
-
return match && match[1] || "";
|
|
337
|
-
};
|
|
338
|
-
var relative = function(from, to) {
|
|
339
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
340
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
341
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
342
|
-
return _to.join("/");
|
|
343
|
-
}
|
|
344
|
-
const _fromCopy = [..._from];
|
|
345
|
-
for (const segment of _fromCopy) {
|
|
346
|
-
if (_to[0] !== segment) {
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
_from.shift();
|
|
350
|
-
_to.shift();
|
|
351
|
-
}
|
|
352
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
353
|
-
};
|
|
354
|
-
var dirname = function(p) {
|
|
355
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
356
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
357
|
-
segments[0] += "/";
|
|
358
|
-
}
|
|
359
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
360
|
-
};
|
|
361
|
-
var format = function(p) {
|
|
362
|
-
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
363
|
-
const segments = [p.root, p.dir, _nullishCoalesce(p.base, () => ( (_nullishCoalesce(p.name, () => ( ""))) + ext))].filter(
|
|
364
|
-
Boolean
|
|
365
|
-
);
|
|
366
|
-
return normalizeWindowsPath(
|
|
367
|
-
p.root ? resolve(...segments) : segments.join("/")
|
|
368
|
-
);
|
|
369
|
-
};
|
|
370
|
-
var basename = function(p, extension) {
|
|
371
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
372
|
-
let lastSegment = "";
|
|
373
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
374
|
-
const val = segments[i];
|
|
375
|
-
if (val) {
|
|
376
|
-
lastSegment = val;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
381
|
-
};
|
|
382
|
-
var parse = function(p) {
|
|
383
|
-
const root = _optionalChain([_PATH_ROOT_RE, 'access', _4 => _4.exec, 'call', _5 => _5(p), 'optionalAccess', _6 => _6[0], 'optionalAccess', _7 => _7.replace, 'call', _8 => _8(/\\/g, "/")]) || "";
|
|
384
|
-
const base = basename(p);
|
|
385
|
-
const extension = extname(base);
|
|
386
|
-
return {
|
|
387
|
-
root,
|
|
388
|
-
dir: dirname(p),
|
|
389
|
-
base,
|
|
390
|
-
ext: extension,
|
|
391
|
-
name: base.slice(0, base.length - extension.length)
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
var matchesGlob = (path2, pattern) => {
|
|
395
|
-
return zeptomatch(pattern, normalize(path2));
|
|
396
|
-
};
|
|
397
|
-
var _path = {
|
|
398
|
-
__proto__: null,
|
|
399
|
-
basename,
|
|
400
|
-
dirname,
|
|
401
|
-
extname,
|
|
402
|
-
format,
|
|
403
|
-
isAbsolute,
|
|
404
|
-
join,
|
|
405
|
-
matchesGlob,
|
|
406
|
-
normalize,
|
|
407
|
-
normalizeString,
|
|
408
|
-
parse,
|
|
409
|
-
relative,
|
|
410
|
-
resolve,
|
|
411
|
-
sep,
|
|
412
|
-
toNamespacedPath
|
|
413
|
-
};
|
|
414
17
|
|
|
415
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
416
|
-
var delimiter = /* @__PURE__ */ (() => _optionalChain([globalThis, 'access', _9 => _9.process, 'optionalAccess', _10 => _10.platform]) === "win32" ? ";" : ":")();
|
|
417
|
-
var _platforms = { posix: void 0, win32: void 0 };
|
|
418
|
-
var mix = (del = delimiter) => {
|
|
419
|
-
return new Proxy(_path, {
|
|
420
|
-
get(_, prop) {
|
|
421
|
-
if (prop === "delimiter") return del;
|
|
422
|
-
if (prop === "posix") return posix;
|
|
423
|
-
if (prop === "win32") return win32;
|
|
424
|
-
return _platforms[prop] || _path[prop];
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
var posix = /* @__PURE__ */ mix(":");
|
|
429
|
-
var win32 = /* @__PURE__ */ mix(";");
|
|
430
18
|
|
|
431
|
-
|
|
432
|
-
function removeFileExtension(filePath) {
|
|
433
|
-
if (!filePath) {
|
|
434
|
-
return "";
|
|
435
|
-
}
|
|
436
|
-
let baseName = posix.basename(filePath);
|
|
437
|
-
let ext = posix.extname(baseName);
|
|
438
|
-
while (ext) {
|
|
439
|
-
baseName = baseName.slice(0, -ext.length);
|
|
440
|
-
ext = posix.extname(baseName);
|
|
441
|
-
}
|
|
442
|
-
const dir = posix.dirname(filePath);
|
|
443
|
-
return posix.join(dir, baseName);
|
|
444
|
-
}
|
|
445
|
-
function md5(input) {
|
|
446
|
-
const hash = _crypto2.default.createHash("md5");
|
|
447
|
-
hash.update(input);
|
|
448
|
-
return hash.digest("hex");
|
|
449
|
-
}
|
|
19
|
+
var _node = require('@weapp-tailwindcss/shared/node');
|
|
450
20
|
|
|
451
21
|
// src/config.ts
|
|
452
22
|
function getDefaultConfig() {
|
|
@@ -470,7 +40,7 @@ function getConfig(options) {
|
|
|
470
40
|
var postcssPlugin = "postcss-tailwindcss-injector";
|
|
471
41
|
|
|
472
42
|
// src/wxml.ts
|
|
473
|
-
var
|
|
43
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
474
44
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
475
45
|
var _htmlparser2 = require('htmlparser2');
|
|
476
46
|
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
@@ -535,10 +105,10 @@ function processWxml(wxml) {
|
|
|
535
105
|
}
|
|
536
106
|
async function getDep(filepath, set) {
|
|
537
107
|
if (await _fsextra2.default.exists(filepath)) {
|
|
538
|
-
const
|
|
108
|
+
const dirname = _path2.default.dirname(filepath);
|
|
539
109
|
set.add(filepath);
|
|
540
110
|
const wxml = await _fsextra2.default.readFile(filepath, "utf8");
|
|
541
|
-
const hash = md5(wxml);
|
|
111
|
+
const hash = _node.md5.call(void 0, wxml);
|
|
542
112
|
const oldHash = hashMap.get(filepath);
|
|
543
113
|
const isChanged = hash !== oldHash;
|
|
544
114
|
let deps = [];
|
|
@@ -551,7 +121,7 @@ async function getDep(filepath, set) {
|
|
|
551
121
|
deps = cacheDeps;
|
|
552
122
|
}
|
|
553
123
|
for (const { value } of deps) {
|
|
554
|
-
const p =
|
|
124
|
+
const p = _path2.default.resolve(dirname, value);
|
|
555
125
|
if (!set.has(p)) {
|
|
556
126
|
await getDep(p, set);
|
|
557
127
|
}
|
|
@@ -566,14 +136,14 @@ async function getDepFiles(file) {
|
|
|
566
136
|
|
|
567
137
|
// src/postcss.ts
|
|
568
138
|
var configCache = /* @__PURE__ */ new Map();
|
|
569
|
-
async function loadTailwindConfigOnce(
|
|
570
|
-
const cacheKey = `${
|
|
139
|
+
async function loadTailwindConfigOnce(cwd, configPath) {
|
|
140
|
+
const cacheKey = `${cwd}::${configPath}`;
|
|
571
141
|
let cached = configCache.get(cacheKey);
|
|
572
142
|
if (!cached) {
|
|
573
143
|
cached = _tailwindcssconfig.loadConfig.call(void 0, {
|
|
574
|
-
cwd
|
|
144
|
+
cwd,
|
|
575
145
|
config: configPath
|
|
576
|
-
}).then((result) => _optionalChain([result, 'optionalAccess',
|
|
146
|
+
}).then((result) => _optionalChain([result, 'optionalAccess', _ => _.config]));
|
|
577
147
|
configCache.set(cacheKey, cached);
|
|
578
148
|
}
|
|
579
149
|
return cached;
|
|
@@ -586,19 +156,19 @@ function cloneConfig(config) {
|
|
|
586
156
|
...config
|
|
587
157
|
};
|
|
588
158
|
}
|
|
589
|
-
async function resolveTailwindConfig(config,
|
|
159
|
+
async function resolveTailwindConfig(config, cwd, sourceInput) {
|
|
590
160
|
if (!config) {
|
|
591
161
|
return void 0;
|
|
592
162
|
}
|
|
593
163
|
const resolved = typeof config === "function" ? config(sourceInput) : config;
|
|
594
164
|
if (typeof resolved === "string") {
|
|
595
|
-
const loaded = await loadTailwindConfigOnce(
|
|
165
|
+
const loaded = await loadTailwindConfigOnce(cwd, resolved);
|
|
596
166
|
return cloneConfig(loaded);
|
|
597
167
|
}
|
|
598
168
|
return cloneConfig(resolved);
|
|
599
169
|
}
|
|
600
170
|
var creator = (options) => {
|
|
601
|
-
const { config, filter, directiveParams, cwd
|
|
171
|
+
const { config, filter, directiveParams, cwd, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
|
|
602
172
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
603
173
|
return {
|
|
604
174
|
postcssPlugin,
|
|
@@ -606,7 +176,7 @@ var creator = (options) => {
|
|
|
606
176
|
{
|
|
607
177
|
postcssPlugin: `${postcssPlugin}:post`,
|
|
608
178
|
async Once(root, helpers) {
|
|
609
|
-
const sourceInput = _optionalChain([root, 'access',
|
|
179
|
+
const sourceInput = _optionalChain([root, 'access', _2 => _2.source, 'optionalAccess', _3 => _3.input]);
|
|
610
180
|
if (filter(sourceInput)) {
|
|
611
181
|
const nodes = _nullishCoalesce(root.nodes, () => ( []));
|
|
612
182
|
let atruleAnchorIndex = -1;
|
|
@@ -640,13 +210,13 @@ var creator = (options) => {
|
|
|
640
210
|
directivePresence.add(params);
|
|
641
211
|
}
|
|
642
212
|
}
|
|
643
|
-
if (_optionalChain([sourceInput, 'optionalAccess',
|
|
644
|
-
const tailwindcssConfig = await _asyncNullishCoalesce(await resolveTailwindConfig(config,
|
|
645
|
-
const
|
|
646
|
-
const contentEntries = [`${
|
|
647
|
-
const deps = await getDepFiles(`${
|
|
213
|
+
if (_optionalChain([sourceInput, 'optionalAccess', _4 => _4.file])) {
|
|
214
|
+
const tailwindcssConfig = await _asyncNullishCoalesce(await resolveTailwindConfig(config, cwd, sourceInput), async () => ( { content: [] }));
|
|
215
|
+
const basename = _node.removeAllExtensions.call(void 0, sourceInput.file);
|
|
216
|
+
const contentEntries = [`${basename}.${extensionsGlob}`];
|
|
217
|
+
const deps = await getDepFiles(`${basename}.wxml`);
|
|
648
218
|
for (const dep of deps) {
|
|
649
|
-
contentEntries.push(`${
|
|
219
|
+
contentEntries.push(`${_node.removeAllExtensions.call(void 0, dep)}.${extensionsGlob}`);
|
|
650
220
|
}
|
|
651
221
|
const uniqueEntries = Array.from(new Set(contentEntries));
|
|
652
222
|
const { content: existingContent } = tailwindcssConfig;
|
package/dist/postcss.js
CHANGED
|
@@ -4,449 +4,19 @@ import tailwindcss from "tailwindcss";
|
|
|
4
4
|
import { loadConfig } from "tailwindcss-config";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
7
|
-
import
|
|
7
|
+
import process from "process";
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return r;
|
|
21
|
-
}, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
|
|
22
|
-
q(w, { default: () => re });
|
|
23
|
-
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
24
|
-
const e = /* @__PURE__ */ new Map();
|
|
25
|
-
return (n) => {
|
|
26
|
-
const a = e.get(n);
|
|
27
|
-
if (a) return a;
|
|
28
|
-
const t = r(n);
|
|
29
|
-
return e.set(n, t), t;
|
|
30
|
-
};
|
|
31
|
-
}, rr = (r, e, n = {}) => {
|
|
32
|
-
const a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
33
|
-
if (v(e)(a) && a.index === r.length) return a.output;
|
|
34
|
-
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
35
|
-
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
36
|
-
const n = {};
|
|
37
|
-
for (const a of r) {
|
|
38
|
-
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
39
|
-
const t = a.charCodeAt(0);
|
|
40
|
-
n[t] = true;
|
|
41
|
-
}
|
|
42
|
-
return (a) => {
|
|
43
|
-
const t = a.index, o = a.input;
|
|
44
|
-
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
45
|
-
const u = a.index;
|
|
46
|
-
if (u > t) {
|
|
47
|
-
if (!h(e) && !a.options.silent) {
|
|
48
|
-
const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
49
|
-
h(c) || a.output.push(c);
|
|
50
|
-
}
|
|
51
|
-
a.indexMax = Math.max(a.indexMax, a.index);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
55
|
-
}, nr = (r, e) => {
|
|
56
|
-
const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
57
|
-
return g((o) => {
|
|
58
|
-
t.lastIndex = o.index;
|
|
59
|
-
const u = t.exec(o.input);
|
|
60
|
-
if (u) {
|
|
61
|
-
if (!h(e) && !o.options.silent) {
|
|
62
|
-
const s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
63
|
-
h(s) || o.output.push(s);
|
|
64
|
-
}
|
|
65
|
-
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
|
|
66
|
-
} else return false;
|
|
67
|
-
});
|
|
68
|
-
}, ar = (r, e) => (n) => {
|
|
69
|
-
if (n.input.startsWith(r, n.index)) {
|
|
70
|
-
if (!h(e) && !n.options.silent) {
|
|
71
|
-
const t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
72
|
-
h(t) || n.output.push(t);
|
|
73
|
-
}
|
|
74
|
-
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
|
|
75
|
-
} else return false;
|
|
76
|
-
}, C = (r, e, n, a) => {
|
|
77
|
-
const t = v(r);
|
|
78
|
-
return g(_(M((o) => {
|
|
79
|
-
let u = 0;
|
|
80
|
-
for (; u < n; ) {
|
|
81
|
-
const s = o.index;
|
|
82
|
-
if (!t(o) || (u += 1, o.index === s)) break;
|
|
83
|
-
}
|
|
84
|
-
return u >= e;
|
|
85
|
-
})));
|
|
86
|
-
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
87
|
-
const n = r.map(v);
|
|
88
|
-
return g(_(M((a) => {
|
|
89
|
-
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
|
|
90
|
-
return true;
|
|
91
|
-
})));
|
|
92
|
-
}, l = (r, e) => {
|
|
93
|
-
const n = r.map(v);
|
|
94
|
-
return g(_((a) => {
|
|
95
|
-
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
|
|
96
|
-
return false;
|
|
97
|
-
}));
|
|
98
|
-
}, M = (r, e = false) => {
|
|
99
|
-
const n = v(r);
|
|
100
|
-
return (a) => {
|
|
101
|
-
const t = a.index, o = a.output.length, u = n(a);
|
|
102
|
-
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
103
|
-
};
|
|
104
|
-
}, _ = (r, e) => {
|
|
105
|
-
const n = v(r);
|
|
106
|
-
return n;
|
|
107
|
-
}, g = /* @__PURE__ */ (() => {
|
|
108
|
-
let r = 0;
|
|
109
|
-
return (e) => {
|
|
110
|
-
const n = v(e), a = r += 1;
|
|
111
|
-
return (t) => {
|
|
112
|
-
var o;
|
|
113
|
-
if (t.options.memoization === false) return n(t);
|
|
114
|
-
const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
115
|
-
if (c === false) return false;
|
|
116
|
-
if (W(c)) return t.index = c, true;
|
|
117
|
-
if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), true;
|
|
118
|
-
{
|
|
119
|
-
const Z = t.output.length;
|
|
120
|
-
if (n(t)) {
|
|
121
|
-
const D = t.index, U = t.output.length;
|
|
122
|
-
if (U > Z) {
|
|
123
|
-
const ee = t.output.slice(Z, U);
|
|
124
|
-
s.set(u, { index: D, output: ee });
|
|
125
|
-
} else s.set(u, D);
|
|
126
|
-
return true;
|
|
127
|
-
} else return s.set(u, false), false;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
})(), E = (r) => {
|
|
132
|
-
let e;
|
|
133
|
-
return (n) => (e || (e = v(r())), e(n));
|
|
134
|
-
}, v = Y((r) => {
|
|
135
|
-
if (d(r)) return Q(r) ? E(r) : r;
|
|
136
|
-
if (b(r) || X(r)) return i(r);
|
|
137
|
-
if (A(r)) return x(r);
|
|
138
|
-
if (K(r)) return l(Object.values(r));
|
|
139
|
-
throw new Error("Invalid rule");
|
|
140
|
-
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
141
|
-
let e = "";
|
|
142
|
-
for (; r > 0; ) {
|
|
143
|
-
const n = (r - 1) % 26;
|
|
144
|
-
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
145
|
-
}
|
|
146
|
-
return e;
|
|
147
|
-
}, O = (r) => {
|
|
148
|
-
let e = 0;
|
|
149
|
-
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
150
|
-
return e;
|
|
151
|
-
}, S = (r, e) => {
|
|
152
|
-
if (e < r) return S(e, r);
|
|
153
|
-
const n = [];
|
|
154
|
-
for (; r <= e; ) n.push(r++);
|
|
155
|
-
return n;
|
|
156
|
-
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
|
|
157
|
-
const e = {};
|
|
158
|
-
return (n) => e[n] ?? (e[n] = r(n));
|
|
159
|
-
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, tr(Ar), f(Er), wr]), Pr = i("{", "(?:"), Or = i("}", ")"), Rr = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = z(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
160
|
-
const n = Array.isArray(r) ? r : [r];
|
|
161
|
-
if (!n.length) return false;
|
|
162
|
-
const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
163
|
-
return a.some((s) => s.test(o));
|
|
164
|
-
};
|
|
165
|
-
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
166
|
-
var re = $;
|
|
167
|
-
return J(w);
|
|
168
|
-
})();
|
|
169
|
-
return __lib__.default || __lib__;
|
|
170
|
-
};
|
|
171
|
-
var _match;
|
|
172
|
-
var zeptomatch = (path2, pattern) => {
|
|
173
|
-
if (!_match) {
|
|
174
|
-
_match = _lazyMatch();
|
|
175
|
-
_lazyMatch = null;
|
|
176
|
-
}
|
|
177
|
-
return _match(path2, pattern);
|
|
178
|
-
};
|
|
179
|
-
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
180
|
-
function normalizeWindowsPath(input = "") {
|
|
181
|
-
if (!input) {
|
|
182
|
-
return input;
|
|
183
|
-
}
|
|
184
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
185
|
-
}
|
|
186
|
-
var _UNC_REGEX = /^[/\\]{2}/;
|
|
187
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
188
|
-
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
189
|
-
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
190
|
-
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
191
|
-
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
192
|
-
var sep = "/";
|
|
193
|
-
var normalize = function(path2) {
|
|
194
|
-
if (path2.length === 0) {
|
|
195
|
-
return ".";
|
|
196
|
-
}
|
|
197
|
-
path2 = normalizeWindowsPath(path2);
|
|
198
|
-
const isUNCPath = path2.match(_UNC_REGEX);
|
|
199
|
-
const isPathAbsolute = isAbsolute(path2);
|
|
200
|
-
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
201
|
-
path2 = normalizeString(path2, !isPathAbsolute);
|
|
202
|
-
if (path2.length === 0) {
|
|
203
|
-
if (isPathAbsolute) {
|
|
204
|
-
return "/";
|
|
205
|
-
}
|
|
206
|
-
return trailingSeparator ? "./" : ".";
|
|
207
|
-
}
|
|
208
|
-
if (trailingSeparator) {
|
|
209
|
-
path2 += "/";
|
|
210
|
-
}
|
|
211
|
-
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
212
|
-
path2 += "/";
|
|
213
|
-
}
|
|
214
|
-
if (isUNCPath) {
|
|
215
|
-
if (!isPathAbsolute) {
|
|
216
|
-
return `//./${path2}`;
|
|
217
|
-
}
|
|
218
|
-
return `//${path2}`;
|
|
219
|
-
}
|
|
220
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
221
|
-
};
|
|
222
|
-
var join = function(...segments) {
|
|
223
|
-
let path2 = "";
|
|
224
|
-
for (const seg of segments) {
|
|
225
|
-
if (!seg) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (path2.length > 0) {
|
|
229
|
-
const pathTrailing = path2[path2.length - 1] === "/";
|
|
230
|
-
const segLeading = seg[0] === "/";
|
|
231
|
-
const both = pathTrailing && segLeading;
|
|
232
|
-
if (both) {
|
|
233
|
-
path2 += seg.slice(1);
|
|
234
|
-
} else {
|
|
235
|
-
path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
path2 += seg;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return normalize(path2);
|
|
242
|
-
};
|
|
243
|
-
function cwd() {
|
|
244
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
245
|
-
return process.cwd().replace(/\\/g, "/");
|
|
246
|
-
}
|
|
247
|
-
return "/";
|
|
248
|
-
}
|
|
249
|
-
var resolve = function(...arguments_) {
|
|
250
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
251
|
-
let resolvedPath = "";
|
|
252
|
-
let resolvedAbsolute = false;
|
|
253
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
254
|
-
const path2 = index >= 0 ? arguments_[index] : cwd();
|
|
255
|
-
if (!path2 || path2.length === 0) {
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
resolvedPath = `${path2}/${resolvedPath}`;
|
|
259
|
-
resolvedAbsolute = isAbsolute(path2);
|
|
260
|
-
}
|
|
261
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
262
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
263
|
-
return `/${resolvedPath}`;
|
|
264
|
-
}
|
|
265
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
266
|
-
};
|
|
267
|
-
function normalizeString(path2, allowAboveRoot) {
|
|
268
|
-
let res = "";
|
|
269
|
-
let lastSegmentLength = 0;
|
|
270
|
-
let lastSlash = -1;
|
|
271
|
-
let dots = 0;
|
|
272
|
-
let char = null;
|
|
273
|
-
for (let index = 0; index <= path2.length; ++index) {
|
|
274
|
-
if (index < path2.length) {
|
|
275
|
-
char = path2[index];
|
|
276
|
-
} else if (char === "/") {
|
|
277
|
-
break;
|
|
278
|
-
} else {
|
|
279
|
-
char = "/";
|
|
280
|
-
}
|
|
281
|
-
if (char === "/") {
|
|
282
|
-
if (lastSlash === index - 1 || dots === 1) ;
|
|
283
|
-
else if (dots === 2) {
|
|
284
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
285
|
-
if (res.length > 2) {
|
|
286
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
287
|
-
if (lastSlashIndex === -1) {
|
|
288
|
-
res = "";
|
|
289
|
-
lastSegmentLength = 0;
|
|
290
|
-
} else {
|
|
291
|
-
res = res.slice(0, lastSlashIndex);
|
|
292
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
293
|
-
}
|
|
294
|
-
lastSlash = index;
|
|
295
|
-
dots = 0;
|
|
296
|
-
continue;
|
|
297
|
-
} else if (res.length > 0) {
|
|
298
|
-
res = "";
|
|
299
|
-
lastSegmentLength = 0;
|
|
300
|
-
lastSlash = index;
|
|
301
|
-
dots = 0;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (allowAboveRoot) {
|
|
306
|
-
res += res.length > 0 ? "/.." : "..";
|
|
307
|
-
lastSegmentLength = 2;
|
|
308
|
-
}
|
|
309
|
-
} else {
|
|
310
|
-
if (res.length > 0) {
|
|
311
|
-
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
312
|
-
} else {
|
|
313
|
-
res = path2.slice(lastSlash + 1, index);
|
|
314
|
-
}
|
|
315
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
316
|
-
}
|
|
317
|
-
lastSlash = index;
|
|
318
|
-
dots = 0;
|
|
319
|
-
} else if (char === "." && dots !== -1) {
|
|
320
|
-
++dots;
|
|
321
|
-
} else {
|
|
322
|
-
dots = -1;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return res;
|
|
326
|
-
}
|
|
327
|
-
var isAbsolute = function(p) {
|
|
328
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
329
|
-
};
|
|
330
|
-
var toNamespacedPath = function(p) {
|
|
331
|
-
return normalizeWindowsPath(p);
|
|
332
|
-
};
|
|
333
|
-
var extname = function(p) {
|
|
334
|
-
if (p === "..") return "";
|
|
335
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
336
|
-
return match && match[1] || "";
|
|
337
|
-
};
|
|
338
|
-
var relative = function(from, to) {
|
|
339
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
340
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
341
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
342
|
-
return _to.join("/");
|
|
343
|
-
}
|
|
344
|
-
const _fromCopy = [..._from];
|
|
345
|
-
for (const segment of _fromCopy) {
|
|
346
|
-
if (_to[0] !== segment) {
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
_from.shift();
|
|
350
|
-
_to.shift();
|
|
351
|
-
}
|
|
352
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
353
|
-
};
|
|
354
|
-
var dirname = function(p) {
|
|
355
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
356
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
357
|
-
segments[0] += "/";
|
|
358
|
-
}
|
|
359
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
360
|
-
};
|
|
361
|
-
var format = function(p) {
|
|
362
|
-
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
363
|
-
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
364
|
-
Boolean
|
|
365
|
-
);
|
|
366
|
-
return normalizeWindowsPath(
|
|
367
|
-
p.root ? resolve(...segments) : segments.join("/")
|
|
368
|
-
);
|
|
369
|
-
};
|
|
370
|
-
var basename = function(p, extension) {
|
|
371
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
372
|
-
let lastSegment = "";
|
|
373
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
374
|
-
const val = segments[i];
|
|
375
|
-
if (val) {
|
|
376
|
-
lastSegment = val;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
381
|
-
};
|
|
382
|
-
var parse = function(p) {
|
|
383
|
-
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
384
|
-
const base = basename(p);
|
|
385
|
-
const extension = extname(base);
|
|
386
|
-
return {
|
|
387
|
-
root,
|
|
388
|
-
dir: dirname(p),
|
|
389
|
-
base,
|
|
390
|
-
ext: extension,
|
|
391
|
-
name: base.slice(0, base.length - extension.length)
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
var matchesGlob = (path2, pattern) => {
|
|
395
|
-
return zeptomatch(pattern, normalize(path2));
|
|
396
|
-
};
|
|
397
|
-
var _path = {
|
|
398
|
-
__proto__: null,
|
|
399
|
-
basename,
|
|
400
|
-
dirname,
|
|
401
|
-
extname,
|
|
402
|
-
format,
|
|
403
|
-
isAbsolute,
|
|
404
|
-
join,
|
|
405
|
-
matchesGlob,
|
|
406
|
-
normalize,
|
|
407
|
-
normalizeString,
|
|
408
|
-
parse,
|
|
409
|
-
relative,
|
|
410
|
-
resolve,
|
|
411
|
-
sep,
|
|
412
|
-
toNamespacedPath
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
416
|
-
var delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
|
417
|
-
var _platforms = { posix: void 0, win32: void 0 };
|
|
418
|
-
var mix = (del = delimiter) => {
|
|
419
|
-
return new Proxy(_path, {
|
|
420
|
-
get(_, prop) {
|
|
421
|
-
if (prop === "delimiter") return del;
|
|
422
|
-
if (prop === "posix") return posix;
|
|
423
|
-
if (prop === "win32") return win32;
|
|
424
|
-
return _platforms[prop] || _path[prop];
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
var posix = /* @__PURE__ */ mix(":");
|
|
429
|
-
var win32 = /* @__PURE__ */ mix(";");
|
|
430
|
-
|
|
431
|
-
// src/utils.ts
|
|
432
|
-
function removeFileExtension(filePath) {
|
|
433
|
-
if (!filePath) {
|
|
434
|
-
return "";
|
|
435
|
-
}
|
|
436
|
-
let baseName = posix.basename(filePath);
|
|
437
|
-
let ext = posix.extname(baseName);
|
|
438
|
-
while (ext) {
|
|
439
|
-
baseName = baseName.slice(0, -ext.length);
|
|
440
|
-
ext = posix.extname(baseName);
|
|
441
|
-
}
|
|
442
|
-
const dir = posix.dirname(filePath);
|
|
443
|
-
return posix.join(dir, baseName);
|
|
444
|
-
}
|
|
445
|
-
function md5(input) {
|
|
446
|
-
const hash = crypto.createHash("md5");
|
|
447
|
-
hash.update(input);
|
|
448
|
-
return hash.digest("hex");
|
|
449
|
-
}
|
|
10
|
+
import {
|
|
11
|
+
defu,
|
|
12
|
+
defuOverrideArray,
|
|
13
|
+
isRegexp,
|
|
14
|
+
regExpTest
|
|
15
|
+
} from "@weapp-tailwindcss/shared";
|
|
16
|
+
import {
|
|
17
|
+
md5,
|
|
18
|
+
removeAllExtensions
|
|
19
|
+
} from "@weapp-tailwindcss/shared/node";
|
|
450
20
|
|
|
451
21
|
// src/config.ts
|
|
452
22
|
function getDefaultConfig() {
|
|
@@ -455,7 +25,7 @@ function getDefaultConfig() {
|
|
|
455
25
|
config: void 0,
|
|
456
26
|
// 倒叙插入
|
|
457
27
|
directiveParams: ["utilities", "components"],
|
|
458
|
-
cwd:
|
|
28
|
+
cwd: process.cwd(),
|
|
459
29
|
extensions: ["wxml", "js", "ts"],
|
|
460
30
|
// @import and @use (scss)
|
|
461
31
|
insertAfterAtRulesNames: ["import", "use"],
|
|
@@ -535,7 +105,7 @@ function processWxml(wxml) {
|
|
|
535
105
|
}
|
|
536
106
|
async function getDep(filepath, set) {
|
|
537
107
|
if (await fs.exists(filepath)) {
|
|
538
|
-
const
|
|
108
|
+
const dirname = path.dirname(filepath);
|
|
539
109
|
set.add(filepath);
|
|
540
110
|
const wxml = await fs.readFile(filepath, "utf8");
|
|
541
111
|
const hash = md5(wxml);
|
|
@@ -551,7 +121,7 @@ async function getDep(filepath, set) {
|
|
|
551
121
|
deps = cacheDeps;
|
|
552
122
|
}
|
|
553
123
|
for (const { value } of deps) {
|
|
554
|
-
const p = path.resolve(
|
|
124
|
+
const p = path.resolve(dirname, value);
|
|
555
125
|
if (!set.has(p)) {
|
|
556
126
|
await getDep(p, set);
|
|
557
127
|
}
|
|
@@ -566,12 +136,12 @@ async function getDepFiles(file) {
|
|
|
566
136
|
|
|
567
137
|
// src/postcss.ts
|
|
568
138
|
var configCache = /* @__PURE__ */ new Map();
|
|
569
|
-
async function loadTailwindConfigOnce(
|
|
570
|
-
const cacheKey = `${
|
|
139
|
+
async function loadTailwindConfigOnce(cwd, configPath) {
|
|
140
|
+
const cacheKey = `${cwd}::${configPath}`;
|
|
571
141
|
let cached = configCache.get(cacheKey);
|
|
572
142
|
if (!cached) {
|
|
573
143
|
cached = loadConfig({
|
|
574
|
-
cwd
|
|
144
|
+
cwd,
|
|
575
145
|
config: configPath
|
|
576
146
|
}).then((result) => result?.config);
|
|
577
147
|
configCache.set(cacheKey, cached);
|
|
@@ -586,19 +156,19 @@ function cloneConfig(config) {
|
|
|
586
156
|
...config
|
|
587
157
|
};
|
|
588
158
|
}
|
|
589
|
-
async function resolveTailwindConfig(config,
|
|
159
|
+
async function resolveTailwindConfig(config, cwd, sourceInput) {
|
|
590
160
|
if (!config) {
|
|
591
161
|
return void 0;
|
|
592
162
|
}
|
|
593
163
|
const resolved = typeof config === "function" ? config(sourceInput) : config;
|
|
594
164
|
if (typeof resolved === "string") {
|
|
595
|
-
const loaded = await loadTailwindConfigOnce(
|
|
165
|
+
const loaded = await loadTailwindConfigOnce(cwd, resolved);
|
|
596
166
|
return cloneConfig(loaded);
|
|
597
167
|
}
|
|
598
168
|
return cloneConfig(resolved);
|
|
599
169
|
}
|
|
600
170
|
var creator = (options) => {
|
|
601
|
-
const { config, filter, directiveParams, cwd
|
|
171
|
+
const { config, filter, directiveParams, cwd, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
|
|
602
172
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
603
173
|
return {
|
|
604
174
|
postcssPlugin,
|
|
@@ -641,12 +211,12 @@ var creator = (options) => {
|
|
|
641
211
|
}
|
|
642
212
|
}
|
|
643
213
|
if (sourceInput?.file) {
|
|
644
|
-
const tailwindcssConfig = await resolveTailwindConfig(config,
|
|
645
|
-
const
|
|
646
|
-
const contentEntries = [`${
|
|
647
|
-
const deps = await getDepFiles(`${
|
|
214
|
+
const tailwindcssConfig = await resolveTailwindConfig(config, cwd, sourceInput) ?? { content: [] };
|
|
215
|
+
const basename = removeAllExtensions(sourceInput.file);
|
|
216
|
+
const contentEntries = [`${basename}.${extensionsGlob}`];
|
|
217
|
+
const deps = await getDepFiles(`${basename}.wxml`);
|
|
648
218
|
for (const dep of deps) {
|
|
649
|
-
contentEntries.push(`${
|
|
219
|
+
contentEntries.push(`${removeAllExtensions(dep)}.${extensionsGlob}`);
|
|
650
220
|
}
|
|
651
221
|
const uniqueEntries = Array.from(new Set(contentEntries));
|
|
652
222
|
const { content: existingContent } = tailwindcssConfig;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-injector",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8-alpha.0",
|
|
5
5
|
"description": "tsup(esbuild) build package template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"magic-string": "^0.30.19",
|
|
37
37
|
"postcss": "^8.5.6",
|
|
38
38
|
"tailwindcss": "^3.4.17",
|
|
39
|
-
"@weapp-tailwindcss/shared": "1.0.
|
|
40
|
-
"tailwindcss-config": "1.1.
|
|
39
|
+
"@weapp-tailwindcss/shared": "1.1.0-alpha.0",
|
|
40
|
+
"tailwindcss-config": "1.1.2-alpha.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch --sourcemap",
|