motoko 3.6.15 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  installPackages,
8
8
  validatePackage,
9
9
  } from './package';
10
+ import { asciiToUtf8 } from './utils/asciiToUtf8';
10
11
  import { resolveLib, resolveMain } from './utils/resolveEntryPoint';
11
12
 
12
13
  export type Motoko = ReturnType<typeof wrapMotoko>;
@@ -164,7 +165,10 @@ export default function wrapMotoko(compiler: Compiler) {
164
165
  path: string,
165
166
  libPaths?: string[] | undefined,
166
167
  ): { stdout: string; stderr: string; result: Result } {
167
- return invoke('run', false, [libPaths || [], path]);
168
+ const run = invoke('run', false, [libPaths || [], path]);
169
+ run.stdout = asciiToUtf8(run.stdout);
170
+ run.stderr = asciiToUtf8(run.stderr);
171
+ return run;
168
172
  },
169
173
  candid(path: string): string {
170
174
  return invoke('candid', true, [path]);
package/src/keywords.ts CHANGED
@@ -15,6 +15,7 @@ export const keywords = [
15
15
  'do',
16
16
  'else',
17
17
  'false',
18
+ 'finally',
18
19
  'flexible',
19
20
  'for',
20
21
  'from_candid',
@@ -0,0 +1,10 @@
1
+ const textDecoder = new TextDecoder();
2
+
3
+ /// Convert an ASCII string from `js_of_ocaml` to a UTF-8 string.
4
+ export const asciiToUtf8 = (text: string): string => {
5
+ return textDecoder.decode(
6
+ Uint8Array.from({ length: text.length }).map((_, i) =>
7
+ text.charCodeAt(i),
8
+ ),
9
+ );
10
+ };