Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

45
node_modules/protobufjs/cli/pbjs/targets/amd.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
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.
*/
var description = "Runtime structures as AMD module";
var ProtoBuf = require("../../../index.js"),
util = require("../util.js"),
js = require("./js.js");
/**
* pbjs target: Runtime structures as an AMD module
* @exports pbjs/targets/amd
* @function
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
var amd = module.exports = function(builder, options) {
options = options || {};
return [
"define([", JSON.stringify(options.dependency || "protobuf"), "]", options.min ? "," : ", ",
"function(ProtoBuf)", options.min ? "{" : " {\n ",
"return ProtoBuf",
util.indent(js.build(builder, options), options.min ? "" : " "), options.min ? "" : "\n",
"});"
].join('');
};
/**
* Module description.
* @type {string}
*/
amd.description = description;

42
node_modules/protobufjs/cli/pbjs/targets/commonjs.js generated vendored Normal file
View File

@ -0,0 +1,42 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
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.
*/
var description = "Runtime structures as CommonJS module";
var util = require("../util.js"),
js = require("./js.js");
/**
* pbjs target: Runtime structures as a CommonJS module
* @exports pbjs/targets/commonjs
* @function
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
var commonjs = module.exports = function(builder, options) {
options = options || {};
return [
"module.exports", options.min ? "=" : " = ",
"require(", JSON.stringify(options.dependency || "protobufjs"), ")",
js.build(builder, options)
].join('');
};
/**
* Module description.
* @type {string}
*/
commonjs.description = description;

63
node_modules/protobufjs/cli/pbjs/targets/js.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
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.
*/
var description = "Runtime structures";
var util = require("../util.js"),
json = require("./json.js");
/**
* pbjs target: Runtime structures
* @exports pbjs/targets/js
* @function
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
var js = module.exports = function(builder, options) {
options = options || {};
var varName = "_root";
if (options.exports)
varName = options.exports.substring(options.exports.lastIndexOf(".")+1);
return [
"var ", varName, options.min ? "=" : " = ", options.dependency || "dcodeIO.ProtoBuf",
js.build(builder, options)
].join('');
};
/**
* Builds the core js target.
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
js.build = function(builder, options) {
options = options || {};
return [
".newBuilder(",
JSON.stringify(util.getBuilderOptions(options, "use"), null, options.min ? 0 : 4),
")['import'](",
json(builder, options),
").build(",
typeof options.exports === 'string' ? JSON.stringify(options.exports.split(".")) : "",
");"
].join('');
};
/**
* Module description.
* @type {string}
*/
js.description = description;

260
node_modules/protobufjs/cli/pbjs/targets/json.js generated vendored Normal file
View File

