balm-core 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +7 -0
  3. package/lib/balm.js +2 -2
  4. package/lib/bundler/webpack/config/env.js +1 -1
  5. package/lib/config/globals.js +14 -1
  6. package/lib/plugins/imagemin.js +13 -8
  7. package/lib/plugins/index.js +2 -0
  8. package/lib/plugins/postcss.js +2 -2
  9. package/lib/plugins/rename.js +1 -3
  10. package/lib/plugins/replace.js +4 -2
  11. package/lib/plugins/sass-legacy.js +131 -0
  12. package/lib/plugins/sass.js +66 -125
  13. package/lib/tasks/foundation/balm.js +3 -2
  14. package/lib/tasks/foundation/balm_style.js +1 -1
  15. package/lib/tasks/private/build.js +1 -1
  16. package/lib/tasks/private/cache.js +1 -1
  17. package/lib/tasks/private/clean.js +3 -3
  18. package/lib/tasks/private/end.js +1 -1
  19. package/lib/tasks/private/extra.js +1 -1
  20. package/lib/tasks/private/font.js +1 -1
  21. package/lib/tasks/private/image.js +3 -2
  22. package/lib/tasks/private/lint.js +1 -1
  23. package/lib/tasks/private/media.js +1 -1
  24. package/lib/tasks/private/modernizr.js +3 -3
  25. package/lib/tasks/private/pwa-cache.js +1 -1
  26. package/lib/tasks/private/sprite.js +5 -3
  27. package/lib/tasks/private/start.js +1 -1
  28. package/lib/tasks/private/workbox-sw.js +1 -1
  29. package/lib/tasks/public/html.js +2 -2
  30. package/lib/tasks/public/publish.js +2 -2
  31. package/lib/tasks/public/remove.js +2 -2
  32. package/lib/tasks/public/sass.js +1 -2
  33. package/lib/tasks/public/server.js +2 -2
  34. package/lib/tasks/public/url.js +2 -2
  35. package/lib/utilities/compiling.js +2 -2
  36. package/lib/utilities/loading.js +2 -2
  37. package/lib/utilities/logger.js +2 -2
  38. package/package.json +53 -52
  39. package/tslib/balm.js +5 -8
  40. package/tslib/config/globals.js +21 -1
  41. package/tslib/plugins/imagemin.js +13 -8
  42. package/tslib/plugins/index.js +2 -0
  43. package/tslib/plugins/rename.js +1 -1
  44. package/tslib/plugins/replace.js +2 -1
  45. package/tslib/plugins/sass-legacy.js +95 -0
  46. package/tslib/plugins/sass.js +62 -124
  47. package/tslib/tasks/foundation/balm.js +10 -7
  48. package/tslib/tasks/foundation/balm_style.js +3 -1
  49. package/tslib/tasks/private/build.js +7 -7
  50. package/tslib/tasks/private/cache.js +10 -10
  51. package/tslib/tasks/private/clean.js +28 -31
  52. package/tslib/tasks/private/end.js +8 -8
  53. package/tslib/tasks/private/extra.js +7 -7
  54. package/tslib/tasks/private/font.js +4 -4
  55. package/tslib/tasks/private/image.js +16 -15
  56. package/tslib/tasks/private/lint.js +9 -9
  57. package/tslib/tasks/private/media.js +4 -4
  58. package/tslib/tasks/private/modernizr.js +40 -43
  59. package/tslib/tasks/private/pwa-cache.js +11 -11
  60. package/tslib/tasks/private/sprite.js +37 -40
  61. package/tslib/tasks/private/start.js +7 -7
  62. package/tslib/tasks/private/workbox-sw.js +4 -4
  63. package/tslib/tasks/public/html.js +23 -26
  64. package/tslib/tasks/public/publish.js +13 -16
  65. package/tslib/tasks/public/remove.js +8 -11
  66. package/tslib/tasks/public/sass.js +1 -2
  67. package/tslib/tasks/public/server.js +34 -37
  68. package/tslib/tasks/public/url.js +16 -19
  69. package/tslib/utilities/compiling.js +4 -9
  70. package/tslib/utilities/loading.js +8 -14
  71. package/tslib/utilities/logger.js +13 -18
