@tuya-sat/micro-script 3.0.0-beta.10 → 3.0.0-beta.13

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.
@@ -24,7 +24,6 @@ const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
24
24
  const path_1 = __importDefault(require("path"));
25
25
  const index_1 = require("@tuya-sat/micro-dev-loader/dist/less/utils/index");
26
26
  const paths_1 = __importDefault(require("./paths"));
27
- const locales_1 = __importDefault(require("@tuya-sat/micro-dev-loader/dist/plugins/locales"));
28
27
  const utils_1 = require("../utils");
29
28
  const toArray = (value) => {
30
29
  return Array.isArray(value) ? value : [value];
@@ -183,7 +182,6 @@ function getCommonConfig({ isDev, isBuild, }) {
183
182
  chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
184
183
  }),
185
184
  isBuild && enableThemeCompile && new micro_dev_loader_1.ThemePlugin(),
186
- isBuild && new locales_1.default(),
187
185
  ].filter((value) => Boolean(value)),
188
186
  };
189
187
  return baseConfig;
@@ -45,12 +45,17 @@ function mockSaasInfo(app, microPort) {
45
45
  apps: [],
46
46
  entry_info: { entries: [], entry_mode: 'normal' },
47
47
  permissions: {},
48
+ saas_id_info_list: [],
48
49
  };
49
50
  multiApps.forEach((app) => {
50
51
  const entry_id = idsMap.get(app.name).entry_id;
51
52
  const manifest = fs_extra_1.default.readJSONSync(path.join(process.cwd(), `${app.dir}/manifest.json`), 'utf-8');
52
53
  const oem_micro_app_id = idsMap.get(app.name).oem_micro_app_id;
53
54
  const baseUrl = `/apps/${oem_micro_app_id}`;
55
+ result.saas_id_info_list.push({
56
+ oem_micro_app_id: oem_micro_app_id,
57
+ universal_id: '',
58
+ });
54
59
  const micoApp = consturctApp(manifest, oem_micro_app_id, baseUrl, lang, microPort, app.name);
55
60
  const entryInfo = consturctEntry(manifest, oem_micro_app_id, entry_id, baseUrl, lang, app.dir);
56
61
  const permission = consturctPermissions();
@@ -82,6 +87,9 @@ function mockSaasInfo(app, microPort) {
82
87
  apps: [app],
83
88
  entry_info: { entries: [entryInfo], entry_mode: 'normal' },
84
89
  permissions: { [oem_micro_app_id]: permission },
90
+ saas_id_info_list: [
91
+ { oem_micro_app_id: oem_micro_app_id, universal_id: '' },
92
+ ],
85
93
  },
86
94
  success: true,
87
95
  });
