protobufjs 4.1.2 → 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 +3 -1
- package/README.md +147 -25
- package/bin/pbjs +2 -2
- package/bower.json +3 -3
- package/cli/pbjs/targets/amd.js +1 -1
- package/cli/pbjs/targets/json.js +9 -1
- package/cli/pbjs/targets/proto.js +48 -24
- package/cli/pbjs/util.js +1 -1
- package/cli/pbjs.js +9 -2
- package/dist/README.md +10 -10
- package/dist/{ProtoBuf-light.js → protobuf-light.js} +207 -152
- package/dist/protobuf-light.min.js +94 -0
- package/dist/protobuf-light.min.js.gz +0 -0
- package/dist/protobuf-light.min.map +8 -0
- package/dist/{ProtoBuf.js → protobuf.js} +265 -175
- package/dist/protobuf.min.js +116 -0
- package/dist/protobuf.min.js.gz +0 -0
- package/dist/protobuf.min.map +8 -0
- package/docs/ProtoBuf.Builder.Message.html +1473 -967
- 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 +919 -652
- 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 +271 -180
- 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/donate.png +0 -0
- 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 → protobuf.js} +933 -922
- package/index.js +1 -18
- package/jsdoc.json +1 -1
- package/package.json +11 -11
- package/protobuf.png +0 -0
- package/scripts/build.js +53 -58
- package/src/ProtoBuf/Builder/Message.js +18 -9
- package/src/ProtoBuf/Builder/Service.js +3 -0
- package/src/ProtoBuf/Builder.js +34 -10
- package/src/ProtoBuf/DotProto/Parser.js +58 -23
- package/src/ProtoBuf/Reflect/Element.js +17 -4
- package/src/ProtoBuf/Reflect/Message/Field.js +6 -5
- package/src/ProtoBuf/Reflect/Message.js +9 -4
- package/src/ProtoBuf/Util.js +116 -116
- package/src/bower.json +2 -2
- package/src/google/protobuf/descriptor.json +55 -15
- package/src/{ProtoBuf.js → protobuf.js} +0 -0
- package/src/wrap.js +4 -4
- 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-weak.proto +7 -0
- 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 +107 -82
- package/ProtoBuf.png +0 -0
- package/dist/ProtoBuf-light.min.js +0 -87
- package/dist/ProtoBuf-light.min.js.gz +0 -0
- package/dist/ProtoBuf-light.min.map +0 -8
- package/dist/ProtoBuf.min.js +0 -108
- package/dist/ProtoBuf.min.js.gz +0 -0
- package/dist/ProtoBuf.min.map +0 -8
- package/externs/ByteBuffer.js +0 -767
- package/externs/Long.js +0 -328
- 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/issue42/innerextend.proto +0 -18
- package/sandbox/issue42/main.js +0 -8
- package/sandbox/issue42/outerextend.proto +0 -17
- package/tests/gtfs-realtime.proto +0 -552
- package/webpack.config.js +0 -9
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @license
|
|
18
|
+
* @license protobuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
19
19
|
* Released under the Apache License, Version 2.0
|
|
20
|
-
* see: https://github.com/dcodeIO/
|
|
20
|
+
* see: https://github.com/dcodeIO/protobuf.js for details
|
|
21
21
|
*/
|
|
22
22
|
(function(global, factory) {
|
|
23
23
|
|
|
24
24
|
/* AMD */ if (typeof define === 'function' && define["amd"])
|
|
25
|
-
define(["
|
|
25
|
+
define(["bytebuffer"], factory);
|
|
26
26
|
/* CommonJS */ else if (typeof require === "function" && typeof module === "object" && module && module["exports"])
|
|
27
27
|
module["exports"] = factory(require("bytebuffer"), true);
|
|
28
28
|
/* Global */ else
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @const
|
|
58
58
|
* @expose
|
|
59
59
|
*/
|
|
60
|
-
ProtoBuf.VERSION = "
|
|
60
|
+
ProtoBuf.VERSION = "5.0.2";
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Wire types.
|
|
@@ -289,122 +289,122 @@
|
|
|
289
289
|
*/
|
|
290
290
|
ProtoBuf.populateDefaults = true;
|
|
291
291
|
|
|
292
|
-
/**
|
|
293
|
-
* @alias ProtoBuf.Util
|
|
294
|
-
* @expose
|
|
295
|
-
*/
|
|
296
|
-
ProtoBuf.Util = (function() {
|
|
297
|
-
"use strict";
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* ProtoBuf utilities.
|
|
301
|
-
* @exports ProtoBuf.Util
|
|
302
|
-
* @namespace
|
|
303
|
-
*/
|
|
304
|
-
var Util = {};
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Flag if running in node or not.
|
|
308
|
-
* @type {boolean}
|
|
309
|
-
* @const
|
|
310
|
-
* @expose
|
|
311
|
-
*/
|
|
312
|
-
Util.IS_NODE = !!(
|
|
313
|
-
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Constructs a XMLHttpRequest object.
|
|
318
|
-
* @return {XMLHttpRequest}
|
|
319
|
-
* @throws {Error} If XMLHttpRequest is not supported
|
|
320
|
-
* @expose
|
|
321
|
-
*/
|
|
322
|
-
Util.XHR = function() {
|
|
323
|
-
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
324
|
-
var XMLHttpFactories = [
|
|
325
|
-
function () {return new XMLHttpRequest()},
|
|
326
|
-
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
327
|
-
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
328
|
-
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
329
|
-
];
|
|
330
|
-
/** @type {?XMLHttpRequest} */
|
|
331
|
-
var xhr = null;
|
|
332
|
-
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
333
|
-
try { xhr = XMLHttpFactories[i](); }
|
|
334
|
-
catch (e) { continue; }
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
if (!xhr)
|
|
338
|
-
throw Error("XMLHttpRequest is not supported");
|
|
339
|
-
return xhr;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Fetches a resource.
|
|
344
|
-
* @param {string} path Resource path
|
|
345
|
-
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
346
|
-
* be fetched synchronously. If the request failed, contents will be null.
|
|
347
|
-
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
348
|
-
* @expose
|
|
349
|
-
*/
|
|
350
|
-
Util.fetch = function(path, callback) {
|
|
351
|
-
if (callback && typeof callback != 'function')
|
|
352
|
-
callback = null;
|
|
353
|
-
if (Util.IS_NODE) {
|
|
354
|
-
var fs = require("fs");
|
|
355
|
-
if (callback) {
|
|
356
|
-
fs.readFile(path, function(err, data) {
|
|
357
|
-
if (err)
|
|
358
|
-
callback(null);
|
|
359
|
-
else
|
|
360
|
-
callback(""+data);
|
|
361
|
-
});
|
|
362
|
-
} else
|
|
363
|
-
try {
|
|
364
|
-
return fs.readFileSync(path);
|
|
365
|
-
} catch (e) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
var xhr = Util.XHR();
|
|
370
|
-
xhr.open('GET', path, callback ? true : false);
|
|
371
|
-
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
372
|
-
xhr.setRequestHeader('Accept', 'text/plain');
|
|
373
|
-
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
374
|
-
if (callback) {
|
|
375
|
-
xhr.onreadystatechange = function() {
|
|
376
|
-
if (xhr.readyState != 4) return;
|
|
377
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
378
|
-
callback(xhr.responseText);
|
|
379
|
-
else
|
|
380
|
-
callback(null);
|
|
381
|
-
};
|
|
382
|
-
if (xhr.readyState == 4)
|
|
383
|
-
return;
|
|
384
|
-
xhr.send(null);
|
|
385
|
-
} else {
|
|
386
|
-
xhr.send(null);
|
|
387
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
388
|
-
return xhr.responseText;
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Converts a string to camel case.
|
|
396
|
-
* @param {string} str
|
|
397
|
-
* @returns {string}
|
|
398
|
-
* @expose
|
|
399
|
-
*/
|
|
400
|
-
Util.toCamelCase = function(str) {
|
|
401
|
-
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
402
|
-
return $1.toUpperCase();
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
return Util;
|
|
407
|
-
})();
|
|
292
|
+
/**
|
|
293
|
+
* @alias ProtoBuf.Util
|
|
294
|
+
* @expose
|
|
295
|
+
*/
|
|
296
|
+
ProtoBuf.Util = (function() {
|
|
297
|
+
"use strict";
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* ProtoBuf utilities.
|
|
301
|
+
* @exports ProtoBuf.Util
|
|
302
|
+
* @namespace
|
|
303
|
+
*/
|
|
304
|
+
var Util = {};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Flag if running in node or not.
|
|
308
|
+
* @type {boolean}
|
|
309
|
+
* @const
|
|
310
|
+
* @expose
|
|
311
|
+
*/
|
|
312
|
+
Util.IS_NODE = !!(
|
|
313
|
+
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Constructs a XMLHttpRequest object.
|
|
318
|
+
* @return {XMLHttpRequest}
|
|
319
|
+
* @throws {Error} If XMLHttpRequest is not supported
|
|
320
|
+
* @expose
|
|
321
|
+
*/
|
|
322
|
+
Util.XHR = function() {
|
|
323
|
+
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
324
|
+
var XMLHttpFactories = [
|
|
325
|
+
function () {return new XMLHttpRequest()},
|
|
326
|
+
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
327
|
+
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
328
|
+
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
329
|
+
];
|
|
330
|
+
/** @type {?XMLHttpRequest} */
|
|
331
|
+
var xhr = null;
|
|
332
|
+
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
333
|
+
try { xhr = XMLHttpFactories[i](); }
|
|
334
|
+
catch (e) { continue; }
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
if (!xhr)
|
|
338
|
+
throw Error("XMLHttpRequest is not supported");
|
|
339
|
+
return xhr;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Fetches a resource.
|
|
344
|
+
* @param {string} path Resource path
|
|
345
|
+
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
346
|
+
* be fetched synchronously. If the request failed, contents will be null.
|
|
347
|
+
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
348
|
+
* @expose
|
|
349
|
+
*/
|
|
350
|
+
Util.fetch = function(path, callback) {
|
|
351
|
+
if (callback && typeof callback != 'function')
|
|
352
|
+
callback = null;
|
|
353
|
+
if (Util.IS_NODE) {
|
|
354
|
+
var fs = require("fs");
|
|
355
|
+
if (callback) {
|
|
356
|
+
fs.readFile(path, function(err, data) {
|
|
357
|
+
if (err)
|
|
358
|
+
callback(null);
|
|
359
|
+
else
|
|
360
|
+
callback(""+data);
|
|
361
|
+
});
|
|
362
|
+
} else
|
|
363
|
+
try {
|
|
364
|
+
return fs.readFileSync(path);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
var xhr = Util.XHR();
|
|
370
|
+
xhr.open('GET', path, callback ? true : false);
|
|
371
|
+
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
372
|
+
xhr.setRequestHeader('Accept', 'text/plain');
|
|
373
|
+
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
374
|
+
if (callback) {
|
|
375
|
+
xhr.onreadystatechange = function() {
|
|
376
|
+
if (xhr.readyState != 4) return;
|
|
377
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
378
|
+
callback(xhr.responseText);
|
|
379
|
+
else
|
|
380
|
+
callback(null);
|
|
381
|
+
};
|
|
382
|
+
if (xhr.readyState == 4)
|
|
383
|
+
return;
|
|
384
|
+
xhr.send(null);
|
|
385
|
+
} else {
|
|
386
|
+
xhr.send(null);
|
|
387
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
388
|
+
return xhr.responseText;
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Converts a string to camel case.
|
|
396
|
+
* @param {string} str
|
|
397
|
+
* @returns {string}
|
|
398
|
+
* @expose
|
|
399
|
+
*/
|
|
400
|
+
Util.toCamelCase = function(str) {
|
|
401
|
+
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
402
|
+
return $1.toUpperCase();
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
return Util;
|
|
407
|
+
})();
|
|
408
408
|
|
|
409
409
|
/**
|
|
410
410
|
* Language expressions.
|
|
@@ -725,7 +725,8 @@
|
|
|
725
725
|
// "syntax": undefined
|
|
726
726
|
};
|
|
727
727
|
var token,
|
|
728
|
-
head = true
|
|
728
|
+
head = true,
|
|
729
|
+
weak;
|
|
729
730
|
try {
|
|
730
731
|
while (token = this.tn.next()) {
|
|
731
732
|
switch (token) {
|
|
@@ -742,11 +743,12 @@
|
|
|
742
743
|
if (!head)
|
|
743
744
|
throw Error("unexpected 'import'");
|
|
744
745
|
token = this.tn.peek();
|
|
745
|
-
if (token === "public") // ignored
|
|
746
|
+
if (token === "public" || (weak = token === "weak")) // token ignored
|
|
746
747
|
this.tn.next();
|
|
747
748
|
token = this._readString();
|
|
748
749
|
this.tn.skip(";");
|
|
749
|
-
|
|
750
|
+
if (!weak) // import ignored
|
|
751
|
+
topLevel["imports"].push(token);
|
|
750
752
|
break;
|
|
751
753
|
case 'syntax':
|
|
752
754
|
if (!head)
|
|
@@ -1071,6 +1073,7 @@
|
|
|
1071
1073
|
"enums": [],
|
|
1072
1074
|
"messages": [],
|
|
1073
1075
|
"options": {},
|
|
1076
|
+
"services": [],
|
|
1074
1077
|
"oneofs": {}
|
|
1075
1078
|
// "extensions": undefined
|
|
1076
1079
|
};
|
|
@@ -1097,8 +1100,16 @@
|
|
|
1097
1100
|
this._parseMessage(msg);
|
|
1098
1101
|
else if (token === "option")
|
|
1099
1102
|
this._parseOption(msg);
|
|
1103
|
+
else if (token === "service")
|
|
1104
|
+
this._parseService(msg);
|
|
1100
1105
|
else if (token === "extensions")
|
|
1101
|
-
|
|
1106
|
+
if (msg.hasOwnProperty("extensions")) {
|
|
1107
|
+
msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
|
|
1108
|
+
} else {
|
|
1109
|
+
msg["extensions"] = this._parseExtensionRanges();
|
|
1110
|
+
}
|
|
1111
|
+
else if (token === "reserved")
|
|
1112
|
+
this._parseIgnored(); // TODO
|
|
1102
1113
|
else if (token === "extend")
|
|
1103
1114
|
this._parseExtend(msg);
|
|
1104
1115
|
else if (Lang.TYPEREF.test(token)) {
|
|
@@ -1113,6 +1124,16 @@
|
|
|
1113
1124
|
return msg;
|
|
1114
1125
|
};
|
|
1115
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* Parses an ignored statement.
|
|
1129
|
+
* @private
|
|
1130
|
+
*/
|
|
1131
|
+
ParserPrototype._parseIgnored = function() {
|
|
1132
|
+
while (this.tn.peek() !== ';')
|
|
1133
|
+
this.tn.next();
|
|
1134
|
+
this.tn.skip(";");
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1116
1137
|
/**
|
|
1117
1138
|
* Parses a message field.
|
|
1118
1139
|
* @param {!Object} msg Message definition
|
|
@@ -1275,29 +1296,43 @@
|
|
|
1275
1296
|
};
|
|
1276
1297
|
|
|
1277
1298
|
/**
|
|
1278
|
-
* Parses
|
|
1279
|
-
* @
|
|
1299
|
+
* Parses extension / reserved ranges.
|
|
1300
|
+
* @returns {!Array.<!Array.<number>>}
|
|
1280
1301
|
* @private
|
|
1281
1302
|
*/
|
|
1282
|
-
ParserPrototype.
|
|
1283
|
-
var
|
|
1303
|
+
ParserPrototype._parseExtensionRanges = function() {
|
|
1304
|
+
var ranges = [];
|
|
1305
|
+
var token,
|
|
1306
|
+
range,
|
|
1307
|
+
value;
|
|
1308
|
+
do {
|
|
1284
1309
|
range = [];
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1310
|
+
while (true) {
|
|
1311
|
+
token = this.tn.next();
|
|
1312
|
+
switch (token) {
|
|
1313
|
+
case "min":
|
|
1314
|
+
value = ProtoBuf.ID_MIN;
|
|
1315
|
+
break;
|
|
1316
|
+
case "max":
|
|
1317
|
+
value = ProtoBuf.ID_MAX;
|
|
1318
|
+
break;
|
|
1319
|
+
default:
|
|
1320
|
+
value = mkNumber(token);
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
range.push(value);
|
|
1324
|
+
if (range.length === 2)
|
|
1325
|
+
break;
|
|
1326
|
+
if (this.tn.peek() !== "to") {
|
|
1327
|
+
range.push(value);
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
this.tn.next();
|
|
1331
|
+
}
|
|
1332
|
+
ranges.push(range);
|
|
1333
|
+
} while (this.tn.omit(","));
|
|
1299
1334
|
this.tn.skip(";");
|
|
1300
|
-
|
|
1335
|
+
return ranges;
|
|
1301
1336
|
};
|
|
1302
1337
|
|
|
1303
1338
|
/**
|
|
@@ -1678,9 +1713,11 @@
|
|
|
1678
1713
|
* converted to string form if so.
|
|
1679
1714
|
* @param {string} syntax Syntax level of defining message type, e.g.,
|
|
1680
1715
|
* proto2 or proto3.
|
|
1716
|
+
* @param {string} name Name of the field containing this element (for error
|
|
1717
|
+
* messages)
|
|
1681
1718
|
* @constructor
|
|
1682
1719
|
*/
|
|
1683
|
-
var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
1720
|
+
var Element = function(type, resolvedType, isMapKey, syntax, name) {
|
|
1684
1721
|
|
|
1685
1722
|
/**
|
|
1686
1723
|
* Element type, as a string (e.g., int32).
|
|
@@ -1706,6 +1743,12 @@
|
|
|
1706
1743
|
*/
|
|
1707
1744
|
this.syntax = syntax;
|
|
1708
1745
|
|
|
1746
|
+
/**
|
|
1747
|
+
* Name of the field containing this element (for error messages)
|
|
1748
|
+
* @type {string}
|
|
1749
|
+
*/
|
|
1750
|
+
this.name = name;
|
|
1751
|
+
|
|
1709
1752
|
if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0)
|
|
1710
1753
|
throw Error("Invalid map key type: " + type.name);
|
|
1711
1754
|
};
|
|
@@ -1756,6 +1799,10 @@
|
|
|
1756
1799
|
throw Error("not convertible to Long");
|
|
1757
1800
|
}
|
|
1758
1801
|
|
|
1802
|
+
ElementPrototype.toString = function() {
|
|
1803
|
+
return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1759
1806
|
/**
|
|
1760
1807
|
* Checks if the given value can be set for an element of this type (singular
|
|
1761
1808
|
* field or one element of a repeated field or map).
|
|
@@ -1765,9 +1812,10 @@
|
|
|
1765
1812
|
* @expose
|
|
1766
1813
|
*/
|
|
1767
1814
|
ElementPrototype.verifyValue = function(value) {
|
|
1768
|
-
var
|
|
1769
|
-
|
|
1770
|
-
|
|
1815
|
+
var self = this;
|
|
1816
|
+
function fail(val, msg) {
|
|
1817
|
+
throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")");
|
|
1818
|
+
}
|
|
1771
1819
|
switch (this.type) {
|
|
1772
1820
|
// Signed 32bit
|
|
1773
1821
|
case ProtoBuf.TYPES["int32"]:
|
|
@@ -2257,10 +2305,10 @@
|
|
|
2257
2305
|
|
|
2258
2306
|
/**
|
|
2259
2307
|
* Extensions range.
|
|
2260
|
-
* @type {!Array.<number
|
|
2308
|
+
* @type {!Array.<number>|undefined}
|
|
2261
2309
|
* @expose
|
|
2262
2310
|
*/
|
|
2263
|
-
this.extensions =
|
|
2311
|
+
this.extensions = undefined;
|
|
2264
2312
|
|
|
2265
2313
|
/**
|
|
2266
2314
|
* Runtime message class.
|
|
@@ -2429,9 +2477,11 @@
|
|
|
2429
2477
|
MessagePrototype.set = function(keyOrObj, value, noAssert) {
|
|
2430
2478
|
if (keyOrObj && typeof keyOrObj === 'object') {
|
|
2431
2479
|
noAssert = value;
|
|
2432
|
-
for (var ikey in keyOrObj)
|
|
2433
|
-
if
|
|
2480
|
+
for (var ikey in keyOrObj) {
|
|
2481
|
+
// Check if virtual oneof field - don't set these
|
|
2482
|
+
if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
|
|
2434
2483
|
this.$set(ikey, value, noAssert);
|
|
2484
|
+
}
|
|
2435
2485
|
return this;
|
|
2436
2486
|
}
|
|
2437
2487
|
var field = T._fieldsByName[keyOrObj];
|
|
@@ -2659,18 +2709,19 @@
|
|
|
2659
2709
|
* @name ProtoBuf.Builder.Message#encodeDelimited
|
|
2660
2710
|
* @function
|
|
2661
2711
|
* @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted.
|
|
2712
|
+
* @param {boolean=} noVerify Whether to not verify field values, defaults to `false`
|
|
2662
2713
|
* @return {!ByteBuffer} Encoded message as a ByteBuffer
|
|
2663
2714
|
* @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
|
|
2664
2715
|
* returns the encoded ByteBuffer in the `encoded` property on the error.
|
|
2665
2716
|
* @expose
|
|
2666
2717
|
*/
|
|
2667
|
-
MessagePrototype.encodeDelimited = function(buffer) {
|
|
2718
|
+
MessagePrototype.encodeDelimited = function(buffer, noVerify) {
|
|
2668
2719
|
var isNew = false;
|
|
2669
2720
|
if (!buffer)
|
|
2670
2721
|
buffer = new ByteBuffer(),
|
|
2671
2722
|
isNew = true;
|
|
2672
2723
|
var enc = new ByteBuffer().LE();
|
|
2673
|
-
T.encode(this, enc).flip();
|
|
2724
|
+
T.encode(this, enc, noVerify).flip();
|
|
2674
2725
|
buffer.writeVarint32(enc.remaining());
|
|
2675
2726
|
buffer.append(enc);
|
|
2676
2727
|
return isNew ? buffer.flip() : buffer;
|
|
@@ -2817,7 +2868,7 @@
|
|
|
2817
2868
|
return binaryAsBase64 ? obj.toBase64() : obj.toBuffer();
|
|
2818
2869
|
// Convert Longs to proper objects or strings
|
|
2819
2870
|
if (ProtoBuf.Long.isLong(obj))
|
|
2820
|
-
return longsAsStrings ? obj.toString() :
|
|
2871
|
+
return longsAsStrings ? obj.toString() : ProtoBuf.Long.fromValue(obj);
|
|
2821
2872
|
var clone;
|
|
2822
2873
|
// Clone arrays
|
|
2823
2874
|
if (Array.isArray(obj)) {
|
|
@@ -2879,6 +2930,7 @@
|
|
|
2879
2930
|
* @name ProtoBuf.Builder.Message.decode
|
|
2880
2931
|
* @function
|
|
2881
2932
|
* @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from
|
|
2933
|
+
* @param {(number|string)=} length Message length. Defaults to decode all the remainig data.
|
|
2882
2934
|
* @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64
|
|
2883
2935
|
* @return {!ProtoBuf.Builder.Message} Decoded message
|
|
2884
2936
|
* @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
|
|
@@ -2887,13 +2939,17 @@
|
|
|
2887
2939
|
* @see ProtoBuf.Builder.Message.decode64
|
|
2888
2940
|
* @see ProtoBuf.Builder.Message.decodeHex
|
|
2889
2941
|
*/
|
|
2890
|
-
Message.decode = function(buffer, enc) {
|
|
2942
|
+
Message.decode = function(buffer, length, enc) {
|
|
2943
|
+
if (typeof length === 'string')
|
|
2944
|
+
enc = length,
|
|
2945
|
+
length = -1;
|
|
2891
2946
|
if (typeof buffer === 'string')
|
|
2892
2947
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2893
|
-
|
|
2948
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2949
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2894
2950
|
var le = buffer.littleEndian;
|
|
2895
2951
|
try {
|
|
2896
|
-
var msg = T.decode(buffer.LE());
|
|
2952
|
+
var msg = T.decode(buffer.LE(), length);
|
|
2897
2953
|
buffer.LE(le);
|
|
2898
2954
|
return msg;
|
|
2899
2955
|
} catch (e) {
|
|
@@ -2916,7 +2972,8 @@
|
|
|
2916
2972
|
Message.decodeDelimited = function(buffer, enc) {
|
|
2917
2973
|
if (typeof buffer === 'string')
|
|
2918
2974
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2919
|
-
|
|
2975
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2976
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2920
2977
|
if (buffer.remaining() < 1)
|
|
2921
2978
|
return null;
|
|
2922
2979
|
var off = buffer.offset,
|
|
@@ -3038,6 +3095,7 @@
|
|
|
3038
3095
|
this._fields = [];
|
|
3039
3096
|
this._fieldsById = {};
|
|
3040
3097
|
this._fieldsByName = {};
|
|
3098
|
+
this._oneofsByName = {};
|
|
3041
3099
|
for (var i=0, k=this.children.length, child; i<k; i++) {
|
|
3042
3100
|
child = this.children[i];
|
|
3043
3101
|
if (child instanceof Enum || child instanceof Message || child instanceof Service) {
|
|
@@ -3049,6 +3107,9 @@
|
|
|
3049
3107
|
this._fields.push(child),
|
|
3050
3108
|
this._fieldsById[child.id] = child,
|
|
3051
3109
|
this._fieldsByName[child.name] = child;
|
|
3110
|
+
else if (child instanceof Message.OneOf) {
|
|
3111
|
+
this._oneofsByName[child.name] = child;
|
|
3112
|
+
}
|
|
3052
3113
|
else if (!(child instanceof Message.OneOf) && !(child instanceof Extension)) // Not built
|
|
3053
3114
|
throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
|
|
3054
3115
|
}
|
|
@@ -3148,14 +3209,15 @@
|
|
|
3148
3209
|
/**
|
|
3149
3210
|
* Decodes an encoded message and returns the decoded message.
|
|
3150
3211
|
* @param {ByteBuffer} buffer ByteBuffer to decode from
|
|
3151
|
-
* @param {number=} length Message length. Defaults to decode all
|
|
3212
|
+
* @param {number=} length Message length. Defaults to decode all remaining data.
|
|
3152
3213
|
* @param {number=} expectedGroupEndId Expected GROUPEND id if this is a legacy group
|
|
3153
3214
|
* @return {ProtoBuf.Builder.Message} Decoded message
|
|
3154
3215
|
* @throws {Error} If the message cannot be decoded
|
|
3155
3216
|
* @expose
|
|
3156
3217
|
*/
|
|
3157
3218
|
MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
|
|
3158
|
-
|
|
3219
|
+
if (typeof length !== 'number')
|
|
3220
|
+
length = -1;
|
|
3159
3221
|
var start = buffer.offset,
|
|
3160
3222
|
msg = new (this.clazz)(),
|
|
3161
3223
|
tag, wireType, id, field;
|
|
@@ -3374,9 +3436,9 @@
|
|
|
3374
3436
|
* @expose
|
|
3375
3437
|
*/
|
|
3376
3438
|
FieldPrototype.build = function() {
|
|
3377
|
-
this.element = new Element(this.type, this.resolvedType, false, this.syntax);
|
|
3439
|
+
this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name);
|
|
3378
3440
|
if (this.map)
|
|
3379
|
-
this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
|
|
3441
|
+
this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
|
|
3380
3442
|
|
|
3381
3443
|
// In proto3, fields do not have field presence, and every field is set to
|
|
3382
3444
|
// its type's default value ("", 0, 0.0, or false).
|
|
@@ -3398,9 +3460,10 @@
|
|
|
3398
3460
|
*/
|
|
3399
3461
|
FieldPrototype.verifyValue = function(value, skipRepeated) {
|
|
3400
3462
|
skipRepeated = skipRepeated || false;
|
|
3401
|
-
var
|
|
3402
|
-
|
|
3403
|
-
|
|
3463
|
+
var self = this;
|
|
3464
|
+
function fail(val, msg) {
|
|
3465
|
+
throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")");
|
|
3466
|
+
}
|
|
3404
3467
|
if (value === null) { // NULL values for optional fields
|
|
3405
3468
|
if (this.required)
|
|
3406
3469
|
fail(typeof value, "required");
|
|
@@ -4014,6 +4077,9 @@
|
|
|
4014
4077
|
callback(err);
|
|
4015
4078
|
return;
|
|
4016
4079
|
}
|
|
4080
|
+
// Coalesce to empty string when service response has empty content
|
|
4081
|
+
if (res === null)
|
|
4082
|
+
res = ''
|
|
4017
4083
|
try { res = method.resolvedResponseType.clazz.decode(res); } catch (notABuffer) {}
|
|
4018
4084
|
if (!res || !(res instanceof method.resolvedResponseType.clazz)) {
|
|
4019
4085
|
callback(Error("Illegal response type received in service method "+ T.name+"#"+method.name));
|
|
@@ -4457,13 +4523,12 @@
|
|
|
4457
4523
|
subObj.push(svc);
|
|
4458
4524
|
});
|
|
4459
4525
|
|
|
4460
|
-
// Set extension
|
|
4526
|
+
// Set extension ranges
|
|
4461
4527
|
if (def["extensions"]) {
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
obj.extensions[1] = ProtoBuf.ID_MAX;
|
|
4528
|
+
if (typeof def["extensions"][0] === 'number') // pre 5.0.1
|
|
4529
|
+
obj.extensions = [ def["extensions"] ];
|
|
4530
|
+
else
|
|
4531
|
+
obj.extensions = def["extensions"];
|
|
4467
4532
|
}
|
|
4468
4533
|
|
|
4469
4534
|
// Create on top of current namespace
|
|
@@ -4502,8 +4567,16 @@
|
|
|
4502
4567
|
def["fields"].forEach(function(fld) {
|
|
4503
4568
|
if (obj.getChild(fld['id']|0) !== null)
|
|
4504
4569
|
throw Error("duplicate extended field id in "+obj.name+": "+fld['id']);
|
|
4505
|
-
if
|
|
4506
|
-
|
|
4570
|
+
// Check if field id is allowed to be extended
|
|
4571
|
+
if (obj.extensions) {
|
|
4572
|
+
var valid = false;
|
|
4573
|
+
obj.extensions.forEach(function(range) {
|
|
4574
|
+
if (fld["id"] >= range[0] && fld["id"] <= range[1])
|
|
4575
|
+
valid = true;
|
|
4576
|
+
});
|
|
4577
|
+
if (!valid)
|
|
4578
|
+
throw Error("illegal extended field id in "+obj.name+": "+fld['id']+" (not within valid ranges)");
|
|
4579
|
+
}
|
|
4507
4580
|
// Convert extension field names to camel case notation if the override is set
|
|
4508
4581
|
var name = fld["name"];
|
|
4509
4582
|
if (this.options['convertFieldsToCamelCase'])
|
|
@@ -4584,7 +4657,11 @@
|
|
|
4584
4657
|
root = require("path")['resolve'](root);
|
|
4585
4658
|
if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
|
|
4586
4659
|
delim = '\\';
|
|
4587
|
-
var fname
|
|
4660
|
+
var fname;
|
|
4661
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4662
|
+
fname = require("path")['join'](root, filename.file);
|
|
4663
|
+
else
|
|
4664
|
+
fname = root + delim + filename.file;
|
|
4588
4665
|
if (this.files[fname] === true)
|
|
4589
4666
|
return this.reset();
|
|
4590
4667
|
this.files[fname] = true;
|
|
@@ -4630,7 +4707,10 @@
|
|
|
4630
4707
|
var importFilename = json['imports'][i];
|
|
4631
4708
|
if (importFilename === "google/protobuf/descriptor.proto")
|
|
4632
4709
|
continue; // Not needed and therefore not used
|
|
4633
|
-
|
|
4710
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4711
|
+
importFilename = require("path")['join'](importRoot, importFilename);
|
|
4712
|
+
else
|
|
4713
|
+
importFilename = importRoot + delim + importFilename;
|
|
4634
4714
|
if (this.files[importFilename] === true)
|
|
4635
4715
|
continue; // Already imported
|
|
4636
4716
|
if (/\.proto$/i.test(importFilename) && !ProtoBuf.DotProto) // If this is a light build
|
|
@@ -4728,6 +4808,16 @@
|
|
|
4728
4808
|
this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
|
|
4729
4809
|
}
|
|
4730
4810
|
|
|
4811
|
+
// If it's a repeated and packable field then proto3 mandates it should be packed by
|
|
4812
|
+
// default
|
|
4813
|
+
if (
|
|
4814
|
+
this.ptr.syntax === 'proto3' &&
|
|
4815
|
+
this.ptr.repeated && this.ptr.options.packed === undefined &&
|
|
4816
|
+
ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
|
|
4817
|
+
) {
|
|
4818
|
+
this.ptr.options.packed = true;
|
|
4819
|
+
}
|
|
4820
|
+
|
|
4731
4821
|
} else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
|
|
4732
4822
|
|
|
4733
4823
|
if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
|