1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-22 15:10:44 -05:00
denoland-deno/js/main.ts

43 lines
1 KiB
TypeScript
Raw Normal View History

2018-07-01 23:53:21 +04:30
// tslint:disable-next-line:no-reference
2018-06-12 03:54:55 +02:00
/// <reference path="deno.d.ts" />
import * as ts from "typescript";
2018-07-01 23:53:21 +04:30
import { deno as pb } from "./msg.pb";
2018-06-12 03:54:55 +02:00
const globalEval = eval;
const window = globalEval("this");
2018-06-11 22:29:34 +02:00
window["denoMain"] = () => {
2018-06-14 14:31:31 +02:00
deno.print(`ts.version: ${ts.version}`);
const res = deno.send("startDeno2", emptyArrayBuffer());
2018-07-01 23:53:21 +04:30
// deno.print(`after`);
const resUi8 = new Uint8Array(res);
2018-06-14 14:31:31 +02:00
deno.print(`before`);
const msg = pb.Msg.decode(resUi8);
2018-06-14 14:31:31 +02:00
deno.print(`after`);
const {
startCwd: cwd,
startArgv: argv,
startDebugFlag: debugFlag,
startMainJs: mainJs,
startMainMap: mainMap
} = msg;
2018-06-14 01:40:35 +02:00
2018-06-14 14:31:31 +02:00
deno.print(`cwd: ${cwd}`);
deno.print(`debugFlag: ${debugFlag}`);
2018-06-14 01:40:35 +02:00
for (let i = 0; i < argv.length; i++) {
2018-06-14 14:31:31 +02:00
deno.print(`argv[${i}] ${argv[i]}`);
2018-06-14 01:40:35 +02:00
}
2018-06-11 21:32:06 +02: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([]));
}