-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🏗✨ Upgrade closure compiler to v20190709 #23417
Conversation
This PR is now ready for review. I've added several folks for different pieces:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date picker change LGTM
Do we still have custom passes? |
@choumx All our old custom passes now have equivalent With this, there are two pieces of custom code that remain:
Most of the tests run by /cc @cramforce who wrote a fair bit of this code during the early days of the project |
Verified that this PR isn't resulting in any significant changes to diff --git a/dist-master/v0.js b/dist-closure-upgrade/v0.js
index 4518ee0..d9b829b 100644
--- a/dist-master/v0.js
+++ b/dist-closure-upgrade/v0.js
@@ -147,7 +147,7 @@ r&&(h.rvu=r);v&&(h.mso=v)}dg||(dg=mg());h.jse=dg;var w=[];g=self.__AMP__EXPERIME
ag.splice(0,ag.length-25+1);ag.push(b);return h}}}function ig(){var a=self;if(!a.document)return!1;a=a.document.querySelectorAll("script[src]");for(var b=0;b<a.length;b++)if(!K(a[b].src.toLowerCase()))return!0;return!1}
function mg(){function a(){}a.prototype.t=function(){throw Error("message");};var b=new a;try{b.t()}catch(d){b=d.stack;if(zb(b,"t@"))return"Safari";if(-1<b.indexOf(".prototype.t@"))return"Firefox";var c=b.split("\n").pop();if(/\bat .* \(/i.test(c))return"IE";if(zb(b,"Error: message"))return"Chrome"}return"unknown"};var ng="__AMP_ACTION_MAP__"+Math.random(),og={form:["submit","clear"]},pg={button:!0,checkbox:!0,link:!0,listbox:!0,menuitem:!0,menuitemcheckbox:!0,menuitemradio:!0,option:!0,radio:!0,scrollbar:!0,slider:!0,spinbutton:!0,"switch":!0,tab:!0,treeitem:!0};
function qg(a,b,c,d,e,g,h,k,l,m){k=void 0===k?"?":k;l=void 0===l?null:l;m=void 0===m?Math.random():m;this.node=a;this.method=b;this.args=c;this.source=d;this.caller=e;this.event=g;this.trust=h;this.actionEventType=k;this.tagOrTarget=l||a.tagName;this.sequenceId=m}
-qg.prototype.satisfiesTrust=function(a){return Wa(this.trust)?this.trust<a?(u().error("Action",'"'+this.actionEventType+'" is not allowed to invoke '+('"'+this.tagOrTarget+"."+this.method+'".')),!1):!0:(x().error("Action","Invalid trust for '"+this.method+"': "+this.trust),!1)};
+qg.prototype.satisfiesTrust=function(a){return Wa(this.trust)?this.trust<a?(u().error("Action",'"'+this.actionEventType+'" is not allowed to invoke "'+(this.tagOrTarget+"."+this.method+'".')),!1):!0:(x().error("Action","Invalid trust for '"+this.method+"': "+this.trust),!1)};
function rg(a,b){this.ampdoc=a;this.$=b||a.getRootNode();this.Xa=Jg(this);this.Pd=A();this.Gf=A();this.addEvent("tap");this.addEvent("submit");this.addEvent("change");this.addEvent("input-debounced");this.addEvent("input-throttled");this.addEvent("valid");this.addEvent("invalid")}rg.installInEmbedWindow=function(a,b){ce(a,"action",new rg(b,a.document))};f=rg.prototype;
f.addEvent=function(a){var b=this;if("tap"==a)this.$.addEventListener("click",function(c){c.defaultPrevented||b.trigger(c.target,a,c,100)}),this.$.addEventListener("keydown",function(c){var d=c.key,e=c.target;if("Enter"==d||" "==d){var k=e.getAttribute("role");if(d=k)d=k.toLowerCase(),d=sb.call(pg,d);var l=d;if(!c.defaultPrevented&&l){var m=b.trigger(e,a,c,100);m&&c.preventDefault()}}});else if("submit"==a)this.$.addEventListener(a,function(c){b.trigger(c.target,a,c,100)});else if("change"==a)this.$.addEventListener(a,
function(c){var d=c.target;Kg(c);b.trigger(d,a,c,100)});else if("input-debounced"==a){var c=Xf(this.ampdoc.win,function(c){b.trigger(c.target,a,c,100)});this.$.addEventListener("input",function(a){var b=new Lg(a);Kg(b);c(b)})}else if("input-throttled"==a){var d=Wf(this.ampdoc.win,function(c){b.trigger(c.target,a,c,100)});this.$.addEventListener("input",function(a){a=new Lg(a);Kg(a);d(a)})}else"valid"!=a&&"invalid"!=a||this.$.addEventListener(a,function(c){b.trigger(c.target,a,c,100)})};
@@ -186,7 +186,7 @@ Ah.prototype.If=function(a){if(a.optOut)return Bh(this,"$OPT_OUT",31536E6),"$OPT
Ih.prototype.get=function(a,b,c){var d=this;y(Fh.test(a.scope)&&Fh.test(a.cookieName),"The CID scope and cookie name must only use the characters [a-zA-Z0-9-_.]+\nInstead found: %s",a.scope);return b.then(function(){return W(d.ampdoc).whenFirstVisible()}).then(function(){return Jh(d.ampdoc)}).then(function(e){if(e)return"";var g=Kh(d,a,c||b);return V(d.ampdoc.win).timeoutPromise(1E4,g,'Getting cid for "'+a.scope+'" timed out').catch(function(a){ib(a)})})};Ih.prototype.optOut=function(){return Lh(this.ampdoc)};
function Kh(a,b,c){var d=b.scope,e=I(a.ampdoc.win.location.href);if(!K(e)){var g=Mh(a,d);return g?a.Xg.getScopedCid(g,d).then(function(e){if("$OPT_OUT"==e)return null;if(e){var g=b.cookieName||d;Nh(a.ampdoc.win,g,e);return e}return Oh(a,b,c)}):Oh(a,b,c)}return a.Eg.isSupported().then(function(b){if(b){var g=Mh(a,d);return a.Eg.getScopedCid(g,d)}return a.qf.isSupported()&&Mh(a,d)?a.qf.getScopedCid(d).then(function(b){return b?b:Ph(a,c,d,e)}):Ph(a,c,d,e)})}
function Ph(a,b,c,d){return Qh(a,b).then(function(b){return R(a.ampdoc.win,"crypto").sha384Base64(b+Rh(d)+c)})}function Mh(a,b){a.yd||(a.yd=Sh(a));return a.yd[b]}
-function Sh(a){var b={},c=a.ampdoc.win.document.head.querySelector("meta[name=amp-google-client-id-api]");c&&c.hasAttribute("content")&&c.getAttribute("content").split(",").forEach(function(a){a=a.trim();if(0<a.indexOf("=")){var d=a.split("=");a=d[0].trim();b[a]=d[1].trim()}else{var g=a;(a=Gh[g])?b[a]=Hh[g]:u().warn("CID","Unsupported client for Google CID API: "+g+"."+("Please remove or correct "+c.outerHTML))}});return b}
+function Sh(a){var b={},c=a.ampdoc.win.document.head.querySelector("meta[name=amp-google-client-id-api]");c&&c.hasAttribute("content")&&c.getAttribute("content").split(",").forEach(function(a){a=a.trim();if(0<a.indexOf("=")){var d=a.split("=");a=d[0].trim();b[a]=d[1].trim()}else{var g=a;(a=Gh[g])?b[a]=Hh[g]:u().warn("CID","Unsupported client for Google CID API: "+g+".Please remove or correct "+c.outerHTML)}});return b}
function Lh(a){W(a).sendMessage("cidOptOut",{});return ge(a,"storage").then(function(a){return a.set("amp-cid-optout",!0)})}function Jh(a){return ge(a,"storage").then(function(a){return a.get("amp-cid-optout").then(function(a){return!!a})}).catch(function(){return!1})}function Nh(a,b,c){var d=Date.now()+31536E6;yh(a,b,c,d)}
function Oh(a,b,c){var d=a.ampdoc.win,e=b.scope,g=b.cookieName||e,h=wh(d,g);if(!h&&!b.createCookieIfNotPresent)return Promise.resolve(null);if(a.Md[e])return a.Md[e];if(h)return/^amp-/.test(h)&&Nh(d,g,h),Promise.resolve(h);var k=Th(d).then(function(a){return"amp-"+a});Promise.all([k,c]).then(function(a){var b=a[0],c=wh(d,g);c||Nh(d,g,b)});return a.Md[e]=k}function Rh(a){y(K(a),"Expected proxy origin %s",a.origin);return Ed(a)}
function Qh(a,b){if(a.zd)return a.zd;var c=a.ampdoc.win;return a.zd=Uh(a.ampdoc).then(function(d){var e=!1;if(d&&!Vh(d)){var g=Promise.resolve(d.cid);Wh(d)&&(e=!0)}else g=R(c,"crypto").sha384Base64(Xh(c)),e=!0;e&&g.then(function(c){Yh(a.ampdoc,b,c)});return g})}function Yh(a,b,c){var d=a.win;$b(d)?Zh(a,$h(c)):b.then(function(){try{d.localStorage.setItem("amp-cid",$h(c))}catch(e){}})}
@@ -318,7 +318,7 @@ f.getMajorVersion=function(){return this.isSafari()?this.isIos()?this.getIosMajo
f.getIosVersionString=function(){if(!this.W.userAgent||!this.isIos())return"";var a=this.W.userAgent.match(/OS ([0-9]+[_.][0-9]+([_.][0-9]+)?)\b/);return a?a=a[1].replace(/_/g,"."):""};f.getIosMajorVersion=function(){var a=this.getIosVersionString();return""==a?null:Number(a.split(".")[0])};function Qj(a){this.H=a;this.xg=Object.create(null)}Qj.prototype.addTransition=function(a,b,c){var d=a+"|"+b;this.xg[d]=c};Qj.prototype.setState=function(a){var b=this.H;this.H=a;(a=this.xg[b+"|"+a])&&a()};function Rj(a){var b=6E4,c=this;this.win=a;this.Mh=b;this.R=[];this.Zf=new Y;this.sf=function(a){a.target&&1==a.target.nodeType&&Sj(c,a.target)};this.rf=function(){V(a).delay(function(){Sj(c,c.win.document.activeElement)},500)};this.win.document.addEventListener("focus",this.sf,!0);this.win.addEventListener("blur",this.rf)}f=Rj.prototype;f.mi=function(){this.win.document.removeEventListener("focus",this.sf,!0);this.win.removeEventListener("blur",this.rf)};f.onFocus=function(a){return this.Zf.add(a)};
function Sj(a,b){var c=Date.now();0==a.R.length||a.R[a.R.length-1].el!=b?a.R.push({el:b,time:c}):a.R[a.R.length-1].time=c;a.purgeBefore(c-a.Mh);a.Zf.fire(b)}f.getLast=function(){return 0==this.R.length?null:this.R[this.R.length-1].el};f.purgeBefore=function(a){for(var b=this.R.length-1,c=0;c<this.R.length;c++)if(this.R[c].time>=a){b=c-1;break}-1!=b&&this.R.splice(0,b+1)};
f.hasDescendantsOf=function(a){this.win.document.activeElement&&Sj(this,this.win.document.activeElement);for(var b=0;b<this.R.length;b++)if(a.contains(this.R[b].el))return!0;return!1};function Tj(){this.K=[];this.$b={};this.Pf=this.Qf=0}f=Tj.prototype;f.getSize=function(){return this.K.length};f.getLastEnqueueTime=function(){return this.Qf};f.getLastDequeueTime=function(){return this.Pf};f.getTaskById=function(a){return this.$b[a]||null};f.enqueue=function(a){this.K.push(a);this.$b[a.id]=a;this.Qf=Date.now()};f.dequeue=function(a){var b=this.removeAtIndex(a,this.K.indexOf(this.$b[a.id]));if(!b)return!1;this.Pf=Date.now();return!0};
-f.peek=function(a,b){for(var c=1E6,d=null,e=0;e<this.K.length;e++){var g=this.K[e],h=a(g,b);h<c&&(c=h,d=g)}return d};f.forEach=function(a){this.K.forEach(a)};f.removeAtIndex=function(a,b){var c=this.$b[a.id];if(!c||this.K[b]!=c)return!1;this.K.splice(b,1);delete this.$b[a.id];return!0};f.purge=function(a){for(var b=this.K.length;b--;)a(this.K[b])&&this.removeAtIndex(this.K[b],b)};function Uj(a){var b;return!(b||U(a)).isIe()||Vj(a)?null:new Promise(function(b){var c=Date.now()+2E3,e=a.setInterval(function(){var d=Date.now(),h=Vj(a);if(h||d>c)a.clearInterval(e),b(),h||x().error("ie-media-bug","IE media never resolved")},10)})}function Vj(a){var b="(min-width: "+(a.innerWidth-1)+"px)"+(" AND (max-width: "+(a.innerWidth+1)+"px)");try{return a.matchMedia(b).matches}catch(c){return x().error("ie-media-bug","IE matchMedia failed: ",c),!0}};function Wj(a){var b=this;this.ampdoc=a;this.win=a.win;this.h=W(a);this.wa=this.h.isRuntimeOn();this.ph=!1;this.Uh=0;this.A=[];this.nf=this.Ue=0;this.pa=this.h.isVisible();this.Ha=this.h.getPrerenderSize();this.yb=!1;this.Cf=!0;this.Ve=!1;this.Fa=-1;this.mb=!0;this.Vb=-1;this.ke=this.Cc=0;this.Uc=new oj(this.win,function(){return b.doPass()});this.hg=new oj(this.win,function(){b.mb=!0;b.schedulePass()});this.va=new Tj;this.C=new Tj;this.D=L(this.win,"layers");this.pd=L(this.win,"layers-prioritization");
+f.peek=function(a,b){for(var c=1E6,d=null,e=0;e<this.K.length;e++){var g=this.K[e],h=a(g,b);h<c&&(c=h,d=g)}return d};f.forEach=function(a){this.K.forEach(a)};f.removeAtIndex=function(a,b){var c=this.$b[a.id];if(!c||this.K[b]!=c)return!1;this.K.splice(b,1);delete this.$b[a.id];return!0};f.purge=function(a){for(var b=this.K.length;b--;)a(this.K[b])&&this.removeAtIndex(this.K[b],b)};function Uj(a){var b;return!(b||U(a)).isIe()||Vj(a)?null:new Promise(function(b){var c=Date.now()+2E3,e=a.setInterval(function(){var d=Date.now(),h=Vj(a);if(h||d>c)a.clearInterval(e),b(),h||x().error("ie-media-bug","IE media never resolved")},10)})}function Vj(a){var b="(min-width: "+(a.innerWidth-1)+"px) AND (max-width: "+(a.innerWidth+1+"px)");try{return a.matchMedia(b).matches}catch(c){return x().error("ie-media-bug","IE matchMedia failed: ",c),!0}};function Wj(a){var b=this;this.ampdoc=a;this.win=a.win;this.h=W(a);this.wa=this.h.isRuntimeOn();this.ph=!1;this.Uh=0;this.A=[];this.nf=this.Ue=0;this.pa=this.h.isVisible();this.Ha=this.h.getPrerenderSize();this.yb=!1;this.Cf=!0;this.Ve=!1;this.Fa=-1;this.mb=!0;this.Vb=-1;this.ke=this.Cc=0;this.Uc=new oj(this.win,function(){return b.doPass()});this.hg=new oj(this.win,function(){b.mb=!0;b.schedulePass()});this.va=new Tj;this.C=new Tj;this.D=L(this.win,"layers");this.pd=L(this.win,"layers-prioritization");
var c;this.ef=c=this.D&&this.pd?this.Ug.bind(this):this.Vg.bind(this);this.la=[];this.xa=[];this.ce=!1;this.G=Ce(this.ampdoc);this.w=Be(this.win);this.Se=new Rj(this.win);this.Re=!1;this.mc=0;this.Pa=!1;this.Tc=[];this.Gg=new Qj(this.h.getVisibilityState());Xj(this,this.Gg);this.G.onChanged(function(a){b.Cc=Date.now();b.ke=a.velocity;a.relayoutAll&&(b.mb=!0,b.Pa=!0);b.schedulePass()});this.G.onScroll(function(){b.Cc=Date.now()});this.D&&(this.eb=fe(this.ampdoc,"layers"),this.Ng=this.Tg.bind(this));
this.h.onVisibilityChanged(function(){-1==b.Fa&&b.h.isVisible()&&(b.Fa=Date.now());b.schedulePass()});this.h.onRuntimeState(function(a){b.wa=a;b.schedulePass(1)});this.Se.onFocus(function(a){Yj(b,a)});this.schedulePass();Zj(this)}
function Zj(a){a.ampdoc.whenReady().then(function(){function b(){return a.hg.schedule()}a.yb=!0;ak(a);a.xa=null;var c=Uj(a.win);c?c.then(b):b();bk(a);Promise.race([nf(a.win),V(a.win).promise(3100)]).then(b);a.win.document.fonts&&"loaded"!=a.win.document.fonts.status&&a.win.document.fonts.ready.then(b)})}f=Wj.prototype;f.get=function(){return this.A.slice(0)};
@@ -519,7 +519,7 @@ f.Wh=function(){var a=this;this.Ub=null;this.lg++;this.Ua=this.j.getScrollLeft()
f.Xh=function(){var a=this;this.De||(this.De=!0,this.w.measure(function(){a.De=!1;a.h.sendMessage("scroll",C({scrollTop:a.getScrollTop()}),!0)}))};f.jg=function(){var a=this;this.Ub=null;var b=this.U;this.U=null;var c=this.getSize();this.ha.update().then(function(){var d=!b||b.width!=c.width;en(a,d,0);var e=d||b.height!=c.height;e&&a.ma.fire({relayoutAll:d,width:c.width,height:c.height})})};
function fn(a){var b=W(a),c=a.win,d;if(d=a.isSingleDoc()){d=b.getParam("viewportType")||gn;if(U(c).isIos()&&d==gn){var e=L(c,"ios-scrollable-iframe");d=!$b(c)&&(t(c).localDev||t(c).development)&&!e||$b(c)&&t(c).test||$b(c)&&b.isEmbedded()&&!e?hn:d}d=d==hn}c=d?L(c,"ios-embed-sd")&&c.Element.prototype.attachShadow&&12.2<=parseFloat(U(c).getIosVersionString())?new Cm(c):new Dm(c):new Em(a);return new Vm(a,c,b)}var gn="natural",hn="natural-ios-embed";var jn=["<div class=i-amphtml-jank-meter></div>"];function kn(a){this.o=a;this.Gc=this.Fc=this.bc=this.jc=0;this.Wb=null;this.ya=ee(a);this.Kb=this.$e=this.af=null;ln(this)}kn.prototype.onScheduled=function(){mn(this)&&null==this.Wb&&(this.Wb=this.o.Date.now())};
kn.prototype.onRun=function(){if(mn(this)&&null!=this.Wb){var a=this.o.Date.now()-this.Wb;this.Wb=null;this.bc++;16<a&&(this.jc++,x().info("JANK","Paint latency: "+a+"ms"));if(this.ya&&200==this.bc){var b=this.o.Math.floor((this.bc-this.jc)/this.bc*100);this.ya.tickDelta("gfp",b);this.ya.tickDelta("bf",this.jc);this.Kb&&(this.ya.tickDelta("lts",this.Gc),this.ya.tickDelta("ltc",this.Fc),this.Kb.disconnect(),this.Kb=null);var c=0;this.af&&null!=this.$e&&(c=this.o.Math.max(0,this.o.Math.floor(100*this.af.level-
-this.$e)),this.ya.tickDelta("bd",c));this.ya.flush();if(L(this.o,"jank-meter")){var d=c,e=this.o.document,g=Fe(e)(jn);g.textContent="bf:"+this.jc+", lts: "+this.Gc+", "+("ltc:"+this.Fc+", bd:"+d);e.body.appendChild(g)}}}};function mn(a){return L(a.o,"jank-meter")||a.ya&&a.ya.isPerformanceTrackingOn()&&200>a.bc}
+this.$e)),this.ya.tickDelta("bd",c));this.ya.flush();if(L(this.o,"jank-meter")){var d=c,e=this.o.document,g=Fe(e)(jn);g.textContent="bf:"+this.jc+", lts: "+this.Gc+", ltc:"+(this.Fc+", bd:"+d);e.body.appendChild(g)}}}};function mn(a){return L(a.o,"jank-meter")||a.ya&&a.ya.isPerformanceTrackingOn()&&200>a.bc}
function ln(a){mn(a)&&nn(a.o)&&(a.Kb=new a.o.PerformanceObserver(function(b){for(var c=b.getEntries(),d=0;d<c.length;d++)if("longtask"==c[d].entryType){var e=a.o.Math.floor(c[d].duration/50);"cross-origin-descendant"==c[d].name?(a.Fc+=e,u().info("LONGTASK","from child frame "+c[d].duration+"ms")):(a.Gc+=e,x().info("LONGTASK","from self frame "+c[d].duration+"ms"))}}),a.Kb.observe({entryTypes:["longtask"]}))}
function nn(a){return!!a.PerformanceObserver&&!!a.TaskAttributionTiming&&"containerName"in a.TaskAttributionTiming.prototype};function on(a){var b=this;this.win=a;this.Za=xe(this.win);this.xb=R(this.win,"documentState");this.Oh=pn(this);this.K=[];this.se=[];this.Je=[];this.re=[];this.ta=!1;this.qe=this.Mc=null;this.Ed=this.Vh.bind(this);this.nh=new oj(this.win,this.Ed,16);this.Ze=new oj(this.win,this.Ed,40);this.Ge=null;var c=this.we.bind(this);if(this.Za.isSingleDoc())ge(this.Za.getSingleDoc(),"viewer").then(function(a){b.Ge=a;a.onVisibilityChanged(c)});else this.xb.onVisibilityChanged(c);this.Of=new kn(this.win)}f=on.prototype;
f.we=function(){this.ta&&qn(this)};f.run=function(a,b){this.K.push(a);this.Je.push(b||void 0);this.Ta()};f.runPromise=function(a,b){this.run(a,b);if(this.Mc)return this.Mc;a=new E;this.qe=a.resolve;return this.Mc=a.promise};f.createTask=function(a){var b=this;return function(c){b.run(a,c)}};f.mutate=function(a){this.run({measure:void 0,mutate:a})};f.mutatePromise=function(a){return this.runPromise({measure:void 0,mutate:a})};f.measure=function(a){this.run({measure:a,mutate:void 0})}; |
Tested as follows:
Merging this now. |
This PR upgrades the version of closure compiler used to minify the AMP runtime to
v20190709
.Highlights:
compiler.jar
with the version that natively ships withv20190709
third_party/closure-compiler
runner.jar
fromnode_modules/google-closure-compiler-java/compiler.jar
node_modules/google-closure-compiler-java/compiler.jar
for single pass compilationweb_animations
externs tothird_party/web-animations-externs/
amp-date-picker
(see FixReact.Component
type errors inamp-date-picker
and remove suppressions #23429)Notes:
runner.jar
were moved tobabel
transformsrunner.jar
that has been replaced by babel transforms #23378, a lot of the unnecessary code inAmpPass.java
was deletedcompiler.jar
andcompiler-and-tests.jar
withnode_modules/google-closure-compiler-java/compiler.jar
is that we can no longer run tests forAmpPass.java
viaant test
Coming up:
runner.jar
instead of checking in a pre-built binary (Dynamically generate custom closure compiler for AMP #22452)build-system/runner/
and do away with the need forrunner.jar
(move away from custom closure passes and transformation #17120)Partial fix for #22452, #18748, and #17120
Follow up to #18552, #18609, #18794, #19449, #20056, #21618, and #22446