From 1b0e75d2b1ad79e96f8908f2eb3ec83fc2116424 Mon Sep 17 00:00:00 2001 From: Paul Johnston Date: Wed, 8 Oct 2025 15:45:53 -0600 Subject: [PATCH] Update to use patched protobuf-javascript --- MODULE.bazel | 21 ++-- closure/protobuf/protobuf_javascript.patch | 113 ++++++++++++++++++ closure/protobuf/protobuf_js.BUILD | 0 closure/templates/BUILD | 15 --- closure/templates/javascript-BUILD.patch | 18 --- closure/templates/required_by_soy.js.patch | 40 ------- .../soyutils_usegoog.js-gbigint.patch | 18 --- .../soyutils_usegoog.js-safehtml.patch | 39 ------ closure/templates/soyutils_usegoog.js.patch | 38 ------ 9 files changed, 125 insertions(+), 177 deletions(-) create mode 100644 closure/protobuf/protobuf_javascript.patch delete mode 100644 closure/protobuf/protobuf_js.BUILD delete mode 100644 closure/templates/javascript-BUILD.patch delete mode 100644 closure/templates/required_by_soy.js.patch delete mode 100644 closure/templates/soyutils_usegoog.js-gbigint.patch delete mode 100644 closure/templates/soyutils_usegoog.js-safehtml.patch delete mode 100644 closure/templates/soyutils_usegoog.js.patch diff --git a/MODULE.bazel b/MODULE.bazel index c58a00efb4..23dab3efae 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -43,18 +43,21 @@ archive_override( urls = ["https://github.com/stackb/closure-templates/archive/9b100cf0d63d36086e00a0a8ca79dd8bf274408e.tar.gz"], ) -# Commit: 91b1fff21928815fb0b5ec3143ededde5711611c -# Date: 2025-10-06 20:16:43 +0000 UTC -# URL: https://github.com/protocolbuffers/protobuf-javascript/commit/91b1fff21928815fb0b5ec3143ededde5711611c -# -# Fix closure-js output -# Size: 401316 (401 kB) # NOTE: cannot upgrade past protobuf editions... +# +# Commit: 263ee701cba6b75e1f8eddad5adcdf74718318b1 +# Date: 2025-10-08 21:32:22 +0000 UTC +# URL: https://github.com/protocolbuffers/protobuf-javascript/commit/263ee701cba6b75e1f8eddad5adcdf74718318b1 +# +# remove writeZigzagVarint64BigInt +# Size: 401599 (402 kB) archive_override( module_name = "protobuf_javascript", - sha256 = "6919eb403df3f1ae16932801b5667b5198a817cdf2d6a4490eb81121d2357891", - strip_prefix = "protobuf-javascript-91b1fff21928815fb0b5ec3143ededde5711611c", - urls = ["https://github.com/protocolbuffers/protobuf-javascript/archive/91b1fff21928815fb0b5ec3143ededde5711611c.tar.gz"], + sha256 = "8a50071fbca5e4a26361e6c9d81dd842207f0005f7cc1720226f20c25a231805", + strip_prefix = "protobuf-javascript-263ee701cba6b75e1f8eddad5adcdf74718318b1", + urls = ["https://github.com/protocolbuffers/protobuf-javascript/archive/263ee701cba6b75e1f8eddad5adcdf74718318b1.tar.gz"], + patches = ["closure/protobuf/protobuf_javascript.patch"], + patch_strip = 1, ) # ------------------------------------------------------------------- diff --git a/closure/protobuf/protobuf_javascript.patch b/closure/protobuf/protobuf_javascript.patch new file mode 100644 index 0000000000..0e46275771 --- /dev/null +++ b/closure/protobuf/protobuf_javascript.patch @@ -0,0 +1,113 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index 62355ce..f989623 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -2,10 +2,6 @@ + # + # See also code generation logic under generator/ + +-load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix") +-load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") +-load("//:protobuf_javascript_release.bzl", "package_naming") +- + config_setting( + name = "x64_x86_windows", + values = {"cpu": "x64_x86_windows"}, +@@ -31,65 +27,38 @@ config_setting( + values = {"cpu": "darwin_x86_64"}, + ) + +-package_naming( +- name = "protobuf_javascript_pkg_naming", +- platform = select({ +- ":k8": "linux-x86_64", # currently the only supported build type in Github Actions +- ":x64_x86_windows": "win32", +- ":x64_windows": "win64", +- ":darwin_arm64": "osx-aarch_64", +- ":darwin_x86_64": "osx-x86_64", +- "//conditions:default": "" # continues with current behavior when no --cpu is specified allowing existing internal builds to function +- }) +-) +- +-pkg_files( +- name = "plugin_files", +- srcs = ["//generator:protoc-gen-js"], +- attributes = pkg_attributes(mode = "0555"), +- prefix = "bin/", +-) +- +-pkg_files( +- name = "dist_files", +- srcs = glob([ +- "google/protobuf/*.js", +- "google/protobuf/compiler/*.js" +- ]) + [ +- "google-protobuf.js", +- "package.json", +- "README.md", +- "LICENSE.md", +- "LICENSE-asserts.md", +- ], +- strip_prefix = strip_prefix.from_root(""), +-) +- +-pkg_tar( +- name = "dist_tar", +- srcs = [ +- ":dist_files", +- ":plugin_files", +- ], +- extension = "tar.gz", +- package_file_name = "protobuf-javascript-{version}-{platform}.tar.gz", +- package_variables = ":protobuf_javascript_pkg_naming", +-) +- +-pkg_zip( +- name = "dist_zip", +- srcs = [ +- ":dist_files", +- ":plugin_files", +- ], +- package_file_name = "protobuf-javascript-{version}-{platform}.zip", +- package_variables = ":protobuf_javascript_pkg_naming", +-) +- + filegroup( +- name = "dist_all", ++ name = "javascript", + srcs = [ +- ":dist_tar", +- ":dist_zip", +- ] ++ "asserts.js", ++ "binary/any_field_type.js", ++ "binary/arith.js", ++ "binary/binary_constants.js", ++ "binary/bytesource.js", ++ "binary/bytesource_alias.js", ++ "binary/decoder.js", ++ "binary/decoder_alias.js", ++ "binary/encoder.js", ++ "binary/encoder_alias.js", ++ "binary/errors.js", ++ "binary/internal_buffer.js", ++ "binary/reader.js", ++ "binary/reader_alias.js", ++ "binary/repeated_field_type.js", ++ "binary/scalar_field_type.js", ++ "binary/test_utils.js", ++ "binary/utf8.js", ++ "binary/utils.js", ++ "binary/writer.js", ++ "binary/writer_alias.js", ++ "bytestring.js", ++ "debug.js", ++ "internal_bytes.js", ++ "internal_options.js", ++ "internal_public.js", ++ "map.js", ++ "message.js", ++ "unsafe_bytestring.js", ++ ], ++ visibility = ["//visibility:public"], + ) diff --git a/closure/protobuf/protobuf_js.BUILD b/closure/protobuf/protobuf_js.BUILD deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/closure/templates/BUILD b/closure/templates/BUILD index f3395d9926..4f1d17bf48 100644 --- a/closure/templates/BUILD +++ b/closure/templates/BUILD @@ -13,27 +13,12 @@ # limitations under the License. load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile") - -# load("@rules_java//java:defs.bzl", "java_library") load("//closure:defs.bzl", "closure_js_library") package(default_visibility = ["//visibility:public"]) licenses(["notice"]) -exports_files([ - "javascript-BUILD.patch", - "required_by_soy.js.patch", - "soyutils_usegoog.js.patch", - "soyutils_usegoog.js-gbigint.patch", - "soyutils_usegoog.js-safehtml.patch", -]) - -# java_library( -# name = "templates", -# exports = ["@com_google_template_soy"], -# ) - closure_js_library( name = "soy_jssrc", srcs = [ diff --git a/closure/templates/javascript-BUILD.patch b/closure/templates/javascript-BUILD.patch deleted file mode 100644 index 5ee2501e85..0000000000 --- a/closure/templates/javascript-BUILD.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/javascript/BUILD.bazel b/javascript/BUILD.bazel -new file mode 100644 -index 000000000..e80c73a2d ---- /dev/null -+++ b/javascript/BUILD.bazel -@@ -0,0 +1,12 @@ -+filegroup( -+ name = "soyutils", -+ srcs = [ -+ "required_by_soy.js", -+ "soydata_converters.js", -+ "soyutils_map.js", -+ "soyutils_newmaps.js", -+ "soyutils_templates.js", -+ "soyutils_usegoog.js", -+ ], -+ visibility = ["//visibility:public"], -+) diff --git a/closure/templates/required_by_soy.js.patch b/closure/templates/required_by_soy.js.patch deleted file mode 100644 index 2d65e99cda..0000000000 --- a/closure/templates/required_by_soy.js.patch +++ /dev/null @@ -1,40 +0,0 @@ -commit 2374ce63f349344f4202204216a64d9fdf7f7e7d -Author: Paul Johnston -Date: Sun Oct 5 15:04:06 2025 -0600 - - remove idom - -diff --git a/javascript/required_by_soy.js b/javascript/required_by_soy.js -index ee8558cf3..9645290db 100644 ---- a/javascript/required_by_soy.js -+++ b/javascript/required_by_soy.js -@@ -37,14 +37,12 @@ goog.require('goog.soy'); - goog.require('goog.soy.data'); - goog.require('goog.string'); - goog.require('goog.string.Const'); --goog.require('google3.javascript.template.soy.soyutils_idom'); - goog.require('proto.webutil.html.types.SafeHtmlProto'); - goog.require('proto.webutil.html.types.SafeScriptProto'); - goog.require('proto.webutil.html.types.SafeStyleProto'); - goog.require('proto.webutil.html.types.SafeStyleSheetProto'); - goog.require('proto.webutil.html.types.SafeUrlProto'); - goog.require('proto.webutil.html.types.TrustedResourceUrlProto'); --goog.require('soydata.converters.idom'); - goog.require('xid'); - - goog.scope(function() { -@@ -102,14 +100,12 @@ goog.exportSymbol('goog.string.regExpEscape', goog.string.regExpEscape); - goog.exportSymbol('goog.string.unescapeEntities', goog.string.unescapeEntities); - goog.exportSymbol('goog.string.newLineToBr', goog.string.newLineToBr); - goog.exportSymbol('goog.string.urlEncode', goog.string.urlEncode); --goog.exportSymbol('google3.javascript.template.soy.soyutils_idom', goog.module.get('google3.javascript.template.soy.soyutils_idom')); - goog.exportSymbol('proto.webutil.html.types.SafeHtmlProto', proto.webutil.html.types.SafeHtmlProto); - goog.exportSymbol('proto.webutil.html.types.SafeScriptProto', proto.webutil.html.types.SafeScriptProto); - goog.exportSymbol('proto.webutil.html.types.SafeStyleProto', proto.webutil.html.types.SafeStyleProto); - goog.exportSymbol('proto.webutil.html.types.SafeStyleSheetProto', proto.webutil.html.types.SafeStyleSheetProto); - goog.exportSymbol('proto.webutil.html.types.SafeUrlProto', proto.webutil.html.types.SafeUrlProto); - goog.exportSymbol('proto.webutil.html.types.TrustedResourceUrlProto', proto.webutil.html.types.TrustedResourceUrlProto); --goog.exportSymbol('soydata.converters.idom', goog.module.get('soydata.converters.idom')); - goog.exportSymbol('xid', xid); - - }); diff --git a/closure/templates/soyutils_usegoog.js-gbigint.patch b/closure/templates/soyutils_usegoog.js-gbigint.patch deleted file mode 100644 index 8d4b74b0f6..0000000000 --- a/closure/templates/soyutils_usegoog.js-gbigint.patch +++ /dev/null @@ -1,18 +0,0 @@ -commit 75fb273bead026ec45824c7f32d439985d9fdd49 -Author: Paul Johnston -Date: Sun Oct 5 15:10:16 2025 -0600 - - require gbitint - -diff --git a/javascript/soyutils_usegoog.js b/javascript/soyutils_usegoog.js -index 29ec261a5..bf1794f33 100644 ---- a/javascript/soyutils_usegoog.js -+++ b/javascript/soyutils_usegoog.js -@@ -39,6 +39,7 @@ const {Message} = goog.requireType('jspb'); - const {SafeHtml, SafeScript, SafeStyleSheet, TrustedResourceUrl, isUrl, unwrapHtml, unwrapResourceUrl, unwrapScript, unwrapStyleSheet, unwrapUrl} = goog.require('google3.third_party.javascript.safevalues.index'); - const {SanitizedContent, SanitizedContentKind, SanitizedCss, SanitizedHtml, SanitizedHtmlAttribute, SanitizedJs, SanitizedTrustedResourceUri, SanitizedUri} = goog.require('goog.soy.data'); - const {compareBigInt} = goog.require('google3.javascript.common.bigint.index'); -+const {gbigint} = goog.requireType('soy.types.gbigint'); - const {htmlSafeByReview} = goog.require('google3.third_party.javascript.safevalues.restricted.reviewed'); - const {isReadonly} = goog.require('google3.javascript.apps.jspb.types.is_readonly'); - diff --git a/closure/templates/soyutils_usegoog.js-safehtml.patch b/closure/templates/soyutils_usegoog.js-safehtml.patch deleted file mode 100644 index c6a2e4a179..0000000000 --- a/closure/templates/soyutils_usegoog.js-safehtml.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/javascript/soyutils_usegoog.js b/javascript/soyutils_usegoog.js -index bf1794f33..b4eab643b 100644 ---- a/javascript/soyutils_usegoog.js -+++ b/javascript/soyutils_usegoog.js -@@ -33,6 +33,7 @@ const bidi = goog.require('goog.i18n.bidi'); - const googArray = goog.require('goog.array'); - const googDebug = goog.require('goog.debug'); - const googFormat = goog.require('goog.format'); -+const GoogSafeHtml = goog.require('goog.html.SafeHtml'); - const googSoy = goog.requireType('goog.soy'); - const googString = goog.require('goog.string'); - const {Message} = goog.requireType('jspb'); -@@ -2382,6 +2383,7 @@ const $$bidiMarkAfter = function(bidiGlobalDir, text, isHtml) { - * @param {?} text The string to be wrapped. Can be other types, but the value - * will be coerced to a string. - * @return {string} The wrapped text. -+ * @suppress {checkTypes} - */ - const $$bidiSpanWrap = function(bidiGlobalDir, text) { - const formatter = getBidiFormatterInstance_(bidiGlobalDir); -@@ -2397,12 +2399,16 @@ const $$bidiSpanWrap = function(bidiGlobalDir, text) { - String(text), - {justification: 'Soy |bidiSpanWrap is applied on an autoescaped text.'}); - const dir = $$bidiTextDir(text, /** isHtml= */ true); -- const wrappedHtml = formatter.spanWrapSafeHtmlWithKnownDir(dir, html); -+ const googHtml = GoogSafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(unwrapHtml(html)); -+ const wrappedHtml = formatter.spanWrapSafeHtmlWithKnownDir(dir, googHtml); - - // Like other directives whose Java class implements SanitizedContentOperator, - // |bidiSpanWrap is called after the escaping (if any) has already been done, - // and thus there is no need for it to produce actual SanitizedContent. -- return unwrapHtml(wrappedHtml).toString(); -+ const safeWrappedHtml = htmlSafeByReview( -+ GoogSafeHtml.unwrapTrustedHTML(wrappedHtml), -+ { justification: 'Converting goog.html.SafeHtml back to safevalues SafeHtml for unwrapHtml.'}); -+ return unwrapHtml(safeWrappedHtml).toString(); - }; - - diff --git a/closure/templates/soyutils_usegoog.js.patch b/closure/templates/soyutils_usegoog.js.patch deleted file mode 100644 index 605fb97d06..0000000000 --- a/closure/templates/soyutils_usegoog.js.patch +++ /dev/null @@ -1,38 +0,0 @@ -commit 916f1d26671e8d30f3ff437eafa2760f7ebb6385 -Author: Paul Johnston -Date: Sun Oct 5 15:06:56 2025 -0600 - - remove proto immutable - -diff --git a/javascript/soyutils_usegoog.js b/javascript/soyutils_usegoog.js -index 6a63f0c07..29ec261a5 100644 ---- a/javascript/soyutils_usegoog.js -+++ b/javascript/soyutils_usegoog.js -@@ -39,7 +39,6 @@ const {Message} = goog.requireType('jspb'); - const {SafeHtml, SafeScript, SafeStyleSheet, TrustedResourceUrl, isUrl, unwrapHtml, unwrapResourceUrl, unwrapScript, unwrapStyleSheet, unwrapUrl} = goog.require('google3.third_party.javascript.safevalues.index'); - const {SanitizedContent, SanitizedContentKind, SanitizedCss, SanitizedHtml, SanitizedHtmlAttribute, SanitizedJs, SanitizedTrustedResourceUri, SanitizedUri} = goog.require('goog.soy.data'); - const {compareBigInt} = goog.require('google3.javascript.common.bigint.index'); --const {defaultImmutableInstance} = goog.require('jspb.immutable_message'); - const {htmlSafeByReview} = goog.require('google3.third_party.javascript.safevalues.restricted.reviewed'); - const {isReadonly} = goog.require('google3.javascript.apps.jspb.types.is_readonly'); - -@@ -2612,9 +2611,6 @@ const /** boolean */ SOY_CREATED_PROTOS_ARE_IMMUTABLE = false; - * @return {?} - */ - function $$emptyProto(/** function(new:Message,?Array=)*/ ctor) { -- if (SOY_CREATED_PROTOS_ARE_IMMUTABLE) { -- return defaultImmutableInstance(ctor); -- } - return new ctor(); - } - -@@ -2624,9 +2620,6 @@ function $$emptyProto(/** function(new:Message,?Array=)*/ ctor) { - * @return {?} - */ - function $$maybeMakeImmutableProto(/** !Message*/ message) { -- if (SOY_CREATED_PROTOS_ARE_IMMUTABLE) { -- return message.toImmutable(); -- } - return message; - } -