@tuya-sat/micro-script 3.0.19-beta.1 → 3.0.19

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
+ import '@tuya-sat/sdf-main-sdk/dist/main.css';
2
+ import 'react';
3
+ import { bootStrapSDF } from '@tuya-sat/sdf-main-sdk';
4
+ import { reWriteUI } from './utils';
5
+ import lang from '../../src/lang';
6
+ import hooks from '../../src/hooks';
7
+
8
+ bootStrapSDF({ lang, hooks, ui: reWriteUI() });
@@ -0,0 +1,51 @@
1
+ import { IUI } from '@tuya-sat/sdf-main-sdk';
2
+
3
+ const bindCmp = (result, cmp, name) => {
4
+ cmp.keys().forEach((key) => {
5
+ if (key.includes('index.tsx')) {
6
+ result[name] = cmp(key).default;
7
+ } else {
8
+ return;
9
+ }
10
+ });
11
+ };
12
+
13
+ export const reWriteUI = () => {
14
+ const result = { pages: {} };
15
+ const pages = (require as any).context(
16
+ '../../src/pages',
17
+ true,
18
+ /\.([tj]sx)|[tj]s$/
19
+ );
20
+ pages.keys().forEach((key) => {
21
+ if (key.includes('index.tsx')) {
22
+ const name = key.split('/')[1];
23
+ result.pages[name.charAt(0).toUpperCase() + name.slice(1)] =
24
+ pages(key).default;
25
+ } else {
26
+ return;
27
+ }
28
+ });
29
+
30
+ const bdb = (require as any).context(
31
+ '../../src/bdb',
32
+ true,
33
+ /\.([tj]sx)|[tj]s$/
34
+ );
35
+ bindCmp(result, bdb, 'bdb');
36
+
37
+ const menu = (require as any).context(
38
+ '../../src/menu',
39
+ true,
40
+ /\.([tj]sx)|[tj]s$/
41
+ );
42
+ bindCmp(result, menu, 'menu');
43
+
44
+ const nav = (require as any).context(
45
+ '../../src/nav',
46
+ true,
47
+ /\.([tj]sx)|[tj]s$/
48
+ );
49
+ bindCmp(result, nav, 'nav');
50
+ return result as IUI;
51
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.0.19-beta.1",
3
+ "version": "3.0.19",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "@babel/preset-typescript": "7.16.7",
24
24
  "@babel/traverse": "^7.20.13",
25
25
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
26
- "@tuya-sat/micro-dev-loader": "3.0.19-beta.1",
27
- "@tuya-sat/micro-dev-proxy": "3.0.19-beta.1",
28
- "@tuya-sat/micro-utils": "3.0.19-beta.1",
26
+ "@tuya-sat/micro-dev-loader": "3.0.19",
27
+ "@tuya-sat/micro-dev-proxy": "3.0.19",
28
+ "@tuya-sat/micro-utils": "3.0.19",
29
29
  "@types/kill-port": "^2.0.0",
30
30
  "babel-loader": "8.2.4",
31
31
  "babel-plugin-import": "1.13.3",
@@ -5,3 +5,8 @@ fs.copySync(
5
5
  path.join(process.cwd(), './src/template/micro-app'),
6
6
  path.join(process.cwd(), 'dist/template/micro-app')
7
7
  );
8
+
9
+ fs.copySync(
10
+ path.join(process.cwd(), './src/template/main-app'),
11
+ path.join(process.cwd(), 'dist/template/main-app')
12
+ );