@shijiu/jsview 2.3.151-test.0 → 3.0.0-next-vue.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 (78) hide show
  1. package/dom/bin/jsview-dom-browser-engine-core.min.js +1 -1
  2. package/dom/bin/jsview-dom-browser-engine-modules.min.js +1 -1
  3. package/dom/bin/{jsview-dom-browser-forge.1493.9a36.wasm → jsview-dom-browser-forge.1760.0e35.wasm} +0 -0
  4. package/dom/bin/jsview-dom-browser-forge.min.js +1 -1
  5. package/dom/bin/jsview-dom-browser-forge.worker.min.js +1 -1
  6. package/dom/bin/jsview-dom-browser.min.js +1 -1
  7. package/dom/bin/jsview-dom-native.min.js +1 -1
  8. package/dom/bin/jsview-engine-js-native.min.js +1 -1
  9. package/dom/target_core_revision.mjs +2 -2
  10. package/loader/jsv-core-api/jsview-core-api-glue.js +10 -1
  11. package/loader/jsv-core-api/wasm/core-api.js +87 -2
  12. package/loader/jsv-core-api/wasm/wasm-extension.js +5 -0
  13. package/loader/jsview-loader.js +7 -0
  14. package/loader/jsview-main.mjs +2 -1
  15. package/loader/jsview.config.default.js +4 -0
  16. package/package.json +7 -5
  17. package/patches/@vitejs+plugin-vue+4.0.0.patch +51 -0
  18. package/patches/@vitejs+plugin-vue+6.0.6.patch +54 -0
  19. package/patches/@vue+compiler-dom+3.2.45.patch +22 -0
  20. package/patches/@vue+compiler-dom+3.6.0-beta.10.patch +22 -0
  21. package/patches/@vue+compiler-sfc+3.2.45.patch +1986 -0
  22. package/patches/@vue+compiler-sfc+3.6.0-beta.10.patch +69 -0
  23. package/patches/@vue+runtime-core+3.2.45.patch +353 -0
  24. package/patches/@vue+runtime-core+3.6.0-beta.10.patch +196 -0
  25. package/patches/@vue+runtime-dom+3.2.45.patch +81 -0
  26. package/patches/@vue+runtime-dom+3.6.0-beta.10.patch +47 -0
  27. package/patches/postcss-js+5.1.0.patch +20 -0
  28. package/patches/vite+4.0.0.patch +117 -0
  29. package/patches/vite+8.0.9.patch +77 -0
  30. package/patches/vue-router+4.1.6.patch +17 -0
  31. package/patches/vue-router+5.0.6.patch +0 -0
  32. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js → thirdparty/@vue/compiler-sfc/jsview-css-to-js.cjs} +15 -10
  33. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-checker.js → thirdparty/@vue/compiler-sfc/jsview-style-checker.cjs} +6 -1
  34. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-formator.cjs.js → thirdparty/@vue/compiler-sfc/jsview-style-formator.cjs} +3 -0
  35. package/thirdparty/@vue/runtime-core/jsview-render-break.mjs +189 -0
  36. package/thirdparty/vite/jsview-vite-extension.mjs +336 -0
  37. package/tools/jsview-build-zip.mjs +7 -2
  38. package/tools/jsview-common.mjs +17 -4
  39. package/tools/{jsview-logger.js → jsview-logger.cjs} +1 -1
  40. package/tools/jsview-post-build.mjs +55 -0
  41. package/tools/jsview-post-install.mjs +105 -103
  42. package/tools/jsview-run-tool.mjs +3 -6
  43. package/tools/jsview-vue-devtools.mjs +1 -1
  44. package/loader/jsview-react-main.js +0 -37
  45. package/loader/jsview-react-script-loader.js +0 -134
  46. package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +0 -520
  47. package/patches/node_modules/@vitejs/plugin-react/package.json +0 -55
  48. package/patches/node_modules/@vitejs/plugin-vue/dist/index.mjs +0 -2756
  49. package/patches/node_modules/@vitejs/plugin-vue/package.json +0 -51
  50. package/patches/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -3152
  51. package/patches/node_modules/@vue/compiler-dom/package.json +0 -43
  52. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -17730
  53. package/patches/node_modules/@vue/compiler-sfc/package.json +0 -59
  54. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8154
  55. package/patches/node_modules/@vue/runtime-core/package.json +0 -38
  56. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +0 -1531
  57. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1740
  58. package/patches/node_modules/@vue/runtime-dom/package.json +0 -42
  59. package/patches/node_modules/postcss-js/objectifier.js +0 -94
  60. package/patches/node_modules/postcss-js/package.json +0 -42
  61. package/patches/node_modules/react-dev-utils/WebpackDevServerUtils.js +0 -450
  62. package/patches/node_modules/react-dev-utils/package.json +0 -88
  63. package/patches/node_modules/react-dom/cjs/react-dom.development.js +0 -29868
  64. package/patches/node_modules/react-dom/cjs/react-dom.production.min.js +0 -323
  65. package/patches/node_modules/react-dom/package.json +0 -62
  66. package/patches/node_modules/react-scripts/config/paths.js +0 -179
  67. package/patches/node_modules/react-scripts/config/webpack.config.js +0 -858
  68. package/patches/node_modules/react-scripts/package.json +0 -108
  69. package/patches/node_modules/vite/dist/node/chunks/dep-ed9cb113.js +0 -63182
  70. package/patches/node_modules/vite/dist/node/constants.js +0 -125
  71. package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +0 -245
  72. package/patches/node_modules/vite/package.json +0 -153
  73. package/patches/node_modules/vue-router/dist/vue-router.mjs +0 -3613
  74. package/patches/node_modules/vue-router/package.json +0 -114
  75. package/patches/node_modules/webpack-dev-server/client/utils/reloadApp.js +0 -76
  76. package/patches/node_modules/webpack-dev-server/client/utils/sendMessage.js +0 -21
  77. package/patches/node_modules/webpack-dev-server/package.json +0 -141
  78. /package/patches/{node_modules/@originjs/vite-plugin-federation/1.3.4/@originjs+vite-plugin-federation+1.3.4.patch → @originjs+vite-plugin-federation+1.3.4.patch} +0 -0
