Skip to content

Commit 6a7eced

Browse files
pcjdibenede
authored andcommitted
Fix closure-js output
1 parent cbeded2 commit 6a7eced

File tree

7 files changed

+56
-67
lines changed

7 files changed

+56
-67
lines changed

BUILD.bazel

Lines changed: 32 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
#
33
# See also code generation logic under generator/
44

5-
load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix")
6-
load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip")
7-
load("//:protobuf_javascript_release.bzl", "package_naming")
8-
95
config_setting(
106
name = "x64_x86_windows",
117
values = {"cpu": "x64_x86_windows"},
@@ -31,65 +27,38 @@ config_setting(
3127
values = {"cpu": "darwin_x86_64"},
3228
)
3329

34-
package_naming(
35-
name = "protobuf_javascript_pkg_naming",
36-
platform = select({
37-
":k8": "linux-x86_64", # currently the only supported build type in Github Actions
38-
":x64_x86_windows": "win32",
39-
":x64_windows": "win64",
40-
":darwin_arm64": "osx-aarch_64",
41-
":darwin_x86_64": "osx-x86_64",
42-
"//conditions:default": "" # continues with current behavior when no --cpu is specified allowing existing internal builds to function
43-
})
44-
)
45-
46-
pkg_files(
47-
name = "plugin_files",
48-
srcs = ["//generator:protoc-gen-js"],
49-
attributes = pkg_attributes(mode = "0555"),
50-
prefix = "bin/",
51-
)
52-
53-
pkg_files(
54-
name = "dist_files",
55-
srcs = glob([
56-
"google/protobuf/*.js",
57-
"google/protobuf/compiler/*.js"
58-
]) + [
59-
"google-protobuf.js",
60-
"package.json",
61-
"README.md",
62-
"LICENSE.md",
63-
"LICENSE-asserts.md",
64-
],
65-
strip_prefix = strip_prefix.from_root(""),
66-
)
67-
68-
pkg_tar(
69-
name = "dist_tar",
70-
srcs = [
71-
":dist_files",
72-
":plugin_files",
73-
],
74-
extension = "tar.gz",
75-
package_file_name = "protobuf-javascript-{version}-{platform}.tar.gz",
76-
package_variables = ":protobuf_javascript_pkg_naming",
77-
)
78-
79-
pkg_zip(
80-
name = "dist_zip",
81-
srcs = [
82-
":dist_files",
83-
":plugin_files",
84-
],
85-
package_file_name = "protobuf-javascript-{version}-{platform}.zip",
86-
package_variables = ":protobuf_javascript_pkg_naming",
87-
)
88-
8930
filegroup(
90-
name = "dist_all",
31+
name = "javascript",
9132
srcs = [
92-
":dist_tar",
93-
":dist_zip",
94-
]
33+
"asserts.js",
34+
"binary/any_field_type.js",
35+
"binary/arith.js",
36+
"binary/binary_constants.js",
37+
"binary/bytesource.js",
38+
"binary/bytesource_alias.js",
39+
"binary/decoder.js",
40+
"binary/decoder_alias.js",
41+
"binary/encoder.js",
42+
"binary/encoder_alias.js",
43+
"binary/errors.js",
44+
"binary/internal_buffer.js",
45+
"binary/reader.js",
46+
"binary/reader_alias.js",
47+
"binary/repeated_field_type.js",
48+
"binary/scalar_field_type.js",
49+
"binary/test_utils.js",
50+
"binary/utf8.js",
51+
"binary/utils.js",
52+
"binary/writer.js",
53+
"binary/writer_alias.js",
54+
"bytestring.js",
55+
"debug.js",
56+
"internal_bytes.js",
57+
"internal_options.js",
58+
"internal_public.js",
59+
"map.js",
60+
"message.js",
61+
"unsafe_bytestring.js",
62+
],
63+
visibility = ["//visibility:public"],
9564
)

