@shijiu/jsview 2.0.1002 → 2.0.1021
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/jsview-dom-browser.min.js +1 -1
- package/dom/bin/jsview-dom-native.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/target_core_revision.mjs +4 -6
- package/loader/jsview-loader.js +1 -1
- package/package.json +1 -1
- package/tools/jsview-batch-upgrade.mjs +83 -106
- package/tools/jsview-common.mjs +13 -0
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const TargetRevision = {
|
|
6
|
-
"CoreRevision":
|
|
7
|
-
"CoreRevisionAndBranch": "
|
|
8
|
-
"JseRevision": "1.0.
|
|
6
|
+
"CoreRevision": 1021336,
|
|
7
|
+
"CoreRevisionAndBranch": "1021336",
|
|
8
|
+
"JseRevision": "1.0.882",
|
|
9
9
|
"JseUrl":
|
|
10
|
-
"http://cdn.release.qcast.cn/forge_js/master/
|
|
10
|
+
"http://cdn.release.qcast.cn/forge_js/master/JsViewES6_js2c_r882.jsv.1f7c4fd1.js"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// 版本是否存在测试方法
|
|
14
14
|
// 启动参数的UpdateUrl + CoreRevisionAndBranch
|
|
15
15
|
// 例如: https://launcher.cluster.qcast.cn/jsview/version/1021047_release_build_js2c
|
|
16
16
|
|
|
17
|
-
// 不要用export default,update-env脚本不能解析
|
|
18
|
-
// module.exports = TargetRevision;
|
|
19
17
|
export default TargetRevision;
|
package/loader/jsview-loader.js
CHANGED
|
@@ -83,7 +83,7 @@ export default class JsViewLoader {
|
|
|
83
83
|
window.JsView.addKeysMap(this.#config.vendorConfig.bindKeys);
|
|
84
84
|
|
|
85
85
|
// (可选配置)localStorage支持
|
|
86
|
-
window.JsView.setStorageDomain(appName); // Domain为app包名
|
|
86
|
+
window.JsView.setStorageDomain(this.#config.jsviewConfig.localStorage.domain??appName); // Domain为app包名
|
|
87
87
|
|
|
88
88
|
const localStorageKeys = this.#config.jsviewConfig.localStorage.presetKeys;
|
|
89
89
|
window.JsView.enableStorageNames(...localStorageKeys);
|
package/package.json
CHANGED
|
@@ -17,48 +17,43 @@ function main(argv)
|
|
|
17
17
|
const options = getOptions(argv);
|
|
18
18
|
|
|
19
19
|
// Stage 1
|
|
20
|
+
if (options.stages.includes(options.stageAppConfig)) {
|
|
21
|
+
upgradeStageAppConfig(options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Stage 2
|
|
20
25
|
if (options.stages.includes(options.stageAlias)) {
|
|
21
26
|
upgradeStageAlias(options);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
// Stage
|
|
29
|
+
// Stage 3
|
|
25
30
|
if (options.stages.includes(options.stageImportPostfix)) {
|
|
26
31
|
upgradeStageImportPostfix(options);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
// Stage
|
|
34
|
+
// Stage 4
|
|
30
35
|
if (options.stages.includes(options.stageCommonJS)) {
|
|
31
36
|
upgradeStageCommonJS(options);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
// Stage
|
|
39
|
+
// Stage 5
|
|
35
40
|
if (options.stages.includes(options.stageHashHistory)) {
|
|
36
41
|
upgradeStageHashHistory(options);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
// Stage
|
|
44
|
+
// Stage 6
|
|
40
45
|
if (options.stages.includes(options.stageAnimation)) {
|
|
41
46
|
upgradeStageAnimation(options);
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
// Stage 6
|
|
45
|
-
if (options.stages.includes(options.stagePixels)) {
|
|
46
|
-
upgradeStagePixel(options);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
49
|
// Stage 7
|
|
50
|
-
if (options.stages.includes(options.
|
|
51
|
-
|
|
50
|
+
if (options.stages.includes(options.stageJsvAudio)) {
|
|
51
|
+
upgradeStageJsvAudio(options);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Stage 8
|
|
55
|
-
if (options.stages.includes(options.
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Stage 9
|
|
60
|
-
if (options.stages.includes(options.stageMainEntry)) {
|
|
61
|
-
upgradeStageMainEntry(options);
|
|
55
|
+
if (options.stages.includes(options.stagePixels)) {
|
|
56
|
+
upgradeStagePixel(options);
|
|
62
57
|
}
|
|
63
58
|
} catch (ex) {
|
|
64
59
|
console.error('JsView Error: Failed to update jsview source!');
|
|
@@ -72,15 +67,14 @@ function main(argv)
|
|
|
72
67
|
function getOptions(argv)
|
|
73
68
|
{
|
|
74
69
|
const options = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
stageMainEntry: '9',
|
|
70
|
+
stageAppConfig: '1',
|
|
71
|
+
stageAlias: '2',
|
|
72
|
+
stageImportPostfix: '3',
|
|
73
|
+
stageCommonJS: '4',
|
|
74
|
+
stageHashHistory: '5',
|
|
75
|
+
stageAnimation: '6',
|
|
76
|
+
stageJsvAudio: '7',
|
|
77
|
+
stagePixels: '8',
|
|
84
78
|
};
|
|
85
79
|
|
|
86
80
|
options.projectDir = process.cwd();
|
|
@@ -115,6 +109,29 @@ function getOptions(argv)
|
|
|
115
109
|
return options;
|
|
116
110
|
}
|
|
117
111
|
|
|
112
|
+
function upgradeStageAppConfig(options)
|
|
113
|
+
{
|
|
114
|
+
const msgPrefix = 'Stage ' + options.stageAppConfig;
|
|
115
|
+
console.info(msgPrefix + ': Upgrading appConfig...');
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const appConfigDir = path.resolve(options.upgradeDir, 'appConfig');
|
|
119
|
+
if (fs.existsSync(appConfigDir) == false) {
|
|
120
|
+
console.error(msgPrefix + ': Failed to upgrading appConfig, appConfig folder is not found.');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const appConfigFilePath = path.resolve(appConfigDir, 'app_config.json');
|
|
125
|
+
|
|
126
|
+
renameStageFile(options, [ appConfigFilePath ], msgPrefix,
|
|
127
|
+
[ 'app_config.json' ], 'app.config.mjs');
|
|
128
|
+
|
|
129
|
+
renameStageFile(options, [ appConfigFilePath ], msgPrefix,
|
|
130
|
+
[ 'jsview.config.js' ], 'jsview.config.mjs');
|
|
131
|
+
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
118
135
|
function upgradeStageAlias(options)
|
|
119
136
|
{
|
|
120
137
|
const msgPrefix = 'Stage ' + options.stageAlias;
|
|
@@ -271,8 +288,6 @@ function upgradeStagePixel(options) {
|
|
|
271
288
|
'top',
|
|
272
289
|
'width',
|
|
273
290
|
|
|
274
|
-
'borderRadius',
|
|
275
|
-
|
|
276
291
|
'fontSize',
|
|
277
292
|
'lineHeight',
|
|
278
293
|
];
|
|
@@ -288,59 +303,19 @@ function upgradeStagePixel(options) {
|
|
|
288
303
|
return;
|
|
289
304
|
}
|
|
290
305
|
|
|
291
|
-
function
|
|
306
|
+
function upgradeStageJsvAudio(options)
|
|
292
307
|
{
|
|
293
|
-
const msgPrefix = 'Stage ' + options.
|
|
294
|
-
console.info(msgPrefix + ': Upgrading
|
|
308
|
+
const msgPrefix = 'Stage ' + options.stageJsvAudio;
|
|
309
|
+
console.info(msgPrefix + ': Upgrading jsv audio...');
|
|
295
310
|
|
|
296
|
-
|
|
297
|
-
|
|
311
|
+
const amendJsvAudio = function(content) {
|
|
312
|
+
let fixedContent = content.replace('<audiotrack', '<jsv-audiotrack');
|
|
313
|
+
fixedContent = fixedContent.replace(/import *JsvAudio *from.*/, "import { JsvAudio } from 'jsview'");
|
|
298
314
|
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function upgradeStageAppConfig(options)
|
|
303
|
-
{
|
|
304
|
-
const msgPrefix = 'Stage ' + options.stageAppConfig;
|
|
305
|
-
console.info(msgPrefix + ': Upgrading appConfig...');
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const appConfigDir = path.resolve(options.upgradeDir, 'appConfig');
|
|
309
|
-
if (fs.existsSync(appConfigDir) == false) {
|
|
310
|
-
console.error(msgPrefix + ': Failed to upgrading appConfig, appConfig folder is not found.');
|
|
311
|
-
process.exit(1);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const appConfigFilePath = path.resolve(appConfigDir, 'app_config.json');
|
|
315
|
-
|
|
316
|
-
removeStageFile(options, [ appConfigFilePath ], msgPrefix,
|
|
317
|
-
[ 'app_config.json' ], 'app.config.json');
|
|
318
|
-
|
|
319
|
-
const sourcePathList = getFilesRecursive(appConfigDir);
|
|
320
|
-
|
|
321
|
-
removeStageFile(options, sourcePathList, msgPrefix,
|
|
322
|
-
[ '.js', '.json' ], '.mjs');
|
|
323
|
-
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function upgradeStageMainEntry(options)
|
|
328
|
-
{
|
|
329
|
-
const msgPrefix = 'Stage ' + options.stageMainEntry;
|
|
330
|
-
console.info(msgPrefix + ': Upgrading main entry...');
|
|
331
|
-
|
|
332
|
-
const mainEntryFilePath = path.resolve(options.upgradeDir, 'main.ts');
|
|
333
|
-
const fixedMainEntryFilePath = path.resolve(options.upgradeDir, 'main.tsx');
|
|
334
|
-
if (fs.existsSync(mainEntryFilePath) == false) {
|
|
335
|
-
if (fs.existsSync(fixedMainEntryFilePath)) {
|
|
336
|
-
return 0;
|
|
337
|
-
}
|
|
338
|
-
console.error(msgPrefix + ': Failed to upgrading main entry, main.ts is not found.');
|
|
339
|
-
process.exit(1);
|
|
315
|
+
return fixedContent;
|
|
340
316
|
}
|
|
341
317
|
|
|
342
|
-
|
|
343
|
-
[ 'main.ts' ], 'main.tsx');
|
|
318
|
+
processSourceLineByLine(options, options.sourcePathList, msgPrefix, amendJsvAudio);
|
|
344
319
|
|
|
345
320
|
return;
|
|
346
321
|
}
|
|
@@ -426,7 +401,7 @@ function replaceStageContent(options, sourcePathList, msgPrefix,
|
|
|
426
401
|
return;
|
|
427
402
|
}
|
|
428
403
|
|
|
429
|
-
function
|
|
404
|
+
function renameStageFile(options, sourcePathList, msgPrefix,
|
|
430
405
|
fromExtNameList, toExtName)
|
|
431
406
|
{
|
|
432
407
|
for (const filePath of sourcePathList) {
|
|
@@ -445,13 +420,13 @@ function removeStageFile(options, sourcePathList, msgPrefix,
|
|
|
445
420
|
fs.renameSync(filePath, toFilePath)
|
|
446
421
|
|
|
447
422
|
// json => mjs
|
|
448
|
-
if (fromExtName
|
|
423
|
+
if (fromExtName.endsWith('.json')) {
|
|
449
424
|
const content = fs.readFileSync(toFilePath, 'utf8');
|
|
450
|
-
const fixedContent = 'export default ' + content;
|
|
425
|
+
const fixedContent = 'export default ' + content.replaceAll(/"([^"]+)":/g, '$1:');
|
|
451
426
|
fs.writeFileSync(toFilePath, fixedContent, 'utf8');
|
|
452
427
|
}
|
|
453
428
|
|
|
454
|
-
console.info(msgPrefix + ': Upgraded ' + path.relative(options.projectDir, filePath));
|
|
429
|
+
console.info(msgPrefix + ': Upgraded ' + path.relative(options.projectDir, filePath) + ' => ' + path.relative(options.projectDir, toFilePath));
|
|
455
430
|
}
|
|
456
431
|
|
|
457
432
|
return;
|
|
@@ -512,38 +487,40 @@ function processSourceLineByLine(options, sourcePathList, msgPrefix, processor)
|
|
|
512
487
|
const requiredUsages = {
|
|
513
488
|
'--stages': `Upgrade stages, separate by comma(,). The value means the following:
|
|
514
489
|
|
|
515
|
-
1. Fix
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
=> import somemodule from 'somemodule[.js|.vue|/index.js|/index.vue]',
|
|
520
|
-
* import('somemodule')
|
|
521
|
-
=> import('somemodule[.js|.vue|/index.js|/index.vue]')
|
|
490
|
+
1. Fix appConfig. * app_config.json
|
|
491
|
+
=> app.config.mjs
|
|
492
|
+
* jsview.config.js
|
|
493
|
+
=> jsview.config.mjs
|
|
522
494
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
* module.exports = somemodule
|
|
526
|
-
=> export default somemodule
|
|
527
|
-
* module.exports = {}
|
|
528
|
-
=> export {}
|
|
495
|
+
2. Fix alias: @. * import App from '@/App'
|
|
496
|
+
=> import App from '/src/App'
|
|
529
497
|
|
|
530
|
-
|
|
531
|
-
|
|
498
|
+
3. Fix import postfix. * import somemodule from 'somemodule'
|
|
499
|
+
=> import somemodule from 'somemodule[.js|.vue|/index.js|/index.vue]',
|
|
500
|
+
* import('somemodule')
|
|
501
|
+
=> import('somemodule[.js|.vue|/index.js|/index.vue]')
|
|
532
502
|
|
|
533
|
-
|
|
534
|
-
|
|
503
|
+
4. Fix commonjs. * const somemodule = require('somemodule')
|
|
504
|
+
=> import somemodule from 'somemodule',
|
|
505
|
+
* module.exports = somemodule
|
|
506
|
+
=> export default somemodule
|
|
507
|
+
* module.exports = {}
|
|
508
|
+
=> export {}
|
|
535
509
|
|
|
536
|
-
|
|
537
|
-
|
|
510
|
+
5. Fix hash history. * createJsvHashHistory
|
|
511
|
+
=> jsvCreateHashHistory
|
|
538
512
|
|
|
539
|
-
|
|
540
|
-
|
|
513
|
+
6. Fix animation. * :onAnimationEnd
|
|
514
|
+
=> @animationend
|
|
541
515
|
|
|
542
|
-
|
|
543
|
-
|
|
516
|
+
7. Fix jsv-audio. * <audiotrack>
|
|
517
|
+
=> <jsv-audiotrack>
|
|
518
|
+
* import JsvPlayer from 'jsview'
|
|
519
|
+
=> import { JsvPlayer } from 'jsview'
|
|
544
520
|
|
|
545
|
-
|
|
546
|
-
|
|
521
|
+
8. Fix pixels. * [left, top, width, height, fontSize, lineHeight]="00px"
|
|
522
|
+
=> [left, top, width, height, fontSize, lineHeight]=00
|
|
523
|
+
`
|
|
547
524
|
};
|
|
548
525
|
const optionalUsages = {
|
|
549
526
|
'--dir': 'Upgrade directory, default is [src].',
|
package/tools/jsview-common.mjs
CHANGED
|
@@ -331,6 +331,18 @@ function askAndAnswer(question)
|
|
|
331
331
|
return answer;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
function readJsonFile(filePath) {
|
|
335
|
+
try {
|
|
336
|
+
const pkgJsonContent = fs.readFileSync(filePath, 'utf8');
|
|
337
|
+
const pkgJsonObj = JSON.parse(pkgJsonContent);
|
|
338
|
+
|
|
339
|
+
return pkgJsonObj;
|
|
340
|
+
} catch (ex) {
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
|
|
334
346
|
export {
|
|
335
347
|
askAndAnswer,
|
|
336
348
|
checkNodeVersion,
|
|
@@ -340,6 +352,7 @@ export {
|
|
|
340
352
|
getPackageObject,
|
|
341
353
|
isSymlinkSync,
|
|
342
354
|
parseArguments,
|
|
355
|
+
readJsonFile,
|
|
343
356
|
rmSync,
|
|
344
357
|
symlinkSync,
|
|
345
358
|
}
|