@tuya-sat/micro-script 3.0.17-beta.3 → 3.0.17
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.
|
@@ -107,7 +107,9 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
|
|
|
107
107
|
menu.oem_micro_app_id = oem_micro_app_id;
|
|
108
108
|
menu.entry_id = entry_id;
|
|
109
109
|
//@ts-ignore
|
|
110
|
-
menu.
|
|
110
|
+
menu.entry_name_zh = pickText(menu.entry_name, 'zh');
|
|
111
|
+
//@ts-ignore
|
|
112
|
+
menu.entry_name_en = pickText(menu.entry_name, 'en');
|
|
111
113
|
//@ts-ignore
|
|
112
114
|
menu.micro_app_name = pickText(menu.micro_app_name, lang);
|
|
113
115
|
menu.path = `${baseUrl}${menu.path}`;
|
|
@@ -40,29 +40,41 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
40
40
|
const fakeSaas_1 = __importStar(require("./fakeSaas"));
|
|
41
41
|
const paths_1 = __importDefault(require("../../config/paths"));
|
|
42
42
|
const webpack_common_1 = require("../../config/webpack.common");
|
|
43
|
-
const
|
|
43
|
+
const undici_1 = require("undici");
|
|
44
|
+
function parse_SDF(html) {
|
|
45
|
+
var _a;
|
|
46
|
+
const REGEX = /(?<=window._SDF=).*?}(?=;)/;
|
|
47
|
+
return ((_a = REGEX.exec(html)) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
|
48
|
+
}
|
|
44
49
|
function staticMain(app, debuggerConfig, microPort) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'/login',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
//获取当前SaaS版本
|
|
52
|
+
let SDF;
|
|
53
|
+
let { body } = yield (0, undici_1.request)(new URL('/login?disable_third_login=true', debuggerConfig.target).href);
|
|
54
|
+
const data = yield body.text();
|
|
55
|
+
SDF = JSON.parse(parse_SDF(data));
|
|
56
|
+
app.get([
|
|
57
|
+
'/',
|
|
58
|
+
'/apps/:appId',
|
|
59
|
+
'/login',
|
|
60
|
+
'/apps/:appId/*',
|
|
61
|
+
'/application',
|
|
62
|
+
'/application/*',
|
|
63
|
+
], (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (!debuggerConfig.isMainApp && app._isLogin) {
|
|
65
|
+
yield app._isLogin;
|
|
66
|
+
}
|
|
67
|
+
let base = SDF.base;
|
|
68
|
+
if (debuggerConfig.isMainApp) {
|
|
69
|
+
base = `http://localhost:${microPort}`;
|
|
70
|
+
}
|
|
71
|
+
const { data } = yield axios_1.default.get(new URL('index.html', base).href);
|
|
72
|
+
const $ = cheerio_1.default.load(data);
|
|
73
|
+
modifySrcAttr($, base);
|
|
74
|
+
yield insertScript($, debuggerConfig);
|
|
75
|
+
res.send($.html());
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
66
78
|
}
|
|
67
79
|
exports.default = staticMain;
|
|
68
80
|
function initalCustom_configs(saas) {
|
|
@@ -92,7 +92,7 @@ function runMain({ port, microPort, }) {
|
|
|
92
92
|
});
|
|
93
93
|
(0, socket_1.bootStrap)(io);
|
|
94
94
|
mainServer && mainServer.before && mainServer.before(app);
|
|
95
|
-
(0, staticMain_1.default)(app, debuggerConfig, microPort);
|
|
95
|
+
yield (0, staticMain_1.default)(app, debuggerConfig, microPort);
|
|
96
96
|
(0, fakeSaasInfo_1.default)(app, microPort);
|
|
97
97
|
(0, mock_1.default)(app);
|
|
98
98
|
(0, proxy_1.default)(app);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "3.0.17
|
|
3
|
+
"version": "3.0.17",
|
|
4
4
|
"bin": "./dist/bin/cli.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@babel/preset-typescript": "7.16.7",
|
|
24
24
|
"@babel/traverse": "^7.20.13",
|
|
25
25
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
|
|
26
|
-
"@tuya-sat/micro-dev-loader": "3.0.17
|
|
27
|
-
"@tuya-sat/micro-dev-proxy": "3.0.17
|
|
28
|
-
"@tuya-sat/micro-utils": "3.0.17
|
|
26
|
+
"@tuya-sat/micro-dev-loader": "3.0.17",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.0.17",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.0.17",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"svg-url-loader": "7.1.1",
|
|
62
62
|
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
63
63
|
"uid": "^2.0.1",
|
|
64
|
+
"undici": "^5.20.0",
|
|
64
65
|
"url-loader": "4.1.1",
|
|
65
66
|
"uuid": "8.3.2",
|
|
66
67
|
"vue-loader": "17.0.0",
|