weapp-tailwindcss 5.1.4 → 5.1.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.
Files changed (53) hide show
  1. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
  2. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
  3. package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
  4. package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
  5. package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
  6. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
  7. package/dist/cli.js +18 -3
  8. package/dist/cli.mjs +16 -1
  9. package/dist/{context-DCVMkTRj.js → context-BziwyWy1.js} +21 -6
  10. package/dist/{context-Bkpmt3ja.mjs → context-rrYZuUBU.mjs} +18 -3
  11. package/dist/core.js +1 -1
  12. package/dist/core.mjs +1 -1
  13. package/dist/css-macro/index.d.ts +2 -1
  14. package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
  15. package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
  16. package/dist/defaults.d.ts +1 -1
  17. package/dist/defaults.js +1 -1
  18. package/dist/defaults.mjs +1 -1
  19. package/dist/{gulp-Bogfnoki.js → gulp-CuVsZdO9.js} +3 -3
  20. package/dist/{gulp-0RsqkF_d.mjs → gulp-ygWfmOqh.mjs} +3 -3
  21. package/dist/gulp.js +1 -1
  22. package/dist/gulp.mjs +1 -1
  23. package/dist/{hmr-timing-BV6nFPoT.js → hmr-timing-BKdCeIrn.js} +207 -67
  24. package/dist/{hmr-timing-BRNaz8Od.mjs → hmr-timing-Dh_nn3w5.mjs} +207 -67
  25. package/dist/index.js +3 -3
  26. package/dist/index.mjs +3 -3
  27. package/dist/js/js-string-escape.d.ts +1 -0
  28. package/dist/presets.js +1 -1
  29. package/dist/presets.mjs +1 -1
  30. package/dist/rspack.js +1 -1
  31. package/dist/rspack.mjs +1 -1
  32. package/dist/{source-candidate-scan-signature-BB1hvW68.mjs → source-candidate-scan-signature-DATRnS1X.mjs} +157 -6
  33. package/dist/{source-candidate-scan-signature-CaDT0gkj.js → source-candidate-scan-signature-DIj9m4wB.js} +168 -5
  34. package/dist/style-injector/internal.d.ts +7 -0
  35. package/dist/style-injector/options.d.ts +25 -0
  36. package/dist/tailwindcss/v4/preflight.d.ts +4 -0
  37. package/dist/{tailwindcss-D2xs4OEu.js → tailwindcss-BwoNQ3t8.js} +52 -12
  38. package/dist/{tailwindcss-D0JF0fuZ.mjs → tailwindcss-C-uM4rB8.mjs} +47 -13
  39. package/dist/{transform-BP86eSZp.mjs → transform-DHLemtaX.mjs} +1 -1
  40. package/dist/{transform-CXCQ28Tc.js → transform-KLD1tJdb.js} +1 -1
  41. package/dist/typedoc.export.d.ts +1 -0
  42. package/dist/types/index.d.ts +2 -1
  43. package/dist/types/user-defined-options/general.d.ts +2 -0
  44. package/dist/{vite-BYgT1ir9.js → vite-Yp14HNyS.js} +101 -37
  45. package/dist/{vite-B1SlBmqO.mjs → vite-cH0tTMHc.mjs} +101 -37
  46. package/dist/vite.js +1 -1
  47. package/dist/vite.mjs +1 -1
  48. package/dist/weapp-tw-css-import-rewrite-loader.js +276 -83
  49. package/dist/{webpack-Bg6pefpb.mjs → webpack-DBhmJ-_P.mjs} +62 -18
  50. package/dist/{webpack-khSwkXP5.js → webpack-DN3tgLbF.js} +61 -17
  51. package/dist/webpack.js +1 -1
  52. package/dist/webpack.mjs +1 -1
  53. package/package.json +16 -5
