@arms/rum-browser
Advanced tools
Comparing version 0.0.24-beta.2 to 0.0.24-beta.3
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_objectWithoutPropertiesLoose2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_rumCore=require("@arms/rum-core"),_blank=require("../../utils/blank"),_global=require("../../utils/global"),_excluded=["result"],cancelList=[],eventRegistrationMap={LEAVE:function LEAVE(a){// TODO: 可能会替换为pagehide | ||
return _global.document.addEventListener("beforeunload",a),function(){return _global.document.removeEventListener("beforeunload",a)}},ROUTE_CHANGE:function ROUTE_CHANGE(a,b){return!0===b||"hash"===b?(_global.global.addEventListener("hashchange",a),function(){return _global.global.removeEventListener("hashchange",a)}):((0,_rumCore.interceptFunction)(_global.global.history,"pushState",a),(0,_rumCore.interceptFunction)(_global.global.history,"replaceState",a),_global.global.addEventListener("popstate",a),function(){_global.global.removeEventListener("popstate",a)})},ERROR:function ERROR(a){return _global.global.addEventListener("error",a),function(){return _global.global.removeEventListener("error",a)}},LOAD:function LOAD(a){return"complete"===_global.document.readyState?(setTimeout(a,0),function(){}):(_global.global.addEventListener("load",a),function(){return _global.global.removeEventListener("load",a)})}},WhiteScreenCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="white-screen-collector",this.observers=[],this.ctx=void 0,this.sendEvent=void 0,this.abort=function(){a.observers.forEach(function(a){return a()}),a.observers=[]},this.blankHandler=/*#__PURE__*/function(){var b=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function d(b,c){var e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator["default"].wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(e=b.target,f=b.tester,g=b.delay,h=void 0===g?0:g,i=b.configOptions,j=void 0===i?{}:i,"LEAVE"===c&&"ERROR"===c){d.next=4;break}return d.next=4,new Promise(function(a){return setTimeout(a,h)});case 4:if(k=_global.document.querySelector(e),k&&f){d.next=7;break}return d.abrupt("return");case 7:d.t0=typeof f,d.next="function"===d.t0?10:"string"===d.t0?13:29;break;case 10:return l=f(k),m={when:c,method:"CUSTOM"},d.abrupt("break",30);case 13:d.t1=f,d.next="HAS_CONTENT"===d.t1?16:"SCREENSHOT"===d.t1?19:27;break;case 16:return l=null!==k&&void 0!==k&&k.textContent,m={when:c,method:"HAS_CONTENT"},d.abrupt("break",28);case 19:return d.next=21,(0,_blank.performScreenshotCheck)(k,j);case 21:return n=d.sent,o=n.result,p=(0,_objectWithoutPropertiesLoose2["default"])(n,_excluded),l=o,m=(0,_extends2["default"])({when:c,method:"SCREENSHOT"},p),d.abrupt("break",28);case 27:console.warn("[RUM] Unsupported tester: "+f);case 28:return d.abrupt("break",30);case 29:console.warn("[RUM] Invalid tester type. Expected either a function or a string.");case 30:if(!l){d.next=32;break}return d.abrupt("return");case 32:q={event_type:_rumCore.RumEventType.EXCEPTION,type:"blank",snapshots:JSON.stringify((0,_extends2["default"])({},m))},a.sendEvent(q),a.abort();case 35:case"end":return d.stop()}},d)}));return function(){return b.apply(this,arguments)}}()}var b=a.prototype;return b.setup=function setup(a,b){var c=this;this.ctx=a,this.sendEvent=b;var d=a.getConfig(),e=d.whiteScreen,f=d.spaMode,g=e.detectionRules;Array.isArray(g)&&g.length&&g.forEach(function(a){a.test_when.forEach(function(b){var d=function handler(){cancelList.forEach(function(a){return clearTimeout(a)}),cancelList=[];var d=setTimeout(function(){try{c.blankHandler(a,b)}catch(a){console.warn("[RUM] Failed to inject blank handler: ",a)}},a.delay);cancelList.push(d)},e=eventRegistrationMap[b];if(e){var g=e(d,f);c.observers.push(g)}})})},b.destroy=function destroy(){this.abort()},a}(); | ||
return _global.document.addEventListener("beforeunload",a),function(){return _global.document.removeEventListener("beforeunload",a)}},ROUTE_CHANGE:function ROUTE_CHANGE(a,b){return!0===b||"hash"===b?(_global.global.addEventListener("hashchange",a),function(){return _global.global.removeEventListener("hashchange",a)}):((0,_rumCore.interceptFunction)(_global.global.history,"pushState",a),(0,_rumCore.interceptFunction)(_global.global.history,"replaceState",a),_global.global.addEventListener("popstate",a),function(){_global.global.removeEventListener("popstate",a)})},ERROR:function ERROR(a){return _global.global.addEventListener("error",a),function(){return _global.global.removeEventListener("error",a)}},LOAD:function LOAD(a){return"complete"===_global.document.readyState?(setTimeout(a,0),function(){}):(_global.global.addEventListener("load",a),function(){return _global.global.removeEventListener("load",a)})}},WhiteScreenCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="white-screen-collector",this.observers=[],this.ctx=void 0,this.sendEvent=void 0,this.abort=function(){a.observers.forEach(function(a){return a()}),a.observers=[]},this.blankHandler=/*#__PURE__*/function(){var b=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function d(b,c){var e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator["default"].wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(e=b.target,f=b.tester,g=b.delay,h=void 0===g?0:g,i=b.configOptions,j=void 0===i?{}:i,"LEAVE"===c&&"ERROR"===c){d.next=4;break}return d.next=4,new Promise(function(a){return setTimeout(a,h)});case 4:if(k=_global.document.querySelector(e),k&&f){d.next=7;break}return d.abrupt("return");case 7:d.t0=typeof f,d.next="function"===d.t0?10:"string"===d.t0?13:29;break;case 10:return l=f(k),m={when:c,method:"CUSTOM"},d.abrupt("break",30);case 13:d.t1=f,d.next="HAS_CONTENT"===d.t1?16:"SCREENSHOT"===d.t1?19:27;break;case 16:return l=null!==k&&void 0!==k&&k.textContent,m={when:c,method:"HAS_CONTENT"},d.abrupt("break",28);case 19:return d.next=21,(0,_blank.performScreenshotCheck)(k,j);case 21:return n=d.sent,o=n.result,p=(0,_objectWithoutPropertiesLoose2["default"])(n,_excluded),l=o,m=(0,_extends2["default"])({when:c,method:"SCREENSHOT"},p),d.abrupt("break",28);case 27:console.warn("[RUM] Unsupported tester: "+f);case 28:return d.abrupt("break",30);case 29:console.warn("[RUM] Invalid tester type. Expected either a function or a string.");case 30:if(!l){d.next=32;break}return d.abrupt("return");case 32:q={event_type:_rumCore.RumEventType.EXCEPTION,type:"blank",snapshots:JSON.stringify((0,_extends2["default"])({},m))},a.sendEvent(q),a.abort();case 35:case"end":return d.stop()}},d)}));return function(){return b.apply(this,arguments)}}()}var b=a.prototype;return b.setup=function setup(a,b){var c=this;this.ctx=a,this.sendEvent=b;var d=a.getConfig(),e=d.whiteScreen,f=d.spaMode;if(e){// 开启白屏监控 | ||
var g=e.detectionRules;Array.isArray(g)&&g.length&&g.forEach(function(a){a.test_when.forEach(function(b){var d=function handler(){cancelList.forEach(function(a){return clearTimeout(a)}),cancelList=[];var d=setTimeout(function(){try{c.blankHandler(a,b)}catch(a){console.warn("[RUM] Failed to inject blank handler: ",a)}},a.delay);cancelList.push(d)},e=eventRegistrationMap[b];if(e){var g=e(d,f);c.observers.push(g)}})})}},b.destroy=function destroy(){this.abort()},a}(); |
@@ -1,5 +0,5 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports.performScreenshotCheck=exports.performSampleCheck=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_html2canvas=require("./html2canvas"),_global=require("./global"),isPureColor=function(a,b){for(var c,d=!0,e=0;e<a.length;e+=4)if(c="rgb("+a[e]+", "+a[e+1]+", "+a[e+2]+")",!b.includes(c)){d=!1;break}return d},performScreenshotCheck=exports.performScreenshotCheck=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,z,A,B,C,D,E,F,G,H,I,J;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(void 0===b&&(b={}),c.prev=1,d=window.innerWidth,e=window.innerHeight,!(3e3<d||1600<e)){c.next=6;break}return c.abrupt("return",{result:!1,image:null});case 6:if(f={colorRange:["rgb(255, 255, 255)"],horizontalOffset:0,verticalOffset:0,pixels:10,threshold:.8,dpr:.3,debug:!1,ignoreUrlList:[],ignoreElements:[],fillColor:"rgba(0,100,200,255)"},g=(0,_extends2["default"])({},f,b),!(g.ignoreUrlList.includes(_global.location.pathname)||g.ignoreUrlList.includes(_global.location.hash))){c.next=10;break}return c.abrupt("return",{result:!1,image:null,error:null});case 10:return h=g.debug,i=g.colorRange,j=g.horizontalOffset,k=g.verticalOffset,l=g.pixels,m=g.threshold,n=g.dpr,o=d*n,p=e*n,q=_global.document.createElement("canvas"),q.height=p,q.width=o,q.style.width=o+"px",q.style.height=p+"px",r=q.getContext("2d",{willReadFrequently:!0}),c.next=21,(0,_html2canvas.html2canvas)(a,{ignoreElements:g.ignoreElements,fillColor:g.fillColor});case 21:if(s=c.sent,"string"!=typeof s){c.next=24;break}return c.abrupt("return",{result:!1,image:null,error:null});case 24:return t=new Image,t.src=s.toDataURL("image/png"),t.crossOrigin="Anonymous",c.next=29,new Promise(function(a){t.addEventListener("load",function(){return a()})});case 29:for(r.drawImage(t,0,0,o,p),u=0,v=2*l,w=2*l,z=Math.floor((o-j*n)/v),A=Math.floor((p-k*n)/w),B=z*A,C=0;C<z;C++)for(D=0;D<A;D++)// 根据间隙调整x和y坐标 | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports.performScreenshotCheck=exports.performSampleCheck=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_html2canvas=require("./html2canvas"),_global=require("./global"),isPureColor=function(a,b){for(var c,d=!0,e=0;e<a.length;e+=4)if(c="rgb("+a[e]+", "+a[e+1]+", "+a[e+2]+")",!b.includes(c)){d=!1;break}return d},performScreenshotCheck=exports.performScreenshotCheck=/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,z,A,B,C,D,E,F,G,H,I,J;return _regenerator["default"].wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(void 0===b&&(b={}),c.prev=1,d=window.innerWidth,e=window.innerHeight,f={colorRange:["rgb(255, 255, 255)"],horizontalOffset:0,verticalOffset:0,pixels:10,threshold:.8,dpr:.3,debug:!1,ignoreUrlList:[],ignoreElements:[],fillColor:"rgba(0,100,200,255)"},g=(0,_extends2["default"])({},f,b),!(g.ignoreUrlList.includes(_global.location.pathname)||g.ignoreUrlList.includes(_global.location.hash))){c.next=8;break}return c.abrupt("return",{result:!1,image:null,error:null});case 8:return h=g.debug,i=g.colorRange,j=g.horizontalOffset,k=g.verticalOffset,l=g.pixels,m=g.threshold,n=g.dpr,o=d*n,p=e*n,q=_global.document.createElement("canvas"),q.height=p,q.width=o,q.style.width=o+"px",q.style.height=p+"px",r=q.getContext("2d",{willReadFrequently:!0}),c.next=19,(0,_html2canvas.html2canvas)(a,{ignoreElements:g.ignoreElements,fillColor:g.fillColor});case 19:if(s=c.sent,"string"!=typeof s){c.next=22;break}return c.abrupt("return",{result:!1,image:null,error:null});case 22:return t=new Image,t.src=s.toDataURL("image/png"),t.crossOrigin="Anonymous",c.next=27,new Promise(function(a){t.addEventListener("load",function(){return a()})});case 27:for(r.drawImage(t,0,0,o,p),u=0,v=2*l,w=2*l,z=Math.floor((o-j*n)/v),A=Math.floor((p-k*n)/w),B=z*A,C=0;C<z;C++)for(D=0;D<A;D++)// 根据间隙调整x和y坐标 | ||
// 获取该像素点的颜色数据 | ||
// x y 要有一定偏移量 尽量取内容区的点 | ||
E=C*v,F=D*v,G=r.getImageData(E+j*n,F+k*n,l,l),H=G.data,isPureColor(H,i)&&u++;return I={result:u<B*m,rate:u/B,image:t.src,whitePixels:u,checkPoints:B,threshold:m},h&&console.log(I),c.abrupt("return",I);case 42:return c.prev=42,c.t0=c["catch"](1),(null===(J=b)||void 0===J?void 0:J.debug)&&console.log("[RUM] Failed to inject blank handler: ",c.t0),c.abrupt("return",{result:!1,image:null,error:c.t0});case 46:case"end":return c.stop()}},c,null,[[1,42]])}));return function(){return a.apply(this,arguments)}}(),performSampleCheck=exports.performSampleCheck=function(){return!0};/** | ||
E=C*v,F=D*v,G=r.getImageData(E+j*n,F+k*n,l,l),H=G.data,isPureColor(H,i)&&u++;return I={result:u<B*m,rate:u/B,image:t.src,whitePixels:u,checkPoints:B,threshold:m},h&&console.log(I),c.abrupt("return",I);case 40:return c.prev=40,c.t0=c["catch"](1),(null===(J=b)||void 0===J?void 0:J.debug)&&console.log("[RUM] Failed to inject blank handler: ",c.t0),c.abrupt("return",{result:!1,image:null,error:c.t0});case 44:case"end":return c.stop()}},c,null,[[1,40]])}));return function(){return a.apply(this,arguments)}}(),performSampleCheck=exports.performSampleCheck=function(){return!0};/** | ||
* 检查给定像素数据是否为纯色。 | ||
@@ -6,0 +6,0 @@ * @param data 像素数据数组,通常由getImageData方法获取。 |
{ | ||
"name": "@arms/rum-browser", | ||
"version": "0.0.24-beta.2", | ||
"version": "0.0.24-beta.3", | ||
"description": "arms rum javascript sdk for browser", | ||
@@ -26,3 +26,3 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", | ||
"@arms/rum-core": "0.0.23", | ||
"web-vitals": "^3.4.0" | ||
"web-vitals": "3.5.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
720
67465
Updatedweb-vitals@3.5.2