Add dependencies locally
This commit is contained in:
32
deps/protobuf/js/commonjs/export.js
vendored
Normal file
32
deps/protobuf/js/commonjs/export.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @fileoverview Export symbols needed by generated code in CommonJS style.
|
||||
*
|
||||
* This effectively is our canonical list of what we publicly export from
|
||||
* the google-protobuf.js file that we build at distribution time.
|
||||
*/
|
||||
|
||||
goog.provide('jspb.Export');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('jspb.BinaryReader');
|
||||
goog.require('jspb.BinaryWriter');
|
||||
goog.require('jspb.ExtensionFieldBinaryInfo');
|
||||
goog.require('jspb.ExtensionFieldInfo');
|
||||
goog.require('jspb.Message');
|
||||
goog.require('jspb.Map');
|
||||
|
||||
if (typeof exports === 'object') {
|
||||
exports.Map = jspb.Map;
|
||||
exports.Message = jspb.Message;
|
||||
exports.BinaryReader = jspb.BinaryReader;
|
||||
exports.BinaryWriter = jspb.BinaryWriter;
|
||||
exports.ExtensionFieldInfo = jspb.ExtensionFieldInfo;
|
||||
exports.ExtensionFieldBinaryInfo = jspb.ExtensionFieldBinaryInfo;
|
||||
|
||||
// These are used by generated code but should not be used directly by
|
||||
// clients.
|
||||
exports.exportSymbol = goog.exportSymbol;
|
||||
exports.inherits = goog.inherits;
|
||||
exports.object = {extend: goog.object.extend};
|
||||
exports.typeOf = goog.typeOf;
|
||||
}
|
39
deps/protobuf/js/commonjs/export_asserts.js
vendored
Normal file
39
deps/protobuf/js/commonjs/export_asserts.js
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @fileoverview Exports symbols needed only by tests.
|
||||
*
|
||||
* This file exports several Closure Library symbols that are only
|
||||
* used by tests. It is used to generate a file
|
||||
* closure_asserts_commonjs.js that is only used at testing time.
|
||||
*/
|
||||
|
||||
goog.provide('jspb.ExportAsserts');
|
||||
|
||||
goog.require('goog.testing.asserts');
|
||||
|
||||
var global = Function('return this')();
|
||||
|
||||
// All of the closure "assert" functions are exported at the global level.
|
||||
//
|
||||
// The Google Closure assert functions start with assert, eg.
|
||||
// assertThrows
|
||||
// assertNotThrows
|
||||
// assertTrue
|
||||
// ...
|
||||
//
|
||||
// The one exception is the "fail" function.
|
||||
function shouldExport(str) {
|
||||
return str.lastIndexOf('assert') === 0 || str == 'fail';
|
||||
}
|
||||
|
||||
for (var key in global) {
|
||||
if ((typeof key == "string") && global.hasOwnProperty(key) &&
|
||||
shouldExport(key)) {
|
||||
exports[key] = global[key];
|
||||
}
|
||||
}
|
||||
|
||||
// The COMPILED variable is set by Closure compiler to "true" when it compiles
|
||||
// JavaScript, so in practice this is equivalent to "exports.COMPILED = true".
|
||||
// This will disable some debugging functionality in debug.js. We could
|
||||
// investigate whether this can/should be enabled in CommonJS builds.
|
||||
exports.COMPILED = COMPILED
|
22
deps/protobuf/js/commonjs/export_testdeps.js
vendored
Normal file
22
deps/protobuf/js/commonjs/export_testdeps.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @fileoverview Export symbols needed by tests in CommonJS style.
|
||||
*
|
||||
* This file is like export.js, but for symbols that are only used by tests.
|
||||
* However we exclude assert functions here, because they are exported into
|
||||
* the global namespace, so those are handled as a special case in
|
||||
* export_asserts.js.
|
||||
*/
|
||||
|
||||
goog.provide('jspb.ExportTestDeps');
|
||||
|
||||
goog.require('goog.crypt.base64');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('jspb.arith.Int64');
|
||||
goog.require('jspb.arith.UInt64');
|
||||
goog.require('jspb.BinaryEncoder');
|
||||
goog.require('jspb.BinaryDecoder');
|
||||
goog.require('jspb.BinaryWriter');
|
||||
goog.require('jspb.utils');
|
||||
|
||||
exports.goog = goog;
|
||||
exports.jspb = jspb;
|
52
deps/protobuf/js/commonjs/import_test.js
vendored
Normal file
52
deps/protobuf/js/commonjs/import_test.js
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Test suite is written using Jasmine -- see http://jasmine.github.io/
|
||||
|
||||
|
||||
|
||||
var googleProtobuf = require('google-protobuf');
|
||||
var asserts = require('closure_asserts_commonjs');
|
||||
var global = Function('return this')();
|
||||
|
||||
// Bring asserts into the global namespace.
|
||||
googleProtobuf.object.extend(global, asserts);
|
||||
googleProtobuf.exportSymbol('jspb.Message', googleProtobuf.Message, global);
|
||||
|
||||
var test7_pb = require('./test7/test7_pb');
|
||||
googleProtobuf.exportSymbol('proto.jspb.test.framing.FramingMessage', test7_pb.FramingMessage, global);
|
||||
|
||||
describe('Import test suite', function() {
|
||||
it('testImportedMessage', function() {
|
||||
var framing1 = new proto.jspb.test.framing.FramingMessage([]);
|
||||
var framing2 = new proto.jspb.test.framing.FramingMessage([]);
|
||||
assertObjectEquals(framing1.toObject(), framing2.toObject());
|
||||
});
|
||||
});
|
9
deps/protobuf/js/commonjs/jasmine.json
vendored
Normal file
9
deps/protobuf/js/commonjs/jasmine.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"spec_dir": "",
|
||||
"spec_files": [
|
||||
"*_test.js",
|
||||
"binary/proto_test.js"
|
||||
],
|
||||
"helpers": [
|
||||
]
|
||||
}
|
99
deps/protobuf/js/commonjs/rewrite_tests_for_commonjs.js
vendored
Normal file
99
deps/protobuf/js/commonjs/rewrite_tests_for_commonjs.js
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* @fileoverview Utility to translate test files to CommonJS imports.
|
||||
*
|
||||
* This is a somewhat hacky tool designed to do one very specific thing.
|
||||
* All of the test files in *_test.js are written with Closure-style
|
||||
* imports (goog.require()). This works great for running the tests
|
||||
* against Closure-style generated code, but we also want to run the
|
||||
* tests against CommonJS-style generated code without having to fork
|
||||
* the tests.
|
||||
*
|
||||
* Closure-style imports import each individual type by name. This is
|
||||
* very different than CommonJS imports which are by file. So we put
|
||||
* special comments in these tests like:
|
||||
*
|
||||
* // CommonJS-LoadFromFile: test_pb
|
||||
* goog.require('proto.jspb.test.CloneExtension');
|
||||
* goog.require('proto.jspb.test.Complex');
|
||||
* goog.require('proto.jspb.test.DefaultValues');
|
||||
*
|
||||
* This script parses that special comment and uses it to generate proper
|
||||
* CommonJS require() statements so that the tests can run and pass using
|
||||
* CommonJS imports. The script will change the above statements into:
|
||||
*
|
||||
* var test_pb = require('test_pb');
|
||||
* googleProtobuf.exportSymbol('proto.jspb.test.CloneExtension', test_pb.CloneExtension, global);
|
||||
* googleProtobuf.exportSymbol('proto.jspb.test.Complex', test_pb.Complex, global);
|
||||
* googleProtobuf.exportSymbol('proto.jspb.test.DefaultValues', test_pb.DefaultValues, global);
|
||||
*
|
||||
* (The "exportSymbol" function will define the given names in the global
|
||||
* namespace, taking care not to overwrite any previous value for
|
||||
* "proto.jspb.test").
|
||||
*/
|
||||
|
||||
var lineReader = require('readline').createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
function tryStripPrefix(str, prefix) {
|
||||
if (str.lastIndexOf(prefix) !== 0) {
|
||||
throw "String: " + str + " didn't start with: " + prefix;
|
||||
}
|
||||
return str.substr(prefix.length);
|
||||
}
|
||||
|
||||
function camelCase(str) {
|
||||
var ret = '';
|
||||
var ucaseNext = false;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (str[i] == '-') {
|
||||
ucaseNext = true;
|
||||
} else if (ucaseNext) {
|
||||
ret += str[i].toUpperCase();
|
||||
ucaseNext = false;
|
||||
} else {
|
||||
ret += str[i];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
var module = null;
|
||||
var pkg = null;
|
||||
|
||||
// Header: goes in every file at the top.
|
||||
console.log("var global = Function('return this')();");
|
||||
console.log("var googleProtobuf = require('google-protobuf');");
|
||||
console.log("var testdeps = require('testdeps_commonjs');");
|
||||
console.log("global.goog = testdeps.goog;");
|
||||
console.log("global.jspb = testdeps.jspb;");
|
||||
console.log("var asserts = require('closure_asserts_commonjs');");
|
||||
console.log("");
|
||||
console.log("// Bring asserts into the global namespace.");
|
||||
console.log("googleProtobuf.object.extend(global, asserts);");
|
||||
|
||||
lineReader.on('line', function(line) {
|
||||
var isRequire = line.match(/goog\.require\('([^']*)'\)/);
|
||||
var isLoadFromFile = line.match(/CommonJS-LoadFromFile: (\S*) (.*)/);
|
||||
var isSetTestOnly = line.match(/goog.setTestOnly()/);
|
||||
if (isRequire) {
|
||||
if (module) { // Skip goog.require() lines before the first directive.
|
||||
var fullSym = isRequire[1];
|
||||
// Skip lines importing from jspb.*, these are handled by the header above.
|
||||
if (fullSym.match(/^jspb\./)) return;
|
||||
var sym = tryStripPrefix(fullSym, pkg);
|
||||
console.log("googleProtobuf.exportSymbol('" + fullSym + "', " + module + sym + ', global);');
|
||||
}
|
||||
} else if (isLoadFromFile) {
|
||||
var module_path = isLoadFromFile[1].split('/');
|
||||
module = camelCase(module_path[module_path.length - 1]);
|
||||
pkg = isLoadFromFile[2];
|
||||
|
||||
if (module != "googleProtobuf") { // We unconditionally require this in the header.
|
||||
console.log("var " + module + " = require('./" + isLoadFromFile[1] + "');");
|
||||
}
|
||||
} else if (!isSetTestOnly) { // Remove goog.setTestOnly() lines.
|
||||
console.log(line);
|
||||
}
|
||||
});
|
67
deps/protobuf/js/commonjs/strict_test.js
vendored
Normal file
67
deps/protobuf/js/commonjs/strict_test.js
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Test suite is written using Jasmine -- see http://jasmine.github.io/
|
||||
|
||||
|
||||
|
||||
var googleProtobuf = require('google-protobuf');
|
||||
var asserts = require('closure_asserts_commonjs');
|
||||
var global = Function('return this')();
|
||||
|
||||
// Bring asserts into the global namespace.
|
||||
googleProtobuf.object.extend(global, asserts);
|
||||
|
||||
var test9_pb = require('./test9_pb');
|
||||
var test10_pb = require('./test10_pb');
|
||||
|
||||
describe('Strict test suite', function() {
|
||||
it('testImportedMessage', function() {
|
||||
var simple1 = new test9_pb.jspb.exttest.strict.nine.Simple9()
|
||||
var simple2 = new test9_pb.jspb.exttest.strict.nine.Simple9()
|
||||
assertObjectEquals(simple1.toObject(), simple2.toObject());
|
||||
});
|
||||
|
||||
it('testGlobalScopePollution', function() {
|
||||
assertObjectEquals(global.jspb.exttest, undefined);
|
||||
});
|
||||
|
||||
describe('with imports', function() {
|
||||
it('testImportedMessage', function() {
|
||||
var simple1 = new test10_pb.jspb.exttest.strict.ten.Simple10()
|
||||
var simple2 = new test10_pb.jspb.exttest.strict.ten.Simple10()
|
||||
assertObjectEquals(simple1.toObject(), simple2.toObject());
|
||||
});
|
||||
|
||||
it('testGlobalScopePollution', function() {
|
||||
assertObjectEquals(global.jspb.exttest, undefined);
|
||||
});
|
||||
});
|
||||
});
|
40
deps/protobuf/js/commonjs/test6/test6.proto
vendored
Normal file
40
deps/protobuf/js/commonjs/test6/test6.proto
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "com.google.apps.jspb.proto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
package jspb.test.importing;
|
||||
|
||||
message ImportedMessage {
|
||||
string string_value = 1;
|
||||
}
|
42
deps/protobuf/js/commonjs/test7/test7.proto
vendored
Normal file
42
deps/protobuf/js/commonjs/test7/test7.proto
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "com.google.apps.jspb.proto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
package jspb.test.framing;
|
||||
|
||||
import "test6/test6.proto";
|
||||
|
||||
message FramingMessage {
|
||||
jspb.test.importing.ImportedMessage imported_message = 1;
|
||||
}
|
Reference in New Issue
Block a user