@@ -2,17 +2,6 @@ import { deleteAsync } from 'del';
2
2
  class PwaCacheTask extends BalmJS.BalmTask {
3
3
  constructor() {
4
4
  super('pwa-cache');
5
- this.fn = () => {
6
- this.init();
7
- const newVersion = BalmJS.config.pwa.version || Date.now().toString();
8
- BalmJS.logger.info('pwa - version', newVersion);
9
- const stream = this.src
10
- .pipe(BalmJS.plugins.replace('{{ version }}', newVersion))
11
- .pipe($.if(BalmJS.config.env.isProd, BalmJS.plugins.jsmin(BalmJS.config.scripts.minifyOptions)))
12
- .pipe(gulp.dest(this.output));
13
- this.clear();
14
- return stream;
15
- };
16
5
  this.defaultOutput = BalmJS.config.dest.base;
17
6
  this.defaultInput = node.path.join(this.defaultOutput, BalmJS.config.pwa.swDestFilename);
18
7
  }
@@ -20,5 +9,16 @@ class PwaCacheTask extends BalmJS.BalmTask {
20
9
  const swOrigin = BalmJS.file.absPath(node.path.join(BalmJS.config.dest.base, BalmJS.config.pwa.swSrcFilename));
21
10
  deleteAsync(swOrigin, { force: true });
22
11
  }
12
+ fn = () => {
13
+ this.init();
14
+ const newVersion = BalmJS.config.pwa.version || Date.now().toString();
15
+ BalmJS.logger.info('pwa - version', newVersion);
16
+ const stream = this.src
17
+ .pipe(BalmJS.plugins.replace('{{ version }}', newVersion))
18
+ .pipe($.if(BalmJS.config.env.isProd, BalmJS.plugins.jsmin(BalmJS.config.scripts.minifyOptions)))
19
+ .pipe(gulp.dest(this.output));
20
+ this.clear();
21
+ return stream;
22
+ };
23
23
  }
24
24
  export default PwaCacheTask;
@@ -1,42 +1,8 @@
1
- var _SpriteTask_tasks, _SpriteTask_getParams;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import mergeStream from '../../utilities/merge-stream.js';
4
2
  class SpriteTask extends BalmJS.BalmTask {
3
+ #tasks = [];
5
4
  constructor() {
6
5
  super('sprite');
7
- _SpriteTask_tasks.set(this, []);
8
- _SpriteTask_getParams.set(this, (spriteItem, spriteOptions) => {
9
- const stylesConfig = Object.assign(spriteOptions, BalmJS.config.styles);
10
- const spriteName = `${spriteItem.folderName}-${this.name}s`;
11
- const imageTarget = stylesConfig.imageTarget || BalmJS.config.paths.target.img;
12
- let defaultParams = Object.assign({
13
- padding: 1
14
- }, {
15
- imgName: `${spriteName}.png`,
16
- cssName: `_${spriteItem.folderName}.${stylesConfig.extname}`,
17
- imgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}.png`,
18
- cssVarMap: (sprite) => {
19
- sprite.name = `${spriteItem.folderName}-${sprite.name}`;
20
- },
21
- cssSpritesheetName: `${spriteItem.folderName}-spritesheet`,
22
- cssOpts: {
23
- cssSelector: (sprite) => `.${sprite.name}`
24
- }
25
- });
26
- if (stylesConfig.spriteRetina) {
27
- defaultParams = Object.assign(defaultParams, {
28
- retinaSrcFilter: `${spriteItem.retinaSrc}`,
29
- retinaImgName: `${spriteName}@2x.png`,
30
- retinaImgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}@2x.png`,
31
- cssVarMap: (sprite) => {
32
- sprite.name = `${spriteItem.folderName}-${sprite.name}`;
33
- },
34
- cssRetinaSpritesheetName: `${spriteItem.folderName}-spritesheet-2x`,
35
- cssRetinaGroupsName: `${spriteItem.folderName}-retina-groups`
36
- });
37
- }
38
- return Object.assign(defaultParams, stylesConfig.spriteParams);
39
- });
40
6
  this.defaultInput = BalmJS.config.styles.sprites;
