weapp-tailwindcss 5.0.0-next.8 → 5.0.0

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 (167) hide show
  1. package/README.md +2 -2
  2. package/dist/auto-DEHRmEAx.mjs +200 -0
  3. package/dist/auto-dPpsm6FB.js +238 -0
  4. package/dist/bundle-state-CnaJxkFY.mjs +413 -0
  5. package/dist/bundle-state-DgGEhk_z.js +529 -0
  6. package/dist/bundlers/shared/cache.d.ts +9 -7
  7. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
  8. package/dist/bundlers/shared/css-cleanup.d.ts +1 -3
  9. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  10. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +12 -3
  12. package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
  13. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  14. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  15. package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +6 -2
  17. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  18. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  19. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  20. package/dist/bundlers/vite/css-finalizer.d.ts +6 -0
  21. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  23. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  24. package/dist/bundlers/vite/generate-bundle.d.ts +13 -1
  25. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +10 -2
  26. package/dist/bundlers/vite/index.d.ts +5 -2
  27. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  28. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -5
  29. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -1
  30. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  31. package/dist/bundlers/vite/source-candidates.d.ts +24 -2
  32. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  33. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  34. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  35. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -1
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -3
  37. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  38. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  39. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
  40. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  41. package/dist/cache/index.d.ts +6 -6
  42. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  43. package/dist/cli/context.d.ts +1 -11
  44. package/dist/cli/doctor/types.d.ts +11 -11
  45. package/dist/cli/vscode-entry.d.ts +3 -3
  46. package/dist/cli.js +684 -41
  47. package/dist/cli.mjs +682 -40
  48. package/dist/context/runtime-package-replacements.d.ts +2 -0
  49. package/dist/context/style-options.d.ts +3 -0
  50. package/dist/context/tailwindcss.d.ts +1 -1
  51. package/dist/core.js +1 -2
  52. package/dist/core.mjs +1 -1
  53. package/dist/css-macro/auto.d.ts +11 -0
  54. package/dist/css-macro/constants.d.ts +5 -2
  55. package/dist/css-macro/postcss.d.ts +1 -0
  56. package/dist/css-macro/postcss.js +7 -46
  57. package/dist/css-macro/postcss.mjs +2 -46
  58. package/dist/css-macro.js +16 -7
  59. package/dist/css-macro.mjs +15 -6
  60. package/dist/defaults-8xrgzxFY.mjs +151 -0
  61. package/dist/defaults-zKUH2mDe.js +193 -0
  62. package/dist/defaults.js +6 -150
  63. package/dist/defaults.mjs +1 -143
  64. package/dist/escape.js +10 -2
  65. package/dist/escape.mjs +10 -2
  66. package/dist/generator/options.d.ts +11 -6
  67. package/dist/generator/types.d.ts +3 -3
  68. package/dist/generator--0-ekuVO.js +92 -0
  69. package/dist/generator-B76ovqsv.mjs +67 -0
  70. package/dist/generator.js +12 -12
  71. package/dist/generator.mjs +2 -1
  72. package/dist/gulp.js +163 -40
  73. package/dist/gulp.mjs +155 -32
  74. package/dist/incremental-runtime-class-set-CN6K_97P.js +2366 -0
  75. package/dist/incremental-runtime-class-set-x10M9bn_.mjs +2291 -0
  76. package/dist/index.d.ts +2 -1
  77. package/dist/index.js +17 -5
  78. package/dist/index.mjs +6 -5
  79. package/dist/js/babel/cache-options.d.ts +3 -0
  80. package/dist/js/babel/parse.d.ts +7 -4
  81. package/dist/js/precheck.d.ts +2 -2
  82. package/dist/js/replacement-cache.d.ts +5 -0
  83. package/dist/postcss-C7BMYpEF.mjs +169 -0
  84. package/dist/{postcss-w48mGIhe.mjs → postcss-CR9UCaIK.mjs} +54 -114
  85. package/dist/postcss-CiYLsqZn.js +192 -0
  86. package/dist/{postcss-QIXwT40c.js → postcss-hYimKoN_.js} +60 -121
  87. package/dist/postcss-html-transform.js +1 -1
  88. package/dist/postcss.js +1 -1
  89. package/dist/postcss.mjs +1 -1
  90. package/dist/precheck-BrNwLG2e.mjs +4716 -0
  91. package/dist/precheck-DPtJjZmV.js +4842 -0
  92. package/dist/presets/index.d.ts +1 -0
  93. package/dist/presets/uni-app-x.d.ts +1 -0
  94. package/dist/presets.js +27 -13
  95. package/dist/presets.mjs +25 -13
  96. package/dist/reset.js +1 -1
  97. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  98. package/dist/shared/mpx.d.ts +1 -0
  99. package/dist/source-candidates-DN1mihlU.mjs +322 -0
  100. package/dist/source-candidates-DSxme_O2.js +335 -0
  101. package/dist/tailwindcss/miniprogram.d.ts +1 -5
  102. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  103. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  104. package/dist/tailwindcss/runtime.d.ts +9 -9
  105. package/dist/tailwindcss/source-scan.d.ts +35 -0
  106. package/dist/tailwindcss/v3-engine/types.d.ts +19 -14
  107. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  108. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  109. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  110. package/dist/tailwindcss/v4-engine/types.d.ts +18 -5
  111. package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-DWtPieNE.mjs} +72 -60
  112. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-glCm_d3H.js} +81 -69
  113. package/dist/typedoc.export.d.ts +1 -1
  114. package/dist/types/index.d.ts +51 -41
  115. package/dist/types/shared.d.ts +3 -0
  116. package/dist/types/typedoc-tailwindcss-patch.d.ts +67 -0
  117. package/dist/types/user-defined-options/general.d.ts +25 -22
  118. package/dist/types/user-defined-options/important.d.ts +32 -27
  119. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  120. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  121. package/dist/unocss/index.d.ts +2 -0
  122. package/dist/utils/object.d.ts +9 -0
  123. package/dist/utils/options.d.ts +2 -0
  124. package/dist/utils/regex.d.ts +1 -0
  125. package/dist/{utils-BiShvil9.js → utils-D7Ygohep.js} +2 -2
  126. package/dist/{utils-Btw1iOVV.mjs → utils-DsaS975I.mjs} +1 -1
  127. package/dist/v3-engine-D3BMLVAN.js +3712 -0
  128. package/dist/v3-engine-DCxNPBVs.mjs +3417 -0
  129. package/dist/vite-DOprpdH-.mjs +24493 -0
  130. package/dist/vite-Ec0uX6kF.js +24507 -0
  131. package/dist/vite.js +1 -1
  132. package/dist/vite.mjs +1 -1
  133. package/dist/weapp-tw-css-import-rewrite-loader.js +5444 -22
  134. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  135. package/dist/{webpack-CNV2dx3Q.js → webpack-Ccohlg3A.js} +341 -96
  136. package/dist/{webpack-CT6EEENx.mjs → webpack-DFlZcqAU.mjs} +323 -79
  137. package/dist/webpack.d.ts +1 -3
  138. package/dist/webpack.js +3 -4
  139. package/dist/webpack.mjs +2 -2
  140. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -4
  141. package/package.json +22 -20
  142. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
  143. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -4
  144. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
  145. package/dist/cache-BVAiJV3J.js +0 -502
  146. package/dist/cache-CHs4DXui.mjs +0 -434
  147. package/dist/constants-BoB_6lFw.js +0 -73
  148. package/dist/constants-E_loJC49.mjs +0 -44
  149. package/dist/generator-DKkhJbOg.js +0 -1531
  150. package/dist/generator-UBmfduYg.mjs +0 -1432
  151. package/dist/generator-css-BIapP56i.mjs +0 -1323
  152. package/dist/generator-css-Mksw8PgB.js +0 -1362
  153. package/dist/lightningcss/index.d.ts +0 -8
  154. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  155. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  156. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  157. package/dist/lightningcss/style-handler.d.ts +0 -17
  158. package/dist/precheck-B32p-gLI.js +0 -2736
  159. package/dist/precheck-B4RH6ZNN.mjs +0 -2622
  160. package/dist/run-tasks-B50A3pxt.js +0 -128
  161. package/dist/run-tasks-DdNi-hkk.mjs +0 -91
  162. package/dist/runtime-patch-CwN5ya72.mjs +0 -71
  163. package/dist/runtime-patch-D6mBo_KB.js +0 -85
  164. package/dist/vite-BwgRVgxH.mjs +0 -2405
  165. package/dist/vite-DyZuiyap.js +0 -2418
  166. /package/dist/{logger-Bub1jggA.mjs → logger-BNzxZbZj.mjs} +0 -0
  167. /package/dist/{logger-BRy6XPQ2.js → logger-TlKT3xmR.js} +0 -0
