balm-core 5.0.2 → 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.
- package/README.md +1 -1
- package/index.d.ts +7 -0
- package/lib/config/globals.js +14 -1
- package/lib/plugins/imagemin.js +15 -10
- package/lib/plugins/index.js +2 -0
- package/lib/plugins/postcss.js +2 -2
- package/lib/plugins/rename.js +1 -3
- package/lib/plugins/replace.js +3 -1
- package/lib/plugins/sass-legacy.js +131 -0
- package/lib/plugins/sass.js +66 -125
- package/lib/tasks/foundation/balm.js +2 -2
- package/lib/tasks/foundation/balm_style.js +1 -2
- package/lib/tasks/private/cache.js +0 -5
- package/lib/tasks/private/image.js +2 -2
- package/lib/tasks/public/sass.js +1 -2
- package/package.json +46 -46
- package/tslib/balm.js +5 -8
- package/tslib/config/globals.js +21 -1
- package/tslib/plugins/imagemin.js +15 -10
- package/tslib/plugins/index.js +2 -0
- package/tslib/plugins/rename.js +1 -1
- package/tslib/plugins/replace.js +2 -1
- package/tslib/plugins/sass-legacy.js +95 -0
- package/tslib/plugins/sass.js +62 -124
- package/tslib/tasks/foundation/balm.js +10 -8
- package/tslib/tasks/foundation/balm_style.js +3 -2
- package/tslib/tasks/private/build.js +7 -7
- package/tslib/tasks/private/cache.js +10 -13
- package/tslib/tasks/private/clean.js +28 -31
- package/tslib/tasks/private/end.js +8 -8
- package/tslib/tasks/private/extra.js +7 -7
- package/tslib/tasks/private/font.js +4 -4
- package/tslib/tasks/private/image.js +16 -16
- package/tslib/tasks/private/lint.js +9 -9
- package/tslib/tasks/private/media.js +4 -4
- package/tslib/tasks/private/modernizr.js +40 -43
- package/tslib/tasks/private/pwa-cache.js +11 -11
- package/tslib/tasks/private/sprite.js +36 -39
- package/tslib/tasks/private/start.js +7 -7
- package/tslib/tasks/private/workbox-sw.js +4 -4
- package/tslib/tasks/public/html.js +23 -26
- package/tslib/tasks/public/publish.js +13 -16
- package/tslib/tasks/public/remove.js +8 -11
- package/tslib/tasks/public/sass.js +1 -2
- package/tslib/tasks/public/server.js +34 -37
- package/tslib/tasks/public/url.js +16 -19
- package/tslib/utilities/compiling.js +4 -9
- package/tslib/utilities/loading.js +8 -14
- package/tslib/utilities/logger.js +13 -18
|
@@ -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
|
-
:
|
|
47
|
+
: this.#hasSourcePath(type);
|
|
50
48
|
if (canUpdate) {
|
|
51
|
-
stream = stream.pipe(
|
|
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
|
-
?
|
|
62
|
-
:
|
|
59
|
+
? this.#hasSourcePath(type) && !BalmJS.config.inFrontend
|
|
60
|
+
: this.#hasSourcePath(type);
|
|
63
61
|
if (canUpdate) {
|
|
64
|
-
stream = stream.pipe(
|
|
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) =>
|
|
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
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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(
|
|
28
|
-
.pipe(
|
|
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
|
-
|
|
6
|
-
_BalmCompiling_firstCompile.set(this, true);
|
|
7
|
-
}
|
|
3
|
+
#firstCompile = true;
|
|
8
4
|
start() {
|
|
9
|
-
if (!BalmJS.useCacache &&
|
|
5
|
+
if (!BalmJS.useCacache && this.#firstCompile) {
|
|
10
6
|
loading.render('Compiling to JS...');
|
|
11
7
|
}
|
|
12
8
|
}
|
|
13
9
|
stop() {
|
|
14
|
-
if (!BalmJS.useCacache &&
|
|
15
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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(
|
|
19
|
-
readline.cursorTo(
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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),
|
|
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),
|
|
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),
|
|
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),
|
|
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),
|
|
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();
|