@weapp-tailwindcss/postcss 3.3.3 → 3.3.4
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/index.cjs +50 -5
- package/dist/index.js +50 -5
- package/dist/types.d.ts +13 -0
- package/package.json +5 -6
package/dist/index.cjs
CHANGED
|
@@ -29,11 +29,11 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
29
29
|
let micromatch = require("micromatch");
|
|
30
30
|
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
31
31
|
let tailwindcss_config = require("tailwindcss-config");
|
|
32
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
32
33
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
33
34
|
let lru_cache = require("lru-cache");
|
|
34
35
|
let autoprefixer = require("autoprefixer");
|
|
35
36
|
autoprefixer = require_rolldown_runtime.__toESM(autoprefixer, 1);
|
|
36
|
-
let es_toolkit = require("es-toolkit");
|
|
37
37
|
let postcss_pxtrans = require("postcss-pxtrans");
|
|
38
38
|
postcss_pxtrans = require_rolldown_runtime.__toESM(postcss_pxtrans, 1);
|
|
39
39
|
let postcss_rem_to_responsive_pixel = require("postcss-rem-to-responsive-pixel");
|
|
@@ -5333,8 +5333,20 @@ function getCalcDuplicateCleaner(options) {
|
|
|
5333
5333
|
const EMPTY_CALC_OPTIONS = {};
|
|
5334
5334
|
function getCalcPlugin(options) {
|
|
5335
5335
|
if (!options.cssCalc) return null;
|
|
5336
|
-
if (options.cssCalc === true || Array.isArray(options.cssCalc))
|
|
5337
|
-
|
|
5336
|
+
if (options.cssCalc === true || Array.isArray(options.cssCalc)) {
|
|
5337
|
+
const calcOptions = Array.isArray(options.cssCalc) ? {
|
|
5338
|
+
includeCustomProperties: options.cssCalc,
|
|
5339
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
5340
|
+
} : options.customPropertyValues ? {
|
|
5341
|
+
customPropertyValues: options.customPropertyValues,
|
|
5342
|
+
includeCustomProperties: [...options.customPropertyValues.keys()]
|
|
5343
|
+
} : EMPTY_CALC_OPTIONS;
|
|
5344
|
+
return (0, _weapp_tailwindcss_postcss_calc.default)(calcOptions);
|
|
5345
|
+
}
|
|
5346
|
+
return (0, _weapp_tailwindcss_postcss_calc.default)({
|
|
5347
|
+
...options.cssCalc,
|
|
5348
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
5349
|
+
});
|
|
5338
5350
|
}
|
|
5339
5351
|
//#endregion
|
|
5340
5352
|
//#region src/plugins/getCustomPropertyCleaner.ts
|
|
@@ -7235,10 +7247,21 @@ function createStyleHandler(options) {
|
|
|
7235
7247
|
}
|
|
7236
7248
|
const cacheKey = `${getOptionsFingerprint(resolvedOptions)}|${signal ? signalToCacheKey(signal) : ""}|${simpleHash(source)}`;
|
|
7237
7249
|
const cachedResult = resultCache.get(cacheKey);
|
|
7238
|
-
if (cachedResult)
|
|
7250
|
+
if (cachedResult) {
|
|
7251
|
+
resolvedOptions.onDiagnostic?.({
|
|
7252
|
+
phase: "postcss",
|
|
7253
|
+
durationMs: 0,
|
|
7254
|
+
cache: {
|
|
7255
|
+
hit: true,
|
|
7256
|
+
key: cacheKey
|
|
7257
|
+
}
|
|
7258
|
+
});
|
|
7259
|
+
return Promise.resolve(cloneOutput ? cloneResult(cachedResult) : cachedResult);
|
|
7260
|
+
}
|
|
7239
7261
|
const processor = processorCache.getProcessor(resolvedOptions, signal);
|
|
7240
7262
|
const processOptions = processorCache.getProcessOptions(resolvedOptions);
|
|
7241
|
-
|
|
7263
|
+
const startedAt = node_perf_hooks.performance.now();
|
|
7264
|
+
return processor.process(processInput, processOptions).async().then(async (result) => {
|
|
7242
7265
|
let finalResult = resolvePostcssFrameworkProfile(resolvedOptions).postprocess(result, resolvedOptions);
|
|
7243
7266
|
if (resolvedOptions.isMainChunk !== false && finalResult.root) {
|
|
7244
7267
|
let removed = 0;
|
|
@@ -7267,7 +7290,29 @@ function createStyleHandler(options) {
|
|
|
7267
7290
|
if (splitUnresolvedAuthorVariableFallbacks(finalResult.root, /* @__PURE__ */ new Map())) finalResult.css = finalResult.root.toString();
|
|
7268
7291
|
}
|
|
7269
7292
|
resultCache.set(cacheKey, finalResult);
|
|
7293
|
+
await resolvedOptions.onDiagnostic?.({
|
|
7294
|
+
phase: "postcss",
|
|
7295
|
+
durationMs: node_perf_hooks.performance.now() - startedAt,
|
|
7296
|
+
cache: {
|
|
7297
|
+
hit: false,
|
|
7298
|
+
key: cacheKey
|
|
7299
|
+
}
|
|
7300
|
+
});
|
|
7270
7301
|
return cloneOutput ? cloneResult(finalResult) : finalResult;
|
|
7302
|
+
}).catch(async (error) => {
|
|
7303
|
+
await resolvedOptions.onDiagnostic?.({
|
|
7304
|
+
phase: "postcss",
|
|
7305
|
+
durationMs: node_perf_hooks.performance.now() - startedAt,
|
|
7306
|
+
cache: {
|
|
7307
|
+
hit: false,
|
|
7308
|
+
key: cacheKey
|
|
7309
|
+
},
|
|
7310
|
+
error: {
|
|
7311
|
+
name: error instanceof Error ? error.name : void 0,
|
|
7312
|
+
message: error instanceof Error ? error.message : String(error)
|
|
7313
|
+
}
|
|
7314
|
+
});
|
|
7315
|
+
throw error;
|
|
7271
7316
|
});
|
|
7272
7317
|
}
|
|
7273
7318
|
const handler = ((rawSource, opt) => {
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,10 @@ import { realpathSync } from "node:fs";
|
|
|
18
18
|
import { readFile, stat } from "node:fs/promises";
|
|
19
19
|
import micromatch from "micromatch";
|
|
20
20
|
import { loadConfig } from "tailwindcss-config";
|
|
21
|
+
import { performance } from "node:perf_hooks";
|
|
21
22
|
import { defu, defuOverrideArray, regExpTest } from "@weapp-tailwindcss/shared";
|
|
22
23
|
import { LRUCache } from "lru-cache";
|
|
23
24
|
import autoprefixerPlugin from "autoprefixer";
|
|
24
|
-
import { omit } from "es-toolkit";
|
|
25
25
|
import postcssPxtrans from "postcss-pxtrans";
|
|
26
26
|
import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
|
|
27
27
|
import postcssUnitConverter, { composeRules as unitConversionComposeRules, presets, presets as unitConversionPresets } from "postcss-rule-unit-converter";
|
|
@@ -5317,8 +5317,20 @@ function getCalcDuplicateCleaner(options) {
|
|
|
5317
5317
|
const EMPTY_CALC_OPTIONS = {};
|
|
5318
5318
|
function getCalcPlugin(options) {
|
|
5319
5319
|
if (!options.cssCalc) return null;
|
|
5320
|
-
if (options.cssCalc === true || Array.isArray(options.cssCalc))
|
|
5321
|
-
|
|
5320
|
+
if (options.cssCalc === true || Array.isArray(options.cssCalc)) {
|
|
5321
|
+
const calcOptions = Array.isArray(options.cssCalc) ? {
|
|
5322
|
+
includeCustomProperties: options.cssCalc,
|
|
5323
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
5324
|
+
} : options.customPropertyValues ? {
|
|
5325
|
+
customPropertyValues: options.customPropertyValues,
|
|
5326
|
+
includeCustomProperties: [...options.customPropertyValues.keys()]
|
|
5327
|
+
} : EMPTY_CALC_OPTIONS;
|
|
5328
|
+
return postcssCalc(calcOptions);
|
|
5329
|
+
}
|
|
5330
|
+
return postcssCalc({
|
|
5331
|
+
...options.cssCalc,
|
|
5332
|
+
...options.customPropertyValues ? { customPropertyValues: options.customPropertyValues } : {}
|
|
5333
|
+
});
|
|
5322
5334
|
}
|
|
5323
5335
|
//#endregion
|
|
5324
5336
|
//#region src/plugins/getCustomPropertyCleaner.ts
|
|
@@ -7219,10 +7231,21 @@ function createStyleHandler(options) {
|
|
|
7219
7231
|
}
|
|
7220
7232
|
const cacheKey = `${getOptionsFingerprint(resolvedOptions)}|${signal ? signalToCacheKey(signal) : ""}|${simpleHash(source)}`;
|
|
7221
7233
|
const cachedResult = resultCache.get(cacheKey);
|
|
7222
|
-
if (cachedResult)
|
|
7234
|
+
if (cachedResult) {
|
|
7235
|
+
resolvedOptions.onDiagnostic?.({
|
|
7236
|
+
phase: "postcss",
|
|
7237
|
+
durationMs: 0,
|
|
7238
|
+
cache: {
|
|
7239
|
+
hit: true,
|
|
7240
|
+
key: cacheKey
|
|
7241
|
+
}
|
|
7242
|
+
});
|
|
7243
|
+
return Promise.resolve(cloneOutput ? cloneResult(cachedResult) : cachedResult);
|
|
7244
|
+
}
|
|
7223
7245
|
const processor = processorCache.getProcessor(resolvedOptions, signal);
|
|
7224
7246
|
const processOptions = processorCache.getProcessOptions(resolvedOptions);
|
|
7225
|
-
|
|
7247
|
+
const startedAt = performance.now();
|
|
7248
|
+
return processor.process(processInput, processOptions).async().then(async (result) => {
|
|
7226
7249
|
let finalResult = resolvePostcssFrameworkProfile(resolvedOptions).postprocess(result, resolvedOptions);
|
|
7227
7250
|
if (resolvedOptions.isMainChunk !== false && finalResult.root) {
|
|
7228
7251
|
let removed = 0;
|
|
@@ -7251,7 +7274,29 @@ function createStyleHandler(options) {
|
|
|
7251
7274
|
if (splitUnresolvedAuthorVariableFallbacks(finalResult.root, /* @__PURE__ */ new Map())) finalResult.css = finalResult.root.toString();
|
|
7252
7275
|
}
|
|
7253
7276
|
resultCache.set(cacheKey, finalResult);
|
|
7277
|
+
await resolvedOptions.onDiagnostic?.({
|
|
7278
|
+
phase: "postcss",
|
|
7279
|
+
durationMs: performance.now() - startedAt,
|
|
7280
|
+
cache: {
|
|
7281
|
+
hit: false,
|
|
7282
|
+
key: cacheKey
|
|
7283
|
+
}
|
|
7284
|
+
});
|
|
7254
7285
|
return cloneOutput ? cloneResult(finalResult) : finalResult;
|
|
7286
|
+
}).catch(async (error) => {
|
|
7287
|
+
await resolvedOptions.onDiagnostic?.({
|
|
7288
|
+
phase: "postcss",
|
|
7289
|
+
durationMs: performance.now() - startedAt,
|
|
7290
|
+
cache: {
|
|
7291
|
+
hit: false,
|
|
7292
|
+
key: cacheKey
|
|
7293
|
+
},
|
|
7294
|
+
error: {
|
|
7295
|
+
name: error instanceof Error ? error.name : void 0,
|
|
7296
|
+
message: error instanceof Error ? error.message : String(error)
|
|
7297
|
+
}
|
|
7298
|
+
});
|
|
7299
|
+
throw error;
|
|
7255
7300
|
});
|
|
7256
7301
|
}
|
|
7257
7302
|
const handler = ((rawSource, opt) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -140,6 +140,19 @@ export interface CssOptions {
|
|
|
140
140
|
tailwindcssV4GradientFallback?: boolean | undefined;
|
|
141
141
|
}
|
|
142
142
|
export type IStyleHandlerOptions = {
|
|
143
|
+
/** 编译诊断回调;由上层 bundler 注入,保持 PostCSS 包与 compiler 解耦。 */
|
|
144
|
+
onDiagnostic?: (event: {
|
|
145
|
+
phase: 'postcss';
|
|
146
|
+
durationMs: number;
|
|
147
|
+
cache?: {
|
|
148
|
+
hit: boolean;
|
|
149
|
+
key?: string;
|
|
150
|
+
};
|
|
151
|
+
error?: {
|
|
152
|
+
name?: string;
|
|
153
|
+
message: string;
|
|
154
|
+
};
|
|
155
|
+
}) => void | Promise<void>;
|
|
143
156
|
appType?: PostcssAppType | undefined;
|
|
144
157
|
ctx?: PostcssContext | undefined;
|
|
145
158
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.4",
|
|
5
5
|
"description": "PostCSS transforms that bring Tailwind CSS compatibility to every platform. 将 Tailwind CSS 兼容能力带到全端的 PostCSS 转换工具。",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"@csstools/css-tokenizer": "^4.0.0",
|
|
72
72
|
"@tailwindcss-mangle/engine": "0.2.0",
|
|
73
73
|
"@weapp-core/escape": "~8.0.0",
|
|
74
|
-
"@weapp-tailwindcss/postcss-calc": "1.0.
|
|
74
|
+
"@weapp-tailwindcss/postcss-calc": "1.0.7",
|
|
75
75
|
"@weapp-tailwindcss/shared": "2.0.3",
|
|
76
|
-
"autoprefixer": "^10.5.
|
|
76
|
+
"autoprefixer": "^10.5.6",
|
|
77
77
|
"es-toolkit": "^1.52.0",
|
|
78
78
|
"lru-cache": "11.5.2",
|
|
79
79
|
"micromatch": "^4.0.8",
|
|
80
80
|
"postcss": "^8.5.28",
|
|
81
81
|
"postcss-load-config": "^6.0.1",
|
|
82
|
-
"postcss-preset-env": "^11.5.
|
|
82
|
+
"postcss-preset-env": "^11.5.2",
|
|
83
83
|
"postcss-pxtrans": "^1.0.4",
|
|
84
84
|
"postcss-rem-to-responsive-pixel": "^7.0.5",
|
|
85
85
|
"postcss-rule-unit-converter": "^0.2.3",
|
|
@@ -90,8 +90,7 @@
|
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@csstools/postcss-is-pseudo-class": "^6.0.0",
|
|
93
|
-
"fast-check": "^4.
|
|
94
|
-
"postcss-calc": "link:../postcss-calc",
|
|
93
|
+
"fast-check": "^4.10.0",
|
|
95
94
|
"postcss-custom-properties": "^15.0.1"
|
|
96
95
|
},
|
|
97
96
|
"scripts": {
|