@@ -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-rrYZuUBU.mjs";
3
+ import { g as resolveTailwindV4EntriesFromCssCached } from "./tailwindcss-C-uM4rB8.mjs";
4
+ import { u as generateCssByGenerator } from "./hmr-timing-Dh_nn3w5.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 };
@@ -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-BziwyWy1.js");
4
+ const require_tailwindcss = require("./tailwindcss-BwoNQ3t8.js");
5
+ const require_hmr_timing = require("./hmr-timing-BKdCeIrn.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() {
@@ -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;
@@ -16,6 +16,41 @@ let fast_glob = require("fast-glob");
16
16
  fast_glob = require_rolldown_runtime.__toESM(fast_glob);
17
17
  let tailwindcss_config = require("tailwindcss-config");
18
18
  let node_url = require("node:url");
19
+ //#region src/tailwindcss/v4/preflight.ts
20
+ function parseCssImportSpecifier(params) {
21
+ const value = params.trim();
22
+ const quoted = /^(['"])(.*?)\1/.exec(value);
23
+ if (quoted) return quoted[2];
24
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
25
+ return url?.[2] ?? url?.[3];
26
+ }
27
+ function normalizeTailwindImportSpecifier(params) {
28
+ return parseCssImportSpecifier(params)?.replaceAll("\\", "/");
29
+ }
30
+ function isTailwindV4CssImportParam(params) {
31
+ const specifier = normalizeTailwindImportSpecifier(params);
32
+ return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier?.startsWith("tailwindcss/") === true || specifier?.startsWith("tailwindcss4/") === true || specifier?.endsWith("/tailwindcss/index.css") === true;
33
+ }
34
+ function isTailwindV4PreflightImportParam(params) {
35
+ const specifier = normalizeTailwindImportSpecifier(params);
36
+ return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier === "tailwindcss/preflight" || specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss4/preflight" || specifier === "tailwindcss4/preflight.css" || specifier?.endsWith("/tailwindcss/index.css") === true || specifier?.endsWith("/tailwindcss/preflight.css") === true;
37
+ }
38
+ function includesTailwindV4PreflightDirective(css) {
39
+ try {
40
+ const root = _weapp_tailwindcss_postcss.postcss.parse(css);
41
+ let includesPreflight = false;
42
+ root.walkAtRules("import", (rule) => {
43
+ includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
44
+ });
45
+ root.walkAtRules("tailwind", (rule) => {
46
+ includesPreflight || (includesPreflight = rule.params.trim() === "base");
47
+ });
48
+ return includesPreflight;
49
+ } catch {
50
+ return /@import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/(?:preflight(?:\.css)?|index\.css))?["')\s;]/.test(css) || /@tailwind\s+base\b/.test(css);
51
+ }
52
+ }
53
+ //#endregion
19
54
  //#region src/bundlers/vite/static-config-content.ts
20
55
  function skipWhitespaceAndComments(source, start) {
21
56
  let index = start;
@@ -198,17 +233,6 @@ function parseImportSourceParam(params) {
198
233
  sourcePath: match[3]
199
234
  };
200
235
  }
201
- function parseCssImportSpecifier(params) {
202
- const value = params.trim();
203
- const quoted = /^(['"])(.*?)\1/.exec(value);
204
- if (quoted) return quoted[2];
205
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
206
- return url?.[2] ?? url?.[3];
207
- }
208
- function isTailwindCssImport(params) {
209
- const specifier = parseCssImportSpecifier(params);
210
- return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
211
- }
212
236
  function resolveSourceBase(base, sourcePath) {
213
237
  return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
214
238
  }
@@ -298,17 +322,22 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
298
322
  let importSourceBase;
299
323
  let hasSourceNone = false;
300
324
  let hasTailwindCssImport = false;
325
+ let includesPreflight = false;
301
326
  const [sourceEntries, configEntries] = await Promise.all([require_v4_engine.resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
302
327
  const entries = [...configEntries.entries, ...sourceEntries];
303
328
  const hasPositiveEntries = entries.some((entry) => !entry.negated);
304
329
  const inlineCandidates = require_v4_engine.collectCssInlineSourceCandidates(root);
305
330
  root.walkAtRules("import", (rule) => {
306
- if (!isTailwindCssImport(rule.params)) return;
331
+ if (!isTailwindV4CssImportParam(rule.params)) return;
307
332
  hasTailwindCssImport = true;
333
+ includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
308
334
  const sourceParam = parseImportSourceParam(rule.params);
309
335
  if (sourceParam?.none) hasSourceNone = true;
310
336
  if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
311
337
  });
338
+ root.walkAtRules("tailwind", (rule) => {
339
+ includesPreflight || (includesPreflight = rule.params.trim() === "base");
340
+ });
312
341
  if (importSourceBase) return {
313
342
  entries: [{
314
343
  base: importSourceBase,
@@ -316,30 +345,35 @@ async function resolveTailwindV4EntriesFromCss(css, base) {
316
345
  pattern: VITE_SOURCE_CANDIDATE_PATTERN
317
346
  }, ...entries],
318
347
  explicit: true,
348
+ includesPreflight,
319
349
  inlineCandidates,
320
350
  dependencies: configEntries.dependencies
321
351
  };
322
352
  if (hasSourceNone) return {
323
353
  entries,
324
354
  explicit: true,
355
+ includesPreflight,
325
356
  inlineCandidates,
326
357
  dependencies: configEntries.dependencies
327
358
  };
328
359
  if (hasPositiveEntries) return {
329
360
  entries,
330
361
  explicit: true,
362
+ includesPreflight,
331
363
  inlineCandidates,
332
364
  dependencies: configEntries.dependencies
333
365
  };
334
366
  if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
335
367
  entries: [],
336
368
  explicit: true,
369
+ includesPreflight,
337
370
  inlineCandidates,
338
371
  dependencies: configEntries.dependencies
339
372
  };
340
373
  return hasTailwindCssImport ? {
341
374
  entries,
342
375
  explicit: false,
376
+ includesPreflight,
343
377
  inlineCandidates,
344
378
  dependencies: configEntries.dependencies
345
379
  } : void 0;
@@ -1472,6 +1506,12 @@ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
1472
1506
  return getRuntimeClassSetSignatureWithSources;
1473
1507
  }
1474
1508
  });
1509
+ Object.defineProperty(exports, "includesTailwindV4PreflightDirective", {
1510
+ enumerable: true,
1511
+ get: function() {
1512
+ return includesTailwindV4PreflightDirective;
1513
+ }
1514
+ });
1475
1515
  Object.defineProperty(exports, "invalidateRuntimeClassSet", {
1476
1516
  enumerable: true,
1477
1517
  get: function() {