weapp-tailwindcss 4.7.1 → 4.7.2

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 (39) hide show
  1. package/dist/{chunk-KMGWHIDU.js → chunk-2SI3KT2H.js} +7 -6
  2. package/dist/{chunk-W4YVU4OO.mjs → chunk-3ARXMTWC.mjs} +10 -1
  3. package/dist/{chunk-C7SH2SQK.mjs → chunk-5BW6X6AJ.mjs} +42 -36
  4. package/dist/chunk-667CYXAH.mjs +133 -0
  5. package/dist/chunk-BUMQQPAO.js +133 -0
  6. package/dist/{chunk-KCL4CARB.js → chunk-FPDJ3BCM.js} +260 -108
  7. package/dist/{chunk-4NJFDWBZ.js → chunk-GNWJEIZZ.js} +92 -77
  8. package/dist/{chunk-Z6YNBYLM.mjs → chunk-JYCQWWYU.mjs} +257 -105
  9. package/dist/{chunk-NRG7N2Q7.mjs → chunk-KZJLIZIK.mjs} +0 -1
  10. package/dist/{chunk-34T2BFTJ.mjs → chunk-KZUIVLPP.mjs} +42 -1
  11. package/dist/{chunk-KF7YCOEP.js → chunk-OPTIAB5G.js} +10 -1
  12. package/dist/{chunk-F6IW6L27.mjs → chunk-Q6PLZCM6.mjs} +6 -5
  13. package/dist/{chunk-XLUAMJS6.js → chunk-QZRXYCOQ.js} +49 -43
  14. package/dist/{chunk-WVKK6TBL.js → chunk-W7BVY5S5.js} +42 -1
  15. package/dist/{chunk-LZ6L3UQO.js → chunk-WXBFAARR.js} +0 -1
  16. package/dist/{chunk-FUMBS2BS.mjs → chunk-Z2H7M33Z.mjs} +83 -68
  17. package/dist/cli.js +6 -6
  18. package/dist/cli.mjs +3 -3
  19. package/dist/core.js +10 -9
  20. package/dist/core.mjs +10 -9
  21. package/dist/defaults.js +2 -2
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/gulp.js +6 -6
  24. package/dist/gulp.mjs +5 -5
  25. package/dist/index.js +9 -9
  26. package/dist/index.mjs +8 -8
  27. package/dist/presets.js +2 -2
  28. package/dist/presets.mjs +1 -1
  29. package/dist/types.d.mts +2 -21
  30. package/dist/types.d.ts +2 -21
  31. package/dist/vite.js +7 -7
  32. package/dist/vite.mjs +6 -6
  33. package/dist/webpack.js +7 -7
  34. package/dist/webpack.mjs +6 -6
  35. package/dist/webpack4.js +51 -45
  36. package/dist/webpack4.mjs +44 -38
  37. package/package.json +3 -3
  38. package/dist/chunk-FB5P4TRH.js +0 -70
  39. package/dist/chunk-YPBRGP6K.mjs +0 -70
@@ -4,10 +4,11 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
4
4
 
5
5
 
6
6
 
7
- var _chunkFB5P4TRHjs = require('./chunk-FB5P4TRH.js');
8
7
 
8
+ var _chunkBUMQQPAOjs = require('./chunk-BUMQQPAO.js');
9
9
 
10
- var _chunkKCL4CARBjs = require('./chunk-KCL4CARB.js');
10
+
11
+ var _chunkFPDJ3BCMjs = require('./chunk-FPDJ3BCM.js');
11
12
 
12
13
  // src/bundlers/gulp/index.ts
13
14
  var _buffer = require('buffer');
@@ -15,13 +16,13 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
15
16
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
16
17
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
17
18
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
18
- var debug = _chunkFB5P4TRHjs.createDebug.call(void 0, );
19
+ var debug = _chunkBUMQQPAOjs.createDebug.call(void 0, );
19
20
  var Transform = _stream2.default.Transform;
20
21
  function createPlugins(options = {}) {
21
- const opts = _chunkKCL4CARBjs.getCompilerContext.call(void 0, options);
22
+ const opts = _chunkFPDJ3BCMjs.getCompilerContext.call(void 0, options);
22
23
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher } = opts;
23
24
  let runtimeSet = /* @__PURE__ */ new Set();