@@ -1,5 +1,5 @@
1
- import { Express } from "express";
2
- import type { Config } from "@tuya-sat/micro-dev-proxy";
1
+ import { Express } from 'express';
2
+ import type { Config } from '@tuya-sat/micro-dev-proxy';
3
3
  export interface DebuggerConfig extends Config {
4
4
  themeConfig?: {
5
5
  primaryColor: string;
@@ -40,21 +40,21 @@ const axios_1 = __importDefault(require("axios"));
40
40
  const fakeSaas_1 = __importStar(require("./fakeSaas"));
41
41
  const paths_1 = __importDefault(require("../../config/paths"));
42
42
  const webpack_common_1 = require("../../config/webpack.common");
43
- const defaultBase = "https://static1.tuyacn.com/static/sdf-gw/v1.0.1.516/";
43
+ const defaultBase = 'https://static1.tuyacn.com/static/sdf-gw/v1.0.1.516/';
44
44
  function staticMain(app, debuggerConfig) {
45
45
  app.get([
46
- "/",
47
- "/apps/:appId",
48
- "/login",
49
- "/apps/:appId/*",
50
- "/application",
51
- "/application/*",
46
+ '/',
47
+ '/apps/:appId',
48
+ '/login',
49
+ '/apps/:appId/*',
50
+ '/application',
51
+ '/application/*',
52
52
  ], (req, res) => __awaiter(this, void 0, void 0, function* () {
53
53
  if (app._isLogin) {
54
54
  yield app._isLogin;
55
55
  }
56
56
  const base = debuggerConfig.base || defaultBase;
57
- const { data } = yield axios_1.default.get(new URL("index.html", base).href);
57
+ const { data } = yield axios_1.default.get(new URL('index.html', base).href);
58
58
  const $ = cheerio_1.default.load(data);
59
59
  modifySrcAttr($, base);
60
60
  yield insertScript($, debuggerConfig);
@@ -64,15 +64,15 @@ function staticMain(app, debuggerConfig) {
64
64
  exports.default = staticMain;
65
65
  function initalCustom_configs(saas) {
66
66
  const config = {
67
- config_group: "",
68
- config_key: "dynamic_theme",
69
- config_value: "",
70
- config_label: "",
71
- config_value_json: "{}",
72
- config_name_zh: "",
73
- config_name_en: "",
74
- platform: "",
75
- config_id: "",
67
+ config_group: '',
68
+ config_key: 'dynamic_theme',
69
+ config_value: '',
70
+ config_label: '',
71
+ config_value_json: '{}',
72
+ config_name_zh: '',
73
+ config_name_en: '',
74
+ platform: '',
75
+ config_id: '',
76
76
  };
77
77
  saas.custom_configs.push(config);
78
78
  return config;
@@ -82,7 +82,7 @@ function readThemeConfig() {
82
82
  return require(paths_1.default.microConfig).debuggerConfig.themeConfig;
83
83
  }
84
84
  function overrideNotification(value) {
85
- const isProxy = process.env.MICRO_PROXY === "true";
85
+ const isProxy = process.env.MICRO_PROXY === 'true';
86
86
  !isProxy && (value.message_switch = false);
87
87
  }
88
88
  function insertScript($, debuggerConfig) {
@@ -93,7 +93,7 @@ function insertScript($, debuggerConfig) {
93
93
  const { saas } = _SDF;
94
94
  (_a = saas.custom_configs) !== null && _a !== void 0 ? _a : (saas.custom_configs = []);
95
95
  let themeConfig = saas.custom_configs.find((item) => {
96
- return item.config_key === "dynamic_theme";
96
+ return item.config_key === 'dynamic_theme';
97
97
  }) || initalCustom_configs(saas);
98
98
  const theme = (0, webpack_common_1.validateMicroTheme)();
99
99
  themeConfig.config_value_json = JSON.stringify(Object.assign(Object.assign(Object.assign({}, JSON.parse(themeConfig.config_value_json)), (theme
@@ -103,17 +103,17 @@ function insertScript($, debuggerConfig) {
103
103
  : {})), readThemeConfig()));
104
104
  overrideNotification(saas);
105
105
  // 本地开发态多语言剥离多语言平台,走本地多语言兜底逻辑
106
- _SDF.saas.saas_locales = {};
107
- $("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)};
106
+ delete _SDF.saas.saas_locales;
107
+ $('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
108
  localStorage.setItem('theme',${JSON.stringify(process.env.MICRO_THEME)});
109
109
  localStorage.setItem('isDebugger','true')
110
110
  `));
111
111
  });
112
112
  }
113
113
  function modifySrcAttr($, base) {
114
- const tags = ["img src", "link href", "script src"];
114
+ const tags = ['img src', 'link href', 'script src'];
115
115
  tags.forEach((p) => {
116
- const [tagName, attr] = p.split(" ");
116
+ const [tagName, attr] = p.split(' ');
117
117
  $(tagName).map(function () {
118
118
  const origin = $(this).attr(attr);
119
119
  if (/^(\/|http:|https:)/.test(origin))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.0.0-beta.10",
3
+ "version": "3.0.0-beta.13",
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": "3.0.0-beta.10",
24
- "@tuya-sat/micro-dev-proxy": "3.0.0-beta.10",
25
- "@tuya-sat/micro-utils": "3.0.0-beta.10",
23
+ "@tuya-sat/micro-dev-loader": "3.0.0-beta.13",
24
+ "@tuya-sat/micro-dev-proxy": "3.0.0-beta.13",
25
+ "@tuya-sat/micro-utils": "3.0.0-beta.13",
26
26
  "@types/kill-port": "^2.0.0",
27
27
  "babel-loader": "8.2.4",
28
28
  "babel-plugin-import": "1.13.3",