mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Demo protobufs in deno2.
Adds deno_set_response() to allow stack allocated responses.
This commit is contained in:
parent
f97216609d
commit
4ac67cf343
10 changed files with 88 additions and 35 deletions
|
@ -4,11 +4,32 @@ import * as ts from "typescript";
|
|||
|
||||
const globalEval = eval;
|
||||
const window = globalEval("this");
|
||||
|
||||
window["denoMain"] = () => {
|
||||
denoPrint("Hello world");
|
||||
const msg = pb.Msg.fromObject({});
|
||||
denoPrint(`msg.command: ${msg.command}`);
|
||||
denoPrint(`ts.version: ${ts.version}`);
|
||||
denoPrint("Hello world from foo");
|
||||
return "foo";
|
||||
const res = denoPub("startDeno2", emptyArrayBuffer());
|
||||
//denoPrint(`after`);
|
||||
const resUi8 = new Uint8Array(res);
|
||||
denoPrint(`before`);
|
||||
const msg = pb.Msg.decode(resUi8);
|
||||
denoPrint(`after`);
|
||||
const {
|
||||
startCwd: cwd,
|
||||
startArgv: argv,
|
||||
startDebugFlag: debugFlag,
|
||||
startMainJs: mainJs,
|
||||
startMainMap: mainMap
|
||||
} = msg;
|
||||
denoPrint(`cwd: ${cwd}`);
|
||||
};
|
||||
|
||||
function typedArrayToArrayBuffer(ta: Uint8Array): ArrayBuffer {
|
||||
return ta.buffer.slice(
|
||||
ta.byteOffset,
|
||||
ta.byteOffset + ta.byteLength
|
||||
) as ArrayBuffer;
|
||||
}
|
||||
|
||||
function emptyArrayBuffer(): ArrayBuffer {
|
||||
return typedArrayToArrayBuffer(new Uint8Array([]));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue