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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/lib/build/base.js +297 -1
  4. package/lib/build/build-g-config.json +11 -11
  5. package/lib/build/getModule.js +182 -1
  6. package/lib/build/index.js +370 -1
  7. package/lib/build/manifest.build.js +103 -1
  8. package/lib/build/mcVersion.js +86 -1
  9. package/lib/build/utils.js +6 -1
  10. package/lib/code-processor/c-handler-export.js +12 -1
  11. package/lib/code-processor/index.js +141 -1
  12. package/lib/code-processor/mtreehandler.js +164 -1
  13. package/lib/commander/index.js +154 -1
  14. package/lib/data/includes.json +12 -12
  15. package/lib/git/clone.js +28 -1
  16. package/lib/git/index.js +12 -1
  17. package/lib/git/pull.js +100 -1
  18. package/lib/lang/__translate.js +93 -1
  19. package/lib/lang/en.js +128 -1
  20. package/lib/lang/index.js +78 -1
  21. package/lib/lang/zh.js +146 -1
  22. package/lib/loger/colors.js +13 -1
  23. package/lib/loger/index.js +136 -1
  24. package/lib/mcx/ast/index.js +11 -1
  25. package/lib/mcx/ast/prop.js +78 -1
  26. package/lib/mcx/ast/tag.js +246 -1
  27. package/lib/mcx/compile-component/lib.js +106 -1
  28. package/lib/mcx/compile-component/types.js +2 -1
  29. package/lib/mcx/compile-component/utils.js +26 -1
  30. package/lib/mcx/compile-mcx/_compile.js +1 -1
  31. package/lib/mcx/compile-mcx/compile.js +34 -1
  32. package/lib/mcx/compile-mcx/context.js +19 -1
  33. package/lib/mcx/compile-mcx/index.js +10 -1
  34. package/lib/mcx/compile-mcx/mcx/index.js +2 -1
  35. package/lib/mcx/compile-mcx/mcx/types.js +2 -1
  36. package/lib/mcx/compile-mcx/template/module.js +42 -1
  37. package/lib/mcx/compile-mcx/types.js +2 -1
  38. package/lib/mcx/compile-mcx/utils.node.js +207 -1
  39. package/lib/mcx/index.js +13 -1
  40. package/lib/mcx/test/index.js +7 -1
  41. package/lib/mcx/test.js +21 -1
  42. package/lib/mcx/types.js +2 -1
  43. package/lib/mcx/utils.js +86 -1
  44. package/lib/module-handler/index.js +482 -1
  45. package/lib/modules/create-game/src/Runner/RunnerManager.js +113 -1
  46. package/lib/modules/create-game/src/Runner/scriptRunner.js +70 -1
  47. package/lib/modules/create-game/src/config.js +27 -1
  48. package/lib/modules/create-game/src/constants.js +19 -1
  49. package/lib/modules/create-game/src/createGameModule.js +24 -1
  50. package/lib/modules/create-game/src/gameComponent/common/autoStop.js +38 -1
  51. package/lib/modules/create-game/src/gameComponent/common/lazyLoader.js +76 -1
  52. package/lib/modules/create-game/src/gameComponent/common/stopWatch/onTimeEvent.js +36 -1
  53. package/lib/modules/create-game/src/gameComponent/common/stopWatch/stopWatch.js +90 -1
  54. package/lib/modules/create-game/src/gameComponent/common/stopWatch/tickEvent.js +29 -1
  55. package/lib/modules/create-game/src/gameComponent/common/timer/onTimeEvent.js +36 -1
  56. package/lib/modules/create-game/src/gameComponent/common/timer/tickEvent.js +29 -1
  57. package/lib/modules/create-game/src/gameComponent/common/timer/timer.js +87 -1
  58. package/lib/modules/create-game/src/gameComponent/gameComponent.js +53 -1
  59. package/lib/modules/create-game/src/gameComponent/index.js +31 -1
  60. package/lib/modules/create-game/src/gameComponent/player/blockInteractionBlocker.js +40 -1
  61. package/lib/modules/create-game/src/gameComponent/player/entityInteractionBlocker.js +48 -1
  62. package/lib/modules/create-game/src/gameComponent/player/healthIndicator.js +48 -1
  63. package/lib/modules/create-game/src/gameComponent/player/regionMonitor.js +22 -1
  64. package/lib/modules/create-game/src/gameComponent/player/respawn.js +59 -1
  65. package/lib/modules/create-game/src/gameComponent/player/spawnProtector.js +69 -1
  66. package/lib/modules/create-game/src/gameComponent/region/regionProtecter.js +53 -1
  67. package/lib/modules/create-game/src/gameComponent/region/regionTeamChooser.js +71 -1
  68. package/lib/modules/create-game/src/gameComponent/region/regionTeamCleaner.js +20 -1
  69. package/lib/modules/create-game/src/gameComponent/view/infoScoreboard.js +77 -1
  70. package/lib/modules/create-game/src/gameComponent/view/teamScoreboard.js +83 -1
  71. package/lib/modules/create-game/src/gameContext.js +6 -1
  72. package/lib/modules/create-game/src/gameEngine.js +139 -1
  73. package/lib/modules/create-game/src/gameEvent/eventManager.js +108 -1
  74. package/lib/modules/create-game/src/gameEvent/eventSignal.js +28 -1
  75. package/lib/modules/create-game/src/gameEvent/events/buttonPush.js +41 -1
  76. package/lib/modules/create-game/src/gameEvent/events/inSlot.js +77 -1
  77. package/lib/modules/create-game/src/gameEvent/events/interval.js +51 -1
  78. package/lib/modules/create-game/src/gameEvent/events/itemUse.js +36 -1
  79. package/lib/modules/create-game/src/gameEvent/events/onBlock.js +106 -1
  80. package/lib/modules/create-game/src/gameEvent/events/regionEvents.js +105 -1
  81. package/lib/modules/create-game/src/gameEvent/events/signClick.js +45 -1
  82. package/lib/modules/create-game/src/gameEvent/gameEvent.js +54 -1
  83. package/lib/modules/create-game/src/gameEvent/index.js +20 -1
  84. package/lib/modules/create-game/src/gameEvent/mapEventSignal.js +101 -1
  85. package/lib/modules/create-game/src/gameEvent/subscription.js +17 -1
  86. package/lib/modules/create-game/src/gamePlayer/gamePlayer.js +102 -1
  87. package/lib/modules/create-game/src/gamePlayer/groupBuilder.js +38 -1
  88. package/lib/modules/create-game/src/gamePlayer/groupSet.js +96 -1
  89. package/lib/modules/create-game/src/gamePlayer/index.js +25 -1
  90. package/lib/modules/create-game/src/gamePlayer/playerGroup.js +145 -1
  91. package/lib/modules/create-game/src/gamePlayer/playerManager.js +57 -1
  92. package/lib/modules/create-game/src/gameRegion/gameRegion.js +229 -1
  93. package/lib/modules/create-game/src/gameRegion/index.js +43 -1
  94. package/lib/modules/create-game/src/gameRegion/regionHelper.js +79 -1
  95. package/lib/modules/create-game/src/gameState/common/autoStop.js +39 -1
  96. package/lib/modules/create-game/src/gameState/gameState.js +169 -1
  97. package/lib/modules/create-game/src/gameState/index.js +7 -1
  98. package/lib/modules/create-game/src/gameState/types.js +35 -1
  99. package/lib/modules/create-game/src/gameStructure/gameStructure.js +36 -1
  100. package/lib/modules/create-game/src/main.js +86 -1
  101. package/lib/modules/create-game/src/system/gameCommand.js +107 -1
  102. package/lib/modules/create-game/src/system/gameManager.js +124 -1
  103. package/lib/modules/create-game/src/system/globalPlayerManager.js +119 -1
  104. package/lib/modules/create-game/src/utils/GameError.js +31 -1
  105. package/lib/modules/create-game/src/utils/algorithm.js +95 -1
  106. package/lib/modules/create-game/src/utils/chunk.js +63 -1
  107. package/lib/modules/create-game/src/utils/deferredObject.js +27 -1
  108. package/lib/modules/create-game/src/utils/duration.js +25 -1
  109. package/lib/modules/create-game/src/utils/func.js +20 -1
  110. package/lib/modules/create-game/src/utils/index.js +52 -1
  111. package/lib/modules/create-game/src/utils/interfaces.js +2 -1
  112. package/lib/modules/create-game/src/utils/logger.js +47 -1
  113. package/lib/modules/create-game/src/utils/random.js +76 -1
  114. package/lib/modules/create-game/src/utils/vanila-data.js +123 -1
  115. package/lib/modules/create-game/src/utils/vector.js +96 -1
  116. package/lib/modules/gameLib/src/config.js +134 -1
  117. package/lib/modules/gameLib/src/data.js +77 -1
  118. package/lib/modules/gameLib/src/entity.js +256 -1
  119. package/lib/modules/gameLib/src/event.js +285 -1
  120. package/lib/modules/gameLib/src/index.js +20 -1
  121. package/lib/modules/gameLib/src/loger.js +21 -1
  122. package/lib/modules/gameLib/src/ui.js +209 -1
  123. package/lib/modules/gameLib/src/utils.js +122 -1
  124. package/lib/modules/gutils/src/index.js +22 -1
  125. package/lib/runTemp/File.js +54 -1
  126. package/lib/runTemp/index.js +137 -1
  127. package/lib/runTemp/securityFile.js +93 -1
  128. package/lib/start/addPack.js +3 -1
  129. package/lib/start/clean.js +84 -1
  130. package/lib/start/create.js +146 -1
  131. package/lib/start/dev.js +99 -1
  132. package/lib/start/getResConfig.js +3 -1
  133. package/lib/start/incg.js +3 -1
  134. package/lib/start/index.js +207 -1
  135. package/lib/start/init.js +125 -1
  136. package/lib/start/rechce.js +57 -1
  137. package/lib/start/unaddPack.js +3 -1
  138. package/lib/start/unincg.js +67 -1
  139. package/lib/start/version.js +73 -1
  140. package/lib/utils/index.js +298 -1
  141. package/lib/uuid/index.js +27 -1
  142. package/package.json +1 -1
  143. package/test/script-mbler/behavior/scripts/index.js +0 -5
