motoko 3.6.15 → 3.6.16
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/asciiToUtf8.d.ts +2 -0
- package/lib/utils/asciiToUtf8.d.ts.map +1 -0
- package/lib/utils/asciiToUtf8.js +10 -0
- package/lib/utils/asciiToUtf8.js.map +1 -0
- package/package.json +1 -1
- package/packages/latest/base.json +1 -1
- package/src/index.ts +5 -1
- package/src/utils/asciiToUtf8.ts +10 -0
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
|
-
|
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]);
|
@@ -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
|
+
};
|