tailwindcss-injector 1.0.6 → 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 CHANGED
@@ -1,675 +1,22 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.5_jiti@2.5.1_postcss@8.5.6_tsx@4.20.5_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
31
- var init_cjs_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.5_jiti@2.5.1_postcss@8.5.6_tsx@4.20.5_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js"() {
33
- "use strict";
34
- }
35
- });
36
-
37
- // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
38
- var require_is_primitive = __commonJS({
39
- "../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
40
- "use strict";
41
- init_cjs_shims();
42
- module.exports = function isPrimitive(val) {
43
- if (typeof val === "object") {
44
- return val === null;
45
- }
46
- return typeof val !== "function";
47
- };
48
- }
49
- });
50
-
51
- // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
52
- var require_isobject = __commonJS({
53
- "../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
54
- "use strict";
55
- init_cjs_shims();
56
- module.exports = function isObject(val) {
57
- return val != null && typeof val === "object" && Array.isArray(val) === false;
58
- };
59
- }
60
- });
61
-
62
- // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
63
- var require_is_plain_object = __commonJS({
64
- "../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
65
- "use strict";
66
- init_cjs_shims();
67
- var isObject = require_isobject();
68
- function isObjectObject(o) {
69
- return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
70
- }
71
- module.exports = function isPlainObject(o) {
72
- var ctor, prot;
73
- if (isObjectObject(o) === false) return false;
74
- ctor = o.constructor;
75
- if (typeof ctor !== "function") return false;
76
- prot = ctor.prototype;
77
- if (isObjectObject(prot) === false) return false;
78
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
79
- return false;
80
- }
81
- return true;
82
- };
83
- }
84
- });
85
-
86
- // ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
87
- var require_set_value = __commonJS({
88
- "../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
89
- "use strict";
90
- init_cjs_shims();
91
- var { deleteProperty } = Reflect;
92
- var isPrimitive = require_is_primitive();
93
- var isPlainObject = require_is_plain_object();
94
- var isObject = (value) => {
95
- return typeof value === "object" && value !== null || typeof value === "function";
96
- };
97
- var isUnsafeKey = (key) => {
98
- return key === "__proto__" || key === "constructor" || key === "prototype";
99
- };
100
- var validateKey = (key) => {
101
- if (!isPrimitive(key)) {
102
- throw new TypeError("Object keys must be strings or symbols");
103
- }
104
- if (isUnsafeKey(key)) {
105
- throw new Error(`Cannot set unsafe key: "${key}"`);
106
- }
107
- };
108
- var toStringKey = (input) => {
109
- return Array.isArray(input) ? input.flat().map(String).join(",") : input;
110
- };
111
- var createMemoKey = (input, options) => {
112
- if (typeof input !== "string" || !options) return input;
113
- let key = input + ";";
114
- if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
115
- if (options.separator !== void 0) key += `separator=${options.separator};`;
116
- if (options.split !== void 0) key += `split=${options.split};`;
117
- if (options.merge !== void 0) key += `merge=${options.merge};`;
118
- if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
119
- return key;
120
- };
121
- var memoize = (input, options, fn) => {
122
- const key = toStringKey(options ? createMemoKey(input, options) : input);
123
- validateKey(key);
124
- const value = setValue.cache.get(key) || fn();
125
- setValue.cache.set(key, value);
126
- return value;
127
- };
128
- var splitString = (input, options = {}) => {
129
- const sep2 = options.separator || ".";
130
- const preserve = sep2 === "/" ? false : options.preservePaths;
131
- if (typeof input === "string" && preserve !== false && /\//.test(input)) {
132
- return [input];
133
- }
134
- const parts = [];
135
- let part = "";
136
- const push = (part2) => {
137
- let number;
138
- if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
139
- parts.push(number);
140
- } else {
141
- parts.push(part2);
142
- }
143
- };
144
- for (let i = 0; i < input.length; i++) {
145
- const value = input[i];
146
- if (value === "\\") {
147
- part += input[++i];
148
- continue;
149
- }
150
- if (value === sep2) {
151
- push(part);
152
- part = "";
153
- continue;
154
- }
155
- part += value;
156
- }
157
- if (part) {
158
- push(part);
159
- }
160
- return parts;
161
- };
162
- var split = (input, options) => {
163
- if (options && typeof options.split === "function") return options.split(input);
164
- if (typeof input === "symbol") return [input];
165
- if (Array.isArray(input)) return input;
166
- return memoize(input, options, () => splitString(input, options));
167
- };
168
- var assignProp = (obj, prop, value, options) => {
169
- validateKey(prop);
170
- if (value === void 0) {
171
- deleteProperty(obj, prop);
172
- } else if (options && options.merge) {
173
- const merge = options.merge === "function" ? options.merge : Object.assign;
174
- if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
175
- obj[prop] = merge(obj[prop], value);
176
- } else {
177
- obj[prop] = value;
178
- }
179
- } else {
180
- obj[prop] = value;
181
- }
182
- return obj;
183
- };
184
- var setValue = (target, path2, value, options) => {
185
- if (!path2 || !isObject(target)) return target;
186
- const keys = split(path2, options);
187
- let obj = target;
188
- for (let i = 0; i < keys.length; i++) {
189
- const key = keys[i];
190
- const next = keys[i + 1];
191
- validateKey(key);
192
- if (next === void 0) {
193
- assignProp(obj, key, value, options);
194
- break;
195
- }
196
- if (typeof next === "number" && !Array.isArray(obj[key])) {
197
- obj = obj[key] = [];
198
- continue;
199
- }
200
- if (!isObject(obj[key])) {
201
- obj[key] = {};
202
- }
203
- obj = obj[key];
204
- }
205
- return target;
206
- };
207
- setValue.split = split;
208
- setValue.cache = /* @__PURE__ */ new Map();
209
- setValue.clear = () => {
210
- setValue.cache = /* @__PURE__ */ new Map();
211
- };
212
- module.exports = setValue;
213
- }
214
- });
215
-
216
- // src/postcss.ts
217
- init_cjs_shims();
218
- var import_set_value = __toESM(require_set_value(), 1);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/postcss.ts
219
2
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
220
3
  var _tailwindcss = require('tailwindcss'); var _tailwindcss2 = _interopRequireDefault(_tailwindcss);
