@tuya-sat/micro-script 3.1.7 → 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
- export default function mockSaasInfo(app: Express, microPort: number): void;
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,6 +133,9 @@ 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}`;
136
+ const cookie = expressApp.__appProxy__.getCookie('');
137
+ const csrf = expressApp.__appProxy__.csrfValue.value;
138
+ console.log('cookie...', { cookie, csrf });
135
139
  const app = consturctApp(manifest, oem_micro_app_id, baseUrl, lang, microPort);
136
140
  const entryInfo = consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, '');
137
141
  const permission = consturctPermissions();
@@ -188,18 +192,20 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
188
192
  }
189
193
  return fakeMenu;
190
194
  }
191
- function refactorConstructApp(saasUrl, localApps) {
195
+ function refactorConstructApp(config, localApps) {
192
196
  var _a;
193
197
  return __awaiter(this, void 0, void 0, function* () {
194
198
  const saasAppsMap = {};
195
199
  try {
196
- const res = yield axios_1.default.get(new URL('/api/saas-info', saasUrl).href);
200
+ const res = yield axios_1.default.get(new URL('/api/saas-info', config.url).href, {
201
+ headers: config.headers,
202
+ });
197
203
  (_a = res.data.result.apps) === null || _a === void 0 ? void 0 : _a.forEach((app) => {
198
204
  saasAppsMap[app.universal_id] = app;
199
205
  });
200
206
  }
201
207
  catch (e) {
202
- console.error('获取 SaaS 信息失败,尝试使用假数据模拟 APP 信息');
208
+ console.error('\n获取 SaaS 信息失败,尝试使用假数据模拟 APP 信息\n');
203
209
  }
204
210
  const packageInfo = (0, micro_utils_1.getPackage)();
205
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.7",
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.7",
27
- "@tuya-sat/micro-dev-proxy": "3.1.7",
28
- "@tuya-sat/micro-utils": "3.1.7",
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",