mbler 0.1.1 → 0.1.3-alpha
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 +28 -0
- package/lib/build/base.js +297 -1
- package/lib/build/build-g-config.json +11 -11
- package/lib/build/getModule.js +182 -1
- package/lib/build/index.js +370 -1
- package/lib/build/manifest.build.js +103 -1
- package/lib/build/mcVersion.js +86 -1
- package/lib/build/utils.js +6 -1
- package/lib/code-processor/c-handler-export.js +12 -1
- package/lib/code-processor/index.js +141 -1
- package/lib/code-processor/mtreehandler.js +164 -1
- package/lib/commander/index.js +154 -1
- package/lib/data/includes.json +12 -12
- package/lib/git/clone.js +28 -1
- package/lib/git/index.js +12 -1
- package/lib/git/pull.js +100 -1
- package/lib/lang/__translate.js +93 -1
- package/lib/lang/en.js +128 -1
- package/lib/lang/index.js +78 -1
- package/lib/lang/zh.js +146 -1
- package/lib/loger/colors.js +13 -1
- package/lib/loger/index.js +136 -1
- package/lib/mcx/ast/index.js +11 -1
- package/lib/mcx/ast/prop.js +78 -1
- package/lib/mcx/ast/tag.js +246 -1
- package/lib/mcx/compile-component/lib.js +106 -1
- package/lib/mcx/compile-component/types.js +2 -1
- package/lib/mcx/compile-component/utils.js +26 -1
- package/lib/mcx/compile-mcx/_compile.js +1 -1
- package/lib/mcx/compile-mcx/compile.js +34 -1
- package/lib/mcx/compile-mcx/context.js +19 -1
- package/lib/mcx/compile-mcx/index.js +10 -1
- package/lib/mcx/compile-mcx/mcx/index.js +2 -1
- package/lib/mcx/compile-mcx/mcx/types.js +2 -1
- package/lib/mcx/compile-mcx/template/module.js +42 -1
- package/lib/mcx/compile-mcx/types.js +2 -1
- package/lib/mcx/compile-mcx/utils.node.js +207 -1
- package/lib/mcx/index.js +13 -1
- package/lib/mcx/test/index.js +7 -1
- package/lib/mcx/test.js +21 -1
- package/lib/mcx/types.js +2 -1
- package/lib/mcx/utils.js +86 -1
- package/lib/module-handler/index.js +482 -1
- package/lib/modules/create-game/src/Runner/RunnerManager.js +113 -1
- package/lib/modules/create-game/src/Runner/scriptRunner.js +70 -1
- package/lib/modules/create-game/src/config.js +27 -1
- package/lib/modules/create-game/src/constants.js +19 -1
- package/lib/modules/create-game/src/createGameModule.js +24 -1
- package/lib/modules/create-game/src/gameComponent/common/autoStop.js +38 -1
- package/lib/modules/create-game/src/gameComponent/common/lazyLoader.js +76 -1
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/onTimeEvent.js +36 -1
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/stopWatch.js +90 -1
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/tickEvent.js +29 -1
- package/lib/modules/create-game/src/gameComponent/common/timer/onTimeEvent.js +36 -1
- package/lib/modules/create-game/src/gameComponent/common/timer/tickEvent.js +29 -1
- package/lib/modules/create-game/src/gameComponent/common/timer/timer.js +87 -1
- package/lib/modules/create-game/src/gameComponent/gameComponent.js +53 -1
- package/lib/modules/create-game/src/gameComponent/index.js +31 -1
- package/lib/modules/create-game/src/gameComponent/player/blockInteractionBlocker.js +40 -1
- package/lib/modules/create-game/src/gameComponent/player/entityInteractionBlocker.js +48 -1
- package/lib/modules/create-game/src/gameComponent/player/healthIndicator.js +48 -1
- package/lib/modules/create-game/src/gameComponent/player/regionMonitor.js +22 -1
- package/lib/modules/create-game/src/gameComponent/player/respawn.js +59 -1
- package/lib/modules/create-game/src/gameComponent/player/spawnProtector.js +69 -1
- package/lib/modules/create-game/src/gameComponent/region/regionProtecter.js +53 -1
- package/lib/modules/create-game/src/gameComponent/region/regionTeamChooser.js +71 -1
- package/lib/modules/create-game/src/gameComponent/region/regionTeamCleaner.js +20 -1
- package/lib/modules/create-game/src/gameComponent/view/infoScoreboard.js +77 -1
- package/lib/modules/create-game/src/gameComponent/view/teamScoreboard.js +83 -1
- package/lib/modules/create-game/src/gameContext.js +6 -1
- package/lib/modules/create-game/src/gameEngine.js +139 -1
- package/lib/modules/create-game/src/gameEvent/eventManager.js +108 -1
- package/lib/modules/create-game/src/gameEvent/eventSignal.js +28 -1
- package/lib/modules/create-game/src/gameEvent/events/buttonPush.js +41 -1
- package/lib/modules/create-game/src/gameEvent/events/inSlot.js +77 -1
- package/lib/modules/create-game/src/gameEvent/events/interval.js +51 -1
- package/lib/modules/create-game/src/gameEvent/events/itemUse.js +36 -1
- package/lib/modules/create-game/src/gameEvent/events/onBlock.js +106 -1
- package/lib/modules/create-game/src/gameEvent/events/regionEvents.js +105 -1
- package/lib/modules/create-game/src/gameEvent/events/signClick.js +45 -1
- package/lib/modules/create-game/src/gameEvent/gameEvent.js +54 -1
- package/lib/modules/create-game/src/gameEvent/index.js +20 -1
- package/lib/modules/create-game/src/gameEvent/mapEventSignal.js +101 -1
- package/lib/modules/create-game/src/gameEvent/subscription.js +17 -1
- package/lib/modules/create-game/src/gamePlayer/gamePlayer.js +102 -1
- package/lib/modules/create-game/src/gamePlayer/groupBuilder.js +38 -1
- package/lib/modules/create-game/src/gamePlayer/groupSet.js +96 -1
- package/lib/modules/create-game/src/gamePlayer/index.js +25 -1
- package/lib/modules/create-game/src/gamePlayer/playerGroup.js +145 -1
- package/lib/modules/create-game/src/gamePlayer/playerManager.js +57 -1
- package/lib/modules/create-game/src/gameRegion/gameRegion.js +229 -1
- package/lib/modules/create-game/src/gameRegion/index.js +43 -1
- package/lib/modules/create-game/src/gameRegion/regionHelper.js +79 -1
- package/lib/modules/create-game/src/gameState/common/autoStop.js +39 -1
- package/lib/modules/create-game/src/gameState/gameState.js +169 -1
- package/lib/modules/create-game/src/gameState/index.js +7 -1
- package/lib/modules/create-game/src/gameState/types.js +35 -1
- package/lib/modules/create-game/src/gameStructure/gameStructure.js +36 -1
- package/lib/modules/create-game/src/main.js +86 -1
- package/lib/modules/create-game/src/system/gameCommand.js +107 -1
- package/lib/modules/create-game/src/system/gameManager.js +124 -1
- package/lib/modules/create-game/src/system/globalPlayerManager.js +119 -1
- package/lib/modules/create-game/src/utils/GameError.js +31 -1
- package/lib/modules/create-game/src/utils/algorithm.js +95 -1
- package/lib/modules/create-game/src/utils/chunk.js +63 -1
- package/lib/modules/create-game/src/utils/deferredObject.js +27 -1
- package/lib/modules/create-game/src/utils/duration.js +25 -1
- package/lib/modules/create-game/src/utils/func.js +20 -1
- package/lib/modules/create-game/src/utils/index.js +52 -1
- package/lib/modules/create-game/src/utils/interfaces.js +2 -1
- package/lib/modules/create-game/src/utils/logger.js +47 -1
- package/lib/modules/create-game/src/utils/random.js +76 -1
- package/lib/modules/create-game/src/utils/vanila-data.js +123 -1
- package/lib/modules/create-game/src/utils/vector.js +96 -1
- package/lib/modules/gameLib/src/config.js +134 -1
- package/lib/modules/gameLib/src/data.js +77 -1
- package/lib/modules/gameLib/src/entity.js +256 -1
- package/lib/modules/gameLib/src/event.js +285 -1
- package/lib/modules/gameLib/src/index.js +20 -1
- package/lib/modules/gameLib/src/loger.js +21 -1
- package/lib/modules/gameLib/src/ui.js +209 -1
- package/lib/modules/gameLib/src/utils.js +122 -1
- package/lib/modules/gutils/src/index.js +22 -1
- package/lib/runTemp/File.js +54 -1
- package/lib/runTemp/index.js +137 -1
- package/lib/runTemp/securityFile.js +93 -1
- package/lib/start/addPack.js +3 -1
- package/lib/start/clean.js +84 -1
- package/lib/start/create.js +146 -1
- package/lib/start/dev.js +99 -1
- package/lib/start/getResConfig.js +3 -1
- package/lib/start/incg.js +3 -1
- package/lib/start/index.js +207 -1
- package/lib/start/init.js +125 -1
- package/lib/start/rechce.js +57 -1
- package/lib/start/unaddPack.js +3 -1
- package/lib/start/unincg.js +67 -1
- package/lib/start/version.js +73 -1
- package/lib/utils/index.js +298 -1
- package/lib/uuid/index.js +27 -1
- package/package.json +1 -1
- package/test/script-mbler/behavior/scripts/index.js +0 -5
package/lib/mcx/ast/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tag_js_1 = __importDefault(require("./tag.js"));
|
|
7
|
+
const prop_js_1 = __importDefault(require("./prop.js"));
|
|
8
|
+
exports.default = {
|
|
9
|
+
tag: tag_js_1.default,
|
|
10
|
+
prop: prop_js_1.default
|
|
11
|
+
};
|
package/lib/mcx/ast/prop.js
CHANGED
|
@@ -1 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lexer = void 0;
|
|
4
|
+
exports.default = PropParser;
|
|
5
|
+
const STATUS = [0, 1]; // 0: 搜集 key,1: 搜集 value
|
|
6
|
+
class Lexer {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code) {
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
// 对外暴露的 tokenize 方法(生成器函数)
|
|
12
|
+
*tokenize() {
|
|
13
|
+
let currStatus = STATUS[0]; // 0: key,1: value
|
|
14
|
+
let key = "";
|
|
15
|
+
let value = "";
|
|
16
|
+
let hasEquals = false;
|
|
17
|
+
for (const char of this.code) {
|
|
18
|
+
if (/\s/.test(char)) {
|
|
19
|
+
if (char === '\n') {
|
|
20
|
+
if (currStatus === STATUS[1] && key && value) {
|
|
21
|
+
const propNode = {
|
|
22
|
+
key,
|
|
23
|
+
value: this.HandlerValue(value),
|
|
24
|
+
type: "PropChar"
|
|
25
|
+
};
|
|
26
|
+
yield propNode;
|
|
27
|
+
}
|
|
28
|
+
else if (currStatus === STATUS[0] && key) { }
|
|
29
|
+
key = "";
|
|
30
|
+
value = "";
|
|
31
|
+
hasEquals = false;
|
|
32
|
+
currStatus = STATUS[0];
|
|
33
|
+
}
|
|
34
|
+
continue; // 跳过所有空白字符
|
|
35
|
+
}
|
|
36
|
+
if (char === '=') {
|
|
37
|
+
if (currStatus === STATUS[0]) {
|
|
38
|
+
currStatus = STATUS[1]; // 切换到 value 状态
|
|
39
|
+
hasEquals = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
if (currStatus === STATUS[0]) {
|
|
44
|
+
key += char; // 搜集 key
|
|
45
|
+
}
|
|
46
|
+
else if (currStatus === STATUS[1]) {
|
|
47
|
+
value += char; // 搜集 value
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (key && value) {
|
|
52
|
+
const propNode = {
|
|
53
|
+
key,
|
|
54
|
+
value: this.HandlerValue(value),
|
|
55
|
+
type: "PropChar"
|
|
56
|
+
};
|
|
57
|
+
yield propNode;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
HandlerValue(value) {
|
|
61
|
+
try {
|
|
62
|
+
const num = Number(value);
|
|
63
|
+
if (!Number.isNaN(num))
|
|
64
|
+
return num;
|
|
65
|
+
if (["[", "{"].includes(value.slice(0, 1)) && ["]", "}"].includes(value.slice(-1))) {
|
|
66
|
+
return JSON.parse(value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Lexer = Lexer;
|
|
74
|
+
// 默认导出解析函数
|
|
75
|
+
function PropParser(code) {
|
|
76
|
+
const lexer = new Lexer(code);
|
|
77
|
+
return Array.from(lexer.tokenize());
|
|
78
|
+
}
|
package/lib/mcx/ast/tag.js
CHANGED
|
@@ -1 +1,246 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Lexer {
|
|
4
|
+
text;
|
|
5
|
+
booleanProxyCache;
|
|
6
|
+
constructor(text) {
|
|
7
|
+
this.text = text;
|
|
8
|
+
this.booleanProxyCache = new WeakMap();
|
|
9
|
+
}
|
|
10
|
+
get tokens() {
|
|
11
|
+
return {
|
|
12
|
+
[Symbol.iterator]: () => this.tokenIterator()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 解析标签属性,如:<div id="app" disabled />
|
|
17
|
+
*/
|
|
18
|
+
parseAttributes(tagContent) {
|
|
19
|
+
const attributes = {};
|
|
20
|
+
let currentKey = '';
|
|
21
|
+
let currentValue = '';
|
|
22
|
+
let inKey = true;
|
|
23
|
+
let name = '';
|
|
24
|
+
let inValue = false;
|
|
25
|
+
let quoteChar = null;
|
|
26
|
+
let isTagName = true;
|
|
27
|
+
for (let i = 0; i < tagContent.length; i++) {
|
|
28
|
+
const char = tagContent[i];
|
|
29
|
+
if (isTagName) {
|
|
30
|
+
if (char === ' ' || char === '>') {
|
|
31
|
+
name = currentKey.trim();
|
|
32
|
+
currentKey = '';
|
|
33
|
+
isTagName = false;
|
|
34
|
+
if (char === '>')
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
currentKey += char;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (inValue) {
|
|
43
|
+
if (char === quoteChar &&
|
|
44
|
+
(currentValue.length === 0 || currentValue[currentValue.length - 1] !== '\\')) {
|
|
45
|
+
attributes[currentKey.trim()] = currentValue;
|
|
46
|
+
currentKey = '';
|
|
47
|
+
currentValue = '';
|
|
48
|
+
inKey = true;
|
|
49
|
+
inValue = false;
|
|
50
|
+
quoteChar = null;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
currentValue += char;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (char === '=' && inKey) {
|
|
57
|
+
inKey = false;
|
|
58
|
+
inValue = true;
|
|
59
|
+
const nextIndex = i + 1;
|
|
60
|
+
const nextChar = nextIndex < tagContent.length ? tagContent[nextIndex] : ' ';
|
|
61
|
+
quoteChar = (nextChar === '"' || nextChar === "'") ? nextChar : null;
|
|
62
|
+
}
|
|
63
|
+
else if (char === ' ' && inKey && currentKey) {
|
|
64
|
+
attributes[currentKey.trim()] = 'true';
|
|
65
|
+
currentKey = '';
|
|
66
|
+
}
|
|
67
|
+
else if (inKey) {
|
|
68
|
+
currentKey += char;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (isTagName) {
|
|
72
|
+
name = currentKey.trim();
|
|
73
|
+
}
|
|
74
|
+
else if (currentKey) {
|
|
75
|
+
attributes[currentKey.trim()] = inValue ?
|
|
76
|
+
currentValue.replace(/^["']/, '').replace(/["']$/, '') :
|
|
77
|
+
'true';
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
name,
|
|
81
|
+
arr: attributes,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 拆分输入文本为 Token 流:Tag、TagEnd、Content
|
|
86
|
+
*/
|
|
87
|
+
*tagSplitIterator() {
|
|
88
|
+
let inTag = false;
|
|
89
|
+
let buffer = '';
|
|
90
|
+
let inContent = false;
|
|
91
|
+
let contentBuffer = '';
|
|
92
|
+
for (const char of this.text) {
|
|
93
|
+
if (char === '<') {
|
|
94
|
+
if (contentBuffer) {
|
|
95
|
+
const n = {
|
|
96
|
+
data: contentBuffer,
|
|
97
|
+
type: 'Content'
|
|
98
|
+
};
|
|
99
|
+
yield n;
|
|
100
|
+
contentBuffer = '';
|
|
101
|
+
}
|
|
102
|
+
inTag = true;
|
|
103
|
+
buffer = '<';
|
|
104
|
+
}
|
|
105
|
+
else if (char === '>') {
|
|
106
|
+
if (!inTag) {
|
|
107
|
+
throw new Error("未匹配的 '>'");
|
|
108
|
+
}
|
|
109
|
+
buffer += '>';
|
|
110
|
+
inTag = false;
|
|
111
|
+
const type = buffer.startsWith('</') ? 'TagEnd' : 'Tag';
|
|
112
|
+
const n = {
|
|
113
|
+
data: buffer,
|
|
114
|
+
type
|
|
115
|
+
};
|
|
116
|
+
yield n;
|
|
117
|
+
buffer = '';
|
|
118
|
+
}
|
|
119
|
+
else if (inTag) {
|
|
120
|
+
buffer += char;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
contentBuffer += char;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (contentBuffer) {
|
|
127
|
+
const n = {
|
|
128
|
+
data: contentBuffer,
|
|
129
|
+
type: 'Content'
|
|
130
|
+
};
|
|
131
|
+
yield n;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 生成 Token 迭代器,用于遍历所有结构化 Token
|
|
136
|
+
*/
|
|
137
|
+
*tokenIterator() {
|
|
138
|
+
const tagTokens = Array.from(this.tagSplitIterator());
|
|
139
|
+
let currentTag = null;
|
|
140
|
+
let contentStartIndex = 0;
|
|
141
|
+
for (let i = 0; i < tagTokens.length; i++) {
|
|
142
|
+
const token = tagTokens[i];
|
|
143
|
+
if (!token)
|
|
144
|
+
continue;
|
|
145
|
+
if (token.type === 'Tag') {
|
|
146
|
+
const arr = this.parseAttributes(token.data.slice(1, -1));
|
|
147
|
+
currentTag = {
|
|
148
|
+
start: token,
|
|
149
|
+
name: arr.name,
|
|
150
|
+
arr: arr.arr,
|
|
151
|
+
content: null,
|
|
152
|
+
end: null,
|
|
153
|
+
};
|
|
154
|
+
contentStartIndex = i + 1;
|
|
155
|
+
}
|
|
156
|
+
else if (token.type === 'TagEnd' && currentTag) {
|
|
157
|
+
currentTag.end = token;
|
|
158
|
+
let contentData = '';
|
|
159
|
+
for (let j = contentStartIndex; j < i; j++) {
|
|
160
|
+
const contentToken = tagTokens[j];
|
|
161
|
+
contentData += contentToken.data;
|
|
162
|
+
}
|
|
163
|
+
const n = {
|
|
164
|
+
data: contentData,
|
|
165
|
+
type: 'TagContent',
|
|
166
|
+
};
|
|
167
|
+
currentTag.content = n;
|
|
168
|
+
// 构造最终的 ParsedTagNode
|
|
169
|
+
const tagNode = {
|
|
170
|
+
start: currentTag.start,
|
|
171
|
+
name: currentTag.name,
|
|
172
|
+
arr: currentTag.arr,
|
|
173
|
+
content: currentTag.content,
|
|
174
|
+
end: currentTag.end,
|
|
175
|
+
};
|
|
176
|
+
yield tagNode; // 直接 yield 结构化 AST 节点
|
|
177
|
+
currentTag = null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 创建一个动态布尔属性访问的 Proxy(可选功能)
|
|
183
|
+
*/
|
|
184
|
+
getBooleanCheckProxy() {
|
|
185
|
+
if (!this.booleanProxyCache.has(this)) {
|
|
186
|
+
const charMap = new Map();
|
|
187
|
+
const proxy = new Proxy({}, {
|
|
188
|
+
get(_, prop) {
|
|
189
|
+
if (typeof prop !== 'string')
|
|
190
|
+
return false;
|
|
191
|
+
return charMap.get(prop) || false;
|
|
192
|
+
},
|
|
193
|
+
set(_, prop, value) {
|
|
194
|
+
if (typeof prop !== 'string')
|
|
195
|
+
return false;
|
|
196
|
+
charMap.set(prop, Boolean(value));
|
|
197
|
+
return true;
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
this.booleanProxyCache.set(this, proxy);
|
|
201
|
+
}
|
|
202
|
+
return this.booleanProxyCache.get(this);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class McxAst {
|
|
206
|
+
text;
|
|
207
|
+
constructor(text) {
|
|
208
|
+
this.text = text;
|
|
209
|
+
}
|
|
210
|
+
getAST() {
|
|
211
|
+
const lexer = new Lexer(this.text);
|
|
212
|
+
return Array.from(lexer.tokens);
|
|
213
|
+
}
|
|
214
|
+
get data() {
|
|
215
|
+
return this.getAST();
|
|
216
|
+
}
|
|
217
|
+
parseAST() {
|
|
218
|
+
return this.getAST();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 生成代码字符串
|
|
222
|
+
* @param node 要生成代码的AST节点
|
|
223
|
+
* @returns 生成的代码字符串
|
|
224
|
+
*/
|
|
225
|
+
static generateCode(node) {
|
|
226
|
+
let code = `<${node.name}`;
|
|
227
|
+
// 添加属性
|
|
228
|
+
for (const [key, value] of Object.entries(node.arr)) {
|
|
229
|
+
if (value === 'true') {
|
|
230
|
+
code += ` ${key}`;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
code += ` ${key}=${value}`;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
code += '>';
|
|
237
|
+
// 添加内容
|
|
238
|
+
if (node.content) {
|
|
239
|
+
code += node.content.data;
|
|
240
|
+
}
|
|
241
|
+
// 添加结束标签
|
|
242
|
+
code += `</${node.name}>`;
|
|
243
|
+
return code;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.default = McxAst;
|
|
@@ -1 +1,106 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemComponent = void 0;
|
|
4
|
+
class ItemComponent {
|
|
5
|
+
#opt;
|
|
6
|
+
constructor(opt) {
|
|
7
|
+
this.#opt = opt;
|
|
8
|
+
}
|
|
9
|
+
toJSON() {
|
|
10
|
+
if (!this.#opt)
|
|
11
|
+
throw new Error("[mcx component]: cannot read component");
|
|
12
|
+
const result = {
|
|
13
|
+
format_version: "",
|
|
14
|
+
"minecraft:item": {
|
|
15
|
+
components: {},
|
|
16
|
+
description: {
|
|
17
|
+
identifier: ""
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
if (typeof this.#opt.format == "string" && /\d.\d.\d/.test(this.#opt.format)) {
|
|
22
|
+
result["format_version"] = this.#opt.format;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error("[compile component]: no format");
|
|
26
|
+
}
|
|
27
|
+
if (typeof this.#opt.id == "string" && /[a-zA-Z0-9_]:[a-zA-Z0-9_]/.test(this.#opt.id)) {
|
|
28
|
+
result["minecraft:item"].description.identifier = this.#opt.id;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error("[compile component]:cno id");
|
|
32
|
+
}
|
|
33
|
+
const ApplyComponents = result["minecraft:item"].components;
|
|
34
|
+
if (typeof this.#opt.name == "string") {
|
|
35
|
+
ApplyComponents["minecraft:display_name"] = {
|
|
36
|
+
value: this.#opt.name
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (this.#opt.components) {
|
|
40
|
+
const components = this.#opt.components;
|
|
41
|
+
if (typeof components.damage == "number") {
|
|
42
|
+
ApplyComponents["minecraft:damage"] = {
|
|
43
|
+
value: components.damage
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (typeof components.offHand == "boolean" && components.offHand) {
|
|
47
|
+
ApplyComponents["minecraft:allow_off_hand"] = {
|
|
48
|
+
value: true
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (typeof components.DestroyInCreate == "boolean") {
|
|
52
|
+
ApplyComponents["minecraft:can_destroy_in_creative"] = {
|
|
53
|
+
value: components.DestroyInCreate
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
// 外界方法
|
|
60
|
+
/**
|
|
61
|
+
* set name
|
|
62
|
+
* @throws {Error}&
|
|
63
|
+
* @param {string} newValue
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
setName(newValue) {
|
|
67
|
+
if (typeof newValue == "string") {
|
|
68
|
+
this.#opt.name = newValue;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error("[set error]: name type error");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
setIcon(newValue) {
|
|
75
|
+
if (typeof newValue == "string") {
|
|
76
|
+
this.#opt.components.icon = newValue;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new Error("[set error]: icon: type error");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* get name
|
|
84
|
+
* @returns {string} name
|
|
85
|
+
*/
|
|
86
|
+
getName() {
|
|
87
|
+
return this.#opt.name;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* set identifier
|
|
91
|
+
* @param {string} newValue
|
|
92
|
+
*/
|
|
93
|
+
setId(newValue) {
|
|
94
|
+
if (typeof newValue == "string") {
|
|
95
|
+
this.#opt.id == newValue;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error("[set error]: id: type error");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
getId() { }
|
|
102
|
+
}
|
|
103
|
+
exports.ItemComponent = ItemComponent;
|
|
104
|
+
exports.default = {
|
|
105
|
+
Item: ItemComponent
|
|
106
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const normalize = (v) => {
|
|
4
|
+
return String(v || '').trim();
|
|
5
|
+
};
|
|
6
|
+
const parts = (v) => {
|
|
7
|
+
return normalize(v)
|
|
8
|
+
.split('.')
|
|
9
|
+
.slice(0, 3)
|
|
10
|
+
.map((n) => parseInt(n, 10) || 0);
|
|
11
|
+
};
|
|
12
|
+
// 比较版本号,返回 1 表示 a > b,-1 表示 a < b,0 表示相等
|
|
13
|
+
const compareVar = (a, b) => {
|
|
14
|
+
const A = parts(a);
|
|
15
|
+
const B = parts(b);
|
|
16
|
+
for (let i = 0; i < 3; i++) {
|
|
17
|
+
const a = A[i];
|
|
18
|
+
const b = B[i];
|
|
19
|
+
if (!a || !b)
|
|
20
|
+
continue;
|
|
21
|
+
if (a !== b)
|
|
22
|
+
return a > b ? 1 : -1;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
};
|
|
26
|
+
exports.default = compareVar;
|
|
@@ -220,7 +220,7 @@ class ComponentExport {
|
|
|
220
220
|
writeResult(spData, declaration, id) {
|
|
221
221
|
// @ts-ignore
|
|
222
222
|
if (this.rule.getExport && this.rule.getExport.includes(id)) {
|
|
223
|
-
|
|
223
|
+
return;
|
|
224
224
|
}
|
|
225
225
|
const init = declaration.init;
|
|
226
226
|
if (init?.type !== "NewExpression")
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = CompileMcxProject;
|
|
7
|
+
const utils_js_1 = __importDefault(require("./../utils.js"));
|
|
8
|
+
/*import _compile from "./_compile.js"*/
|
|
9
|
+
/**
|
|
10
|
+
* @description - this is a function factory to generate mcxProject
|
|
11
|
+
*/
|
|
12
|
+
function CompileMcxProject(BuildOpt) {
|
|
13
|
+
return (new Compile(BuildOpt)).start();
|
|
14
|
+
}
|
|
15
|
+
class Compile {
|
|
16
|
+
BuildOpt;
|
|
17
|
+
constructor(BuildOpt) {
|
|
18
|
+
this.BuildOpt = BuildOpt;
|
|
19
|
+
// 类型验证
|
|
20
|
+
if (!utils_js_1.default.TypeVerify(this.BuildOpt, {
|
|
21
|
+
cacheDir: "string",
|
|
22
|
+
main: "string",
|
|
23
|
+
moduleDir: "string",
|
|
24
|
+
output: "string",
|
|
25
|
+
isCache: "boolean"
|
|
26
|
+
})) {
|
|
27
|
+
throw new TypeError("[compile checker]Input Opt is not right");
|
|
28
|
+
}
|
|
29
|
+
;
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
32
|
+
/*await (new _compile(this.BuildOpt)).compile();*/
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InfoCompile = void 0;
|
|
7
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
8
|
+
const buildSystem = node_os_1.default.type();
|
|
9
|
+
const buildSystemVersion = node_os_1.default.version();
|
|
10
|
+
class Context {
|
|
11
|
+
__MCX__ = {
|
|
12
|
+
author: "github@RuanhoR",
|
|
13
|
+
buildSystem,
|
|
14
|
+
buildSystemVersion,
|
|
15
|
+
buildTime: Date.now()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.default = Context;
|
|
19
|
+
exports.InfoCompile = ["__MCX__"];
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = CompileMcxDir;
|
|
7
|
+
const compile_js_1 = __importDefault(require("./compile.js"));
|
|
8
|
+
async function CompileMcxDir(BuildOpt) {
|
|
9
|
+
await (0, compile_js_1.default)(BuildOpt);
|
|
10
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Module {
|
|
4
|
+
modules;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.init();
|
|
7
|
+
}
|
|
8
|
+
init() {
|
|
9
|
+
}
|
|
10
|
+
import(ModuleDir, dirname) {
|
|
11
|
+
const _Import = (ModuleDir, dirname) => {
|
|
12
|
+
const foundModule = this.modules[key];
|
|
13
|
+
if (foundModule) {
|
|
14
|
+
if (foundModule.isLoad)
|
|
15
|
+
return foundModule.data;
|
|
16
|
+
foundModule.Load();
|
|
17
|
+
return foundModule.data;
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Cannot find module '${ModuleDir}'`);
|
|
20
|
+
};
|
|
21
|
+
_Import(ModuleDir, dirname);
|
|
22
|
+
}
|
|
23
|
+
HandlerModule(id, fn) {
|
|
24
|
+
if (typeof fn !== "function" || typeof name !== "")
|
|
25
|
+
throw new Error("Cannot create Module");
|
|
26
|
+
this.modules[id] = {
|
|
27
|
+
fn: fn,
|
|
28
|
+
isLoad: false,
|
|
29
|
+
Load() {
|
|
30
|
+
if (isLoad)
|
|
31
|
+
return;
|
|
32
|
+
const __Module = {
|
|
33
|
+
export: {},
|
|
34
|
+
currenyId: id
|
|
35
|
+
};
|
|
36
|
+
fn(__Module);
|
|
37
|
+
this.data = exp;
|
|
38
|
+
this.isLoad = true;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|