summaryrefslogtreecommitdiff
path: root/src/js/main.ts
diff options
context:
space:
mode:
authorTristan Marion <trismarion@gmail.com>2018-06-22 15:30:35 +0200
committerRyan Dahl <ry@tinyclouds.org>2018-06-22 15:30:35 +0200
commit3b595253a2e9f8badc416f85d0b09bf48f344634 (patch)
tree85939e43b504cf0ff78f69a1912209e90b67ffe5 /src/js/main.ts
parent86354a29a40fb97e334f951428239ab8e171e2dd (diff)
Move `deno2` folder to `src` (#277)
Diffstat (limited to 'src/js/main.ts')
-rw-r--r--src/js/main.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/js/main.ts b/src/js/main.ts
new file mode 100644
index 000000000..d2d61f419
--- /dev/null
+++ b/src/js/main.ts
@@ -0,0 +1,41 @@
+/// <reference path="deno.d.ts" />
+import { deno as pb } from "./msg.pb";
+import * as ts from "typescript";
+
+const globalEval = eval;
+const window = globalEval("this");
+
+window["denoMain"] = () => {
+ deno.print(`ts.version: ${ts.version}`);
+ const res = deno.pub("startDeno2", emptyArrayBuffer());
+ //deno.print(`after`);
+ const resUi8 = new Uint8Array(res);
+ deno.print(`before`);
+ const msg = pb.Msg.decode(resUi8);
+ deno.print(`after`);
+ const {
+ startCwd: cwd,
+ startArgv: argv,
+ startDebugFlag: debugFlag,
+ startMainJs: mainJs,
+ startMainMap: mainMap
+ } = msg;
+
+ deno.print(`cwd: ${cwd}`);
+ deno.print(`debugFlag: ${debugFlag}`);
+
+ for (let i = 0; i < argv.length; i++) {
+ deno.print(`argv[${i}] ${argv[i]}`);
+ }
+};
+
+function typedArrayToArrayBuffer(ta: Uint8Array): ArrayBuffer {
+ return ta.buffer.slice(
+ ta.byteOffset,
+ ta.byteOffset + ta.byteLength
+ ) as ArrayBuffer;
+}
+
+function emptyArrayBuffer(): ArrayBuffer {
+ return typedArrayToArrayBuffer(new Uint8Array([]));
+}