@tuya-sat/micro-script 2.2.18 → 2.2.21

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.
@@ -43,7 +43,7 @@ function getCommonConfig({ isDev, isBuild, }) {
43
43
  const devMicroTheme = validateMicroTheme();
44
44
  const enableThemeCompile = isDev
45
45
  ? !!devMicroTheme
46
- : annotations["sdf.feat:theme"];
46
+ : annotations["sdf.feat:colorTheme"];
47
47
  //获取style处理的loader
48
48
  const getStyleLoaders = (extraLoader = []) => {
49
49
  extraLoader = toArray(extraLoader);
@@ -112,13 +112,15 @@ function getCommonConfig({ isDev, isBuild, }) {
112
112
  ? enableThemeCompile
113
113
  ? (0, index_1.getLessOptions)(devMicroTheme)
114
114
  : {}
115
- : annotations["sdf.feat:theme"]
115
+ : annotations["sdf.feat:colorTheme"]
116
116
  ? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
117
117
  : {})), { javascriptEnabled: true }),
118
118
  },
119
119
  },
120
120
  enableThemeCompile &&
121
121
  require("@tuya-sat/micro-dev-loader").changeAntdGlobalImport,
122
+ enableThemeCompile &&
123
+ require("@tuya-sat/micro-dev-loader").changeTuyaSatComponentImport
122
124
  ].filter(Boolean)),
123
125
  },
124
126
  {
@@ -7,4 +7,11 @@ export default function getFakeSaas(config: DebuggerConfig): Promise<{
7
7
  _SDF_CONFIG: anyObject;
8
8
  __MAIN_APP_PUBLIC_PATH: string;
9
9
  }>;
10
+ export declare function getFakeUser(config: DebuggerConfig): {
11
+ user_name: string;
12
+ roles: {
13
+ role_code: string;
14
+ role_name: string;
15
+ }[];
16
+ };
10
17
  export {};
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getFakeUser = void 0;
15
16
  const fs_extra_1 = __importDefault(require("fs-extra"));
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  const chalk_1 = __importDefault(require("chalk"));
@@ -38,7 +39,7 @@ function getFakeSaas(config) {
38
39
  process.exit(1);
39
40
  }
40
41
  if (!fs_extra_1.default.existsSync(paths_1.default.saasCache)) {
41
- const { data } = yield axios_1.default.get(config.target);
42
+ const { data } = yield axios_1.default.get(new URL("/login", config.target).href);
42
43
  const _SDF_CONFIG = parse_SDF_CONFIG(data);
43
44
  const _SDF = parse_SDF(data);
44
45
  const __MAIN_APP_PUBLIC_PATH = parse__MAIN_APP_PUBLIC_PATH(data);
@@ -47,7 +48,6 @@ function getFakeSaas(config) {
47
48
  _SDF: JSON.parse(_SDF),
48
49
  __MAIN_APP_PUBLIC_PATH: JSON.parse(__MAIN_APP_PUBLIC_PATH),
49
50
  };
50
- console.log(saas);
51
51
  fs_extra_1.default.writeJSONSync(paths_1.default.saasCache, saas);
52
52
  return saas;
53
53
  }
@@ -55,3 +55,15 @@ function getFakeSaas(config) {
55
55
  });
56
56
  }
57
57
  exports.default = getFakeSaas;
58
+ function getFakeUser(config) {
59
+ return {
60
+ user_name: config.username || "admin@tuya.com",
61
+ roles: [
62
+ {
63
+ role_code: "FAKE_ROLE_CODE",
64
+ role_name: "FAKE_ROLE_NAME",
65
+ },
66
+ ],
67
+ };
68
+ }
69
+ exports.getFakeUser = getFakeUser;
@@ -18,4 +18,6 @@ export declare type CustomConfig = {
18
18
  platform: string;
19
19
  config_id: string;
20
20
  };
21
- export default function staticMain(app: Express, debuggerConfig: DebuggerConfig): void;
21
+ export default function staticMain(app: Express & {
22
+ _isLogin?: Promise<void>;
23
+ }, debuggerConfig: DebuggerConfig): void;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -14,9 +37,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
37
  Object.defineProperty(exports, "__esModule", { value: true });
15
38
  const cheerio_1 = __importDefault(require("cheerio"));
16
39
  const axios_1 = __importDefault(require("axios"));
17
- const fakeSaas_1 = __importDefault(require("./fakeSaas"));
40
+ const fakeSaas_1 = __importStar(require("./fakeSaas"));
18
41
  const paths_1 = __importDefault(require("../../config/paths"));
19
- const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.293/";
42
+ const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.352/";
20
43
  function staticMain(app, debuggerConfig) {
21
44
  app.get([
22
45
  "/",
@@ -26,24 +49,18 @@ function staticMain(app, debuggerConfig) {
26
49
  "/application",
27
50
  "/application/*",
28
51
  ], (req, res) => __awaiter(this, void 0, void 0, function* () {
52
+ if (app._isLogin) {
53
+ yield app._isLogin;
54
+ }
29
55
  const base = debuggerConfig.base || defaultBase;
30
56
  const { data } = yield axios_1.default.get(new URL("index.html", base).href);
31
57
  const $ = cheerio_1.default.load(data);
32
58
  modifySrcAttr($, base);
33
- insertLocalStorage($);
34
59
  yield insertScript($, debuggerConfig);
35
60
  res.send($.html());
36
61
  }));
37
62
  }
38
63
  exports.default = staticMain;
39
- function insertLocalStorage($) {
40
- //可能有坑
41
- $("head").append($("<script>").text(`
42
- window.localStorage.setItem('isLogin','Yes');
43
- window.localStorage.setItem('_USERNAME','fake_user');
44
- window.localStorage.setItem('_ROLE','普通');
45
- `));
46
- }
47
64
  function initalCustom_configs(saas) {
48
65
  const config = {
49
66
  config_group: "",
@@ -67,6 +84,7 @@ function insertScript($, debuggerConfig) {
67
84
  var _a;
68
85
  return __awaiter(this, void 0, void 0, function* () {
69
86
  const { _SDF_CONFIG, _SDF, __MAIN_APP_PUBLIC_PATH } = yield (0, fakeSaas_1.default)(debuggerConfig);
87
+ _SDF.user = (0, fakeSaas_1.getFakeUser)(debuggerConfig);
70
88
  const { saas } = _SDF;
71
89
  (_a = saas.custom_configs) !== null && _a !== void 0 ? _a : (saas.custom_configs = []);
72
90
  let themeConfig = saas.custom_configs.find((item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "2.2.18",
3
+ "version": "2.2.21",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  "@babel/preset-react": "7.16.7",
21
21
  "@babel/preset-typescript": "7.16.7",
22
22
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
23
- "@tuya-sat/micro-dev-loader": "2.2.18",
24
- "@tuya-sat/micro-dev-proxy": "2.2.18",
25
- "@tuya-sat/micro-utils": "2.2.18",
23
+ "@tuya-sat/micro-dev-loader": "2.2.21",
24
+ "@tuya-sat/micro-dev-proxy": "2.2.21",
25
+ "@tuya-sat/micro-utils": "2.2.21",
26
26
  "babel-loader": "8.2.4",
27
27
  "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",