@shijiu/jsview 2.1.448-test.0 → 2.1.482-test.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/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/package.json +1 -1
- package/patches/node_modules/@originjs/vite-plugin-federation/1.3.4/@originjs+vite-plugin-federation+1.3.4.patch +50 -6
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +1 -1
- package/tools/jsview-common.mjs +32 -1
- package/tools/jsview-logger.js +12 -0
- package/tools/jsview-run-tool.mjs +27 -30
- package/tools/jsview-vue-devtools.mjs +97 -0
package/package.json
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
diff --git a/node_modules/@originjs/vite-plugin-federation/dist/index.js b/node_modules/@originjs/vite-plugin-federation/dist/index.js
|
|
2
|
-
index 980b8e3..
|
|
2
|
+
index 980b8e3..534e796 100644
|
|
3
3
|
--- a/node_modules/@originjs/vite-plugin-federation/dist/index.js
|
|
4
4
|
+++ b/node_modules/@originjs/vite-plugin-federation/dist/index.js
|
|
5
|
-
@@ -
|
|
5
|
+
@@ -301,11 +301,20 @@ function createRemotesMap(remotes) {
|
|
6
|
+
return `'${external}'`;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
+// JsView Modified >>>
|
|
10
|
+
+// return `const remotesMap = {
|
|
11
|
+
+// ${remotes.map(
|
|
12
|
+
+// (remote) => `'${remote.id}':{url:${createUrl(remote)},format:'${remote.config.format}',from:'${remote.config.from}'}`
|
|
13
|
+
+// ).join(",\n ")}
|
|
14
|
+
+// };`;
|
|
15
|
+
return `const remotesMap = {
|
|
16
|
+
${remotes.map(
|
|
17
|
+
(remote) => `'${remote.id}':{url:${createUrl(remote)},format:'${remote.config.format}',from:'${remote.config.from}'}`
|
|
18
|
+
).join(",\n ")}
|
|
19
|
+
-};`;
|
|
20
|
+
+};;
|
|
21
|
+
+window.JsvCode.Federation = { remotesMap };
|
|
22
|
+
+`;
|
|
23
|
+
+// JsView Modified <<<
|
|
24
|
+
}
|
|
25
|
+
function getFileExtname(url) {
|
|
26
|
+
const fileNameAndParamArr = normalizePath(url).split("/");
|
|
27
|
+
@@ -970,8 +979,11 @@ function prodExposePlugin(options) {
|
|
6
28
|
const filepathMap = /* @__PURE__ */ new Map();
|
|
7
29
|
const getFilename = (name) => path.parse(path.parse(name).name).name;
|
|
8
30
|
const cssBundlesMap = Object.keys(bundle).filter((name) => path.extname(name) === ".css").reduce((res, name) => {
|
|
@@ -16,7 +38,7 @@ index 980b8e3..48baae5 100644
|
|
|
16
38
|
return res;
|
|
17
39
|
}, /* @__PURE__ */ new Map());
|
|
18
40
|
remoteEntryChunk.code = remoteEntryChunk.code.replace(
|
|
19
|
-
@@ -1481,6 +
|
|
41
|
+
@@ -1481,6 +1493,16 @@ function federation(options) {
|
|
20
42
|
}
|
|
21
43
|
builderInfo.builder = "vite";
|
|
22
44
|
builderInfo.assetsDir = ((_b = config == null ? void 0 : config.build) == null ? void 0 : _b.assetsDir) ?? "assets";
|
|
@@ -34,10 +56,32 @@ index 980b8e3..48baae5 100644
|
|
|
34
56
|
configureServer(server) {
|
|
35
57
|
var _a;
|
|
36
58
|
diff --git a/node_modules/@originjs/vite-plugin-federation/dist/index.mjs b/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
37
|
-
index 57bae8f..
|
|
59
|
+
index 57bae8f..3b3c2c1 100644
|
|
38
60
|
--- a/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
39
61
|
+++ b/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
40
|
-
@@ -
|
|
62
|
+
@@ -284,11 +284,20 @@ function createRemotesMap(remotes) {
|
|
63
|
+
return `'${external}'`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
+// JsView Modified >>>
|
|
67
|
+
+// return `const remotesMap = {
|
|
68
|
+
+// ${remotes.map(
|
|
69
|
+
+// (remote) => `'${remote.id}':{url:${createUrl(remote)},format:'${remote.config.format}',from:'${remote.config.from}'}`
|
|
70
|
+
+// ).join(",\n ")}
|
|
71
|
+
+// };`;
|
|
72
|
+
return `const remotesMap = {
|
|
73
|
+
${remotes.map(
|
|
74
|
+
(remote) => `'${remote.id}':{url:${createUrl(remote)},format:'${remote.config.format}',from:'${remote.config.from}'}`
|
|
75
|
+
).join(",\n ")}
|
|
76
|
+
-};`;
|
|
77
|
+
+};;
|
|
78
|
+
+window.JsvCode.Federation = { remotesMap };
|
|
79
|
+
+`;
|
|
80
|
+
+// JsView Modified <<<
|
|
81
|
+
}
|
|
82
|
+
function getFileExtname(url) {
|
|
83
|
+
const fileNameAndParamArr = normalizePath(url).split("/");
|
|
84
|
+
@@ -953,8 +962,11 @@ function prodExposePlugin(options) {
|
|
41
85
|
const filepathMap = /* @__PURE__ */ new Map();
|
|
42
86
|
const getFilename = (name) => parse(parse(name).name).name;
|
|
43
87
|
const cssBundlesMap = Object.keys(bundle).filter((name) => extname(name) === ".css").reduce((res, name) => {
|
|
@@ -51,7 +95,7 @@ index 57bae8f..9320e8d 100644
|
|
|
51
95
|
return res;
|
|
52
96
|
}, /* @__PURE__ */ new Map());
|
|
53
97
|
remoteEntryChunk.code = remoteEntryChunk.code.replace(
|
|
54
|
-
@@ -1464,6 +
|
|
98
|
+
@@ -1464,6 +1476,16 @@ function federation(options) {
|
|
55
99
|
}
|
|
56
100
|
builderInfo.builder = "vite";
|
|
57
101
|
builderInfo.assetsDir = ((_b = config == null ? void 0 : config.build) == null ? void 0 : _b.assetsDir) ?? "assets";
|
package/tools/jsview-common.mjs
CHANGED
|
@@ -350,6 +350,18 @@ function execCommand(cmdline, withOutput)
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
function execCommandAsync(cmdline)
|
|
354
|
+
{
|
|
355
|
+
Logger.Info('Run [' + cmdline + ']... ');
|
|
356
|
+
const child = childProcess.exec(cmdline);
|
|
357
|
+
child.stdout.on('data', (data) => {
|
|
358
|
+
console.log(data);
|
|
359
|
+
});
|
|
360
|
+
child.stderr.on('data', (data) => {
|
|
361
|
+
Logger.ErrorAndExit(data)
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
353
365
|
function checkNodeVersion(minMajorVersion = 16)
|
|
354
366
|
{
|
|
355
367
|
const versions = process.version.replace('v', '').split('.');
|
|
@@ -466,6 +478,23 @@ function getNpmRegistry()
|
|
|
466
478
|
return 'https://nexus.cluster.qcast.cn/repository/npm-public';
|
|
467
479
|
}
|
|
468
480
|
|
|
481
|
+
function getNetworkIpv4Addresses() {
|
|
482
|
+
const addresses = [];
|
|
483
|
+
const interfaces = os.networkInterfaces();
|
|
484
|
+
for (const devName in interfaces) {
|
|
485
|
+
const iface = interfaces[devName];
|
|
486
|
+
|
|
487
|
+
for (var idx = 0; idx < iface.length; idx++) {
|
|
488
|
+
var alias = iface[idx];
|
|
489
|
+
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
|
|
490
|
+
addresses.push(alias.address);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return addresses;
|
|
496
|
+
}
|
|
497
|
+
|
|
469
498
|
export {
|
|
470
499
|
askAndAnswer,
|
|
471
500
|
checkNodeVersion,
|
|
@@ -473,8 +502,10 @@ export {
|
|
|
473
502
|
cpSync,
|
|
474
503
|
downloadFileAsync,
|
|
475
504
|
execCommand,
|
|
476
|
-
|
|
505
|
+
execCommandAsync,
|
|
506
|
+
getNetworkIpv4Addresses,
|
|
477
507
|
getNpmRegistry,
|
|
508
|
+
getOptions,
|
|
478
509
|
isSymlinkSync,
|
|
479
510
|
loadPackageObject,
|
|
480
511
|
makeZip,
|
package/tools/jsview-logger.js
CHANGED
|
@@ -13,6 +13,10 @@ class Logger {
|
|
|
13
13
|
process.exit(1);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
static ErrorAndExitNoSilent(...args) {
|
|
17
|
+
Logger.ErrorNoException(...args);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
static ErrorAndThrow(...args) {
|
|
18
22
|
Logger.Error(...args);
|
|
@@ -49,6 +53,14 @@ class Logger {
|
|
|
49
53
|
console.warn(Logger.Yellow(Logger.Bold('JsView Warning:')), ...args);
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
static Tip(...args) {
|
|
57
|
+
const size = args?.length ?? 0;
|
|
58
|
+
for(let idx = 0; idx < size; idx++) {
|
|
59
|
+
args[idx] = Logger.Blue(Logger.Bold(args[idx]));
|
|
60
|
+
}
|
|
61
|
+
console.info(...args);
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
static Info(...args) {
|
|
53
65
|
console.info(Logger.Green('JsView Info:'), ...args);
|
|
54
66
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
askAndAnswer,
|
|
6
6
|
checkNodeVersion,
|
|
7
|
+
getNetworkIpv4Addresses,
|
|
7
8
|
getOptions,
|
|
8
9
|
parseArguments,
|
|
9
10
|
Logger,
|
|
@@ -27,6 +28,7 @@ async function getExtraOptions(argv)
|
|
|
27
28
|
commandCount += (argv.buildMinmap ? 1 : 0);
|
|
28
29
|
commandCount += (argv.buildZip ? 1 : 0);
|
|
29
30
|
commandCount += (argv.moduleFederation ? 1 : 0);
|
|
31
|
+
commandCount += (argv.vueDevtools ? 1 : 0);
|
|
30
32
|
if(commandCount == 0) {
|
|
31
33
|
if(argv.help || argv.h) {
|
|
32
34
|
printArgumentsUsages(requiredUsages, optionalUsages);
|
|
@@ -34,48 +36,34 @@ async function getExtraOptions(argv)
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const commandPrompt = [
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
39
|
+
'runonAndroid',
|
|
40
|
+
'configApp',
|
|
41
|
+
'genKeypair',
|
|
42
|
+
'buildMinmap',
|
|
43
|
+
'buildZip',
|
|
44
|
+
'vueDevtools',
|
|
45
|
+
'moduleFederation',
|
|
43
46
|
];
|
|
44
47
|
|
|
45
48
|
Logger.Info();
|
|
46
49
|
Logger.Info('Please choice a command:');
|
|
47
|
-
for(
|
|
48
|
-
Logger.Info(
|
|
50
|
+
for(let idx = 0; idx < commandPrompt.length; idx++) {
|
|
51
|
+
Logger.Info(idx, ': ' + commandPrompt[idx].replace(/[A-Z]/g, match => `-${match.toLowerCase()}`));
|
|
49
52
|
}
|
|
50
|
-
const answer = askAndAnswer(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
break;
|
|
55
|
-
case '2':
|
|
56
|
-
options.configApp = true;
|
|
57
|
-
break;
|
|
58
|
-
case '3':
|
|
59
|
-
options.genKeypair = true;
|
|
60
|
-
break;
|
|
61
|
-
case '4':
|
|
62
|
-
options.buildMinmap = true;
|
|
63
|
-
break;
|
|
64
|
-
case '5':
|
|
65
|
-
options.buildZip = true;
|
|
66
|
-
break;
|
|
67
|
-
case '6':
|
|
68
|
-
options.moduleFederation = true;
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
Logger.ErrorAndExitNoException("Unknown input: " + answer);
|
|
53
|
+
const answer = askAndAnswer(`Command Index (0~${commandPrompt.length-1}): `);
|
|
54
|
+
const command = commandPrompt[answer];
|
|
55
|
+
if(!command) {
|
|
56
|
+
Logger.ErrorAndExitNoException("Bad index: " + answer);
|
|
72
57
|
}
|
|
58
|
+
Logger.Info('command:', command);
|
|
59
|
+
options[command] = true
|
|
73
60
|
} else if(commandCount == 1) {
|
|
74
61
|
options.runonAndroid = argv.runonAndroid;
|
|
75
62
|
options.configApp = argv.configApp;
|
|
76
63
|
options.genKeypair = argv.genKeypair;
|
|
77
64
|
options.buildMinmap = argv.buildMinmap;
|
|
78
65
|
options.buildZip = argv.buildZip;
|
|
66
|
+
options.vueDevtools = argv.vueDevtools;
|
|
79
67
|
options.moduleFederation = argv.moduleFederation;
|
|
80
68
|
} else if(commandCount > 1) {
|
|
81
69
|
Logger.ErrorAndExitNoException("Only one command can be executed.");
|
|
@@ -117,6 +105,14 @@ function doCommand(options) {
|
|
|
117
105
|
}
|
|
118
106
|
|
|
119
107
|
command = 'node node_modules/@shijiu/jsview/tools/jsview-build-zip.mjs --password=' + password;
|
|
108
|
+
} else if(options.vueDevtools) {
|
|
109
|
+
var defaultPort = 8098;
|
|
110
|
+
const port = (typeof(options.vueDevtools) === 'string' ? options.vueDevtools : defaultPort);
|
|
111
|
+
if(port !== options.vueDevtools) {
|
|
112
|
+
Logger.Warn('Vue Devtools server port is not set, use default value: ' + defaultPort);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
command = 'node node_modules/@shijiu/jsview/tools/jsview-vue-devtools.mjs --port=' + port;
|
|
120
116
|
} else if(options.moduleFederation) {
|
|
121
117
|
var argumentsLine = options.argumentsLine.replace(/ --framework.*? /, ' ');
|
|
122
118
|
argumentsLine = argumentsLine.replace(' -f ', ' ').replace(' --module-federation ', ' ');
|
|
@@ -145,6 +141,7 @@ const optionalUsages = {
|
|
|
145
141
|
'-g | --gen-keypair': 'Generate sign keypair.',
|
|
146
142
|
'-m | --build-minmap': 'Build target with filter map, like: -m or --build-minmap=[filter].',
|
|
147
143
|
'-z | --build-zip': 'Build target to offline zip package, like: -z or --build-zip=[password].',
|
|
144
|
+
'-d | --vue-devtools': 'Start vue dev server and vue-devtools standalone, like: -d or --vue-devtools=[port].',
|
|
148
145
|
'-f | --module-federation': 'Make project to module federation, use --module-federation --help for details.',
|
|
149
146
|
};
|
|
150
147
|
const argv = parseArguments(requiredUsages, optionalUsages, true, true, true);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
askAndAnswer,
|
|
8
|
+
checkNodeVersion,
|
|
9
|
+
execCommand,
|
|
10
|
+
getNetworkIpv4Addresses,
|
|
11
|
+
getOptions,
|
|
12
|
+
parseArguments,
|
|
13
|
+
Logger,
|
|
14
|
+
} from './jsview-common.mjs';
|
|
15
|
+
|
|
16
|
+
function getDefaultPort() {
|
|
17
|
+
return 8098;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function getExtraOptions(argv)
|
|
21
|
+
{
|
|
22
|
+
const options = getOptions(argv.framework);
|
|
23
|
+
|
|
24
|
+
options.hostIp = 'your-pc-ip';
|
|
25
|
+
const addresses = getNetworkIpv4Addresses();
|
|
26
|
+
if(addresses.length > 0) {
|
|
27
|
+
options.hostIp = addresses[0];
|
|
28
|
+
}
|
|
29
|
+
options.hostPort = argv.port ?? getDefaultPort();
|
|
30
|
+
|
|
31
|
+
if(process.platform == 'win32' && options.hostPort != getDefaultPort()) {
|
|
32
|
+
Logger.ErrorAndExit("Windows can't support to set custom port to Vue DevTools standalone application. please use default value.")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function runVueDevtoolsStandalone(options)
|
|
39
|
+
{
|
|
40
|
+
const vuedtFilePath = options.modulesDir + '/.bin/vue-devtools';
|
|
41
|
+
|
|
42
|
+
var exportPrefix = 'export';
|
|
43
|
+
if(process.platform == 'win32') {
|
|
44
|
+
exportPrefix = 'set'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (fs.existsSync(vuedtFilePath) == false
|
|
48
|
+
|| fs.existsSync(options.modulesDir + '/electron') == false) {
|
|
49
|
+
Logger.ErrorNoException('Vue DevTools standalone application is not found.')
|
|
50
|
+
Logger.Info(' Do you want to install it thought "@vue/vue-devtools@6.5.1"?');
|
|
51
|
+
const answer = askAndAnswer('(y/N) ');
|
|
52
|
+
if (answer.substring(0, 1) != 'y' && answer.substring(0, 3) != 'yes') {
|
|
53
|
+
Logger.ErrorAndExitNoSilent('User cancelled.')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const exportElectronMirror = exportPrefix + ' ELECTRON_MIRROR=http://cdn.release.qcast.cn/RN_devtools/electron-env/'
|
|
57
|
+
let cmdline = exportElectronMirror + ' && npm install --package-lock-only --save-exact --save-dev electron@21.4.4 @vue/devtools@6.5.1'
|
|
58
|
+
execCommand(cmdline);
|
|
59
|
+
cmdline = exportElectronMirror + ' && npm ci'
|
|
60
|
+
execCommand(cmdline);
|
|
61
|
+
|
|
62
|
+
console.log()
|
|
63
|
+
console.log()
|
|
64
|
+
Logger.Tip(" *** NOTICE ***:")
|
|
65
|
+
Logger.Tip(" Don't forget to add the following code at the beginning of your source entry ['main.ts' or 'main.tsx']:")
|
|
66
|
+
console.log(" if (process.env.NODE_ENV === 'development') {")
|
|
67
|
+
console.log(" window.requestAnimationFrame = (callback) => setTimeout(callback, 0)")
|
|
68
|
+
console.log(" const devtools = await import('@vue/devtools')")
|
|
69
|
+
console.log(" devtools.connect('" + options.hostIp + "', " + options.hostPort + ")")
|
|
70
|
+
console.log(" console.warn('@vue/devtools has been ready.')")
|
|
71
|
+
console.log(" }")
|
|
72
|
+
console.log()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var cmdline = /* 不要添加 `node `,windows cmd执行出错 */ path.relative(options.projectDir, vuedtFilePath)
|
|
76
|
+
if(process.platform != 'win32') { // 在Window系统上设置port 会导致WebSocket连接失败。
|
|
77
|
+
cmdline = (exportPrefix + ' PORT=' + options.hostPort + ' && ' + cmdline);
|
|
78
|
+
}
|
|
79
|
+
execCommand(cmdline);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function main(argv)
|
|
83
|
+
{
|
|
84
|
+
checkNodeVersion();
|
|
85
|
+
|
|
86
|
+
const options = await getExtraOptions(argv);
|
|
87
|
+
|
|
88
|
+
runVueDevtoolsStandalone(options);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const requiredUsages = {
|
|
92
|
+
};
|
|
93
|
+
const optionalUsages = {
|
|
94
|
+
'--port': 'Set vue devtools standalone server port. default is: ' + getDefaultPort(),
|
|
95
|
+
};
|
|
96
|
+
const argv = parseArguments(requiredUsages, optionalUsages, false);
|
|
97
|
+
main(argv)
|