@tuya-sat/micro-dev-loader 1.0.1 → 1.0.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.
- package/dist/index.js +8 -8
- package/dist/manifestDom.js +8 -1
- package/dist/plugins/layoutMock/index.js +25 -58
- package/dist/plugins/layoutMock/layout-static/index.html +2 -3
- package/dist/transform.js +128 -109
- package/dist/utils/getFakeMenu.js +9 -11
- package/dist/utils/getLang.js +4 -50
- package/dist/utils/parseManifest.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,16 +19,16 @@ function _interopRequireDefault(obj) {
|
|
|
19
19
|
default: obj
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sourceCode
|
|
27
|
-
microFramework
|
|
22
|
+
const addjsLoader = function(sourceCode) {
|
|
23
|
+
const { authedCode =[] , microFramework } = (0, _loaderUtils).getOptions(this);
|
|
24
|
+
const manifest = (0, _parseManifest).default();
|
|
25
|
+
const codeMaker = new _transform.default({
|
|
26
|
+
sourceCode,
|
|
27
|
+
microFramework
|
|
28
28
|
});
|
|
29
29
|
codeMaker.changeAst({
|
|
30
|
-
authedCode
|
|
31
|
-
manifest
|
|
30
|
+
authedCode,
|
|
31
|
+
manifest
|
|
32
32
|
});
|
|
33
33
|
return codeMaker.gtAst() + _manifestDom.default;
|
|
34
34
|
};
|
package/dist/manifestDom.js
CHANGED
|
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
-
|
|
6
|
+
const manifestDom = `
|
|
7
|
+
(function ExternalRender() {
|
|
8
|
+
const div = document.createElement('div');
|
|
9
|
+
const { insertDom } = require("@tuya-sat/micro-dev-component");
|
|
10
|
+
insertDom(div)
|
|
11
|
+
document.body.appendChild(div);
|
|
12
|
+
})();
|
|
13
|
+
`;
|
|
7
14
|
var _default = manifestDom;
|
|
8
15
|
exports.default = _default;
|
|
@@ -11,71 +11,38 @@ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
|
11
11
|
var _parseManifest = _interopRequireDefault(require("../../utils/parseManifest"));
|
|
12
12
|
var _getLang = require("../../utils/getLang");
|
|
13
13
|
var _getFakeMenu = require("../../utils/getFakeMenu");
|
|
14
|
-
function _classCallCheck(instance, Constructor) {
|
|
15
|
-
if (!(instance instanceof Constructor)) {
|
|
16
|
-
throw new TypeError("Cannot call a class as a function");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function _defineProperties(target, props) {
|
|
20
|
-
for(var i = 0; i < props.length; i++){
|
|
21
|
-
var descriptor = props[i];
|
|
22
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
23
|
-
descriptor.configurable = true;
|
|
24
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
29
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
30
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
31
|
-
return Constructor;
|
|
32
|
-
}
|
|
33
14
|
function _interopRequireDefault(obj) {
|
|
34
15
|
return obj && obj.__esModule ? obj : {
|
|
35
16
|
default: obj
|
|
36
17
|
};
|
|
37
18
|
}
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
const manifest = (0, _parseManifest).default();
|
|
20
|
+
const layoutMockTpl = _fsExtra.default.readFileSync(_path.default.resolve(__dirname, "./layout-static/index.html"), {
|
|
40
21
|
encoding: "utf-8"
|
|
41
22
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
class LayoutMockPlugin {
|
|
24
|
+
static useLayoutStatic(app) {
|
|
25
|
+
app.get("/layout-static/*", function(req, res) {
|
|
26
|
+
res.sendFile(_path.default.join(__dirname, req.path));
|
|
27
|
+
});
|
|
46
28
|
}
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
$("head").html(),
|
|
61
|
-
$("body").html()
|
|
62
|
-
].join("")
|
|
63
|
-
});
|
|
64
|
-
cb(null, data);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
], [
|
|
70
|
-
{
|
|
71
|
-
key: "useLayoutStatic",
|
|
72
|
-
value: function useLayoutStatic(app) {
|
|
73
|
-
app.get("/layout-static/*", function(req, res) {
|
|
74
|
-
res.sendFile(_path.default.join(__dirname, req.path));
|
|
29
|
+
apply(compiler) {
|
|
30
|
+
compiler.hooks.compilation.tap("MyPlugin", (compilation)=>{
|
|
31
|
+
_htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync("LayoutMockPlugin", (data, cb)=>{
|
|
32
|
+
const $ = _cheerio.default.load(data.html);
|
|
33
|
+
const { name , defaultMenuIcon } = manifest;
|
|
34
|
+
data.html = _ejs.default.render(layoutMockTpl, {
|
|
35
|
+
appName: (0, _getLang).nameProcesser2(name)[0],
|
|
36
|
+
appIcon: defaultMenuIcon.url,
|
|
37
|
+
menu: (0, _getFakeMenu).getFakeMenu(manifest),
|
|
38
|
+
appHtml: [
|
|
39
|
+
$("head").html(),
|
|
40
|
+
$("body").html()
|
|
41
|
+
].join("")
|
|
75
42
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
43
|
+
cb(null, data);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
81
48
|
exports.default = LayoutMockPlugin;
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
.c-debugger-content {
|
|
53
53
|
flex: 1 1 auto;
|
|
54
54
|
height: 100%;
|
|
55
|
+
width: 0;
|
|
55
56
|
background-color: #f0f2f5;
|
|
56
57
|
}
|
|
57
58
|
#root {
|
|
@@ -197,9 +198,7 @@ ADI2MI8huMQAAAAASUVORK5CYII="
|
|
|
197
198
|
p-id="2324"
|
|
198
199
|
></path>
|
|
199
200
|
</svg>
|
|
200
|
-
<div class="c-debugger-menu-name">
|
|
201
|
-
<%= menu.entry_name[0] %>
|
|
202
|
-
</div>
|
|
201
|
+
<div class="c-debugger-menu-name"><%= menu.entry_name[0] %></div>
|
|
203
202
|
</div>
|
|
204
203
|
<% } else { %>
|
|
205
204
|
<div class="c-debugger-menu">
|
package/dist/transform.js
CHANGED
|
@@ -8,128 +8,147 @@ 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
10
|
var _getFakeMenu = require("./utils/getFakeMenu");
|
|
11
|
-
function _classCallCheck(instance, Constructor) {
|
|
12
|
-
if (!(instance instanceof Constructor)) {
|
|
13
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _defineProperties(target, props) {
|
|
17
|
-
for(var i = 0; i < props.length; i++){
|
|
18
|
-
var descriptor = props[i];
|
|
19
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
20
|
-
descriptor.configurable = true;
|
|
21
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
22
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
26
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
27
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
28
|
-
return Constructor;
|
|
29
|
-
}
|
|
30
11
|
function _interopRequireDefault(obj) {
|
|
31
12
|
return obj && obj.__esModule ? obj : {
|
|
32
13
|
default: obj
|
|
33
14
|
};
|
|
34
15
|
}
|
|
35
|
-
|
|
16
|
+
const VUE_TYPES = [
|
|
36
17
|
"VUE_TS",
|
|
37
18
|
"VUE_JS"
|
|
38
19
|
];
|
|
39
|
-
|
|
20
|
+
const REACT_TYPES = [
|
|
40
21
|
"REACT_TS",
|
|
41
22
|
"REACT_JS"
|
|
42
23
|
];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
class CodeMaker {
|
|
25
|
+
parse(code) {
|
|
26
|
+
return (0, _core).parse(code, {
|
|
27
|
+
plugins: [
|
|
28
|
+
[
|
|
29
|
+
_pluginSyntaxTypescript.default,
|
|
30
|
+
{
|
|
31
|
+
isTSX: true,
|
|
32
|
+
allExtensions: true
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
]
|
|
36
|
+
});
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
changeAst(props) {
|
|
39
|
+
const { manifest , authedCode } = props;
|
|
40
|
+
const { privileges } = manifest;
|
|
41
|
+
const authTemp = this.getAuthTemp({
|
|
42
|
+
authedCode,
|
|
43
|
+
privileges
|
|
44
|
+
});
|
|
45
|
+
const menuTemp = this.getMenuCode(manifest);
|
|
46
|
+
(0, _core).traverse(this.ast, {
|
|
47
|
+
ExportNamedDeclaration (path) {
|
|
48
|
+
let isTarget = false;
|
|
49
|
+
try {
|
|
50
|
+
isTarget = path.node.declaration.kind === "let" && path.node.declaration.declarations[0].id.name === "microProps";
|
|
51
|
+
} catch (e) {}
|
|
52
|
+
if (!isTarget) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
[
|
|
56
|
+
authTemp,
|
|
57
|
+
menuTemp,
|
|
58
|
+
"microProps = {}"
|
|
59
|
+
].forEach((temp)=>{
|
|
60
|
+
path.insertAfter(_template.default.ast(temp));
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var _privileges = props.privileges, privileges = _privileges === void 0 ? [] : _privileges, _authedCode = props.authedCode, authedCode = _authedCode === void 0 ? [] : _authedCode;
|
|
128
|
-
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 ");
|
|
129
|
-
return temp;
|
|
130
|
-
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
gtAst() {
|
|
66
|
+
const { code } = (0, _generator).default(this.ast);
|
|
67
|
+
return code;
|
|
68
|
+
}
|
|
69
|
+
vueReRenderTemp() {
|
|
70
|
+
return `
|
|
71
|
+
const reRender = () => {
|
|
72
|
+
app.unmount()
|
|
73
|
+
render({})
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
reactReRenderTemp() {
|
|
78
|
+
return `
|
|
79
|
+
const reRender = () => {
|
|
80
|
+
ReactDOM.unmountComponentAtNode(document.querySelector('#root'))
|
|
81
|
+
render({})
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
getMenuCode(manifest) {
|
|
86
|
+
const temp = `
|
|
87
|
+
{
|
|
88
|
+
microProps.getOwnMenu = ()=> {
|
|
89
|
+
const localLng = localStorage.getItem("i18nextLng");
|
|
90
|
+
let index = localLng === "zh-CN" ? 0 : 1
|
|
91
|
+
const ownMenu = ${JSON.stringify((0, _getFakeMenu).getFakeMenu(manifest))}
|
|
92
|
+
ownMenu.micro_app_name = ownMenu.micro_app_name[index]
|
|
93
|
+
ownMenu.entry_name = ownMenu.entry_name[index]
|
|
94
|
+
ownMenu.sub_entry_list = ownMenu.sub_entry_list.map(item=>({
|
|
95
|
+
...item,
|
|
96
|
+
micro_app_name:item.micro_app_name[index],
|
|
97
|
+
entry_name:item.entry_name[index]
|
|
98
|
+
}))
|
|
99
|
+
return ownMenu
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
return temp;
|
|
104
|
+
}
|
|
105
|
+
getAuthTemp(props) {
|
|
106
|
+
const { privileges =[] , authedCode =[] } = props;
|
|
107
|
+
const temp = `
|
|
108
|
+
{
|
|
109
|
+
window._allCodesStatusMap = new Map()
|
|
110
|
+
window._authedCodeInfoProxy = {}
|
|
111
|
+
microProps.hasPermission = (code) => {
|
|
112
|
+
return window._allCodesStatusMap.get(code)
|
|
113
|
+
};
|
|
114
|
+
const changeAuthedMap = (authedCode) => {
|
|
115
|
+
const privileges = ${JSON.stringify(privileges)}
|
|
116
|
+
const allCodesStatus = privileges?.map(
|
|
117
|
+
({ name, code }) => [
|
|
118
|
+
code,
|
|
119
|
+
authedCode.includes(code),
|
|
120
|
+
]
|
|
121
|
+
);
|
|
122
|
+
window._allCodesStatusMap = new Map(allCodesStatus)
|
|
131
123
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
|
|
125
|
+
${REACT_TYPES.includes(this.microFramework) ? this.reactReRenderTemp() : this.vueReRenderTemp()}
|
|
126
|
+
const authedCodeInfo = {
|
|
127
|
+
authedCode:${JSON.stringify(authedCode)}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
changeAuthedMap(authedCodeInfo.authedCode)
|
|
131
|
+
window._authedCodeInfoProxy = new Proxy(authedCodeInfo,{
|
|
132
|
+
get(target,prop){
|
|
133
|
+
return target[prop]
|
|
134
|
+
},
|
|
135
|
+
set(target,prop,value){
|
|
136
|
+
target[prop] = value
|
|
137
|
+
if(prop === 'authedCode') {
|
|
138
|
+
changeAuthedMap(value)
|
|
139
|
+
reRender()
|
|
140
|
+
}
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
return temp;
|
|
148
|
+
}
|
|
149
|
+
constructor({ sourceCode , microFramework }){
|
|
150
|
+
this.ast = this.parse(sourceCode);
|
|
151
|
+
this.microFramework = microFramework;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
135
154
|
exports.default = CodeMaker;
|
|
@@ -33,13 +33,13 @@ function _objectSpread(target) {
|
|
|
33
33
|
return target;
|
|
34
34
|
}
|
|
35
35
|
function getFakeMenu(manifest) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const { name: appName , entries =[] } = manifest;
|
|
37
|
+
const appNameLang = (0, _getLang).nameProcesser2(appName);
|
|
38
|
+
const fakeMenuDefault = {
|
|
39
39
|
micro_app_name: appNameLang,
|
|
40
40
|
sub_entry_list: []
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
let fakeMenu = null;
|
|
43
43
|
switch(entries.length){
|
|
44
44
|
case 0:
|
|
45
45
|
fakeMenu = _objectSpread({
|
|
@@ -48,7 +48,7 @@ function getFakeMenu(manifest) {
|
|
|
48
48
|
}, fakeMenuDefault);
|
|
49
49
|
break;
|
|
50
50
|
case 1:
|
|
51
|
-
|
|
51
|
+
const { name: name1 , path: path1 } = entries[0];
|
|
52
52
|
fakeMenu = _objectSpread({
|
|
53
53
|
entry_name: (0, _getLang).nameProcesser2(name1),
|
|
54
54
|
path: path1
|
|
@@ -59,13 +59,11 @@ function getFakeMenu(manifest) {
|
|
|
59
59
|
entry_name: appNameLang,
|
|
60
60
|
path: ""
|
|
61
61
|
}, fakeMenuDefault, {
|
|
62
|
-
sub_entry_list: entries.map(
|
|
63
|
-
var name = param.name, path = param.path;
|
|
64
|
-
return _objectSpread({
|
|
62
|
+
sub_entry_list: entries.map(({ name , path })=>_objectSpread({
|
|
65
63
|
entry_name: (0, _getLang).nameProcesser2(name),
|
|
66
|
-
path
|
|
67
|
-
}, fakeMenuDefault)
|
|
68
|
-
|
|
64
|
+
path
|
|
65
|
+
}, fakeMenuDefault)
|
|
66
|
+
)
|
|
69
67
|
});
|
|
70
68
|
break;
|
|
71
69
|
}
|
package/dist/utils/getLang.js
CHANGED
|
@@ -5,61 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.nameProcesser2 = void 0;
|
|
6
6
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
7
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
8
|
function _interopRequireDefault(obj) {
|
|
17
9
|
return obj && obj.__esModule ? obj : {
|
|
18
10
|
default: obj
|
|
19
11
|
};
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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];
|
|
13
|
+
const zhLang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/zh-CN.json"));
|
|
14
|
+
const enLang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/en.json"));
|
|
15
|
+
const nameProcesser2 = (name)=>{
|
|
16
|
+
const [_, key] = name.split(".");
|
|
63
17
|
return [
|
|
64
18
|
zhLang[key] || name,
|
|
65
19
|
enLang[key] || name
|
|
@@ -11,8 +11,8 @@ function _interopRequireDefault(obj) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function parseManifest() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const MANIFEST_FILE = "manifest.json";
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const manifest = _fsExtra.default.readJSONSync(_path.default.resolve(cwd, MANIFEST_FILE), "utf-8");
|
|
17
17
|
return manifest;
|
|
18
18
|
}
|