weapp-tailwindcss 4.11.0-alpha.0 → 4.11.0-alpha.1

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.
@@ -8,6 +8,90 @@ var _chunkOV7FX6XRjs = require('./chunk-OV7FX6XR.js');
8
8
  // src/logger/index.ts
9
9
  var _logger = require('@weapp-tailwindcss/logger');
10
10
 
11
+ // src/context/workspace.ts
12
+ var _fs = require('fs');
13
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
14
+ var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
15
+ "node_modules",
16
+ ".git",
17
+ ".hg",
18
+ ".svn",
19
+ ".turbo",
20
+ ".output",
21
+ ".next",
22
+ "dist",
23
+ "build"
24
+ ]);
25
+ function findWorkspaceRoot(startDir) {
26
+ if (!startDir) {
27
+ return void 0;
28
+ }
29
+ let current = _path2.default.resolve(startDir);
30
+ while (true) {
31
+ const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
32
+ if (_fs.existsSync.call(void 0, workspaceFile)) {
33
+ return current;
34
+ }
35
+ const parent = _path2.default.dirname(current);
36
+ if (parent === current) {
37
+ return void 0;
38
+ }
39
+ current = parent;
40
+ }
41
+ }
42
+ function findNearestPackageRoot(startDir) {
43
+ if (!startDir) {
44
+ return void 0;
45
+ }
46
+ let current = _path2.default.resolve(startDir);
47
+ while (true) {
48
+ const pkgPath = _path2.default.join(current, "package.json");
49
+ if (_fs.existsSync.call(void 0, pkgPath)) {
50
+ return current;
51
+ }
52
+ const parent = _path2.default.dirname(current);
53
+ if (parent === current) {
54
+ return void 0;
55
+ }
56
+ current = parent;
57
+ }
58
+ }
59
+ function findWorkspacePackageDir(rootDir, packageName) {
60
+ const visited = /* @__PURE__ */ new Set();
61
+ const queue = [_path2.default.resolve(rootDir)];
62
+ while (queue.length > 0) {
63
+ const current = queue.shift();
64
+ const normalized = _path2.default.normalize(current);
65
+ if (visited.has(normalized)) {
66
+ continue;
67
+ }
68
+ visited.add(normalized);
69
+ try {
70
+ const pkgPath = _path2.default.join(normalized, "package.json");
71
+ if (_fs.existsSync.call(void 0, pkgPath)) {
72
+ const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
73
+ if (_optionalChain([pkg, 'optionalAccess', _ => _.name]) === packageName) {
74
+ return normalized;
75
+ }
76
+ }
77
+ } catch (e) {
78
+ }
79
+ let entries;
80
+ try {
81
+ entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
82
+ } catch (e2) {
83
+ continue;
84
+ }
85
+ for (const entry of entries) {
86
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _2 => _2.isSymbolicLink, 'optionalCall', _3 => _3()])) {
87
+ continue;
88
+ }
89
+ queue.push(_path2.default.join(normalized, entry.name));
90
+ }
91
+ }
92
+ return void 0;
93
+ }
94
+
11
95
  // src/tailwindcss/v4/config.ts
12
96
 
13
97
  var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
@@ -77,18 +161,18 @@ function hasConfiguredCssEntries(ctx) {
77
161
  if (normalizeCssEntriesConfig(ctx.cssEntries)) {
78
162
  return true;
79
163
  }
80
- if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _ => _.tailwindcss, 'optionalAccess', _2 => _2.v4, 'optionalAccess', _3 => _3.cssEntries]))) {
164
+ if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _4 => _4.tailwindcss, 'optionalAccess', _5 => _5.v4, 'optionalAccess', _6 => _6.cssEntries]))) {
81
165
  return true;
82
166
  }
83
167
  const patcherOptions = ctx.tailwindcssPatcherOptions;
84
168
  if (patcherOptions) {
85
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _4 => _4.tailwindcss, 'optionalAccess', _5 => _5.v4, 'optionalAccess', _6 => _6.cssEntries]))) {
169
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _7 => _7.tailwindcss, 'optionalAccess', _8 => _8.v4, 'optionalAccess', _9 => _9.cssEntries]))) {
86
170
  return true;
87
171
  }
88
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _7 => _7.tailwind, 'optionalAccess', _8 => _8.v4, 'optionalAccess', _9 => _9.cssEntries]))) {
172
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _10 => _10.tailwind, 'optionalAccess', _11 => _11.v4, 'optionalAccess', _12 => _12.cssEntries]))) {
89
173
  return true;
90
174
  }
