protobufjs 5.0.1 → 5.0.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/.travis.yml +2 -1
- package/README.md +144 -22
- package/bin/pbjs +2 -2
- package/bower.json +2 -2
- package/cli/pbjs/targets/amd.js +1 -1
- package/cli/pbjs/targets/json.js +8 -0
- package/cli/pbjs/util.js +1 -1
- package/cli/pbjs.js +1 -1
- package/dist/protobuf-light.js +166 -128
- package/dist/protobuf-light.min.js +88 -81
- package/dist/protobuf-light.min.js.gz +0 -0
- package/dist/protobuf-light.min.map +4 -4
- package/dist/protobuf.js +171 -129
- package/dist/protobuf.min.js +106 -98
- package/dist/protobuf.min.js.gz +0 -0
- package/dist/protobuf.min.map +4 -4
- package/docs/ProtoBuf.Builder.Message.html +1408 -971
- package/docs/ProtoBuf.Builder.Service.html +266 -197
- package/docs/ProtoBuf.Builder.html +758 -542
- package/docs/ProtoBuf.DotProto.Parser.html +223 -161
- package/docs/ProtoBuf.DotProto.Tokenizer.html +344 -248
- package/docs/ProtoBuf.DotProto.html +20 -12
- package/docs/ProtoBuf.Element.html +554 -554
- package/docs/ProtoBuf.Map.html +158 -123
- package/docs/ProtoBuf.Reflect.Element.html +286 -143
- package/docs/ProtoBuf.Reflect.Enum.Value.html +329 -228
- package/docs/ProtoBuf.Reflect.Enum.html +757 -537
- package/docs/ProtoBuf.Reflect.Extension.html +73 -56
- package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +1013 -740
- package/docs/ProtoBuf.Reflect.Message.Field.html +926 -649
- package/docs/ProtoBuf.Reflect.Message.OneOf.html +327 -245
- package/docs/ProtoBuf.Reflect.Message.html +915 -651
- package/docs/ProtoBuf.Reflect.Namespace.html +648 -447
- package/docs/ProtoBuf.Reflect.Service.Method.html +363 -251
- package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +545 -397
- package/docs/ProtoBuf.Reflect.Service.html +721 -511
- package/docs/ProtoBuf.Reflect.T.html +268 -197
- package/docs/ProtoBuf.Reflect.html +20 -12
- package/docs/ProtoBuf.Util.html +169 -118
- package/docs/ProtoBuf.html +840 -628
- package/docs/ProtoBuf.js.html +177 -134
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/index.html +7 -5
- package/docs/styles/jsdoc-default.css +95 -75
- package/docs/styles/prettify-tomorrow.css +1 -1
- package/examples/protoify/json.js +123 -123
- package/examples/protoify/json.json +123 -123
- package/examples/websocket/server.js +4 -4
- package/externs/protobuf.js +1 -1
- package/jsdoc.json +1 -1
- package/package.json +2 -2
- package/scripts/build.js +53 -53
- package/src/ProtoBuf/Builder/Message.js +9 -5
- package/src/ProtoBuf/Builder.js +19 -2
- package/src/ProtoBuf/DotProto/Parser.js +5 -1
- package/src/ProtoBuf/Reflect/Element.js +13 -1
- package/src/ProtoBuf/Reflect/Message/Field.js +2 -2
- package/src/ProtoBuf/Reflect/Message.js +6 -1
- package/src/ProtoBuf/Util.js +116 -116
- package/src/bower.json +1 -1
- package/src/google/protobuf/descriptor.json +27 -1
- package/tests/bench.txt +373 -373
- package/tests/complex.json +8 -1
- package/tests/custom-options.json +169 -169
- package/tests/extend.json +71 -71
- package/tests/imports.json +83 -83
- package/tests/nodeunit-browser/nodeunit.css +70 -70
- package/tests/nodeunit-browser/nodeunit.js +2108 -2108
- package/tests/options.json +32 -32
- package/tests/proto2js/Bar.json +46 -46
- package/tests/suite.js +43 -1
- package/sandbox/gapi/googleapis/google/api/annotations.proto +0 -29
- package/sandbox/gapi/googleapis/google/api/http.proto +0 -245
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/datastore.proto +0 -281
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/entity.proto +0 -189
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/query.proto +0 -281
- package/sandbox/gapi/googleapis/google/longrunning/operations.proto +0 -144
- package/sandbox/gapi/googleapis/google/protobuf/any.proto +0 -98
- package/sandbox/gapi/googleapis/google/protobuf/any_test.proto +0 -41
- package/sandbox/gapi/googleapis/google/protobuf/api.proto +0 -201
- package/sandbox/gapi/googleapis/google/protobuf/descriptor.proto +0 -773
- package/sandbox/gapi/googleapis/google/protobuf/duration.proto +0 -95
- package/sandbox/gapi/googleapis/google/protobuf/empty.proto +0 -50
- package/sandbox/gapi/googleapis/google/protobuf/field_mask.proto +0 -167
- package/sandbox/gapi/googleapis/google/protobuf/map_lite_unittest.proto +0 -130
- package/sandbox/gapi/googleapis/google/protobuf/map_proto2_unittest.proto +0 -60
- package/sandbox/gapi/googleapis/google/protobuf/map_unittest.proto +0 -129
- package/sandbox/gapi/googleapis/google/protobuf/map_unittest_proto3.proto +0 -120
- package/sandbox/gapi/googleapis/google/protobuf/source_context.proto +0 -47
- package/sandbox/gapi/googleapis/google/protobuf/struct.proto +0 -94
- package/sandbox/gapi/googleapis/google/protobuf/timestamp.proto +0 -107
- package/sandbox/gapi/googleapis/google/protobuf/type.proto +0 -176
- package/sandbox/gapi/googleapis/google/protobuf/unittest.proto +0 -878
- package/sandbox/gapi/googleapis/google/protobuf/unittest_arena.proto +0 -46
- package/sandbox/gapi/googleapis/google/protobuf/unittest_custom_options.proto +0 -394
- package/sandbox/gapi/googleapis/google/protobuf/unittest_drop_unknown_fields.proto +0 -58
- package/sandbox/gapi/googleapis/google/protobuf/unittest_embed_optimize_for.proto +0 -51
- package/sandbox/gapi/googleapis/google/protobuf/unittest_empty.proto +0 -38
- package/sandbox/gapi/googleapis/google/protobuf/unittest_enormous_descriptor.proto +0 -1048
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import.proto +0 -66
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_lite.proto +0 -52
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_proto3.proto +0 -68
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public.proto +0 -41
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_lite.proto +0 -43
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_proto3.proto +0 -42
- package/sandbox/gapi/googleapis/google/protobuf/unittest_lite.proto +0 -385
- package/sandbox/gapi/googleapis/google/protobuf/unittest_lite_imports_nonlite.proto +0 -44
- package/sandbox/gapi/googleapis/google/protobuf/unittest_mset.proto +0 -82
- package/sandbox/gapi/googleapis/google/protobuf/unittest_mset_wire_format.proto +0 -52
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena.proto +0 -202
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_import.proto +0 -37
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_lite.proto +0 -42
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_field_presence.proto +0 -138
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_generic_services.proto +0 -54
- package/sandbox/gapi/googleapis/google/protobuf/unittest_optimize_for.proto +0 -67
- package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum.proto +0 -71
- package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum2.proto +0 -50
- package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3.proto +0 -388
- package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3_arena.proto +0 -206
- package/sandbox/gapi/googleapis/google/protobuf/unittest_well_known_types.proto +0 -112
- package/sandbox/gapi/googleapis/google/protobuf/unknown_enum_test.proto +0 -62
- package/sandbox/gapi/googleapis/google/protobuf/wrappers.proto +0 -117
- package/sandbox/gapi/googleapis/google/rpc/code.proto +0 -190
- package/sandbox/gapi/googleapis/google/rpc/error_details.proto +0 -157
- package/sandbox/gapi/googleapis/google/rpc/status.proto +0 -90
- package/sandbox/gapi/googleapis/google/type/color.proto +0 -163
- package/sandbox/gapi/googleapis/google/type/date.proto +0 -43
- package/sandbox/gapi/googleapis/google/type/dayofweek.proto +0 -50
- package/sandbox/gapi/googleapis/google/type/latlng.proto +0 -36
- package/sandbox/gapi/googleapis/google/type/money.proto +0 -40
- package/sandbox/gapi/googleapis/google/type/timeofday.proto +0 -42
- package/sandbox/gapi/test.js +0 -17
- package/sandbox/gapi/test.proto +0 -12
- 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/issue182/commands.proto +0 -10
- package/sandbox/issue182/execute.js +0 -22
- package/sandbox/issue182/session_commands.proto +0 -14
- package/sandbox/issue289/A.proto +0 -8
- package/sandbox/issue289/B.proto +0 -8
- package/sandbox/issue289/common.proto +0 -5
- package/sandbox/issue289/main.js +0 -7
- package/sandbox/issue300/IAuth.proto +0 -14
- package/sandbox/issue300/Request.proto +0 -14
- package/sandbox/issue300/main.js +0 -26
- package/sandbox/issue347/index.js +0 -27
- package/sandbox/issue355/main.proto +0 -15
- package/sandbox/issue42/innerextend.proto +0 -18
- package/sandbox/issue42/main.js +0 -8
- package/sandbox/issue42/outerextend.proto +0 -17
package/docs/ProtoBuf.js.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<title>JSDoc: Source:
|
|
5
|
+
<title>JSDoc: Source: protobuf.js</title>
|
|
6
6
|
|
|
7
7
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
8
8
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
<div id="main">
|
|
19
19
|
|
|
20
|
-
<h1 class="page-title">Source:
|
|
20
|
+
<h1 class="page-title">Source: protobuf.js</h1>
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
|
|
25
26
|
|
|
26
27
|
<section>
|
|
27
28
|
<article>
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
* @const
|
|
85
86
|
* @expose
|
|
86
87
|
*/
|
|
87
|
-
ProtoBuf.VERSION = "5.0.
|
|
88
|
+
ProtoBuf.VERSION = "5.0.2";
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
91
|
* Wire types.
|
|
@@ -316,122 +317,122 @@
|
|
|
316
317
|
*/
|
|
317
318
|
ProtoBuf.populateDefaults = true;
|
|
318
319
|
|
|
319
|
-
/**
|
|
320
|
-
* @alias ProtoBuf.Util
|
|
321
|
-
* @expose
|
|
322
|
-
*/
|
|
323
|
-
ProtoBuf.Util = (function() {
|
|
324
|
-
"use strict";
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* ProtoBuf utilities.
|
|
328
|
-
* @exports ProtoBuf.Util
|
|
329
|
-
* @namespace
|
|
330
|
-
*/
|
|
331
|
-
var Util = {};
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Flag if running in node or not.
|
|
335
|
-
* @type {boolean}
|
|
336
|
-
* @const
|
|
337
|
-
* @expose
|
|
338
|
-
*/
|
|
339
|
-
Util.IS_NODE = !!(
|
|
340
|
-
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Constructs a XMLHttpRequest object.
|
|
345
|
-
* @return {XMLHttpRequest}
|
|
346
|
-
* @throws {Error} If XMLHttpRequest is not supported
|
|
347
|
-
* @expose
|
|
348
|
-
*/
|
|
349
|
-
Util.XHR = function() {
|
|
350
|
-
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
351
|
-
var XMLHttpFactories = [
|
|
352
|
-
function () {return new XMLHttpRequest()},
|
|
353
|
-
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
354
|
-
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
355
|
-
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
356
|
-
];
|
|
357
|
-
/** @type {?XMLHttpRequest} */
|
|
358
|
-
var xhr = null;
|
|
359
|
-
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
360
|
-
try { xhr = XMLHttpFactories[i](); }
|
|
361
|
-
catch (e) { continue; }
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
if (!xhr)
|
|
365
|
-
throw Error("XMLHttpRequest is not supported");
|
|
366
|
-
return xhr;
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Fetches a resource.
|
|
371
|
-
* @param {string} path Resource path
|
|
372
|
-
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
373
|
-
* be fetched synchronously. If the request failed, contents will be null.
|
|
374
|
-
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
375
|
-
* @expose
|
|
376
|
-
*/
|
|
377
|
-
Util.fetch = function(path, callback) {
|
|
378
|
-
if (callback && typeof callback != 'function')
|
|
379
|
-
callback = null;
|
|
380
|
-
if (Util.IS_NODE) {
|
|
381
|
-
var fs = require("fs");
|
|
382
|
-
if (callback) {
|
|
383
|
-
fs.readFile(path, function(err, data) {
|
|
384
|
-
if (err)
|
|
385
|
-
callback(null);
|
|
386
|
-
else
|
|
387
|
-
callback(""+data);
|
|
388
|
-
});
|
|
389
|
-
} else
|
|
390
|
-
try {
|
|
391
|
-
return fs.readFileSync(path);
|
|
392
|
-
} catch (e) {
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
} else {
|
|
396
|
-
var xhr = Util.XHR();
|
|
397
|
-
xhr.open('GET', path, callback ? true : false);
|
|
398
|
-
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
399
|
-
xhr.setRequestHeader('Accept', 'text/plain');
|
|
400
|
-
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
401
|
-
if (callback) {
|
|
402
|
-
xhr.onreadystatechange = function() {
|
|
403
|
-
if (xhr.readyState != 4) return;
|
|
404
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
405
|
-
callback(xhr.responseText);
|
|
406
|
-
else
|
|
407
|
-
callback(null);
|
|
408
|
-
};
|
|
409
|
-
if (xhr.readyState == 4)
|
|
410
|
-
return;
|
|
411
|
-
xhr.send(null);
|
|
412
|
-
} else {
|
|
413
|
-
xhr.send(null);
|
|
414
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
415
|
-
return xhr.responseText;
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Converts a string to camel case.
|
|
423
|
-
* @param {string} str
|
|
424
|
-
* @returns {string}
|
|
425
|
-
* @expose
|
|
426
|
-
*/
|
|
427
|
-
Util.toCamelCase = function(str) {
|
|
428
|
-
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
429
|
-
return $1.toUpperCase();
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
return Util;
|
|
434
|
-
})();
|
|
320
|
+
/**
|
|
321
|
+
* @alias ProtoBuf.Util
|
|
322
|
+
* @expose
|
|
323
|
+
*/
|
|
324
|
+
ProtoBuf.Util = (function() {
|
|
325
|
+
"use strict";
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* ProtoBuf utilities.
|
|
329
|
+
* @exports ProtoBuf.Util
|
|
330
|
+
* @namespace
|
|
331
|
+
*/
|
|
332
|
+
var Util = {};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Flag if running in node or not.
|
|
336
|
+
* @type {boolean}
|
|
337
|
+
* @const
|
|
338
|
+
* @expose
|
|
339
|
+
*/
|
|
340
|
+
Util.IS_NODE = !!(
|
|
341
|
+
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Constructs a XMLHttpRequest object.
|
|
346
|
+
* @return {XMLHttpRequest}
|
|
347
|
+
* @throws {Error} If XMLHttpRequest is not supported
|
|
348
|
+
* @expose
|
|
349
|
+
*/
|
|
350
|
+
Util.XHR = function() {
|
|
351
|
+
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
352
|
+
var XMLHttpFactories = [
|
|
353
|
+
function () {return new XMLHttpRequest()},
|
|
354
|
+
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
355
|
+
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
356
|
+
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
357
|
+
];
|
|
358
|
+
/** @type {?XMLHttpRequest} */
|
|
359
|
+
var xhr = null;
|
|
360
|
+
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
361
|
+
try { xhr = XMLHttpFactories[i](); }
|
|
362
|
+
catch (e) { continue; }
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
if (!xhr)
|
|
366
|
+
throw Error("XMLHttpRequest is not supported");
|
|
367
|
+
return xhr;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Fetches a resource.
|
|
372
|
+
* @param {string} path Resource path
|
|
373
|
+
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
374
|
+
* be fetched synchronously. If the request failed, contents will be null.
|
|
375
|
+
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
376
|
+
* @expose
|
|
377
|
+
*/
|
|
378
|
+
Util.fetch = function(path, callback) {
|
|
379
|
+
if (callback && typeof callback != 'function')
|
|
380
|
+
callback = null;
|
|
381
|
+
if (Util.IS_NODE) {
|
|
382
|
+
var fs = require("fs");
|
|
383
|
+
if (callback) {
|
|
384
|
+
fs.readFile(path, function(err, data) {
|
|
385
|
+
if (err)
|
|
386
|
+
callback(null);
|
|
387
|
+
else
|
|
388
|
+
callback(""+data);
|
|
389
|
+
});
|
|
390
|
+
} else
|
|
391
|
+
try {
|
|
392
|
+
return fs.readFileSync(path);
|
|
393
|
+
} catch (e) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
var xhr = Util.XHR();
|
|
398
|
+
xhr.open('GET', path, callback ? true : false);
|
|
399
|
+
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
400
|
+
xhr.setRequestHeader('Accept', 'text/plain');
|
|
401
|
+
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
402
|
+
if (callback) {
|
|
403
|
+
xhr.onreadystatechange = function() {
|
|
404
|
+
if (xhr.readyState != 4) return;
|
|
405
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
406
|
+
callback(xhr.responseText);
|
|
407
|
+
else
|
|
408
|
+
callback(null);
|
|
409
|
+
};
|
|
410
|
+
if (xhr.readyState == 4)
|
|
411
|
+
return;
|
|
412
|
+
xhr.send(null);
|
|
413
|
+
} else {
|
|
414
|
+
xhr.send(null);
|
|
415
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
416
|
+
return xhr.responseText;
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Converts a string to camel case.
|
|
424
|
+
* @param {string} str
|
|
425
|
+
* @returns {string}
|
|
426
|
+
* @expose
|
|
427
|
+
*/
|
|
428
|
+
Util.toCamelCase = function(str) {
|
|
429
|
+
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
430
|
+
return $1.toUpperCase();
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
return Util;
|
|
435
|
+
})();
|
|
435
436
|
|
|
436
437
|
/**
|
|
437
438
|
* Language expressions.
|
|
@@ -1130,7 +1131,11 @@
|
|
|
1130
1131
|
else if (token === "service")
|
|
1131
1132
|
this._parseService(msg);
|
|
1132
1133
|
else if (token === "extensions")
|
|
1133
|
-
msg
|
|
1134
|
+
if (msg.hasOwnProperty("extensions")) {
|
|
1135
|
+
msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
|
|
1136
|
+
} else {
|
|
1137
|
+
msg["extensions"] = this._parseExtensionRanges();
|
|
1138
|
+
}
|
|
1134
1139
|
else if (token === "reserved")
|
|
1135
1140
|
this._parseIgnored(); // TODO
|
|
1136
1141
|
else if (token === "extend")
|
|
@@ -1736,9 +1741,11 @@
|
|
|
1736
1741
|
* converted to string form if so.
|
|
1737
1742
|
* @param {string} syntax Syntax level of defining message type, e.g.,
|
|
1738
1743
|
* proto2 or proto3.
|
|
1744
|
+
* @param {string} name Name of the field containing this element (for error
|
|
1745
|
+
* messages)
|
|
1739
1746
|
* @constructor
|
|
1740
1747
|
*/
|
|
1741
|
-
var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
1748
|
+
var Element = function(type, resolvedType, isMapKey, syntax, name) {
|
|
1742
1749
|
|
|
1743
1750
|
/**
|
|
1744
1751
|
* Element type, as a string (e.g., int32).
|
|
@@ -1764,6 +1771,12 @@
|
|
|
1764
1771
|
*/
|
|
1765
1772
|
this.syntax = syntax;
|
|
1766
1773
|
|
|
1774
|
+
/**
|
|
1775
|
+
* Name of the field containing this element (for error messages)
|
|
1776
|
+
* @type {string}
|
|
1777
|
+
*/
|
|
1778
|
+
this.name = name;
|
|
1779
|
+
|
|
1767
1780
|
if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0)
|
|
1768
1781
|
throw Error("Invalid map key type: " + type.name);
|
|
1769
1782
|
};
|
|
@@ -1814,6 +1827,10 @@
|
|
|
1814
1827
|
throw Error("not convertible to Long");
|
|
1815
1828
|
}
|
|
1816
1829
|
|
|
1830
|
+
ElementPrototype.toString = function() {
|
|
1831
|
+
return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1817
1834
|
/**
|
|
1818
1835
|
* Checks if the given value can be set for an element of this type (singular
|
|
1819
1836
|
* field or one element of a repeated field or map).
|
|
@@ -2488,9 +2505,11 @@
|
|
|
2488
2505
|
MessagePrototype.set = function(keyOrObj, value, noAssert) {
|
|
2489
2506
|
if (keyOrObj && typeof keyOrObj === 'object') {
|
|
2490
2507
|
noAssert = value;
|
|
2491
|
-
for (var ikey in keyOrObj)
|
|
2492
|
-
if
|
|
2508
|
+
for (var ikey in keyOrObj) {
|
|
2509
|
+
// Check if virtual oneof field - don't set these
|
|
2510
|
+
if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
|
|
2493
2511
|
this.$set(ikey, value, noAssert);
|
|
2512
|
+
}
|
|
2494
2513
|
return this;
|
|
2495
2514
|
}
|
|
2496
2515
|
var field = T._fieldsByName[keyOrObj];
|
|
@@ -2954,10 +2973,11 @@
|
|
|
2954
2973
|
length = -1;
|
|
2955
2974
|
if (typeof buffer === 'string')
|
|
2956
2975
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2957
|
-
|
|
2976
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2977
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2958
2978
|
var le = buffer.littleEndian;
|
|
2959
2979
|
try {
|
|
2960
|
-
var msg = T.decode(buffer.LE());
|
|
2980
|
+
var msg = T.decode(buffer.LE(), length);
|
|
2961
2981
|
buffer.LE(le);
|
|
2962
2982
|
return msg;
|
|
2963
2983
|
} catch (e) {
|
|
@@ -2980,7 +3000,8 @@
|
|
|
2980
3000
|
Message.decodeDelimited = function(buffer, enc) {
|
|
2981
3001
|
if (typeof buffer === 'string')
|
|
2982
3002
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2983
|
-
|
|
3003
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
3004
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2984
3005
|
if (buffer.remaining() < 1)
|
|
2985
3006
|
return null;
|
|
2986
3007
|
var off = buffer.offset,
|
|
@@ -3102,6 +3123,7 @@
|
|
|
3102
3123
|
this._fields = [];
|
|
3103
3124
|
this._fieldsById = {};
|
|
3104
3125
|
this._fieldsByName = {};
|
|
3126
|
+
this._oneofsByName = {};
|
|
3105
3127
|
for (var i=0, k=this.children.length, child; i<k; i++) {
|
|
3106
3128
|
child = this.children[i];
|
|
3107
3129
|
if (child instanceof Enum || child instanceof Message || child instanceof Service) {
|
|
@@ -3113,6 +3135,9 @@
|
|
|
3113
3135
|
this._fields.push(child),
|
|
3114
3136
|
this._fieldsById[child.id] = child,
|
|
3115
3137
|
this._fieldsByName[child.name] = child;
|
|
3138
|
+
else if (child instanceof Message.OneOf) {
|
|
3139
|
+
this._oneofsByName[child.name] = child;
|
|
3140
|
+
}
|
|
3116
3141
|
else if (!(child instanceof Message.OneOf) && !(child instanceof Extension)) // Not built
|
|
3117
3142
|
throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
|
|
3118
3143
|
}
|
|
@@ -3219,7 +3244,8 @@
|
|
|
3219
3244
|
* @expose
|
|
3220
3245
|
*/
|
|
3221
3246
|
MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
|
|
3222
|
-
|
|
3247
|
+
if (typeof length !== 'number')
|
|
3248
|
+
length = -1;
|
|
3223
3249
|
var start = buffer.offset,
|
|
3224
3250
|
msg = new (this.clazz)(),
|
|
3225
3251
|
tag, wireType, id, field;
|
|
@@ -3438,9 +3464,9 @@
|
|
|
3438
3464
|
* @expose
|
|
3439
3465
|
*/
|
|
3440
3466
|
FieldPrototype.build = function() {
|
|
3441
|
-
this.element = new Element(this.type, this.resolvedType, false, this.syntax);
|
|
3467
|
+
this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name);
|
|
3442
3468
|
if (this.map)
|
|
3443
|
-
this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
|
|
3469
|
+
this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
|
|
3444
3470
|
|
|
3445
3471
|
// In proto3, fields do not have field presence, and every field is set to
|
|
3446
3472
|
// its type's default value ("", 0, 0.0, or false).
|
|
@@ -4659,7 +4685,11 @@
|
|
|
4659
4685
|
root = require("path")['resolve'](root);
|
|
4660
4686
|
if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
|
|
4661
4687
|
delim = '\\';
|
|
4662
|
-
var fname
|
|
4688
|
+
var fname;
|
|
4689
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4690
|
+
fname = require("path")['join'](root, filename.file);
|
|
4691
|
+
else
|
|
4692
|
+
fname = root + delim + filename.file;
|
|
4663
4693
|
if (this.files[fname] === true)
|
|
4664
4694
|
return this.reset();
|
|
4665
4695
|
this.files[fname] = true;
|
|
@@ -4705,7 +4735,10 @@
|
|
|
4705
4735
|
var importFilename = json['imports'][i];
|
|
4706
4736
|
if (importFilename === "google/protobuf/descriptor.proto")
|
|
4707
4737
|
continue; // Not needed and therefore not used
|
|
4708
|
-
|
|
4738
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4739
|
+
importFilename = require("path")['join'](importRoot, importFilename);
|
|
4740
|
+
else
|
|
4741
|
+
importFilename = importRoot + delim + importFilename;
|
|
4709
4742
|
if (this.files[importFilename] === true)
|
|
4710
4743
|
continue; // Already imported
|
|
4711
4744
|
if (/\.proto$/i.test(importFilename) && !ProtoBuf.DotProto) // If this is a light build
|
|
@@ -4803,6 +4836,16 @@
|
|
|
4803
4836
|
this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
|
|
4804
4837
|
}
|
|
4805
4838
|
|
|
4839
|
+
// If it's a repeated and packable field then proto3 mandates it should be packed by
|
|
4840
|
+
// default
|
|
4841
|
+
if (
|
|
4842
|
+
this.ptr.syntax === 'proto3' &&
|
|
4843
|
+
this.ptr.repeated && this.ptr.options.packed === undefined &&
|
|
4844
|
+
ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
|
|
4845
|
+
) {
|
|
4846
|
+
this.ptr.options.packed = true;
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4806
4849
|
} else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
|
|
4807
4850
|
|
|
4808
4851
|
if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
|
|
@@ -5258,13 +5301,13 @@
|
|
|
5258
5301
|
</div>
|
|
5259
5302
|
|
|
5260
5303
|
<nav>
|
|
5261
|
-
<h2><a href="index.html">
|
|
5304
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ProtoBuf.Builder.html">Builder</a></li><li><a href="ProtoBuf.Builder.Message.html">Message</a></li><li><a href="ProtoBuf.Builder.Service.html">Service</a></li><li><a href="ProtoBuf.DotProto.Parser.html">Parser</a></li><li><a href="ProtoBuf.DotProto.Tokenizer.html">Tokenizer</a></li><li><a href="ProtoBuf.Map.html">Map</a></li><li><a href="ProtoBuf.Reflect.Element.html">Element</a></li><li><a href="ProtoBuf.Reflect.Enum.html">Enum</a></li><li><a href="ProtoBuf.Reflect.Enum.Value.html">Value</a></li><li><a href="ProtoBuf.Reflect.Extension.html">Extension</a></li><li><a href="ProtoBuf.Reflect.Message.html">Message</a></li><li><a href="ProtoBuf.Reflect.Message.ExtensionField.html">ExtensionField</a></li><li><a href="ProtoBuf.Reflect.Message.Field.html">Field</a></li><li><a href="ProtoBuf.Reflect.Message.OneOf.html">OneOf</a></li><li><a href="ProtoBuf.Reflect.Namespace.html">Namespace</a></li><li><a href="ProtoBuf.Reflect.Service.html">Service</a></li><li><a href="ProtoBuf.Reflect.Service.Method.html">Method</a></li><li><a href="ProtoBuf.Reflect.Service.RPCMethod.html">RPCMethod</a></li><li><a href="ProtoBuf.Reflect.T.html">T</a></li></ul><h3>Namespaces</h3><ul><li><a href="ProtoBuf.html">ProtoBuf</a></li><li><a href="ProtoBuf.DotProto.html">DotProto</a></li><li><a href="ProtoBuf.Reflect.html">Reflect</a></li><li><a href="ProtoBuf.Util.html">Util</a></li></ul>
|
|
5262
5305
|
</nav>
|
|
5263
5306
|
|
|
5264
|
-
<br
|
|
5307
|
+
<br class="clear">
|
|
5265
5308
|
|
|
5266
5309
|
<footer>
|
|
5267
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.
|
|
5310
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Fri Jan 27 2017 17:03:55 GMT+0100 (Mitteleuropäische Zeit)
|
|
5268
5311
|
</footer>
|
|
5269
5312
|
|
|
5270
5313
|
<script> prettyPrint(); </script>
|
|
Binary file
|