balm-core 4.11.0 → 4.12.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 (108) hide show
  1. package/lib/balm.js +0 -20
  2. package/lib/bootstrap/check_config.js +6 -9
  3. package/lib/bootstrap/index.js +16 -22
  4. package/lib/bundler/esbuild/build.js +0 -2
  5. package/lib/bundler/esbuild/index.js +0 -2
  6. package/lib/bundler/esbuild/transform.js +0 -4
  7. package/lib/bundler/rollup/build.js +2 -4
  8. package/lib/bundler/rollup/entry.js +2 -5
  9. package/lib/bundler/rollup/index.js +0 -3
  10. package/lib/bundler/rollup/output.js +0 -5
  11. package/lib/bundler/rollup/plugins.js +0 -10
  12. package/lib/bundler/webpack/config/common.js +4 -15
  13. package/lib/bundler/webpack/config/dev.js +2 -3
  14. package/lib/bundler/webpack/config/env.js +12 -14
  15. package/lib/bundler/webpack/config/index.js +0 -2
  16. package/lib/bundler/webpack/config/prod.js +4 -7
  17. package/lib/bundler/webpack/entry.js +8 -12
  18. package/lib/bundler/webpack/index.js +2 -5
  19. package/lib/bundler/webpack/loaders.js +0 -6
  20. package/lib/bundler/webpack/output.js +0 -5
  21. package/lib/bundler/webpack/rules/asset.js +2 -3
  22. package/lib/bundler/webpack/rules/babel.js +3 -4
  23. package/lib/bundler/webpack/rules/css.js +4 -10
  24. package/lib/bundler/webpack/rules/html.js +0 -2
  25. package/lib/config/assets.js +0 -5
  26. package/lib/config/env.js +0 -2
  27. package/lib/config/globals.js +2 -5
  28. package/lib/config/index.js +0 -5
  29. package/lib/config/logs.js +0 -1
  30. package/lib/config/paths.js +3 -3
  31. package/lib/config/pwa.js +0 -3
  32. package/lib/config/roots.js +0 -2
  33. package/lib/config/scripts.js +20 -28
  34. package/lib/config/server.js +4 -10
  35. package/lib/config/styles.js +2 -10
  36. package/lib/hello.js +0 -2
  37. package/lib/hooks/index.js +18 -35
  38. package/lib/hooks/maker.js +0 -14
  39. package/lib/middlewares/history.js +0 -2
  40. package/lib/middlewares/index.js +0 -4
  41. package/lib/middlewares/proxy.js +0 -6
  42. package/lib/middlewares/webpack.js +0 -5
  43. package/lib/plugins/htmlmin.js +1 -7
  44. package/lib/plugins/imagemin.js +1 -18
  45. package/lib/plugins/jsmin.js +0 -10
  46. package/lib/plugins/less.js +7 -14
  47. package/lib/plugins/plumber.js +4 -21
  48. package/lib/plugins/postcss-plugins.js +0 -2
  49. package/lib/plugins/postcss.js +8 -21
  50. package/lib/plugins/rename.js +2 -13
  51. package/lib/plugins/replace.js +4 -22
  52. package/lib/plugins/sass.js +30 -39
  53. package/lib/plugins/sftp.js +33 -62
  54. package/lib/tasks/default.js +10 -19
  55. package/lib/tasks/foundation/balm.js +0 -25
  56. package/lib/tasks/foundation/balm_style.js +2 -15
  57. package/lib/tasks/foundation/index.js +0 -2
  58. package/lib/tasks/index.js +8 -7
  59. package/lib/tasks/private/build.js +0 -5
  60. package/lib/tasks/private/cache.js +0 -6
  61. package/lib/tasks/private/clean.js +0 -20
  62. package/lib/tasks/private/end.js +0 -6
  63. package/lib/tasks/private/extra.js +4 -11
  64. package/lib/tasks/private/font.js +0 -5
  65. package/lib/tasks/private/image.js +0 -11
  66. package/lib/tasks/private/lint.js +0 -5
  67. package/lib/tasks/private/media.js +0 -5
  68. package/lib/tasks/private/modernizr.js +0 -19
  69. package/lib/tasks/private/pwa-cache.js +0 -7
  70. package/lib/tasks/private/script.js +0 -3
  71. package/lib/tasks/private/sprite.js +3 -25
  72. package/lib/tasks/private/start.js +0 -6
  73. package/lib/tasks/private/style.js +0 -3
  74. package/lib/tasks/private/workbox-sw.js +0 -5
  75. package/lib/tasks/public/copy.js +0 -5
  76. package/lib/tasks/public/esbuild.js +0 -6
  77. package/lib/tasks/public/ftp.js +0 -11
  78. package/lib/tasks/public/html.js +0 -20
  79. package/lib/tasks/public/jsmin.js +0 -6
  80. package/lib/tasks/public/less.js +0 -6
  81. package/lib/tasks/public/postcss.js +0 -5
  82. package/lib/tasks/public/publish.js +3 -15
  83. package/lib/tasks/public/pwa.js +0 -13
  84. package/lib/tasks/public/remove.js +2 -18
  85. package/lib/tasks/public/replace.js +0 -7
  86. package/lib/tasks/public/rollup.js +0 -6
  87. package/lib/tasks/public/sass.js +0 -6
  88. package/lib/tasks/public/server.js +4 -32
  89. package/lib/tasks/public/url.js +0 -13
  90. package/lib/tasks/public/version.js +0 -6
  91. package/lib/tasks/public/webpack.js +2 -12
  92. package/lib/tasks/public/zip.js +0 -5
  93. package/lib/utilities/address.js +5 -16
  94. package/lib/utilities/cache-core.js +5 -13
  95. package/lib/utilities/color.js +0 -5
  96. package/lib/utilities/compiling.js +0 -14
  97. package/lib/utilities/detect-port.js +6 -22
  98. package/lib/utilities/escape-string-regexp.js +3 -4
  99. package/lib/utilities/file.js +2 -18
  100. package/lib/utilities/loading.js +0 -23
  101. package/lib/utilities/logger.js +0 -19
  102. package/lib/utilities/merge-stream.js +0 -8
  103. package/lib/utilities/namespace.js +0 -4
  104. package/lib/utilities/public-url.js +10 -10
  105. package/lib/utilities/replacestream.js +5 -27
  106. package/lib/utilities/typeof.js +0 -2
  107. package/lib/utilities/utils.js +2 -9
  108. package/package.json +24 -24
