motoko 2.0.6 → 2.0.9

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # MotokoJS · [![npm version](https://img.shields.io/npm/v/motoko.svg?logo=npm)](https://www.npmjs.com/package/motoko) [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dfinity/motoko/issues)
3
3
 
4
- > ### Compile [Motoko](https://smartcontracts.org/) smart contracts in Node.js and the browser.
4
+ > #### Compile and run [Motoko](https://smartcontracts.org/) smart contracts in Node.js or the browser.
5
5
 
6
6
  ---
7
7
 
@@ -137,7 +137,7 @@ mo.parseMotoko(motokoString)
137
137
  // Return the parse tree for a Candid string
138
138
  mo.parseCandid(candidString)
139
139
 
140
- // Get the version name
140
+ // Get the compiler version ('latest' by default)
141
141
  mo.version
142
142
 
143
143
  // Access the underlying Motoko compiler
package/contrib/monaco.js CHANGED
@@ -1,44 +1,44 @@
1
- 'use strict'
1
+ 'use strict';
2
2
 
3
3
  /// Monaco editor configuration
4
4
  exports.configure = (monaco) => {
5
- monaco.languages.register({ id: "motoko" });
6
- monaco.languages.setLanguageConfiguration("motoko", {
5
+ monaco.languages.register({ id: 'motoko' });
6
+ monaco.languages.setLanguageConfiguration('motoko', {
7
7
  comments: {
8
- lineComment: "//",
9
- blockComment: ["/*", "*/"],
8
+ lineComment: '//',
9
+ blockComment: ['/*', '*/'],
10
10
  },
11
11
  brackets: [
12
- ["{", "}"],
13
- ["[", "]"],
14
- ["(", ")"],
12
+ ['{', '}'],
13
+ ['[', ']'],
14
+ ['(', ')'],
15
15
  ],
16
16
  autoClosingPairs: [
17
- { open: "{", close: "}" },
18
- { open: "[", close: "]" },
19
- { open: "(", close: ")" },
17
+ { open: '{', close: '}' },
18
+ { open: '[', close: ']' },
19
+ { open: '(', close: ')' },
20
20
  { open: '"', close: '"' },
21
- { open: "<", close: ">" },
21
+ { open: '<', close: '>' },
22
22
  ],
23
23
  });
24
- monaco.languages.setMonarchTokensProvider("motoko", {
25
- defaultToken: "",
26
- tokenPostfix: ".mo",
24
+ monaco.languages.setMonarchTokensProvider('motoko', {
25
+ defaultToken: '',
26
+ tokenPostfix: '.mo',
27
27
  // prettier-ignore
28
28
  keywords: [
29
29
  'actor', 'and', 'async', 'assert', 'await', 'break', 'case', 'catch', 'class',
30
- 'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'for', 'from_candid', 'func', 'if', 'ignore', 'in', 'import',
31
- 'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'return',
32
- 'switch', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
30
+ 'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'flexible', 'for', 'from_candid', 'func', 'if', 'ignore', 'in',
31
+ 'import', 'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'private', 'public', 'query', 'return', 'shared',
32
+ 'stable', 'switch', 'system', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
33
33
  ],
34
34
  accessmodifiers: [
35
- "public",
36
- "private",
37
- "flexible",
38
- "query",
39
- "shared",
40
- "stable",
41
- "system",
35
+ 'public',
36
+ 'private',
37
+ 'flexible',
38
+ 'query',
39
+ 'shared',
40
+ 'stable',
41
+ 'system',
42
42
  ],
43
43
  // prettier-ignore
44
44
  typeKeywords: [
@@ -62,55 +62,68 @@ exports.configure = (monaco) => {
62
62
  /[a-zA-Z_$][\w$]*/,
63
63
  {
64
64
  cases: {
65
- "@typeKeywords": "keyword.type",
66
- "@keywords": "keyword",
67
- "@default": "identifier",
65
+ '@typeKeywords': 'keyword.type',
66
+ '@keywords': 'keyword',
67
+ '@default': 'identifier',
68
68
  },
69
69
  },
70
70
  ],
71
71
  // whitespace
72
- { include: "@whitespace" },
72
+ { include: '@whitespace' },
73
73
 
74
74
  // delimiters and operators
75
- [/[{}()[\]]/, "@brackets"],
76
- [/[<>](?!@symbols)/, "@brackets"],
77
- [/@symbols/, { cases: { "@operators": "operator", "@default": "" } }],
75
+ [/[{}()[\]]/, '@brackets'],
76
+ [/[<>](?!@symbols)/, '@brackets'],
77
+ [
78
+ /@symbols/,
79
+ { cases: { '@operators': 'operator', '@default': '' } },
80
+ ],
78
81
  // numbers
79
- [/\d*\.\d+([eE][-+]?\d+)?/, "number.float"],
80
- [/0[xX][0-9a-fA-F_]+/, "number.hex"],
81
- [/[0-9_]+/, "number"],
82
+ [/\d*\.\d+([eE][-+]?\d+)?/, 'number.float'],
83
+ [/0[xX][0-9a-fA-F_]+/, 'number.hex'],
84
+ [/[0-9_]+/, 'number'],
82
85
 
83
86
  // delimiter: after number because of .\d floats
84
- [/[;,.]/, "delimiter"],
87
+ [/[;,.]/, 'delimiter'],
85
88
 
86
89
  // strings
87
- [/"([^"\\]|\\.)*$/, "string.invalid"], // non-teminated string
88
- [/"/, { token: "string.quote", bracket: "@open", next: "@string" }],
90
+ [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
91
+ [
92
+ /"/,
93
+ {
94
+ token: 'string.quote',
95
+ bracket: '@open',
96
+ next: '@string',
97
+ },
98
+ ],
89
99
 
90
100
  // characters
91
- [/'[^\\']'/, "string"],
92
- [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
93
- [/'/, "string.invalid"],
101
+ [/'[^\\']'/, 'string'],
102
+ [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
103
+ [/'/, 'string.invalid'],
94
104
  ],
95
105
 
96
106
  comment: [
97
- [/[^/*]+/, "comment"],
98
- [/\/\*/, "comment", "@push"], // nested comment
99
- ["\\*/", "comment", "@pop"],
100
- [/[/*]/, "comment"],
107
+ [/[^/*]+/, 'comment'],
108
+ [/\/\*/, 'comment', '@push'], // nested comment
109
+ ['\\*/', 'comment', '@pop'],
110
+ [/[/*]/, 'comment'],
101
111
  ],
102
112
 
103
113
  string: [
104
- [/[^\\"]+/, "string"],
105
- [/@escapes/, "string.escape"],
106
- [/\\./, "string.escape.invalid"],
107
- [/"/, { token: "string.quote", bracket: "@close", next: "@pop" }],
114
+ [/[^\\"]+/, 'string'],
115
+ [/@escapes/, 'string.escape'],
116
+ [/\\./, 'string.escape.invalid'],
117
+ [
118
+ /"/,
119
+ { token: 'string.quote', bracket: '@close', next: '@pop' },
120
+ ],
108
121
  ],
109
122
 
110
123
  whitespace: [
111
- [/[ \t\r\n]+/, "white"],
112
- [/\/\*/, "comment", "@comment"],
113
- [/\/\/.*$/, "comment"],
124
+ [/[ \t\r\n]+/, 'white'],
125
+ [/\/\*/, 'comment', '@comment'],
126
+ [/\/\/.*$/, 'comment'],
114
127
  ],
115
128
  },
116
129
  });
package/index.js CHANGED
@@ -1,6 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('./lib')(
4
- require('./versions/latest/moc.min').Motoko,
5
- 'latest',
6
- );
3
+ module.exports = require('./lib/versions/moc').default;
package/interpreter.js CHANGED
@@ -1,6 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('./lib')(
4
- require('./versions/latest/moc.min').Motoko,
5
- 'latest/interpreter',
6
- );
3
+ module.exports = require('./lib/versions/interpreter').default;
package/lib/file.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { Motoko, WasmMode } from '.';
2
+ export declare type MotokoFile = ReturnType<typeof file>;
3
+ export declare const file: (mo: Motoko, path: string) => {
4
+ readonly path: string;
5
+ clone(): any;
6
+ read(): string;
7
+ write(content: string): void;
8
+ rename(newPath: string): void;
9
+ delete(): void;
10
+ list(): string[];
11
+ check(): import(".").Diagnostic[];
12
+ run(): {
13
+ stdout: string;
14
+ stderr: string;
15
+ result: string | number;
16
+ };
17
+ candid(): string;
18
+ wasm(mode: WasmMode): any;
19
+ parseMotoko(): object;
20
+ parseCandid(): object;
21
+ };
22
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAerC,oBAAY,UAAU,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AAEjD,eAAO,MAAM,IAAI,OAAQ,MAAM,QAAQ,MAAM;;;YAa7B,MAAM;mBAGC,MAAM;oBAGL,MAAM;;;;;;;;;;eAoBX,QAAQ;;;CAW1B,CAAC"}
package/lib/file.js CHANGED
@@ -1,5 +1,6 @@
1
- 'use strict';
2
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.file = void 0;
3
4
  function getValidPath(path) {
4
5
  if (typeof path !== 'string') {
5
6
  throw new Error('File path must be a string');
@@ -12,8 +13,7 @@ function getValidPath(path) {
12
13
  }
13
14
  return path;
14
15
  }
15
-
16
- exports.file = (mo, path) => {
16
+ const file = (mo, path) => {
17
17
  path = getValidPath(path);
18
18
  const result = {
19
19
  get path() {
@@ -44,7 +44,7 @@ exports.file = (mo, path) => {
44
44
  return mo.list(path);
45
45
  },
46
46
  check() {
47
- return mo.check(path, ...args);
47
+ return mo.check(path);
48
48
  },
49
49
  run() {
50
50
  return mo.run(path);
@@ -64,3 +64,5 @@ exports.file = (mo, path) => {
64
64
  };
65
65
  return result;
66
66
  };
67
+ exports.file = file;
68
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":";;;AAEA,SAAS,YAAY,CAAC,IAAY;IAC9B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KACjD;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACtB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,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ACD,IAAI,CAAC,IAAc;YACf,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,WAAW;YACP,OAAO,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,WAAW;YACP,OAAO,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;KACJ,CAAC;IACF,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAlDW,QAAA,IAAI,QAkDf"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { PackageInfo } from './package';
2
+ export declare type Motoko = ReturnType<typeof getMotoko>;
3
+ declare type Compiler = any;
4
+ export declare type Diagnostic = {
5
+ code?: string | number | {
6
+ target: any;
7
+ value: string | number;
8
+ };
9
+ message: string;
10
+ range: {
11
+ start: {
12
+ line: number;
13
+ character: number;
14
+ };
15
+ end: {
16
+ line: number;
17
+ character: number;
18
+ };
19
+ };
20
+ severity: string;
21
+ source?: string;
22
+ tags?: string[];
23
+ };
24
+ export declare type WasmMode = 'ic' | 'wasi';
25
+ export default function getMotoko(compiler: Compiler, version: string): {
26
+ version: string;
27
+ compiler: any;
28
+ file(path: string): {
29
+ readonly path: string;
30
+ clone(): any;
31
+ read(): string;
32
+ write(content: string): void;
33
+ rename(newPath: string): void;
34
+ delete(): void;
35
+ list(): string[];
36
+ check(): Diagnostic[];
37
+ run(): {
38
+ stdout: string;
39
+ stderr: string;
40
+ result: number | string;
41
+ };
42
+ candid(): string;
43
+ wasm(mode: WasmMode): any;
44
+ parseMotoko(): object;
45
+ parseCandid(): object;
46
+ };
47
+ loadPackages(packages: Record<string, string | PackageInfo>): Promise<void>;
48
+ read(path: string): string;
49
+ write(path: string, content?: string): void;
50
+ rename(path: string, newPath: string): void;
51
+ delete(path: string): void;
52
+ list(directory: string): string[];
53
+ addPackage(name: string, directory: string): void;
54
+ clearPackages(): void;
55
+ setAliases(aliases: string): void;
56
+ setMetadata(values: string): void;
57
+ check(path: string): Diagnostic[];
58
+ run(path: string, libPaths?: string[] | undefined): {
59
+ stdout: string;
60
+ stderr: string;
61
+ result: number | string;
62
+ };
63
+ candid(path: string): string;
64
+ wasm(path: string, mode: WasmMode): any;
65
+ parseMotoko(content: string): object;
66
+ parseCandid(content: string): object;
67
+ };
68
+ export {};
69
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtD,oBAAY,MAAM,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,aAAK,QAAQ,GAAG,GAAG,CAAC;AAGpB,oBAAY,UAAU,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG;QAAE,MAAM,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACH,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3C,GAAG,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KAC5C,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,oBAAY,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM;;;eA2ClD,MAAM;;;;;;;;;;oBAiDJ,MAAM;oBAAU,MAAM;oBAAU,MAAM,GAAG,MAAM;;;;;;;2BA7C/B,OAAO,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;eAGtD,MAAM,GAAG,MAAM;gBAGd,MAAM,YAAW,MAAM;iBAOtB,MAAM,WAAW,MAAM;iBAGvB,MAAM;oBAIH,MAAM,GAAG,MAAM,EAAE;qBAGhB,MAAM,aAAa,MAAM;;wBAQtB,MAAM;wBAIN,MAAM;gBAGd,MAAM,GAAG,UAAU,EAAE;cAKvB,MAAM,aACD,MAAM,EAAE,GAAG,SAAS,GAChC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;iBAGjD,MAAM,GAAG,MAAM;eAGjB,MAAM,QAAQ,QAAQ;yBAQZ,MAAM,GAAG,MAAM;yBAGf,MAAM,GAAG,MAAM;EAO3C"}
package/lib/index.js CHANGED
@@ -1,16 +1,21 @@
1
- 'use strict';
2
-
3
- const { file } = require('./file');
4
- const { /* findPackage, */ loadPackages } = require('./package');
5
-
6
- module.exports = (compiler, version) => {
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const file_1 = require("./file");
13
+ const package_1 = require("./package");
14
+ function getMotoko(compiler, version) {
7
15
  const debug = require('debug')(version ? `motoko:${version}` : 'motoko');
8
-
9
16
  const invoke = (key, unwrap, args) => {
10
17
  if (!compiler) {
11
- throw new Error(
12
- 'Please load a Motoko compiler before running this function',
13
- );
18
+ throw new Error('Please load a Motoko compiler before running this function');
14
19
  }
15
20
  if (typeof compiler[key] !== 'function') {
16
21
  throw new Error(`Unknown compiler function: '${key}'`);
@@ -18,40 +23,38 @@ module.exports = (compiler, version) => {
18
23
  let result;
19
24
  try {
20
25
  result = compiler[key](...args);
21
- } catch (err) {
26
+ }
27
+ catch (err) {
22
28
  if (err instanceof Error) {
23
29
  throw err;
24
30
  }
25
- throw new Error(
26
- `Unable to execute ${key}(${[...args]
27
- .map((x) => typeof x)
28
- .join(', ')}):\n${JSON.stringify(err)}`,
29
- );
31
+ throw new Error(`Unable to execute ${key}(${[...args]
32
+ .map((x) => typeof x)
33
+ .join(', ')}):\n${JSON.stringify(err)}`);
30
34
  }
31
35
  if (!unwrap) {
32
36
  return result;
33
37
  }
34
38
  if (!result.code) {
35
- throw new Error(
36
- result.diagnostics
37
- ? result.diagnostics
38
- .map(({ message }) => message)
39
- .join('; ')
40
- : '(no diagnostics)',
41
- );
39
+ throw new Error(result.diagnostics
40
+ ? result.diagnostics
41
+ .map(({ message }) => message)
42
+ .join('; ')
43
+ : '(no diagnostics)');
42
44
  }
43
45
  return result.code;
44
46
  };
45
-
46
47
  const mo = {
47
48
  version,
48
49
  compiler,
49
50
  file(path) {
50
- return file(mo, path);
51
+ return (0, file_1.file)(mo, path);
51
52
  },
52
53
  // findPackage,
53
- async loadPackages(packages) {
54
- return loadPackages(mo, packages);
54
+ loadPackages(packages) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return (0, package_1.loadPackages)(mo, packages);
57
+ });
55
58
  },
56
59
  read(path) {
57
60
  return invoke('readFile', false, [path]);
@@ -101,20 +104,22 @@ module.exports = (compiler, version) => {
101
104
  wasm(path, mode) {
102
105
  if (!mode) {
103
106
  mode = 'ic';
104
- } else if (mode !== 'ic' && mode !== 'wasi') {
107
+ }
108
+ else if (mode !== 'ic' && mode !== 'wasi') {
105
109
  throw new Error(`Invalid WASM format: ${mode}`);
106
110
  }
107
111
  return invoke('compileWasm', true, [mode, path]);
108
112
  },
109
113
  parseMotoko(content) {
110
- const ast = invoke('parseMotoko', true, [content]);
111
- return ast;
114
+ return invoke('parseMotoko', true, [content]);
112
115
  },
113
116
  parseCandid(content) {
114
- const ast = invoke('parseCandid', true, [content]);
115
- return ast;
117
+ return invoke('parseCandid', true, [content]);
116
118
  },
117
119
  };
120
+ // @ts-ignore
121
+ mo.default = mo;
118
122
  return mo;
119
- };
120
- exports.default = exports;
123
+ }
124
+ exports.default = getMotoko;
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAC9B,uCAAsD;AAqBtD,SAAwB,SAAS,CAAC,QAAkB,EAAE,OAAe;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAEzE,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,MAAe,EAAE,IAAW,EAAE,EAAE;QACzD,IAAI,CAAC,QAAQ,EAAE;YACX,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;SACL;QACD,IAAI,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,GAAG,CAAC,CAAC;SAC1D;QACD,IAAI,MAAM,CAAC;QACX,IAAI;YACA,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACV,IAAI,GAAG,YAAY,KAAK,EAAE;gBACtB,MAAM,GAAG,CAAC;aACb;YACD,MAAM,IAAI,KAAK,CACX,qBAAqB,GAAG,IAAI,CAAC,GAA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AAE,KAAK,EAAE,CAAC,QAAQ,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,CAAC,IAAY;YACf,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC,IAAY,EAAE,IAAc;YAC7B,IAAI,CAAC,IAAI,EAAE;gBACP,IAAI,GAAG,IAAI,CAAC;aACf;iBAAM,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,MAAM,EAAE;gBACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;aACnD;YACD,OAAO,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,CAAC,OAAe;YACvB,OAAO,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,WAAW,CAAC,OAAe;YACvB,OAAO,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,CAAC;KACJ,CAAC;IACF,aAAa;IACb,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC;AACd,CAAC;AApHD,4BAoHC"}
@@ -0,0 +1,10 @@
1
+ import { Motoko } from '.';
2
+ export interface PackageInfo {
3
+ name: string;
4
+ repo: string;
5
+ version: string;
6
+ dir: string;
7
+ branch?: string | undefined;
8
+ }
9
+ export declare function loadPackages(mo: Motoko, packages: Record<string, string | PackageInfo>): Promise<void>;
10
+ //# sourceMappingURL=package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../src/package.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAE3B,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AA0JD,wBAAsB,YAAY,CAC9B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,iBAQjD"}