@node-minify/core 9.0.2 → 10.0.0-next.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.cjs ADDED
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => src_default
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/compress.ts
38
+ var import_node_fs = __toESM(require("fs"), 1);
39
+ var import_utils = require("@node-minify/utils");
40
+ var import_mkdirp = require("mkdirp");
41
+ var compress = (settings) => {
42
+ if (typeof settings.compressor !== "function") {
43
+ throw new Error(
44
+ "compressor should be a function, maybe you forgot to install the compressor"
45
+ );
46
+ }
47
+ if (settings.output) {
48
+ createDirectory(settings.output);
49
+ }
50
+ if (Array.isArray(settings.output)) {
51
+ return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
52
+ }
53
+ return import_utils.utils.compressSingleFile(settings);
54
+ };
55
+ var compressArrayOfFilesSync = (settings) => {
56
+ return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
57
+ const content = import_utils.utils.getContentFromFiles(input);
58
+ return import_utils.utils.runSync({ settings, content, index });
59
+ });
60
+ };
61
+ var compressArrayOfFilesAsync = (settings) => {
62
+ let sequence = Promise.resolve();
63
+ Array.isArray(settings.input) && settings.input.forEach((input, index) => {
64
+ const content = import_utils.utils.getContentFromFiles(input);
65
+ sequence = sequence.then(
66
+ () => import_utils.utils.runAsync({ settings, content, index })
67
+ );
68
+ });
69
+ return sequence;
70
+ };
71
+ var createDirectory = (file) => {
72
+ if (Array.isArray(file)) {
73
+ file = file[0];
74
+ }
75
+ const dir = file?.substr(0, file.lastIndexOf("/"));
76
+ if (!dir) {
77
+ return;
78
+ }
79
+ if (!import_node_fs.default.statSync(dir).isDirectory()) {
80
+ import_mkdirp.mkdirp.sync(dir);
81
+ }
82
+ };
83
+
84
+ // src/compressInMemory.ts
85
+ var import_utils2 = require("@node-minify/utils");
86
+ var compressInMemory = (settings) => {
87
+ if (typeof settings.compressor !== "function") {
88
+ throw new Error(
89
+ "compressor should be a function, maybe you forgot to install the compressor"
90
+ );
91
+ }
92
+ return import_utils2.utils.compressSingleFile(settings);
93
+ };
94
+
95
+ // src/setup.ts
96
+ var import_node_path = __toESM(require("path"), 1);
97
+ var import_utils3 = require("@node-minify/utils");
98
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
99
+ var defaultSettings = {
100
+ sync: false,
101
+ options: {},
102
+ buffer: 1e3 * 1024,
103
+ callback: false
104
+ };
105
+ var setup = (inputSettings) => {
106
+ let settings = Object.assign(
107
+ import_utils3.utils.clone(defaultSettings),
108
+ inputSettings
109
+ );
110
+ if (settings.content) {
111
+ checkMandatoriesMemoryContent(inputSettings);
112
+ return settings;
113
+ }
114
+ checkMandatories(inputSettings);
115
+ if (settings.input) {
116
+ settings = Object.assign(
117
+ settings,
118
+ wildcards(settings.input, settings.publicFolder)
119
+ );
120
+ }
121
+ if (settings.input && settings.output) {
122
+ settings = Object.assign(
123
+ settings,
124
+ checkOutput(
125
+ settings.input,
126
+ settings.output,
127
+ settings.publicFolder,
128
+ settings.replaceInPlace
129
+ )
130
+ );
131
+ }
132
+ if (settings.input && settings.publicFolder) {
133
+ settings = Object.assign(
134
+ settings,
135
+ setPublicFolder(settings.input, settings.publicFolder)
136
+ );
137
+ }
138
+ return settings;
139
+ };
140
+ var checkOutput = (input, output, publicFolder, replaceInPlace) => {
141
+ const reg = /\$1/;
142
+ if (reg.test(output)) {
143
+ if (Array.isArray(input)) {
144
+ const outputMin = input.map(
145
+ (file) => import_utils3.utils.setFileNameMin(
146
+ file,
147
+ output,
148
+ replaceInPlace ? void 0 : publicFolder,
149
+ replaceInPlace
150
+ )
151
+ );
152
+ return { output: outputMin };
153
+ }
154
+ return {
155
+ output: import_utils3.utils.setFileNameMin(
156
+ input,
157
+ output,
158
+ replaceInPlace ? void 0 : publicFolder,
159
+ replaceInPlace
160
+ )
161
+ };
162
+ }
163
+ };
164
+ var wildcards = (input, publicFolder) => {
165
+ if (!Array.isArray(input)) {
166
+ return wildcardsString(input, publicFolder);
167
+ }
168
+ return wildcardsArray(input, publicFolder);
169
+ };
170
+ var wildcardsString = (input, publicFolder) => {
171
+ const output = {};
172
+ if (input.indexOf("*") > -1) {
173
+ output.input = getFilesFromWildcards(input, publicFolder);
174
+ }
175
+ return output;
176
+ };
177
+ var wildcardsArray = (input, publicFolder) => {
178
+ const output = {};
179
+ let isWildcardsPresent = false;
180
+ output.input = input;
181
+ const inputWithPublicFolder = input.map((item) => {
182
+ if (item.indexOf("*") > -1) {
183
+ isWildcardsPresent = true;
184
+ }
185
+ return (publicFolder || "") + item;
186
+ });
187
+ if (isWildcardsPresent) {
188
+ output.input = import_fast_glob.default.globSync(inputWithPublicFolder);
189
+ }
190
+ for (let i = 0; i < output.input.length; i++) {
191
+ if (output.input[i].indexOf("*") > -1) {
192
+ output.input.splice(i, 1);
193
+ i--;
194
+ }
195
+ }
196
+ return output;
197
+ };
198
+ var getFilesFromWildcards = (input, publicFolder) => {
199
+ let output = [];
200
+ if (input.indexOf("*") > -1) {
201
+ output = import_fast_glob.default.globSync((publicFolder || "") + input);
202
+ }
203
+ return output;
204
+ };
205
+ var setPublicFolder = (input, publicFolder) => {
206
+ const output = {};
207
+ if (typeof publicFolder !== "string") {
208
+ return output;
209
+ }
210
+ publicFolder = import_node_path.default.normalize(publicFolder);
211
+ if (Array.isArray(input)) {
212
+ output.input = input.map((item) => {
213
+ if (import_node_path.default.normalize(item).indexOf(publicFolder) > -1) {
214
+ return item;
215
+ }
216
+ return import_node_path.default.normalize(publicFolder + item);
217
+ });
218
+ return output;
219
+ }
220
+ input = import_node_path.default.normalize(input);
221
+ if (input.indexOf(publicFolder) > -1) {
222
+ output.input = input;
223
+ return output;
224
+ }
225
+ output.input = import_node_path.default.normalize(publicFolder + input);
226
+ return output;
227
+ };
228
+ var checkMandatories = (settings) => {
229
+ ["compressor", "input", "output"].forEach(
230
+ (item) => mandatory(item, settings)
231
+ );
232
+ };
233
+ var checkMandatoriesMemoryContent = (settings) => {
234
+ ["compressor", "content"].forEach(
235
+ (item) => mandatory(item, settings)
236
+ );
237
+ };
238
+ var mandatory = (setting, settings) => {
239
+ if (!settings[setting]) {
240
+ throw new Error(`${setting} is mandatory.`);
241
+ }
242
+ };
243
+
244
+ // src/index.ts
245
+ var minify = (settings) => {
246
+ return new Promise((resolve, reject) => {
247
+ const method = settings.content ? compressInMemory : compress;
248
+ settings = setup(settings);
249
+ if (!settings.sync) {
250
+ method(settings).then((minified) => {
251
+ if (settings.callback) {
252
+ settings.callback(null, minified);
253
+ }
254
+ resolve(minified);
255
+ }).catch((err) => {
256
+ if (settings.callback) {
257
+ settings.callback(err);
258
+ }
259
+ reject(err);
260
+ });
261
+ } else {
262
+ const minified = method(settings);
263
+ if (settings.callback) {
264
+ settings.callback(null, minified);
265
+ }
266
+ resolve(minified);
267
+ }
268
+ });
269
+ };
270
+ minify.default = minify;
271
+ var src_default = minify;
272
+ /*!
273
+ * node-minify
274
+ * Copyright(c) 2011-2024 Rodolphe Stoclin
275
+ * MIT Licensed
276
+ */
277
+
278
+ // fix-cjs-exports
279
+ if (module.exports.default) {
280
+ Object.assign(module.exports.default, module.exports);
281
+ module.exports = module.exports.default;
282
+ delete module.exports.default;
283
+ }
@@ -12,3 +12,4 @@ declare const minify: {
12
12
  };
