weapp-tailwindcss 4.8.4 → 4.8.5
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-7KTLLGAG.mjs → chunk-3XGTIDA6.mjs} +72 -49
- package/dist/{chunk-JMYADIPN.mjs → chunk-67CD2S5L.mjs} +1 -1
- package/dist/{chunk-6EATUPTN.js → chunk-6CS6EPEP.js} +27 -20
- package/dist/{chunk-K234IGOT.js → chunk-AB45L5FP.js} +2 -2
- package/dist/{chunk-IHJU6M6B.mjs → chunk-FE63QKGM.mjs} +13 -6
- package/dist/chunk-FVSKLXO5.js +29 -0
- package/dist/{chunk-WTOLVORM.mjs → chunk-K62QTSOE.mjs} +389 -52
- package/dist/{chunk-NLLCK6RM.mjs → chunk-OKBZMEXY.mjs} +11 -4
- package/dist/{chunk-AXEKXGG7.js → chunk-P6ACVBPQ.js} +427 -90
- package/dist/{chunk-KSHK56CW.mjs → chunk-PSYJXCQJ.mjs} +1 -1
- package/dist/{chunk-MG4O3AGN.js → chunk-RA4QKEFU.js} +14 -7
- package/dist/{chunk-ZXU4EYKV.js → chunk-RJRLVYVJ.js} +77 -54
- package/dist/{chunk-5P342MNS.js → chunk-RXCVTHDO.js} +52 -39
- package/dist/chunk-SFQCTDJA.mjs +29 -0
- package/dist/{chunk-47NJZTIW.js → chunk-TWBCI2I3.js} +5 -5
- package/dist/{chunk-WGLBMNPG.js → chunk-UTZLVU3M.js} +1 -1
- package/dist/{chunk-UUVGNRUM.mjs → chunk-WSMJXGQQ.mjs} +36 -23
- package/dist/cli.js +217 -20
- package/dist/cli.mjs +215 -18
- package/dist/core.js +19 -11
- package/dist/core.mjs +14 -6
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -5
- package/dist/gulp.mjs +5 -4
- package/dist/index.js +10 -9
- package/dist/index.mjs +8 -7
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +4 -6
- package/dist/presets.mjs +3 -5
- package/dist/reset.d.mts +30 -0
- package/dist/reset.d.ts +32 -0
- package/dist/reset.js +161 -0
- package/dist/reset.mjs +161 -0
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -6
- package/dist/vite.mjs +5 -4
- package/dist/webpack.js +8 -7
- package/dist/webpack.mjs +6 -5
- package/dist/webpack4.js +29 -22
- package/dist/webpack4.mjs +14 -7
- package/package.json +9 -2
- package/dist/chunk-OXASK55Q.js +0 -6
- package/dist/chunk-PMF2CCKK.mjs +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createTailwindcssPatcherFromContext
|
|
3
|
-
|
|
2
|
+
createTailwindcssPatcherFromContext,
|
|
3
|
+
findNearestPackageRoot
|
|
4
|
+
} from "./chunk-3XGTIDA6.mjs";
|
|
4
5
|
import {
|
|
5
6
|
getDefaultOptions
|
|
6
7
|
} from "./chunk-DKPIYG24.mjs";
|
|
@@ -52,9 +53,16 @@ function invalidateRuntimeClassSet(twPatcher) {
|
|
|
52
53
|
}
|
|
53
54
|
runtimeClassSetCache.delete(twPatcher);
|
|
54
55
|
}
|
|
55
|
-
function createTailwindPatchPromise(twPatcher) {
|
|
56
|
-
return Promise.resolve(twPatcher.patch()).then((result) => {
|
|
56
|
+
function createTailwindPatchPromise(twPatcher, onPatched) {
|
|
57
|
+
return Promise.resolve(twPatcher.patch()).then(async (result) => {
|
|
57
58
|
invalidateRuntimeClassSet(twPatcher);
|
|
59
|
+
if (onPatched) {
|
|
60
|
+
try {
|
|
61
|
+
await onPatched();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
debug("failed to persist patch target after patch(): %O", error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
58
66
|
return result;
|
|
59
67
|
});
|
|
60
68
|
}
|
|
@@ -72,7 +80,7 @@ async function refreshTailwindRuntimeState(state, force) {
|
|
|
72
80
|
refreshed = true;
|
|
73
81
|
}
|
|
74
82
|
if (refreshed) {
|
|
75
|
-
state.patchPromise = createTailwindPatchPromise(state.twPatcher);
|
|
83
|
+
state.patchPromise = createTailwindPatchPromise(state.twPatcher, state.onPatchCompleted);
|
|
76
84
|
}
|
|
77
85
|
return refreshed;
|
|
78
86
|
}
|
|
@@ -170,12 +178,243 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
170
178
|
}
|
|
171
179
|
}
|
|
172
180
|
|
|
181
|
+
// package.json
|
|
182
|
+
var package_default = {
|
|
183
|
+
name: "weapp-tailwindcss",
|
|
184
|
+
version: "4.8.5",
|
|
185
|
+
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!",
|
|
186
|
+
author: "ice breaker <1324318532@qq.com>",
|
|
187
|
+
license: "MIT",
|
|
188
|
+
homepage: "https://tw.icebreaker.top",
|
|
189
|
+
repository: {
|
|
190
|
+
type: "git",
|
|
191
|
+
url: "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
|
|
192
|
+
directory: "packages/weapp-tailwindcss"
|
|
193
|
+
},
|
|
194
|
+
bugs: {
|
|
195
|
+
url: "https://github.com/sonofmagic/weapp-tailwindcss/issues"
|
|
196
|
+
},
|
|
197
|
+
keywords: [
|
|
198
|
+
"tailwindcss",
|
|
199
|
+
"weapp",
|
|
200
|
+
"wechat",
|
|
201
|
+
"mini",
|
|
202
|
+
"miniprogram",
|
|
203
|
+
"mini app",
|
|
204
|
+
"weapp-tw",
|
|
205
|
+
"weapp-tailwindcss",
|
|
206
|
+
"taro",
|
|
207
|
+
"uni-app",
|
|
208
|
+
"remax",
|
|
209
|
+
"rax",
|
|
210
|
+
"mpx",
|
|
211
|
+
"jit",
|
|
212
|
+
"mp",
|
|
213
|
+
"android",
|
|
214
|
+
"ios",
|
|
215
|
+
"\u5C0F\u7A0B\u5E8F",
|
|
216
|
+
"vite",
|
|
217
|
+
"postcss",
|
|
218
|
+
"webpack",
|
|
219
|
+
"webpack-plugin",
|
|
220
|
+
"gulp",
|
|
221
|
+
"gulp-plugin"
|
|
222
|
+
],
|
|
223
|
+
exports: {
|
|
224
|
+
".": {
|
|
225
|
+
style: "./index.css",
|
|
226
|
+
types: "./dist/index.d.ts",
|
|
227
|
+
import: "./dist/index.mjs",
|
|
228
|
+
require: "./dist/index.js"
|
|
229
|
+
},
|
|
230
|
+
"./escape": {
|
|
231
|
+
types: "./dist/escape.d.ts",
|
|
232
|
+
import: "./dist/escape.mjs",
|
|
233
|
+
require: "./dist/escape.js"
|
|
234
|
+
},
|
|
235
|
+
"./vite": {
|
|
236
|
+
types: "./dist/vite.d.ts",
|
|
237
|
+
import: "./dist/vite.mjs",
|
|
238
|
+
require: "./dist/vite.js"
|
|
239
|
+
},
|
|
240
|
+
"./webpack": {
|
|
241
|
+
types: "./dist/webpack.d.ts",
|
|
242
|
+
import: "./dist/webpack.mjs",
|
|
243
|
+
require: "./dist/webpack.js"
|
|
244
|
+
},
|
|
245
|
+
"./webpack4": {
|
|
246
|
+
types: "./dist/webpack4.d.ts",
|
|
247
|
+
import: "./dist/webpack4.mjs",
|
|
248
|
+
require: "./dist/webpack4.js"
|
|
249
|
+
},
|
|
250
|
+
"./core": {
|
|
251
|
+
types: "./dist/core.d.ts",
|
|
252
|
+
import: "./dist/core.mjs",
|
|
253
|
+
require: "./dist/core.js"
|
|
254
|
+
},
|
|
255
|
+
"./gulp": {
|
|
256
|
+
types: "./dist/gulp.d.ts",
|
|
257
|
+
import: "./dist/gulp.mjs",
|
|
258
|
+
require: "./dist/gulp.js"
|
|
259
|
+
},
|
|
260
|
+
"./defaults": {
|
|
261
|
+
types: "./dist/defaults.d.ts",
|
|
262
|
+
import: "./dist/defaults.mjs",
|
|
263
|
+
require: "./dist/defaults.js"
|
|
264
|
+
},
|
|
265
|
+
"./presets": {
|
|
266
|
+
types: "./dist/presets.d.ts",
|
|
267
|
+
import: "./dist/presets.mjs",
|
|
268
|
+
require: "./dist/presets.js"
|
|
269
|
+
},
|
|
270
|
+
"./reset": {
|
|
271
|
+
types: "./dist/reset.d.ts",
|
|
272
|
+
import: "./dist/reset.mjs",
|
|
273
|
+
require: "./dist/reset.js"
|
|
274
|
+
},
|
|
275
|
+
"./css-macro/postcss": {
|
|
276
|
+
types: "./dist/css-macro/postcss.d.ts",
|
|
277
|
+
import: "./dist/css-macro/postcss.mjs",
|
|
278
|
+
require: "./dist/css-macro/postcss.js"
|
|
279
|
+
},
|
|
280
|
+
"./css-macro": {
|
|
281
|
+
types: "./dist/css-macro.d.ts",
|
|
282
|
+
import: "./dist/css-macro.mjs",
|
|
283
|
+
require: "./dist/css-macro.js"
|
|
284
|
+
},
|
|
285
|
+
"./types": {
|
|
286
|
+
types: "./dist/types.d.ts",
|
|
287
|
+
import: "./dist/types.mjs",
|
|
288
|
+
require: "./dist/types.js"
|
|
289
|
+
},
|
|
290
|
+
"./postcss-html-transform": {
|
|
291
|
+
types: "./dist/postcss-html-transform.d.ts",
|
|
292
|
+
import: "./dist/postcss-html-transform.mjs",
|
|
293
|
+
require: "./dist/postcss-html-transform.js"
|
|
294
|
+
},
|
|
295
|
+
"./package.json": "./package.json",
|
|
296
|
+
"./index.css": "./index.css",
|
|
297
|
+
"./index": "./index.css",
|
|
298
|
+
"./preflight.css": "./preflight.css",
|
|
299
|
+
"./preflight": "./preflight.css",
|
|
300
|
+
"./theme.css": "./theme.css",
|
|
301
|
+
"./theme": "./theme.css",
|
|
302
|
+
"./utilities.css": "./utilities.css",
|
|
303
|
+
"./utilities": "./utilities.css",
|
|
304
|
+
"./with-layer.css": "./with-layer.css",
|
|
305
|
+
"./with-layer": "./with-layer.css",
|
|
306
|
+
"./uni-app-x": "./uni-app-x.css",
|
|
307
|
+
"./uni-app-x.css": "./uni-app-x.css",
|
|
308
|
+
"./css": "./css/index.css",
|
|
309
|
+
"./*": "./*"
|
|
310
|
+
},
|
|
311
|
+
main: "./dist/index.js",
|
|
312
|
+
module: "./dist/index.mjs",
|
|
313
|
+
types: "./dist/index.d.ts",
|
|
314
|
+
style: "index.css",
|
|
315
|
+
typesVersions: {
|
|
316
|
+
"*": {
|
|
317
|
+
"*": [
|
|
318
|
+
"./dist/*",
|
|
319
|
+
"./dist/index.d.ts"
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
bin: {
|
|
324
|
+
"weapp-tailwindcss-webpack-plugin": "bin/weapp-tailwindcss.js",
|
|
325
|
+
"weapp-tailwindcss": "bin/weapp-tailwindcss.js",
|
|
326
|
+
"weapp-tw": "bin/weapp-tailwindcss.js"
|
|
327
|
+
},
|
|
328
|
+
files: [
|
|
329
|
+
"bin",
|
|
330
|
+
"css",
|
|
331
|
+
"dist",
|
|
332
|
+
"index.css",
|
|
333
|
+
"preflight.css",
|
|
334
|
+
"theme.css",
|
|
335
|
+
"uni-app-x.css",
|
|
336
|
+
"utilities.css",
|
|
337
|
+
"with-layer.css"
|
|
338
|
+
],
|
|
339
|
+
engines: {
|
|
340
|
+
node: "^18.17.0 || >=20.5.0"
|
|
341
|
+
},
|
|
342
|
+
scripts: {
|
|
343
|
+
dev: "tsup --watch --sourcemap",
|
|
344
|
+
build: "tsup && node scripts/ensure-escape-dts.mjs",
|
|
345
|
+
"build:tsc": "cross-env NODE_ENV=development tsc --build tsconfig.json",
|
|
346
|
+
"build:cli": "cd plugins/cli && pnpm run build",
|
|
347
|
+
"build:css": "tsx scripts/build-css.ts",
|
|
348
|
+
"build:weapp-theme": "tsx scripts/build-weapp-theme.ts",
|
|
349
|
+
test: "npm run postinstall && vitest run",
|
|
350
|
+
"test:dev": "vitest",
|
|
351
|
+
"test:ui": "vitest --ui",
|
|
352
|
+
"bench:js-handlers": "tsx scripts/js-bench.ts",
|
|
353
|
+
"bench:js-diff": "tsx scripts/js-bench-diff.ts",
|
|
354
|
+
clean: "tsx scripts/clean.ts",
|
|
355
|
+
"get-decl": "tsx scripts/get-decl.ts",
|
|
356
|
+
"ls:pack": "npm pack --dry-run",
|
|
357
|
+
"cli:patch": "node bin/weapp-tailwindcss.js patch",
|
|
358
|
+
colors: "tsx scripts/colors.ts",
|
|
359
|
+
release: "tsx scripts/release.ts",
|
|
360
|
+
lint: "eslint .",
|
|
361
|
+
"lint:fix": "eslint ./src --fix",
|
|
362
|
+
postinstall: "node bin/weapp-tailwindcss.js patch"
|
|
363
|
+
},
|
|
364
|
+
publishConfig: {
|
|
365
|
+
access: "public",
|
|
366
|
+
registry: "https://registry.npmjs.org"
|
|
367
|
+
},
|
|
368
|
+
dependencies: {
|
|
369
|
+
"@ast-core/escape": "~1.0.1",
|
|
370
|
+
"@babel/parser": "~7.28.5",
|
|
371
|
+
"@babel/traverse": "~7.28.5",
|
|
372
|
+
"@babel/types": "~7.28.5",
|
|
373
|
+
"@tailwindcss-mangle/config": "^6.1.0",
|
|
374
|
+
"@vue/compiler-dom": "^3.5.24",
|
|
375
|
+
"@vue/compiler-sfc": "^3.5.24",
|
|
376
|
+
"@weapp-core/escape": "~5.0.1",
|
|
377
|
+
"@weapp-core/regex": "~1.0.1",
|
|
378
|
+
"@weapp-tailwindcss/logger": "workspace:*",
|
|
379
|
+
"@weapp-tailwindcss/postcss": "workspace:*",
|
|
380
|
+
"@weapp-tailwindcss/shared": "workspace:*",
|
|
381
|
+
cac: "^6.7.14",
|
|
382
|
+
debug: "~4.4.3",
|
|
383
|
+
"fast-glob": "^3.3.3",
|
|
384
|
+
htmlparser2: "10.0.0",
|
|
385
|
+
"loader-utils": "2.0.4",
|
|
386
|
+
"local-pkg": "^1.1.2",
|
|
387
|
+
"lru-cache": "10.4.3",
|
|
388
|
+
"magic-string": "0.30.21",
|
|
389
|
+
semver: "~7.7.3",
|
|
390
|
+
"tailwindcss-patch": "catalog:tailwindcssPatch",
|
|
391
|
+
"webpack-sources": "3.3.3",
|
|
392
|
+
yaml: "^2.8.1"
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// src/constants.ts
|
|
397
|
+
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
398
|
+
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
399
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
400
|
+
var WEAPP_TW_VERSION = package_default.version;
|
|
401
|
+
var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
402
|
+
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
403
|
+
"class-variance-authority": "@weapp-tailwindcss/cva",
|
|
404
|
+
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
405
|
+
};
|
|
406
|
+
|
|
173
407
|
// src/tailwindcss/targets.ts
|
|
174
408
|
import { existsSync, readFileSync } from "fs";
|
|
175
409
|
import { mkdir, writeFile } from "fs/promises";
|
|
176
410
|
import path from "path";
|
|
177
411
|
import process from "process";
|
|
178
412
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
413
|
+
|
|
414
|
+
// src/cache/md5.ts
|
|
415
|
+
import { md5 } from "@weapp-tailwindcss/shared/node";
|
|
416
|
+
|
|
417
|
+
// src/tailwindcss/targets.ts
|
|
179
418
|
var PATCH_INFO_FILENAME = "tailwindcss-target.json";
|
|
180
419
|
var PATCH_INFO_CACHE_RELATIVE_PATH = path.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
|
|
181
420
|
var PATCH_INFO_LEGACY_RELATIVE_PATH = path.join(".tw-patch", PATCH_INFO_FILENAME);
|
|
@@ -193,14 +432,33 @@ function formatRelativeToBase(targetPath, baseDir) {
|
|
|
193
432
|
}
|
|
194
433
|
return path.join(".", relative);
|
|
195
434
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
435
|
+
function resolveRecordLocation(baseDir) {
|
|
436
|
+
const normalizedBase = path.normalize(baseDir);
|
|
437
|
+
const packageRoot = findNearestPackageRoot(normalizedBase) ?? normalizedBase;
|
|
438
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
439
|
+
const hasPackageJson = existsSync(packageJsonPath);
|
|
440
|
+
const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
|
|
441
|
+
const recordKey = md5(path.normalize(recordKeySource));
|
|
442
|
+
const recordDir = path.join(packageRoot, "node_modules", ".cache", "weapp-tailwindcss", recordKey);
|
|
443
|
+
const recordPath = path.join(recordDir, PATCH_INFO_FILENAME);
|
|
444
|
+
return {
|
|
445
|
+
normalizedBase,
|
|
446
|
+
packageRoot,
|
|
447
|
+
recordDir,
|
|
448
|
+
recordKey,
|
|
449
|
+
recordPath,
|
|
450
|
+
packageJsonPath: hasPackageJson ? packageJsonPath : void 0
|
|
451
|
+
};
|
|
198
452
|
}
|
|
199
453
|
function getRecordFileCandidates(baseDir) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
454
|
+
const { normalizedBase, packageRoot, recordPath } = resolveRecordLocation(baseDir);
|
|
455
|
+
const candidates = /* @__PURE__ */ new Set([
|
|
456
|
+
recordPath,
|
|
457
|
+
path.join(packageRoot, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
458
|
+
path.join(normalizedBase, PATCH_INFO_CACHE_RELATIVE_PATH),
|
|
459
|
+
path.join(normalizedBase, PATCH_INFO_LEGACY_RELATIVE_PATH)
|
|
460
|
+
]);
|
|
461
|
+
return [...candidates];
|
|
204
462
|
}
|
|
205
463
|
function logTailwindcssTarget(kind, patcher, baseDir) {
|
|
206
464
|
const packageInfo = patcher?.packageInfo;
|
|
@@ -259,25 +517,36 @@ function readPatchTargetRecord(baseDir) {
|
|
|
259
517
|
}
|
|
260
518
|
return void 0;
|
|
261
519
|
}
|
|
262
|
-
async function saveCliPatchTargetRecord(baseDir, patcher) {
|
|
520
|
+
async function saveCliPatchTargetRecord(baseDir, patcher, options) {
|
|
263
521
|
if (!baseDir || !patcher?.packageInfo?.rootPath) {
|
|
264
522
|
return void 0;
|
|
265
523
|
}
|
|
266
524
|
const normalizedBase = path.normalize(baseDir);
|
|
525
|
+
const location = resolveRecordLocation(normalizedBase);
|
|
526
|
+
const recordPath = options?.recordPath ? path.normalize(options.recordPath) : location.recordPath;
|
|
267
527
|
const record = {
|
|
268
528
|
tailwindPackagePath: path.normalize(patcher.packageInfo.rootPath),
|
|
269
529
|
packageVersion: patcher.packageInfo.version,
|
|
270
530
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
271
|
-
source: "cli",
|
|
272
|
-
tailwindcssBasedir: normalizedBase
|
|
531
|
+
source: options?.source ?? "cli",
|
|
532
|
+
tailwindcssBasedir: normalizedBase,
|
|
533
|
+
cwd: options?.cwd ? path.normalize(options.cwd) : normalizedBase,
|
|
534
|
+
patchVersion: WEAPP_TW_VERSION,
|
|
535
|
+
packageJsonPath: options?.packageJsonPath ?? location.packageJsonPath,
|
|
536
|
+
recordKey: options?.recordKey ?? location.recordKey
|
|
273
537
|
};
|
|
274
|
-
const recordPath = getRecordFilePath(normalizedBase);
|
|
275
538
|
try {
|
|
276
539
|
await mkdir(path.dirname(recordPath), { recursive: true });
|
|
277
540
|
await writeFile(recordPath, `${JSON.stringify(record, null, 2)}
|
|
278
541
|
`, "utf8");
|
|
279
542
|
return recordPath;
|
|
280
543
|
} catch (error) {
|
|
544
|
+
const baseDisplay = formatRelativeToBase(normalizedBase, process.cwd());
|
|
545
|
+
logger.warn(
|
|
546
|
+
'\u81EA\u52A8\u66F4\u65B0 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\u5931\u8D25\uFF0C\u8BF7\u5728 %s \u8FD0\u884C "weapp-tw patch --cwd %s"\u3002',
|
|
547
|
+
baseDisplay,
|
|
548
|
+
normalizedBase
|
|
549
|
+
);
|
|
281
550
|
logger.debug("failed to persist patch target record %s: %O", recordPath, error);
|
|
282
551
|
return void 0;
|
|
283
552
|
}
|
|
@@ -300,51 +569,71 @@ function findPatchTargetRecord(baseDir) {
|
|
|
300
569
|
}
|
|
301
570
|
return void 0;
|
|
302
571
|
}
|
|
303
|
-
function
|
|
304
|
-
if (!baseDir || !patcher?.packageInfo?.rootPath) {
|
|
305
|
-
return;
|
|
572
|
+
function createPatchTargetRecorder(baseDir, patcher, options) {
|
|
573
|
+
if (!baseDir || !patcher?.packageInfo?.rootPath || options?.recordTarget === false) {
|
|
574
|
+
return void 0;
|
|
306
575
|
}
|
|
307
|
-
const
|
|
576
|
+
const normalizedBase = path.normalize(baseDir);
|
|
577
|
+
const recorded = findPatchTargetRecord(normalizedBase);
|
|
578
|
+
const location = resolveRecordLocation(normalizedBase);
|
|
579
|
+
const expectedPath = path.normalize(patcher.packageInfo.rootPath);
|
|
580
|
+
let reason;
|
|
308
581
|
if (!recorded) {
|
|
309
|
-
|
|
582
|
+
reason = "missing";
|
|
583
|
+
} else {
|
|
584
|
+
const normalizedRecorded = path.normalize(recorded.record.tailwindPackagePath);
|
|
585
|
+
if (normalizedRecorded !== expectedPath) {
|
|
586
|
+
reason = "mismatch";
|
|
587
|
+
} else if (path.normalize(recorded.path) !== path.normalize(location.recordPath) || !recorded.record.recordKey || recorded.record.recordKey !== location.recordKey) {
|
|
588
|
+
reason = "migrate";
|
|
589
|
+
} else if (!recorded.record.patchVersion || recorded.record.patchVersion !== WEAPP_TW_VERSION) {
|
|
590
|
+
reason = "stale";
|
|
591
|
+
} else if (options?.cwd && recorded.record.cwd && path.normalize(recorded.record.cwd) !== path.normalize(options.cwd)) {
|
|
592
|
+
reason = "metadata";
|
|
593
|
+
} else if (!recorded.record.cwd && options?.cwd) {
|
|
594
|
+
reason = "metadata";
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const shouldPersist = options?.alwaysRecord || !recorded || Boolean(reason);
|
|
598
|
+
if (!shouldPersist) {
|
|
599
|
+
return void 0;
|
|
310
600
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
601
|
+
let message;
|
|
602
|
+
switch (reason) {
|
|
603
|
+
case "mismatch":
|
|
604
|
+
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";
|
|
605
|
+
break;
|
|
606
|
+
case "migrate":
|
|
607
|
+
case "stale":
|
|
608
|
+
message = "\u6B63\u5728\u5237\u65B0\u5F53\u524D\u5B50\u5305\u7684 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\uFF0C\u786E\u4FDD\u7F13\u5B58\u9694\u79BB\u3002";
|
|
609
|
+
break;
|
|
610
|
+
case "missing":
|
|
611
|
+
message = "\u672A\u627E\u5230\u5F53\u524D\u5B50\u5305\u7684 Tailwind CSS \u76EE\u6807\u8BB0\u5F55\uFF0C\u6B63\u5728\u751F\u6210\u3002";
|
|
612
|
+
break;
|
|
613
|
+
default:
|
|
614
|
+
break;
|
|
315
615
|
}
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
616
|
+
const onPatched = async () => saveCliPatchTargetRecord(normalizedBase, patcher, {
|
|
617
|
+
cwd: options?.cwd ?? normalizedBase,
|
|
618
|
+
source: options?.source ?? "cli",
|
|
619
|
+
recordPath: location.recordPath,
|
|
620
|
+
recordKey: location.recordKey,
|
|
621
|
+
packageJsonPath: location.packageJsonPath
|
|
622
|
+
});
|
|
623
|
+
return {
|
|
624
|
+
recordPath: location.recordPath,
|
|
625
|
+
message,
|
|
626
|
+
reason,
|
|
627
|
+
onPatched
|
|
628
|
+
};
|
|
325
629
|
}
|
|
326
630
|
|
|
327
|
-
// src/constants.ts
|
|
328
|
-
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
329
|
-
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
330
|
-
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
331
|
-
var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
332
|
-
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
333
|
-
"class-variance-authority": "@weapp-tailwindcss/cva",
|
|
334
|
-
"tailwind-variants": "@weapp-tailwindcss/variants"
|
|
335
|
-
};
|
|
336
|
-
|
|
337
631
|
// src/context/index.ts
|
|
338
632
|
import { rm } from "fs/promises";
|
|
339
633
|
import { logger as logger4, pc } from "@weapp-tailwindcss/logger";
|
|
340
634
|
|
|
341
635
|
// src/cache/index.ts
|
|
342
636
|
import { LRUCache } from "lru-cache";
|
|
343
|
-
|
|
344
|
-
// src/cache/md5.ts
|
|
345
|
-
import { md5 } from "@weapp-tailwindcss/shared/node";
|
|
346
|
-
|
|
347
|
-
// src/cache/index.ts
|
|
348
637
|
function isProcessResult(value) {
|
|
349
638
|
return typeof value === "object" && value !== null && "result" in value;
|
|
350
639
|
}
|
|
@@ -2481,6 +2770,54 @@ function ensureDefaultsIncluded(value) {
|
|
|
2481
2770
|
}
|
|
2482
2771
|
return value;
|
|
2483
2772
|
}
|
|
2773
|
+
function normalizeCssEntriesConfig(entries) {
|
|
2774
|
+
if (!entries) {
|
|
2775
|
+
return void 0;
|
|
2776
|
+
}
|
|
2777
|
+
if (typeof entries === "string") {
|
|
2778
|
+
const trimmed = entries.trim();
|
|
2779
|
+
return trimmed ? [trimmed] : void 0;
|
|
2780
|
+
}
|
|
2781
|
+
if (!Array.isArray(entries)) {
|
|
2782
|
+
return void 0;
|
|
2783
|
+
}
|
|
2784
|
+
const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
2785
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
2786
|
+
}
|
|
2787
|
+
function hasConfiguredCssEntries(ctx) {
|
|
2788
|
+
if (normalizeCssEntriesConfig(ctx.cssEntries)) {
|
|
2789
|
+
return true;
|
|
2790
|
+
}
|
|
2791
|
+
if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) {
|
|
2792
|
+
return true;
|
|
2793
|
+
}
|
|
2794
|
+
const patcherOptions = ctx.tailwindcssPatcherOptions;
|
|
2795
|
+
if (patcherOptions) {
|
|
2796
|
+
if (normalizeCssEntriesConfig(patcherOptions.tailwind?.v4?.cssEntries)) {
|
|
2797
|
+
return true;
|
|
2798
|
+
}
|
|
2799
|
+
if (normalizeCssEntriesConfig(patcherOptions.patch?.tailwindcss?.v4?.cssEntries)) {
|
|
2800
|
+
return true;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return false;
|
|
2804
|
+
}
|
|
2805
|
+
var hasWarnedMissingCssEntries = false;
|
|
2806
|
+
function warnMissingCssEntries(ctx, patcher) {
|
|
2807
|
+
if (hasWarnedMissingCssEntries) {
|
|
2808
|
+
return;
|
|
2809
|
+
}
|
|
2810
|
+
if (patcher?.majorVersion !== 4) {
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
if (hasConfiguredCssEntries(ctx)) {
|
|
2814
|
+
return;
|
|
2815
|
+
}
|
|
2816
|
+
hasWarnedMissingCssEntries = true;
|
|
2817
|
+
logger4.warn(
|
|
2818
|
+
'[tailwindcss@4] \u672A\u68C0\u6D4B\u5230 cssEntries \u914D\u7F6E\u3002\u8BF7\u4F20\u5165\u5305\u542B tailwindcss \u5F15\u7528\u7684 CSS \u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 cssEntries: ["/absolute/path/to/src/app.css"]\uFF0C\u5426\u5219 tailwindcss \u751F\u6210\u7684\u7C7B\u540D\u4E0D\u4F1A\u53C2\u4E0E\u8F6C\u8BD1\u3002'
|
|
2819
|
+
);
|
|
2820
|
+
}
|
|
2484
2821
|
async function clearTailwindcssPatcherCache(patcher, options) {
|
|
2485
2822
|
if (!patcher) {
|
|
2486
2823
|
return;
|
|
@@ -2531,7 +2868,7 @@ function createInternalCompilerContext(opts) {
|
|
|
2531
2868
|
} else {
|
|
2532
2869
|
logger4.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
|
|
2533
2870
|
}
|
|
2534
|
-
|
|
2871
|
+
warnMissingCssEntries(ctx, twPatcher);
|
|
2535
2872
|
let cssCalcOptions = ctx.cssCalc ?? twPatcher.majorVersion === 4;
|
|
2536
2873
|
if (twPatcher.majorVersion === 4 && cssCalcOptions) {
|
|
2537
2874
|
cssCalcOptions = ensureDefaultsIncluded(cssCalcOptions);
|
|
@@ -2575,12 +2912,12 @@ export {
|
|
|
2575
2912
|
createTailwindPatchPromise,
|
|
2576
2913
|
refreshTailwindRuntimeState,
|
|
2577
2914
|
collectRuntimeClassSet,
|
|
2578
|
-
logTailwindcssTarget,
|
|
2579
|
-
saveCliPatchTargetRecord,
|
|
2580
|
-
toCustomAttributesEntities,
|
|
2581
2915
|
pluginName,
|
|
2582
2916
|
vitePluginName,
|
|
2583
2917
|
WEAPP_TW_REQUIRED_NODE_VERSION,
|
|
2918
|
+
logTailwindcssTarget,
|
|
2919
|
+
createPatchTargetRecorder,
|
|
2920
|
+
toCustomAttributesEntities,
|
|
2584
2921
|
replaceWxml,
|
|
2585
2922
|
createAttributeMatcher,
|
|
2586
2923
|
generateCode,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
processCachedTask
|
|
3
3
|
} from "./chunk-RRHPTTCP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
setupPatchRecorder
|
|
6
|
+
} from "./chunk-SFQCTDJA.mjs";
|
|
4
7
|
import {
|
|
5
8
|
collectRuntimeClassSet,
|
|
6
9
|
createDebug,
|
|
7
|
-
createTailwindPatchPromise,
|
|
8
10
|
getCompilerContext,
|
|
9
11
|
refreshTailwindRuntimeState
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-K62QTSOE.mjs";
|
|
11
13
|
|
|
12
14
|
// src/bundlers/gulp/index.ts
|
|
13
15
|
import { Buffer } from "buffer";
|
|
@@ -20,11 +22,16 @@ var Transform = stream.Transform;
|
|
|
20
22
|
function createPlugins(options = {}) {
|
|
21
23
|
const opts = getCompilerContext(options);
|
|
22
24
|
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
25
|
+
const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
|
|
26
|
+
source: "runtime",
|
|
27
|
+
cwd: opts.tailwindcssBasedir ?? process.cwd()
|
|
28
|
+
});
|
|
23
29
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
24
30
|
const runtimeState = {
|
|
25
31
|
twPatcher: initialTwPatcher,
|
|
26
|
-
patchPromise:
|
|
27
|
-
refreshTailwindcssPatcher
|
|
32
|
+
patchPromise: patchRecorderState.patchPromise,
|
|
33
|
+
refreshTailwindcssPatcher,
|
|
34
|
+
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
28
35
|
};
|
|
29
36
|
const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
|
|
30
37
|
let runtimeSetInitialized = false;
|