91
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _10 => _10.patch, 'optionalAccess', _11 => _11.tailwindcss, 'optionalAccess', _12 => _12.v4, 'optionalAccess', _13 => _13.cssEntries]))) {
175
+ if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _13 => _13.patch, 'optionalAccess', _14 => _14.tailwindcss, 'optionalAccess', _15 => _15.v4, 'optionalAccess', _16 => _16.cssEntries]))) {
92
176
  return true;
93
177
  }
94
178
  }
@@ -99,7 +183,7 @@ function warnMissingCssEntries(ctx, patcher) {
99
183
  if (hasWarnedMissingCssEntries) {
100
184
  return;
101
185
  }
102
- if (_optionalChain([patcher, 'optionalAccess', _14 => _14.majorVersion]) !== 4) {
186
+ if (_optionalChain([patcher, 'optionalAccess', _17 => _17.majorVersion]) !== 4) {
103
187
  return;
104
188
  }
105
189
  if (hasConfiguredCssEntries(ctx)) {
@@ -111,107 +195,132 @@ function warnMissingCssEntries(ctx, patcher) {
111
195
  );
112
196
  }
113
197
  function applyV4CssCalcDefaults(cssCalc, patcher) {
114
- const cssCalcOptions = _nullishCoalesce(cssCalc, () => ( _optionalChain([patcher, 'optionalAccess', _15 => _15.majorVersion]) === 4));
115
- if (_optionalChain([patcher, 'optionalAccess', _16 => _16.majorVersion]) === 4 && cssCalcOptions) {
198
+ const cssCalcOptions = _nullishCoalesce(cssCalc, () => ( _optionalChain([patcher, 'optionalAccess', _18 => _18.majorVersion]) === 4));
199
+ if (_optionalChain([patcher, 'optionalAccess', _19 => _19.majorVersion]) === 4 && cssCalcOptions) {
116
200
  return ensureDefaultsIncluded(cssCalcOptions);
117
201
  }
118
202
  return cssCalcOptions;
119
203
  }
120
204
 
121
- // src/tailwindcss/v4/patcher.ts
205
+ // src/tailwindcss/patcher-resolve.ts
122
206
 
207
+ var _module = require('module');
123
208
 
124
- // src/tailwindcss/patcher.ts
125
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
126
209
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
127
-
128
- var _shared = require('@weapp-tailwindcss/shared');
129
- var _tailwindcsspatch = require('tailwindcss-patch');
130
-
131
- // src/context/workspace.ts
132
- var _fs = require('fs');
133
-
134
- var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
135
- "node_modules",
136
- ".git",
137
- ".hg",
138
- ".svn",
139
- ".turbo",
140
- ".output",
141
- ".next",
142
- "dist",
143
- "build"
144
- ]);
145
- function findWorkspaceRoot(startDir) {
146
- if (!startDir) {
210
+ var _url = require('url');
211
+ var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
212
+ var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
213
+ "stubs/config.full.js",
214
+ "defaultConfig.js"
215
+ ];
216
+ var TAILWIND_CONFIG_FILES = [
217
+ "tailwind.config.js",
218
+ "tailwind.config.cjs",
219
+ "tailwind.config.mjs",
220
+ "tailwind.config.ts",
221
+ "tailwind.config.cts",
222
+ "tailwind.config.mts"
223
+ ];
224
+ function isPathSpecifier(specifier) {
225
+ if (!specifier) {
226
+ return false;
227
+ }
228
+ if (specifier.startsWith("file://")) {
229
+ return true;
230
+ }
231
+ if (_path2.default.isAbsolute(specifier)) {
232
+ return true;
233
+ }
234
+ return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
235
+ }
236
+ function resolveModuleFromPaths(specifier, paths) {
237
+ if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
147
238
  return void 0;
148
239
  }
149
- let current = _path2.default.resolve(startDir);
150
- while (true) {
151
- const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
152
- if (_fs.existsSync.call(void 0, workspaceFile)) {
153
- return current;
154
- }
155
- const parent = _path2.default.dirname(current);
156
- if (parent === current) {
157
- return void 0;
158
- }
159
- current = parent;
240
+ try {
241
+ const req = _module.createRequire.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
242
+ return req.resolve(specifier, { paths });
243
+ } catch (e3) {
244
+ return void 0;
160
245
  }
161
246
  }
162
- function findNearestPackageRoot(startDir) {
163
- if (!startDir) {
247
+ function resolveTailwindConfigFallback(packageName, paths) {
248
+ if (!packageName) {
164
249
  return void 0;
165
250
  }
166
- let current = _path2.default.resolve(startDir);
167
- while (true) {
168
- const pkgPath = _path2.default.join(current, "package.json");
169
- if (_fs.existsSync.call(void 0, pkgPath)) {
170
- return current;
171
- }
172
- const parent = _path2.default.dirname(current);
173
- if (parent === current) {
174
- return void 0;
251
+ for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
252
+ const candidate = `${packageName}/${suffix}`;
253
+ const resolved = resolveModuleFromPaths(candidate, paths);
254
+ if (resolved) {
255
+ return resolved;
175
256
  }
176
- current = parent;
177
257
  }
258
+ return void 0;
178
259
  }
179
- function findWorkspacePackageDir(rootDir, packageName) {
180
- const visited = /* @__PURE__ */ new Set();
181
- const queue = [_path2.default.resolve(rootDir)];
182
- while (queue.length > 0) {
183
- const current = queue.shift();
184
- const normalized = _path2.default.normalize(current);
185
- if (visited.has(normalized)) {
186
- continue;
187
- }
188
- visited.add(normalized);
189
- try {
190
- const pkgPath = _path2.default.join(normalized, "package.json");
191
- if (_fs.existsSync.call(void 0, pkgPath)) {
192
- const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
193
- if (_optionalChain([pkg, 'optionalAccess', _17 => _17.name]) === packageName) {
194
- return normalized;
195
- }
260
+ function appendNodeModules(paths, dir) {
261
+ if (!dir) {
262
+ return;
263
+ }
264
+ const nodeModulesDir = _path2.default.join(dir, "node_modules");
265
+ if (_fs.existsSync.call(void 0, nodeModulesDir)) {
266
+ paths.add(nodeModulesDir);
267
+ }
268
+ }
269
+ function findTailwindConfig(searchRoots) {
270
+ for (const root of searchRoots) {
271
+ for (const file of TAILWIND_CONFIG_FILES) {
272
+ const candidate = _path2.default.resolve(root, file);
273
+ if (_fs.existsSync.call(void 0, candidate)) {
274
+ return candidate;
196
275
  }
197
- } catch (e) {
198
276
  }
199
- let entries;
200
- try {
201
- entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
202
- } catch (e2) {
203
- continue;
277
+ }
278
+ return void 0;
279
+ }
280
+ function createDefaultResolvePaths(basedir) {
281
+ const paths = /* @__PURE__ */ new Set();
282
+ let fallbackCandidates = [];
283
+ if (basedir) {
284
+ const resolvedBase = _path2.default.resolve(basedir);
285
+ appendNodeModules(paths, resolvedBase);
286
+ fallbackCandidates.push(resolvedBase);
287
+ const packageRoot = findNearestPackageRoot(resolvedBase);
288
+ if (packageRoot) {
289
+ appendNodeModules(paths, packageRoot);
290
+ fallbackCandidates.push(packageRoot);
204
291
  }
205
- for (const entry of entries) {
206
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _18 => _18.isSymbolicLink, 'optionalCall', _19 => _19()])) {
207
- continue;
208
- }
209
- queue.push(_path2.default.join(normalized, entry.name));
292
+ }
293
+ const cwd = _process2.default.cwd();
294
+ appendNodeModules(paths, cwd);
295
+ try {
296
+ const modulePath = _url.fileURLToPath.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
297
+ const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
298
+ paths.add(candidate);
299
+ } catch (e4) {
300
+ paths.add(_chunkOV7FX6XRjs.importMetaUrl);
301
+ }
302
+ if (paths.size === 0) {
303
+ fallbackCandidates = fallbackCandidates.filter(Boolean);
304
+ if (fallbackCandidates.length === 0) {
305
+ fallbackCandidates.push(cwd);
306
+ }
307
+ for (const candidate of fallbackCandidates) {
308
+ paths.add(candidate);
210
309
  }
211
310
  }
212
- return void 0;
311
+ return [...paths];
213
312
  }
214
313
 
314
+ // src/tailwindcss/v4/patcher.ts
315
+
316
+
317
+ // src/tailwindcss/patcher.ts
318
+
319
+
320
+
321
+ var _shared = require('@weapp-tailwindcss/shared');
322
+ var _tailwindcsspatch = require('tailwindcss-patch');
323
+
215
324
  // src/tailwindcss/patcher-options.ts
216
325
  function normalizeExtendLengthUnits(value) {
217
326
  if (value === false) {
@@ -363,115 +472,6 @@ function toModernTailwindcssPatchOptions(options) {
363
472
  return normalized;
364
473
  }
365
474
 
366
- // src/tailwindcss/patcher-resolve.ts
367
-
368
- var _module = require('module');
369
-
370
-
371
- var _url = require('url');
372
- var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
373
- var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
374
- "stubs/config.full.js",
375
- "defaultConfig.js"
376
- ];
377
- var TAILWIND_CONFIG_FILES = [
378
- "tailwind.config.js",
379
- "tailwind.config.cjs",
380
- "tailwind.config.mjs",
381
- "tailwind.config.ts",
382
- "tailwind.config.cts",
383
- "tailwind.config.mts"
384
- ];
385
- function isPathSpecifier(specifier) {
386
- if (!specifier) {
387
- return false;
388
- }
389
- if (specifier.startsWith("file://")) {
390
- return true;
391
- }
392
- if (_path2.default.isAbsolute(specifier)) {
393
- return true;
394
- }
395
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
396
- }
397
- function resolveModuleFromPaths(specifier, paths) {
398
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
399
- return void 0;
400
- }
401
- try {
402
- const req = _module.createRequire.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
403
- return req.resolve(specifier, { paths });
404
- } catch (e3) {
405
- return void 0;
406
- }
407
- }
408
- function resolveTailwindConfigFallback(packageName, paths) {
409
- if (!packageName) {
410
- return void 0;
411
- }
412
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
413
- const candidate = `${packageName}/${suffix}`;
414
- const resolved = resolveModuleFromPaths(candidate, paths);
415
- if (resolved) {
416
- return resolved;
417
- }
418
- }
419
- return void 0;
420
- }
421
- function appendNodeModules(paths, dir) {
422
- if (!dir) {
423
- return;
424
- }
425
- const nodeModulesDir = _path2.default.join(dir, "node_modules");
426
- if (_fs.existsSync.call(void 0, nodeModulesDir)) {
427
- paths.add(nodeModulesDir);
428
- }
429
- }
430
- function findTailwindConfig(searchRoots) {
431
- for (const root of searchRoots) {
432
- for (const file of TAILWIND_CONFIG_FILES) {
433
- const candidate = _path2.default.resolve(root, file);
434
- if (_fs.existsSync.call(void 0, candidate)) {
435
- return candidate;
436
- }
437
- }
438
- }
439
- return void 0;
440
- }
441
- function createDefaultResolvePaths(basedir) {
442
- const paths = /* @__PURE__ */ new Set();
443
- let fallbackCandidates = [];
444
- if (basedir) {
445
- const resolvedBase = _path2.default.resolve(basedir);
446
- appendNodeModules(paths, resolvedBase);
447
- fallbackCandidates.push(resolvedBase);
448
- const packageRoot = findNearestPackageRoot(resolvedBase);
449
- if (packageRoot) {
450
- appendNodeModules(paths, packageRoot);
451
- fallbackCandidates.push(packageRoot);
452
- }
453
- }
454
- const cwd = _process2.default.cwd();
455
- appendNodeModules(paths, cwd);
456
- try {
457
- const modulePath = _url.fileURLToPath.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
458
- const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
459
- paths.add(candidate);
460
- } catch (e4) {
461
- paths.add(_chunkOV7FX6XRjs.importMetaUrl);
462
- }
463
- if (paths.size === 0) {
464
- fallbackCandidates = fallbackCandidates.filter(Boolean);
465
- if (fallbackCandidates.length === 0) {
466
- fallbackCandidates.push(cwd);
467
- }
468
- for (const candidate of fallbackCandidates) {
469
- paths.add(candidate);
470
- }
471
- }
472
- return [...paths];
473
- }
474
-
475
475
  // src/tailwindcss/patcher.ts
476
476
  function createFallbackTailwindcssPatcher() {
477
477
  const packageInfo = {
@@ -1265,4 +1265,5 @@ function createTailwindcssPatcherFromContext(ctx) {
1265
1265
 
1266
1266
 
1267
1267
 
1268
- exports.findWorkspaceRoot = findWorkspaceRoot; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;
1268
+
1269
+ exports.findWorkspaceRoot = findWorkspaceRoot; exports.findNearestPackageRoot = findNearestPackageRoot; exports.warnMissingCssEntries = warnMissingCssEntries; exports.applyV4CssCalcDefaults = applyV4CssCalcDefaults; exports.findTailwindConfig = findTailwindConfig; exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext; exports.logger = _logger.logger;