24
- const patchPromise = Promise.resolve(twPatcher.patch());
25
+ const patchPromise = _chunkBUMQQPAOjs.createTailwindPatchPromise.call(void 0, twPatcher);
25
26
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
26
27
  let runtimeSetInitialized = false;
27
28
  async function refreshRuntimeSet(force = false) {
@@ -29,7 +30,7 @@ function createPlugins(options = {}) {
29
30
  if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
30
31
  return runtimeSet;
31
32
  }
32
- runtimeSet = await _chunkFB5P4TRHjs.collectRuntimeClassSet.call(void 0, twPatcher);
33
+ runtimeSet = await _chunkBUMQQPAOjs.collectRuntimeClassSet.call(void 0, twPatcher, { force });
33
34
  runtimeSetInitialized = true;
34
35
  return runtimeSet;
35
36
  }
@@ -384,6 +384,12 @@ var ENV_BASEDIR_KEYS = [
384
384
  "PWD"
385
385
  ];
386
386
  var GENERIC_ENV_BASEDIR_KEYS = /* @__PURE__ */ new Set(["INIT_CWD", "PWD"]);
387
+ function isLegacyTailwindcssPatcherOptions(options) {
388
+ return typeof options === "object" && options !== null && "patch" in options;
389
+ }
390
+ function isModernTailwindcssPatchOptions(options) {
391
+ return typeof options === "object" && options !== null && !("patch" in options);
392
+ }
387
393
  function pickEnvBasedir() {
388
394
  for (const key of ENV_BASEDIR_KEYS) {
389
395
  const value = process2.env[key];
@@ -542,7 +548,7 @@ function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries)
542
548
  if (!options) {
543
549
  return options;
544
550
  }
545
- if ("patch" in options) {
551
+ if (isLegacyTailwindcssPatcherOptions(options)) {
546
552
  const patchOptions = options.patch;
547
553
  if (!patchOptions) {
548
554
  return options;
@@ -567,6 +573,9 @@ function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries)
567
573
  patch: nextPatch
568
574
  };
569
575
  }
576
+ if (!isModernTailwindcssPatchOptions(options)) {
577
+ return options;
578
+ }
570
579
  if (!options.tailwind) {
571
580
  return options;
572
581
  }
@@ -2,20 +2,22 @@ import {
2
2
  getCacheKey
3
3
  } from "./chunk-2F7HOQQY.mjs";
4
4
  import {
5
+ pushConcurrentTaskFactories,
5
6
  resolveOutputSpecifier,
6
7
  toAbsoluteOutputPath
7
- } from "./chunk-34T2BFTJ.mjs";
8
+ } from "./chunk-KZUIVLPP.mjs";
8
9
  import {
9
10
  processCachedTask
10
11
  } from "./chunk-RRHPTTCP.mjs";
11
12
  import {
12
13
  collectRuntimeClassSet,
13
- createDebug
14
- } from "./chunk-YPBRGP6K.mjs";
14
+ createDebug,
15
+ createTailwindPatchPromise
16
+ } from "./chunk-667CYXAH.mjs";
15
17
  import {
16
18
  getCompilerContext,
17
19
  pluginName
18
- } from "./chunk-Z6YNBYLM.mjs";
20
+ } from "./chunk-JYCQWWYU.mjs";
19
21
  import {
20
22
  getGroupedEntries
21
23
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -51,12 +53,12 @@ var UnifiedWebpackPluginV5 = class {
51
53
  if (disabled) {
52
54
  return;
53
55
  }
54
- const patchPromise = Promise.resolve(twPatcher.patch());
56
+ const patchPromise = createTailwindPatchPromise(twPatcher);
55
57
  const { Compilation, sources, NormalModule } = compiler.webpack;
56
58
  const { ConcatSource } = sources;
57
59
  async function getClassSetInLoader() {
58
60
  await patchPromise;
59
- await collectRuntimeClassSet(twPatcher);
61
+ await collectRuntimeClassSet(twPatcher, { force: true });
60
62
  }
61
63
  onLoad();
62
64
  const loader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
@@ -147,7 +149,7 @@ var UnifiedWebpackPluginV5 = class {
147
149
  }
148
150
  };
149
151
  const groupedEntries = getGroupedEntries(entries, this.options);
150
- const runtimeSet = await collectRuntimeClassSet(twPatcher);
152
+ const runtimeSet = await collectRuntimeClassSet(twPatcher, { force: true });
151
153
  debug("get runtimeSet, class count: %d", runtimeSet.size);
152
154
  const tasks = [];
153
155
  if (Array.isArray(groupedEntries.html)) {
@@ -181,6 +183,7 @@ var UnifiedWebpackPluginV5 = class {
181
183
  );
182
184
  }
183
185
  }