13
13
 
14
14
  export { minify as default };
15
+ export = minify
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@ declare const minify: {
12
12
  };
13
13
 
14
14
  export { minify as default };
15
+ export = minify
package/dist/index.js CHANGED
@@ -1,31 +1,7 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
1
  // src/compress.ts
26
- var import_node_fs = __toESM(require("fs"));
27
- var import_utils = require("@node-minify/utils");
28
- var import_mkdirp = require("mkdirp");
2
+ import fs from "node:fs";
3
+ import { utils } from "@node-minify/utils";
4
+ import { mkdirp } from "mkdirp";
29
5
  var compress = (settings) => {
30
6
  if (typeof settings.compressor !== "function") {
31
7
  throw new Error(
@@ -38,20 +14,20 @@ var compress = (settings) => {
38
14
  if (Array.isArray(settings.output)) {
39
15
  return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
40
16
  }
41
- return import_utils.utils.compressSingleFile(settings);
17
+ return utils.compressSingleFile(settings);
42
18
  };
43
19
  var compressArrayOfFilesSync = (settings) => {
44
20
  return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
45
- const content = import_utils.utils.getContentFromFiles(input);
46
- return import_utils.utils.runSync({ settings, content, index });
21
+ const content = utils.getContentFromFiles(input);
22
+ return utils.runSync({ settings, content, index });
47
23
  });
48
24
  };
49
25
  var compressArrayOfFilesAsync = (settings) => {
50
26
  let sequence = Promise.resolve();
51
27
  Array.isArray(settings.input) && settings.input.forEach((input, index) => {
52
- const content = import_utils.utils.getContentFromFiles(input);
28
+ const content = utils.getContentFromFiles(input);
53
29
  sequence = sequence.then(
54
- () => import_utils.utils.runAsync({ settings, content, index })
30
+ () => utils.runAsync({ settings, content, index })
55
31
  );
56
32
  });
57
33
  return sequence;
@@ -64,26 +40,26 @@ var createDirectory = (file) => {
64
40
  if (!dir) {
65
41
  return;
66
42
  }
67
- if (!import_node_fs.default.statSync(dir).isDirectory()) {
68
- import_mkdirp.mkdirp.sync(dir);
43
+ if (!fs.statSync(dir).isDirectory()) {
44
+ mkdirp.sync(dir);
69
45
  }
70
46
  };
71
47
 
72
48
  // src/compressInMemory.ts
73
- var import_utils2 = require("@node-minify/utils");
49
+ import { utils as utils2 } from "@node-minify/utils";
74
50
  var compressInMemory = (settings) => {
75
51
  if (typeof settings.compressor !== "function") {
76
52
  throw new Error(
77
53
  "compressor should be a function, maybe you forgot to install the compressor"
78
54
  );
79
55
  }
80
- return import_utils2.utils.compressSingleFile(settings);
56
+ return utils2.compressSingleFile(settings);
81
57
  };
82
58
 
83
59
  // src/setup.ts
84
- var import_node_path = __toESM(require("path"));
85
- var import_utils3 = require("@node-minify/utils");
86
- var import_glob = require("glob");
60
+ import path from "node:path";
61
+ import { utils as utils3 } from "@node-minify/utils";
62
+ import fg from "fast-glob";
87
63
  var defaultSettings = {
88
64
  sync: false,
89
65
  options: {},
@@ -92,7 +68,7 @@ var defaultSettings = {
92
68
  };
93
69
  var setup = (inputSettings) => {
94
70
  let settings = Object.assign(
95
- import_utils3.utils.clone(defaultSettings),
71
+ utils3.clone(defaultSettings),
96
72
  inputSettings
97
73
  );
98
74
  if (settings.content) {
@@ -130,7 +106,7 @@ var checkOutput = (input, output, publicFolder, replaceInPlace) => {
130
106
  if (reg.test(output)) {
131
107
  if (Array.isArray(input)) {
132
108
  const outputMin = input.map(
133
- (file) => import_utils3.utils.setFileNameMin(
109
+ (file) => utils3.setFileNameMin(
134
110
  file,
135
111
  output,
136
112
  replaceInPlace ? void 0 : publicFolder,
@@ -140,7 +116,7 @@ var checkOutput = (input, output, publicFolder, replaceInPlace) => {
140
116
  return { output: outputMin };
141
117
  }
142
118
  return {
143
- output: import_utils3.utils.setFileNameMin(
119
+ output: utils3.setFileNameMin(
144
120
  input,
145
121
  output,
146
122
  replaceInPlace ? void 0 : publicFolder,
@@ -173,7 +149,7 @@ var wildcardsArray = (input, publicFolder) => {
173
149
  return (publicFolder || "") + item;
174
150
  });
175
151
  if (isWildcardsPresent) {
176
- output.input = (0, import_glob.globSync)(inputWithPublicFolder);
152
+ output.input = fg.globSync(inputWithPublicFolder);
177
153
  }
178
154
  for (let i = 0; i < output.input.length; i++) {
179
155
  if (output.input[i].indexOf("*") > -1) {
@@ -186,7 +162,7 @@ var wildcardsArray = (input, publicFolder) => {
186
162
  var getFilesFromWildcards = (input, publicFolder) => {
187
163
  let output = [];
188
164
  if (input.indexOf("*") > -1) {
189
- output = (0, import_glob.globSync)((publicFolder || "") + input);
165
+ output = fg.globSync((publicFolder || "") + input);
190
166
  }
191
167
  return output;
192
168
  };
@@ -195,22 +171,22 @@ var setPublicFolder = (input, publicFolder) => {
195
171
  if (typeof publicFolder !== "string") {
196
172
  return output;
197
173
  }
198
- publicFolder = import_node_path.default.normalize(publicFolder);
174
+ publicFolder = path.normalize(publicFolder);
199
175
  if (Array.isArray(input)) {
200
176
  output.input = input.map((item) => {
201
- if (import_node_path.default.normalize(item).indexOf(publicFolder) > -1) {
177
+ if (path.normalize(item).indexOf(publicFolder) > -1) {
202
178
  return item;
203
179
  }
204
- return import_node_path.default.normalize(publicFolder + item);
180
+ return path.normalize(publicFolder + item);
205
181
  });
206
182
  return output;
207
183
  }
208
- input = import_node_path.default.normalize(input);
184
+ input = path.normalize(input);
209
185
  if (input.indexOf(publicFolder) > -1) {
210
186
  output.input = input;
211
187
  return output;
212
188
  }
213
- output.input = import_node_path.default.normalize(publicFolder + input);
189
+ output.input = path.normalize(publicFolder + input);
214
190
  return output;
215
191
  };
216
192
  var checkMandatories = (settings) => {
@@ -256,10 +232,12 @@ var minify = (settings) => {
256
232
  });
257
233
  };
258
234
  minify.default = minify;
259
- module.exports = minify;
235
+ var src_default = minify;
236
+ export {
237
+ src_default as default
238
+ };
260
239
  /*!
261
240
  * node-minify
262
241
  * Copyright(c) 2011-2024 Rodolphe Stoclin
263
242
  * MIT Licensed
264
243
  */
265
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/core",
3
- "version": "9.0.2",
3
+ "version": "10.0.0-next.0",
4
4
  "description": "core of @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -8,23 +8,22 @@
8
8
  "minifier"
9
9
  ],
10
10
  "author": "Rodolphe Stoclin <srodolphe@gmail.com>",
11
- "homepage": "https://github.com/srod/node-minify/tree/master/packages/core#readme",
11
+ "homepage": "https://github.com/srod/node-minify/tree/main/packages/core#readme",
12
12
  "license": "MIT",
13
+ "type": "module",
13
14
  "engines": {
14
- "node": ">=18.0.0"
15
+ "node": ">=22.0.0"
15
16
  },
16
17
  "directories": {
17
18
  "lib": "dist",
18
19
  "test": "__tests__"
19
20
  },
20
- "main": "./dist/index.js",
21
- "module": "./dist/index.mjs",
22
- "types": "./dist/index.d.ts",
21
+ "main": "./dist/index.cjs",
23
22
  "exports": {
23
+ "./package.json": "./package.json",
24
24
  ".": {
25
- "types": "./dist/index.d.ts",
26
- "import": "./dist/index.mjs",
27
- "require": "./dist/index.js"
25
+ "import": "./dist/index.js",
26
+ "default": "./dist/index.cjs"
28
27
  }
29
28
  },
30
29
  "files": [
@@ -40,21 +39,23 @@
40
39
  "bugs": {
41
40
  "url": "https://github.com/srod/node-minify/issues"
42
41
  },
43
- "dependencies": {
44
- "glob": "10.3.3",
45
- "mkdirp": "3.0.1",
46
- "@node-minify/utils": "9.0.1"
47
- },
48
- "devDependencies": {
49
- "@types/mkdirp": "^1.0.2",
50
- "@node-minify/types": "9.0.0"
51
- },
52
42
  "scripts": {
53
- "clean": "pnpm dlx rimraf dist",
54
- "build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
43
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean && bunx fix-tsup-cjs",
44
+ "check-exports": "attw --pack .",
45
+ "format:check": "biome check .",
55
46
  "lint": "biome lint .",
47
+ "prepublishOnly": "bun run build",
56
48
  "test": "vitest run",
57
49
  "test:ci": "vitest run --coverage",
58
50
  "test:watch": "vitest"
51
+ },
52
+ "dependencies": {
53
+ "@node-minify/utils": "workspace:*",
54
+ "fast-glob": "^3.3.2",
55
+ "mkdirp": "3.0.1"
56
+ },
57
+ "devDependencies": {
58
+ "@node-minify/types": "workspace:*",
59
+ "@types/mkdirp": "^2.0.0"
59
60
  }
60
- }
61
+ }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/compress.ts","../src/compressInMemory.ts","../src/setup.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport fs from \"node:fs\";\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport { mkdirp } from \"mkdirp\";\n\n/**\n * Run compressor.\n * @param settings Settings\n */\nconst compress = (settings: Settings): Promise<string> | string => {\n if (typeof settings.compressor !== \"function\") {\n throw new Error(\n \"compressor should be a function, maybe you forgot to install the compressor\"\n );\n }\n\n if (settings.output) {\n createDirectory(settings.output);\n }\n\n if (Array.isArray(settings.output)) {\n return settings.sync\n ? compressArrayOfFilesSync(settings)\n : compressArrayOfFilesAsync(settings);\n }\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Compress an array of files in sync.\n * @param settings Settings\n */\nconst compressArrayOfFilesSync = (settings: Settings): any => {\n return (\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n return utils.runSync({ settings, content, index });\n })\n );\n};\n\n/**\n * Compress an array of files in async.\n * @param settings Settings\n */\nconst compressArrayOfFilesAsync = (\n settings: Settings\n): Promise<string | void> => {\n let sequence: Promise<string | void> = Promise.resolve();\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n sequence = sequence.then(() =>\n utils.runAsync({ settings, content, index })\n );\n });\n return sequence;\n};\n\n/**\n * Create folder of the target file.\n * @param file Full path of the file\n */\nconst createDirectory = (file: string) => {\n if (Array.isArray(file)) {\n file = file[0];\n }\n const dir = file?.substr(0, file.lastIndexOf(\"/\"));\n if (!dir) {\n return;\n }\n if (!fs.statSync(dir).isDirectory()) {\n mkdirp.sync(dir);\n }\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compressor.\n * @param settings Settings\n */\nconst compressInMemory = (settings: Settings): Promise<string> | string => {\n if (typeof settings.compressor !== \"function\") {\n throw new Error(\n \"compressor should be a function, maybe you forgot to install the compressor\"\n );\n }\n\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compressInMemory };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport path from \"node:path\";\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport { globSync } from \"glob\";\n\n/**\n * Default settings.\n */\nconst defaultSettings = {\n sync: false,\n options: {},\n buffer: 1000 * 1024,\n callback: false,\n};\n\n/**\n * Run setup.\n * @param inputSettings Settings from user input\n */\nconst setup = (inputSettings: Settings) => {\n let settings: Settings = Object.assign(\n utils.clone(defaultSettings),\n inputSettings\n );\n\n // In memory\n if (settings.content) {\n checkMandatoriesMemoryContent(inputSettings);\n return settings;\n }\n\n checkMandatories(inputSettings);\n\n if (settings.input) {\n settings = Object.assign(\n settings,\n wildcards(settings.input, settings.publicFolder)\n );\n }\n if (settings.input && settings.output) {\n settings = Object.assign(\n settings,\n checkOutput(\n settings.input,\n settings.output,\n settings.publicFolder,\n settings.replaceInPlace\n )\n );\n }\n if (settings.input && settings.publicFolder) {\n settings = Object.assign(\n settings,\n setPublicFolder(settings.input, settings.publicFolder)\n );\n }\n\n return settings;\n};\n\n/**\n * Check the output path, searching for $1\n * if exist, returns the path replacing $1 by file name\n * @param input Path file\n * @param output Path to the output file\n * @param publicFolder Path to the public folder\n * @param replaceInPlace True to replace file in same folder\n */\nconst checkOutput = (\n input: string | string[],\n output: string,\n publicFolder?: string,\n replaceInPlace?: boolean\n) => {\n const reg = /\\$1/;\n if (reg.test(output)) {\n if (Array.isArray(input)) {\n const outputMin = input.map((file) =>\n utils.setFileNameMin(\n file,\n output,\n replaceInPlace ? undefined : publicFolder,\n replaceInPlace\n )\n );\n return { output: outputMin };\n }\n return {\n output: utils.setFileNameMin(\n input,\n output,\n replaceInPlace ? undefined : publicFolder,\n replaceInPlace\n ),\n };\n }\n};\n\n/**\n * Handle wildcards in a path, get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcards = (input: string | string[], publicFolder?: string) => {\n // If it's a string\n if (!Array.isArray(input)) {\n return wildcardsString(input, publicFolder);\n }\n\n return wildcardsArray(input, publicFolder);\n};\n\n/**\n * Handle wildcards in a path (string only), get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcardsString = (input: string, publicFolder?: string) => {\n const output: { input?: string[] } = {};\n\n if (input.indexOf(\"*\") > -1) {\n output.input = getFilesFromWildcards(input, publicFolder);\n }\n\n return output;\n};\n\n/**\n * Handle wildcards in a path (array only), get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcardsArray = (input: string[], publicFolder?: string) => {\n const output: { input?: string[] } = {};\n let isWildcardsPresent = false;\n\n output.input = input;\n\n // Transform all wildcards to path file\n const inputWithPublicFolder = input.map((item) => {\n if (item.indexOf(\"*\") > -1) {\n isWildcardsPresent = true;\n }\n return (publicFolder || \"\") + item;\n });\n\n if (isWildcardsPresent) {\n output.input = globSync(inputWithPublicFolder);\n }\n\n // Remove all wildcards from array\n for (let i = 0; i < output.input.length; i++) {\n if (output.input[i].indexOf(\"*\") > -1) {\n output.input.splice(i, 1);\n\n i--;\n }\n }\n\n return output;\n};\n\n/**\n * Get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst getFilesFromWildcards = (input: string, publicFolder?: string) => {\n let output: string[] = [];\n\n if (input.indexOf(\"*\") > -1) {\n output = globSync((publicFolder || \"\") + input);\n }\n\n return output;\n};\n\n/**\n * Prepend the public folder to each file.\n * @param input Path to file(s)\n * @param publicFolder Path to the public folder\n */\nconst setPublicFolder = (input: string | string[], publicFolder: string) => {\n const output: { input?: string | string[] } = {};\n\n if (typeof publicFolder !== \"string\") {\n return output;\n }\n\n publicFolder = path.normalize(publicFolder);\n\n if (Array.isArray(input)) {\n output.input = input.map((item) => {\n // Check if publicFolder is already in path\n if (path.normalize(item).indexOf(publicFolder) > -1) {\n return item;\n }\n return path.normalize(publicFolder + item);\n });\n return output;\n }\n\n input = path.normalize(input);\n\n // Check if publicFolder is already in path\n if (input.indexOf(publicFolder) > -1) {\n output.input = input;\n return output;\n }\n\n output.input = path.normalize(publicFolder + input);\n\n return output;\n};\n\n/**\n * Check if some settings are here.\n * @param settings Settings\n */\nconst checkMandatories = (settings: Settings) => {\n [\"compressor\", \"input\", \"output\"].forEach((item: string) =>\n mandatory(item, settings)\n );\n};\n\n/**\n * Check if some settings are here for memory content.\n * @param settings Settings\n */\nconst checkMandatoriesMemoryContent = (settings: Settings) => {\n [\"compressor\", \"content\"].forEach((item: string) =>\n mandatory(item, settings)\n );\n};\n\n/**\n * Check if the setting exist.\n * @param setting Setting\n * @param settings Settings\n */\nconst mandatory = (setting: string, settings: { [key: string]: any }) => {\n if (!settings[setting]) {\n throw new Error(`${setting} is mandatory.`);\n }\n};\n\n/**\n * Expose `setup()`.\n */\nexport { setup };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Settings } from \"@node-minify/types\";\nimport { compress } from \"./compress\";\nimport { compressInMemory } from \"./compressInMemory\";\nimport { setup } from \"./setup\";\n\n/**\n * Run node-minify.\n * @param settings Settings from user input\n */\nconst minify = (settings: Settings) => {\n return new Promise((resolve, reject) => {\n const method: any = settings.content ? compressInMemory : compress;\n settings = setup(settings);\n if (!settings.sync) {\n method(settings)\n .then((minified: string) => {\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n })\n .catch((err: Error) => {\n if (settings.callback) {\n settings.callback(err);\n }\n reject(err);\n });\n } else {\n const minified: string = method(settings);\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n }\n });\n};\n\n/**\n * Expose `minify()`.\n */\nminify.default = minify;\nexport = minify;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASA,qBAAe;AAEf,mBAAsB;AACtB,oBAAuB;AAMvB,IAAM,WAAW,CAAC,aAAiD;AAC/D,MAAI,OAAO,SAAS,eAAe,YAAY;AAC3C,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAEA,MAAI,SAAS,QAAQ;AACjB,oBAAgB,SAAS,MAAM;AAAA,EACnC;AAEA,MAAI,MAAM,QAAQ,SAAS,MAAM,GAAG;AAChC,WAAO,SAAS,OACV,yBAAyB,QAAQ,IACjC,0BAA0B,QAAQ;AAAA,EAC5C;AACA,SAAO,mBAAM,mBAAmB,QAAQ;AAC5C;AAMA,IAAM,2BAA2B,CAAC,aAA4B;AAC1D,SACI,MAAM,QAAQ,SAAS,KAAK,KAC5B,SAAS,MAAM,QAAQ,CAAC,OAAO,UAAU;AACrC,UAAM,UAAU,mBAAM,oBAAoB,KAAK;AAC/C,WAAO,mBAAM,QAAQ,EAAE,UAAU,SAAS,MAAM,CAAC;AAAA,EACrD,CAAC;AAET;AAMA,IAAM,4BAA4B,CAC9B,aACyB;AACzB,MAAI,WAAmC,QAAQ,QAAQ;AACvD,QAAM,QAAQ,SAAS,KAAK,KACxB,SAAS,MAAM,QAAQ,CAAC,OAAO,UAAU;AACrC,UAAM,UAAU,mBAAM,oBAAoB,KAAK;AAC/C,eAAW,SAAS;AAAA,MAAK,MACrB,mBAAM,SAAS,EAAE,UAAU,SAAS,MAAM,CAAC;AAAA,IAC/C;AAAA,EACJ,CAAC;AACL,SA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MAAM,QAAQ;AAAA,EAC5B;AACJ;AAOA,IAAM,YAAY,CAAC,SAAiB,aAAqC;AACrE,MAAI,CAAC,SAAS,OAAO,GAAG;AACpB,UAAM,IAAI,MAAM,GAAG,OAAO,gBAAgB;AAAA,EAC9C;AACJ;;;AC3OA,IAAM,SAAS,CAAC,aAAuB;AACnC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,UAAM,SAAc,SAAS,UAAU,mBAAmB;AAC1D,eAAW,MAAM,QAAQ;AACzB,QAAI,CAAC,SAAS,MAAM;AAChB,aAAO,QAAQ,EACV,KAAK,CAAC,aAAqB;AACxB,YAAI,SAAS,UAAU;AACnB,mBAAS,SAAS,MAAM,QAAQ;AAAA,QACpC;AACA,gBAAQ,QAAQ;AAAA,MACpB,CAAC,EACA,MAAM,CAAC,QAAe;AACnB,YAAI,SAAS,UAAU;AACnB,mBAAS,SAAS,GAAG;AAAA,QACzB;AACA,eAAO,GAAG;AAAA,MACd,CAAC;AAAA,IACT,OAAO;AACH,YAAM,WAAmB,OAAO,QAAQ;AACxC,UAAI,SAAS,UAAU;AACnB,iBAAS,SAAS,MAAM,QAAQ;AAAA,MACpC;AACA,cAAQ,QAAQ;AAAA,IACpB;AAAA,EACJ,CAAC;AACL;AAKA,OAAO,UAAU;AACjB,iBAAS;","names":["fs","import_utils","import_utils","path"]}
package/dist/index.mjs DELETED
@@ -1,275 +0,0 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
- };
5
- var __commonJS = (cb, mod) => function __require() {
6
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
- };
8
-
9
- // src/compress.ts
10
- import fs from "node:fs";
11
- import { utils } from "@node-minify/utils";
12
- import { mkdirp } from "mkdirp";
13
- var compress, compressArrayOfFilesSync, compressArrayOfFilesAsync, createDirectory;
14
- var init_compress = __esm({
15
- "src/compress.ts"() {
16
- "use strict";
17
- compress = (settings) => {
18
- if (typeof settings.compressor !== "function") {
19
- throw new Error(
20
- "compressor should be a function, maybe you forgot to install the compressor"
21
- );
22
- }
23
- if (settings.output) {
24
- createDirectory(settings.output);
25
- }
26
- if (Array.isArray(settings.output)) {
27
- return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
28
- }
29
- return utils.compressSingleFile(settings);
30
- };
31
- compressArrayOfFilesSync = (settings) => {
32
- return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
33
- const content = utils.getContentFromFiles(input);
34
- return utils.runSync({ settings, content, index });
35
- });
36
- };
37
- compressArrayOfFilesAsync = (settings) => {
38
- let sequence = Promise.resolve();
39
- Array.isArray(settings.input) && settings.input.forEach((input, index) => {
40
- const content = utils.getContentFromFiles(input);
41
- sequence = sequence.then(
42
- () => utils.runAsync({ settings, content, index })
43
- );
44
- });
45
- return sequence;
46
- };
47
- createDirectory = (file) => {
48
- if (Array.isArray(file)) {
49
- file = file[0];
50
- }
51
- const dir = file?.substr(0, file.lastIndexOf("/"));
52
- if (!dir) {
53
- return;
54
- }
55
- if (!fs.statSync(dir).isDirectory()) {
56
- mkdirp.sync(dir);
57
- }
58
- };
59
- }
60
- });
61
-
62
- // src/compressInMemory.ts
63
- import { utils as utils2 } from "@node-minify/utils";
64
- var compressInMemory;
65
- var init_compressInMemory = __esm({
66
- "src/compressInMemory.ts"() {
67
- "use strict";
68
- compressInMemory = (settings) => {
69
- if (typeof settings.compressor !== "function") {
70
- throw new Error(
71
- "compressor should be a function, maybe you forgot to install the compressor"
72
- );
73
- }
74
- return utils2.compressSingleFile(settings);
75
- };
76
- }
77
- });
78
-
79
- // src/setup.ts
80
- import path from "node:path";
81
- import { utils as utils3 } from "@node-minify/utils";
82
- import { globSync } from "glob";
83
- var defaultSettings, setup, checkOutput, wildcards, wildcardsString, wildcardsArray, getFilesFromWildcards, setPublicFolder, checkMandatories, checkMandatoriesMemoryContent, mandatory;
84
- var init_setup = __esm({
85
- "src/setup.ts"() {
86
- "use strict";
87
- defaultSettings = {
88
- sync: false,
89
- options: {},
90
- buffer: 1e3 * 1024,
91
- callback: false
92
- };
93
- setup = (inputSettings) => {
94
- let settings = Object.assign(
95
- utils3.clone(defaultSettings),
96
- inputSettings
97
- );
98
- if (settings.content) {
99
- checkMandatoriesMemoryContent(inputSettings);
100
- return settings;
101
- }
102
- checkMandatories(inputSettings);
103
- if (settings.input) {
104
- settings = Object.assign(
105
- settings,
106
- wildcards(settings.input, settings.publicFolder)
107
- );
108
- }
109
- if (settings.input && settings.output) {
110
- settings = Object.assign(
111
- settings,
112
- checkOutput(
113
- settings.input,
114
- settings.output,
115
- settings.publicFolder,
116
- settings.replaceInPlace
117
- )
118
- );
119
- }
120
- if (settings.input && settings.publicFolder) {
121
- settings = Object.assign(
122
- settings,
123
- setPublicFolder(settings.input, settings.publicFolder)
124
- );
125
- }
126
- return settings;
127
- };
128
- checkOutput = (input, output, publicFolder, replaceInPlace) => {
129
- const reg = /\$1/;
130
- if (reg.test(output)) {
131
- if (Array.isArray(input)) {
132
- const outputMin = input.map(
133
- (file) => utils3.setFileNameMin(
134
- file,
135
- output,
136
- replaceInPlace ? void 0 : publicFolder,
137
- replaceInPlace
138
- )
139
- );
140
- return { output: outputMin };
141
- }
142
- return {
143
- output: utils3.setFileNameMin(
144
- input,
145
- output,
146
- replaceInPlace ? void 0 : publicFolder,
147
- replaceInPlace
148
- )
149
- };
150
- }
151
- };
152
- wildcards = (input, publicFolder) => {
153
- if (!Array.isArray(input)) {
154
- return wildcardsString(input, publicFolder);
155
- }
156
- return wildcardsArray(input, publicFolder);
157
- };
158
- wildcardsString = (input, publicFolder) => {
159
- const output = {};
160
- if (input.indexOf("*") > -1) {
161
- output.input = getFilesFromWildcards(input, publicFolder);
162
- }
163
- return output;
164
- };
165
- wildcardsArray = (input, publicFolder) => {
166
- const output = {};
167
- let isWildcardsPresent = false;
168
- output.input = input;
169
- const inputWithPublicFolder = input.map((item) => {
170
- if (item.indexOf("*") > -1) {
171
- isWildcardsPresent = true;
172
- }
173
- return (publicFolder || "") + item;
174
- });
175
- if (isWildcardsPresent) {
176
- output.input = globSync(inputWithPublicFolder);
177
- }
178
- for (let i = 0; i < output.input.length; i++) {
179
- if (output.input[i].indexOf("*") > -1) {
180
- output.input.splice(i, 1);
181
- i--;
182
- }
183
- }
184
- return output;
185
- };
186
- getFilesFromWildcards = (input, publicFolder) => {
187
- let output = [];
188
- if (input.indexOf("*") > -1) {
189
- output = globSync((publicFolder || "") + input);
190
- }
191
- return output;
192
- };
193
- setPublicFolder = (input, publicFolder) => {
194
- const output = {};
195
- if (typeof publicFolder !== "string") {
196
- return output;
197
- }
198
- publicFolder = path.normalize(publicFolder);
199
- if (Array.isArray(input)) {
200
- output.input = input.map((item) => {
201
- if (path.normalize(item).indexOf(publicFolder) > -1) {
202
- return item;
203
- }
204
- return path.normalize(publicFolder + item);
205
- });
206
- return output;
207
- }
208
- input = path.normalize(input);
209
- if (input.indexOf(publicFolder) > -1) {
210
- output.input = input;
211
- return output;
212
- }
213
- output.input = path.normalize(publicFolder + input);
214
- return output;
215
- };
216
- checkMandatories = (settings) => {
217
- ["compressor", "input", "output"].forEach(
218
- (item) => mandatory(item, settings)
219
- );
220
- };
221
- checkMandatoriesMemoryContent = (settings) => {
222
- ["compressor", "content"].forEach(
223
- (item) => mandatory(item, settings)
224
- );
225
- };
226
- mandatory = (setting, settings) => {
227
- if (!settings[setting]) {
228
- throw new Error(`${setting} is mandatory.`);
229
- }
230
- };
231
- }
232
- });
233
-
234
- // src/index.ts
235
- var require_src = __commonJS({
236
- "src/index.ts"(exports, module) {
237
- init_compress();
238
- init_compressInMemory();
239
- init_setup();
240
- var minify = (settings) => {
241
- return new Promise((resolve, reject) => {
242
- const method = settings.content ? compressInMemory : compress;
243
- settings = setup(settings);
244
- if (!settings.sync) {
245
- method(settings).then((minified) => {
246
- if (settings.callback) {
247
- settings.callback(null, minified);
248
- }
249
- resolve(minified);
250
- }).catch((err) => {
251
- if (settings.callback) {
252
- settings.callback(err);
253
- }
254
- reject(err);
255
- });
256
- } else {
257
- const minified = method(settings);
258
- if (settings.callback) {
259
- settings.callback(null, minified);
260
- }
261
- resolve(minified);
262
- }
263
- });
264
- };
265
- minify.default = minify;
266
- module.exports = minify;
267
- }
268
- });
269
- export default require_src();
270
- /*!
271
- * node-minify
272
- * Copyright(c) 2011-2024 Rodolphe Stoclin
273
- * MIT Licensed
274
- */
275
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/compress.ts","../src/compressInMemory.ts","../src/setup.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport fs from \"node:fs\";\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport { mkdirp } from \"mkdirp\";\n\n/**\n * Run compressor.\n * @param settings Settings\n */\nconst compress = (settings: Settings): Promise<string> | string => {\n if (typeof settings.compressor !== \"function\") {\n throw new Error(\n \"compressor should be a function, maybe you forgot to install the compressor\"\n );\n }\n\n if (settings.output) {\n createDirectory(settings.output);\n }\n\n if (Array.isArray(settings.output)) {\n return settings.sync\n ? compressArrayOfFilesSync(settings)\n : compressArrayOfFilesAsync(settings);\n }\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Compress an array of files in sync.\n * @param settings Settings\n */\nconst compressArrayOfFilesSync = (settings: Settings): any => {\n return (\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n return utils.runSync({ settings, content, index });\n })\n );\n};\n\n/**\n * Compress an array of files in async.\n * @param settings Settings\n */\nconst compressArrayOfFilesAsync = (\n settings: Settings\n): Promise<string | void> => {\n let sequence: Promise<string | void> = Promise.resolve();\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n sequence = sequence.then(() =>\n utils.runAsync({ settings, content, index })\n );\n });\n return sequence;\n};\n\n/**\n * Create folder of the target file.\n * @param file Full path of the file\n */\nconst createDirectory = (file: string) => {\n if (Array.isArray(file)) {\n file = file[0];\n }\n const dir = file?.substr(0, file.lastIndexOf(\"/\"));\n if (!dir) {\n return;\n }\n if (!fs.statSync(dir).isDirectory()) {\n mkdirp.sync(dir);\n }\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compressor.\n * @param settings Settings\n */\nconst compressInMemory = (settings: Settings): Promise<string> | string => {\n if (typeof settings.compressor !== \"function\") {\n throw new Error(\n \"compressor should be a function, maybe you forgot to install the compressor\"\n );\n }\n\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compressInMemory };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport path from \"node:path\";\nimport type { Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\nimport { globSync } from \"glob\";\n\n/**\n * Default settings.\n */\nconst defaultSettings = {\n sync: false,\n options: {},\n buffer: 1000 * 1024,\n callback: false,\n};\n\n/**\n * Run setup.\n * @param inputSettings Settings from user input\n */\nconst setup = (inputSettings: Settings) => {\n let settings: Settings = Object.assign(\n utils.clone(defaultSettings),\n inputSettings\n );\n\n // In memory\n if (settings.content) {\n checkMandatoriesMemoryContent(inputSettings);\n return settings;\n }\n\n checkMandatories(inputSettings);\n\n if (settings.input) {\n settings = Object.assign(\n settings,\n wildcards(settings.input, settings.publicFolder)\n );\n }\n if (settings.input && settings.output) {\n settings = Object.assign(\n settings,\n checkOutput(\n settings.input,\n settings.output,\n settings.publicFolder,\n settings.replaceInPlace\n )\n );\n }\n if (settings.input && settings.publicFolder) {\n settings = Object.assign(\n settings,\n setPublicFolder(settings.input, settings.publicFolder)\n );\n }\n\n return settings;\n};\n\n/**\n * Check the output path, searching for $1\n * if exist, returns the path replacing $1 by file name\n * @param input Path file\n * @param output Path to the output file\n * @param publicFolder Path to the public folder\n * @param replaceInPlace True to replace file in same folder\n */\nconst checkOutput = (\n input: string | string[],\n output: string,\n publicFolder?: string,\n replaceInPlace?: boolean\n) => {\n const reg = /\\$1/;\n if (reg.test(output)) {\n if (Array.isArray(input)) {\n const outputMin = input.map((file) =>\n utils.setFileNameMin(\n file,\n output,\n replaceInPlace ? undefined : publicFolder,\n replaceInPlace\n )\n );\n return { output: outputMin };\n }\n return {\n output: utils.setFileNameMin(\n input,\n output,\n replaceInPlace ? undefined : publicFolder,\n replaceInPlace\n ),\n };\n }\n};\n\n/**\n * Handle wildcards in a path, get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcards = (input: string | string[], publicFolder?: string) => {\n // If it's a string\n if (!Array.isArray(input)) {\n return wildcardsString(input, publicFolder);\n }\n\n return wildcardsArray(input, publicFolder);\n};\n\n/**\n * Handle wildcards in a path (string only), get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcardsString = (input: string, publicFolder?: string) => {\n const output: { input?: string[] } = {};\n\n if (input.indexOf(\"*\") > -1) {\n output.input = getFilesFromWildcards(input, publicFolder);\n }\n\n return output;\n};\n\n/**\n * Handle wildcards in a path (array only), get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst wildcardsArray = (input: string[], publicFolder?: string) => {\n const output: { input?: string[] } = {};\n let isWildcardsPresent = false;\n\n output.input = input;\n\n // Transform all wildcards to path file\n const inputWithPublicFolder = input.map((item) => {\n if (item.indexOf(\"*\") > -1) {\n isWildcardsPresent = true;\n }\n return (publicFolder || \"\") + item;\n });\n\n if (isWildcardsPresent) {\n output.input = globSync(inputWithPublicFolder);\n }\n\n // Remove all wildcards from array\n for (let i = 0; i < output.input.length; i++) {\n if (output.input[i].indexOf(\"*\") > -1) {\n output.input.splice(i, 1);\n\n i--;\n }\n }\n\n return output;\n};\n\n/**\n * Get the real path of each files.\n * @param input Path with wildcards\n * @param publicFolder Path to the public folder\n */\nconst getFilesFromWildcards = (input: string, publicFolder?: string) => {\n let output: string[] = [];\n\n if (input.indexOf(\"*\") > -1) {\n output = globSync((publicFolder || \"\") + input);\n }\n\n return output;\n};\n\n/**\n * Prepend the public folder to each file.\n * @param input Path to file(s)\n * @param publicFolder Path to the public folder\n */\nconst setPublicFolder = (input: string | string[], publicFolder: string) => {\n const output: { input?: string | string[] } = {};\n\n if (typeof publicFolder !== \"string\") {\n return output;\n }\n\n publicFolder = path.normalize(publicFolder);\n\n if (Array.isArray(input)) {\n output.input = input.map((item) => {\n // Check if publicFolder is already in path\n if (path.normalize(item).indexOf(publicFolder) > -1) {\n return item;\n }\n return path.normalize(publicFolder + item);\n });\n return output;\n }\n\n input = path.normalize(input);\n\n // Check if publicFolder is already in path\n if (input.indexOf(publicFolder) > -1) {\n output.input = input;\n return output;\n }\n\n output.input = path.normalize(publicFolder + input);\n\n return output;\n};\n\n/**\n * Check if some settings are here.\n * @param settings Settings\n */\nconst checkMandatories = (settings: Settings) => {\n [\"compressor\", \"input\", \"output\"].forEach((item: string) =>\n mandatory(item, settings)\n );\n};\n\n/**\n * Check if some settings are here for memory content.\n * @param settings Settings\n */\nconst checkMandatoriesMemoryContent = (settings: Settings) => {\n [\"compressor\", \"content\"].forEach((item: string) =>\n mandatory(item, settings)\n );\n};\n\n/**\n * Check if the setting exist.\n * @param setting Setting\n * @param settings Settings\n */\nconst mandatory = (setting: string, settings: { [key: string]: any }) => {\n if (!settings[setting]) {\n throw new Error(`${setting} is mandatory.`);\n }\n};\n\n/**\n * Expose `setup()`.\n */\nexport { setup };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Settings } from \"@node-minify/types\";\nimport { compress } from \"./compress\";\nimport { compressInMemory } from \"./compressInMemory\";\nimport { setup } from \"./setup\";\n\n/**\n * Run node-minify.\n * @param settings Settings from user input\n */\nconst minify = (settings: Settings) => {\n return new Promise((resolve, reject) => {\n const method: any = settings.content ? compressInMemory : compress;\n settings = setup(settings);\n if (!settings.sync) {\n method(settings)\n .then((minified: string) => {\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n })\n .catch((err: Error) => {\n if (settings.callback) {\n settings.callback(err);\n }\n reject(err);\n });\n } else {\n const minified: string = method(settings);\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n }\n });\n};\n\n/**\n * Expose `minify()`.\n */\nminify.default = minify;\nexport = minify;\n"],"mappings":";;;;;;;;;AASA,OAAO,QAAQ;AAEf,SAAS,aAAa;AACtB,SAAS,cAAc;AAZvB,IAkBM,UAuBA,0BAcA,2BAkBA;AAzEN;AAAA;AAAA;AAkBA,IAAM,WAAW,CAAC,aAAiD;AAC/D,UAAI,OAAO,SAAS,eAAe,YAAY;AAC3C,cAAM,IAAI;AAAA,UACN;AAAA,QACJ;AAAA,MACJ;AAEA,UAAI,SAAS,QAAQ;AACjB,wBAAgB,SAAS,MAAM;AAAA,MACnC;AAEA,UAAI,MAAM,QAAQ,SAAS,MAAM,GAAG;AAChC,eAAO,SAAS,OACV,yBAAyB,QAAQ,IACjC,0BAA0B,QAAQ;AAAA,MAC5C;AACA,aAAO,MAAM,mBAAmB,QAAQ;AAAA,IAC5C;AAMA,IAAM,2BAA2B,CAAC,aAA4B;AAC1D,aACI,MAAM,QAAQ,SAAS,KAAK,KAC5B,SAAS,MAAM,QAAQ,CAAC,OAAO,UAAU;AACrC,cAAM,UAAU,MAAM,oBAAoB,KAAK;AAC/C,eAAO,MAAM,QAAQ,EAAE,UAAU,SAAS,MAA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