Permalink
Browse files

Fixed: Properly set up reflection when using light build

  • Loading branch information...
dcodeIO committed Jan 24, 2017
1 parent 1a376ba commit 039ac77b062ee6ebf4ec84a5e6c6ece221e63401
@@ -1,4 +1,4 @@
# [6.6.0](https://github.com/dcodeIO/protobuf.js/releases/tag/6.6.0)
# [6.6.0](https://github.com/dcodeIO/protobuf.js/releases/tag/6.6.0) ([release](https://github.com/dcodeIO/protobuf.js/releases/tag/6.6.0))
## Breaking
[:hash:](https://github.com/dcodeIO/protobuf.js/commit/cdfe6bfba27fa1a1d0e61887597ad4bb16d7e5ed) Inlined / refactored away .testJSON, see [#653](https://github.com/dcodeIO/protobuf.js/issues/653)<br />

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +23 Bytes (100%) dist/light/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
BIN +1 Byte (100%) dist/minimal/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -4 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -2143,15 +2143,6 @@ export namespace util {
emit(evt: string, ...args: any[]): util.EventEmitter;
}
/**
* Lets the specified constructor extend `this` class.
* @memberof util
* @param {*} ctor Extending constructor
* @returns {Object.<string,*>} Constructor prototype
* @this Function
*/
function extend(this: Function, ctor: any): { [k: string]: any };
/**
* Fetches the contents of a file.
* @memberof util
@@ -1,6 +1,6 @@
{
"name": "protobufjs",
"version": "6.6.0",
"version": "6.6.1",
"versionScheme": "~",
"description": "Protocol Buffers for JavaScript (& TypeScript).",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
@@ -31,7 +31,7 @@
"changelog": "node scripts/changelog -w",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js tests/node/*.js",
"coverage-ci": "npm run coverage && cat coverage/lcov.info | coveralls",
"docs": "jsdoc -c jsdoc.docs.json -R README.md -P package.json --verbose --pedantic",
"docs": "jsdoc -c jsdoc.docs.json -R README.md --verbose --pedantic",
"lint": "eslint src",
"pages": "node scripts/pages",
"prepublish": "node scripts/prepublish",
@@ -96,3 +96,8 @@ protobuf.Message = require("./message");
// Utility
protobuf.types = require("./types");
protobuf.util = require("./util");
// Configure reflection
protobuf.ReflectionObject._configure(protobuf.Root);
protobuf.Namespace._configure(protobuf.Type, protobuf.Service);
protobuf.Root._configure(protobuf.Type);
@@ -57,5 +57,6 @@ if (typeof define === "function" && define.amd)
return protobuf;
});
// Configure serialization
protobuf.Writer._configure(protobuf.BufferWriter);
configure();
@@ -8,6 +8,5 @@ protobuf.tokenize = require("./tokenize");
protobuf.parse = require("./parse");
protobuf.common = require("./common");
protobuf.ReflectionObject._configure(protobuf.Root);
protobuf.Namespace._configure(protobuf.Type, protobuf.Service);
// Configure parser
protobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common);

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -4,61 +4,82 @@ var fs = require("fs"),
long = require("long"),
tape = require("tape");
var distPath = path.join(__dirname, "..", "..", "dist", "protobuf.min.js");
var dist = fs.readFileSync(distPath).toString("utf8");
var distPath = path.join(__dirname, "..", "..", "dist");
tape.test("script tags", function(test) {
var sandbox;
[
{
name: "full",
data: fs.readFileSync(path.join(distPath, "protobuf.min.js")).toString("utf8")
},
{
name: "light",
data: fs.readFileSync(path.join(distPath, "light/protobuf.min.js")).toString("utf8")
},
{
name: "minimal",
data: fs.readFileSync(path.join(distPath, "minimal/protobuf.min.js")).toString("utf8")
}
]
.forEach(function(dist) {
var dcodeIO = { Long: long };
tape.test(dist.name + " build", function(test) {
vm.runInNewContext(dist, sandbox = {
window: {
dcodeIO: dcodeIO
},
dcodeIO: dcodeIO
});
test.test(test.name + " - script tags", function(test) {
var sandbox;
test.ok(sandbox.window.protobuf, "should load the library as a global");
test.ok(sandbox.window.protobuf.util.Long, "should load long.js to util");
test.end();
});
var dcodeIO = { Long: long };
tape.test("webworkers", function(test) {
var sandbox;
vm.runInNewContext(dist.data, sandbox = {
window: {
dcodeIO: dcodeIO
},
dcodeIO: dcodeIO
});
var dcodeIO = { Long: long };
test.ok(sandbox.window.protobuf, "should load the library as a global");
test.ok(sandbox.window.protobuf.util.Long, "should load long.js to util");
test.end();
});
vm.runInNewContext(dist, sandbox = {
self: {
dcodeIO: dcodeIO
},
dcodeIO: dcodeIO
});
test.test(test.name + " - webworkers", function(test) {
var sandbox;
test.ok(sandbox.self.protobuf, "should load the library as a global");
test.ok(sandbox.self.protobuf.util.Long, "should load long.js to util");
test.end();
});
var dcodeIO = { Long: long };
tape.test("amd loaders", function(test) {
var sandbox;
vm.runInNewContext(dist.data, sandbox = {
self: {
dcodeIO: dcodeIO
},
dcodeIO: dcodeIO
});
function fakeDefine(deps, init) {
test.same(deps, [ "long" ], "should request long.js as a dependency");
test.notOk(sandbox.window.protobuf.util.Long, "should not have loaded long.js before calling the factory function");
init([ long ]);
}
fakeDefine.amd = true;
test.ok(sandbox.self.protobuf, "should load the library as a global");
test.ok(sandbox.self.protobuf.util.Long, "should load long.js to util");
test.end();
});
vm.runInNewContext(dist, sandbox = {
define: fakeDefine,
window: {}
});
test.test(test.name + " - amd loaders", function(test) {
var sandbox;
function fakeDefine(deps, init) {
test.same(deps, [ "long" ], "should request long.js as a dependency");
test.notOk(sandbox.window.protobuf.util.Long, "should not have loaded long.js before calling the factory function");
init([ long ]);
}
fakeDefine.amd = true;
vm.runInNewContext(dist.data, sandbox = {
define: fakeDefine,
window: {}
});
test.ok(sandbox.window.protobuf, "should load the library as a global");
test.ok(sandbox.window.protobuf.util.Long, "should have loaded long.js after calling the factory function");
test.end();
test.ok(sandbox.window.protobuf, "should load the library as a global");
test.ok(sandbox.window.protobuf.util.Long, "should have loaded long.js after calling the factory function");
test.end();
});
});
});

0 comments on commit 039ac77

Please sign in to comment.