@shijiu/jsview 2.0.999 → 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/loader/jsview-main.mjs +2 -2
- package/package.json +1 -1
- package/tools/jsview-batch-upgrade.mjs +95 -118
- 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/loader/jsview-main.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import AppData from '/src/appConfig/app.config'
|
|
2
|
-
import JsViewVendorConfig from "/src/appConfig/jsview.config"
|
|
1
|
+
import AppData from '/src/appConfig/app.config.mjs'
|
|
2
|
+
import JsViewVendorConfig from "/src/appConfig/jsview.config.mjs"
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
let JsViewLoader = null;
|
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 5
|
|
40
|
-
if (options.stages.includes(options.stagePixels)) {
|
|
41
|
-
upgradeStagePixel(options);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
44
|
// Stage 6
|
|
45
45
|
if (options.stages.includes(options.stageAnimation)) {
|
|
46
46
|
upgradeStageAnimation(options);
|
|
47
47
|
}
|
|
48
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
|
-
|
|
70
|
+
stageAppConfig: '1',
|
|
71
|
+
stageAlias: '2',
|
|
72
|
+
stageImportPostfix: '3',
|
|
73
|
+
stageCommonJS: '4',
|
|
74
|
+
stageHashHistory: '5',
|
|
80
75
|
stageAnimation: '6',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
stageMainEntry: '9',
|
|
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;
|
|
@@ -126,11 +143,11 @@ function upgradeStageAlias(options)
|
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
let filePath = getImportFilePath(content);
|
|
129
|
-
if (!filePath || filePath.startsWith('
|
|
146
|
+
if (!filePath || filePath.startsWith('@/') == false) {
|
|
130
147
|
return content;
|
|
131
148
|
}
|
|
132
149
|
|
|
133
|
-
let fixedFilePath = filePath.replace(
|
|
150
|
+
let fixedFilePath = filePath.replace(/^@\//, '/src/');
|
|
134
151
|
const fixedContent = content.replace(filePath, fixedFilePath);
|
|
135
152
|
|
|
136
153
|
return fixedContent;
|
|
@@ -159,7 +176,7 @@ function upgradeStageImportPostfix(options)
|
|
|
159
176
|
let fixedFilePath = null;
|
|
160
177
|
if (filePath.startsWith('/')) {
|
|
161
178
|
fixedFilePath = path.resolve(options.projectDir, filePath.replace('/', ''));
|
|
162
|
-
} else if (filePath.startsWith('
|
|
179
|
+
} else if (filePath.startsWith('@/')) {
|
|
163
180
|
fixedFilePath = path.resolve(options.projectDir, 'src', filePath.replace('@/', ''));
|
|
164
181
|
} else {
|
|
165
182
|
fixedFilePath = path.resolve(sourceDir, filePath);
|
|
@@ -227,6 +244,17 @@ function upgradeStageHashHistory(options)
|
|
|
227
244
|
return;
|
|
228
245
|
}
|
|
229
246
|
|
|
247
|
+
function upgradeStageAnimation(options)
|
|
248
|
+
{
|
|
249
|
+
const msgPrefix = 'Stage ' + options.stageAnimation;
|
|
250
|
+
console.info(msgPrefix + ': Upgrading animation...');
|
|
251
|
+
|
|
252
|
+
const ret = replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
253
|
+
':onAnimationEnd', '@animationend');
|
|
254
|
+
|
|
255
|
+
return ret;
|
|
256
|
+
}
|
|
257
|
+
|
|
230
258
|
function upgradeStagePixel(options) {
|
|
231
259
|
const msgPrefix = 'Stage ' + options.stagePixels;
|
|
232
260
|
console.info(msgPrefix + ': Upgrading pixels...');
|
|
@@ -260,8 +288,6 @@ function upgradeStagePixel(options) {
|
|
|
260
288
|
'top',
|
|
261
289
|
'width',
|
|
262
290
|
|
|
263
|
-
'borderRadius',
|
|
264
|
-
|
|
265
291
|
'fontSize',
|
|
266
292
|
'lineHeight',
|
|
267
293
|
];
|
|
@@ -277,70 +303,19 @@ function upgradeStagePixel(options) {
|
|
|
277
303
|
return;
|
|
278
304
|
}
|
|
279
305
|
|
|
280
|
-
function
|
|
281
|
-
{
|
|
282
|
-
const msgPrefix = 'Stage ' + options.stageAnimation;
|
|
283
|
-
console.info(msgPrefix + ': Upgrading animation...');
|
|
284
|
-
|
|
285
|
-
const ret = replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
286
|
-
':onAnimationEnd', '@animationend');
|
|
287
|
-
|
|
288
|
-
return ret;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function upgradeStageAudiotrack(options)
|
|
306
|
+
function upgradeStageJsvAudio(options)
|
|
292
307
|
{
|
|
293
|
-
const msgPrefix = 'Stage ' + options.
|
|
294
|
-
console.info(msgPrefix + ': Upgrading
|
|
295
|
-
|
|
296
|
-
replaceStageContent(options, options.sourcePathList, msgPrefix,
|
|
297
|
-
'<audiotrack', '<jsv-audiotrack');
|
|
308
|
+
const msgPrefix = 'Stage ' + options.stageJsvAudio;
|
|
309
|
+
console.info(msgPrefix + ': Upgrading jsv audio...');
|
|
298
310
|
|
|
299
|
-
|
|
300
|
-
|
|
311
|
+
const amendJsvAudio = function(content) {
|
|
312
|
+
let fixedContent = content.replace('<audiotrack', '<jsv-audiotrack');
|
|
313
|
+
fixedContent = fixedContent.replace(/import *JsvAudio *from.*/, "import { JsvAudio } from 'jsview'");
|
|
301
314
|
|
|
302
|
-
|
|
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
|
}
|