weapp-tailwindcss 5.0.0-next.31 → 5.0.0-next.33

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.
Files changed (50) hide show
  1. package/dist/auto-DEHRmEAx.mjs +200 -0
  2. package/dist/auto-dPpsm6FB.js +238 -0
  3. package/dist/{bundle-state-Ct_8GcSR.js → bundle-state-Co_ksa-C.js} +3 -3
  4. package/dist/{bundle-state-Bi-cQua6.mjs → bundle-state-DUIidcox.mjs} +2 -2
  5. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
  6. package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
  7. package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
  8. package/dist/cli.js +3 -6
  9. package/dist/cli.mjs +4 -7
  10. package/dist/core.js +1 -1
  11. package/dist/core.mjs +1 -1
  12. package/dist/css-macro/auto.d.ts +2 -1
  13. package/dist/css-macro.js +1 -1
  14. package/dist/css-macro.mjs +1 -1
  15. package/dist/{generator-CrU-Ghc1.js → generator-BEXaaUzP.js} +1 -1
  16. package/dist/{generator-Qw-tZ0Z2.mjs → generator-CpsHA4Wd.mjs} +1 -1
  17. package/dist/generator.js +2 -2
  18. package/dist/generator.mjs +2 -2
  19. package/dist/gulp.js +7 -7
  20. package/dist/gulp.mjs +6 -6
  21. package/dist/{incremental-runtime-class-set-FAOHZmzh.js → incremental-runtime-class-set-BE8RVbuz.js} +71 -9
  22. package/dist/{incremental-runtime-class-set-Boqi1QlB.mjs → incremental-runtime-class-set-BXYUYjCd.mjs} +70 -8
  23. package/dist/index.js +4 -4
  24. package/dist/index.mjs +4 -4
  25. package/dist/{postcss-C6zOQqlL.mjs → postcss-BvkdIZr8.mjs} +3 -3
  26. package/dist/{postcss-DAWf9D3C.js → postcss-DN7IQzYb.js} +4 -4
  27. package/dist/postcss.js +1 -1
  28. package/dist/postcss.mjs +1 -1
  29. package/dist/{precheck-D7gJSmJz.js → precheck-D_KT1pis.js} +8 -10
  30. package/dist/{precheck-D7K12zeX.mjs → precheck-mM9IVd1f.mjs} +8 -10
  31. package/dist/presets.js +4 -4
  32. package/dist/presets.mjs +3 -3
  33. package/dist/{source-candidates-DNM8iwXW.js → source-candidates-7Q-kTOSb.js} +1 -1
  34. package/dist/{source-candidates-CX2ozpKM.mjs → source-candidates-_x8bq0Mz.mjs} +1 -1
  35. package/dist/{tailwindcss-B-e2RiXr.js → tailwindcss-Cl7hUlYV.js} +3 -3
  36. package/dist/{tailwindcss-C7dJHZ0G.mjs → tailwindcss-udhXxMX9.mjs} +2 -2
  37. package/dist/{v3-engine-DcvCCHfs.mjs → v3-engine-C_KeUQG3.mjs} +6 -6
  38. package/dist/{v3-engine-CHItlVq5.js → v3-engine-DwY4Fixu.js} +7 -7
  39. package/dist/{vite-BgTPSkQS.js → vite-BVbIr2vs.js} +105 -44
  40. package/dist/{vite-fFRpSvyz.mjs → vite-C8vSTuBQ.mjs} +104 -43
  41. package/dist/vite.js +1 -1
  42. package/dist/vite.mjs +1 -1
  43. package/dist/weapp-tw-css-import-rewrite-loader.js +127 -7
  44. package/dist/{webpack-BXSWVdXh.js → webpack-DlHo84RT.js} +8 -8
  45. package/dist/{webpack-Dx2AZpGU.mjs → webpack-dva53gYi.mjs} +7 -7
  46. package/dist/webpack.js +1 -1
  47. package/dist/webpack.mjs +1 -1
  48. package/package.json +5 -5
  49. package/dist/auto-TH1jG2UW.js +0 -115
  50. package/dist/auto-XyKTOP7B.mjs +0 -78
