balm-core 5.0.2 → 5.2.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.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +9 -0
  3. package/lib/config/globals.js +14 -1
  4. package/lib/plugins/htmlmin.js +4 -3
  5. package/lib/plugins/imagemin.js +15 -10
  6. package/lib/plugins/index.js +2 -0
  7. package/lib/plugins/postcss.js +2 -2
  8. package/lib/plugins/rename.js +1 -3
  9. package/lib/plugins/replace.js +3 -1
  10. package/lib/plugins/sass-legacy.js +131 -0
  11. package/lib/plugins/sass.js +66 -125
  12. package/lib/plugins/sftp.js +7 -5
  13. package/lib/tasks/foundation/balm.js +4 -4
  14. package/lib/tasks/foundation/balm_style.js +1 -2
  15. package/lib/tasks/private/cache.js +7 -4
  16. package/lib/tasks/private/image.js +2 -2
  17. package/lib/tasks/private/pwa-cache.js +10 -4
  18. package/lib/tasks/public/publish.js +9 -3
  19. package/lib/tasks/public/pwa.js +22 -7
  20. package/lib/tasks/public/sass.js +1 -2
  21. package/package.json +48 -49
  22. package/tslib/balm.js +5 -8
  23. package/tslib/config/globals.js +21 -1
  24. package/tslib/plugins/htmlmin.js +4 -3
  25. package/tslib/plugins/imagemin.js +15 -10
  26. package/tslib/plugins/index.js +2 -0
  27. package/tslib/plugins/rename.js +1 -1
  28. package/tslib/plugins/replace.js +2 -1
  29. package/tslib/plugins/sass-legacy.js +95 -0
  30. package/tslib/plugins/sass.js +62 -124
  31. package/tslib/plugins/sftp.js +7 -4
  32. package/tslib/tasks/foundation/balm.js +12 -10
  33. package/tslib/tasks/foundation/balm_style.js +3 -2
  34. package/tslib/tasks/private/build.js +7 -7
  35. package/tslib/tasks/private/cache.js +14 -11
  36. package/tslib/tasks/private/clean.js +28 -31
  37. package/tslib/tasks/private/end.js +8 -8
  38. package/tslib/tasks/private/extra.js +7 -7
  39. package/tslib/tasks/private/font.js +4 -4
  40. package/tslib/tasks/private/image.js +16 -16
  41. package/tslib/tasks/private/lint.js +9 -9
  42. package/tslib/tasks/private/media.js +4 -4
  43. package/tslib/tasks/private/modernizr.js +40 -43
  44. package/tslib/tasks/private/pwa-cache.js +21 -13
  45. package/tslib/tasks/private/sprite.js +36 -39
  46. package/tslib/tasks/private/start.js +7 -7
  47. package/tslib/tasks/private/workbox-sw.js +4 -4
  48. package/tslib/tasks/public/html.js +23 -26
  49. package/tslib/tasks/public/publish.js +19 -16
  50. package/tslib/tasks/public/pwa.js +23 -6
  51. package/tslib/tasks/public/remove.js +8 -11
  52. package/tslib/tasks/public/sass.js +1 -2
  53. package/tslib/tasks/public/server.js +34 -37
  54. package/tslib/tasks/public/url.js +16 -19
  55. package/tslib/utilities/compiling.js +4 -9
  56. package/tslib/utilities/loading.js +8 -14
  57. package/tslib/utilities/logger.js +13 -18