@ -0,0 +1,260 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
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.
*/
var description = "Plain JSON descriptor";
var ProtoBuf = require(__dirname+"/../../../index.js"),
util = require("../util.js");
/**
* pbjs target: Plain JSON descriptor
* @exports pbjs/targets/json
* @function
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
var json = module.exports = function(builder, options) {
options = options || {};
builder.resolveAll();
// Set the pointer to the lowest common namespace (with options)
var ptr = builder.ns;
while (ptr.children.length === 1 && Object.keys(ptr.options).length === 0 && ptr.children[0].className === "Namespace")
ptr = ptr.children[0];
// Start by building the package namespace
var pkg = ptr.fqn().substring(1),
out = {
"package": pkg !== "" ? pkg : null
};
buildNamespace(ptr, out);
return JSON.stringify(out, null, options.min ? 0 : 4);
};
/**
* Module description.
* @type {string}
*/
json.description = description;
/**
* Builds all structures in a namespace.
* @param {!ProtoBuf.Reflect.Namespace} ns Namespace to build
* @param {!Object.<string,*>} out Extended output object
*/
function buildNamespace(ns, out) {
var messages, enums, services;
util.extend(out, {
"syntax" : ns.syntax || 'proto2',
"options" : out.options || {},
"messages" : messages = [],
"enums" : enums = [],
"services" : services = []
});
if (!(ns instanceof ProtoBuf.Reflect.Message))
out['isNamespace'] = true;
util.extend(out["options"], buildOptions(ns.options));
ns.getChildren(ProtoBuf.Reflect.Enum).forEach(function(enm) {
enums.push(buildEnum(enm));
});
if (enums.length === 0)
delete out["enums"];
ns.getChildren(ProtoBuf.Reflect.Message).forEach(function(msg) {
messages.push(buildMessage(msg));
});
ns.getChildren(ProtoBuf.Reflect.Service).forEach(function(svc) {
services.push(buildService(svc));
});
if (services.length === 0)
delete out["services"];
Array.prototype.push.apply(messages, buildExtensions(ns));
ns.getChildren(ProtoBuf.Reflect.Namespace).forEach(function(innerNs) {
if (innerNs.className !== "Namespace")
return;
var emptyMessage = {
"name": innerNs.name,
"fields": []
};
buildNamespace(innerNs, emptyMessage);
messages.push(emptyMessage);
});
if (messages.length === 0)
delete out["messages"];
if (Object.keys(out["options"]).length === 0)
delete out["options"];
}
/**
* Builds extensions declared in the specified namespace.
* @param {!ProtoBuf.Reflect.Namespace} ns Namespace
* @returns {!Array.<!*>}
*/
function buildExtensions(ns) {
var exts = util.groupExtensions(ns);
if (exts === null)
return [];
var messages = [];
Object.keys(exts).forEach(function(extFqn) {
var extMsg = ns.resolve(extFqn),
extFields = exts[extFqn];
var fields, ext = {
"ref" : ns.qn(extMsg),
"fields" : fields = []
};
extFields.forEach(function(extField) {
fields.push(buildMessageField(extField));
});
messages.push(ext);
});
return messages;
}
/**
* Builds block-level options.
* @param {!Object.<string,*>} options Options
* @returns {!Object.<string,*>}
*/
function buildOptions(options) {
Object.keys(options = options || {}).forEach(function(key) {
var val = options[key];
switch (typeof val) {
case 'string':
case 'number':
case 'boolean':
case 'object':
break;
default:
throw Error("Illegal option type: "+typeof(val));
}
});
return options;
}
/**
* Builds a message.
* @param {!ProtoBuf.Reflect.Message} msg Message
* @returns {!*}
*/
function buildMessage(msg) {
var fields, oneofs;
var out = {
"name" : msg.name,
"syntax" : msg.syntax || 'proto2',
"options" : {},
"fields" : fields = [],
"oneofs" : oneofs = {}
};
msg.getChildren(ProtoBuf.Reflect.Message.Field).forEach(function(fld) {
if (fld instanceof ProtoBuf.Reflect.Message.ExtensionField)
return;
fields.push(buildMessageField(fld));
});
msg.getChildren(ProtoBuf.Reflect.Message.OneOf).forEach(function(oneof) {
oneofs[oneof.name] = buildMessageOneof(oneof);
});
if (msg.extensions)
out["extensions"] = msg.extensions;
if (Object.keys(oneofs).length === 0)
delete out["oneofs"];
buildNamespace(msg, out);
return out;
}
/**
* Builds a message field.
* @param {!ProtoBuf.Reflect.Message.Field} fld Message field
* @returns {!*}
*/
function buildMessageField(fld) {
return {
"rule" : fld.map ? "map" : (fld.repeated ? "repeated" : (fld.required ? "required" : "optional")),
"type" : fld.resolvedType ? fld.parent.qn(fld.resolvedType) : fld.type['name'],
"keytype" : (typeof(fld.keyType) === 'string') ? fld.keyType : (fld.keyType !== null ? fld.keyType.name : undefined),
"name" : fld instanceof ProtoBuf.Reflect.Message.ExtensionField ? fld.name.substring(fld.name.lastIndexOf(".")+1): fld.name,
"id" : fld.id,
"options" : Object.keys(fld.options).length > 0 ? buildOptions(fld.options) : undefined,
"oneof" : fld.oneof ? fld.oneof.name : undefined
};
}
/**
* Builds a message oneof.
* @param {!ProtoBuf.Reflect.message.OneOf} oneof Message oneof
* @returns {!Array.<!*>}
*/
function buildMessageOneof(oneof) {
var out = [];
oneof.fields.forEach(function(fld) {
out.push(fld.id);
});
return out;
}
/**
* Builds an enum.
* @param {!ProtoBuf.Reflect.Enum} enm Enum
* @returns {!*}
*/
function buildEnum(enm) {
var values;
var out = {
"name" : enm.name,
"syntax" : enm.syntax || 'proto2',
"values" : values = []
};
enm.getChildren(ProtoBuf.Reflect.Enum.Value).forEach(function(val) {
values.push(buildEnumValue(val));
});
if (Object.keys(enm.options).length > 0)
out["options"] = buildOptions(enm.options);
return out;
}
/**
* Builds an enum value.
* @param {!ProtoBuf.Reflect.Enum.Value} val Enum value
* @returns {!*}
*/
function buildEnumValue(val) {
return {
"name" : val.name,
"id" : val.id
};
}
/**
* Builds a service.
* @param {!ProtoBuf.Reflect.Service} svc Service
* @returns {!*}
*/
function buildService(svc) {
var rpc;
var out = {
"name": svc.name,
"options": buildOptions(svc.options),
"rpc": rpc = {}
};
svc.getChildren(ProtoBuf.Reflect.Service.RPCMethod).forEach(function(mtd) {
rpc[mtd.name] = {
"request": svc.qn(mtd.resolvedRequestType),
"request_stream": mtd.requestStream,
"response": svc.qn(mtd.resolvedResponseType),
"response_stream": mtd.responseStream,
"options": buildOptions(mtd.options)
};
});
return out;
}

