@mbler/mcx-core 0.0.4-beta → 0.0.5-alpha.r20260410.1

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 (36) hide show
  1. package/README.md +2 -19
  2. package/package.json +1 -1
  3. package/dist/index.d.ts +0 -325
  4. package/dist/index.js +0 -2085
  5. package/dist/index.js.map +0 -1
  6. package/dist/types/ast/index.d.ts +0 -7
  7. package/dist/types/ast/prop.d.ts +0 -8
  8. package/dist/types/ast/tag.d.ts +0 -26
  9. package/dist/types/compile-mcx/compile.d.ts +0 -5
  10. package/dist/types/compile-mcx/compiler/compileData.d.ts +0 -20
  11. package/dist/types/compile-mcx/compiler/index.d.ts +0 -33
  12. package/dist/types/compile-mcx/compiler/main.d.ts +0 -4
  13. package/dist/types/compile-mcx/compiler/utils.d.ts +0 -11
  14. package/dist/types/compile-mcx/index.d.ts +0 -3
  15. package/dist/types/compile-mcx/types.d.ts +0 -52
  16. package/dist/types/compile-mcx/utils.node.d.ts +0 -14
  17. package/dist/types/index.d.ts +0 -9
  18. package/dist/types/mcx-component/index.d.ts +0 -2
  19. package/dist/types/mcx-component/lib.d.ts +0 -29
  20. package/dist/types/mcx-component/types.d.ts +0 -44
  21. package/dist/types/mcx-component/utils.d.ts +0 -2
  22. package/dist/types/transforms/config.d.ts +0 -8
  23. package/dist/types/transforms/file_id.d.ts +0 -1
  24. package/dist/types/transforms/index.d.ts +0 -4
  25. package/dist/types/transforms/main.d.ts +0 -2
  26. package/dist/types/transforms/utils.d.ts +0 -22
  27. package/dist/types/transforms/x-comp/index.d.ts +0 -3
  28. package/dist/types/transforms/x-comp/x-app.d.ts +0 -2
  29. package/dist/types/transforms/x-comp/x-event.d.ts +0 -2
  30. package/dist/types/transforms/x-comp/x-ui.d.ts +0 -2
  31. package/dist/types/tsc/index.d.ts +0 -1
  32. package/dist/types/tsc/volar/index.d.ts +0 -1
  33. package/dist/types/tsc/volar/plugins/index.d.ts +0 -1
  34. package/dist/types/tsc/volar/plugins/mcx-file.d.ts +0 -33
  35. package/dist/types/types.d.ts +0 -87
  36. package/dist/types/utils.d.ts +0 -19
package/README.md CHANGED
@@ -1,22 +1,5 @@
1
1
  # mcx
2
2
 
3
- mcx-core mbler mcx 功能的编译器核心,目前在 alpha 阶段。
3
+ ## This is a DSL for build minecraft bedrock script
4
4
 
