@shijiu/jsview 1.9.760 → 1.9.779
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-browser-debug-dom.min.js +1 -1
- package/dom/bin/jsview-dom.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/jsv-dom.js +3 -1
- package/loader/loader.js +3 -3
- package/package.json +7 -8
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +3085 -2968
- package/patches/node_modules/@vue/compiler-sfc/package.json +6 -6
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8123 -8038
- package/patches/node_modules/@vue/runtime-core/package.json +3 -3
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1681 -1663
- package/patches/node_modules/@vue/runtime-dom/package.json +3 -3
- package/patches/node_modules/react-dom/cjs/react-dom.development.js +29868 -0
- package/patches/node_modules/react-dom/cjs/react-dom.production.min.js +323 -0
- package/patches/node_modules/react-dom/package.json +62 -0
- package/patches/node_modules/react-scripts/config/paths.js +4 -1
- package/patches/node_modules/react-scripts/config/webpack.config.js +3 -3
- package/patches/node_modules/vite/dist/node/chunks/{dep-0fc8e132.js → dep-ed9cb113.js} +46837 -46866
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +155 -0
- package/patches/node_modules/vite/package.json +48 -39
- package/patches/node_modules/vue-router/dist/vue-router.mjs +22 -5
- package/patches/node_modules/vue-router/package.json +12 -12
- package/tools/jsview-common.js +169 -0
- package/tools/jsview-jsmap-serve.mjs +127 -0
- package/tools/jsview-post-build.js +63 -55
- package/tools/jsview-post-install.js +92 -42
- package/tools/jsview-run-android.js +46 -38
- package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +0 -7
- package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +0 -7
- package/patches/node_modules/vite/dist/node/jsview.vite.config.js +0 -64
- package/tools/common.js +0 -63
- package/tools/jsview-jsmap-serve.js +0 -105
- package/tools/jsview-post-install-react.js +0 -15
- package/tools/jsview-post-install-vue.js +0 -20
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import http from 'http';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import url from 'url';
|
|
9
|
+
|
|
10
|
+
const context = {
|
|
11
|
+
scriptDir: path.dirname(url.fileURLToPath(import.meta.url)),
|
|
12
|
+
baseUrl: null,
|
|
13
|
+
needRedirect: false,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function requestListener(req, res)
|
|
17
|
+
{
|
|
18
|
+
console.log('[request] ' + req.url);
|
|
19
|
+
|
|
20
|
+
if (req.url.endsWith('.map') == false) { // 只处理 .map 文件
|
|
21
|
+
console.log('JsView Error: Failed to process ' + req.url);
|
|
22
|
+
res.writeHead(404);
|
|
23
|
+
res.end();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 解决 devtools://devtools 引起的 CORS 问题。
|
|
28
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
29
|
+
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
|
|
30
|
+
|
|
31
|
+
if (context.needRedirect) {
|
|
32
|
+
// redirect with 302 HTTP code in response
|
|
33
|
+
let redirectTarget = context.baseUrl + convertMapBaseUrl(req.url)
|
|
34
|
+
console.log(`redirect ${req.url} -> ${redirectTarget}`)
|
|
35
|
+
res.writeHead(302, { 'Location': redirectTarget });
|
|
36
|
+
return res.end();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const fileContent = fs.readFileSync(context.baseUrl + '/' + req.url);
|
|
41
|
+
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
42
|
+
res.write(fileContent);
|
|
43
|
+
} catch (ex) {
|
|
44
|
+
console.log('JsView Error: Failed to process ' + req.url + '\nException: ' + ex);
|
|
45
|
+
res.writeHead(404);
|
|
46
|
+
}
|
|
47
|
+
res.end();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function convertMapBaseUrl(originUrl)
|
|
52
|
+
{
|
|
53
|
+
if (originUrl.startsWith('/map/')) {
|
|
54
|
+
/* 去掉子目录/map/ */
|
|
55
|
+
return originUrl.substr(5);
|
|
56
|
+
} else if (originUrl.startsWith('/')) {
|
|
57
|
+
/* 去掉'/' */
|
|
58
|
+
return originUrl.substring(1, originUrl.length);
|
|
59
|
+
} else {
|
|
60
|
+
return originUrl;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getIPAddress()
|
|
65
|
+
{
|
|
66
|
+
let ret = [];
|
|
67
|
+
|
|
68
|
+
var interfaces = os.networkInterfaces();
|
|
69
|
+
for (var devname in interfaces) {
|
|
70
|
+
var iface = interfaces[devname];
|
|
71
|
+
|
|
72
|
+
for (var i = 0; i < iface.length; i++) {
|
|
73
|
+
var alias = iface[i];
|
|
74
|
+
if (alias.family === 'IPv4' && !alias.internal)
|
|
75
|
+
ret.push(alias.address);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return ret;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseBaseUrl(context, argv)
|
|
82
|
+
{
|
|
83
|
+
context.baseUrl = context.scriptDir;
|
|
84
|
+
if (argv.length < 3) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const redirectPath = argv[2];
|
|
89
|
+
const regex = /^(http|https):\/\//i;
|
|
90
|
+
if (regex.test(redirectPath)) {
|
|
91
|
+
context.baseUrl = redirectPath;
|
|
92
|
+
context.needRedirect = true;
|
|
93
|
+
} else if (redirectPath.startsWith('file://')) {
|
|
94
|
+
context.baseUrl = url.fileURLToPath(redirectPath)
|
|
95
|
+
} else {
|
|
96
|
+
context.baseUrl = path.resolve(process.cwd(), redirectPath);
|
|
97
|
+
}
|
|
98
|
+
if (context.baseUrl.endsWith('/') == false) {
|
|
99
|
+
context.baseUrl += '/';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function main(argv)
|
|
106
|
+
{
|
|
107
|
+
parseBaseUrl(context, argv);
|
|
108
|
+
|
|
109
|
+
const server = http.createServer(requestListener);
|
|
110
|
+
const port = 57245;
|
|
111
|
+
server.listen(port, '0.0.0.0', () => {
|
|
112
|
+
const ipAddrs = getIPAddress();
|
|
113
|
+
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log('SourceMap base url: ' + context.baseUrl)
|
|
116
|
+
console.log('');
|
|
117
|
+
console.log('JsView server running at:');
|
|
118
|
+
console.log('');
|
|
119
|
+
console.log(' - Local: http://localhost:' + port + '/');
|
|
120
|
+
for(const ip of ipAddrs) {
|
|
121
|
+
console.log(' - Network: http://' + ip + ':' + port + '/');
|
|
122
|
+
}
|
|
123
|
+
console.log('');
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main(process.argv);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
const crypto = require('crypto');
|
|
4
5
|
const fs = require('fs');
|
|
5
6
|
const path = require('path');
|
|
7
|
+
const { getOptions } = require('./jsview-common');
|
|
6
8
|
|
|
7
9
|
// main.js处理AppData信息
|
|
8
10
|
async function prepareMainAppData(options, fileMd5)
|
|
@@ -69,7 +71,7 @@ async function prepareMainAppData(options, fileMd5)
|
|
|
69
71
|
}
|
|
70
72
|
// const appConfigText = fs.readFileSync(appConfigFile);
|
|
71
73
|
// const appDataOriginJson = JSON.parse(appConfigText);
|
|
72
|
-
appDataOriginJson = await import(appConfigFile);
|
|
74
|
+
const appDataOriginJson = await import(appConfigFile);
|
|
73
75
|
|
|
74
76
|
// 组装AppData
|
|
75
77
|
let targetAppData = {};
|
|
@@ -80,31 +82,24 @@ async function prepareMainAppData(options, fileMd5)
|
|
|
80
82
|
return JSON.stringify(targetAppData);
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
function signApp(options)
|
|
85
|
+
async function signApp(options)
|
|
84
86
|
{
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return;
|
|
87
|
+
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
88
|
+
for(const fileName of jsFileNames) {
|
|
89
|
+
if (!fileName.endsWith('.js')) {
|
|
90
|
+
continue;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
const
|
|
93
|
-
console.log('
|
|
93
|
+
const filePath = path.resolve(options.distJsDir, fileName);
|
|
94
|
+
// console.log(' -> ' + path.relative(options.projectDir, filePath));
|
|
94
95
|
|
|
95
|
-
var
|
|
96
|
-
jsvAppContents = jsvAppContents.toString();
|
|
96
|
+
var sourceContent = fs.readFileSync(filePath, 'utf8');
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
let mapStr = (jsvAppContents.substring(mapOffset, jsvAppContents.length)).replace(
|
|
100
|
-
'# sourceMappingURL=', '# sourceMappingURL=http://localhost:57245/map/');
|
|
101
|
-
jsvAppContents = jsvAppContents.substring(0, mapOffset) + mapStr;
|
|
102
|
-
|
|
103
|
-
jsvAppContents += '\n'; // 把\n归入算进md5计算中
|
|
98
|
+
sourceContent += '\n'; // 把\n归入算进md5计算中
|
|
104
99
|
|
|
105
|
-
const jsvAppMd5 = crypto.createHash('md5').update(
|
|
100
|
+
const jsvAppMd5 = crypto.createHash('md5').update(sourceContent).digest('hex');
|
|
106
101
|
let appDataInfo = '';
|
|
107
|
-
if (
|
|
102
|
+
if (fileName.indexOf('main.jsv.') >= 0) {
|
|
108
103
|
// 对main文件加入应用头信息
|
|
109
104
|
appDataInfo = await prepareMainAppData(options, jsvAppMd5);
|
|
110
105
|
|
|
@@ -113,54 +108,66 @@ function signApp(options)
|
|
|
113
108
|
const infoLen = new TextEncoder().encode(appDataInfo).length;
|
|
114
109
|
appDataInfo = '/*jsvapp:' + infoLen + ':' + appDataInfo + ':' + infoLen + ':jsvapp*/';
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
fs.writeFileSync(
|
|
118
|
-
}
|
|
111
|
+
sourceContent = sourceContent + appDataInfo + '/*jsvmd5:' + jsvAppMd5 + '*/';
|
|
112
|
+
fs.writeFileSync(filePath, sourceContent, 'utf8');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function redirectSourceMappingURL(options)
|
|
117
|
+
{
|
|
118
|
+
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
119
|
+
for(const fileName of jsFileNames) {
|
|
120
|
+
if (!fileName.endsWith('.js')) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const filePath = path.resolve(options.distJsDir, fileName);
|
|
125
|
+
// console.log(' -> ' + path.relative(options.projectDir, filePath));
|
|
126
|
+
|
|
127
|
+
let sourceContent = fs.readFileSync(filePath, 'utf8');
|
|
128
|
+
|
|
129
|
+
let mapUrlOffset = sourceContent.lastIndexOf('# sourceMappingURL='); // 避免代码中间位置的sourceMappingUrl内容被替换
|
|
130
|
+
let mapUrlStr = (sourceContent.substring(mapUrlOffset, sourceContent.length)).replace(
|
|
131
|
+
'# sourceMappingURL=', '# sourceMappingURL=http://localhost:57245/map/');
|
|
132
|
+
sourceContent = sourceContent.substring(0, mapUrlOffset) + mapUrlStr;
|
|
133
|
+
|
|
134
|
+
fs.writeFileSync(filePath, sourceContent, 'utf8');
|
|
135
|
+
};
|
|
119
136
|
}
|
|
120
137
|
|
|
121
138
|
function makeDebugMap(options)
|
|
122
139
|
{
|
|
123
|
-
fs.mkdirSync(options.
|
|
140
|
+
fs.mkdirSync(options.distDebugMapDir, { recursive: true });
|
|
124
141
|
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return;
|
|
142
|
+
const jsFileNames = fs.readdirSync(options.distJsDir);
|
|
143
|
+
for(const fileName of jsFileNames) {
|
|
144
|
+
if (!fileName.endsWith('.map')) {
|
|
145
|
+
continue;
|
|
130
146
|
}
|
|
131
147
|
|
|
132
|
-
const from = path.resolve(
|
|
133
|
-
const to = path.resolve(options.
|
|
134
|
-
console.log(
|
|
148
|
+
const from = path.resolve(options.distJsDir, fileName);
|
|
149
|
+
const to = path.resolve(options.distDebugMapDir, fileName);
|
|
150
|
+
// console.log(' -> ' + path.relative(options.projectDir, to));
|
|
135
151
|
fs.renameSync(from, to);
|
|
136
|
-
}
|
|
152
|
+
};
|
|
137
153
|
|
|
138
|
-
const jsmapServeName =
|
|
139
|
-
const jsmapServePath = path.resolve(options.
|
|
154
|
+
const jsmapServeName = 'jsview-jsmap-serve.mjs';
|
|
155
|
+
const jsmapServePath = path.resolve(options.jsviewToolsDir, jsmapServeName);
|
|
140
156
|
if (!fs.existsSync(jsmapServePath)) {
|
|
141
|
-
console.error(
|
|
157
|
+
console.error('JsView Error: Failed to copy ' + jsmapServePath + ', file not exists.');
|
|
142
158
|
process.exit(1);
|
|
143
159
|
}
|
|
144
160
|
|
|
145
|
-
const to = path.resolve(options.
|
|
146
|
-
console.log(
|
|
161
|
+
const to = path.resolve(options.distDebugDir, jsmapServeName);
|
|
162
|
+
console.log(' -> ' + path.relative(options.projectDir, to));
|
|
147
163
|
fs.copyFileSync(jsmapServePath, to);
|
|
148
164
|
}
|
|
149
165
|
|
|
150
|
-
function main()
|
|
151
|
-
|
|
152
|
-
options
|
|
153
|
-
options.modulesDir = path.resolve(options.projectDir, "node_modules");
|
|
154
|
-
options.jsviewDir = path.resolve(options.modulesDir, "@shijiu", "jsview");
|
|
155
|
-
options.patchesDir = path.resolve(options.jsviewDir, "patches");
|
|
156
|
-
options.toolsDir = path.resolve(options.jsviewDir, "tools");
|
|
157
|
-
options.distDir = path.resolve(options.projectDir, "dist");
|
|
158
|
-
options.appConfigDir = path.resolve(options.projectDir, "src", "appConfig");
|
|
159
|
-
options.debugDir = path.resolve(options.distDir, "debug");
|
|
160
|
-
options.mapDir = path.resolve(options.debugDir, "map");
|
|
161
|
-
|
|
166
|
+
async function main()
|
|
167
|
+
{
|
|
168
|
+
const options = getOptions();
|
|
162
169
|
|
|
163
|
-
vueConfigFile = path.resolve(options.projectDir, 'vue.config.js');
|
|
170
|
+
const vueConfigFile = path.resolve(options.projectDir, 'vue.config.js');
|
|
164
171
|
if (fs.existsSync(vueConfigFile)) {
|
|
165
172
|
vueCfgObj = require(vueConfigFile);
|
|
166
173
|
if(vueCfgObj.outputDir) {
|
|
@@ -168,16 +175,17 @@ function main() {
|
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
177
|
|
|
171
|
-
console.info('Signing JsView App...');
|
|
172
|
-
console.info();
|
|
173
|
-
signApp(options);
|
|
174
178
|
console.info();
|
|
179
|
+
console.info('Redirecting JsView source map...');
|
|
180
|
+
redirectSourceMappingURL(options)
|
|
181
|
+
console.info('Redirected JsView source map...');
|
|
182
|
+
|
|
183
|
+
console.info('Signing JsView App...');
|
|
184
|
+
await signApp(options);
|
|
175
185
|
console.info('Signed JsView App.');
|
|
176
186
|
|
|
177
187
|
console.info('Making JsView Debug map...');
|
|
178
|
-
console.info();
|
|
179
188
|
makeDebugMap(options);
|
|
180
|
-
console.info();
|
|
181
189
|
console.info('Made JsView Debug map.');
|
|
182
190
|
}
|
|
183
191
|
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
const fs = require('fs');
|
|
4
5
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const url = require('url');
|
|
7
|
+
const {
|
|
8
|
+
cpSync,
|
|
9
|
+
getOptions,
|
|
10
|
+
getPackageObject,
|
|
11
|
+
parseArguments,
|
|
12
|
+
symlinkSync,
|
|
13
|
+
rmSync
|
|
14
|
+
} = require('./jsview-common');
|
|
15
|
+
|
|
16
|
+
function checkNpmCommand()
|
|
17
|
+
{
|
|
9
18
|
let command = process.env.npm_command;
|
|
10
19
|
if(!command) {
|
|
11
20
|
command = process.env.npm_config_refer; // for linux
|
|
@@ -20,54 +29,61 @@ function checkNpmCommand() {
|
|
|
20
29
|
console.warn();
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
function
|
|
32
|
+
function checkNpmLinkForDebug(options, linkablePkgNames)
|
|
24
33
|
{
|
|
25
|
-
const
|
|
26
|
-
if (!fs.existsSync(pkgFullFile)) {
|
|
27
|
-
console.error('Error: Failed to install jsview patches, "' + path.relative(options.projectDir, pkgFullFile) + '" is not exists.');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
const pkgObj = require(pkgFullFile);
|
|
34
|
+
const pkgObj = getPackageObject(options.projectDir);
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
for (const linkableName of linkablePkgNames) {
|
|
37
|
+
let linkableTarget = pkgObj.dependencies?.[linkableName];
|
|
38
|
+
if (!linkableTarget || !linkableTarget.startsWith('file:')) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
linkableTarget = linkableTarget.replace('file:', '');
|
|
43
|
+
const linkableTargetPath = path.resolve(options.projectDir, linkableTarget);
|
|
44
|
+
const linkablePath = path.resolve(options.modulesDir, linkableName);
|
|
45
|
+
symlinkSync(linkableTargetPath, linkablePath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
function checkPatches(options, pkgNeedPatch, skipCheckVersion)
|
|
50
|
+
{
|
|
51
|
+
console.info('Checking package:');
|
|
52
|
+
for (const pkgName of pkgNeedPatch) {
|
|
53
|
+
if (skipCheckVersion !== true) {
|
|
54
|
+
const patchPkgDir = path.resolve(options.jsviewPatchModulesDir, pkgName);
|
|
55
|
+
const patchPkgObj = getPackageObject(options, patchPkgDir);
|
|
56
|
+
console.info(' ' + pkgName + ': ' + patchPkgObj.version);
|
|
57
|
+
|
|
58
|
+
const modulePkgDir = path.resolve(options.modulesDir, pkgName);
|
|
59
|
+
const modulePkgObj = getPackageObject(modulePkgDir);
|
|
43
60
|
if (modulePkgObj.version != patchPkgObj.version) {
|
|
44
61
|
console.error('Error: ' + pkgName + '@' + modulePkgObj.version + ' is not supported, required version is ' + patchPkgObj.version);
|
|
45
62
|
process.exit(1);
|
|
46
63
|
}
|
|
47
64
|
} else {
|
|
48
|
-
console.info(
|
|
65
|
+
console.info(' Skip ', pkgName);
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
68
|
}
|
|
52
69
|
|
|
53
|
-
function installPatches(options, pkgNeedPatch)
|
|
70
|
+
function installPatches(options, pkgNeedPatch)
|
|
71
|
+
{
|
|
54
72
|
console.info('\nPatching JsView:');
|
|
55
|
-
for (pkgName of pkgNeedPatch) {
|
|
56
|
-
const patchSrc = path.resolve(options.
|
|
73
|
+
for (const pkgName of pkgNeedPatch) {
|
|
74
|
+
const patchSrc = path.resolve(options.jsviewPatchModulesDir, pkgName);
|
|
57
75
|
const patchDest = path.resolve(options.modulesDir, pkgName);
|
|
58
76
|
|
|
59
77
|
cpSync(options.projectDir, patchSrc, patchDest, ['package.json']);
|
|
60
78
|
}
|
|
61
79
|
|
|
62
80
|
console.info('\nCleanup node_modules cache... ');
|
|
63
|
-
|
|
64
|
-
rmSync(nodeModuleCacheDir);
|
|
81
|
+
rmSync(options.cacheDir);
|
|
65
82
|
}
|
|
66
83
|
|
|
67
|
-
async function printRevision(options)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const jsviewVersionURL = pathToFileURL(jsviewVersionFile);
|
|
84
|
+
async function printRevision(options)
|
|
85
|
+
{
|
|
86
|
+
const jsviewVersionURL = url.pathToFileURL(options.jsviewRevisionFile);
|
|
71
87
|
const { default: jsviewTargetVersion } = await import(jsviewVersionURL);
|
|
72
88
|
|
|
73
89
|
console.log('**************************************************');
|
|
@@ -81,8 +97,9 @@ async function printRevision(options) {
|
|
|
81
97
|
{
|
|
82
98
|
let pluginDirPath = path.resolve(options.jsviewFrameworkDir, 'utils', 'JsViewPlugin');
|
|
83
99
|
if(fs.existsSync(pluginDirPath)) {
|
|
84
|
-
fs.readdirSync(pluginDirPath)
|
|
85
|
-
|
|
100
|
+
const pluginFileNames = fs.readdirSync(pluginDirPath);
|
|
101
|
+
for(const fileName of pluginFileNames) {
|
|
102
|
+
var pathname = path.resolve(pluginDirPath, fileName);
|
|
86
103
|
if (fs.statSync(pathname).isDirectory()) {
|
|
87
104
|
let versionFilePath = path.resolve(pathname, 'version.js');
|
|
88
105
|
if (fs.existsSync(versionFilePath)) {
|
|
@@ -101,17 +118,23 @@ async function printRevision(options) {
|
|
|
101
118
|
console.log('**************************************************');
|
|
102
119
|
}
|
|
103
120
|
|
|
104
|
-
function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
|
|
105
|
-
|
|
121
|
+
function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
|
|
122
|
+
{
|
|
123
|
+
const options = getOptions(framework);
|
|
106
124
|
options.projectDir = process.cwd();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
|
|
126
|
+
const linkablePkgNames = [
|
|
127
|
+
'@shijiu/jsview',
|
|
128
|
+
'@shijiu/jsview-vue',
|
|
129
|
+
'@shijiu/jsview-vue-samples',
|
|
130
|
+
'@shijiu/jsview-react',
|
|
131
|
+
'@shijiu/jsview-react-samples',
|
|
132
|
+
]
|
|
112
133
|
|
|
113
134
|
checkNpmCommand();
|
|
114
135
|
|
|
136
|
+
checkNpmLinkForDebug(options, linkablePkgNames);
|
|
137
|
+
|
|
115
138
|
checkPatches(options, pkgNeedPatch, skipCheckVersion);
|
|
116
139
|
|
|
117
140
|
installPatches(options, pkgNeedPatch);
|
|
@@ -119,6 +142,33 @@ function doPostInstall(framework, pkgNeedPatch, skipCheckVersion) {
|
|
|
119
142
|
printRevision(options);
|
|
120
143
|
}
|
|
121
144
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
145
|
+
function main(argv)
|
|
146
|
+
{
|
|
147
|
+
let pkgNeedPatch;
|
|
148
|
+
|
|
149
|
+
switch (argv.framework) {
|
|
150
|
+
case 'vue':
|
|
151
|
+
pkgNeedPatch = [
|
|
152
|
+
'@vue/compiler-sfc',
|
|
153
|
+
'@vue/runtime-core',
|
|
154
|
+
'@vue/runtime-dom',
|
|
155
|
+
'postcss-js',
|
|
156
|
+
'vite',
|
|
157
|
+
'vue-router',
|
|
158
|
+
];
|
|
159
|
+
break;
|
|
160
|
+
case 'react':
|
|
161
|
+
pkgNeedPatch = [
|
|
162
|
+
'react-dom',
|
|
163
|
+
'react-scripts',
|
|
164
|
+
];
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error('JsView Error: Failed to support framework: ' + framework);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
doPostInstall(argv.framework, pkgNeedPatch, argv.skipCheckVersion);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const argv = parseArguments();
|
|
174
|
+
main(argv);
|
|
@@ -1,53 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
const childProcess = require('child_process');
|
|
4
5
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
+
const url = require('url');
|
|
7
|
+
const {
|
|
8
|
+
getOptions,
|
|
9
|
+
parseArguments
|
|
10
|
+
} = require('./jsview-common');
|
|
6
11
|
|
|
7
|
-
async function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
async function getExtraOptions(argv)
|
|
13
|
+
{
|
|
14
|
+
const options = getOptions(argv.framework);
|
|
15
|
+
options.androidPackage = 'com.tvcode.sjcenter/com.tvcode.chmarket.MainActivity';
|
|
16
|
+
options.jsviewCoreRevision = null;
|
|
17
|
+
options.jsviewEngineUrl = null;
|
|
18
|
+
options.entryUrl = null;
|
|
14
19
|
|
|
15
|
-
if (
|
|
16
|
-
options.androidPackage =
|
|
20
|
+
if (argv.unparsed.length > 0) {
|
|
21
|
+
options.androidPackage = argv.unparsed[0];
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const jsviewRevisionFile = url.pathToFileURL(options.jsviewRevisionFile);
|
|
25
|
+
const { default: jsviewTargetRevision } = await import(jsviewRevisionFile);
|
|
26
|
+
options.jsviewCoreRevision = jsviewTargetRevision.CoreRevision;
|
|
27
|
+
options.jsviewEngineUrl = jsviewTargetRevision.JseUrl;
|
|
28
|
+
|
|
29
|
+
const baseUrlFile = url.pathToFileURL(options.baseUrlFile);
|
|
30
|
+
let { default: baseUrl } = await import(baseUrlFile);
|
|
31
|
+
baseUrl = baseUrl.replace(/\u001b\[.*?m/g, '')
|
|
32
|
+
options.entryUrl = baseUrl + 'js/main.jsv.js';
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
options.homepageUrl = homepageDomain + "js/main.jsv.js?module=true";
|
|
34
|
+
if (argv.framework === 'vue') {
|
|
35
|
+
options.entryUrl += '?module=true';
|
|
36
|
+
}
|
|
32
37
|
|
|
33
38
|
return options;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
function printRevision(options)
|
|
37
|
-
|
|
38
|
-
console.log(
|
|
39
|
-
console.log(
|
|
40
|
-
console.log(
|
|
41
|
-
console.log(
|
|
42
|
-
console.log(
|
|
41
|
+
function printRevision(options)
|
|
42
|
+
{
|
|
43
|
+
console.log('**************************************************');
|
|
44
|
+
console.log('* Android Package: ' + options.androidPackage);
|
|
45
|
+
console.log('* Core: ' + options.jsviewCoreRevision);
|
|
46
|
+
console.log('* Engine JS url: ' + options.jsviewEngineUrl);
|
|
47
|
+
console.log('* Homepage url: ' + options.entryUrl);
|
|
48
|
+
console.log('**************************************************');
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
function androidStartActivity(options)
|
|
46
|
-
|
|
51
|
+
function androidStartActivity(options)
|
|
52
|
+
{
|
|
53
|
+
let cmdline = 'adb shell am start';
|
|
47
54
|
cmdline += ` -n ${options.androidPackage}`;
|
|
48
|
-
cmdline += ` --es COREVERSIONRANGE "${options.
|
|
49
|
-
cmdline += ` --es ENGINE "${options.
|
|
50
|
-
cmdline += ` --es URL "${options.
|
|
55
|
+
cmdline += ` --es COREVERSIONRANGE "${options.jsviewCoreRevision}"`;
|
|
56
|
+
cmdline += ` --es ENGINE "${options.jsviewEngineUrl}"`;
|
|
57
|
+
cmdline += ` --es URL "${options.entryUrl}"`;
|
|
51
58
|
console.log(`Run command: ${cmdline}\n`);
|
|
52
59
|
try {
|
|
53
60
|
childProcess.execSync(cmdline, {stdio: [0, 1, 2]});
|
|
@@ -56,12 +63,13 @@ function androidStartActivity(options) {
|
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
async function main()
|
|
61
|
-
|
|
66
|
+
const argv = parseArguments(false);
|
|
67
|
+
async function main(argv)
|
|
68
|
+
{
|
|
69
|
+
const options = await getExtraOptions(argv);
|
|
62
70
|
|
|
63
71
|
printRevision(options);
|
|
64
72
|
|
|
65
73
|
androidStartActivity(options);
|
|
66
74
|
}
|
|
67
|
-
main()
|
|
75
|
+
main(argv)
|