@@ -1,31 +1,29 @@
1
- var _UrlTask_urlProcessing;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  class UrlTask extends BalmJS.BalmTask {
4
2
  constructor() {
5
3
  super('url');
6
- _UrlTask_urlProcessing.set(this, (type) => {
7
- const pattern = BalmJS.config.paths.source[type]
8
- .split('/')
9
- .pop();
10
- const pathSrc = new RegExp(`\\.{2}/${pattern}/`, 'g');
11
- const pathDest = `../${BalmJS.config.paths.target[type]}/`;
12
- BalmJS.logger.debug(`${this.name} task`, {
13
- regex: pathSrc,
14
- replacement: pathDest
15
- }, {
16
- pre: true
17
- });
18
- return BalmJS.plugins.replace(pathSrc, pathDest);
19
- });
20
4
  this.defaultOutput = BalmJS.config.dest.css;
21
5
  this.defaultInput = BalmJS.file.matchAllFiles(this.defaultOutput, '*.css');
22
6
  }
7
+ #urlProcessing = (type) => {
8
+ const pattern = BalmJS.config.paths.source[type]
9
+ .split('/')
10
+ .pop();
11
+ const pathSrc = new RegExp(`\\.{2}/${pattern}/`, 'g');
12
+ const pathDest = `../${BalmJS.config.paths.target[type]}/`;
13
+ BalmJS.logger.debug(`${this.name} task`, {
14
+ regex: pathSrc,
15
+ replacement: pathDest
16
+ }, {
17
+ pre: true
18
+ });
19
+ return BalmJS.plugins.replace(pathSrc, pathDest);
20
+ };
23
21
  recipe(input, output) {
24
22
  const balmUrl = () => {
25
23
  this.init(input, output);
26
24
  return this.src
27
- .pipe(__classPrivateFieldGet(this, _UrlTask_urlProcessing, "f").call(this, 'img'))
28
- .pipe(__classPrivateFieldGet(this, _UrlTask_urlProcessing, "f").call(this, 'font'))
25
+ .pipe(this.#urlProcessing('img'))
26
+ .pipe(this.#urlProcessing('font'))
29
27
  .pipe(gulp.dest(this.output));
30
28
  };
31
29
  return balmUrl;
@@ -34,5 +32,4 @@ class UrlTask extends BalmJS.BalmTask {
34
32
  return this.recipe();
35
33
  }
36
34
  }
37
- _UrlTask_urlProcessing = new WeakMap();
38
35
  export default UrlTask;
@@ -1,21 +1,16 @@
1
- var _BalmCompiling_firstCompile;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import loading from './loading.js';
4
2
  class BalmCompiling {
5
- constructor() {
6
- _BalmCompiling_firstCompile.set(this, true);
7
- }
3
+ #firstCompile = true;
8
4
  start() {
9
- if (!BalmJS.useCacache && __classPrivateFieldGet(this, _BalmCompiling_firstCompile, "f")) {
5
+ if (!BalmJS.useCacache && this.#firstCompile) {
10
6
  loading.render('Compiling to JS...');
11
7
  }
12
8
  }
13
9
  stop() {
14
- if (!BalmJS.useCacache && __classPrivateFieldGet(this, _BalmCompiling_firstCompile, "f")) {
15
- __classPrivateFieldSet(this, _BalmCompiling_firstCompile, false, "f");
10
+ if (!BalmJS.useCacache && this.#firstCompile) {
11
+ this.#firstCompile = false;
16
12
  loading.clear();
17
13
  }
18
14
  }
19
15
  }
20
- _BalmCompiling_firstCompile = new WeakMap();
21
16
  export default new BalmCompiling();
@@ -1,31 +1,25 @@
1
- var _BalmLoading_stream, _BalmLoading_frameIndex, _BalmLoading_frameCount;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import readline from 'readline';
4
2
  import spinner from '../config/spinner.js';
5
3
  class BalmLoading {
6
- constructor() {
7
- _BalmLoading_stream.set(this, process.stderr);
8
- _BalmLoading_frameIndex.set(this, 0);
9
- _BalmLoading_frameCount.set(this, spinner.frames.length);
10
- }
4
+ #stream = process.stderr;
5
+ #frameIndex = 0;
6
+ #frameCount = spinner.frames.length;
11
7
  get frame() {
12
- var _a;
13
- const currentFrame = spinner.frames[__classPrivateFieldGet(this, _BalmLoading_frameIndex, "f")];
14
- __classPrivateFieldSet(this, _BalmLoading_frameIndex, __classPrivateFieldSet(this, _BalmLoading_frameIndex, (_a = __classPrivateFieldGet(this, _BalmLoading_frameIndex, "f"), ++_a), "f") % __classPrivateFieldGet(this, _BalmLoading_frameCount, "f"), "f");
8
+ const currentFrame = spinner.frames[this.#frameIndex];
9
+ this.#frameIndex = ++this.#frameIndex % this.#frameCount;
15
10
  return currentFrame;
16
11
  }
17
12
  clear() {
18
- readline.clearLine(__classPrivateFieldGet(this, _BalmLoading_stream, "f"), 0);
19
- readline.cursorTo(__classPrivateFieldGet(this, _BalmLoading_stream, "f"), 0);
13
+ readline.clearLine(this.#stream, 0);
14
+ readline.cursorTo(this.#stream, 0);
20
15
  }
21
16
  render(text = `${this.frame} BalmJS is initializing...`) {
22
17
  this.clear();
23
- __classPrivateFieldGet(this, _BalmLoading_stream, "f").write(text);
18
+ this.#stream.write(text);
24
19
  }
25
20
  succeed() {
26
21
  this.clear();
27
22
  console.log(`BalmJS core version: ${BalmJS.version}`);
28
23
  }
29
24
  }
30
- _BalmLoading_stream = new WeakMap(), _BalmLoading_frameIndex = new WeakMap(), _BalmLoading_frameCount = new WeakMap();
31
25
  export default new BalmLoading();
@@ -1,5 +1,3 @@
1
- var _Logger_log;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import util from 'node:util';
4
2
  import fancyLog from 'fancy-log';
5
3
  import color from './color.js';
@@ -39,23 +37,21 @@ const LOG = {
39
37
  end: '^'.padEnd(36, '.')
40
38
  };
41
39
  class Logger {
42
- constructor() {
43
- _Logger_log.set(this, (obj, pre = false) => {
44
- const options = Object.assign({
45
- showHidden: false,
46
- depth: 2,
47
- colors: true
48
- }, BalmJS.config.logs.formatOptions);
49
- return pre ? util.inspect(obj, options) : obj;
50
- });
51
- }
40
+ #log = (obj, pre = false) => {
41
+ const options = Object.assign({
42
+ showHidden: false,
43
+ depth: 2,
44
+ colors: true
45
+ }, BalmJS.config.logs.formatOptions);
46
+ return pre ? util.inspect(obj, options) : obj;
47
+ };
52
48
  success(label, message, options = {}) {
53
49
  const logOptions = Object.assign({
54
50
  logLevel: BalmJS.LogLevel.Trace
55
51
  }, options);
56
52
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
57
53
  console.log(LOG.beginning);
58
- fancyLog(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.OK), __classPrivateFieldGet(this, _Logger_log, "f").call(this, message, logOptions.pre));
54
+ fancyLog(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.OK), this.#log(message, logOptions.pre));
59
55
  console.log(LOG.end);
60
56
  }
61
57
  }
@@ -64,7 +60,7 @@ class Logger {
64
60
  logLevel: BalmJS.LogLevel.Debug
65
61
  }, options);
66
62
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
67
- fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.DEBUG), __classPrivateFieldGet(this, _Logger_log, "f").call(this, message, logOptions.pre));
63
+ fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.DEBUG), this.#log(message, logOptions.pre));
68
64
  }
