@tuya-sat/micro-script 3.1.4 → 3.1.6
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.
|
@@ -57,7 +57,7 @@ function parse__MAIN_APP_PUBLIC_PATH(html) {
|
|
|
57
57
|
}
|
|
58
58
|
const grabSaasPage = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
59
|
try {
|
|
60
|
-
return axios_1.default.get(target);
|
|
60
|
+
return yield axios_1.default.get(target);
|
|
61
61
|
}
|
|
62
62
|
catch (e) {
|
|
63
63
|
return axios_1.default.get(new URL('/login?disable_third_login=true', target).href);
|
|
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
36
|
};
|
|
@@ -33,8 +42,9 @@ const uid_1 = require("uid");
|
|
|
33
42
|
const path = __importStar(require("path"));
|
|
34
43
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
35
44
|
const utils_1 = require("../../utils");
|
|
45
|
+
const axios_1 = __importDefault(require("axios"));
|
|
36
46
|
function mockSaasInfo(app, microPort) {
|
|
37
|
-
let { multiApps, microApps, debuggerConfig: { isMainApp }, } = require(paths_1.default.microConfig);
|
|
47
|
+
let { multiApps, microApps, debuggerConfig: { isMainApp, target }, } = require(paths_1.default.microConfig);
|
|
38
48
|
const idsMap = new Map();
|
|
39
49
|
multiApps = (0, utils_1.processMultiApps)(multiApps);
|
|
40
50
|
if (isMainApp && fs_extra_1.default.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
@@ -122,7 +132,15 @@ function mockSaasInfo(app, microPort) {
|
|
|
122
132
|
const entry_id = (0, uuid_1.v4)();
|
|
123
133
|
const oem_micro_app_id = manifest.universalId;
|
|
124
134
|
const baseUrl = `/apps/${oem_micro_app_id}`;
|
|
125
|
-
const
|
|
135
|
+
const localApps = refactorConstructApp(target, [
|
|
136
|
+
{
|
|
137
|
+
manifest,
|
|
138
|
+
oem_micro_app_id,
|
|
139
|
+
baseUrl,
|
|
140
|
+
lang,
|
|
141
|
+
port: microPort
|
|
142
|
+
}
|
|
143
|
+
]);
|
|
126
144
|
const entryInfo = consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, '');
|
|
127
145
|
const permission = consturctPermissions();
|
|
128
146
|
res.send({
|
|
@@ -130,7 +148,7 @@ function mockSaasInfo(app, microPort) {
|
|
|
130
148
|
errorMsg: null,
|
|
131
149
|
msg: null,
|
|
132
150
|
result: {
|
|
133
|
-
apps:
|
|
151
|
+
apps: localApps,
|
|
134
152
|
entry_info: { entries: [entryInfo], entry_mode: 'normal' },
|
|
135
153
|
permissions: { [oem_micro_app_id]: permission },
|
|
136
154
|
saas_id_info_list: [
|
|
@@ -178,6 +196,27 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
|
|
|
178
196
|
}
|
|
179
197
|
return fakeMenu;
|
|
180
198
|
}
|
|
199
|
+
function refactorConstructApp(saasUrl, localApps) {
|
|
200
|
+
var _a;
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
const saasAppsMap = {};
|
|
203
|
+
try {
|
|
204
|
+
const res = yield axios_1.default.get(new URL('/api/saas-info', saasUrl).href);
|
|
205
|
+
(_a = res.data.result.apps) === null || _a === void 0 ? void 0 : _a.forEach((app) => {
|
|
206
|
+
saasAppsMap[app.universal_id] = app;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
console.error('获取 SaaS 信息失败,尝试使用假数据模拟 APP 信息');
|
|
211
|
+
}
|
|
212
|
+
const packageInfo = (0, micro_utils_1.getPackage)();
|
|
213
|
+
return localApps.map((app) => {
|
|
214
|
+
const uuid = app.manifest.universalId;
|
|
215
|
+
const code = app.code || `${packageInfo.name}`;
|
|
216
|
+
return Object.assign(Object.assign({}, saasAppsMap[app.oem_micro_app_id]), { active_rule: app.baseUrl, micro_app_code: code, micro_app_name: code ? `${code}-dev` : `${packageInfo.name}-dev`, micro_app_version: '0.0.0-x', oem_micro_app_id: app.oem_micro_app_id, resource: `http://localhost:${app.port}/${code || 'index'}.html`, universal_id: uuid, isAuth: true, schema: null });
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
181
220
|
function consturctApp(manifest, oem_micro_app_id, baseUrl, lang, port, code) {
|
|
182
221
|
const packageInfo = (0, micro_utils_1.getPackage)();
|
|
183
222
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
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.1.
|
|
27
|
-
"@tuya-sat/micro-dev-proxy": "3.1.
|
|
28
|
-
"@tuya-sat/micro-utils": "3.1.
|
|
26
|
+
"@tuya-sat/micro-dev-loader": "3.1.6",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.1.6",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.1.6",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|