@tuya-sat/micro-script 2.2.15 → 2.2.16

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.
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const cheerio_1 = __importDefault(require("cheerio"));
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const fakeSaas_1 = __importDefault(require("./fakeSaas"));
18
+ const paths_1 = __importDefault(require("../../config/paths"));
18
19
  const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.293/";
19
20
  function staticMain(app, debuggerConfig) {
20
21
  app.get([
@@ -43,26 +44,35 @@ function insertLocalStorage($) {
43
44
  window.localStorage.setItem('_ROLE','普通');
44
45
  `));
45
46
  }
47
+ function initalCustom_configs(saas) {
48
+ const config = {
49
+ config_group: "",
50
+ config_key: "dynamic_theme",
51
+ config_value: "",
52
+ config_label: "",
53
+ config_value_json: "",
54
+ config_name_zh: "",
55
+ config_name_en: "",
56
+ platform: "",
57
+ config_id: "",
58
+ };
59
+ saas.custom_configs.push(config);
60
+ return config;
61
+ }
62
+ function readThemeConfig() {
63
+ delete require.cache[paths_1.default.microConfig];
64
+ return require(paths_1.default.microConfig).debuggerConfig.themeConfig;
65
+ }
46
66
  function insertScript($, debuggerConfig) {
47
67
  var _a;
48
- var _b;
49
68
  return __awaiter(this, void 0, void 0, function* () {
50
69
  const { _SDF_CONFIG, _SDF, __MAIN_APP_PUBLIC_PATH } = yield (0, fakeSaas_1.default)(debuggerConfig);
51
- (_a = (_b = _SDF.saas).custom_configs) !== null && _a !== void 0 ? _a : (_b.custom_configs = []);
52
- let themeConfig = _SDF.saas.custom_configs.find((item) => {
70
+ const { saas } = _SDF;
71
+ (_a = saas.custom_configs) !== null && _a !== void 0 ? _a : (saas.custom_configs = []);
72
+ let themeConfig = saas.custom_configs.find((item) => {
53
73
  return item.config_key === "dynamic_theme";
54
- }) || {
55
- config_group: "",
56
- config_key: "",
57
- config_value: "",
58
- config_label: "",
59
- config_value_json: "",
60
- config_name_zh: "",
61
- config_name_en: "",
62
- platform: "",
63
- config_id: "",
64
- };
65
- themeConfig.config_value_json = JSON.stringify(debuggerConfig.themeConfig);
74
+ }) || initalCustom_configs(saas);
75
+ themeConfig.config_value_json = JSON.stringify(readThemeConfig());
66
76
  $("head").append($("<script>").text(`window._SDF_CONFIG=${JSON.stringify(_SDF_CONFIG)};window._SDF=${JSON.stringify(_SDF)};window.__MAIN_APP_PUBLIC_PATH=${JSON.stringify(__MAIN_APP_PUBLIC_PATH)};
67
77
  localStorage.setItem('theme',${JSON.stringify(process.env.MICRO_THEME)});
68
78
  localStorage.setItem('isDebugger','true')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "2.2.15",
3
+ "version": "2.2.16",
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.15",
24
- "@tuya-sat/micro-dev-proxy": "2.2.15",
25
- "@tuya-sat/micro-utils": "2.2.15",
23
+ "@tuya-sat/micro-dev-loader": "2.2.16",
24
+ "@tuya-sat/micro-dev-proxy": "2.2.16",
25
+ "@tuya-sat/micro-utils": "2.2.16",
26
26
  "babel-loader": "8.2.4",
27
27
  "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",