@@ -30,7 +30,6 @@ _babel_traverse = require_runtime_registry.__toESM(_babel_traverse);
30
30
  require("@babel/parser");
31
31
  require("@babel/types");
32
32
  require("@ast-core/escape");
33
- require("@weapp-tailwindcss/shared/extractors");
34
33
  //#region src/bundlers/shared/css-imports.ts
35
34
  const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
36
35
  const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
@@ -278,6 +277,126 @@ const creator = () => {
278
277
  };
279
278
  creator.postcss = true;
280
279
  const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
280
+ const PLATFORM_ENV_KEYS = [
281
+ "WEAPP_TW_TARGET",
282
+ "WEAPP_TAILWINDCSS_TARGET",
283
+ "UNI_PLATFORM",
284
+ "UNI_UTS_PLATFORM",
285
+ "TARO_ENV",
286
+ "MPX_CLI_MODE",
287
+ "MPX_CURRENT_TARGET_MODE"
288
+ ];
289
+ const CONDITIONAL_END_RE = /^\s*#endif\s*$/;
290
+ function readEnvValue(key) {
291
+ return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
292
+ }
293
+ function normalizePlatformToken(value) {
294
+ return value?.trim().replaceAll("_", "-").toUpperCase() || void 0;
295
+ }
296
+ function resolveCssMacroPlatform(options) {
297
+ const explicit = normalizePlatformToken(options?.platform);
298
+ if (explicit) return explicit;
299
+ for (const key of PLATFORM_ENV_KEYS) {
300
+ const value = normalizePlatformToken(readEnvValue(key));
301
+ if (value) return value;
302
+ }
303
+ }
304
+ function createPlatformTokenSet(platform) {
305
+ const normalized = normalizePlatformToken(platform);
306
+ const tokens = /* @__PURE__ */ new Set();
307
+ if (!normalized) return tokens;
308
+ tokens.add(normalized);
309
+ if (normalized.startsWith("MP-")) tokens.add("MP");
310
+ if (normalized === "WEAPP" || normalized === "WEIXIN" || normalized === "WX") {
311
+ tokens.add("MP");
312
+ tokens.add("MP-WEIXIN");
313
+ }
314
+ if (normalized === "MP-WEIXIN") {
315
+ tokens.add("WEAPP");
316
+ tokens.add("WEIXIN");
317
+ tokens.add("WX");
318
+ }
319
+ if (normalized === "H5") tokens.add("WEB");
320
+ if (normalized === "WEB") tokens.add("H5");
321
+ if (normalized === "APP") tokens.add("APP-PLUS");
322
+ if (normalized.startsWith("APP-")) tokens.add("APP");
323
+ if (normalized.startsWith("QUICKAPP-WEBVIEW")) tokens.add("QUICKAPP-WEBVIEW");
324
+ return tokens;
325
+ }
326
+ function combineAnd(values) {
327
+ if (values.includes(false)) return false;
328
+ return values.every((value) => value === true) ? true : void 0;
329
+ }
330
+ function combineOr(values) {
331
+ if (values.includes(true)) return true;
332
+ return values.every((value) => value === false) ? false : void 0;
333
+ }
334
+ function evaluatePlatformExpression(expression, platformTokens) {
335
+ return combineOr(expression.split(/\s*\|\|\s*/).map((orPart) => {
336
+ return combineAnd(orPart.split(/\s*&&\s*/).map((part) => {
337
+ const token = normalizePlatformToken(part);
338
+ if (!token || /[<>=!()]/.test(token)) return;
339
+ return platformTokens.has(token);
340
+ }));
341
+ }));
342
+ }
343
+ function negateConditionalValue(value) {
344
+ return value === void 0 ? void 0 : !value;
345
+ }
346
+ function getActiveConditionalValue(stack) {
347
+ if (stack.includes(false)) return false;
348
+ return stack.includes(void 0) ? void 0 : true;
349
+ }
350
+ function parseConditionalStart(text) {
351
+ const normalized = text.trim();
352
+ if (!normalized.startsWith("#")) return;
353
+ const body = normalized.slice(1).trimStart();
354
+ for (const directive of ["ifndef", "ifdef"]) {
355
+ if (!body.startsWith(directive)) continue;
356
+ const expression = body.slice(directive.length).trim();
357
+ if (expression.length === 0) return;
358
+ return {
359
+ directive,
360
+ expression
361
+ };
362
+ }
363
+ }
364
+ function compileCssMacroConditionalComments(css, options) {
365
+ const platformTokens = createPlatformTokenSet(resolveCssMacroPlatform(options));
366
+ if (platformTokens.size === 0 || !css.includes("#if")) return css;
367
+ try {
368
+ const root = require_runtime_registry.postcss_default.parse(css);
369
+ const transformContainer = (container) => {
370
+ const stack = [];
371
+ for (const node of [...container.nodes ?? []]) {
372
+ if (node.type === "comment") {
373
+ const start = parseConditionalStart(node.text);
374
+ if (start) {
375
+ const value = start.directive === "ifndef" ? negateConditionalValue(evaluatePlatformExpression(start.expression, platformTokens)) : evaluatePlatformExpression(start.expression, platformTokens);
376
+ const parentActive = getActiveConditionalValue(stack);
377
+ stack.push(value);
378
+ if (parentActive !== void 0 && value !== void 0) node.remove();
379
+ continue;
380
+ }
381
+ if (CONDITIONAL_END_RE.test(node.text)) {
382
+ const value = stack.pop();
383
+ if (getActiveConditionalValue(stack) !== void 0 && value !== void 0) node.remove();
384
+ continue;
385
+ }
386
+ }
387
+ if (getActiveConditionalValue(stack) === false) {
388
+ node.remove();
389
+ continue;
390
+ }
391
+ if ("nodes" in node && node.nodes) transformContainer(node);
392
+ }
393
+ };
394
+ transformContainer(root);
395
+ return root.toString();
396
+ } catch {
397
+ return css;
398
+ }
399
+ }
281
400
  function isCssMacroTailwindPlugin(value) {
282
401
  return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
283
402
  }
