@shijiu/jsview 1.9.760 → 1.9.778

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