@tuya-sat/micro-script 3.1.5 → 3.1.7

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.
@@ -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'))) {
@@ -178,6 +188,27 @@ function consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, dir
178
188
  }
179
189
  return fakeMenu;
180
190
  }
191
+ function refactorConstructApp(saasUrl, localApps) {
192
+ var _a;
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ const saasAppsMap = {};
195
+ try {
196
+ const res = yield axios_1.default.get(new URL('/api/saas-info', saasUrl).href);
197
+ (_a = res.data.result.apps) === null || _a === void 0 ? void 0 : _a.forEach((app) => {
198
+ saasAppsMap[app.universal_id] = app;
199
+ });
200
+ }
201
+ catch (e) {
202
+ console.error('获取 SaaS 信息失败,尝试使用假数据模拟 APP 信息');
203
+ }
204
+ const packageInfo = (0, micro_utils_1.getPackage)();
205
+ return localApps.map((app) => {
206
+ const uuid = app.manifest.universalId;
207
+ const code = app.code || `${packageInfo.name}`;
208
+ 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 });
209
+ });
210
+ });
211
+ }
181
212
  function consturctApp(manifest, oem_micro_app_id, baseUrl, lang, port, code) {
182
213
  const packageInfo = (0, micro_utils_1.getPackage)();
183
214
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
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.5",
27
- "@tuya-sat/micro-dev-proxy": "3.1.5",
28
- "@tuya-sat/micro-utils": "3.1.5",
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",
29
29
  "@types/kill-port": "^2.0.0",
30
30
  "babel-loader": "8.2.4",
31
31
  "babel-plugin-import": "1.13.3",