186
+ const jsTaskFactories = [];
184
187
  if (Array.isArray(groupedEntries.js)) {
185
188
  for (const [file] of groupedEntries.js) {
186
189
  const cacheKey = getCacheKey(file);
@@ -191,35 +194,37 @@ var UnifiedWebpackPluginV5 = class {
191
194
  const absoluteFile = toAbsoluteOutputPath(file, outputDir);
192
195
  const initialSource = asset.source.source();
193
196
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
194
- await processCachedTask({
195
- cache,
196
- cacheKey,
197
- rawSource: initialRawSource,
198
- applyResult(source) {
199
- compilation.updateAsset(file, source);
200
- },
201
- onCacheHit() {
202
- debug("js cache hit: %s", file);
203
- },
204
- transform: async () => {
205
- const currentAsset = compilation.getAsset(file);
206
- const currentSourceValue = currentAsset?.source.source();
207
- const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
208
- const { code, linked } = await jsHandler(currentSource, runtimeSet, {
209
- filename: absoluteFile,
210
- moduleGraph: moduleGraphOptions,
211
- babelParserOptions: {
212
- sourceFilename: absoluteFile
213
- }
214
- });
215
- const source = new ConcatSource(code);
216
- onUpdate(file, currentSource, code);
217
- debug("js handle: %s", file);
218
- applyLinkedResults(linked);
219
- return {
220
- result: source
221
- };
222
- }
197
+ jsTaskFactories.push(async () => {
198
+ await processCachedTask({
199
+ cache,
200
+ cacheKey,
201
+ rawSource: initialRawSource,
202
+ applyResult(source) {
203
+ compilation.updateAsset(file, source);
204
+ },
205
+ onCacheHit() {
206
+ debug("js cache hit: %s", file);
207
+ },
208
+ transform: async () => {
209
+ const currentAsset = compilation.getAsset(file);
210
+ const currentSourceValue = currentAsset?.source.source();
211
+ const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
212
+ const { code, linked } = await jsHandler(currentSource, runtimeSet, {
213
+ filename: absoluteFile,
214
+ moduleGraph: moduleGraphOptions,
215
+ babelParserOptions: {
216
+ sourceFilename: absoluteFile
217
+ }
218
+ });
219
+ const source = new ConcatSource(code);
220
+ onUpdate(file, currentSource, code);
221
+ debug("js handle: %s", file);
222
+ applyLinkedResults(linked);
223
+ return {
224
+ result: source
225
+ };
226
+ }
227
+ });
223
228
  });
224
229
  }
225
230
  }
@@ -261,6 +266,7 @@ var UnifiedWebpackPluginV5 = class {
261
266
  );
262
267
  }
263
268
  }
269
+ pushConcurrentTaskFactories(tasks, jsTaskFactories);
264
270
  await Promise.all(tasks);
265
271
  debug("end");
266
272
  onEnd();
@@ -0,0 +1,133 @@
1
+ // src/tailwindcss/runtime.ts
2
+ import { statSync } from "fs";
3
+
4
+ // src/debug/index.ts
5
+ import _createDebug from "debug";
6
+ var _debug = _createDebug("weapp-tw");
7
+ function createDebug(prefix) {
8
+ function debug2(formatter, ...args) {
9
+ return _debug((prefix ?? "") + formatter, ...args);
10
+ }
11
+ return debug2;
12
+ }
13
+
14
+ // src/tailwindcss/runtime.ts
15
+ var debug = createDebug("[tailwindcss:runtime] ");
16
+ var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
17
+ function getCacheEntry(twPatcher) {
18
+ let entry = runtimeClassSetCache.get(twPatcher);
19
+ if (!entry) {
20
+ entry = {};
21
+ runtimeClassSetCache.set(twPatcher, entry);
22
+ }
23
+ return entry;
24
+ }
25
+ function getTailwindConfigSignature(twPatcher) {
26
+ const configPath = twPatcher.options?.tailwind?.config;
27
+ if (typeof configPath !== "string" || configPath.length === 0) {
28
+ return void 0;
29
+ }
30
+ try {
31
+ const stats = statSync(configPath);
32
+ return `${configPath}:${stats.size}:${stats.mtimeMs}`;
33
+ } catch {
34
+ return `${configPath}:missing`;
35
+ }
36
+ }
37
+ function invalidateRuntimeClassSet(twPatcher) {
38
+ if (!twPatcher) {
39
+ return;
40
+ }
41
+ runtimeClassSetCache.delete(twPatcher);
42
+ }
43
+ function createTailwindPatchPromise(twPatcher) {
44
+ return Promise.resolve(twPatcher.patch()).then((result) => {
45
+ invalidateRuntimeClassSet(twPatcher);
46
+ return result;
47
+ });
48
+ }
49
+ function shouldPreferSync(majorVersion) {
50
+ if (majorVersion == null) {
51
+ return true;
52
+ }
53
+ if (majorVersion === 3) {
54
+ return true;
55
+ }
56
+ if (majorVersion === 4) {
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+ function tryGetRuntimeClassSetSync(twPatcher) {
62
+ if (typeof twPatcher.getClassSetSync !== "function") {
63
+ return void 0;
64
+ }
65
+ if (!shouldPreferSync(twPatcher.majorVersion)) {
66
+ return void 0;
67
+ }
68
+ try {
69
+ return twPatcher.getClassSetSync();
70
+ } catch (error) {
71
+ if (twPatcher.majorVersion === 4) {
72
+ debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
73
+ } else {
74
+ debug("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
75
+ }
76
+ return void 0;
77
+ }
78
+ }
79
+ async function collectRuntimeClassSet(twPatcher, options = {}) {
80
+ const entry = getCacheEntry(twPatcher);
81
+ const signature = getTailwindConfigSignature(twPatcher);
82
+ if (!options.force) {
83
+ if (entry.value && entry.signature === signature) {
84
+ return entry.value;
85
+ }
86
+ if (entry.promise) {
87
+ return entry.promise;
88
+ }
89
+ } else {
90
+ entry.value = void 0;
91
+ }
92
+ const task = (async () => {
93
+ const syncSet = tryGetRuntimeClassSetSync(twPatcher);
94
+ if (syncSet) {
95
+ return syncSet;
96
+ }
97
+ try {
98
+ const result = await twPatcher.extract({ write: false });
99
+ if (result?.classSet) {
100
+ return result.classSet;
101
+ }
102
+ } catch (error) {
103
+ debug("extract() failed, fallback to getClassSet(): %O", error);
104
+ }
105
+ try {
106
+ const fallbackSet = await Promise.resolve(twPatcher.getClassSet());
107
+ if (fallbackSet) {
108
+ return fallbackSet;
109
+ }
110
+ } catch (error) {
111
+ debug("getClassSet() failed, returning empty set: %O", error);
112
+ }
113
+ return /* @__PURE__ */ new Set();
114
+ })();
115
+ entry.promise = task;
116
+ entry.signature = signature;
117
+ try {
118
+ const resolved = await task;
119
+ entry.value = resolved;
120
+ entry.promise = void 0;
121
+ entry.signature = signature;
122
+ return resolved;
123
+ } catch (error) {
124
+ entry.promise = void 0;
125
+ throw error;
126
+ }
127
+ }
128
+
129
+ export {
130
+ createDebug,
131
+ createTailwindPatchPromise,
132
+ collectRuntimeClassSet
133
+ };
@@ -0,0 +1,133 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/tailwindcss/runtime.ts
2
+ var _fs = require('fs');
3
+
4
+ // src/debug/index.ts
5
+ var _debug2 = require('debug'); var _debug3 = _interopRequireDefault(_debug2);
6
+ var _debug = _debug3.default.call(void 0, "weapp-tw");
7
+ function createDebug(prefix) {
8
+ function debug2(formatter, ...args) {
9
+ return _debug((_nullishCoalesce(prefix, () => ( ""))) + formatter, ...args);
10
+ }
11
+ return debug2;
12
+ }
13
+
14
+ // src/tailwindcss/runtime.ts
15
+ var debug = createDebug("[tailwindcss:runtime] ");
16
+ var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
17
+ function getCacheEntry(twPatcher) {
18
+ let entry = runtimeClassSetCache.get(twPatcher);
19
+ if (!entry) {
20
+ entry = {};
21
+ runtimeClassSetCache.set(twPatcher, entry);
22
+ }
23
+ return entry;
24
+ }
25
+ function getTailwindConfigSignature(twPatcher) {
26
+ const configPath = _optionalChain([twPatcher, 'access', _ => _.options, 'optionalAccess', _2 => _2.tailwind, 'optionalAccess', _3 => _3.config]);
27
+ if (typeof configPath !== "string" || configPath.length === 0) {
28
+ return void 0;
29
+ }
30
+ try {
31
+ const stats = _fs.statSync.call(void 0, configPath);
32
+ return `${configPath}:${stats.size}:${stats.mtimeMs}`;
33
+ } catch (e) {
34
+ return `${configPath}:missing`;
35
+ }
36
+ }
37
+ function invalidateRuntimeClassSet(twPatcher) {
38
+ if (!twPatcher) {
39
+ return;
40
+ }
41
+ runtimeClassSetCache.delete(twPatcher);
42
+ }
43
+ function createTailwindPatchPromise(twPatcher) {
44
+ return Promise.resolve(twPatcher.patch()).then((result) => {
45
+ invalidateRuntimeClassSet(twPatcher);
46
+ return result;
47
+ });
48
+ }
49
+ function shouldPreferSync(majorVersion) {
50
+ if (majorVersion == null) {
51
+ return true;
52
+ }
53
+ if (majorVersion === 3) {
54
+ return true;
55
+ }
56
+ if (majorVersion === 4) {
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+ function tryGetRuntimeClassSetSync(twPatcher) {
62
+ if (typeof twPatcher.getClassSetSync !== "function") {
63
+ return void 0;
64
+ }
65
+ if (!shouldPreferSync(twPatcher.majorVersion)) {
66
+ return void 0;
67
+ }
68
+ try {
69
+ return twPatcher.getClassSetSync();
70
+ } catch (error) {
71
+ if (twPatcher.majorVersion === 4) {
72
+ debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
73
+ } else {
74
+ debug("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
75
+ }
76
+ return void 0;
77
+ }
78
+ }
79
+ async function collectRuntimeClassSet(twPatcher, options = {}) {
80
+ const entry = getCacheEntry(twPatcher);
81
+ const signature = getTailwindConfigSignature(twPatcher);
82
+ if (!options.force) {
83
+ if (entry.value && entry.signature === signature) {
84
+ return entry.value;
85
+ }
86
+ if (entry.promise) {
87
+ return entry.promise;
88
+ }
89
+ } else {
90
+ entry.value = void 0;
91
+ }
92
+ const task = (async () => {
93
+ const syncSet = tryGetRuntimeClassSetSync(twPatcher);
94
+ if (syncSet) {
95
+ return syncSet;
96
+ }
97
+ try {
98
+ const result = await twPatcher.extract({ write: false });
99
+ if (_optionalChain([result, 'optionalAccess', _4 => _4.classSet])) {
100
+ return result.classSet;
101
+ }
102
+ } catch (error) {
103
+ debug("extract() failed, fallback to getClassSet(): %O", error);
104
+ }
105
+ try {
106
+ const fallbackSet = await Promise.resolve(twPatcher.getClassSet());
107
+ if (fallbackSet) {
108
+ return fallbackSet;
109
+ }
110
+ } catch (error) {
111
+ debug("getClassSet() failed, returning empty set: %O", error);
112
+ }
113
+ return /* @__PURE__ */ new Set();
114
+ })();
115
+ entry.promise = task;
116
+ entry.signature = signature;
117
+ try {
118
+ const resolved = await task;
119
+ entry.value = resolved;
120
+ entry.promise = void 0;
121
+ entry.signature = signature;
122
+ return resolved;
123
+ } catch (error) {
124
+ entry.promise = void 0;
125
+ throw error;
126
+ }
127
+ }
128
+
129
+
130
+
131
+
132
+
133
+ exports.createDebug = createDebug; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.collectRuntimeClassSet = collectRuntimeClassSet;