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,57 +1,54 @@
1
- var _ModernizrTask_readConfig, _ModernizrTask_createDir, _ModernizrTask_generateScript;
2
- import { __classPrivateFieldGet } from "tslib";
3
1
  import { build } from 'modernizr';
4
2
  class ModernizrTask extends BalmJS.BalmTask {
5
3
  constructor() {
6
4
  super('modernizr');
7
- _ModernizrTask_readConfig.set(this, () => {
8
- return new Promise((resolve, reject) => {
9
- node.fs.readFile(this.input, 'utf8', (err, data) => {
10
- if (err)
11
- reject(err);
12
- resolve(JSON.parse(data));
13
- });
5
+ this.defaultInput = `${this.name}.json`;
6
+ this.defaultOutput = node.path.join(BalmJS.config.dest.js, `${this.name}.js`);
7
+ }
8
+ #readConfig = () => {
9
+ return new Promise((resolve, reject) => {
10
+ node.fs.readFile(this.input, 'utf8', (err, data) => {
11
+ if (err)
12
+ reject(err);
13
+ resolve(JSON.parse(data));
14
+ });
15
+ });
16
+ };
17
+ #createDir = () => {
18
+ return new Promise((resolve, reject) => {
19
+ node.fs.mkdir(BalmJS.file.absPath(BalmJS.config.dest.js), { recursive: true }, (err) => {
20
+ if (err)
21
+ reject(err);
22
+ resolve();
14
23
  });
15
24
  });
16
- _ModernizrTask_createDir.set(this, () => {
17
- return new Promise((resolve, reject) => {
18
- node.fs.mkdir(BalmJS.file.absPath(BalmJS.config.dest.js), { recursive: true }, (err) => {
25
+ };
26
+ #generateScript = (config) => {
27
+ return new Promise((resolve, reject) => {
28
+ build(config, (content) => {
29
+ node.fs.writeFile(this.output, content, (err) => {
19
30
  if (err)
20
31
  reject(err);
21
- resolve();
32
+ resolve(content);
22
33
  });
23
34
  });
24
35
  });
25
- _ModernizrTask_generateScript.set(this, (config) => {
26
- return new Promise((resolve, reject) => {
27
- build(config, (content) => {
28
- node.fs.writeFile(this.output, content, (err) => {
29
- if (err)
30
- reject(err);
31
- resolve(content);
32
- });
33
- });
36
+ };
37
+ fn = async (callback) => {
38
+ this.init();
39
+ if (node.fs.existsSync(this.input)) {
40
+ const [config] = await Promise.all([
41
+ this.#readConfig(),
42
+ this.#createDir()
43
+ ]);
44
+ await this.#generateScript(config);
45
+ }
46
+ else {
47
+ BalmJS.logger.warn(`${this.name} task`, `The '${this.input}' does not exist`, {
48
+ logLevel: BalmJS.LogLevel.Info
34
49
  });
35
- });
36
- this.fn = async (callback) => {
37
- this.init();
38
- if (node.fs.existsSync(this.input)) {
39
- const [config] = await Promise.all([
40
- __classPrivateFieldGet(this, _ModernizrTask_readConfig, "f").call(this),
41
- __classPrivateFieldGet(this, _ModernizrTask_createDir, "f").call(this)
42
- ]);
43
- await __classPrivateFieldGet(this, _ModernizrTask_generateScript, "f").call(this, config);
44
- }
45
- else {
46
- BalmJS.logger.warn(`${this.name} task`, `The '${this.input}' does not exist`, {
47
- logLevel: BalmJS.LogLevel.Info
48
- });
49
- }
50
- callback();
51
- };
52
- this.defaultInput = `${this.name}.json`;
53
- this.defaultOutput = node.path.join(BalmJS.config.dest.js, `${this.name}.js`);
54
- }
50
+ }
51
+ callback();
52
+ };
55
53
  }
56
- _ModernizrTask_readConfig = new WeakMap(), _ModernizrTask_createDir = new WeakMap(), _ModernizrTask_generateScript = new WeakMap();
57
54
  export default ModernizrTask;
@@ -2,23 +2,31 @@ 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
  }
19
8
  clear() {
20
- const swOrigin = BalmJS.file.absPath(node.path.join(BalmJS.config.dest.base, BalmJS.config.pwa.swSrcFilename));
21
- deleteAsync(swOrigin, { force: true });
9
+ if (BalmJS.config.pwa.swSrcFilename !== BalmJS.config.pwa.swDestFilename) {
10
+ const swOrigin = BalmJS.file.absPath(node.path.join(BalmJS.config.dest.base, BalmJS.config.pwa.swSrcFilename));
11
+ deleteAsync(swOrigin, { force: true });
12
+ }
22
13
  }
14
+ fn = () => {
15
+ this.init();
16
+ const swDest = typeof this.input === 'string' && this.input
17
+ ? BalmJS.file.absPath(this.input)
18
+ : '';
19
+ if (!swDest || !node.fs.existsSync(swDest)) {
20
+ return Promise.resolve();
21
+ }
22
+ const newVersion = BalmJS.config.pwa.version || Date.now().toString();
23
+ BalmJS.logger.info('pwa - version', newVersion);
24
+ const stream = this.src
25
+ .pipe(BalmJS.plugins.replace('{{ version }}', newVersion))
26
+ .pipe($.if(BalmJS.config.env.isProd, BalmJS.plugins.jsmin(BalmJS.config.scripts.minifyOptions)))
27
+ .pipe(gulp.dest(this.output));
28
+ this.clear();
29
+ return stream;
30
+ };
23
31
  }
24
32
  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,7 +62,7 @@ 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
68
  .src(spriteConfig.input, { encoding: false })
@@ -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,39 @@
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
+ let srcPath;
13
+ let destPath;
14
+ if (input && output) {
15
+ srcPath = BalmJS.file.absPaths(node.path.join(BalmJS.config.dest.base, input));
16
+ destPath = BalmJS.file.absPath(node.path.join(BalmJS.config.assets.root, output));
17
+ }
18
+ else {
19
+ this.init();
20
+ srcPath = this.input;
21
+ destPath = this.output;
22
+ }
23
+ return gulp
24
+ .src(srcPath, { allowEmpty: true })
25
+ .pipe($.if(!BalmJS.utils.isArray(srcPath), BalmJS.plugins.rename(renameOptions)))
26
+ .pipe(gulp.dest(destPath));
27
+ };
24
28
  recipe(input, output, renameOptions) {
25
29
  const balmPublish = (callback) => {
26
30
  if (BalmJS.config.env.isProd) {
27
31
  if (BalmJS.utils.isArray(input)) {
28
- const tasks = input.map((template) => __classPrivateFieldGet(this, _PublishTask_release, "f").call(this, template.input, template.output, template.renameOptions));
32
+ const tasks = input.map((template) => this.#release(template.input, template.output, template.renameOptions));
29
33
  return mergeStream(...tasks);
30
34
  }
31
35
  else {
32
- return __classPrivateFieldGet(this, _PublishTask_release, "f").call(this, input, output, renameOptions);
36
+ return this.#release(input, output, renameOptions);
33
37
  }
34
38
  }
35
39
  else {
@@ -43,5 +47,4 @@ class PublishTask extends BalmJS.BalmTask {
43
47
  callback();
44
48
  }
45
49
  }
46
- _PublishTask_release = new WeakMap();
47
50
  export default PublishTask;
@@ -46,14 +46,31 @@ class PwaTask extends BalmJS.BalmTask {
46
46
  const workboxBuild = mode === 'generateSW'
47
47
  ? generateSW(options)
48
48
  : injectManifest(options);
49
- await workboxBuild
50
- .then(({ count, size }) => {
49
+ try {
50
+ const { count, size } = await workboxBuild;
51
51
  BalmJS.logger.info(`pwa - ${mode}`, `Generated '${swDest}', which will precache ${count} files, totaling ${size} bytes`);
52
- gulp.parallel(BalmJS.toNamespace('pwa-cache'))();
53
- })
54
- .catch((err) => {
52
+ await new Promise((resolve) => {
53
+ const pwaCacheTask = BalmJS.tasks.get('pwa-cache');
54
+ if (pwaCacheTask) {
55
+ const stream = pwaCacheTask.fn();
56
+ if (stream && typeof stream.on === 'function') {
57
+ stream.on('finish', resolve).on('error', () => resolve());
58
+ }
59
+ else if (stream && typeof stream.then === 'function') {
60
+ stream.then(resolve, resolve);
61
+ }
62
+ else {
63
+ resolve();
64
+ }
65
+ }
66
+ else {
67
+ resolve();
68
+ }
69
+ });
70
+ }
71
+ catch (err) {
55
72
  BalmJS.logger.warn(`pwa - ${mode}`, `Service worker generation failed: ${err}`);
56
- });
73
+ }
57
74
  callback();
58
75
  }
59
76
  else {
@@ -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;