221
4
  var _tailwindcssconfig = require('tailwindcss-config');
222
5
 
223
6
  // src/config.ts
224
- init_cjs_shims();
225
7
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
226
8
 
227
9
  // src/utils.ts
228
- init_cjs_shims();
229
- var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
230
- var _shared = require('@weapp-tailwindcss/shared');
231
10
 
232
- // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
233
- init_cjs_shims();
234
11
 
235
- // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
236
- init_cjs_shims();
237
- var _lazyMatch = () => {
238
- var __lib__ = (() => {
239
- var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
240
- for (var n in e) m(r, n, { get: e[n], enumerable: true });
241
- }, H = (r, e, n, a) => {
242
- 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 });
243
- return r;
244
- }, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
245
- q(w, { default: () => re });
246
- 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) => {
247
- const e = /* @__PURE__ */ new Map();
248
- return (n) => {
249
- const a = e.get(n);
250
- if (a) return a;
251
- const t = r(n);
252
- return e.set(n, t), t;
253
- };
254
- }, rr = (r, e, n = {}) => {
255
- const a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
256
- if (v(e)(a) && a.index === r.length) return a.output;
257
- throw new Error(`Failed to parse at index ${a.indexMax}`);
258
- }, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
259
- const n = {};
260
- for (const a of r) {
261
- if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
262
- const t = a.charCodeAt(0);
263
- n[t] = true;
264
- }
265
- return (a) => {
266
- const t = a.index, o = a.input;
267
- for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
268
- const u = a.index;
269
- if (u > t) {
270
- if (!h(e) && !a.options.silent) {
271
- const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
272
- h(c) || a.output.push(c);
273
- }
274
- a.indexMax = Math.max(a.indexMax, a.index);
275
- }
276
- return true;
277
- };
278
- }, nr = (r, e) => {
279
- const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
280
- return g((o) => {
281
- t.lastIndex = o.index;
282
- const u = t.exec(o.input);
283
- if (u) {
284
- if (!h(e) && !o.options.silent) {
285
- const s = d(e) ? e(...u, o.input, String(o.index)) : e;
286
- h(s) || o.output.push(s);
287
- }
288
- return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
289
- } else return false;
290
- });
291
- }, ar = (r, e) => (n) => {
292
- if (n.input.startsWith(r, n.index)) {
293
- if (!h(e) && !n.options.silent) {
294
- const t = d(e) ? e(r, n.input, String(n.index)) : e;
295
- h(t) || n.output.push(t);
296
- }
297
- return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
298
- } else return false;
299
- }, C = (r, e, n, a) => {
300
- const t = v(r);
301
- return g(_(M((o) => {
302
- let u = 0;
303
- for (; u < n; ) {
304
- const s = o.index;
305
- if (!t(o) || (u += 1, o.index === s)) break;
306
- }
307
- return u >= e;
308
- })));
309
- }, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
310
- const n = r.map(v);
311
- return g(_(M((a) => {
312
- for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
313
- return true;
314
- })));
315
- }, l = (r, e) => {
316
- const n = r.map(v);
317
- return g(_((a) => {
318
- for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
319
- return false;
320
- }));
321
- }, M = (r, e = false) => {
322
- const n = v(r);
323
- return (a) => {
324
- const t = a.index, o = a.output.length, u = n(a);
325
- return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
326
- };
327
- }, _ = (r, e) => {
328
- const n = v(r);
329
- return n;
330
- }, g = /* @__PURE__ */ (() => {
331
- let r = 0;
332
- return (e) => {
333
- const n = v(e), a = r += 1;
334
- return (t) => {
335
- var o;
336
- if (t.options.memoization === false) return n(t);
337
- const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
338
- if (c === false) return false;
339
- if (W(c)) return t.index = c, true;
340
- if (c) return t.index = c.index, _optionalChain([c, 'access', _2 => _2.output, 'optionalAccess', _3 => _3.length]) && t.output.push(...c.output), true;
341
- {
342
- const Z = t.output.length;
343
- if (n(t)) {
344
- const D = t.index, U = t.output.length;
345
- if (U > Z) {
346
- const ee = t.output.slice(Z, U);
347
- s.set(u, { index: D, output: ee });
348
- } else s.set(u, D);
349
- return true;
350
- } else return s.set(u, false), false;
351
- }
352
- };
353
- };
354
- })(), E = (r) => {
355
- let e;
356
- return (n) => (e || (e = v(r())), e(n));
357
- }, v = Y((r) => {
358
- if (d(r)) return Q(r) ? E(r) : r;
359
- if (b(r) || X(r)) return i(r);
360
- if (A(r)) return x(r);
361
- if (K(r)) return l(Object.values(r));
362
- throw new Error("Invalid rule");
363
- }), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
364
- let e = "";
365
- for (; r > 0; ) {
366
- const n = (r - 1) % 26;
367
- e = P[n] + e, r = Math.floor((r - 1) / 26);
368
- }
369
- return e;
370
- }, O = (r) => {
371
- let e = 0;
372
- for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
373
- return e;
374
- }, S = (r, e) => {
375
- if (e < r) return S(e, r);
376
- const n = [];
377
- for (; r <= e; ) n.push(r++);
378
- return n;
379
- }, 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) => {
380
- const e = {};
381
- return (n) => _nullishCoalesce(e[n], () => ( (e[n] = r(n))));
382
- }, 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) => {
383
- const n = Array.isArray(r) ? r : [r];
384
- if (!n.length) return false;
385
- const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
386
- return a.some((s) => s.test(o));
387
- };
388
- $.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
389
- var re = $;
390
- return J(w);
391
- })();
392
- return __lib__.default || __lib__;
393
- };
394
- var _match;
395
- var zeptomatch = (path2, pattern) => {
396
- if (!_match) {
397
- _match = _lazyMatch();
398
- _lazyMatch = null;
399
- }
400
- return _match(path2, pattern);
401
- };
402
- var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
403
- function normalizeWindowsPath(input = "") {
404
- if (!input) {
405
- return input;
406
- }
407
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
408
- }
409
- var _UNC_REGEX = /^[/\\]{2}/;
410
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
411
- var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
412
- var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
413
- var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
414
- var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
415
- var sep = "/";
416
- var normalize = function(path2) {
417
- if (path2.length === 0) {
418
- return ".";
419
- }
420
- path2 = normalizeWindowsPath(path2);
421
- const isUNCPath = path2.match(_UNC_REGEX);
422
- const isPathAbsolute = isAbsolute(path2);
423
- const trailingSeparator = path2[path2.length - 1] === "/";
424
- path2 = normalizeString(path2, !isPathAbsolute);
425
- if (path2.length === 0) {
426
- if (isPathAbsolute) {
427
- return "/";
428
- }
429
- return trailingSeparator ? "./" : ".";
430
- }
431
- if (trailingSeparator) {
432
- path2 += "/";
433
- }
434
- if (_DRIVE_LETTER_RE.test(path2)) {
435
- path2 += "/";
436
- }
437
- if (isUNCPath) {
438
- if (!isPathAbsolute) {
439
- return `//./${path2}`;
440
- }
441
- return `//${path2}`;
442
- }
443
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
444
- };
445
- var join = function(...segments) {
446
- let path2 = "";
447
- for (const seg of segments) {
448
- if (!seg) {
449
- continue;
450
- }
451
- if (path2.length > 0) {
452
- const pathTrailing = path2[path2.length - 1] === "/";
453
- const segLeading = seg[0] === "/";
454
- const both = pathTrailing && segLeading;
455
- if (both) {
456
- path2 += seg.slice(1);
457
- } else {
458
- path2 += pathTrailing || segLeading ? seg : `/${seg}`;
459
- }
460
- } else {
461
- path2 += seg;
462
- }
463
- }
464
- return normalize(path2);
465
- };
466
- function cwd() {
467
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
468
- return process.cwd().replace(/\\/g, "/");
469
- }
470
- return "/";
471
- }
472
- var resolve = function(...arguments_) {
473
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
474
- let resolvedPath = "";
475
- let resolvedAbsolute = false;
476
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
477
- const path2 = index >= 0 ? arguments_[index] : cwd();
478
- if (!path2 || path2.length === 0) {
479
- continue;
480
- }
481
- resolvedPath = `${path2}/${resolvedPath}`;
482
- resolvedAbsolute = isAbsolute(path2);
483
- }
484
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
485
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
486
- return `/${resolvedPath}`;
487
- }
488
- return resolvedPath.length > 0 ? resolvedPath : ".";
489
- };
490
- function normalizeString(path2, allowAboveRoot) {
491
- let res = "";
492
- let lastSegmentLength = 0;
493
- let lastSlash = -1;
494
- let dots = 0;
495
- let char = null;
496
- for (let index = 0; index <= path2.length; ++index) {
497
- if (index < path2.length) {
498
- char = path2[index];
499
- } else if (char === "/") {
500
- break;
501
- } else {
502
- char = "/";
503
- }
504
- if (char === "/") {
505
- if (lastSlash === index - 1 || dots === 1) ;
506
- else if (dots === 2) {
507
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
508
- if (res.length > 2) {
509
- const lastSlashIndex = res.lastIndexOf("/");
510
- if (lastSlashIndex === -1) {
511
- res = "";
512
- lastSegmentLength = 0;
513
- } else {
514
- res = res.slice(0, lastSlashIndex);
515
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
516
- }
517
- lastSlash = index;
518
- dots = 0;
519
- continue;
520
- } else if (res.length > 0) {
521
- res = "";
522
- lastSegmentLength = 0;
523
- lastSlash = index;
524
- dots = 0;
525
- continue;
526
- }
527
- }
528
- if (allowAboveRoot) {
529
- res += res.length > 0 ? "/.." : "..";
530
- lastSegmentLength = 2;
531
- }
532
- } else {
533
- if (res.length > 0) {
534
- res += `/${path2.slice(lastSlash + 1, index)}`;
535
- } else {
536
- res = path2.slice(lastSlash + 1, index);
537
- }
538
- lastSegmentLength = index - lastSlash - 1;
539
- }
540
- lastSlash = index;
541
- dots = 0;
542
- } else if (char === "." && dots !== -1) {
543
- ++dots;
544
- } else {
545
- dots = -1;
546
- }
547
- }
548
- return res;
549
- }
550
- var isAbsolute = function(p) {
551
- return _IS_ABSOLUTE_RE.test(p);
552
- };
553
- var toNamespacedPath = function(p) {
554
- return normalizeWindowsPath(p);
555
- };
556
- var extname = function(p) {
557
- if (p === "..") return "";
558
- const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
559
- return match && match[1] || "";
560
- };
561
- var relative = function(from, to) {
562
- const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
563
- const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
564
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
565
- return _to.join("/");
566
- }
567
- const _fromCopy = [..._from];
568
- for (const segment of _fromCopy) {
569
- if (_to[0] !== segment) {
570
- break;
571
- }
572
- _from.shift();
573
- _to.shift();
574
- }
575
- return [..._from.map(() => ".."), ..._to].join("/");
576
- };
577
- var dirname = function(p) {
578
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
579
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
580
- segments[0] += "/";
581
- }
582
- return segments.join("/") || (isAbsolute(p) ? "/" : ".");
583
- };
584
- var format = function(p) {
585
- const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
586
- const segments = [p.root, p.dir, _nullishCoalesce(p.base, () => ( (_nullishCoalesce(p.name, () => ( ""))) + ext))].filter(
587
- Boolean
588
- );
589
- return normalizeWindowsPath(
590
- p.root ? resolve(...segments) : segments.join("/")
591
- );
592
- };
593
- var basename = function(p, extension) {
594
- const segments = normalizeWindowsPath(p).split("/");
595
- let lastSegment = "";
596
- for (let i = segments.length - 1; i >= 0; i--) {
597
- const val = segments[i];
598
- if (val) {
599
- lastSegment = val;
600
- break;
601
- }
602
- }
603
- return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
604
- };
605
- var parse = function(p) {
606
- 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, "/")]) || "";
607
- const base = basename(p);
608
- const extension = extname(base);
609
- return {
610
- root,
611
- dir: dirname(p),
612
- base,
613
- ext: extension,
614
- name: base.slice(0, base.length - extension.length)
615
- };
616
- };
617
- var matchesGlob = (path2, pattern) => {
618
- return zeptomatch(pattern, normalize(path2));
619
- };
620
- var _path = {
621
- __proto__: null,
622
- basename,
623
- dirname,
624
- extname,
625
- format,
626
- isAbsolute,
627
- join,
628
- matchesGlob,
629
- normalize,
630
- normalizeString,
631
- parse,
632
- relative,
633
- resolve,
634
- sep,
635
- toNamespacedPath
636
- };
637
12
 