@@ -338,8 +457,9 @@ function withCssMacroStyleOptions(options) {
338
457
  function hasCssMacroStyleOptions(options) {
339
458
  return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
340
459
  }
341
- async function transformCssMacroCss(css) {
342
- return (await require_runtime_registry.postcss_default([creator()]).process(css, { from: void 0 })).css;
460
+ async function transformCssMacroCss(css, options) {
461
+ const result = (await require_runtime_registry.postcss_default([creator()]).process(css, { from: void 0 })).css;
462
+ return compileCssMacroConditionalComments(result, options);
343
463
  }
344
464
  //#endregion
345
465
  //#region src/context/workspace.ts
@@ -912,7 +1032,7 @@ function normalizeTailwindV4GeneratedUrlValues(css) {
912
1032
  });
913
1033
  }
914
1034
  async function transformTailwindV4CssToWeapp(css, options) {
915
- const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
1035
+ const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
916
1036
  const result = await defaultStyleHandler$1(protectedCss.css, {
917
1037
  cssChildCombinatorReplaceValue: ["view", "text"],
918
1038
  cssRemoveHoverPseudoClass: true,
@@ -925,7 +1045,7 @@ async function transformTailwindV4CssToWeapp(css, options) {
925
1045
  }
926
1046
  async function transformTailwindV4CssByTarget(css, target, options) {
927
1047
  if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
928
- return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
1048
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
929
1049
  }
930
1050
  //#endregion
931
1051
  //#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
@@ -2625,7 +2745,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2625
2745
  }
2626
2746
  }
2627
2747
  async function transformTailwindV3CssToWeapp(css, options) {
2628
- const result = await defaultStyleHandler(css, {
2748
+ const result = await defaultStyleHandler(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css, {
2629
2749
  cssChildCombinatorReplaceValue: ["view", "text"],
2630
2750
  cssRemoveHoverPseudoClass: true,
2631
2751
  isMainChunk: true,
@@ -2640,7 +2760,7 @@ async function transformTailwindV3CssToWeapp(css, options) {
2640
2760
  }
2641
2761
  async function transformTailwindV3CssByTarget(css, target, options) {
2642
2762
  if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
2643
- return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
2763
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
2644
2764
  }
2645
2765
  //#endregion
2646
2766
  //#region src/tailwindcss/v3-engine/generator.ts
@@ -1,19 +1,19 @@
1
1
  const require_chunk = require("./chunk-C5U5_Hdc.js");
2
- const require_v3_engine = require("./v3-engine-CHItlVq5.js");
3
- const require_generator = require("./generator-CrU-Ghc1.js");
4
- const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-FAOHZmzh.js");
5
- const require_precheck = require("./precheck-D7gJSmJz.js");
2
+ const require_v3_engine = require("./v3-engine-DwY4Fixu.js");
3
+ const require_generator = require("./generator-BEXaaUzP.js");
4
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BE8RVbuz.js");
5
+ const require_precheck = require("./precheck-D_KT1pis.js");
6
6
  const require_utils = require("./utils-D7Ygohep.js");
7
- const require_tailwindcss = require("./tailwindcss-B-e2RiXr.js");
8
- const require_bundle_state = require("./bundle-state-Ct_8GcSR.js");
7
+ const require_tailwindcss = require("./tailwindcss-Cl7hUlYV.js");
8
+ const require_bundle_state = require("./bundle-state-Co_ksa-C.js");
9
9
  let node_fs = require("node:fs");
10
10
  node_fs = require_chunk.__toESM(node_fs);
11
11
  let node_module = require("node:module");
12
12
  node_module = require_chunk.__toESM(node_module);
13
- let node_path = require("node:path");
14
- node_path = require_chunk.__toESM(node_path);
15
13
  let node_process = require("node:process");
16
14
  node_process = require_chunk.__toESM(node_process);
15
+ let node_path = require("node:path");
16
+ node_path = require_chunk.__toESM(node_path);
17
17
  //#region src/shared/tailwindcss-css-redirect.ts
18
18
  const moduleWithMutableResolve = node_module.default;
19
19
  const patched = /* @__PURE__ */ new WeakSet();
@@ -1,14 +1,14 @@
1
- import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-D7K12zeX.mjs";
2
- import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-DcvCCHfs.mjs";
3
- import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-Qw-tZ0Z2.mjs";
4
- import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-Boqi1QlB.mjs";
1
+ import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-mM9IVd1f.mjs";
2
+ import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-C_KeUQG3.mjs";
3
+ import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CpsHA4Wd.mjs";
4
+ import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-BXYUYjCd.mjs";
5
5
  import { r as getGroupedEntries } from "./utils-DsaS975I.mjs";
6
- import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-C7dJHZ0G.mjs";
7
- import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-Bi-cQua6.mjs";
6
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-udhXxMX9.mjs";
7
+ import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-DUIidcox.mjs";
8
8
  import Module, { createRequire } from "node:module";
9
9
  import fs from "node:fs";
10
- import path from "node:path";
11
10
  import process from "node:process";
11
+ import path from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  //#region src/shared/tailwindcss-css-redirect.ts
14
14
  const moduleWithMutableResolve = Module;
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_webpack = require("./webpack-BXSWVdXh.js");
2
+ const require_webpack = require("./webpack-DlHo84RT.js");
3
3
  exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
4
4
  exports.weappTailwindcss = require_webpack.WeappTailwindcss;
5
5
  exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
package/dist/webpack.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-Dx2AZpGU.mjs";
1
+ import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-dva53gYi.mjs";
2
2
  export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "5.0.0-next.31",
3
+ "version": "5.0.0-next.33",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -182,13 +182,13 @@
182
182
  "micromatch": "^4.0.8",
183
183
  "postcss-load-config": "^6.0.1",
184
184
  "semver": "~7.8.1",
185
- "tailwindcss-patch": "9.3.7",
185
+ "tailwindcss-patch": "9.4.1",
186
186
  "yaml": "^2.9.0",
187
187
  "@weapp-tailwindcss/logger": "2.0.0-next.0",
188
- "@weapp-tailwindcss/postcss": "3.0.0-next.8",
188
+ "@weapp-tailwindcss/postcss": "3.0.0-next.9",
189
189
  "@weapp-tailwindcss/reset": "0.1.1-next.1",
190
- "@weapp-tailwindcss/shared": "2.0.0-next.0",
191
- "tailwindcss-config": "2.0.0-next.2"
190
+ "@weapp-tailwindcss/shared": "2.0.0-next.1",
191
+ "tailwindcss-config": "2.0.0-next.3"
192
192
  },
193
193
  "devDependencies": {
194
194
  "@vue/compiler-dom": "^3.5.35",
@@ -1,115 +0,0 @@
1
- const require_chunk = require("./chunk-C5U5_Hdc.js");
2
- const require_postcss = require("./postcss-CiYLsqZn.js");
3
- let postcss = require("postcss");
4
- postcss = require_chunk.__toESM(postcss);
5
- //#region src/css-macro/auto.ts
6
- const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
7
- const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
8
- function markCssMacroPlugin(value) {
9
- Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
10
- configurable: false,
11
- enumerable: false,
12
- value: true
13
- });
14
- return value;
15
- }
16
- function isCssMacroTailwindPlugin(value) {
17
- return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
18
- }
19
- function hasCssMacroTailwindPlugin(plugins) {
20
- if (!plugins) return false;
21
- if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
22
- if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
23
- return false;
24
- }
25
- function parseCssPluginRequest(params) {
26
- const value = params.trim();
27
- const quoted = /^(['"])(.*?)\1/.exec(value);
28
- if (quoted) return quoted[2];
29
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
30
- return url?.[2] ?? url?.[3];
31
- }
32
- function isCssMacroPluginRequest(request) {
33
- return request === "weapp-tailwindcss/css-macro";
34
- }
35
- function hasCssMacroTailwindV4Directive(css) {
36
- if (!css?.includes("css-macro")) return false;
37
- try {
38
- let found = false;
39
- postcss.default.parse(css).walkAtRules("plugin", (rule) => {
40
- if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
41
- });
42
- return found;
43
- } catch {
44
- return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
45
- }
46
- }
47
- function isCssMacroPostcssPlugin(plugin) {
48
- if (plugin === require_postcss.creator) return true;
49
- return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
50
- }
51
- function withCssMacroPostcssPlugins(plugins) {
52
- const macroPlugin = require_postcss.creator();
53
- if (!plugins) return [macroPlugin];
54
- if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
55
- if (typeof plugins === "object") {
56
- const values = Object.values(plugins).filter(Boolean);
57
- if (values.some(isCssMacroPostcssPlugin)) return values;
58
- return [...values, macroPlugin];
59
- }
60
- return [macroPlugin];
61
- }
62
- function withCssMacroStyleOptions(options) {
63
- const postcssOptions = options?.postcssOptions;
64
- return {
65
- ...options,
66
- [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
67
- postcssOptions: {
68
- ...postcssOptions,
69
- plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
70
- }
71
- };
72
- }
73
- function hasCssMacroStyleOptions(options) {
74
- return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
75
- }
76
- async function transformCssMacroCss(css) {
77
- return (await (0, postcss.default)([require_postcss.creator()]).process(css, { from: void 0 })).css;
78
- }
79
- //#endregion
80
- Object.defineProperty(exports, "hasCssMacroStyleOptions", {
81
- enumerable: true,
82
- get: function() {
83
- return hasCssMacroStyleOptions;
84
- }
85
- });
86
- Object.defineProperty(exports, "hasCssMacroTailwindPlugin", {
87
- enumerable: true,
88
- get: function() {
89
- return hasCssMacroTailwindPlugin;
90
- }
91
- });
92
- Object.defineProperty(exports, "hasCssMacroTailwindV4Directive", {
93
- enumerable: true,
94
- get: function() {
95
- return hasCssMacroTailwindV4Directive;
96
- }
97
- });
98
- Object.defineProperty(exports, "markCssMacroPlugin", {
99
- enumerable: true,
100
- get: function() {
101
- return markCssMacroPlugin;
102
- }
103
- });
104
- Object.defineProperty(exports, "transformCssMacroCss", {
105
- enumerable: true,
106
- get: function() {
107
- return transformCssMacroCss;
108
- }
109
- });
110
- Object.defineProperty(exports, "withCssMacroStyleOptions", {
111
- enumerable: true,
112
- get: function() {
113
- return withCssMacroStyleOptions;
114
- }
115
- });
@@ -1,78 +0,0 @@
1
- import { n as creator } from "./postcss-C7BMYpEF.mjs";
2
- import postcss from "postcss";
3
- //#region src/css-macro/auto.ts
4
- const CSS_MACRO_PLUGIN_MARKER = "__weappTailwindcssCssMacro";
5
- const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
6
- function markCssMacroPlugin(value) {
7
- Object.defineProperty(value, CSS_MACRO_PLUGIN_MARKER, {
8
- configurable: false,
9
- enumerable: false,
10
- value: true
11
- });
12
- return value;
13
- }
14
- function isCssMacroTailwindPlugin(value) {
15
- return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
16
- }
17
- function hasCssMacroTailwindPlugin(plugins) {
18
- if (!plugins) return false;
19
- if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
20
- if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
21
- return false;
22
- }
23
- function parseCssPluginRequest(params) {
24
- const value = params.trim();
25
- const quoted = /^(['"])(.*?)\1/.exec(value);
26
- if (quoted) return quoted[2];
27
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
28
- return url?.[2] ?? url?.[3];
29
- }
30
- function isCssMacroPluginRequest(request) {
31
- return request === "weapp-tailwindcss/css-macro";
32
- }
33
- function hasCssMacroTailwindV4Directive(css) {
34
- if (!css?.includes("css-macro")) return false;
35
- try {
36
- let found = false;
37
- postcss.parse(css).walkAtRules("plugin", (rule) => {
38
- if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
39
- });
40
- return found;
41
- } catch {
42
- return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
43
- }
44
- }
45
- function isCssMacroPostcssPlugin(plugin) {
46
- if (plugin === creator) return true;
47
- return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
48
- }
49
- function withCssMacroPostcssPlugins(plugins) {
50
- const macroPlugin = creator();
51
- if (!plugins) return [macroPlugin];
52
- if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
53
- if (typeof plugins === "object") {
54
- const values = Object.values(plugins).filter(Boolean);
55
- if (values.some(isCssMacroPostcssPlugin)) return values;
56
- return [...values, macroPlugin];
57
- }
58
- return [macroPlugin];
59
- }
60
- function withCssMacroStyleOptions(options) {
61
- const postcssOptions = options?.postcssOptions;
62
- return {
63
- ...options,
64
- [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
65
- postcssOptions: {
66
- ...postcssOptions,
67
- plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
68
- }
69
- };
70
- }
71
- function hasCssMacroStyleOptions(options) {
72
- return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
73
- }
74
- async function transformCssMacroCss(css) {
75
- return (await postcss([creator()]).process(css, { from: void 0 })).css;
76
- }
77
- //#endregion
78
- export { transformCssMacroCss as a, markCssMacroPlugin as i, hasCssMacroTailwindPlugin as n, withCssMacroStyleOptions as o, hasCssMacroTailwindV4Directive as r, hasCssMacroStyleOptions as t };