0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/deno2/js/main.ts

42 lines
1,018 B
TypeScript
Raw Normal View History

2018-06-11 21:54:55 -04:00
/// <reference path="deno.d.ts" />
2018-06-13 13:37:24 -04:00
import { deno as pb } from "./msg.pb";
2018-06-11 21:54:55 -04:00
import * as ts from "typescript";
const globalEval = eval;
const window = globalEval("this");
2018-06-11 16:29:34 -04:00
window["denoMain"] = () => {
2018-06-14 08:31:31 -04:00
deno.print(`ts.version: ${ts.version}`);
const res = deno.pub("startDeno2", emptyArrayBuffer());
//deno.print(`after`);
const resUi8 = new Uint8Array(res);
2018-06-14 08:31:31 -04:00
deno.print(`before`);
const msg = pb.Msg.decode(resUi8);
2018-06-14 08:31:31 -04:00
deno.print(`after`);
const {
startCwd: cwd,
startArgv: argv,
startDebugFlag: debugFlag,
startMainJs: mainJs,
startMainMap: mainMap
} = msg;
2018-06-13 19:40:35 -04:00
2018-06-14 08:31:31 -04:00
deno.print(`cwd: ${cwd}`);
deno.print(`debugFlag: ${debugFlag}`);
2018-06-13 19:40:35 -04:00
for (let i = 0; i < argv.length; i++) {
2018-06-14 08:31:31 -04:00
deno.print(`argv[${i}] ${argv[i]}`);
2018-06-13 19:40:35 -04:00
}
2018-06-11 15:32:06 -04:00
};
function typedArrayToArrayBuffer(ta: Uint8Array): ArrayBuffer {
return ta.buffer.slice(
ta.byteOffset,
ta.byteOffset + ta.byteLength
) as ArrayBuffer;
}
function emptyArrayBuffer(): ArrayBuffer {
return typedArrayToArrayBuffer(new Uint8Array([]));
}