638
- // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
639
- var delimiter = /* @__PURE__ */ (() => _optionalChain([globalThis, 'access', _9 => _9.process, 'optionalAccess', _10 => _10.platform]) === "win32" ? ";" : ":")();
640
- var _platforms = { posix: void 0, win32: void 0 };
641
- var mix = (del = delimiter) => {
642
- return new Proxy(_path, {
643
- get(_, prop) {
644
- if (prop === "delimiter") return del;
645
- if (prop === "posix") return posix;
646
- if (prop === "win32") return win32;
647
- return _platforms[prop] || _path[prop];
648
- }
649
- });
650
- };
651
- var posix = /* @__PURE__ */ mix(":");
652
- var win32 = /* @__PURE__ */ mix(";");
653
13
 
654
- // src/utils.ts
655
- function removeFileExtension(filePath) {
656
- if (!filePath) {
657
- return "";
658
- }
659
- let baseName = posix.basename(filePath);
660
- let ext = posix.extname(baseName);
661
- while (ext) {
662
- baseName = baseName.slice(0, -ext.length);
663
- ext = posix.extname(baseName);
664
- }
665
- const dir = posix.dirname(filePath);
666
- return posix.join(dir, baseName);
667
- }
668
- function md5(input) {
669
- const hash = _crypto2.default.createHash("md5");
670
- hash.update(input);
671
- return hash.digest("hex");
672
- }
14
+
15
+ var _shared = require('@weapp-tailwindcss/shared');
16
+
17
+
18
+
19
+ var _node = require('@weapp-tailwindcss/shared/node');
673
20
 
