mbler 0.1.3-alpha → 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.
Files changed (178) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +15 -6
  3. package/bin/mbler.js +12 -12
  4. package/bin/minify.js +58 -44
  5. package/lib/build/base.js +1 -297
  6. package/lib/build/build-g-config.json +12 -12
  7. package/lib/build/getModule.js +1 -182
  8. package/lib/build/index.js +1 -370
  9. package/lib/build/manifest.build.js +1 -103
  10. package/lib/build/mcVersion.js +1 -86
  11. package/lib/build/utils.js +1 -6
  12. package/lib/code-processor/c-handler-export.js +1 -12
  13. package/lib/code-processor/index.js +1 -141
  14. package/lib/code-processor/mtreehandler.js +1 -164
  15. package/lib/commander/index.js +1 -154
  16. package/lib/data/includes.json +13 -13
  17. package/lib/data/version.json +88 -88
  18. package/lib/git/clone.js +1 -28
  19. package/lib/git/index.js +1 -12
  20. package/lib/git/pull.js +1 -100
  21. package/lib/lang/__translate.js +1 -93
  22. package/lib/lang/en.js +1 -128
  23. package/lib/lang/index.js +1 -78
  24. package/lib/lang/zh.js +1 -146
  25. package/lib/loger/colors.js +1 -13
  26. package/lib/loger/index.js +1 -136
  27. package/lib/mcx/ast/index.js +1 -11
  28. package/lib/mcx/ast/prop.js +1 -78
  29. package/lib/mcx/ast/tag.js +1 -246
  30. package/lib/mcx/compile-component/lib.js +1 -106
  31. package/lib/mcx/compile-component/types.js +1 -2
  32. package/lib/mcx/compile-component/utils.js +1 -26
  33. package/lib/mcx/compile-mcx/compile.js +1 -34
  34. package/lib/mcx/compile-mcx/compiler/bundler.js +1 -0
  35. package/lib/mcx/compile-mcx/compiler/compileData.js +1 -0
  36. package/lib/mcx/compile-mcx/compiler/compileMain.js +1 -0
  37. package/lib/mcx/compile-mcx/compiler/index.js +1 -0
  38. package/lib/mcx/compile-mcx/compiler/utils.js +1 -0
  39. package/lib/mcx/compile-mcx/context.js +1 -19
  40. package/lib/mcx/compile-mcx/index.js +1 -10
  41. package/lib/mcx/compile-mcx/mcx/index.js +1 -2
  42. package/lib/mcx/compile-mcx/mcx/types.js +1 -2
  43. package/lib/mcx/compile-mcx/template/module.js +1 -42
  44. package/lib/mcx/compile-mcx/types.js +1 -2
  45. package/lib/mcx/compile-mcx/utils.node.js +1 -207
  46. package/lib/mcx/index.js +1 -13
  47. package/lib/mcx/test/index.js +1 -7
  48. package/lib/mcx/test.js +1 -21
  49. package/lib/mcx/types.js +1 -2
  50. package/lib/mcx/utils.js +1 -86
  51. package/lib/module-handler/index.js +1 -482
  52. package/lib/modules/create-game/mbler.config.json +13 -13
  53. package/lib/modules/create-game/src/Runner/RunnerManager.js +1 -113
  54. package/lib/modules/create-game/src/Runner/scriptRunner.js +1 -70
  55. package/lib/modules/create-game/src/config.js +1 -27
  56. package/lib/modules/create-game/src/constants.js +1 -19
  57. package/lib/modules/create-game/src/createGameModule.js +1 -24
  58. package/lib/modules/create-game/src/gameComponent/common/autoStop.js +1 -38
  59. package/lib/modules/create-game/src/gameComponent/common/lazyLoader.js +1 -76
  60. package/lib/modules/create-game/src/gameComponent/common/stopWatch/onTimeEvent.js +1 -36
  61. package/lib/modules/create-game/src/gameComponent/common/stopWatch/stopWatch.js +1 -90
  62. package/lib/modules/create-game/src/gameComponent/common/stopWatch/tickEvent.js +1 -29
  63. package/lib/modules/create-game/src/gameComponent/common/timer/onTimeEvent.js +1 -36
  64. package/lib/modules/create-game/src/gameComponent/common/timer/tickEvent.js +1 -29
  65. package/lib/modules/create-game/src/gameComponent/common/timer/timer.js +1 -87
  66. package/lib/modules/create-game/src/gameComponent/gameComponent.js +1 -53
  67. package/lib/modules/create-game/src/gameComponent/index.js +1 -31
  68. package/lib/modules/create-game/src/gameComponent/player/blockInteractionBlocker.js +1 -40
  69. package/lib/modules/create-game/src/gameComponent/player/entityInteractionBlocker.js +1 -48
  70. package/lib/modules/create-game/src/gameComponent/player/healthIndicator.js +1 -48
  71. package/lib/modules/create-game/src/gameComponent/player/regionMonitor.js +1 -22
  72. package/lib/modules/create-game/src/gameComponent/player/respawn.js +1 -59
  73. package/lib/modules/create-game/src/gameComponent/player/spawnProtector.js +1 -69
  74. package/lib/modules/create-game/src/gameComponent/region/regionProtecter.js +1 -53
  75. package/lib/modules/create-game/src/gameComponent/region/regionTeamChooser.js +1 -71
  76. package/lib/modules/create-game/src/gameComponent/region/regionTeamCleaner.js +1 -20
  77. package/lib/modules/create-game/src/gameComponent/view/infoScoreboard.js +1 -77
  78. package/lib/modules/create-game/src/gameComponent/view/teamScoreboard.js +1 -83
  79. package/lib/modules/create-game/src/gameContext.js +1 -6
  80. package/lib/modules/create-game/src/gameEngine.js +1 -139
  81. package/lib/modules/create-game/src/gameEvent/eventManager.js +1 -108
  82. package/lib/modules/create-game/src/gameEvent/eventSignal.js +1 -28
  83. package/lib/modules/create-game/src/gameEvent/events/buttonPush.js +1 -41
  84. package/lib/modules/create-game/src/gameEvent/events/inSlot.js +1 -77
  85. package/lib/modules/create-game/src/gameEvent/events/interval.js +1 -51
  86. package/lib/modules/create-game/src/gameEvent/events/itemUse.js +1 -36
  87. package/lib/modules/create-game/src/gameEvent/events/onBlock.js +1 -106
  88. package/lib/modules/create-game/src/gameEvent/events/regionEvents.js +1 -105
  89. package/lib/modules/create-game/src/gameEvent/events/signClick.js +1 -45
  90. package/lib/modules/create-game/src/gameEvent/gameEvent.js +1 -54
  91. package/lib/modules/create-game/src/gameEvent/index.js +1 -20
  92. package/lib/modules/create-game/src/gameEvent/mapEventSignal.js +1 -101
  93. package/lib/modules/create-game/src/gameEvent/subscription.js +1 -17
  94. package/lib/modules/create-game/src/gamePlayer/gamePlayer.js +1 -102
  95. package/lib/modules/create-game/src/gamePlayer/groupBuilder.js +1 -38
  96. package/lib/modules/create-game/src/gamePlayer/groupSet.js +1 -96
  97. package/lib/modules/create-game/src/gamePlayer/index.js +1 -25
  98. package/lib/modules/create-game/src/gamePlayer/playerGroup.js +1 -145
  99. package/lib/modules/create-game/src/gamePlayer/playerManager.js +1 -57
  100. package/lib/modules/create-game/src/gameRegion/gameRegion.js +1 -229
  101. package/lib/modules/create-game/src/gameRegion/index.js +1 -43
  102. package/lib/modules/create-game/src/gameRegion/regionHelper.js +1 -79
  103. package/lib/modules/create-game/src/gameState/common/autoStop.js +1 -39
  104. package/lib/modules/create-game/src/gameState/gameState.js +1 -169
  105. package/lib/modules/create-game/src/gameState/index.js +1 -7
  106. package/lib/modules/create-game/src/gameState/types.js +1 -35
  107. package/lib/modules/create-game/src/gameStructure/gameStructure.js +1 -36
  108. package/lib/modules/create-game/src/main.js +1 -86
  109. package/lib/modules/create-game/src/system/gameCommand.js +1 -107
  110. package/lib/modules/create-game/src/system/gameManager.js +1 -124
  111. package/lib/modules/create-game/src/system/globalPlayerManager.js +1 -119
  112. package/lib/modules/create-game/src/utils/GameError.js +1 -31
  113. package/lib/modules/create-game/src/utils/algorithm.js +1 -95
  114. package/lib/modules/create-game/src/utils/chunk.js +1 -63
  115. package/lib/modules/create-game/src/utils/deferredObject.js +1 -27
  116. package/lib/modules/create-game/src/utils/duration.js +1 -25
  117. package/lib/modules/create-game/src/utils/func.js +1 -20
  118. package/lib/modules/create-game/src/utils/index.js +1 -52
  119. package/lib/modules/create-game/src/utils/interfaces.js +1 -2
  120. package/lib/modules/create-game/src/utils/logger.js +1 -47
  121. package/lib/modules/create-game/src/utils/random.js +1 -76
  122. package/lib/modules/create-game/src/utils/vanila-data.js +1 -123
  123. package/lib/modules/create-game/src/utils/vector.js +1 -96
  124. package/lib/modules/gameLib/mbler.config.json +15 -15
  125. package/lib/modules/gameLib/src/config.js +1 -134
  126. package/lib/modules/gameLib/src/data.js +1 -77
  127. package/lib/modules/gameLib/src/entity.js +1 -256
  128. package/lib/modules/gameLib/src/event.js +1 -285
  129. package/lib/modules/gameLib/src/index.js +1 -20
  130. package/lib/modules/gameLib/src/loger.js +1 -21
  131. package/lib/modules/gameLib/src/ui.js +1 -209
  132. package/lib/modules/gameLib/src/utils.js +1 -122
  133. package/lib/modules/gutils/mbler.config.json +11 -11
  134. package/lib/modules/gutils/src/index.js +1 -22
  135. package/lib/modules/innerDef.json +4 -4
  136. package/lib/runTemp/File.js +1 -54
  137. package/lib/runTemp/config.json +3 -3
  138. package/lib/runTemp/index.js +1 -137
  139. package/lib/runTemp/securityFile.js +1 -93
  140. package/lib/start/addPack.js +1 -3
  141. package/lib/start/clean.js +1 -84
  142. package/lib/start/create.js +1 -146
  143. package/lib/start/dev.js +1 -99
  144. package/lib/start/getResConfig.js +1 -3
  145. package/lib/start/incg.js +1 -3
  146. package/lib/start/index.js +1 -207
  147. package/lib/start/init.js +1 -125
  148. package/lib/start/rechce.js +1 -57
  149. package/lib/start/unaddPack.js +1 -3
  150. package/lib/start/unincg.js +1 -67
  151. package/lib/start/version.js +1 -73
  152. package/lib/utils/index.js +1 -298
  153. package/lib/uuid/index.js +1 -27
  154. package/package.json +49 -1
  155. package/test/2x sword/behavior/scripts/index.js +24 -24
  156. package/test/2x sword/mbler.config.json +11 -11
  157. package/test/2x sword/package.json +13 -13
  158. package/test/README.md +7 -7
  159. package/test/des/index.js +19 -19
  160. package/test/des/mbler.config.json +4 -4
  161. package/test/des/package.json +6 -6
  162. package/test/initializer/index.js +5 -5
  163. package/test/initializer/mbler.config.json +4 -4
  164. package/test/initializer/package.json +6 -6
  165. package/test/mbler-int/behavior/res/items/mang_one_int.json +21 -21
  166. package/test/mbler-int/behavior/scripts/index.js +7 -7
  167. package/test/mbler-int/behavior/scripts/lib/event/index.js +19 -19
  168. package/test/mbler-int/behavior/scripts/lib/ui/Lore.js +18 -18
  169. package/test/mbler-int/behavior/scripts/lib/ui/baseUi.js +6 -6
  170. package/test/mbler-int/behavior/scripts/lib/ui/index.js +206 -206
  171. package/test/mbler-int/behavior/scripts/lib/utils/index.js +51 -51
  172. package/test/mbler-int/mbler.config.json +18 -18
  173. package/test/mbler-int/package.json +12 -12
  174. package/test/script-mbler/behavior/scripts/index.js +5 -0
  175. package/test/script-mbler/behavior/scripts/index.ts +5 -5
  176. package/test/script-mbler/mbler.config.json +14 -14
  177. package/test/script-mbler/package.json +15 -15
  178. package/lib/mcx/compile-mcx/_compile.js +0 -602