@@ -1,37 +1,37 @@
1
1
  import { URL } from 'node:url';
2
2
  import { DOMAIN } from '../config/constants.js';
3
+
3
4
  /**
4
5
  * Returns a URL or a path with slash at the end
5
6
  * In production can be URL, absolute path, relative path
6
7
  * In development always will be an absolute path
7
8
  * In development can use `path` module functions for operations
8
9
  */
9
-
10
10
  function getPublicUrlOrPath(homepage, envPublicUrl) {
11
11
  const stubDomain = DOMAIN;
12
-
13
12
  if (envPublicUrl) {
14
13
  // ensure last slash exists
15
- envPublicUrl = envPublicUrl.endsWith('/') ? envPublicUrl : envPublicUrl + '/'; // validate if `envPublicUrl` is a URL or path like
16
- // `stubDomain` is ignored if `envPublicUrl` contains a domain
14
+ envPublicUrl = envPublicUrl.endsWith('/') ? envPublicUrl : envPublicUrl + '/';
17
15
 
16
+ // validate if `envPublicUrl` is a URL or path like
17
+ // `stubDomain` is ignored if `envPublicUrl` contains a domain
18
18
  const validPublicUrl = new URL(envPublicUrl, stubDomain);
19
- return BalmJS.config.env.isDev ? envPublicUrl.startsWith('.') ? '/' : validPublicUrl.pathname : // Some apps do not use client-side routing with pushState.
19
+ return BalmJS.config.env.isDev ? envPublicUrl.startsWith('.') ? '/' : validPublicUrl.pathname :
20
+ // Some apps do not use client-side routing with pushState.
20
21
  // For these, "homepage" can be set to "." to enable relative asset paths.
21
22
  envPublicUrl;
22
23
  }
23
-
24
24
  if (homepage) {
25
25
  // strip last slash if exists
26
- homepage = homepage.endsWith('/') ? homepage : homepage + '/'; // validate if `homepage` is a URL or path like and use just pathname
26
+ homepage = homepage.endsWith('/') ? homepage : homepage + '/';
27
27
 
28
+ // validate if `homepage` is a URL or path like and use just pathname
28
29
  const validHomepagePathname = new URL(homepage, stubDomain).pathname;
29
- return BalmJS.config.env.isDev ? homepage.startsWith('.') ? '/' : validHomepagePathname : // Some apps do not use client-side routing with pushState.
30
+ return BalmJS.config.env.isDev ? homepage.startsWith('.') ? '/' : validHomepagePathname :
31
+ // Some apps do not use client-side routing with pushState.
30
32
  // For these, "homepage" can be set to "." to enable relative asset paths.
31
33
  homepage.startsWith('.') ? homepage : validHomepagePathname;
32
34
  }
33
-
34
35
  return '/';
35
36
  }
