@tuya-sat/micro-dev-loader 0.0.1 → 1.0.0-rc.1

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.
package/dist/index.js CHANGED
@@ -21,14 +21,14 @@ function _interopRequireDefault(obj) {
21
21
  }
22
22
  var addjsLoader = function addjsLoader(sourceCode) {
23
23
  var ref = (0, _loaderUtils).getOptions(this), _authedCode = ref.authedCode, authedCode = _authedCode === void 0 ? [] : _authedCode, microFramework = ref.microFramework;
24
- var privileges = (0, _parseManifest).default().privileges;
24
+ var manifest = (0, _parseManifest).default();
25
25
  var codeMaker = new _transform.default({
26
26
  sourceCode: sourceCode,
27
27
  microFramework: microFramework
28
28
  });
29
29
  codeMaker.changeAst({
30
- privileges: privileges,
31
- authedCode: authedCode
30
+ authedCode: authedCode,
31
+ manifest: manifest
32
32
  });
33
33
  return codeMaker.gtAst() + _manifestDom.default;
34
34
  };
@@ -9,9 +9,8 @@ var _ejs = _interopRequireDefault(require("ejs"));
9
9
  var _cheerio = _interopRequireDefault(require("cheerio"));
10
10
  var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
11
11
  var _parseManifest = _interopRequireDefault(require("../../utils/parseManifest"));
12
- function _arrayWithHoles(arr) {
13
- if (Array.isArray(arr)) return arr;
14
- }
12
+ var _getLang = require("../../utils/getLang");
13
+ var _getFakeMenu = require("../../utils/getFakeMenu");
15
14
  function _classCallCheck(instance, Constructor) {
16
15
  if (!(instance instanceof Constructor)) {
17
16
  throw new TypeError("Cannot call a class as a function");
@@ -31,70 +30,12 @@ function _createClass(Constructor, protoProps, staticProps) {
31
30
  if (staticProps) _defineProperties(Constructor, staticProps);
32
31
  return Constructor;
33
32
  }
34
- function _defineProperty(obj, key, value) {
35
- if (key in obj) {
36
- Object.defineProperty(obj, key, {
37
- value: value,
38
- enumerable: true,
39
- configurable: true,
40
- writable: true
41
- });
42
- } else {
43
- obj[key] = value;
44
- }
45
- return obj;
46
- }
47
33
  function _interopRequireDefault(obj) {
48
34
  return obj && obj.__esModule ? obj : {
49
35
  default: obj
50
36
  };
51
37
  }
52
- function _iterableToArrayLimit(arr, i) {
53
- var _arr = [];
54
- var _n = true;
55
- var _d = false;
56
- var _e = undefined;
57
- try {
58
- for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){
59
- _arr.push(_s.value);
60
- if (i && _arr.length === i) break;
61
- }
62
- } catch (err) {
63
- _d = true;
64
- _e = err;
65
- } finally{
66
- try {
67
- if (!_n && _i["return"] != null) _i["return"]();
68
- } finally{
69
- if (_d) throw _e;
70
- }
71
- }
72
- return _arr;
73
- }
74
- function _nonIterableRest() {
75
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
76
- }
77
- function _objectSpread(target) {
78
- for(var i = 1; i < arguments.length; i++){
79
- var source = arguments[i] != null ? arguments[i] : {
80
- };
81
- var ownKeys = Object.keys(source);
82
- if (typeof Object.getOwnPropertySymbols === "function") {
83
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
84
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
85
- }));
86
- }
87
- ownKeys.forEach(function(key) {
88
- _defineProperty(target, key, source[key]);
89
- });
90
- }
91
- return target;
92
- }
93
- function _slicedToArray(arr, i) {
94
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
95
- }
96
38
  var manifest = (0, _parseManifest).default();
97
- var lang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/zh-CN.json"));
98
39
  var layoutMockTpl = _fsExtra.default.readFileSync(_path.default.resolve(__dirname, "./layout-static/index.html"), {
99
40
  encoding: "utf-8"
100
41
  });
