@mbler/mcx-core 0.0.2 → 0.0.3-alpha.r20260311

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.
@@ -1,4 +1,4 @@
1
+ import { TransformPluginContext } from "rollup";
1
2
  import { MCXCompileData } from "../compile-mcx/compiler/compileData";
2
- import { CompileOpt } from "../compile-mcx/types";
3
- import type { TransformPluginContext } from "rollup";
4
- export declare function transform(compileData: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt): Promise<string>;
3
+ import { CompileOpt } from "@mbler/mcx-types";
4
+ export declare function transform(code: MCXCompileData, cache: Map<string, MCXCompileData>, id: string, context: TransformPluginContext, opt: CompileOpt): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import { transformCtx } from "../types";
2
+ export declare function _transform(ctx: transformCtx): Promise<string>;
@@ -1,7 +1,22 @@
1
1
  import * as t from "@babel/types";
2
2
  import { JsCompileData } from "../compile-mcx/compiler/compileData";
3
- declare const allKeys: (node: t.Declaration) => string[];
4
- export declare const generateTempId: () => string;
5
- declare function generateMain(JSIR: JsCompileData): [...t.ImportDeclaration[], t.VariableDeclaration];
6
- declare function DeclarationToExpression(node: t.FunctionDeclaration | t.ClassDeclaration | t.TSDeclareFunction): t.Expression;
7
- export { DeclarationToExpression, generateMain, allKeys };
3
+ import { ParsedTagNode, transformCtx } from "../types";
4
+ declare function extrectVarDefIdList(express: t.LVal | t.VoidPattern): string[];
5
+ declare function extractIdList(expression: t.Declaration): string[];
6
+ declare function generateMain(code: JsCompileData): [t.Statement[], t.ImportDeclaration[]];
7
+ declare function generateEventConfig(eventTag: ParsedTagNode, ctx: transformCtx, impBody: t.ImportDeclaration[]): Promise<t.ObjectExpression>;
8
+ /**
9
+ * record enable
10
+ * @returns {(): void} - only call one
11
+ */
12
+ declare function _enable(): (() => void) & {
13
+ prototype: {
14
+ enable: boolean;
15
+ };
16
+ };
17
+ declare function _enableWithData<T extends any>(): ((data: T) => void) & {
18
+ prototype: {
19
+ enable: T | null;
20
+ };
21
+ };
22
+ export { extractIdList, extrectVarDefIdList, generateEventConfig, _enable, generateMain, _enableWithData };
@@ -0,0 +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";
@@ -0,0 +1,2 @@
1
+ import { transformParseCtx } from "../../types";
2
+ export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { transformParseCtx } from "../../types";
2
+ export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { transformParseCtx } from "../../types";
2
+ export declare function Comp(ctx: transformParseCtx): Promise<void>;
@@ -1,3 +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
5
  interface BaseToken {
2
6
  data: string;
3
7
  type: TokenType;
@@ -34,6 +38,7 @@ interface ParsedTagNode {
34
38
  content: (ParsedTagContentNode | ParsedTagNode)[];
35
39
  end: TagEndToken | null;
36
40
  loc: MCXLoc;
41
+ type: "TagNode";
37
42
  }
38
43
  interface ParsedTagContentNode {
39
44
  data: string;
@@ -56,5 +61,30 @@ export interface ParseReadFileOpt {
56
61
  want: 'string' | 'object';
57
62
  }
58
63
  export type ReadFileOpt = Partial<ParseReadFileOpt>;
59
- export type mcxType = "component" | "event" | "app";
64
+ export type mcxType = "component" | "event" | "app" | "ui";
60
65
  export type { Token, ContentToken, TagEndToken, TagToken, BaseToken, AttributeMap, PropValue, TokenType, ParsedTagContentNode, TypeVerifyBody, JsType, PropNode, ParsedTagNode, MCXLoc };
66
+ export interface transformCtx {
67
+ rollupContext: TransformPluginContext;
68
+ compiledCode: MCXCompileData;
69
+ cache: Map<string, MCXCompileData>;
70
+ currentId: string;
71
+ scriptTag: ParsedTagNode;
72
+ currentAST: t.Program;
73
+ mainFn: {
74
+ param: t.FunctionParameter[];
75
+ body: t.Statement[];
76
+ };
77
+ impAST: t.ImportDeclaration[];
78
+ opt: CompileOpt;
79
+ }
80
+ export interface transformParseCtx {
81
+ prop: t.ObjectProperty[];
82
+ impBody: t.ImportDeclaration[];
83
+ mainFn: t.Statement[];
84
+ ctx: transformCtx;
85
+ app: ((data: t.ObjectProperty[]) => void) & {
86
+ prototype: {
87
+ enable: t.ObjectProperty[] | null;
88
+ };
89
+ };
90
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@mbler/mcx-core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-alpha.r20260311",
4
4
  "description": "a DSL compiler of mcx",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "cd __test__ && npm run test",
8
- "build": "rollup -c"
8
+ "build": "rollup -c",
9
+ "publish": "BUILD_MODULE=release rollup -c && npm publish"
9
10
  },
10
11
  "keywords": [
11
12
  "compiler",
@@ -16,12 +17,7 @@
16
17
  "@babel/generator": "7.28.5",
17
18
  "@babel/parser": "7.28.5",
18
19
  "@babel/types": "7.28.6",
19
- "@rollup/plugin-commonjs": "^29.0.0",
20
- "@rollup/plugin-json": "^6.1.0",
21
- "@rollup/plugin-node-resolve": "^16.0.3",
22
- "@rollup/plugin-typescript": "^12.3.0",
23
- "magic-string": "^0.30.21",
24
- "rollup": "^4.57.1"
20
+ "magic-string": "0.30.21"
25
21
  },
26
22
  "module": "commjs",
27
23
  "files": [
@@ -38,9 +34,16 @@
38
34
  "license": "MIT",
39
35
  "devDependencies": {
40
36
  "@mbler/mcx-types": "latest",
41
- "@types/babel__generator": "^7.27.0",
42
- "@types/node": "^25.2.0",
43
- "rollup-plugin-dts": "^6.3.0",
44
- "tslib": "^2.8.1"
37
+ "@rollup/plugin-commonjs": "29.0.1",
38
+ "@rollup/plugin-json": "6.1.0",
39
+ "@rollup/plugin-node-resolve": "16.0.3",
40
+ "@rollup/plugin-typescript": "12.3.0",
41
+ "@types/babel__generator": "7.27.0",
42
+ "@types/babel__traverse": "7.28.0",
43
+ "@types/node": "25.3.5",
44
+ "rollup": "4.59.0",
45
+ "rollup-plugin-dts": "6.3.0",
46
+ "tslib": "2.8.1",
47
+ "typescript": "5.9.3"
45
48
  }
46
49
  }
@@ -1,4 +0,0 @@
1
- import { CompileOpt } from "@mbler/mcx-types";
2
- import { MCXCompileData } from "../compile-mcx/compiler/compileData";
3
- declare function compileComponent(compileData: MCXCompileData, opt: CompileOpt): Promise<void>;
4
- export { compileComponent };
@@ -1,2 +0,0 @@
1
- import { JsCompileData, MCXCompileData } from "./compileData";
2
- export default function bundlerWrite(data: Array<JsCompileData | MCXCompileData>): void;
@@ -1,6 +0,0 @@
1
- declare const _default: {
2
- readonly imp: "__mcx__require";
3
- readonly exp: "__mcx__export";
4
- readonly module: "__mcx__module";
5
- };
6
- export default _default;