motoko 3.12.0 → 3.12.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/contrib/generated/errorCodes.json +1 -1
- package/contrib/snippets.json +2 -2
- package/lib/file.d.ts +3 -3
- package/lib/file.d.ts.map +1 -1
- package/lib/file.js +6 -6
- package/lib/file.js.map +1 -1
- package/lib/index.d.ts +7 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -7
- package/lib/index.js.map +1 -1
- package/lib/versions/interpreter.d.ts +7 -7
- package/lib/versions/moc.d.ts +7 -7
- package/package.json +1 -1
- package/packages/latest/base.json +1 -1
- package/src/file.ts +6 -6
- package/src/index.ts +14 -5
- package/versions/latest/moc.min.js +1 -1
- package/versions/latest/moc_interpreter.min.js +1 -1
package/src/file.ts
CHANGED
@@ -64,17 +64,17 @@ export const file = (mo: Motoko, path: string) => {
|
|
64
64
|
parseCandid() {
|
65
65
|
return mo.parseCandid(result.read());
|
66
66
|
},
|
67
|
-
parseMotoko() {
|
68
|
-
return mo.parseMotoko(result.read());
|
67
|
+
parseMotoko(enableRecovery?: boolean) {
|
68
|
+
return mo.parseMotoko(result.read(), enableRecovery);
|
69
69
|
},
|
70
|
-
parseMotokoWithDeps() {
|
71
|
-
return mo.parseMotokoWithDeps(path, result.read());
|
70
|
+
parseMotokoWithDeps(enableRecovery?: boolean) {
|
71
|
+
return mo.parseMotokoWithDeps(path, result.read(), enableRecovery);
|
72
72
|
},
|
73
73
|
parseMotokoTyped() {
|
74
74
|
return mo.parseMotokoTyped(path);
|
75
75
|
},
|
76
|
-
parseMotokoTypedWithScopeCache(scopeCache: Map<string, Scope
|
77
|
-
return mo.parseMotokoTypedWithScopeCache(path, scopeCache);
|
76
|
+
parseMotokoTypedWithScopeCache(scopeCache: Map<string, Scope>, enableRecovery?: boolean) {
|
77
|
+
return mo.parseMotokoTypedWithScopeCache(path, scopeCache, enableRecovery);
|
78
78
|
},
|
79
79
|
};
|
80
80
|
return result;
|
package/src/index.ts
CHANGED
@@ -71,6 +71,8 @@ export default function wrapMotoko(compiler: Compiler) {
|
|
71
71
|
return result.code;
|
72
72
|
};
|
73
73
|
|
74
|
+
/* Note: [parseMotokoTyped] is an old API which
|
75
|
+
doesn't support scope cache and recovery */
|
74
76
|
// Function signatures for `mo.parseMotokoTyped()`
|
75
77
|
type ParseMotokoTypedResult = { ast: Node; type: Node };
|
76
78
|
function parseMotokoTyped(paths: string): ParseMotokoTypedResult;
|
@@ -100,21 +102,27 @@ export default function wrapMotoko(compiler: Compiler) {
|
|
100
102
|
function parseMotokoTypedWithScopeCache(
|
101
103
|
paths: string,
|
102
104
|
scopeCache: Map<string, Scope>,
|
105
|
+
enableRecovery?: boolean,
|
103
106
|
): [ParseMotokoTypedWithScopeCacheResult, Map<string, Scope>];
|
104
107
|
function parseMotokoTypedWithScopeCache(
|
105
108
|
paths: string[],
|
106
109
|
scopeCache: Map<string, Scope>,
|
110
|
+
enableRecovery?: boolean,
|
107
111
|
): [ParseMotokoTypedWithScopeCacheResult[], Map<string, Scope>];
|
108
112
|
function parseMotokoTypedWithScopeCache(
|
109
113
|
paths: string | string[],
|
110
114
|
scopeCache: Map<string, Scope>,
|
115
|
+
enableRecovery?: boolean,
|
111
116
|
): [ParseMotokoTypedWithScopeCacheResult | ParseMotokoTypedWithScopeCacheResult[], Map<string, Scope>] {
|
117
|
+
if (enableRecovery === undefined) {
|
118
|
+
enableRecovery = false;
|
119
|
+
}
|
112
120
|
if (typeof paths === 'string') {
|
113
|
-
const [progs, outCache] = mo.parseMotokoTypedWithScopeCache([paths], scopeCache);
|
121
|
+
const [progs, outCache] = mo.parseMotokoTypedWithScopeCache([paths], scopeCache, enableRecovery);
|
114
122
|
return [progs[0], outCache];
|
115
123
|
}
|
116
124
|
const [progs, outCache] =
|
117
|
-
invoke('parseMotokoTypedWithScopeCache', true, [paths, scopeCache]);
|
125
|
+
invoke('parseMotokoTypedWithScopeCache', true, [enableRecovery, paths, scopeCache]);
|
118
126
|
return [
|
119
127
|
progs.map(
|
120
128
|
({ ast, typ, immediateImports }: {
|
@@ -226,16 +234,17 @@ export default function wrapMotoko(compiler: Compiler) {
|
|
226
234
|
parseCandid(content: string): object {
|
227
235
|
return invoke('parseCandid', true, [content]);
|
228
236
|
},
|
229
|
-
parseMotoko(content: string): Node {
|
230
|
-
const ast = invoke('parseMotoko', true, [content]);
|
237
|
+
parseMotoko(content: string, enableRecovery = false): Node {
|
238
|
+
const ast = invoke('parseMotoko', true, [enableRecovery, content]);
|
231
239
|
return simplifyAST(ast);
|
232
240
|
},
|
233
241
|
parseMotokoWithDeps(
|
234
242
|
path: string,
|
235
243
|
content: string,
|
244
|
+
enableRecovery = false,
|
236
245
|
): { ast: Node, immediateImports: string[] } {
|
237
246
|
const { ast, immediateImports } =
|
238
|
-
invoke('parseMotokoWithDeps', true, [path, content]);
|
247
|
+
invoke('parseMotokoWithDeps', true, [enableRecovery, path, content]);
|
239
248
|
return { ast: simplifyAST(ast), immediateImports };
|
240
249
|
},
|
241
250
|
parseMotokoTyped,
|