tailwindcss-injector 1.0.5 → 1.0.7
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 +87 -300
- package/dist/postcss.js +124 -339
- package/package.json +3 -3
package/dist/postcss.cjs
CHANGED
|
@@ -1,239 +1,16 @@
|
|
|
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; }
|
|
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.12.1_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.12.1_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
10
|
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
230
11
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
231
12
|
|
|
232
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
233
|
-
init_cjs_shims();
|
|
234
|
-
|
|
235
13
|
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
236
|
-
init_cjs_shims();
|
|
237
14
|
var _lazyMatch = () => {
|
|
238
15
|
var __lib__ = (() => {
|
|
239
16
|
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
@@ -690,11 +467,9 @@ function getConfig(options) {
|
|
|
690
467
|
}
|
|
691
468
|
|
|
692
469
|
// src/constants.ts
|
|
693
|
-
init_cjs_shims();
|
|
694
470
|
var postcssPlugin = "postcss-tailwindcss-injector";
|
|
695
471
|
|
|
696
472
|
// src/wxml.ts
|
|
697
|
-
init_cjs_shims();
|
|
698
473
|
var _path2 = require('path'); var _path3 = _interopRequireDefault(_path2);
|
|
699
474
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
700
475
|
var _htmlparser2 = require('htmlparser2');
|
|
@@ -758,10 +533,10 @@ function processWxml(wxml) {
|
|
|
758
533
|
parser.end();
|
|
759
534
|
return deps;
|
|
760
535
|
}
|
|
761
|
-
async function getDep(filepath,
|
|
536
|
+
async function getDep(filepath, set) {
|
|
762
537
|
if (await _fsextra2.default.exists(filepath)) {
|
|
763
538
|
const dirname2 = _path3.default.dirname(filepath);
|
|
764
|
-
|
|
539
|
+
set.add(filepath);
|
|
765
540
|
const wxml = await _fsextra2.default.readFile(filepath, "utf8");
|
|
766
541
|
const hash = md5(wxml);
|
|
767
542
|
const oldHash = hashMap.get(filepath);
|
|
@@ -777,19 +552,51 @@ async function getDep(filepath, set2) {
|
|
|
777
552
|
}
|
|
778
553
|
for (const { value } of deps) {
|
|
779
554
|
const p = _path3.default.resolve(dirname2, value);
|
|
780
|
-
if (!
|
|
781
|
-
await getDep(p,
|
|
555
|
+
if (!set.has(p)) {
|
|
556
|
+
await getDep(p, set);
|
|
782
557
|
}
|
|
783
558
|
}
|
|
784
559
|
}
|
|
785
560
|
}
|
|
786
561
|
async function getDepFiles(file) {
|
|
787
|
-
const
|
|
788
|
-
await getDep(file,
|
|
789
|
-
return
|
|
562
|
+
const set = /* @__PURE__ */ new Set();
|
|
563
|
+
await getDep(file, set);
|
|
564
|
+
return set;
|
|
790
565
|
}
|
|
791
566
|
|
|
792
567
|
// src/postcss.ts
|
|
568
|
+
var configCache = /* @__PURE__ */ new Map();
|
|
569
|
+
async function loadTailwindConfigOnce(cwd2, configPath) {
|
|
570
|
+
const cacheKey = `${cwd2}::${configPath}`;
|
|
571
|
+
let cached = configCache.get(cacheKey);
|
|
572
|
+
if (!cached) {
|
|
573
|
+
cached = _tailwindcssconfig.loadConfig.call(void 0, {
|
|
574
|
+
cwd: cwd2,
|
|
575
|
+
config: configPath
|
|
576
|
+
}).then((result) => _optionalChain([result, 'optionalAccess', _11 => _11.config]));
|
|
577
|
+
configCache.set(cacheKey, cached);
|
|
578
|
+
}
|
|
579
|
+
return cached;
|
|
580
|
+
}
|
|
581
|
+
function cloneConfig(config) {
|
|
582
|
+
if (!config) {
|
|
583
|
+
return config;
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
...config
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
async function resolveTailwindConfig(config, cwd2, sourceInput) {
|
|
590
|
+
if (!config) {
|
|
591
|
+
return void 0;
|
|
592
|
+
}
|
|
593
|
+
const resolved = typeof config === "function" ? config(sourceInput) : config;
|
|
594
|
+
if (typeof resolved === "string") {
|
|
595
|
+
const loaded = await loadTailwindConfigOnce(cwd2, resolved);
|
|
596
|
+
return cloneConfig(loaded);
|
|
597
|
+
}
|
|
598
|
+
return cloneConfig(resolved);
|
|
599
|
+
}
|
|
793
600
|
var creator = (options) => {
|
|
794
601
|
const { config, filter, directiveParams, cwd: cwd2, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
|
|
795
602
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
@@ -799,51 +606,65 @@ var creator = (options) => {
|
|
|
799
606
|
{
|
|
800
607
|
postcssPlugin: `${postcssPlugin}:post`,
|
|
801
608
|
async Once(root, helpers) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
const
|
|
805
|
-
|
|
609
|
+
const sourceInput = _optionalChain([root, 'access', _12 => _12.source, 'optionalAccess', _13 => _13.input]);
|
|
610
|
+
if (filter(sourceInput)) {
|
|
611
|
+
const nodes = _nullishCoalesce(root.nodes, () => ( []));
|
|
612
|
+
let atruleAnchorIndex = -1;
|
|
613
|
+
let commentAnchorIndex = -1;
|
|
614
|
+
const directivePresence = /* @__PURE__ */ new Set();
|
|
615
|
+
nodes.forEach((node, index) => {
|
|
616
|
+
if (node.type === "atrule") {
|
|
617
|
+
const nameMatches = insertAfterAtRulesNames.includes(node.name);
|
|
618
|
+
if (nameMatches) {
|
|
619
|
+
atruleAnchorIndex = Math.max(atruleAnchorIndex, index);
|
|
620
|
+
}
|
|
621
|
+
if (typeof node.params === "string") {
|
|
622
|
+
directivePresence.add(node.params);
|
|
623
|
+
}
|
|
624
|
+
} else if (node.type === "comment" && _shared.regExpTest.call(void 0, insertAfterComments, node.text)) {
|
|
625
|
+
commentAnchorIndex = Math.max(commentAnchorIndex, index);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
const anchorIndex = Math.max(atruleAnchorIndex, commentAnchorIndex);
|
|
629
|
+
const anchorNode = anchorIndex >= 0 ? nodes[anchorIndex] : void 0;
|
|
630
|
+
let lastInserted = anchorNode;
|
|
806
631
|
for (const params of directiveParams) {
|
|
807
|
-
|
|
808
|
-
if (!node) {
|
|
632
|
+
if (!directivePresence.has(params)) {
|
|
809
633
|
const atRule = helpers.atRule({ name: "tailwind", params });
|
|
810
|
-
if (
|
|
811
|
-
root.
|
|
634
|
+
if (lastInserted) {
|
|
635
|
+
root.insertAfter(lastInserted, atRule);
|
|
812
636
|
} else {
|
|
813
|
-
root.
|
|
637
|
+
root.prepend(atRule);
|
|
814
638
|
}
|
|
639
|
+
lastInserted = atRule;
|
|
640
|
+
directivePresence.add(params);
|
|
815
641
|
}
|
|
816
642
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const
|
|
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
|
-
]);
|
|
643
|
+
if (_optionalChain([sourceInput, 'optionalAccess', _14 => _14.file])) {
|
|
644
|
+
const tailwindcssConfig = await _asyncNullishCoalesce(await resolveTailwindConfig(config, cwd2, sourceInput), async () => ( { content: [] }));
|
|
645
|
+
const basename2 = removeFileExtension(sourceInput.file);
|
|
646
|
+
const contentEntries = [`${basename2}.${extensionsGlob}`];
|
|
837
647
|
const deps = await getDepFiles(`${basename2}.wxml`);
|
|
838
648
|
for (const dep of deps) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
649
|
+
contentEntries.push(`${removeFileExtension(dep)}.${extensionsGlob}`);
|
|
650
|
+
}
|
|
651
|
+
const uniqueEntries = Array.from(new Set(contentEntries));
|
|
652
|
+
const { content: existingContent } = tailwindcssConfig;
|
|
653
|
+
if (!existingContent || Array.isArray(existingContent)) {
|
|
654
|
+
tailwindcssConfig.content = uniqueEntries;
|
|
655
|
+
} else if (typeof existingContent === "object" && existingContent !== null) {
|
|
656
|
+
const normalizedContent = { ...existingContent };
|
|
657
|
+
const currentFiles = normalizedContent.files;
|
|
658
|
+
const normalizedFiles = Array.isArray(currentFiles) ? currentFiles : typeof currentFiles === "string" ? [currentFiles] : [];
|
|
659
|
+
normalizedContent.files = Array.from(/* @__PURE__ */ new Set([...normalizedFiles, ...uniqueEntries]));
|
|
660
|
+
tailwindcssConfig.content = normalizedContent;
|
|
661
|
+
} else {
|
|
662
|
+
tailwindcssConfig.content = uniqueEntries;
|
|
842
663
|
}
|
|
843
664
|
await _postcss2.default.call(void 0, [
|
|
844
665
|
_tailwindcss2.default.call(void 0, tailwindcssConfig)
|
|
845
666
|
]).process(root, {
|
|
846
|
-
from:
|
|
667
|
+
from: sourceInput.file
|
|
847
668
|
}).async();
|
|
848
669
|
}
|
|
849
670
|
}
|
|
@@ -857,39 +678,5 @@ var postcss_default = creator;
|
|
|
857
678
|
|
|
858
679
|
|
|
859
680
|
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
681
|
|
|
895
682
|
module.exports = exports.default;
|
package/dist/postcss.js
CHANGED
|
@@ -1,241 +1,16 @@
|
|
|
1
|
-
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.12.1_jiti@2.5.1_postcss@8.5.6_tsx@4.20.5_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js
|
|
31
|
-
import path from "path";
|
|
32
|
-
import { fileURLToPath } from "url";
|
|
33
|
-
var init_esm_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.1_jiti@2.5.1_postcss@8.5.6_tsx@4.20.5_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js"() {
|
|
35
|
-
"use strict";
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
|
|
40
|
-
var require_is_primitive = __commonJS({
|
|
41
|
-
"../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
|
|
42
|
-
"use strict";
|
|
43
|
-
init_esm_shims();
|
|
44
|
-
module.exports = function isPrimitive(val) {
|
|
45
|
-
if (typeof val === "object") {
|
|
46
|
-
return val === null;
|
|
47
|
-
}
|
|
48
|
-
return typeof val !== "function";
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
|
|
54
|
-
var require_isobject = __commonJS({
|
|
55
|
-
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
|
|
56
|
-
"use strict";
|
|
57
|
-
init_esm_shims();
|
|
58
|
-
module.exports = function isObject(val) {
|
|
59
|
-
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
65
|
-
var require_is_plain_object = __commonJS({
|
|
66
|
-
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
|
|
67
|
-
"use strict";
|
|
68
|
-
init_esm_shims();
|
|
69
|
-
var isObject = require_isobject();
|
|
70
|
-
function isObjectObject(o) {
|
|
71
|
-
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
72
|
-
}
|
|
73
|
-
module.exports = function isPlainObject(o) {
|
|
74
|
-
var ctor, prot;
|
|
75
|
-
if (isObjectObject(o) === false) return false;
|
|
76
|
-
ctor = o.constructor;
|
|
77
|
-
if (typeof ctor !== "function") return false;
|
|
78
|
-
prot = ctor.prototype;
|
|
79
|
-
if (isObjectObject(prot) === false) return false;
|
|
80
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
|
|
89
|
-
var require_set_value = __commonJS({
|
|
90
|
-
"../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
|
|
91
|
-
"use strict";
|
|
92
|
-
init_esm_shims();
|
|
93
|
-
var { deleteProperty } = Reflect;
|
|
94
|
-
var isPrimitive = require_is_primitive();
|
|
95
|
-
var isPlainObject = require_is_plain_object();
|
|
96
|
-
var isObject = (value) => {
|
|
97
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
98
|
-
};
|
|
99
|
-
var isUnsafeKey = (key) => {
|
|
100
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
101
|
-
};
|
|
102
|
-
var validateKey = (key) => {
|
|
103
|
-
if (!isPrimitive(key)) {
|
|
104
|
-
throw new TypeError("Object keys must be strings or symbols");
|
|
105
|
-
}
|
|
106
|
-
if (isUnsafeKey(key)) {
|
|
107
|
-
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var toStringKey = (input) => {
|
|
111
|
-
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
112
|
-
};
|
|
113
|
-
var createMemoKey = (input, options) => {
|
|
114
|
-
if (typeof input !== "string" || !options) return input;
|
|
115
|
-
let key = input + ";";
|
|
116
|
-
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
117
|
-
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
118
|
-
if (options.split !== void 0) key += `split=${options.split};`;
|
|
119
|
-
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
120
|
-
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
121
|
-
return key;
|
|
122
|
-
};
|
|
123
|
-
var memoize = (input, options, fn) => {
|
|
124
|
-
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
125
|
-
validateKey(key);
|
|
126
|
-
const value = setValue.cache.get(key) || fn();
|
|
127
|
-
setValue.cache.set(key, value);
|
|
128
|
-
return value;
|
|
129
|
-
};
|
|
130
|
-
var splitString = (input, options = {}) => {
|
|
131
|
-
const sep2 = options.separator || ".";
|
|
132
|
-
const preserve = sep2 === "/" ? false : options.preservePaths;
|
|
133
|
-
if (typeof input === "string" && preserve !== false && /\//.test(input)) {
|
|
134
|
-
return [input];
|
|
135
|
-
}
|
|
136
|
-
const parts = [];
|
|
137
|
-
let part = "";
|
|
138
|
-
const push = (part2) => {
|
|
139
|
-
let number;
|
|
140
|
-
if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
|
|
141
|
-
parts.push(number);
|
|
142
|
-
} else {
|
|
143
|
-
parts.push(part2);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
for (let i = 0; i < input.length; i++) {
|
|
147
|
-
const value = input[i];
|
|
148
|
-
if (value === "\\") {
|
|
149
|
-
part += input[++i];
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (value === sep2) {
|
|
153
|
-
push(part);
|
|
154
|
-
part = "";
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
part += value;
|
|
158
|
-
}
|
|
159
|
-
if (part) {
|
|
160
|
-
push(part);
|
|
161
|
-
}
|
|
162
|
-
return parts;
|
|
163
|
-
};
|
|
164
|
-
var split = (input, options) => {
|
|
165
|
-
if (options && typeof options.split === "function") return options.split(input);
|
|
166
|
-
if (typeof input === "symbol") return [input];
|
|
167
|
-
if (Array.isArray(input)) return input;
|
|
168
|
-
return memoize(input, options, () => splitString(input, options));
|
|
169
|
-
};
|
|
170
|
-
var assignProp = (obj, prop, value, options) => {
|
|
171
|
-
validateKey(prop);
|
|
172
|
-
if (value === void 0) {
|
|
173
|
-
deleteProperty(obj, prop);
|
|
174
|
-
} else if (options && options.merge) {
|
|
175
|
-
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
176
|
-
if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
|
|
177
|
-
obj[prop] = merge(obj[prop], value);
|
|
178
|
-
} else {
|
|
179
|
-
obj[prop] = value;
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
obj[prop] = value;
|
|
183
|
-
}
|
|
184
|
-
return obj;
|
|
185
|
-
};
|
|
186
|
-
var setValue = (target, path3, value, options) => {
|
|
187
|
-
if (!path3 || !isObject(target)) return target;
|
|
188
|
-
const keys = split(path3, options);
|
|
189
|
-
let obj = target;
|
|
190
|
-
for (let i = 0; i < keys.length; i++) {
|
|
191
|
-
const key = keys[i];
|
|
192
|
-
const next = keys[i + 1];
|
|
193
|
-
validateKey(key);
|
|
194
|
-
if (next === void 0) {
|
|
195
|
-
assignProp(obj, key, value, options);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
199
|
-
obj = obj[key] = [];
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (!isObject(obj[key])) {
|
|
203
|
-
obj[key] = {};
|
|
204
|
-
}
|
|
205
|
-
obj = obj[key];
|
|
206
|
-
}
|
|
207
|
-
return target;
|
|
208
|
-
};
|
|
209
|
-
setValue.split = split;
|
|
210
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
211
|
-
setValue.clear = () => {
|
|
212
|
-
setValue.cache = /* @__PURE__ */ new Map();
|
|
213
|
-
};
|
|
214
|
-
module.exports = setValue;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
1
|
// src/postcss.ts
|
|
219
|
-
init_esm_shims();
|
|
220
|
-
var import_set_value = __toESM(require_set_value(), 1);
|
|
221
2
|
import postcss from "postcss";
|
|
222
3
|
import tailwindcss from "tailwindcss";
|
|
223
4
|
import { loadConfig } from "tailwindcss-config";
|
|
224
5
|
|
|
225
6
|
// src/config.ts
|
|
226
|
-
init_esm_shims();
|
|
227
7
|
import process2 from "process";
|
|
228
8
|
|
|
229
9
|
// src/utils.ts
|
|
230
|
-
init_esm_shims();
|
|
231
10
|
import crypto from "crypto";
|
|
232
11
|
import { defu, defuOverrideArray, isRegexp, regExpTest } from "@weapp-tailwindcss/shared";
|
|
233
12
|
|
|
234
|
-
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
|
|
235
|
-
init_esm_shims();
|
|
236
|
-
|
|
237
13
|
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
238
|
-
init_esm_shims();
|
|
239
14
|
var _lazyMatch = () => {
|
|
240
15
|
var __lib__ = (() => {
|
|
241
16
|
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
@@ -394,12 +169,12 @@ var _lazyMatch = () => {
|
|
|
394
169
|
return __lib__.default || __lib__;
|
|
395
170
|
};
|
|
396
171
|
var _match;
|
|
397
|
-
var zeptomatch = (
|
|
172
|
+
var zeptomatch = (path2, pattern) => {
|
|
398
173
|
if (!_match) {
|
|
399
174
|
_match = _lazyMatch();
|
|
400
175
|
_lazyMatch = null;
|
|
401
176
|
}
|
|
402
|
-
return _match(
|
|
177
|
+
return _match(path2, pattern);
|
|
403
178
|
};
|
|
404
179
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
405
180
|
function normalizeWindowsPath(input = "") {
|
|
@@ -415,55 +190,55 @@ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
|
415
190
|
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
416
191
|
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
417
192
|
var sep = "/";
|
|
418
|
-
var normalize = function(
|
|
419
|
-
if (
|
|
193
|
+
var normalize = function(path2) {
|
|
194
|
+
if (path2.length === 0) {
|
|
420
195
|
return ".";
|
|
421
196
|
}
|
|
422
|
-
|
|
423
|
-
const isUNCPath =
|
|
424
|
-
const isPathAbsolute = isAbsolute(
|
|
425
|
-
const trailingSeparator =
|
|
426
|
-
|
|
427
|
-
if (
|
|
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) {
|
|
428
203
|
if (isPathAbsolute) {
|
|
429
204
|
return "/";
|
|
430
205
|
}
|
|
431
206
|
return trailingSeparator ? "./" : ".";
|
|
432
207
|
}
|
|
433
208
|
if (trailingSeparator) {
|
|
434
|
-
|
|
209
|
+
path2 += "/";
|
|
435
210
|
}
|
|
436
|
-
if (_DRIVE_LETTER_RE.test(
|
|
437
|
-
|
|
211
|
+
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
212
|
+
path2 += "/";
|
|
438
213
|
}
|
|
439
214
|
if (isUNCPath) {
|
|
440
215
|
if (!isPathAbsolute) {
|
|
441
|
-
return `//./${
|
|
216
|
+
return `//./${path2}`;
|
|
442
217
|
}
|
|
443
|
-
return `//${
|
|
218
|
+
return `//${path2}`;
|
|
444
219
|
}
|
|
445
|
-
return isPathAbsolute && !isAbsolute(
|
|
220
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
446
221
|
};
|
|
447
222
|
var join = function(...segments) {
|
|
448
|
-
let
|
|
223
|
+
let path2 = "";
|
|
449
224
|
for (const seg of segments) {
|
|
450
225
|
if (!seg) {
|
|
451
226
|
continue;
|
|
452
227
|
}
|
|
453
|
-
if (
|
|
454
|
-
const pathTrailing =
|
|
228
|
+
if (path2.length > 0) {
|
|
229
|
+
const pathTrailing = path2[path2.length - 1] === "/";
|
|
455
230
|
const segLeading = seg[0] === "/";
|
|
456
231
|
const both = pathTrailing && segLeading;
|
|
457
232
|
if (both) {
|
|
458
|
-
|
|
233
|
+
path2 += seg.slice(1);
|
|
459
234
|
} else {
|
|
460
|
-
|
|
235
|
+
path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
461
236
|
}
|
|
462
237
|
} else {
|
|
463
|
-
|
|
238
|
+
path2 += seg;
|
|
464
239
|
}
|
|
465
240
|
}
|
|
466
|
-
return normalize(
|
|
241
|
+
return normalize(path2);
|
|
467
242
|
};
|
|
468
243
|
function cwd() {
|
|
469
244
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
@@ -476,12 +251,12 @@ var resolve = function(...arguments_) {
|
|
|
476
251
|
let resolvedPath = "";
|
|
477
252
|
let resolvedAbsolute = false;
|
|
478
253
|
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
479
|
-
const
|
|
480
|
-
if (!
|
|
254
|
+
const path2 = index >= 0 ? arguments_[index] : cwd();
|
|
255
|
+
if (!path2 || path2.length === 0) {
|
|
481
256
|
continue;
|
|
482
257
|
}
|
|
483
|
-
resolvedPath = `${
|
|
484
|
-
resolvedAbsolute = isAbsolute(
|
|
258
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
259
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
485
260
|
}
|
|
486
261
|
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
487
262
|
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
@@ -489,15 +264,15 @@ var resolve = function(...arguments_) {
|
|
|
489
264
|
}
|
|
490
265
|
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
491
266
|
};
|
|
492
|
-
function normalizeString(
|
|
267
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
493
268
|
let res = "";
|
|
494
269
|
let lastSegmentLength = 0;
|
|
495
270
|
let lastSlash = -1;
|
|
496
271
|
let dots = 0;
|
|
497
272
|
let char = null;
|
|
498
|
-
for (let index = 0; index <=
|
|
499
|
-
if (index <
|
|
500
|
-
char =
|
|
273
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
274
|
+
if (index < path2.length) {
|
|
275
|
+
char = path2[index];
|
|
501
276
|
} else if (char === "/") {
|
|
502
277
|
break;
|
|
503
278
|
} else {
|
|
@@ -533,9 +308,9 @@ function normalizeString(path3, allowAboveRoot) {
|
|
|
533
308
|
}
|
|
534
309
|
} else {
|
|
535
310
|
if (res.length > 0) {
|
|
536
|
-
res += `/${
|
|
311
|
+
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
537
312
|
} else {
|
|
538
|
-
res =
|
|
313
|
+
res = path2.slice(lastSlash + 1, index);
|
|
539
314
|
}
|
|
540
315
|
lastSegmentLength = index - lastSlash - 1;
|
|
541
316
|
}
|
|
@@ -616,8 +391,8 @@ var parse = function(p) {
|
|
|
616
391
|
name: base.slice(0, base.length - extension.length)
|
|
617
392
|
};
|
|
618
393
|
};
|
|
619
|
-
var matchesGlob = (
|
|
620
|
-
return zeptomatch(pattern, normalize(
|
|
394
|
+
var matchesGlob = (path2, pattern) => {
|
|
395
|
+
return zeptomatch(pattern, normalize(path2));
|
|
621
396
|
};
|
|
622
397
|
var _path = {
|
|
623
398
|
__proto__: null,
|
|
@@ -692,12 +467,10 @@ function getConfig(options) {
|
|
|
692
467
|
}
|
|
693
468
|
|
|
694
469
|
// src/constants.ts
|
|
695
|
-
init_esm_shims();
|
|
696
470
|
var postcssPlugin = "postcss-tailwindcss-injector";
|
|
697
471
|
|
|
698
472
|
// src/wxml.ts
|
|
699
|
-
|
|
700
|
-
import path2 from "path";
|
|
473
|
+
import path from "path";
|
|
701
474
|
import fs from "fs-extra";
|
|
702
475
|
import { Parser } from "htmlparser2";
|
|
703
476
|
import MagicString from "magic-string";
|
|
@@ -760,10 +533,10 @@ function processWxml(wxml) {
|
|
|
760
533
|
parser.end();
|
|
761
534
|
return deps;
|
|
762
535
|
}
|
|
763
|
-
async function getDep(filepath,
|
|
536
|
+
async function getDep(filepath, set) {
|
|
764
537
|
if (await fs.exists(filepath)) {
|
|
765
|
-
const dirname2 =
|
|
766
|
-
|
|
538
|
+
const dirname2 = path.dirname(filepath);
|
|
539
|
+
set.add(filepath);
|
|
767
540
|
const wxml = await fs.readFile(filepath, "utf8");
|
|
768
541
|
const hash = md5(wxml);
|
|
769
542
|
const oldHash = hashMap.get(filepath);
|
|
@@ -778,20 +551,52 @@ async function getDep(filepath, set2) {
|
|
|
778
551
|
deps = cacheDeps;
|
|
779
552
|
}
|
|
780
553
|
for (const { value } of deps) {
|
|
781
|
-
const p =
|
|
782
|
-
if (!
|
|
783
|
-
await getDep(p,
|
|
554
|
+
const p = path.resolve(dirname2, value);
|
|
555
|
+
if (!set.has(p)) {
|
|
556
|
+
await getDep(p, set);
|
|
784
557
|
}
|
|
785
558
|
}
|
|
786
559
|
}
|
|
787
560
|
}
|
|
788
561
|
async function getDepFiles(file) {
|
|
789
|
-
const
|
|
790
|
-
await getDep(file,
|
|
791
|
-
return
|
|
562
|
+
const set = /* @__PURE__ */ new Set();
|
|
563
|
+
await getDep(file, set);
|
|
564
|
+
return set;
|
|
792
565
|
}
|
|
793
566
|
|
|
794
567
|
// src/postcss.ts
|
|
568
|
+
var configCache = /* @__PURE__ */ new Map();
|
|
569
|
+
async function loadTailwindConfigOnce(cwd2, configPath) {
|
|
570
|
+
const cacheKey = `${cwd2}::${configPath}`;
|
|
571
|
+
let cached = configCache.get(cacheKey);
|
|
572
|
+
if (!cached) {
|
|
573
|
+
cached = loadConfig({
|
|
574
|
+
cwd: cwd2,
|
|
575
|
+
config: configPath
|
|
576
|
+
}).then((result) => result?.config);
|
|
577
|
+
configCache.set(cacheKey, cached);
|
|
578
|
+
}
|
|
579
|
+
return cached;
|
|
580
|
+
}
|
|
581
|
+
function cloneConfig(config) {
|
|
582
|
+
if (!config) {
|
|
583
|
+
return config;
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
...config
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
async function resolveTailwindConfig(config, cwd2, sourceInput) {
|
|
590
|
+
if (!config) {
|
|
591
|
+
return void 0;
|
|
592
|
+
}
|
|
593
|
+
const resolved = typeof config === "function" ? config(sourceInput) : config;
|
|
594
|
+
if (typeof resolved === "string") {
|
|
595
|
+
const loaded = await loadTailwindConfigOnce(cwd2, resolved);
|
|
596
|
+
return cloneConfig(loaded);
|
|
597
|
+
}
|
|
598
|
+
return cloneConfig(resolved);
|
|
599
|
+
}
|
|
795
600
|
var creator = (options) => {
|
|
796
601
|
const { config, filter, directiveParams, cwd: cwd2, extensions, insertAfterAtRulesNames, insertAfterComments } = getConfig(options);
|
|
797
602
|
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
@@ -801,51 +606,65 @@ var creator = (options) => {
|
|
|
801
606
|
{
|
|
802
607
|
postcssPlugin: `${postcssPlugin}:post`,
|
|
803
608
|
async Once(root, helpers) {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
609
|
+
const sourceInput = root.source?.input;
|
|
610
|
+
if (filter(sourceInput)) {
|
|
611
|
+
const nodes = root.nodes ?? [];
|
|
612
|
+
let atruleAnchorIndex = -1;
|
|
613
|
+
let commentAnchorIndex = -1;
|
|
614
|
+
const directivePresence = /* @__PURE__ */ new Set();
|
|
615
|
+
nodes.forEach((node, index) => {
|
|
616
|
+
if (node.type === "atrule") {
|
|
617
|
+
const nameMatches = insertAfterAtRulesNames.includes(node.name);
|
|
618
|
+
if (nameMatches) {
|
|
619
|
+
atruleAnchorIndex = Math.max(atruleAnchorIndex, index);
|
|
620
|
+
}
|
|
621
|
+
if (typeof node.params === "string") {
|
|
622
|
+
directivePresence.add(node.params);
|
|
623
|
+
}
|
|
624
|
+
} else if (node.type === "comment" && regExpTest(insertAfterComments, node.text)) {
|
|
625
|
+
commentAnchorIndex = Math.max(commentAnchorIndex, index);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
const anchorIndex = Math.max(atruleAnchorIndex, commentAnchorIndex);
|
|
629
|
+
const anchorNode = anchorIndex >= 0 ? nodes[anchorIndex] : void 0;
|
|
630
|
+
let lastInserted = anchorNode;
|
|
808
631
|
for (const params of directiveParams) {
|
|
809
|
-
|
|
810
|
-
if (!node) {
|
|
632
|
+
if (!directivePresence.has(params)) {
|
|
811
633
|
const atRule = helpers.atRule({ name: "tailwind", params });
|
|
812
|
-
if (
|
|
813
|
-
root.
|
|
634
|
+
if (lastInserted) {
|
|
635
|
+
root.insertAfter(lastInserted, atRule);
|
|
814
636
|
} else {
|
|
815
|
-
root.
|
|
637
|
+
root.prepend(atRule);
|
|
816
638
|
}
|
|
639
|
+
lastInserted = atRule;
|
|
640
|
+
directivePresence.add(params);
|
|
817
641
|
}
|
|
818
642
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
const
|
|
823
|
-
cwd: cwd2,
|
|
824
|
-
config: cfg
|
|
825
|
-
});
|
|
826
|
-
if (result) {
|
|
827
|
-
tailwindcssConfig = result.config;
|
|
828
|
-
}
|
|
829
|
-
} else {
|
|
830
|
-
tailwindcssConfig = cfg ?? {
|
|
831
|
-
content: []
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
if (tailwindcssConfig && root.source?.input && root.source.input.file) {
|
|
835
|
-
const basename2 = removeFileExtension(root.source.input.file);
|
|
836
|
-
(0, import_set_value.default)(tailwindcssConfig, "content", [
|
|
837
|
-
`${basename2}.${extensionsGlob}`
|
|
838
|
-
]);
|
|
643
|
+
if (sourceInput?.file) {
|
|
644
|
+
const tailwindcssConfig = await resolveTailwindConfig(config, cwd2, sourceInput) ?? { content: [] };
|
|
645
|
+
const basename2 = removeFileExtension(sourceInput.file);
|
|
646
|
+
const contentEntries = [`${basename2}.${extensionsGlob}`];
|
|
839
647
|
const deps = await getDepFiles(`${basename2}.wxml`);
|
|
840
648
|
for (const dep of deps) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
649
|
+
contentEntries.push(`${removeFileExtension(dep)}.${extensionsGlob}`);
|
|
650
|
+
}
|
|
651
|
+
const uniqueEntries = Array.from(new Set(contentEntries));
|
|
652
|
+
const { content: existingContent } = tailwindcssConfig;
|
|
653
|
+
if (!existingContent || Array.isArray(existingContent)) {
|
|
654
|
+
tailwindcssConfig.content = uniqueEntries;
|
|
655
|
+
} else if (typeof existingContent === "object" && existingContent !== null) {
|
|
656
|
+
const normalizedContent = { ...existingContent };
|
|
657
|
+
const currentFiles = normalizedContent.files;
|
|
658
|
+
const normalizedFiles = Array.isArray(currentFiles) ? currentFiles : typeof currentFiles === "string" ? [currentFiles] : [];
|
|
659
|
+
normalizedContent.files = Array.from(/* @__PURE__ */ new Set([...normalizedFiles, ...uniqueEntries]));
|
|
660
|
+
tailwindcssConfig.content = normalizedContent;
|
|
661
|
+
} else {
|
|
662
|
+
tailwindcssConfig.content = uniqueEntries;
|
|
844
663
|
}
|
|
845
664
|
await postcss([
|
|
846
665
|
tailwindcss(tailwindcssConfig)
|
|
847
666
|
]).process(root, {
|
|
848
|
-
from:
|
|
667
|
+
from: sourceInput.file
|
|
849
668
|
}).async();
|
|
850
669
|
}
|
|
851
670
|
}
|
|
@@ -859,37 +678,3 @@ var postcss_default = creator;
|
|
|
859
678
|
export {
|
|
860
679
|
postcss_default as default
|
|
861
680
|
};
|
|
862
|
-
/*! Bundled license information:
|
|
863
|
-
|
|
864
|
-
is-primitive/index.js:
|
|
865
|
-
(*!
|
|
866
|
-
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
|
867
|
-
*
|
|
868
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
869
|
-
* Released under the MIT License.
|
|
870
|
-
*)
|
|
871
|
-
|
|
872
|
-
isobject/index.js:
|
|
873
|
-
(*!
|
|
874
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
875
|
-
*
|
|
876
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
877
|
-
* Released under the MIT License.
|
|
878
|
-
*)
|
|
879
|
-
|
|
880
|
-
is-plain-object/index.js:
|
|
881
|
-
(*!
|
|
882
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
883
|
-
*
|
|
884
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
885
|
-
* Released under the MIT License.
|
|
886
|
-
*)
|
|
887
|
-
|
|
888
|
-
set-value/index.js:
|
|
889
|
-
(*!
|
|
890
|
-
* set-value <https://github.com/jonschlinkert/set-value>
|
|
891
|
-
*
|
|
892
|
-
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
893
|
-
* Released under the MIT License.
|
|
894
|
-
*)
|
|
895
|
-
*/
|
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.7",
|
|
5
5
|
"description": "tsup(esbuild) build package template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"fs-extra": "^11.3.
|
|
34
|
+
"fs-extra": "^11.3.2",
|
|
35
35
|
"htmlparser2": "^10.0.0",
|
|
36
|
-
"magic-string": "^0.30.
|
|
36
|
+
"magic-string": "^0.30.19",
|
|
37
37
|
"postcss": "^8.5.6",
|
|
38
38
|
"tailwindcss": "^3.4.17",
|
|
39
39
|
"@weapp-tailwindcss/shared": "1.0.3",
|