@shijiu/jsview 2.2.426-test.0 → 2.3.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/dom/bin/DroidNaskh-Regular.ttf +0 -0
- package/dom/bin/DroidSans.ttf +0 -0
- package/dom/bin/jsview-dom-browser-engine-core.min.js +1 -1
- package/dom/bin/jsview-dom-browser-engine-modules.min.js +1 -1
- package/dom/bin/{jsview-dom-browser-forge.1385.f80e.wasm → jsview-dom-browser-forge.1436.54c9.wasm} +0 -0
- package/dom/bin/jsview-dom-browser-forge.min.js +1 -1
- package/dom/bin/jsview-dom-browser-forge.worker.min.js +1 -1
- package/dom/bin/jsview-dom-browser.min.js +1 -1
- package/dom/bin/jsview-dom-native.min.js +1 -1
- package/dom/bin/jsview-engine-js-native.min.js +1 -1
- package/dom/target_core_revision.mjs +3 -6
- package/loader/jsv-core-api/wasm/core-api.js +7 -5
- package/loader/jsv-core-api/wasm/wasm-extension.js +37 -0
- package/loader/jsview-loader.js +1 -0
- package/package.json +1 -1
- package/tools/jsview-post-build.mjs +62 -11
- package/tools/jsview-run-tool.mjs +54 -26
- package/shijiu-jsview-0.0.0.tgz +0 -0
|
@@ -156,7 +156,7 @@ async function prepareMainAppData(options)
|
|
|
156
156
|
const encryptBase64 = getEncryptBase64(options.appPrivKey, options.appPubKey, options.appEntryMd5);
|
|
157
157
|
|
|
158
158
|
// 获取 预加载的文件名
|
|
159
|
-
const
|
|
159
|
+
const chunkFilterKeys = [
|
|
160
160
|
'domNativePath',
|
|
161
161
|
'NativePlatformDomBridge',
|
|
162
162
|
'ForgeExtension',
|
|
@@ -165,7 +165,7 @@ async function prepareMainAppData(options)
|
|
|
165
165
|
'mount("#app")',
|
|
166
166
|
];
|
|
167
167
|
const preloadChunks = [];
|
|
168
|
-
|
|
168
|
+
let jsFileNames = fs.readdirSync(options.distJsDir);
|
|
169
169
|
for(const fileName of jsFileNames) {
|
|
170
170
|
if (!fileName.startsWith('chunk.jsv') || !fileName.endsWith('.js')) {
|
|
171
171
|
continue;
|
|
@@ -173,17 +173,32 @@ async function prepareMainAppData(options)
|
|
|
173
173
|
|
|
174
174
|
const filePath = path.resolve(options.distJsDir, fileName);
|
|
175
175
|
const sourceContent = fs.readFileSync(filePath, 'utf8');
|
|
176
|
-
if(
|
|
176
|
+
if(chunkFilterKeys.some(it => sourceContent.includes(it)) == false) {
|
|
177
177
|
continue;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
preloadChunks.push(fileName);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
const preloadBurdenResources = [];
|
|
184
|
+
const bunderBaseUrl = process.env['JSVIEW_BURDEN_LOCAL'] ? '' : getBunderBaseUrl();
|
|
185
|
+
const burdenFilePathList = getBurdenFilePathList(options);
|
|
186
|
+
for(const filePath of burdenFilePathList) {
|
|
187
|
+
let fileName = path.basename(filePath);
|
|
188
|
+
if(process.env['JSVIEW_BURDEN_LOCAL']) {
|
|
189
|
+
fileName = path.relative(options.distJsDir, filePath);
|
|
190
|
+
}
|
|
191
|
+
preloadBurdenResources.push(fileName);
|
|
192
|
+
}
|
|
193
|
+
|
|
183
194
|
// 组装AppData
|
|
184
195
|
appConfig.PublicKeys = publicKeys; // 使用签名数组,支持后续追加签名
|
|
185
196
|
appConfig.EncryptCodes = [encryptBase64]; // 同样使用数组,支持后续追加
|
|
186
197
|
appConfig.PreloadChunks = preloadChunks;
|
|
198
|
+
appConfig.PreloadBurdens = {
|
|
199
|
+
BaseUrl: bunderBaseUrl,
|
|
200
|
+
Resources: preloadBurdenResources,
|
|
201
|
+
};
|
|
187
202
|
|
|
188
203
|
return JSON.stringify(appConfig);
|
|
189
204
|
}
|
|
@@ -254,10 +269,10 @@ async function signApp(options)
|
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
271
|
|
|
257
|
-
function
|
|
272
|
+
function getBunderBaseUrl()
|
|
258
273
|
{
|
|
259
274
|
if(process.env['JSVIEW_BURDEN_LOCAL']) {
|
|
260
|
-
return;
|
|
275
|
+
return undefined;
|
|
261
276
|
}
|
|
262
277
|
|
|
263
278
|
let burdenBaseUrl = process.env['JSVIEW_BURDEN_BASEURL'];
|
|
@@ -268,27 +283,47 @@ function redirectBurdenResource(options)
|
|
|
268
283
|
burdenBaseUrl += '/';
|
|
269
284
|
}
|
|
270
285
|
|
|
286
|
+
return burdenBaseUrl;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function getBurdenFilePathList(options)
|
|
290
|
+
{
|
|
291
|
+
const burdenFilterSuffixes = [
|
|
292
|
+
'.wasm',
|
|
293
|
+
'.ttf',
|
|
294
|
+
];
|
|
271
295
|
const burdenFilePathList = [];
|
|
272
296
|
|
|
273
297
|
const assetFileNames = fs.readdirSync(options.distAssetsDir);
|
|
274
298
|
for(const fileName of assetFileNames) {
|
|
275
|
-
|
|
299
|
+
const fileExt = path.extname(fileName);
|
|
300
|
+
if (!burdenFilterSuffixes.includes(fileExt)) {
|
|
276
301
|
continue;
|
|
277
302
|
}
|
|
278
303
|
burdenFilePathList.push(path.resolve(options.distAssetsDir, fileName));
|
|
279
304
|
}
|
|
280
305
|
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
281
306
|
for(const fileName of jsFileNames) {
|
|
282
|
-
|
|
307
|
+
const fileExt = path.extname(fileName);
|
|
308
|
+
if (!burdenFilterSuffixes.includes(fileExt)) {
|
|
283
309
|
continue;
|
|
284
310
|
}
|
|
285
311
|
burdenFilePathList.push(path.resolve(options.distJsDir, fileName));
|
|
286
312
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
313
|
+
|
|
314
|
+
return burdenFilePathList;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function redirectBurdenResource(options)
|
|
318
|
+
{
|
|
319
|
+
let burdenBaseUrl = getBunderBaseUrl();
|
|
320
|
+
if(!burdenBaseUrl) { // use local
|
|
321
|
+
return;
|
|
290
322
|
}
|
|
323
|
+
|
|
324
|
+
const burdenFilePathList = getBurdenFilePathList(options);
|
|
291
325
|
|
|
326
|
+
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
292
327
|
for(const fileName of jsFileNames) {
|
|
293
328
|
if (!fileName.endsWith('.js') && !fileName.endsWith('.js.map')) {
|
|
294
329
|
continue;
|
|
@@ -306,13 +341,27 @@ function redirectBurdenResource(options)
|
|
|
306
341
|
const burdenFileUrl = burdenBaseUrl + path.basename(burdenFilePath);
|
|
307
342
|
|
|
308
343
|
sourceContent = sourceContent.replaceAll(relativeBurdenFilePath, burdenFileUrl);
|
|
309
|
-
Logger.Info('
|
|
344
|
+
Logger.Info('Burdening ' + path.relative(options.projectDir, filePath) + ' for [' + relativeBurdenFilePath + ']');
|
|
310
345
|
}
|
|
311
346
|
|
|
312
347
|
fs.writeFileSync(filePath, sourceContent, 'utf8');
|
|
313
348
|
};
|
|
314
349
|
}
|
|
315
350
|
|
|
351
|
+
function cleanupBurdenResource(options)
|
|
352
|
+
{
|
|
353
|
+
let burdenBaseUrl = getBunderBaseUrl();
|
|
354
|
+
if(!burdenBaseUrl) { // 本地用不要清除
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const burdenFilePathList = getBurdenFilePathList(options);
|
|
359
|
+
for(const filePath of burdenFilePathList) {
|
|
360
|
+
fs.rmSync(filePath);
|
|
361
|
+
Logger.Info('Cleanup burden file: ' + path.relative(options.projectDir, filePath));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
316
365
|
function redirectSourceMappingURL(options)
|
|
317
366
|
{
|
|
318
367
|
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
@@ -534,6 +583,8 @@ async function main(argv)
|
|
|
534
583
|
await makeJsvInfo(options);
|
|
535
584
|
Logger.Info('Made JsView info...');
|
|
536
585
|
|
|
586
|
+
cleanupBurdenResource(options);
|
|
587
|
+
|
|
537
588
|
Logger.Info('Done...');
|
|
538
589
|
}
|
|
539
590
|
|
|
@@ -24,17 +24,19 @@ async function getExtraOptions(argv)
|
|
|
24
24
|
options.entryUrl = argv.url;
|
|
25
25
|
|
|
26
26
|
let commandCount = 0;
|
|
27
|
-
commandCount += (argv.httpServer ? 1 : 0);
|
|
28
|
-
commandCount += (argv.httpsServer ? 1 : 0);
|
|
29
|
-
commandCount += (argv.httpVite ? 1 : 0);
|
|
30
|
-
commandCount += (argv.httpsVite ? 1 : 0);
|
|
31
27
|
commandCount += (argv.configApp ? 1 : 0);
|
|
32
28
|
commandCount += (argv.genKeypair ? 1 : 0);
|
|
33
29
|
commandCount += (argv.runonAndroid ? 1 : 0);
|
|
34
30
|
commandCount += (argv.buildMinifyExclude ? 1 : 0);
|
|
35
31
|
commandCount += (argv.buildZip ? 1 : 0);
|
|
36
32
|
commandCount += (argv.buildBurdenLocal ? 1 : 0);
|
|
33
|
+
commandCount += (argv.buildBurdenBaseurl ? 1 : 0);
|
|
37
34
|
commandCount += (argv.moduleFederation ? 1 : 0);
|
|
35
|
+
commandCount += (argv.httpServer ? 1 : 0);
|
|
36
|
+
commandCount += (argv.httpsServer ? 1 : 0);
|
|
37
|
+
commandCount += (argv.httpVite ? 1 : 0);
|
|
38
|
+
commandCount += (argv.httpsVite ? 1 : 0);
|
|
39
|
+
commandCount += (argv.fowardArkweb ? 1 : 0);
|
|
38
40
|
commandCount += (argv.vueDevtools ? 1 : 0);
|
|
39
41
|
if(commandCount == 0) {
|
|
40
42
|
if(argv.help || argv.h) {
|
|
@@ -43,17 +45,19 @@ async function getExtraOptions(argv)
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
const commandPrompt = [
|
|
46
|
-
'httpServer',
|
|
47
|
-
'httpsServer',
|
|
48
|
-
'httpVite',
|
|
49
|
-
'httpsVite',
|
|
50
48
|
'runonAndroid',
|
|
51
49
|
'configApp',
|
|
52
50
|
'genKeypair',
|
|
53
51
|
'buildMinifyExclude',
|
|
54
52
|
'buildZip',
|
|
55
53
|
'buildBurdenLocal',
|
|
54
|
+
'buildBurdenBaseurl',
|
|
56
55
|
'vueDevtools',
|
|
56
|
+
'httpServer',
|
|
57
|
+
'httpsServer',
|
|
58
|
+
'httpVite',
|
|
59
|
+
'httpsVite',
|
|
60
|
+
'fowardArkweb',
|
|
57
61
|
'moduleFederation',
|
|
58
62
|
];
|
|
59
63
|
|
|
@@ -70,17 +74,19 @@ async function getExtraOptions(argv)
|
|
|
70
74
|
Logger.Info('command:', command);
|
|
71
75
|
options[command] = true
|
|
72
76
|
} else if(commandCount == 1) {
|
|
73
|
-
options.httpServer = argv.httpServer;
|
|
74
|
-
options.httpsServer = argv.httpsServer;
|
|
75
|
-
options.httpsVite = argv.httpsVite;
|
|
76
|
-
options.httpVite = argv.httpVite;
|
|
77
77
|
options.runonAndroid = argv.runonAndroid;
|
|
78
78
|
options.configApp = argv.configApp;
|
|
79
79
|
options.genKeypair = argv.genKeypair;
|
|
80
80
|
options.buildMinifyExclude = argv.buildMinifyExclude;
|
|
81
81
|
options.buildZip = argv.buildZip;
|
|
82
82
|
options.buildBurdenLocal = argv.buildBurdenLocal;
|
|
83
|
+
options.buildBurdenBaseurl = argv.buildBurdenBaseurl;
|
|
83
84
|
options.vueDevtools = argv.vueDevtools;
|
|
85
|
+
options.httpServer = argv.httpServer;
|
|
86
|
+
options.httpsServer = argv.httpsServer;
|
|
87
|
+
options.httpsVite = argv.httpsVite;
|
|
88
|
+
options.httpVite = argv.httpVite;
|
|
89
|
+
options.fowardArkweb = argv.fowardArkweb;
|
|
84
90
|
options.moduleFederation = argv.moduleFederation;
|
|
85
91
|
} else if(commandCount > 1) {
|
|
86
92
|
Logger.ErrorAndExitNoException("Only one command can be executed.");
|
|
@@ -110,13 +116,13 @@ function doCommand(options, argv) {
|
|
|
110
116
|
let filter = options.buildMinifyExclude;
|
|
111
117
|
if(typeof(filter) !== 'string') {
|
|
112
118
|
filter = 'jsview-';
|
|
113
|
-
Logger.Warn(
|
|
119
|
+
Logger.Warn(`Minify filter is not set, use default value: ${filter}`);
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
let script = argv.s ?? argv.script;
|
|
117
123
|
if(typeof(script) !== 'string') {
|
|
118
124
|
script = 'build';
|
|
119
|
-
Logger.Warn(
|
|
125
|
+
Logger.Warn(`Build script is not set, use default value: ${script}`);
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
command = 'node node_modules/@shijiu/jsview/tools/jsview-build-minify-exclude.mjs --filter=' + filter + ' --script=' + script;
|
|
@@ -124,28 +130,33 @@ function doCommand(options, argv) {
|
|
|
124
130
|
const defaultPassword = 'jsview.shijiu.com';
|
|
125
131
|
const password = (typeof(options.buildZip) === 'string' ? options.buildZip : defaultPassword);
|
|
126
132
|
if(password !== options.buildZip) {
|
|
127
|
-
Logger.Warn(
|
|
133
|
+
Logger.Warn(`Zip password is not set, use default value: ${defaultPassword}`);
|
|
128
134
|
}
|
|
129
135
|
|
|
130
|
-
command =
|
|
136
|
+
command = `node node_modules/@shijiu/jsview/tools/jsview-build-zip.mjs --password=${password}`;
|
|
131
137
|
} else if(options.buildBurdenLocal) {
|
|
132
138
|
command = 'JSVIEW_BURDEN_LOCAL=true npm run build';
|
|
139
|
+
} else if(options.buildBurdenBaseurl) {
|
|
140
|
+
if(typeof options.buildBurdenBaseurl != 'string') {
|
|
141
|
+
Logger.ErrorAndExitNoException("Bad build burden base url, please set valid url such as: https://example.com/burden-dir.");
|
|
142
|
+
}
|
|
143
|
+
command = `JSVIEW_BURDEN_BASEURL=${options.buildBurdenBaseurl} npm run build`;
|
|
133
144
|
} else if(options.vueDevtools) {
|
|
134
145
|
var defaultPort = 8098;
|
|
135
146
|
const port = (typeof(options.vueDevtools) === 'string' ? options.vueDevtools : defaultPort);
|
|
136
147
|
if(port !== options.vueDevtools) {
|
|
137
|
-
Logger.Warn(
|
|
148
|
+
Logger.Warn(`Vue Devtools server port is not set, use default value: ${port}`);
|
|
138
149
|
}
|
|
139
150
|
|
|
140
|
-
command =
|
|
151
|
+
command = `node node_modules/@shijiu/jsview/tools/jsview-vue-devtools.mjs --port=${port}`;
|
|
141
152
|
} else if(options.moduleFederation) {
|
|
142
153
|
var argumentsLine = options.argumentsLine.replace(/ --framework.*? /, ' ');
|
|
143
154
|
argumentsLine = argumentsLine.replace(' -f ', ' ').replace(' --module-federation ', ' ');
|
|
144
155
|
|
|
145
|
-
command =
|
|
156
|
+
command = `node node_modules/@shijiu/jsview/tools/jsview-module-federation.mjs ${argumentsLine}`;
|
|
146
157
|
} else if(options.httpServer) {
|
|
147
158
|
if(isCommandAvailable('serve') == false) {
|
|
148
|
-
Logger.ErrorAndExitNoException("Command
|
|
159
|
+
Logger.ErrorAndExitNoException("Command 'serve' is not found, please install it first by 'npm install -g serve'.");
|
|
149
160
|
}
|
|
150
161
|
if(typeof options.httpServer !== 'string') {
|
|
151
162
|
Logger.ErrorAndExitNoException("Dir path is not found, please set dir by [-t|--http-server]=[DirPath].");
|
|
@@ -153,7 +164,7 @@ function doCommand(options, argv) {
|
|
|
153
164
|
command = `serve -p 8080 --cors ${options.httpServer}`;
|
|
154
165
|
} else if(options.httpsServer) {
|
|
155
166
|
if(isCommandAvailable('serve') == false) {
|
|
156
|
-
Logger.ErrorAndExitNoException("Command
|
|
167
|
+
Logger.ErrorAndExitNoException("Command 'serve' is not found, please install it first by 'npm install -g serve'.");
|
|
157
168
|
}
|
|
158
169
|
if(typeof options.httpsServer !== 'string') {
|
|
159
170
|
Logger.ErrorAndExitNoException("Dir path is not found, please set dir by [-s|--https-server]=[DirPath].");
|
|
@@ -169,6 +180,21 @@ function doCommand(options, argv) {
|
|
|
169
180
|
} else if(options.httpsVite) {
|
|
170
181
|
const exportPrefix = getExportPrefix();
|
|
171
182
|
command = `${exportPrefix} JSVIEW_ENABLE_HTTPS=true && npm start`;
|
|
183
|
+
} else if(options.fowardArkweb) {
|
|
184
|
+
var defaultPort = 9220;
|
|
185
|
+
const port = (typeof(options.fowardArkweb) === 'string' ? options.fowardArkweb : defaultPort);
|
|
186
|
+
if(port !== options.fowardArkweb) {
|
|
187
|
+
Logger.Warn(`Foward webview port is not set, use default value: ${port}`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
command = `hdc shell cat /proc/net/unix | grep devtools`;
|
|
191
|
+
const output = execCommand(command, true);
|
|
192
|
+
if(output.includes('@webview_devtools_remote_') == false) {
|
|
193
|
+
Logger.ErrorAndThrow(`Failed to find foward webview process.`);
|
|
194
|
+
}
|
|
195
|
+
const webviewPid = output.substring(output.indexOf('@') + 1).trim();
|
|
196
|
+
|
|
197
|
+
command = `hdc fport tcp:${port} localabstract:${webviewPid}`;
|
|
172
198
|
}
|
|
173
199
|
|
|
174
200
|
execCommand(command);
|
|
@@ -187,17 +213,19 @@ const requiredUsages = {
|
|
|
187
213
|
'--framework': 'Select from [vue|react]',
|
|
188
214
|
};
|
|
189
215
|
const optionalUsages = {
|
|
190
|
-
'-t | --http-server': '=[DirPath]. Start http server for debug, port is 8080.',
|
|
191
|
-
'-s | --https-server': '=[DirPath]. Start https server for debug, port is 8080.',
|
|
192
|
-
'-v | --http-vite': 'Start vite https server for debug, same as `npm start`',
|
|
193
|
-
'-i | --https-vite': 'Start vite https server for debug.',
|
|
194
216
|
'-a | --runon-android': 'Run app on android devices.',
|
|
195
217
|
'-c | --config-app': 'Config app, like: -c or --config-app=[AppName:AppTitle].',
|
|
196
218
|
'-g | --gen-keypair': 'Generate sign keypair.',
|
|
197
219
|
'-m | --build-minify-exclude': 'Build target with minify-exclude filter, like: -m or --build-minify-exclude=[filter], additional options: -s or --script=build:dev.',
|
|
198
220
|
'-z | --build-zip': 'Build target to offline zip package, like: -z or --build-zip=[password].',
|
|
199
|
-
'-
|
|
221
|
+
'-l | --build-burden-local': 'Build target with local burden files.',
|
|
222
|
+
'-b | --build-burden-baseurl': 'Build target with custom burden base url.',
|
|
200
223
|
'-d | --vue-devtools': 'Start vue dev server and vue-devtools standalone, like: -d or --vue-devtools=[port].',
|
|
224
|
+
'-t | --http-server': '=[DirPath]. Start http server for debug, port is 8080.',
|
|
225
|
+
'-s | --https-server': '=[DirPath]. Start https server for debug, port is 8080.',
|
|
226
|
+
'-v | --http-vite': 'Start vite https server for debug, same as `npm start`',
|
|
227
|
+
'-i | --https-vite': 'Start vite https server for debug.',
|
|
228
|
+
'-p | --foward-arkweb': 'Foward port to openharmony webview devtools, like -p or --foward-arkweb=[port].',
|
|
201
229
|
'-f | --module-federation': 'Make project to module federation, use --module-federation --help for details.',
|
|
202
230
|
};
|
|
203
231
|
const argv = parseArguments(requiredUsages, optionalUsages, true, true, true);
|
package/shijiu-jsview-0.0.0.tgz
DELETED
|
Binary file
|