@mbler/mcx-core 0.1.2-rc.9 → 0.1.3-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -40
- package/dist/chunk-6Ep1yQYe.js +16 -0
- package/dist/chunk-D0rfrjR5.js +21 -0
- package/dist/index.d.ts +8 -11
- package/dist/index.js +508 -377
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/client.d.ts +0 -17
package/README.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# @mbler/mcx-core
|
|
2
|
-
|
|
3
|
-
The MCX DSL compiler — the core of the MCX ecosystem. Compiles `.mcx` source files into MCBE-compatible JSON components, UI forms, and event systems.
|
|
4
|
-
|
|
5
|
-
## Pipeline
|
|
6
|
-
|
|
7
|
-
`.mcx` file → **parser** → AST → **transform** (Babel) → compiled JS → MCBE JSON
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **MCX Parser** — Parses `.mcx` source into a tokenized AST (`tag`, `prop`)
|
|
12
|
-
- **Transform Pipeline** — Detects file type (`event`, `ui`, `component`, `app`) and generates compiled Babel AST
|
|
13
|
-
- **Component Compilation** — Runs component scripts in a sandboxed VM, generates MCBE JSON, executes file edit operations
|
|
14
|
-
- **CJS Transform** — Rewrites ESM imports to CommonJS `require()` for VM execution
|
|
15
|
-
- **Image Assets** — Compiles PNG, JPG, SVG, GIF image references into MCBE texture assets
|
|
16
|
-
- **Rollup/Rolldown Plugin** — Seamless `.mcx` file resolution and transformation in your build pipeline
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pnpm add -D @mbler/mcx-core
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
Add the plugin to your Rollup or Rolldown config:
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
import { rollupPlugin } from '@mbler/mcx-core'
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
plugins: [rollupPlugin({ moduleDir: './modules', tsconfigPath: './tsconfig.json' })],
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
For full documentation, visit the **[Docs](https://mbler-docs.ruanhor.dpdns.org/guide/mcx)**.
|
|
37
|
-
|
|
38
|
-
## License
|
|
39
|
-
|
|
40
|
-
MIT
|
|
1
|
+
# @mbler/mcx-core
|
|
2
|
+
|
|
3
|
+
The MCX DSL compiler — the core of the MCX ecosystem. Compiles `.mcx` source files into MCBE-compatible JSON components, UI forms, and event systems.
|
|
4
|
+
|
|
5
|
+
## Pipeline
|
|
6
|
+
|
|
7
|
+
`.mcx` file → **parser** → AST → **transform** (Babel) → compiled JS → MCBE JSON
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **MCX Parser** — Parses `.mcx` source into a tokenized AST (`tag`, `prop`)
|
|
12
|
+
- **Transform Pipeline** — Detects file type (`event`, `ui`, `component`, `app`) and generates compiled Babel AST
|
|
13
|
+
- **Component Compilation** — Runs component scripts in a sandboxed VM, generates MCBE JSON, executes file edit operations
|
|
14
|
+
- **CJS Transform** — Rewrites ESM imports to CommonJS `require()` for VM execution
|
|
15
|
+
- **Image Assets** — Compiles PNG, JPG, SVG, GIF image references into MCBE texture assets
|
|
16
|
+
- **Rollup/Rolldown Plugin** — Seamless `.mcx` file resolution and transformation in your build pipeline
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add -D @mbler/mcx-core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Add the plugin to your Rollup or Rolldown config:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { rollupPlugin } from '@mbler/mcx-core'
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
plugins: [rollupPlugin({ moduleDir: './modules', tsconfigPath: './tsconfig.json' })],
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For full documentation, visit the **[Docs](https://mbler-docs.ruanhor.dpdns.org/guide/mcx)**.
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { __exportAll as n, __require as r, __commonJSMin as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) {
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (!no_symbols) {
|
|
14
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __require as n, __exportAll as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { ArgumentPlaceholder, CallExpression, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, Expression, ImportDeclaration, SpreadElement } from "@babel/types";
|
|
3
3
|
import * as Parser from "@babel/parser";
|
|
4
|
-
import { BlockComponent, BlockComponent as BlockComponent$1, EnchantableSlot, EntityComponent, EntityComponent as EntityComponent$1, EntityComponentOptions, FoodEffect, GIFImageComponent, GIFImageComponent as GIFImageComponent$1, ItemComponent, ItemComponent as ItemComponent$1, ItemComponentOptions, JPGImageComponent, JPGImageComponent as JPGImageComponent$1, PNGImageComponent, PNGImageComponent as PNGImageComponent$1, ParticleType, Rarity, SVGImageComponent, SVGImageComponent as SVGImageComponent$1, SoundEvent } from "@mbler/mcx-component";
|
|
5
4
|
import { Plugin, TransformPluginContext } from "rollup";
|
|
6
5
|
import { CompileOpt, CompileOpt as CompileOpt$1 } from "@mbler/mcx-types";
|
|
7
6
|
import { Plugin as Plugin$1 } from "rolldown";
|
|
7
|
+
import { EnchantableSlot, EntityComponentOptions, FoodEffect, ItemComponentOptions, ParticleType, Rarity, SoundEvent } from "@mbler/mcx-component";
|
|
8
8
|
|
|
9
9
|
//#region src/compile-mcx/types.d.ts
|
|
10
10
|
interface callList {
|
|
@@ -54,6 +54,7 @@ interface MCXstructureLoc {
|
|
|
54
54
|
};
|
|
55
55
|
}>;
|
|
56
56
|
UI: ParsedTagNode | null;
|
|
57
|
+
Form: ParsedTagNode | null;
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region src/compile-mcx/compiler/compileData.d.ts
|
|
@@ -141,7 +142,7 @@ interface ParseReadFileOpt {
|
|
|
141
142
|
want: 'string' | 'object';
|
|
142
143
|
}
|
|
143
144
|
type ReadFileOpt = Partial<ParseReadFileOpt>;
|
|
144
|
-
type mcxType = 'component' | 'event' | 'app' | 'ui';
|
|
145
|
+
type mcxType = 'component' | 'event' | 'app' | 'ui' | 'form';
|
|
145
146
|
interface transformCtx {
|
|
146
147
|
rollupContext: TransformPluginContext;
|
|
147
148
|
compiledCode: MCXCompileData;
|
|
@@ -178,14 +179,10 @@ declare class McxAst {
|
|
|
178
179
|
private text;
|
|
179
180
|
private includeComments;
|
|
180
181
|
constructor(text: string, includeComments?: boolean);
|
|
181
|
-
private getAST;
|
|
182
|
-
get data(): ParsedTagNode[];
|
|
183
182
|
parseAST(): ParsedTagNode[];
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* @returns 代码字符串
|
|
188
|
-
*/
|
|
183
|
+
private convertTemplateChild;
|
|
184
|
+
private convertVueElement;
|
|
185
|
+
private convertVueChildren;
|
|
189
186
|
static generateCode(node: ParsedTagNode): string;
|
|
190
187
|
}
|
|
191
188
|
//#endregion
|
|
@@ -345,7 +342,7 @@ declare class RunScript {
|
|
|
345
342
|
static isCanUseEsmRunVm: boolean;
|
|
346
343
|
}
|
|
347
344
|
declare namespace index_d_exports {
|
|
348
|
-
export {
|
|
345
|
+
export { RunScript, clearCachedOptions, compileComponent, execESMMethod, execEdit, generateItemTextureJson, resolveFilePoint, transformESMToCJS };
|
|
349
346
|
}
|
|
350
347
|
/** Clear all cached bind options (called between builds). */
|
|
351
348
|
declare function clearCachedOptions(): void;
|
|
@@ -397,5 +394,5 @@ declare function compileComponent(compiledCode: MCXCompileData, ctx: transformCt
|
|
|
397
394
|
//#region src/transforms/index.d.ts
|
|
398
395
|
declare function transform(code: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt, output: transformCtx['output']): Promise<string>;
|
|
399
396
|
//#endregion
|
|
400
|
-
export { _default as AST,
|
|
397
|
+
export { _default as AST, types_d_exports as ComponentType, types_d_exports$1 as PubType, index_d_exports as compile_component, index_d_exports$1 as compiler, rolldownPlugin, rollupPlugin, transform, Utils as utils };
|
|
401
398
|
//# sourceMappingURL=index.d.ts.map
|