36
-
37
37
  export default getPublicUrlOrPath;
@@ -1,51 +1,42 @@
1
1
  import { Transform } from 'readable-stream';
2
2
  import escapeRegExp from './escape-string-regexp.js';
3
-
4
3
  function createReplaceFn(replace, isRegEx) {
5
4
  function regexReplaceFunction(...args) {
6
- let newReplace = replace; // ability to us $1 with captures
5
+ let newReplace = replace;
6
+
7
+ // ability to us $1 with captures
7
8
  // Start at 1 and end at length - 2 to avoid the match parameter and offset
8
9
  // And string parameters
9
-
10
10
  const paramLength = [...args].length - 2;
11
-
12
11
  for (let i = 1; i < paramLength; i++) {
13
12
  newReplace = newReplace.replace(new RegExp(`\\$${i}`, 'g'), [...args][i] || '');
14
13
  }
15
-
16
14
  return newReplace;
17
15
  }
18
-
19
16
  if (!(replace instanceof Function)) {
20
17
  return isRegEx ? regexReplaceFunction : () => {
21
18
  return replace;
22
19
  };
23
20
  }
24
-
25
21
  return replace;
26
22
  }
27
-
28
23
  function matchFromRegex(regex, options) {
29
24
  if (options.regExpFlags) {
30
25
  regex = new RegExp(regex.source, options.regExpFlags);
31
- } // If there is no global flag then there can only be one match
32
-
26
+ }
33
27
 
28
+ // If there is no global flag then there can only be one match
34
29
  if (!regex.global) {
35
30
  options.limit = 1;
36
31
  }
37
-
38
32
  return regex;
39
33
  }
40
-
41
34
  function matchFromString(str, options) {
42
35
  if (options.regExpFlags) {
43
36
  return new RegExp(escapeRegExp(str), options.regExpFlags);
44
37
  }
45
-
46
38
  return new RegExp(escapeRegExp(str), options.ignoreCase ? 'gmi' : 'gm');
47
39
  }
