weapp-tailwindcss 5.1.4 → 5.1.6

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 (69) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
  4. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
  5. package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
  6. package/dist/bundlers/shared/generator-css/user-css.d.ts +4 -1
  7. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +1 -0
  8. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
  9. package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
  10. package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
  11. package/dist/bundlers/vite/processed-css-assets.d.ts +7 -0
  12. package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
  13. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
  14. package/dist/cli.js +18 -3
  15. package/dist/cli.mjs +16 -1
  16. package/dist/{context-Bkpmt3ja.mjs → context-3GGqW9vw.mjs} +20 -5
  17. package/dist/{context-DCVMkTRj.js → context-BCSk_YnL.js} +23 -8
  18. package/dist/core.js +1 -1
  19. package/dist/core.mjs +1 -1
  20. package/dist/css-macro/index.d.ts +2 -1
  21. package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
  22. package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
  23. package/dist/defaults.d.ts +1 -1
  24. package/dist/defaults.js +1 -1
  25. package/dist/defaults.mjs +1 -1
  26. package/dist/{generator-24-HgU9F.mjs → generator-CoT5vu9w.mjs} +2 -2
  27. package/dist/{generator-CilgHtxb.js → generator-CqWzj2Z1.js} +2 -2
  28. package/dist/generator.js +2 -2
  29. package/dist/generator.mjs +2 -2
  30. package/dist/{gulp-0RsqkF_d.mjs → gulp-Bss4wJ8t.mjs} +4 -4
  31. package/dist/{gulp-Bogfnoki.js → gulp-hXE1U4Cu.js} +4 -4
  32. package/dist/gulp.js +1 -1
  33. package/dist/gulp.mjs +1 -1
  34. package/dist/{hmr-timing-BRNaz8Od.mjs → hmr-timing-Cfu-4Bnf.mjs} +229 -576
  35. package/dist/{hmr-timing-BV6nFPoT.js → hmr-timing-Df4203aI.js} +253 -630
  36. package/dist/index.js +4 -4
  37. package/dist/index.mjs +4 -4
  38. package/dist/js/js-string-escape.d.ts +1 -0
  39. package/dist/postcss.js +2 -2
  40. package/dist/postcss.mjs +2 -2
  41. package/dist/presets.js +6 -3
  42. package/dist/presets.mjs +6 -3
  43. package/dist/rspack.js +1 -1
  44. package/dist/rspack.mjs +1 -1
  45. package/dist/runtime-branch/generator-target-env.d.ts +1 -0
  46. package/dist/{source-candidate-scan-signature-CaDT0gkj.js → source-candidate-scan-signature-5Uk6U72B.js} +168 -5
  47. package/dist/{source-candidate-scan-signature-BB1hvW68.mjs → source-candidate-scan-signature-BbCmW975.mjs} +157 -6
  48. package/dist/style-injector/internal.d.ts +7 -0
  49. package/dist/style-injector/options.d.ts +25 -0
  50. package/dist/tailwindcss/v4/preflight.d.ts +4 -0
  51. package/dist/{tailwindcss-D0JF0fuZ.mjs → tailwindcss-Bjr3aphG.mjs} +62 -15
  52. package/dist/{tailwindcss-D2xs4OEu.js → tailwindcss-DYJ3HZD2.js} +67 -14
  53. package/dist/{transform-BP86eSZp.mjs → transform--155BmeJ.mjs} +1 -1
  54. package/dist/{transform-CXCQ28Tc.js → transform-B6_y_yCB.js} +1 -1
  55. package/dist/typedoc.export.d.ts +1 -0
  56. package/dist/types/index.d.ts +2 -1
  57. package/dist/types/user-defined-options/general.d.ts +2 -0
  58. package/dist/{v4-engine-CKtsdKxK.js → v4-engine-C9cmNlP8.js} +610 -3
  59. package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-DRQaCFMm.mjs} +529 -6
  60. package/dist/{vite-BYgT1ir9.js → vite-Baw9qNrc.js} +652 -140
  61. package/dist/{vite-B1SlBmqO.mjs → vite-PdxjaqhO.mjs} +653 -141
  62. package/dist/vite.js +1 -1
  63. package/dist/vite.mjs +1 -1
  64. package/dist/weapp-tw-css-import-rewrite-loader.js +2981 -2752
  65. package/dist/{webpack-Bg6pefpb.mjs → webpack-BffTDmod.mjs} +69 -26
  66. package/dist/{webpack-khSwkXP5.js → webpack-C9u7mfGE.js} +74 -31
  67. package/dist/webpack.js +1 -1
  68. package/dist/webpack.mjs +1 -1
  69. package/package.json +16 -5
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_framework = require("./framework.js");
3
- const require_generator = require("./generator-CilgHtxb.js");
4
- const require_gulp = require("./gulp-Bogfnoki.js");
3
+ const require_generator = require("./generator-CqWzj2Z1.js");
4
+ const require_gulp = require("./gulp-hXE1U4Cu.js");
5
5
  const require_postcss = require("./postcss.js");
