tailwindcss-patch 8.6.0 → 8.6.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.
@@ -221,6 +221,25 @@ async function importNode() {
221
221
  async function importOxide() {
222
222
  return Promise.resolve().then(() => _interopRequireWildcard(require("@tailwindcss/oxide")));
223
223
  }
224
+ async function loadDesignSystem(css, bases) {
225
+ const uniqueBases = Array.from(new Set(bases.filter(Boolean)));
226
+ if (uniqueBases.length === 0) {
227
+ throw new Error("No base directories provided for Tailwind CSS design system.");
228
+ }
229
+ const { __unstable__loadDesignSystem } = await importNode();
230
+ let lastError;
231
+ for (const base of uniqueBases) {
232
+ try {
233
+ return await __unstable__loadDesignSystem(css, { base });
234
+ } catch (error) {
235
+ lastError = error;
236
+ }
237
+ }
238
+ if (lastError instanceof Error) {
239
+ throw lastError;
240
+ }
241
+ throw new Error("Failed to load Tailwind CSS design system.");
242
+ }
224
243
  async function extractRawCandidatesWithPositions(content, extension = "html") {
225
244
  const { Scanner } = await importOxide();
226
245
  const scanner = new Scanner({});
@@ -242,6 +261,7 @@ async function extractValidCandidates(options) {
242
261
  const providedOptions = _nullishCoalesce(options, () => ( {}));
243
262
  const defaultCwd = _nullishCoalesce(providedOptions.cwd, () => ( _process2.default.cwd()));
244
263
  const base = _nullishCoalesce(providedOptions.base, () => ( defaultCwd));
264
+ const baseFallbacks = _nullishCoalesce(providedOptions.baseFallbacks, () => ( []));
245
265
  const css = _nullishCoalesce(providedOptions.css, () => ( '@import "tailwindcss";'));
246
266
  const sources = (_nullishCoalesce(providedOptions.sources, () => ( [
247
267
  {
@@ -254,8 +274,7 @@ async function extractValidCandidates(options) {
254
274
  pattern: source.pattern,
255
275
  negated: source.negated
256
276
  }));
257
- const { __unstable__loadDesignSystem } = await importNode();
258
- const designSystem = await __unstable__loadDesignSystem(css, { base });
277
+ const designSystem = await loadDesignSystem(css, [base, ...baseFallbacks]);
259
278
  const candidates = await extractRawCandidates(sources);
260
279
  const parsedCandidates = candidates.filter(
261
280
  (rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
@@ -1347,11 +1366,13 @@ async function collectClassesFromTailwindV4(options) {
1347
1366
  }
1348
1367
  const css = await _fsextra2.default.readFile(filePath, "utf8");
1349
1368
  const entryDir = _pathe2.default.dirname(filePath);
1350
- const baseForEntry = _nullishCoalesce(resolvedConfiguredBase, () => ( entryDir));
1351
- const sources = resolveSources(baseForEntry);
1369
+ const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
1370
+ const sourcesBase = _nullishCoalesce(resolvedConfiguredBase, () => ( entryDir));
1371
+ const sources = resolveSources(sourcesBase);
1352
1372
  const candidates = await extractValidCandidates({
1353
1373
  cwd: options.projectRoot,
1354
- base: baseForEntry,
1374
+ base: designSystemBases[0],
1375
+ baseFallbacks: designSystemBases.slice(1),
1355
1376
  css,
1356
1377
  sources
1357
1378
  });
@@ -217,6 +217,25 @@ async function importNode() {
217
217
  async function importOxide() {
218
218
  return import("@tailwindcss/oxide");
219
219
  }
220
+ async function loadDesignSystem(css, bases) {
221
+ const uniqueBases = Array.from(new Set(bases.filter(Boolean)));
222
+ if (uniqueBases.length === 0) {
223
+ throw new Error("No base directories provided for Tailwind CSS design system.");
224
+ }
225
+ const { __unstable__loadDesignSystem } = await importNode();
226
+ let lastError;
227
+ for (const base of uniqueBases) {
228
+ try {
229
+ return await __unstable__loadDesignSystem(css, { base });
230
+ } catch (error) {
231
+ lastError = error;
232
+ }
233
+ }
234
+ if (lastError instanceof Error) {
235
+ throw lastError;
236
+ }
237
+ throw new Error("Failed to load Tailwind CSS design system.");
238
+ }
220
239
  async function extractRawCandidatesWithPositions(content, extension = "html") {
221
240
  const { Scanner } = await importOxide();
222
241
  const scanner = new Scanner({});
@@ -238,6 +257,7 @@ async function extractValidCandidates(options) {
238
257
  const providedOptions = options ?? {};
239
258
  const defaultCwd = providedOptions.cwd ?? process2.cwd();
240
259
  const base = providedOptions.base ?? defaultCwd;
260
+ const baseFallbacks = providedOptions.baseFallbacks ?? [];
241
261
  const css = providedOptions.css ?? '@import "tailwindcss";';
242
262
  const sources = (providedOptions.sources ?? [
243
263
  {
@@ -250,8 +270,7 @@ async function extractValidCandidates(options) {
250
270
  pattern: source.pattern,
251
271
  negated: source.negated
252
272
  }));
253
- const { __unstable__loadDesignSystem } = await importNode();
254
- const designSystem = await __unstable__loadDesignSystem(css, { base });
273
+ const designSystem = await loadDesignSystem(css, [base, ...baseFallbacks]);
255
274
  const candidates = await extractRawCandidates(sources);
256
275
  const parsedCandidates = candidates.filter(
257
276
  (rawCandidate) => designSystem.parseCandidate(rawCandidate).length > 0
@@ -1343,11 +1362,13 @@ async function collectClassesFromTailwindV4(options) {
1343
1362
  }
1344
1363
  const css = await fs5.readFile(filePath, "utf8");
1345
1364
  const entryDir = path5.dirname(filePath);
1346
- const baseForEntry = resolvedConfiguredBase ?? entryDir;
1347
- const sources = resolveSources(baseForEntry);
1365
+ const designSystemBases = resolvedConfiguredBase && resolvedConfiguredBase !== entryDir ? [entryDir, resolvedConfiguredBase] : [entryDir];
1366
+ const sourcesBase = resolvedConfiguredBase ?? entryDir;
1367
+ const sources = resolveSources(sourcesBase);
1348
1368
  const candidates = await extractValidCandidates({
1349
1369
  cwd: options.projectRoot,
1350
- base: baseForEntry,
1370
+ base: designSystemBases[0],
1371
+ baseFallbacks: designSystemBases.slice(1),
1351
1372
  css,
1352
1373
  sources
1353
1374
  });
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _chunkJ27TPXH5js = require('./chunk-J27TPXH5.js');
3
+ var _chunkDRPYVUDAjs = require('./chunk-DRPYVUDA.js');
4
4
 
5
5
  // src/cli.ts
6
- var cli = _chunkJ27TPXH5js.createTailwindcssPatchCli.call(void 0, );
6
+ var cli = _chunkDRPYVUDAjs.createTailwindcssPatchCli.call(void 0, );
7
7
  cli.help();
8
8
  cli.parse();
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createTailwindcssPatchCli
3
- } from "./chunk-RVSD53YX.mjs";
3
+ } from "./chunk-LOJHMBK5.mjs";
4
4
 
5
5
  // src/cli.ts
6
6
  var cli = createTailwindcssPatchCli();
package/dist/index.d.mts CHANGED
@@ -380,6 +380,7 @@ interface LegacyTailwindcssPatcherOptions {
380
380
  interface ExtractValidCandidatesOption {
381
381
  sources?: SourceEntry[];
382
382
  base?: string;
383
+ baseFallbacks?: string[];
383
384
  css?: string;
384
385
  cwd?: string;
385
386
  }
package/dist/index.d.ts CHANGED
@@ -380,6 +380,7 @@ interface LegacyTailwindcssPatcherOptions {
380
380
  interface ExtractValidCandidatesOption {
381
381
  sources?: SourceEntry[];
382
382
  base?: string;
383
+ baseFallbacks?: string[];
383
384
  css?: string;
384
385
  cwd?: string;
385
386
  }
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- var _chunkJ27TPXH5js = require('./chunk-J27TPXH5.js');
19
+ var _chunkDRPYVUDAjs = require('./chunk-DRPYVUDA.js');
20
20
 
21
21
  // src/index.ts
22
22
  var _config = require('@tailwindcss-mangle/config');
@@ -39,4 +39,4 @@ var _config = require('@tailwindcss-mangle/config');
39
39
 
40
40
 
41
41
 
42
- exports.CacheStore = _chunkJ27TPXH5js.CacheStore; exports.TailwindcssPatcher = _chunkJ27TPXH5js.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkJ27TPXH5js.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkJ27TPXH5js.collectClassesFromTailwindV4; exports.createTailwindcssPatchCli = _chunkJ27TPXH5js.createTailwindcssPatchCli; exports.defineConfig = _config.defineConfig; exports.extractProjectCandidatesWithPositions = _chunkJ27TPXH5js.extractProjectCandidatesWithPositions; exports.extractRawCandidates = _chunkJ27TPXH5js.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkJ27TPXH5js.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkJ27TPXH5js.extractValidCandidates; exports.getPatchStatusReport = _chunkJ27TPXH5js.getPatchStatusReport; exports.groupTokensByFile = _chunkJ27TPXH5js.groupTokensByFile; exports.loadRuntimeContexts = _chunkJ27TPXH5js.loadRuntimeContexts; exports.logger = _chunkJ27TPXH5js.logger_default; exports.mountTailwindcssPatchCommands = _chunkJ27TPXH5js.mountTailwindcssPatchCommands; exports.normalizeOptions = _chunkJ27TPXH5js.normalizeOptions; exports.runTailwindBuild = _chunkJ27TPXH5js.runTailwindBuild; exports.tailwindcssPatchCommands = _chunkJ27TPXH5js.tailwindcssPatchCommands;
42
+ exports.CacheStore = _chunkDRPYVUDAjs.CacheStore; exports.TailwindcssPatcher = _chunkDRPYVUDAjs.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkDRPYVUDAjs.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkDRPYVUDAjs.collectClassesFromTailwindV4; exports.createTailwindcssPatchCli = _chunkDRPYVUDAjs.createTailwindcssPatchCli; exports.defineConfig = _config.defineConfig; exports.extractProjectCandidatesWithPositions = _chunkDRPYVUDAjs.extractProjectCandidatesWithPositions; exports.extractRawCandidates = _chunkDRPYVUDAjs.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkDRPYVUDAjs.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkDRPYVUDAjs.extractValidCandidates; exports.getPatchStatusReport = _chunkDRPYVUDAjs.getPatchStatusReport; exports.groupTokensByFile = _chunkDRPYVUDAjs.groupTokensByFile; exports.loadRuntimeContexts = _chunkDRPYVUDAjs.loadRuntimeContexts; exports.logger = _chunkDRPYVUDAjs.logger_default; exports.mountTailwindcssPatchCommands = _chunkDRPYVUDAjs.mountTailwindcssPatchCommands; exports.normalizeOptions = _chunkDRPYVUDAjs.normalizeOptions; exports.runTailwindBuild = _chunkDRPYVUDAjs.runTailwindBuild; exports.tailwindcssPatchCommands = _chunkDRPYVUDAjs.tailwindcssPatchCommands;
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  normalizeOptions,
17
17
  runTailwindBuild,
18
18
  tailwindcssPatchCommands
19
- } from "./chunk-RVSD53YX.mjs";
19
+ } from "./chunk-LOJHMBK5.mjs";
20
20
 
21
21
  // src/index.ts
22
22
  import { defineConfig } from "@tailwindcss-mangle/config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "8.6.0",
3
+ "version": "8.6.1",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",