@mbler/mcx-core 0.1.1 → 0.1.2-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/dist/chunk-DEq-mXcV.js +15 -0
- package/dist/index.d.ts +296 -5175
- package/dist/index.js +1813 -12192
- package/dist/index.js.map +1 -1
- package/package.json +15 -6
- package/dist/types/ast/index.d.ts +0 -7
- package/dist/types/ast/prop.d.ts +0 -8
- package/dist/types/ast/tag.d.ts +0 -66
- package/dist/types/compile-mcx/compiler/compileData.d.ts +0 -20
- package/dist/types/compile-mcx/compiler/index.d.ts +0 -36
- package/dist/types/compile-mcx/compiler/main.d.ts +0 -6
- package/dist/types/compile-mcx/compiler/utils.d.ts +0 -11
- package/dist/types/compile-mcx/index.d.ts +0 -1
- package/dist/types/compile-mcx/types.d.ts +0 -52
- package/dist/types/compile-mcx/utils.node.d.ts +0 -14
- package/dist/types/index.d.ts +0 -10
- package/dist/types/mcx-component/components/block.d.ts +0 -4
- package/dist/types/mcx-component/components/entity.d.ts +0 -1266
- package/dist/types/mcx-component/components/item.d.ts +0 -520
- package/dist/types/mcx-component/index.d.ts +0 -17
- package/dist/types/mcx-component/lib.d.ts +0 -32
- package/dist/types/mcx-component/types/AttackCriticalHitChoices.d.ts +0 -3
- package/dist/types/mcx-component/types/EnchantableSlot.d.ts +0 -9
- package/dist/types/mcx-component/types/ParticleType.d.ts +0 -8
- package/dist/types/mcx-component/types/SoundEvent.d.ts +0 -8
- package/dist/types/mcx-component/types/StartSoundChoices.d.ts +0 -3
- package/dist/types/mcx-component/types.d.ts +0 -3053
- package/dist/types/mcx-component/utils.d.ts +0 -2
- package/dist/types/mcx-component/vm.d.ts +0 -28
- package/dist/types/transforms/config.d.ts +0 -8
- package/dist/types/transforms/file_id.d.ts +0 -1
- package/dist/types/transforms/index.d.ts +0 -5
- package/dist/types/transforms/main.d.ts +0 -2
- package/dist/types/transforms/utils.d.ts +0 -22
- package/dist/types/transforms/x-comp/index.d.ts +0 -3
- package/dist/types/transforms/x-comp/x-app.d.ts +0 -2
- package/dist/types/transforms/x-comp/x-event.d.ts +0 -2
- package/dist/types/transforms/x-comp/x-ui.d.ts +0 -2
- package/dist/types/types.d.ts +0 -100
- package/dist/types/utils.d.ts +0 -18
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as t from '@babel/types';
|
|
2
|
-
export declare enum execESMMethod {
|
|
3
|
-
transformCjs = 0,
|
|
4
|
-
runInVm = 1,
|
|
5
|
-
importESM = 2
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* ESM => CJS
|
|
9
|
-
*/
|
|
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
|
-
export declare class RunScript {
|
|
12
|
-
filePath: string;
|
|
13
|
-
module: 'esm' | 'cjs';
|
|
14
|
-
private pluginContext?;
|
|
15
|
-
private _module;
|
|
16
|
-
private _context;
|
|
17
|
-
private _pluginContext;
|
|
18
|
-
constructor(filePath?: string, module?: 'esm' | 'cjs', pluginContext?: Record<string, string | null | boolean | number> | undefined);
|
|
19
|
-
/**
|
|
20
|
-
* run code in nodejs vm
|
|
21
|
-
* @param code {string} exetuce code
|
|
22
|
-
* @returns code exports
|
|
23
|
-
*/
|
|
24
|
-
run(code: string, esmExecMethod?: execESMMethod, transformCjsHook?: (data: t.CallExpression | t.MemberExpression, setData?: (newData: t.Expression) => void) => void): Promise<unknown>;
|
|
25
|
-
private getContext;
|
|
26
|
-
static isCanUseEsmRunVm: boolean;
|
|
27
|
-
}
|
|
28
|
-
export { transformESMToCJS };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateFileId(): string;
|
|
@@ -1,5 +0,0 @@
|
|
|
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,22 +0,0 @@
|
|
|
1
|
-
import * as t from '@babel/types';
|
|
2
|
-
import { JsCompileData } from '../compile-mcx/compiler/compileData';
|
|
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>(): ((data: T) => void) & {
|
|
18
|
-
prototype: {
|
|
19
|
-
enable: T | null;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export { extractIdList, extrectVarDefIdList, generateEventConfig, _enable, generateMain, _enableWithData, };
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
interface BaseToken {
|
|
6
|
-
data: string;
|
|
7
|
-
type: TokenType;
|
|
8
|
-
start: MCXPosition;
|
|
9
|
-
end: MCXPosition;
|
|
10
|
-
}
|
|
11
|
-
interface TagToken extends BaseToken {
|
|
12
|
-
type: 'Tag';
|
|
13
|
-
}
|
|
14
|
-
interface TagEndToken extends BaseToken {
|
|
15
|
-
type: 'TagEnd';
|
|
16
|
-
}
|
|
17
|
-
interface ContentToken extends BaseToken {
|
|
18
|
-
type: 'Content';
|
|
19
|
-
}
|
|
20
|
-
interface CommentToken extends BaseToken {
|
|
21
|
-
type: 'Comment';
|
|
22
|
-
}
|
|
23
|
-
type Token = TagToken | TagEndToken | ContentToken | CommentToken;
|
|
24
|
-
type AttributeMap = Record<string, string | boolean>;
|
|
25
|
-
/** 统一的位置信息结构 */
|
|
26
|
-
interface MCXPosition {
|
|
27
|
-
line: number;
|
|
28
|
-
column: number;
|
|
29
|
-
}
|
|
30
|
-
interface MCXLoc {
|
|
31
|
-
start: MCXPosition;
|
|
32
|
-
end: MCXPosition;
|
|
33
|
-
}
|
|
34
|
-
interface ParsedTagNode {
|
|
35
|
-
start: TagToken;
|
|
36
|
-
name: string;
|
|
37
|
-
arr: AttributeMap;
|
|
38
|
-
content: (ParsedTagContentNode | ParsedTagNode | ParsedCommentNode)[];
|
|
39
|
-
end: TagEndToken | null;
|
|
40
|
-
loc: MCXLoc;
|
|
41
|
-
type: 'TagNode';
|
|
42
|
-
}
|
|
43
|
-
interface ParsedTagContentNode {
|
|
44
|
-
data: string;
|
|
45
|
-
type: 'TagContent';
|
|
46
|
-
}
|
|
47
|
-
interface ParsedCommentNode {
|
|
48
|
-
data: string;
|
|
49
|
-
type: 'Comment';
|
|
50
|
-
loc?: MCXLoc;
|
|
51
|
-
}
|
|
52
|
-
type TokenType = 'Tag' | 'TagEnd' | 'Content' | 'Comment';
|
|
53
|
-
type PropValue = number | string | object;
|
|
54
|
-
interface PropNode {
|
|
55
|
-
key: string;
|
|
56
|
-
value: PropValue;
|
|
57
|
-
type: 'PropChar' | 'PropObject';
|
|
58
|
-
}
|
|
59
|
-
type JsType = 'boolean' | 'number' | 'string' | 'object' | 'function' | 'bigint' | 'symbol';
|
|
60
|
-
interface TypeVerifyBody {
|
|
61
|
-
[key: string]: JsType;
|
|
62
|
-
}
|
|
63
|
-
export interface ParseReadFileOpt {
|
|
64
|
-
delay: number;
|
|
65
|
-
maxRetries: number;
|
|
66
|
-
want: 'string' | 'object';
|
|
67
|
-
}
|
|
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, };
|
|
71
|
-
export interface transformCtx {
|
|
72
|
-
rollupContext: TransformPluginContext;
|
|
73
|
-
compiledCode: MCXCompileData;
|
|
74
|
-
cache: Map<string, MCXCompileData>;
|
|
75
|
-
currentId: string;
|
|
76
|
-
scriptTag: ParsedTagNode;
|
|
77
|
-
currentAST: t.Program;
|
|
78
|
-
mainFn: {
|
|
79
|
-
param: t.FunctionParameter[];
|
|
80
|
-
body: t.Statement[];
|
|
81
|
-
};
|
|
82
|
-
impAST: t.ImportDeclaration[];
|
|
83
|
-
opt: CompileOpt;
|
|
84
|
-
output: {
|
|
85
|
-
dist: string;
|
|
86
|
-
behavior: string;
|
|
87
|
-
resources: string;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export interface transformParseCtx {
|
|
91
|
-
prop: t.ObjectProperty[];
|
|
92
|
-
impBody: t.ImportDeclaration[];
|
|
93
|
-
mainFn: t.Statement[];
|
|
94
|
-
ctx: transformCtx;
|
|
95
|
-
app: ((data: t.ObjectProperty[]) => void) & {
|
|
96
|
-
prototype: {
|
|
97
|
-
enable: t.ObjectProperty[] | null;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
}
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ReadFileOpt, TypeVerifyBody } from './types.js';
|
|
2
|
-
export default class Utlis {
|
|
3
|
-
static FileExsit(path: string): Promise<boolean>;
|
|
4
|
-
static readFile(filePath: string, opt?: ReadFileOpt): Promise<object | string>;
|
|
5
|
-
static sleep(time: number): Promise<void>;
|
|
6
|
-
static TypeVerify<T extends Record<string, any>, U extends TypeVerifyBody>(obj: T, types: U): obj is T & {
|
|
7
|
-
[P in keyof U]: {
|
|
8
|
-
boolean: boolean;
|
|
9
|
-
number: number;
|
|
10
|
-
string: string;
|
|
11
|
-
object: object;
|
|
12
|
-
function: Function;
|
|
13
|
-
bigint: bigint;
|
|
14
|
-
symbol: Symbol;
|
|
15
|
-
}[U[P]];
|
|
16
|
-
};
|
|
17
|
-
static AbsoluteJoin(baseDir: string, inputPath: string): string;
|
|
18
|
-
}
|