tailwindcss-patch 1.2.7 → 2.0.0-alpha.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/dist/index.js DELETED
@@ -1,191 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var path = require('node:path');
6
- var fs = require('node:fs');
7
- var patcher = require('./patcher-a07f477f.js');
8
- require('semver');
9
- require('@babel/types');
10
- require('@babel/generator');
11
- require('@babel/traverse');
12
- require('@babel/parser');
13
- require('resolve');
14
-
15
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
18
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
19
-
20
- function getTailwindcssEntry(basedir = process.cwd()) {
21
- return patcher.requireResolve('tailwindcss');
22
- }
23
- function getContexts(basedir) {
24
- const twPath = getTailwindcssEntry(basedir);
25
- const distPath = path__default["default"].dirname(twPath);
26
- let injectFilePath = path__default["default"].join(distPath, 'plugin.js');
27
- if (!fs__default["default"].existsSync(injectFilePath)) {
28
- injectFilePath = path__default["default"].join(distPath, 'index.js');
29
- }
30
- const mo = require(injectFilePath);
31
- if (mo.contextRef) {
32
- return mo.contextRef.value;
33
- }
34
- return [];
35
- }
36
- function getClassCaches(basedir) {
37
- const contexts = getContexts(basedir);
38
- return contexts.map((x) => x.classCache);
39
- }
40
- function getClassCacheSet(basedir) {
41
- const classCaches = getClassCaches(basedir);
42
- const classSet = new Set();
43
- for (const classCacheMap of classCaches) {
44
- const keys = classCacheMap.keys();
45
- for (const key of keys) {
46
- classSet.add(key.toString());
47
- }
48
- }
49
- return classSet;
50
- }
51
-
52
- const pkgName = 'tailwindcss-patch';
53
-
54
- function log(message, ...optionalParams) {
55
- return console.log(`[${pkgName}]:` + message, ...optionalParams);
56
- }
57
-
58
- function mkCacheDirectory(cacheDirectory) {
59
- const exists = fs__default["default"].existsSync(cacheDirectory);
60
- if (!exists) {
61
- fs__default["default"].mkdirSync(cacheDirectory, {
62
- recursive: true
63
- });
64
- }
65
- return cacheDirectory;
66
- }
67
- function getCacheOptions$1(options = {}) {
68
- var _a, _b, _c;
69
- const cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
70
- const dir = (_b = options.dir) !== null && _b !== void 0 ? _b : path__default["default"].resolve(cwd, 'node_modules/.cache', pkgName);
71
- const file = (_c = options.file) !== null && _c !== void 0 ? _c : 'index.json';
72
- const filename = path__default["default"].resolve(dir, file);
73
- return {
74
- cwd,
75
- dir,
76
- file,
77
- filename,
78
- strategy: 'merge'
79
- };
80
- }
81
- function writeCache(data, options = {}) {
82
- try {
83
- const { dir, filename } = getCacheOptions$1(options);
84
- mkCacheDirectory(dir);
85
- fs__default["default"].writeFileSync(filename, JSON.stringify([...data], undefined, 2), 'utf8');
86
- return filename;
87
- }
88
- catch (_a) {
89
- log('write cache file fail!');
90
- }
91
- }
92
- function readCache(options = {}) {
93
- const { filename } = getCacheOptions$1(options);
94
- try {
95
- if (fs__default["default"].existsSync(filename)) {
96
- const data = fs__default["default"].readFileSync(filename, 'utf8');
97
- return new Set(JSON.parse(data));
98
- }
99
- }
100
- catch (_a) {
101
- log('parse cache content fail! path:' + filename);
102
- try {
103
- fs__default["default"].unlinkSync(filename);
104
- }
105
- catch (_b) {
106
- log('delete cache file fail! path:' + filename);
107
- }
108
- }
109
- }
110
-
111
- function getCacheOptions(options) {
112
- let cache;
113
- switch (typeof options) {
114
- case 'undefined': {
115
- cache = {
116
- enable: false
117
- };
118
- break;
119
- }
120
- case 'boolean': {
121
- cache = {
122
- enable: options
123
- };
124
- break;
125
- }
126
- case 'object': {
127
- cache = Object.assign(Object.assign({}, options), { enable: true });
128
- break;
129
- }
130
- }
131
- return cache;
132
- }
133
- class TailwindcssPatcher {
134
- constructor(options = {}) {
135
- this.rawOptions = options;
136
- this.cacheOptions = getCacheOptions(options.cache);
137
- this.patchOptions = patcher.getPatchOptions(options.patch);
138
- this.patch = patcher.createPatch(this.patchOptions);
139
- }
140
- getPkgEntry(basedir) {
141
- return getTailwindcssEntry(basedir);
142
- }
143
- setCache(set) {
144
- if (this.cacheOptions.enable) {
145
- return writeCache(set, this.cacheOptions);
146
- }
147
- }
148
- getCache() {
149
- return readCache(this.cacheOptions);
150
- }
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;
157
- const set = getClassCacheSet(basedir);
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
- }
170
- return set;
171
- }
172
- getContexts(basedir) {
173
- return getContexts(basedir);
174
- }
175
- }
176
-
177
- exports.createPatch = patcher.createPatch;
178
- exports.ensureFileContent = patcher.ensureFileContent;
179
- exports.getInstalledPkgJsonPath = patcher.getInstalledPkgJsonPath;
180
- exports.getPatchOptions = patcher.getPatchOptions;
181
- exports.inspectPostcssPlugin = patcher.inspectPostcssPlugin;
182
- exports.inspectProcessTailwindFeaturesReturnContext = patcher.inspectProcessTailwindFeaturesReturnContext;
183
- exports.internalPatch = patcher.internalPatch;
184
- exports.monkeyPatchForExposingContext = patcher.monkeyPatchForExposingContext;
185
- exports.requireResolve = patcher.requireResolve;
186
- exports.TailwindcssPatcher = TailwindcssPatcher;
187
- exports.getCacheOptions = getCacheOptions;
188
- exports.getClassCacheSet = getClassCacheSet;
189
- exports.getClassCaches = getClassCaches;
190
- exports.getContexts = getContexts;
191
- exports.getTailwindcssEntry = getTailwindcssEntry;
@@ -1,302 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('node:path');
4
- var fs = require('node:fs');
5
- var semver = require('semver');
6
- var t = require('@babel/types');
7
- var generate = require('@babel/generator');
8
- var traverse = require('@babel/traverse');
9
- var parser = require('@babel/parser');
10
- var resolve = require('resolve');
11
-
12
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- function _interopNamespaceCompat(e) {
15
- if (e && typeof e === 'object' && 'default' in e) return e;
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- }
28
- n["default"] = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
33
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
34
- var t__namespace = /*#__PURE__*/_interopNamespaceCompat(t);
35
- var generate__default = /*#__PURE__*/_interopDefaultCompat(generate);
36
- var traverse__default = /*#__PURE__*/_interopDefaultCompat(traverse);
37
-
38
- function ensureFileContent(filepaths) {
39
- if (typeof filepaths === 'string') {
40
- filepaths = [filepaths];
41
- }
42
- let content;
43
- for (const filepath of filepaths) {
44
- if (fs__default["default"].existsSync(filepath)) {
45
- content = fs__default["default"].readFileSync(filepath, {
46
- encoding: 'utf8'
47
- });
48
- break;
49
- }
50
- }
51
- return content;
52
- }
53
- function requireResolve(id, opts) {
54
- return resolve.sync(id, opts);
55
- }
56
-
57
- function inspectProcessTailwindFeaturesReturnContext(content) {
58
- const ast = parser.parse(content);
59
- let hasPatched = false;
60
- traverse__default["default"](ast, {
61
- FunctionDeclaration(p) {
62
- var _a;
63
- const n = p.node;
64
- if (((_a = n.id) === null || _a === void 0 ? void 0 : _a.name) === 'processTailwindFeatures' && n.body.body.length === 1 && t__namespace.isReturnStatement(n.body.body[0])) {
65
- const rts = n.body.body[0];
66
- if (t__namespace.isFunctionExpression(rts.argument)) {
67
- const body = rts.argument.body.body;
68
- const lastStatement = body.at(-1);
69
- hasPatched = t__namespace.isReturnStatement(lastStatement) && t__namespace.isIdentifier(lastStatement.argument) && lastStatement.argument.name === 'context';
70
- if (!hasPatched) {
71
- const rts = t__namespace.returnStatement(t__namespace.identifier('context'));
72
- body.push(rts);
73
- }
74
- }
75
- }
76
- }
77
- });
78
- return {
79
- code: hasPatched ? content : generate__default["default"](ast).code,
80
- hasPatched
81
- };
82
- }
83
- function inspectPostcssPlugin(content) {
84
- const ast = parser.parse(content);
85
- const exportKey = 'contextRef';
86
- const variableName = 'contextRef';
87
- const valueKey = 'value';
88
- let hasPatched = false;
89
- traverse__default["default"](ast, {
90
- Program(p) {
91
- const n = p.node;
92
- const idx = n.body.findIndex((x) => {
93
- var _a;
94
- return (t__namespace.isExpressionStatement(x) &&
95
- t__namespace.isAssignmentExpression(x.expression) &&
96
- t__namespace.isMemberExpression(x.expression.left) &&
97
- t__namespace.isFunctionExpression(x.expression.right) &&
98
- ((_a = x.expression.right.id) === null || _a === void 0 ? void 0 : _a.name) === 'tailwindcss');
99
- });
100
- if (idx > -1) {
101
- const prevStatement = n.body[idx - 1];
102
- const lastStatement = n.body.at(-1);
103
- const hasPatchedCondition0 = prevStatement &&
104
- t__namespace.isVariableDeclaration(prevStatement) &&
105
- prevStatement.declarations.length === 1 &&
106
- t__namespace.isIdentifier(prevStatement.declarations[0].id) &&
107
- prevStatement.declarations[0].id.name === variableName;
108
- const hasPatchedCondition1 = t__namespace.isExpressionStatement(lastStatement) &&
109
- t__namespace.isAssignmentExpression(lastStatement.expression) &&
110
- t__namespace.isIdentifier(lastStatement.expression.right) &&
111
- lastStatement.expression.right.name === variableName;
112
- hasPatched = hasPatchedCondition0 || hasPatchedCondition1;
113
- if (!hasPatched) {
114
- const statement = t__namespace.variableDeclaration('const', [
115
- t__namespace.variableDeclarator(t__namespace.identifier(variableName), t__namespace.objectExpression([t__namespace.objectProperty(t__namespace.identifier(valueKey), t__namespace.arrayExpression())]))
116
- ]);
117
- n.body.splice(idx, 0, statement);
118
- n.body.push(t__namespace.expressionStatement(t__namespace.assignmentExpression('=', t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier('module'), t__namespace.identifier('exports')), t__namespace.identifier(exportKey)), t__namespace.identifier(variableName))));
119
- }
120
- }
121
- },
122
- FunctionExpression(p) {
123
- var _a;
124
- if (hasPatched) {
125
- return;
126
- }
127
- const n = p.node;
128
- if (((_a = n.id) === null || _a === void 0 ? void 0 : _a.name) === 'tailwindcss' && n.body.body.length === 1 && t__namespace.isReturnStatement(n.body.body[0])) {
129
- const returnStatement = n.body.body[0];
130
- if (t__namespace.isObjectExpression(returnStatement.argument) && returnStatement.argument.properties.length === 2) {
131
- const properties = returnStatement.argument.properties;
132
- if (t__namespace.isObjectProperty(properties[0]) && t__namespace.isObjectProperty(properties[1])) {
133
- const keyMatched = t__namespace.isIdentifier(properties[0].key) && properties[0].key.name === 'postcssPlugin';
134
- const pluginsMatched = t__namespace.isIdentifier(properties[1].key) && properties[1].key.name === 'plugins';
135
- if (pluginsMatched &&
136
- keyMatched &&
137
- t__namespace.isCallExpression(properties[1].value) &&
138
- t__namespace.isMemberExpression(properties[1].value.callee) &&
139
- t__namespace.isArrayExpression(properties[1].value.callee.object)) {
140
- const pluginsCode = properties[1].value.callee.object.elements;
141
- if (pluginsCode[1] && t__namespace.isFunctionExpression(pluginsCode[1])) {
142
- const targetBlockStatement = pluginsCode[1].body;
143
- const lastStatement = targetBlockStatement.body.at(-1);
144
- if (t__namespace.isExpressionStatement(lastStatement)) {
145
- const newExpressionStatement = t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier(variableName), t__namespace.identifier('value')), t__namespace.identifier('push')), [lastStatement.expression]));
146
- targetBlockStatement.body[targetBlockStatement.body.length - 1] = newExpressionStatement;
147
- }
148
- const ifIdx = targetBlockStatement.body.findIndex((x) => t__namespace.isIfStatement(x));
149
- if (ifIdx > -1) {
150
- const ifRoot = targetBlockStatement.body[ifIdx];
151
- if (t__namespace.isBlockStatement(ifRoot.consequent) && ifRoot.consequent.body[1] && t__namespace.isForOfStatement(ifRoot.consequent.body[1])) {
152
- const forOf = ifRoot.consequent.body[1];
153
- if (t__namespace.isBlockStatement(forOf.body) && forOf.body.body.length === 1 && t__namespace.isIfStatement(forOf.body.body[0])) {
154
- const if2 = forOf.body.body[0];
155
- if (t__namespace.isBlockStatement(if2.consequent) && if2.consequent.body.length === 1 && t__namespace.isExpressionStatement(if2.consequent.body[0])) {
156
- const target = if2.consequent.body[0];
157
- const newExpressionStatement = t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier(variableName), t__namespace.identifier('value')), t__namespace.identifier('push')), [target.expression]));
158
- if2.consequent.body[0] = newExpressionStatement;
159
- }
160
- }
161
- }
162
- }
163
- targetBlockStatement.body.unshift(t__namespace.expressionStatement(t__namespace.assignmentExpression('=', t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier(variableName), t__namespace.identifier(valueKey)), t__namespace.identifier('length')), t__namespace.numericLiteral(0))));
164
- }
165
- }
166
- }
167
- }
168
- }
169
- }
170
- });
171
- return {
172
- code: hasPatched ? content : generate__default["default"](ast).code,
173
- hasPatched
174
- };
175
- }
176
-
177
- function isObject(value) {
178
- return value !== null && typeof value === "object";
179
- }
180
- function _defu(baseObject, defaults, namespace = ".", merger) {
181
- if (!isObject(defaults)) {
182
- return _defu(baseObject, {}, namespace, merger);
183
- }
184
- const object = Object.assign({}, defaults);
185
- for (const key in baseObject) {
186
- if (key === "__proto__" || key === "constructor") {
187
- continue;
188
- }
189
- const value = baseObject[key];
190
- if (value === null || value === void 0) {
191
- continue;
192
- }
193
- if (merger && merger(object, key, value, namespace)) {
194
- continue;
195
- }
196
- if (Array.isArray(value) && Array.isArray(object[key])) {
197
- object[key] = [...value, ...object[key]];
198
- } else if (isObject(value) && isObject(object[key])) {
199
- object[key] = _defu(
200
- value,
201
- object[key],
202
- (namespace ? `${namespace}.` : "") + key.toString(),
203
- merger
204
- );
205
- } else {
206
- object[key] = value;
207
- }
208
- }
209
- return object;
210
- }
211
- function createDefu(merger) {
212
- return (...arguments_) => (
213
- // eslint-disable-next-line unicorn/no-array-reduce
214
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
215
- );
216
- }
217
- const defu = createDefu();
218
-
219
- const defaultOptions = {
220
- overwrite: true
221
- };
222
-
223
- function getInstalledPkgJsonPath(options = {}) {
224
- try {
225
- const tmpJsonPath = requireResolve(`tailwindcss/package.json`, {
226
- paths: options.paths
227
- });
228
- return tmpJsonPath;
229
- }
230
- catch (error) {
231
- if (error.code === 'MODULE_NOT_FOUND') {
232
- console.warn("Can't find npm pkg: `tailwindcss`, Please ensure it has been installed!");
233
- }
234
- }
235
- }
236
- function getPatchOptions(options = {}) {
237
- return defu(options, {
238
- basedir: process.cwd()
239
- }, defaultOptions);
240
- }
241
- function createPatch(opt) {
242
- return () => {
243
- try {
244
- const pkgJsonPath = getInstalledPkgJsonPath(opt);
245
- return internalPatch(pkgJsonPath, opt);
246
- }
247
- catch (error) {
248
- console.warn(`patch tailwindcss failed:` + error.message);
249
- }
250
- };
251
- }
252
- function monkeyPatchForExposingContext(twDir, opt) {
253
- const processTailwindFeaturesFilePath = path__default["default"].resolve(twDir, 'lib/processTailwindFeatures.js');
254
- const processTailwindFeaturesContent = ensureFileContent(processTailwindFeaturesFilePath);
255
- const result = {};
256
- if (processTailwindFeaturesContent) {
257
- const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext(processTailwindFeaturesContent);
258
- if (!hasPatched && opt.overwrite) {
259
- fs__default["default"].writeFileSync(processTailwindFeaturesFilePath, code, {
260
- encoding: 'utf8'
261
- });
262
- console.log('patch tailwindcss processTailwindFeatures for return content successfully!');
263
- }
264
- result.processTailwindFeatures = code;
265
- }
266
- const pluginFilePath = path__default["default"].resolve(twDir, 'lib/plugin.js');
267
- const indexFilePath = path__default["default"].resolve(twDir, 'lib/index.js');
268
- const pluginContent = ensureFileContent([pluginFilePath, indexFilePath]);
269
- if (pluginContent) {
270
- const { code, hasPatched } = inspectPostcssPlugin(pluginContent);
271
- if (!hasPatched && opt.overwrite) {
272
- fs__default["default"].writeFileSync(pluginFilePath, code, {
273
- encoding: 'utf8'
274
- });
275
- console.log('patch tailwindcss for expose runtime content successfully!');
276
- }
277
- result.plugin = code;
278
- }
279
- opt.custom && typeof opt.custom === 'function' && opt.custom(twDir, result);
280
- return result;
281
- }
282
- function internalPatch(pkgJsonPath, options) {
283
- if (pkgJsonPath) {
284
- const pkgJson = require(pkgJsonPath);
285
- const twDir = path__default["default"].dirname(pkgJsonPath);
286
- if (semver.gte(pkgJson.version, '3.0.0')) {
287
- options.version = pkgJson.version;
288
- const result = monkeyPatchForExposingContext(twDir, options);
289
- return result;
290
- }
291
- }
292
- }
293
-
294
- exports.createPatch = createPatch;
295
- exports.ensureFileContent = ensureFileContent;
296
- exports.getInstalledPkgJsonPath = getInstalledPkgJsonPath;
297
- exports.getPatchOptions = getPatchOptions;
298
- exports.inspectPostcssPlugin = inspectPostcssPlugin;
299
- exports.inspectProcessTailwindFeaturesReturnContext = inspectProcessTailwindFeaturesReturnContext;
300
- exports.internalPatch = internalPatch;
301
- exports.monkeyPatchForExposingContext = monkeyPatchForExposingContext;
302
- exports.requireResolve = requireResolve;
@@ -1,3 +0,0 @@
1
- export { default as generate } from '@babel/generator';
2
- export { default as traverse } from '@babel/traverse';
3
- export { parse } from '@babel/parser';
@@ -1,7 +0,0 @@
1
- import type { CacheOptions } from './type';
2
- export declare function mkCacheDirectory(cacheDirectory: string): string;
3
- export declare function getCacheOptions(options?: CacheOptions): Required<CacheOptions> & {
4
- filename: string;
5
- };
6
- export declare function writeCache(data: Set<string>, options?: CacheOptions): string | undefined;
7
- export declare function readCache(options?: CacheOptions): Set<string> | undefined;
@@ -1,17 +0,0 @@
1
- import type { CacheOptions, InternalCacheOptions, InternalPatchOptions, TailwindcssPatcherOptions, CacheStrategy } from './type';
2
- export declare function getCacheOptions(options?: CacheOptions | boolean): InternalCacheOptions;
3
- export declare class TailwindcssPatcher {
4
- rawOptions: TailwindcssPatcherOptions;
5
- cacheOptions: InternalCacheOptions;
6
- patchOptions: InternalPatchOptions;
7
- patch: () => void;
8
- constructor(options?: TailwindcssPatcherOptions);
9
- getPkgEntry(basedir?: string): string;
10
- setCache(set: Set<string>): string | undefined;
11
- getCache(): Set<string> | undefined;
12
- getClassSet(options?: {
13
- basedir?: string;
14
- cacheStrategy?: CacheStrategy;
15
- }): Set<string>;
16
- getContexts(basedir?: string): import("./type").TailwindcssRuntimeContext[];
17
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const pkgName = "tailwindcss-patch";
@@ -1,2 +0,0 @@
1
- import type { PatchOptions } from './type';
2
- export declare const defaultOptions: PatchOptions;
@@ -1,5 +0,0 @@
1
- import type { TailwindcssClassCache, TailwindcssRuntimeContext } from './type';
2
- export declare function getTailwindcssEntry(basedir?: string): string;
3
- export declare function getContexts(basedir?: string): TailwindcssRuntimeContext[];
4
- export declare function getClassCaches(basedir?: string): TailwindcssClassCache[];
5
- export declare function getClassCacheSet(basedir?: string): Set<string>;
@@ -1,6 +0,0 @@
1
- export * from './class';
2
- export * from './exposeContext';
3
- export * from './inspector';
4
- export * from './patcher';
5
- export * from './utils';
6
- export * from './type';
@@ -1,8 +0,0 @@
1
- export declare function inspectProcessTailwindFeaturesReturnContext(content: string): {
2
- code: string;
3
- hasPatched: boolean;
4
- };
5
- export declare function inspectPostcssPlugin(content: string): {
6
- code: string;
7
- hasPatched: boolean;
8
- };
@@ -1 +0,0 @@
1
- export declare function log(message?: any, ...optionalParams: any[]): void;
@@ -1,9 +0,0 @@
1
- import type { PatchOptions, InternalPatchOptions } from './type';
2
- export declare function getInstalledPkgJsonPath(options?: PatchOptions): string | undefined;
3
- export declare function getPatchOptions(options?: PatchOptions): InternalPatchOptions;
4
- export declare function createPatch(opt: InternalPatchOptions): () => any;
5
- export declare function monkeyPatchForExposingContext(twDir: string, opt: InternalPatchOptions): {
6
- processTailwindFeatures?: string | undefined;
7
- plugin?: string | undefined;
8
- } & Record<string, any>;
9
- export declare function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions): any | undefined;
@@ -1,72 +0,0 @@
1
- import type { Rule, Node } from 'postcss';
2
- import type { Config } from 'tailwindcss';
3
- export type CacheStrategy = 'merge' | 'overwrite';
4
- export interface CacheOptions {
5
- dir?: string;
6
- cwd?: string;
7
- file?: string;
8
- strategy?: CacheStrategy;
9
- }
10
- export type InternalCacheOptions = CacheOptions & {
11
- enable?: boolean;
12
- };
13
- export interface PatchOptions {
14
- overwrite?: boolean;
15
- paths?: string[];
16
- basedir?: string;
17
- custom?: (dir: string, ctx: Record<string, any>) => void;
18
- }
19
- export interface InternalPatchOptions {
20
- overwrite: boolean;
21
- paths?: string[];
22
- basedir?: string;
23
- custom?: (dir: string, ctx: Record<string, any>) => void;
24
- version?: string;
25
- }
26
- export interface TailwindcssPatcherOptions {
27
- cache?: CacheOptions | boolean;
28
- patch?: PatchOptions;
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
- };
@@ -1,3 +0,0 @@
1
- import { type SyncOpts } from 'resolve';
2
- export declare function ensureFileContent(filepaths: string | string[]): string | undefined;
3
- export declare function requireResolve(id: string, opts?: SyncOpts): string;