protobufjs 6.8.4 → 6.8.8
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/CHANGELOG.md +46 -0
- package/README.md +2 -2
- package/cli/node_modules/os-tmpdir/index.js +25 -0
- package/cli/node_modules/os-tmpdir/license +21 -0
- package/cli/node_modules/os-tmpdir/readme.md +32 -0
- package/cli/node_modules/tmp/LICENSE +21 -0
- package/cli/node_modules/tmp/README.md +314 -0
- package/cli/node_modules/tmp/lib/tmp.js +611 -0
- package/cli/pbjs.d.ts +1 -1
- package/cli/pbjs.js +11 -1
- package/cli/pbts.d.ts +1 -1
- package/cli/pbts.js +36 -7
- package/cli/targets/proto.js +1 -1
- package/cli/targets/static.js +3 -6
- package/dist/light/protobuf.js +143 -64
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +23 -14
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +268 -90
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor/index.d.ts +0 -1
- package/ext/descriptor/index.js +3 -0
- package/index.d.ts +57 -16
- package/package-lock.json +4579 -3191
- package/package.json +122 -125
- package/src/common.js +22 -1
- package/src/converter.js +9 -3
- package/src/enum.js +17 -5
- package/src/field.js +17 -4
- package/src/index-light.js +2 -2
- package/src/index-minimal.js +1 -1
- package/src/mapfield.js +9 -5
- package/src/message.js +1 -1
- package/src/method.js +14 -4
- package/src/namespace.js +14 -10
- package/src/object.js +1 -0
- package/src/oneof.js +14 -4
- package/src/parse.js +11 -3
- package/src/reader.js +2 -4
- package/src/root.js +3 -2
- package/src/service.js +8 -4
- package/src/tokenize.js +92 -22
- package/src/type.js +10 -5
- package/src/util/minimal.js +11 -2
- package/google/protobuf/field_mask.json +0 -21
- package/google/protobuf/field_mask.proto +0 -7
package/cli/pbts.js
CHANGED
|
@@ -24,9 +24,10 @@ exports.main = function(args, callback) {
|
|
|
24
24
|
name: "n",
|
|
25
25
|
out : "o",
|
|
26
26
|
main: "m",
|
|
27
|
-
global: "g"
|
|
27
|
+
global: "g",
|
|
28
|
+
import: "i"
|
|
28
29
|
},
|
|
29
|
-
string: [ "name", "out", "global" ],
|
|
30
|
+
string: [ "name", "out", "global", "import" ],
|
|
30
31
|
boolean: [ "comments", "main" ],
|
|
31
32
|
default: {
|
|
32
33
|
comments: true,
|
|
@@ -49,6 +50,8 @@ exports.main = function(args, callback) {
|
|
|
49
50
|
"",
|
|
50
51
|
" -g, --global Name of the global object in browser environments, if any.",
|
|
51
52
|
"",
|
|
53
|
+
" -i, --import Comma delimited list of imports. Local names will equal camelCase of the basename.",
|
|
54
|
+
"",
|
|
52
55
|
" --no-comments Does not output any JSDoc comments.",
|
|
53
56
|
"",
|
|
54
57
|
chalk.bold.gray(" Internal flags:"),
|
|
@@ -98,7 +101,8 @@ exports.main = function(args, callback) {
|
|
|
98
101
|
// There is no proper API for jsdoc, so this executes the CLI and pipes the output
|
|
99
102
|
var basedir = path.join(__dirname, ".");
|
|
100
103
|
var moduleName = argv.name || "null";
|
|
101
|
-
var
|
|
104
|
+
var nodePath = process.execPath;
|
|
105
|
+
var cmd = "\"" + nodePath + "\" \"" + require.resolve("jsdoc/jsdoc.js") + "\" -c \"" + path.join(basedir, "lib", "tsd-jsdoc.json") + "\" -q \"module=" + encodeURIComponent(moduleName) + "&comments=" + Boolean(argv.comments) + "\" " + files.map(function(file) { return "\"" + file + "\""; }).join(" ");
|
|
102
106
|
var child = child_process.exec(cmd, {
|
|
103
107
|
cwd: process.cwd(),
|
|
104
108
|
argv0: "node",
|
|
@@ -134,18 +138,43 @@ exports.main = function(args, callback) {
|
|
|
134
138
|
return undefined;
|
|
135
139
|
});
|
|
136
140
|
|
|
141
|
+
function getImportName(importItem) {
|
|
142
|
+
return path.basename(importItem, ".js").replace(/([-_~.+]\w)/g, function(match) {
|
|
143
|
+
return match[1].toUpperCase();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
function finish() {
|
|
138
148
|
var output = [];
|
|
139
|
-
if (argv.
|
|
149
|
+
if (argv.main)
|
|
140
150
|
output.push(
|
|
141
|
-
"
|
|
151
|
+
"// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run types'.",
|
|
142
152
|
""
|
|
143
153
|
);
|
|
144
|
-
if (
|
|
154
|
+
if (argv.global)
|
|
145
155
|
output.push(
|
|
146
|
-
"
|
|
156
|
+
"export as namespace " + argv.global + ";",
|
|
147
157
|
""
|
|
148
158
|
);
|
|
159
|
+
|
|
160
|
+
if (!argv.main) {
|
|
161
|
+
// Ensure we have a usable array of imports
|
|
162
|
+
var importArray = typeof argv.import === "string" ? argv.import.split(",") : argv.import || [];
|
|
163
|
+
|
|
164
|
+
// Build an object of imports and paths
|
|
165
|
+
var imports = {
|
|
166
|
+
$protobuf: "protobufjs"
|
|
167
|
+
};
|
|
168
|
+
importArray.forEach(function(importItem) {
|
|
169
|
+
imports[getImportName(importItem)] = importItem;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Write out the imports
|
|
173
|
+
Object.keys(imports).forEach(function(key) {
|
|
174
|
+
output.push("import * as " + key + " from \"" + imports[key] + "\";");
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
149
178
|
output = output.join("\n") + "\n" + out.join("");
|
|
150
179
|
|
|
151
180
|
try {
|
package/cli/targets/proto.js
CHANGED
package/cli/targets/static.js
CHANGED
|
@@ -172,12 +172,9 @@ var shortVars = {
|
|
|
172
172
|
function beautifyCode(code) {
|
|
173
173
|
// Add semicolons
|
|
174
174
|
code = UglifyJS.minify(code, {
|
|
175
|
-
fromString: true,
|
|
176
175
|
compress: false,
|
|
177
176
|
mangle: false,
|
|
178
|
-
output: {
|
|
179
|
-
beautify: true
|
|
180
|
-
}
|
|
177
|
+
output: { beautify: true }
|
|
181
178
|
}).code;
|
|
182
179
|
// Properly beautify
|
|
183
180
|
var ast = espree.parse(code);
|
|
@@ -653,11 +650,11 @@ function buildService(ref, service) {
|
|
|
653
650
|
"@returns {undefined}",
|
|
654
651
|
"@variation 1"
|
|
655
652
|
]);
|
|
656
|
-
push(escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
|
|
653
|
+
push("Object.defineProperty(" + escapeName(service.name) + ".prototype" + util.safeProp(lcName) + " = function " + escapeName(lcName) + "(request, callback) {");
|
|
657
654
|
++indent;
|
|
658
655
|
push("return this.rpcCall(" + escapeName(lcName) + ", $root." + exportName(method.resolvedRequestType) + ", $root." + exportName(method.resolvedResponseType) + ", request, callback);");
|
|
659
656
|
--indent;
|
|
660
|
-
push("};");
|
|
657
|
+
push("}, \"name\", { value: " + JSON.stringify(method.name) + " });");
|
|
661
658
|
if (config.comments)
|
|
662
659
|
push("");
|
|
663
660
|
pushComment([
|