41
7
  this.defaultOutput = BalmJS.config.dest.img;
42
8
  if (this.defaultInput.length) {
@@ -44,6 +10,38 @@ class SpriteTask extends BalmJS.BalmTask {
44
10
  this.collect();
45
11
  }
46
12
  }
13
+ #getParams = (spriteItem, spriteOptions) => {
14
+ const stylesConfig = Object.assign(spriteOptions, BalmJS.config.styles);
15
+ const spriteName = `${spriteItem.folderName}-${this.name}s`;
16
+ const imageTarget = stylesConfig.imageTarget || BalmJS.config.paths.target.img;
17
+ let defaultParams = Object.assign({
18
+ padding: 1
19
+ }, {
20
+ imgName: `${spriteName}.png`,
21
+ cssName: `_${spriteItem.folderName}.${stylesConfig.extname}`,
22
+ imgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}.png`,
23
+ cssVarMap: (sprite) => {
24
+ sprite.name = `${spriteItem.folderName}-${sprite.name}`;
25
+ },
26
+ cssSpritesheetName: `${spriteItem.folderName}-spritesheet`,
27
+ cssOpts: {
28
+ cssSelector: (sprite) => `.${sprite.name}`
29
+ }
30
+ });
31
+ if (stylesConfig.spriteRetina) {
32
+ defaultParams = Object.assign(defaultParams, {
33
+ retinaSrcFilter: `${spriteItem.retinaSrc}`,
34
+ retinaImgName: `${spriteName}@2x.png`,
35
+ retinaImgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}@2x.png`,
36
+ cssVarMap: (sprite) => {
37
+ sprite.name = `${spriteItem.folderName}-${sprite.name}`;
38
+ },
39
+ cssRetinaSpritesheetName: `${spriteItem.folderName}-spritesheet-2x`,
40
+ cssRetinaGroupsName: `${spriteItem.folderName}-retina-groups`
41
+ });
42
+ }
43
+ return Object.assign(defaultParams, stylesConfig.spriteParams);
44
+ };
47
45
  collect(spriteOptions = {}) {
48
46
  const spriteList = [];
49
47
  for (const spriteName of this.input) {
@@ -64,10 +62,10 @@ class SpriteTask extends BalmJS.BalmTask {
64
62
  BalmJS.logger.debug(`${this.name} task`, spriteConfig, {
65
63
  pre: true
66
64
  });
67
- spriteConfig.params = __classPrivateFieldGet(this, _SpriteTask_getParams, "f").call(this, spriteItem, spriteOptions);
65
+ spriteConfig.params = this.#getParams(spriteItem, spriteOptions);
68
66
  gulp.task(BalmJS.toNamespace(spriteTaskName), () => {
69
67
  const spriteData = gulp
70
- .src(spriteConfig.input)
68
+ .src(spriteConfig.input, { encoding: false })
71
69
  .pipe(BalmJS.plugins.plumber((error) => {
72
70
  BalmJS.logger.error(`${this.name} task`, error.message);
73
71
  }))
@@ -76,7 +74,7 @@ class SpriteTask extends BalmJS.BalmTask {
76
74
  const cssStream = spriteData.css.pipe(gulp.dest(spriteConfig.cssOutput));
77
75
  return mergeStream(imgStream, cssStream);
78
76
  });
79
- __classPrivateFieldGet(this, _SpriteTask_tasks, "f").push(spriteTaskName);
77
+ this.#tasks.push(spriteTaskName);
80
78
  }
81
79
  }
82
80
  recipe(input, output, spriteOptions = {}) {
@@ -89,8 +87,7 @@ class SpriteTask extends BalmJS.BalmTask {
89
87
  }
90
88
  }
91
89
  get deps() {
92
- return __classPrivateFieldGet(this, _SpriteTask_tasks, "f");
90
+ return this.#tasks;
93
91
  }
94
92
  }
95
- _SpriteTask_tasks = new WeakMap(), _SpriteTask_getParams = new WeakMap();
96
93
  export default SpriteTask;
@@ -1,13 +1,13 @@
1
1
  class StartTask extends BalmJS.BalmTask {
2
2
  constructor() {
3
3
  super('start');
4
- this.fn = async (callback) => {
5
- BalmJS.start = process.hrtime();
6
- if (BalmJS.utils.isFunction(BalmJS.beforeTask)) {
7
- await BalmJS.beforeTask();
8
- }
9
- callback();
10
- };
11
4
  }
5
+ fn = async (callback) => {
6
+ BalmJS.start = process.hrtime();
7
+ if (BalmJS.utils.isFunction(BalmJS.beforeTask)) {
8
+ await BalmJS.beforeTask();
9
+ }
10
+ callback();
11
+ };
12
12
  }
13
13
  export default StartTask;
@@ -1,15 +1,15 @@
1
1
  class WorkboxSwTask extends BalmJS.BalmTask {
2
2
  constructor() {
3
3
  super('workbox-sw');
4
- this.fn = () => {
5
- this.init();
6
- return this.src.pipe(gulp.dest(this.output));
7
- };
8
4
  this.defaultInput = [
9
5
  BalmJS.config.pwa.workboxSw,
10
6
  `${BalmJS.config.pwa.workboxSw}.map`
11
7
  ];
12
8
  this.defaultOutput = BalmJS.config.dest.base;
13
9
  }
10
+ fn = () => {
11
+ this.init();
12
+ return this.src.pipe(gulp.dest(this.output));
13
+ };
14
14
  }
15
15
  export default WorkboxSwTask;
@@ -1,33 +1,31 @@
1
- var _HtmlTask_updateAssetsPath, _HtmlTask_hasSourcePath;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import { PUBLIC_URL } from '../../config/constants.js';
4
2
  class HtmlTask extends BalmJS.BalmTask {
5
3
  constructor() {
6
4
  super('html');
7
- _HtmlTask_updateAssetsPath.set(this, (type) => {
8
- const isManifest = type === 'manifest';
9
- const assetsType = isManifest ? 'img' : type;
10
- const from = BalmJS.config.paths.source[assetsType];
11
- const to = BalmJS.file.assetsPath(BalmJS.config.paths.target[assetsType]);
12
- const assetsPathSrc = new RegExp(isManifest ? `/?${from}` : `${PUBLIC_URL}/${from}`, 'g');
13
- const assetsPathDest = `${PUBLIC_URL}/${to}`;
14
- BalmJS.logger.debug(`${this.name} task - assets path`, {
15
- regex: assetsPathSrc,
16
- replacement: assetsPathDest
17
- }, {
18
- pre: true
19
- });
20
- return BalmJS.plugins.replace(assetsPathSrc, assetsPathDest);
21
- });
22
- _HtmlTask_hasSourcePath.set(this, (type) => {
23
- return !!BalmJS.config.paths.source[type];
24
- });
25
5
  this.defaultInput = [
26
6
  node.path.join(BalmJS.file.templateBasePath, '*.html'),
27
7
  node.path.join(BalmJS.file.templateBasePath, BalmJS.config.pwa.manifest)
28
8
  ];
29
9
  this.defaultOutput = BalmJS.config.dest.base;
30
10
  }
11
+ #updateAssetsPath = (type) => {
12
+ const isManifest = type === 'manifest';
13
+ const assetsType = isManifest ? 'img' : type;
14
+ const from = BalmJS.config.paths.source[assetsType];
15
+ const to = BalmJS.file.assetsPath(BalmJS.config.paths.target[assetsType]);
16
+ const assetsPathSrc = new RegExp(isManifest ? `/?${from}` : `${PUBLIC_URL}/${from}`, 'g');
17
+ const assetsPathDest = `${PUBLIC_URL}/${to}`;
18
+ BalmJS.logger.debug(`${this.name} task - assets path`, {
19
+ regex: assetsPathSrc,
20
+ replacement: assetsPathDest
21
+ }, {
22
+ pre: true
23
+ });
24
+ return BalmJS.plugins.replace(assetsPathSrc, assetsPathDest);
25
+ };
26
+ #hasSourcePath = (type) => {
27
+ return !!BalmJS.config.paths.source[type];
28
+ };
31
29
  recipe(input, output) {
32
30
  const balmHtml = () => {
33
31
  this.init(input, output);
@@ -46,9 +44,9 @@ class HtmlTask extends BalmJS.BalmTask {
46
44
  ['css', 'js', 'img', 'media', 'manifest'].forEach((type) => {
47
45
  const canUpdate = type === 'manifest'
48
46
  ? BalmJS.config.pwa.enabled
49
- : __classPrivateFieldGet(this, _HtmlTask_hasSourcePath, "f").call(this, type);
47
+ : this.#hasSourcePath(type);
50
48
  if (canUpdate) {
51
- stream = stream.pipe(__classPrivateFieldGet(this, _HtmlTask_updateAssetsPath, "f").call(this, type));
49
+ stream = stream.pipe(this.#updateAssetsPath(type));
52
50
  }
53
51
  });
54
52
  stream = BalmJS.config.assets.cache
@@ -58,10 +56,10 @@ class HtmlTask extends BalmJS.BalmTask {
58
56
  else {
59
57
  ['css', 'js', 'img', 'media'].forEach((type, index) => {
60
58
  const canUpdate = index > 1
61
- ? __classPrivateFieldGet(this, _HtmlTask_hasSourcePath, "f").call(this, type) && !BalmJS.config.inFrontend
62
- : __classPrivateFieldGet(this, _HtmlTask_hasSourcePath, "f").call(this, type);
59
+ ? this.#hasSourcePath(type) && !BalmJS.config.inFrontend
60
+ : this.#hasSourcePath(type);
63
61
  if (canUpdate) {
64
- stream = stream.pipe(__classPrivateFieldGet(this, _HtmlTask_updateAssetsPath, "f").call(this, type));
62
+ stream = stream.pipe(this.#updateAssetsPath(type));
65
63
  }
66
64
  });
67
65
  stream = stream.pipe(BalmJS.file.setPublicPath());
@@ -74,5 +72,4 @@ class HtmlTask extends BalmJS.BalmTask {
74
72
  return this.recipe();
75
73
  }
76
74
  }
77
- _HtmlTask_updateAssetsPath = new WeakMap(), _HtmlTask_hasSourcePath = new WeakMap();
78
75
  export default HtmlTask;
@@ -1,35 +1,33 @@
1
- var _PublishTask_release;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import mergeStream from '../../utilities/merge-stream.js';
4
2
  class PublishTask extends BalmJS.BalmTask {
5
3
  constructor() {
6
4
  super('publish');
7
- _PublishTask_release.set(this, (input, output, renameOptions = {}) => {
8
- if (input && output) {
9
- this.init(node.path.join(BalmJS.config.dest.base, input), node.path.join(BalmJS.config.assets.root, output));
10
- }
11
- else {
12
- this.init();
13
- }
14
- return this.src
15
- .pipe($.if(!BalmJS.utils.isArray(this.input), BalmJS.plugins.rename(renameOptions)))
16
- .pipe(gulp.dest(this.output));
17
- });
18
5
  this.defaultInput = [
19
6
  BalmJS.file.matchAllFiles(BalmJS.config.dest.static),
20
7
  node.path.join(`!${BalmJS.config.dest.base}`, '*.*')
21
8
  ];
22
9
  this.defaultOutput = BalmJS.config.assets.static;
23
10
  }
11
+ #release = (input, output, renameOptions = {}) => {
12
+ if (input && output) {
13
+ this.init(node.path.join(BalmJS.config.dest.base, input), node.path.join(BalmJS.config.assets.root, output));
14
+ }
15
+ else {
16
+ this.init();
17
+ }
18
+ return this.src
19
+ .pipe($.if(!BalmJS.utils.isArray(this.input), BalmJS.plugins.rename(renameOptions)))
20
+ .pipe(gulp.dest(this.output));
21
+ };
24
22
  recipe(input, output, renameOptions) {
25
23
  const balmPublish = (callback) => {
26
24
  if (BalmJS.config.env.isProd) {
27
25
  if (BalmJS.utils.isArray(input)) {
28
- const tasks = input.map((template) => __classPrivateFieldGet(this, _PublishTask_release, "f").call(this, template.input, template.output, template.renameOptions));
26
+ const tasks = input.map((template) => this.#release(template.input, template.output, template.renameOptions));
29
27
  return mergeStream(...tasks);
30
28
  }
31
29
  else {
32
- return __classPrivateFieldGet(this, _PublishTask_release, "f").call(this, input, output, renameOptions);
30
+ return this.#release(input, output, renameOptions);
33
31
  }
34
32
  }
35
33
  else {
@@ -43,5 +41,4 @@ class PublishTask extends BalmJS.BalmTask {
43
41
  callback();
44
42
  }
45
43
  }
46
- _PublishTask_release = new WeakMap();
47
44
  export default PublishTask;
@@ -1,23 +1,21 @@
1
- var _RemoveTask_getFiles;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import { deleteAsync } from 'del';
4
2
  class RemoveTask extends BalmJS.BalmTask {
5
3
  constructor() {
6
4
  super('remove');
7
- _RemoveTask_getFiles.set(this, (input) => {
8
- let files = BalmJS.file.absPaths(input);
9
- files = BalmJS.utils.isArray(input)
10
- ? files.map((file) => file.replace(/\\/g, '/'))
11
- : files.replace(/\\/g, '/');
12
- return files;
13
- });
14
5
  }
6
+ #getFiles = (input) => {
7
+ let files = BalmJS.file.absPaths(input);
8
+ files = BalmJS.utils.isArray(input)
9
+ ? files.map((file) => file.replace(/\\/g, '/'))
10
+ : files.replace(/\\/g, '/');
11
+ return files;
12
+ };
15
13
  recipe(input) {
16
14
  const balmRemove = async (callback) => {
17
15
  const canDel = !!((BalmJS.utils.isString(input) && input.trim()) ||
18
16
  (BalmJS.utils.isArray(input) && input.length));
19
17
  if (canDel) {
20
- const files = __classPrivateFieldGet(this, _RemoveTask_getFiles, "f").call(this, input);
18
+ const files = this.#getFiles(input);
21
19
  BalmJS.logger.debug(`${this.name} task`, {
22
20
  files
23
21
  }, {
@@ -43,5 +41,4 @@ class RemoveTask extends BalmJS.BalmTask {
43
41
  callback();
44
42
  }
45
43
  }
46
- _RemoveTask_getFiles = new WeakMap();
47
44
  export default RemoveTask;
@@ -1,10 +1,9 @@
1
- import { isLegacy } from '../../plugins/sass.js';
2
1
  class SassTask extends BalmJS.BalmStyleTask {
3
2
  constructor() {
4
3
  super('sass');
5
4
  }
6
5
  get options() {
7
- return Object.assign(isLegacy
6
+ return Object.assign(node.isLegacySass
8
7
  ? {
9
8
  includePaths: BalmJS.file.stylePaths,
10
9
  outputStyle: 'expanded'
@@ -1,43 +1,8 @@
1
- var _ServerTask_watchTask, _ServerTask_onWatch;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import detectPort from '../../utilities/detect-port.js';
4
2
  import getMiddlewares from '../../middlewares/index.js';
5
3
  class ServerTask extends BalmJS.BalmTask {
6
4
  constructor() {
7
5
  super('serve');
8
- _ServerTask_watchTask.set(this, (taskName, serverReload = false) => {
9
- const balmTask = BalmJS.tasks.get(taskName).fn;
10
- const reload = (done) => {
11
- server.reload();
12
- done();
13
- };
14
- return serverReload ? gulp.series(balmTask, reload) : balmTask;
15
- });
16
- _ServerTask_onWatch.set(this, () => {
17
- const { watch } = gulp;
18
- const watchOptions = {
19
- cwd: BalmJS.config.workspace
20
- };
21
- watch([
22
- `${BalmJS.config.src.img}/**/*`,
23
- `${BalmJS.config.dest.font}/**/*`,
24
- ...BalmJS.config.server.extraWatchFiles
25
- ], watchOptions).on('change', server.reload);
26
- watch(`${BalmJS.file.templateBasePath}/*.html`, watchOptions, __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, 'html', true));
27
- watch(`${BalmJS.config.src.css}/**/*.${BalmJS.config.styles.extname}`, watchOptions, __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, BalmJS.config.inFrontend ? this.styleName : 'style'));
28
- if (!BalmJS.config.server.useHMR) {
29
- watch(`${BalmJS.config.src.js}/**/*`, watchOptions, __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, BalmJS.config.scripts.bundler, true));
30
- }
31
- watch(`${BalmJS.config.src.base}/modernizr.json`, watchOptions, __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, 'modernizr'));
32
- watch(`${BalmJS.config.src.font}/**/*`, watchOptions, __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, 'font'));
33
- if (BalmJS.config.ftp.watchFiles.length) {
34
- watch(BalmJS.config.ftp.watchFiles, watchOptions).on('change', (path) => {
35
- BalmJS.logger.debug(`${this.name} task`, `File ${path} was changed`);
36
- BalmJS.watchFtpFile = path;
37
- __classPrivateFieldGet(this, _ServerTask_watchTask, "f").call(this, 'ftp', true)();
38
- });
39
- }
40
- });
41
6
  if (BalmJS.config.env.isDev) {
42
7
  detectPort(BalmJS.config.server.port, BalmJS.config.server.host).then((port) => {
43
8
  if (BalmJS.config.server.port !== port) {
@@ -47,6 +12,39 @@ class ServerTask extends BalmJS.BalmTask {
47
12
  }, () => { });
48
13
  }
49
14
  }
15
+ #watchTask = (taskName, serverReload = false) => {
16
+ const balmTask = BalmJS.tasks.get(taskName).fn;
17
+ const reload = (done) => {
18
+ server.reload();
19
+ done();
20
+ };
21
+ return serverReload ? gulp.series(balmTask, reload) : balmTask;
22
+ };
23
+ #onWatch = () => {
24
+ const { watch } = gulp;
25
+ const watchOptions = {
26
+ cwd: BalmJS.config.workspace
27
+ };
28
+ watch([
29
+ `${BalmJS.config.src.img}/**/*`,
30
+ `${BalmJS.config.dest.font}/**/*`,
31
+ ...BalmJS.config.server.extraWatchFiles
32
+ ], watchOptions).on('change', server.reload);
33
+ watch(`${BalmJS.file.templateBasePath}/*.html`, watchOptions, this.#watchTask('html', true));
34
+ watch(`${BalmJS.config.src.css}/**/*.${BalmJS.config.styles.extname}`, watchOptions, this.#watchTask(BalmJS.config.inFrontend ? this.styleName : 'style'));
35
+ if (!BalmJS.config.server.useHMR) {
36
+ watch(`${BalmJS.config.src.js}/**/*`, watchOptions, this.#watchTask(BalmJS.config.scripts.bundler, true));
37
+ }
38
+ watch(`${BalmJS.config.src.base}/modernizr.json`, watchOptions, this.#watchTask('modernizr'));
39
+ watch(`${BalmJS.config.src.font}/**/*`, watchOptions, this.#watchTask('font'));
40
+ if (BalmJS.config.ftp.watchFiles.length) {
41
+ watch(BalmJS.config.ftp.watchFiles, watchOptions).on('change', (path) => {
42
+ BalmJS.logger.debug(`${this.name} task`, `File ${path} was changed`);
43
+ BalmJS.watchFtpFile = path;
44
+ this.#watchTask('ftp', true)();
45
+ });
46
+ }
47
+ };
50
48
  recipe(customHandler) {
51
49
  const balmServe = (callback) => {
52
50
  if (BalmJS.server) {
@@ -102,7 +100,7 @@ class ServerTask extends BalmJS.BalmTask {
102
100
  if (BalmJS.config.env.isDev) {
103
101
  BalmJS.server = server.init(bsOptions);
104
102
  if (BalmJS.config.useDefaults) {
105
- __classPrivateFieldGet(this, _ServerTask_onWatch, "f").call(this);
103
+ this.#onWatch();
106
104
  }
107
105
  else {
108
106
  BalmJS.watching = true;
@@ -128,5 +126,4 @@ class ServerTask extends BalmJS.BalmTask {
128
126
  return this.recipe();
129
127
  }
130
128
  }
131
- _ServerTask_watchTask = new WeakMap(), _ServerTask_onWatch = new WeakMap();
132
129
  export default ServerTask;
@@ -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();