balm-core 5.2.0 → 6.0.0-alpha.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.
Files changed (301) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.cjs +2625 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +569 -0
  5. package/dist/index.d.ts +569 -0
  6. package/dist/index.js +2527 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +49 -123
  9. package/src/balm.ts +108 -0
  10. package/src/bundler/esbuild.ts +47 -0
  11. package/src/bundler/index.ts +3 -0
  12. package/src/bundler/rollup.ts +45 -0
  13. package/src/bundler/webpack.ts +124 -0
  14. package/src/config/constants.ts +12 -0
  15. package/src/config/defaults.ts +209 -0
  16. package/src/config/index.ts +112 -0
  17. package/src/hooks/index.ts +224 -0
  18. package/src/index.ts +16 -0
  19. package/src/pipeline/file.ts +69 -0
  20. package/src/pipeline/index.ts +10 -0
  21. package/src/pipeline/pipeline.ts +135 -0
  22. package/src/pipeline/transforms/cache.ts +146 -0
  23. package/src/pipeline/transforms/htmlmin.ts +18 -0
  24. package/src/pipeline/transforms/less.ts +75 -0
  25. package/src/pipeline/transforms/postcss.ts +43 -0
  26. package/src/pipeline/transforms/rename.ts +37 -0
  27. package/src/pipeline/transforms/replace.ts +30 -0
  28. package/src/pipeline/transforms/sass.ts +106 -0
  29. package/src/pipeline/transforms/terser.ts +20 -0
  30. package/src/runner/dag.ts +77 -0
  31. package/src/runner/task.ts +38 -0
  32. package/src/shims.d.ts +5 -0
  33. package/src/tasks/cache.ts +72 -0
  34. package/src/tasks/clean.ts +21 -0
  35. package/src/tasks/copy.ts +36 -0
  36. package/src/tasks/ftp.ts +90 -0
  37. package/src/tasks/html.ts +232 -0
  38. package/src/tasks/index.ts +14 -0
  39. package/src/tasks/publish.ts +71 -0
  40. package/src/tasks/pwa.ts +99 -0
  41. package/src/tasks/remove.ts +24 -0
  42. package/src/tasks/replace.ts +34 -0
  43. package/src/tasks/script.ts +28 -0
  44. package/src/tasks/server.ts +183 -0
  45. package/src/tasks/static.ts +104 -0
  46. package/src/tasks/style.ts +57 -0
  47. package/src/tasks/zip.ts +65 -0
  48. package/src/types/index.ts +202 -0
  49. package/src/utilities/file.ts +120 -0
  50. package/src/utilities/logger.ts +63 -0
  51. package/src/utilities/utils.ts +46 -0
  52. package/src/utilities/workspace.ts +38 -0
  53. package/src/watcher/index.ts +100 -0
  54. package/tsconfig.json +8 -0
  55. package/tsup.config.ts +12 -0
  56. package/README.md +0 -196
  57. package/index.d.ts +0 -360
  58. package/lib/balm.js +0 -49
  59. package/lib/bootstrap/check_config.js +0 -43
  60. package/lib/bootstrap/index.js +0 -87
  61. package/lib/bundler/esbuild/build.js +0 -26
  62. package/lib/bundler/esbuild/index.js +0 -7
  63. package/lib/bundler/esbuild/options.js +0 -7
  64. package/lib/bundler/esbuild/transform.js +0 -36
  65. package/lib/bundler/rollup/build.js +0 -52
  66. package/lib/bundler/rollup/entry.js +0 -28
  67. package/lib/bundler/rollup/index.js +0 -20
  68. package/lib/bundler/rollup/output.js +0 -20
  69. package/lib/bundler/rollup/plugins.js +0 -31
  70. package/lib/bundler/webpack/config/common.js +0 -135
  71. package/lib/bundler/webpack/config/dev.js +0 -12
  72. package/lib/bundler/webpack/config/env.js +0 -67
  73. package/lib/bundler/webpack/config/index.js +0 -6
  74. package/lib/bundler/webpack/config/prod.js +0 -39
  75. package/lib/bundler/webpack/config/regex.js +0 -10
  76. package/lib/bundler/webpack/entry.js +0 -65
  77. package/lib/bundler/webpack/index.js +0 -32
  78. package/lib/bundler/webpack/loaders.js +0 -50
  79. package/lib/bundler/webpack/output.js +0 -41
  80. package/lib/bundler/webpack/rules/asset.js +0 -33
  81. package/lib/bundler/webpack/rules/babel.js +0 -19
  82. package/lib/bundler/webpack/rules/css.js +0 -109
  83. package/lib/bundler/webpack/rules/html.js +0 -15
  84. package/lib/bundler/webpack/rules/index.js +0 -10
  85. package/lib/config/assets.js +0 -30
  86. package/lib/config/constants.js +0 -14
  87. package/lib/config/env.js +0 -35
  88. package/lib/config/extras.js +0 -6
  89. package/lib/config/ftp.js +0 -6
  90. package/lib/config/globals.js +0 -43
  91. package/lib/config/html.js +0 -22
  92. package/lib/config/images.js +0 -4
  93. package/lib/config/index.js +0 -63
  94. package/lib/config/logs.js +0 -11
  95. package/lib/config/paths.js +0 -46
  96. package/lib/config/pwa.js +0 -24
  97. package/lib/config/roots.js +0 -9
  98. package/lib/config/scripts.js +0 -162
  99. package/lib/config/server.js +0 -84
  100. package/lib/config/spinner.js +0 -9
  101. package/lib/config/styles.js +0 -67
  102. package/lib/hello.js +0 -19
  103. package/lib/hooks/index.js +0 -94
  104. package/lib/hooks/maker.js +0 -59
  105. package/lib/index.js +0 -5
  106. package/lib/middlewares/history.js +0 -6
  107. package/lib/middlewares/index.js +0 -11
  108. package/lib/middlewares/proxy.js +0 -28
  109. package/lib/middlewares/webpack.js +0 -26
  110. package/lib/plugins/htmlmin.js +0 -39
  111. package/lib/plugins/imagemin.js +0 -95
  112. package/lib/plugins/index.js +0 -27
  113. package/lib/plugins/jsmin.js +0 -37
  114. package/lib/plugins/less.js +0 -97
  115. package/lib/plugins/plumber.js +0 -87
  116. package/lib/plugins/postcss-plugins.js +0 -13
  117. package/lib/plugins/postcss.js +0 -117
  118. package/lib/plugins/rename.js +0 -51
  119. package/lib/plugins/replace.js +0 -91
  120. package/lib/plugins/sass-legacy.js +0 -131
  121. package/lib/plugins/sass.js +0 -134
  122. package/lib/plugins/sftp.js +0 -288
  123. package/lib/tasks/default.js +0 -46
  124. package/lib/tasks/foundation/balm.js +0 -72
  125. package/lib/tasks/foundation/balm_style.js +0 -65
  126. package/lib/tasks/foundation/index.js +0 -10
  127. package/lib/tasks/index.js +0 -48
  128. package/lib/tasks/private/build.js +0 -18
  129. package/lib/tasks/private/cache.js +0 -31
  130. package/lib/tasks/private/clean.js +0 -69
  131. package/lib/tasks/private/end.js +0 -24
  132. package/lib/tasks/private/extra.js +0 -35
  133. package/lib/tasks/private/font.js +0 -15
  134. package/lib/tasks/private/image.js +0 -37
  135. package/lib/tasks/private/index.js +0 -34
  136. package/lib/tasks/private/lint.js +0 -20
  137. package/lib/tasks/private/media.js +0 -15
  138. package/lib/tasks/private/modernizr.js +0 -59
  139. package/lib/tasks/private/pwa-cache.js +0 -32
  140. package/lib/tasks/private/script.js +0 -9
  141. package/lib/tasks/private/sprite.js +0 -105
  142. package/lib/tasks/private/start.js +0 -16
  143. package/lib/tasks/private/style.js +0 -9
  144. package/lib/tasks/private/workbox-sw.js +0 -15
  145. package/lib/tasks/public/copy.js +0 -16
  146. package/lib/tasks/public/esbuild.js +0 -18
  147. package/lib/tasks/public/ftp.js +0 -39
  148. package/lib/tasks/public/html.js +0 -65
  149. package/lib/tasks/public/index.js +0 -38
  150. package/lib/tasks/public/jsmin.js +0 -23
  151. package/lib/tasks/public/less.js +0 -21
  152. package/lib/tasks/public/postcss.js +0 -16
  153. package/lib/tasks/public/publish.js +0 -51
  154. package/lib/tasks/public/pwa.js +0 -84
  155. package/lib/tasks/public/remove.js +0 -46
  156. package/lib/tasks/public/replace.js +0 -26
  157. package/lib/tasks/public/rollup.js +0 -17
  158. package/lib/tasks/public/sass.js +0 -27
  159. package/lib/tasks/public/server.js +0 -130
  160. package/lib/tasks/public/url.js +0 -35
  161. package/lib/tasks/public/version.js +0 -23
  162. package/lib/tasks/public/webpack.js +0 -39
  163. package/lib/tasks/public/zip.js +0 -19
  164. package/lib/utilities/address.js +0 -55
  165. package/lib/utilities/cache-core.js +0 -66
  166. package/lib/utilities/color.js +0 -27
  167. package/lib/utilities/compiling.js +0 -24
  168. package/lib/utilities/detect-port.js +0 -100
  169. package/lib/utilities/escape-string-regexp.js +0 -10
  170. package/lib/utilities/file.js +0 -70
  171. package/lib/utilities/index.js +0 -8
  172. package/lib/utilities/loading.js +0 -37
  173. package/lib/utilities/logger.js +0 -99
  174. package/lib/utilities/merge-stream.js +0 -38
  175. package/lib/utilities/namespace.js +0 -11
  176. package/lib/utilities/public-url.js +0 -37
  177. package/lib/utilities/replacestream.js +0 -106
  178. package/lib/utilities/typeof.js +0 -5
  179. package/lib/utilities/utils.js +0 -43
  180. package/tslib/balm.js +0 -44
  181. package/tslib/bootstrap/check_config.js +0 -36
  182. package/tslib/bootstrap/index.js +0 -82
  183. package/tslib/bundler/esbuild/build.js +0 -30
  184. package/tslib/bundler/esbuild/index.js +0 -11
  185. package/tslib/bundler/esbuild/options.js +0 -7
  186. package/tslib/bundler/esbuild/transform.js +0 -38
  187. package/tslib/bundler/rollup/build.js +0 -17
  188. package/tslib/bundler/rollup/entry.js +0 -24
  189. package/tslib/bundler/rollup/index.js +0 -21
  190. package/tslib/bundler/rollup/output.js +0 -23
  191. package/tslib/bundler/rollup/plugins.js +0 -27
  192. package/tslib/bundler/webpack/config/common.js +0 -130
  193. package/tslib/bundler/webpack/config/dev.js +0 -14
  194. package/tslib/bundler/webpack/config/env.js +0 -44
  195. package/tslib/bundler/webpack/config/index.js +0 -8
  196. package/tslib/bundler/webpack/config/prod.js +0 -43
  197. package/tslib/bundler/webpack/config/regex.js +0 -10
  198. package/tslib/bundler/webpack/entry.js +0 -68
  199. package/tslib/bundler/webpack/index.js +0 -30
  200. package/tslib/bundler/webpack/loaders.js +0 -51
  201. package/tslib/bundler/webpack/output.js +0 -41
  202. package/tslib/bundler/webpack/rules/asset.js +0 -33
  203. package/tslib/bundler/webpack/rules/babel.js +0 -16
  204. package/tslib/bundler/webpack/rules/css.js +0 -95
  205. package/tslib/bundler/webpack/rules/html.js +0 -15
  206. package/tslib/bundler/webpack/rules/index.js +0 -10
  207. package/tslib/config/assets.js +0 -24
  208. package/tslib/config/constants.js +0 -14
  209. package/tslib/config/env.js +0 -43
  210. package/tslib/config/extras.js +0 -6
  211. package/tslib/config/ftp.js +0 -6
  212. package/tslib/config/globals.js +0 -47
  213. package/tslib/config/html.js +0 -17
  214. package/tslib/config/images.js +0 -4
  215. package/tslib/config/index.js +0 -56
  216. package/tslib/config/logs.js +0 -6
  217. package/tslib/config/paths.js +0 -30
  218. package/tslib/config/pwa.js +0 -18
  219. package/tslib/config/roots.js +0 -8
  220. package/tslib/config/scripts.js +0 -93
  221. package/tslib/config/server.js +0 -33
  222. package/tslib/config/spinner.js +0 -10
  223. package/tslib/config/styles.js +0 -37
  224. package/tslib/hello.js +0 -19
  225. package/tslib/hooks/index.js +0 -75
  226. package/tslib/hooks/maker.js +0 -66
  227. package/tslib/index.js +0 -5
  228. package/tslib/middlewares/history.js +0 -12
  229. package/tslib/middlewares/index.js +0 -18
  230. package/tslib/middlewares/proxy.js +0 -27
  231. package/tslib/middlewares/webpack.js +0 -29
  232. package/tslib/plugins/htmlmin.js +0 -38
  233. package/tslib/plugins/imagemin.js +0 -97
  234. package/tslib/plugins/index.js +0 -27
  235. package/tslib/plugins/jsmin.js +0 -39
  236. package/tslib/plugins/less.js +0 -90
  237. package/tslib/plugins/plumber.js +0 -81
  238. package/tslib/plugins/postcss-plugins.js +0 -24
  239. package/tslib/plugins/postcss.js +0 -111
  240. package/tslib/plugins/rename.js +0 -51
  241. package/tslib/plugins/replace.js +0 -72
  242. package/tslib/plugins/sass-legacy.js +0 -95
  243. package/tslib/plugins/sass.js +0 -109
  244. package/tslib/plugins/sftp.js +0 -258
  245. package/tslib/tasks/default.js +0 -59
  246. package/tslib/tasks/foundation/balm.js +0 -75
  247. package/tslib/tasks/foundation/balm_style.js +0 -68
  248. package/tslib/tasks/foundation/index.js +0 -10
  249. package/tslib/tasks/index.js +0 -43
  250. package/tslib/tasks/private/build.js +0 -15
  251. package/tslib/tasks/private/cache.js +0 -48
  252. package/tslib/tasks/private/clean.js +0 -82
  253. package/tslib/tasks/private/end.js +0 -21
  254. package/tslib/tasks/private/extra.js +0 -34
  255. package/tslib/tasks/private/font.js +0 -12
  256. package/tslib/tasks/private/image.js +0 -42
  257. package/tslib/tasks/private/index.js +0 -34
  258. package/tslib/tasks/private/lint.js +0 -17
  259. package/tslib/tasks/private/media.js +0 -12
  260. package/tslib/tasks/private/modernizr.js +0 -54
  261. package/tslib/tasks/private/pwa-cache.js +0 -32
  262. package/tslib/tasks/private/script.js +0 -9
  263. package/tslib/tasks/private/sprite.js +0 -93
  264. package/tslib/tasks/private/start.js +0 -13
  265. package/tslib/tasks/private/style.js +0 -12
  266. package/tslib/tasks/private/workbox-sw.js +0 -15
  267. package/tslib/tasks/public/copy.js +0 -18
  268. package/tslib/tasks/public/esbuild.js +0 -18
  269. package/tslib/tasks/public/ftp.js +0 -39
  270. package/tslib/tasks/public/html.js +0 -75
  271. package/tslib/tasks/public/index.js +0 -38
  272. package/tslib/tasks/public/jsmin.js +0 -24
  273. package/tslib/tasks/public/less.js +0 -21
  274. package/tslib/tasks/public/postcss.js +0 -16
  275. package/tslib/tasks/public/publish.js +0 -50
  276. package/tslib/tasks/public/pwa.js +0 -87
  277. package/tslib/tasks/public/remove.js +0 -44
  278. package/tslib/tasks/public/replace.js +0 -27
  279. package/tslib/tasks/public/rollup.js +0 -17
  280. package/tslib/tasks/public/sass.js +0 -27
  281. package/tslib/tasks/public/server.js +0 -129
  282. package/tslib/tasks/public/url.js +0 -35
  283. package/tslib/tasks/public/version.js +0 -27
  284. package/tslib/tasks/public/webpack.js +0 -41
  285. package/tslib/tasks/public/zip.js +0 -19
  286. package/tslib/utilities/address.js +0 -48
  287. package/tslib/utilities/cache-core.js +0 -57
  288. package/tslib/utilities/color.js +0 -33
  289. package/tslib/utilities/compiling.js +0 -16
  290. package/tslib/utilities/detect-port.js +0 -91
  291. package/tslib/utilities/escape-string-regexp.js +0 -7
  292. package/tslib/utilities/file.js +0 -78
  293. package/tslib/utilities/index.js +0 -8
  294. package/tslib/utilities/loading.js +0 -25
  295. package/tslib/utilities/logger.js +0 -92
  296. package/tslib/utilities/merge-stream.js +0 -34
  297. package/tslib/utilities/namespace.js +0 -12
  298. package/tslib/utilities/public-url.js +0 -31
  299. package/tslib/utilities/replacestream.js +0 -112
  300. package/tslib/utilities/typeof.js +0 -8
  301. package/tslib/utilities/utils.js +0 -38
