tailwindcss-patch 7.1.6 → 8.1.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/cli.js CHANGED
@@ -1,54 +1,147 @@
1
- "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ "use strict"; 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; }
2
2
 
3
3
 
4
4
 
5
5
 
6
-
7
- var _chunkZKCG5Q25js = require('./chunk-ZKCG5Q25.js');
6
+ var _chunkF3S7POWFjs = require('./chunk-F3S7POWF.js');
8
7
 
9
8
  // src/cli.ts
10
9
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
11
10
  var _config = require('@tailwindcss-mangle/config');
12
- var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
13
- function init() {
14
- const cwd = _process2.default.cwd();
15
- return _config.initConfig.call(void 0, cwd);
11
+
12
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
13
+ function isPlainObject(value) {
14
+ if (value === null || typeof value !== "object") {
15
+ return false;
16
+ }
17
+ const prototype = Object.getPrototypeOf(value);
18
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
19
+ return false;
20
+ }
21
+ if (Symbol.iterator in value) {
22
+ return false;
23
+ }
24
+ if (Symbol.toStringTag in value) {
25
+ return Object.prototype.toString.call(value) === "[object Module]";
26
+ }
27
+ return true;
28
+ }
29
+ function _defu(baseObject, defaults, namespace = ".", merger) {
30
+ if (!isPlainObject(defaults)) {
31
+ return _defu(baseObject, {}, namespace, merger);
32
+ }
33
+ const object = Object.assign({}, defaults);
34
+ for (const key in baseObject) {
35
+ if (key === "__proto__" || key === "constructor") {
36
+ continue;
37
+ }
38
+ const value = baseObject[key];
39
+ if (value === null || value === void 0) {
40
+ continue;
41
+ }
42
+ if (merger && merger(object, key, value, namespace)) {
43
+ continue;
44
+ }
45
+ if (Array.isArray(value) && Array.isArray(object[key])) {
46
+ object[key] = [...value, ...object[key]];
47
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
48
+ object[key] = _defu(
49
+ value,
50
+ object[key],
51
+ (namespace ? `${namespace}.` : "") + key.toString(),
52
+ merger
53
+ );
54
+ } else {
55
+ object[key] = value;
56
+ }
57
+ }
58
+ return object;
59
+ }
60
+ function createDefu(merger) {
61
+ return (...arguments_) => (
62
+ // eslint-disable-next-line unicorn/no-array-reduce
63
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
64
+ );
16
65
  }
17
- var cli = _cac2.default.call(void 0, );
18
- cli.command("install", "patch install").action(() => {
19
- const twPatcher = new (0, _chunkZKCG5Q25js.TailwindcssPatcher)({
20
- patch: _chunkZKCG5Q25js.getPatchOptions.call(void 0, )
21
- });
22
- twPatcher.patch();
66
+ var defu = createDefu();
67
+ var defuFn = createDefu((object, key, currentValue) => {
68
+ if (object[key] !== void 0 && typeof currentValue === "function") {
69
+ object[key] = currentValue(object[key]);
70
+ return true;
71
+ }
23
72
  });
24
- cli.command("init").action(async () => {
25
- await init();
26
- _chunkZKCG5Q25js.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
73
+ var defuArrayFn = createDefu((object, key, currentValue) => {
74
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
75
+ object[key] = currentValue(object[key]);
76
+ return true;
77
+ }
78
+ });
79
+
80
+ // ../shared/src/utils.ts
81
+ var defuOverrideArray = createDefu((obj, key, value) => {
82
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
83
+ obj[key] = value;
84
+ return true;
85
+ }
86
+ });
87
+ var preserveClassNames = [
88
+ // https://tailwindcss.com/docs/transition-timing-function start
89
+ // https://github.com/sonofmagic/tailwindcss-mangle/issues/21
90
+ "ease-out",
91
+ "ease-linear",
92
+ "ease-in",
93
+ "ease-in-out"
94
+ // https://tailwindcss.com/docs/transition-timing-function end
95
+ ];
96
+ var preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
97
+ acc[cur] = true;
98
+ return acc;
99
+ }, {});
100
+ var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
101
+
102
+ // src/cli.ts
103
+ var _cac = require('cac'); var _cac2 = _interopRequireDefault(_cac);
104
+ var cli = _cac2.default.call(void 0, "tw-patch");
105
+ async function loadPatchOptions(cwd, overrides) {
106
+ const { config } = await _config.getConfig.call(void 0, cwd);
107
+ const legacyConfig = config;
108
+ const base = _optionalChain([config, 'optionalAccess', _ => _.registry]) ? _chunkF3S7POWFjs.fromUnifiedConfig.call(void 0, config.registry) : _optionalChain([legacyConfig, 'optionalAccess', _2 => _2.patch]) ? _chunkF3S7POWFjs.fromLegacyOptions.call(void 0, { patch: legacyConfig.patch }) : {};
109
+ const merged = defu(_nullishCoalesce(overrides, () => ( {})), base);
110
+ return merged;
111
+ }
112
+ cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
113
+ const options = await loadPatchOptions(args.cwd);
114
+ const patcher = new (0, _chunkF3S7POWFjs.TailwindcssPatcher)(options);
115
+ await patcher.patch();
116
+ _chunkF3S7POWFjs.logger_default.success("Tailwind CSS runtime patched successfully.");
27
117
  });