48
-
49
40
  function replaceStream(search, replace, opts) {
50
41
  const options = Object.assign({
51
42
  limit: Infinity,
@@ -57,33 +48,27 @@ function replaceStream(search, replace, opts) {
57
48
  const isRegex = search instanceof RegExp;
58
49
  const replaceFn = createReplaceFn(replace, isRegex);
59
50
  let match;
60
-
61
51
  if (isRegex) {
62
52
  match = matchFromRegex(search, options);
63
53
  } else {
64
54
  match = matchFromString(search, options);
65
55
  options.maxMatchLen = search.length;
66
56
  }
67
-
68
57
  function getDataToAppend(before, match) {
69
58
  let dataToAppend = before;
70
59
  totalMatches++;
71
60
  dataToAppend += isRegex ? replaceFn.apply(this, match.concat([match.index.toString(), match.input])) : replaceFn(match[0]);
72
61
  return dataToAppend;
73
62
  }
74
-
75
63
  function getDataToQueue(matchCount, haystack, rewritten, lastPos) {
76
64
  if (matchCount > 0) {
77
65
  if (haystack.length > tail.length) {
78
66
  return rewritten + haystack.slice(lastPos, haystack.length - tail.length);
79
67
  }
80
-
81
68
  return rewritten;
82
69
  }
83
-
84
70
  return haystack.slice(0, haystack.length - tail.length);
85
71
  }
86
-
87
72
  function transform(chunk, encoding, callback) {
88
73
  let matches;
89
74
  let lastPos = 0;
@@ -91,13 +76,11 @@ function replaceStream(search, replace, opts) {
91
76
  let rewritten = '';
92
77
  const haystack = `${tail}${chunk.toString(options.encoding)}`;
93
78
  tail = '';
94
-
95
79
  while (totalMatches < options.limit && (matches = match.exec(haystack)) !== null) {
96
80
  matchCount++;
97
81
  const before = haystack.slice(lastPos, matches.index);
98
82
  const regexMatch = matches;
99
83
  lastPos = matches.index + regexMatch[0].length;
100
-
101
84
  if (lastPos > haystack.length && regexMatch[0].length < options.maxMatchLen) {
102
85
  tail = regexMatch[0];
103
86
  } else {
@@ -105,24 +88,19 @@ function replaceStream(search, replace, opts) {
105
88
  rewritten += dataToAppend;
106
89
  }
107
90
  }
108
-
109
91
  if (tail.length < 1) tail = haystack.slice(lastPos).length > options.maxMatchLen ? haystack.slice(lastPos).slice(0 - options.maxMatchLen) : haystack.slice(lastPos);
110
92
  const dataToQueue = getDataToQueue(matchCount, haystack, rewritten, lastPos);
111
93
  callback(null, dataToQueue);
112
94
  }
113
-
114
95
  function flush(callback) {
115
96
  if (tail) {
116
97
  this.push(tail);
117
98
  }
118
-
119
99
  callback();
120
100
  }
121
-
122
101
  return new Transform({
123
102
  transform,
124
103
  flush
125
104
  });
126
105
  }
127
-
128
106
  export default replaceStream;
@@ -1,7 +1,5 @@
1
1
  const reTypeOf = /(?:^\[object\s(.*?)\]$)/;
2
-
3
2
  function getType(obj) {
4
3
  return Object.prototype.toString.call(obj).replace(reTypeOf, '$1').toLowerCase();
5
4
  }
6
-
7
5
  export default getType;
@@ -1,23 +1,19 @@
1
1
  import getType from './typeof.js';
2
-
3
2
  function isString(str) {
4
3
  return getType(str) === 'string';
5
4
  }
6
-
7
5
  function isObject(obj) {
8
6
  return getType(obj) === 'object';
9
7
  }
10
-
11
8
  function isArray(arr) {
12
9
  return Array.isArray(arr);
13
10
  }
14
-
15
11
  function isFunction(fn) {
16
12
  const type = getType(fn);
17
13
  return type === 'function' || type === 'generatorfunction';
18
- } // Deep merge two objects
19
-
14
+ }
20
15
 
16
+ // Deep merge two objects
21
17
  function deepMerge(target, source) {
22
18
  if (isObject(target) && isObject(source)) {
23
19
  Object.keys(source).forEach(key => {
@@ -27,7 +23,6 @@ function deepMerge(target, source) {
27
23
  [key]: {}
28
24
  });
29
25
  }
30
-
31
26
  deepMerge(target[key], source[key]);
32
27
  } else {
33
28
  Object.assign(target, {
@@ -36,10 +31,8 @@ function deepMerge(target, source) {
36
31
  }
37
32
  });
38
33
  }
39
-
40
34
  return target;
41
35
  }
42
-
43
36
  export default {
44
37
  getType,
45
38
  isString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balm-core",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "BalmJS compiler core",
5
5
  "keywords": [
6
6
  "balm",
@@ -43,15 +43,15 @@
43
43
  "dependencies": {
44
44
  "ansi-colors": "^4.1.3",
45
45
  "async": "^3.2.4",
46
- "autoprefixer": "^10.4.11",
47
- "babel-loader": "^8.2.5",
46
+ "autoprefixer": "^10.4.13",
47
+ "babel-loader": "^9.1.0",
48
48
  "browser-sync": "^2.27.10",
49
49
  "connect-history-api-fallback": "^2.0.0",
50
- "css-loader": "^6.7.1",
51
- "css-minimizer-webpack-plugin": "^4.1.0",
52
- "cssnano": "^5.1.13",
50
+ "css-loader": "^6.7.2",
51
+ "css-minimizer-webpack-plugin": "^4.2.2",
52
+ "cssnano": "^5.1.14",
53
53
  "del": "^7.0.0",
54
- "dotenv": "^16.0.2",
54
+ "dotenv": "^16.0.3",
55
55
  "dotenv-expand": "^9.0.0",
56
56
  "esbuild": "^0.15.0",
57
57
  "fancy-log": "^2.0.0",
@@ -64,48 +64,48 @@
64
64
  "gulp-useref": "^5.0.0",
65
65
  "gulp-zip": "^5.1.0",
66
66
  "gulp.spritesmith": "^6.13.0",
67
- "html-loader": "^4.1.0",
67
+ "html-loader": "^4.2.0",
68
68
  "html-minifier": "^4.0.0",
69
69
  "html-webpack-plugin": "^5.5.0",
70
70
  "http-proxy-middleware": "^2.0.6",
71
71
  "imagemin": "^8.0.1",
72
72
  "istextorbinary": "^6.0.0",
73
73
  "less": "^4.1.3",
74
- "mini-css-extract-plugin": "^2.6.1",
74
+ "mini-css-extract-plugin": "^2.7.0",
75
75
  "modernizr": "^3.12.0",
76
76
  "parents": "^1.0.1",
77
77
  "plugin-error": "^2.0.0",
78
- "postcss": "^8.4.16",
78
+ "postcss": "^8.4.19",
79
79
  "postcss-flexbugs-fixes": "^5.0.2",
80
80
  "postcss-import": "^15.0.0",
81
81
  "postcss-load-config": "^4.0.1",
82
82
  "postcss-loader": "7.0.1",
83
- "postcss-preset-env": "^7.8.2",
83
+ "postcss-preset-env": "^7.8.3",
84
84
  "pretty-bytes": "^6.0.0",
85
- "readable-stream": "^4.1.0",
85
+ "readable-stream": "^4.2.0",
86
86
  "replace-ext": "^2.0.0",
87
- "rollup": "^2.79.0",
87
+ "rollup": "^3.4.0",
88
88
  "rollup-plugin-terser": "^7.0.2",
89
- "sass": "^1.54.9",
90
- "sass-loader": "^13.0.2",
89
+ "sass": "^1.56.1",
90
+ "sass-loader": "^13.2.0",
91
91
  "ssh2": "^1.11.0",
92
92
  "strip-ansi": "^7.0.1",
93
93
  "style-loader": "^3.3.1",
94
- "terser": "^5.15.0",
94
+ "terser": "^5.15.1",
95
95
  "terser-webpack-plugin": "^5.3.6",
96
96
  "through2": "^4.0.2",
97
97
  "through2-concurrent": "^2.0.0",
98
- "tslib": "^2.4.0",
98
+ "tslib": "^2.4.1",
99
99
  "vinyl-sourcemaps-apply": "^0.2.1",
100
- "webpack": "^5.74.0",
101
- "webpack-bundle-analyzer": "^4.6.1",
102
- "webpack-dev-middleware": "^5.3.3",
103
- "webpack-hot-middleware": "^2.25.2",
100
+ "webpack": "^5.75.0",
101
+ "webpack-bundle-analyzer": "^4.7.0",
102
+ "webpack-dev-middleware": "^6.0.0",
103
+ "webpack-hot-middleware": "^2.25.3",
104
104
  "webpack-merge": "^5.8.0",
105
105
  "workbox-build": "^6.5.4"
106
106
  },
107
107
  "devDependencies": {
108
- "@swc/core": "^1.2",
108
+ "@swc/core": "1",
109
109
  "@types/express": "4",
110
110
  "@types/node": "18",
111
111
  "@types/uglify-js": "3",
@@ -118,7 +118,7 @@
118
118
  "imagemin-svgo": "^9.0.0"
119
119
  },
120
120
  "engines": {
121
- "node": ">=14.15.0"
121
+ "node": ">=14.18.0"
122
122
  },
123
- "gitHead": "f47edb0cb41157d4cd1ab1a69ba49caa789872d7"
123
+ "gitHead": "f841e5829cff219635117376aa74e74641f32078"
124
124
  }