From 06a28998ea3fd38a2173d71eeb3fae5fb5559b2e Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 4 Jul 2018 14:50:28 -0400 Subject: [PATCH] Replace protobufs with flatbuffers --- .gitignore | 3 +- BUILD.gn | 54 +- gclient_config.py | 15 +- js/flatbufferjs_hack.py | 33 + js/main.ts | 28 +- js/msg.pb.d.ts | 314 ------ js/msg.pb.js | 1100 --------------------- js/msg_generated.ts | 161 +++ js/package.json | 10 +- js/pbjs_hack.py | 48 - src/main.rs | 1 + src/mock_main.cc | 28 +- src/msg.fbs | 12 + src/msg.proto | 96 -- src/snapshot_creator.cc | 2 +- third_party/flatbuffers/BUILD.gn | 120 +++ third_party/flatbuffers/LICENSE | 202 ++++ third_party/flatbuffers/OWNERS | 3 + third_party/flatbuffers/README.chromium | 14 + third_party/flatbuffers/flatbuffer.gni | 148 +++ third_party/flatbuffers/ts_flatbuffer.gni | 84 ++ third_party/yarn.lock | 262 +---- tools/format.sh | 4 +- tools/lint.sh | 3 +- tools/protoc_wrapper | 1 - 25 files changed, 871 insertions(+), 1875 deletions(-) create mode 100755 js/flatbufferjs_hack.py delete mode 100644 js/msg.pb.d.ts delete mode 100644 js/msg.pb.js create mode 100644 js/msg_generated.ts delete mode 100755 js/pbjs_hack.py create mode 100644 src/msg.fbs delete mode 100644 src/msg.proto create mode 100644 third_party/flatbuffers/BUILD.gn create mode 100644 third_party/flatbuffers/LICENSE create mode 100644 third_party/flatbuffers/OWNERS create mode 100644 third_party/flatbuffers/README.chromium create mode 100644 third_party/flatbuffers/flatbuffer.gni create mode 100644 third_party/flatbuffers/ts_flatbuffer.gni delete mode 120000 tools/protoc_wrapper diff --git a/.gitignore b/.gitignore index c8cf15063a..73b7b0c45d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,10 @@ node_modules # git deps /third_party/v8/ -/third_party/tools/protoc_wrapper/ /third_party/cpplint/ -/third_party/protobuf/ /third_party/zlib/ /third_party/rust_crates/libc/ +/third_party/flatbuffers/src/ # gclient files /third_party/.gclient_entries diff --git a/BUILD.gn b/BUILD.gn index 3785042ec4..380e29edb3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,6 +1,7 @@ -import("//third_party/protobuf/proto_library.gni") import("//third_party/v8/gni/v8.gni") import("//third_party/v8/snapshot_toolchain.gni") +import("//third_party/flatbuffers/flatbuffer.gni") +import("//third_party/flatbuffers/ts_flatbuffer.gni") import("deno.gni") import("rust.gni") @@ -30,9 +31,9 @@ executable("mock_main") { "src/mock_main.cc", ] deps = [ + ":flatbufferjs", ":libdeno", - ":msg_proto", - "//third_party/protobuf:protoc_lib", + ":msg_cpp", ] configs += [ ":deno_config" ] } @@ -89,26 +90,24 @@ executable("snapshot_creator") { configs += [ ":deno_config" ] } -proto_library("msg_proto") { +flatbuffer("msg_cpp") { sources = [ - "src/msg.proto", + "src/msg.fbs", ] - generate_python = false } run_node("bundle") { out_dir = "$target_gen_dir/bundle/" sources = [ "js/main.ts", - "js/msg.pb.d.ts", - "js/msg.pb.js", + "js/msg_generated.ts", "js/package.json", # The `browserslist` field controls Babel behavior. ] outputs = [ out_dir + "main.js", ] deps = [ - ":protobufjs", + ":flatbufferjs", ":run_tsc", ] args = [ @@ -128,8 +127,7 @@ run_node("run_tsc") { tsconfig = "tsconfig.json" out_dir = "$target_gen_dir/tsc_dist/" sources = [ - "js/msg.pb.d.ts", - "js/msg.pb.js", + "js/msg_generated.ts", main, tsconfig, ] @@ -137,7 +135,7 @@ run_node("run_tsc") { out_dir + "/main.js", ] deps = [ - ":protobufjs", + ":flatbufferjs", ] args = [ "./node_modules/typescript/bin/tsc", @@ -148,26 +146,38 @@ run_node("run_tsc") { ] } -# Generates protobufjs code. -# TODO(ry) Ideally protobufjs output files should be written into +# Generates flatbuffer TypeScript code. +# TODO(ry) Ideally flatc output files should be written into # target_gen_dir, but its difficult to get this working in a way that the # bundler can resolve their location. (The bundler does not support NODE_PATH?) -# Therefore this hack: write the generated msg.pb.js and msg.pb.d.ts outputs -# into the js/ folder, and we check them into the repo. Hopefully this hack can -# be removed at some point. If msg.proto is changed, commit changes to the +# Therefore this hack: write the msg_generated.ts output +# into the js/ folder, and we check it into the repo. Hopefully this hack can +# be removed at some point. If msg.fps is changed, commit changes to the # generated JS files. The stamp file is just to make gn work. -action("protobufjs") { - script = "js/pbjs_hack.py" +action("flatbufferjs") { + script = "js/flatbufferjs_hack.py" sources = [ - "src/msg.proto", + "src/msg.fbs", ] outputs = [ - "$target_gen_dir/pbjs_hack.stamp", + "$target_gen_dir/flatbufferjs_hack.stamp", ] + args = [ - rebase_path(sources[0], root_build_dir), + rebase_path("$target_gen_dir/msg_generated.ts", root_build_dir), + rebase_path("js/msg_generated.ts", root_build_dir), rebase_path(outputs[0], root_build_dir), ] + + deps = [ + ":msg_ts", + ] +} + +ts_flatbuffer("msg_ts") { + sources = [ + "src/msg.fbs", + ] } # Generates $target_gen_dir/snapshot_deno.cc diff --git a/gclient_config.py b/gclient_config.py index 409a8b0f89..3113440bac 100644 --- a/gclient_config.py +++ b/gclient_config.py @@ -17,14 +17,6 @@ solutions = [{ 'v8/test/test262/harness': None, 'v8/tools/luci-go': None } -}, { - 'url': 'https://github.com/ry/protobuf_chromium.git', - 'name': 'protobuf', -}, { - 'url': - 'https://chromium.googlesource.com/chromium/src/tools/protoc_wrapper@9af82fef8cb9ca3ccc13e2ed958f58f2c21f449b', - 'name': - 'tools/protoc_wrapper' }, { 'url': 'https://chromium.googlesource.com/chromium/src/third_party/zlib@39b4a6260702da4c089eca57136abf40a39667e9', @@ -35,6 +27,13 @@ solutions = [{ 'https://github.com/cpplint/cpplint.git@a33992f68f36fcaa6d0f531a25012a4c474d3542', 'name': 'cpplint' +}, { + # Tracking a bleeding-edge branch that is nearing rust support. + # https://github.com/google/flatbuffers/pull/3894 + 'url': + 'https://github.com/rw/flatbuffers.git@2018-02--rust', + 'name': + 'flatbuffers/src' }, { 'url': 'https://github.com/rust-lang/libc.git@8a85d662b90c14d458bc4ae9521a05564e20d7ae', diff --git a/js/flatbufferjs_hack.py b/js/flatbufferjs_hack.py new file mode 100755 index 0000000000..2f411c1db3 --- /dev/null +++ b/js/flatbufferjs_hack.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +""" +gn can only run python scripts. + +Generates flatbuffer TypeScript code. +""" +import subprocess +import sys +import os +import shutil + +# TODO(ry) Ideally flatc output files should be written into target_gen_dir, but +# its difficult to get this working in a way that parcel can resolve their +# location. (Parcel does not support NODE_PATH.) Therefore this hack: write the +# generated msg_generated.ts outputs into the js/ folder, and we check them into +# the repo. Hopefully this hack can be removed at some point. If msg.fps is +# changed, commit changes to the generated JS file. + +src = sys.argv[1] +dst = sys.argv[2] +stamp_file = sys.argv[3] + +shutil.copyfile(src, dst) + + +def touch(fname): + if os.path.exists(fname): + os.utime(fname, None) + else: + open(fname, 'a').close() + + +touch(stamp_file) diff --git a/js/main.ts b/js/main.ts index ae98ad5d40..3613f3c890 100644 --- a/js/main.ts +++ b/js/main.ts @@ -1,7 +1,9 @@ // tslint:disable-next-line:no-reference /// import * as ts from "typescript"; -import { deno as pb } from "./msg.pb"; + +import { flatbuffers } from "flatbuffers"; +import { deno as fbs } from "./msg_generated"; const globalEval = eval; const window = globalEval("this"); @@ -11,22 +13,20 @@ window["denoMain"] = () => { const res = deno.send("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; + const bb = new flatbuffers.ByteBuffer(resUi8); + const msg = fbs.Msg.getRootAsMsg(bb); + + // startDebugFlag: debugFlag, + // startMainJs: mainJs, + // startMainMap: mainMap + const cwd = msg.startCwd(); deno.print(`cwd: ${cwd}`); - deno.print(`debugFlag: ${debugFlag}`); - for (let i = 0; i < argv.length; i++) { - deno.print(`argv[${i}] ${argv[i]}`); + const argv: string[] = []; + for (let i = 0; i < msg.startArgvLength(); i++) { + const arg = msg.startArgv(i); + deno.print(`argv[${i}] ${arg}`); } }; diff --git a/js/msg.pb.d.ts b/js/msg.pb.d.ts deleted file mode 100644 index 081e2abf10..0000000000 --- a/js/msg.pb.d.ts +++ /dev/null @@ -1,314 +0,0 @@ -import * as $protobuf from "protobufjs"; - -/** Namespace deno. */ -export namespace deno { - - /** Properties of a Msg. */ - interface IMsg { - - /** Msg command */ - command?: (deno.Msg.Command|null); - - /** Msg error */ - error?: (string|null); - - /** Msg startCwd */ - startCwd?: (string|null); - - /** Msg startArgv */ - startArgv?: (string[]|null); - - /** Msg startDebugFlag */ - startDebugFlag?: (boolean|null); - - /** Msg startMainJs */ - startMainJs?: (string|null); - - /** Msg startMainMap */ - startMainMap?: (string|null); - - /** Msg codeFetchModuleSpecifier */ - codeFetchModuleSpecifier?: (string|null); - - /** Msg codeFetchContainingFile */ - codeFetchContainingFile?: (string|null); - - /** Msg codeFetchResModuleName */ - codeFetchResModuleName?: (string|null); - - /** Msg codeFetchResFilename */ - codeFetchResFilename?: (string|null); - - /** Msg codeFetchResSourceCode */ - codeFetchResSourceCode?: (string|null); - - /** Msg codeFetchResOutputCode */ - codeFetchResOutputCode?: (string|null); - - /** Msg codeCacheFilename */ - codeCacheFilename?: (string|null); - - /** Msg codeCacheSourceCode */ - codeCacheSourceCode?: (string|null); - - /** Msg codeCacheOutputCode */ - codeCacheOutputCode?: (string|null); - - /** Msg exitCode */ - exitCode?: (number|null); - - /** Msg timerStartId */ - timerStartId?: (number|null); - - /** Msg timerStartInterval */ - timerStartInterval?: (boolean|null); - - /** Msg timerStartDelay */ - timerStartDelay?: (number|null); - - /** Msg timerReadyId */ - timerReadyId?: (number|null); - - /** Msg timerReadyDone */ - timerReadyDone?: (boolean|null); - - /** Msg timerClearId */ - timerClearId?: (number|null); - - /** Msg fetchReqId */ - fetchReqId?: (number|null); - - /** Msg fetchReqUrl */ - fetchReqUrl?: (string|null); - - /** Msg fetchResId */ - fetchResId?: (number|null); - - /** Msg fetchResStatus */ - fetchResStatus?: (number|null); - - /** Msg fetchResHeaderLine */ - fetchResHeaderLine?: (string[]|null); - - /** Msg fetchResBody */ - fetchResBody?: (Uint8Array|null); - - /** Msg readFileSyncFilename */ - readFileSyncFilename?: (string|null); - - /** Msg readFileSyncData */ - readFileSyncData?: (Uint8Array|null); - - /** Msg writeFileSyncFilename */ - writeFileSyncFilename?: (string|null); - - /** Msg writeFileSyncData */ - writeFileSyncData?: (Uint8Array|null); - - /** Msg writeFileSyncPerm */ - writeFileSyncPerm?: (number|null); - } - - /** Represents a Msg. */ - class Msg implements IMsg { - - /** - * Constructs a new Msg. - * @param [properties] Properties to set - */ - constructor(properties?: deno.IMsg); - - /** Msg command. */ - public command: deno.Msg.Command; - - /** Msg error. */ - public error: string; - - /** Msg startCwd. */ - public startCwd: string; - - /** Msg startArgv. */ - public startArgv: string[]; - - /** Msg startDebugFlag. */ - public startDebugFlag: boolean; - - /** Msg startMainJs. */ - public startMainJs: string; - - /** Msg startMainMap. */ - public startMainMap: string; - - /** Msg codeFetchModuleSpecifier. */ - public codeFetchModuleSpecifier: string; - - /** Msg codeFetchContainingFile. */ - public codeFetchContainingFile: string; - - /** Msg codeFetchResModuleName. */ - public codeFetchResModuleName: string; - - /** Msg codeFetchResFilename. */ - public codeFetchResFilename: string; - - /** Msg codeFetchResSourceCode. */ - public codeFetchResSourceCode: string; - - /** Msg codeFetchResOutputCode. */ - public codeFetchResOutputCode: string; - - /** Msg codeCacheFilename. */ - public codeCacheFilename: string; - - /** Msg codeCacheSourceCode. */ - public codeCacheSourceCode: string; - - /** Msg codeCacheOutputCode. */ - public codeCacheOutputCode: string; - - /** Msg exitCode. */ - public exitCode: number; - - /** Msg timerStartId. */ - public timerStartId: number; - - /** Msg timerStartInterval. */ - public timerStartInterval: boolean; - - /** Msg timerStartDelay. */ - public timerStartDelay: number; - - /** Msg timerReadyId. */ - public timerReadyId: number; - - /** Msg timerReadyDone. */ - public timerReadyDone: boolean; - - /** Msg timerClearId. */ - public timerClearId: number; - - /** Msg fetchReqId. */ - public fetchReqId: number; - - /** Msg fetchReqUrl. */ - public fetchReqUrl: string; - - /** Msg fetchResId. */ - public fetchResId: number; - - /** Msg fetchResStatus. */ - public fetchResStatus: number; - - /** Msg fetchResHeaderLine. */ - public fetchResHeaderLine: string[]; - - /** Msg fetchResBody. */ - public fetchResBody: Uint8Array; - - /** Msg readFileSyncFilename. */ - public readFileSyncFilename: string; - - /** Msg readFileSyncData. */ - public readFileSyncData: Uint8Array; - - /** Msg writeFileSyncFilename. */ - public writeFileSyncFilename: string; - - /** Msg writeFileSyncData. */ - public writeFileSyncData: Uint8Array; - - /** Msg writeFileSyncPerm. */ - public writeFileSyncPerm: number; - - /** - * Creates a new Msg instance using the specified properties. - * @param [properties] Properties to set - * @returns Msg instance - */ - public static create(properties?: deno.IMsg): deno.Msg; - - /** - * Encodes the specified Msg message. Does not implicitly {@link deno.Msg.verify|verify} messages. - * @param message Msg message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: deno.IMsg, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Msg message, length delimited. Does not implicitly {@link deno.Msg.verify|verify} messages. - * @param message Msg message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: deno.IMsg, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Msg message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Msg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): deno.Msg; - - /** - * Decodes a Msg message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Msg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): deno.Msg; - - /** - * Verifies a Msg message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a Msg message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Msg - */ - public static fromObject(object: { [k: string]: any }): deno.Msg; - - /** - * Creates a plain object from a Msg message. Also converts values to other types if specified. - * @param message Msg - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: deno.Msg, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Msg to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - namespace Msg { - - /** Command enum. */ - enum Command { - ERROR = 0, - START = 1, - CODE_FETCH = 2, - CODE_FETCH_RES = 3, - CODE_CACHE = 4, - EXIT = 5, - TIMER_START = 6, - TIMER_READY = 7, - TIMER_CLEAR = 8, - FETCH_REQ = 9, - FETCH_RES = 10, - READ_FILE_SYNC = 11, - READ_FILE_SYNC_RES = 12, - WRITE_FILE_SYNC = 13 - } - } -} diff --git a/js/msg.pb.js b/js/msg.pb.js deleted file mode 100644 index 7ac7fbbcc6..0000000000 --- a/js/msg.pb.js +++ /dev/null @@ -1,1100 +0,0 @@ -/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ -(function(global, factory) { /* global define, require, module */ - - /* AMD */ if (typeof define === 'function' && define.amd) - define(["protobufjs/minimal"], factory); - - /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) - module.exports = factory(require("protobufjs/minimal")); - -})(this, function($protobuf) { - "use strict"; - - // Common aliases - var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; - - // Exported root namespace - var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - - $root.deno = (function() { - - /** - * Namespace deno. - * @exports deno - * @namespace - */ - var deno = {}; - - deno.Msg = (function() { - - /** - * Properties of a Msg. - * @memberof deno - * @interface IMsg - * @property {deno.Msg.Command|null} [command] Msg command - * @property {string|null} [error] Msg error - * @property {string|null} [startCwd] Msg startCwd - * @property {Array.|null} [startArgv] Msg startArgv - * @property {boolean|null} [startDebugFlag] Msg startDebugFlag - * @property {string|null} [startMainJs] Msg startMainJs - * @property {string|null} [startMainMap] Msg startMainMap - * @property {string|null} [codeFetchModuleSpecifier] Msg codeFetchModuleSpecifier - * @property {string|null} [codeFetchContainingFile] Msg codeFetchContainingFile - * @property {string|null} [codeFetchResModuleName] Msg codeFetchResModuleName - * @property {string|null} [codeFetchResFilename] Msg codeFetchResFilename - * @property {string|null} [codeFetchResSourceCode] Msg codeFetchResSourceCode - * @property {string|null} [codeFetchResOutputCode] Msg codeFetchResOutputCode - * @property {string|null} [codeCacheFilename] Msg codeCacheFilename - * @property {string|null} [codeCacheSourceCode] Msg codeCacheSourceCode - * @property {string|null} [codeCacheOutputCode] Msg codeCacheOutputCode - * @property {number|null} [exitCode] Msg exitCode - * @property {number|null} [timerStartId] Msg timerStartId - * @property {boolean|null} [timerStartInterval] Msg timerStartInterval - * @property {number|null} [timerStartDelay] Msg timerStartDelay - * @property {number|null} [timerReadyId] Msg timerReadyId - * @property {boolean|null} [timerReadyDone] Msg timerReadyDone - * @property {number|null} [timerClearId] Msg timerClearId - * @property {number|null} [fetchReqId] Msg fetchReqId - * @property {string|null} [fetchReqUrl] Msg fetchReqUrl - * @property {number|null} [fetchResId] Msg fetchResId - * @property {number|null} [fetchResStatus] Msg fetchResStatus - * @property {Array.|null} [fetchResHeaderLine] Msg fetchResHeaderLine - * @property {Uint8Array|null} [fetchResBody] Msg fetchResBody - * @property {string|null} [readFileSyncFilename] Msg readFileSyncFilename - * @property {Uint8Array|null} [readFileSyncData] Msg readFileSyncData - * @property {string|null} [writeFileSyncFilename] Msg writeFileSyncFilename - * @property {Uint8Array|null} [writeFileSyncData] Msg writeFileSyncData - * @property {number|null} [writeFileSyncPerm] Msg writeFileSyncPerm - */ - - /** - * Constructs a new Msg. - * @memberof deno - * @classdesc Represents a Msg. - * @implements IMsg - * @constructor - * @param {deno.IMsg=} [properties] Properties to set - */ - function Msg(properties) { - this.startArgv = []; - this.fetchResHeaderLine = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Msg command. - * @member {deno.Msg.Command} command - * @memberof deno.Msg - * @instance - */ - Msg.prototype.command = 0; - - /** - * Msg error. - * @member {string} error - * @memberof deno.Msg - * @instance - */ - Msg.prototype.error = ""; - - /** - * Msg startCwd. - * @member {string} startCwd - * @memberof deno.Msg - * @instance - */ - Msg.prototype.startCwd = ""; - - /** - * Msg startArgv. - * @member {Array.} startArgv - * @memberof deno.Msg - * @instance - */ - Msg.prototype.startArgv = $util.emptyArray; - - /** - * Msg startDebugFlag. - * @member {boolean} startDebugFlag - * @memberof deno.Msg - * @instance - */ - Msg.prototype.startDebugFlag = false; - - /** - * Msg startMainJs. - * @member {string} startMainJs - * @memberof deno.Msg - * @instance - */ - Msg.prototype.startMainJs = ""; - - /** - * Msg startMainMap. - * @member {string} startMainMap - * @memberof deno.Msg - * @instance - */ - Msg.prototype.startMainMap = ""; - - /** - * Msg codeFetchModuleSpecifier. - * @member {string} codeFetchModuleSpecifier - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchModuleSpecifier = ""; - - /** - * Msg codeFetchContainingFile. - * @member {string} codeFetchContainingFile - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchContainingFile = ""; - - /** - * Msg codeFetchResModuleName. - * @member {string} codeFetchResModuleName - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchResModuleName = ""; - - /** - * Msg codeFetchResFilename. - * @member {string} codeFetchResFilename - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchResFilename = ""; - - /** - * Msg codeFetchResSourceCode. - * @member {string} codeFetchResSourceCode - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchResSourceCode = ""; - - /** - * Msg codeFetchResOutputCode. - * @member {string} codeFetchResOutputCode - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeFetchResOutputCode = ""; - - /** - * Msg codeCacheFilename. - * @member {string} codeCacheFilename - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeCacheFilename = ""; - - /** - * Msg codeCacheSourceCode. - * @member {string} codeCacheSourceCode - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeCacheSourceCode = ""; - - /** - * Msg codeCacheOutputCode. - * @member {string} codeCacheOutputCode - * @memberof deno.Msg - * @instance - */ - Msg.prototype.codeCacheOutputCode = ""; - - /** - * Msg exitCode. - * @member {number} exitCode - * @memberof deno.Msg - * @instance - */ - Msg.prototype.exitCode = 0; - - /** - * Msg timerStartId. - * @member {number} timerStartId - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerStartId = 0; - - /** - * Msg timerStartInterval. - * @member {boolean} timerStartInterval - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerStartInterval = false; - - /** - * Msg timerStartDelay. - * @member {number} timerStartDelay - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerStartDelay = 0; - - /** - * Msg timerReadyId. - * @member {number} timerReadyId - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerReadyId = 0; - - /** - * Msg timerReadyDone. - * @member {boolean} timerReadyDone - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerReadyDone = false; - - /** - * Msg timerClearId. - * @member {number} timerClearId - * @memberof deno.Msg - * @instance - */ - Msg.prototype.timerClearId = 0; - - /** - * Msg fetchReqId. - * @member {number} fetchReqId - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchReqId = 0; - - /** - * Msg fetchReqUrl. - * @member {string} fetchReqUrl - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchReqUrl = ""; - - /** - * Msg fetchResId. - * @member {number} fetchResId - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchResId = 0; - - /** - * Msg fetchResStatus. - * @member {number} fetchResStatus - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchResStatus = 0; - - /** - * Msg fetchResHeaderLine. - * @member {Array.} fetchResHeaderLine - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchResHeaderLine = $util.emptyArray; - - /** - * Msg fetchResBody. - * @member {Uint8Array} fetchResBody - * @memberof deno.Msg - * @instance - */ - Msg.prototype.fetchResBody = $util.newBuffer([]); - - /** - * Msg readFileSyncFilename. - * @member {string} readFileSyncFilename - * @memberof deno.Msg - * @instance - */ - Msg.prototype.readFileSyncFilename = ""; - - /** - * Msg readFileSyncData. - * @member {Uint8Array} readFileSyncData - * @memberof deno.Msg - * @instance - */ - Msg.prototype.readFileSyncData = $util.newBuffer([]); - - /** - * Msg writeFileSyncFilename. - * @member {string} writeFileSyncFilename - * @memberof deno.Msg - * @instance - */ - Msg.prototype.writeFileSyncFilename = ""; - - /** - * Msg writeFileSyncData. - * @member {Uint8Array} writeFileSyncData - * @memberof deno.Msg - * @instance - */ - Msg.prototype.writeFileSyncData = $util.newBuffer([]); - - /** - * Msg writeFileSyncPerm. - * @member {number} writeFileSyncPerm - * @memberof deno.Msg - * @instance - */ - Msg.prototype.writeFileSyncPerm = 0; - - /** - * Creates a new Msg instance using the specified properties. - * @function create - * @memberof deno.Msg - * @static - * @param {deno.IMsg=} [properties] Properties to set - * @returns {deno.Msg} Msg instance - */ - Msg.create = function create(properties) { - return new Msg(properties); - }; - - /** - * Encodes the specified Msg message. Does not implicitly {@link deno.Msg.verify|verify} messages. - * @function encode - * @memberof deno.Msg - * @static - * @param {deno.IMsg} message Msg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Msg.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.command != null && message.hasOwnProperty("command")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.command); - if (message.error != null && message.hasOwnProperty("error")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.error); - if (message.startCwd != null && message.hasOwnProperty("startCwd")) - writer.uint32(/* id 10, wireType 2 =*/82).string(message.startCwd); - if (message.startArgv != null && message.startArgv.length) - for (var i = 0; i < message.startArgv.length; ++i) - writer.uint32(/* id 11, wireType 2 =*/90).string(message.startArgv[i]); - if (message.startDebugFlag != null && message.hasOwnProperty("startDebugFlag")) - writer.uint32(/* id 12, wireType 0 =*/96).bool(message.startDebugFlag); - if (message.startMainJs != null && message.hasOwnProperty("startMainJs")) - writer.uint32(/* id 13, wireType 2 =*/106).string(message.startMainJs); - if (message.startMainMap != null && message.hasOwnProperty("startMainMap")) - writer.uint32(/* id 14, wireType 2 =*/114).string(message.startMainMap); - if (message.codeFetchModuleSpecifier != null && message.hasOwnProperty("codeFetchModuleSpecifier")) - writer.uint32(/* id 20, wireType 2 =*/162).string(message.codeFetchModuleSpecifier); - if (message.codeFetchContainingFile != null && message.hasOwnProperty("codeFetchContainingFile")) - writer.uint32(/* id 21, wireType 2 =*/170).string(message.codeFetchContainingFile); - if (message.codeFetchResModuleName != null && message.hasOwnProperty("codeFetchResModuleName")) - writer.uint32(/* id 30, wireType 2 =*/242).string(message.codeFetchResModuleName); - if (message.codeFetchResFilename != null && message.hasOwnProperty("codeFetchResFilename")) - writer.uint32(/* id 31, wireType 2 =*/250).string(message.codeFetchResFilename); - if (message.codeFetchResSourceCode != null && message.hasOwnProperty("codeFetchResSourceCode")) - writer.uint32(/* id 32, wireType 2 =*/258).string(message.codeFetchResSourceCode); - if (message.codeFetchResOutputCode != null && message.hasOwnProperty("codeFetchResOutputCode")) - writer.uint32(/* id 33, wireType 2 =*/266).string(message.codeFetchResOutputCode); - if (message.codeCacheFilename != null && message.hasOwnProperty("codeCacheFilename")) - writer.uint32(/* id 41, wireType 2 =*/330).string(message.codeCacheFilename); - if (message.codeCacheSourceCode != null && message.hasOwnProperty("codeCacheSourceCode")) - writer.uint32(/* id 42, wireType 2 =*/338).string(message.codeCacheSourceCode); - if (message.codeCacheOutputCode != null && message.hasOwnProperty("codeCacheOutputCode")) - writer.uint32(/* id 43, wireType 2 =*/346).string(message.codeCacheOutputCode); - if (message.exitCode != null && message.hasOwnProperty("exitCode")) - writer.uint32(/* id 50, wireType 0 =*/400).int32(message.exitCode); - if (message.timerStartId != null && message.hasOwnProperty("timerStartId")) - writer.uint32(/* id 60, wireType 0 =*/480).int32(message.timerStartId); - if (message.timerStartInterval != null && message.hasOwnProperty("timerStartInterval")) - writer.uint32(/* id 61, wireType 0 =*/488).bool(message.timerStartInterval); - if (message.timerStartDelay != null && message.hasOwnProperty("timerStartDelay")) - writer.uint32(/* id 62, wireType 0 =*/496).int32(message.timerStartDelay); - if (message.timerReadyId != null && message.hasOwnProperty("timerReadyId")) - writer.uint32(/* id 70, wireType 0 =*/560).int32(message.timerReadyId); - if (message.timerReadyDone != null && message.hasOwnProperty("timerReadyDone")) - writer.uint32(/* id 71, wireType 0 =*/568).bool(message.timerReadyDone); - if (message.timerClearId != null && message.hasOwnProperty("timerClearId")) - writer.uint32(/* id 80, wireType 0 =*/640).int32(message.timerClearId); - if (message.fetchReqId != null && message.hasOwnProperty("fetchReqId")) - writer.uint32(/* id 90, wireType 0 =*/720).int32(message.fetchReqId); - if (message.fetchReqUrl != null && message.hasOwnProperty("fetchReqUrl")) - writer.uint32(/* id 91, wireType 2 =*/730).string(message.fetchReqUrl); - if (message.fetchResId != null && message.hasOwnProperty("fetchResId")) - writer.uint32(/* id 100, wireType 0 =*/800).int32(message.fetchResId); - if (message.fetchResStatus != null && message.hasOwnProperty("fetchResStatus")) - writer.uint32(/* id 101, wireType 0 =*/808).int32(message.fetchResStatus); - if (message.fetchResHeaderLine != null && message.fetchResHeaderLine.length) - for (var i = 0; i < message.fetchResHeaderLine.length; ++i) - writer.uint32(/* id 102, wireType 2 =*/818).string(message.fetchResHeaderLine[i]); - if (message.fetchResBody != null && message.hasOwnProperty("fetchResBody")) - writer.uint32(/* id 103, wireType 2 =*/826).bytes(message.fetchResBody); - if (message.readFileSyncFilename != null && message.hasOwnProperty("readFileSyncFilename")) - writer.uint32(/* id 110, wireType 2 =*/882).string(message.readFileSyncFilename); - if (message.readFileSyncData != null && message.hasOwnProperty("readFileSyncData")) - writer.uint32(/* id 120, wireType 2 =*/962).bytes(message.readFileSyncData); - if (message.writeFileSyncFilename != null && message.hasOwnProperty("writeFileSyncFilename")) - writer.uint32(/* id 130, wireType 2 =*/1042).string(message.writeFileSyncFilename); - if (message.writeFileSyncData != null && message.hasOwnProperty("writeFileSyncData")) - writer.uint32(/* id 131, wireType 2 =*/1050).bytes(message.writeFileSyncData); - if (message.writeFileSyncPerm != null && message.hasOwnProperty("writeFileSyncPerm")) - writer.uint32(/* id 132, wireType 0 =*/1056).uint32(message.writeFileSyncPerm); - return writer; - }; - - /** - * Encodes the specified Msg message, length delimited. Does not implicitly {@link deno.Msg.verify|verify} messages. - * @function encodeDelimited - * @memberof deno.Msg - * @static - * @param {deno.IMsg} message Msg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Msg.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Msg message from the specified reader or buffer. - * @function decode - * @memberof deno.Msg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {deno.Msg} Msg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Msg.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.deno.Msg(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.command = reader.int32(); - break; - case 2: - message.error = reader.string(); - break; - case 10: - message.startCwd = reader.string(); - break; - case 11: - if (!(message.startArgv && message.startArgv.length)) - message.startArgv = []; - message.startArgv.push(reader.string()); - break; - case 12: - message.startDebugFlag = reader.bool(); - break; - case 13: - message.startMainJs = reader.string(); - break; - case 14: - message.startMainMap = reader.string(); - break; - case 20: - message.codeFetchModuleSpecifier = reader.string(); - break; - case 21: - message.codeFetchContainingFile = reader.string(); - break; - case 30: - message.codeFetchResModuleName = reader.string(); - break; - case 31: - message.codeFetchResFilename = reader.string(); - break; - case 32: - message.codeFetchResSourceCode = reader.string(); - break; - case 33: - message.codeFetchResOutputCode = reader.string(); - break; - case 41: - message.codeCacheFilename = reader.string(); - break; - case 42: - message.codeCacheSourceCode = reader.string(); - break; - case 43: - message.codeCacheOutputCode = reader.string(); - break; - case 50: - message.exitCode = reader.int32(); - break; - case 60: - message.timerStartId = reader.int32(); - break; - case 61: - message.timerStartInterval = reader.bool(); - break; - case 62: - message.timerStartDelay = reader.int32(); - break; - case 70: - message.timerReadyId = reader.int32(); - break; - case 71: - message.timerReadyDone = reader.bool(); - break; - case 80: - message.timerClearId = reader.int32(); - break; - case 90: - message.fetchReqId = reader.int32(); - break; - case 91: - message.fetchReqUrl = reader.string(); - break; - case 100: - message.fetchResId = reader.int32(); - break; - case 101: - message.fetchResStatus = reader.int32(); - break; - case 102: - if (!(message.fetchResHeaderLine && message.fetchResHeaderLine.length)) - message.fetchResHeaderLine = []; - message.fetchResHeaderLine.push(reader.string()); - break; - case 103: - message.fetchResBody = reader.bytes(); - break; - case 110: - message.readFileSyncFilename = reader.string(); - break; - case 120: - message.readFileSyncData = reader.bytes(); - break; - case 130: - message.writeFileSyncFilename = reader.string(); - break; - case 131: - message.writeFileSyncData = reader.bytes(); - break; - case 132: - message.writeFileSyncPerm = reader.uint32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Msg message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof deno.Msg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {deno.Msg} Msg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Msg.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Msg message. - * @function verify - * @memberof deno.Msg - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Msg.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.command != null && message.hasOwnProperty("command")) - switch (message.command) { - default: - return "command: enum value expected"; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - break; - } - if (message.error != null && message.hasOwnProperty("error")) - if (!$util.isString(message.error)) - return "error: string expected"; - if (message.startCwd != null && message.hasOwnProperty("startCwd")) - if (!$util.isString(message.startCwd)) - return "startCwd: string expected"; - if (message.startArgv != null && message.hasOwnProperty("startArgv")) { - if (!Array.isArray(message.startArgv)) - return "startArgv: array expected"; - for (var i = 0; i < message.startArgv.length; ++i) - if (!$util.isString(message.startArgv[i])) - return "startArgv: string[] expected"; - } - if (message.startDebugFlag != null && message.hasOwnProperty("startDebugFlag")) - if (typeof message.startDebugFlag !== "boolean") - return "startDebugFlag: boolean expected"; - if (message.startMainJs != null && message.hasOwnProperty("startMainJs")) - if (!$util.isString(message.startMainJs)) - return "startMainJs: string expected"; - if (message.startMainMap != null && message.hasOwnProperty("startMainMap")) - if (!$util.isString(message.startMainMap)) - return "startMainMap: string expected"; - if (message.codeFetchModuleSpecifier != null && message.hasOwnProperty("codeFetchModuleSpecifier")) - if (!$util.isString(message.codeFetchModuleSpecifier)) - return "codeFetchModuleSpecifier: string expected"; - if (message.codeFetchContainingFile != null && message.hasOwnProperty("codeFetchContainingFile")) - if (!$util.isString(message.codeFetchContainingFile)) - return "codeFetchContainingFile: string expected"; - if (message.codeFetchResModuleName != null && message.hasOwnProperty("codeFetchResModuleName")) - if (!$util.isString(message.codeFetchResModuleName)) - return "codeFetchResModuleName: string expected"; - if (message.codeFetchResFilename != null && message.hasOwnProperty("codeFetchResFilename")) - if (!$util.isString(message.codeFetchResFilename)) - return "codeFetchResFilename: string expected"; - if (message.codeFetchResSourceCode != null && message.hasOwnProperty("codeFetchResSourceCode")) - if (!$util.isString(message.codeFetchResSourceCode)) - return "codeFetchResSourceCode: string expected"; - if (message.codeFetchResOutputCode != null && message.hasOwnProperty("codeFetchResOutputCode")) - if (!$util.isString(message.codeFetchResOutputCode)) - return "codeFetchResOutputCode: string expected"; - if (message.codeCacheFilename != null && message.hasOwnProperty("codeCacheFilename")) - if (!$util.isString(message.codeCacheFilename)) - return "codeCacheFilename: string expected"; - if (message.codeCacheSourceCode != null && message.hasOwnProperty("codeCacheSourceCode")) - if (!$util.isString(message.codeCacheSourceCode)) - return "codeCacheSourceCode: string expected"; - if (message.codeCacheOutputCode != null && message.hasOwnProperty("codeCacheOutputCode")) - if (!$util.isString(message.codeCacheOutputCode)) - return "codeCacheOutputCode: string expected"; - if (message.exitCode != null && message.hasOwnProperty("exitCode")) - if (!$util.isInteger(message.exitCode)) - return "exitCode: integer expected"; - if (message.timerStartId != null && message.hasOwnProperty("timerStartId")) - if (!$util.isInteger(message.timerStartId)) - return "timerStartId: integer expected"; - if (message.timerStartInterval != null && message.hasOwnProperty("timerStartInterval")) - if (typeof message.timerStartInterval !== "boolean") - return "timerStartInterval: boolean expected"; - if (message.timerStartDelay != null && message.hasOwnProperty("timerStartDelay")) - if (!$util.isInteger(message.timerStartDelay)) - return "timerStartDelay: integer expected"; - if (message.timerReadyId != null && message.hasOwnProperty("timerReadyId")) - if (!$util.isInteger(message.timerReadyId)) - return "timerReadyId: integer expected"; - if (message.timerReadyDone != null && message.hasOwnProperty("timerReadyDone")) - if (typeof message.timerReadyDone !== "boolean") - return "timerReadyDone: boolean expected"; - if (message.timerClearId != null && message.hasOwnProperty("timerClearId")) - if (!$util.isInteger(message.timerClearId)) - return "timerClearId: integer expected"; - if (message.fetchReqId != null && message.hasOwnProperty("fetchReqId")) - if (!$util.isInteger(message.fetchReqId)) - return "fetchReqId: integer expected"; - if (message.fetchReqUrl != null && message.hasOwnProperty("fetchReqUrl")) - if (!$util.isString(message.fetchReqUrl)) - return "fetchReqUrl: string expected"; - if (message.fetchResId != null && message.hasOwnProperty("fetchResId")) - if (!$util.isInteger(message.fetchResId)) - return "fetchResId: integer expected"; - if (message.fetchResStatus != null && message.hasOwnProperty("fetchResStatus")) - if (!$util.isInteger(message.fetchResStatus)) - return "fetchResStatus: integer expected"; - if (message.fetchResHeaderLine != null && message.hasOwnProperty("fetchResHeaderLine")) { - if (!Array.isArray(message.fetchResHeaderLine)) - return "fetchResHeaderLine: array expected"; - for (var i = 0; i < message.fetchResHeaderLine.length; ++i) - if (!$util.isString(message.fetchResHeaderLine[i])) - return "fetchResHeaderLine: string[] expected"; - } - if (message.fetchResBody != null && message.hasOwnProperty("fetchResBody")) - if (!(message.fetchResBody && typeof message.fetchResBody.length === "number" || $util.isString(message.fetchResBody))) - return "fetchResBody: buffer expected"; - if (message.readFileSyncFilename != null && message.hasOwnProperty("readFileSyncFilename")) - if (!$util.isString(message.readFileSyncFilename)) - return "readFileSyncFilename: string expected"; - if (message.readFileSyncData != null && message.hasOwnProperty("readFileSyncData")) - if (!(message.readFileSyncData && typeof message.readFileSyncData.length === "number" || $util.isString(message.readFileSyncData))) - return "readFileSyncData: buffer expected"; - if (message.writeFileSyncFilename != null && message.hasOwnProperty("writeFileSyncFilename")) - if (!$util.isString(message.writeFileSyncFilename)) - return "writeFileSyncFilename: string expected"; - if (message.writeFileSyncData != null && message.hasOwnProperty("writeFileSyncData")) - if (!(message.writeFileSyncData && typeof message.writeFileSyncData.length === "number" || $util.isString(message.writeFileSyncData))) - return "writeFileSyncData: buffer expected"; - if (message.writeFileSyncPerm != null && message.hasOwnProperty("writeFileSyncPerm")) - if (!$util.isInteger(message.writeFileSyncPerm)) - return "writeFileSyncPerm: integer expected"; - return null; - }; - - /** - * Creates a Msg message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof deno.Msg - * @static - * @param {Object.} object Plain object - * @returns {deno.Msg} Msg - */ - Msg.fromObject = function fromObject(object) { - if (object instanceof $root.deno.Msg) - return object; - var message = new $root.deno.Msg(); - switch (object.command) { - case "ERROR": - case 0: - message.command = 0; - break; - case "START": - case 1: - message.command = 1; - break; - case "CODE_FETCH": - case 2: - message.command = 2; - break; - case "CODE_FETCH_RES": - case 3: - message.command = 3; - break; - case "CODE_CACHE": - case 4: - message.command = 4; - break; - case "EXIT": - case 5: - message.command = 5; - break; - case "TIMER_START": - case 6: - message.command = 6; - break; - case "TIMER_READY": - case 7: - message.command = 7; - break; - case "TIMER_CLEAR": - case 8: - message.command = 8; - break; - case "FETCH_REQ": - case 9: - message.command = 9; - break; - case "FETCH_RES": - case 10: - message.command = 10; - break; - case "READ_FILE_SYNC": - case 11: - message.command = 11; - break; - case "READ_FILE_SYNC_RES": - case 12: - message.command = 12; - break; - case "WRITE_FILE_SYNC": - case 13: - message.command = 13; - break; - } - if (object.error != null) - message.error = String(object.error); - if (object.startCwd != null) - message.startCwd = String(object.startCwd); - if (object.startArgv) { - if (!Array.isArray(object.startArgv)) - throw TypeError(".deno.Msg.startArgv: array expected"); - message.startArgv = []; - for (var i = 0; i < object.startArgv.length; ++i) - message.startArgv[i] = String(object.startArgv[i]); - } - if (object.startDebugFlag != null) - message.startDebugFlag = Boolean(object.startDebugFlag); - if (object.startMainJs != null) - message.startMainJs = String(object.startMainJs); - if (object.startMainMap != null) - message.startMainMap = String(object.startMainMap); - if (object.codeFetchModuleSpecifier != null) - message.codeFetchModuleSpecifier = String(object.codeFetchModuleSpecifier); - if (object.codeFetchContainingFile != null) - message.codeFetchContainingFile = String(object.codeFetchContainingFile); - if (object.codeFetchResModuleName != null) - message.codeFetchResModuleName = String(object.codeFetchResModuleName); - if (object.codeFetchResFilename != null) - message.codeFetchResFilename = String(object.codeFetchResFilename); - if (object.codeFetchResSourceCode != null) - message.codeFetchResSourceCode = String(object.codeFetchResSourceCode); - if (object.codeFetchResOutputCode != null) - message.codeFetchResOutputCode = String(object.codeFetchResOutputCode); - if (object.codeCacheFilename != null) - message.codeCacheFilename = String(object.codeCacheFilename); - if (object.codeCacheSourceCode != null) - message.codeCacheSourceCode = String(object.codeCacheSourceCode); - if (object.codeCacheOutputCode != null) - message.codeCacheOutputCode = String(object.codeCacheOutputCode); - if (object.exitCode != null) - message.exitCode = object.exitCode | 0; - if (object.timerStartId != null) - message.timerStartId = object.timerStartId | 0; - if (object.timerStartInterval != null) - message.timerStartInterval = Boolean(object.timerStartInterval); - if (object.timerStartDelay != null) - message.timerStartDelay = object.timerStartDelay | 0; - if (object.timerReadyId != null) - message.timerReadyId = object.timerReadyId | 0; - if (object.timerReadyDone != null) - message.timerReadyDone = Boolean(object.timerReadyDone); - if (object.timerClearId != null) - message.timerClearId = object.timerClearId | 0; - if (object.fetchReqId != null) - message.fetchReqId = object.fetchReqId | 0; - if (object.fetchReqUrl != null) - message.fetchReqUrl = String(object.fetchReqUrl); - if (object.fetchResId != null) - message.fetchResId = object.fetchResId | 0; - if (object.fetchResStatus != null) - message.fetchResStatus = object.fetchResStatus | 0; - if (object.fetchResHeaderLine) { - if (!Array.isArray(object.fetchResHeaderLine)) - throw TypeError(".deno.Msg.fetchResHeaderLine: array expected"); - message.fetchResHeaderLine = []; - for (var i = 0; i < object.fetchResHeaderLine.length; ++i) - message.fetchResHeaderLine[i] = String(object.fetchResHeaderLine[i]); - } - if (object.fetchResBody != null) - if (typeof object.fetchResBody === "string") - $util.base64.decode(object.fetchResBody, message.fetchResBody = $util.newBuffer($util.base64.length(object.fetchResBody)), 0); - else if (object.fetchResBody.length) - message.fetchResBody = object.fetchResBody; - if (object.readFileSyncFilename != null) - message.readFileSyncFilename = String(object.readFileSyncFilename); - if (object.readFileSyncData != null) - if (typeof object.readFileSyncData === "string") - $util.base64.decode(object.readFileSyncData, message.readFileSyncData = $util.newBuffer($util.base64.length(object.readFileSyncData)), 0); - else if (object.readFileSyncData.length) - message.readFileSyncData = object.readFileSyncData; - if (object.writeFileSyncFilename != null) - message.writeFileSyncFilename = String(object.writeFileSyncFilename); - if (object.writeFileSyncData != null) - if (typeof object.writeFileSyncData === "string") - $util.base64.decode(object.writeFileSyncData, message.writeFileSyncData = $util.newBuffer($util.base64.length(object.writeFileSyncData)), 0); - else if (object.writeFileSyncData.length) - message.writeFileSyncData = object.writeFileSyncData; - if (object.writeFileSyncPerm != null) - message.writeFileSyncPerm = object.writeFileSyncPerm >>> 0; - return message; - }; - - /** - * Creates a plain object from a Msg message. Also converts values to other types if specified. - * @function toObject - * @memberof deno.Msg - * @static - * @param {deno.Msg} message Msg - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Msg.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.startArgv = []; - object.fetchResHeaderLine = []; - } - if (options.defaults) { - object.command = options.enums === String ? "ERROR" : 0; - object.error = ""; - object.startCwd = ""; - object.startDebugFlag = false; - object.startMainJs = ""; - object.startMainMap = ""; - object.codeFetchModuleSpecifier = ""; - object.codeFetchContainingFile = ""; - object.codeFetchResModuleName = ""; - object.codeFetchResFilename = ""; - object.codeFetchResSourceCode = ""; - object.codeFetchResOutputCode = ""; - object.codeCacheFilename = ""; - object.codeCacheSourceCode = ""; - object.codeCacheOutputCode = ""; - object.exitCode = 0; - object.timerStartId = 0; - object.timerStartInterval = false; - object.timerStartDelay = 0; - object.timerReadyId = 0; - object.timerReadyDone = false; - object.timerClearId = 0; - object.fetchReqId = 0; - object.fetchReqUrl = ""; - object.fetchResId = 0; - object.fetchResStatus = 0; - object.fetchResBody = options.bytes === String ? "" : []; - object.readFileSyncFilename = ""; - object.readFileSyncData = options.bytes === String ? "" : []; - object.writeFileSyncFilename = ""; - object.writeFileSyncData = options.bytes === String ? "" : []; - object.writeFileSyncPerm = 0; - } - if (message.command != null && message.hasOwnProperty("command")) - object.command = options.enums === String ? $root.deno.Msg.Command[message.command] : message.command; - if (message.error != null && message.hasOwnProperty("error")) - object.error = message.error; - if (message.startCwd != null && message.hasOwnProperty("startCwd")) - object.startCwd = message.startCwd; - if (message.startArgv && message.startArgv.length) { - object.startArgv = []; - for (var j = 0; j < message.startArgv.length; ++j) - object.startArgv[j] = message.startArgv[j]; - } - if (message.startDebugFlag != null && message.hasOwnProperty("startDebugFlag")) - object.startDebugFlag = message.startDebugFlag; - if (message.startMainJs != null && message.hasOwnProperty("startMainJs")) - object.startMainJs = message.startMainJs; - if (message.startMainMap != null && message.hasOwnProperty("startMainMap")) - object.startMainMap = message.startMainMap; - if (message.codeFetchModuleSpecifier != null && message.hasOwnProperty("codeFetchModuleSpecifier")) - object.codeFetchModuleSpecifier = message.codeFetchModuleSpecifier; - if (message.codeFetchContainingFile != null && message.hasOwnProperty("codeFetchContainingFile")) - object.codeFetchContainingFile = message.codeFetchContainingFile; - if (message.codeFetchResModuleName != null && message.hasOwnProperty("codeFetchResModuleName")) - object.codeFetchResModuleName = message.codeFetchResModuleName; - if (message.codeFetchResFilename != null && message.hasOwnProperty("codeFetchResFilename")) - object.codeFetchResFilename = message.codeFetchResFilename; - if (message.codeFetchResSourceCode != null && message.hasOwnProperty("codeFetchResSourceCode")) - object.codeFetchResSourceCode = message.codeFetchResSourceCode; - if (message.codeFetchResOutputCode != null && message.hasOwnProperty("codeFetchResOutputCode")) - object.codeFetchResOutputCode = message.codeFetchResOutputCode; - if (message.codeCacheFilename != null && message.hasOwnProperty("codeCacheFilename")) - object.codeCacheFilename = message.codeCacheFilename; - if (message.codeCacheSourceCode != null && message.hasOwnProperty("codeCacheSourceCode")) - object.codeCacheSourceCode = message.codeCacheSourceCode; - if (message.codeCacheOutputCode != null && message.hasOwnProperty("codeCacheOutputCode")) - object.codeCacheOutputCode = message.codeCacheOutputCode; - if (message.exitCode != null && message.hasOwnProperty("exitCode")) - object.exitCode = message.exitCode; - if (message.timerStartId != null && message.hasOwnProperty("timerStartId")) - object.timerStartId = message.timerStartId; - if (message.timerStartInterval != null && message.hasOwnProperty("timerStartInterval")) - object.timerStartInterval = message.timerStartInterval; - if (message.timerStartDelay != null && message.hasOwnProperty("timerStartDelay")) - object.timerStartDelay = message.timerStartDelay; - if (message.timerReadyId != null && message.hasOwnProperty("timerReadyId")) - object.timerReadyId = message.timerReadyId; - if (message.timerReadyDone != null && message.hasOwnProperty("timerReadyDone")) - object.timerReadyDone = message.timerReadyDone; - if (message.timerClearId != null && message.hasOwnProperty("timerClearId")) - object.timerClearId = message.timerClearId; - if (message.fetchReqId != null && message.hasOwnProperty("fetchReqId")) - object.fetchReqId = message.fetchReqId; - if (message.fetchReqUrl != null && message.hasOwnProperty("fetchReqUrl")) - object.fetchReqUrl = message.fetchReqUrl; - if (message.fetchResId != null && message.hasOwnProperty("fetchResId")) - object.fetchResId = message.fetchResId; - if (message.fetchResStatus != null && message.hasOwnProperty("fetchResStatus")) - object.fetchResStatus = message.fetchResStatus; - if (message.fetchResHeaderLine && message.fetchResHeaderLine.length) { - object.fetchResHeaderLine = []; - for (var j = 0; j < message.fetchResHeaderLine.length; ++j) - object.fetchResHeaderLine[j] = message.fetchResHeaderLine[j]; - } - if (message.fetchResBody != null && message.hasOwnProperty("fetchResBody")) - object.fetchResBody = options.bytes === String ? $util.base64.encode(message.fetchResBody, 0, message.fetchResBody.length) : options.bytes === Array ? Array.prototype.slice.call(message.fetchResBody) : message.fetchResBody; - if (message.readFileSyncFilename != null && message.hasOwnProperty("readFileSyncFilename")) - object.readFileSyncFilename = message.readFileSyncFilename; - if (message.readFileSyncData != null && message.hasOwnProperty("readFileSyncData")) - object.readFileSyncData = options.bytes === String ? $util.base64.encode(message.readFileSyncData, 0, message.readFileSyncData.length) : options.bytes === Array ? Array.prototype.slice.call(message.readFileSyncData) : message.readFileSyncData; - if (message.writeFileSyncFilename != null && message.hasOwnProperty("writeFileSyncFilename")) - object.writeFileSyncFilename = message.writeFileSyncFilename; - if (message.writeFileSyncData != null && message.hasOwnProperty("writeFileSyncData")) - object.writeFileSyncData = options.bytes === String ? $util.base64.encode(message.writeFileSyncData, 0, message.writeFileSyncData.length) : options.bytes === Array ? Array.prototype.slice.call(message.writeFileSyncData) : message.writeFileSyncData; - if (message.writeFileSyncPerm != null && message.hasOwnProperty("writeFileSyncPerm")) - object.writeFileSyncPerm = message.writeFileSyncPerm; - return object; - }; - - /** - * Converts this Msg to JSON. - * @function toJSON - * @memberof deno.Msg - * @instance - * @returns {Object.} JSON object - */ - Msg.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Command enum. - * @name deno.Msg.Command - * @enum {string} - * @property {number} ERROR=0 ERROR value - * @property {number} START=1 START value - * @property {number} CODE_FETCH=2 CODE_FETCH value - * @property {number} CODE_FETCH_RES=3 CODE_FETCH_RES value - * @property {number} CODE_CACHE=4 CODE_CACHE value - * @property {number} EXIT=5 EXIT value - * @property {number} TIMER_START=6 TIMER_START value - * @property {number} TIMER_READY=7 TIMER_READY value - * @property {number} TIMER_CLEAR=8 TIMER_CLEAR value - * @property {number} FETCH_REQ=9 FETCH_REQ value - * @property {number} FETCH_RES=10 FETCH_RES value - * @property {number} READ_FILE_SYNC=11 READ_FILE_SYNC value - * @property {number} READ_FILE_SYNC_RES=12 READ_FILE_SYNC_RES value - * @property {number} WRITE_FILE_SYNC=13 WRITE_FILE_SYNC value - */ - Msg.Command = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "ERROR"] = 0; - values[valuesById[1] = "START"] = 1; - values[valuesById[2] = "CODE_FETCH"] = 2; - values[valuesById[3] = "CODE_FETCH_RES"] = 3; - values[valuesById[4] = "CODE_CACHE"] = 4; - values[valuesById[5] = "EXIT"] = 5; - values[valuesById[6] = "TIMER_START"] = 6; - values[valuesById[7] = "TIMER_READY"] = 7; - values[valuesById[8] = "TIMER_CLEAR"] = 8; - values[valuesById[9] = "FETCH_REQ"] = 9; - values[valuesById[10] = "FETCH_RES"] = 10; - values[valuesById[11] = "READ_FILE_SYNC"] = 11; - values[valuesById[12] = "READ_FILE_SYNC_RES"] = 12; - values[valuesById[13] = "WRITE_FILE_SYNC"] = 13; - return values; - })(); - - return Msg; - })(); - - return deno; - })(); - - return $root; -}); diff --git a/js/msg_generated.ts b/js/msg_generated.ts new file mode 100644 index 0000000000..aa8f000129 --- /dev/null +++ b/js/msg_generated.ts @@ -0,0 +1,161 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +/** + * @enum + */ +export namespace deno{ +export enum Command{ + START= 0 +}}; + +/** + * @constructor + */ +export namespace deno{ +export class Msg { + /** + * @type {flatbuffers.ByteBuffer} + */ + bb: flatbuffers.ByteBuffer|null = null; + + /** + * @type {number} + */ + bb_pos:number = 0; +/** + * @param {number} i + * @param {flatbuffers.ByteBuffer} bb + * @returns {Msg} + */ +__init(i:number, bb:flatbuffers.ByteBuffer):Msg { + this.bb_pos = i; + this.bb = bb; + return this; +}; + +/** + * @param {flatbuffers.ByteBuffer} bb + * @param {Msg=} obj + * @returns {Msg} + */ +static getRootAsMsg(bb:flatbuffers.ByteBuffer, obj?:Msg):Msg { + return (obj || new Msg).__init(bb.readInt32(bb.position()) + bb.position(), bb); +}; + +/** + * @returns {deno.Command} + */ +command():deno.Command { + var offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? /** @type {deno.Command} */ (this.bb!.readInt8(this.bb_pos + offset)) : deno.Command.START; +}; + +/** + * @param {deno.Command} value + * @returns {boolean} + */ +mutate_command(value:deno.Command):boolean { + var offset = this.bb!.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb!.writeInt8(this.bb_pos + offset, value); + return true; +}; + +/** + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array|null} + */ +startCwd():string|null +startCwd(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +startCwd(optionalEncoding?:any):string|Uint8Array|null { + var offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +}; + +/** + * @param {number} index + * @param {flatbuffers.Encoding=} optionalEncoding + * @returns {string|Uint8Array} + */ +startArgv(index: number):string +startArgv(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array +startArgv(index: number,optionalEncoding?:any):string|Uint8Array|null { + var offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; +}; + +/** + * @returns {number} + */ +startArgvLength():number { + var offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; +}; + +/** + * @param {flatbuffers.Builder} builder + */ +static startMsg(builder:flatbuffers.Builder) { + builder.startObject(3); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {deno.Command} command + */ +static addCommand(builder:flatbuffers.Builder, command:deno.Command) { + builder.addFieldInt8(0, command, deno.Command.START); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} startCwdOffset + */ +static addStartCwd(builder:flatbuffers.Builder, startCwdOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, startCwdOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} startArgvOffset + */ +static addStartArgv(builder:flatbuffers.Builder, startArgvOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, startArgvOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +static createStartArgvVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { + builder.startVector(4, data.length, 4); + for (var i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +static startStartArgvVector(builder:flatbuffers.Builder, numElems:number) { + builder.startVector(4, numElems, 4); +}; + +/** + * @param {flatbuffers.Builder} builder + * @returns {flatbuffers.Offset} + */ +static endMsg(builder:flatbuffers.Builder):flatbuffers.Offset { + var offset = builder.endObject(); + return offset; +}; + +} +} diff --git a/js/package.json b/js/package.json index 3451843c94..e93ab1f1b0 100644 --- a/js/package.json +++ b/js/package.json @@ -1,18 +1,14 @@ { "devDependencies": { "@types/base64-js": "^1.2.5", + "@types/flatbuffers": "^1.9.0", "@types/source-map-support": "^0.4.1", - "espree": "^3.5.3", - "jsdoc": "^3.5.5", - "minimist": "^1.2.0", + "flatbuffers": "^1.9.0", "parcel-bundler": "^1.8.1", - "protobufjs": "^6.8.6", - "tmp": "0.0.33", "tslint": "^5.10.0", "tslint-eslint-rules": "^5.3.1", "tslint-no-circular-imports": "^0.5.0", - "typescript": "^2.9.1", - "uglify-js": "^2.8.29" + "typescript": "^2.9.1" }, "browserslist": [ "chrome 69" diff --git a/js/pbjs_hack.py b/js/pbjs_hack.py deleted file mode 100755 index 19b7c16912..0000000000 --- a/js/pbjs_hack.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -""" -gn can only run python scripts. - -Generates protobufjs code. -""" -import subprocess -import sys -import os -# TODO(ry) Ideally protobufjs output files should be written into -# target_gen_dir, but its difficult to get this working in a way that parcel can -# resolve their location. (Parcel does not support NODE_PATH.) Therefore this -# hack: write the generated msg.pb.js and msg.pb.d.ts outputs into the js/ -# folder, and we check them into the repo. Hopefully this hack can be removed at -# some point. If msg.proto is changed, commit changes to the generated JS -# files. - -js_path = os.path.dirname(os.path.realpath(__file__)) -pbjs_path = os.path.join(js_path, "node_modules", "protobufjs", "bin") -pbjs_bin = os.path.join(pbjs_path, "pbjs") -pbts_bin = os.path.join(pbjs_path, "pbts") -msg_pbjs_out = os.path.join(js_path, "msg.pb.js") -msg_pbts_out = os.path.join(js_path, "msg.pb.d.ts") -assert os.path.exists(pbjs_bin) -assert os.path.exists(pbts_bin) - -proto_in = sys.argv[1] -stamp_file = sys.argv[2] - - -def touch(fname): - if os.path.exists(fname): - os.utime(fname, None) - else: - open(fname, 'a').close() - - -subprocess.check_call([ - "node", pbjs_bin, "--target=static-module", "--wrapper=commonjs", - "--out=" + msg_pbjs_out, proto_in -]) -assert os.path.exists(msg_pbjs_out) - -subprocess.check_call( - ["node", pbts_bin, "--out=" + msg_pbts_out, msg_pbjs_out]) -assert os.path.exists(msg_pbts_out) - -touch(stamp_file) diff --git a/src/main.rs b/src/main.rs index 31a225d208..4441b40052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ extern crate libc; + use libc::c_char; use libc::c_int; use libc::c_void; diff --git a/src/mock_main.cc b/src/mock_main.cc index 1341e6397d..40d3d89d2d 100644 --- a/src/mock_main.cc +++ b/src/mock_main.cc @@ -10,8 +10,9 @@ #include #endif +#include "flatbuffers/flatbuffers.h" #include "include/deno.h" -#include "src/msg.pb.h" +#include "src/msg_generated.h" #include "third_party/v8/src/base/logging.h" static char** global_argv; @@ -20,24 +21,29 @@ static int global_argc; void MessagesFromJS(Deno* d, const char* channel, deno_buf buf) { printf("MessagesFromJS %s\n", channel); - deno::Msg response; - response.set_command(deno::Msg_Command_START); + flatbuffers::FlatBufferBuilder builder; char cwdbuf[1024]; // TODO(piscisaureus): support unicode on windows. - std::string cwd(getcwd(cwdbuf, sizeof(cwdbuf))); - response.set_start_cwd(cwd); + getcwd(cwdbuf, sizeof(cwdbuf)); + auto start_cwd = builder.CreateString(cwdbuf); + std::vector> args; for (int i = 0; i < global_argc; ++i) { - printf("arg %d %s\n", i, global_argv[i]); - response.add_start_argv(global_argv[i]); + args.push_back(builder.CreateString(global_argv[i])); } - printf("response.start_argv_size %d \n", response.start_argv_size()); + auto start_argv = builder.CreateVector(args); - std::string output; - CHECK(response.SerializeToString(&output)); + deno::MsgBuilder msg_builder(builder); + msg_builder.add_command(deno::Command_START); + msg_builder.add_start_cwd(start_cwd); + msg_builder.add_start_argv(start_argv); - deno_buf bufout{output.c_str(), output.length()}; + auto response = msg_builder.Finish(); + builder.Finish(response); + + deno_buf bufout{reinterpret_cast(builder.GetBufferPointer()), + builder.GetSize()}; deno_set_response(d, bufout); } diff --git a/src/msg.fbs b/src/msg.fbs new file mode 100644 index 0000000000..3dbb8e420b --- /dev/null +++ b/src/msg.fbs @@ -0,0 +1,12 @@ +namespace deno; + +enum Command: byte { + START = 0, +} + +table Msg { + command: Command; + start_cwd: string; + start_argv: [string]; +} + diff --git a/src/msg.proto b/src/msg.proto deleted file mode 100644 index 1b093050d5..0000000000 --- a/src/msg.proto +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2018 Ryan Dahl -// All rights reserved. MIT License. -syntax = "proto3"; -package deno; - -message Msg { - enum Command { - ERROR = 0; - START = 1; - CODE_FETCH = 2; - CODE_FETCH_RES = 3; - CODE_CACHE = 4; - EXIT = 5; - TIMER_START = 6; - TIMER_READY = 7; - TIMER_CLEAR = 8; - FETCH_REQ = 9; - FETCH_RES = 10; - READ_FILE_SYNC = 11; - READ_FILE_SYNC_RES = 12; - WRITE_FILE_SYNC = 13; - } - Command command = 1; - - // We avoid creating a message for each command (and use oneof or any types) - // In order to reduce code in the size of the generated javascript - // "msg.pb.js". It seems that each new message adds 20k and we want to - // potentially add many hundreds of commands. Therefore we just prefix command - // arguments by their name. - - // ERROR - string error = 2; - - // START - string start_cwd = 10; - repeated string start_argv = 11; - bool start_debug_flag = 12; - string start_main_js = 13; // The contents of dist/main.js - string start_main_map = 14; // The contents of dist/main.map - - // CODE_FETCH - string code_fetch_module_specifier = 20; - string code_fetch_containing_file = 21; - - // CODE_FETCH_RES - // If it's a non-http module, moduleName and filename will be the same. - // For http modules, moduleName is its resolved http URL, and filename - // is the location of the locally downloaded source code. - string code_fetch_res_module_name = 30; - string code_fetch_res_filename = 31; - string code_fetch_res_source_code = 32; - string code_fetch_res_output_code = 33; // Non-empty only if cached. - - // CODE_CACHE - string code_cache_filename = 41; - string code_cache_source_code = 42; - string code_cache_output_code = 43; - - // EXIT - int32 exit_code = 50; - - // TIMER_START - int32 timer_start_id = 60; - bool timer_start_interval = 61; - int32 timer_start_delay = 62; // In milliseconds. - - // TIMER_READY - int32 timer_ready_id = 70; - bool timer_ready_done = 71; - - // TIMER_CLEAR - int32 timer_clear_id = 80; - - // FETCH_REQ - int32 fetch_req_id = 90; - string fetch_req_url = 91; - // repeated string fetch_req_header_line = 91 - - // FETCH_RES - int32 fetch_res_id = 100; - int32 fetch_res_status = 101; - repeated string fetch_res_header_line = 102; - bytes fetch_res_body = 103; - - // READ_FILE_SYNC - string read_file_sync_filename = 110; - - // READ_FILE_SYNC_RES - bytes read_file_sync_data = 120; - - // WRITE_FILE_SYNC - string write_file_sync_filename = 130; - bytes write_file_sync_data = 131; - uint32 write_file_sync_perm = 132; - // write_file_sync_perm specified by https://godoc.org/os#FileMode -} diff --git a/src/snapshot_creator.cc b/src/snapshot_creator.cc index 30134b3abb..a49f656aa9 100644 --- a/src/snapshot_creator.cc +++ b/src/snapshot_creator.cc @@ -35,7 +35,7 @@ v8::StartupData MakeSnapshot(const char* js_filename, const char* js_source) { } auto snapshot_blob = - creator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep); + creator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear); return snapshot_blob; } diff --git a/third_party/flatbuffers/BUILD.gn b/third_party/flatbuffers/BUILD.gn new file mode 100644 index 0000000000..e32ac2126e --- /dev/null +++ b/third_party/flatbuffers/BUILD.gn @@ -0,0 +1,120 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# import("//testing/test.gni") +import("//third_party/flatbuffers/flatbuffer.gni") + +config("flatbuffers_config") { + include_dirs = [ "src/include" ] + + if (is_clang) { + cflags = [ + "-Wno-exit-time-destructors", + "-Wno-header-hygiene", + ] + } +} + +# The part of FlatBuffers that Chrome is interested in. +source_set("flatbuffers") { + sources = [ + "src/include/flatbuffers/flatbuffers.h", + ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + + public_configs = [ ":flatbuffers_config" ] +} + +# The complete FlatBuffers library, as required to build the flatc compiler and +# some of the tests. +source_set("compiler_files") { + include_dirs = [ "src/grpc" ] + sources = [ + "src/grpc/src/compiler/config.h", + "src/grpc/src/compiler/config.h", + "src/grpc/src/compiler/cpp_generator.cc", + "src/grpc/src/compiler/cpp_generator.h", + "src/grpc/src/compiler/go_generator.cc", + "src/grpc/src/compiler/go_generator.h", + "src/grpc/src/compiler/java_generator.cc", + "src/grpc/src/compiler/java_generator.h", + "src/grpc/src/compiler/schema_interface.h", + "src/include/flatbuffers/code_generators.h", + "src/include/flatbuffers/flatc.h", + "src/include/flatbuffers/flexbuffers.h", + "src/include/flatbuffers/grpc.h", + "src/include/flatbuffers/hash.h", + "src/include/flatbuffers/idl.h", + "src/include/flatbuffers/reflection.h", + "src/include/flatbuffers/reflection_generated.h", + "src/include/flatbuffers/util.h", + "src/src/code_generators.cpp", + "src/src/flatc.cpp", + "src/src/idl_gen_cpp.cpp", + "src/src/idl_gen_fbs.cpp", + "src/src/idl_gen_general.cpp", + "src/src/idl_gen_go.cpp", + "src/src/idl_gen_grpc.cpp", + "src/src/idl_gen_js.cpp", + "src/src/idl_gen_json_schema.cpp", + "src/src/idl_gen_php.cpp", + "src/src/idl_gen_python.cpp", + "src/src/idl_gen_rust.cpp", + "src/src/idl_gen_text.cpp", + "src/src/idl_parser.cpp", + "src/src/reflection.cpp", + "src/src/util.cpp", + ] + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] + visibility = [ ":*" ] + deps = [ + ":flatbuffers", + ] +} + +executable("flatc") { + sources = [ + "src/src/flatc_main.cpp", + ] + deps = [ + ":compiler_files", + ":flatbuffers", + ] +} + +# The following is just for testing. + +flatbuffer("flatbuffers_samplebuffer") { + testonly = true + sources = [ + "src/tests/include_test/include_test1.fbs", + "src/tests/include_test/sub/include_test2.fbs", + "src/tests/monster_test.fbs", + "src/tests/namespace_test/namespace_test1.fbs", + "src/tests/namespace_test/namespace_test2.fbs", + ] + flatc_include_dirs = [ "src/tests/include_test" ] +} +# test("flatbuffers_unittest") { +# sources = [ +# "src/tests/test.cpp", +# ] +# deps = [ +# ":compiler_files", +# ":flatbuffers", +# ":flatbuffers_samplebuffer", +# ] +# data = [ +# "src/tests/", +# ] +# +# if (is_win) { +# # Suppress "object allocated on the heap may not be aligned 16". +# cflags = [ "/wd4316" ] +# } +# defines = [ "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE" ] +# } diff --git a/third_party/flatbuffers/LICENSE b/third_party/flatbuffers/LICENSE new file mode 100644 index 0000000000..a4c5efd822 --- /dev/null +++ b/third_party/flatbuffers/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/flatbuffers/OWNERS b/third_party/flatbuffers/OWNERS new file mode 100644 index 0000000000..94966f0a5f --- /dev/null +++ b/third_party/flatbuffers/OWNERS @@ -0,0 +1,3 @@ +battre@chromium.org +csharrison@chromium.org +engedy@chromium.org diff --git a/third_party/flatbuffers/README.chromium b/third_party/flatbuffers/README.chromium new file mode 100644 index 0000000000..1400e04f7c --- /dev/null +++ b/third_party/flatbuffers/README.chromium @@ -0,0 +1,14 @@ +Name: FlatBuffers +Short Name: flatbuffers +URL: https://github.com/google/flatbuffers +Version: 01c50d57a67a52ee3cddd81b54d4647e9123a290 +Date: 2017-06-05 +License: Apache 2.0 +License File: LICENSE +Security Critical: yes + +Description: +FlatBuffers is an efficient cross platform serialization library for games and +other memory constrained apps. It allows you to directly access serialized data +without unpacking/parsing it first, while still having great forwards/backwards +compatibility. diff --git a/third_party/flatbuffers/flatbuffer.gni b/third_party/flatbuffers/flatbuffer.gni new file mode 100644 index 0000000000..11aae5ed74 --- /dev/null +++ b/third_party/flatbuffers/flatbuffer.gni @@ -0,0 +1,148 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Compile a flatbuffer. +# +# flatc_out_dir (optional) +# Specifies the path suffix that output files are generated under. This +# path will be appended to root_gen_dir. +# +# Targets that depend on the flatbuffer target will be able to include +# the resulting FlatBuffers header with an include like: +# #include "dir/for/my_flatbuffer/buffer_generated.h" +# If undefined, this defaults to matchign the input directory for each +# .fbs file (you should almost always use the default mode). +# +# flatc_include_dirs (optional) +# Specifies the directories which FlatBuffers compiler uses to find +# included .fbs files in. Almost always should be empty. +# +# The list always has an implicit first item corresponding to the root of +# the source tree. This enables including .fbs files by absolute path. +# +# The compiler will try the directories in the order given, and if all +# fail it will try to load relative to the directory of the schema file +# being parsed. +# +# deps (optional) +# Additional dependencies. +# +# Parameters for compiling the generated code: +# +# defines (optional) +# Defines to supply to the source set that compiles the generated source +# code. +# +# extra_configs (optional) +# A list of config labels that will be appended to the configs applying +# to the source set. +# +# testonly (optional) +# Boolean to indicate whether the generated source sets should be labeled +# as testonly. +# +# Example: +# flatbuffer("mylib") { +# sources = [ +# "foo.fbs", +# ] +# } + +import("//build/compiled_action.gni") + +template("flatbuffer") { + assert(defined(invoker.sources), "Need sources for flatbuffers_library") + + # Don't apply OS-specific sources filtering to the assignments later on. + # Platform files should have gotten filtered out in the sources assignment + # when this template was invoked. If they weren't, it was on purpose and + # this template shouldn't re-apply the filter. + set_sources_assignment_filter([]) + + action_name = "${target_name}_gen" + source_set_name = target_name + compiled_action_foreach(action_name) { + visibility = [ ":$source_set_name" ] + + tool = "//third_party/flatbuffers:flatc" + + sources = invoker.sources + deps = [] + + if (defined(invoker.flatc_out_dir)) { + out_dir = "$root_gen_dir/" + invoker.flatc_out_dir + } else { + out_dir = "{{source_gen_dir}}" + } + + outputs = [ + "$out_dir/{{source_name_part}}_generated.h", + ] + + args = [ + "-c", + "--keep-prefix", + "-o", + "$out_dir", + "-I", + rebase_path("//", root_build_dir), + ] + + if (defined(invoker.flatc_include_dirs)) { + foreach(include_dir, invoker.flatc_include_dirs) { + args += [ + "-I", + rebase_path(include_dir, root_build_dir), + ] + } + } + + args += [ "{{source}}" ] + + # The deps may have steps that have to run before running flatc. + if (defined(invoker.deps)) { + deps += invoker.deps + } + } + + source_set(target_name) { + forward_variables_from(invoker, + [ + "visibility", + "defines", + ]) + + sources = get_target_outputs(":$action_name") + + if (defined(invoker.extra_configs)) { + configs += invoker.extra_configs + } + + if (defined(invoker.testonly)) { + testonly = invoker.testonly + } + + public_configs = [ "//third_party/flatbuffers:flatbuffers_config" ] + + public_deps = [ + # The generated headers reference headers within FlatBuffers, so + # dependencies must be able to find those headers too. + "//third_party/flatbuffers", + ] + deps = [ + ":$action_name", + ] + + # This will link any libraries in the deps (the use of invoker.deps in the + # action won't link it). + if (defined(invoker.deps)) { + deps += invoker.deps + } + + # Same for public_deps. + if (defined(invoker.public_deps)) { + public_deps += invoker.public_deps + } + } +} diff --git a/third_party/flatbuffers/ts_flatbuffer.gni b/third_party/flatbuffers/ts_flatbuffer.gni new file mode 100644 index 0000000000..d9c090aa63 --- /dev/null +++ b/third_party/flatbuffers/ts_flatbuffer.gni @@ -0,0 +1,84 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Compile a flatbuffer to typescript. +# +# flatc_include_dirs (optional) +# Specifies the directories which FlatBuffers compiler uses to find +# included .fbs files in. Almost always should be empty. +# +# The list always has an implicit first item corresponding to the root of +# the source tree. This enables including .fbs files by absolute path. +# +# The compiler will try the directories in the order given, and if all +# fail it will try to load relative to the directory of the schema file +# being parsed. +# +# deps (optional) +# Additional dependencies. +# +# Example: +# ts_flatbuffer("foo_ts") { +# sources = [ +# "foo.fbs", +# ] +# } + +import("//build/compiled_action.gni") + +template("ts_flatbuffer") { + assert(defined(invoker.sources), "Need sources for flatbuffers_library") + + # Don't apply OS-specific sources filtering to the assignments later on. + # Platform files should have gotten filtered out in the sources assignment + # when this template was invoked. If they weren't, it was on purpose and + # this template shouldn't re-apply the filter. + set_sources_assignment_filter([]) + + copy_name = target_name + "_copy" + + copy(copy_name) { + sources = [ "//third_party/flatbuffers/src/js/flatbuffers.js" ] + outputs = [ "$target_gen_dir/flatbuffers.js" ] + } + + compiled_action_foreach(target_name) { + tool = "//third_party/flatbuffers:flatc" + + sources = invoker.sources + deps = [ ":" + copy_name ] + + out_dir = target_gen_dir + + outputs = [ + "$out_dir/{{source_name_part}}_generated.ts", + ] + + args = [ + "--ts", + "--no-fb-import", + "--gen-mutable", + "-o", + rebase_path(out_dir, root_build_dir), + "-I", + rebase_path("//", root_build_dir), + ] + + if (defined(invoker.flatc_include_dirs)) { + foreach(include_dir, invoker.flatc_include_dirs) { + args += [ + "-I", + rebase_path(include_dir, root_build_dir), + ] + } + } + + args += [ "{{source}}" ] + + # The deps may have steps that have to run before running flatc. + if (defined(invoker.deps)) { + deps += invoker.deps + } + } +} diff --git a/third_party/yarn.lock b/third_party/yarn.lock index 8daa08843a..9778aa3c8c 100644 --- a/third_party/yarn.lock +++ b/third_party/yarn.lock @@ -2,65 +2,18 @@ # yarn lockfile v1 -"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - -"@protobufjs/fetch@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - -"@protobufjs/inquire@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - -"@protobufjs/path@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - -"@protobufjs/pool@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - -"@protobufjs/utf8@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - "@types/base64-js@^1.2.5": version "1.2.5" resolved "https://registry.yarnpkg.com/@types/base64-js/-/base64-js-1.2.5.tgz#582b2476169a6cba460a214d476c744441d873d5" -"@types/long@^3.0.32": - version "3.0.32" - resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69" +"@types/flatbuffers@^1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@types/flatbuffers/-/flatbuffers-1.9.0.tgz#4c5cf3a9ce6af36f4c17f8ae2bfe1084d0e8c2ea" "@types/node@*": version "10.3.3" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.3.3.tgz#8798d9e39af2fa604f715ee6a6b19796528e46c3" -"@types/node@^8.9.4": - version "8.10.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.19.tgz#66b5b6325c048cbf4512b7a88b0e79c2ee99d3d2" - "@types/source-map-support@^0.4.1": version "0.4.1" resolved "https://registry.yarnpkg.com/@types/source-map-support/-/source-map-support-0.4.1.tgz#ad77158e8c6695a16629ef82b9fb9dfe7c610ac0" @@ -71,32 +24,10 @@ abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" -acorn-jsx@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" - dependencies: - acorn "^3.0.4" - -acorn@^3.0.4: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" - acorn@^5.0.0: version "5.6.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.6.2.tgz#b1da1d7be2ac1b4a327fb9eab851702c5045b4e7" -acorn@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8" - -align-text@^0.1.1, align-text@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" - dependencies: - kind-of "^3.0.2" - longest "^1.0.1" - repeat-string "^1.5.2" - alphanum-sort@^1.0.1, alphanum-sort@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" @@ -682,10 +613,6 @@ babylon-walk@^1.0.2: babel-types "^6.15.0" lodash.clone "^4.5.0" -babylon@7.0.0-beta.19: - version "7.0.0-beta.19" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" - babylon@^6.17.4, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -722,7 +649,7 @@ bindings@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" -bluebird@^3.0.5, bluebird@~3.5.0: +bluebird@^3.0.5: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -877,10 +804,6 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" -camelcase@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" - caniuse-api@^1.5.2: version "1.6.1" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-1.6.1.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c" @@ -898,19 +821,6 @@ caniuse-lite@^1.0.30000844: version "1.0.30000853" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000853.tgz#505249fc78d60e20ad47af3c13706d6f9fd209fd" -catharsis@~0.8.9: - version "0.8.9" - resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" - dependencies: - underscore-contrib "~0.3.0" - -center-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" - dependencies: - align-text "^0.1.3" - lazy-cache "^1.0.3" - chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -973,14 +883,6 @@ class-utils@^0.3.5: isobject "^3.0.0" static-extend "^0.1.1" -cliui@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" - dependencies: - center-align "^0.1.1" - right-align "^0.1.1" - wordwrap "0.0.2" - clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" @@ -1282,7 +1184,7 @@ debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6. dependencies: ms "2.0.0" -decamelize@^1.0.0, decamelize@^1.1.2: +decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1485,7 +1387,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1511,13 +1413,6 @@ escodegen@~1.9.0: optionalDependencies: source-map "~0.6.1" -espree@^3.5.3: - version "3.5.4" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" - dependencies: - acorn "^5.5.0" - acorn-jsx "^3.0.0" - esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" @@ -1621,6 +1516,10 @@ fill-range@^4.0.0: repeat-string "^1.6.1" to-regex-range "^2.1.0" +flatbuffers@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/flatbuffers/-/flatbuffers-1.9.0.tgz#e1ef5267deaab4872c08dbca56a936d6dbc27ecd" + flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" @@ -1707,7 +1606,7 @@ globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" -graceful-fs@^4.1.2, graceful-fs@^4.1.9: +graceful-fs@^4.1.2: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2104,29 +2003,6 @@ js-yaml@~3.7.0: argparse "^1.0.7" esprima "^2.6.0" -js2xmlparser@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" - dependencies: - xmlcreate "^1.0.1" - -jsdoc@^3.5.5: - version "3.5.5" - resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d" - dependencies: - babylon "7.0.0-beta.19" - bluebird "~3.5.0" - catharsis "~0.8.9" - escape-string-regexp "~1.0.5" - js2xmlparser "~3.0.0" - klaw "~2.0.0" - marked "~0.3.6" - mkdirp "~0.5.1" - requizzle "~0.2.1" - strip-json-comments "~2.0.1" - taffydb "2.6.2" - underscore "~1.8.3" - jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -2165,16 +2041,6 @@ kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" -klaw@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" - dependencies: - graceful-fs "^4.1.9" - -lazy-cache@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" - levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" @@ -2198,14 +2064,6 @@ lodash@^4.17.4: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" -long@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" - -longest@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" - loose-envify@^1.0.0: version "1.3.1" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" @@ -2234,10 +2092,6 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -marked@~0.3.6: - version "0.3.19" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" - math-expression-evaluator@^1.2.14: version "1.2.17" resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac" @@ -2571,7 +2425,7 @@ os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -2970,24 +2824,6 @@ proto-list@~1.2.1: version "1.2.4" resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" -protobufjs@^6.8.6: - version "6.8.6" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.6.tgz#ce3cf4fff9625b62966c455fc4c15e4331a11ca2" - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/long" "^3.0.32" - "@types/node" "^8.9.4" - long "^4.0.0" - pseudomap@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" @@ -3147,7 +2983,7 @@ repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" -repeat-string@^1.5.2, repeat-string@^1.6.1: +repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" @@ -3157,12 +2993,6 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -requizzle@~0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" - dependencies: - underscore "~1.6.0" - resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -3183,12 +3013,6 @@ ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" -right-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" - dependencies: - align-text "^0.1.1" - rimraf@^2.6.1: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" @@ -3388,7 +3212,7 @@ source-map@0.6.1, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" -source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1: +source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -3551,10 +3375,6 @@ svgo@^1.0.5: unquote "~1.1.1" util.promisify "~1.0.0" -taffydb@2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" - tar@^4: version "4.4.4" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.4.tgz#ec8409fae9f665a4355cc3b4087d0820232bb8cd" @@ -3584,12 +3404,6 @@ tiny-inflate@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/tiny-inflate/-/tiny-inflate-1.0.2.tgz#93d9decffc8805bd57eae4310f0b745e9b6fb3a7" -tmp@0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - dependencies: - os-tmpdir "~1.0.2" - to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -3706,33 +3520,6 @@ uglify-es@^3.2.1, uglify-es@^3.3.9: commander "~2.13.0" source-map "~0.6.1" -uglify-js@^2.8.29: - version "2.8.29" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" - dependencies: - source-map "~0.5.1" - yargs "~3.10.0" - optionalDependencies: - uglify-to-browserify "~1.0.0" - -uglify-to-browserify@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" - -underscore-contrib@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" - dependencies: - underscore "1.6.0" - -underscore@1.6.0, underscore@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" - -underscore@~1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" - unicode-trie@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/unicode-trie/-/unicode-trie-0.3.1.tgz#d671dddd89101a08bac37b6a5161010602052085" @@ -3846,14 +3633,6 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -window-size@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" - -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" @@ -3868,10 +3647,6 @@ ws@^5.1.1: dependencies: async-limiter "~1.0.0" -xmlcreate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" - xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" @@ -3879,12 +3654,3 @@ xtend@^4.0.0, xtend@~4.0.1: yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" - -yargs@~3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" - dependencies: - camelcase "^1.0.2" - cliui "^2.1.0" - decamelize "^1.0.0" - window-size "0.1.0" diff --git a/tools/format.sh b/tools/format.sh index 1225ac08a4..bbb0c93c88 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -15,7 +15,7 @@ prettier --write \ js/mock_runtime.js \ tsconfig.json # Do not format these. -# js/msg.pb.js -# js/msg.pb.d.ts +# js/msg_generated.ts +# js/flatbuffers.js rustfmt --write-mode overwrite src/*.rs diff --git a/tools/lint.sh b/tools/lint.sh index 54bc43f94e..90e79ce898 100755 --- a/tools/lint.sh +++ b/tools/lint.sh @@ -8,4 +8,5 @@ cd `dirname "$0"`/.. src/*.cc \ src/*.h \ src/include/*.h -node ./js/node_modules/.bin/tslint -p . +node third_party/node_modules/.bin/tslint -p . \ + --exclude js/msg_generated.ts diff --git a/tools/protoc_wrapper b/tools/protoc_wrapper deleted file mode 120000 index 008a7795e5..0000000000 --- a/tools/protoc_wrapper +++ /dev/null @@ -1 +0,0 @@ -../third_party/tools/protoc_wrapper \ No newline at end of file