From d701b3a881cac8cbb64a64343a089f30b7575a54 Mon Sep 17 00:00:00 2001 From: Allan Banaag Date: Wed, 10 Mar 2021 12:26:58 -0800 Subject: [PATCH 01/20] Update test to fix go vet error: call of t.Fatalf copies lock value: github.com/ampproject/amppackager/transformer/request.Request contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex PiperOrigin-RevId: 362115014 --- transformer/transformer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transformer/transformer_test.go b/transformer/transformer_test.go index f17a8642e..bc68f42a2 100644 --- a/transformer/transformer_test.go +++ b/transformer/transformer_test.go @@ -309,8 +309,8 @@ func TestCustom(t *testing.T) { } func TestCustomFail(t *testing.T) { - r := rpb.Request{Html: "", Config: rpb.Request_CUSTOM, Transformers: []string{"does_not_exist"}} - if html, _, err := Process(&r); err == nil { + r := &rpb.Request{Html: "", Config: rpb.Request_CUSTOM, Transformers: []string{"does_not_exist"}} + if html, _, err := Process(r); err == nil { t.Fatalf("Process(%v) = %s, nil; want error", r, html) } } From 2de06f3444d4727ad37b99b805e59bb838497a8b Mon Sep 17 00:00:00 2001 From: honeybadgerdontcare Date: Wed, 10 Mar 2021 17:48:37 -0800 Subject: [PATCH 02/20] Make relative amp-story-page-attachment URLs absolute. PiperOrigin-RevId: 362183596 --- transformer/transformers/absoluteurl.go | 7 +++++++ transformer/transformers/absoluteurl_test.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/transformer/transformers/absoluteurl.go b/transformer/transformers/absoluteurl.go index 16e2dac53..ddfc4cb4b 100644 --- a/transformer/transformers/absoluteurl.go +++ b/transformer/transformers/absoluteurl.go @@ -28,6 +28,7 @@ var /* const */ anyTagAttrs = []string{"background", "poster", "src"} var /* const */ ampInstallServiceWorkerTagAttrs = []string{"data-iframe-src", "data-no-service-worker-fallback-shell-url"} var /* const */ ampStoryTagAttrs = []string{"background-audio", "bookend-config-src", "poster-landscape-src", "poster-square-src", "publisher-logo-src"} var /* const */ ampStoryPageTagAttrs = []string{"background-audio"} +var /* const */ ampStoryPageAttachmentTagAttrs = []string{"cta-image", "cta-image-2"} var /* const */ formTagAttrs = []string{"action", "action-xhr", "verify-xhr"} var /* const */ imgTagAttrs = []string{"longdesc"} @@ -57,6 +58,9 @@ var /* const */ imgTagAttrs = []string{"longdesc"} // * publisher-logo-src // * Any tag with attribute: // * background-audio +// * Any tag with attribute: +// * cta-image +// * cta-image-2 // * Any
tag with attribute: // * action // * action-xhr @@ -98,6 +102,9 @@ func AbsoluteURL(e *Context) error { case "amp-story-page": // Make attributes with URLs portable on tag. rewriteAbsoluteURLs(n, documentURL, e.BaseURL, ampStoryPageTagAttrs) + case "amp-story-page-attachment": + // Make attributes with URLs portable on tag. + rewriteAbsoluteURLs(n, documentURL, e.BaseURL, ampStoryPageAttachmentTagAttrs) } } diff --git a/transformer/transformers/absoluteurl_test.go b/transformer/transformers/absoluteurl_test.go index 65c2f5ddb..43d8c5320 100644 --- a/transformer/transformers/absoluteurl_test.go +++ b/transformer/transformers/absoluteurl_test.go @@ -249,6 +249,10 @@ func TestSpecificTagsAreAbsoluted(t *testing.T) { publisher-logo-src=/foo> + +
From 78598d675b01e30a7831d4867e3c2a4645a67254 Mon Sep 17 00:00:00 2001 From: honeybadgerdontcare Date: Tue, 16 Mar 2021 13:28:24 -0700 Subject: [PATCH 03/20] Add extension module/nomodule tests to stripjs.go PiperOrigin-RevId: 363257129 --- transformer/transformers/stripjs_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/transformer/transformers/stripjs_test.go b/transformer/transformers/stripjs_test.go index eb7ad61d4..667605ba2 100644 --- a/transformer/transformers/stripjs_test.go +++ b/transformer/transformers/stripjs_test.go @@ -37,15 +37,25 @@ func TestStripJS(t *testing.T) { Expected: "", }, { - Desc: "keeps module script correct src", + Desc: "keeps module runtime script correct src", Input: "", Expected: "", }, { - Desc: "keeps nomodule script correct src", + Desc: "keeps nomodule runtime script correct src", Input: "", Expected: "", }, + { + Desc: "keeps module extension script correct src", + Input: "", + Expected: "", + }, + { + Desc: "keeps nomodule extension script correct src", + Input: "", + Expected: "", + }, { Desc: "keeps script correct src case-insensitive", Input: "", From bae824631c8340e5a14f0353a887617bd5bcc0f2 Mon Sep 17 00:00:00 2001 From: honeybadgerdontcare Date: Wed, 17 Mar 2021 08:44:47 -0700 Subject: [PATCH 04/20] Add module detection to IsScriptAMPRuntime and related test cases PiperOrigin-RevId: 363427993 --- transformer/internal/amphtml/amphtml.go | 6 ++- transformer/internal/amphtml/amphtml_test.go | 56 +++++++++++++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/transformer/internal/amphtml/amphtml.go b/transformer/internal/amphtml/amphtml.go index c5828f013..0d874be35 100644 --- a/transformer/internal/amphtml/amphtml.go +++ b/transformer/internal/amphtml/amphtml.go @@ -90,7 +90,7 @@ func IsScriptAMPExtension(n *html.Node) bool { return ok } -// IsScriptAMPRuntime returns true if the node is of the form +// IsScriptAMPRuntime returns true if the node is of the form func IsScriptAMPRuntime(n *html.Node) bool { if n.DataAtom != atom.Script { return false @@ -100,7 +100,9 @@ func IsScriptAMPRuntime(n *html.Node) bool { !IsScriptAMPExtension(n) && strings.HasPrefix(v, AMPCacheRootURL) && (strings.HasSuffix(v, "/v0.js") || - strings.HasSuffix(v, "/amp4ads-v0.js")) + strings.HasSuffix(v, "v0.mjs") || + strings.HasSuffix(v, "/amp4ads-v0.js") || + strings.HasSuffix(v, "/amp4ads-v0.mjs")) } return false } diff --git a/transformer/internal/amphtml/amphtml_test.go b/transformer/internal/amphtml/amphtml_test.go index ab00b38ec..2c7d8d7fb 100644 --- a/transformer/internal/amphtml/amphtml_test.go +++ b/transformer/internal/amphtml/amphtml_test.go @@ -150,8 +150,7 @@ func TestIsScriptAMPRuntime(t *testing.T) { Attr: []html.Attribute{ {Key: "async"}, {Key: "custom-element"}, - {Key: "src", - Val: "https://cdn.ampproject.org/v0.js"}}}, + {Key: "src", Val: "https://cdn.ampproject.org/v0.js"}}}, false, }, { @@ -160,8 +159,28 @@ func TestIsScriptAMPRuntime(t *testing.T) { Data: "script", DataAtom: atom.Script, Attr: []html.Attribute{ {Key: "async"}, - {Key: "src", - Val: "https://cdn.ampproject.org/v0.js"}}}, + {Key: "src", Val: "https://cdn.ampproject.org/v0.js"}}}, + true, + }, + { + "amp runtime module true", + &html.Node{Type: html.ElementNode, + Data: "script", + DataAtom: atom.Script, Attr: []html.Attribute{ + {Key: "async"}, + {Key: "crossorigin", Val: "anonymous"}, + {Key: "src", Val: "https://cdn.ampproject.org/v0.js"}, + {Key: "type", Val: "module"}}}, + true, + }, + { + "amp runtime nomodule true", + &html.Node{Type: html.ElementNode, + Data: "script", + DataAtom: atom.Script, Attr: []html.Attribute{ + {Key: "async"}, + {Key: "nomodule"}, + {Key: "src", Val: "https://cdn.ampproject.org/v0.mjs"}}}, true, }, { @@ -172,8 +191,7 @@ func TestIsScriptAMPRuntime(t *testing.T) { Attr: []html.Attribute{ {Key: "async"}, {Key: "custom-element"}, - {Key: "src", - Val: "https://cdn.ampproject.org/amp4ads-v0.js"}}}, + {Key: "src", Val: "https://cdn.ampproject.org/amp4ads-v0.js"}}}, false, }, { @@ -183,8 +201,30 @@ func TestIsScriptAMPRuntime(t *testing.T) { DataAtom: atom.Script, Attr: []html.Attribute{ {Key: "async"}, - {Key: "src", - Val: "https://cdn.ampproject.org/amp4ads-v0.js"}}}, + {Key: "src", Val: "https://cdn.ampproject.org/amp4ads-v0.js"}}}, + true, + }, + { + "amp4ads runtime module true", + &html.Node{Type: html.ElementNode, + Data: "script", + DataAtom: atom.Script, + Attr: []html.Attribute{ + {Key: "async"}, + {Key: "crossorigin", Val: "anonymous"}, + {Key: "src", Val: "https://cdn.ampproject.org/amp4ads-v0.mjs"}, + {Key: "type", Val: "module"}}}, + true, + }, + { + "amp4ads runtime nomodule true", + &html.Node{Type: html.ElementNode, + Data: "script", + DataAtom: atom.Script, + Attr: []html.Attribute{ + {Key: "async"}, + {Key: "nomodule"}, + {Key: "src", Val: "https://cdn.ampproject.org/amp4ads-v0.js"}}}, true, }, { From 684426cfb5acac64648b2ff80ec0b89a183d9c94 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 17 Mar 2021 15:31:06 -0700 Subject: [PATCH 05/20] Copy optional crossorigin attribute to PiperOrigin-RevId: 363521960 --- transformer/transformer.go | 6 +++++- transformer/transformer_test.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/transformer/transformer.go b/transformer/transformer.go index 820af6e51..51d6244f4 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -211,7 +211,11 @@ func extractPreloads(dom *amphtml.DOM) []*rpb.Metadata_Preload { switch current.DataAtom { case atom.Script: if src, ok := htmlnode.GetAttributeVal(current, "", "src"); ok { - preloads = append(preloads, &rpb.Metadata_Preload{Url: src, As: "script"}) + preload := &rpb.Metadata_Preload{Url: src, As: "script"} + if crossorigin, ok := htmlnode.GetAttributeVal(current, "", "crossorigin"); ok && crossorigin != "" { + preload.Attributes = append(preload.Attributes, &rpb.Metadata_Preload_Attribute{Key: "crossorigin", Val: crossorigin}) + } + preloads = append(preloads, preload) } case atom.Link: if rel, ok := htmlnode.GetAttributeVal(current, "", "rel"); ok { diff --git a/transformer/transformer_test.go b/transformer/transformer_test.go index bc68f42a2..d116d1b39 100644 --- a/transformer/transformer_test.go +++ b/transformer/transformer_test.go @@ -80,6 +80,11 @@ func TestPreloads(t *testing.T) { "", []*rpb.Metadata_Preload{}, }, + { + "", + []*rpb.Metadata_Preload{{Url: "foo", As: "script", Attributes: []*rpb.Metadata_Preload_Attribute{{Key: "crossorigin", Val: "anonymous"}}}}, + }, { "", From 8e2622daa536d5d49dbb6c80f39cbffe65053f72 Mon Sep 17 00:00:00 2001 From: honeybadgerdontcare Date: Thu, 18 Mar 2021 16:21:58 -0700 Subject: [PATCH 06/20] Update reorderhead to allow for regular scripts, module scripts and nomodule scripts. PiperOrigin-RevId: 363771272 --- transformer/internal/amphtml/amphtml.go | 26 ++++++++++- transformer/internal/amphtml/amphtml_test.go | 34 +++++++++++++++ transformer/internal/testing/testing.go | 30 +++++++++++++ transformer/transformers/reorderhead.go | 20 ++++----- transformer/transformers/reorderhead_test.go | 46 ++++++++++++++++++++ 5 files changed, 144 insertions(+), 12 deletions(-) diff --git a/transformer/internal/amphtml/amphtml.go b/transformer/internal/amphtml/amphtml.go index 0d874be35..c12555f5a 100644 --- a/transformer/internal/amphtml/amphtml.go +++ b/transformer/internal/amphtml/amphtml.go @@ -15,6 +15,7 @@ package amphtml import ( + "regexp" "strings" "github.com/ampproject/amppackager/transformer/internal/htmlnode" @@ -69,6 +70,29 @@ func IsAMPCustomElement(n *html.Node) bool { return n.Type == html.ElementNode && strings.HasPrefix(n.Data, "amp-") } +var srcURLRE = regexp.MustCompile( + `^https://cdn\.ampproject\.org` + + `(?:/lts)?` + + `/v0/` + + `(?Pamp-[a-z0-9-]*-[a-z0-9.]*\.m?js)` + + `(?:\?f=sxg)?$`) + +// AMPExtensionScriptDefinition returns a unique script definition that takes into account the extension name, version and if it is module/nomodule. Example (amp-ad): amp-ad-0.1.js (regular/nomodule), amp-ad-0.1.mjs (module). The AMP Validator prevents a mix of regular and nomodule extensions. If the pattern is not found then uses value of "src" attribute. Returns ok=false if this isn't an extension. +func AMPExtensionScriptDefinition(n *html.Node) (string, bool) { + if n.DataAtom != atom.Script { + return "", false + } + src, hasSrc := htmlnode.GetAttributeVal(n, "", "src") + if hasSrc { + m := srcURLRE.FindStringSubmatch(src) + if len(m) < 2 { + return src, true + } + return m[1], true + } + return "", false +} + // AMPExtensionName returns the name of the extension this node represents. For most extensions this is the value of the "custom-element" attribute. Returns ok=false if this isn't an extension. func AMPExtensionName(n *html.Node) (string, bool) { if n.DataAtom != atom.Script { @@ -100,7 +124,7 @@ func IsScriptAMPRuntime(n *html.Node) bool { !IsScriptAMPExtension(n) && strings.HasPrefix(v, AMPCacheRootURL) && (strings.HasSuffix(v, "/v0.js") || - strings.HasSuffix(v, "v0.mjs") || + strings.HasSuffix(v, "/v0.mjs") || strings.HasSuffix(v, "/amp4ads-v0.js") || strings.HasSuffix(v, "/amp4ads-v0.mjs")) } diff --git a/transformer/internal/amphtml/amphtml_test.go b/transformer/internal/amphtml/amphtml_test.go index 2c7d8d7fb..c8a252ad3 100644 --- a/transformer/internal/amphtml/amphtml_test.go +++ b/transformer/internal/amphtml/amphtml_test.go @@ -320,6 +320,40 @@ func TestIsScriptRenderDelaying(t *testing.T) { } } +func TestAMPExtensionScriptDefinition(t *testing.T) { + tcs := []struct { + desc string + n *html.Node + expected string + }{ + { + "amp-ad script", + &html.Node{Type: html.ElementNode, Data: "script", DataAtom: atom.Script, Attr: []html.Attribute{{Key: "async"}, {Key: "custom-element", Val: "amp-ad"}, {Key: "src", Val: "https://cdn.ampproject.org/v0/amp-ad-0.1.js"}}}, + "amp-ad-0.1.js", + }, + { + "amp-ad module script", + &html.Node{Type: html.ElementNode, Data: "script", DataAtom: atom.Script, Attr: []html.Attribute{{Key: "async"}, {Key: "custom-element", Val: "amp-ad"}, {Key: "src", Val: "https://cdn.ampproject.org/v0/amp-ad-0.1.mjs"}, {Key: "type", Val: "module"}}}, + "amp-ad-0.1.mjs", + }, + { + "amp-ad nomodule script", + &html.Node{Type: html.ElementNode, Data: "script", DataAtom: atom.Script, Attr: []html.Attribute{{Key: "async"}, {Key: "custom-element", Val: "amp-ad"}, {Key: "nomodule"}, {Key: "src", Val: "https://cdn.ampproject.org/v0/amp-ad-0.1.js"}}}, + "amp-ad-0.1.js", + }, + { + "runtime script", + &html.Node{Type: html.ElementNode, Data: "script", DataAtom: atom.Script, Attr: []html.Attribute{{Key: "async"}, {Key: "src", Val: "https://cdn.ampproject.org/v0.js"}}}, + "https://cdn.ampproject.org/v0.js", + }, + } + for _, tc := range tcs { + if r, _ := AMPExtensionScriptDefinition(tc.n); r != tc.expected { + t.Errorf("%s: AMPExtensionScriptDefinition()=%s want=%s", tc.desc, r, tc.expected) + } + } +} + func TestNewDOM(t *testing.T) { tcs := []struct { desc string diff --git a/transformer/internal/testing/testing.go b/transformer/internal/testing/testing.go index b78a03ebd..d5393beef 100644 --- a/transformer/internal/testing/testing.go +++ b/transformer/internal/testing/testing.go @@ -78,24 +78,54 @@ const ( // ScriptAMPAudio is the script for amp-audio. ScriptAMPAudio = "" + // ScriptAMPAudioModule is the module script for amp-audio. + ScriptAMPAudioModule = "" + + // ScriptAMPAudioNomodule is the nomodule script for amp-audio. + ScriptAMPAudioNomodule = "" + // ScriptAMPDynamicCSSClasses is the script for amp-dynamic-css-class. ScriptAMPDynamicCSSClasses = "" // ScriptAMPExperiment is the script for amp-experiment. ScriptAMPExperiment = "" + // ScriptAMPExperimentModule is the module script for amp-experiment. + ScriptAMPExperimentModule = "" + + // ScriptAMPExperimentNomodule is the nomodule script for amp-experiment. + ScriptAMPExperimentNomodule = "" + // ScriptAMPForm is the script for amp-form. ScriptAMPForm = "" // ScriptAMPMraid is the script for amp-mraid. ScriptAMPMraid = "" + // ScriptAMPMraidModule is the module script for amp-mraid. + ScriptAMPMraidModule = "" + + // ScriptAMPMraidNomodule is the nomodule script for amp-mraid. + ScriptAMPMraidNomodule = "" + // ScriptAMPMustache is the script for amp-mustache. ScriptAMPMustache = "" + // ScriptAMPMustacheModule is the module script for amp-mustache. + ScriptAMPMustacheModule = "" + + // ScriptAMPMustacheNomodule is the nomodule script for amp-mustache. + ScriptAMPMustacheNomodule = "" + // ScriptAMPRuntime is the AMP script tag. ScriptAMPRuntime = "" + // ScriptAMPRuntimeModule is the AMP module script tag. + ScriptAMPRuntimeModule = "" + + // ScriptAMPRuntimeNomodule is the AMP nomodule script tag. + ScriptAMPRuntimeNomodule = "" + // ScriptAMPViewerRuntime is the AMP viewer runtime script tag. ScriptAMPViewerRuntime = "" diff --git a/transformer/transformers/reorderhead.go b/transformer/transformers/reorderhead.go index 973d0ce8a..d643d6a8b 100644 --- a/transformer/transformers/reorderhead.go +++ b/transformer/transformers/reorderhead.go @@ -33,7 +33,7 @@ type headNodes struct { metaOther []*html.Node noscript *html.Node other []*html.Node - scriptAMPRuntime *html.Node + scriptAMPRuntime []*html.Node scriptAMPViewer *html.Node scriptNonRenderDelaying []*html.Node scriptRenderDelaying []*html.Node @@ -47,7 +47,7 @@ type headNodes struct { // (0) tag // (1) ", + ""), + rtv: "", + css: "", + }, { desc: "no css", input: "", expected: tt.Concat("", - "", + "", ""), + rtv: "0142", css: "", }, { desc: "inline css", input: "", expected: tt.Concat("", - "", + "", ""), + rtv: "0142", css: "CSS contents to inline", }, { desc: "inline trimmed css", input: "", expected: tt.Concat("", - "", + "", ""), + rtv: "0142", css: " \t\n CSS contents to inline \n\t\r\n", }, { - desc: "removes existing ", + "", + ""), + expected: tt.Concat("", + "", + "", + ""), + rtv: "0142", + css: "", + }, + { + desc: "keeps existing ", + "", + ""), + expected: tt.Concat("", + "", + "", + ""), + rtv: "0142", + css: "CSS contents to inline", + }, + { + desc: "removes existing ", + "", + ""), + expected: tt.Concat("", + "", + ""), + rtv: "0142", + css: "CSS contents to inline", + }, + { + desc: "removes existing ", - "", + "", + "", ""), expected: tt.Concat("", - "", + "", ""), + rtv: "0142", css: "CSS contents to inline", }, } @@ -75,7 +126,7 @@ func TestAMPRuntimeCSS(t *testing.T) { t.Errorf("%s\namphtml.NewDOM for %s failed %q", tc.desc, tc.input, err) continue } - transformers.AMPRuntimeCSS(&transformers.Context{DOM: inputDOM, Request: &rpb.Request{Rtv: "42", Css: tc.css}}) + transformers.AMPRuntimeCSS(&transformers.Context{DOM: inputDOM, Request: &rpb.Request{Rtv: tc.rtv, Css: tc.css}}) var input strings.Builder if err := html.Render(&input, inputDoc); err != nil { t.Errorf("%s: html.Render on %s failed %q", tc.desc, tc.input, err) From 8fbd1a7cddc23f50e23e84f1c40af7967d1fb1dd Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Mon, 19 Apr 2021 13:25:17 -0700 Subject: [PATCH 17/20] When there is at least one module on the page, extract only modulepreloads. A future commit will format this properly in signer.go. PiperOrigin-RevId: 369289290 --- transformer/request/request.pb.go | 773 +++++++++++------------------- transformer/request/request.proto | 3 + transformer/transformer.go | 24 +- transformer/transformer_test.go | 7 +- 4 files changed, 303 insertions(+), 504 deletions(-) diff --git a/transformer/request/request.pb.go b/transformer/request/request.pb.go index 7dc83d779..3b626146f 100644 --- a/transformer/request/request.pb.go +++ b/transformer/request/request.pb.go @@ -1,38 +1,24 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 // source: transformer/request/request.proto package request import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" ) -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // This should be kept in sync with HtmlFormat.Code in // github.com/ampproject/amphtml/validator/validator.proto. @@ -41,56 +27,35 @@ const ( type Request_HtmlFormat int32 const ( - Request_UNKNOWN_CODE Request_HtmlFormat = 0 // Never used + Request_UNKNOWN_CODE Request_HtmlFormat = 0 Request_AMP Request_HtmlFormat = 1 Request_AMP4ADS Request_HtmlFormat = 2 Request_AMP4EMAIL Request_HtmlFormat = 3 - Request_EXPERIMENTAL Request_HtmlFormat = 4 // Currently unused + Request_EXPERIMENTAL Request_HtmlFormat = 4 ) -// Enum value maps for Request_HtmlFormat. -var ( - Request_HtmlFormat_name = map[int32]string{ - 0: "UNKNOWN_CODE", - 1: "AMP", - 2: "AMP4ADS", - 3: "AMP4EMAIL", - 4: "EXPERIMENTAL", - } - Request_HtmlFormat_value = map[string]int32{ - "UNKNOWN_CODE": 0, - "AMP": 1, - "AMP4ADS": 2, - "AMP4EMAIL": 3, - "EXPERIMENTAL": 4, - } -) - -func (x Request_HtmlFormat) Enum() *Request_HtmlFormat { - p := new(Request_HtmlFormat) - *p = x - return p -} - -func (x Request_HtmlFormat) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Request_HtmlFormat) Descriptor() protoreflect.EnumDescriptor { - return file_transformer_request_request_proto_enumTypes[0].Descriptor() +var Request_HtmlFormat_name = map[int32]string{ + 0: "UNKNOWN_CODE", + 1: "AMP", + 2: "AMP4ADS", + 3: "AMP4EMAIL", + 4: "EXPERIMENTAL", } -func (Request_HtmlFormat) Type() protoreflect.EnumType { - return &file_transformer_request_request_proto_enumTypes[0] +var Request_HtmlFormat_value = map[string]int32{ + "UNKNOWN_CODE": 0, + "AMP": 1, + "AMP4ADS": 2, + "AMP4EMAIL": 3, + "EXPERIMENTAL": 4, } -func (x Request_HtmlFormat) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) +func (x Request_HtmlFormat) String() string { + return proto.EnumName(Request_HtmlFormat_name, int32(x)) } -// Deprecated: Use Request_HtmlFormat.Descriptor instead. func (Request_HtmlFormat) EnumDescriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{0, 0} + return fileDescriptor_762cce2ac5f73405, []int{0, 0} } type Request_TransformersConfig int32 @@ -125,56 +90,31 @@ const ( Request_CUSTOM Request_TransformersConfig = 3 ) -// Enum value maps for Request_TransformersConfig. -var ( - Request_TransformersConfig_name = map[int32]string{ - 0: "DEFAULT", - 1: "NONE", - 2: "VALIDATION", - 3: "CUSTOM", - } - Request_TransformersConfig_value = map[string]int32{ - "DEFAULT": 0, - "NONE": 1, - "VALIDATION": 2, - "CUSTOM": 3, - } -) - -func (x Request_TransformersConfig) Enum() *Request_TransformersConfig { - p := new(Request_TransformersConfig) - *p = x - return p -} - -func (x Request_TransformersConfig) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Request_TransformersConfig) Descriptor() protoreflect.EnumDescriptor { - return file_transformer_request_request_proto_enumTypes[1].Descriptor() +var Request_TransformersConfig_name = map[int32]string{ + 0: "DEFAULT", + 1: "NONE", + 2: "VALIDATION", + 3: "CUSTOM", } -func (Request_TransformersConfig) Type() protoreflect.EnumType { - return &file_transformer_request_request_proto_enumTypes[1] +var Request_TransformersConfig_value = map[string]int32{ + "DEFAULT": 0, + "NONE": 1, + "VALIDATION": 2, + "CUSTOM": 3, } -func (x Request_TransformersConfig) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) +func (x Request_TransformersConfig) String() string { + return proto.EnumName(Request_TransformersConfig_name, int32(x)) } -// Deprecated: Use Request_TransformersConfig.Descriptor instead. func (Request_TransformersConfig) EnumDescriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{0, 1} + return fileDescriptor_762cce2ac5f73405, []int{0, 1} } // A Request encapsulates input and contextual parameters for use by the // transformers. type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - // The AMP HTML document to transform. Html string `protobuf:"bytes,1,opt,name=html,proto3" json:"html,omitempty"` // The public URL of the document, i.e. the location that should appear in @@ -194,149 +134,137 @@ type Request struct { Transformers []string `protobuf:"bytes,3,rep,name=transformers,proto3" json:"transformers,omitempty"` // The version of the transforms to perform (optional). If specified, it must // be a supported version. - Version int64 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"` + Version int64 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_transformer_request_request_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_762cce2ac5f73405, []int{0} } -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) +func (m *Request) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Request.Unmarshal(m, b) } - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_transformer_request_request_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) } - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{0} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return xxx_messageInfo_Request.Size(m) } +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo -func (x *Request) GetHtml() string { - if x != nil { - return x.Html +func (m *Request) GetHtml() string { + if m != nil { + return m.Html } return "" } -func (x *Request) GetDocumentUrl() string { - if x != nil { - return x.DocumentUrl +func (m *Request) GetDocumentUrl() string { + if m != nil { + return m.DocumentUrl } return "" } -func (x *Request) GetRtv() string { - if x != nil { - return x.Rtv +func (m *Request) GetRtv() string { + if m != nil { + return m.Rtv } return "" } -func (x *Request) GetCss() string { - if x != nil { - return x.Css +func (m *Request) GetCss() string { + if m != nil { + return m.Css } return "" } -func (x *Request) GetAllowedFormats() []Request_HtmlFormat { - if x != nil { - return x.AllowedFormats +func (m *Request) GetAllowedFormats() []Request_HtmlFormat { + if m != nil { + return m.AllowedFormats } return nil } -func (x *Request) GetConfig() Request_TransformersConfig { - if x != nil { - return x.Config +func (m *Request) GetConfig() Request_TransformersConfig { + if m != nil { + return m.Config } return Request_DEFAULT } -func (x *Request) GetTransformers() []string { - if x != nil { - return x.Transformers +func (m *Request) GetTransformers() []string { + if m != nil { + return m.Transformers } return nil } -func (x *Request) GetVersion() int64 { - if x != nil { - return x.Version +func (m *Request) GetVersion() int64 { + if m != nil { + return m.Version } return 0 } // An inclusive range of version numbers. type VersionRange struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Min int64 `protobuf:"varint,1,opt,name=min,proto3" json:"min,omitempty"` - Max int64 `protobuf:"varint,2,opt,name=max,proto3" json:"max,omitempty"` + Min int64 `protobuf:"varint,1,opt,name=min,proto3" json:"min,omitempty"` + Max int64 `protobuf:"varint,2,opt,name=max,proto3" json:"max,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *VersionRange) Reset() { - *x = VersionRange{} - if protoimpl.UnsafeEnabled { - mi := &file_transformer_request_request_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (m *VersionRange) Reset() { *m = VersionRange{} } +func (m *VersionRange) String() string { return proto.CompactTextString(m) } +func (*VersionRange) ProtoMessage() {} +func (*VersionRange) Descriptor() ([]byte, []int) { + return fileDescriptor_762cce2ac5f73405, []int{1} } -func (x *VersionRange) String() string { - return protoimpl.X.MessageStringOf(x) +func (m *VersionRange) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VersionRange.Unmarshal(m, b) } - -func (*VersionRange) ProtoMessage() {} - -func (x *VersionRange) ProtoReflect() protoreflect.Message { - mi := &file_transformer_request_request_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (m *VersionRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VersionRange.Marshal(b, m, deterministic) } - -// Deprecated: Use VersionRange.ProtoReflect.Descriptor instead. -func (*VersionRange) Descriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{1} +func (m *VersionRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_VersionRange.Merge(m, src) +} +func (m *VersionRange) XXX_Size() int { + return xxx_messageInfo_VersionRange.Size(m) } +func (m *VersionRange) XXX_DiscardUnknown() { + xxx_messageInfo_VersionRange.DiscardUnknown(m) +} + +var xxx_messageInfo_VersionRange proto.InternalMessageInfo -func (x *VersionRange) GetMin() int64 { - if x != nil { - return x.Min +func (m *VersionRange) GetMin() int64 { + if m != nil { + return m.Min } return 0 } -func (x *VersionRange) GetMax() int64 { - if x != nil { - return x.Max +func (m *VersionRange) GetMax() int64 { + if m != nil { + return m.Max } return 0 } @@ -347,10 +275,6 @@ func (x *VersionRange) GetMax() int64 { // serialization/deserialization round-trip when the Go library is called from // C. type Metadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - // Absolute URLs of resources that should be preloaded when the AMP is // prefetched. In a signed exchange (SXG) context, these would be included as // `Link: rel=preload` headers, as these are used by the browser during SXG @@ -361,60 +285,52 @@ type Metadata struct { // based on the content being signed. In particular, JS is given a shorter // lifetime to reduce risk of issues due to downgrades: // https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html#seccons-downgrades. - MaxAgeSecs int32 `protobuf:"varint,2,opt,name=max_age_secs,json=maxAgeSecs,proto3" json:"max_age_secs,omitempty"` + MaxAgeSecs int32 `protobuf:"varint,2,opt,name=max_age_secs,json=maxAgeSecs,proto3" json:"max_age_secs,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *Metadata) Reset() { - *x = Metadata{} - if protoimpl.UnsafeEnabled { - mi := &file_transformer_request_request_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_762cce2ac5f73405, []int{2} } -func (x *Metadata) String() string { - return protoimpl.X.MessageStringOf(x) +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Metadata.Unmarshal(m, b) } - -func (*Metadata) ProtoMessage() {} - -func (x *Metadata) ProtoReflect() protoreflect.Message { - mi := &file_transformer_request_request_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) } - -// Deprecated: Use Metadata.ProtoReflect.Descriptor instead. -func (*Metadata) Descriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{2} +func (m *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return xxx_messageInfo_Metadata.Size(m) } +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo -func (x *Metadata) GetPreloads() []*Metadata_Preload { - if x != nil { - return x.Preloads +func (m *Metadata) GetPreloads() []*Metadata_Preload { + if m != nil { + return m.Preloads } return nil } -func (x *Metadata) GetMaxAgeSecs() int32 { - if x != nil { - return x.MaxAgeSecs +func (m *Metadata) GetMaxAgeSecs() int32 { + if m != nil { + return m.MaxAgeSecs } return 0 } type Metadata_Preload struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - // The URL of the resource to preload. Will be an absolute URL on the domain // of the target AMP cache. Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` @@ -427,313 +343,176 @@ type Metadata_Preload struct { As string `protobuf:"bytes,2,opt,name=as,proto3" json:"as,omitempty"` // The media attribute for image preload link. This attribute is useful // only for image links. Deprecated, instead use the `attributes` field. - // - // Deprecated: Do not use. - Media string `protobuf:"bytes,3,opt,name=media,proto3" json:"media,omitempty"` + Media string `protobuf:"bytes,3,opt,name=media,proto3" json:"media,omitempty"` // Deprecated: Do not use. // Optional remaining attributes. This does not include the `href` or `as` // attributes. Attributes []*Metadata_Preload_Attribute `protobuf:"bytes,4,rep,name=attributes,proto3" json:"attributes,omitempty"` + // If true, this is a modulepreload instead of a preload. + Module bool `protobuf:"varint,5,opt,name=module,proto3" json:"module,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *Metadata_Preload) Reset() { - *x = Metadata_Preload{} - if protoimpl.UnsafeEnabled { - mi := &file_transformer_request_request_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (m *Metadata_Preload) Reset() { *m = Metadata_Preload{} } +func (m *Metadata_Preload) String() string { return proto.CompactTextString(m) } +func (*Metadata_Preload) ProtoMessage() {} +func (*Metadata_Preload) Descriptor() ([]byte, []int) { + return fileDescriptor_762cce2ac5f73405, []int{2, 0} } -func (x *Metadata_Preload) String() string { - return protoimpl.X.MessageStringOf(x) +func (m *Metadata_Preload) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Metadata_Preload.Unmarshal(m, b) } - -func (*Metadata_Preload) ProtoMessage() {} - -func (x *Metadata_Preload) ProtoReflect() protoreflect.Message { - mi := &file_transformer_request_request_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (m *Metadata_Preload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Metadata_Preload.Marshal(b, m, deterministic) } - -// Deprecated: Use Metadata_Preload.ProtoReflect.Descriptor instead. -func (*Metadata_Preload) Descriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{2, 0} +func (m *Metadata_Preload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata_Preload.Merge(m, src) } +func (m *Metadata_Preload) XXX_Size() int { + return xxx_messageInfo_Metadata_Preload.Size(m) +} +func (m *Metadata_Preload) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata_Preload.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata_Preload proto.InternalMessageInfo -func (x *Metadata_Preload) GetUrl() string { - if x != nil { - return x.Url +func (m *Metadata_Preload) GetUrl() string { + if m != nil { + return m.Url } return "" } -func (x *Metadata_Preload) GetAs() string { - if x != nil { - return x.As +func (m *Metadata_Preload) GetAs() string { + if m != nil { + return m.As } return "" } // Deprecated: Do not use. -func (x *Metadata_Preload) GetMedia() string { - if x != nil { - return x.Media +func (m *Metadata_Preload) GetMedia() string { + if m != nil { + return m.Media } return "" } -func (x *Metadata_Preload) GetAttributes() []*Metadata_Preload_Attribute { - if x != nil { - return x.Attributes +func (m *Metadata_Preload) GetAttributes() []*Metadata_Preload_Attribute { + if m != nil { + return m.Attributes } return nil } -type Metadata_Preload_Attribute struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"` -} - -func (x *Metadata_Preload_Attribute) Reset() { - *x = Metadata_Preload_Attribute{} - if protoimpl.UnsafeEnabled { - mi := &file_transformer_request_request_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (m *Metadata_Preload) GetModule() bool { + if m != nil { + return m.Module } + return false } -func (x *Metadata_Preload_Attribute) String() string { - return protoimpl.X.MessageStringOf(x) +type Metadata_Preload_Attribute struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (*Metadata_Preload_Attribute) ProtoMessage() {} - -func (x *Metadata_Preload_Attribute) ProtoReflect() protoreflect.Message { - mi := &file_transformer_request_request_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (m *Metadata_Preload_Attribute) Reset() { *m = Metadata_Preload_Attribute{} } +func (m *Metadata_Preload_Attribute) String() string { return proto.CompactTextString(m) } +func (*Metadata_Preload_Attribute) ProtoMessage() {} +func (*Metadata_Preload_Attribute) Descriptor() ([]byte, []int) { + return fileDescriptor_762cce2ac5f73405, []int{2, 0, 0} } -// Deprecated: Use Metadata_Preload_Attribute.ProtoReflect.Descriptor instead. -func (*Metadata_Preload_Attribute) Descriptor() ([]byte, []int) { - return file_transformer_request_request_proto_rawDescGZIP(), []int{2, 0, 0} +func (m *Metadata_Preload_Attribute) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Metadata_Preload_Attribute.Unmarshal(m, b) +} +func (m *Metadata_Preload_Attribute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Metadata_Preload_Attribute.Marshal(b, m, deterministic) +} +func (m *Metadata_Preload_Attribute) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata_Preload_Attribute.Merge(m, src) +} +func (m *Metadata_Preload_Attribute) XXX_Size() int { + return xxx_messageInfo_Metadata_Preload_Attribute.Size(m) +} +func (m *Metadata_Preload_Attribute) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata_Preload_Attribute.DiscardUnknown(m) } -func (x *Metadata_Preload_Attribute) GetKey() string { - if x != nil { - return x.Key +var xxx_messageInfo_Metadata_Preload_Attribute proto.InternalMessageInfo + +func (m *Metadata_Preload_Attribute) GetKey() string { + if m != nil { + return m.Key } return "" } -func (x *Metadata_Preload_Attribute) GetVal() string { - if x != nil { - return x.Val +func (m *Metadata_Preload_Attribute) GetVal() string { + if m != nil { + return m.Val } return "" } -var File_transformer_request_request_proto protoreflect.FileDescriptor - -var file_transformer_request_request_proto_rawDesc = []byte{ - 0x0a, 0x21, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x2f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x61, 0x6d, 0x70, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, - 0x72, 0x6d, 0x22, 0xd1, 0x03, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x68, 0x74, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x74, - 0x6d, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x75, - 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x74, 0x76, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x72, 0x74, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x73, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x73, 0x73, 0x12, 0x4a, 0x0a, 0x0f, 0x61, 0x6c, 0x6c, - 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, - 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x61, 0x6d, 0x70, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, - 0x72, 0x6d, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x48, 0x74, 0x6d, 0x6c, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x52, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x46, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x61, 0x6d, 0x70, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x55, 0x0a, 0x0a, 0x48, 0x74, 0x6d, 0x6c, 0x46, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x0c, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, - 0x43, 0x4f, 0x44, 0x45, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4d, 0x50, 0x10, 0x01, 0x12, - 0x0b, 0x0a, 0x07, 0x41, 0x4d, 0x50, 0x34, 0x41, 0x44, 0x53, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, - 0x41, 0x4d, 0x50, 0x34, 0x45, 0x4d, 0x41, 0x49, 0x4c, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x45, - 0x58, 0x50, 0x45, 0x52, 0x49, 0x4d, 0x45, 0x4e, 0x54, 0x41, 0x4c, 0x10, 0x04, 0x22, 0x47, 0x0a, - 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, - 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x56, 0x41, - 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x55, - 0x53, 0x54, 0x4f, 0x4d, 0x10, 0x03, 0x22, 0x32, 0x0a, 0x0c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x03, 0x6d, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6d, 0x61, 0x78, 0x22, 0xad, 0x02, 0x0a, 0x08, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x6c, 0x6f, - 0x61, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x61, 0x6d, 0x70, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x50, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x08, 0x70, 0x72, 0x65, 0x6c, - 0x6f, 0x61, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x61, 0x67, 0x65, 0x5f, - 0x73, 0x65, 0x63, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x41, - 0x67, 0x65, 0x53, 0x65, 0x63, 0x73, 0x1a, 0xc1, 0x01, 0x0a, 0x07, 0x50, 0x72, 0x65, 0x6c, 0x6f, - 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x72, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x61, 0x73, 0x12, 0x18, 0x0a, 0x05, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x05, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x12, 0x49, - 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x61, 0x6d, 0x70, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, - 0x72, 0x6d, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x72, 0x65, 0x6c, - 0x6f, 0x61, 0x64, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x52, 0x0a, 0x61, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x1a, 0x2f, 0x0a, 0x09, 0x41, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x6d, 0x70, 0x70, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x2f, 0x61, 0x6d, 0x70, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x72, 0x2f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x65, 0x72, 0x2f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_transformer_request_request_proto_rawDescOnce sync.Once - file_transformer_request_request_proto_rawDescData = file_transformer_request_request_proto_rawDesc -) - -func file_transformer_request_request_proto_rawDescGZIP() []byte { - file_transformer_request_request_proto_rawDescOnce.Do(func() { - file_transformer_request_request_proto_rawDescData = protoimpl.X.CompressGZIP(file_transformer_request_request_proto_rawDescData) - }) - return file_transformer_request_request_proto_rawDescData -} - -var file_transformer_request_request_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_transformer_request_request_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_transformer_request_request_proto_goTypes = []interface{}{ - (Request_HtmlFormat)(0), // 0: amp.transform.Request.HtmlFormat - (Request_TransformersConfig)(0), // 1: amp.transform.Request.TransformersConfig - (*Request)(nil), // 2: amp.transform.Request - (*VersionRange)(nil), // 3: amp.transform.VersionRange - (*Metadata)(nil), // 4: amp.transform.Metadata - (*Metadata_Preload)(nil), // 5: amp.transform.Metadata.Preload - (*Metadata_Preload_Attribute)(nil), // 6: amp.transform.Metadata.Preload.Attribute -} -var file_transformer_request_request_proto_depIdxs = []int32{ - 0, // 0: amp.transform.Request.allowed_formats:type_name -> amp.transform.Request.HtmlFormat - 1, // 1: amp.transform.Request.config:type_name -> amp.transform.Request.TransformersConfig - 5, // 2: amp.transform.Metadata.preloads:type_name -> amp.transform.Metadata.Preload - 6, // 3: amp.transform.Metadata.Preload.attributes:type_name -> amp.transform.Metadata.Preload.Attribute - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_transformer_request_request_proto_init() } -func file_transformer_request_request_proto_init() { - if File_transformer_request_request_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_transformer_request_request_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transformer_request_request_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionRange); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transformer_request_request_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transformer_request_request_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metadata_Preload); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transformer_request_request_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metadata_Preload_Attribute); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_transformer_request_request_proto_rawDesc, - NumEnums: 2, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transformer_request_request_proto_goTypes, - DependencyIndexes: file_transformer_request_request_proto_depIdxs, - EnumInfos: file_transformer_request_request_proto_enumTypes, - MessageInfos: file_transformer_request_request_proto_msgTypes, - }.Build() - File_transformer_request_request_proto = out.File - file_transformer_request_request_proto_rawDesc = nil - file_transformer_request_request_proto_goTypes = nil - file_transformer_request_request_proto_depIdxs = nil +func init() { + proto.RegisterEnum("amp.transform.Request_HtmlFormat", Request_HtmlFormat_name, Request_HtmlFormat_value) + proto.RegisterEnum("amp.transform.Request_TransformersConfig", Request_TransformersConfig_name, Request_TransformersConfig_value) + proto.RegisterType((*Request)(nil), "amp.transform.Request") + proto.RegisterType((*VersionRange)(nil), "amp.transform.VersionRange") + proto.RegisterType((*Metadata)(nil), "amp.transform.Metadata") + proto.RegisterType((*Metadata_Preload)(nil), "amp.transform.Metadata.Preload") + proto.RegisterType((*Metadata_Preload_Attribute)(nil), "amp.transform.Metadata.Preload.Attribute") +} + +func init() { + proto.RegisterFile("transformer/request/request.proto", fileDescriptor_762cce2ac5f73405) +} + +var fileDescriptor_762cce2ac5f73405 = []byte{ + // 583 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcd, 0x72, 0xda, 0x3c, + 0x14, 0x8d, 0x2d, 0xc2, 0xcf, 0x0d, 0xe1, 0xf3, 0x68, 0xf1, 0x8d, 0x26, 0x9b, 0x3a, 0xac, 0xc8, + 0xc6, 0xcc, 0xd0, 0x76, 0xba, 0xe8, 0xca, 0x09, 0x4e, 0x4b, 0x0b, 0x86, 0x51, 0x20, 0xed, 0x74, + 0xc3, 0x28, 0x46, 0x21, 0x34, 0x16, 0xa6, 0x92, 0x48, 0xc9, 0x03, 0xf6, 0x01, 0xba, 0xec, 0xdb, + 0x74, 0x24, 0x63, 0x92, 0xf4, 0x67, 0xba, 0xd2, 0xb9, 0x47, 0xf7, 0x48, 0x67, 0xee, 0x0f, 0x1c, + 0x6b, 0xc9, 0x96, 0xea, 0x3a, 0x93, 0x82, 0xcb, 0xb6, 0xe4, 0x5f, 0xd6, 0x5c, 0xe9, 0xe2, 0x0c, + 0x56, 0x32, 0xd3, 0x19, 0x3e, 0x64, 0x62, 0x15, 0xec, 0xd2, 0x9a, 0xdf, 0x11, 0x54, 0x68, 0x9e, + 0x80, 0x31, 0x94, 0x6e, 0xb4, 0x48, 0x89, 0xe3, 0x3b, 0xad, 0x1a, 0xb5, 0x18, 0x1f, 0x43, 0x7d, + 0x96, 0x25, 0x6b, 0xc1, 0x97, 0x7a, 0xba, 0x96, 0x29, 0x71, 0xed, 0xdd, 0x41, 0xc1, 0x4d, 0x64, + 0x8a, 0x3d, 0x40, 0x52, 0xdf, 0x91, 0x92, 0xbd, 0x31, 0xd0, 0x30, 0x89, 0x52, 0x64, 0x3f, 0x67, + 0x12, 0xa5, 0xf0, 0x3b, 0xf8, 0x8f, 0xa5, 0x69, 0xf6, 0x95, 0xcf, 0xa6, 0xe6, 0x5b, 0xa6, 0x15, + 0xa9, 0xf8, 0xa8, 0xd5, 0xe8, 0x1c, 0x07, 0x4f, 0xfc, 0x04, 0x5b, 0x2f, 0xc1, 0x5b, 0x2d, 0xd2, + 0x73, 0x9b, 0x49, 0x1b, 0x5b, 0x65, 0x1e, 0x2a, 0x1c, 0x42, 0x39, 0xc9, 0x96, 0xd7, 0x8b, 0x39, + 0x29, 0xfb, 0x4e, 0xab, 0xd1, 0x39, 0xf9, 0xcb, 0x13, 0xe3, 0x87, 0x5a, 0xa8, 0x33, 0x2b, 0xa0, + 0x5b, 0x21, 0x6e, 0x42, 0xfd, 0x51, 0xa5, 0x14, 0x41, 0x3e, 0x6a, 0xd5, 0xe8, 0x13, 0x0e, 0x13, + 0xa8, 0xdc, 0x71, 0xa9, 0x16, 0xd9, 0x92, 0x54, 0x7d, 0xa7, 0x85, 0x68, 0x11, 0x36, 0x27, 0x00, + 0x0f, 0xf6, 0xb0, 0x07, 0xf5, 0x49, 0xfc, 0x3e, 0x1e, 0x7e, 0x88, 0xa7, 0x67, 0xc3, 0x6e, 0xe4, + 0xed, 0xe1, 0x0a, 0xa0, 0x70, 0x30, 0xf2, 0x1c, 0x7c, 0x00, 0x95, 0x70, 0x30, 0x7a, 0x11, 0x76, + 0x2f, 0x3c, 0x17, 0x1f, 0x42, 0xcd, 0x04, 0xd1, 0x20, 0xec, 0xf5, 0x3d, 0x64, 0x64, 0xd1, 0xc7, + 0x51, 0x44, 0x7b, 0x83, 0x28, 0x1e, 0x87, 0x7d, 0xaf, 0xd4, 0x7c, 0x03, 0xf8, 0x77, 0xcb, 0xe6, + 0x8d, 0x6e, 0x74, 0x1e, 0x4e, 0xfa, 0x63, 0x6f, 0x0f, 0x57, 0xa1, 0x14, 0x0f, 0xe3, 0xc8, 0x73, + 0x70, 0x03, 0xe0, 0x32, 0xec, 0xf7, 0xba, 0xe1, 0xb8, 0x37, 0x8c, 0x3d, 0x17, 0x03, 0x94, 0xcf, + 0x26, 0x17, 0xe3, 0xe1, 0xc0, 0x43, 0xcd, 0x0e, 0xd4, 0x2f, 0x73, 0xab, 0x94, 0x2d, 0xe7, 0xdc, + 0xb4, 0x43, 0x2c, 0x96, 0xb6, 0xad, 0x88, 0x1a, 0x68, 0x19, 0xb6, 0xb1, 0xcd, 0x34, 0x0c, 0xdb, + 0x34, 0xbf, 0xb9, 0x50, 0x1d, 0x70, 0xcd, 0x66, 0x4c, 0x33, 0xfc, 0x1a, 0xaa, 0x2b, 0xc9, 0xd3, + 0x8c, 0xcd, 0x14, 0x71, 0x7c, 0xd4, 0x3a, 0xe8, 0x3c, 0xfb, 0xa5, 0xc6, 0x45, 0x6a, 0x30, 0xca, + 0xf3, 0xe8, 0x4e, 0x80, 0x7d, 0xa8, 0x0b, 0xb6, 0x99, 0xb2, 0x39, 0x9f, 0x2a, 0x9e, 0x28, 0xfb, + 0xc9, 0x3e, 0x05, 0xc1, 0x36, 0xe1, 0x9c, 0x5f, 0xf0, 0x44, 0x1d, 0xfd, 0x70, 0xa0, 0xb2, 0xd5, + 0x19, 0x27, 0x66, 0xac, 0xf2, 0x91, 0x33, 0x10, 0x37, 0xc0, 0x65, 0x6a, 0x3b, 0x67, 0x2e, 0x33, + 0x7d, 0xd8, 0x17, 0x7c, 0xb6, 0x60, 0x04, 0x19, 0xea, 0xd4, 0x25, 0x0e, 0xcd, 0x09, 0xdc, 0x03, + 0x60, 0x5a, 0xcb, 0xc5, 0xd5, 0x5a, 0x73, 0x45, 0x4a, 0xd6, 0xe8, 0xc9, 0x3f, 0x8c, 0x06, 0x61, + 0xa1, 0xa0, 0x8f, 0xc4, 0xf8, 0x7f, 0x28, 0x8b, 0x6c, 0xb6, 0x4e, 0xb9, 0x1d, 0xda, 0x2a, 0xdd, + 0x46, 0x47, 0x6d, 0xa8, 0xed, 0x04, 0xc6, 0xeb, 0x2d, 0xbf, 0x2f, 0xbc, 0xde, 0xf2, 0x7b, 0xc3, + 0xdc, 0xb1, 0x62, 0x29, 0x0c, 0x3c, 0x7d, 0xf5, 0xe9, 0xe5, 0x7c, 0xa1, 0x6f, 0xd6, 0x57, 0x41, + 0x92, 0x89, 0x36, 0x13, 0xab, 0x95, 0xcc, 0x3e, 0xf3, 0x44, 0x5b, 0xc8, 0x92, 0x5b, 0x36, 0xe7, + 0xb2, 0xfd, 0x87, 0x2d, 0xbd, 0x2a, 0xdb, 0xf5, 0x7c, 0xfe, 0x33, 0x00, 0x00, 0xff, 0xff, 0xa7, + 0x23, 0x3f, 0xb6, 0xc3, 0x03, 0x00, 0x00, } diff --git a/transformer/request/request.proto b/transformer/request/request.proto index 6db7d672f..4243ee12d 100644 --- a/transformer/request/request.proto +++ b/transformer/request/request.proto @@ -131,6 +131,9 @@ message Metadata { // Optional remaining attributes. This does not include the `href` or `as` // attributes. repeated Attribute attributes = 4; + + // If true, this is a modulepreload instead of a preload. + bool module = 5; } // Absolute URLs of resources that should be preloaded when the AMP is // prefetched. In a signed exchange (SXG) context, these would be included as diff --git a/transformer/transformer.go b/transformer/transformer.go index 51d6244f4..ad4072f18 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -202,19 +202,31 @@ func extractPreloads(dom *amphtml.DOM) []*rpb.Metadata_Preload { // If you add additional preloads here, verify that they can not be // unintentionally author supplied. preloads := []*rpb.Metadata_Preload{} - next := dom.HeadNode.FirstChild - for next != nil { - // Set the next node to visit - current := next - next = current.NextSibling - + // If there are any modules present, then we will skip preloads for non-module scripts. + hasModule := false + for current := dom.HeadNode.FirstChild; current != nil; current = current.NextSibling { + if current.DataAtom == atom.Script { + if scriptType, _ := htmlnode.GetAttributeVal(current, "", "type"); scriptType == "module" { + hasModule = true + break + } + } + } + for current := dom.HeadNode.FirstChild; current != nil; current = current.NextSibling { switch current.DataAtom { case atom.Script: if src, ok := htmlnode.GetAttributeVal(current, "", "src"); ok { + scriptType, _ := htmlnode.GetAttributeVal(current, "", "type") + if hasModule && scriptType != "module" { + continue + } preload := &rpb.Metadata_Preload{Url: src, As: "script"} if crossorigin, ok := htmlnode.GetAttributeVal(current, "", "crossorigin"); ok && crossorigin != "" { preload.Attributes = append(preload.Attributes, &rpb.Metadata_Preload_Attribute{Key: "crossorigin", Val: crossorigin}) } + if scriptType == "module" { + preload.Module = true + } preloads = append(preloads, preload) } case atom.Link: diff --git a/transformer/transformer_test.go b/transformer/transformer_test.go index d116d1b39..6a447e013 100644 --- a/transformer/transformer_test.go +++ b/transformer/transformer_test.go @@ -85,6 +85,11 @@ func TestPreloads(t *testing.T) { "", []*rpb.Metadata_Preload{{Url: "foo", As: "script", Attributes: []*rpb.Metadata_Preload_Attribute{{Key: "crossorigin", Val: "anonymous"}}}}, }, + { + "", + "", + []*rpb.Metadata_Preload{{Url: "mjs", As: "script", Attributes: []*rpb.Metadata_Preload_Attribute{{Key: "crossorigin", Val: "anonymous"}}, Module: true}}, + }, { "", @@ -169,7 +174,7 @@ func TestPreloads(t *testing.T) { t.Fatalf("unexpected failure: %v", err) } - if diff := diff.Diff(output, tc.expectedHTML); diff != "" { + if diff := diff.Diff(tc.expectedHTML, output); diff != "" { t.Errorf("html output differs (-want +got):\n%s", diff) } if diff := cmp.Diff(tc.expectedPreloads, metadata.Preloads, cmp.Comparer(proto.Equal)); diff != "" { From aeed17aad596fabf387bf897eac3695d113cad2c Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Mon, 19 Apr 2021 14:01:54 -0700 Subject: [PATCH 18/20] Format modulepreload links correctly. (#528) As introduced in commit 8fbd1a7c. --- packager/signer/signer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packager/signer/signer.go b/packager/signer/signer.go index 9a7347e3b..13a256f38 100644 --- a/packager/signer/signer.go +++ b/packager/signer/signer.go @@ -455,7 +455,13 @@ func formatLinkHeader(preloads []*rpb.Metadata_Preload) (string, error) { var value strings.Builder value.WriteByte('<') value.WriteString(u.String()) - value.WriteString(">;rel=preload;as=") + value.WriteString(">;rel=") + if preload.Module { + value.WriteString("modulepreload") + } else { + value.WriteString("preload") + } + value.WriteString(";as=") value.WriteString(preload.As) for _, attr := range preload.GetAttributes() { value.WriteByte(';') From e3e5fe58b31bf94c127870efcf316ff80af3b7cb Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Mon, 19 Apr 2021 16:59:50 -0700 Subject: [PATCH 19/20] Make AMPBoilerplate preserve " func TestAMPBoilerplate(t *testing.T) { - canonicalExpected := tt.Concat(tt.Doctype, "", - tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, - tt.LinkFavicon, tt.LinkCanonical, tt.StyleAMPBoilerplate, - ampBoilerplateNoscriptWithAttr, "") - tcs := []tt.TestCase{ { Desc: "Keeps boilerplate", Input: tt.Concat(tt.Doctype, "", - tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon, + tt.MetaCharset, tt.MetaViewport, tt.StyleAMPRuntime, tt.ScriptAMPRuntime, tt.LinkFavicon, tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate, ""), - Expected: canonicalExpected, + Expected: tt.Concat(tt.Doctype, "", + tt.MetaCharset, tt.MetaViewport, tt.StyleAMPRuntime, tt.ScriptAMPRuntime, + tt.LinkFavicon, tt.LinkCanonical, tt.StyleAMPBoilerplate, + ampBoilerplateNoscriptWithAttr, ""), }, { Desc: "Adds boilerplate if missing", @@ -52,7 +50,10 @@ func TestAMPBoilerplate(t *testing.T) { tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon, tt.LinkCanonical, ""), - Expected: canonicalExpected, + Expected: tt.Concat(tt.Doctype, "", + tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, + tt.LinkFavicon, tt.LinkCanonical, tt.StyleAMPBoilerplate, + ampBoilerplateNoscriptWithAttr, ""), }, } diff --git a/transformer/transformers/ampruntimecss.go b/transformer/transformers/ampruntimecss.go index e4f343e84..0d98c9311 100644 --- a/transformer/transformers/ampruntimecss.go +++ b/transformer/transformers/ampruntimecss.go @@ -61,7 +61,7 @@ func AMPRuntimeCSS(e *Context) error { } // Create