mbler 0.1.1 → 0.1.3-alpha-r2
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/LICENSE +21 -0
- package/README.md +37 -0
- package/bin/mbler.js +12 -12
- package/bin/minify.js +58 -44
- package/lib/build/build-g-config.json +11 -11
- package/lib/build/index.js +1 -1
- package/lib/data/includes.json +12 -12
- package/lib/data/version.json +88 -88
- package/lib/lang/en.js +1 -1
- package/lib/lang/index.js +1 -1
- package/lib/lang/zh.js +1 -1
- package/lib/mcx/ast/tag.js +1 -1
- package/lib/mcx/compile-mcx/compile.js +1 -1
- package/lib/mcx/compile-mcx/compiler/bundler.js +1 -0
- package/lib/mcx/compile-mcx/compiler/compileData.js +1 -0
- package/lib/mcx/compile-mcx/compiler/compileMain.js +1 -0
- package/lib/mcx/compile-mcx/compiler/index.js +1 -0
- package/lib/mcx/compile-mcx/compiler/utils.js +1 -0
- package/lib/mcx/compile-mcx/types.js +1 -1
- package/lib/modules/create-game/mbler.config.json +13 -13
- package/lib/modules/gameLib/mbler.config.json +15 -15
- package/lib/modules/gutils/mbler.config.json +11 -11
- package/lib/modules/innerDef.json +4 -4
- package/lib/runTemp/config.json +3 -3
- package/lib/start/create.js +1 -1
- package/lib/start/index.js +1 -1
- package/lib/start/rechce.js +1 -1
- package/package.json +49 -1
- package/test/2x sword/behavior/scripts/index.js +24 -24
- package/test/2x sword/mbler.config.json +11 -11
- package/test/2x sword/package.json +13 -13
- package/test/README.md +7 -7
- package/test/des/index.js +19 -19
- package/test/des/mbler.config.json +4 -4
- package/test/des/package.json +6 -6
- package/test/initializer/index.js +5 -5
- package/test/initializer/mbler.config.json +4 -4
- package/test/initializer/package.json +6 -6
- package/test/mbler-int/behavior/res/items/mang_one_int.json +21 -21
- package/test/mbler-int/behavior/scripts/index.js +7 -7
- package/test/mbler-int/behavior/scripts/lib/event/index.js +19 -19
- package/test/mbler-int/behavior/scripts/lib/ui/Lore.js +18 -18
- package/test/mbler-int/behavior/scripts/lib/ui/baseUi.js +6 -6
- package/test/mbler-int/behavior/scripts/lib/ui/index.js +206 -206
- package/test/mbler-int/behavior/scripts/lib/utils/index.js +51 -51
- package/test/mbler-int/mbler.config.json +18 -18
- package/test/mbler-int/package.json +12 -12
- package/test/script-mbler/behavior/scripts/index.js +5 -5
- package/test/script-mbler/behavior/scripts/index.ts +5 -5
- package/test/script-mbler/mbler.config.json +14 -14
- package/test/script-mbler/package.json +15 -15
- package/lib/mcx/compile-mcx/_compile.js +0 -602
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 RuanhoR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# McBeBuilder - MBLER
|
|
2
|
+
### 提示
|
|
3
|
+
最近一次提交, 我们办了一件大事...
|
|
4
|
+
- 把 mcx 这个模块移到新仓库,用npm引用
|
|
5
|
+
- 你会看到大量代码被删除,并不是放弃开发,而是迁移
|
|
6
|
+
- 新仓库 https://github.com/RuanhoR/mcx-core
|
|
7
|
+
### 介绍
|
|
8
|
+
一个针对Minecraft JavaScript API 的nodejs包,让你的附加包版本管理更简单
|
|
9
|
+
### 安装
|
|
10
|
+
确保你已经安装以下工具:
|
|
11
|
+
- Node.js 与 npm
|
|
12
|
+
- Git
|
|
13
|
+
推荐使用 GitHub 仓库:
|
|
14
|
+
从 [这里](https://github.com/RuanhoR/mbler/releases) 选择版本下载,到达这个目录(使用命令行cd),运行`npm link`
|
|
15
|
+
也可使用 Gitee 的克隆链接或github镜像站,可能速度更快
|
|
16
|
+
本项目目前迁移`typescript`,你也可以直接运行`tsc`进行构建
|
|
17
|
+
- npm `npm install -g mbler`
|
|
18
|
+
安装成功后,你可以直接使用:
|
|
19
|
+
```bash
|
|
20
|
+
# 获取版本
|
|
21
|
+
mbler -v
|
|
22
|
+
```
|
|
23
|
+
初始化目录配置文件
|
|
24
|
+
```bash
|
|
25
|
+
mbler -c <项目路径>
|
|
26
|
+
mbler init
|
|
27
|
+
```
|
|
28
|
+
** 详细请看 : [文档](https://mbler-docs.ruanhor.dpdns.org/) **
|
|
29
|
+
|
|
30
|
+
### 发布平台
|
|
31
|
+
[github](https://github.com/RuanhoR/mbler)
|
|
32
|
+
[gitee](https://gitee.com/n304sc-haoran/mbler)
|
|
33
|
+
|
|
34
|
+
## 文档
|
|
35
|
+
[中文](https://zh.mbler-docs.ruanhor.dpdns.org/)
|
|
36
|
+
[英文](https://mbler-docs.ruanhor.dpdns.org/)
|
|
37
|
+
|
package/bin/mbler.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @description MCBE附加包开发工具
|
|
6
|
-
* @author github-Ruanhor
|
|
7
|
-
*/
|
|
8
|
-
const main = require('./../lib/start');
|
|
9
|
-
try {
|
|
10
|
-
new main(require('path').dirname(__dirname))
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.log("[runtime error]: " + error.stack);
|
|
13
|
-
process.exit(1)
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @description MCBE附加包开发工具
|
|
6
|
+
* @author github-Ruanhor
|
|
7
|
+
*/
|
|
8
|
+
const main = require('./../lib/start');
|
|
9
|
+
try {
|
|
10
|
+
new main(require('path').dirname(__dirname))
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.log("[runtime error]: " + error.stack);
|
|
13
|
+
process.exit(1)
|
|
14
14
|
}
|
package/bin/minify.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
const { execSync } = require(
|
|
2
|
-
const fs = require(
|
|
3
|
-
const path = require(
|
|
4
|
-
const { minify } = require(
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { minify } = require("terser");
|
|
5
5
|
|
|
6
6
|
// 清理 dist 目录
|
|
7
7
|
fs.rmSync(path.join(__dirname, "../dist"), {
|
|
8
8
|
recursive: true,
|
|
9
|
-
force: true
|
|
9
|
+
force: true,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
// 编译 TypeScript
|
|
13
13
|
try {
|
|
14
|
-
execSync(
|
|
15
|
-
stdio:
|
|
14
|
+
execSync("tsc", {
|
|
15
|
+
stdio: "inherit",
|
|
16
16
|
});
|
|
17
|
-
console.log(
|
|
17
|
+
console.log("TypeScript 编译完成!");
|
|
18
18
|
} catch (error) {
|
|
19
|
-
console.error(
|
|
19
|
+
console.error("TypeScript 编译失败:", error.message);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const distDir = path.resolve(__dirname,
|
|
23
|
-
console.log(
|
|
22
|
+
const distDir = path.resolve(__dirname, "./../dist");
|
|
23
|
+
console.log(distDir);
|
|
24
24
|
|
|
25
25
|
if (!fs.existsSync(distDir)) {
|
|
26
|
-
console.error(
|
|
26
|
+
console.error("dist 目录不存在:", distDir);
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -33,13 +33,13 @@ const jsonFiles = [];
|
|
|
33
33
|
// 扫描编译后的 JS 文件
|
|
34
34
|
function scanDistDirectory(directory) {
|
|
35
35
|
const files = fs.readdirSync(directory);
|
|
36
|
-
files.forEach(file => {
|
|
36
|
+
files.forEach((file) => {
|
|
37
37
|
const fullPath = path.join(directory, file);
|
|
38
38
|
const stat = fs.statSync(fullPath);
|
|
39
39
|
|
|
40
40
|
if (stat.isDirectory()) {
|
|
41
41
|
scanDistDirectory(fullPath); // 递归扫描子目录
|
|
42
|
-
} else if (file.endsWith(
|
|
42
|
+
} else if (file.endsWith(".js") && !file.endsWith(".min.js")) {
|
|
43
43
|
jsFiles.push(fullPath);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
@@ -48,7 +48,7 @@ function scanDistDirectory(directory) {
|
|
|
48
48
|
// 扫描源码中的 JSON 文件
|
|
49
49
|
function scanSrcJsonDirectory(directory) {
|
|
50
50
|
const files = fs.readdirSync(directory);
|
|
51
|
-
files.forEach(file => {
|
|
51
|
+
files.forEach((file) => {
|
|
52
52
|
const fullPath = path.join(directory, file);
|
|
53
53
|
const stat = fs.statSync(fullPath);
|
|
54
54
|
|
|
@@ -56,11 +56,14 @@ function scanSrcJsonDirectory(directory) {
|
|
|
56
56
|
scanSrcJsonDirectory(fullPath); // 递归扫描子目录
|
|
57
57
|
} else if (file.endsWith(".json")) {
|
|
58
58
|
// 计算对应的 dist 路径
|
|
59
|
-
const relativePath = path.relative(
|
|
59
|
+
const relativePath = path.relative(
|
|
60
|
+
path.join(__dirname, "../src"),
|
|
61
|
+
fullPath,
|
|
62
|
+
);
|
|
60
63
|
const distPath = path.join(distDir, "lib", relativePath);
|
|
61
64
|
jsonFiles.push({
|
|
62
65
|
srcPath: fullPath,
|
|
63
|
-
distPath: distPath
|
|
66
|
+
distPath: distPath,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
});
|
|
@@ -70,12 +73,12 @@ scanDistDirectory(distDir);
|
|
|
70
73
|
scanSrcJsonDirectory(path.join(__dirname, "../src"));
|
|
71
74
|
|
|
72
75
|
if (jsFiles.length === 0) {
|
|
73
|
-
console.log(
|
|
76
|
+
console.log("没有找到需要压缩的文件");
|
|
74
77
|
process.exit(0);
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
console.log(`${jsFiles.length} 个文件需要处理`);
|
|
78
|
-
|
|
81
|
+
processFiles()
|
|
79
82
|
async function processFiles() {
|
|
80
83
|
let successCount = 0;
|
|
81
84
|
let failCount = 0;
|
|
@@ -84,9 +87,13 @@ async function processFiles() {
|
|
|
84
87
|
for (const jsonFile of jsonFiles) {
|
|
85
88
|
try {
|
|
86
89
|
console.log(`复制 JSON: ${jsonFile.srcPath} -> ${jsonFile.distPath}`);
|
|
87
|
-
|
|
88
|
-
try{
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
// 确保目标目录存在
|
|
93
|
+
await fs.promises.mkdir(path.dirname(jsonFile.distPath), {
|
|
94
|
+
recursive: true,
|
|
95
|
+
});
|
|
96
|
+
} catch {}
|
|
90
97
|
await fs.promises.copyFile(jsonFile.srcPath, jsonFile.distPath);
|
|
91
98
|
successCount++;
|
|
92
99
|
} catch (error) {
|
|
@@ -99,24 +106,24 @@ try{ // 确保目标目录存在
|
|
|
99
106
|
for (const filePath of jsFiles) {
|
|
100
107
|
try {
|
|
101
108
|
// 处理 JS 文件压缩
|
|
102
|
-
const originalCode = fs.readFileSync(filePath,
|
|
109
|
+
const originalCode = fs.readFileSync(filePath, "utf8");
|
|
103
110
|
const result = await minify(originalCode, {
|
|
104
111
|
compress: {
|
|
105
112
|
drop_console: false,
|
|
106
113
|
dead_code: true,
|
|
107
|
-
drop_debugger: true
|
|
114
|
+
drop_debugger: true,
|
|
108
115
|
},
|
|
109
116
|
mangle: true,
|
|
110
117
|
format: {
|
|
111
|
-
comments: false
|
|
112
|
-
}
|
|
118
|
+
comments: false,
|
|
119
|
+
},
|
|
113
120
|
});
|
|
114
121
|
|
|
115
122
|
if (result.error) {
|
|
116
123
|
throw new Error(result.error);
|
|
117
124
|
}
|
|
118
125
|
|
|
119
|
-
fs.writeFileSync(filePath, result.code,
|
|
126
|
+
fs.writeFileSync(filePath, result.code, "utf8");
|
|
120
127
|
successCount++;
|
|
121
128
|
} catch (error) {
|
|
122
129
|
console.error(`处理失败 ${filePath}:`, error.message);
|
|
@@ -127,29 +134,36 @@ try{ // 确保目标目录存在
|
|
|
127
134
|
console.log(`\n处理完成: 成功 ${successCount} 个, 失败 ${failCount} 个`);
|
|
128
135
|
// 复制其他必要文件
|
|
129
136
|
await Promise.all([
|
|
130
|
-
async function(){
|
|
131
|
-
const fileC = JSON.parse(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
(async function () {
|
|
138
|
+
const fileC = JSON.parse(
|
|
139
|
+
await fs.promises.readFile(
|
|
140
|
+
path.join(__dirname, "../package.json"),
|
|
141
|
+
"utf-8",
|
|
142
|
+
),
|
|
143
|
+
);
|
|
144
|
+
delete fileC.devDependencies;
|
|
145
|
+
await fs.promises.writeFile(
|
|
146
|
+
path.join(distDir, "package.json"),
|
|
147
|
+
JSON.stringify(fileC),
|
|
148
|
+
);
|
|
149
|
+
})(),
|
|
135
150
|
fs.promises.cp(
|
|
136
151
|
path.join(__dirname, "../bin"),
|
|
137
152
|
path.join(__dirname, "../dist/bin"),
|
|
138
|
-
{ recursive: true, force: true }
|
|
153
|
+
{ recursive: true, force: true },
|
|
139
154
|
),
|
|
140
155
|
fs.promises.cp(
|
|
141
156
|
path.join(__dirname, "../test"),
|
|
142
157
|
path.join(__dirname, "../dist/test"),
|
|
143
|
-
{ recursive: true, force: true }
|
|
144
|
-
)
|
|
158
|
+
{ recursive: true, force: true },
|
|
159
|
+
),
|
|
160
|
+
fs.promises.cp(
|
|
161
|
+
path.join(__dirname, "../README.md"),
|
|
162
|
+
path.join(__dirname, "../dist/README.md"),
|
|
163
|
+
),
|
|
164
|
+
fs.promises.cp(
|
|
165
|
+
path.join(__dirname, "../LICENSE"),
|
|
166
|
+
path.join(__dirname, "../dist/LICENSE"),
|
|
167
|
+
),
|
|
145
168
|
]);
|
|
146
|
-
|
|
147
|
-
if (failCount > 0) {
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
processFiles().catch(err => {
|
|
153
|
-
console.error('处理过程中出现错误:', err);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"resources": {
|
|
3
|
-
"header": "48793164",
|
|
4
|
-
"module": "ab43f7cb"
|
|
5
|
-
},
|
|
6
|
-
"data": {
|
|
7
|
-
"header": "7604691",
|
|
8
|
-
"module": "bcd46f7a"
|
|
9
|
-
},
|
|
10
|
-
"ScriptId": "4654236ace4",
|
|
11
|
-
"PackageFile": "mbler.config.json"
|
|
1
|
+
{
|
|
2
|
+
"resources": {
|
|
3
|
+
"header": "48793164",
|
|
4
|
+
"module": "ab43f7cb"
|
|
5
|
+
},
|
|
6
|
+
"data": {
|
|
7
|
+
"header": "7604691",
|
|
8
|
+
"module": "bcd46f7a"
|
|
9
|
+
},
|
|
10
|
+
"ScriptId": "4654236ace4",
|
|
11
|
+
"PackageFile": "mbler.config.json"
|
|
12
12
|
}
|
package/lib/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,s){void 0===s&&(s=i);var a=Object.getOwnPropertyDescriptor(t,i);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,s,a)}:function(e,t,i,s){void 0===s&&(s=i),e[s]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var s=e(t),a=0;a<s.length;a++)"default"!==s[a]&&__createBinding(i,t,s[a]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const fs=__importStar(require("fs/promises")),path=__importStar(require("path")),ts=__importStar(require("typescript")),index_js_1=__importDefault(require("./../lang/index.js")),index_js_2=require("./../uuid/index.js"),index_js_3=__importDefault(require("./../code-processor/index.js")),utils=__importStar(require("./../utils/index.js")),getModule_js_1=__importDefault(require("./getModule.js")),includes_json_1=__importDefault(require("./../data/includes.json")),clean_js_1=__importDefault(require("./../start/clean.js")),index_js_4=__importDefault(require("./../runTemp/index.js")),base_js_1=require("./base.js"),manifest_build_js_1=require("./manifest.build.js"),
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,s){void 0===s&&(s=i);var a=Object.getOwnPropertyDescriptor(t,i);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,s,a)}:function(e,t,i,s){void 0===s&&(s=i),e[s]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var s=e(t),a=0;a<s.length;a++)"default"!==s[a]&&__createBinding(i,t,s[a]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const fs=__importStar(require("fs/promises")),path=__importStar(require("path")),ts=__importStar(require("typescript")),index_js_1=__importDefault(require("./../lang/index.js")),index_js_2=require("./../uuid/index.js"),index_js_3=__importDefault(require("./../code-processor/index.js")),utils=__importStar(require("./../utils/index.js")),getModule_js_1=__importDefault(require("./getModule.js")),includes_json_1=__importDefault(require("./../data/includes.json")),clean_js_1=__importDefault(require("./../start/clean.js")),index_js_4=__importDefault(require("./../runTemp/index.js")),base_js_1=require("./base.js"),manifest_build_js_1=require("./manifest.build.js"),mcx_core_1=__importDefault(require("@mbler/mcx-core")),node_os_1=__importDefault(require("node:os")),utils_1=__importDefault(require("./utils"));class Build extends base_js_1.BaseBuild{baseDir;baseModDir;gamelibModule;constructor(e,t){super(),e||utils.Exit(index_js_1.default.build.config_invalid),this.baseDir=t,this.baseCwd=path.isAbsolute(e)?e:path.join(t,e),this.cwd=path.join(this.baseCwd,"behavior"),this.ResOutDir=null,this.ResCwd=path.join(this.baseCwd,"resources"),this.dependencies={},this.gamelibModule=null,this.baseModDir=path.join(this.baseDir,"lib/modules"),this.#e(["baseModDir","baseDir"]),this.#t(["outdir","dependencies","gamelibModule","cwd","ResCwd","baseModDir","baseCwd"]),this.cacheDir=path.join(this.baseCwd,".cache__mbler__")}#e(e){if(Array.isArray(e))for(let t of e)Object.defineProperty(this,t,{enumerable:!1,writable:!1})}#t(e){if(Array.isArray(e))for(let t of e)Object.defineProperty(this,t,{enumerable:!1})}async#i(){try{await fs.mkdir(this.cacheDir,{recursive:!0})}catch(e){if("EEXIST"!==e.code)throw e}}build(){return this.start().catch(e=>{const t=utils.toString(e);(0,utils_1.default)(index_js_1.default.build.error_message_log+t)})}async start(){const e=Date.now();await this.#i();const{configChanged:t,packageChanged:i}=await this.chackConfigHash(),s=new clean_js_1.default(this.baseCwd,this.baseDir);await s.run(),await utils.waitGC();const a=await this.loadPackageData();this.d_data=a,this.outdir=this.getOutputDir(a.outdir?.behavior,path.join(this.baseCwd,"dist/dep")),this.ResOutDir=this.getOutputDir(a.outdir?.resources,path.join(this.baseCwd,"dist/res"));const r=["name","description","version","mcVersion"];if(!utils.hasKeys(a,r,r.length))throw new Error(`${index_js_1.default.build.package_file} 字段缺失:必需字段 ${JSON.stringify(r)}`);switch(this.gamelibModule=await(0,getModule_js_1.default)(this.baseDir),console.log(index_js_1.default.build.build_info_header),console.table({[index_js_1.default.build.project_path]:this.baseCwd,[index_js_1.default.build.output_dir]:JSON.stringify(a.outdir),[index_js_1.default.build.minify_enabled]:Boolean(a.minify),[index_js_1.default.build.build_time]:Build.times,[index_js_1.default.build.tip_dist]:process.env.MBLER_BUILD_MODULE||"dev"}),await Promise.all([this.writeManifest(a),this.handleScripts(a),this.handleIncludes(),this.processSubpacks(a)]),a.script?.lang||""){case"ts":await this.compileTypeScriptUnified();break;case"mcx":await mcx_core_1.default.load({ProjectDir:path.join(this.cwd,"scripts"),config:{useTS:!0},output:path.join(this.outdir,"scripts"),moduleList:this.Modules,main:path.join(this.cwd,a.script?.main||"index.js"),cacheDir:this.cacheDir,moduleDir:path.join(this.outdir,"scripts/node_modules"),isCache:!0})}await Promise.all([this.processMinification(a),this.processResources()]),await this.processDist(),console.log(`${index_js_1.default.build.build_success} ${(Date.now()-e)/1e3}`)}async writeManifest(e){const t=await this.buildManifest(e);await this.writeFile(path.join(this.outdir,"manifest.json"),t)}async buildManifest(e){const t=new manifest_build_js_1.ManiFest(e,"data").data,i=e.subpack||{};return"object"==typeof e.ResDes&&this.processResourceDependencies(e,t),"object"==typeof e.subpack&&Object.keys(e.subpack).length>0&&(t.subpack=Object.keys(e.subpack).map(e=>({folder_name:e,name:i[e]||"",memory_tier:1}))),t}processResourceDependencies(e,t){const{name:i="unknown",version:s}=e.ResDes||{};s&&utils.isVerison(s)&&t.dependencies.push({name:(0,index_js_2.fromString)(i),version:utils.ToArray(s)})}async handleScripts(e){if(!e.script||"object"!=typeof e.script)return;const t=path.join(this.cwd,"scripts"),i=path.join(this.outdir,"scripts");await utils.FileExsit(t)&&(await utils.copy(t,i),this.dependencies=e.script.dependencies||{},await this.initNpmDes(),Object.keys(this.dependencies).length>0&&(this.Modules=await this.handlerMod(this.dependencies,new Set)))}async processSubpacks(e){if("object"!=typeof e.subpack)return;const t=this.outdir,i=new Build(this.cwd,this.baseDir);for(let[s,a]of Object.entries(e.subpack))try{const e=path.join(this.cwd,"subpacks",s),a=path.join(t,"subpacks",s);if(await fs.mkdir(a,{recursive:!0}),!await utils.FileExsit(e)){(0,utils_1.default)(index_js_1.default.build.subpack_folder_not_found.replace("{id}",s));continue}const r=path.join(e,"scripts"),n=path.join(a,"scripts");await utils.FileExsit(r)&&await utils.copy(r,n),i.cwd=e,i.outdir=a,await i.handleIncludes()}catch(e){(0,utils_1.default)(index_js_1.default.build.error_processing_subpack.replace("{id}",s).replace("{error}",e.stack))}}async compileTypeScriptUnified(){const e=new index_js_4.default(path.join(node_os_1.default.tmpdir(),"mbler"));await e.init();const t=e.dir;try{const e=await this.getAllTsFiles(this.outdir);if(!e||0===e.length)return void(0,utils_1.default)(index_js_1.default.build.ts_no_files);let i={compilerOptions:{target:"esnext",module:"esnext",moduleResolution:"NodeNext",esModuleInterop:!0,verbatimModuleSyntax:!1,allowSyntheticDefaultImports:!0,outDir:t,rootDir:this.outdir,strict:!0,allowJs:!0,sourceMap:!1,incremental:!0,tsBuildInfoFile:path.join(this.cacheDir,"tsbuildinfo")},include:["**/*.ts"]};await utils.FileExsit(path.join(this.baseCwd,"tsconfig.json"))&&(i=JSON.parse(await fs.readFile(path.join(this.baseCwd,"tsconfig.json"),"utf-8")));const s=ts.parseJsonConfigFileContent(i,ts.sys,this.outdir,void 0,"tsconfig.json"),a=ts.createProgram({rootNames:e,options:s.options}),r=a.emit();ts.getPreEmitDiagnostics(a).concat(r.diagnostics).forEach(e=>{const t=ts.flattenDiagnosticMessageText(e.messageText,"\n");if(e.file){const{line:i,character:s}=e.file.getLineAndCharacterOfPosition(e.start);(0,utils_1.default)(index_js_1.default.build.ts_diagnostics.replace("{file}",e.file.fileName).replace("{line}",(i+1).toString()).replace("{character}",(s+1).toString()).replace("{message}",t))}else(0,utils_1.default)(t)}),await this.removeJsFiles(path.join(this.outdir,"scripts")),await this.copyCompiledOnly(t,this.outdir),(0,utils_1.default)(index_js_1.default.build.ts_compilation_error+" 完成")}catch(e){throw(0,utils_1.default)(index_js_1.default.build.ts_compilation_error+e.stack),e}finally{await e.remove()}}async handlerMod(e,t=new Set){const i=this.gamelibModule.getAll(),s=path.join(this.outdir,"scripts/node_modules");let a={};for(const[r,n]of Object.entries(e)){if(!i.includes(r)||t.has(r))continue;const e=await this.gamelibModule.getDir(r,{gitUrl:n,v:this.d_data.mcVersion});if(!e||!await utils.FileExsit(e))continue;const o=await utils.handlerPackage(e,{des:Array.from(t)});o.des&&Object.assign(a,o.des),await utils.copy(e,path.join(s,r)),await utils.waitGC(),t.add(r)}return Object.keys(a).length>0&&await this.handlerMod(a,t),Array.from(t)}handleIncludes(){if(!Array.isArray(includes_json_1.default))return;const e=includes_json_1.default.filter(e=>"string"==typeof e).map(async e=>{const t=path.join(this.cwd,"res",e),i=path.join(this.outdir,e);await utils.FileExsit(t)&&await utils.copy(t,i)});return Promise.all(e)}async processMinification(e){try{if(!Array.isArray(includes_json_1.default))return void(0,utils_1.default)(index_js_1.default.build.includes_not_array);await(0,index_js_3.default)(this.outdir,{modules:this.Modules,sourceDir:path.join(this.outdir,"scripts"),baseDir:this.baseDir,minify:Boolean(e.minify)}),await utils.waitGC()}catch(e){(0,utils_1.default)(index_js_1.default.build.minification_error+e)}}}exports.default=Build;
|
package/lib/data/includes.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
[
|
|
2
|
-
"items",
|
|
3
|
-
"entities",
|
|
4
|
-
"texts",
|
|
5
|
-
"pack_icon.png",
|
|
6
|
-
"recipes",
|
|
7
|
-
"functions",
|
|
8
|
-
"loot_tables",
|
|
9
|
-
"blocks",
|
|
10
|
-
"animation_controllers",
|
|
11
|
-
"spawn_rules",
|
|
12
|
-
"animations"
|
|
1
|
+
[
|
|
2
|
+
"items",
|
|
3
|
+
"entities",
|
|
4
|
+
"texts",
|
|
5
|
+
"pack_icon.png",
|
|
6
|
+
"recipes",
|
|
7
|
+
"functions",
|
|
8
|
+
"loot_tables",
|
|
9
|
+
"blocks",
|
|
10
|
+
"animation_controllers",
|
|
11
|
+
"spawn_rules",
|
|
12
|
+
"animations"
|
|
13
13
|
]
|
package/lib/data/version.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "版本表",
|
|
3
|
-
"version": [
|
|
4
|
-
{
|
|
5
|
-
"range": [
|
|
6
|
-
"1.21.130",
|
|
7
|
-
"1.21.139"
|
|
8
|
-
],
|
|
9
|
-
"format": {
|
|
10
|
-
"server": "2.4.0",
|
|
11
|
-
"server_ui": "2.0.0"
|
|
12
|
-
},
|
|
13
|
-
"beta": {
|
|
14
|
-
"server": "2.5.0-beta",
|
|
15
|
-
"server_ui": "2.1.0-beta"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"range": [
|
|
20
|
-
"1.21.120",
|
|
21
|
-
"1.21.129"
|
|
22
|
-
],
|
|
23
|
-
"format": {
|
|
24
|
-
"server": "2.3.0",
|
|
25
|
-
"server_ui": "2.0.0"
|
|
26
|
-
},
|
|
27
|
-
"beta": {
|
|
28
|
-
"server": "2.4.0-beta",
|
|
29
|
-
"server_ui": "2.1.0-beta"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"range": [
|
|
34
|
-
"1.21.110",
|
|
35
|
-
"1.21.119"
|
|
36
|
-
],
|
|
37
|
-
"format": {
|
|
38
|
-
"server": "2.2.0",
|
|
39
|
-
"server_ui": "2.0.0"
|
|
40
|
-
},
|
|
41
|
-
"beta": {
|
|
42
|
-
"server": "2.3.0-beta",
|
|
43
|
-
"server_ui": "2.1.0-beta"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"range": [
|
|
48
|
-
"1.21.90",
|
|
49
|
-
"1.21.109"
|
|
50
|
-
],
|
|
51
|
-
"format": {
|
|
52
|
-
"server": "2.1.0",
|
|
53
|
-
"server_ui": "2.0.0"
|
|
54
|
-
},
|
|
55
|
-
"beta": {
|
|
56
|
-
"server": "2.2.0-beta",
|
|
57
|
-
"server_ui": "2.1.0-beta"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"range": [
|
|
62
|
-
"1.21.70",
|
|
63
|
-
"1.21.89"
|
|
64
|
-
],
|
|
65
|
-
"format": {
|
|
66
|
-
"server": "1.19.0",
|
|
67
|
-
"server_ui": "1.3.0"
|
|
68
|
-
},
|
|
69
|
-
"beta": {
|
|
70
|
-
"server": "2.0.0-beta",
|
|
71
|
-
"server_ui": "2.0.0-beta"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"range": [
|
|
76
|
-
"1.21.60",
|
|
77
|
-
"1.21.69"
|
|
78
|
-
],
|
|
79
|
-
"format": {
|
|
80
|
-
"server": "1.17.0",
|
|
81
|
-
"server_ui": "1.3.0"
|
|
82
|
-
},
|
|
83
|
-
"beta": {
|
|
84
|
-
"server": "1.18.0-beta",
|
|
85
|
-
"server_ui": "1.4.0-beta"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"description": "版本表",
|
|
3
|
+
"version": [
|
|
4
|
+
{
|
|
5
|
+
"range": [
|
|
6
|
+
"1.21.130",
|
|
7
|
+
"1.21.139"
|
|
8
|
+
],
|
|
9
|
+
"format": {
|
|
10
|
+
"server": "2.4.0",
|
|
11
|
+
"server_ui": "2.0.0"
|
|
12
|
+
},
|
|
13
|
+
"beta": {
|
|
14
|
+
"server": "2.5.0-beta",
|
|
15
|
+
"server_ui": "2.1.0-beta"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"range": [
|
|
20
|
+
"1.21.120",
|
|
21
|
+
"1.21.129"
|
|
22
|
+
],
|
|
23
|
+
"format": {
|
|
24
|
+
"server": "2.3.0",
|
|
25
|
+
"server_ui": "2.0.0"
|
|
26
|
+
},
|
|
27
|
+
"beta": {
|
|
28
|
+
"server": "2.4.0-beta",
|
|
29
|
+
"server_ui": "2.1.0-beta"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"range": [
|
|
34
|
+
"1.21.110",
|
|
35
|
+
"1.21.119"
|
|
36
|
+
],
|
|
37
|
+
"format": {
|
|
38
|
+
"server": "2.2.0",
|
|
39
|
+
"server_ui": "2.0.0"
|
|
40
|
+
},
|
|
41
|
+
"beta": {
|
|
42
|
+
"server": "2.3.0-beta",
|
|
43
|
+
"server_ui": "2.1.0-beta"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"range": [
|
|
48
|
+
"1.21.90",
|
|
49
|
+
"1.21.109"
|
|
50
|
+
],
|
|
51
|
+
"format": {
|
|
52
|
+
"server": "2.1.0",
|
|
53
|
+
"server_ui": "2.0.0"
|
|
54
|
+
},
|
|
55
|
+
"beta": {
|
|
56
|
+
"server": "2.2.0-beta",
|
|
57
|
+
"server_ui": "2.1.0-beta"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"range": [
|
|
62
|
+
"1.21.70",
|
|
63
|
+
"1.21.89"
|
|
64
|
+
],
|
|
65
|
+
"format": {
|
|
66
|
+
"server": "1.19.0",
|
|
67
|
+
"server_ui": "1.3.0"
|
|
68
|
+
},
|
|
69
|
+
"beta": {
|
|
70
|
+
"server": "2.0.0-beta",
|
|
71
|
+
"server_ui": "2.0.0-beta"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"range": [
|
|
76
|
+
"1.21.60",
|
|
77
|
+
"1.21.69"
|
|
78
|
+
],
|
|
79
|
+
"format": {
|
|
80
|
+
"server": "1.17.0",
|
|
81
|
+
"server_ui": "1.3.0"
|
|
82
|
+
},
|
|
83
|
+
"beta": {
|
|
84
|
+
"server": "1.18.0-beta",
|
|
85
|
+
"server_ui": "1.4.0-beta"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
89
|
}
|
package/lib/lang/en.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={help:"MBLER\nMinecraft Bedrock Edition\nAddon Bulider In Nodejs\nnodejs build tools on bedrock version of minecraft\nSolve the problem of checking documents everywhere to configure api version\nUsage: node index.js [command]\n* You can also omit the node prefix after npm link link\nCommands: dev, install, build, init, version, -v,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={help:"MBLER\nMinecraft Bedrock Edition\nAddon Bulider In Nodejs\nnodejs build tools on bedrock version of minecraft\nSolve the problem of checking documents everywhere to configure api version\nUsage: node index.js [command]\n* You can also omit the node prefix after npm link link\nCommands: dev, install, build, init, version, -v, clean, checkout, -c, -i, v, create, recache, lang\nHelp command:\n help\n Show help information\n The second parameter is the name of the command to be queried or empty\n Alias: -h, -help\n git https://github.com/RuanhoR/mbler/",config_invalid:"Non-GameLib projects",err_bulid:"Build error",uncommand:"Invalid command",s0:"Operation successful",noGit:"Git security restrictions detected\nGit is rejecting the operation because the directory might not belong to the current user or be in a system-protected path.\nPlease select a processing method:\n\n1: Only add the current directory to the trusted zone (recommended, safe)\n2: Globally trust all directories (not recommended, but convenient)\n3: Cancel operation",SameDes:"Dependencies with the same name",invalidConfig:"Invalid configuration",inited:"Already initialized",noGitRepo:"The requested git repository was not specified and the installation failed.",invalidDes:"invalid dependency",workPackV:"Current working directory package version:",cleanFinally:"Clean build successful",noCommandTip:"Do you want to express:",init:{name:"Project name:",desc:"Project description:",useMcVersion:"Supported minecraft versions:",useSapi:"Use Script API? (Y/N)",useTs:"Using TypeScript? (Y/N)",InputFormatErr:"It is not the correct version number in x.x.x format, please re-enter it.",main:"Main script path (such as ./index.js):",useUi:"Use UI? (Y/N)",ReInput:"Not meeting specifications. Try again:"},dev:{start:"Start monitoring the build in real time. The following is the first build.",start_d:"Start an incremental build",tip:"Listen for changes:"},installGit:{NoPackage:"This GIT repository does not contain a properly configured mbler",InstallFinally:"Installation completed",HadBeen:"There is already a dependent package with the same package name. Do you want to replace it? Y/N",SetContent:"Modifying index table"},vm:{shouldNotImp:"Importing a module is prohibited because it can be used in unsafe ways",runScriptErr:"Error running script, error stack"},build:{build_info_header:"--- Build information list ---",project_path:"Project path:",output_dir:"Output directory:",minify_enabled:"Enable compression:",build_time:"Build time:",build_success:"Build successfully. Time taken:",build_failed:"Build failed",config_invalid:"Invalid configuration",package_file_missing_fields:'Missing fields: required fields ["name","description","version","mcVersion"]',script_main_entry_missing:"script is enabled, but main entry file is not specified",subpack_folder_not_found:"{id} subpackage folder does not exist, packaging failed",subpack_processing_failed:"Subpackage {id} failed to process: {error}",includes_not_array:"includes.json is not an array, skip resource copying",ts_no_files:"No .ts files found, skipping TypeScript compilation",ts_diagnostics:"{file} ({line},{character}): {message}",ts_compilation_error:"Error compiling TypeScript",no_ts_files_skip:"No .ts files found, skipping TypeScript compilation",copying_subpack_script:"Subpackage script directory copied",copying_subpack_resources:"Copying subpackage other resources",removing_js_files:"Remove the .js files in the script directory",copying_compiled_ts:"Copy the compiled TypeScript file",minification_error:"Code compression failed",temp_mod_init:"Initialize temporary module directory",script_entry_required:"script is enabled but the main entry is not set",invalid_script_entry:"The main entry file is empty or invalid",module_copy_success:"Module copied to output directory",invalid_subpack_type:"subpack is not an object, skip processing",invalid_includes_type:"includes.json is not an array, skip resource copying",handle_includes_info:"Handle includes resource copy",minification_skipped:"includes.json is not an array, skips code compression",remove_js_files_info:"Remove compiled .js files (e.g. from ts)",process_minification:"Start code compression processing",copy_compiled_ts_only:"Copy only compiled ts files",temp_mod_usage:"Using a temporary directory to handle TypeScript compilation",build_failed_catch:"The build process terminated abnormally",error_message_log:"error message:",exit_with_code:"Process exits with code:",class_pri_locked:"Lock key attributes within a class",object_pri_enforced:"Setting object properties is not enumerable",no_resources:"Resource package resource not found, resource compilation skipped",ziped:"The zip compression is complete and you can directly import the game.\nThe mcaddon file is in:",tip_dist:"Packaging mode:"},buildBase:{npm_deps_skipped_no_json:"npm dependency not found, skip installation",build_time:"Build time",cannot_read_project_config:"Unable to read project configuration file",invalid_project_config_format:"The project configuration file format is invalid",starting_npm_install:"Start installing npm dependencies",npm_install_completed:"Dependency installation completed",npm_install_exit_code:"npm install exit code:",npm_install_error:"npmInstall error",calculating_sha1:"Calculate file SHA1 hash value",file_not_exist:"File does not exist",config_hash_stored:"Configuration hash stored",package_hash_stored:"Packet hash stored",config_changed:"Configuration has changed",package_changed:"Package has changed",saving_current_hash:"Save current hash to cache",removing_js_files:"Remove the .js files in the script directory",removing_js_error_ignored:"Remove .js file error, ignored",removing_npm_des:"Remove npm dependency description",module_not_included:"Module not included, skip deletion",recursive_remove_js:"Recursively remove Js files",reading_file_content:"Read file contents"},commands:{list:{0:"dev",1:"install",2:"build",3:"init",4:"version",5:"-v",6:"clean",7:"checkout",8:"-c",9:"-i",10:"v",11:"create",12:"recache",13:"lang"},dev:"mblerdev\nMonitor files and repackage when modified",build:"mbler build\nPackage the project, package the mbler project into a standard mcbe behavior package, see the document for details on the mbler project",init:"mbler init\nInitialization path configuration file, created interactively from the command line, alias: -i",version:"mbler version [null | x.x.x]\nView or set the package version of the current working directory","-c":"$checkout","-i":"$init","-v":"$v",v:"mbler [v/-v]\nCheck the version of the mbler tool itself",checkout:"mbler [checkout/-c] [null | PATH]\nView (when the second parameter is null) or switch the working directory",create:"mbler create [npm package name | git url | path]\nAfter downloading from the specified source (with cache), create the template package in the sandbox vm, similar to npm create",recache:"mbler recache\nreset cache",lang:"mbler lang [lang name]\nSet the language, such as mbler lang zh_CN\nThe current languages are\n 1. zh 中文\n 2. en English",install:"mbler install [modulesName[]]\nWhen installing a module, the modules declared in the configuration will be scanned."}};
|
package/lib/lang/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0})
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const node_fs_1=__importDefault(require("node:fs")),zh_js_1=__importDefault(require("./zh.js")),en_js_1=__importDefault(require("./en.js")),node_path_1=__importDefault(require("node:path")),langs=["zh","en"],configPath=node_path_1.default.join(require("node:os").homedir(),".cache/mbler/.lang.db");class Lang{currenyLang="zh";init(){try{const e=node_fs_1.default.readFileSync(configPath,"utf-8").toString().trim();if("zh"!=e&&"en"!=e)throw new Error("[setup lang]: set lang error");this.currenyLang=e}catch{this.currenyLang="zh"}}set(e){return!!langs.includes(e)&&(node_fs_1.default.existsSync(configPath)||node_fs_1.default.mkdirSync(node_path_1.default.dirname(configPath),{recursive:!0}),node_fs_1.default.writeFileSync(configPath,e),this.currenyLang=e,!0)}async get(){try{return"zh"==this.currenyLang?zh_js_1.default:en_js_1.default}catch{return zh_js_1.default}}}let exp={};async function Export(e){const t=await e.get();Object.setPrototypeOf(exp,{...t,__internal:{class:e,set:t=>{e.set(t),Export(e)}}})}const lang=new Lang;lang.init(),Export(lang),exports.default=exp;
|