@mirascript/wasm 0.1.88 → 0.1.90
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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/lib/wasm.d.ts +34 -34
- package/lib/wasm.js +76 -76
- package/lib/wasm_bg.wasm +0 -0
- package/lib/wasm_bg.wasm.d.ts +22 -22
- package/package.json +3 -3
- package/src/index.ts +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { wasm };
|
|
|
4
4
|
/** 初始化模块 */
|
|
5
5
|
export declare function init(): Promise<void>;
|
|
6
6
|
/** 创建可重用的配置 */
|
|
7
|
-
export declare function createConfig(config?: Config | wasm.
|
|
7
|
+
export declare function createConfig(config?: Config | wasm.CompileConfig): wasm.CompileConfig;
|
|
8
8
|
/** 编译结果 */
|
|
9
9
|
export interface CompileResult {
|
|
10
10
|
/** 编译诊断 */
|
|
@@ -13,5 +13,5 @@ export interface CompileResult {
|
|
|
13
13
|
readonly chunk?: Uint8Array;
|
|
14
14
|
}
|
|
15
15
|
/** 编译 MiraScript 代码 */
|
|
16
|
-
export declare function compileSync(script: ScriptInput, config: Config | wasm.
|
|
16
|
+
export declare function compileSync(script: ScriptInput, config: Config | wasm.CompileConfig): CompileResult;
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAyC,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,YAAY;AACZ,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1C;AAED,eAAe;AACf,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAyC,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,YAAY;AACZ,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1C;AAED,eAAe;AACf,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAkBrF;AAED,WAAW;AACX,MAAM,WAAW,aAAa;IAC1B,WAAW;IACX,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,eAAe;IACf,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;CAC/B;AAuBD,uBAAuB;AACvB,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,GAAG,aAAa,CAInG"}
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ export async function init() {
|
|
|
9
9
|
/** 创建可重用的配置 */
|
|
10
10
|
export function createConfig(config) {
|
|
11
11
|
if (!config)
|
|
12
|
-
return new wasm.
|
|
13
|
-
if (config instanceof wasm.
|
|
12
|
+
return new wasm.CompileConfig();
|
|
13
|
+
if (config instanceof wasm.CompileConfig)
|
|
14
14
|
return config;
|
|
15
|
-
const cfg = new wasm.
|
|
15
|
+
const cfg = new wasm.CompileConfig();
|
|
16
16
|
for (const key in config) {
|
|
17
17
|
if (key === 'free')
|
|
18
18
|
continue; // 忽略 free 方法
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,YAAY;AACZ,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,eAAe;AACf,MAAM,UAAU,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,YAAY;AACZ,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,eAAe;AACf,MAAM,UAAU,YAAY,CAAC,MAAoC;IAC7D,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7C,IAAI,MAAM,YAAY,IAAI,CAAC,aAAa;QAAE,OAAO,MAAM,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,MAAM;YAAE,SAAS,CAAC,aAAa;QAC3C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;YAAE,SAAS;QAC1C,IAAI,KAAK,GAAG,MAAM,CAAC,GAAmB,CAAU,CAAC;QACjD,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;YACvB,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAkB,CAAU,CAAC;QACxD,CAAC;aAAM,IAAI,GAAG,KAAK,8BAA8B,EAAE,CAAC;YAChD,KAAK,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAmC,CAAU,CAAC;QAC1F,CAAC;QACD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;YAAE,SAAS;QAC5B,GAAG,CAAC,GAAmB,CAAC,GAAG,KAAK,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAUD,SAAS;AACT,SAAS,WAAW,CAChB,QAAuE,EACvE,MAAS,EACT,MAAmC;IAEnC,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7B,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC;YAAS,CAAC;QACP,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,oBAAoB;QACpB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACjB,GAAG,CAAC,IAAI,EAAE,CAAC;QACf,CAAC;IACL,CAAC;AACL,CAAC;AAED,uBAAuB;AACvB,MAAM,UAAU,WAAW,CAAC,MAAmB,EAAE,MAAmC;IAChF,OAAO,OAAO,MAAM,IAAI,QAAQ;QAC5B,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;QAC3C,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
package/lib/wasm.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
export class
|
|
5
|
-
private constructor();
|
|
6
|
-
free(): void;
|
|
7
|
-
[Symbol.dispose](): void;
|
|
8
|
-
chunk(): Uint8Array | undefined;
|
|
9
|
-
diagnostics(): Uint32Array;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class Config {
|
|
4
|
+
export class CompileConfig {
|
|
13
5
|
free(): void;
|
|
14
6
|
[Symbol.dispose](): void;
|
|
15
7
|
constructor();
|
|
@@ -25,6 +17,14 @@ export class Config {
|
|
|
25
17
|
trivia: boolean;
|
|
26
18
|
}
|
|
27
19
|
|
|
20
|
+
export class CompileResult {
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
chunk(): Uint8Array | undefined;
|
|
25
|
+
diagnostics(): Uint32Array;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
28
|
/**
|
|
29
29
|
* Encoding for counting positions in diagnostics.
|
|
30
30
|
*/
|
|
@@ -63,13 +63,13 @@ export class MonacoCompiler {
|
|
|
63
63
|
diagnostics(): Uint32Array;
|
|
64
64
|
emit(): Uint8Array | undefined;
|
|
65
65
|
format(): string | undefined;
|
|
66
|
-
constructor(input: string, config:
|
|
66
|
+
constructor(input: string, config: CompileConfig);
|
|
67
67
|
parse(): boolean;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function compile(script: string, config:
|
|
70
|
+
export function compile(script: string, config: CompileConfig): CompileResult;
|
|
71
71
|
|
|
72
|
-
export function compile_buffer(script: Uint8Array, config:
|
|
72
|
+
export function compile_buffer(script: Uint8Array, config: CompileConfig): CompileResult;
|
|
73
73
|
|
|
74
74
|
export function main(): void;
|
|
75
75
|
|
|
@@ -89,28 +89,28 @@ export interface InitOutput {
|
|
|
89
89
|
readonly monacocompiler_new: (a: number, b: number, c: number) => number;
|
|
90
90
|
readonly monacocompiler_parse: (a: number) => number;
|
|
91
91
|
readonly compile_buffer: (a: number, b: number, c: number) => number;
|
|
92
|
-
readonly
|
|
93
|
-
readonly
|
|
94
|
-
readonly
|
|
95
|
-
readonly
|
|
96
|
-
readonly
|
|
97
|
-
readonly
|
|
98
|
-
readonly
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
103
|
-
readonly
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
106
|
-
readonly
|
|
107
|
-
readonly
|
|
108
|
-
readonly
|
|
109
|
-
readonly
|
|
110
|
-
readonly
|
|
111
|
-
readonly
|
|
112
|
-
readonly
|
|
113
|
-
readonly
|
|
92
|
+
readonly __wbg_compileconfig_free: (a: number, b: number) => void;
|
|
93
|
+
readonly __wbg_get_compileconfig_diagnostic_error: (a: number) => number;
|
|
94
|
+
readonly __wbg_get_compileconfig_diagnostic_hint: (a: number) => number;
|
|
95
|
+
readonly __wbg_get_compileconfig_diagnostic_info: (a: number) => number;
|
|
96
|
+
readonly __wbg_get_compileconfig_diagnostic_position_encoding: (a: number) => number;
|
|
97
|
+
readonly __wbg_get_compileconfig_diagnostic_reference: (a: number) => number;
|
|
98
|
+
readonly __wbg_get_compileconfig_diagnostic_sourcemap: (a: number) => number;
|
|
99
|
+
readonly __wbg_get_compileconfig_diagnostic_tag: (a: number) => number;
|
|
100
|
+
readonly __wbg_get_compileconfig_diagnostic_warning: (a: number) => number;
|
|
101
|
+
readonly __wbg_get_compileconfig_input_mode: (a: number) => number;
|
|
102
|
+
readonly __wbg_get_compileconfig_trivia: (a: number) => number;
|
|
103
|
+
readonly __wbg_set_compileconfig_diagnostic_error: (a: number, b: number) => void;
|
|
104
|
+
readonly __wbg_set_compileconfig_diagnostic_hint: (a: number, b: number) => void;
|
|
105
|
+
readonly __wbg_set_compileconfig_diagnostic_info: (a: number, b: number) => void;
|
|
106
|
+
readonly __wbg_set_compileconfig_diagnostic_position_encoding: (a: number, b: number) => void;
|
|
107
|
+
readonly __wbg_set_compileconfig_diagnostic_reference: (a: number, b: number) => void;
|
|
108
|
+
readonly __wbg_set_compileconfig_diagnostic_sourcemap: (a: number, b: number) => void;
|
|
109
|
+
readonly __wbg_set_compileconfig_diagnostic_tag: (a: number, b: number) => void;
|
|
110
|
+
readonly __wbg_set_compileconfig_diagnostic_warning: (a: number, b: number) => void;
|
|
111
|
+
readonly __wbg_set_compileconfig_input_mode: (a: number, b: number) => void;
|
|
112
|
+
readonly __wbg_set_compileconfig_trivia: (a: number, b: number) => void;
|
|
113
|
+
readonly compileconfig_new: () => number;
|
|
114
114
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
115
115
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
116
116
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/lib/wasm.js
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
1
|
/* @ts-self-types="./wasm.d.ts" */
|
|
2
2
|
|
|
3
|
-
export class
|
|
4
|
-
static __wrap(ptr) {
|
|
5
|
-
const obj = Object.create(CompileResult.prototype);
|
|
6
|
-
obj.__wbg_ptr = ptr;
|
|
7
|
-
CompileResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8
|
-
return obj;
|
|
9
|
-
}
|
|
10
|
-
__destroy_into_raw() {
|
|
11
|
-
const ptr = this.__wbg_ptr;
|
|
12
|
-
this.__wbg_ptr = 0;
|
|
13
|
-
CompileResultFinalization.unregister(this);
|
|
14
|
-
return ptr;
|
|
15
|
-
}
|
|
16
|
-
free() {
|
|
17
|
-
const ptr = this.__destroy_into_raw();
|
|
18
|
-
wasm.__wbg_compileresult_free(ptr, 0);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @returns {Uint8Array | undefined}
|
|
22
|
-
*/
|
|
23
|
-
chunk() {
|
|
24
|
-
const ret = wasm.compileresult_chunk(this.__wbg_ptr);
|
|
25
|
-
let v1;
|
|
26
|
-
if (ret[0] !== 0) {
|
|
27
|
-
v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
28
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
29
|
-
}
|
|
30
|
-
return v1;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @returns {Uint32Array}
|
|
34
|
-
*/
|
|
35
|
-
diagnostics() {
|
|
36
|
-
const ret = wasm.compileresult_diagnostics(this.__wbg_ptr);
|
|
37
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
38
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
39
|
-
return v1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (Symbol.dispose) CompileResult.prototype[Symbol.dispose] = CompileResult.prototype.free;
|
|
43
|
-
|
|
44
|
-
export class Config {
|
|
3
|
+
export class CompileConfig {
|
|
45
4
|
__destroy_into_raw() {
|
|
46
5
|
const ptr = this.__wbg_ptr;
|
|
47
6
|
this.__wbg_ptr = 0;
|
|
48
|
-
|
|
7
|
+
CompileConfigFinalization.unregister(this);
|
|
49
8
|
return ptr;
|
|
50
9
|
}
|
|
51
10
|
free() {
|
|
52
11
|
const ptr = this.__destroy_into_raw();
|
|
53
|
-
wasm.
|
|
12
|
+
wasm.__wbg_compileconfig_free(ptr, 0);
|
|
54
13
|
}
|
|
55
14
|
constructor() {
|
|
56
|
-
const ret = wasm.
|
|
15
|
+
const ret = wasm.compileconfig_new();
|
|
57
16
|
this.__wbg_ptr = ret;
|
|
58
|
-
|
|
17
|
+
CompileConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
59
18
|
return this;
|
|
60
19
|
}
|
|
61
20
|
/**
|
|
62
21
|
* @returns {boolean}
|
|
63
22
|
*/
|
|
64
23
|
get diagnostic_error() {
|
|
65
|
-
const ret = wasm.
|
|
24
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_error(this.__wbg_ptr);
|
|
66
25
|
return ret !== 0;
|
|
67
26
|
}
|
|
68
27
|
/**
|
|
69
28
|
* @returns {boolean}
|
|
70
29
|
*/
|
|
71
30
|
get diagnostic_hint() {
|
|
72
|
-
const ret = wasm.
|
|
31
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_hint(this.__wbg_ptr);
|
|
73
32
|
return ret !== 0;
|
|
74
33
|
}
|
|
75
34
|
/**
|
|
76
35
|
* @returns {boolean}
|
|
77
36
|
*/
|
|
78
37
|
get diagnostic_info() {
|
|
79
|
-
const ret = wasm.
|
|
38
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_info(this.__wbg_ptr);
|
|
80
39
|
return ret !== 0;
|
|
81
40
|
}
|
|
82
41
|
/**
|
|
83
42
|
* @returns {DiagnosticPositionEncoding}
|
|
84
43
|
*/
|
|
85
44
|
get diagnostic_position_encoding() {
|
|
86
|
-
const ret = wasm.
|
|
45
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_position_encoding(this.__wbg_ptr);
|
|
87
46
|
return ret;
|
|
88
47
|
}
|
|
89
48
|
/**
|
|
90
49
|
* @returns {boolean}
|
|
91
50
|
*/
|
|
92
51
|
get diagnostic_reference() {
|
|
93
|
-
const ret = wasm.
|
|
52
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_reference(this.__wbg_ptr);
|
|
94
53
|
return ret !== 0;
|
|
95
54
|
}
|
|
96
55
|
/**
|
|
97
56
|
* @returns {boolean}
|
|
98
57
|
*/
|
|
99
58
|
get diagnostic_sourcemap() {
|
|
100
|
-
const ret = wasm.
|
|
59
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_sourcemap(this.__wbg_ptr);
|
|
101
60
|
return ret !== 0;
|
|
102
61
|
}
|
|
103
62
|
/**
|
|
104
63
|
* @returns {boolean}
|
|
105
64
|
*/
|
|
106
65
|
get diagnostic_tag() {
|
|
107
|
-
const ret = wasm.
|
|
66
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_tag(this.__wbg_ptr);
|
|
108
67
|
return ret !== 0;
|
|
109
68
|
}
|
|
110
69
|
/**
|
|
111
70
|
* @returns {boolean}
|
|
112
71
|
*/
|
|
113
72
|
get diagnostic_warning() {
|
|
114
|
-
const ret = wasm.
|
|
73
|
+
const ret = wasm.__wbg_get_compileconfig_diagnostic_warning(this.__wbg_ptr);
|
|
115
74
|
return ret !== 0;
|
|
116
75
|
}
|
|
117
76
|
/**
|
|
118
77
|
* @returns {InputMode}
|
|
119
78
|
*/
|
|
120
79
|
get input_mode() {
|
|
121
|
-
const ret = wasm.
|
|
80
|
+
const ret = wasm.__wbg_get_compileconfig_input_mode(this.__wbg_ptr);
|
|
122
81
|
return ret;
|
|
123
82
|
}
|
|
124
83
|
/**
|
|
125
84
|
* @returns {boolean}
|
|
126
85
|
*/
|
|
127
86
|
get trivia() {
|
|
128
|
-
const ret = wasm.
|
|
87
|
+
const ret = wasm.__wbg_get_compileconfig_trivia(this.__wbg_ptr);
|
|
129
88
|
return ret !== 0;
|
|
130
89
|
}
|
|
131
90
|
/**
|
|
132
91
|
* @param {boolean} arg0
|
|
133
92
|
*/
|
|
134
93
|
set diagnostic_error(arg0) {
|
|
135
|
-
wasm.
|
|
94
|
+
wasm.__wbg_set_compileconfig_diagnostic_error(this.__wbg_ptr, arg0);
|
|
136
95
|
}
|
|
137
96
|
/**
|
|
138
97
|
* @param {boolean} arg0
|
|
139
98
|
*/
|
|
140
99
|
set diagnostic_hint(arg0) {
|
|
141
|
-
wasm.
|
|
100
|
+
wasm.__wbg_set_compileconfig_diagnostic_hint(this.__wbg_ptr, arg0);
|
|
142
101
|
}
|
|
143
102
|
/**
|
|
144
103
|
* @param {boolean} arg0
|
|
145
104
|
*/
|
|
146
105
|
set diagnostic_info(arg0) {
|
|
147
|
-
wasm.
|
|
106
|
+
wasm.__wbg_set_compileconfig_diagnostic_info(this.__wbg_ptr, arg0);
|
|
148
107
|
}
|
|
149
108
|
/**
|
|
150
109
|
* @param {DiagnosticPositionEncoding} arg0
|
|
151
110
|
*/
|
|
152
111
|
set diagnostic_position_encoding(arg0) {
|
|
153
|
-
wasm.
|
|
112
|
+
wasm.__wbg_set_compileconfig_diagnostic_position_encoding(this.__wbg_ptr, arg0);
|
|
154
113
|
}
|
|
155
114
|
/**
|
|
156
115
|
* @param {boolean} arg0
|
|
157
116
|
*/
|
|
158
117
|
set diagnostic_reference(arg0) {
|
|
159
|
-
wasm.
|
|
118
|
+
wasm.__wbg_set_compileconfig_diagnostic_reference(this.__wbg_ptr, arg0);
|
|
160
119
|
}
|
|
161
120
|
/**
|
|
162
121
|
* @param {boolean} arg0
|
|
163
122
|
*/
|
|
164
123
|
set diagnostic_sourcemap(arg0) {
|
|
165
|
-
wasm.
|
|
124
|
+
wasm.__wbg_set_compileconfig_diagnostic_sourcemap(this.__wbg_ptr, arg0);
|
|
166
125
|
}
|
|
167
126
|
/**
|
|
168
127
|
* @param {boolean} arg0
|
|
169
128
|
*/
|
|
170
129
|
set diagnostic_tag(arg0) {
|
|
171
|
-
wasm.
|
|
130
|
+
wasm.__wbg_set_compileconfig_diagnostic_tag(this.__wbg_ptr, arg0);
|
|
172
131
|
}
|
|
173
132
|
/**
|
|
174
133
|
* @param {boolean} arg0
|
|
175
134
|
*/
|
|
176
135
|
set diagnostic_warning(arg0) {
|
|
177
|
-
wasm.
|
|
136
|
+
wasm.__wbg_set_compileconfig_diagnostic_warning(this.__wbg_ptr, arg0);
|
|
178
137
|
}
|
|
179
138
|
/**
|
|
180
139
|
* @param {InputMode} arg0
|
|
181
140
|
*/
|
|
182
141
|
set input_mode(arg0) {
|
|
183
|
-
wasm.
|
|
142
|
+
wasm.__wbg_set_compileconfig_input_mode(this.__wbg_ptr, arg0);
|
|
184
143
|
}
|
|
185
144
|
/**
|
|
186
145
|
* @param {boolean} arg0
|
|
187
146
|
*/
|
|
188
147
|
set trivia(arg0) {
|
|
189
|
-
wasm.
|
|
148
|
+
wasm.__wbg_set_compileconfig_trivia(this.__wbg_ptr, arg0);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (Symbol.dispose) CompileConfig.prototype[Symbol.dispose] = CompileConfig.prototype.free;
|
|
152
|
+
|
|
153
|
+
export class CompileResult {
|
|
154
|
+
static __wrap(ptr) {
|
|
155
|
+
const obj = Object.create(CompileResult.prototype);
|
|
156
|
+
obj.__wbg_ptr = ptr;
|
|
157
|
+
CompileResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
158
|
+
return obj;
|
|
159
|
+
}
|
|
160
|
+
__destroy_into_raw() {
|
|
161
|
+
const ptr = this.__wbg_ptr;
|
|
162
|
+
this.__wbg_ptr = 0;
|
|
163
|
+
CompileResultFinalization.unregister(this);
|
|
164
|
+
return ptr;
|
|
165
|
+
}
|
|
166
|
+
free() {
|
|
167
|
+
const ptr = this.__destroy_into_raw();
|
|
168
|
+
wasm.__wbg_compileresult_free(ptr, 0);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @returns {Uint8Array | undefined}
|
|
172
|
+
*/
|
|
173
|
+
chunk() {
|
|
174
|
+
const ret = wasm.compileresult_chunk(this.__wbg_ptr);
|
|
175
|
+
let v1;
|
|
176
|
+
if (ret[0] !== 0) {
|
|
177
|
+
v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
178
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
179
|
+
}
|
|
180
|
+
return v1;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @returns {Uint32Array}
|
|
184
|
+
*/
|
|
185
|
+
diagnostics() {
|
|
186
|
+
const ret = wasm.compileresult_diagnostics(this.__wbg_ptr);
|
|
187
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
188
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
189
|
+
return v1;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
if (Symbol.dispose)
|
|
192
|
+
if (Symbol.dispose) CompileResult.prototype[Symbol.dispose] = CompileResult.prototype.free;
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* Encoding for counting positions in diagnostics.
|
|
@@ -271,12 +271,12 @@ export class MonacoCompiler {
|
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* @param {string} input
|
|
274
|
-
* @param {
|
|
274
|
+
* @param {CompileConfig} config
|
|
275
275
|
*/
|
|
276
276
|
constructor(input, config) {
|
|
277
277
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
278
|
const len0 = WASM_VECTOR_LEN;
|
|
279
|
-
_assertClass(config,
|
|
279
|
+
_assertClass(config, CompileConfig);
|
|
280
280
|
const ret = wasm.monacocompiler_new(ptr0, len0, config.__wbg_ptr);
|
|
281
281
|
this.__wbg_ptr = ret;
|
|
282
282
|
MonacoCompilerFinalization.register(this, this.__wbg_ptr, this);
|
|
@@ -294,26 +294,26 @@ if (Symbol.dispose) MonacoCompiler.prototype[Symbol.dispose] = MonacoCompiler.pr
|
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* @param {string} script
|
|
297
|
-
* @param {
|
|
297
|
+
* @param {CompileConfig} config
|
|
298
298
|
* @returns {CompileResult}
|
|
299
299
|
*/
|
|
300
300
|
export function compile(script, config) {
|
|
301
301
|
const ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
302
302
|
const len0 = WASM_VECTOR_LEN;
|
|
303
|
-
_assertClass(config,
|
|
303
|
+
_assertClass(config, CompileConfig);
|
|
304
304
|
const ret = wasm.compile(ptr0, len0, config.__wbg_ptr);
|
|
305
305
|
return CompileResult.__wrap(ret);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
/**
|
|
309
309
|
* @param {Uint8Array} script
|
|
310
|
-
* @param {
|
|
310
|
+
* @param {CompileConfig} config
|
|
311
311
|
* @returns {CompileResult}
|
|
312
312
|
*/
|
|
313
313
|
export function compile_buffer(script, config) {
|
|
314
314
|
const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_malloc);
|
|
315
315
|
const len0 = WASM_VECTOR_LEN;
|
|
316
|
-
_assertClass(config,
|
|
316
|
+
_assertClass(config, CompileConfig);
|
|
317
317
|
const ret = wasm.compile_buffer(ptr0, len0, config.__wbg_ptr);
|
|
318
318
|
return CompileResult.__wrap(ret);
|
|
319
319
|
}
|
|
@@ -365,12 +365,12 @@ function __wbg_get_imports() {
|
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
const CompileConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
369
|
+
? { register: () => {}, unregister: () => {} }
|
|
370
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compileconfig_free(ptr, 1));
|
|
368
371
|
const CompileResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
369
372
|
? { register: () => {}, unregister: () => {} }
|
|
370
373
|
: new FinalizationRegistry(ptr => wasm.__wbg_compileresult_free(ptr, 1));
|
|
371
|
-
const ConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
372
|
-
? { register: () => {}, unregister: () => {} }
|
|
373
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_config_free(ptr, 1));
|
|
374
374
|
const MonacoCompilerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
375
375
|
? { register: () => {}, unregister: () => {} }
|
|
376
376
|
: new FinalizationRegistry(ptr => wasm.__wbg_monacocompiler_free(ptr, 1));
|
package/lib/wasm_bg.wasm
CHANGED
|
Binary file
|
package/lib/wasm_bg.wasm.d.ts
CHANGED
|
@@ -13,28 +13,28 @@ export const monacocompiler_format: (a: number) => [number, number];
|
|
|
13
13
|
export const monacocompiler_new: (a: number, b: number, c: number) => number;
|
|
14
14
|
export const monacocompiler_parse: (a: number) => number;
|
|
15
15
|
export const compile_buffer: (a: number, b: number, c: number) => number;
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
29
|
-
export const
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
33
|
-
export const
|
|
34
|
-
export const
|
|
35
|
-
export const
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
16
|
+
export const __wbg_compileconfig_free: (a: number, b: number) => void;
|
|
17
|
+
export const __wbg_get_compileconfig_diagnostic_error: (a: number) => number;
|
|
18
|
+
export const __wbg_get_compileconfig_diagnostic_hint: (a: number) => number;
|
|
19
|
+
export const __wbg_get_compileconfig_diagnostic_info: (a: number) => number;
|
|
20
|
+
export const __wbg_get_compileconfig_diagnostic_position_encoding: (a: number) => number;
|
|
21
|
+
export const __wbg_get_compileconfig_diagnostic_reference: (a: number) => number;
|
|
22
|
+
export const __wbg_get_compileconfig_diagnostic_sourcemap: (a: number) => number;
|
|
23
|
+
export const __wbg_get_compileconfig_diagnostic_tag: (a: number) => number;
|
|
24
|
+
export const __wbg_get_compileconfig_diagnostic_warning: (a: number) => number;
|
|
25
|
+
export const __wbg_get_compileconfig_input_mode: (a: number) => number;
|
|
26
|
+
export const __wbg_get_compileconfig_trivia: (a: number) => number;
|
|
27
|
+
export const __wbg_set_compileconfig_diagnostic_error: (a: number, b: number) => void;
|
|
28
|
+
export const __wbg_set_compileconfig_diagnostic_hint: (a: number, b: number) => void;
|
|
29
|
+
export const __wbg_set_compileconfig_diagnostic_info: (a: number, b: number) => void;
|
|
30
|
+
export const __wbg_set_compileconfig_diagnostic_position_encoding: (a: number, b: number) => void;
|
|
31
|
+
export const __wbg_set_compileconfig_diagnostic_reference: (a: number, b: number) => void;
|
|
32
|
+
export const __wbg_set_compileconfig_diagnostic_sourcemap: (a: number, b: number) => void;
|
|
33
|
+
export const __wbg_set_compileconfig_diagnostic_tag: (a: number, b: number) => void;
|
|
34
|
+
export const __wbg_set_compileconfig_diagnostic_warning: (a: number, b: number) => void;
|
|
35
|
+
export const __wbg_set_compileconfig_input_mode: (a: number, b: number) => void;
|
|
36
|
+
export const __wbg_set_compileconfig_trivia: (a: number, b: number) => void;
|
|
37
|
+
export const compileconfig_new: () => number;
|
|
38
38
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
39
39
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
40
40
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirascript/wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.90",
|
|
4
4
|
"author": "CloudPSS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "MiraScript compiler for WebAssembly",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"@mirascript/constants": "~0.1.90",
|
|
34
|
+
"nodemon": "^3.1.14"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"wasm": "wasm-pack build --target web --out-dir ../../packages/wasm/lib --no-pack ../../crates/wasm",
|
package/src/index.ts
CHANGED
|
@@ -11,10 +11,10 @@ export async function init(): Promise<void> {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/** 创建可重用的配置 */
|
|
14
|
-
export function createConfig(config?: Config | wasm.
|
|
15
|
-
if (!config) return new wasm.
|
|
16
|
-
if (config instanceof wasm.
|
|
17
|
-
const cfg = new wasm.
|
|
14
|
+
export function createConfig(config?: Config | wasm.CompileConfig): wasm.CompileConfig {
|
|
15
|
+
if (!config) return new wasm.CompileConfig();
|
|
16
|
+
if (config instanceof wasm.CompileConfig) return config;
|
|
17
|
+
const cfg = new wasm.CompileConfig();
|
|
18
18
|
for (const key in config) {
|
|
19
19
|
if (key === 'free') continue; // 忽略 free 方法
|
|
20
20
|
if (!Object.hasOwn(config, key)) continue;
|
|
@@ -41,9 +41,9 @@ export interface CompileResult {
|
|
|
41
41
|
|
|
42
42
|
/** 编译 */
|
|
43
43
|
function compileImpl<T>(
|
|
44
|
-
compiler: (script: T, config: wasm.
|
|
44
|
+
compiler: (script: T, config: wasm.CompileConfig) => wasm.CompileResult,
|
|
45
45
|
script: T,
|
|
46
|
-
config: Config | wasm.
|
|
46
|
+
config: Config | wasm.CompileConfig,
|
|
47
47
|
): CompileResult {
|
|
48
48
|
const cfg = createConfig(config);
|
|
49
49
|
const result = compiler(script, cfg);
|
|
@@ -61,7 +61,7 @@ function compileImpl<T>(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** 编译 MiraScript 代码 */
|
|
64
|
-
export function compileSync(script: ScriptInput, config: Config | wasm.
|
|
64
|
+
export function compileSync(script: ScriptInput, config: Config | wasm.CompileConfig): CompileResult {
|
|
65
65
|
return typeof script == 'string'
|
|
66
66
|
? compileImpl(wasm.compile, script, config)
|
|
67
67
|
: compileImpl(wasm.compile_buffer, script, config);
|