binary/bytesource_alias.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @fileoverview Legacy alias for the old namespace used by encoder.js
3+
*/
4+
goog.module('jspb.ByteSource');
5+
goog.module.declareLegacyNamespace();
6+
7+
const { ByteSource } = goog.require('jspb.binary.bytesource');
8+
9+
exports = ByteSource;

binary/encoder.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ class BinaryEncoder {
191191
this.writeSplitVarint64(utils.getSplit64Low(), utils.getSplit64High());
192192
}
193193

194+
/**
195+
* Encodes a BigInt into its wire-format, zigzag-encoded varint
196+
* representation and stores it in the buffer.
197+
* @param {bigint} value The BigInt to convert.
198+
*/
199+
writeZigzagVarint64BigInt(value) {
200+
this.writeZigzagVarint64String(value.toString());
201+
}
202+
194203
/**
195204
* Encodes a JavaScript decimal string into its wire-format, zigzag-encoded
196205
* varint representation and stores it in the buffer. Integers not

binary/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ goog.module.declareLegacyNamespace();
1212
const BinaryConstants = goog.require('jspb.BinaryConstants');
1313
const { assert } = goog.require('goog.asserts');
1414
const { isBigIntAvailable } = goog.require('jspb.internal_options');
15+
const { ByteSource } = goog.require('jspb.binary.bytesource');
1516
const { ByteString } = goog.require('jspb.bytestring');
1617
const { decodeStringToUint8Array } = goog.require('goog.crypt.base64');
1718
const { unsafeUint8ArrayFromByteString } = goog.require('jspb.unsafe_bytestring');

generator/js_generator.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options,
18551855
required->insert("jspb.internal.public_for_gencode");
18561856
required->insert("jspb.BinaryReader");
18571857
required->insert("jspb.BinaryWriter");
1858+
required->insert("jspb.binary.bytesource");
18581859
}
18591860
if (require_extension) {
18601861
required->insert("jspb.ExtensionFieldBinaryInfo");
@@ -3016,7 +3017,7 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,
30163017
printer->Print(
30173018
"/**\n"
30183019
" * Deserializes binary data (in protobuf wire format).\n"
3019-
" * @param {jspb.ByteSource} bytes The bytes to deserialize.\n"
3020+
" * @param {jspb.binary.bytesource.ByteSource} bytes The bytes to deserialize.\n"
30203021
" * @return {!$class$}\n"
30213022
" */\n"
30223023
"$class$.deserializeBinary = function(bytes) {\n"

internal_public.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ goog.module.declareLegacyNamespace();
1212
const asserts = goog.require('goog.asserts');
1313
const { BinaryReader } = goog.require('jspb.binary.reader');
1414
const { BinaryWriter } = goog.requireType('jspb.binary.writer');
15-
const {Map: JspbMap} = goog.requireType('jspb.Map');
15+
const JspbMap = goog.requireType('jspb.Map');
1616

1717
/**
1818
* Write this Map field in wire format to a BinaryWriter, using the given

message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ jspb.Message.clone_ = function(obj) {
18761876
// NOTE:redundant null check existing for NTI compatibility.
18771877
// see b/70515949
18781878
clonedArray[i] = (typeof o == 'object') ?
1879-
jspb.Message.clone_(jspb.asserts.assert(o)) :
1879+
jspb.Message.clone_(/** @type {!Object} */(jspb.asserts.assert(o))) :
18801880
o;
18811881
}
18821882
}
@@ -1892,7 +1892,7 @@ jspb.Message.clone_ = function(obj) {
18921892
// NOTE:redundant null check existing for NTI compatibility.
18931893
// see b/70515949
18941894
clone[key] = (typeof o == 'object') ?
1895-
jspb.Message.clone_(jspb.asserts.assert(o)) :
1895+
jspb.Message.clone_(/** @type {!Object} */(jspb.asserts.assert(o))) :
18961896
o;
18971897
}
18981898
}

0 commit comments

Comments
 (0)