feat(runtime): 全站前端脚本统一接入 AksrtFrontend 全局 DOM 生命周期
- rehydrate.js 新增 boot()/aksrt:ready 事件,支持 boot 后晚注册立即以 init 触发 - aksrt-runtime.js 初始加载改走 AksrtFrontend.boot,tooltip/倒计时注册为组件 - 约 30 个前端脚本(首页、评论、支付、路由、页面叶子、widgets) 从直接 DOMContentLoaded 迁移为 AksrtFrontend.register,并加幂等标记 - section-navs 依赖改为 aksrt-runtime,保证注册时序 - 清理死代码:删除孤儿 loader.js/main.js 及 runtime/page-navs 遗留副本 - loader.js 移除已迁移模块的 tbquire 路径映射,main.js 相应瘦身 - build-public-assets.mjs 增加 runtime/main.min.js 自动压缩步骤 - 新增 4 个契约测试(homepage-dom/rehydrate-runtime/global-dom-init/ public-bundle-parity),3 个既有 harness 适配注册表初始化方式
This commit is contained in:
1 parent
5984d4e42d
commit
1f4a39d8f8
60 files changed
+1810
-1742
No files matched your search
Vendored
+1
-1
@@ -1 +1 @@
|
||||
jQuery.cookie=function(e,a,t){if(a===void 0){var r=null;if(document.cookie&&document.cookie!="")for(var n=document.cookie.split(";"),i=0;i<n.length;i++){var s=jQuery.trim(n[i]);if(s.substring(0,e.length+1)==e+"="){r=decodeURIComponent(s.substring(e.length+1));break}}return r}t=t||{},a===null&&(a="",t.expires=-1);var o="";if(t.expires&&(typeof t.expires=="number"||t.expires.toUTCString)){var d;typeof t.expires=="number"?(d=new Date,d.setTime(d.getTime()+24*t.expires*60*60*1e3)):d=t.expires,o="; expires="+d.toUTCString()}var u=t.path?"; path="+t.path:"",c=t.domain?"; domain="+t.domain:"",l=t.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(a),o,u,c,l].join("")};var lcs={get:function(e){return window.localStorage?localStorage.getItem(e):jQuery.cookie(e)},set:function(e,a){window.localStorage?localStorage[e]=a:jQuery.cookie(e,a)},remove:function(e){window.localStorage?localStorage.removeItem(e):jQuery.cookie(e,"")}};function aksrt__(e){var a=window._win&&window._win.i18n;return a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:e}function aksrt_is_fatal_error_response(e){return e&&(e.indexOf("Fatal error")>-1||e.indexOf("致命错误")>-1)}function aksrt_sprintf(e){var a=Array.prototype.slice.call(arguments,1),t=aksrt__(e),r=0;return t.replace(/%(\d+\$)?s/g,function(n,i){var s=i?parseInt(i,10)-1:r++;return a[s]!==void 0&&a[s]!==null?a[s]:n})}(function(e,a){var t=a(e,e.document,Date);e.lazySizes=t,typeof module=="object"&&module.exports&&(module.exports=t)})(typeof window<"u"?window:{},function(a,t,r){"use strict";var n,i;if((function(){var w,y={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",loadafterClass:"lazyloadafter",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};i=a.lazySizesConfig||a.lazysizesConfig||{};for(w in y)w in i||(i[w]=y[w])})(),!t||!t.getElementsByClassName)return{init:function(){},cfg:i,noSupport:!0};var s=t.documentElement,o=a.HTMLPictureElement,d="addEventListener",u="getAttribute",c=a[d].bind(a),l=a.setTimeout,h=a.requestAnimationFrame||l,f=a.requestIdleCallback,p=/^picture$/i,g=["load","error","lazyincluded","_lazyloaded"],v={},b=Array.prototype.forEach,_=function(w,y){return v[y]||(v[y]=new RegExp("(\\s|^)"+y+"(\\s|$)")),v[y].test(w[u]("class")||"")&&v[y]},Q=function(w,y){_(w,y)||w.setAttribute("class",(w[u]("class")||"").trim()+" "+y)},j=function(w,y){var k;(k=_(w,y))&&w.setAttribute("class",(w[u]("class")||"").replace(k," "))},C=function(w,y,k){var L=k?d:"removeEventListener";k&&C(w,y),g.forEach(function(q){w[L](q,y)})},T=function(w,y,k,L,q){var z=t.createEvent("Event");return k||(k={}),k.instance=n,z.initEvent(y,!L,!q),z.detail=k,w.dispatchEvent(z),z},F=function(w,y){var k;!o&&(k=a.picturefill||i.pf)?(y&&y.src&&!w[u]("srcset")&&w.setAttribute("srcset",y.src),k({reevaluate:!0,elements:[w]})):y&&y.src&&(w.src=y.src)},X=function(w,y){return(getComputedStyle(w,null)||{})[y]},Z=function(w,y,k){for(k=k||w.offsetWidth;k<i.minSize&&y&&!w._lazysizesWidth;)k=y.offsetWidth,y=y.parentNode;return k},Y=(function(){var w,y,k=[],L=[],q=k,z=function(){var E=q;for(q=k.length?L:k,w=!0,y=!1;E.length;)E.shift()();w=!1},O=function(E,A){w&&!A?E.apply(this,arguments):(q.push(E),y||(y=!0,(t.hidden?l:h)(z)))};return O._lsFlush=z,O})(),G=function(w,y){return y?function(){Y(w)}:function(){var k=this,L=arguments;Y(function(){w.apply(k,L)})}},pe=function(w){var y,k=0,L=i.throttleDelay,q=i.ricTimeout,z=function(){y=!1,k=r.now(),w()},O=f&&q>49?function(){f(z,{timeout:q}),q!==i.ricTimeout&&(q=i.ricTimeout)}:G(function(){l(z)},!0);return function(E){var A;(E=E===!0)&&(q=33),!y&&(y=!0,A=L-(r.now()-k),A<0&&(A=0),E||A<9?O():l(O,A))}},oe=function(w){var y,k,L=99,q=function(){y=null,w()},z=function(){var O=r.now()-k;O<L?l(z,L-O):(f||q)(q)};return function(){k=r.now(),y||(y=l(z,L))}},le=(function(){var w,y,k,L,q,z,O,E,A,W,$,J,me=/^img$/i,ye=/^iframe$/i,ge="onscroll"in a&&!/(gle|ing)bot/.test(navigator.userAgent),_e=0,ae=0,R=0,ee=-1,de=function(m){R--,(!m||R<0||!m.target)&&(R=0)},ue=function(m){return J==null&&(J=X(t.body,"visibility")=="hidden"),J||!(X(m.parentNode,"visibility")=="hidden"&&X(m,"visibility")=="hidden")},we=function(m,x){var S,M=m,H=ue(m);for(E-=x,$+=x,A-=x,W+=x;H&&(M=M.offsetParent)&&M!=t.body&&M!=s;)H=(X(M,"opacity")||1)>0,H&&X(M,"overflow")!="visible"&&(S=M.getBoundingClientRect(),H=W>S.left&&A<S.right&&$>S.top-1&&E<S.bottom+1);return H},ce=function(){var m,x,S,M,H,I,B,D,V,U,K,te,N=n.elements;if((L=i.loadMode)&&R<8&&(m=N.length)){for(x=0,ee++;x<m;x++)if(!(!N[x]||N[x]._lazyRace)){if(!ge||n.prematureUnveil&&n.prematureUnveil(N[x])){re(N[x]);continue}if((!(D=N[x][u]("data-expand"))||!(I=D*1))&&(I=ae),U||(U=!i.expand||i.expand<1?s.clientHeight>500&&s.clientWidth>500?500:370:i.expand,n._defEx=U,K=U*i.expFactor,te=i.hFac,J=null,ae<K&&R<1&&ee>2&&L>2&&!t.hidden?(ae=KLine truncated
|
||||
jQuery.cookie=function(e,o,t){if(o===void 0){var i=null;if(document.cookie&&document.cookie!="")for(var r=document.cookie.split(";"),n=0;n<r.length;n++){var c=jQuery.trim(r[n]);if(c.substring(0,e.length+1)==e+"="){i=decodeURIComponent(c.substring(e.length+1));break}}return i}t=t||{},o===null&&(o="",t.expires=-1);var a="";if(t.expires&&(typeof t.expires=="number"||t.expires.toUTCString)){var l2;typeof t.expires=="number"?(l2=new Date,l2.setTime(l2.getTime()+24*t.expires*60*60*1e3)):l2=t.expires,a="; expires="+l2.toUTCString()}var u=t.path?"; path="+t.path:"",s=t.domain?"; domain="+t.domain:"",m=t.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(o),a,u,s,m].join("")};var lcs={get:function(e){return window.localStorage?localStorage.getItem(e):jQuery.cookie(e)},set:function(e,o){window.localStorage?localStorage[e]=o:jQuery.cookie(e,o)},remove:function(e){window.localStorage?localStorage.removeItem(e):jQuery.cookie(e,"")}};function aksrt__(key){var map=window._win&&window._win.i18n;return map&&Object.prototype.hasOwnProperty.call(map,key)?map[key]:key}function aksrt_is_fatal_error_response(text){return text&&(text.indexOf("Fatal error")>-1||text.indexOf("致命错误")>-1)}function aksrt_sprintf(key){var args=Array.prototype.slice.call(arguments,1),str=aksrt__(key),autoIndex=0;return str.replace(/%(\d+\$)?s/g,function(match,num){var idx=num?parseInt(num,10)-1:autoIndex++;return args[idx]!==void 0&&args[idx]!==null?args[idx]:match})}(function(window2,factory){var lazySizes=factory(window2,window2.document,Date);window2.lazySizes=lazySizes,typeof module=="object"&&module.exports&&(module.exports=lazySizes)})(typeof window<"u"?window:{},function(window2,document2,Date2){"use strict";var lazysizes,lazySizesCfg;if((function(){var prop,lazySizesDefaults={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",loadafterClass:"lazyloadafter",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};lazySizesCfg=window2.lazySizesConfig||window2.lazysizesConfig||{};for(prop in lazySizesDefaults)prop in lazySizesCfg||(lazySizesCfg[prop]=lazySizesDefaults[prop])})(),!document2||!document2.getElementsByClassName)return{init:function(){},cfg:lazySizesCfg,noSupport:!0};var docElem=document2.documentElement,supportPicture=window2.HTMLPictureElement,_addEventListener="addEventListener",_getAttribute="getAttribute",addEventListener=window2[_addEventListener].bind(window2),setTimeout2=window2.setTimeout,requestAnimationFrame2=window2.requestAnimationFrame||setTimeout2,requestIdleCallback=window2.requestIdleCallback,regPicture=/^picture$/i,loadEvents=["load","error","lazyincluded","_lazyloaded"],regClassCache={},forEach=Array.prototype.forEach,hasClass=function(ele,cls){return regClassCache[cls]||(regClassCache[cls]=new RegExp("(\\s|^)"+cls+"(\\s|$)")),regClassCache[cls].test(ele[_getAttribute]("class")||"")&®ClassCache[cls]},addClass=function(ele,cls){hasClass(ele,cls)||ele.setAttribute("class",(ele[_getAttribute]("class")||"").trim()+" "+cls)},removeClass=function(ele,cls){var reg2;(reg2=hasClass(ele,cls))&&ele.setAttribute("class",(ele[_getAttribute]("class")||"").replace(reg2," "))},addRemoveLoadEvents=function(dom,fn,add){var action=add?_addEventListener:"removeEventListener";add&&addRemoveLoadEvents(dom,fn),loadEvents.forEach(function(evt){dom[action](evt,fn)})},triggerEvent=function(elem,name,detail,noBubbles,noCancelable){var event=document2.createEvent("Event");return detail||(detail={}),detail.instance=lazysizes,event.initEvent(name,!noBubbles,!noCancelable),event.detail=detail,elem.dispatchEvent(event),event},updatePolyfill=function(el,full){var polyfill;!supportPicture&&(polyfill=window2.picturefill||lazySizesCfg.pf)?(full&&full.src&&!el[_getAttribute]("srcset")&&el.setAttribute("srcset",full.src),polyfill({reevaluate:!0,elements:[el]})):full&&full.src&&(el.src=full.src)},getCSS=function(elem,style){return(getComputedStyle(elem,null)||{})[style]},getWidth=function(elem,parent,width){for(width=width||elem.offsetWidth;width<lazySizesCfg.minSize&&parent&&!elem._lazysizesWidth;)width=parent.offsetWidth,parent=parent.parentNode;return width},rAF=(function(){var running,waiting,firstFns=[],secondFns=[],fns=firstFns,run=function(){var runFns=fns;for(fns=firstFns.length?secondFns:firstFns,running=!0,waiting=!1;runFns.length;)runFns.shift()();running=!1},rafBatch=function(fn,queue){running&&!queue?fn.apply(this,arguments):(fns.push(fn),waiting||(waiting=!0,(document2.hidden?setTimeout2:requestAnimationFrame2)(run)))};return rafBatch._lsFlush=run,rafBatch})(),rAFIt=function(fn,simple){return simple?function(){rAF(fn)}:function(){var that=this,args=arguments;rAF(function(){fn.apply(that,args)})}},throttle2=function(fn){var running,lastTime=0,gDelay=lazySizesCfg.throttleDelay,rICTimeout=lazySizesCfLine truncated
|
||||
Reference in new issue
Block a user