28
- cli.command("extract").option("--css [file]", "css file entries").action(async (options) => {
29
- const { config } = await _config.getConfig.call(void 0, );
30
- const file = options.css;
31
- if (config) {
32
- const twPatcher = new (0, _chunkZKCG5Q25js.TailwindcssPatcher)(
33
- {
34
- patch: _chunkZKCG5Q25js.defuOverrideArray.call(void 0,
35
- config.patch,
36
- {
37
- resolve: {
38
- paths: [_chunkZKCG5Q25js.importMetaUrl]
39
- },
40
- tailwindcss: {
41
- v4: {
42
- cssEntries: file ? [file] : void 0
43
- }
44
- }
45
- }
46
- )
118
+ cli.command("extract", "Collect generated class names into a cache file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).option("--output <file>", "Override output file path").option("--format <format>", "Output format (json|lines)").option("--css <file>", "Tailwind CSS entry CSS when using v4").option("--no-write", "Skip writing to disk").action(async (args) => {
119
+ const overrides = {};
120
+ if (args.output || args.format) {
121
+ overrides.output = {
122
+ file: args.output,
123
+ format: args.format
124
+ };
125
+ }
126
+ if (args.css) {
127
+ overrides.tailwind = {
128
+ v4: {
129
+ cssEntries: [args.css]
47
130
  }
48
- );
49
- const p = await twPatcher.extract();
50
- p && _chunkZKCG5Q25js.logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
131
+ };
132
+ }
133
+ const options = await loadPatchOptions(args.cwd, overrides);
134
+ const patcher = new (0, _chunkF3S7POWFjs.TailwindcssPatcher)(options);
135
+ const result = await patcher.extract({ write: args.write });
136
+ if (result.filename) {
137
+ _chunkF3S7POWFjs.logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
138
+ } else {
139
+ _chunkF3S7POWFjs.logger_default.success(`Collected ${result.classList.length} classes.`);
51
140
  }
52
141
  });
142
+ cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: _process2.default.cwd() }).action(async (args) => {
143
+ await _config.initConfig.call(void 0, args.cwd);
144
+ _chunkF3S7POWFjs.logger_default.success(`\u2728 ${_config.CONFIG_NAME}.config.ts initialized!`);
145
+ });
53
146
  cli.help();
54
147
  cli.parse();
package/dist/cli.mjs CHANGED
@@ -1,53 +1,147 @@
1
1
  import {
2
2
  TailwindcssPatcher,
3
- defuOverrideArray,
4
- getPatchOptions,
3
+ fromLegacyOptions,
4
+ fromUnifiedConfig,
5
5
  logger_default
6
- } from "./chunk-NS2I2YPX.mjs";
6
+ } from "./chunk-IQ26TKX2.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import process from "process";
10
10
  import { CONFIG_NAME, getConfig, initConfig } from "@tailwindcss-mangle/config";
11
- import cac from "cac";
12
- function init() {
13
- const cwd = process.cwd();
14
- return initConfig(cwd);
11
+
12
+ // ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
13
+ function isPlainObject(value) {
14
+ if (value === null || typeof value !== "object") {
15
+ return false;
16
+ }
17
+ const prototype = Object.getPrototypeOf(value);
18
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
19
+ return false;
20
+ }
21
+ if (Symbol.iterator in value) {
22
+ return false;
23
+ }
24
+ if (Symbol.toStringTag in value) {
25
+ return Object.prototype.toString.call(value) === "[object Module]";
26
+ }
27
+ return true;
15
28
  }
