tailwindcss-patch 8.5.1 → 8.6.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.
package/README.md CHANGED
@@ -129,6 +129,7 @@ const patcher = new TailwindcssPatcher({
129
129
  enabled: true,
130
130
  dir: '.tw-patch/cache',
131
131
  strategy: 'merge',
132
+ driver: 'file',
132
133
  },
133
134
  output: {
134
135
  file: '.tw-patch/tw-class-list.json',
@@ -163,10 +164,12 @@ console.log(patchStatus.entries)
163
164
 
164
165
  The constructor accepts either the new object shown above or the historical `patch`/`cache` shape. Conversions happen internally so existing configs remain backwards compatible.
165
166
 
167
+ Use cache.driver to switch between the default file-backed cache, an in-memory cache (memory), or a no-op cache (noop) when filesystem permissions are restricted.
168
+
166
169
  ### Helper utilities
167
170
 
168
171
  - `normalizeOptions` – normalise raw user input to the runtime shape.
169
- - `CacheStore` – read/write class caches respecting merge or overwrite semantics.
172
+ - `CacheStore` – read/write class caches (file, memory, or noop drivers) respecting merge or overwrite semantics.
170
173
  - `extractProjectCandidatesWithPositions` – gather Tailwind tokens for every configured source file with location metadata.
171
174
  - `groupTokensByFile` – convert a token report into a `{ [filePath]: TailwindTokenLocation[] }` map.
172
175
  - `extractValidCandidates` – scan Tailwind v4 CSS/content sources with the Tailwind Oxide scanner.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } var _class;// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; } var _class; var _class2;// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
2
2
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
3
3
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
4
4
 
@@ -16,10 +16,13 @@ function isErrnoException(error) {
16
16
  function isAccessDenied(error) {
17
17
  return isErrnoException(error) && Boolean(error.code && ["EPERM", "EBUSY", "EACCES"].includes(error.code));
18
18
  }
19
- var CacheStore = class {
20
- constructor(options) {
19
+ var CacheStore = (_class = class {
20
+ constructor(options) {;_class.prototype.__init.call(this);
21
21
  this.options = options;
22
+ this.driver = _nullishCoalesce(options.driver, () => ( "file"));
22
23
  }
24
+
25
+ __init() {this.memoryCache = null}
23
26
  async ensureDir() {
24
27
  await _fsextra2.default.ensureDir(this.options.dir);
25
28
  }
@@ -92,6 +95,13 @@ var CacheStore = class {
92
95
  if (!this.options.enabled) {
93
96
  return void 0;
94
97
  }
98
+ if (this.driver === "noop") {
99
+ return void 0;
100
+ }
101
+ if (this.driver === "memory") {
102
+ this.memoryCache = new Set(data);
103
+ return "memory";
104
+ }
95
105
  const tempPath = this.createTempPath();
96
106
  try {
97
107
  await this.ensureDir();
@@ -112,6 +122,13 @@ var CacheStore = class {
112
122
  if (!this.options.enabled) {
113
123
  return void 0;
114
124
  }
125
+ if (this.driver === "noop") {
126
+ return void 0;
127
+ }
128
+ if (this.driver === "memory") {
129
+ this.memoryCache = new Set(data);
130
+ return "memory";
131
+ }
115
132
  const tempPath = this.createTempPath();
116
133
  try {
117
134
  this.ensureDirSync();
@@ -132,6 +149,12 @@ var CacheStore = class {
132
149
  if (!this.options.enabled) {
133
150
  return /* @__PURE__ */ new Set();
134
151
  }
152
+ if (this.driver === "noop") {
153
+ return /* @__PURE__ */ new Set();
154
+ }
155
+ if (this.driver === "memory") {
156
+ return new Set(_nullishCoalesce(this.memoryCache, () => ( [])));
157
+ }
135
158
  try {
136
159
  const exists = await _fsextra2.default.pathExists(this.options.path);
137
160
  if (!exists) {
@@ -158,6 +181,12 @@ var CacheStore = class {
158
181
  if (!this.options.enabled) {
159
182
  return /* @__PURE__ */ new Set();
160
183
  }
184
+ if (this.driver === "noop") {
185
+ return /* @__PURE__ */ new Set();
186
+ }
187
+ if (this.driver === "memory") {
188
+ return new Set(_nullishCoalesce(this.memoryCache, () => ( [])));
189
+ }
161
190
  try {
162
191
  const exists = _fsextra2.default.pathExistsSync(this.options.path);
163
192
  if (!exists) {
@@ -180,7 +209,7 @@ var CacheStore = class {
180
209
  }
181
210
  return /* @__PURE__ */ new Set();
182
211
  }
183
- };
212
+ }, _class);
184
213
 
185
214
  // src/extraction/candidate-extractor.ts
186
215
  var _fs = require('fs');
@@ -395,12 +424,19 @@ function toPrettyValue(value) {
395
424
  }
396
425
  return false;
397
426
  }
427
+ function normalizeCacheDriver(driver) {
428
+ if (driver === "memory" || driver === "noop") {
429
+ return driver;
430
+ }
431
+ return "file";
432
+ }
398
433
  function normalizeCacheOptions(cache, projectRoot) {
399
434
  let enabled = false;
400
435
  let cwd = projectRoot;
401
436
  let dir = _pathe2.default.resolve(cwd, "node_modules/.cache", pkgName);
402
437
  let file = "class-cache.json";
403
438
  let strategy = "merge";
439
+ let driver = "file";
404
440
  if (typeof cache === "boolean") {
405
441
  enabled = cache;
406
442
  } else if (typeof cache === "object" && cache) {
@@ -409,6 +445,7 @@ function normalizeCacheOptions(cache, projectRoot) {
409
445
  dir = cache.dir ? _pathe2.default.resolve(cache.dir) : _pathe2.default.resolve(cwd, "node_modules/.cache", pkgName);
410
446
  file = _nullishCoalesce(cache.file, () => ( file));
411
447
  strategy = _nullishCoalesce(cache.strategy, () => ( strategy));
448
+ driver = normalizeCacheDriver(cache.driver);
412
449
  }
413
450
  const filename = _pathe2.default.resolve(dir, file);
414
451
  return {
@@ -417,7 +454,8 @@ function normalizeCacheOptions(cache, projectRoot) {
417
454
  dir,
418
455
  file,
419
456
  path: filename,
420
- strategy
457
+ strategy,
458
+ driver
421
459
  };
422
460
  }
423
461
  function normalizeOutputOptions(output) {
@@ -1691,12 +1729,12 @@ function resolveTailwindExecutionOptions(normalized, majorVersion) {
1691
1729
  postcssPlugin: base.postcssPlugin
1692
1730
  };
1693
1731
  }
1694
- var TailwindcssPatcher = (_class = class {
1732
+ var TailwindcssPatcher = (_class2 = class {
1695
1733
 
1696
1734
 
1697
1735
 
1698
1736
 
1699
- constructor(options = {}) {;_class.prototype.__init.call(this);
1737
+ constructor(options = {}) {;_class2.prototype.__init2.call(this);
1700
1738
  const resolvedOptions = options && typeof options === "object" && "patch" in options ? fromLegacyOptions(options) : options;
1701
1739
  this.options = normalizeOptions(resolvedOptions);
1702
1740
  const packageInfo = _localpkg.getPackageInfoSync.call(void 0,
@@ -1834,7 +1872,7 @@ var TailwindcssPatcher = (_class = class {
1834
1872
  };
1835
1873
  }
1836
1874
  // Backwards compatibility helper used by tests and API consumers.
1837
- __init() {this.extractValidCandidates = exports.extractValidCandidates = extractValidCandidates}
1875
+ __init2() {this.extractValidCandidates = exports.extractValidCandidates = extractValidCandidates}
1838
1876
  async collectContentTokens(options) {
1839
1877
  return extractProjectCandidatesWithPositions({
1840
1878
  cwd: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _72 => _72.cwd]), () => ( this.options.projectRoot)),
@@ -1851,7 +1889,7 @@ var TailwindcssPatcher = (_class = class {
1851
1889
  stripAbsolutePaths: _optionalChain([options, 'optionalAccess', _81 => _81.stripAbsolutePaths])
1852
1890
  });
1853
1891
  }
1854
- }, _class);
1892
+ }, _class2);
1855
1893
 
1856
1894
  // src/cli/commands.ts
1857
1895
 
@@ -15,7 +15,10 @@ function isAccessDenied(error) {
15
15
  var CacheStore = class {
16
16
  constructor(options) {
17
17
  this.options = options;
18
+ this.driver = options.driver ?? "file";
18
19
  }
20
+ driver;
21
+ memoryCache = null;
19
22
  async ensureDir() {
20
23
  await fs.ensureDir(this.options.dir);
21
24
  }
@@ -88,6 +91,13 @@ var CacheStore = class {
88
91
  if (!this.options.enabled) {
89
92
  return void 0;
90
93
  }
94
+ if (this.driver === "noop") {
95
+ return void 0;
96
+ }
97
+ if (this.driver === "memory") {
98
+ this.memoryCache = new Set(data);
99
+ return "memory";
100
+ }
91
101
  const tempPath = this.createTempPath();
92
102
  try {
93
103
  await this.ensureDir();
@@ -108,6 +118,13 @@ var CacheStore = class {
108
118
  if (!this.options.enabled) {
109
119
  return void 0;
110
120
  }
121
+ if (this.driver === "noop") {
122
+ return void 0;
123
+ }
124
+ if (this.driver === "memory") {
125
+ this.memoryCache = new Set(data);
126
+ return "memory";
127
+ }
111
128
  const tempPath = this.createTempPath();
112
129
  try {
113
130
  this.ensureDirSync();
@@ -128,6 +145,12 @@ var CacheStore = class {
128
145
  if (!this.options.enabled) {
129
146
  return /* @__PURE__ */ new Set();
130
147
  }
148
+ if (this.driver === "noop") {
149
+ return /* @__PURE__ */ new Set();
150
+ }
151
+ if (this.driver === "memory") {
152
+ return new Set(this.memoryCache ?? []);
153
+ }
131
154
  try {
132
155
  const exists = await fs.pathExists(this.options.path);
133
156
  if (!exists) {
@@ -154,6 +177,12 @@ var CacheStore = class {
154
177
  if (!this.options.enabled) {
155
178
  return /* @__PURE__ */ new Set();
156
179
  }
180
+ if (this.driver === "noop") {
181
+ return /* @__PURE__ */ new Set();
182
+ }
183
+ if (this.driver === "memory") {
184
+ return new Set(this.memoryCache ?? []);
185
+ }
157
186
  try {
158
187
  const exists = fs.pathExistsSync(this.options.path);
159
188
  if (!exists) {
@@ -391,12 +420,19 @@ function toPrettyValue(value) {
391
420
  }
392
421
  return false;
393
422
  }
423
+ function normalizeCacheDriver(driver) {
424
+ if (driver === "memory" || driver === "noop") {
425
+ return driver;
426
+ }
427
+ return "file";
428
+ }
394
429
  function normalizeCacheOptions(cache, projectRoot) {
395
430
  let enabled = false;
396
431
  let cwd = projectRoot;
397
432
  let dir = path2.resolve(cwd, "node_modules/.cache", pkgName);
398
433
  let file = "class-cache.json";
399
434
  let strategy = "merge";
435
+ let driver = "file";
400
436
  if (typeof cache === "boolean") {
401
437
  enabled = cache;
402
438
  } else if (typeof cache === "object" && cache) {
@@ -405,6 +441,7 @@ function normalizeCacheOptions(cache, projectRoot) {
405
441
  dir = cache.dir ? path2.resolve(cache.dir) : path2.resolve(cwd, "node_modules/.cache", pkgName);
406
442
  file = cache.file ?? file;
407
443
  strategy = cache.strategy ?? strategy;
444
+ driver = normalizeCacheDriver(cache.driver);
408
445
  }
409
446
  const filename = path2.resolve(dir, file);
410
447
  return {
@@ -413,7 +450,8 @@ function normalizeCacheOptions(cache, projectRoot) {
413
450
  dir,
414
451
  file,
415
452
  path: filename,
416
- strategy
453
+ strategy,
454
+ driver
417
455
  };
418
456
  }
419
457
  function normalizeOutputOptions(output) {
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _chunkBSUCDWMJjs = require('./chunk-BSUCDWMJ.js');
3
+ var _chunkJ27TPXH5js = require('./chunk-J27TPXH5.js');
4
4
 
5
5
  // src/cli.ts
6
- var cli = _chunkBSUCDWMJjs.createTailwindcssPatchCli.call(void 0, );
6
+ var cli = _chunkJ27TPXH5js.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-KGBUT44N.mjs";
3
+ } from "./chunk-RVSD53YX.mjs";
4
4
 
5
5
  // src/cli.ts
6
6
  var cli = createTailwindcssPatchCli();
package/dist/index.d.mts CHANGED
@@ -8,6 +8,7 @@ import { Command, CAC } from 'cac';
8
8
  import * as consola from 'consola';
9
9
 
10
10
  type CacheStrategy = 'merge' | 'overwrite';
11
+ type CacheDriver = 'file' | 'memory' | 'noop';
11
12
  /**
12
13
  * Configures how the Tailwind class cache is stored and where it lives on disk.
13
14
  */
@@ -25,6 +26,8 @@ interface CacheUserOptions {
25
26
  file?: string;
26
27
  /** Strategy used when merging new class lists with an existing cache. */
27
28
  strategy?: CacheStrategy;
29
+ /** Backend used to persist the cache (`file`, `memory`, or `noop`). Defaults to `file`. */
30
+ driver?: CacheDriver;
28
31
  }
29
32
  /**
30
33
  * Controls how extracted class lists are written to disk.
@@ -150,6 +153,7 @@ interface NormalizedCacheOptions {
150
153
  file: string;
151
154
  path: string;
152
155
  strategy: CacheStrategy;
156
+ driver: CacheDriver;
153
157
  }
154
158
  /** Tracks whether runtime contexts should be exposed and via which property. */
155
159
  interface NormalizedExposeContextOptions {
@@ -431,6 +435,8 @@ declare class TailwindcssPatcher {
431
435
 
432
436
  declare class CacheStore {
433
437
  private readonly options;
438
+ private readonly driver;
439
+ private memoryCache;
434
440
  constructor(options: NormalizedCacheOptions);
435
441
  private ensureDir;
436
442
  private ensureDirSync;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { Command, CAC } from 'cac';
8
8
  import * as consola from 'consola';
9
9
 
10
10
  type CacheStrategy = 'merge' | 'overwrite';
11
+ type CacheDriver = 'file' | 'memory' | 'noop';
11
12
  /**
12
13
  * Configures how the Tailwind class cache is stored and where it lives on disk.
13
14
  */
@@ -25,6 +26,8 @@ interface CacheUserOptions {
25
26
  file?: string;
26
27
  /** Strategy used when merging new class lists with an existing cache. */
27
28
  strategy?: CacheStrategy;
29
+ /** Backend used to persist the cache (`file`, `memory`, or `noop`). Defaults to `file`. */
30
+ driver?: CacheDriver;
28
31
  }
29
32
  /**
30
33
  * Controls how extracted class lists are written to disk.
@@ -150,6 +153,7 @@ interface NormalizedCacheOptions {
150
153
  file: string;
151
154
  path: string;
152
155
  strategy: CacheStrategy;
156
+ driver: CacheDriver;
153
157
  }
154
158
  /** Tracks whether runtime contexts should be exposed and via which property. */
155
159
  interface NormalizedExposeContextOptions {
@@ -431,6 +435,8 @@ declare class TailwindcssPatcher {
431
435
 
432
436
  declare class CacheStore {
433
437
  private readonly options;
438
+ private readonly driver;
439
+ private memoryCache;
434
440
  constructor(options: NormalizedCacheOptions);
435
441
  private ensureDir;
436
442
  private ensureDirSync;
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- var _chunkBSUCDWMJjs = require('./chunk-BSUCDWMJ.js');
19
+ var _chunkJ27TPXH5js = require('./chunk-J27TPXH5.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 = _chunkBSUCDWMJjs.CacheStore; exports.TailwindcssPatcher = _chunkBSUCDWMJjs.TailwindcssPatcher; exports.collectClassesFromContexts = _chunkBSUCDWMJjs.collectClassesFromContexts; exports.collectClassesFromTailwindV4 = _chunkBSUCDWMJjs.collectClassesFromTailwindV4; exports.createTailwindcssPatchCli = _chunkBSUCDWMJjs.createTailwindcssPatchCli; exports.defineConfig = _config.defineConfig; exports.extractProjectCandidatesWithPositions = _chunkBSUCDWMJjs.extractProjectCandidatesWithPositions; exports.extractRawCandidates = _chunkBSUCDWMJjs.extractRawCandidates; exports.extractRawCandidatesWithPositions = _chunkBSUCDWMJjs.extractRawCandidatesWithPositions; exports.extractValidCandidates = _chunkBSUCDWMJjs.extractValidCandidates; exports.getPatchStatusReport = _chunkBSUCDWMJjs.getPatchStatusReport; exports.groupTokensByFile = _chunkBSUCDWMJjs.groupTokensByFile; exports.loadRuntimeContexts = _chunkBSUCDWMJjs.loadRuntimeContexts; exports.logger = _chunkBSUCDWMJjs.logger_default; exports.mountTailwindcssPatchCommands = _chunkBSUCDWMJjs.mountTailwindcssPatchCommands; exports.normalizeOptions = _chunkBSUCDWMJjs.normalizeOptions; exports.runTailwindBuild = _chunkBSUCDWMJjs.runTailwindBuild; exports.tailwindcssPatchCommands = _chunkBSUCDWMJjs.tailwindcssPatchCommands;
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;
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  normalizeOptions,
17
17
  runTailwindBuild,
18
18
  tailwindcssPatchCommands
19
- } from "./chunk-KGBUT44N.mjs";
19
+ } from "./chunk-RVSD53YX.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.5.1",
3
+ "version": "8.6.0",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",