674
21
  // src/config.ts
675
22
  function getDefaultConfig() {
@@ -690,12 +37,10 @@ function getConfig(options) {
690
37
  }
691
38
 
692
39
  // src/constants.ts
693
- init_cjs_shims();
694
40
  var postcssPlugin = "postcss-tailwindcss-injector";
695
41
 
696
42
  // src/wxml.ts
697
- init_cjs_shims();
698
- var _path2 = require('path'); var _path3 = _interopRequireDefault(_path2);
43
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
699
44
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
700
45
  var _htmlparser2 = require('htmlparser2');
701
46
  var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
@@ -758,12 +103,12 @@ function processWxml(wxml) {
758
103
  parser.end();
759
104
  return deps;
760
105
  }
761
- async function getDep(filepath, set2) {
106
+ async function getDep(filepath, set) {
762
107
  if (await _fsextra2.default.exists(filepath)) {
763
- const dirname2 = _path3.default.dirname(filepath);
764
- set2.add(filepath);
108
+ const dirname = _path2.default.dirname(filepath);
109
+ set.add(filepath);
765
110
  const wxml = await _fsextra2.default.readFile(filepath, "utf8");
766
- const hash = md5(wxml);
111
+ const hash = _node.md5.call(void 0, wxml);
767
112
  const oldHash = hashMap.get(filepath);
768
113
  const isChanged = hash !== oldHash;
769
114
  let deps = [];
@@ -776,22 +121,54 @@ async function getDep(filepath, set2) {
776
121
  deps = cacheDeps;
777
122
  }
778
123
  for (const { value } of deps) {
779
- const p = _path3.default.resolve(dirname2, value);
780
- if (!set2.has(p)) {
781
- await getDep(p, set2);
124
+ const p = _path2.default.resolve(dirname, value);
125
+ if (!set.has(p)) {
126
+ await getDep(p, set);
782
127
  }
783
128
  }
784
129
  }
785
130
  }
786
131
  async function getDepFiles(file) {
787
- const set2 = /* @__PURE__ */ new Set();
788
- await getDep(file, set2);
789
- return set2;
132
+ const set = /* @__PURE__ */ new Set();
133
+ await getDep(file, set);
134
+ return set;
790
135
  }
791
136
 
792
137
  // src/postcss.ts
138
+ var configCache = /* @__PURE__ */ new Map();
139
+ async function loadTailwindConfigOnce(cwd, configPath) {
140
+ const cacheKey = `${cwd}::${configPath}`;
141
+ let cached = configCache.get(cacheKey);
142
+ if (!cached) {
143
+ cached = _tailwindcssconfig.loadConfig.call(void 0, {
144
+ cwd,
145
+ config: configPath
146
+ }).then((result) => _optionalChain([result, 'optionalAccess', _ => _.config]));
147
+ configCache.set(cacheKey, cached);
148
+ }
149
+ return cached;
150
+ }
151
+ function cloneConfig(config) {
152
+ if (!config) {
153
+ return config;
154
+ }
155
+ return {
156
+ ...config
157
+ };
158
+ }
159
+ async function resolveTailwindConfig(config, cwd, sourceInput) {
160
+ if (!config) {
161
+ return void 0;
162
+ }
163
+ const resolved = typeof config === "function" ? config(sourceInput) : config;
164
+ if (typeof resolved === "string") {
165
+ const loaded = await loadTailwindConfigOnce(cwd, resolved);
166
+ return cloneConfig(loaded);
167
+ }
168
+ return cloneConfig(resolved);
169
+ }
793
170
  var creator = (options) => {
794
- const { config, filter, directiveParams, cwd: cwd2, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
171
+ const { config, filter, directiveParams, cwd, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
795
172
  const extensionsGlob = `{${extensions.join(",")}}`;
796
173
  return {
797
174
  postcssPlugin,
@@ -799,51 +176,65 @@ var creator = (options) => {
799
176
  {
800
177
  postcssPlugin: `${postcssPlugin}:post`,
801
178
  async Once(root, helpers) {
802
- if (filter(_optionalChain([root, 'access', _11 => _11.source, 'optionalAccess', _12 => _12.input]))) {
803
- const atruleLastIndex = root.nodes.findLastIndex((x) => x.type === "atrule" && insertAfterAtRulesNames.includes(x.name));
804
- const commentLastIndex = root.nodes.findLastIndex((x) => x.type === "comment" && _shared.regExpTest.call(void 0, insertAfterComments, x.text));
805
- const lastIndex = Math.max(atruleLastIndex, commentLastIndex);
179
+ const sourceInput = _optionalChain([root, 'access', _2 => _2.source, 'optionalAccess', _3 => _3.input]);
180
+ if (filter(sourceInput)) {
181
+ const nodes = _nullishCoalesce(root.nodes, () => ( []));
182
+ let atruleAnchorIndex = -1;
183
+ let commentAnchorIndex = -1;
184
+ const directivePresence = /* @__PURE__ */ new Set();
185
+ nodes.forEach((node, index) => {
186
+ if (node.type === "atrule") {
187
+ const nameMatches = insertAfterAtRulesNames.includes(node.name);
188
+ if (nameMatches) {
189
+ atruleAnchorIndex = Math.max(atruleAnchorIndex, index);
190
+ }
191
+ if (typeof node.params === "string") {
192
+ directivePresence.add(node.params);
193
+ }
194
+ } else if (node.type === "comment" && _shared.regExpTest.call(void 0, insertAfterComments, node.text)) {
195
+ commentAnchorIndex = Math.max(commentAnchorIndex, index);
196
+ }
197
+ });
198
+ const anchorIndex = Math.max(atruleAnchorIndex, commentAnchorIndex);
199
+ const anchorNode = anchorIndex >= 0 ? nodes[anchorIndex] : void 0;
200
+ let lastInserted = anchorNode;
806
201
  for (const params of directiveParams) {
807
- const node = root.nodes.find((x) => x.type === "atrule" && x.params === params);
808
- if (!node) {
202
+ if (!directivePresence.has(params)) {
809
203
  const atRule = helpers.atRule({ name: "tailwind", params });
810
- if (lastIndex < 0) {
811
- root.prepend(atRule);
204
+ if (lastInserted) {
205
+ root.insertAfter(lastInserted, atRule);
812
206
  } else {
813
- root.insertAfter(lastIndex, atRule);
207
+ root.prepend(atRule);
814
208
  }
209
+ lastInserted = atRule;
210
+ directivePresence.add(params);
815
211
  }
816
212
  }
817
- const cfg = typeof config === "function" ? config(_optionalChain([root, 'access', _13 => _13.source, 'optionalAccess', _14 => _14.input])) : config;
818
- let tailwindcssConfig;
819
- if (typeof cfg === "string") {
820
- const result = await _tailwindcssconfig.loadConfig.call(void 0, {
821
- cwd: cwd2,
822
- config: cfg
823
- });
824
- if (result) {
825
- tailwindcssConfig = result.config;
826
- }
827
- } else {
828
- tailwindcssConfig = _nullishCoalesce(cfg, () => ( {
829
- content: []
830
- }));
831
- }
832
- if (tailwindcssConfig && _optionalChain([root, 'access', _15 => _15.source, 'optionalAccess', _16 => _16.input]) && root.source.input.file) {
833
- const basename2 = removeFileExtension(root.source.input.file);
834
- (0, import_set_value.default)(tailwindcssConfig, "content", [
835
- `${basename2}.${extensionsGlob}`
836
- ]);
837
- const deps = await getDepFiles(`${basename2}.wxml`);
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`);
838
218
  for (const dep of deps) {
839
- if (Array.isArray(tailwindcssConfig.content)) {
840
- tailwindcssConfig.content.push(`${removeFileExtension(dep)}.${extensionsGlob}`);
841
- }
219
+ contentEntries.push(`${_node.removeAllExtensions.call(void 0, dep)}.${extensionsGlob}`);
220
+ }
221
+ const uniqueEntries = Array.from(new Set(contentEntries));
222
+ const { content: existingContent } = tailwindcssConfig;
223
+ if (!existingContent || Array.isArray(existingContent)) {
224
+ tailwindcssConfig.content = uniqueEntries;
225
+ } else if (typeof existingContent === "object" && existingContent !== null) {
226
+ const normalizedContent = { ...existingContent };
227
+ const currentFiles = normalizedContent.files;
228
+ const normalizedFiles = Array.isArray(currentFiles) ? currentFiles : typeof currentFiles === "string" ? [currentFiles] : [];
229
+ normalizedContent.files = Array.from(/* @__PURE__ */ new Set([...normalizedFiles, ...uniqueEntries]));
230
+ tailwindcssConfig.content = normalizedContent;
231
+ } else {
232
+ tailwindcssConfig.content = uniqueEntries;
842
233
  }
843
234
  await _postcss2.default.call(void 0, [
844
235
  _tailwindcss2.default.call(void 0, tailwindcssConfig)
845
236
  ]).process(root, {
846
- from: root.source.input.file
237
+ from: sourceInput.file
847
238
  }).async();
848
239
  }
849
240
  }
@@ -857,39 +248,5 @@ var postcss_default = creator;
857
248
 
858
249
 
859
250
  exports.default = postcss_default;
860
- /*! Bundled license information:
861
-
862
- is-primitive/index.js:
863
- (*!
864
- * is-primitive <https://github.com/jonschlinkert/is-primitive>
865
- *
866
- * Copyright (c) 2014-present, Jon Schlinkert.
867
- * Released under the MIT License.
868
- *)
869
-
870
- isobject/index.js:
871
- (*!
872
- * isobject <https://github.com/jonschlinkert/isobject>
873
- *
874
- * Copyright (c) 2014-2017, Jon Schlinkert.
875
- * Released under the MIT License.
876
- *)
877
-
878
- is-plain-object/index.js:
879
- (*!
880
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
881
- *
882
- * Copyright (c) 2014-2017, Jon Schlinkert.
883
- * Released under the MIT License.
884
- *)
885
-
886
- set-value/index.js:
887
- (*!
888
- * set-value <https://github.com/jonschlinkert/set-value>
889
- *
890
- * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
891
- * Released under the MIT License.
892
- *)
893
- */
894
251
 
895
252
  module.exports = exports.default;