@tuya-sat/micro-script 1.0.2 → 1.0.3

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.
@@ -0,0 +1,8 @@
1
+ /// <reference types="qs" />
2
+ /// <reference types="express" />
3
+ declare const _default: {
4
+ name: string;
5
+ path: string;
6
+ middleware: import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
7
+ };
8
+ export default _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const middleware = (req, res, next) => {
4
+ if (req.method === "OPTIONS") {
5
+ res.statusCode = 204;
6
+ res.send("ok");
7
+ return;
8
+ }
9
+ next();
10
+ };
11
+ exports.default = {
12
+ name: "options-middleware",
13
+ path: "*",
14
+ middleware,
15
+ };
@@ -11,22 +11,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
+ var _a;
14
15
  Object.defineProperty(exports, "__esModule", { value: true });
15
16
  const webpack_1 = __importDefault(require("webpack"));
16
17
  const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
17
18
  const ora_1 = __importDefault(require("ora"));
19
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
20
  const portfinder_1 = __importDefault(require("portfinder"));
19
21
  const micro_dev_loader_1 = require("@tuya-sat/micro-dev-loader");
20
22
  const paths_1 = __importDefault(require("../config/paths"));
21
23
  const webpack_config_1 = __importDefault(require("../config/webpack.config"));
22
24
  const mock_1 = __importDefault(require("../module/mock"));
25
+ const options_1 = __importDefault(require("../module/options"));
26
+ const isMobile = ((_a = fs_extra_1.default.readJSONSync(paths_1.default.manifest).supportedPlatform) === null || _a === void 0 ? void 0 : _a[0]) === "MOBILE";
27
+ const { debuggerConfig, needMainLayout = !isMobile, } = require(paths_1.default.microConfig);
23
28
  const config = Object.assign(Object.assign({}, (0, webpack_config_1.default)()), {
24
29
  //下面所有配置都是为了精简terminal输出
25
30
  infrastructureLogging: {
26
31
  level: "warn",
27
32
  }, stats: "errors-warnings" });
28
33
  const compiler = (0, webpack_1.default)(config);
29
- new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
34
+ needMainLayout && new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
30
35
  (() => __awaiter(void 0, void 0, void 0, function* () {
31
36
  let defaultPort = 9000;
32
37
  //检测端口占用情况
@@ -46,11 +51,11 @@ new micro_dev_loader_1.LayoutMockPlugin().apply(compiler);
46
51
  "Access-Control-Allow-Headers": "*",
47
52
  },
48
53
  setupMiddlewares(middlewares, { app }) {
49
- micro_dev_loader_1.LayoutMockPlugin.useLayoutStatic(app);
54
+ needMainLayout && micro_dev_loader_1.LayoutMockPlugin.useLayoutStatic(app);
55
+ middlewares.push(options_1.default);
50
56
  (0, mock_1.default)(app);
51
57
  if (process.env.MICRO_DEBUGGER === "true") {
52
58
  const createProxy = require("@tuya-sat/micro-dev-proxy").default;
53
- const { debuggerConfig } = require(paths_1.default.microConfig);
54
59
  createProxy(debuggerConfig)(app);
55
60
  }
56
61
  return middlewares;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -15,8 +15,8 @@
15
15
  "@babel/preset-react": "^7.14.5",
16
16
  "@babel/preset-typescript": "^7.15.0",
17
17
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
18
- "@tuya-sat/micro-dev-loader": "1.0.2",
19
- "@tuya-sat/micro-dev-proxy": "1.0.2",
18
+ "@tuya-sat/micro-dev-loader": "1.0.3",
19
+ "@tuya-sat/micro-dev-proxy": "1.0.3",
20
20
  "babel-loader": "^8.2.2",
21
21
  "babel-plugin-import": "^1.13.3",
22
22
  "chalk": "4.1.2",