@@ -0,0 +1,336 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ // import fullReload from 'vite-plugin-full-reload';
4
+ // import wasm from "vite-plugin-wasm";
5
+
6
+ // https://vitejs.dev/config/
7
+ const jsviewConfig = {
8
+ assetsInclude: ['**/*.bmp'],
9
+ base: './', // index.html 使用相对路径
10
+ build: {
11
+ assetsInlineLimit: 0,
12
+ //cssTarget: 'css/', // 未生效
13
+ commonjsOptions: getCommonjsOptions(),
14
+ emptyOutDir: true,
15
+ minify: useMinify(),
16
+ // jsvMinifyExclude: process.env['JSVIEW_MINIFY_EXCLUDE'],
17
+ modulePreload: {
18
+ polyfill: false
19
+ },
20
+ rolldownOptions: {
21
+ onwarn: onRolldownWarning,
22
+ output: {
23
+ assetFileNames: getAssetFileName,
24
+ chunkFileNames: getChunkFileName,
25
+ entryFileNames: 'js/main.jsv.[hash].js',
26
+ format: 'esm',
27
+ hashCharacters: 'hex',
28
+ manualChunks: getManualChunks,
29
+ },
30
+ plugins: [
31
+ rolldownRemoveBangsPlugin(),
32
+ rolldownMinifyExcludePlugin(),
33
+ ],
34
+ },
35
+ sourcemap: true,
36
+ target: 'es2022', // 不转译async/await
37
+ },
38
+ isCustomElement: isCustomElement,
39
+ optimizeDeps: getOptimizeDeps(),
40
+ plugins: [
41
+ // fullReload('node_modules/@shijiu/**/*'),
42
+ // wasm(),
43
+ ],
44
+ resolve: {
45
+ alias: getResolveAlias(),
46
+ preserveSymlinks: true
47
+ },
48
+ server: {
49
+ headers: { // 启用浏览器SharedArrayBuffer,webassmbly的thread用
50
+ 'Cross-Origin-Opener-Policy': 'same-origin',
51
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
52
+ },
53
+ host: true,
54
+ https: process.env['JSVIEW_ENABLE_HTTPS'] ? getHttpsConfig() : false,
55
+ open: !process.env['JSVIEW_DISABLE_OPEN_BROWSER'] && process.platform === "darwin",
56
+ watch: {
57
+ ignored: [
58
+ '!**/node_modules/@shijiu/**',
59
+ ],
60
+ }
61
+ },
62
+ worker: {
63
+ format: 'esm',
64
+ rolldownOptions: {
65
+ output: {
66
+ assetFileNames: getAssetFileName,
67
+ chunkFileNames: getChunkFileName,
68
+ entryFileNames: getChunkFileName,
69
+ format: 'esm',
70
+ hashCharacters: 'hex',
71
+ },
72
+ },
73
+ },
74
+ };
75
+
76
+ function ensureFramework(originConfig) {
77
+ const checkFramework = function (name) {
78
+ if (name.indexOf('vue') >= 0) {
79
+ return 'vue';
80
+ // } else if (name.indexOf('react') >= 0) {
81
+ // return 'react';
82
+ }
83
+
84
+ return null;
85
+
86
+ };
87
+
88
+ let framework = 'unknown';
89
+ for (const plugins of originConfig.plugins) {
90
+ if (Array.isArray(plugins)) {
91
+ for (const plugin of plugins) {
92
+ framework = checkFramework(plugin.name);
93
+ if (framework) {
94
+ break;
95
+ }
96
+ }
97
+ } else {
98
+ const plugin = plugins;
99
+ framework = checkFramework(plugin.name);
100
+ }
101
+ if (framework) {
102
+ break;
103
+ }
104
+ }
105
+
106
+ return framework;
107
+ }
108
+
109
+ function getAssetFileName(chunkInfo) {
110
+ if(chunkInfo.name?.endsWith('.css')) {
111
+ return 'css/[name].[hash].css';
112
+ } else if(chunkInfo.name?.endsWith('.ttf')) {
113
+ return 'assets/[name].ttf';
114
+ } else if(chunkInfo.name?.endsWith('.wasm')) {
115
+ return 'js/[name].wasm';
116
+ }
117
+
118
+ // return 'assets/[name].[hash].[ext]'
119
+ return 'assets/[name].[hash][extname]'
120
+ }
121
+
122
+ function getChunkFileName(chunkInfo) {
123
+ return (process.env['JSVIEW_KEEP_CHUNKNAME'] ? 'js/[name].[hash].js' : 'js/chunk.jsv2.[hash].js');
124
+ }
125
+
126
+ function getCommonjsOptions() {
127
+ return {
128
+ 'gifuct-js': true,
129
+ 'js-binary-schema-parser': true,
130
+ 'mockjs': true,
131
+ 'qr.js': true,
132
+ };
133
+ }
134
+
135
+ function getHttpsConfig() {
136
+ const configDir = path.resolve(getModuleDir(), '@shijiu/jsview/tools/https-server-config');
137
+ const certFilePath = path.resolve(configDir, 'cert.pem');
138
+ const keyFilePath = path.resolve(configDir, 'key.pem');
139
+
140
+ return {
141
+ cert: fs.readFileSync(certFilePath),
142
+ key: fs.readFileSync(keyFilePath),
143
+ maxVersion: 'TLSv1.2',
144
+ minVersion: 'TLSv1',
145
+ }
146
+ }
147
+
148
+ function getManualChunks(moduleId) {
149
+ const manualChunks = {
150
+ 'export-sfc': ['\0plugin-vue:export-helper', '@shijiu/jsview-vue/bin/export-sfc.mjs'], // 将_export_sfc独立出来,防止被集成在jsview-vue中导致import deadloop.
151
+ 'vue': ['vue'], // 将vue独立出来,防止被集成在main.js中导致import deadloop.
152
+ // 将dom-entry和forge-define分割出来,防止被集成在main.js中导致import deadloop.
153
+ 'jsview-forge-define': ['@shijiu/jsview/dom/jsv-forge-define.mjs'],
154
+ 'jsview-dom-entry': ['@shijiu/jsview/dom/index.mjs'],
155
+ 'jsview-vue-entry': ['@shijiu/jsview-vue/index.js'],
156
+ 'jsview-vue-common': ['@shijiu/jsview-vue/bin/jsview-vue-common.mjs'],
157
+ // 'jsview-vue-export-sfc': [], // 将jsview-vue中的export-sfc,防止被集成在jsview-vue-entry中导致import deadloop.
158
+ };
159
+
160
+ for(const [key, valueList] of Object.entries(manualChunks)) {
161
+ for(const value of valueList) {
162
+ if(moduleId.endsWith(value)) {
163
+ return key;
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ function getModuleDir() {
170
+ const moduleDir = path.resolve(process.cwd(), 'node_modules');
171
+ return moduleDir;
172
+ }
173
+
174
+ function getOptimizeDeps() {
175
+ return {
176
+ include: [
177
+ 'gifuct-js',
178
+ // 'mockjs',
179
+ 'qr.js'
180
+ ],
181
+ exclude: [
182
+ '@shijiu/jsview/loader/jsview-main.mjs', // 解决windows上出现解析异常的问题。
183
+ '@shijiu/jsview',
184
+ '@shijiu/jsview-vue',
185
+ '@shijiu/jsview-vue-samples',
186
+ 'jsview',
187
+ 'jsview-vue',
188
+ 'jsview-vue-samples',
189
+ ],
190
+ }
191
+ }
192
+
193
+ function getResolveAlias() {
194
+ return {
195
+ // 'jsview': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview'),
196
+ 'jsview-vue': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-vue'),
197
+ 'jsview-vue-samples': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-vue-samples'),
198
+ // 'jsview-react': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-react'),
199
+ // 'jsview-react-samples': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-react-samples'),
200
+ '/js/main.jsv.mjs': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview/loader/jsview-main.mjs'),
201
+ }
202
+ }
203
+
204
+ function isCustomElement(tag) {
205
+ return tag == 'fdiv' || tag.startsWith('jsv-')
206
+ }
207
+
208
+ function onRolldownWarning(warning, defaultHandler) {
209
+ if (warning.message?.includes('externalized for browser compatibility')
210
+ && warning.message?.includes('jsview-dom-browser-forge')) {
211
+ // console.info('\nJsView Info: Ignore warning', warning.message)
212
+ return;
213
+ } else if (warning.code === 'FILE_NAME_CONFLICT') {
214
+ if(warning.message.includes('jsview-dom-browser-forge')
215
+ && warning.message.includes('.wasm')) {
216
+ console.info('\nJsView Info: Ignore warning', warning.message)
217
+ return;
218
+ }
219
+ } else if (warning.code === 'EVAL') {
220
+ if(warning.message.includes('mock.js')) {
221
+ console.info('\nJsView Info: Ignore warning', warning.message)
222
+ return;
223
+ }
224
+ }
225
+
226
+ defaultHandler(warning);
227
+ }
228
+
229
+ function rolldownMinifyExcludePlugin() {
230
+ const jsvMinifyExclude = process.env['JSVIEW_MINIFY_EXCLUDE'];
231
+ const minifyExcludeChunkCodes = new Map();
232
+ let minifyExcludeRegex = null;
233
+
234
+ minifyExcludeRegex = new RegExp(jsvMinifyExclude?.trim() ?? '');
235
+ function isExcludeChunk(chunk) {
236
+ const name = chunk.name ?? chunk.fileName;
237
+ return minifyExcludeRegex.test(name);
238
+ }
239
+
240
+ function minifyExcludeRenderChunk(code, chunk, _options) {
241
+ if(isExcludeChunk(chunk)) {
242
+ const name = chunk.name ?? chunk.fileName;
243
+ // renderChunk 发生在 minify 之前,先缓存原始代码,稍后在 generateBundle 覆盖回来
244
+ minifyExcludeChunkCodes.set(name, code);
245
+ }
246
+
247
+ // 统一交给 Rolldown 构建链路;命中项会在 generateBundle 阶段恢复原始代码
248
+ return null;
249
+ }
250
+
251
+ function minifyExcludeGenerateBundle(_options, bundle) {
252
+ for(const item of Object.values(bundle)) {
253
+ if(item.type !== 'chunk') {
254
+ continue;
255
+ }
256
+ if(!isExcludeChunk(item)) {
257
+ continue;
258
+ }
259
+
260
+ const originalCode = minifyExcludeChunkCodes.get(item.name || item.fileName);
261
+ if(typeof originalCode === 'string') {
262
+ item.code = originalCode;
263
+ }
264
+ }
265
+ }
266
+
267
+ return {
268
+ name: 'rolldown-plugin-minify-exclude',
269
+ renderChunk: jsvMinifyExclude ? minifyExcludeRenderChunk : null,
270
+ generateBundle: jsvMinifyExclude ? minifyExcludeGenerateBundle : null,
271
+ };
272
+ }
273
+
274
+ function rolldownRemoveBangsPlugin() {
275
+ return {
276
+ name: 'rolldown-plugin-remove-bangs',
277
+ renderChunk(code, _chunk, _options) {
278
+ return {
279
+ code: code.replace(/^\/\/!/g, '//').replace(/^\/\*!/g, '/*'),
280
+ map: null,
281
+ }
282
+ },
283
+ };
284
+ }
285
+
286
+ function useMinify() {
287
+ return process.env['JSVIEW_DISABLE_MINIFY'] ? false : true;
288
+ }
289
+
290
+ function jsvCreateJsViewViteConfig(originConfig) {
291
+ let aliasJsView;
292
+
293
+ const moduleDir = getModuleDir();
294
+ const framework = ensureFramework(originConfig);
295
+ switch (framework) {
296
+ case 'vue':
297
+ aliasJsView = path.resolve(moduleDir, '@shijiu/jsview-vue');
298
+ break;
299
+ // case 'react':
300
+ // aliasJsView = path.resolve(moduleDir, '@shijiu/jsview-react');
301
+ // break;
302
+ default:
303
+ throw new Error('JsView Error: Failed to support framework: ' + framework);
304
+ }
305
+ jsviewConfig.resolve.alias['jsview'] = aliasJsView;
306
+
307
+ if(process.env['JSVIEW_DISABLE_MANUALCHUNKS']) {
308
+ delete jsviewConfig.build.rolldownOptions.output.manualChunks
309
+ }
310
+
311
+ // 解决templete工程中没有mockjs导致的报错。
312
+ const mockjs = path.resolve(moduleDir, 'mockjs');
313
+ if(fs.existsSync(mockjs)) {
314
+ jsviewConfig.optimizeDeps.include.push('mockjs');
315
+ }
316
+
317
+ return jsviewConfig;
318
+ }
319
+
320
+ function jsvSaveUrlToCache(urls) {
321
+ if ((urls?.network?.length ?? -1 )<= 0) {
322
+ console.error("JsView Error: Failed to find network info.");
323
+ return;
324
+ }
325
+
326
+ const moduleDir = getModuleDir();
327
+ const urlCacheDir = path.resolve(moduleDir, '.vite', 'jsview')
328
+ const urlCacheFilePath = path.resolve(urlCacheDir, 'network.mjs')
329
+ fs.mkdirSync(urlCacheDir, { recursive: true });
330
+ fs.writeFileSync(urlCacheFilePath, `export default "${urls.network[0]}"`)
331
+ }
332
+
333
+ export {
334
+ jsvCreateJsViewViteConfig,
335
+ jsvSaveUrlToCache,
336
+ }
@@ -21,12 +21,16 @@ async function main(argv)
21
21
  const zipName = 'dist.dat';
22
22
  const zipPath = path.resolve(options.distDir, zipName);
23
23
 
24
- const password = argv.password ?? 'jsview.shijiu.com';
24
+ let password = argv.password ?? 'jsview.shijiu.com';
25
+ if(argv.noPassword) {
26
+ password = null;
27
+ }
25
28
 
26
29
  execCommand('npm run build');
27
30
 
28
31
  let childFileNames = fs.readdirSync(options.distDir);
29
32
  childFileNames = childFileNames.filter(it => it !== zipName);
33
+ childFileNames = childFileNames.filter(it => it !== 'debug');
30
34
  childFileNames = childFileNames.map(it => path.resolve(options.distDir, it));
31
35
 
32
36
  makeZip(zipPath, password, ...childFileNames)
@@ -37,7 +41,8 @@ async function main(argv)
37
41
  const requiredUsages = {
38
42
  };
39
43
  const optionalUsages = {
40
- '--password': 'Input passwork',
44
+ '--password': 'Input password',
45
+ '--no-password': 'Ignore password',
41
46
  };
42
47
  const argv = parseArguments(requiredUsages, optionalUsages);
43
48
  main(argv);
@@ -6,7 +6,7 @@ import fs from 'node:fs';
6
6
  import https from 'node:https';
7
7
  import os from 'node:os';
8
8
  import path from 'node:path';
9
- import { Logger } from "./jsview-logger.js";
9
+ import { Logger } from "./jsview-logger.cjs";
10
10
 
11
11
  function printArgumentsUsages(requiredUsages, optionalUsages, helpUsages)
12
12
  {
@@ -180,6 +180,7 @@ function parseArguments(requiredUsages = {},
180
180
  * jsview-test-project
181
181
  * ├── dist
182
182
  * │   ├── assets
183
+ * │   ├── css
183
184
  * │   ├── debug
184
185
  * │   │   └── map
185
186
  * │   └── js
@@ -212,12 +213,11 @@ function getOptions(framework)
212
213
  options.jsviewDomDir = path.resolve(options.jsviewDir, 'dom');
213
214
  options.jsviewDomBinDir = path.resolve(options.jsviewDomDir, 'bin');
214
215
  options.jsviewPatchesDir = path.resolve(options.jsviewDir, 'patches');
215
- options.jsviewPatchModulesDir = path.resolve(options.jsviewPatchesDir, 'node_modules');
216
216
  options.jsviewToolsDir = path.resolve(options.jsviewDir, 'tools');
217
217
  options.jsviewDomRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
218
218
 
219
219
  options.jsviewVueDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-vue');
220
- options.jsviewReactDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-react');
220
+ // options.jsviewReactDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-react');
221
221
  if (framework) {
222
222
  options.jsviewFrameworkDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-' + framework);
223
223
  }
@@ -245,6 +245,7 @@ function getOptions(framework)
245
245
  options.distJsvInfoFile = path.resolve(options.distDir, 'jsv-info.json');
246
246
  options.distJsIndexFile = path.resolve(options.distDir, 'index.html');
247
247
  options.distAssetsDir = path.resolve(options.distDir, 'assets');
248
+ options.distCssDir = path.resolve(options.distDir, 'css');
248
249
  options.distJsDir = path.resolve(options.distDir, 'js');
249
250
  options.distDebugDir = path.resolve(options.distDir, 'debug');
250
251
  options.distDebugMapDir = path.resolve(options.distDebugDir, 'map');
@@ -427,7 +428,7 @@ function execCommandWithLiveLog(cmdline)
427
428
  }
428
429
 
429
430
 
430
- function checkNodeVersion(minMajorVersion = 16)
431
+ function checkNodeVersion(minMajorVersion = 20)
431
432
  {
432
433
  const versions = process.version.replace('v', '').split('.');
433
434
  const [majorVersion, minorVersion, patchVersion] = versions;
@@ -438,6 +439,17 @@ function checkNodeVersion(minMajorVersion = 16)
438
439
  }
439
440
  }
440
441
 
442
+ function getNodeVersion()
443
+ {
444
+ const versions = process.version.replace('v', '').split('.');
445
+ const [major, minor, patch] = versions;
446
+ return {
447
+ major,
448
+ minor,
449
+ patch,
450
+ };
451
+ }
452
+
441
453
  function askAndAnswer(question)
442
454
  {
443
455
  process.stdout.write(question)
@@ -588,6 +600,7 @@ export {
588
600
  getExportPrefix,
589
601
  getJsViewBurdenDefaultBaseUrl,
590
602
  getNetworkIpv4Addresses,
603
+ getNodeVersion,
591
604
  getNpmRegistry,
592
605
  getOptions,
593
606
  isCommandAvailable,
@@ -58,7 +58,7 @@ class Logger {
58
58
  for(let idx = 0; idx < size; idx++) {
59
59
  args[idx] = Logger.Blue(Logger.Bold(args[idx]));
60
60
  }
61
- console.info(...args);
61
+ console.info(Logger.Blue('JsView Tip:'), ...args);
62
62
  }
63
63
 
64
64
  static Info(...args) {
@@ -192,6 +192,22 @@ async function prepareMainAppData(options)
192
192
  preloadBurdenResources.push(fileName);
193
193
  }
194
194
 
195
+ const aesKeyFilePath = path.resolve(options.appConfigDir, 'fingerprint_aes_key.mjs');
196
+ if (fs.existsSync(aesKeyFilePath)) {
197
+ const aesKeyFileUrl = url.pathToFileURL(aesKeyFilePath);
198
+ const { default: aesKeyConfig } = await import (aesKeyFileUrl);
199
+ const aesKey = aesKeyConfig.aes_key;
200
+ const aesIv = aesKeyConfig.iv;
201
+
202
+ // 对appConfig.AppName进行aes加密并赋值给EncryptCode2
203
+ if (aesKey && aesIv) {
204
+ const cipher = crypto.createCipheriv('aes-128-cbc', Buffer.from(aesKey, 'utf8'), Buffer.from(aesIv, 'utf8'));
205
+ let encrypted = cipher.update(appConfig.AppName, 'utf8', 'base64');
206
+ encrypted += cipher.final('base64');
207
+ appConfig.EncryptCode2 = encrypted;
208
+ }
209
+ }
210
+
195
211
  // 组装AppData
196
212
  appConfig.PublicKeys = publicKeys; // 使用签名数组,支持后续追加签名
197
213
  appConfig.EncryptCodes = [encryptBase64]; // 同样使用数组,支持后续追加
@@ -200,10 +216,32 @@ async function prepareMainAppData(options)
200
216
  BaseUrl: bunderBaseUrl,
201
217
  Resources: preloadBurdenResources,
202
218
  };
219
+ if (appConfig.FingerPrint) {
220
+ // 删除FingerPrint的存储,节省信息字节数
221
+ delete appConfig.FingerPrint;
222
+ }
203
223
 
204
224
  return JSON.stringify(appConfig);
205
225
  }
206
226
 
227
+ async function checkCssFileSize(options)
228
+ {
229
+ if(fs.existsSync(options.distCssDir) == false) {
230
+ return;
231
+ }
232
+
233
+ const cssFileNames = fs.readdirSync(options.distCssDir);
234
+ for(const fileName of cssFileNames) {
235
+ const filePath = path.resolve(options.distCssDir, fileName)
236
+ const fileStats = await fs.statSync(filePath);
237
+ if (fileStats.size > 0) {
238
+ continue;
239
+ }
240
+
241
+ fs.writeFileSync(filePath, ' ', 'utf8'); // 防止空文件。
242
+ }
243
+ }
244
+
207
245
  async function checkAppConfig(options)
208
246
  {
209
247
  const appConfigFilePath = path.resolve(options.appConfigDir, 'app.config.mjs');
@@ -488,12 +526,25 @@ async function makeJsvConfig(options)
488
526
  // appEntryFileName = appEntryFileName.replace(/\.js$/, '.mjs'); // deprecated
489
527
  appEntryFileName = appEntryFileName.replaceAll('\\', '/'); // windows平台适配
490
528
 
529
+ const appConfigFilePath = path.resolve(options.appConfigDir, 'app.config.mjs');
530
+ if (!fs.existsSync(appConfigFilePath)) {
531
+ Logger.ErrorAndExit('Failed to open app config file from ' + appConfigFilePath);
532
+ }
533
+ const appConfigFileUrl = url.pathToFileURL(appConfigFilePath);
534
+ const { default: appConfig } = await import(appConfigFileUrl);
535
+
491
536
  const jsvConfig = {
492
537
  "COREVERSIONRANGE": jsviewTargetVersion.CoreRevisionAndBranch,
493
538
  "ENGINE": jsviewTargetVersion.JseUrl,
494
539
  "URL": appEntryFileName,
540
+ "MINIAPPNAME": appConfig.AppName,
495
541
  };
496
542
 
543
+ // 启动图
544
+ if (appConfig.StartImageUrl && appConfig.StartImageUrl.length != 0) {
545
+ jsvConfig.STARTIMG = appConfig.StartImageUrl;
546
+ }
547
+
497
548
  const content = JSON.stringify(jsvConfig, null, 2);
498
549
  fs.writeFileSync(options.distJsvConfigFile, content, 'utf8');
499
550
  }
@@ -586,6 +637,10 @@ async function main(argv)
586
637
  // EntryMd5 要放在sourcemap更新之后
587
638
  updateOptions(options);
588
639
 
640
+ Logger.Info('Checking JsView css file size...');
641
+ await checkCssFileSize(options);
642
+ Logger.Info('Checked JsView css file size...');
643
+
589
644
  Logger.Info('Checking JsView app config...');
590
645
  await checkAppConfig(options);
591
646
  Logger.Info('Checked JsView app config...');