267
node_modules/protobufjs/cli/pbjs/targets/proto.js generated vendored Normal file
View File

@ -0,0 +1,267 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
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.
*/
var description = "Plain .proto descriptor";
var ProtoBuf = require(__dirname+"/../../../index.js"),
util = require("../util.js");
/**
* pbjs target: Plain .proto descriptor
* @exports pbjs/targets/proto
* @function
* @param {!ProtoBuf.Builder} builder Builder
* @param {!Object.<string,*>=} options Options
* @returns {string}
*/
var proto = module.exports = function(builder, options) {
options = options || {};
builder.resolveAll();
// Set the pointer to the lowest common namespace (with options)
var ptr = builder.ns;
while (ptr.children.length === 1 && Object.keys(ptr.options).length === 0 && ptr.children[0].className === "Namespace")
ptr = ptr.children[0];
var out = [];
function trim() {
out[out.length-1] = out[out.length-1].replace(/\n{2,}$/, "\n");
}
// Builds a set of top level options
function buildOptions(opt, indent) {
var keys;
if ((keys = Object.keys(opt)).length === 0)
return;
keys.forEach(function(key) {
if (!options.min)
out.push(indent);
out.push("option ", key, options.min ? "=" : " = ", value(opt[key]), options.min ? ";" : ";\n");
});
if (!options.min)
out[out.length-1] += "\n";
}
// Builds everything within a namespace
function buildNamespace(ns, indent) {
ns.getChildren(ProtoBuf.Reflect.Enum).forEach(function(enm) {
buildEnum(enm, indent);
});
ns.getChildren(ProtoBuf.Reflect.Message).forEach(function(msg) {
if (!msg.isGroup) // legacy groups are build within the respective field
buildMessage(msg, indent);
});
var exts = util.groupExtensions(ns);
if (exts !== null) {
Object.keys(exts).forEach(function(extFqn) {
var extMsg = ns.resolve(extFqn),
extFields = exts[extFqn];
if (!options.min)
out.push(indent);
out.push("extend ", ns.qn(extMsg), options.min ? "{" : " {\n");
extFields.forEach(function(extField) {
buildMessageField(ns, extField, indent+" ", false);
});
if (!options.min)
out.push(indent);
out.push(options.min ? "}" : "}\n\n");
});
}
ns.getChildren(ProtoBuf.Reflect.Service).forEach(function(svc) {
buildService(svc, indent);
});
ns.getChildren(ProtoBuf.Reflect.Namespace).forEach(function(innerNs) {
if (innerNs.className !== "Namespace")
return;
if (!options.min)
out.push(indent);
out.push("message ", innerNs.name, options.min ? "{" : " {\n");
buildNamespace(innerNs, indent+" ");
if (!options.min)
out.push(indent);
out.push(options.min ? "}" : "}\n");
});
trim();
}
// Builds a message
function buildMessage(msg, indent) {
if (!msg.isGroup) {
if (!options.min)
out.push(indent);
out.push("message ", msg.name);
}
out.push(options.min ? "{" : " {\n");
buildOptions(msg.options, indent+" ");
var n = 0, oneofFields = [];
msg.getChildren(ProtoBuf.Reflect.Message.OneOf).forEach(function(oneof) {
if (!options.min)
out.push(indent, " ");
out.push("oneof ", oneof.name, options.min ? "{" : " {\n");
oneof.fields.forEach(function(fld) {
buildMessageField(msg, fld, indent+" ", true);
oneofFields.push(fld);
});
if (!options.min)
out.push(indent, " ");
out.push(options.min ? "}" : "}\n");
});
msg.getChildren(ProtoBuf.Reflect.Message.Field).forEach(function(fld) {
if (fld instanceof ProtoBuf.Reflect.Message.ExtensionField)
return;
if (oneofFields.indexOf(fld) >= 0)
return;
buildMessageField(msg, fld, indent+" ", false);
n++;
});
if (n > 0 && !options.min)
out[out.length-1] += "\n";
if (msg.extensions) { // array of ranges
if (!options.min)
out.push(indent, " ");
out.push("extensions ");
msg.extensions.forEach(function(range, index) {
if (index > 0)
out.push(options.min ? "," : ", ");
out.push(value(range[0]));
if (range[1] !== range[0])
out.push(" to ", range[1] === ProtoBuf.ID_MAX ? "max" : value(range[1]));
});
out.push(options.min ? ";" : ";\n\n");
}
buildNamespace(msg, indent+" ");
if (!options.min)
out.push(indent);
out.push(options.min ? "}" : "}\n\n");
}
// Builds a message field
function buildMessageField(msg, fld, indent, isOneOf) {
var isGroup = false;
if (!options.min)
out.push(indent);
if (!isOneOf)
out.push(fld.required ? "required " : (fld.repeated ? "repeated " : "optional "));
if (fld.resolvedType !== null) {
if (fld.resolvedType instanceof ProtoBuf.Reflect.Message && fld.resolvedType.isGroup) {
// inline legacy groups
out.push("group ");
isGroup = true;
}
out.push(msg.qn(fld.resolvedType));
} else
out.push(fld.type['name']);
if (!isGroup)
out.push(" ", fld instanceof ProtoBuf.Reflect.Message.ExtensionField ? fld.name.substring(fld.name.lastIndexOf(".")+1) : fld.name);
out.push(options.min ? "=" : " = ", fld.id);
if (isGroup) // inline
buildMessage(fld.resolvedType, indent);
else {
var keys = Object.keys(fld.options);
if (keys.length > 0) {
out.push(options.min ? "[" : " [");
var n = 0;
keys.forEach(function (key) {
if (n > 0)
out.push(options.min ? "," : ", ");
out.push(key, options.min ? "=" : " = ",
// BEWARE: Monkey patch for string enum defaults
key === "default" && fld.type === ProtoBuf.TYPES["enum"] && typeof fld.options[key] === 'string' ? fld.options[key] : value(fld.options[key])
);
n++;
});
out.push("]");
}
out.push(options.min ? ";" : ";\n");
}
}
// Builds an enum
function buildEnum(enm, indent) {
if (!options.min)
out.push(indent);
out.push("enum ", enm.name, options.min ? "{" : " {\n");
buildOptions(enm.options, indent+" ");
enm.getChildren(ProtoBuf.Reflect.Enum.Value).forEach(function(val) {
if (!options.min)
out.push(indent, " ");
out.push(val.name, options.min ? "=" : " = ", val.id, options.min? ";" : ";\n");
});
if (!options.min)
out.push(indent);
out.push(options.min ? "}" : "}\n\n");
}
// Builds a service
function buildService(svc, indent) {
if (!options.min)
out.push(indent);
out.push("service ", svc.name, options.min ? "{" : " {\n");
buildOptions(svc.options, indent+" ");
svc.getChildren(ProtoBuf.Reflect.Service.RPCMethod).forEach(function(rpc) {
if (!options.min)
out.push(indent+" ");
out.push("rpc ", rpc.name, "(", svc.qn(rpc.resolvedRequestType), ") returns(", svc.qn(rpc.resolvedResponseType), ")");
var keys = Object.keys(rpc.options);
if (keys.length === 0) {
out.push(options.min ? ";" : ";\n")
} else {
out.push(options.min ? "{" : " {\n");
buildOptions(rpc.options, indent+" ");
trim();
if (!options.min)
out.push(indent+" ");
out.push(options.min ? "}" : "}\n");
}
if (!options.min)
out[out.length-1] += "\n";
});
trim();
out.push(options.min ? "}" : "}\n");
}
// Start by building the package namespace
var pkg = ptr.fqn().substring(1);
if (pkg !== "")
out.push("package ", pkg, options.min ? ";" : ";\n\n");
buildOptions(ptr.options, "");
buildNamespace(ptr, "");
return out.join('');
};
/**
* Module description.
* @type {string}
*/
proto.description = description;
/**
* Converts a JavaScript value to a .proto value.
* @param {*} v Value
* @returns {string} Dot proto value
*/
function value(v) {
switch (typeof v) {
case 'boolean':
return v ? 'true' : 'false';
case 'number':
return v.toString();
case 'string':
return '"'+v.replace(/"/g, '\\"')+'"';
default:
throw new Error("illegal value type: "+typeof(v));
}
}