tailwindcss-patch 6.0.0 → 6.0.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.
- package/dist/{chunk-AZHCF3SW.mjs → chunk-U2NQZPXE.mjs} +13 -21
- package/dist/{chunk-P7C42UCO.js → chunk-U3S6WRCP.js} +13 -21
- package/dist/cli.js +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -52,22 +52,21 @@ var CacheManager = class {
|
|
|
52
52
|
strategy: "merge"
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
write(data) {
|
|
55
|
+
async write(data) {
|
|
56
56
|
try {
|
|
57
|
-
const {
|
|
58
|
-
fs.
|
|
59
|
-
fs.outputFileSync(filename, JSON.stringify([...data], void 0, 2), "utf8");
|
|
57
|
+
const { filename } = this.options;
|
|
58
|
+
await fs.outputJSON(filename, [...data]);
|
|
60
59
|
return filename;
|
|
61
60
|
} catch {
|
|
62
61
|
logger_default.error("write cache file fail!");
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
read() {
|
|
64
|
+
async read() {
|
|
66
65
|
const { filename } = this.options;
|
|
67
66
|
try {
|
|
68
|
-
if (fs.
|
|
69
|
-
const data = fs.
|
|
70
|
-
return new Set(
|
|
67
|
+
if (await fs.exists(filename)) {
|
|
68
|
+
const data = await fs.readJSON(filename);
|
|
69
|
+
return new Set(data);
|
|
71
70
|
}
|
|
72
71
|
} catch {
|
|
73
72
|
logger_default.error(`parse cache content fail! path:${filename}`);
|
|
@@ -825,9 +824,9 @@ var TailwindcssPatcher = class {
|
|
|
825
824
|
const contexts = this.getContexts();
|
|
826
825
|
return contexts.filter((x) => isObject(x)).map((x) => x.classCache);
|
|
827
826
|
}
|
|
828
|
-
async getClassCacheSet(
|
|
827
|
+
async getClassCacheSet() {
|
|
829
828
|
const classSet = /* @__PURE__ */ new Set();
|
|
830
|
-
const { output, tailwindcss } =
|
|
829
|
+
const { output, tailwindcss } = this.patchOptions;
|
|
831
830
|
if (this.majorVersion === 4) {
|
|
832
831
|
const { v4 } = tailwindcss ?? {};
|
|
833
832
|
if (Array.isArray(v4?.cssEntries)) {
|
|
@@ -888,17 +887,13 @@ var TailwindcssPatcher = class {
|
|
|
888
887
|
/**
|
|
889
888
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
890
889
|
*/
|
|
891
|
-
async getClassSet(
|
|
892
|
-
const { output, tailwindcss } = options ?? {};
|
|
890
|
+
async getClassSet() {
|
|
893
891
|
const cacheStrategy = this.cacheOptions.strategy ?? "merge";
|
|
894
|
-
const set = await this.getClassCacheSet(
|
|
895
|
-
output,
|
|
896
|
-
tailwindcss
|
|
897
|
-
});
|
|
892
|
+
const set = await this.getClassCacheSet();
|
|
898
893
|
if (cacheStrategy === "overwrite") {
|
|
899
894
|
set.size > 0 && this.setCache(set);
|
|
900
895
|
} else if (cacheStrategy === "merge") {
|
|
901
|
-
const cacheSet = this.getCache();
|
|
896
|
+
const cacheSet = await this.getCache();
|
|
902
897
|
if (cacheSet) {
|
|
903
898
|
for (const x of cacheSet) {
|
|
904
899
|
set.add(x);
|
|
@@ -918,10 +913,7 @@ var TailwindcssPatcher = class {
|
|
|
918
913
|
majorVersion: this.majorVersion
|
|
919
914
|
});
|
|
920
915
|
}
|
|
921
|
-
const set = await this.getClassSet(
|
|
922
|
-
output,
|
|
923
|
-
tailwindcss
|
|
924
|
-
});
|
|
916
|
+
const set = await this.getClassSet();
|
|
925
917
|
if (filename) {
|
|
926
918
|
const classList = [...set];
|
|
927
919
|
await fs4.outputJSON(filename, classList, {
|
|
@@ -56,22 +56,21 @@ var CacheManager = class {
|
|
|
56
56
|
strategy: "merge"
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
write(data) {
|
|
59
|
+
async write(data) {
|
|
60
60
|
try {
|
|
61
|
-
const {
|
|
62
|
-
_fsextra2.default.
|
|
63
|
-
_fsextra2.default.outputFileSync(filename, JSON.stringify([...data], void 0, 2), "utf8");
|
|
61
|
+
const { filename } = this.options;
|
|
62
|
+
await _fsextra2.default.outputJSON(filename, [...data]);
|
|
64
63
|
return filename;
|
|
65
64
|
} catch (e2) {
|
|
66
65
|
logger_default.error("write cache file fail!");
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
read() {
|
|
68
|
+
async read() {
|
|
70
69
|
const { filename } = this.options;
|
|
71
70
|
try {
|
|
72
|
-
if (_fsextra2.default.
|
|
73
|
-
const data = _fsextra2.default.
|
|
74
|
-
return new Set(
|
|
71
|
+
if (await _fsextra2.default.exists(filename)) {
|
|
72
|
+
const data = await _fsextra2.default.readJSON(filename);
|
|
73
|
+
return new Set(data);
|
|
75
74
|
}
|
|
76
75
|
} catch (e3) {
|
|
77
76
|
logger_default.error(`parse cache content fail! path:${filename}`);
|
|
@@ -829,9 +828,9 @@ var TailwindcssPatcher = (_class = class {
|
|
|
829
828
|
const contexts = this.getContexts();
|
|
830
829
|
return contexts.filter((x) => isObject(x)).map((x) => x.classCache);
|
|
831
830
|
}
|
|
832
|
-
async getClassCacheSet(
|
|
831
|
+
async getClassCacheSet() {
|
|
833
832
|
const classSet = /* @__PURE__ */ new Set();
|
|
834
|
-
const { output, tailwindcss } =
|
|
833
|
+
const { output, tailwindcss } = this.patchOptions;
|
|
835
834
|
if (this.majorVersion === 4) {
|
|
836
835
|
const { v4 } = _nullishCoalesce(tailwindcss, () => ( {}));
|
|
837
836
|
if (Array.isArray(_optionalChain([v4, 'optionalAccess', _25 => _25.cssEntries]))) {
|
|
@@ -892,17 +891,13 @@ var TailwindcssPatcher = (_class = class {
|
|
|
892
891
|
/**
|
|
893
892
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
894
893
|
*/
|
|
895
|
-
async getClassSet(
|
|
896
|
-
const { output, tailwindcss } = _nullishCoalesce(options, () => ( {}));
|
|
894
|
+
async getClassSet() {
|
|
897
895
|
const cacheStrategy = _nullishCoalesce(this.cacheOptions.strategy, () => ( "merge"));
|
|
898
|
-
const set = await this.getClassCacheSet(
|
|
899
|
-
output,
|
|
900
|
-
tailwindcss
|
|
901
|
-
});
|
|
896
|
+
const set = await this.getClassCacheSet();
|
|
902
897
|
if (cacheStrategy === "overwrite") {
|
|
903
898
|
set.size > 0 && this.setCache(set);
|
|
904
899
|
} else if (cacheStrategy === "merge") {
|
|
905
|
-
const cacheSet = this.getCache();
|
|
900
|
+
const cacheSet = await this.getCache();
|
|
906
901
|
if (cacheSet) {
|
|
907
902
|
for (const x of cacheSet) {
|
|
908
903
|
set.add(x);
|
|
@@ -922,10 +917,7 @@ var TailwindcssPatcher = (_class = class {
|
|
|
922
917
|
majorVersion: this.majorVersion
|
|
923
918
|
});
|
|
924
919
|
}
|
|
925
|
-
const set = await this.getClassSet(
|
|
926
|
-
output,
|
|
927
|
-
tailwindcss
|
|
928
|
-
});
|
|
920
|
+
const set = await this.getClassSet();
|
|
929
921
|
if (filename) {
|
|
930
922
|
const classList = [...set];
|
|
931
923
|
await _fsextra2.default.outputJSON(filename, classList, {
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkU3S6WRCPjs = require('./chunk-U3S6WRCP.js');
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
@@ -14,21 +14,21 @@ function init() {
|
|
|
14
14
|
}
|
|
15
15
|
var cli = _cac2.default.call(void 0, );
|
|
16
16
|
cli.command("install", "patch install").action(() => {
|
|
17
|
-
const twPatcher = new (0,
|
|
18
|
-
patch:
|
|
17
|
+
const twPatcher = new (0, _chunkU3S6WRCPjs.TailwindcssPatcher)({
|
|
18
|
+
patch: _chunkU3S6WRCPjs.getPatchOptions.call(void 0, )
|
|
19
19
|
});
|
|
20
20
|
twPatcher.patch();
|
|
21
21
|
});
|
|
22
22
|
cli.command("init").action(async () => {
|
|
23
23
|
await init();
|
|
24
|
-
|
|
24
|
+
_chunkU3S6WRCPjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
|
|
25
25
|
});
|
|
26
26
|
cli.command("extract").action(async () => {
|
|
27
27
|
const { config } = await _config.getConfig.call(void 0, );
|
|
28
28
|
if (config) {
|
|
29
|
-
const twPatcher = new (0,
|
|
29
|
+
const twPatcher = new (0, _chunkU3S6WRCPjs.TailwindcssPatcher)();
|
|
30
30
|
const p = await twPatcher.extract(config.patch);
|
|
31
|
-
|
|
31
|
+
_chunkU3S6WRCPjs.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p}`);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
cli.help();
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Node, Rule } from 'postcss';
|
|
2
|
-
import { Config } from 'tailwindcss';
|
|
3
1
|
import { PatchUserConfig } from '@tailwindcss-mangle/config';
|
|
4
2
|
export { defineConfig } from '@tailwindcss-mangle/config';
|
|
3
|
+
import { PackageJson } from 'pkg-types';
|
|
4
|
+
import { Node, Rule } from 'postcss';
|
|
5
|
+
import { Config } from 'tailwindcss';
|
|
5
6
|
import { GlobEntry } from '@tailwindcss/oxide';
|
|
6
7
|
import * as consola from 'consola';
|
|
7
8
|
|
|
@@ -11,6 +12,7 @@ interface PackageInfo {
|
|
|
11
12
|
version: string | undefined;
|
|
12
13
|
rootPath: string;
|
|
13
14
|
packageJsonPath: string;
|
|
15
|
+
packageJson: PackageJson;
|
|
14
16
|
}
|
|
15
17
|
interface CacheOptions {
|
|
16
18
|
dir?: string;
|
|
@@ -21,7 +23,7 @@ interface CacheOptions {
|
|
|
21
23
|
interface InternalCacheOptions extends CacheOptions {
|
|
22
24
|
enable?: boolean;
|
|
23
25
|
}
|
|
24
|
-
interface PatchOptions {
|
|
26
|
+
interface PatchOptions extends PatchUserConfig {
|
|
25
27
|
overwrite?: boolean;
|
|
26
28
|
paths?: string[];
|
|
27
29
|
basedir?: string;
|
|
@@ -100,8 +102,8 @@ declare class CacheManager {
|
|
|
100
102
|
getOptions(options?: CacheOptions): Required<CacheOptions> & {
|
|
101
103
|
filename: string;
|
|
102
104
|
};
|
|
103
|
-
write(data: Set<string>): string | undefined
|
|
104
|
-
read(): Set<string> | undefined
|
|
105
|
+
write(data: Set<string>): Promise<string | undefined>;
|
|
106
|
+
read(): Promise<Set<string> | undefined>;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
interface ExtractValidCandidatesOption {
|
|
@@ -120,15 +122,15 @@ declare class TailwindcssPatcher {
|
|
|
120
122
|
packageInfo: PackageInfo;
|
|
121
123
|
majorVersion?: number;
|
|
122
124
|
constructor(options?: TailwindcssPatcherOptions);
|
|
123
|
-
setCache(set: Set<string>): string | undefined;
|
|
124
|
-
getCache(): Set<string> | undefined
|
|
125
|
+
setCache(set: Set<string>): Promise<string | undefined> | undefined;
|
|
126
|
+
getCache(): Promise<Set<string> | undefined>;
|
|
125
127
|
getContexts(): TailwindcssRuntimeContext[];
|
|
126
128
|
getClassCaches(): TailwindcssClassCache[];
|
|
127
|
-
getClassCacheSet(
|
|
129
|
+
getClassCacheSet(): Promise<Set<string>>;
|
|
128
130
|
/**
|
|
129
131
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
130
132
|
*/
|
|
131
|
-
getClassSet(
|
|
133
|
+
getClassSet(): Promise<Set<string>>;
|
|
132
134
|
extract(options?: PatchUserConfig): Promise<string | undefined>;
|
|
133
135
|
extractValidCandidates: typeof extractValidCandidates;
|
|
134
136
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Node, Rule } from 'postcss';
|
|
2
|
-
import { Config } from 'tailwindcss';
|
|
3
1
|
import { PatchUserConfig } from '@tailwindcss-mangle/config';
|
|
4
2
|
export { defineConfig } from '@tailwindcss-mangle/config';
|
|
3
|
+
import { PackageJson } from 'pkg-types';
|
|
4
|
+
import { Node, Rule } from 'postcss';
|
|
5
|
+
import { Config } from 'tailwindcss';
|
|
5
6
|
import { GlobEntry } from '@tailwindcss/oxide';
|
|
6
7
|
import * as consola from 'consola';
|
|
7
8
|
|
|
@@ -11,6 +12,7 @@ interface PackageInfo {
|
|
|
11
12
|
version: string | undefined;
|
|
12
13
|
rootPath: string;
|
|
13
14
|
packageJsonPath: string;
|
|
15
|
+
packageJson: PackageJson;
|
|
14
16
|
}
|
|
15
17
|
interface CacheOptions {
|
|
16
18
|
dir?: string;
|
|
@@ -21,7 +23,7 @@ interface CacheOptions {
|
|
|
21
23
|
interface InternalCacheOptions extends CacheOptions {
|
|
22
24
|
enable?: boolean;
|
|
23
25
|
}
|
|
24
|
-
interface PatchOptions {
|
|
26
|
+
interface PatchOptions extends PatchUserConfig {
|
|
25
27
|
overwrite?: boolean;
|
|
26
28
|
paths?: string[];
|
|
27
29
|
basedir?: string;
|
|
@@ -100,8 +102,8 @@ declare class CacheManager {
|
|
|
100
102
|
getOptions(options?: CacheOptions): Required<CacheOptions> & {
|
|
101
103
|
filename: string;
|
|
102
104
|
};
|
|
103
|
-
write(data: Set<string>): string | undefined
|
|
104
|
-
read(): Set<string> | undefined
|
|
105
|
+
write(data: Set<string>): Promise<string | undefined>;
|
|
106
|
+
read(): Promise<Set<string> | undefined>;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
interface ExtractValidCandidatesOption {
|
|
@@ -120,15 +122,15 @@ declare class TailwindcssPatcher {
|
|
|
120
122
|
packageInfo: PackageInfo;
|
|
121
123
|
majorVersion?: number;
|
|
122
124
|
constructor(options?: TailwindcssPatcherOptions);
|
|
123
|
-
setCache(set: Set<string>): string | undefined;
|
|
124
|
-
getCache(): Set<string> | undefined
|
|
125
|
+
setCache(set: Set<string>): Promise<string | undefined> | undefined;
|
|
126
|
+
getCache(): Promise<Set<string> | undefined>;
|
|
125
127
|
getContexts(): TailwindcssRuntimeContext[];
|
|
126
128
|
getClassCaches(): TailwindcssClassCache[];
|
|
127
|
-
getClassCacheSet(
|
|
129
|
+
getClassCacheSet(): Promise<Set<string>>;
|
|
128
130
|
/**
|
|
129
131
|
* @description 在多个 tailwindcss 上下文时,这个方法将被执行多次,所以策略上应该使用 append
|
|
130
132
|
*/
|
|
131
|
-
getClassSet(
|
|
133
|
+
getClassSet(): Promise<Set<string>>;
|
|
132
134
|
extract(options?: PatchUserConfig): Promise<string | undefined>;
|
|
133
135
|
extractValidCandidates: typeof extractValidCandidates;
|
|
134
136
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkU3S6WRCPjs = require('./chunk-U3S6WRCP.js');
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
var _config = require('@tailwindcss-mangle/config');
|
|
@@ -21,4 +21,4 @@ var _config = require('@tailwindcss-mangle/config');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.CacheManager =
|
|
24
|
+
exports.CacheManager = _chunkU3S6WRCPjs.CacheManager; exports.TailwindcssPatcher = _chunkU3S6WRCPjs.TailwindcssPatcher; exports.defineConfig = _config.defineConfig; exports.getCacheOptions = _chunkU3S6WRCPjs.getCacheOptions; exports.internalPatch = _chunkU3S6WRCPjs.internalPatch; exports.logger = _chunkU3S6WRCPjs.logger_default; exports.monkeyPatchForExposingContextV2 = _chunkU3S6WRCPjs.monkeyPatchForExposingContextV2; exports.monkeyPatchForExposingContextV3 = _chunkU3S6WRCPjs.monkeyPatchForExposingContextV3; exports.monkeyPatchForSupportingCustomUnit = _chunkU3S6WRCPjs.monkeyPatchForSupportingCustomUnit;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
monkeyPatchForExposingContextV2,
|
|
8
8
|
monkeyPatchForExposingContextV3,
|
|
9
9
|
monkeyPatchForSupportingCustomUnit
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-U2NQZPXE.mjs";
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
import { defineConfig } from "@tailwindcss-mangle/config";
|