weapp-tailwindcss 4.11.0-alpha.1 → 4.11.0-alpha.2
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/{chunk-35EI5JMK.mjs → chunk-23K4XDKF.mjs} +3 -1
- package/dist/{chunk-W2EMGF7H.js → chunk-2W24MRCQ.js} +10 -12
- package/dist/chunk-4AFQP74Z.js +24 -0
- package/dist/{chunk-SQG2MOFQ.js → chunk-4TTPYMVM.js} +12 -8
- package/dist/{chunk-4LPOQMFS.js → chunk-5KSBT6GU.js} +396 -219
- package/dist/{chunk-LD7LZ4IK.mjs → chunk-66E76FQE.mjs} +91 -50
- package/dist/{chunk-GWDHNCL2.js → chunk-6O7HJU2F.js} +123 -42
- package/dist/{chunk-RRHPTTCP.mjs → chunk-76S2EME4.mjs} +2 -0
- package/dist/{chunk-G3G437UE.js → chunk-7LKMJZD2.js} +2 -2
- package/dist/{chunk-OV7FX6XR.js → chunk-CRDOWYG4.js} +1 -1
- package/dist/{chunk-DOH7FULQ.mjs → chunk-EFBQ4SQR.mjs} +1 -1
- package/dist/{chunk-IEZ5RBMG.mjs → chunk-EW2K6CO5.mjs} +365 -188
- package/dist/{chunk-FZNYV7VH.mjs → chunk-HADJCWHU.mjs} +212 -258
- package/dist/{chunk-CZLXTEHN.js → chunk-K7CZXT46.js} +132 -91
- package/dist/{chunk-ACTJYB33.js → chunk-LL3QUKJI.js} +3 -1
- package/dist/{chunk-G5NLM3AL.js → chunk-LYGLQCWI.js} +278 -324
- package/dist/{chunk-LTJQUORK.js → chunk-OF6MFURR.js} +2 -0
- package/dist/{chunk-KKT2DKMW.mjs → chunk-RED7Y22U.mjs} +91 -10
- package/dist/{chunk-R6KEYO3F.mjs → chunk-SJ3SG6DU.mjs} +5 -1
- package/dist/{chunk-JBM3HGHP.mjs → chunk-UCUAXK7F.mjs} +4 -6
- package/dist/cli.js +1006 -147
- package/dist/cli.mjs +942 -107
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +9 -11
- package/dist/core.mjs +6 -8
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +3 -3
- package/dist/css-macro.mjs +4 -4
- package/dist/defaults.d.mts +2 -2
- package/dist/defaults.d.ts +2 -2
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/gulp.d.mts +2 -2
- package/dist/gulp.d.ts +2 -2
- package/dist/gulp.js +7 -8
- package/dist/gulp.mjs +6 -7
- package/dist/{index-t_VBjwYm.d.ts → index-BMwzhITq.d.mts} +6 -6
- package/dist/{index-t_VBjwYm.d.mts → index-BMwzhITq.d.ts} +6 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -12
- package/dist/index.mjs +9 -10
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.d.mts +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +8 -9
- package/dist/vite.mjs +6 -7
- package/dist/weapp-tw-css-import-rewrite-loader.js +3 -1
- package/dist/weapp-tw-runtime-classset-loader.js +29 -2
- package/dist/webpack.d.mts +2 -2
- package/dist/webpack.d.ts +2 -2
- package/dist/webpack.js +9 -10
- package/dist/webpack.mjs +7 -8
- package/dist/webpack4.d.mts +2 -2
- package/dist/webpack4.d.ts +2 -2
- package/dist/webpack4.js +41 -41
- package/dist/webpack4.mjs +12 -12
- package/package.json +8 -8
- package/dist/chunk-NOKJXG3W.js +0 -29
- package/dist/chunk-QYZCRG7F.mjs +0 -29
package/dist/cli.js
CHANGED
|
@@ -1,40 +1,899 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
2
24
|
|
|
25
|
+
// src/cli.ts
|
|
26
|
+
var import_node_process17 = __toESM(require("process"));
|
|
27
|
+
var import_semver = __toESM(require("semver"));
|
|
28
|
+
var import_tailwindcss_patch3 = require("tailwindcss-patch");
|
|
3
29
|
|
|
30
|
+
// src/cli/context.ts
|
|
31
|
+
var import_node_path12 = __toESM(require("path"));
|
|
32
|
+
var import_node_process11 = __toESM(require("process"));
|
|
4
33
|
|
|
34
|
+
// src/context/index.ts
|
|
35
|
+
var import_promises2 = require("fs/promises");
|
|
36
|
+
var import_logger10 = require("@weapp-tailwindcss/logger");
|
|
5
37
|
|
|
6
|
-
|
|
38
|
+
// src/cache/index.ts
|
|
39
|
+
var import_lru_cache = require("lru-cache");
|
|
7
40
|
|
|
41
|
+
// src/cache/md5.ts
|
|
42
|
+
var import_node = require("@weapp-tailwindcss/shared/node");
|
|
8
43
|
|
|
44
|
+
// src/defaults.ts
|
|
45
|
+
var import_escape = require("@weapp-core/escape");
|
|
9
46
|
|
|
10
|
-
|
|
11
|
-
require(
|
|
12
|
-
require('./chunk-DYLQ6UOI.js');
|
|
13
|
-
require('./chunk-OV7FX6XR.js');
|
|
47
|
+
// src/utils/index.ts
|
|
48
|
+
var import_shared = require("@weapp-tailwindcss/shared");
|
|
14
49
|
|
|
15
|
-
// src/
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var _tailwindcsspatch = require('tailwindcss-patch');
|
|
50
|
+
// src/utils/hbuilderx.ts
|
|
51
|
+
var import_node_path = __toESM(require("path"));
|
|
52
|
+
var import_node_process = __toESM(require("process"));
|
|
19
53
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
54
|
+
// src/utils/uni-platform.ts
|
|
55
|
+
var import_node_process2 = __toESM(require("process"));
|
|
56
|
+
|
|
57
|
+
// src/debug/index.ts
|
|
58
|
+
var import_debug = __toESM(require("debug"));
|
|
59
|
+
var _debug = (0, import_debug.default)("weapp-tw");
|
|
60
|
+
function createDebug(prefix) {
|
|
61
|
+
const debug3 = ((formatter, ...args) => {
|
|
62
|
+
return _debug((prefix ?? "") + formatter, ...args);
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(debug3, "enabled", {
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: false,
|
|
67
|
+
get() {
|
|
68
|
+
return _debug.enabled;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return debug3;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/tailwindcss/runtime/cache.ts
|
|
75
|
+
var import_node_fs = require("fs");
|
|
76
|
+
|
|
77
|
+
// src/tailwindcss/runtime.ts
|
|
78
|
+
var debug = createDebug("[tailwindcss:runtime] ");
|
|
79
|
+
|
|
80
|
+
// src/tailwindcss/targets.ts
|
|
81
|
+
var import_node_process5 = __toESM(require("process"));
|
|
82
|
+
var import_logger2 = require("@weapp-tailwindcss/logger");
|
|
83
|
+
|
|
84
|
+
// src/tailwindcss/targets/paths.ts
|
|
85
|
+
var import_node_fs3 = require("fs");
|
|
86
|
+
var import_node_path3 = __toESM(require("path"));
|
|
87
|
+
|
|
88
|
+
// src/context/workspace.ts
|
|
89
|
+
var import_node_fs2 = require("fs");
|
|
90
|
+
var import_node_path2 = __toESM(require("path"));
|
|
91
|
+
function findWorkspaceRoot(startDir) {
|
|
92
|
+
if (!startDir) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
let current = import_node_path2.default.resolve(startDir);
|
|
96
|
+
while (true) {
|
|
97
|
+
const workspaceFile = import_node_path2.default.join(current, "pnpm-workspace.yaml");
|
|
98
|
+
if ((0, import_node_fs2.existsSync)(workspaceFile)) {
|
|
99
|
+
return current;
|
|
100
|
+
}
|
|
101
|
+
const parent = import_node_path2.default.dirname(current);
|
|
102
|
+
if (parent === current) {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
current = parent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function findNearestPackageRoot(startDir) {
|
|
109
|
+
if (!startDir) {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
let current = import_node_path2.default.resolve(startDir);
|
|
113
|
+
while (true) {
|
|
114
|
+
const pkgPath = import_node_path2.default.join(current, "package.json");
|
|
115
|
+
if ((0, import_node_fs2.existsSync)(pkgPath)) {
|
|
116
|
+
return current;
|
|
117
|
+
}
|
|
118
|
+
const parent = import_node_path2.default.dirname(current);
|
|
119
|
+
if (parent === current) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
current = parent;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/tailwindcss/targets/paths.ts
|
|
127
|
+
var PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
128
|
+
var PATCH_INFO_CACHE_RELATIVE_PATH = import_node_path3.default.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
|
|
129
|
+
var PATCH_INFO_LEGACY_RELATIVE_PATH = import_node_path3.default.join(".tw-patch", PATCH_INFO_FILENAME);
|
|
130
|
+
function formatRelativeToBase(targetPath, baseDir) {
|
|
131
|
+
if (!baseDir) {
|
|
132
|
+
return import_node_path3.default.normalize(targetPath);
|
|
133
|
+
}
|
|
134
|
+
const relative = import_node_path3.default.relative(baseDir, targetPath);
|
|
135
|
+
if (!relative || relative === ".") {
|
|
136
|
+
return ".";
|
|
137
|
+
}
|
|
138
|
+
if (relative.startsWith("..")) {
|
|
139
|
+
return import_node_path3.default.normalize(targetPath);
|
|
140
|
+
}
|
|
141
|
+
return import_node_path3.default.join(".", relative);
|
|
142
|
+
}
|
|
143
|
+
function resolveRecordLocation(baseDir) {
|
|
144
|
+
const normalizedBase = import_node_path3.default.normalize(baseDir);
|
|
145
|
+
const packageRoot = findNearestPackageRoot(normalizedBase) ?? normalizedBase;
|
|
146
|
+
const packageJsonPath = import_node_path3.default.join(packageRoot, "package.json");
|
|
147
|
+
const hasPackageJson = (0, import_node_fs3.existsSync)(packageJsonPath);
|
|
148
|
+
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
149
|
+
const recordKey = (0, import_node.md5)(import_node_path3.default.normalize(recordKeySource));
|
|
150
|
+
const recordDir = import_node_path3.default.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
151
|
+
const recordPath = import_node_path3.default.join(recordDir, PATCH_INFO_FILENAME);
|
|
152
|
+
return {
|
|
153
|
+
normalizedBase,
|
|
154
|
+
packageRoot,
|
|
155
|
+
recordDir,
|
|
156
|
+
recordKey,
|
|
157
|
+
recordPath,
|
|
158
|
+
packageJsonPath: hasPackageJson ? packageJsonPath : void 0
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function getRecordFileCandidates(baseDir) {
|
|
162
|
+
const { normalizedBase, packageRoot, recordPath } = resolveRecordLocation(baseDir);
|
|
163
|
+
const candidates = /* @__PURE__ */ new Set([
|
|
164
|
+
recordPath,
|
|
165
|
+
import_node_path3.default.join(packageRoot, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
166
|
+
import_node_path3.default.join(normalizedBase, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
167
|
+
import_node_path3.default.join(normalizedBase, PATCH_INFO_LEGACY_RELATIVE_PATH)
|
|
168
|
+
]);
|
|
169
|
+
return [...candidates];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/tailwindcss/targets/record-io.ts
|
|
173
|
+
var import_node_fs4 = require("fs");
|
|
174
|
+
var import_promises = require("fs/promises");
|
|
175
|
+
var import_node_path4 = __toESM(require("path"));
|
|
176
|
+
var import_node_process3 = __toESM(require("process"));
|
|
177
|
+
var import_logger = require("@weapp-tailwindcss/logger");
|
|
178
|
+
|
|
179
|
+
// package.json
|
|
180
|
+
var package_default = {
|
|
181
|
+
name: "weapp-tailwindcss",
|
|
182
|
+
version: "4.11.0-alpha.2",
|
|
183
|
+
description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
|
|
184
|
+
author: "ice breaker <1324318532@qq.com>",
|
|
185
|
+
license: "MIT",
|
|
186
|
+
homepage: "https://tw.icebreaker.top",
|
|
187
|
+
repository: {
|
|
188
|
+
type: "git",
|
|
189
|
+
url: "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
|
|
190
|
+
directory: "packages/weapp-tailwindcss"
|
|
191
|
+
},
|
|
192
|
+
bugs: {
|
|
193
|
+
url: "https://github.com/sonofmagic/weapp-tailwindcss/issues"
|
|
194
|
+
},
|
|
195
|
+
keywords: [
|
|
196
|
+
"tailwindcss",
|
|
197
|
+
"weapp",
|
|
198
|
+
"wechat",
|
|
199
|
+
"mini",
|
|
200
|
+
"miniprogram",
|
|
201
|
+
"mini app",
|
|
202
|
+
"weapp-tw",
|
|
203
|
+
"weapp-tailwindcss",
|
|
204
|
+
"taro",
|
|
205
|
+
"uni-app",
|
|
206
|
+
"remax",
|
|
207
|
+
"rax",
|
|
208
|
+
"mpx",
|
|
209
|
+
"jit",
|
|
210
|
+
"mp",
|
|
211
|
+
"android",
|
|
212
|
+
"ios",
|
|
213
|
+
"\u5C0F\u7A0B\u5E8F",
|
|
214
|
+
"vite",
|
|
215
|
+
"postcss",
|
|
216
|
+
"webpack",
|
|
217
|
+
"webpack-plugin",
|
|
218
|
+
"gulp",
|
|
219
|
+
"gulp-plugin"
|
|
220
|
+
],
|
|
221
|
+
exports: {
|
|
222
|
+
".": {
|
|
223
|
+
style: "./index.css",
|
|
224
|
+
types: "./dist/index.d.ts",
|
|
225
|
+
import: "./dist/index.mjs",
|
|
226
|
+
require: "./dist/index.js"
|
|
227
|
+
},
|
|
228
|
+
"./escape": {
|
|
229
|
+
types: "./dist/escape.d.ts",
|
|
230
|
+
import: "./dist/escape.mjs",
|
|
231
|
+
require: "./dist/escape.js"
|
|
232
|
+
},
|
|
233
|
+
"./vite": {
|
|
234
|
+
types: "./dist/vite.d.ts",
|
|
235
|
+
import: "./dist/vite.mjs",
|
|
236
|
+
require: "./dist/vite.js"
|
|
237
|
+
},
|
|
238
|
+
"./webpack": {
|
|
239
|
+
types: "./dist/webpack.d.ts",
|
|
240
|
+
import: "./dist/webpack.mjs",
|
|
241
|
+
require: "./dist/webpack.js"
|
|
242
|
+
},
|
|
243
|
+
"./webpack4": {
|
|
244
|
+
types: "./dist/webpack4.d.ts",
|
|
245
|
+
import: "./dist/webpack4.mjs",
|
|
246
|
+
require: "./dist/webpack4.js"
|
|
247
|
+
},
|
|
248
|
+
"./core": {
|
|
249
|
+
types: "./dist/core.d.ts",
|
|
250
|
+
import: "./dist/core.mjs",
|
|
251
|
+
require: "./dist/core.js"
|
|
252
|
+
},
|
|
253
|
+
"./gulp": {
|
|
254
|
+
types: "./dist/gulp.d.ts",
|
|
255
|
+
import: "./dist/gulp.mjs",
|
|
256
|
+
require: "./dist/gulp.js"
|
|
257
|
+
},
|
|
258
|
+
"./defaults": {
|
|
259
|
+
types: "./dist/defaults.d.ts",
|
|
260
|
+
import: "./dist/defaults.mjs",
|
|
261
|
+
require: "./dist/defaults.js"
|
|
262
|
+
},
|
|
263
|
+
"./presets": {
|
|
264
|
+
types: "./dist/presets.d.ts",
|
|
265
|
+
import: "./dist/presets.mjs",
|
|
266
|
+
require: "./dist/presets.js"
|
|
267
|
+
},
|
|
268
|
+
"./reset": {
|
|
269
|
+
types: "./dist/reset.d.ts",
|
|
270
|
+
import: "./dist/reset.mjs",
|
|
271
|
+
require: "./dist/reset.js"
|
|
272
|
+
},
|
|
273
|
+
"./css-macro/postcss": {
|
|
274
|
+
types: "./dist/css-macro/postcss.d.ts",
|
|
275
|
+
import: "./dist/css-macro/postcss.mjs",
|
|
276
|
+
require: "./dist/css-macro/postcss.js"
|
|
277
|
+
},
|
|
278
|
+
"./css-macro": {
|
|
279
|
+
types: "./dist/css-macro.d.ts",
|
|
280
|
+
import: "./dist/css-macro.mjs",
|
|
281
|
+
require: "./dist/css-macro.js"
|
|
282
|
+
},
|
|
283
|
+
"./types": {
|
|
284
|
+
types: "./dist/types.d.ts",
|
|
285
|
+
import: "./dist/types.mjs",
|
|
286
|
+
require: "./dist/types.js"
|
|
287
|
+
},
|
|
288
|
+
"./postcss-html-transform": {
|
|
289
|
+
types: "./dist/postcss-html-transform.d.ts",
|
|
290
|
+
import: "./dist/postcss-html-transform.mjs",
|
|
291
|
+
require: "./dist/postcss-html-transform.js"
|
|
292
|
+
},
|
|
293
|
+
"./package.json": "./package.json",
|
|
294
|
+
"./index.css": "./index.css",
|
|
295
|
+
"./index": "./index.css",
|
|
296
|
+
"./preflight.css": "./preflight.css",
|
|
297
|
+
"./preflight": "./preflight.css",
|
|
298
|
+
"./theme.css": "./theme.css",
|
|
299
|
+
"./theme": "./theme.css",
|
|
300
|
+
"./utilities.css": "./utilities.css",
|
|
301
|
+
"./utilities": "./utilities.css",
|
|
302
|
+
"./with-layer.css": "./with-layer.css",
|
|
303
|
+
"./with-layer": "./with-layer.css",
|
|
304
|
+
"./uni-app-x": "./uni-app-x.css",
|
|
305
|
+
"./uni-app-x.css": "./uni-app-x.css",
|
|
306
|
+
"./css": "./css/index.css",
|
|
307
|
+
"./*": "./*"
|
|
308
|
+
},
|
|
309
|
+
main: "./dist/index.js",
|
|
310
|
+
module: "./dist/index.mjs",
|
|
311
|
+
types: "./dist/index.d.ts",
|
|
312
|
+
style: "index.css",
|
|
313
|
+
typesVersions: {
|
|
314
|
+
"*": {
|
|
315
|
+
"*": [
|
|
316
|
+
"./dist/*",
|
|
317
|
+
"./dist/index.d.ts"
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
bin: {
|
|
322
|
+
"weapp-tailwindcss-webpack-plugin": "bin/weapp-tailwindcss.js",
|
|
323
|
+
"weapp-tailwindcss": "bin/weapp-tailwindcss.js",
|
|
324
|
+
"weapp-tw": "bin/weapp-tailwindcss.js"
|
|
325
|
+
},
|
|
326
|
+
files: [
|
|
327
|
+
"bin",
|
|
328
|
+
"css",
|
|
329
|
+
"dist",
|
|
330
|
+
"index.css",
|
|
331
|
+
"preflight.css",
|
|
332
|
+
"theme.css",
|
|
333
|
+
"uni-app-x.css",
|
|
334
|
+
"utilities.css",
|
|
335
|
+
"with-layer.css"
|
|
336
|
+
],
|
|
337
|
+
engines: {
|
|
338
|
+
node: "^18.17.0 || >=20.5.0"
|
|
339
|
+
},
|
|
340
|
+
scripts: {
|
|
341
|
+
dev: "tsup --watch --sourcemap",
|
|
342
|
+
build: "tsup && node scripts/ensure-escape-dts.mjs",
|
|
343
|
+
"build:tsc": "cross-env NODE_ENV=development tsc --build tsconfig.json",
|
|
344
|
+
"build:cli": "cd plugins/cli && pnpm run build",
|
|
345
|
+
"build:css": "tsx scripts/build-css.ts",
|
|
346
|
+
"build:weapp-theme": "tsx scripts/build-weapp-theme.ts",
|
|
347
|
+
test: "npm run postinstall && vitest run",
|
|
348
|
+
"test:dev": "vitest",
|
|
349
|
+
"test:ui": "vitest --ui",
|
|
350
|
+
bench: "vitest bench --config ./vitest.config.ts",
|
|
351
|
+
"bench:vite-perf": "tsx scripts/vite-perf-bench.ts",
|
|
352
|
+
"bench:vite-perf:summary": "tsx scripts/vite-perf-summary.ts",
|
|
353
|
+
"bench:js-handlers": "tsx scripts/js-bench.ts",
|
|
354
|
+
"bench:js-diff": "tsx scripts/js-bench-diff.ts",
|
|
355
|
+
tsd: "tsd",
|
|
356
|
+
clean: "tsx scripts/clean.ts",
|
|
357
|
+
"get-decl": "tsx scripts/get-decl.ts",
|
|
358
|
+
"ls:pack": "npm pack --dry-run",
|
|
359
|
+
"cli:patch": "node bin/weapp-tailwindcss.js patch",
|
|
360
|
+
colors: "tsx scripts/colors.ts",
|
|
361
|
+
release: "tsx scripts/release.ts",
|
|
362
|
+
lint: "eslint .",
|
|
363
|
+
"lint:fix": "eslint ./src --fix",
|
|
364
|
+
postinstall: "node bin/weapp-tailwindcss.js patch",
|
|
365
|
+
"bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
|
|
366
|
+
"test:watch-hmr": "node --import tsx scripts/watch-hmr-regression/index.ts"
|
|
367
|
+
},
|
|
368
|
+
publishConfig: {
|
|
369
|
+
access: "public",
|
|
370
|
+
registry: "https://registry.npmjs.org"
|
|
371
|
+
},
|
|
372
|
+
dependencies: {
|
|
373
|
+
"@ast-core/escape": "~1.0.1",
|
|
374
|
+
"@babel/parser": "~7.29.2",
|
|
375
|
+
"@babel/traverse": "~7.29.0",
|
|
376
|
+
"@babel/types": "~7.29.0",
|
|
377
|
+
"@tailwindcss-mangle/config": "^6.1.3",
|
|
378
|
+
"@vue/compiler-dom": "catalog:vue3",
|
|
379
|
+
"@vue/compiler-sfc": "catalog:vue3",
|
|
380
|
+
"@weapp-core/escape": "~7.0.0",
|
|
381
|
+
"@weapp-core/regex": "~1.0.1",
|
|
382
|
+
"@weapp-tailwindcss/logger": "workspace:*",
|
|
383
|
+
"@weapp-tailwindcss/postcss": "workspace:*",
|
|
384
|
+
"@weapp-tailwindcss/shared": "workspace:*",
|
|
385
|
+
cac: "6.7.14",
|
|
386
|
+
debug: "~4.4.3",
|
|
387
|
+
"fast-glob": "^3.3.3",
|
|
388
|
+
htmlparser2: "10.1.0",
|
|
389
|
+
"loader-utils": "2.0.4",
|
|
390
|
+
"local-pkg": "^1.1.2",
|
|
391
|
+
"lru-cache": "10.4.3",
|
|
392
|
+
"magic-string": "0.30.21",
|
|
393
|
+
semver: "~7.7.4",
|
|
394
|
+
"tailwindcss-patch": "catalog:tailwindcssPatch",
|
|
395
|
+
"webpack-sources": "3.3.4",
|
|
396
|
+
yaml: "^2.8.3"
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// src/constants.ts
|
|
401
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
402
|
+
var WEAPP_TW_VERSION = package_default.version;
|
|
403
|
+
|
|
404
|
+
// src/tailwindcss/targets/record-io.ts
|
|
405
|
+
var loggedInvalidPatchRecords = /* @__PURE__ */ new Set();
|
|
406
|
+
function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
|
|
407
|
+
const normalizedPath = import_node_path4.default.normalize(recordPath);
|
|
408
|
+
if (loggedInvalidPatchRecords.has(normalizedPath)) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
loggedInvalidPatchRecords.add(normalizedPath);
|
|
412
|
+
const fileDisplay = formatRelativeToBase(normalizedPath, baseDir);
|
|
413
|
+
const baseDisplay = formatRelativeToBase(import_node_path4.default.normalize(baseDir), import_node_process3.default.cwd());
|
|
414
|
+
const reasonMessage = reason ? `\uFF1A${reason}` : "";
|
|
415
|
+
import_logger.logger.warn(
|
|
416
|
+
`\u68C0\u6D4B\u5230\u635F\u574F\u7684 Tailwind CSS \u76EE\u6807\u8BB0\u5F55 ${fileDisplay}${reasonMessage}\u3002\u8BF7\u5728 ${baseDisplay} \u91CD\u65B0\u6267\u884C "weapp-tw patch --record-target" \u6216\u5220\u9664\u8BE5\u6587\u4EF6\u540E\u518D\u8FD0\u884C\u3002`
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
function readPatchTargetRecord(baseDir) {
|
|
420
|
+
if (!baseDir) {
|
|
421
|
+
return void 0;
|
|
422
|
+
}
|
|
423
|
+
const normalizedBase = import_node_path4.default.normalize(baseDir);
|
|
424
|
+
for (const recordPath of getRecordFileCandidates(normalizedBase)) {
|
|
425
|
+
if (!(0, import_node_fs4.existsSync)(recordPath)) {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
const content = (0, import_node_fs4.readFileSync)(recordPath, "utf8");
|
|
430
|
+
const parsed = JSON.parse(content);
|
|
431
|
+
if (!parsed || typeof parsed.tailwindPackagePath !== "string") {
|
|
432
|
+
warnInvalidPatchTargetRecord(normalizedBase, recordPath, "\u7F3A\u5C11 tailwindPackagePath \u5B57\u6BB5");
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
baseDir: normalizedBase,
|
|
437
|
+
path: recordPath,
|
|
438
|
+
record: parsed
|
|
439
|
+
};
|
|
440
|
+
} catch (error) {
|
|
441
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
442
|
+
warnInvalidPatchTargetRecord(normalizedBase, recordPath, reason);
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return void 0;
|
|
447
|
+
}
|
|
448
|
+
async function saveCliPatchTargetRecord(baseDir, patcher, options) {
|
|
449
|
+
if (!baseDir || !patcher?.packageInfo?.rootPath) {
|
|
450
|
+
return void 0;
|
|
451
|
+
}
|
|
452
|
+
const normalizedBase = import_node_path4.default.normalize(baseDir);
|
|
453
|
+
const location = resolveRecordLocation(normalizedBase);
|
|
454
|
+
const recordPath = options?.recordPath ? import_node_path4.default.normalize(options.recordPath) : location.recordPath;
|
|
455
|
+
const record = {
|
|
456
|
+
tailwindPackagePath: import_node_path4.default.normalize(patcher.packageInfo.rootPath),
|
|
457
|
+
packageVersion: patcher.packageInfo.version,
|
|
458
|
+
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
459
|
+
source: options?.source ?? "cli",
|
|
460
|
+
tailwindcssBasedir: normalizedBase,
|
|
461
|
+
cwd: options?.cwd ? import_node_path4.default.normalize(options.cwd) : normalizedBase,
|
|
462
|
+
patchVersion: WEAPP_TW_VERSION,
|
|
463
|
+
packageJsonPath: options?.packageJsonPath ?? location.packageJsonPath,
|
|
464
|
+
recordKey: options?.recordKey ?? location.recordKey
|
|
465
|
+
};
|
|
466
|
+
try {
|
|
467
|
+
await (0, import_promises.mkdir)(import_node_path4.default.dirname(recordPath), { recursive: true });
|
|
468
|
+
await (0, import_promises.writeFile)(recordPath, `${JSON.stringify(record, null, 2)}
|
|
469
|
+
`, "utf8");
|
|
470
|
+
return recordPath;
|
|
471
|
+
} catch (error) {
|
|
472
|
+
const baseDisplay = formatRelativeToBase(normalizedBase, import_node_process3.default.cwd());
|
|
473
|
+
import_logger.logger.warn(
|
|
474
|
+
'\u81EA\u52A8\u66F4\u65B0 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\u5931\u8D25\uFF0C\u8BF7\u5728 %s \u8FD0\u884C "weapp-tw patch --cwd %s"\u3002',
|
|
475
|
+
baseDisplay,
|
|
476
|
+
normalizedBase
|
|
477
|
+
);
|
|
478
|
+
import_logger.logger.debug("failed to persist patch target record %s: %O", recordPath, error);
|
|
479
|
+
return void 0;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// src/tailwindcss/targets/recorder.ts
|
|
484
|
+
var import_node_path5 = __toESM(require("path"));
|
|
485
|
+
var import_node_process4 = __toESM(require("process"));
|
|
486
|
+
function findPatchTargetRecord(baseDir) {
|
|
487
|
+
const visited = /* @__PURE__ */ new Set();
|
|
488
|
+
const fallback = baseDir ?? import_node_process4.default.cwd();
|
|
489
|
+
let current = import_node_path5.default.resolve(fallback);
|
|
490
|
+
while (!visited.has(current)) {
|
|
491
|
+
const record = readPatchTargetRecord(current);
|
|
492
|
+
if (record) {
|
|
493
|
+
return record;
|
|
494
|
+
}
|
|
495
|
+
const parent = import_node_path5.default.dirname(current);
|
|
496
|
+
if (parent === current) {
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
visited.add(current);
|
|
500
|
+
current = parent;
|
|
501
|
+
}
|
|
502
|
+
return void 0;
|
|
503
|
+
}
|
|
504
|
+
function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
505
|
+
if (!baseDir || !patcher?.packageInfo?.rootPath || options?.recordTarget === false) {
|
|
506
|
+
return void 0;
|
|
507
|
+
}
|
|
508
|
+
const normalizedBase = import_node_path5.default.normalize(baseDir);
|
|
509
|
+
const recorded = findPatchTargetRecord(normalizedBase);
|
|
510
|
+
const location = resolveRecordLocation(normalizedBase);
|
|
511
|
+
const expectedPath = import_node_path5.default.normalize(patcher.packageInfo.rootPath);
|
|
512
|
+
let reason;
|
|
513
|
+
if (!recorded) {
|
|
514
|
+
reason = "missing";
|
|
515
|
+
} else {
|
|
516
|
+
const normalizedRecorded = import_node_path5.default.normalize(recorded.record.tailwindPackagePath);
|
|
517
|
+
if (normalizedRecorded !== expectedPath) {
|
|
518
|
+
reason = "mismatch";
|
|
519
|
+
} else if (import_node_path5.default.normalize(recorded.path) !== import_node_path5.default.normalize(location.recordPath) || !recorded.record.recordKey || recorded.record.recordKey !== location.recordKey) {
|
|
520
|
+
reason = "migrate";
|
|
521
|
+
} else if (!recorded.record.patchVersion || recorded.record.patchVersion !== WEAPP_TW_VERSION) {
|
|
522
|
+
reason = "stale";
|
|
523
|
+
} else if (options?.cwd && recorded.record.cwd && import_node_path5.default.normalize(recorded.record.cwd) !== import_node_path5.default.normalize(options.cwd)) {
|
|
524
|
+
reason = "metadata";
|
|
525
|
+
} else if (!recorded.record.cwd && options?.cwd) {
|
|
526
|
+
reason = "metadata";
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const shouldPersist = options?.alwaysRecord || !recorded || Boolean(reason);
|
|
530
|
+
if (!shouldPersist) {
|
|
531
|
+
return void 0;
|
|
532
|
+
}
|
|
533
|
+
let message;
|
|
534
|
+
switch (reason) {
|
|
535
|
+
case "mismatch":
|
|
536
|
+
message = "\u68C0\u6D4B\u5230 Tailwind CSS \u76EE\u6807\u8BB0\u5F55\u4E0E\u5F53\u524D\u89E3\u6790\u7ED3\u679C\u4E0D\u4E00\u81F4\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u65B0 patch \u5E76\u5237\u65B0\u7F13\u5B58\u3002";
|
|
537
|
+
break;
|
|
538
|
+
case "migrate":
|
|
539
|
+
case "stale":
|
|
540
|
+
message = "\u6B63\u5728\u5237\u65B0\u5F53\u524D\u5B50\u5305\u7684 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\uFF0C\u786E\u4FDD\u7F13\u5B58\u9694\u79BB\u3002";
|
|
541
|
+
break;
|
|
542
|
+
case "missing":
|
|
543
|
+
message = "\u672A\u627E\u5230\u5F53\u524D\u5B50\u5305\u7684 Tailwind CSS \u76EE\u6807\u8BB0\u5F55\uFF0C\u6B63\u5728\u751F\u6210\u3002";
|
|
544
|
+
break;
|
|
545
|
+
default:
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
const onPatched = async () => saveCliPatchTargetRecord(normalizedBase, patcher, {
|
|
549
|
+
cwd: options?.cwd ?? normalizedBase,
|
|
550
|
+
source: options?.source ?? "cli",
|
|
551
|
+
recordPath: location.recordPath,
|
|
552
|
+
recordKey: location.recordKey,
|
|
553
|
+
packageJsonPath: location.packageJsonPath
|
|
554
|
+
});
|
|
555
|
+
return {
|
|
556
|
+
recordPath: location.recordPath,
|
|
557
|
+
message,
|
|
558
|
+
reason,
|
|
559
|
+
onPatched
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/tailwindcss/targets.ts
|
|
564
|
+
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
565
|
+
const packageInfo = patcher?.packageInfo;
|
|
566
|
+
const label = kind === "cli" ? "weapp-tw patch" : "tailwindcss-patcher";
|
|
567
|
+
if (!packageInfo?.rootPath) {
|
|
568
|
+
import_logger2.logger.warn(
|
|
569
|
+
"%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
|
|
570
|
+
label,
|
|
571
|
+
baseDir ?? import_node_process5.default.cwd()
|
|
572
|
+
);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
|
|
576
|
+
const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
|
|
577
|
+
import_logger2.logger.info("%s \u7ED1\u5B9A Tailwind CSS -> %s%s", label, displayPath, version);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/tailwindcss/v4/config.ts
|
|
581
|
+
var import_logger3 = require("@weapp-tailwindcss/logger");
|
|
582
|
+
|
|
583
|
+
// src/tailwindcss/v4/patcher.ts
|
|
584
|
+
var import_logger5 = require("@weapp-tailwindcss/logger");
|
|
585
|
+
|
|
586
|
+
// src/tailwindcss/patcher.ts
|
|
587
|
+
var import_node_path7 = __toESM(require("path"));
|
|
588
|
+
var import_node_process7 = __toESM(require("process"));
|
|
589
|
+
var import_logger4 = require("@weapp-tailwindcss/logger");
|
|
590
|
+
var import_shared2 = require("@weapp-tailwindcss/shared");
|
|
591
|
+
var import_tailwindcss_patch = require("tailwindcss-patch");
|
|
592
|
+
|
|
593
|
+
// src/tailwindcss/patcher-resolve.ts
|
|
594
|
+
var import_node_fs5 = require("fs");
|
|
595
|
+
var import_node_module = require("module");
|
|
596
|
+
var import_node_path6 = __toESM(require("path"));
|
|
597
|
+
var import_node_process6 = __toESM(require("process"));
|
|
598
|
+
var import_node_url = require("url");
|
|
599
|
+
|
|
600
|
+
// src/tailwindcss/v4/css-entries.ts
|
|
601
|
+
var import_node_path8 = __toESM(require("path"));
|
|
602
|
+
|
|
603
|
+
// src/context/compiler-context-cache.ts
|
|
604
|
+
var import_node_buffer = require("buffer");
|
|
605
|
+
var import_node_path9 = __toESM(require("path"));
|
|
606
|
+
var import_node_process8 = __toESM(require("process"));
|
|
607
|
+
var import_logger6 = require("@weapp-tailwindcss/logger");
|
|
608
|
+
var globalCacheHolder = globalThis;
|
|
609
|
+
var compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
|
|
610
|
+
|
|
611
|
+
// src/context/handlers.ts
|
|
612
|
+
var import_postcss = require("@weapp-tailwindcss/postcss");
|
|
613
|
+
|
|
614
|
+
// src/babel/index.ts
|
|
615
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
616
|
+
var import_parser = require("@babel/parser");
|
|
617
|
+
function _interopDefaultCompat(e) {
|
|
618
|
+
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
619
|
+
}
|
|
620
|
+
var traverse = _interopDefaultCompat(import_traverse.default);
|
|
621
|
+
|
|
622
|
+
// src/utils/nameMatcher.ts
|
|
623
|
+
var import_regex = require("@weapp-core/regex");
|
|
624
|
+
|
|
625
|
+
// src/js/babel/parse.ts
|
|
626
|
+
var import_lru_cache2 = require("lru-cache");
|
|
627
|
+
var parseCache = new import_lru_cache2.LRUCache(
|
|
628
|
+
{
|
|
629
|
+
max: 1024
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
// src/js/babel/process.ts
|
|
634
|
+
var import_magic_string = __toESM(require("magic-string"));
|
|
635
|
+
|
|
636
|
+
// src/js/handlers.ts
|
|
637
|
+
var import_escape3 = require("@ast-core/escape");
|
|
638
|
+
var import_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
639
|
+
|
|
640
|
+
// src/wxml/shared.ts
|
|
641
|
+
var import_escape2 = require("@weapp-core/escape");
|
|
642
|
+
|
|
643
|
+
// src/js/handlers.ts
|
|
644
|
+
var debug2 = createDebug("[js:handlers] ");
|
|
645
|
+
|
|
646
|
+
// src/js/evalTransforms.ts
|
|
647
|
+
var import_escape4 = require("@ast-core/escape");
|
|
648
|
+
|
|
649
|
+
// src/wxml/utils/codegen/legacy-rewriter.ts
|
|
650
|
+
var import_magic_string2 = __toESM(require("magic-string"));
|
|
651
|
+
|
|
652
|
+
// src/wxml/utils/codegen/legacy-visitor.ts
|
|
653
|
+
var t = __toESM(require("@babel/types"));
|
|
654
|
+
|
|
655
|
+
// src/wxml/utils/codegen.ts
|
|
656
|
+
var WRAP_EXPRESSION_HANDLER_OPTIONS = Object.freeze({
|
|
657
|
+
wrapExpression: true
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
// src/wxml/utils/custom-template.ts
|
|
661
|
+
var import_htmlparser2 = require("htmlparser2");
|
|
662
|
+
var import_magic_string4 = __toESM(require("magic-string"));
|
|
663
|
+
|
|
664
|
+
// src/wxml/utils/template-fragments.ts
|
|
665
|
+
var import_magic_string3 = __toESM(require("magic-string"));
|
|
666
|
+
|
|
667
|
+
// src/wxml/whitespace.ts
|
|
668
|
+
var WHITESPACE_CODES = /* @__PURE__ */ new Set([
|
|
669
|
+
9,
|
|
670
|
+
// 制表符 \t
|
|
671
|
+
10,
|
|
672
|
+
// 换行符 \n
|
|
673
|
+
11,
|
|
674
|
+
// 垂直制表符 \v
|
|
675
|
+
12,
|
|
676
|
+
// 换页符 \f
|
|
677
|
+
13,
|
|
678
|
+
// 回车符 \r
|
|
679
|
+
32,
|
|
680
|
+
// 空格
|
|
681
|
+
160,
|
|
682
|
+
// 不间断空格 \u00A0
|
|
683
|
+
65279
|
|
684
|
+
// 零宽无断行空格 \uFEFF
|
|
685
|
+
]);
|
|
686
|
+
function isWhitespace(char) {
|
|
687
|
+
if (char.length === 0) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return WHITESPACE_CODES.has(char.charCodeAt(0));
|
|
691
|
+
}
|
|
22
692
|
|
|
693
|
+
// src/wxml/Tokenizer.ts
|
|
694
|
+
var Tokenizer = class {
|
|
695
|
+
constructor() {
|
|
696
|
+
this.reset();
|
|
697
|
+
}
|
|
698
|
+
processChar(char, index) {
|
|
699
|
+
switch (this.state) {
|
|
700
|
+
case 0 /* START */:
|
|
701
|
+
if (isWhitespace(char)) {
|
|
702
|
+
} else if (char === "{") {
|
|
703
|
+
this.state = 2 /* OPEN_BRACE */;
|
|
704
|
+
this.bufferStartIndex = index;
|
|
705
|
+
this.buffer += char;
|
|
706
|
+
this.expressionBuffer = char;
|
|
707
|
+
this.expressionStartIndex = index;
|
|
708
|
+
} else {
|
|
709
|
+
this.state = 1 /* TEXT */;
|
|
710
|
+
this.bufferStartIndex = index;
|
|
711
|
+
this.buffer += char;
|
|
712
|
+
}
|
|
713
|
+
break;
|
|
714
|
+
case 1 /* TEXT */:
|
|
715
|
+
if (isWhitespace(char)) {
|
|
716
|
+
this.tokens.push({ start: this.bufferStartIndex, end: index, value: this.buffer, expressions: this.expressions });
|
|
717
|
+
this.buffer = "";
|
|
718
|
+
this.expressions = [];
|
|
719
|
+
this.state = 0 /* START */;
|
|
720
|
+
} else if (char === "{") {
|
|
721
|
+
this.buffer += char;
|
|
722
|
+
this.expressionBuffer = char;
|
|
723
|
+
this.expressionStartIndex = index;
|
|
724
|
+
this.state = 2 /* OPEN_BRACE */;
|
|
725
|
+
} else {
|
|
726
|
+
this.buffer += char;
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
729
|
+
case 2 /* OPEN_BRACE */:
|
|
730
|
+
if (char === "}") {
|
|
731
|
+
this.buffer += char;
|
|
732
|
+
this.expressionBuffer += char;
|
|
733
|
+
this.state = 3 /* POTENTIAL_CLOSE */;
|
|
734
|
+
} else {
|
|
735
|
+
this.buffer += char;
|
|
736
|
+
this.expressionBuffer += char;
|
|
737
|
+
}
|
|
738
|
+
break;
|
|
739
|
+
case 3 /* POTENTIAL_CLOSE */:
|
|
740
|
+
if (char === "}") {
|
|
741
|
+
this.buffer += char;
|
|
742
|
+
this.expressionBuffer += char;
|
|
743
|
+
this.expressions.push({
|
|
744
|
+
start: this.expressionStartIndex,
|
|
745
|
+
end: index + 1,
|
|
746
|
+
value: this.expressionBuffer
|
|
747
|
+
});
|
|
748
|
+
this.expressionBuffer = "";
|
|
749
|
+
this.state = 4 /* BRACES_COMPLETE */;
|
|
750
|
+
} else {
|
|
751
|
+
this.buffer += char;
|
|
752
|
+
this.expressionBuffer += char;
|
|
753
|
+
this.state = 2 /* OPEN_BRACE */;
|
|
754
|
+
}
|
|
755
|
+
break;
|
|
756
|
+
case 4 /* BRACES_COMPLETE */:
|
|
757
|
+
if (isWhitespace(char)) {
|
|
758
|
+
this.tokens.push({
|
|
759
|
+
start: this.bufferStartIndex,
|
|
760
|
+
end: index,
|
|
761
|
+
value: this.buffer,
|
|
762
|
+
expressions: this.expressions
|
|
763
|
+
});
|
|
764
|
+
this.buffer = "";
|
|
765
|
+
this.expressions = [];
|
|
766
|
+
this.state = 0 /* START */;
|
|
767
|
+
} else if (char === "{") {
|
|
768
|
+
this.expressionStartIndex = index;
|
|
769
|
+
this.expressionBuffer = char;
|
|
770
|
+
this.buffer += char;
|
|
771
|
+
this.state = 2 /* OPEN_BRACE */;
|
|
772
|
+
} else {
|
|
773
|
+
this.buffer += char;
|
|
774
|
+
this.state = 1 /* TEXT */;
|
|
775
|
+
}
|
|
776
|
+
break;
|
|
777
|
+
default:
|
|
778
|
+
throw new Error("Unexpected state");
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
run(input) {
|
|
782
|
+
this.reset();
|
|
783
|
+
for (let i = 0; i < input.length; i++) {
|
|
784
|
+
const char = input[i];
|
|
785
|
+
this.processChar(char, i);
|
|
786
|
+
}
|
|
787
|
+
if (this.buffer.length > 0) {
|
|
788
|
+
this.tokens.push({
|
|
789
|
+
start: this.bufferStartIndex,
|
|
790
|
+
end: input.length,
|
|
791
|
+
value: this.buffer,
|
|
792
|
+
expressions: this.expressions
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
const tokens = this.tokens;
|
|
796
|
+
this.reset();
|
|
797
|
+
return tokens;
|
|
798
|
+
}
|
|
799
|
+
reset() {
|
|
800
|
+
this.state = 0 /* START */;
|
|
801
|
+
this.buffer = "";
|
|
802
|
+
this.tokens = [];
|
|
803
|
+
this.bufferStartIndex = 0;
|
|
804
|
+
this.expressionBuffer = "";
|
|
805
|
+
this.expressionStartIndex = 0;
|
|
806
|
+
this.expressions = [];
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// src/wxml/utils/template-fragments.ts
|
|
811
|
+
var sharedTokenizer = new Tokenizer();
|
|
812
|
+
|
|
813
|
+
// src/context/logger.ts
|
|
814
|
+
var import_logger7 = require("@weapp-tailwindcss/logger");
|
|
815
|
+
|
|
816
|
+
// src/context/tailwindcss.ts
|
|
817
|
+
var import_logger9 = require("@weapp-tailwindcss/logger");
|
|
818
|
+
|
|
819
|
+
// src/context/tailwindcss/basedir.ts
|
|
820
|
+
var import_node_module2 = require("module");
|
|
821
|
+
var import_node_path10 = __toESM(require("path"));
|
|
822
|
+
var import_node_process9 = __toESM(require("process"));
|
|
823
|
+
var import_node_url2 = require("url");
|
|
824
|
+
var import_logger8 = require("@weapp-tailwindcss/logger");
|
|
825
|
+
|
|
826
|
+
// src/context/tailwindcss/rax.ts
|
|
827
|
+
var import_node_fs6 = require("fs");
|
|
828
|
+
var import_node_path11 = __toESM(require("path"));
|
|
829
|
+
var import_node_process10 = __toESM(require("process"));
|
|
830
|
+
|
|
831
|
+
// src/context/index.ts
|
|
832
|
+
async function clearTailwindcssPatcherCache(patcher, options) {
|
|
833
|
+
if (!patcher) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const cacheOptions = patcher.options?.cache;
|
|
837
|
+
if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (typeof patcher.clearCache === "function") {
|
|
841
|
+
try {
|
|
842
|
+
await patcher.clearCache({ scope: "all" });
|
|
843
|
+
} catch (error) {
|
|
844
|
+
import_logger10.logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (!options?.removeDirectory) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
const cachePaths = /* @__PURE__ */ new Map();
|
|
851
|
+
const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
|
|
852
|
+
if (normalizedCacheOptions?.path) {
|
|
853
|
+
cachePaths.set(normalizedCacheOptions.path, false);
|
|
854
|
+
}
|
|
855
|
+
const privateCachePath = patcher?.cacheStore?.options?.path;
|
|
856
|
+
if (privateCachePath) {
|
|
857
|
+
cachePaths.set(privateCachePath, false);
|
|
858
|
+
}
|
|
859
|
+
if (options?.removeDirectory && normalizedCacheOptions?.dir) {
|
|
860
|
+
cachePaths.set(normalizedCacheOptions.dir, true);
|
|
861
|
+
}
|
|
862
|
+
if (!cachePaths.size) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
for (const [cachePath, recursive] of cachePaths.entries()) {
|
|
866
|
+
try {
|
|
867
|
+
await (0, import_promises2.rm)(cachePath, { force: true, recursive });
|
|
868
|
+
} catch (error) {
|
|
869
|
+
const err = error;
|
|
870
|
+
if (err?.code === "ENOENT") {
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
import_logger10.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// src/cli/context.ts
|
|
23
879
|
function formatOutputPath(target, baseDir) {
|
|
24
|
-
const root =
|
|
25
|
-
const relative =
|
|
880
|
+
const root = baseDir ?? import_node_process11.default.cwd();
|
|
881
|
+
const relative = import_node_path12.default.relative(root, target);
|
|
26
882
|
if (!relative) {
|
|
27
883
|
return ".";
|
|
28
884
|
}
|
|
29
885
|
if (relative.startsWith("..")) {
|
|
30
|
-
return
|
|
886
|
+
return import_node_path12.default.normalize(target);
|
|
31
887
|
}
|
|
32
|
-
return relative.startsWith(".") ? relative : `.${
|
|
888
|
+
return relative.startsWith(".") ? relative : `.${import_node_path12.default.sep}${relative}`;
|
|
33
889
|
}
|
|
34
890
|
|
|
35
891
|
// src/cli/helpers.ts
|
|
36
|
-
var
|
|
892
|
+
var import_promises3 = require("fs/promises");
|
|
893
|
+
var import_node_process14 = __toESM(require("process"));
|
|
37
894
|
|
|
895
|
+
// src/logger/index.ts
|
|
896
|
+
var import_logger12 = require("@weapp-tailwindcss/logger");
|
|
38
897
|
|
|
39
898
|
// src/cli/helpers/options/parse.ts
|
|
40
899
|
function readStringOption(flag, value) {
|
|
@@ -89,24 +948,24 @@ function toBoolean(value, fallback) {
|
|
|
89
948
|
}
|
|
90
949
|
|
|
91
950
|
// src/cli/helpers/options/resolve.ts
|
|
92
|
-
|
|
93
|
-
|
|
951
|
+
var import_node_path13 = __toESM(require("path"));
|
|
952
|
+
var import_node_process12 = __toESM(require("process"));
|
|
94
953
|
function resolveCliCwd(value) {
|
|
95
954
|
const raw = readStringOption("cwd", value);
|
|
96
955
|
if (!raw) {
|
|
97
956
|
return void 0;
|
|
98
957
|
}
|
|
99
|
-
return
|
|
958
|
+
return import_node_path13.default.isAbsolute(raw) ? import_node_path13.default.normalize(raw) : import_node_path13.default.resolve(import_node_process12.default.cwd(), raw);
|
|
100
959
|
}
|
|
101
960
|
|
|
102
961
|
// src/cli/helpers/patch-cwd.ts
|
|
103
|
-
|
|
104
|
-
|
|
962
|
+
var import_node_path14 = __toESM(require("path"));
|
|
963
|
+
var import_node_process13 = __toESM(require("process"));
|
|
105
964
|
|
|
106
965
|
// src/tailwindcss/index.ts
|
|
107
|
-
var
|
|
966
|
+
var import_local_pkg = require("local-pkg");
|
|
108
967
|
function getTailwindcssPackageInfo(options) {
|
|
109
|
-
return
|
|
968
|
+
return (0, import_local_pkg.getPackageInfoSync)("tailwindcss", options);
|
|
110
969
|
}
|
|
111
970
|
|
|
112
971
|
// src/cli/helpers/patch-cwd.ts
|
|
@@ -114,29 +973,29 @@ function normalizeCandidatePath(baseDir, candidate) {
|
|
|
114
973
|
if (!candidate) {
|
|
115
974
|
return void 0;
|
|
116
975
|
}
|
|
117
|
-
return
|
|
976
|
+
return import_node_path14.default.isAbsolute(candidate) ? import_node_path14.default.normalize(candidate) : import_node_path14.default.resolve(baseDir, candidate);
|
|
118
977
|
}
|
|
119
978
|
function detectTailwindWorkspace(paths) {
|
|
120
979
|
for (const candidate of paths) {
|
|
121
980
|
try {
|
|
122
981
|
const info = getTailwindcssPackageInfo({ paths: [candidate] });
|
|
123
|
-
if (
|
|
982
|
+
if (info?.rootPath) {
|
|
124
983
|
return candidate;
|
|
125
984
|
}
|
|
126
|
-
} catch
|
|
985
|
+
} catch {
|
|
127
986
|
}
|
|
128
987
|
}
|
|
129
988
|
return void 0;
|
|
130
989
|
}
|
|
131
|
-
function resolvePatchDefaultCwd(currentCwd =
|
|
132
|
-
const baseDir =
|
|
133
|
-
const explicitCwd = normalizeCandidatePath(baseDir,
|
|
990
|
+
function resolvePatchDefaultCwd(currentCwd = import_node_process13.default.cwd()) {
|
|
991
|
+
const baseDir = import_node_path14.default.normalize(currentCwd);
|
|
992
|
+
const explicitCwd = normalizeCandidatePath(baseDir, import_node_process13.default.env.WEAPP_TW_PATCH_CWD);
|
|
134
993
|
if (explicitCwd) {
|
|
135
994
|
return explicitCwd;
|
|
136
995
|
}
|
|
137
|
-
const workspaceRoot =
|
|
138
|
-
const initCwd = normalizeCandidatePath(baseDir,
|
|
139
|
-
const localPrefix = normalizeCandidatePath(baseDir,
|
|
996
|
+
const workspaceRoot = findWorkspaceRoot(baseDir);
|
|
997
|
+
const initCwd = normalizeCandidatePath(baseDir, import_node_process13.default.env.INIT_CWD);
|
|
998
|
+
const localPrefix = normalizeCandidatePath(baseDir, import_node_process13.default.env.npm_config_local_prefix);
|
|
140
999
|
const candidates = [
|
|
141
1000
|
baseDir,
|
|
142
1001
|
workspaceRoot,
|
|
@@ -147,21 +1006,21 @@ function resolvePatchDefaultCwd(currentCwd = _process2.default.cwd()) {
|
|
|
147
1006
|
if (detected) {
|
|
148
1007
|
return detected;
|
|
149
1008
|
}
|
|
150
|
-
return
|
|
1009
|
+
return initCwd ?? localPrefix ?? workspaceRoot ?? baseDir;
|
|
151
1010
|
}
|
|
152
1011
|
|
|
153
1012
|
// src/cli/helpers.ts
|
|
154
1013
|
async function ensureDir(dir) {
|
|
155
|
-
await
|
|
1014
|
+
await (0, import_promises3.mkdir)(dir, { recursive: true });
|
|
156
1015
|
}
|
|
157
1016
|
function handleCliError(error) {
|
|
158
1017
|
if (error instanceof Error) {
|
|
159
|
-
|
|
160
|
-
if (error.stack &&
|
|
161
|
-
|
|
1018
|
+
import_logger12.logger.error(error.message);
|
|
1019
|
+
if (error.stack && import_node_process14.default.env.WEAPP_TW_DEBUG === "1") {
|
|
1020
|
+
import_logger12.logger.error(error.stack);
|
|
162
1021
|
}
|
|
163
1022
|
} else {
|
|
164
|
-
|
|
1023
|
+
import_logger12.logger.error(String(error));
|
|
165
1024
|
}
|
|
166
1025
|
}
|
|
167
1026
|
function commandAction(handler) {
|
|
@@ -170,17 +1029,17 @@ function commandAction(handler) {
|
|
|
170
1029
|
await handler(...args);
|
|
171
1030
|
} catch (error) {
|
|
172
1031
|
handleCliError(error);
|
|
173
|
-
|
|
1032
|
+
import_node_process14.default.exitCode = 1;
|
|
174
1033
|
}
|
|
175
1034
|
};
|
|
176
1035
|
}
|
|
177
1036
|
|
|
178
1037
|
// src/cli/mount-options.ts
|
|
179
|
-
|
|
1038
|
+
var import_node_process16 = __toESM(require("process"));
|
|
180
1039
|
|
|
181
1040
|
// src/cli/mount-options/patch-status.ts
|
|
182
1041
|
function formatStatusFilesHint(files) {
|
|
183
|
-
if (!
|
|
1042
|
+
if (!files?.length) {
|
|
184
1043
|
return "";
|
|
185
1044
|
}
|
|
186
1045
|
return ` (${files.join(", ")})`;
|
|
@@ -191,28 +1050,28 @@ function logPatchStatusReport(report) {
|
|
|
191
1050
|
const skipped = report.entries.filter(
|
|
192
1051
|
(entry) => entry.status === "skipped" || entry.status === "unsupported"
|
|
193
1052
|
);
|
|
194
|
-
const packageLabel = `${
|
|
195
|
-
|
|
1053
|
+
const packageLabel = `${report.package.name ?? "tailwindcss"}@${report.package.version ?? "unknown"}`;
|
|
1054
|
+
import_logger12.logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`);
|
|
196
1055
|
if (applied.length) {
|
|
197
|
-
|
|
1056
|
+
import_logger12.logger.success("Applied:");
|
|
198
1057
|
applied.forEach((entry) => {
|
|
199
|
-
|
|
1058
|
+
import_logger12.logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`);
|
|
200
1059
|
});
|
|
201
1060
|
}
|
|
202
1061
|
if (pending.length) {
|
|
203
|
-
|
|
1062
|
+
import_logger12.logger.warn("Needs attention:");
|
|
204
1063
|
pending.forEach((entry) => {
|
|
205
1064
|
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
206
|
-
|
|
1065
|
+
import_logger12.logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`);
|
|
207
1066
|
});
|
|
208
1067
|
} else {
|
|
209
|
-
|
|
1068
|
+
import_logger12.logger.success("All applicable patches are applied.");
|
|
210
1069
|
}
|
|
211
1070
|
if (skipped.length) {
|
|
212
|
-
|
|
1071
|
+
import_logger12.logger.info("Skipped:");
|
|
213
1072
|
skipped.forEach((entry) => {
|
|
214
1073
|
const details = entry.reason ? ` - ${entry.reason}` : "";
|
|
215
|
-
|
|
1074
|
+
import_logger12.logger.info(` - ${entry.name}${details}`);
|
|
216
1075
|
});
|
|
217
1076
|
}
|
|
218
1077
|
}
|
|
@@ -224,13 +1083,13 @@ var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = {
|
|
|
224
1083
|
overwrite: true
|
|
225
1084
|
};
|
|
226
1085
|
function withDefaultExtendLengthUnits(options) {
|
|
227
|
-
const normalized =
|
|
228
|
-
const extendLengthUnits =
|
|
1086
|
+
const normalized = options ?? {};
|
|
1087
|
+
const extendLengthUnits = normalized.apply?.extendLengthUnits;
|
|
229
1088
|
if (extendLengthUnits == null) {
|
|
230
1089
|
return {
|
|
231
1090
|
...normalized,
|
|
232
1091
|
apply: {
|
|
233
|
-
...
|
|
1092
|
+
...normalized.apply ?? {},
|
|
234
1093
|
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
235
1094
|
}
|
|
236
1095
|
};
|
|
@@ -238,11 +1097,11 @@ function withDefaultExtendLengthUnits(options) {
|
|
|
238
1097
|
return normalized;
|
|
239
1098
|
}
|
|
240
1099
|
function buildExtendLengthUnitsOverride(options) {
|
|
241
|
-
const extendLengthUnits =
|
|
1100
|
+
const extendLengthUnits = options?.apply?.extendLengthUnits;
|
|
242
1101
|
if (extendLengthUnits == null) {
|
|
243
1102
|
return {
|
|
244
1103
|
apply: {
|
|
245
|
-
...
|
|
1104
|
+
...options?.apply ?? {},
|
|
246
1105
|
extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE
|
|
247
1106
|
}
|
|
248
1107
|
};
|
|
@@ -251,35 +1110,35 @@ function buildExtendLengthUnitsOverride(options) {
|
|
|
251
1110
|
}
|
|
252
1111
|
|
|
253
1112
|
// src/cli/workspace.ts
|
|
254
|
-
|
|
255
|
-
|
|
1113
|
+
var import_node_path19 = __toESM(require("path"));
|
|
1114
|
+
var import_node_process15 = __toESM(require("process"));
|
|
256
1115
|
|
|
257
1116
|
// src/cli/workspace/package-dirs.ts
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
var
|
|
1117
|
+
var import_node_fs10 = require("fs");
|
|
1118
|
+
var import_node_path17 = __toESM(require("path"));
|
|
1119
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
261
1120
|
|
|
262
1121
|
// src/cli/workspace/workspace-globs.ts
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
var
|
|
1122
|
+
var import_node_fs8 = require("fs");
|
|
1123
|
+
var import_node_path15 = __toESM(require("path"));
|
|
1124
|
+
var import_yaml = require("yaml");
|
|
266
1125
|
|
|
267
1126
|
// src/cli/workspace/workspace-io.ts
|
|
268
|
-
|
|
1127
|
+
var import_node_fs7 = require("fs");
|
|
269
1128
|
function tryReadJson(file) {
|
|
270
1129
|
try {
|
|
271
|
-
const content =
|
|
1130
|
+
const content = (0, import_node_fs7.readFileSync)(file, "utf8");
|
|
272
1131
|
return JSON.parse(content);
|
|
273
|
-
} catch
|
|
1132
|
+
} catch {
|
|
274
1133
|
return void 0;
|
|
275
1134
|
}
|
|
276
1135
|
}
|
|
277
1136
|
|
|
278
1137
|
// src/cli/workspace/workspace-globs.ts
|
|
279
1138
|
function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
280
|
-
const pkgJsonPath =
|
|
1139
|
+
const pkgJsonPath = import_node_path15.default.join(workspaceRoot, "package.json");
|
|
281
1140
|
const pkg = tryReadJson(pkgJsonPath);
|
|
282
|
-
if (!
|
|
1141
|
+
if (!pkg?.workspaces) {
|
|
283
1142
|
return [];
|
|
284
1143
|
}
|
|
285
1144
|
if (Array.isArray(pkg.workspaces)) {
|
|
@@ -291,30 +1150,30 @@ function parseWorkspaceGlobsFromPackageJson(workspaceRoot) {
|
|
|
291
1150
|
return [];
|
|
292
1151
|
}
|
|
293
1152
|
function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) {
|
|
294
|
-
const workspaceFile =
|
|
295
|
-
if (!
|
|
1153
|
+
const workspaceFile = import_node_path15.default.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
1154
|
+
if (!(0, import_node_fs8.existsSync)(workspaceFile)) {
|
|
296
1155
|
return [];
|
|
297
1156
|
}
|
|
298
1157
|
try {
|
|
299
|
-
const parsed =
|
|
300
|
-
return Array.isArray(
|
|
301
|
-
} catch
|
|
1158
|
+
const parsed = (0, import_yaml.parse)((0, import_node_fs8.readFileSync)(workspaceFile, "utf8"));
|
|
1159
|
+
return Array.isArray(parsed?.packages) ? parsed.packages.filter(Boolean) : [];
|
|
1160
|
+
} catch {
|
|
302
1161
|
return [];
|
|
303
1162
|
}
|
|
304
1163
|
}
|
|
305
1164
|
|
|
306
1165
|
// src/cli/workspace/workspace-lock.ts
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
1166
|
+
var import_node_fs9 = require("fs");
|
|
1167
|
+
var import_node_path16 = __toESM(require("path"));
|
|
1168
|
+
var import_yaml2 = require("yaml");
|
|
310
1169
|
function parseImportersFromLock(workspaceRoot) {
|
|
311
|
-
const lockPath =
|
|
312
|
-
if (!
|
|
1170
|
+
const lockPath = import_node_path16.default.join(workspaceRoot, "pnpm-lock.yaml");
|
|
1171
|
+
if (!(0, import_node_fs9.existsSync)(lockPath)) {
|
|
313
1172
|
return [];
|
|
314
1173
|
}
|
|
315
1174
|
try {
|
|
316
|
-
const parsed =
|
|
317
|
-
const importers =
|
|
1175
|
+
const parsed = (0, import_yaml2.parse)((0, import_node_fs9.readFileSync)(lockPath, "utf8"));
|
|
1176
|
+
const importers = parsed?.importers;
|
|
318
1177
|
if (!importers) {
|
|
319
1178
|
return [];
|
|
320
1179
|
}
|
|
@@ -322,9 +1181,9 @@ function parseImportersFromLock(workspaceRoot) {
|
|
|
322
1181
|
if (!key || key === ".") {
|
|
323
1182
|
return workspaceRoot;
|
|
324
1183
|
}
|
|
325
|
-
return
|
|
1184
|
+
return import_node_path16.default.join(workspaceRoot, key);
|
|
326
1185
|
});
|
|
327
|
-
} catch
|
|
1186
|
+
} catch {
|
|
328
1187
|
return [];
|
|
329
1188
|
}
|
|
330
1189
|
}
|
|
@@ -335,7 +1194,7 @@ var TRAILING_SLASH_RE = /\/+$/;
|
|
|
335
1194
|
async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
336
1195
|
const dirs = /* @__PURE__ */ new Set();
|
|
337
1196
|
for (const importerDir of parseImportersFromLock(workspaceRoot)) {
|
|
338
|
-
dirs.add(
|
|
1197
|
+
dirs.add(import_node_path17.default.normalize(importerDir));
|
|
339
1198
|
}
|
|
340
1199
|
if (!dirs.size) {
|
|
341
1200
|
let globs = parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot);
|
|
@@ -347,7 +1206,7 @@ async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
|
347
1206
|
const normalized = pattern.replace(BACKSLASH_RE, "/").replace(TRAILING_SLASH_RE, "");
|
|
348
1207
|
return normalized.endsWith("package.json") ? normalized : `${normalized}/package.json`;
|
|
349
1208
|
});
|
|
350
|
-
const packageJsonFiles = await
|
|
1209
|
+
const packageJsonFiles = await (0, import_fast_glob.default)(patterns, {
|
|
351
1210
|
cwd: workspaceRoot,
|
|
352
1211
|
absolute: true,
|
|
353
1212
|
onlyFiles: true,
|
|
@@ -355,47 +1214,47 @@ async function resolveWorkspacePackageDirs(workspaceRoot) {
|
|
|
355
1214
|
ignore: ["**/node_modules/**", "**/.git/**"]
|
|
356
1215
|
});
|
|
357
1216
|
for (const file of packageJsonFiles) {
|
|
358
|
-
dirs.add(
|
|
1217
|
+
dirs.add(import_node_path17.default.normalize(import_node_path17.default.dirname(file)));
|
|
359
1218
|
}
|
|
360
1219
|
}
|
|
361
1220
|
}
|
|
362
|
-
const rootPkg =
|
|
363
|
-
if (
|
|
364
|
-
dirs.add(
|
|
1221
|
+
const rootPkg = import_node_path17.default.join(workspaceRoot, "package.json");
|
|
1222
|
+
if ((0, import_node_fs10.existsSync)(rootPkg)) {
|
|
1223
|
+
dirs.add(import_node_path17.default.normalize(workspaceRoot));
|
|
365
1224
|
}
|
|
366
1225
|
return [...dirs];
|
|
367
1226
|
}
|
|
368
1227
|
|
|
369
1228
|
// src/cli/workspace/patch-package.ts
|
|
370
|
-
|
|
1229
|
+
var import_tailwindcss_patch2 = require("tailwindcss-patch");
|
|
371
1230
|
|
|
372
1231
|
// src/cli/workspace/patch-utils.ts
|
|
373
|
-
|
|
1232
|
+
var import_node_path18 = __toESM(require("path"));
|
|
374
1233
|
function formatDisplayName(workspaceRoot, dir, name) {
|
|
375
|
-
const relative =
|
|
1234
|
+
const relative = import_node_path18.default.relative(workspaceRoot, dir) || ".";
|
|
376
1235
|
return name ? `${name} (${relative})` : relative;
|
|
377
1236
|
}
|
|
378
1237
|
function summarizeWorkspaceResults(results) {
|
|
379
1238
|
const patched = results.filter((result) => result.status === "patched").length;
|
|
380
1239
|
const skipped = results.filter((result) => result.status === "skipped").length;
|
|
381
1240
|
const failed = results.filter((result) => result.status === "failed").length;
|
|
382
|
-
|
|
1241
|
+
import_logger12.logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed);
|
|
383
1242
|
}
|
|
384
1243
|
|
|
385
1244
|
// src/cli/workspace/patch-package.ts
|
|
386
1245
|
function createWorkspacePatcher(cwd) {
|
|
387
|
-
const normalized =
|
|
1246
|
+
const normalized = (0, import_tailwindcss_patch2.normalizeOptions)(
|
|
388
1247
|
withDefaultExtendLengthUnits({
|
|
389
1248
|
projectRoot: cwd
|
|
390
1249
|
})
|
|
391
1250
|
);
|
|
392
|
-
return new
|
|
1251
|
+
return new import_tailwindcss_patch2.TailwindcssPatcher(normalized);
|
|
393
1252
|
}
|
|
394
1253
|
async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
395
1254
|
const displayName = formatDisplayName(workspaceRoot, dir, pkgName);
|
|
396
1255
|
const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] });
|
|
397
|
-
if (!
|
|
398
|
-
|
|
1256
|
+
if (!tailwindInfo?.rootPath) {
|
|
1257
|
+
import_logger12.logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName);
|
|
399
1258
|
return {
|
|
400
1259
|
dir,
|
|
401
1260
|
name: pkgName,
|
|
@@ -406,23 +1265,23 @@ async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
|
406
1265
|
try {
|
|
407
1266
|
const patcher = createWorkspacePatcher(dir);
|
|
408
1267
|
if (options.clearCache) {
|
|
409
|
-
await
|
|
1268
|
+
await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
410
1269
|
}
|
|
411
|
-
const recorder =
|
|
1270
|
+
const recorder = createPatchTargetRecorder(dir, patcher, {
|
|
412
1271
|
source: "cli",
|
|
413
1272
|
cwd: dir,
|
|
414
1273
|
recordTarget: options.recordTarget !== false,
|
|
415
1274
|
alwaysRecord: true
|
|
416
1275
|
});
|
|
417
|
-
if (
|
|
418
|
-
|
|
1276
|
+
if (recorder?.message) {
|
|
1277
|
+
import_logger12.logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
419
1278
|
}
|
|
420
|
-
|
|
1279
|
+
logTailwindcssTarget("cli", patcher, dir);
|
|
421
1280
|
await patcher.patch();
|
|
422
|
-
if (
|
|
1281
|
+
if (recorder?.onPatched) {
|
|
423
1282
|
await recorder.onPatched();
|
|
424
1283
|
}
|
|
425
|
-
|
|
1284
|
+
import_logger12.logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName);
|
|
426
1285
|
return {
|
|
427
1286
|
dir,
|
|
428
1287
|
name: pkgName,
|
|
@@ -433,7 +1292,7 @@ async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
|
433
1292
|
const reason = error instanceof Error ? error.message : String(error);
|
|
434
1293
|
const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`;
|
|
435
1294
|
const message = `${reason}\uFF0C${suggestion}`;
|
|
436
|
-
|
|
1295
|
+
import_logger12.logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message);
|
|
437
1296
|
return {
|
|
438
1297
|
dir,
|
|
439
1298
|
name: pkgName,
|
|
@@ -445,18 +1304,18 @@ async function patchWorkspacePackage(workspaceRoot, dir, pkgName, options) {
|
|
|
445
1304
|
|
|
446
1305
|
// src/cli/workspace.ts
|
|
447
1306
|
async function patchWorkspace(options) {
|
|
448
|
-
const cwd =
|
|
449
|
-
const workspaceRoot =
|
|
1307
|
+
const cwd = options.cwd ?? import_node_process15.default.cwd();
|
|
1308
|
+
const workspaceRoot = findWorkspaceRoot(cwd) ?? cwd;
|
|
450
1309
|
const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot);
|
|
451
1310
|
if (packageDirs.length === 0) {
|
|
452
|
-
|
|
1311
|
+
import_logger12.logger.warn("\u672A\u5728 %s \u68C0\u6D4B\u5230 workspace \u5305\uFF0C\u5DF2\u8DF3\u8FC7\u6279\u91CF patch\u3002", workspaceRoot);
|
|
453
1312
|
return;
|
|
454
1313
|
}
|
|
455
1314
|
const results = [];
|
|
456
1315
|
for (const dir of packageDirs) {
|
|
457
|
-
const pkgJsonPath =
|
|
1316
|
+
const pkgJsonPath = import_node_path19.default.join(dir, "package.json");
|
|
458
1317
|
const pkgJson = tryReadJson(pkgJsonPath);
|
|
459
|
-
results.push(await patchWorkspacePackage(workspaceRoot, dir,
|
|
1318
|
+
results.push(await patchWorkspacePackage(workspaceRoot, dir, pkgJson?.name, options));
|
|
460
1319
|
}
|
|
461
1320
|
summarizeWorkspaceResults(results);
|
|
462
1321
|
}
|
|
@@ -464,12 +1323,12 @@ async function patchWorkspace(options) {
|
|
|
464
1323
|
// src/cli/mount-options.ts
|
|
465
1324
|
function handleCliError2(error) {
|
|
466
1325
|
if (error instanceof Error) {
|
|
467
|
-
|
|
468
|
-
if (error.stack &&
|
|
469
|
-
|
|
1326
|
+
import_logger12.logger.error(error.message);
|
|
1327
|
+
if (error.stack && import_node_process16.default.env.WEAPP_TW_DEBUG === "1") {
|
|
1328
|
+
import_logger12.logger.error(error.stack);
|
|
470
1329
|
}
|
|
471
1330
|
} else {
|
|
472
|
-
|
|
1331
|
+
import_logger12.logger.error(String(error));
|
|
473
1332
|
}
|
|
474
1333
|
}
|
|
475
1334
|
function withCommandErrorHandling(handler) {
|
|
@@ -478,7 +1337,7 @@ function withCommandErrorHandling(handler) {
|
|
|
478
1337
|
return await handler(ctx, next);
|
|
479
1338
|
} catch (error) {
|
|
480
1339
|
handleCliError2(error);
|
|
481
|
-
|
|
1340
|
+
import_node_process16.default.exitCode = 1;
|
|
482
1341
|
return void 0;
|
|
483
1342
|
}
|
|
484
1343
|
});
|
|
@@ -548,26 +1407,26 @@ var mountOptions = {
|
|
|
548
1407
|
}
|
|
549
1408
|
const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
|
|
550
1409
|
if (shouldClearCache) {
|
|
551
|
-
await
|
|
1410
|
+
await clearTailwindcssPatcherCache(patcher, { removeDirectory: true });
|
|
552
1411
|
}
|
|
553
|
-
const recorder =
|
|
1412
|
+
const recorder = createPatchTargetRecorder(ctx.cwd, patcher, {
|
|
554
1413
|
source: "cli",
|
|
555
1414
|
cwd: ctx.cwd,
|
|
556
1415
|
recordTarget: shouldRecordTarget,
|
|
557
1416
|
alwaysRecord: true
|
|
558
1417
|
});
|
|
559
|
-
if (
|
|
560
|
-
|
|
1418
|
+
if (recorder?.message) {
|
|
1419
|
+
import_logger12.logger.info(recorder.message);
|
|
561
1420
|
}
|
|
562
|
-
|
|
1421
|
+
logTailwindcssTarget("cli", patcher, ctx.cwd);
|
|
563
1422
|
await patcher.patch();
|
|
564
|
-
if (
|
|
1423
|
+
if (recorder?.onPatched) {
|
|
565
1424
|
const recordPath = await recorder.onPatched();
|
|
566
1425
|
if (recordPath) {
|
|
567
|
-
|
|
1426
|
+
import_logger12.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, ctx.cwd)}`);
|
|
568
1427
|
}
|
|
569
1428
|
}
|
|
570
|
-
|
|
1429
|
+
import_logger12.logger.success("Tailwind CSS \u8FD0\u884C\u65F6\u8865\u4E01\u5DF2\u5B8C\u6210\u3002");
|
|
571
1430
|
}),
|
|
572
1431
|
extract: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
573
1432
|
tokens: withCommandErrorHandling(async (_ctx, next) => next()),
|
|
@@ -576,7 +1435,7 @@ var mountOptions = {
|
|
|
576
1435
|
const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
|
|
577
1436
|
const report = await patcher.getPatchStatus();
|
|
578
1437
|
if (ctx.args.json) {
|
|
579
|
-
|
|
1438
|
+
import_logger12.logger.log(JSON.stringify(report, null, 2));
|
|
580
1439
|
return report;
|
|
581
1440
|
}
|
|
582
1441
|
logPatchStatusReport(report);
|
|
@@ -586,9 +1445,9 @@ var mountOptions = {
|
|
|
586
1445
|
};
|
|
587
1446
|
|
|
588
1447
|
// src/cli/vscode-entry.ts
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
1448
|
+
var import_node_fs11 = require("fs");
|
|
1449
|
+
var import_promises4 = require("fs/promises");
|
|
1450
|
+
var import_node_path20 = __toESM(require("path"));
|
|
592
1451
|
var DEFAULT_VSCODE_ENTRY_OUTPUT = ".vscode/weapp-tailwindcss.intellisense.css";
|
|
593
1452
|
var DEFAULT_VSCODE_SOURCES = [
|
|
594
1453
|
'not "./dist"',
|
|
@@ -605,10 +1464,10 @@ function toPosixPath(filepath) {
|
|
|
605
1464
|
}
|
|
606
1465
|
async function assertFileExists(filepath) {
|
|
607
1466
|
try {
|
|
608
|
-
await
|
|
1467
|
+
await (0, import_promises4.access)(filepath, import_node_fs11.constants.F_OK);
|
|
609
1468
|
} catch (error) {
|
|
610
1469
|
const err = error;
|
|
611
|
-
if (
|
|
1470
|
+
if (err?.code === "ENOENT") {
|
|
612
1471
|
throw new Error(`CSS entry file not found: ${filepath}`);
|
|
613
1472
|
}
|
|
614
1473
|
throw err;
|
|
@@ -616,7 +1475,7 @@ async function assertFileExists(filepath) {
|
|
|
616
1475
|
}
|
|
617
1476
|
async function assertCanWrite(filepath, force) {
|
|
618
1477
|
try {
|
|
619
|
-
await
|
|
1478
|
+
await (0, import_promises4.access)(filepath, import_node_fs11.constants.F_OK);
|
|
620
1479
|
if (!force) {
|
|
621
1480
|
throw new Error(
|
|
622
1481
|
`VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.`
|
|
@@ -624,7 +1483,7 @@ async function assertCanWrite(filepath, force) {
|
|
|
624
1483
|
}
|
|
625
1484
|
} catch (error) {
|
|
626
1485
|
const err = error;
|
|
627
|
-
if (
|
|
1486
|
+
if (err?.code === "ENOENT") {
|
|
628
1487
|
return;
|
|
629
1488
|
}
|
|
630
1489
|
throw err;
|
|
@@ -660,17 +1519,17 @@ function formatSource(pattern) {
|
|
|
660
1519
|
return `@source ${keyword}${body};`;
|
|
661
1520
|
}
|
|
662
1521
|
function resolveOutputPath(baseDir, output) {
|
|
663
|
-
const target =
|
|
664
|
-
return
|
|
1522
|
+
const target = output ?? DEFAULT_VSCODE_ENTRY_OUTPUT;
|
|
1523
|
+
return import_node_path20.default.isAbsolute(target) ? import_node_path20.default.normalize(target) : import_node_path20.default.resolve(baseDir, target);
|
|
665
1524
|
}
|
|
666
1525
|
function resolveCssEntry(baseDir, entry) {
|
|
667
|
-
return
|
|
1526
|
+
return import_node_path20.default.isAbsolute(entry) ? import_node_path20.default.normalize(entry) : import_node_path20.default.resolve(baseDir, entry);
|
|
668
1527
|
}
|
|
669
1528
|
function toRelativeImport(fromFile, targetFile) {
|
|
670
|
-
const fromDir =
|
|
671
|
-
let relative =
|
|
1529
|
+
const fromDir = import_node_path20.default.dirname(fromFile);
|
|
1530
|
+
let relative = import_node_path20.default.relative(fromDir, targetFile);
|
|
672
1531
|
if (!relative) {
|
|
673
|
-
relative =
|
|
1532
|
+
relative = import_node_path20.default.basename(targetFile);
|
|
674
1533
|
}
|
|
675
1534
|
if (!relative.startsWith(".")) {
|
|
676
1535
|
relative = `./${relative}`;
|
|
@@ -682,7 +1541,7 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
682
1541
|
const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry);
|
|
683
1542
|
await assertFileExists(cssEntryPath);
|
|
684
1543
|
const outputPath = resolveOutputPath(baseDir, options.output);
|
|
685
|
-
await ensureDir(
|
|
1544
|
+
await ensureDir(import_node_path20.default.dirname(outputPath));
|
|
686
1545
|
await assertCanWrite(outputPath, options.force);
|
|
687
1546
|
const sources = options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES;
|
|
688
1547
|
const formattedSources = sources.map(formatSource).filter((statement) => Boolean(statement));
|
|
@@ -701,26 +1560,26 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
701
1560
|
`@import '${cssImport}';`,
|
|
702
1561
|
""
|
|
703
1562
|
].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n");
|
|
704
|
-
await
|
|
1563
|
+
await (0, import_promises4.writeFile)(outputPath, `${content}
|
|
705
1564
|
`, "utf8");
|
|
706
1565
|
return { outputPath, cssEntryPath };
|
|
707
1566
|
}
|
|
708
1567
|
|
|
709
1568
|
// src/cli.ts
|
|
710
|
-
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
`You are using Node.js ${
|
|
1569
|
+
import_node_process17.default.title = "node (weapp-tailwindcss)";
|
|
1570
|
+
if (import_semver.default.lt(import_node_process17.default.versions.node, WEAPP_TW_REQUIRED_NODE_VERSION)) {
|
|
1571
|
+
import_logger12.logger.warn(
|
|
1572
|
+
`You are using Node.js ${import_node_process17.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
|
|
714
1573
|
);
|
|
715
1574
|
}
|
|
716
|
-
var cli =
|
|
1575
|
+
var cli = (0, import_tailwindcss_patch3.createTailwindcssPatchCli)({
|
|
717
1576
|
name: "weapp-tailwindcss",
|
|
718
1577
|
mountOptions
|
|
719
1578
|
});
|
|
720
1579
|
cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliSense").option("--cwd <dir>", "Working directory").option("--css <file>", "Path to the CSS file that imports weapp-tailwindcss (required)").option("--output <file>", `Helper output path. Defaults to ${DEFAULT_VSCODE_ENTRY_OUTPUT}`).option("--source <pattern>", "Additional @source glob (can be repeated)").option("--force", "Overwrite the helper file when it already exists").action(
|
|
721
1580
|
commandAction(async (options) => {
|
|
722
1581
|
const resolvedCwd = resolveCliCwd(options.cwd);
|
|
723
|
-
const baseDir =
|
|
1582
|
+
const baseDir = resolvedCwd ?? import_node_process17.default.cwd();
|
|
724
1583
|
const cssEntry = readStringOption("css", options.css);
|
|
725
1584
|
if (!cssEntry) {
|
|
726
1585
|
throw new Error('Option "--css" is required.');
|
|
@@ -735,11 +1594,11 @@ cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliS
|
|
|
735
1594
|
sources,
|
|
736
1595
|
force
|
|
737
1596
|
});
|
|
738
|
-
|
|
1597
|
+
import_logger12.logger.success(
|
|
739
1598
|
`VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}`
|
|
740
1599
|
);
|
|
741
1600
|
})
|
|
742
1601
|
);
|
|
743
1602
|
cli.help();
|
|
744
|
-
cli.version(
|
|
1603
|
+
cli.version(import_node_process17.default.env.npm_package_version ?? "0.0.0");
|
|
745
1604
|
cli.parse();
|