5
- 本工具基于 typescript 开发,底层模块加载由 rollup 支持由工具 mbler 串起编译流程。
6
- ## 整体架构
7
-
8
- | **npm包名** | **描述** | **完成度(%)** |
9
- |-----------------------|------------------------------|---------|
10
- | **@mbler/mcx** | 为用户提供的typescript类型包 | 0 |
11
- | **@mbler/mcx-core** | mcx核心编译器啥的代码 | 10 |
12
- | **@mbler/mcx-types** | 提供类型 | 10 |
13
- | **@mbler/mcx-compat** | mcx检查器规则,主要适配不一样的minecraft版本 | 0 |
14
- | **mbler** | 核心脚手架,把这些东西组装成一个方便使用的cli工具 | 90 |
15
-
16
- ## 加入开发
17
-
18
- 前往作者QQ : 3915264929
19
-
20
- ## 文档(没写完)
21
-
22
- **[这里](https://mbler-docs.ruanhor.dpdns.org/guide/mcx)**
5
+ Docs **[see this](https://mbler-docs.ruanhor.dpdns.org/guide/mcx)**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbler/mcx-core",
3
- "version": "0.0.4-beta",
3
+ "version": "0.0.5-alpha.r20260410.1",
4
4
  "description": "a DSL compiler of mcx",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/dist/index.d.ts DELETED
@@ -1,325 +0,0 @@
1
- import { TransformPluginContext, Plugin } from 'rollup';
2
- import * as t from '@babel/types';
3
- import { Expression, CallExpression, SpreadElement, ArgumentPlaceholder, ImportDeclaration, ExportNamedDeclaration, ExportAllDeclaration, ExportDefaultDeclaration } from '@babel/types';
4
- import { CompileOpt } from '@mbler/mcx-types';
5
- import { VirtualCode, CodeMapping, LanguagePlugin } from '@volar/language-core';
6
- import * as ts from 'typescript';
7
- import { URI } from 'vscode-uri';
8
-
9
- interface callList {
10
- source: Expression;
11
- set: (callEXp: CallExpression) => boolean;
12
- arguments: Array<SpreadElement | Expression | ArgumentPlaceholder>;
13
- remove: () => void;
14
- }
15
- interface ImportListImport {
16
- isAll: boolean;
17
- import?: string | undefined;
18
- as: string;
19
- }
20
- interface ImportList {
21
- source: string;
22
- imported: ImportListImport[];
23
- raw?: ImportDeclaration;
24
- }
25
- interface BuildCache {
26
- call: callList[];
27
- import: ImportList[];
28
- export: Array<ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration>;
29
- }
30
- declare const _MCXstructureLocComponentTypes: {
31
- readonly items: "item";
32
- readonly blocks: "block";
33
- readonly entities: "entity";
34
- };
35
- type MCXstructureLocComponentType = typeof _MCXstructureLocComponentTypes[keyof typeof _MCXstructureLocComponentTypes];
36
- interface MCXstructureLoc {
37
- script: string;
38
- Event: {
39
- on: "after" | "before";
40
- subscribe: Record<string, string>;
41
- loc: {
42
- line: number;
43
- column: number;
44
- };
45
- isLoad: boolean;
46
- };
47
- Component: Record<string, {
48
- type: MCXstructureLocComponentType;
49
- useExpore: string;
50
- loc: {
51
- line: number;
52
- column: number;
53
- };
54
- }>;
55
- UI: ParsedTagNode | null;
56
- }
57
-
58
- declare class JsCompileData {
59
- node: t.Program;
60
- BuildCache: BuildCache;
61
- File: string;
62
- isFile: boolean;
63
- constructor(node: t.Program, BuildCache?: BuildCache);
64
- setFilePath(dir: string): void;
65
- }
66
- declare class MCXCompileData {
67
- raw: ParsedTagNode[];
68
- JSIR: JsCompileData;
69
- strLoc: MCXstructureLoc;
70
- File: string;
71
- isFile: boolean;
72
- constructor(raw: ParsedTagNode[], JSIR: JsCompileData, strLoc: MCXstructureLoc);
73
- setFilePath(dir: string): void;
74
- }
75
-
76
- interface BaseToken {
77
- data: string;
78
- type: TokenType;
79
- start: MCXPosition;
80
- end: MCXPosition;
81
- }
82
- interface TagToken extends BaseToken {
83
- type: 'Tag';
84
- }
85
- interface TagEndToken extends BaseToken {
86
- type: 'TagEnd';
87
- }
88
- interface ContentToken extends BaseToken {
89
- type: 'Content';
90
- }
91
- type Token = TagToken | TagEndToken | ContentToken;
92
- type AttributeMap = Record<string, string | boolean>;
93
- /** 统一的位置信息结构 */
94
- interface MCXPosition {
95
- line: number;
96
- column: number;
97
- }
98
- interface MCXLoc {
99
- start: MCXPosition;
100
- end: MCXPosition;
101
- }
102
- interface ParsedTagNode {
103
- start: TagToken;
104
- name: string;
105
- arr: AttributeMap;
106
- content: (ParsedTagContentNode | ParsedTagNode)[];
107
- end: TagEndToken | null;
108
- loc: MCXLoc;
109
- type: "TagNode";
110
- }
111
- interface ParsedTagContentNode {
112
- data: string;
113
- type: 'TagContent';
114
- }
115
- type TokenType = 'Tag' | 'TagEnd' | 'Content';
116
- type PropValue = number | string | object;
117
- interface PropNode {
118
- key: string;
119
- value: PropValue;
120
- type: "PropChar" | "PropObject";
121
- }
122
- type JsType = "boolean" | "number" | "string" | "object" | "function" | "bigint" | "symbol";
123
- interface TypeVerifyBody {
124
- [key: string]: JsType;
125
- }
126
- interface ParseReadFileOpt {
127
- delay: number;
128
- maxRetries: number;
129
- want: 'string' | 'object';
130
- }
131
- type ReadFileOpt = Partial<ParseReadFileOpt>;
132
- type mcxType = "component" | "event" | "app" | "ui";
133
-
134
- interface transformCtx {
135
- rollupContext: TransformPluginContext;
136
- compiledCode: MCXCompileData;
137
- cache: Map<string, MCXCompileData>;
138
- currentId: string;
139
- scriptTag: ParsedTagNode;
140
- currentAST: t.Program;
141
- mainFn: {
142
- param: t.FunctionParameter[];
143
- body: t.Statement[];
144
- };
145
- impAST: t.ImportDeclaration[];
146
- opt: CompileOpt;
147
- }
148
- interface transformParseCtx {
149
- prop: t.ObjectProperty[];
150
- impBody: t.ImportDeclaration[];
151
- mainFn: t.Statement[];
152
- ctx: transformCtx;
153
- app: ((data: t.ObjectProperty[]) => void) & {
154
- prototype: {
155
- enable: t.ObjectProperty[] | null;
156
- };
157
- };
158
- }
159
-
160
- type types_AttributeMap = AttributeMap;
161
- type types_BaseToken = BaseToken;
162
- type types_ContentToken = ContentToken;
163
- type types_JsType = JsType;
164
- type types_MCXLoc = MCXLoc;
165
- type types_MCXPosition = MCXPosition;
166
- type types_ParseReadFileOpt = ParseReadFileOpt;
167
- type types_ParsedTagContentNode = ParsedTagContentNode;
168
- type types_ParsedTagNode = ParsedTagNode;
169
- type types_PropNode = PropNode;
170
- type types_PropValue = PropValue;
171
- type types_ReadFileOpt = ReadFileOpt;
172
- type types_TagEndToken = TagEndToken;
173
- type types_TagToken = TagToken;
174
- type types_Token = Token;
175
- type types_TokenType = TokenType;
176
- type types_TypeVerifyBody = TypeVerifyBody;
177
- type types_mcxType = mcxType;
178
- type types_transformCtx = transformCtx;
179
- type types_transformParseCtx = transformParseCtx;
180
- declare namespace types {
181
- export type { types_AttributeMap as AttributeMap, types_BaseToken as BaseToken, types_ContentToken as ContentToken, types_JsType as JsType, types_MCXLoc as MCXLoc, types_MCXPosition as MCXPosition, types_ParseReadFileOpt as ParseReadFileOpt, types_ParsedTagContentNode as ParsedTagContentNode, types_ParsedTagNode as ParsedTagNode, types_PropNode as PropNode, types_PropValue as PropValue, types_ReadFileOpt as ReadFileOpt, types_TagEndToken as TagEndToken, types_TagToken as TagToken, types_Token as Token, types_TokenType as TokenType, types_TypeVerifyBody as TypeVerifyBody, types_mcxType as mcxType, types_transformCtx as transformCtx, types_transformParseCtx as transformParseCtx };
182
- }
183
-
184
- declare class McxAst {
185
- private text;
186
- constructor(text: string);
187
- private getAST;
188
- get data(): ParsedTagNode[];
189
- parseAST(): ParsedTagNode[];
190
- /**
191
- * 生成代码字符串(递归处理 content 数组)
192
- * @param node 要生成代码的AST节点
193
- * @returns 生成的代码字符串
194
- */
195
- static generateCode(node: ParsedTagNode): string;
196
- }
197
-
198
- declare function PropParser(code: string): PropNode[];
199
-
200
- declare const _default: {
201
- tag: typeof McxAst;
202
- prop: typeof PropParser;
203
- };
204
-
205
- declare function mcxPlugn(opt: CompileOpt): Plugin;
206
-
207
- declare function CompileMcxDir(BuildOpt: CompileOpt): Promise<void>;
208
-
209
- declare class McxUtlis {
210
- /**
211
- * 检查文件是否存在
212
- * @param path 文件路径
213
- * @returns 是否存在
214
- */
215
- static FileExsit(path: string): Promise<boolean>;
216
- /**
217
- * 读取文件内容,支持返回 string 或 object,带重试机制
218
- * @param filePath 文件路径
219
- * @param opt 配置选项
220
- * @returns 文件内容(string | object),出错时返回 {}
221
- */
222
- static readFile(filePath: string, opt?: ReadFileOpt): Promise<object | string>;
223
- static sleep(time: number): Promise<void>;
224
- static TypeVerify(obj: any, types: TypeVerifyBody): boolean;
225
- static AbsoluteJoin(baseDir: string, inputPath: string): string;
226
- }
227
-
228
- declare class CompileError extends Error {
229
- loc: {
230
- line: number;
231
- column: number;
232
- };
233
- constructor(message: string, loc: {
234
- line: number;
235
- column: number;
236
- });
237
- }
238
- type Context = Record<string, t.Expression | {
239
- status: "wait";
240
- }>;
241
- declare class CompileJS {
242
- node: t.Program;
243
- constructor(node: t.Program);
244
- TopContext: Context;
245
- private indexTemp;
246
- private push;
247
- private takeInnerMost;
248
- private writeImportKeys;
249
- private extractIdentifierNames;
250
- private writeBuildCache;
251
- private CompileData;
252
- getCompileData(): JsCompileData;
253
- private conditionalInTempImport;
254
- private tre;
255
- run(): void;
256
- }
257
- declare function compileJSFn(code: string): JsCompileData;
258
- declare function compileMCXFn(mcxCode: string): MCXCompileData;
259
-
260
- type index$2_CompileError = CompileError;
261
- declare const index$2_CompileError: typeof CompileError;
262
- type index$2_CompileJS = CompileJS;
263
- declare const index$2_CompileJS: typeof CompileJS;
264
- type index$2_Context = Context;
265
- declare const index$2_compileJSFn: typeof compileJSFn;
266
- declare const index$2_compileMCXFn: typeof compileMCXFn;
267
- declare namespace index$2 {
268
- export { index$2_CompileError as CompileError, index$2_CompileJS as CompileJS, index$2_compileJSFn as compileJSFn, index$2_compileMCXFn as compileMCXFn };
269
- export type { index$2_Context as Context };
270
- }
271
-
272
- declare function compileComponent(compiledCode: MCXCompileData, project: string): Promise<void>;
273
-
274
- declare const index$1_compileComponent: typeof compileComponent;
275
- declare namespace index$1 {
276
- export {
277
- index$1_compileComponent as compileComponent,
278
- };
279
- }
280
-
281
- declare function transform(code: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt): Promise<string>;
282
-
283
- /**
284
- * MCX Volar TSC 插件
285
- * 为 MCX 文件提供 TypeScript 智能感知支持
286
- */
287
- declare const mcxVolarTscPlugin: LanguagePlugin<URI>;
288
- /**
289
- * MCX 虚拟代码
290
- * 用于在 Volar 中表示 MCX 文件的内容
291
- */
292
- declare class MCXVirtualCode implements VirtualCode {
293
- snapshot: ts.IScriptSnapshot;
294
- id: string;
295
- languageId: string;
296
- mappings: CodeMapping[];
297
- embeddedCodes: VirtualCode[];
298
- constructor(snapshot: ts.IScriptSnapshot, id?: string);
299
- /**
300
- * 从 MCX 文件中提取 script 标签内容
301
- */
302
- private extractScriptContent;
303
- /**
304
- * 计算 script 内容在源文件中的起始偏移量
305
- */
306
- private calculateScriptOffset;
307
- }
308
- /**
309
- * 创建 MCX 虚拟代码实例
310
- */
311
- declare function createMCXVirtualCode(snapshot: ts.IScriptSnapshot, id?: string): VirtualCode;
312
-
313
- type index_MCXVirtualCode = MCXVirtualCode;
314
- declare const index_MCXVirtualCode: typeof MCXVirtualCode;
315
- declare const index_createMCXVirtualCode: typeof createMCXVirtualCode;
316
- declare const index_mcxVolarTscPlugin: typeof mcxVolarTscPlugin;
317
- declare namespace index {
318
- export {
319
- index_MCXVirtualCode as MCXVirtualCode,
320
- index_createMCXVirtualCode as createMCXVirtualCode,
321
- index_mcxVolarTscPlugin as mcxVolarTscPlugin,
322
- };
323
- }
324
-
325
- export { _default as AST, index$2 as Compiler, types as PUBTYPE, index as TSC, CompileMcxDir as compile, index$1 as compile_component, mcxPlugn as plugin, transform, McxUtlis as utils };