@@ -1,39 +0,0 @@
1
- // Reference `gulp-htmlmin@5.0.1`
2
-
3
- import { minify } from 'html-minifier-terser';
4
- const PLUGIN_NAME = 'htmlmin';
5
- function gulpHtmlmin(options) {
6
- options = BalmJS.utils.deepMerge({}, options);
7
- function transform(file, encoding, callback) {
8
- if (file.isNull()) {
9
- callback(null, file);
10
- return;
11
- }
12
- async function htmlMinify(buf, enc, cb) {
13
- try {
14
- const minified = await minify(buf.toString(), options);
15
- const contents = Buffer.from(minified);
16
- if (cb === callback) {
17
- file.contents = contents;
18
- cb(null, file);
19
- } else {
20
- cb(null, contents);
21
- callback(null, file);
22
- }
23
- } catch (e) {
24
- const opts = Object.assign(options, {
25
- fileName: file.path
26
- });
27
- const error = new PluginError(PLUGIN_NAME, e, opts);
28
- cb === callback ? cb(error) : callback(error);
29
- }
30
- }
31
- if (file.isStream()) {
32
- file.contents = file.contents.pipe(through2(htmlMinify));
33
- } else {
34
- htmlMinify(file.contents, null, callback);
35
- }
36
- }
37
- return through2.obj(transform);
38
- }
39
- export default gulpHtmlmin;
@@ -1,95 +0,0 @@
1
- // Reference `gulp-imagemin@9.1.0`
2
-
3
- import imagemin from 'imagemin';
4
- import prettyBytes from 'pretty-bytes';
5
- import through2Concurrent from 'through2-concurrent';
6
- const PLUGIN_NAME = 'imagemin';
7
- const defaultPlugins = ['gifsicle', 'mozjpeg', 'optipng', 'svgo'];
8
- const loadPlugin = (plugin, ...args) => {
9
- return async input => {
10
- try {
11
- const m = await import(`imagemin-${plugin}`);
12
- const pluginFn = m.default(...args);
13
- return pluginFn(input);
14
- } catch (_) {
15
- BalmJS.logger.error(PLUGIN_NAME, `Could not load default plugin \`${plugin}\``);
16
- return input;
17
- }
18
- };
19
- };
20
- const exposePlugin = plugin => (...args) => loadPlugin(plugin, ...args);
21
- const getDefaultPlugins = () => defaultPlugins.flatMap(plugin => loadPlugin(plugin));
22
- function gulpImagemin(customPlugins) {
23
- if (typeof customPlugins === 'object' && !Array.isArray(customPlugins)) {
24
- customPlugins = undefined;
25
- }
26
- const validExtensions = new Set(['.jpg', '.jpeg', '.png', '.gif', '.svg']);
27
- let totalBytes = 0;
28
- let totalSavedBytes = 0;
29
- let totalFiles = 0;
30
- function transform(file, encoding, callback) {
31
- if (file.isNull()) {
32
- callback(null, file);
33
- return;
34
- }
35
- if (file.isStream()) {
36
- callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
37
- return;
38
- }
39
- if (!validExtensions.has(node.path.extname(file.path).toLowerCase())) {
40
- BalmJS.logger.info(PLUGIN_NAME, `Skipping unsupported image "${file.relative}"`);
41
- callback(null, file);
42
- return;
43
- }
44
- const plugins = customPlugins ?? getDefaultPlugins();
45
- (async () => {
46
- try {
47
- const data = await imagemin.buffer(file.contents, {
48
- plugins: plugins
49
- });
50
- const originalSize = file.contents.length;
51
- const optimizedSize = data.length;
52
- const saved = originalSize - optimizedSize;
53
- const percent = originalSize > 0 ? saved / originalSize * 100 : 0;
54
- const savedMessage = `saved ${prettyBytes(saved)} - ${percent.toFixed(1).replace(/\.0$/, '')}%`;
55
- const message = saved > 0 ? savedMessage : 'already optimized';
56
- if (saved > 0) {
57
- totalBytes += originalSize;
58
- totalSavedBytes += saved;
59
- totalFiles++;
60
- }
61
- BalmJS.logger.debug(PLUGIN_NAME, `${file.relative} (${message})`);
62
- file.contents = Buffer.from(data);
63
- callback(null, file);
64
- } catch (error) {
65
- callback(new PluginError(PLUGIN_NAME, error, {
66
- fileName: file.path
67
- }));
68
- }
69
- })();
70
- }
71
- function flush(callback) {
72
- const percent = totalBytes > 0 ? totalSavedBytes / totalBytes * 100 : 0;
73
- let message = `Minified ${totalFiles} image${totalFiles > 1 ? 's' : ''}`;
74
- if (totalFiles > 0) {
75
- message += ` (saved ${prettyBytes(totalSavedBytes)} - ${percent.toFixed(1).replace(/\.0$/, '')}%)`;
76
- }
77
- BalmJS.logger.info(PLUGIN_NAME, message);
78
- callback();
79
- }
80
- return through2Concurrent.obj({
81
- maxConcurrency: 8
82
- }, transform, flush);
83
- }
84
- const gifsicle = exposePlugin('gifsicle');
85
- const mozjpeg = exposePlugin('mozjpeg');
86
- const optipng = exposePlugin('optipng');
87
- const svgo = exposePlugin('svgo');
88
- const getDefaultImagePlugins = () => ({
89
- gif: gifsicle(),
90
- jpeg: mozjpeg(),
91
- png: optipng(),
92
- svg: svgo()
93
- });
94
- export default gulpImagemin;
95
- export { getDefaultImagePlugins };
@@ -1,27 +0,0 @@
1
- import htmlmin from './htmlmin.js';
2
- import imagemin from './imagemin.js';
3
- import jsmin from './jsmin.js';
4
- import less from './less.js';
5
- import plumber from './plumber.js';
6
- import postcss from './postcss.js';
7
- import postcssPlugins from './postcss-plugins.js';
8
- import rename from './rename.js';
9
- import replace from './replace.js';
10
- import sass from './sass.js';
11
- import legacySass from './sass-legacy.js';
12
- import sftp from './sftp.js';
13
- const plugins = {
14
- htmlmin,
15
- imagemin,
16
- jsmin,
17
- less,
18
- plumber,
19
- postcss,
20
- postcssPlugins,
21
- rename,
22
- replace,
23
- sass,
24
- legacySass,
25
- sftp
26
- };
27
- BalmJS.plugins = plugins;
@@ -1,37 +0,0 @@
1
- import { minify } from 'terser';
2
- const PLUGIN_NAME = 'jsmin';
3
- async function jsMinify(file, opts, cb) {
4
- const extname = node.path.extname(file.path);
5
- if (extname === '.js') {
6
- const code = {};
7
- let content = file.contents.toString();
8
- code[node.path.basename(file.path)] = content;
9
- try {
10
- const result = await minify(code, opts);
11
- content = result.code;
12
- file.contents = Buffer.from(content);
13
- cb(null, file);
14
- } catch (e) {
15
- const error = new PluginError(PLUGIN_NAME, e);
16
- cb(error);
17
- }
18
- } else {
19
- BalmJS.logger.error(PLUGIN_NAME, 'Invalid JS file');
20
- }
21
- return file;
22
- }
23
- function gulpJsmin(options) {
24
- options = BalmJS.utils.deepMerge({}, options);
25
- function transform(chunk, encoding, callback) {
26
- if (chunk.isStream()) {
27
- return this.emit('error', new PluginError(PLUGIN_NAME, 'Streams not supported'));
28
- }
29
- if (chunk.isNull()) {
30
- callback(null, chunk);
31
- return;
32
- }
33
- jsMinify(chunk, options, callback);
34
- }
35
- return through2.obj(transform);
36
- }
37
- export default gulpJsmin;
@@ -1,97 +0,0 @@
1
- // Reference `gulp-less@5.0.0`
2
-
3
- import less from 'less';
4
- import replaceExtension from 'replace-ext';
5
- import applySourceMap from 'vinyl-sourcemaps-apply';
6
- const PLUGIN_NAME = 'less';
7
- function inlineSources(sourcemap) {
8
- if (sourcemap.sourcesContent) {
9
- return Promise.resolve(sourcemap);
10
- }
11
- return Promise.all(sourcemap.sources.map(source => {
12
- return new Promise((resolve, reject) => {
13
- node.fs.readFile(source, 'utf8', (err, data) => {
14
- if (err) {
15
- reject(err);
16
- } else {
17
- resolve(data);
18
- }
19
- });
20
- });
21
- })).then(contents => {
22
- sourcemap.sourcesContent = contents;
23
- return sourcemap;
24
- }, () => sourcemap);
25
- }
26
- function renderLess(input, options) {
27
- return new Promise((resolve, reject) => {
28
- less.render(input, options, (error, output) => {
29
- if (error) {
30
- reject(error);
31
- } else {
32
- const {
33
- css,
34
- imports
35
- } = output;
36
- const result = {
37
- css,
38
- imports
39
- };
40
- if (options.sourceMap && output.map) {
41
- result.sourcemap = JSON.parse(output.map);
42
- inlineSources(result.sourcemap).then(map => {
43
- result.sourcemap = map;
44
- resolve(result);
45
- });
46
- } else {
47
- resolve(result);
48
- }
49
- }
50
- });
51
- });
52
- }
53
- function gulpLess(customOptions) {
54
- // Mixes in default options.
55
- const options = Object.assign({}, {
56
- compress: false,
57
- paths: []
58
- }, customOptions);
59
- return through2.obj((file, enc, cb) => {
60
- if (file.isNull()) {
61
- return cb(null, file);
62
- }
63
- if (file.isStream()) {
64
- return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
65
- }
66
- const input = file.contents.toString();
67
-
68
- // Injects the path of the current file
69
- options.filename = file.path;
70
-
71
- // Bootstrap source maps
72
- if (file.sourceMap || options.sourcemap) {
73
- options.sourceMap = true;
74
- }
75
- renderLess(input, options).then(output => {
76
- file.contents = Buffer.from(output.css);
77
- file.path = replaceExtension(file.path, '.css');
78
- if (output.sourcemap) {
79
- output.sourcemap.file = file.relative;
80
- output.sourcemap.sources = output.sourcemap.sources.map(source => node.path.relative(file.base, source));
81
- applySourceMap(file, output.sourcemap);
82
- }
83
- return file;
84
- }).then(file => {
85
- cb(null, file);
86
- }).catch(err => {
87
- // Convert the keys so PluginError can read them
88
- err.lineNumber = err.line;
89
- err.fileName = err.filename;
90
-
91
- // Add a better error message
92
- err.message = `${err.message} in file ${err.fileName} line no.${err.lineNumber}`;
93
- return cb(new PluginError(PLUGIN_NAME, err));
94
- });
95
- });
96
- }
97
- export default gulpLess;
@@ -1,87 +0,0 @@
1
- // Reference `gulp-plumber@1.2.1`
2
- import { EventEmitter } from 'node:events';
3
- const PLUGIN_NAME = 'plumber';
4
- const emitter = new EventEmitter();
5
- function removeDefaultHandler(stream, event) {
6
- let found = false;
7
- stream.listeners(event).forEach(function (item) {
8
- if (item.name === `on${event}`) {
9
- found = item;
10
- this.removeListener(event, item);
11
- }
12
- }, stream);
13
- return found;
14
- }
15
- function wrapPanicOnErrorHandler(stream) {
16
- const oldHandler = removeDefaultHandler(stream, 'error');
17
- if (oldHandler) {
18
- stream.on('error', function onerror2(error) {
19
- if (emitter.listenerCount('error') === 1) {
20
- this.removeListener('error', onerror2);
21
- oldHandler.call(stream, error);
22
- }
23
- });
24
- }
25
- }
26
- function defaultErrorHandler(error) {
27
- // onerror2 and this handler
28
- if (emitter.listenerCount('error') < 3) {
29
- BalmJS.logger.error(`${PLUGIN_NAME} - found unhandled error`, error.toString());
30
- }
31
- }
32
- function gulpPlumber(opts = {}) {
33
- if (BalmJS.utils.isFunction(opts)) {
34
- opts = {
35
- errorHandler: opts
36
- };
37
- }
38
- const through = through2.obj();
39
- through._plumber = true;
40
- if (opts.errorHandler !== false) {
41
- through.errorHandler = BalmJS.utils.isFunction(opts.errorHandler) ? opts.errorHandler : defaultErrorHandler;
42
- }
43
- function patchPipe(stream) {
44
- if (stream.pipe2) {
45
- wrapPanicOnErrorHandler(stream);
46
- stream._pipe = stream._pipe || stream.pipe;
47
- stream.pipe = stream.pipe2;
48
- stream._plumbed = true;
49
- }
50
- }
51
- through.pipe2 = function pipe2(dest) {
52
- if (!dest) {
53
- throw new PluginError(PLUGIN_NAME, "Can't pipe to undefined");
54
- }
55
- this._pipe(dest);
56
- if (dest._unplumbed) {
57
- return dest;
58
- }
59
- removeDefaultHandler(this, 'error');
60
- if (dest._plumber) {
61
- return dest;
62
- }
63
- dest.pipe2 = pipe2;
64
-
65
- // Patching pipe method
66
- if (opts.inherit !== false) {
67
- patchPipe(dest);
68
- }
69
-
70
- // Placing custom on error handler
71
- if (this.errorHandler) {
72
- dest.errorHandler = this.errorHandler;
73
- dest.on('error', this.errorHandler.bind(dest));
74
- }
75
- dest._plumbed = true;
76
- return dest;
77
- };
78
- patchPipe(through);
79
- return through;
80
- }
81
- function stop() {
82
- const through = through2.obj();
83
- through._unplumbed = true;
84
- return through;
85
- }
86
- export default gulpPlumber;
87
- export { stop };
@@ -1,13 +0,0 @@
1
- import atImport from 'postcss-import';
2
- import postcssFlexbugsFixes from 'postcss-flexbugs-fixes';
3
- import postcssPresetEnv from 'postcss-preset-env';
4
- import autoprefixer from 'autoprefixer';
5
- import cssnano from 'cssnano';
6
- function getDefaultPostcssPlugins(isPostCSS = false, useTailwind = false) {
7
- const defaultPostcssPlugins = isPostCSS || BalmJS.config.styles.extname === 'css' ? [...(useTailwind ? ['tailwindcss'] : []), atImport({
8
- path: BalmJS.file.stylePaths
9
- }), postcssFlexbugsFixes(), postcssPresetEnv(BalmJS.config.styles.postcssEnvOptions)] : [];
10
- const cssnanoPlugin = BalmJS.config.env.isProd || BalmJS.config.styles.minify ? [cssnano(BalmJS.config.styles.options)] : [];
11
- return defaultPostcssPlugins.concat([autoprefixer(), ...cssnanoPlugin, ...BalmJS.config.styles.postcssPlugins]);
12
- }
13
- export default getDefaultPostcssPlugins;
@@ -1,117 +0,0 @@
1
- // Reference `gulp-postcss@10.0.0`
2
- import { Transform } from 'node:stream';
3
- import postcss from 'postcss';
4
- import postcssLoadConfig from 'postcss-load-config';
5
- import applySourceMap from 'vinyl-sourcemaps-apply';
6
- const PLUGIN_NAME = 'postcss';
7
- function gulpPostcss(cb) {
8
- return function (plugins, options) {
9
- if (Array.isArray(plugins)) {
10
- return cb(() => Promise.resolve({
11
- plugins: plugins,
12
- options: options
13
- }));
14
- } else if (typeof plugins === 'function') {
15
- return cb(file => Promise.resolve(plugins(file)));
16
- } else {
17
- const contextOptions = plugins || {};
18
- return cb(file => {
19
- let configPath;
20
- if (contextOptions.config) {
21
- if (node.path.isAbsolute(contextOptions.config)) {
22
- configPath = contextOptions.config;
23
- } else {
24
- configPath = node.path.join(file.base, contextOptions.config);
25
- }
26
- } else {
27
- configPath = file.dirname;
28
- }
29
- const ctx = {
30
- file,
31
- options: contextOptions // @TODO: The options property is deprecated and should be removed
32
- };
33
- return postcssLoadConfig(ctx, configPath);
34
- });
35
- }
36
- };
37
- }
38
- export default gulpPostcss(loadConfig => {
39
- const stream = new Transform({
40
- objectMode: true
41
- });
42
- stream._transform = function (file, encoding, cb) {
43
- if (file.isNull()) {
44
- return cb(null, file);
45
- }
46
- if (file.isStream()) {
47
- return handleError('Streams are not supported!');
48
- }
49
-
50
- // Protect `from` and `map` if using gulp-sourcemaps
51
- const isProtected = file.sourceMap ? {
52
- from: true,
53
- map: true
54
- } : {};
55
- const options = {
56
- from: file.path,
57
- to: file.path,
58
- // Generate a separate source map for gulp-sourcemaps
59
- map: file.sourceMap ? {
60
- annotation: false
61
- } : false
62
- };
63
- loadConfig(file).then(function (config) {
64
- const configOpts = config.options || {};
65
- // Extend the default options if not protected
66
- for (const opt in configOpts) {
67
- if (Object.prototype.hasOwnProperty.call(configOpts, opt) && !isProtected[opt]) {
68
- options[opt] = configOpts[opt];
69
- } else {
70
- BalmJS.logger.info(PLUGIN_NAME, `${file.relative}\nCannot override ${opt} option, because it is required by gulp-sourcemaps`);
71
- }
72
- }
73
- return postcss(config.plugins || []).process(file.contents, options);
74
- }).then(handleResult, handleError);
75
- function handleResult(result) {
76
- let map;
77
- const warnings = result.warnings().join('\n');
78
- file.contents = Buffer.from(result.css);
79
-
80
- // Apply source map to the chain
81
- if (file.sourceMap) {
82
- map = result.map.toJSON();
83
- map.file = file.relative;
84
- map.sources = [].map.call(map.sources, function (source) {
85
- return node.path.join(node.path.dirname(file.relative), source);
86
- });
87
- applySourceMap(file, map);
88
- }
89
- if (warnings) {
90
- BalmJS.logger.info(PLUGIN_NAME, `${file.relative}\nwarnings`);
91
- }
92
- setImmediate(function () {
93
- cb(null, file);
94
- });
95
- }
96
- function handleError(error) {
97
- const errorOptions = {
98
- fileName: file.path,
99
- showStack: true
100
- };
101
- if (error.name === 'CssSyntaxError') {
102
- errorOptions.error = error;
103
- errorOptions.fileName = error.file || file.path;
104
- errorOptions.lineNumber = error.line;
105
- errorOptions.showProperties = false;
106
- errorOptions.showStack = false;
107
- error = `${error.message}\n\n${error.showSourceCode()}\n`;
108
- }
109
- // Prevent stream’s unhandled exception from
110
- // being suppressed by Promise
111
- setImmediate(function () {
112
- cb(new PluginError(PLUGIN_NAME, error, errorOptions));
113
- });
114
- }
115
- };
116
- return stream;
117
- });
@@ -1,51 +0,0 @@
1
- // Reference `gulp-rename@2.0.0`
2
- import { Transform } from 'node:stream';
3
- function gulpRename(obj, options = {}) {
4
- const stream = new Transform({
5
- objectMode: true
6
- });
7
- const parsePath = _path => {
8
- const extname = options.multiExt ? node.path.basename(_path).slice(node.path.basename(_path).indexOf('.')) : node.path.extname(_path);
9
- return {
10
- dirname: node.path.dirname(_path),
11
- basename: node.path.basename(_path, extname),
12
- extname: extname
13
- };
14
- };
15
- stream._transform = (chunk, unused, callback) => {
16
- const file = chunk.clone();
17
- let parsedPath = parsePath(file.relative);
18
- let _path;
19
- const type = typeof obj;
20
- if (type === 'string' && obj !== '') {
21
- _path = obj;
22
- } else if (type === 'function') {
23
- const newParsedPath = obj(parsedPath, file);
24
- if (typeof newParsedPath === 'object' && newParsedPath !== null) {
25
- parsedPath = newParsedPath;
26
- }
27
- _path = node.path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
28
- } else if (type === 'object' && obj !== undefined && obj !== null) {
29
- const _obj = obj;
30
- const dirname = _obj.dirname || parsedPath.dirname;
31
- const prefix = _obj.prefix || '';
32
- const suffix = _obj.suffix || '';
33
- const basename = _obj.basename || parsedPath.basename;
34
- const extname = _obj.extname || parsedPath.extname;
35
- const filename = prefix + basename + suffix + extname;
36
- _path = node.path.join(dirname, filename);
37
- } else {
38
- callback(new Error('Unsupported renaming parameter type supplied'), undefined);
39
- return;
40
- }
41
- file.path = node.path.join(file.base, _path);
42
-
43
- // Rename sourcemap if present
44
- if (file.sourceMap) {
45
- file.sourceMap.file = file.relative;
46
- }
47
- callback(null, file);
48
- };
49
- return stream;
50
- }
51
- export default gulpRename;
@@ -1,91 +0,0 @@
1
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- // Reference `gulp-replace@1.1.4`
7
- import { Transform } from 'node:stream';
8
- // @ts-ignore
9
- import * as isTextModule from 'istextorbinary';
10
- import rs from '../utilities/replacestream.js';
11
- const isText = isTextModule.isText || isTextModule;
12
- const defaultOptions = {
13
- skipBinary: true
14
- };
15
- function gulpReplace(search, _replacement, options = {}) {
16
- // merge options
17
- options = _objectSpread(_objectSpread({}, defaultOptions), options);
18
- return new Transform({
19
- objectMode: true,
20
- /**
21
- * transformation
22
- * @param {import("vinyl")} file
23
- * @param {BufferEncoding} enc
24
- * @param {(error?: Error | null, data?: any) => void} callback
25
- */
26
- transform: (file, encoding, callback) => {
27
- if (file.isNull()) {
28
- return callback(null, file);
29
- }
30
- let replacement = _replacement;
31
- if (typeof _replacement === 'function') {
32
- // Pass the vinyl file object as this.file
33
- replacement = _replacement.bind({
34
- file: file
35
- });
36
- }
37
- function doReplace() {
38
- if (file.isStream()) {
39
- file.contents = file.contents.pipe(rs(search, replacement));
40
- return callback(null, file);
41
- }
42
- if (file.isBuffer()) {
43
- const content = file.contents.toString();
44
- if (search instanceof RegExp) {
45
- file.contents = Buffer.from(content.replace(search, replacement));
46
- } else {
47
- const chunks = content.split(search);
48
- let result;
49
- if (typeof replacement === 'function') {
50
- // Start with the first chunk already in the result
51
- // Replacements will be added thereafter
52
- // This is done to avoid checking the value of i in the loop
53
- result = [chunks[0]];
54
-
55
- // The replacement function should be called once for each match
56
- for (let i = 1; i < chunks.length; i++) {
57
- // Add the replacement value
58
- result.push(replacement(search));
59
-
60
- // Add the next chunk
61
- result.push(chunks[i]);
62
- }
63
- result = result.join('');
64
- } else {
65
- result = chunks.join(replacement);
66
- }
67
- file.contents = Buffer.from(result);
68
- }
69
- return callback(null, file);
70
- }
71
- callback(null, file);
72
- }
73
- if (options.skipBinary) {
74
- // fix@istextorbinary: "editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening."
75
- const isNode16 = process.version.split('.')[0] === 'v16';
76
- if (isNode16) {
77
- doReplace();
78
- } else {
79
- if (isText(file.path, file.contents)) {
80
- doReplace();
81
- } else {
82
- callback(null, file);
83
- }
84
- }
85
- return;
86
- }
87
- doReplace();
88
- }
89
- });
90
- }
91
- export default gulpReplace;