@mbler/mcx-core 0.1.0 → 0.1.1-beta.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 (32) hide show
  1. package/dist/index.d.ts +4569 -4403
  2. package/dist/index.js +4326 -3274
  3. package/dist/index.js.map +1 -1
  4. package/dist/types/ast/index.d.ts +2 -2
  5. package/dist/types/ast/prop.d.ts +1 -1
  6. package/dist/types/ast/tag.d.ts +1 -1
  7. package/dist/types/compile-mcx/compiler/compileData.d.ts +3 -3
  8. package/dist/types/compile-mcx/compiler/index.d.ts +11 -11
  9. package/dist/types/compile-mcx/compiler/utils.d.ts +3 -3
  10. package/dist/types/compile-mcx/index.d.ts +1 -1
  11. package/dist/types/compile-mcx/types.d.ts +6 -6
  12. package/dist/types/compile-mcx/utils.node.d.ts +6 -6
  13. package/dist/types/index.d.ts +9 -9
  14. package/dist/types/mcx-component/components/entity.d.ts +12 -12
  15. package/dist/types/mcx-component/components/item.d.ts +91 -4
  16. package/dist/types/mcx-component/index.d.ts +16 -4
  17. package/dist/types/mcx-component/lib.d.ts +4 -4
  18. package/dist/types/mcx-component/types/EnchantableSlot.d.ts +1 -1
  19. package/dist/types/mcx-component/types/ParticleType.d.ts +1 -1
  20. package/dist/types/mcx-component/types/SoundEvent.d.ts +1 -1
  21. package/dist/types/mcx-component/types.d.ts +242 -163
  22. package/dist/types/mcx-component/vm.d.ts +1 -1
  23. package/dist/types/transforms/index.d.ts +5 -5
  24. package/dist/types/transforms/main.d.ts +1 -1
  25. package/dist/types/transforms/utils.d.ts +4 -4
  26. package/dist/types/transforms/x-comp/index.d.ts +3 -3
  27. package/dist/types/transforms/x-comp/x-app.d.ts +1 -1
  28. package/dist/types/transforms/x-comp/x-event.d.ts +1 -1
  29. package/dist/types/transforms/x-comp/x-ui.d.ts +1 -1
  30. package/dist/types/types.d.ts +9 -9
  31. package/dist/types/utils.d.ts +1 -12
  32. package/package.json +7 -2
@@ -5,7 +5,7 @@ export declare enum execESMMethod {
5
5
  importESM = 2
6
6
  }
7
7
  /**
8
- * ESM 模块转换为 CJS 格式
8
+ * ESM => CJS
9
9
  */
10
10
  declare function transformESMToCJS(code: string, pluginContext?: Record<string, string | null | boolean | number>, hook?: (data: t.CallExpression | t.MemberExpression, setData?: (newData: t.Expression) => void) => void): string;
11
11
  export declare class RunScript {
@@ -1,5 +1,5 @@
1
- import { TransformPluginContext } from "rollup";
2
- import { MCXCompileData } from "../compile-mcx/compiler/compileData";
3
- import { CompileOpt } from "@mbler/mcx-types";
4
- import { transformCtx } from "../types";
5
- export declare function transform(code: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt, output: transformCtx["output"]): Promise<string>;
1
+ import { TransformPluginContext } from 'rollup';
2
+ import { MCXCompileData } from '../compile-mcx/compiler/compileData';
3
+ import { CompileOpt } from '@mbler/mcx-types';
4
+ import { transformCtx } from '../types';
5
+ export declare function transform(code: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt, output: transformCtx['output']): Promise<string>;
@@ -1,2 +1,2 @@
1
- import { transformCtx } from "../types";
1
+ import { transformCtx } from '../types';
2
2
  export declare function _transform(ctx: transformCtx): Promise<string>;
@@ -1,6 +1,6 @@
1
- import * as t from "@babel/types";
2
- import { JsCompileData } from "../compile-mcx/compiler/compileData";
3
- import { ParsedTagNode, transformCtx } from "../types";
1
+ import * as t from '@babel/types';
2
+ import { JsCompileData } from '../compile-mcx/compiler/compileData';
3
+ import { ParsedTagNode, transformCtx } from '../types';
4
4
  declare function extrectVarDefIdList(express: t.LVal | t.VoidPattern): string[];
5
5
  declare function extractIdList(expression: t.Declaration): string[];
6
6
  declare function generateMain(code: JsCompileData): [t.Statement[], t.ImportDeclaration[]];
@@ -19,4 +19,4 @@ declare function _enableWithData<T>(): ((data: T) => void) & {
19
19
  enable: T | null;
20
20
  };
21
21
  };
22
- export { extractIdList, extrectVarDefIdList, generateEventConfig, _enable, generateMain, _enableWithData };
22
+ export { extractIdList, extrectVarDefIdList, generateEventConfig, _enable, generateMain, _enableWithData, };
@@ -1,3 +1,3 @@
1
- export { Comp as UIComp } from "./x-ui";
2
- export { Comp as EventComp } from "./x-event";
3
- export { Comp as AppComp } from "./x-app";
1
+ export { Comp as UIComp } from './x-ui';
2
+ export { Comp as EventComp } from './x-event';
3
+ export { Comp as AppComp } from './x-app';
@@ -1,2 +1,2 @@
1
- import { transformParseCtx } from "../../types";
1
+ import { transformParseCtx } from '../../types';
2
2
  export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { transformParseCtx } from "../../types";
