@tuya-sat/micro-script 3.1.6 → 3.1.11
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.
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
|
|
2
|
+
import AppProxy from "@tuya-sat/micro-dev-proxy/dist/appProxy";
|
|
3
|
+
interface IApp extends Express {
|
|
4
|
+
__appProxy__?: AppProxy;
|
|
5
|
+
}
|
|
6
|
+
export default function mockSaasInfo(app: IApp, microPort: number): void;
|
|
7
|
+
export {};
|
|
@@ -46,6 +46,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
46
46
|
function mockSaasInfo(app, microPort) {
|
|
47
47
|
let { multiApps, microApps, debuggerConfig: { isMainApp, target }, } = require(paths_1.default.microConfig);
|
|
48
48
|
const idsMap = new Map();
|
|
49
|
+
const expressApp = app;
|
|
49
50
|
multiApps = (0, utils_1.processMultiApps)(multiApps);
|
|
50
51
|
if (isMainApp && fs_extra_1.default.existsSync(path.join(process.cwd(), 'apps'))) {
|
|
51
52
|
const dirs = ((microApps === null || microApps === void 0 ? void 0 : microApps.length) > 0 && microApps) ||
|
|
@@ -132,15 +133,10 @@ function mockSaasInfo(app, microPort) {
|
|
|
132
133
|
const entry_id = (0, uuid_1.v4)();
|
|
133
134
|
const oem_micro_app_id = manifest.universalId;
|
|
134
135
|
const baseUrl = `/apps/${oem_micro_app_id}`;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
baseUrl,
|
|
140
|
-
lang,
|
|
141
|
-
port: microPort
|
|
142
|
-
}
|
|
143
|
-
]);
|
|
136
|
+
const cookie = expressApp.__appProxy__.getCookie('');
|
|
137
|
+
const csrf = expressApp.__appProxy__.csrfValue.value;
|
|
138
|
+
console.log('cookie...', { cookie, csrf });
|
|
139
|
+
const app = consturctApp(manifest, oem_micro_app_id, baseUrl, lang, microPort);
|
|
144
140
|
const entryInfo = consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, '');
|
|
145
141
|
const permission = consturctPermissions();
|
|
146
142
|
res.send({
|
|
@@ -148,7 +144,7 @@ function mockSaasInfo(app, microPort) {
|
|
|
148
144
|
errorMsg: null,
|
|
149
145
|
msg: null,
|
|
150
146
|
result: {
|
|
151
|
-
apps:
|
|
147
|
+
apps: [app],
|
|
152
148
|
entry_info: { entries: [entryInfo], entry_mode: 'normal' },
|
|
153
149
|
permissions: { [oem_micro_app_id]: permission },
|
|
154
150
|
saas_id_info_list: [
|
|
@@ -196,18 +192,20 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
|
|
|
196
192
|
}
|
|
197
193
|
return fakeMenu;
|
|
198
194
|
}
|
|
199
|
-
function refactorConstructApp(
|
|
195
|
+
function refactorConstructApp(config, localApps) {
|
|
200
196
|
var _a;
|
|
201
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
202
198
|
const saasAppsMap = {};
|
|
203
199
|
try {
|
|
204
|
-
const res = yield axios_1.default.get(new URL('/api/saas-info',
|
|
200
|
+
const res = yield axios_1.default.get(new URL('/api/saas-info', config.url).href, {
|
|
201
|
+
headers: config.headers,
|
|
202
|
+
});
|
|
205
203
|
(_a = res.data.result.apps) === null || _a === void 0 ? void 0 : _a.forEach((app) => {
|
|
206
204
|
saasAppsMap[app.universal_id] = app;
|
|
207
205
|
});
|
|
208
206
|
}
|
|
209
207
|
catch (e) {
|
|
210
|
-
console.error('获取 SaaS 信息失败,尝试使用假数据模拟 APP
|
|
208
|
+
console.error('\n获取 SaaS 信息失败,尝试使用假数据模拟 APP 信息\n');
|
|
211
209
|
}
|
|
212
210
|
const packageInfo = (0, micro_utils_1.getPackage)();
|
|
213
211
|
return localApps.map((app) => {
|
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.11",
|
|
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.11",
|
|
27
|
+
"@tuya-sat/micro-dev-proxy": "3.1.11",
|
|
28
|
+
"@tuya-sat/micro-utils": "3.1.11",
|
|
29
29
|
"@types/kill-port": "^2.0.0",
|
|
30
30
|
"babel-loader": "8.2.4",
|
|
31
31
|
"babel-plugin-import": "1.13.3",
|