@@ -110,21 +51,11 @@ var LayoutMockPlugin = /*#__PURE__*/ function() {
110
51
  compiler.hooks.compilation.tap("MyPlugin", function(compilation) {
111
52
  _htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync("LayoutMockPlugin", function(data, cb) {
112
53
  var $ = _cheerio.default.load(data.html);
113
- var name1 = manifest.name, defaultMenuIcon = manifest.defaultMenuIcon, entries = manifest.entries;
54
+ var name = manifest.name, defaultMenuIcon = manifest.defaultMenuIcon;
114
55
  data.html = _ejs.default.render(layoutMockTpl, {
115
- appName: function() {
116
- var ref = _slicedToArray(name1.split("."), 2), _ = ref[0], key = ref[1];
117
- return lang[key] || name1;
118
- }(),
56
+ appName: (0, _getLang).nameProcesser2(name)[0],
119
57
  appIcon: defaultMenuIcon.url,
120
- menus: entries.map(function(item) {
121
- var name = item.name;
122
- var ref = _slicedToArray(name.split("."), 2), _ = ref[0], key = ref[1];
123
- return _objectSpread({
124
- }, item, {
125
- langName: lang[key] || name
126
- });
127
- }),
58
+ menu: (0, _getFakeMenu).getFakeMenu(manifest),
128
59
  appHtml: [
129
60
  $("head").html(),
130
61
  $("body").html()
@@ -0,0 +1,231 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" style="margin: 0; padding: 0">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5
+ <meta charset="utf-8" />
6
+ <link rel="icon" href="favicon.ico" />
7
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
8
+ <meta name="theme-color" content="#000000" />
9
+ <meta name="description" content="Tuya General Management Portal" />
10
+ <title><%= appName %></title>
11
+ <style>
12
+ .c-debugger-container {
13
+ width: 100vw;
14
+ height: 100vh;
15
+ display: flex;
16
+ flex-direction: column;
17
+ }
18
+ .c-debugger-header {
19
+ flex: 0 0 auto;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: space-between;
23
+ height: 55px;
24
+ padding: 0 16px;
25
+ border-bottom: 1px solid #eee;
26
+ color: rgba(0, 0, 0, 0.85);
27
+ }
28
+ .c-debugger-logo {
29
+ position: relative;
30
+ overflow: hidden;
31
+ display: flex;
32
+ align-items: center;
33
+ }
34
+ .c-debugger-title {
35
+ color: #000;
36
+ font-size: 14px;
37
+ font-weight: 700;
38
+ height: 32px;
39
+ line-height: 32px;
40
+ margin: 0 0 0 12px;
41
+ }
42
+ .c-debugger-main {
43
+ display: flex;
44
+ flex: 1 1 auto;
45
+ }
46
+ .c-debugger-side {
47
+ flex: 0 0 auto;
48
+ width: 208px;
49
+ height: 100%;
50
+ border-right: 1px solid #f0f2f5;
51
+ }
52
+ .c-debugger-content {
53
+ flex: 1 1 auto;
54
+ height: 100%;
55
+ background-color: #f0f2f5;
56
+ }
57
+ #root {
58
+ width: 100%;
59
+ height: 100%;
60
+ }
61
+ .c-debugger-lang-trigger {
62
+ position: relative;
63
+ display: flex;
64
+ align-items: center;
65
+ white-space: nowrap;
66
+ cursor: pointer;
67
+ font-size: 14px;
68
+ font-weight: normal;
69
+ height: 100%;
70
+ }
71
+ .c-debugger-lang-trigger:hover .c-debugger-lang-list {
72
+ display: block;
73
+ line-height: 1.5;
74
+ }
75
+ .c-debugger-lang-trigger .c-debugger-lang-list {
76
+ position: absolute;
77
+ top: 42px;
78
+ right: -5px;
79
+ display: none;
80
+ background: #ffffff;
81
+ border-radius: 2px;
82
+ outline: none;
83
+ box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%),
84
+ 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
85
+ z-index: 100;
86
+ }
87
+ .c-debugger-lang-trigger .c-debugger-lang-list span {
88
+ display: block;
89
+ padding: 5px 12px;
90
+ }
91
+ .c-debugger-lang-trigger .c-debugger-lang-list span:hover {
92
+ background-color: #f5f5f5;
93
+ }
94
+ .c-debugger-menu {
95
+ display: flex;
96
+ justify-content: flex-start;
97
+ align-items: center;
98
+ height: 40px;
99
+ padding: 0 0 0 17px;
100
+ margin: 4px 0 8px;
101
+ cursor: pointer;
102
+ font-size: 14px;
103
+ color: rgba(0, 0, 0, 0.85);
104
+ }
105
+ .c-debugger-menu-name {
106
+ flex: 1 1 auto;
107
+ margin-left: 10px;
108
+ overflow: hidden;
109
+ text-overflow: ellipsis;
110
+ }
111
+ .c-debugger-menu-suffix {
112
+ display: flex;
113
+ align-items: center;
114
+ width: 14px;
115
+ height: 14px;
116
+ margin: 0 10px 0 0;
117
+ }
118
+ .c-debugger-menu:hover {
119
+ color: #1890ff;
120
+ }
121
+ </style>
122
+ </head>
123
+ <body style="margin: 0; padding: 0">
124
+ <div class="c-debugger-container">
125
+ <div class="c-debugger-header">
126
+ <div class="c-debugger-logo">
127
+ <img
128
+ src="https://promotion-static.tuyacn.com/static/242969466160533504.png"
129
+ alt=""
130
+ style="height: 28px"
131
+ />
132
+ <div class="c-debugger-title"><%= appName %></div>
133
+ </div>
134
+ <div class="c-debugger-lang-trigger">
135
+ <span id="c-debugger-lang-name"></span>
136
+ <div class="c-debugger-lang-list">
137
+ <span onclick="changeLng('en-US')">English</span>
138
+ <span onclick="changeLng('zh-CN')">简体中文</span>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ <div class="c-debugger-main">
143
+ <div class="c-debugger-side">
144
+ <% if (!menu.sub_entry_list.length) { %>
145
+ <div class="c-debugger-menu" onclick="toPage('<%= menu.path %>')">
146
+ <svg
147
+ viewBox="0 0 1024 1024"
148
+ version="1.1"
149
+ xmlns="http://www.w3.org/2000/svg"
150
+ p-id="2323"
151
+ width="14"
152
+ height="14"
153
+ >
154
+ <path
155
+ d="M192.037 287.953h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32zM192.028 543.17h638.608c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.028c-17.673 0-32 14.327-32 32s14.327 32 32 32zM832.161 735.802H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32z"
156
+ fill=""
157
+ p-id="2324"
158
+ ></path>
159
+ </svg>
160
+ <div class="c-debugger-menu-name">
161
+ <%= menu.micro_app_name[0] %>
162
+ </div>
163
+ </div>
164
+ <% } else { %>
165
+ <div class="c-debugger-menu">
166
+ <svg
167
+ viewBox="0 0 1024 1024"
168
+ version="1.1"
169
+ xmlns="http://www.w3.org/2000/svg"
170
+ p-id="2323"
171
+ width="14"
172
+ height="14"
173
+ >
174
+ <path
175
+ d="M192.037 287.953h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32zM192.028 543.17h638.608c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.028c-17.673 0-32 14.327-32 32s14.327 32 32 32zM832.161 735.802H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32z"
176
+ fill=""
177
+ p-id="2324"
178
+ ></path>
179
+ </svg>
180
+ <div class="c-debugger-menu-name">
181
+ <%= menu.micro_app_name[0] %>
182
+ </div>
183
+ <div class="c-debugger-menu-suffix">
184
+ <svg
185
+ viewBox="0 0 1024 1024"
186
+ version="1.1"
187
+ xmlns="http://www.w3.org/2000/svg"
188
+ p-id="2307"
189
+ width="12"
190
+ height="12"
191
+ >
192
+ <path
193
+ d="M881.975333 774.688841 512 404.713508 142.024667 774.688841 64.322981 696.987155 512 249.311159 959.677019 696.987155Z"
194
+ p-id="2308"
195
+ ></path>
196
+ </svg>
197
+ </div>
198
+ </div>
199
+ <% menu.sub_entry_list.forEach(function(subMenu){ %>
200
+ <div class="c-debugger-menu" onclick="toPage('<%= subMenu.path %>')">
201
+ <div style="width: 14px; height: 14px"></div>
202
+ <div class="c-debugger-menu-name"><%= subMenu.entry_name[0] %></div>
203
+ </div>
204
+ <% }) %> <% } %>
205
+ </div>
206
+ <div class="c-debugger-content"><%- appHtml %></div>
207
+ </div>
208
+ </div>
209
+ <script>
210
+ (() => {
211
+ const lngMap = {
212
+ "en-US": "English",
213
+ "zh-CN": "简体中文",
214
+ };
215
+ const localLng = localStorage.getItem("i18nextLng");
216
+ const lng = lngMap[localLng] ? localLng : "zh-CN";
217
+ document.querySelector("#c-debugger-lang-name").textContent =
218
+ lngMap[lng];
219
+ })();
220
+
221
+ function toPage(path) {
222
+ window.location.href = new URL(path, window.location.origin);
223
+ }
224
+
225
+ function changeLng(lng, name) {
226
+ localStorage.setItem("i18nextLng", lng);
227
+ location.reload();
228
+ }
229
+ </script>
230
+ </body>
231
+ </html>
package/dist/transform.js CHANGED
@@ -7,6 +7,7 @@ var _core = require("@babel/core");
7
7
  var _template = _interopRequireDefault(require("@babel/template"));
8
8
  var _generator = _interopRequireDefault(require("@babel/generator"));
9
9
  var _pluginSyntaxTypescript = _interopRequireDefault(require("@babel/plugin-syntax-typescript"));
10
+ var _getFakeMenu = require("./utils/getFakeMenu");
10
11
  function _classCallCheck(instance, Constructor) {
11
12
  if (!(instance instanceof Constructor)) {
12
13
  throw new TypeError("Cannot call a class as a function");
@@ -67,19 +68,30 @@ var CodeMaker = /*#__PURE__*/ function() {
67
68
  {
68
69
  key: "changeAst",
69
70
  value: function changeAst(props) {
70
- var temp = this.getTemp(props);
71
+ var manifest = props.manifest, authedCode = props.authedCode;
72
+ var privileges = manifest.privileges;
73
+ var authTemp = this.getAuthTemp({
74
+ authedCode: authedCode,
75
+ privileges: privileges
76
+ });
77
+ var menuTemp = this.getMenuCode(manifest);
71
78
  (0, _core).traverse(this.ast, {
72
79
  ExportNamedDeclaration: function ExportNamedDeclaration(path) {
73
80
  var isTarget = false;
74
81
  try {
75
- isTarget = path.node.declaration.kind === "let" && path.node.declaration.declarations[0].id.name === "hasPermission";
82
+ isTarget = path.node.declaration.kind === "let" && path.node.declaration.declarations[0].id.name === "microProps";
76
83
  } catch (e) {
77
84
  }
78
85
  if (!isTarget) {
79
86
  return;
80
87
  }
81
- var tempNode = _template.default.ast(temp);
82
- path.insertAfter(tempNode);
88
+ [
89
+ authTemp,
90
+ menuTemp,
91
+ "microProps = {}"
92
+ ].forEach(function(temp) {
93
+ path.insertAfter(_template.default.ast(temp));
94
+ });
83
95
  }
84
96
  });
85
97
  }
@@ -104,10 +116,17 @@ var CodeMaker = /*#__PURE__*/ function() {
104
116
  }
105
117
  },
106
118
  {
107
- key: "getTemp",
108
- value: function getTemp(props) {
109
- var privileges = props.privileges, authedCode = props.authedCode;
110
- var temp = "\n {\n window._allCodesStatusMap = new Map()\n window._authedCodeInfoProxy = {}\n hasPermission = (code) => {\n return window._allCodesStatusMap.get(code)\n };\n const changeAuthedMap = (authedCode) => {\n const privileges = ".concat(JSON.stringify(privileges), "\n const allCodesStatus = privileges?.map(\n ({ name, code }) => [\n code,\n authedCode.includes(code),\n ]\n );\n window._allCodesStatusMap = new Map(allCodesStatus)\n }\n \n ").concat(REACT_TYPES.includes(this.microFramework) ? this.reactReRenderTemp() : this.vueReRenderTemp(), "\n const authedCodeInfo = {\n authedCode:").concat(JSON.stringify(authedCode), "\n }\n \n changeAuthedMap(authedCodeInfo.authedCode)\n window._authedCodeInfoProxy = new Proxy(authedCodeInfo,{\n get(target,prop){\n return target[prop]\n },\n set(target,prop,value){\n if(prop === 'authedCode') {\n changeAuthedMap(value)\n reRender()\n }\n target[prop] = value\n return true\n }\n })\n\n }\n ");
119
+ key: "getMenuCode",
120
+ value: function getMenuCode(manifest) {
121
+ var temp = "\n {\n microProps.getOwnMenu = ()=> {\n const localLng = localStorage.getItem(\"i18nextLng\");\n let index = localLng === \"zh-CN\" ? 0 : 1\n const ownMenu = ".concat(JSON.stringify((0, _getFakeMenu).getFakeMenu(manifest)), "\n ownMenu.micro_app_name = ownMenu.micro_app_name[index]\n ownMenu.entry_name = ownMenu.entry_name[index]\n ownMenu.sub_entry_list = ownMenu.sub_entry_list.map(item=>({\n ...item,\n micro_app_name:item.micro_app_name[index],\n entry_name:item.entry_name[index]\n }))\n return ownMenu\n }\n }\n ");
122
+ return temp;
123
+ }
124
+ },
125
+ {
126
+ key: "getAuthTemp",
127
+ value: function getAuthTemp(props) {
128
+ var _privileges = props.privileges, privileges = _privileges === void 0 ? [] : _privileges, _authedCode = props.authedCode, authedCode = _authedCode === void 0 ? [] : _authedCode;
129
+ var temp = "\n {\n window._allCodesStatusMap = new Map()\n window._authedCodeInfoProxy = {}\n microProps.hasPermission = (code) => {\n return window._allCodesStatusMap.get(code)\n };\n const changeAuthedMap = (authedCode) => {\n const privileges = ".concat(JSON.stringify(privileges), "\n const allCodesStatus = privileges?.map(\n ({ name, code }) => [\n code,\n authedCode.includes(code),\n ]\n );\n window._allCodesStatusMap = new Map(allCodesStatus)\n }\n \n ").concat(REACT_TYPES.includes(this.microFramework) ? this.reactReRenderTemp() : this.vueReRenderTemp(), "\n const authedCodeInfo = {\n authedCode:").concat(JSON.stringify(authedCode), "\n }\n \n changeAuthedMap(authedCodeInfo.authedCode)\n window._authedCodeInfoProxy = new Proxy(authedCodeInfo,{\n get(target,prop){\n return target[prop]\n },\n set(target,prop,value){\n target[prop] = value\n if(prop === 'authedCode') {\n changeAuthedMap(value)\n reRender()\n }\n return true\n }\n })\n\n }\n ");
111
130
  return temp;
112
131
  }
113
132
  }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.getFakeMenu = getFakeMenu;
6
+ var _getLang = require("./getLang");
7
+ function _defineProperty(obj, key, value) {
8
+ if (key in obj) {
9
+ Object.defineProperty(obj, key, {
10
+ value: value,
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ } else {
16
+ obj[key] = value;
17
+ }
18
+ return obj;
19
+ }
20
+ function _objectSpread(target) {
21
+ for(var i = 1; i < arguments.length; i++){
22
+ var source = arguments[i] != null ? arguments[i] : {
23
+ };
24
+ var ownKeys = Object.keys(source);
25
+ if (typeof Object.getOwnPropertySymbols === "function") {
26
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
27
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
28
+ }));
29
+ }
30
+ ownKeys.forEach(function(key) {
31
+ _defineProperty(target, key, source[key]);
32
+ });
33
+ }
34
+ return target;
35
+ }
36
+ function getFakeMenu(manifest) {
37
+ var appName = manifest.name, entries = manifest.entries;
38
+ var appNameLang = (0, _getLang).nameProcesser2(appName);
39
+ var fakeMenuDefault = {
40
+ micro_app_name: appNameLang,
41
+ sub_entry_list: []
42
+ };
43
+ var fakeMenu = null;
44
+ switch(entries.length){
45
+ case 0:
46
+ fakeMenu = _objectSpread({
47
+ entry_name: appNameLang,
48
+ path: ""
49
+ }, fakeMenuDefault);
50
+ break;
51
+ case 1:
52
+ var ref = entries[0], name1 = ref.name, path1 = ref.path;
53
+ fakeMenu = _objectSpread({
54
+ entry_name: (0, _getLang).nameProcesser2(name1),
55
+ path: path1
56
+ }, fakeMenuDefault);
57
+ break;
58
+ default:
59
+ fakeMenu = _objectSpread({
60
+ entry_name: appNameLang,
61
+ path: ""
62
+ }, fakeMenuDefault, {
63
+ sub_entry_list: entries.map(function(param) {
64
+ var name = param.name, path = param.path;
65
+ return _objectSpread({
66
+ entry_name: (0, _getLang).nameProcesser2(name),
67
+ path: path
68
+ }, fakeMenuDefault);
69
+ })
70
+ });
71
+ break;
72
+ }
73
+ return fakeMenu;
74
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.nameProcesser2 = void 0;
6
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
7
+ var _path = _interopRequireDefault(require("path"));
8
+ function _arrayLikeToArray(arr, len) {
9
+ if (len == null || len > arr.length) len = arr.length;
10
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
11
+ return arr2;
12
+ }
13
+ function _arrayWithHoles(arr) {
14
+ if (Array.isArray(arr)) return arr;
15
+ }
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function _iterableToArrayLimit(arr, i) {
22
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
23
+ if (_i == null) return;
24
+ var _arr = [];
25
+ var _n = true;
26
+ var _d = false;
27
+ var _s, _e;
28
+ try {
29
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
30
+ _arr.push(_s.value);
31
+ if (i && _arr.length === i) break;
32
+ }
33
+ } catch (err) {
34
+ _d = true;
35
+ _e = err;
36
+ } finally{
37
+ try {
38
+ if (!_n && _i["return"] != null) _i["return"]();
39
+ } finally{
40
+ if (_d) throw _e;
41
+ }
42
+ }
43
+ return _arr;
44
+ }
45
+ function _nonIterableRest() {
46
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
+ }
48
+ function _slicedToArray(arr, i) {
49
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
50
+ }
51
+ function _unsupportedIterableToArray(o, minLen) {
52
+ if (!o) return;
53
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor) n = o.constructor.name;
56
+ if (n === "Map" || n === "Set") return Array.from(n);
57
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
58
+ }
59
+ var zhLang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/zh-CN.json"));
60
+ var enLang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/en.json"));
61
+ var nameProcesser2 = function(name) {
62
+ var ref = _slicedToArray(name.split("."), 2), _ = ref[0], key = ref[1];
63
+ return [
64
+ zhLang[key] || name,
65
+ enLang[key] || name
66
+ ];
67
+ };
68
+ exports.nameProcesser2 = nameProcesser2;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-loader",
3
- "version": "0.0.1",
3
+ "version": "1.0.0-rc.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "dev": "swc src -D -w -d dist",
8
- "build": "swc src -d dist",
8
+ "build": "rm -rf dist/ && swc src -D -d dist",
9
9
  "prepublish": "yarn build",
10
10
  "test": "jest --verbose ./__tests__"
11
11
  },
@@ -35,5 +35,6 @@
35
35
  "saas",
36
36
  "cloud",
37
37
  "tuya"
38
- ]
38
+ ],
39
+ "stableVersion": "0.0.4"
39
40
  }