@@ -1 +1,11 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const tag_js_1=__importDefault(require("./tag.js")),prop_js_1=__importDefault(require("./prop.js"));exports.default={tag:tag_js_1.default,prop:prop_js_1.default};
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
+ };
@@ -1 +1,78 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Lexer=void 0,exports.default=PropParser;const STATUS=[0,1];class Lexer{code;constructor(e){this.code=e}*tokenize(){let e=STATUS[0],r="",t="",s=!1;for(const o of this.code)if(/\s/.test(o)){if("\n"===o){if(e===STATUS[1]&&r&&t){const e={key:r,value:this.HandlerValue(t),type:"PropChar"};yield e}r="",t="",s=!1,e=STATUS[0]}}else"="===o?e===STATUS[0]&&(e=STATUS[1],s=!0):e===STATUS[0]?r+=o:e===STATUS[1]&&(t+=o);if(r&&t){const e={key:r,value:this.HandlerValue(t),type:"PropChar"};yield e}}HandlerValue(e){try{const r=Number(e);if(!Number.isNaN(r))return r;if(["[","{"].includes(e.slice(0,1))&&["]","}"].includes(e.slice(-1)))return JSON.parse(e)}catch{}return e}}function PropParser(e){const r=new Lexer(e);return Array.from(r.tokenize())}exports.Lexer=Lexer;
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
+ }
@@ -1 +1,246 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class Lexer{text;booleanProxyCache;constructor(t){this.text=t,this.booleanProxyCache=new WeakMap}get tokens(){return{[Symbol.iterator]:()=>this.tokenIterator()}}parseAttributes(t){const e={};let r="",n="",o=!0,a="",s=!1,l=null,i=!0;for(let c=0;c<t.length;c++){const h=t[c];if(i)if(" "===h||">"===h){if(a=r.trim(),r="",i=!1,">"===h)break}else r+=h;else if(s)h!==l||0!==n.length&&"\\"===n[n.length-1]?n+=h:(e[r.trim()]=n,r="",n="",o=!0,s=!1,l=null);else if("="===h&&o){o=!1,s=!0;const e=c+1,r=e<t.length?t[e]:" ";l='"'===r||"'"===r?r:null}else" "===h&&o&&r?(e[r.trim()]="true",r=""):o&&(r+=h)}return i?a=r.trim():r&&(e[r.trim()]=s?n.replace(/^["']/,"").replace(/["']$/,""):"true"),{name:a,arr:e}}*tagSplitIterator(){let t=!1,e="",r="";for(const n of this.text)if("<"===n){if(r){const t={data:r,type:"Content"};yield t,r=""}t=!0,e="<"}else if(">"===n){if(!t)throw new Error("未匹配的 '>'");e+=">",t=!1;const r=e.startsWith("</")?"TagEnd":"Tag",n={data:e,type:r};yield n,e=""}else t?e+=n:r+=n;if(r){const t={data:r,type:"Content"};yield t}}*tokenIterator(){const t=Array.from(this.tagSplitIterator());let e=null,r=0;for(let n=0;n<t.length;n++){const o=t[n];if(o)if("Tag"===o.type){const t=this.parseAttributes(o.data.slice(1,-1));e={start:o,name:t.name,arr:t.arr,content:null,end:null},r=n+1}else if("TagEnd"===o.type&&e){e.end=o;let a="";for(let e=r;e<n;e++){a+=t[e].data}const s={data:a,type:"TagContent"};e.content=s;const l={start:e.start,name:e.name,arr:e.arr,content:e.content,end:e.end};yield l,e=null}}}getBooleanCheckProxy(){if(!this.booleanProxyCache.has(this)){const t=new Map,e=new Proxy({},{get:(e,r)=>"string"==typeof r&&(t.get(r)||!1),set:(e,r,n)=>"string"==typeof r&&(t.set(r,Boolean(n)),!0)});this.booleanProxyCache.set(this,e)}return this.booleanProxyCache.get(this)}}class McxAst{text;constructor(t){this.text=t}getAST(){const t=new Lexer(this.text);return Array.from(t.tokens)}get data(){return this.getAST()}parseAST(){return this.getAST()}static generateCode(t){let e=`<${t.name}`;for(const[r,n]of Object.entries(t.arr))e+="true"===n?` ${r}`:` ${r}=${n}`;return e+=">",t.content&&(e+=t.content.data),e+=`</${t.name}>`,e}}exports.default=McxAst;
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";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemComponent=void 0;class ItemComponent{#t;constructor(t){this.#t=t}toJSON(){if(!this.#t)throw new Error("[mcx component]: cannot read component");const t={format_version:"","minecraft:item":{components:{},description:{identifier:""}}};if("string"!=typeof this.#t.format||!/\d.\d.\d/.test(this.#t.format))throw new Error("[compile component]: no format");if(t.format_version=this.#t.format,"string"!=typeof this.#t.id||!/[a-zA-Z0-9_]:[a-zA-Z0-9_]/.test(this.#t.id))throw new Error("[compile component]:cno id");t["minecraft:item"].description.identifier=this.#t.id;const e=t["minecraft:item"].components;if("string"==typeof this.#t.name&&(e["minecraft:display_name"]={value:this.#t.name}),this.#t.components){const t=this.#t.components;"number"==typeof t.damage&&(e["minecraft:damage"]={value:t.damage}),"boolean"==typeof t.offHand&&t.offHand&&(e["minecraft:allow_off_hand"]={value:!0}),"boolean"==typeof t.DestroyInCreate&&(e["minecraft:can_destroy_in_creative"]={value:t.DestroyInCreate})}return t}setName(t){if("string"!=typeof t)throw new Error("[set error]: name type error");this.#t.name=t}setIcon(t){if("string"!=typeof t)throw new Error("[set error]: icon: type error");this.#t.components.icon=t}getName(){return this.#t.name}setId(t){if("string"!=typeof t)throw new Error("[set error]: id: type error");this.#t.id}getId(){}}exports.ItemComponent=ItemComponent,exports.default={Item:ItemComponent};
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";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,26 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const normalize=r=>String(r||"").trim(),parts=r=>normalize(r).split(".").slice(0,3).map(r=>parseInt(r,10)||0),compareVar=(r,e)=>{const t=parts(r),s=parts(e);for(let r=0;r<3;r++){const e=t[r],a=s[r];if(e&&a&&e!==a)return e>a?1:-1}return 0};exports.default=compareVar;
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
- continue;
223
+ return;
224
224
  }
225
225
  const init = declaration.init;
226
226
  if (init?.type !== "NewExpression")
@@ -1 +1,34 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CompileMcxProject;const utils_js_1=__importDefault(require("./../utils.js")),_compile_js_1=__importDefault(require("./_compile.js"));function CompileMcxProject(t){return new Compile(t).start()}class Compile{BuildOpt;constructor(t){if(this.BuildOpt=t,!utils_js_1.default.TypeVerify(this.BuildOpt,{cacheDir:"string",main:"string",moduleDir:"string",output:"string",isCache:"boolean"}))throw new TypeError("[compile checker]Input Opt is not right")}async start(){await new _compile_js_1.default(this.BuildOpt).compile()}}
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";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.InfoCompile=void 0;const node_os_1=__importDefault(require("node:os")),buildSystem=node_os_1.default.type(),buildSystemVersion=node_os_1.default.version();class Context{__MCX__={author:"github@RuanhoR",buildSystem:buildSystem,buildSystemVersion:buildSystemVersion,buildTime:Date.now()}}exports.default=Context,exports.InfoCompile=["__MCX__"];
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";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CompileMcxDir;const compile_js_1=__importDefault(require("./compile.js"));async function CompileMcxDir(e){await(0,compile_js_1.default)(e)}
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";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,42 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class Module{modules;constructor(){this.init()}init(){}import(e,o){(e=>{const o=this.modules[key];if(o)return o.isLoad||o.Load(),o.data;throw new Error(`Cannot find module '${e}'`)})(e)}HandlerModule(e,o){if("function"!=typeof o||""!=typeof name)throw new Error("Cannot create Module");this.modules[e]={fn:o,isLoad:!1,Load(){if(isLoad)return;o({export:{},currenyId:e}),this.data=exp,this.isLoad=!0}}}}
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";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });