protobufjs 3.6.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/proto2js +16 -4
- package/bower.json +1 -1
- package/dist/ProtoBuf.js +645 -441
- package/dist/ProtoBuf.min.js +96 -96
- package/dist/ProtoBuf.min.js.gz +0 -0
- package/dist/ProtoBuf.min.map +2 -2
- package/dist/ProtoBuf.noparse.js +520 -357
- package/dist/ProtoBuf.noparse.min.js +68 -66
- package/dist/ProtoBuf.noparse.min.js.gz +0 -0
- package/dist/ProtoBuf.noparse.min.map +3 -3
- package/docs/ProtoBuf.Builder.Message.html +673 -135
- package/docs/ProtoBuf.Builder.Service.html +58 -19
- package/docs/ProtoBuf.Builder.html +374 -46
- package/docs/ProtoBuf.DotProto.Parser.html +58 -19
- package/docs/ProtoBuf.DotProto.Tokenizer.html +104 -19
- package/docs/ProtoBuf.DotProto.html +16 -10
- package/docs/ProtoBuf.Reflect.Enum.Value.html +207 -33
- package/docs/ProtoBuf.Reflect.Enum.html +318 -56
- package/docs/ProtoBuf.Reflect.Extension.html +53 -13
- package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +450 -68
- package/docs/ProtoBuf.Reflect.Message.Field.html +454 -51
- package/docs/ProtoBuf.Reflect.Message.OneOf.html +1044 -0
- package/docs/ProtoBuf.Reflect.Message.html +378 -64
- package/docs/ProtoBuf.Reflect.Namespace.html +333 -51
- package/docs/ProtoBuf.Reflect.Service.Method.html +228 -35
- package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +262 -41
- package/docs/ProtoBuf.Reflect.Service.html +318 -56
- package/docs/ProtoBuf.Reflect.T.html +210 -25
- package/docs/ProtoBuf.Reflect.html +17 -11
- package/docs/ProtoBuf.Util.html +59 -13
- package/docs/ProtoBuf.html +235 -67
- package/docs/ProtoBuf.js.html +648 -443
- package/docs/index.html +4 -2
- package/docs/styles/jsdoc-default.css +2 -2
- package/examples/protoify/.npmignore +2 -0
- package/examples/protoify/README.md +28 -0
- package/examples/protoify/index.js +147 -0
- package/examples/protoify/json.js +123 -0
- package/examples/protoify/json.json +123 -0
- package/examples/protoify/json.proto +30 -0
- package/examples/protoify/package.json +15 -0
- package/examples/protoify/test.js +56 -0
- package/examples/websocket/README.md +1 -0
- package/examples/websocket/package.json +1 -1
- package/externs/ProtoBuf.js +922 -922
- package/package.json +3 -3
- package/scripts/build.js +58 -58
- package/src/ProtoBuf/Builder/Message.js +107 -77
- package/src/ProtoBuf/Builder/Service.js +8 -5
- package/src/ProtoBuf/Builder.js +71 -37
- package/src/ProtoBuf/DotProto/Parser.js +108 -72
- package/src/ProtoBuf/DotProto/Tokenizer.js +17 -11
- package/src/ProtoBuf/Lang.js +1 -1
- package/src/ProtoBuf/Reflect/Enum/Value.js +3 -2
- package/src/ProtoBuf/Reflect/Enum.js +9 -5
- package/src/ProtoBuf/Reflect/Extension.js +4 -3
- package/src/ProtoBuf/Reflect/Message/ExtensionField.js +4 -3
- package/src/ProtoBuf/Reflect/Message/Field.js +45 -26
- package/src/ProtoBuf/Reflect/Message/OneOf.js +19 -0
- package/src/ProtoBuf/Reflect/Message.js +36 -19
- package/src/ProtoBuf/Reflect/Namespace.js +19 -15
- package/src/ProtoBuf/Reflect/Service/Method.js +9 -5
- package/src/ProtoBuf/Reflect/Service/RPCMethod.js +3 -2
- package/src/ProtoBuf/Reflect/Service.js +9 -5
- package/src/ProtoBuf/Reflect/T.js +20 -6
- package/src/ProtoBuf/Reflect.js +9 -0
- package/src/ProtoBuf/Util.js +132 -132
- package/src/ProtoBuf.js +15 -17
- package/src/google/protobuf/descriptor.json +33 -13
- package/tests/bench.txt +373 -373
- package/tests/complex.json +8 -4
- package/tests/custom-options.json +169 -169
- package/tests/extend.json +71 -71
- package/tests/nodeunit-browser/nodeunit.css +70 -70
- package/tests/nodeunit-browser/nodeunit.js +2108 -2108
- package/tests/oneof.proto +6 -0
- package/tests/options.json +32 -32
- package/tests/options.proto +2 -0
- package/tests/proto2js/Bar.json +46 -46
- package/tests/suite.js +83 -12
- package/.idea/.name +0 -1
- package/.idea/ProtoBuf.iml +0 -9
- package/.idea/dictionaries/Daniel.xml +0 -7
- package/.idea/encodings.xml +0 -5
- package/.idea/misc.xml +0 -5
- package/.idea/modules.xml +0 -9
- package/.idea/scopes/scope_settings.xml +0 -5
- package/.idea/vcs.xml +0 -7
- package/.idea/workspace.xml +0 -551
- package/NOTICE +0 -2
- package/sandbox/issue146/MyOptions.proto +0 -28
- package/sandbox/issue146/Sample.proto +0 -21
- package/sandbox/issue146/main.js +0 -3
- package/sandbox/issue147/enum.proto +0 -8
- package/sandbox/issue147/main.js +0 -3
- package/sandbox/issue42/innerextend.proto +0 -18
- package/sandbox/issue42/main.js +0 -8
- package/sandbox/issue42/outerextend.proto +0 -17
- package/v8.log +0 -3828
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constructs a new Service.
|
|
3
3
|
* @exports ProtoBuf.Reflect.Service
|
|
4
|
+
* @param {!ProtoBuf.Builder} builder Builder reference
|
|
4
5
|
* @param {!ProtoBuf.Reflect.Namespace} root Root
|
|
5
6
|
* @param {string} name Service name
|
|
6
7
|
* @param {Object.<string,*>=} options Options
|
|
7
8
|
* @constructor
|
|
8
9
|
* @extends ProtoBuf.Reflect.Namespace
|
|
9
10
|
*/
|
|
10
|
-
var Service = function(root, name, options) {
|
|
11
|
-
Namespace.call(this, root, name, options);
|
|
11
|
+
var Service = function(builder, root, name, options) {
|
|
12
|
+
Namespace.call(this, builder, root, name, options);
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @override
|
|
@@ -22,8 +23,11 @@ var Service = function(root, name, options) {
|
|
|
22
23
|
this.clazz = null;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @alias ProtoBuf.Reflect.Service.prototype
|
|
28
|
+
* @inner
|
|
29
|
+
*/
|
|
30
|
+
var ServicePrototype = Service.prototype = Object.create(Namespace.prototype);
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* Builds the service and returns the runtime counterpart, which is a fully functional class.
|
|
@@ -33,7 +37,7 @@ Service.prototype = Object.create(Namespace.prototype);
|
|
|
33
37
|
* @throws {Error} If the message cannot be built
|
|
34
38
|
* @expose
|
|
35
39
|
*/
|
|
36
|
-
|
|
40
|
+
ServicePrototype.build = function(rebuild) {
|
|
37
41
|
if (this.clazz && !rebuild)
|
|
38
42
|
return this.clazz;
|
|
39
43
|
|
|
@@ -3,14 +3,22 @@
|
|
|
3
3
|
* @exports ProtoBuf.Reflect.T
|
|
4
4
|
* @constructor
|
|
5
5
|
* @abstract
|
|
6
|
-
* @param {ProtoBuf.
|
|
6
|
+
* @param {!ProtoBuf.Builder} builder Builder reference
|
|
7
|
+
* @param {?ProtoBuf.Reflect.T} parent Parent object
|
|
7
8
|
* @param {string} name Object name
|
|
8
9
|
*/
|
|
9
|
-
var T = function(parent, name) {
|
|
10
|
+
var T = function(builder, parent, name) {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Builder reference.
|
|
14
|
+
* @type {!ProtoBuf.Builder}
|
|
15
|
+
* @expose
|
|
16
|
+
*/
|
|
17
|
+
this.builder = builder;
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* Parent object.
|
|
13
|
-
* @type {ProtoBuf.Reflect.T
|
|
21
|
+
* @type {?ProtoBuf.Reflect.T}
|
|
14
22
|
* @expose
|
|
15
23
|
*/
|
|
16
24
|
this.parent = parent;
|
|
@@ -30,12 +38,18 @@ var T = function(parent, name) {
|
|
|
30
38
|
this.className;
|
|
31
39
|
};
|
|
32
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @alias ProtoBuf.Reflect.T.prototype
|
|
43
|
+
* @inner
|
|
44
|
+
*/
|
|
45
|
+
var TPrototype = T.prototype;
|
|
46
|
+
|
|
33
47
|
/**
|
|
34
48
|
* Returns the fully qualified name of this object.
|
|
35
49
|
* @returns {string} Fully qualified name as of ".PATH.TO.THIS"
|
|
36
50
|
* @expose
|
|
37
51
|
*/
|
|
38
|
-
|
|
52
|
+
TPrototype.fqn = function() {
|
|
39
53
|
var name = this.name,
|
|
40
54
|
ptr = this;
|
|
41
55
|
do {
|
|
@@ -53,7 +67,7 @@ T.prototype.fqn = function() {
|
|
|
53
67
|
* @return String representation
|
|
54
68
|
* @expose
|
|
55
69
|
*/
|
|
56
|
-
|
|
70
|
+
TPrototype.toString = function(includeClass) {
|
|
57
71
|
return (includeClass ? this.className + " " : "") + this.fqn();
|
|
58
72
|
};
|
|
59
73
|
|
|
@@ -62,6 +76,6 @@ T.prototype.toString = function(includeClass) {
|
|
|
62
76
|
* @throws {Error} If this type cannot be built directly
|
|
63
77
|
* @expose
|
|
64
78
|
*/
|
|
65
|
-
|
|
79
|
+
TPrototype.build = function() {
|
|
66
80
|
throw Error(this.toString(true)+" cannot be built directly");
|
|
67
81
|
};
|
package/src/ProtoBuf/Reflect.js
CHANGED
|
@@ -52,6 +52,14 @@ ProtoBuf.Reflect = (function(ProtoBuf) {
|
|
|
52
52
|
*/
|
|
53
53
|
Reflect.Message.ExtensionField = ExtensionField;
|
|
54
54
|
|
|
55
|
+
//? include("Reflect/Message/OneOf.js");
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @alias ProtoBuf.Reflect.Message.OneOf
|
|
59
|
+
* @expose
|
|
60
|
+
*/
|
|
61
|
+
Reflect.Message.OneOf = OneOf;
|
|
62
|
+
|
|
55
63
|
//? include("Reflect/Enum.js");
|
|
56
64
|
|
|
57
65
|
/**
|
|
@@ -101,4 +109,5 @@ ProtoBuf.Reflect = (function(ProtoBuf) {
|
|
|
101
109
|
Reflect.Service.RPCMethod = RPCMethod;
|
|
102
110
|
|
|
103
111
|
return Reflect;
|
|
112
|
+
|
|
104
113
|
})(ProtoBuf);
|
package/src/ProtoBuf/Util.js
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @alias ProtoBuf.Util
|
|
3
|
-
* @expose
|
|
4
|
-
*/
|
|
5
|
-
ProtoBuf.Util = (function() {
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
// Object.create polyfill
|
|
9
|
-
// ref: https://developer.mozilla.org/de/docs/JavaScript/Reference/Global_Objects/Object/create
|
|
10
|
-
if (!Object.create)
|
|
11
|
-
/** @expose */
|
|
12
|
-
Object.create = function (o) {
|
|
13
|
-
if (arguments.length > 1)
|
|
14
|
-
throw Error('Object.create polyfill only accepts the first parameter.');
|
|
15
|
-
function F() {}
|
|
16
|
-
F.prototype = o;
|
|
17
|
-
return new F();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* ProtoBuf utilities.
|
|
22
|
-
* @exports ProtoBuf.Util
|
|
23
|
-
* @namespace
|
|
24
|
-
*/
|
|
25
|
-
var Util = {};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Flag if running in node (fs is available) or not.
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
* @const
|
|
31
|
-
* @expose
|
|
32
|
-
*/
|
|
33
|
-
Util.IS_NODE = false;
|
|
34
|
-
try {
|
|
35
|
-
// There is no reliable way to detect node.js as an environment, so our
|
|
36
|
-
// best bet is to feature-detect what we actually need.
|
|
37
|
-
Util.IS_NODE =
|
|
38
|
-
typeof require === 'function' &&
|
|
39
|
-
typeof require("fs").readFileSync === 'function' &&
|
|
40
|
-
typeof require("path").resolve === 'function';
|
|
41
|
-
} catch (e) {}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Constructs a XMLHttpRequest object.
|
|
45
|
-
* @return {XMLHttpRequest}
|
|
46
|
-
* @throws {Error} If XMLHttpRequest is not supported
|
|
47
|
-
* @expose
|
|
48
|
-
*/
|
|
49
|
-
Util.XHR = function() {
|
|
50
|
-
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
51
|
-
var XMLHttpFactories = [
|
|
52
|
-
function () {return new XMLHttpRequest()},
|
|
53
|
-
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
54
|
-
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
55
|
-
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
56
|
-
];
|
|
57
|
-
/** @type {?XMLHttpRequest} */
|
|
58
|
-
var xhr = null;
|
|
59
|
-
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
60
|
-
try { xhr = XMLHttpFactories[i](); }
|
|
61
|
-
catch (e) { continue; }
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
if (!xhr)
|
|
65
|
-
throw Error("XMLHttpRequest is not supported");
|
|
66
|
-
return xhr;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Fetches a resource.
|
|
71
|
-
* @param {string} path Resource path
|
|
72
|
-
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
73
|
-
* be fetched synchronously. If the request failed, contents will be null.
|
|
74
|
-
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
75
|
-
* @expose
|
|
76
|
-
*/
|
|
77
|
-
Util.fetch = function(path, callback) {
|
|
78
|
-
if (callback && typeof callback != 'function')
|
|
79
|
-
callback = null;
|
|
80
|
-
if (Util.IS_NODE) {
|
|
81
|
-
if (callback) {
|
|
82
|
-
require("fs").readFile(path, function(err, data) {
|
|
83
|
-
if (err)
|
|
84
|
-
callback(null);
|
|
85
|
-
else
|
|
86
|
-
callback(""+data);
|
|
87
|
-
});
|
|
88
|
-
} else
|
|
89
|
-
try {
|
|
90
|
-
return require("fs").readFileSync(path);
|
|
91
|
-
} catch (e) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
var xhr = Util.XHR();
|
|
96
|
-
xhr.open('GET', path, callback ? true : false);
|
|
97
|
-
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
98
|
-
xhr.setRequestHeader('Accept', 'text/plain');
|
|
99
|
-
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
100
|
-
if (callback) {
|
|
101
|
-
xhr.onreadystatechange = function() {
|
|
102
|
-
if (xhr.readyState != 4) return;
|
|
103
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
104
|
-
callback(xhr.responseText);
|
|
105
|
-
else
|
|
106
|
-
callback(null);
|
|
107
|
-
};
|
|
108
|
-
if (xhr.readyState == 4)
|
|
109
|
-
return;
|
|
110
|
-
xhr.send(null);
|
|
111
|
-
} else {
|
|
112
|
-
xhr.send(null);
|
|
113
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
114
|
-
return xhr.responseText;
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Tests if an object is an array.
|
|
122
|
-
* @function
|
|
123
|
-
* @param {*} obj Object to test
|
|
124
|
-
* @returns {boolean} true if it is an array, else false
|
|
125
|
-
* @expose
|
|
126
|
-
*/
|
|
127
|
-
Util.isArray = Array.isArray || function(obj) {
|
|
128
|
-
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
return Util;
|
|
132
|
-
})();
|
|
1
|
+
/**
|
|
2
|
+
* @alias ProtoBuf.Util
|
|
3
|
+
* @expose
|
|
4
|
+
*/
|
|
5
|
+
ProtoBuf.Util = (function() {
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
// Object.create polyfill
|
|
9
|
+
// ref: https://developer.mozilla.org/de/docs/JavaScript/Reference/Global_Objects/Object/create
|
|
10
|
+
if (!Object.create)
|
|
11
|
+
/** @expose */
|
|
12
|
+
Object.create = function (o) {
|
|
13
|
+
if (arguments.length > 1)
|
|
14
|
+
throw Error('Object.create polyfill only accepts the first parameter.');
|
|
15
|
+
function F() {}
|
|
16
|
+
F.prototype = o;
|
|
17
|
+
return new F();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* ProtoBuf utilities.
|
|
22
|
+
* @exports ProtoBuf.Util
|
|
23
|
+
* @namespace
|
|
24
|
+
*/
|
|
25
|
+
var Util = {};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Flag if running in node (fs is available) or not.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
* @const
|
|
31
|
+
* @expose
|
|
32
|
+
*/
|
|
33
|
+
Util.IS_NODE = false;
|
|
34
|
+
try {
|
|
35
|
+
// There is no reliable way to detect node.js as an environment, so our
|
|
36
|
+
// best bet is to feature-detect what we actually need.
|
|
37
|
+
Util.IS_NODE =
|
|
38
|
+
typeof require === 'function' &&
|
|
39
|
+
typeof require("fs").readFileSync === 'function' &&
|
|
40
|
+
typeof require("path").resolve === 'function';
|
|
41
|
+
} catch (e) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a XMLHttpRequest object.
|
|
45
|
+
* @return {XMLHttpRequest}
|
|
46
|
+
* @throws {Error} If XMLHttpRequest is not supported
|
|
47
|
+
* @expose
|
|
48
|
+
*/
|
|
49
|
+
Util.XHR = function() {
|
|
50
|
+
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
51
|
+
var XMLHttpFactories = [
|
|
52
|
+
function () {return new XMLHttpRequest()},
|
|
53
|
+
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
54
|
+
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
55
|
+
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
56
|
+
];
|
|
57
|
+
/** @type {?XMLHttpRequest} */
|
|
58
|
+
var xhr = null;
|
|
59
|
+
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
60
|
+
try { xhr = XMLHttpFactories[i](); }
|
|
61
|
+
catch (e) { continue; }
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (!xhr)
|
|
65
|
+
throw Error("XMLHttpRequest is not supported");
|
|
66
|
+
return xhr;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Fetches a resource.
|
|
71
|
+
* @param {string} path Resource path
|
|
72
|
+
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
73
|
+
* be fetched synchronously. If the request failed, contents will be null.
|
|
74
|
+
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
75
|
+
* @expose
|
|
76
|
+
*/
|
|
77
|
+
Util.fetch = function(path, callback) {
|
|
78
|
+
if (callback && typeof callback != 'function')
|
|
79
|
+
callback = null;
|
|
80
|
+
if (Util.IS_NODE) {
|
|
81
|
+
if (callback) {
|
|
82
|
+
require("fs").readFile(path, function(err, data) {
|
|
83
|
+
if (err)
|
|
84
|
+
callback(null);
|
|
85
|
+
else
|
|
86
|
+
callback(""+data);
|
|
87
|
+
});
|
|
88
|
+
} else
|
|
89
|
+
try {
|
|
90
|
+
return require("fs").readFileSync(path);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
var xhr = Util.XHR();
|
|
96
|
+
xhr.open('GET', path, callback ? true : false);
|
|
97
|
+
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
98
|
+
xhr.setRequestHeader('Accept', 'text/plain');
|
|
99
|
+
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
100
|
+
if (callback) {
|
|
101
|
+
xhr.onreadystatechange = function() {
|
|
102
|
+
if (xhr.readyState != 4) return;
|
|
103
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
104
|
+
callback(xhr.responseText);
|
|
105
|
+
else
|
|
106
|
+
callback(null);
|
|
107
|
+
};
|
|
108
|
+
if (xhr.readyState == 4)
|
|
109
|
+
return;
|
|
110
|
+
xhr.send(null);
|
|
111
|
+
} else {
|
|
112
|
+
xhr.send(null);
|
|
113
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
114
|
+
return xhr.responseText;
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Tests if an object is an array.
|
|
122
|
+
* @function
|
|
123
|
+
* @param {*} obj Object to test
|
|
124
|
+
* @returns {boolean} true if it is an array, else false
|
|
125
|
+
* @expose
|
|
126
|
+
*/
|
|
127
|
+
Util.isArray = Array.isArray || function(obj) {
|
|
128
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return Util;
|
|
132
|
+
})();
|
package/src/ProtoBuf.js
CHANGED
|
@@ -257,10 +257,9 @@
|
|
|
257
257
|
* @expose
|
|
258
258
|
*/
|
|
259
259
|
ProtoBuf.loadProto = function(proto, builder, filename) {
|
|
260
|
-
if (typeof builder === 'string' || (builder && typeof builder["file"] === 'string' && typeof builder["root"] === 'string'))
|
|
261
|
-
filename = builder
|
|
262
|
-
builder =
|
|
263
|
-
}
|
|
260
|
+
if (typeof builder === 'string' || (builder && typeof builder["file"] === 'string' && typeof builder["root"] === 'string'))
|
|
261
|
+
filename = builder,
|
|
262
|
+
builder = undefined;
|
|
264
263
|
return ProtoBuf.loadJson((new ProtoBuf.DotProto.Parser(proto)).parse(), builder, filename);
|
|
265
264
|
};
|
|
266
265
|
|
|
@@ -328,18 +327,18 @@
|
|
|
328
327
|
//? } // !NOPARSE
|
|
329
328
|
|
|
330
329
|
/**
|
|
331
|
-
* Constructs a new Builder
|
|
332
|
-
* @param {string
|
|
333
|
-
*
|
|
334
|
-
* @param {Object.<string,*>=} options Top level options
|
|
335
|
-
* @return {ProtoBuf.Builder} New Builder
|
|
330
|
+
* Constructs a new empty Builder.
|
|
331
|
+
* @param {Object.<string,*>=} options Builder options, defaults to global options set on ProtoBuf
|
|
332
|
+
* @return {!ProtoBuf.Builder} Builder
|
|
336
333
|
* @expose
|
|
337
334
|
*/
|
|
338
|
-
ProtoBuf.newBuilder = function(
|
|
339
|
-
|
|
340
|
-
if (typeof
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
ProtoBuf.newBuilder = function(options) {
|
|
336
|
+
options = options || {};
|
|
337
|
+
if (typeof options['convertFieldsToCamelCase'] === 'undefined')
|
|
338
|
+
options['convertFieldsToCamelCase'] = ProtoBuf.convertFieldsToCamelCase;
|
|
339
|
+
if (typeof options['populateAccessors'] === 'undefined')
|
|
340
|
+
options['populateAccessors'] = ProtoBuf.populateAccessors;
|
|
341
|
+
return new ProtoBuf.Builder(options);
|
|
343
342
|
};
|
|
344
343
|
|
|
345
344
|
/**
|
|
@@ -361,7 +360,6 @@
|
|
|
361
360
|
json = JSON.parse(json);
|
|
362
361
|
builder["import"](json, filename);
|
|
363
362
|
builder.resolveAll();
|
|
364
|
-
builder.build();
|
|
365
363
|
return builder;
|
|
366
364
|
};
|
|
367
365
|
|
|
@@ -402,8 +400,8 @@
|
|
|
402
400
|
return ProtoBuf;
|
|
403
401
|
}
|
|
404
402
|
|
|
405
|
-
/* CommonJS */ if (typeof module
|
|
406
|
-
module[
|
|
403
|
+
/* CommonJS */ if (typeof require === 'function' && typeof module === 'object' && module && typeof exports === 'object' && exports)
|
|
404
|
+
module['exports'] = init(require("bytebuffer"));
|
|
407
405
|
/* AMD */ else if (typeof define === 'function' && define["amd"])
|
|
408
406
|
define(["ByteBuffer"], init);
|
|
409
407
|
/* Global */ else
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
],
|
|
15
15
|
"enums": [],
|
|
16
16
|
"messages": [],
|
|
17
|
-
"options": {}
|
|
17
|
+
"options": {},
|
|
18
|
+
"oneofs": {}
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
"name": "FileDescriptorProto",
|
|
@@ -99,7 +100,8 @@
|
|
|
99
100
|
],
|
|
100
101
|
"enums": [],
|
|
101
102
|
"messages": [],
|
|
102
|
-
"options": {}
|
|
103
|
+
"options": {},
|
|
104
|
+
"oneofs": {}
|
|
103
105
|
},
|
|
104
106
|
{
|
|
105
107
|
"name": "DescriptorProto",
|
|
@@ -176,10 +178,12 @@
|
|
|
176
178
|
],
|
|
177
179
|
"enums": [],
|
|
178
180
|
"messages": [],
|
|
179
|
-
"options": {}
|
|
181
|
+
"options": {},
|
|
182
|
+
"oneofs": {}
|
|
180
183
|
}
|
|
181
184
|
],
|
|
182
|
-
"options": {}
|
|
185
|
+
"options": {},
|
|
186
|
+
"oneofs": {}
|
|
183
187
|
},
|
|
184
188
|
{
|
|
185
189
|
"name": "FieldDescriptorProto",
|
|
@@ -340,7 +344,8 @@
|
|
|
340
344
|
}
|
|
341
345
|
],
|
|
342
346
|
"messages": [],
|
|
343
|
-
"options": {}
|
|
347
|
+
"options": {},
|
|
348
|
+
"oneofs": {}
|
|
344
349
|
},
|
|
345
350
|
{
|
|
346
351
|
"name": "EnumDescriptorProto",
|
|
@@ -369,7 +374,8 @@
|
|
|
369
374
|
],
|
|
370
375
|
"enums": [],
|
|
371
376
|
"messages": [],
|
|
372
|
-
"options": {}
|
|
377
|
+
"options": {},
|
|
378
|
+
"oneofs": {}
|
|
373
379
|
},
|
|
374
380
|
{
|
|
375
381
|
"name": "EnumValueDescriptorProto",
|
|
@@ -398,7 +404,8 @@
|
|
|
398
404
|
],
|
|
399
405
|
"enums": [],
|
|
400
406
|
"messages": [],
|
|
401
|
-
"options": {}
|
|
407
|
+
"options": {},
|
|
408
|
+
"oneofs": {}
|
|
402
409
|
},
|
|
403
410
|
{
|
|
404
411
|
"name": "ServiceDescriptorProto",
|
|
@@ -427,7 +434,8 @@
|
|
|
427
434
|
],
|
|
428
435
|
"enums": [],
|
|
429
436
|
"messages": [],
|
|
430
|
-
"options": {}
|
|
437
|
+
"options": {},
|
|
438
|
+
"oneofs": {}
|
|
431
439
|
},
|
|
432
440
|
{
|
|
433
441
|
"name": "MethodDescriptorProto",
|
|
@@ -463,7 +471,8 @@
|
|
|
463
471
|
],
|
|
464
472
|
"enums": [],
|
|
465
473
|
"messages": [],
|
|
466
|
-
"options": {}
|
|
474
|
+
"options": {},
|
|
475
|
+
"oneofs": {}
|
|
467
476
|
},
|
|
468
477
|
{
|
|
469
478
|
"name": "FileOptions",
|
|
@@ -573,6 +582,7 @@
|
|
|
573
582
|
],
|
|
574
583
|
"messages": [],
|
|
575
584
|
"options": {},
|
|
585
|
+
"oneofs": {},
|
|
576
586
|
"extensions": [
|
|
577
587
|
1000,
|
|
578
588
|
536870911
|
|
@@ -610,6 +620,7 @@
|
|
|
610
620
|
"enums": [],
|
|
611
621
|
"messages": [],
|
|
612
622
|
"options": {},
|
|
623
|
+
"oneofs": {},
|
|
613
624
|
"extensions": [
|
|
614
625
|
1000,
|
|
615
626
|
536870911
|
|
@@ -698,6 +709,7 @@
|
|
|
698
709
|
],
|
|
699
710
|
"messages": [],
|
|
700
711
|
"options": {},
|
|
712
|
+
"oneofs": {},
|
|
701
713
|
"extensions": [
|
|
702
714
|
1000,
|
|
703
715
|
536870911
|
|
@@ -726,6 +738,7 @@
|
|
|
726
738
|
"enums": [],
|
|
727
739
|
"messages": [],
|
|
728
740
|
"options": {},
|
|
741
|
+
"oneofs": {},
|
|
729
742
|
"extensions": [
|
|
730
743
|
1000,
|
|
731
744
|
536870911
|
|
@@ -745,6 +758,7 @@
|
|
|
745
758
|
"enums": [],
|
|
746
759
|
"messages": [],
|
|
747
760
|
"options": {},
|
|
761
|
+
"oneofs": {},
|
|
748
762
|
"extensions": [
|
|
749
763
|
1000,
|
|
750
764
|
536870911
|
|
@@ -764,6 +778,7 @@
|
|
|
764
778
|
"enums": [],
|
|
765
779
|
"messages": [],
|
|
766
780
|
"options": {},
|
|
781
|
+
"oneofs": {},
|
|
767
782
|
"extensions": [
|
|
768
783
|
1000,
|
|
769
784
|
536870911
|
|
@@ -783,6 +798,7 @@
|
|
|
783
798
|
"enums": [],
|
|
784
799
|
"messages": [],
|
|
785
800
|
"options": {},
|
|
801
|
+
"oneofs": {},
|
|
786
802
|
"extensions": [
|
|
787
803
|
1000,
|
|
788
804
|
536870911
|
|
@@ -863,10 +879,12 @@
|
|
|
863
879
|
],
|
|
864
880
|
"enums": [],
|
|
865
881
|
"messages": [],
|
|
866
|
-
"options": {}
|
|
882
|
+
"options": {},
|
|
883
|
+
"oneofs": {}
|
|
867
884
|
}
|
|
868
885
|
],
|
|
869
|
-
"options": {}
|
|
886
|
+
"options": {},
|
|
887
|
+
"oneofs": {}
|
|
870
888
|
},
|
|
871
889
|
{
|
|
872
890
|
"name": "SourceCodeInfo",
|
|
@@ -919,10 +937,12 @@
|
|
|
919
937
|
],
|
|
920
938
|
"enums": [],
|
|
921
939
|
"messages": [],
|
|
922
|
-
"options": {}
|
|
940
|
+
"options": {},
|
|
941
|
+
"oneofs": {}
|
|
923
942
|
}
|
|
924
943
|
],
|
|
925
|
-
"options": {}
|
|
944
|
+
"options": {},
|
|
945
|
+
"oneofs": {}
|
|
926
946
|
}
|
|
927
947
|
],
|
|
928
948
|
"enums": [],
|