@@ -1,246 +1 @@
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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MCXUtils=void 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 n="",s="",r=!0,a="",i=!1,o=null,l=!0;for(let c=0;c<t.length;c++){const d=t[c];if(l)if(" "===d||">"===d){if(a=n.trim(),n="",l=!1,">"===d)break}else n+=d;else if(i)d!==o||0!==s.length&&"\\"===s[s.length-1]?s+=d:(e[n.trim()]=s,n="",s="",r=!0,i=!1,o=null);else if("="===d&&r){r=!1,i=!0;const e=c+1,n=e<t.length?t[e]:" ";o='"'===n||"'"===n?n:null}else" "===d&&r&&n?(e[n.trim()]="true",n=""):r&&(n+=d)}return l?a=n.trim():n&&(e[n.trim()]=i?s.replace(/^["']/,"").replace(/["']$/,""):"true"),{name:a,arr:e}}*tagSplitIterator(){const t=this.text;let e=0,n=1;const s=t.length;for(;e<s;){if("<"===t[e]){if(t.startsWith("!--",e+1)){const r=t.indexOf("--\x3e",e+4),a=-1===r?s-1:r+2,i=t.slice(e,a+1);for(const t of i)"\n"===t&&n++;e=a+1;continue}const r=e,a=n;let i=e+1,o=!1;for(;i<s;i++){const e=t[i];if(">"===e){o=!0;break}"\n"===e&&n++}const l=i,c=t.slice(r,o?i+1:s),d=c.startsWith("</")?"TagEnd":"Tag",g={data:c,type:d,startIndex:r,endIndex:o?l:s-1,startLine:a};yield g,e=o?i+1:s}else{const r=e,a=n;let i=e;for(;i<s;i++){const e=t[i];if("<"===e)break;"\n"===e&&n++}const o={data:t.slice(r,i),type:"Content",startIndex:r,endIndex:i-1,startLine:a};yield o,e=i}}}*tokenIterator(){const t=Array.from(this.tagSplitIterator()),e=[],n=[];for(let s=0;s<t.length;s++){const r=t[s];if(r)if("Content"===r.type){const t={data:r.data,type:"TagContent"};if(n.length>0){n[n.length-1].content.push(t)}else e.push(t)}else if("Tag"===r.type){const t=r.data.slice(1,-1).trim(),e=t.endsWith("/"),s=this.parseAttributes(e?t.slice(0,-1).trim():t),a={start:r,name:s.name,arr:s.arr,content:[],end:null,loc:{start:{line:r.startLine||1,index:r.startIndex||0},end:{line:r.startLine||1,index:r.endIndex||r.startIndex||0}}};e?n.length>0?n[n.length-1].content.push(a):yield a:n.push(a)}else if("TagEnd"===r.type){const t=r.data.replace(/^<\/\s*/,"").replace(/\s*>$/,"").trim();for(let e=n.length-1;e>=0;e--){const s=n[e];if(s&&s.name===t){s.end=r,s.loc.end={line:r.startLine||s.loc.start.line,index:r.endIndex||r.loc.start.index},n.splice(e,1),n.length>0?n[n.length-1].content.push(s):yield s;break}}}}for(;n.length>0;){const t=n.shift();n.length>0?n[0].content.push(t):yield t}}getBooleanCheckProxy(){if(!this.booleanProxyCache.has(this)){const t=new Map,e=new Proxy({},{get:(e,n)=>"string"==typeof n&&(t.get(n)||!1),set:(e,n,s)=>"string"==typeof n&&(t.set(n,Boolean(s)),!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[n,s]of Object.entries(t.arr||{}))e+="true"===s?` ${n}`:` ${n}=${String(s)}`;e+=">";const n=t.content;if(Array.isArray(n))for(const t of n)"TagContent"===t.type?e+=t.data:e+=McxAst.generateCode(t);return e+=`</${t.name}>`,e}}exports.default=McxAst;class MCXUtils{static isTagNode(t){return!!t&&"object"==typeof t&&"start"in t&&"name"in t&&"arr"in t&&"content"in t&&"end"in t}static isTagContentNode(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t&&"TagContent"===t.type}static isAttributeMap(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}static isToken(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t&&("Tag"===t.type||"TagEnd"===t.type||"Content"===t.type)}static isTagToken(t){return MCXUtils.isToken(t)&&"Tag"===t.type}static isTagEndToken(t){return MCXUtils.isToken(t)&&"TagEnd"===t.type}static isContentToken(t){return MCXUtils.isToken(t)&&"Content"===t.type}static isBaseToken(t){return!!t&&"object"==typeof t&&"data"in t&&"type"in t}static isTokenType(t){return"Tag"===t||"TagEnd"===t||"Content"===t}static isParseNode(t){return Array.isArray(t)&&t.every(MCXUtils.isTagNode)}}exports.MCXUtils=MCXUtils;
@@ -1,106 +1 @@
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
+ "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,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1,26 +1 @@
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;
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,34 +1 @@
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
+ "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"));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(){}}
@@ -0,0 +1 @@
1
+ "use strict";function bundlerWrite(e){}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=bundlerWrite;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MCXCompileData=exports.JsCompileData=void 0;class JsCompileData{node;BuildCache;File="__repl";isFile=!1;constructor(e,t={export:[],import:[],call:[]}){this.node=e,this.BuildCache=t}setFilePath(e){this.isFile=!0,this.File=e}}exports.JsCompileData=JsCompileData;class MCXCompileData{raw;JSIR;strLoc;File="";isFile=!1;constructor(e,t,i){this.raw=e,this.JSIR=t,this.strLoc=i}setFilePath(e){this.JSIR.setFilePath(e),this.isFile=!0,this.File=e}}exports.MCXCompileData=MCXCompileData;
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__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 r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),n=0;n<i.length;n++)"default"!==i[n]&&__createBinding(r,t,i[n]);return __setModuleDefault(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const utils_1=require("./../../../utils"),compiler=__importStar(require("./")),promises_1=require("node:fs/promises"),node_path_1=require("node:path");class CompileMain{opt;main="";constructor(e){this.opt=e,"string"==typeof e.main&&(this.main=(0,utils_1.join)(e.ProjectDir,e.main))}async start(){if(!this.main)throw new Error("[mcx load]: mcx loader must has a main file");const e=await(0,promises_1.readFile)(this.main,"utf-8");this.compMain(e)}compMain(e){if(".js"!==(0,node_path_1.extname)(this.main))throw new Error("[load project]: main file must is a javascript.");return compiler.compileJSFn(e)}}exports.default=CompileMain;
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,o)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=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 r=e(t),o=0;o<r.length;o++)"default"!==r[o]&&__createBinding(i,t,r[o]);return __setModuleDefault(i,t),i}}(),__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompileJS=void 0,exports.compileJSFn=compileJSFn,exports.compileMCXFn=compileMCXFn;const t=__importStar(require("@babel/types")),types_1=require("../types"),CompileData=__importStar(require("./compileData")),utils_1=__importDefault(require("./utils")),parser_1=require("@babel/parser"),tag_1=__importStar(require("../../ast/tag")),prop_1=__importDefault(require("../../ast/prop"));class CompileJS{node;constructor(e){if(this.node=e,!t.isProgram(e))throw new Error("[compile error]: jsCompile can't work in a not program");this.CompileData=new CompileData.JsCompileData(e),this.run(),this.writeBuildCache()}TopContext={};indexTemp={};push(e){for(const t of e.imported)this.indexTemp[t.as]={source:e.source,import:t.import,isAll:t.isAll}}takeInnerMost(e){if(!t.isMemberExpression(e))throw new Error("[take item}: must MemberExpression");let i=e;for(;;){if(!t.isMemberExpression(i)){if(t.isCallExpression(i)){const e=i.callee;if(t.isMemberExpression(e)){i=e.object;continue}i=e;continue}return t.isIdentifier(i)||t.isThisExpression(i)||t.isSuper(i)||t.isImport(i)||t.isNewExpression(i)||"function"==typeof t.isLiteral&&t.isLiteral(i)||t.isLiteral(i)?i:t.stringLiteral("")}i=i.object}}writeImportKeys=[];extractIdentifierNames(e){const i=[];if(t.isIdentifier(e))i.push(e.name);else if(t.isMemberExpression(e))i.push(...this.extractIdentifierNames(e.object)),"PrivateName"!==e.property.type&&i.push(...this.extractIdentifierNames(e.property));else if(t.isCallExpression(e)){i.push(...this.extractIdentifierNames(e.callee));for(const r of e.arguments)t.isExpression(r)&&i.push(...this.extractIdentifierNames(r))}else t.isBinaryExpression(e)||t.isLogicalExpression(e)?(i.push(...this.extractIdentifierNames(e.left)),i.push(...this.extractIdentifierNames(e.right))):t.isUnaryExpression(e)?i.push(...this.extractIdentifierNames(e.argument)):t.isConditionalExpression(e)&&(i.push(...this.extractIdentifierNames(e.test)),i.push(...this.extractIdentifierNames(e.consequent)),i.push(...this.extractIdentifierNames(e.alternate)));return i}writeBuildCache(){const e=[];let t=[];for(const[i,r]of Object.entries(this.indexTemp))if(this.writeImportKeys.includes(i))if(e.includes(r.source)){let e=!1;for(const o in t){const n=t[o];n&&(n.source==r.source&&(n.imported.push({as:i,isAll:r.isAll,import:r.import}),e=!0))}if(!e)throw new Error("[mcx compoiler]: internal error: unexpected source")}else t.push({source:r.source,imported:[{as:i,import:r.import,isAll:r.isAll}]}),e.push(r.source);this.CompileData.BuildCache.import=t}CompileData;getCompileData(){return this.CompileData}conditionalInTempImport(e,i,r){if(t.isIdentifier(e))e.name in this.indexTemp&&!this.writeImportKeys.includes(e.name)&&this.writeImportKeys.push(e.name);else if("FunctionExpression"!=e.type)if("ArrowFunctionExpression"!=e.type){if(!t.isLiteral(e)){if(t.isMemberExpression(e)){const o=this.extractIdentifierNames(e);for(const e of o)e in this.indexTemp&&!this.writeImportKeys.includes(e)&&this.writeImportKeys.push(e);return this.conditionalInTempImport(e.object,i,r),void(t.isExpression(e.property)&&this.conditionalInTempImport(e.property,i,r))}if(t.isCallExpression(e)&&"V8IntrinsicIdentifier"!==e.callee?.type){this.CompileData.BuildCache.call.push({source:e.callee,arguments:e.arguments,remove:r}),this.conditionalInTempImport(e.callee,i,r);for(const o of e.arguments)t.isExpression(o)&&this.conditionalInTempImport(o,i,r)}else try{const t=this.extractIdentifierNames(e);for(const e of t)e in this.indexTemp&&!this.writeImportKeys.includes(e)&&this.writeImportKeys.push(e)}catch(e){}}}else t.isExpression(e.body)?this.conditionalInTempImport(e.body,i,r):this.tre(e.body);else this.tre(t.blockStatement([e.body]))}tre(e,i={}){if(!t.isBlock(e))throw new Error("[compile error]: can't for in not block node");const r=t.isProgram(e),o=r?this.TopContext:i;for(let i=0;i<e.body.length;i++){const n=e.body[i],s=()=>{e.body.splice(i,1),i--};if(n)if("ImportDeclaration"==n.type){if(!r)throw new Error("[compile node]: import declaration must use in top.");this.push(utils_1.default.ImportToCache(n)),s()}else if("BlockStatement"==n.type)this.tre(n,o);else{if("BreakStatement"==n.type||"EmptyStatement"==n.type||"ContinueStatement"==n.type||"ThrowStatement"==n.type||"WithStatement"==n.type)continue;if("TryStatement"==n.type)this.tre(n.block,o);else if("IfStatement"==n.type){const e=n.test;this.conditionalInTempImport(e,o,s);const i=[n.consequent];n.alternate&&i.push(n.alternate),this.tre(t.blockStatement(i),o)}else if("WhileStatement"==n.type)this.tre(t.blockStatement([n.body]),o);else if("ClassDeclaration"==n.type){if(n.superClass){const e=n.superClass;let t=null;if("Identifier"==e.type&&(t=e.name),"MemberExpression"==e.type){const i=this.takeInnerMost(e);"Identifier"==i.type&&(t=i.name)}if("ArrayExpression"==e.type||"BooleanLiteral"==e.type||"BinaryExpression"==e.type||"ThisExpression"==e.type||"ArrowFunctionExpression"==e.type||"BigIntLiteral"==e.type||"NumericLiteral"==e.type||"NullLiteral"==e.type||"AssignmentExpression"==e.type||"Super"==e.type||"NewExpression"==e.type||"DoExpression"==e.type||"StringLiteral"==e.type||"YieldExpression"==e.type||"RecordExpression"==e.type||"RegExpLiteral"==e.type||"DecimalLiteral"==e.type||"BindExpression"==e.type)throw new Error("[compilr error]: class can't extends a not constructor or null");t&&this.indexTemp[t]&&this.writeImportKeys.push(t)}}else if("DoWhileStatement"==n.type)this.tre(t.blockStatement([n.body])),this.conditionalInTempImport(n.test,o,s);else if("VariableDeclaration"==n.type){const e=n.declarations;for(const t of e){const e=t.init,i=t.id;if("Identifier"==i.type){if(e||"let"!=n.kind&&"var"!=n.kind||(o[i.name]={status:"wait"}),!e)throw new Error("[compilr node]: 'const' must has a init");o[i.name]=e}}}else if("ReturnStatement"==n.type){const e=n.argument;if(!e)continue;this.conditionalInTempImport(e,o,s)}else if("ExportAllDeclaration"==n.type||"ExportDefaultDeclaration"==n.type||"ExportNamedDeclaration"==n.type){if(!r)throw new Error("[compiler]: export node can't in not top");this.CompileData.BuildCache.export.push(n),s()}else if("SwitchStatement"==n.type){const e=n.discriminant;this.conditionalInTempImport(e,o,s);for(const e of n.cases)e.test&&this.conditionalInTempImport(e.test,o,s),this.tre(t.blockStatement(e.consequent),o)}else if("ExpressionStatement"==n.type)this.conditionalInTempImport(n.expression,o,s);else if("FunctionDeclaration"==n.type){const e=n.body;this.tre(e,o)}}}}run(){if(!t.isBlock(this.node))throw new Error("[compile error]: can't for a not block");this.tre(this.node)}}exports.CompileJS=CompileJS;class CompileMCX{code;constructor(e){this.code=e;const t=new tag_1.default(e).parseAST();if(!tag_1.MCXUtils.isParseNode(t))throw new Error("[compile error]: mcxCompile can't work in a not mcxNode");this.mcxCode=t,this.structureCheck();const i=this.genenrateJSIR();this.CompileData=new CompileData.MCXCompileData(t,i,this.tempLoc)}mcxCode;tempLoc={script:"",Event:{on:"after",subscribe:{}},Component:{}};getCompileData(){return this.CompileData}checkComponentName(e){return Object.values(types_1._MCXstructureLocComponentTypes).includes(e)}checkComponentParentName(e){return Object.keys(types_1._MCXstructureLocComponentTypes).includes(e)}commonTagNodeContent(e){if(tag_1.MCXUtils.isTagContentNode(e))return e.data;if(tag_1.MCXUtils.isTagNode(e))return e.content.map(e=>this.commonTagNodeContent(e)).join("");throw new Error("[mcx compile]: internal error: unknown node type")}getEventOn(e){if(!tag_1.MCXUtils.isTagNode(e))throw new Error("[mcx compile]: internal error: not tag node");let t="after";const i="string"==typeof e.arr["@after"],r="string"==typeof e.arr["@before"];if(i&&r)throw new Error("[mcx compile]: Event node can't has both @after and @before");return i&&(t="after"),r&&(t="before"),t}structureCheck(){let e=null;const t={script:"",Event:null,Component:{}};for(const i of this.mcxCode||[])tag_1.MCXUtils.isTagNode(i)&&("script"==i.name?t.script=0==i.content.length?"":this.commonTagNodeContent(i):"Event"==i.name?t.Event=i:"Component"==i.name&&(e=i));if(!t.script)throw new Error("[compile error]: mcx must has a script");if(this.tempLoc.script=t.script,t.Event){const e=this.getEventOn(t.Event),i=t.Event.content;if(0==i.length||i.length>1||!tag_1.MCXUtils.isTagContentNode(i[0]))throw new Error("[compile error]: Event node has invalid content");const r=i[0].data.trim();this.tempLoc.Event={on:e,subscribe:Object.fromEntries((0,prop_1.default)(r).map(e=>[e.key,e.value.toString()]))}}if(e)for(const t of e.content||[]){if(!tag_1.MCXUtils.isTagNode(t))continue;t.name;this.handlerChildComponent(t)}}handlerChildComponent(e){const t=e.name;if(!this.checkComponentParentName(t))throw new Error(`[compile error]: invalid component name: ${t}`);const i=e.content;if(!i||0==i.length)throw new Error(`[compile error]: component ${t} has no content`);for(const e of i){if(!tag_1.MCXUtils.isTagNode(e))continue;const i=e.name,r=e.arr.id;if(!r||"string"!=typeof r||""==r.trim())throw new Error(`[compile error]: component ${t} child component ${i} has no id`);const o=r.trim(),n=e.content;if(0==n.length)throw new Error(`[compile error]: component ${t} child component ${i} has no content`);if(!n[0]||!tag_1.MCXUtils.isTagContentNode(n[0]))throw new Error(`[compile error]: component ${t} child component ${i} has invalid content`);const s=n[0].data.trim();i==types_1._MCXstructureLocComponentTypes[t]&&(this.tempLoc.Component[`${t}/${o}`]={type:i,useExpore:s})}}CompileData;genenrateJSIR(){if(!this.tempLoc.script.trim())throw new Error("[compile error]: mcx must has a script");return compileJSFn(this.tempLoc.script)}}function compileJSFn(e){const t=new CompileJS((0,parser_1.parse)(e,{sourceType:"module"}).program);return t.run(),t.getCompileData()}function compileMCXFn(e){return new CompileMCX(e).getCompileData()}
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__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 r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=e(t),o=0;o<i.length;o++)"default"!==i[o]&&__createBinding(r,t,i[o]);return __setModuleDefault(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const promises_1=require("node:fs/promises"),Parser=__importStar(require("@babel/parser")),t=__importStar(require("@babel/types"));class Utils{static async FileAST(e,t){if("string"!=typeof e)throw new TypeError("[read file]: compile utils was passed a non-string value");const r=await(0,promises_1.readFile)(e,"utf-8");if("string"!=typeof r)throw new Error("[read file]: not found file "+e);try{return Parser.parse(r).program}catch(e){throw new Error("[compile ast]: "+e.stack)}}static async FileContent(e){return await(0,promises_1.readFile)(e,"utf-8")}static nodeStringValue(e){if("StringLiteral"==e.type)return e.value;if("Identifier"==e.type)return e.name;throw new TypeError("[read id error]: no way to read string id")}static CheckImportNode(e,t){const r=Utils.ImportToCache(e);if(r.source!==t.source)return!1;if(r.imported.length!==t.imported.length)return!1;for(let e=0;e<r.imported.length;e++){const i=r.imported[e],o=t.imported[e];if(i?.import!==o?.import||i?.as!==o?.as||i?.isAll!==o?.isAll)return!1}return!0}static CacheToImportNode(e){if(!e)throw new TypeError("plase call use right ImportList");if(e?.raw&&Utils.CheckImportNode(e?.raw,e))return e.raw;let r=[];for(let i of e.imported)if(i)if(i.isAll)r.push(t.importNamespaceSpecifier(t.identifier(i.as)));else if("default"!=i.import){if(!i.import)throw new TypeError("[compile node]: not found imported");r.push(t.importSpecifier(t.identifier(i.as),t.identifier(i.import)))}else r.push(t.importDefaultSpecifier(t.identifier(i.as)));return t.importDeclaration(r,t.stringLiteral(e.source))}static ImportToCache(e){const t=[];for(let r of e.specifiers){const e=r.local.name;"ImportNamespaceSpecifier"==r.type?t.push({isAll:!0,as:e}):"ImportDefaultSpecifier"==r.type?t.push({isAll:!1,import:"default",as:e}):"ImportSpecifier"==r.type&&t.push({isAll:!1,as:e,import:Utils.nodeStringValue(r.imported)})}return{source:Utils.nodeStringValue(e.source),imported:t}}}exports.default=Utils;
@@ -1,19 +1 @@
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
+ "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,10 +1 @@
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
+ "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,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1,42 +1 @@
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
+ "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,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._MCXstructureLocComponentTypes=void 0,exports._MCXstructureLocComponentTypes={items:"item",blocks:"block",entities:"entity"};