@@ -1,128 +0,0 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
2
- let node_module = require("node:module");
3
- let node_path = require("node:path");
4
- node_path = require_chunk.__toESM(node_path);
5
- //#region src/bundlers/shared/module-graph.ts
6
- const QUERY_HASH_RE = /[?#].*$/u;
7
- const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
8
- const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
9
- const VIRTUAL_PREFIX = "\0";
10
- const JS_EXTENSIONS = [
11
- ".js",
12
- ".mjs",
13
- ".cjs"
14
- ];
15
- function normalizeOutputPathKey(value) {
16
- return node_path.default.normalize(value).replace(/\\/g, "/");
17
- }
18
- function stripQueryAndHash(specifier) {
19
- return specifier.replace(QUERY_HASH_RE, "");
20
- }
21
- function isResolvableSpecifier(specifier) {
22
- if (!specifier) return false;
23
- const normalized = stripQueryAndHash(specifier);
24
- if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
25
- if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
26
- return !PROTOCOL_RE.test(normalized);
27
- }
28
- function toAbsoluteOutputPath(fileName, outDir) {
29
- if (node_path.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return node_path.default.normalize(fileName);
30
- return node_path.default.resolve(outDir, fileName);
31
- }
32
- function matchWithExtensions(candidate, hasOutput) {
33
- if (hasOutput(candidate)) return candidate;
34
- if (!node_path.default.extname(candidate)) for (const ext of JS_EXTENSIONS) {
35
- const extended = `${candidate}${ext}`;
36
- if (hasOutput(extended)) return extended;
37
- }
38
- }
39
- function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
40
- if (!isResolvableSpecifier(specifier)) return;
41
- const normalized = stripQueryAndHash(specifier);
42
- let candidate;
43
- if (node_path.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = node_path.default.normalize(normalized);
44
- else if (normalized.startsWith("/")) candidate = node_path.default.resolve(outDir, normalized.slice(1));
45
- else candidate = node_path.default.resolve(node_path.default.dirname(importer), normalized);
46
- return matchWithExtensions(candidate, hasOutput);
47
- }
48
- //#endregion
49
- //#region src/utils/disabled.ts
50
- function resolvePluginDisabledState(disabled) {
51
- if (disabled === true) return { plugin: true };
52
- if (disabled === false || disabled == null) return { plugin: false };
53
- return { plugin: disabled.plugin ?? false };
54
- }
55
- //#endregion
56
- //#region src/utils/resolve-package.ts
57
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
58
- function resolvePackageDir(name) {
59
- const pkgPath = require$1.resolve(`${name}/package.json`);
60
- return node_path.default.dirname(pkgPath);
61
- }
62
- //#endregion
63
- //#region src/bundlers/shared/run-tasks.ts
64
- async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
65
- if (factories.length === 0) return [];
66
- const results = Array.from({ length: factories.length });
67
- const executing = /* @__PURE__ */ new Set();
68
- let cursor = 0;
69
- const effectiveLimit = Math.max(1, limit);
70
- const scheduleNext = () => {
71
- if (cursor >= factories.length) return;
72
- const currentIndex = cursor++;
73
- const wrapped = Promise.resolve(factories[currentIndex]()).then((value) => {
74
- results[currentIndex] = value;
75
- }).finally(() => {
76
- executing.delete(wrapped);
77
- });
78
- executing.add(wrapped);
79
- };
80
- while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
81
- while (cursor < factories.length) {
82
- await Promise.race(executing);
83
- scheduleNext();
84
- }
85
- await Promise.all(executing);
86
- return results;
87
- }
88
- function pushConcurrentTaskFactories(queue, factories, limit) {
89
- if (factories.length === 0) return;
90
- queue.push(runWithConcurrency(factories, limit).then(() => void 0));
91
- }
92
- //#endregion
93
- Object.defineProperty(exports, "normalizeOutputPathKey", {
94
- enumerable: true,
95
- get: function() {
96
- return normalizeOutputPathKey;
97
- }
98
- });
99
- Object.defineProperty(exports, "pushConcurrentTaskFactories", {
100
- enumerable: true,
101
- get: function() {
102
- return pushConcurrentTaskFactories;
103
- }
104
- });
105
- Object.defineProperty(exports, "resolveOutputSpecifier", {
106
- enumerable: true,
107
- get: function() {
108
- return resolveOutputSpecifier;
109
- }
110
- });
111
- Object.defineProperty(exports, "resolvePackageDir", {
112
- enumerable: true,
113
- get: function() {
114
- return resolvePackageDir;
115
- }
116
- });
117
- Object.defineProperty(exports, "resolvePluginDisabledState", {
118
- enumerable: true,
119
- get: function() {
120
- return resolvePluginDisabledState;
121
- }
122
- });
123
- Object.defineProperty(exports, "toAbsoluteOutputPath", {
124
- enumerable: true,
125
- get: function() {
126
- return toAbsoluteOutputPath;
127
- }
128
- });
@@ -1,91 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import path from "node:path";
3
- //#region src/bundlers/shared/module-graph.ts
4
- const QUERY_HASH_RE = /[?#].*$/u;
5
- const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
6
- const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
7
- const VIRTUAL_PREFIX = "\0";
8
- const JS_EXTENSIONS = [
9
- ".js",
10
- ".mjs",
11
- ".cjs"
12
- ];
13
- function normalizeOutputPathKey(value) {
14
- return path.normalize(value).replace(/\\/g, "/");
15
- }
16
- function stripQueryAndHash(specifier) {
17
- return specifier.replace(QUERY_HASH_RE, "");
18
- }
19
- function isResolvableSpecifier(specifier) {
20
- if (!specifier) return false;
21
- const normalized = stripQueryAndHash(specifier);
22
- if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
23
- if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
24
- return !PROTOCOL_RE.test(normalized);
25
- }
26
- function toAbsoluteOutputPath(fileName, outDir) {
27
- if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
28
- return path.resolve(outDir, fileName);
29
- }
30
- function matchWithExtensions(candidate, hasOutput) {
31
- if (hasOutput(candidate)) return candidate;
32
- if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
33
- const extended = `${candidate}${ext}`;
34
- if (hasOutput(extended)) return extended;
35
- }
36
- }
37
- function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
38
- if (!isResolvableSpecifier(specifier)) return;
39
- const normalized = stripQueryAndHash(specifier);
40
- let candidate;
41
- if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
42
- else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
43
- else candidate = path.resolve(path.dirname(importer), normalized);
44
- return matchWithExtensions(candidate, hasOutput);
45
- }
46
- //#endregion
47
- //#region src/utils/disabled.ts
48
- function resolvePluginDisabledState(disabled) {
49
- if (disabled === true) return { plugin: true };
50
- if (disabled === false || disabled == null) return { plugin: false };
51
- return { plugin: disabled.plugin ?? false };
52
- }
53
- //#endregion
54
- //#region src/utils/resolve-package.ts
55
- const require = createRequire(import.meta.url);
56
- function resolvePackageDir(name) {
57
- const pkgPath = require.resolve(`${name}/package.json`);
58
- return path.dirname(pkgPath);
59
- }
60
- //#endregion
61
- //#region src/bundlers/shared/run-tasks.ts
62
- async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
63
- if (factories.length === 0) return [];
64
- const results = Array.from({ length: factories.length });
65
- const executing = /* @__PURE__ */ new Set();
66
- let cursor = 0;
67
- const effectiveLimit = Math.max(1, limit);
68
- const scheduleNext = () => {
69
- if (cursor >= factories.length) return;
70
- const currentIndex = cursor++;
71
- const wrapped = Promise.resolve(factories[currentIndex]()).then((value) => {
72
- results[currentIndex] = value;
73
- }).finally(() => {
74
- executing.delete(wrapped);
75
- });
76
- executing.add(wrapped);
77
- };
78
- while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
79
- while (cursor < factories.length) {
80
- await Promise.race(executing);
81
- scheduleNext();
82
- }
83
- await Promise.all(executing);
84
- return results;
85
- }
86
- function pushConcurrentTaskFactories(queue, factories, limit) {
87
- if (factories.length === 0) return;
88
- queue.push(runWithConcurrency(factories, limit).then(() => void 0));
89
- }
90
- //#endregion
91
- export { resolveOutputSpecifier as a, normalizeOutputPathKey as i, resolvePackageDir as n, toAbsoluteOutputPath as o, resolvePluginDisabledState as r, pushConcurrentTaskFactories as t };
@@ -1,71 +0,0 @@
1
- import { i as runtimeSignaturePatchersSymbol } from "./cache-CHs4DXui.mjs";
2
- import { createRequire } from "node:module";
3
- import path from "node:path";
4
- import _createDebug from "debug";
5
- //#region src/debug/index.ts
6
- const _debug = _createDebug("weapp-tw");
7
- function createDebug(prefix) {
8
- const debug = ((formatter, ...args) => {
9
- return _debug((prefix ?? "") + formatter, ...args);
10
- });
11
- Object.defineProperty(debug, "enabled", {
12
- enumerable: false,
13
- configurable: false,
14
- get() {
15
- return _debug.enabled;
16
- }
17
- });
18
- return debug;
19
- }
20
- //#endregion
21
- //#region src/tailwindcss/runtime-patch.ts
22
- const debug = createDebug("[tailwindcss:runtime-patch] ");
23
- const require = createRequire(import.meta.url);
24
- const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
25
- function getNestedPatchers(twPatcher) {
26
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
27
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
28
- }
29
- function shouldApplyRuntimePatch(twPatcher) {
30
- return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
31
- }
32
- function clearTailwindcssRequireCache(twPatcher) {
33
- const rootPath = twPatcher.packageInfo?.rootPath;
34
- if (!rootPath) return;
35
- const normalizedRoot = path.resolve(rootPath);
36
- let count = 0;
37
- for (const id of Object.keys(require.cache)) {
38
- const normalizedId = path.resolve(id);
39
- if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${path.sep}`)) {
40
- delete require.cache[id];
41
- count += 1;
42
- }
43
- }
44
- if (count > 0) debug("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
45
- }
46
- async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
47
- const nestedPatchers = getNestedPatchers(twPatcher);
48
- if (nestedPatchers) {
49
- await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
50
- return;
51
- }
52
- if (!shouldApplyRuntimePatch(twPatcher)) return;
53
- const cached = runtimePatchPromiseCache.get(twPatcher);
54
- if (cached) {
55
- await cached;
56
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
57
- return;
58
- }
59
- const task = Promise.resolve().then(async () => {
60
- debug("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
61
- await twPatcher.patch?.();
62
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
63
- }).catch((error) => {
64
- runtimePatchPromiseCache.delete(twPatcher);
65
- throw error;
66
- });
67
- runtimePatchPromiseCache.set(twPatcher, task);
68
- return task;
69
- }
70
- //#endregion
71
- export { createDebug as n, ensureTailwindcssRuntimePatch as t };
@@ -1,85 +0,0 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_cache = require("./cache-BVAiJV3J.js");
3
- let node_module = require("node:module");
4
- let node_path = require("node:path");
5
- node_path = require_chunk.__toESM(node_path);
6
- let debug = require("debug");
7
- debug = require_chunk.__toESM(debug);
8
- //#region src/debug/index.ts
9
- const _debug = (0, debug.default)("weapp-tw");
10
- function createDebug(prefix) {
11
- const debug$2 = ((formatter, ...args) => {
12
- return _debug((prefix ?? "") + formatter, ...args);
13
- });
14
- Object.defineProperty(debug$2, "enabled", {
15
- enumerable: false,
16
- configurable: false,
17
- get() {
18
- return _debug.enabled;
19
- }
20
- });
21
- return debug$2;
22
- }
23
- //#endregion
24
- //#region src/tailwindcss/runtime-patch.ts
25
- const debug$1 = createDebug("[tailwindcss:runtime-patch] ");
26
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
27
- const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
28
- function getNestedPatchers(twPatcher) {
29
- const nested = twPatcher[require_cache.runtimeSignaturePatchersSymbol];
30
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
31
- }
32
- function shouldApplyRuntimePatch(twPatcher) {
33
- return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
34
- }
35
- function clearTailwindcssRequireCache(twPatcher) {
36
- const rootPath = twPatcher.packageInfo?.rootPath;
37
- if (!rootPath) return;
38
- const normalizedRoot = node_path.default.resolve(rootPath);
39
- let count = 0;
40
- for (const id of Object.keys(require$1.cache)) {
41
- const normalizedId = node_path.default.resolve(id);
42
- if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${node_path.default.sep}`)) {
43
- delete require$1.cache[id];
44
- count += 1;
45
- }
46
- }
47
- if (count > 0) debug$1("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
48
- }
49
- async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
50
- const nestedPatchers = getNestedPatchers(twPatcher);
51
- if (nestedPatchers) {
52
- await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
53
- return;
54
- }
55
- if (!shouldApplyRuntimePatch(twPatcher)) return;
56
- const cached = runtimePatchPromiseCache.get(twPatcher);
57
- if (cached) {
58
- await cached;
59
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
60
- return;
61
- }
62
- const task = Promise.resolve().then(async () => {
63
- debug$1("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
64
- await twPatcher.patch?.();
65
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
66
- }).catch((error) => {
67
- runtimePatchPromiseCache.delete(twPatcher);
68
- throw error;
69
- });
70
- runtimePatchPromiseCache.set(twPatcher, task);
71
- return task;
72
- }
73
- //#endregion
74
- Object.defineProperty(exports, "createDebug", {
75
- enumerable: true,
76
- get: function() {
77
- return createDebug;
78
- }
79
- });
80
- Object.defineProperty(exports, "ensureTailwindcssRuntimePatch", {
81
- enumerable: true,
82
- get: function() {
83
- return ensureTailwindcssRuntimePatch;
84
- }
85
- });