tailwindcss-patch 1.2.5 → 1.2.6

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/dist/index.js CHANGED
@@ -43,7 +43,7 @@ function getClassCacheSet(basedir) {
43
43
  for (const classCacheMap of classCaches) {
44
44
  const keys = classCacheMap.keys();
45
45
  for (const key of keys) {
46
- classSet.add(key);
46
+ classSet.add(key.toString());
47
47
  }
48
48
  }
49
49
  return classSet;
@@ -74,7 +74,8 @@ function getCacheOptions$1(options = {}) {
74
74
  cwd,
75
75
  dir,
76
76
  file,
77
- filename
77
+ filename,
78
+ strategy: 'merge'
78
79
  };
79
80
  }
80
81
  function writeCache(data, options = {}) {
@@ -147,9 +148,25 @@ class TailwindcssPatcher {
147
148
  getCache() {
148
149
  return readCache(this.cacheOptions);
149
150
  }
150
- getClassSet(basedir) {
151
+ getClassSet(options) {
152
+ var _a;
153
+ if (options === void 0) { options = {
154
+ cacheStrategy: (_a = this.cacheOptions.strategy) !== null && _a !== void 0 ? _a : 'merge'
155
+ }; }
156
+ const { basedir, cacheStrategy } = options;
151
157
  const set = getClassCacheSet(basedir);
152
- set.size > 0 && this.setCache(set);
158
+ if (cacheStrategy === 'overwrite') {
159
+ set.size > 0 && this.setCache(set);
160
+ }
161
+ else if (cacheStrategy === 'merge') {
162
+ const cacheSet = this.getCache();
163
+ if (cacheSet) {
164
+ for (const x of cacheSet) {
165
+ set.add(x);
166
+ }
167
+ }
168
+ this.setCache(set);
169
+ }
153
170
  return set;
154
171
  }
155
172
  getContexts(basedir) {
@@ -1,4 +1,4 @@
1
- import type { CacheOptions, InternalCacheOptions, InternalPatchOptions, TailwindcssPatcherOptions } from './type';
1
+ import type { CacheOptions, InternalCacheOptions, InternalPatchOptions, TailwindcssPatcherOptions, CacheStrategy } from './type';
2
2
  export declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
3
3
  export declare class TailwindcssPatcher {
4
4
  rawOptions: TailwindcssPatcherOptions;
@@ -9,6 +9,9 @@ export declare class TailwindcssPatcher {
9
9
  getPkgEntry(basedir?: string): string;
10
10
  setCache(set: Set<string>): string | undefined;
11
11
  getCache(): Set<string> | undefined;
12
- getClassSet(basedir?: string): Set<string>;
12
+ getClassSet(options?: {
13
+ basedir?: string;
14
+ cacheStrategy?: CacheStrategy;
15
+ }): Set<string>;
13
16
  getContexts(basedir?: string): any[];
14
17
  }
@@ -1,7 +1,9 @@
1
+ export type CacheStrategy = 'merge' | 'overwrite';
1
2
  export interface CacheOptions {
2
3
  dir?: string;
3
4
  cwd?: string;
4
5
  file?: string;
6
+ strategy?: CacheStrategy;
5
7
  }
6
8
  export type InternalCacheOptions = CacheOptions & {
7
9
  enable?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "patch tailwindcss for exposing context",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,7 +39,7 @@
39
39
  "@babel/traverse": "^7.22.5",
40
40
  "@babel/types": "^7.22.5",
41
41
  "resolve": "^1.22.2",
42
- "semver": "^7.5.1"
42
+ "semver": "^7.5.2"
43
43
  },
44
44
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
45
45
  "repository": {