69
65
  }
70
66
  info(label, message, options = {}) {
@@ -72,7 +68,7 @@ class Logger {
72
68
  logLevel: BalmJS.LogLevel.Info
73
69
  }, options);
74
70
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
75
- fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.INFO), __classPrivateFieldGet(this, _Logger_log, "f").call(this, message, logOptions.pre));
71
+ fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.INFO), this.#log(message, logOptions.pre));
76
72
  }
77
73
  }
78
74
  warn(label, message, options = {}) {
@@ -80,7 +76,7 @@ class Logger {
80
76
  logLevel: BalmJS.LogLevel.Warn
81
77
  }, options);
82
78
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
83
- fancyLog.warn(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.WARN), __classPrivateFieldGet(this, _Logger_log, "f").call(this, message, logOptions.pre));
79
+ fancyLog.warn(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.WARN), this.#log(message, logOptions.pre));
84
80
  }
85
81
  }
86
82
  error(label, message, options = {}) {
@@ -89,9 +85,8 @@ class Logger {
89
85
  pre: false
90
86
  }, options);
91
87
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
92
- fancyLog.error(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.ERROR), __classPrivateFieldGet(this, _Logger_log, "f").call(this, message, logOptions.pre));
88
+ fancyLog.error(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.ERROR), this.#log(message, logOptions.pre));
93
89
  }
94
90
  }
95
91
  }
96
- _Logger_log = new WeakMap();
97
92
  export default new Logger();