@tuya-sat/micro-script 2.2.26 → 2.2.29

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,5 +1,9 @@
1
1
  import { Configuration } from "webpack";
2
+ import { ThemeCat } from "@tuya-sat/micro-dev-loader/dist/less/utils/index";
3
+ declare type ThemeEnv = ThemeCat | undefined;
4
+ export declare const validateMicroTheme: () => ThemeEnv;
2
5
  export default function getCommonConfig({ isDev, isBuild, }: {
3
6
  isDev: boolean;
4
7
  isBuild: boolean;
5
8
  }): Configuration;
9
+ export {};
@@ -12,7 +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
- const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ exports.validateMicroTheme = void 0;
16
16
  //@ts-ignore
17
17
  const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
18
18
  //@ts-ignore
@@ -23,9 +23,6 @@ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
23
23
  const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
24
24
  const micro_utils_1 = require("@tuya-sat/micro-utils");
25
25
  const paths_1 = __importDefault(require("./paths"));
26
- const isExistPostcssFile = () => {
27
- return fs_extra_1.default.existsSync("postcss.config.js");
28
- };
29
26
  const toArray = (value) => {
30
27
  return Array.isArray(value) ? value : [value];
31
28
  };
@@ -37,16 +34,22 @@ const validateMicroTheme = () => {
37
34
  }
38
35
  return microTheme;
39
36
  };
37
+ exports.validateMicroTheme = validateMicroTheme;
40
38
  function getCommonConfig({ isDev, isBuild, }) {
41
39
  const { name: packageName } = require(paths_1.default.appPkg);
42
40
  const { annotations } = (0, micro_utils_1.parseManifest)();
43
- const devMicroTheme = validateMicroTheme();
41
+ const devMicroTheme = (0, exports.validateMicroTheme)();
44
42
  const enableThemeCompile = isDev
45
43
  ? !!devMicroTheme
46
44
  : annotations["sdf.feat:colorTheme"];
47
45
  //获取style处理的loader
48
46
  const getStyleLoaders = (extraLoader = []) => {
49
47
  extraLoader = toArray(extraLoader);
48
+ const loadersBeforeCssLoader = [
49
+ isDev && require("@tuya-sat/micro-dev-loader").filterCssVariableLoader,
50
+ require.resolve("postcss-loader"),
51
+ ...extraLoader,
52
+ ].filter(Boolean);
50
53
  const loaders = [
51
54
  isBuild ? mini_css_extract_plugin_1.default.loader : require.resolve("style-loader"),
52
55
  {
@@ -56,27 +59,10 @@ function getCommonConfig({ isDev, isBuild, }) {
56
59
  auto: true,
57
60
  localIdentName: isDev ? "[path][name]__[local]" : "[hash:base64]",
58
61
  },
59
- importLoaders: extraLoader.length + 1,
62
+ importLoaders: loadersBeforeCssLoader.length,
60
63
  },
61
64
  },
62
- isDev && require("@tuya-sat/micro-dev-loader").filterCssVariableLoader,
63
- /**
64
- * 优化运行时速度
65
- * dev环境就不需要postcss-loader了
66
- * 默认应该比较新的浏览器了
67
- */
68
- isBuild && Object.assign({ loader: require.resolve("postcss-loader") }, (() => {
69
- return isExistPostcssFile()
70
- ? {}
71
- : {
72
- options: {
73
- postcssOptions: {
74
- plugins: ["postcss-preset-env"],
75
- },
76
- },
77
- };
78
- })()),
79
- ...extraLoader,
65
+ ...loadersBeforeCssLoader
80
66
  ].filter(Boolean);
81
67
  return loaders;
82
68
  };
@@ -39,7 +39,8 @@ const cheerio_1 = __importDefault(require("cheerio"));
39
39
  const axios_1 = __importDefault(require("axios"));
40
40
  const fakeSaas_1 = __importStar(require("./fakeSaas"));
41
41
  const paths_1 = __importDefault(require("../../config/paths"));
42
- const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.452/";
42
+ const webpack_common_1 = require("../../config/webpack.common");
43
+ const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.516/";
43
44
  function staticMain(app, debuggerConfig) {
44
45
  app.get([
45
46
  "/",
@@ -80,6 +81,10 @@ function readThemeConfig() {
80
81
  delete require.cache[paths_1.default.microConfig];
81
82
  return require(paths_1.default.microConfig).debuggerConfig.themeConfig;
82
83
  }
84
+ function overrideNotification(value) {
85
+ const isProxy = process.env.MICRO_PROXY === "true";
86
+ !isProxy && (value.message_switch = false);
87
+ }
83
88
  function insertScript($, debuggerConfig) {
84
89
  var _a;
85
90
  return __awaiter(this, void 0, void 0, function* () {
@@ -90,7 +95,11 @@ function insertScript($, debuggerConfig) {
90
95
  let themeConfig = saas.custom_configs.find((item) => {
91
96
  return item.config_key === "dynamic_theme";
92
97
  }) || initalCustom_configs(saas);
93
- themeConfig.config_value_json = JSON.stringify(Object.assign(Object.assign({}, JSON.parse(themeConfig.config_value_json)), readThemeConfig()));
98
+ const theme = (0, webpack_common_1.validateMicroTheme)();
99
+ themeConfig.config_value_json = JSON.stringify(Object.assign(Object.assign(Object.assign({}, JSON.parse(themeConfig.config_value_json)), (theme ? {
100
+ supportedTheme: theme,
101
+ } : {})), readThemeConfig()));
102
+ overrideNotification(saas);
94
103
  $("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)};
95
104
  localStorage.setItem('theme',${JSON.stringify(process.env.MICRO_THEME)});
96
105
  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.26",
3
+ "version": "2.2.29",
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.26",
24
- "@tuya-sat/micro-dev-proxy": "2.2.26",
25
- "@tuya-sat/micro-utils": "2.2.26",
23
+ "@tuya-sat/micro-dev-loader": "2.2.29",
24
+ "@tuya-sat/micro-dev-proxy": "2.2.29",
25
+ "@tuya-sat/micro-utils": "2.2.29",
26
26
  "babel-loader": "8.2.4",
27
27
  "babel-plugin-import": "1.13.3",
28
28
  "chalk": "4.1.2",