@tuya-sat/micro-script 2.3.0-rc.1 → 2.3.2
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,9 +1,5 @@
|
|
|
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;
|
|
5
2
|
export default function getCommonConfig({ isDev, isBuild, }: {
|
|
6
3
|
isDev: boolean;
|
|
7
4
|
isBuild: boolean;
|
|
8
5
|
}): Configuration;
|
|
9
|
-
export {};
|
|
@@ -12,7 +12,6 @@ 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.validateMicroTheme = void 0;
|
|
16
15
|
//@ts-ignore
|
|
17
16
|
const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
18
17
|
//@ts-ignore
|
|
@@ -23,25 +22,14 @@ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
|
|
|
23
22
|
const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
|
|
24
23
|
const micro_utils_1 = require("@tuya-sat/micro-utils");
|
|
25
24
|
const paths_1 = __importDefault(require("./paths"));
|
|
25
|
+
const theme_1 = require("../utils/theme");
|
|
26
26
|
const toArray = (value) => {
|
|
27
27
|
return Array.isArray(value) ? value : [value];
|
|
28
28
|
};
|
|
29
|
-
const validateMicroTheme = () => {
|
|
30
|
-
const microTheme = process.env.MICRO_THEME;
|
|
31
|
-
if (microTheme && ![index_1.DARK_THEME, index_1.LIGHT_THEME].includes(microTheme)) {
|
|
32
|
-
console.error(`请设置正确的MICRO_THEME环境变量,当前值为${microTheme},请修改为${index_1.LIGHT_THEME}或${index_1.DARK_THEME}`);
|
|
33
|
-
return process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
return microTheme;
|
|
36
|
-
};
|
|
37
|
-
exports.validateMicroTheme = validateMicroTheme;
|
|
38
29
|
function getCommonConfig({ isDev, isBuild, }) {
|
|
39
30
|
const { name: packageName } = require(paths_1.default.appPkg);
|
|
40
31
|
const { annotations } = (0, micro_utils_1.parseManifest)();
|
|
41
|
-
const
|
|
42
|
-
const enableThemeCompile = isDev
|
|
43
|
-
? !!devMicroTheme
|
|
44
|
-
: annotations["sdf.feat:colorTheme"];
|
|
32
|
+
const enableThemeCompile = annotations["sdf.feat:colorTheme"];
|
|
45
33
|
//获取style处理的loader
|
|
46
34
|
const getStyleLoaders = (extraLoader = []) => {
|
|
47
35
|
extraLoader = toArray(extraLoader);
|
|
@@ -62,7 +50,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
62
50
|
importLoaders: loadersBeforeCssLoader.length,
|
|
63
51
|
},
|
|
64
52
|
},
|
|
65
|
-
...loadersBeforeCssLoader
|
|
53
|
+
...loadersBeforeCssLoader
|
|
66
54
|
].filter(Boolean);
|
|
67
55
|
return loaders;
|
|
68
56
|
};
|
|
@@ -94,13 +82,11 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
94
82
|
{
|
|
95
83
|
loader: require.resolve("less-loader"),
|
|
96
84
|
options: {
|
|
97
|
-
lessOptions: Object.assign(Object.assign({}, (
|
|
98
|
-
?
|
|
99
|
-
? (0, index_1.getLessOptions)(
|
|
100
|
-
:
|
|
101
|
-
:
|
|
102
|
-
? (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
|
|
103
|
-
: {})), { javascriptEnabled: true }),
|
|
85
|
+
lessOptions: Object.assign(Object.assign({}, (enableThemeCompile
|
|
86
|
+
? isDev
|
|
87
|
+
? (0, index_1.getLessOptions)((0, theme_1.getBaseTheme)())
|
|
88
|
+
: (0, index_1.getLessOptions)(index_1.LIGHT_THEME)
|
|
89
|
+
: {})), { javascriptEnabled: true }),
|
|
104
90
|
},
|
|
105
91
|
},
|
|
106
92
|
enableThemeCompile &&
|
|
@@ -163,7 +149,7 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
163
149
|
patterns: [
|
|
164
150
|
{
|
|
165
151
|
from: paths_1.default.publicDir,
|
|
166
|
-
filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return
|
|
152
|
+
filter: (resourcePath) => __awaiter(this, void 0, void 0, function* () { return resourcePath !== paths_1.default.spaHtml; }),
|
|
167
153
|
noErrorOnMissing: true,
|
|
168
154
|
},
|
|
169
155
|
],
|
|
@@ -174,7 +160,6 @@ function getCommonConfig({ isDev, isBuild, }) {
|
|
|
174
160
|
chunkFilename: "static/css/[name].[contenthash:8].chunk.css",
|
|
175
161
|
}),
|
|
176
162
|
isBuild && enableThemeCompile && new micro_dev_loader_1.ThemePlugin(),
|
|
177
|
-
isBuild && new micro_dev_loader_1.LocalesPlugin(),
|
|
178
163
|
].filter((value) => Boolean(value)),
|
|
179
164
|
};
|
|
180
165
|
}
|
|
@@ -39,7 +39,7 @@ 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
|
|
42
|
+
const theme_1 = require("../../utils/theme");
|
|
43
43
|
const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.516/";
|
|
44
44
|
function staticMain(app, debuggerConfig) {
|
|
45
45
|
app.get([
|
|
@@ -95,15 +95,11 @@ function insertScript($, debuggerConfig) {
|
|
|
95
95
|
let themeConfig = saas.custom_configs.find((item) => {
|
|
96
96
|
return item.config_key === "dynamic_theme";
|
|
97
97
|
}) || initalCustom_configs(saas);
|
|
98
|
-
const theme = (0,
|
|
99
|
-
themeConfig.config_value_json = JSON.stringify(Object.assign(Object.assign(Object.assign({}, JSON.parse(themeConfig.config_value_json)), (theme
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
: {})), readThemeConfig()));
|
|
98
|
+
const theme = (0, theme_1.getBaseTheme)();
|
|
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()));
|
|
104
102
|
overrideNotification(saas);
|
|
105
|
-
// 本地开发态多语言剥离多语言平台,走本地多语言兜底逻辑
|
|
106
|
-
_SDF.saas.saas_locales = {};
|
|
107
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)};
|
|
108
104
|
localStorage.setItem('theme',${JSON.stringify(process.env.MICRO_THEME)});
|
|
109
105
|
localStorage.setItem('isDebugger','true')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseTheme = void 0;
|
|
4
|
+
const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
|
|
5
|
+
const getBaseTheme = () => {
|
|
6
|
+
const microTheme = process.env.MICRO_THEME;
|
|
7
|
+
if (!microTheme || ![index_1.DARK_THEME, index_1.LIGHT_THEME].includes(microTheme))
|
|
8
|
+
return index_1.LIGHT_THEME;
|
|
9
|
+
return microTheme;
|
|
10
|
+
};
|
|
11
|
+
exports.getBaseTheme = getBaseTheme;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuya-sat/micro-script",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
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.3.
|
|
24
|
-
"@tuya-sat/micro-dev-proxy": "2.3.
|
|
25
|
-
"@tuya-sat/micro-utils": "2.3.
|
|
23
|
+
"@tuya-sat/micro-dev-loader": "2.3.2",
|
|
24
|
+
"@tuya-sat/micro-dev-proxy": "2.3.2",
|
|
25
|
+
"@tuya-sat/micro-utils": "2.3.2",
|
|
26
26
|
"babel-loader": "8.2.4",
|
|
27
27
|
"babel-plugin-import": "1.13.3",
|
|
28
28
|
"chalk": "4.1.2",
|
|
@@ -75,6 +75,5 @@
|
|
|
75
75
|
"saas",
|
|
76
76
|
"cloud",
|
|
77
77
|
"tuya"
|
|
78
|
-
]
|
|
79
|
-
"stableVersion": "2.2.30"
|
|
78
|
+
]
|
|
80
79
|
}
|