Skip to content

Commit

Permalink
Refactoring; Removed the need for triple-slash references in .d.ts by…
Browse files Browse the repository at this point in the history
… providing a minimal Long interface, see #527, see #530
  • Loading branch information
dcodeIO committed Dec 8, 2016
1 parent 228a202 commit 5606cb1
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .zuul.yml
Expand Up @@ -17,7 +17,7 @@ browsers:
- name: iphone
version: [8.1, 9.0, latest]
scripts:
- scripts/polyfill.js
- lib/polyfill.js
- node_modules/long/dist/long.js
tunnel:
type: ngrok
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -185,7 +185,7 @@ message HelloReply {
```js
...
var Greeter = root.lookup("Greeter");
var greeter = Greeter.create(rpcImpl);
var greeter = Greeter.create(rpcImpl, false, false); // rpcImpl (see below), requestDelimited?, responseDelimited?

greeter.sayHello({ name: 'you' }, function(err, response) {
console.log('Greeting:', response.message);
Expand Down
17 changes: 15 additions & 2 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/protobuf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

File renamed without changes.
22 changes: 6 additions & 16 deletions runtime.js
@@ -1,16 +1,6 @@
"use strict";

/**
* Minimal static codegen runtime.
* @namespace
*/
var runtime = exports;

/** @alias Reader */
runtime.Reader = require("./src/reader");

/** @alias Writer */
runtime.Writer = require("./src/writer");

/** @alias util */
runtime.util = require("./src/util/runtime");
// This file exports just the bare minimum required to work with statically generated code.
// Can be used as a drop-in replacement for the full library as it has the same general structure.
var protobuf_rt = exports;
protobuf_rt.Reader = require("./src/reader");
protobuf_rt.Writer = require("./src/writer");
protobuf_rt.util = require("./src/util/runtime");
5 changes: 2 additions & 3 deletions scripts/types.js
Expand Up @@ -4,9 +4,8 @@ var fs = require("fs"),
var dir = path.join(__dirname, "..", "types");

var header = [
'/// <reference types="node" />',
'/// <reference types="long" />',
"",
// '/// <reference types="long" />',
// "",
"/*",
" * protobuf.js v" + pkg.version + " TypeScript definitions",
" * Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
Expand Down
9 changes: 9 additions & 0 deletions src/util/longbits.js
Expand Up @@ -4,6 +4,15 @@ module.exports = LongBits;

var util = require("../util");

/**
* Any compatible Long instance.
* @typedef Long
* @type {Object}
* @property {number} low Low bits
* @property {number} high High bits
* @property {boolean} unsigned Whether unsigned or not
*/

/**
* Constructs new long bits.
* @classdesc Helper class for working with the low and high bits of a 64 bit value.
Expand Down
22 changes: 17 additions & 5 deletions types/protobuf.js.d.ts
@@ -1,9 +1,6 @@
/// <reference types="node" />
/// <reference types="long" />

/*
* protobuf.js v6.1.0 TypeScript definitions
* Generated Wed, 07 Dec 2016 22:34:16 UTC
* Generated Thu, 08 Dec 2016 13:22:46 UTC
*/
declare module "protobufjs" {

Expand Down Expand Up @@ -826,7 +823,7 @@ declare module "protobufjs" {

/**
* Field names that belong to this oneof.
* @type {Array.<string>}
* @type {string[]}
*/
oneof: string[];

Expand Down Expand Up @@ -1497,6 +1494,21 @@ declare module "protobufjs" {

}

/**
* Any compatible Long instance.
* @typedef Long
* @type {Object}
* @property {number} low Low bits
* @property {number} high High bits
* @property {boolean} unsigned Whether unsigned or not
*/
interface Long {
low: number;
high: number;
unsigned: boolean;
}


/**
* Utility functions.
* @namespace
Expand Down

0 comments on commit 5606cb1

Please sign in to comment.