1
+ import { transformParseCtx } from '../../types';
2
2
  export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { transformParseCtx } from "../../types";
1
+ import { transformParseCtx } from '../../types';
2
2
  export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -1,7 +1,7 @@
1
- import { TransformPluginContext } from "rollup";
2
- import type { MCXCompileData } from "./compile-mcx/compiler/compileData";
3
- import { CompileOpt } from "@mbler/mcx-types";
4
- import * as t from "@babel/types";
1
+ import { TransformPluginContext } from 'rollup';
2
+ import type { MCXCompileData } from './compile-mcx/compiler/compileData';
3
+ import { CompileOpt } from '@mbler/mcx-types';
4
+ import * as t from '@babel/types';
5
5
  interface BaseToken {
6
6
  data: string;
7
7
  type: TokenType;
@@ -38,7 +38,7 @@ interface ParsedTagNode {
38
38
  content: (ParsedTagContentNode | ParsedTagNode | ParsedCommentNode)[];
39
39
  end: TagEndToken | null;
40
40
  loc: MCXLoc;
41
- type: "TagNode";
41
+ type: 'TagNode';
42
42
  }
43
43
  interface ParsedTagContentNode {
44
44
  data: string;
@@ -54,9 +54,9 @@ type PropValue = number | string | object;
54
54
  interface PropNode {
55
55
  key: string;
56
56
  value: PropValue;
57
- type: "PropChar" | "PropObject";
57
+ type: 'PropChar' | 'PropObject';
58
58
  }
59
- type JsType = "boolean" | "number" | "string" | "object" | "function" | "bigint" | "symbol";
59
+ type JsType = 'boolean' | 'number' | 'string' | 'object' | 'function' | 'bigint' | 'symbol';
60
60
  interface TypeVerifyBody {
61
61
  [key: string]: JsType;
62
62
  }
@@ -66,8 +66,8 @@ export interface ParseReadFileOpt {
66
66
  want: 'string' | 'object';
67
67
  }
68
68
  export type ReadFileOpt = Partial<ParseReadFileOpt>;
69
- export type mcxType = "component" | "event" | "app" | "ui";
70
- export type { Token, ContentToken, TagEndToken, TagToken, CommentToken, BaseToken, AttributeMap, PropValue, TokenType, ParsedTagContentNode, ParsedCommentNode, TypeVerifyBody, JsType, PropNode, ParsedTagNode, MCXLoc, MCXPosition };
69
+ export type mcxType = 'component' | 'event' | 'app' | 'ui';
70
+ export type { Token, ContentToken, TagEndToken, TagToken, CommentToken, BaseToken, AttributeMap, PropValue, TokenType, ParsedTagContentNode, ParsedCommentNode, TypeVerifyBody, JsType, PropNode, ParsedTagNode, MCXLoc, MCXPosition, };
71
71
  export interface transformCtx {
72
72
  rollupContext: TransformPluginContext;
73
73
  compiledCode: MCXCompileData;
@@ -1,17 +1,6 @@
1
1
  import type { ReadFileOpt, TypeVerifyBody } from './types.js';
2
- export default class McxUtlis {
3
- /**
4
- * 检查文件是否存在
5
- * @param path 文件路径
6
- * @returns 是否存在
7
- */
2
+ export default class Utlis {
8
3
  static FileExsit(path: string): Promise<boolean>;
9
- /**
10
- * 读取文件内容,支持返回 string 或 object,带重试机制
11
- * @param filePath 文件路径
12
- * @param opt 配置选项
13
- * @returns 文件内容(string | object),出错时返回 {}
14
- */
15
4
  static readFile(filePath: string, opt?: ReadFileOpt): Promise<object | string>;
16
5
  static sleep(time: number): Promise<void>;
17
6
  static TypeVerify<T extends Record<string, any>, U extends TypeVerifyBody>(obj: T, types: U): obj is T & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbler/mcx-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-beta.r2",
4
4
  "description": "a DSL compiler of mcx",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [
@@ -18,6 +18,11 @@
18
18
  "types": "./client.d.ts"
19
19
  }
20
20
  },
21
+ "repository": {
22
+ "directory": "/packages/core",
23
+ "type": "git",
24
+ "url": "https://github.com/RuanhoR/mcx-core"
25
+ },
21
26
  "dependencies": {
22
27
  "@babel/generator": "7.28.5",
23
28
  "@babel/parser": "7.28.5",
@@ -27,7 +32,7 @@
27
32
  "rollup": "4.59.0",
28
33
  "rolldown": "1.0.0-rc.18",
29
34
  "typescript": "5.9.3",
30
- "@mbler/mcx-types": "0.0.3-rc.4"
35
+ "@mbler/mcx-types": "0.0.4"
31
36
  },
32
37
  "module": "commjs",
33
38
  "files": [