16
- var cli = cac();
17
- cli.command("install", "patch install").action(() => {
18
- const twPatcher = new TailwindcssPatcher({
19
- patch: getPatchOptions()
20
- });
21
- twPatcher.patch();
29
+ function _defu(baseObject, defaults, namespace = ".", merger) {
30
+ if (!isPlainObject(defaults)) {
31
+ return _defu(baseObject, {}, namespace, merger);
32
+ }
33
+ const object = Object.assign({}, defaults);
34
+ for (const key in baseObject) {
35
+ if (key === "__proto__" || key === "constructor") {
36
+ continue;
37
+ }
38
+ const value = baseObject[key];
39
+ if (value === null || value === void 0) {
40
+ continue;
41
+ }
42
+ if (merger && merger(object, key, value, namespace)) {
43
+ continue;
44
+ }
45
+ if (Array.isArray(value) && Array.isArray(object[key])) {
46
+ object[key] = [...value, ...object[key]];
47
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
48
+ object[key] = _defu(
49
+ value,
50
+ object[key],
51
+ (namespace ? `${namespace}.` : "") + key.toString(),
52
+ merger
53
+ );
54
+ } else {
55
+ object[key] = value;
56
+ }
57
+ }
58
+ return object;
59
+ }
60
+ function createDefu(merger) {
61
+ return (...arguments_) => (
62
+ // eslint-disable-next-line unicorn/no-array-reduce
63
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
64
+ );
65
+ }
66
+ var defu = createDefu();
67
+ var defuFn = createDefu((object, key, currentValue) => {
68
+ if (object[key] !== void 0 && typeof currentValue === "function") {
69
+ object[key] = currentValue(object[key]);
70
+ return true;
71
+ }
22
72
  });
23
- cli.command("init").action(async () => {
24
- await init();
25
- logger_default.success(`\u2728 ${CONFIG_NAME}.config.ts initialized!`);
73
+ var defuArrayFn = createDefu((object, key, currentValue) => {
74
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
75
+ object[key] = currentValue(object[key]);
76
+ return true;
77
+ }
26
78
  });
27
- cli.command("extract").option("--css [file]", "css file entries").action(async (options) => {
28
- const { config } = await getConfig();
29
- const file = options.css;
30
- if (config) {
31
- const twPatcher = new TailwindcssPatcher(
32
- {
33
- patch: defuOverrideArray(
34
- config.patch,
35
- {
36
- resolve: {
37
- paths: [import.meta.url]
38
- },
39
- tailwindcss: {
40
- v4: {
41
- cssEntries: file ? [file] : void 0
42
- }
43
- }
44
- }
45
- )
79
+
80
+ // ../shared/src/utils.ts
81
+ var defuOverrideArray = createDefu((obj, key, value) => {
82
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
83
+ obj[key] = value;
84
+ return true;
85
+ }
86
+ });
87
+ var preserveClassNames = [
88
+ // https://tailwindcss.com/docs/transition-timing-function start
89
+ // https://github.com/sonofmagic/tailwindcss-mangle/issues/21
90
+ "ease-out",
91
+ "ease-linear",
92
+ "ease-in",
93
+ "ease-in-out"
94
+ // https://tailwindcss.com/docs/transition-timing-function end
95
+ ];
96
+ var preserveClassNamesMap = preserveClassNames.reduce((acc, cur) => {
97
+ acc[cur] = true;
98
+ return acc;
99
+ }, {});
100
+ var acceptChars = [..."abcdefghijklmnopqrstuvwxyz"];
101
+
102
+ // src/cli.ts
103
+ import cac from "cac";
104
+ var cli = cac("tw-patch");
105
+ async function loadPatchOptions(cwd, overrides) {
106
+ const { config } = await getConfig(cwd);
107
+ const legacyConfig = config;
108
+ const base = config?.registry ? fromUnifiedConfig(config.registry) : legacyConfig?.patch ? fromLegacyOptions({ patch: legacyConfig.patch }) : {};
109
+ const merged = defu(overrides ?? {}, base);
110
+ return merged;
111
+ }
112
+ cli.command("install", "Apply Tailwind CSS runtime patches").option("--cwd <dir>", "Working directory", { default: process.cwd() }).action(async (args) => {
113
+ const options = await loadPatchOptions(args.cwd);
114
+ const patcher = new TailwindcssPatcher(options);
115
+ await patcher.patch();
116
+ logger_default.success("Tailwind CSS runtime patched successfully.");
117
+ });
118
+ cli.command("extract", "Collect generated class names into a cache file").option("--cwd <dir>", "Working directory", { default: process.cwd() }).option("--output <file>", "Override output file path").option("--format <format>", "Output format (json|lines)").option("--css <file>", "Tailwind CSS entry CSS when using v4").option("--no-write", "Skip writing to disk").action(async (args) => {
119
+ const overrides = {};
120
+ if (args.output || args.format) {
121
+ overrides.output = {
122
+ file: args.output,
123
+ format: args.format
124
+ };
125
+ }
126
+ if (args.css) {
127
+ overrides.tailwind = {
128
+ v4: {
129
+ cssEntries: [args.css]
46
130
  }
47
- );
48
- const p = await twPatcher.extract();
49
- p && logger_default.success(`\u2728 tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`);
131
+ };
50
132
  }
133
+ const options = await loadPatchOptions(args.cwd, overrides);
134
+ const patcher = new TailwindcssPatcher(options);
135
+ const result = await patcher.extract({ write: args.write });
136
+ if (result.filename) {
137
+ logger_default.success(`Collected ${result.classList.length} classes \u2192 ${result.filename}`);
138
+ } else {
139
+ logger_default.success(`Collected ${result.classList.length} classes.`);
140
+ }
141
+ });
142
+ cli.command("init", "Generate a tailwindcss-patch config file").option("--cwd <dir>", "Working directory", { default: process.cwd() }).action(async (args) => {
143
+ await initConfig(args.cwd);
144
+ logger_default.success(`\u2728 ${CONFIG_NAME}.config.ts initialized!`);
51
145
  });
52
146
  cli.help();
53
147
  cli.parse();