6
- const require_vite = require("./vite-BYgT1ir9.js");
7
- const require_webpack = require("./webpack-khSwkXP5.js");
6
+ const require_vite = require("./vite-Baw9qNrc.js");
7
+ const require_webpack = require("./webpack-C9u7mfGE.js");
8
8
  require("./webpack.js");
9
9
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
10
10
  exports.WeappTailwindcss = require_vite.WeappTailwindcss;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform } from "./framework.mjs";
2
- import { t as createWeappTailwindcssGenerator } from "./generator-24-HgU9F.mjs";
3
- import { t as createPlugins } from "./gulp-0RsqkF_d.mjs";
2
+ import { t as createWeappTailwindcssGenerator } from "./generator-CoT5vu9w.mjs";
3
+ import { t as createPlugins } from "./gulp-Bss4wJ8t.mjs";
4
4
  import weappTailwindcssPostcssPlugin from "./postcss.mjs";
5
- import { t as WeappTailwindcss } from "./vite-B1SlBmqO.mjs";
6
- import { n as weappTailwindcssPackageDir } from "./webpack-Bg6pefpb.mjs";
5
+ import { t as WeappTailwindcss } from "./vite-PdxjaqhO.mjs";
6
+ import { n as weappTailwindcssPackageDir } from "./webpack-BffTDmod.mjs";
7
7
  import "./webpack.mjs";
8
8
  import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
9
9
  export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
