tailwindcss-patch 1.2.5 → 1.2.7

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/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var patcher = require('./patcher-d1886807.js');
3
+ var patcher = require('./patcher-a07f477f.js');
4
4
  require('node:path');
5
5
  require('node:fs');
6
6
  require('semver');
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('node:path');
6
6
  var fs = require('node:fs');
7
- var patcher = require('./patcher-d1886807.js');
7
+ var patcher = require('./patcher-a07f477f.js');
8
8
  require('semver');
9
9
  require('@babel/types');
10
10
  require('@babel/generator');
@@ -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) {
@@ -284,6 +284,7 @@ function internalPatch(pkgJsonPath, options) {
284
284
  const pkgJson = require(pkgJsonPath);
285
285
  const twDir = path__default["default"].dirname(pkgJsonPath);
286
286
  if (semver.gte(pkgJson.version, '3.0.0')) {
287
+ options.version = pkgJson.version;
287
288
  const result = monkeyPatchForExposingContext(twDir, options);
288
289
  return result;
289
290
  }
@@ -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>;
13
- getContexts(basedir?: string): any[];
12
+ getClassSet(options?: {
13
+ basedir?: string;
14
+ cacheStrategy?: CacheStrategy;
15
+ }): Set<string>;
16
+ getContexts(basedir?: string): import("./type").TailwindcssRuntimeContext[];
14
17
  }
@@ -1,9 +1,5 @@
1
- import type { Rule } from 'postcss';
1
+ import type { TailwindcssClassCache, TailwindcssRuntimeContext } from './type';
2
2
  export declare function getTailwindcssEntry(basedir?: string): string;
3
- export declare function getContexts(basedir?: string): any[];
4
- export declare function getClassCaches(basedir?: string): Map<string, ({
5
- layer: string;
6
- options: Record<string, any>;
7
- sort: Record<string, any>;
8
- } | Rule)[]>[];
3
+ export declare function getContexts(basedir?: string): TailwindcssRuntimeContext[];
4
+ export declare function getClassCaches(basedir?: string): TailwindcssClassCache[];
9
5
  export declare function getClassCacheSet(basedir?: string): Set<string>;
@@ -1,7 +1,11 @@
1
+ import type { Rule, Node } from 'postcss';
2
+ import type { Config } from 'tailwindcss';
3
+ export type CacheStrategy = 'merge' | 'overwrite';
1
4
  export interface CacheOptions {
2
5
  dir?: string;
3
6
  cwd?: string;
4
7
  file?: string;
8
+ strategy?: CacheStrategy;
5
9
  }
6
10
  export type InternalCacheOptions = CacheOptions & {
7
11
  enable?: boolean;
@@ -17,8 +21,52 @@ export interface InternalPatchOptions {
17
21
  paths?: string[];
18
22
  basedir?: string;
19
23
  custom?: (dir: string, ctx: Record<string, any>) => void;
24
+ version?: string;
20
25
  }
21
26
  export interface TailwindcssPatcherOptions {
22
27
  cache?: CacheOptions | boolean;
23
28
  patch?: PatchOptions;
24
29
  }
30
+ export type TailwindcssClassCache = Map<string, ({
31
+ layer: string;
32
+ options: Record<string, any>;
33
+ sort: Record<string, any>;
34
+ } | Rule)[]>;
35
+ export type TailwindcssRuntimeContext = {
36
+ applyClassCache: Map<any, any>;
37
+ candidateRuleCache: Map<string | String, Set<[
38
+ {
39
+ arbitrary: any;
40
+ index: any;
41
+ layer: string;
42
+ options: any[];
43
+ parallelIndex: any;
44
+ parentLayer: string;
45
+ variants: any;
46
+ },
47
+ Node
48
+ ]>>;
49
+ candidateRuleMap: Map<string | String, [object, Node][]>;
50
+ changedContent: any[];
51
+ classCache: TailwindcssClassCache;
52
+ disposables: any[];
53
+ getClassList: Function;
54
+ getClassOrder: Function;
55
+ getVariants: Function;
56
+ markInvalidUtilityCandidate: Function;
57
+ markInvalidUtilityNode: Function;
58
+ notClassCache: Set<String>;
59
+ offsets: {
60
+ layerPositions: object;
61
+ offsets: object;
62
+ reservedVariantBits: any;
63
+ variantOffsets: Map<string, any>;
64
+ };
65
+ postCssNodeCache: Map<object, [Node]>;
66
+ ruleCache: Set<[object, Node]>;
67
+ stylesheetCache: Record<string, Set<any>>;
68
+ tailwindConfig: Config;
69
+ userConfigPath: string | null;
70
+ variantMap: Map<string, [[object, Function]]>;
71
+ variantOptions: Map<string, object>;
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "patch tailwindcss for exposing context",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -30,16 +30,16 @@
30
30
  "@types/semver": "^7.5.0",
31
31
  "defu": "^6.1.2",
32
32
  "pkg-types": "^1.0.3",
33
- "postcss": "^8.4.24",
34
- "tailwindcss": "^3.3.2"
33
+ "postcss": "^8.4.26",
34
+ "tailwindcss": "^3.3.3"
35
35
  },
36
36
  "dependencies": {
37
- "@babel/generator": "^7.22.5",
38
- "@babel/parser": "^7.22.5",
39
- "@babel/traverse": "^7.22.5",
37
+ "@babel/generator": "^7.22.9",
38
+ "@babel/parser": "^7.22.7",
39
+ "@babel/traverse": "^7.22.8",
40
40
  "@babel/types": "^7.22.5",
41
41
  "resolve": "^1.22.2",
42
- "semver": "^7.5.1"
42
+ "semver": "^7.5.4"
43
43
  },
44
44
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
45
45
  "repository": {