motoko 3.0.0-beta4 → 3.0.0-beta6

Sign up to get free protection for your applications and to get access to all the features.
package/src/index.ts CHANGED
@@ -28,15 +28,11 @@ export type Diagnostic = {
28
28
 
29
29
  export type WasmMode = 'ic' | 'wasi';
30
30
 
31
- export default function wrapMotoko(compiler: Compiler, version: string) {
31
+ export default function wrapMotoko(compiler: Compiler) {
32
+ const version = compiler.version || '(unknown)';
32
33
  const debug = require('debug')(`motoko:${version}`);
33
34
 
34
35
  const invoke = (key: string, unwrap: boolean, args: any[]) => {
35
- if (!compiler) {
36
- throw new Error(
37
- 'Please load a Motoko compiler before running this function',
38
- );
39
- }
40
36
  if (typeof compiler[key] !== 'function') {
41
37
  throw new Error(`Unknown compiler function: '${key}'`);
42
38
  }
@@ -143,8 +139,9 @@ export default function wrapMotoko(compiler: Compiler, version: string) {
143
139
  validatePackage(pkg: Package) {
144
140
  validatePackage(pkg);
145
141
  },
146
- setAliases(aliases: Record<string, string>) {
147
- debug('aliases', aliases);
142
+ setAliases(directory: string, aliases: Record<string, string>) {
143
+ debug('aliases', directory, aliases);
144
+ invoke('setCandidPath', false, [directory]);
148
145
  invoke('setActorAliases', false, [Object.entries(aliases)]);
149
146
  },
150
147
  setMetadata(values: string) {
@@ -0,0 +1,72 @@
1
+ export const keywords = [
2
+ 'actor',
3
+ 'and',
4
+ 'async',
5
+ 'assert',
6
+ 'await',
7
+ 'break',
8
+ 'case',
9
+ 'catch',
10
+ 'class',
11
+ 'continue',
12
+ 'debug',
13
+ 'debug_show',
14
+ 'do',
15
+ 'else',
16
+ 'false',
17
+ 'flexible',
18
+ 'for',
19
+ 'from_candid',
20
+ 'func',
21
+ 'if',
22
+ 'ignore',
23
+ 'in',
24
+ 'import',
25
+ 'label',
26
+ 'let',
27
+ 'loop',
28
+ 'module',
29
+ 'not',
30
+ 'null',
31
+ 'object',
32
+ 'or',
33
+ 'private',
34
+ 'public',
35
+ 'query',
36
+ 'return',
37
+ 'shared',
38
+ 'stable',
39
+ 'switch',
40
+ 'system',
41
+ 'throw',
42
+ 'to_candid',
43
+ 'true',
44
+ 'try',
45
+ 'type',
46
+ 'var',
47
+ 'while',
48
+ 'with',
49
+ ];
50
+
51
+ export const typeKeywords = [
52
+ 'Any',
53
+ 'None',
54
+ 'Null',
55
+ 'Bool',
56
+ 'Int',
57
+ 'Int8',
58
+ 'Int16',
59
+ 'Int32',
60
+ 'Int64',
61
+ 'Nat',
62
+ 'Nat8',
63
+ 'Nat16',
64
+ 'Nat32',
65
+ 'Nat64',
66
+ 'Float',
67
+ 'Char',
68
+ 'Text',
69
+ 'Blob',
70
+ 'Error',
71
+ 'Principal',
72
+ ];
@@ -1,4 +1,4 @@
1
1
  import wrapMotoko from '..';
2
2
  const { Motoko } = require('../../versions/latest/moc_interpreter.min');
3
3
 
4
- export default wrapMotoko(Motoko, 'latest/interpreter');
4
+ export default wrapMotoko(Motoko);
@@ -1,4 +1,4 @@
1
1
  import wrapMotoko from '..';
2
2
  const { Motoko } = require('../../versions/latest/moc.min');
3
3
 
4
- export default wrapMotoko(Motoko, 'latest');
4
+ export default wrapMotoko(Motoko);