@@ -0,0 +1 @@
1
+ export declare function jsStringEscape(value: unknown): string;
package/dist/postcss.js CHANGED
@@ -2,8 +2,8 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
6
- const require_generator = require("./generator-CilgHtxb.js");
5
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
6
+ const require_generator = require("./generator-CqWzj2Z1.js");
7
7
  const weappTailwindcssPostcssPlugin = (0, require("@weapp-tailwindcss/postcss").createWeappTailwindcssPostcssPlugin)({
8
8
  createGenerator: (source) => {
9
9
  return require_generator.createWeappTailwindcssGenerator(source);
package/dist/postcss.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as resolveTailwindV4Source } from "./v4-engine-BuuYDXt1.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-24-HgU9F.mjs";
1
+ import { t as resolveTailwindV4Source } from "./v4-engine-DRQaCFMm.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-CoT5vu9w.mjs";
3
3
  import { createWeappTailwindcssPostcssPlugin } from "@weapp-tailwindcss/postcss";
4
4
  const weappTailwindcssPostcssPlugin = createWeappTailwindcssPostcssPlugin({
5
5
  createGenerator: (source) => {
package/dist/presets.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
3
3
  const require_framework = require("./framework.js");
4
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
4
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
5
5
  require("./utils-D3h8j7Mk.js");
6
- const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
6
+ const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
7
7
  require("./logger-TlKT3xmR.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_rolldown_runtime.__toESM(node_path);
@@ -57,7 +57,10 @@ function createBasePreset(options = {}) {
57
57
  //#endregion
58
58
  //#region src/presets/hbuilderx.ts
59
59
  function hbuilderx(options = {}) {
60
- return createBasePreset(withWebCompatGeneratorDefaults({ ...options }));
60
+ return createBasePreset(withWebCompatGeneratorDefaults({
61
+ appType: "uni-app-vite",
62
+ ...options
63
+ }));
61
64
  }
62
65
  //#endregion
63
66
  //#region src/presets/uni-app.ts
package/dist/presets.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { resolveTaroPlatform, resolveUniPlatformsFromEnv } from "./framework.mjs";
2
- import { ct as omitUndefined } from "./v4-engine-BuuYDXt1.mjs";
2
+ import { Et as omitUndefined } from "./v4-engine-DRQaCFMm.mjs";
3
3
  import { n as defuOverrideArray } from "./utils-DodxWHGz.mjs";
4
- import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-D0JF0fuZ.mjs";
4
+ import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-Bjr3aphG.mjs";
5
5
  import { t as logger } from "./logger-BNzxZbZj.mjs";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
@@ -51,7 +51,10 @@ function createBasePreset(options = {}) {
51
51
  //#endregion
52
52
  //#region src/presets/hbuilderx.ts
53
53
  function hbuilderx(options = {}) {
54
- return createBasePreset(withWebCompatGeneratorDefaults({ ...options }));
54
+ return createBasePreset(withWebCompatGeneratorDefaults({
55
+ appType: "uni-app-vite",
56
+ ...options
57
+ }));
55
58
  }
56
59
  //#endregion
57
60
  //#region src/presets/uni-app.ts
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
3
- const require_webpack = require("./webpack-khSwkXP5.js");
3
+ const require_webpack = require("./webpack-C9u7mfGE.js");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_rolldown_runtime.__toESM(node_path);
6
6
  //#region src/bundlers/rspack/index.ts
package/dist/rspack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-Bg6pefpb.mjs";
1
+ import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-BffTDmod.mjs";
2
2
  import path from "node:path";
3
3
  //#region src/bundlers/rspack/index.ts
4
4
  const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
@@ -1,4 +1,5 @@
1
1
  import type { WeappTailwindcssGeneratorTarget } from './types';
2
2
  export declare const generatorTargetEnvKeys: readonly ["UNI_PLATFORM", "UNI_UTS_PLATFORM", "MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE", "TARO_ENV", "WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
3
3
  export declare function shouldUseWebGeneratorTargetFromEnv(): boolean;
4
+ export declare function shouldUseUniAppViteWebViewGeneratorTarget(appType: string | undefined, platform?: string | undefined): boolean;
4
5
  export declare function inferGeneratorTargetFromEnv(): WeappTailwindcssGeneratorTarget;
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
2
  require("./auto-DtU6f3X6.js");
3
- const require_context = require("./context-DCVMkTRj.js");
4
- const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
5
- const require_hmr_timing = require("./hmr-timing-BV6nFPoT.js");
3
+ const require_context = require("./context-BCSk_YnL.js");
4
+ const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
5
+ const require_hmr_timing = require("./hmr-timing-Df4203aI.js");
6
6
  let node_path = require("node:path");
7
7
  node_path = require_rolldown_runtime.__toESM(node_path);
8
8
  let node_process = require("node:process");
@@ -10,7 +10,148 @@ node_process = require_rolldown_runtime.__toESM(node_process);
10
10
  let node_module = require("node:module");
11
11
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
12
12
  let node_buffer = require("node:buffer");
13
+ let weapp_style_injector_vite = require("weapp-style-injector/vite");
14
+ let weapp_style_injector_vite_taro = require("weapp-style-injector/vite/taro");
15
+ let weapp_style_injector_vite_uni_app = require("weapp-style-injector/vite/uni-app");
16
+ let weapp_style_injector_webpack = require("weapp-style-injector/webpack");
17
+ let weapp_style_injector_webpack_mpx = require("weapp-style-injector/webpack/mpx");
18
+ let weapp_style_injector_webpack_taro = require("weapp-style-injector/webpack/taro");
19
+ let weapp_style_injector_webpack_uni_app = require("weapp-style-injector/webpack/uni-app");
13
20
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
21
+ //#region src/style-injector/options.ts
22
+ function normalizeStyleInjectorOptions(options) {
23
+ if (options === true) return {};
24
+ if (!options) return;
25
+ return options;
26
+ }
27
+ //#endregion
28
+ //#region src/style-injector/internal.ts
29
+ function toPluginArray(pluginOrPlugins) {
30
+ return Array.isArray(pluginOrPlugins) ? pluginOrPlugins : [pluginOrPlugins];
31
+ }
32
+ function isUniAppViteStyleInjectorApp(appType) {
33
+ return appType === "uni-app-vite" || appType === "uni-app-x";
34
+ }
35
+ function isUniAppWebpackStyleInjectorApp(appType) {
36
+ return appType === "uni-app" || appType === "uni-app-vite" || appType === "uni-app-x";
37
+ }
38
+ function normalizeWebpackStyleInjectorOptions(options) {
39
+ const normalized = normalizeStyleInjectorOptions(options);
40
+ if (!normalized) return;
41
+ const { generateSubpackageStyle, loadSubpackageTargetStyle, ...rest } = normalized;
42
+ const webpackOptions = { ...rest };
43
+ if (generateSubpackageStyle) webpackOptions.generateSubpackageStyle = (context) => {
44
+ const generated = generateSubpackageStyle(context);
45
+ if (generated && typeof generated.then === "function") throw new TypeError("[weapp-style-injector] Webpack subpackage style generators must return synchronously.");
46
+ return generated;
47
+ };
48
+ if (loadSubpackageTargetStyle) webpackOptions.loadSubpackageTargetStyle = (fileName, sourceAbsolutePath) => {
49
+ const loaded = loadSubpackageTargetStyle(fileName, sourceAbsolutePath);
50
+ if (loaded && typeof loaded.then === "function") throw new TypeError("[weapp-style-injector] Webpack subpackage target style loaders must return synchronously.");
51
+ return loaded;
52
+ };
53
+ return webpackOptions;
54
+ }
55
+ function getTransformHandler(hook) {
56
+ if (typeof hook === "function") return hook;
57
+ if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
58
+ }
59
+ function getGenerateBundleHandler(hook) {
60
+ if (typeof hook === "function") return hook;
61
+ if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
62
+ }
63
+ function createBuiltinViteStyleInjectorPlugins(options, getAppType) {
64
+ const normalized = normalizeStyleInjectorOptions(options);
65
+ if (!normalized) return [];
66
+ let config;
67
+ let delegates;
68
+ let delegatesConfigured = false;
69
+ let delegatesBuildStarted = false;
70
+ const resolveDelegates = () => {
71
+ if (delegates) return delegates;
72
+ const appType = getAppType();
73
+ if (isUniAppViteStyleInjectorApp(appType)) delegates = toPluginArray((0, weapp_style_injector_vite_uni_app.StyleInjector)(normalized));
74
+ else if (appType === "taro") delegates = toPluginArray((0, weapp_style_injector_vite_taro.StyleInjector)(normalized));
75
+ else delegates = [(0, weapp_style_injector_vite.weappStyleInjector)(normalized)];
76
+ return delegates;
77
+ };
78
+ const configureDelegates = async () => {
79
+ if (delegatesConfigured || !config) return;
80
+ delegatesConfigured = true;
81
+ for (const plugin of resolveDelegates()) if (typeof plugin.configResolved === "function") await plugin.configResolved(config);
82
+ };
83
+ const startDelegates = async (context) => {
84
+ if (delegatesBuildStarted) return;
85
+ await configureDelegates();
86
+ delegatesBuildStarted = true;
87
+ for (const plugin of resolveDelegates()) if (typeof plugin.buildStart === "function") await plugin.buildStart.call(context, {});
88
+ };
89
+ return [{
90
+ name: "weapp-tailwindcss:style-injector-pre",
91
+ apply: "build",
92
+ enforce: "pre",
93
+ configResolved(resolvedConfig) {
94
+ config = resolvedConfig;
95
+ },
96
+ async buildStart() {
97
+ await startDelegates(this);
98
+ },
99
+ async load(id, options) {
100
+ await configureDelegates();
101
+ for (const plugin of resolveDelegates()) {
102
+ if (typeof plugin.load !== "function") continue;
103
+ const result = await plugin.load.call(this, id, options);
104
+ if (result != null) return result;
105
+ }
106
+ },
107
+ async transform(code, id, options) {
108
+ await configureDelegates();
109
+ let currentCode = code;
110
+ let changed = false;
111
+ for (const plugin of resolveDelegates()) {
112
+ const handler = getTransformHandler(plugin.transform);
113
+ if (!handler) continue;
114
+ const result = await handler.call(this, currentCode, id, options);
115
+ if (!result) continue;
116
+ if (typeof result === "string") {
117
+ currentCode = result;
118
+ changed = true;
119
+ } else if (typeof result === "object" && typeof result.code === "string") {
120
+ currentCode = result.code;
121
+ changed = true;
122
+ }
123
+ }
124
+ if (changed) return {
125
+ code: currentCode,
126
+ map: null
127
+ };
128
+ }
129
+ }, {
130
+ name: "weapp-tailwindcss:style-injector",
131
+ apply: "build",
132
+ enforce: "post",
133
+ configResolved(resolvedConfig) {
134
+ config = resolvedConfig;
135
+ },
136
+ async generateBundle(outputOptions, bundle, isWrite) {
137
+ await configureDelegates();
138
+ for (const plugin of resolveDelegates()) {
139
+ const handler = getGenerateBundleHandler(plugin.generateBundle);
140
+ if (!handler) continue;
141
+ await handler.call(this, outputOptions, bundle, isWrite);
142
+ }
143
+ }
144
+ }];
145
+ }
146
+ function createBuiltinWebpackStyleInjectorPlugin(options, appType) {
147
+ const normalized = normalizeWebpackStyleInjectorOptions(options);
148
+ if (!normalized) return;
149
+ if (isUniAppWebpackStyleInjectorApp(appType)) return (0, weapp_style_injector_webpack_uni_app.StyleInjector)(normalized);
150
+ if (appType === "taro") return (0, weapp_style_injector_webpack_taro.StyleInjector)(normalized);
151
+ if (appType === "mpx") return (0, weapp_style_injector_webpack_mpx.StyleInjector)(normalized);
152
+ return (0, weapp_style_injector_webpack.weappStyleInjectorWebpack)(normalized);
153
+ }
154
+ //#endregion
14
155
  //#region src/bundlers/shared/module-graph.ts
15
156
  const QUERY_HASH_RE = /[?#].*$/u;
16
157
  const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
@@ -509,6 +650,14 @@ function intersectCandidates(first, second) {
509
650
  function mergeCandidates(first, second) {
510
651
  return /* @__PURE__ */ new Set([...first, ...second]);
511
652
  }
653
+ function intersectExplicitSourceCandidates(scopedCandidates, localCandidates) {
654
+ if (localCandidates.size === 0 && scopedCandidates.size > 0) return scopedCandidates;
655
+ return intersectCandidates(scopedCandidates, localCandidates);
656
+ }
657
+ function resolveExplicitSourceCandidates(scopedCandidates, localCandidates, fallbackCandidates) {
658
+ if (scopedCandidates.size === 0 && localCandidates.size === 0 && fallbackCandidates?.size) return fallbackCandidates;
659
+ return intersectExplicitSourceCandidates(scopedCandidates, localCandidates);
660
+ }
512
661
  function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries) {
513
662
  if (!hasOwnSourceDirectives(rawSource)) return {
514
663
  entries: resolvedEntries,
@@ -529,7 +678,7 @@ async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fa
529
678
  const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await require_tailwindcss.resolveTailwindV4EntriesFromCssCached(rawSource, node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
530
679
  if (entries === void 0) return fallbackSignature;
531
680
  const scopedCandidates = getSourceCandidatesForEntries(entries);
532
- const scopedSignature = createCandidateSignature(localEntries ? intersectCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries)) : scopedCandidates);
681
+ const scopedSignature = createCandidateSignature(localEntries ? resolveExplicitSourceCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries), getSourceCandidatesForEntries(void 0)) : scopedCandidates);
533
682
  return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
534
683
  }
535
684
  async function createScopedGeneratorRuntime(options) {
@@ -540,7 +689,9 @@ async function createScopedGeneratorRuntime(options) {
540
689
  const scopedCandidates = scopedSourceCandidateGetter?.(entries) ?? getSourceCandidatesForEntries(entries);
541
690
  const shouldMergeFallbackRuntime = (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4CustomVariantConditionalComments)(rawSource);
542
691
  if (!localEntries) return shouldMergeFallbackRuntime ? mergeCandidates(scopedCandidates, fallbackRuntime) : scopedCandidates;
543
- const scopedLocalCandidates = intersectCandidates(scopedCandidates, scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries));
692
+ const localCandidates = scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries);
693
+ const fallbackCandidates = scopedSourceCandidateGetter?.(void 0);
694
+ const scopedLocalCandidates = resolveExplicitSourceCandidates(scopedCandidates, localCandidates, fallbackCandidates);
544
695
  return shouldMergeFallbackRuntime ? mergeCandidates(scopedLocalCandidates, fallbackRuntime) : scopedLocalCandidates;
545
696
  }
546
697
  }
@@ -597,6 +748,18 @@ Object.defineProperty(exports, "classifyBundleEntry", {
597
748
  return classifyBundleEntry;
598
749
  }
599
750
  });
751
+ Object.defineProperty(exports, "createBuiltinViteStyleInjectorPlugins", {
752
+ enumerable: true,
753
+ get: function() {
754
+ return createBuiltinViteStyleInjectorPlugins;
755
+ }
756
+ });
757
+ Object.defineProperty(exports, "createBuiltinWebpackStyleInjectorPlugin", {
758
+ enumerable: true,
759
+ get: function() {
760
+ return createBuiltinWebpackStyleInjectorPlugin;
761
+ }
762
+ });
600
763
  Object.defineProperty(exports, "createBundleBuildState", {
601
764
  enumerable: true,
602
765
  get: function() {
@@ -1,12 +1,153 @@
1
1
  import { n as hasCssMacroTailwindV4CustomVariantConditionalComments } from "./auto-CrJJc5rK.mjs";
2
- import { g as traverse, h as babelParse, o as Parser } from "./context-Bkpmt3ja.mjs";
3
- import { g as resolveTailwindV4EntriesFromCssCached } from "./tailwindcss-D0JF0fuZ.mjs";
4
- import { u as generateCssByGenerator } from "./hmr-timing-BRNaz8Od.mjs";
2
+ import { g as traverse, h as babelParse, o as Parser } from "./context-3GGqW9vw.mjs";
3
+ import { g as resolveTailwindV4EntriesFromCssCached } from "./tailwindcss-Bjr3aphG.mjs";
4
+ import { u as generateCssByGenerator } from "./hmr-timing-Cfu-4Bnf.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
8
8
  import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
9
9
  import { Buffer } from "node:buffer";
10
+ import { weappStyleInjector } from "weapp-style-injector/vite";
11
+ import { StyleInjector } from "weapp-style-injector/vite/taro";
12
+ import { StyleInjector as StyleInjector$1 } from "weapp-style-injector/vite/uni-app";
13
+ import { weappStyleInjectorWebpack } from "weapp-style-injector/webpack";
14
+ import { StyleInjector as StyleInjector$2 } from "weapp-style-injector/webpack/mpx";
15
+ import { StyleInjector as StyleInjector$3 } from "weapp-style-injector/webpack/taro";
16
+ import { StyleInjector as StyleInjector$4 } from "weapp-style-injector/webpack/uni-app";
17
+ //#region src/style-injector/options.ts
18
+ function normalizeStyleInjectorOptions(options) {
19
+ if (options === true) return {};
20
+ if (!options) return;
21
+ return options;
22
+ }
23
+ //#endregion
24
+ //#region src/style-injector/internal.ts
25
+ function toPluginArray(pluginOrPlugins) {
26
+ return Array.isArray(pluginOrPlugins) ? pluginOrPlugins : [pluginOrPlugins];
27
+ }
28
+ function isUniAppViteStyleInjectorApp(appType) {
29
+ return appType === "uni-app-vite" || appType === "uni-app-x";
30
+ }
31
+ function isUniAppWebpackStyleInjectorApp(appType) {
32
+ return appType === "uni-app" || appType === "uni-app-vite" || appType === "uni-app-x";
33
+ }
34
+ function normalizeWebpackStyleInjectorOptions(options) {
35
+ const normalized = normalizeStyleInjectorOptions(options);
36
+ if (!normalized) return;
37
+ const { generateSubpackageStyle, loadSubpackageTargetStyle, ...rest } = normalized;
38
+ const webpackOptions = { ...rest };
39
+ if (generateSubpackageStyle) webpackOptions.generateSubpackageStyle = (context) => {
40
+ const generated = generateSubpackageStyle(context);
41
+ if (generated && typeof generated.then === "function") throw new TypeError("[weapp-style-injector] Webpack subpackage style generators must return synchronously.");
42
+ return generated;
43
+ };
44
+ if (loadSubpackageTargetStyle) webpackOptions.loadSubpackageTargetStyle = (fileName, sourceAbsolutePath) => {
45
+ const loaded = loadSubpackageTargetStyle(fileName, sourceAbsolutePath);
46
+ if (loaded && typeof loaded.then === "function") throw new TypeError("[weapp-style-injector] Webpack subpackage target style loaders must return synchronously.");
47
+ return loaded;
48
+ };
49
+ return webpackOptions;
50
+ }
51
+ function getTransformHandler(hook) {
52
+ if (typeof hook === "function") return hook;
53
+ if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
54
+ }
55
+ function getGenerateBundleHandler(hook) {
56
+ if (typeof hook === "function") return hook;
57
+ if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
58
+ }
59
+ function createBuiltinViteStyleInjectorPlugins(options, getAppType) {
60
+ const normalized = normalizeStyleInjectorOptions(options);
61
+ if (!normalized) return [];
62
+ let config;
63
+ let delegates;
64
+ let delegatesConfigured = false;
65
+ let delegatesBuildStarted = false;
66
+ const resolveDelegates = () => {
67
+ if (delegates) return delegates;
68
+ const appType = getAppType();
69
+ if (isUniAppViteStyleInjectorApp(appType)) delegates = toPluginArray(StyleInjector$1(normalized));
70
+ else if (appType === "taro") delegates = toPluginArray(StyleInjector(normalized));
71
+ else delegates = [weappStyleInjector(normalized)];
72
+ return delegates;
73
+ };
74
+ const configureDelegates = async () => {
75
+ if (delegatesConfigured || !config) return;
76
+ delegatesConfigured = true;
77
+ for (const plugin of resolveDelegates()) if (typeof plugin.configResolved === "function") await plugin.configResolved(config);
78
+ };
79
+ const startDelegates = async (context) => {
80
+ if (delegatesBuildStarted) return;
81
+ await configureDelegates();
82
+ delegatesBuildStarted = true;
83
+ for (const plugin of resolveDelegates()) if (typeof plugin.buildStart === "function") await plugin.buildStart.call(context, {});
84
+ };
85
+ return [{
86
+ name: "weapp-tailwindcss:style-injector-pre",
87
+ apply: "build",
88
+ enforce: "pre",
89
+ configResolved(resolvedConfig) {
90
+ config = resolvedConfig;
91
+ },
92
+ async buildStart() {
93
+ await startDelegates(this);
94
+ },
95
+ async load(id, options) {
96
+ await configureDelegates();
97
+ for (const plugin of resolveDelegates()) {
98
+ if (typeof plugin.load !== "function") continue;
99
+ const result = await plugin.load.call(this, id, options);
100
+ if (result != null) return result;
101
+ }
102
+ },
103
+ async transform(code, id, options) {
104
+ await configureDelegates();
105
+ let currentCode = code;
106
+ let changed = false;
107
+ for (const plugin of resolveDelegates()) {
108
+ const handler = getTransformHandler(plugin.transform);
109
+ if (!handler) continue;
110
+ const result = await handler.call(this, currentCode, id, options);
111
+ if (!result) continue;
112
+ if (typeof result === "string") {
113
+ currentCode = result;
114
+ changed = true;
115
+ } else if (typeof result === "object" && typeof result.code === "string") {
116
+ currentCode = result.code;
117
+ changed = true;
118
+ }
119
+ }
120
+ if (changed) return {
121
+ code: currentCode,
122
+ map: null
123
+ };
124
+ }
125
+ }, {
126
+ name: "weapp-tailwindcss:style-injector",
127
+ apply: "build",
128
+ enforce: "post",
129
+ configResolved(resolvedConfig) {
130
+ config = resolvedConfig;
131
+ },
132
+ async generateBundle(outputOptions, bundle, isWrite) {
133
+ await configureDelegates();
134
+ for (const plugin of resolveDelegates()) {
135
+ const handler = getGenerateBundleHandler(plugin.generateBundle);
136
+ if (!handler) continue;
137
+ await handler.call(this, outputOptions, bundle, isWrite);
138
+ }
139
+ }
140
+ }];
141
+ }
142
+ function createBuiltinWebpackStyleInjectorPlugin(options, appType) {
143
+ const normalized = normalizeWebpackStyleInjectorOptions(options);
144
+ if (!normalized) return;
145
+ if (isUniAppWebpackStyleInjectorApp(appType)) return StyleInjector$4(normalized);
146
+ if (appType === "taro") return StyleInjector$3(normalized);
147
+ if (appType === "mpx") return StyleInjector$2(normalized);
148
+ return weappStyleInjectorWebpack(normalized);
149
+ }
150
+ //#endregion
10
151
  //#region src/bundlers/shared/module-graph.ts
11
152
  const QUERY_HASH_RE = /[?#].*$/u;
12
153
  const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
@@ -505,6 +646,14 @@ function intersectCandidates(first, second) {
505
646
  function mergeCandidates(first, second) {
506
647
  return /* @__PURE__ */ new Set([...first, ...second]);
507
648
  }
649
+ function intersectExplicitSourceCandidates(scopedCandidates, localCandidates) {
650
+ if (localCandidates.size === 0 && scopedCandidates.size > 0) return scopedCandidates;
651
+ return intersectCandidates(scopedCandidates, localCandidates);
652
+ }
653
+ function resolveExplicitSourceCandidates(scopedCandidates, localCandidates, fallbackCandidates) {
654
+ if (scopedCandidates.size === 0 && localCandidates.size === 0 && fallbackCandidates?.size) return fallbackCandidates;
655
+ return intersectExplicitSourceCandidates(scopedCandidates, localCandidates);
656
+ }
508
657
  function resolveScopedSourceEntries(rawSource, sourceFile, resolvedEntries) {
509
658
  if (!hasOwnSourceDirectives(rawSource)) return {
510
659
  entries: resolvedEntries,
@@ -525,7 +674,7 @@ async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fa
525
674
  const { entries, localEntries } = resolveScopedSourceEntries(rawSource, sourceFile, (await resolveTailwindV4EntriesFromCssCached(rawSource, path.dirname(path.resolve(sourceFile.replace(/[?#].*$/, "")))))?.entries);
526
675
  if (entries === void 0) return fallbackSignature;
527
676
  const scopedCandidates = getSourceCandidatesForEntries(entries);
528
- const scopedSignature = createCandidateSignature(localEntries ? intersectCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries)) : scopedCandidates);
677
+ const scopedSignature = createCandidateSignature(localEntries ? resolveExplicitSourceCandidates(scopedCandidates, getSourceCandidatesForEntries(localEntries), getSourceCandidatesForEntries(void 0)) : scopedCandidates);
529
678
  return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
530
679
  }
531
680
  async function createScopedGeneratorRuntime(options) {
@@ -536,7 +685,9 @@ async function createScopedGeneratorRuntime(options) {
536
685
  const scopedCandidates = scopedSourceCandidateGetter?.(entries) ?? getSourceCandidatesForEntries(entries);
537
686
  const shouldMergeFallbackRuntime = hasCssMacroTailwindV4CustomVariantConditionalComments(rawSource);
538
687
  if (!localEntries) return shouldMergeFallbackRuntime ? mergeCandidates(scopedCandidates, fallbackRuntime) : scopedCandidates;
539
- const scopedLocalCandidates = intersectCandidates(scopedCandidates, scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries));
688
+ const localCandidates = scopedSourceCandidateGetter?.(localEntries) ?? getSourceCandidatesForEntries(localEntries);
689
+ const fallbackCandidates = scopedSourceCandidateGetter?.(void 0);
690
+ const scopedLocalCandidates = resolveExplicitSourceCandidates(scopedCandidates, localCandidates, fallbackCandidates);
540
691
  return shouldMergeFallbackRuntime ? mergeCandidates(scopedLocalCandidates, fallbackRuntime) : scopedLocalCandidates;
541
692
  }
542
693
  }
@@ -575,4 +726,4 @@ function createSourceCandidateScanSignature(input) {
575
726
  });
576
727
  }
577
728
  //#endregion
578
- export { isSourceStyleRequest as A, resolvePluginDisabledState as C, isHTMLRequest as D, isCSSRequest as E, normalizeOutputPathKey as M, resolveOutputSpecifier as N, normalizePath as O, toAbsoluteOutputPath as P, resolvePackageDir as S, formatPostcssSourceMap as T, generateTailwindV4Css as _, createJsHashSalt as a, parseBundlerGeneratedCssMarkerBlocks as b, hasRuntimeAffectingSourceChanges as c, classifyBundleEntry as d, createBundleBuildState as f, createBundleModuleGraphOptions as g, applyLinkedResults as h, createCandidateSignature as i, stripRequestQuery as j, slash as k, summarizeStringDiff as l, createRuntimeAffectingSourceSignature as m, createScopedGeneratorCandidateSignature as n, createLinkedImpactSignature as o, updateBundleBuildState as p, createScopedGeneratorRuntime as r, getSnapshotHash as s, createSourceCandidateScanSignature as t, buildBundleSnapshot as u, createBundlerGeneratedCssMarker as v, cleanUrl as w, stripBundlerGeneratedCssMarkers as x, hasBundlerGeneratedCssMarker as y };
729
+ export { isSourceStyleRequest as A, resolvePluginDisabledState as C, isHTMLRequest as D, isCSSRequest as E, createBuiltinViteStyleInjectorPlugins as F, createBuiltinWebpackStyleInjectorPlugin as I, normalizeOutputPathKey as M, resolveOutputSpecifier as N, normalizePath as O, toAbsoluteOutputPath as P, resolvePackageDir as S, formatPostcssSourceMap as T, generateTailwindV4Css as _, createJsHashSalt as a, parseBundlerGeneratedCssMarkerBlocks as b, hasRuntimeAffectingSourceChanges as c, classifyBundleEntry as d, createBundleBuildState as f, createBundleModuleGraphOptions as g, applyLinkedResults as h, createCandidateSignature as i, stripRequestQuery as j, slash as k, summarizeStringDiff as l, createRuntimeAffectingSourceSignature as m, createScopedGeneratorCandidateSignature as n, createLinkedImpactSignature as o, updateBundleBuildState as p, createScopedGeneratorRuntime as r, getSnapshotHash as s, createSourceCandidateScanSignature as t, buildBundleSnapshot as u, createBundlerGeneratedCssMarker as v, cleanUrl as w, stripBundlerGeneratedCssMarkers as x, hasBundlerGeneratedCssMarker as y };
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from 'vite';
2
+ import type { WebpackObjectPluginInstance } from 'weapp-style-injector/webpack';
3
+ import type { WeappTailwindcssStyleInjectorUserOptions } from './options';
4
+ import type { AppType } from '../types/shared';
5
+ export declare function createBuiltinViteStyleInjectorPlugins(options: WeappTailwindcssStyleInjectorUserOptions | undefined, getAppType: () => AppType | undefined): Plugin[];
6
+ export declare function createBuiltinWebpackStyleInjectorPlugin(options: WeappTailwindcssStyleInjectorUserOptions | undefined, appType: AppType | undefined): WebpackObjectPluginInstance | undefined;
7
+ export type { WeappTailwindcssStyleInjectorOptions, WeappTailwindcssStyleInjectorUserOptions } from './options';
@@ -0,0 +1,25 @@
1
+ import type { MpxSubPackageConfig, ResolvedSubpackageStyleScope, SubpackageStyleGenerateContext, SubpackageStyleGenerator, SubpackageStyleRules, TaroSubPackageConfig, UniAppManualStyleConfig, UniAppStyleScopeInput, UniAppSubPackageConfig, WeappStyleInjectorOptions } from 'weapp-style-injector';
2
+ export type WeappTailwindcssStyleInjectorUserOptions = boolean | WeappTailwindcssStyleInjectorOptions;
3
+ export interface WeappTailwindcssStyleInjectorOptions extends WeappStyleInjectorOptions {
4
+ pagesJsonPath?: string | string[] | undefined;
5
+ appConfigPath?: string | string[] | undefined;
6
+ appPath?: string | string[] | undefined;
7
+ sourceRoot?: string | undefined;
8
+ subPackages?: UniAppSubPackageConfig | UniAppSubPackageConfig[] | TaroSubPackageConfig | TaroSubPackageConfig[] | MpxSubPackageConfig | MpxSubPackageConfig[] | undefined;
9
+ uniAppSubPackages?: UniAppSubPackageConfig | UniAppSubPackageConfig[] | undefined;
10
+ uniAppStyleScopes?: UniAppManualStyleConfig | UniAppManualStyleConfig[] | undefined;
11
+ subpackageStyleScopes?: ResolvedSubpackageStyleScope[] | undefined;
12
+ generateSubpackageStyle?: SubpackageStyleGenerator | ((context: SubpackageStyleGenerateContext) => string | Uint8Array | null | undefined | Promise<string | Uint8Array | null | undefined>) | undefined;
13
+ loadSubpackageTargetStyle?: ((fileName: string, sourceAbsolutePath: string) => string | Uint8Array | null | undefined | Promise<string | Uint8Array | null | undefined>) | undefined;
14
+ sourceFileName?: string | string[] | undefined;
15
+ outputName?: string | undefined;
16
+ files?: string | string[] | undefined;
17
+ include?: WeappStyleInjectorOptions['include'];
18
+ exclude?: WeappStyleInjectorOptions['exclude'];
19
+ indexFileName?: string | string[] | undefined;
20
+ indexFileNames?: string | string[] | undefined;
21
+ styleScopes?: UniAppStyleScopeInput | UniAppStyleScopeInput[] | undefined;
22
+ rules?: SubpackageStyleRules | undefined;
23
+ preprocess?: boolean | undefined;
24
+ }
25
+ export declare function normalizeStyleInjectorOptions(options: WeappTailwindcssStyleInjectorUserOptions | undefined): WeappTailwindcssStyleInjectorOptions | undefined;
@@ -0,0 +1,4 @@
1
+ export declare function parseCssImportSpecifier(params: string): string | undefined;
2
+ export declare function isTailwindV4CssImportParam(params: string): boolean;
3
+ export declare function isTailwindV4PreflightImportParam(params: string): boolean;
4
+ export declare function includesTailwindV4PreflightDirective(css: string): boolean;