@shijiu/jsview 2.1.435 → 2.1.476-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-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 +114 -0
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +1 -1
- package/tools/jsview-common.mjs +110 -9
- package/tools/jsview-config-app.mjs +47 -0
- package/tools/jsview-logger.js +12 -0
- package/tools/jsview-module-federation.mjs +354 -0
- package/tools/jsview-post-build.mjs +2 -2
- package/tools/jsview-post-install.mjs +88 -6
- package/tools/jsview-run-tool.mjs +58 -23
- package/tools/jsview-vue-devtools.mjs +97 -0
package/package.json
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
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..534e796 100644
|
|
3
|
+
--- a/node_modules/@originjs/vite-plugin-federation/dist/index.js
|
|
4
|
+
+++ b/node_modules/@originjs/vite-plugin-federation/dist/index.js
|
|
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) {
|
|
28
|
+
const filepathMap = /* @__PURE__ */ new Map();
|
|
29
|
+
const getFilename = (name) => path.parse(path.parse(name).name).name;
|
|
30
|
+
const cssBundlesMap = Object.keys(bundle).filter((name) => path.extname(name) === ".css").reduce((res, name) => {
|
|
31
|
+
- const filename = getFilename(name);
|
|
32
|
+
- res.set(filename, bundle[name]);
|
|
33
|
+
+// JsView Removed >>>
|
|
34
|
+
+// JsView js代码中已内嵌css
|
|
35
|
+
+ //const filename = getFilename(name);
|
|
36
|
+
+ //res.set(filename, bundle[name]);
|
|
37
|
+
+// JsView Removed <<<
|
|
38
|
+
return res;
|
|
39
|
+
}, /* @__PURE__ */ new Map());
|
|
40
|
+
remoteEntryChunk.code = remoteEntryChunk.code.replace(
|
|
41
|
+
@@ -1481,6 +1493,16 @@ function federation(options) {
|
|
42
|
+
}
|
|
43
|
+
builderInfo.builder = "vite";
|
|
44
|
+
builderInfo.assetsDir = ((_b = config == null ? void 0 : config.build) == null ? void 0 : _b.assetsDir) ?? "assets";
|
|
45
|
+
+// JsView Added >>>
|
|
46
|
+
+// 根据chunkFile路径设置assetsDir
|
|
47
|
+
+ let chunkFileNames = config.build.rollupOptions.output.chunkFileNames;
|
|
48
|
+
+ if (typeof (chunkFileNames) === 'function') {
|
|
49
|
+
+ chunkFileNames = chunkFileNames({name: 'test.js'})
|
|
50
|
+
+ }
|
|
51
|
+
+ const jsDir = path.dirname(chunkFileNames);
|
|
52
|
+
+ builderInfo.assetsDir = jsDir;
|
|
53
|
+
+ console.log("builderInfo",builderInfo);
|
|
54
|
+
+// JsView Added <<<
|
|
55
|
+
},
|
|
56
|
+
configureServer(server) {
|
|
57
|
+
var _a;
|
|
58
|
+
diff --git a/node_modules/@originjs/vite-plugin-federation/dist/index.mjs b/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
59
|
+
index 57bae8f..3b3c2c1 100644
|
|
60
|
+
--- a/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
61
|
+
+++ b/node_modules/@originjs/vite-plugin-federation/dist/index.mjs
|
|
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) {
|
|
85
|
+
const filepathMap = /* @__PURE__ */ new Map();
|
|
86
|
+
const getFilename = (name) => parse(parse(name).name).name;
|
|
87
|
+
const cssBundlesMap = Object.keys(bundle).filter((name) => extname(name) === ".css").reduce((res, name) => {
|
|
88
|
+
- const filename = getFilename(name);
|
|
89
|
+
- res.set(filename, bundle[name]);
|
|
90
|
+
+// JsView Removed >>>
|
|
91
|
+
+// JsView js代码中已内嵌css
|
|
92
|
+
+ //const filename = getFilename(name);
|
|
93
|
+
+ //res.set(filename, bundle[name]);
|
|
94
|
+
+// JsView Removed <<<
|
|
95
|
+
return res;
|
|
96
|
+
}, /* @__PURE__ */ new Map());
|
|
97
|
+
remoteEntryChunk.code = remoteEntryChunk.code.replace(
|
|
98
|
+
@@ -1464,6 +1476,16 @@ function federation(options) {
|
|
99
|
+
}
|
|
100
|
+
builderInfo.builder = "vite";
|
|
101
|
+
builderInfo.assetsDir = ((_b = config == null ? void 0 : config.build) == null ? void 0 : _b.assetsDir) ?? "assets";
|
|
102
|
+
+// JsView Added >>>
|
|
103
|
+
+// 根据chunkFile路径设置assetsDir
|
|
104
|
+
+ let chunkFileNames = config.build.rollupOptions.output.chunkFileNames;
|
|
105
|
+
+ if (typeof (chunkFileNames) === 'function') {
|
|
106
|
+
+ chunkFileNames = chunkFileNames({name: 'test.js'})
|
|
107
|
+
+ }
|
|
108
|
+
+ const jsDir = path.dirname(chunkFileNames);
|
|
109
|
+
+ builderInfo.assetsDir = jsDir;
|
|
110
|
+
+ console.log("builderInfo",builderInfo);
|
|
111
|
+
+// JsView Added <<<
|
|
112
|
+
},
|
|
113
|
+
configureServer(server) {
|
|
114
|
+
var _a;
|
package/tools/jsview-common.mjs
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
import childProcess from 'node:child_process';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
|
+
import https from 'node:https';
|
|
6
7
|
import os from 'node:os';
|
|
7
8
|
import path from 'node:path';
|
|
8
9
|
import { Logger } from "./jsview-logger.js";
|
|
9
10
|
|
|
10
11
|
function printArgumentsUsages(requiredUsages, optionalUsages, helpUsages)
|
|
11
12
|
{
|
|
13
|
+
if(!helpUsages) {
|
|
14
|
+
helpUsages = {
|
|
15
|
+
'-h | --help': 'Print help usages.',
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
let maxLength = 0;
|
|
13
20
|
for (const usage in requiredUsages) {
|
|
14
21
|
maxLength = (maxLength > usage.length ? maxLength : usage.length);
|
|
@@ -41,7 +48,9 @@ function printArgumentsUsages(requiredUsages, optionalUsages, helpUsages)
|
|
|
41
48
|
|
|
42
49
|
function parseArguments(requiredUsages = {},
|
|
43
50
|
optionalUsages = {},
|
|
44
|
-
withoutUnparsed = true
|
|
51
|
+
withoutUnparsed = true,
|
|
52
|
+
ignoreUnknown = false,
|
|
53
|
+
ignoreHelpUsage = false)
|
|
45
54
|
{
|
|
46
55
|
const keySeparator = '|';
|
|
47
56
|
const formatKey = (key) => {
|
|
@@ -110,7 +119,8 @@ function parseArguments(requiredUsages = {},
|
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
let options = {
|
|
113
|
-
unparsed: []
|
|
122
|
+
unparsed: [],
|
|
123
|
+
argumentsLine: '',
|
|
114
124
|
};
|
|
115
125
|
|
|
116
126
|
// arg0: node
|
|
@@ -130,7 +140,8 @@ function parseArguments(requiredUsages = {},
|
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
|
|
133
|
-
if (
|
|
143
|
+
if (ignoreUnknown == false
|
|
144
|
+
&& hasKey(helpUsages, key) == false
|
|
134
145
|
&& hasKey(requiredUsages, key) == false
|
|
135
146
|
&& hasKey(optionalUsages, key) == false) {
|
|
136
147
|
Logger.ErrorAndExitNoException('Failed to parse usage: ' + argu);
|
|
@@ -139,11 +150,13 @@ function parseArguments(requiredUsages = {},
|
|
|
139
150
|
let formattedKey = formatKey(key);
|
|
140
151
|
let formattedValue = formatValue(value);
|
|
141
152
|
options[formattedKey] = formattedValue;
|
|
153
|
+
|
|
154
|
+
options.argumentsLine += ' ' + argu;
|
|
142
155
|
}
|
|
143
156
|
|
|
144
157
|
for (const checker in helpUsages) {
|
|
145
158
|
const aliasedOptions = checkAliases(checker, options);
|
|
146
|
-
if (aliasedOptions) {
|
|
159
|
+
if (aliasedOptions && ignoreHelpUsage == false) {
|
|
147
160
|
printArgumentsUsages(requiredUsages, optionalUsages, helpUsages);
|
|
148
161
|
process.exit(0);
|
|
149
162
|
}
|
|
@@ -208,6 +221,8 @@ function getOptions(framework)
|
|
|
208
221
|
}
|
|
209
222
|
|
|
210
223
|
options.appConfigDir = path.resolve(options.projectDir, 'src', 'appConfig');
|
|
224
|
+
options.appConfigFile = path.resolve(options.appConfigDir, 'app.config.mjs');
|
|
225
|
+
options.appJsviewConfigFile = path.resolve(options.appConfigDir, 'jsview.config.mjs');
|
|
211
226
|
options.appPrivKeyFile = path.resolve(options.appConfigDir, 'app_sign_private_key.crt');
|
|
212
227
|
options.appPubKeyFile = path.resolve(options.appConfigDir, 'app_sign_public_key.pem');
|
|
213
228
|
|
|
@@ -231,12 +246,13 @@ function getOptions(framework)
|
|
|
231
246
|
|
|
232
247
|
const cacheName = (framework == 'vue' ? '.vite' : '.cache');
|
|
233
248
|
options.cacheDir = path.resolve(options.modulesDir, cacheName);
|
|
234
|
-
options.
|
|
249
|
+
options.cacheJsViewDir = path.resolve(options.cacheDir, 'jsview');
|
|
250
|
+
options.baseUrlFile = path.resolve(options.cacheJsViewDir, 'network.mjs');
|
|
235
251
|
|
|
236
252
|
return options;
|
|
237
253
|
}
|
|
238
254
|
|
|
239
|
-
function
|
|
255
|
+
function loadPackageObject(modulePath)
|
|
240
256
|
{
|
|
241
257
|
const pkgFullFile = path.resolve(modulePath, 'package.json');
|
|
242
258
|
if (!fs.existsSync(pkgFullFile)) {
|
|
@@ -248,6 +264,16 @@ function getPackageObject(modulePath)
|
|
|
248
264
|
return pkgObj;
|
|
249
265
|
}
|
|
250
266
|
|
|
267
|
+
function savePackageObject(modulePath, pkgObj)
|
|
268
|
+
{
|
|
269
|
+
const pkgFullFile = path.resolve(modulePath, 'package.json');
|
|
270
|
+
const pkgContent = JSON.stringify(pkgObj, null, 2);
|
|
271
|
+
|
|
272
|
+
fs.writeFileSync(pkgFullFile, pkgContent, 'utf8');
|
|
273
|
+
|
|
274
|
+
return pkgObj;
|
|
275
|
+
}
|
|
276
|
+
|
|
251
277
|
function cpSync(workDir, srcPath, destPath, ignore=[])
|
|
252
278
|
{
|
|
253
279
|
const exists = fs.existsSync(srcPath);
|
|
@@ -324,6 +350,18 @@ function execCommand(cmdline, withOutput)
|
|
|
324
350
|
}
|
|
325
351
|
}
|
|
326
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
|
+
|
|
327
365
|
function checkNodeVersion(minMajorVersion = 16)
|
|
328
366
|
{
|
|
329
367
|
const versions = process.version.replace('v', '').split('.');
|
|
@@ -395,25 +433,88 @@ function convertHomeDirectory(filePath)
|
|
|
395
433
|
return filePath.replace(/^~\//, homeDir + '/');
|
|
396
434
|
}
|
|
397
435
|
|
|
436
|
+
function downloadFileAsync(url, localPath, workDir)
|
|
437
|
+
{
|
|
438
|
+
const relativePath = path.relative(workDir, localPath);
|
|
439
|
+
Logger.Info('Downloading ' + url + ' => ' + relativePath);
|
|
440
|
+
|
|
441
|
+
const file = fs.createWriteStream(localPath);
|
|
442
|
+
|
|
443
|
+
return new Promise((resolve, reject) => {
|
|
444
|
+
const request = https.get(url, (response) => {
|
|
445
|
+
response.pipe(file);
|
|
446
|
+
|
|
447
|
+
file.on('finish', () => {
|
|
448
|
+
file.close(() => {
|
|
449
|
+
Logger.Info('Success to download file to ' + relativePath);
|
|
450
|
+
resolve();
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
request.on('error', (err) => {
|
|
456
|
+
fs.unlink(localPath, () => {
|
|
457
|
+
Logger.ErrorAndExit('Failed to download file from ' + url);
|
|
458
|
+
reject(err);
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function unzipFile(zipFilePath, toDir, workDir)
|
|
465
|
+
{
|
|
466
|
+
var relativePath = path.relative(workDir, toDir);
|
|
467
|
+
if(!relativePath) {
|
|
468
|
+
relativePath = './'
|
|
469
|
+
}
|
|
470
|
+
Logger.Info('Unzipping ' + zipFilePath + ' => ' + relativePath);
|
|
471
|
+
|
|
472
|
+
const cmdline = 'npx -y extract-zip ' + zipFilePath + ' ' + toDir;
|
|
473
|
+
execCommand(cmdline);
|
|
474
|
+
}
|
|
475
|
+
|
|
398
476
|
function getNpmRegistry()
|
|
399
477
|
{
|
|
400
478
|
return 'https://nexus.cluster.qcast.cn/repository/npm-public';
|
|
401
479
|
}
|
|
402
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
|
+
|
|
403
498
|
export {
|
|
404
499
|
askAndAnswer,
|
|
405
500
|
checkNodeVersion,
|
|
406
501
|
convertHomeDirectory,
|
|
407
502
|
cpSync,
|
|
503
|
+
downloadFileAsync,
|
|
408
504
|
execCommand,
|
|
409
|
-
|
|
410
|
-
|
|
505
|
+
execCommandAsync,
|
|
506
|
+
getNetworkIpv4Addresses,
|
|
411
507
|
getNpmRegistry,
|
|
508
|
+
getOptions,
|
|
412
509
|
isSymlinkSync,
|
|
510
|
+
loadPackageObject,
|
|
413
511
|
makeZip,
|
|
414
512
|
parseArguments,
|
|
513
|
+
printArgumentsUsages,
|
|
415
514
|
readJsonFile,
|
|
416
515
|
rmSync,
|
|
516
|
+
savePackageObject,
|
|
417
517
|
symlinkSync,
|
|
518
|
+
unzipFile,
|
|
418
519
|
Logger,
|
|
419
|
-
}
|
|
520
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
checkNodeVersion,
|
|
8
|
+
getOptions,
|
|
9
|
+
parseArguments,
|
|
10
|
+
Logger,
|
|
11
|
+
} from './jsview-common.mjs';
|
|
12
|
+
|
|
13
|
+
function setAppConfig(options)
|
|
14
|
+
{
|
|
15
|
+
let appConfigContent = fs.readFileSync(options.appConfigFile, 'utf8');
|
|
16
|
+
|
|
17
|
+
appConfigContent = appConfigContent.replace(/AppName: .*,/, 'AppName: "' + options.appName + '",');
|
|
18
|
+
appConfigContent = appConfigContent.replace(/AppTitle: .*,/, 'AppTitle: "' + options.appTitle + '",');
|
|
19
|
+
|
|
20
|
+
console.log(appConfigContent)
|
|
21
|
+
|
|
22
|
+
fs.writeFileSync(options.appConfigFile, appConfigContent, 'utf8');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function main(argv) {
|
|
26
|
+
checkNodeVersion();
|
|
27
|
+
|
|
28
|
+
const options = getOptions();
|
|
29
|
+
|
|
30
|
+
options.appName = argv.appName ?? 'JsViewDemo';
|
|
31
|
+
options.appTitle = argv.appTitle ?? 'JsView Demo';
|
|
32
|
+
|
|
33
|
+
Logger.Info();
|
|
34
|
+
Logger.Info('Setting config to app.config.mjs ...');
|
|
35
|
+
setAppConfig(options);
|
|
36
|
+
Logger.Info('Set config finish.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const requiredUsages = {
|
|
41
|
+
};
|
|
42
|
+
const optionalUsages = {
|
|
43
|
+
'--app-name': 'App name. default is: "JsViewDemo".',
|
|
44
|
+
'--app-title': 'App title. default is: "JsView Demo".',
|
|
45
|
+
};
|
|
46
|
+
const argv = parseArguments(requiredUsages, optionalUsages, false);
|
|
47
|
+
main(argv)
|
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
|
}
|