anys-web 1.1.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/recorder-plugin.js +10 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
- package/src/recorder-plugin.js +12 -8
package/cjs/recorder-plugin.js
CHANGED
|
@@ -20,10 +20,10 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.crea
|
|
|
20
20
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
21
|
let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
22
22
|
_inheritsLoose(AnysRecorderPlugin, _AnysPlugin);
|
|
23
|
-
function AnysRecorderPlugin(anys, [
|
|
23
|
+
function AnysRecorderPlugin(anys, [offlineStore, urlMonitor, windowSizeMonitor, DOMMutationMonitor]) {
|
|
24
24
|
var _this;
|
|
25
25
|
_this = _AnysPlugin.call(this, anys) || this;
|
|
26
|
-
_this.
|
|
26
|
+
_this.offlineStore = offlineStore;
|
|
27
27
|
_this.urlMonitor = urlMonitor;
|
|
28
28
|
_this.windowSizeMonitor = windowSizeMonitor;
|
|
29
29
|
_this.DOMMutationMonitor = DOMMutationMonitor;
|
|
@@ -74,7 +74,6 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
74
74
|
this.anys.on('refreshTraceId', autoReportWhenRefreshTraceId);
|
|
75
75
|
const timer = setInterval(() => {
|
|
76
76
|
this.anys.report();
|
|
77
|
-
this.cache = {};
|
|
78
77
|
}, this.anys.options.reportInterval);
|
|
79
78
|
let isUnloaded = 0;
|
|
80
79
|
const sendBeaconWhenBeforeUnload = () => {
|
|
@@ -85,7 +84,7 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
85
84
|
const ids = Object.keys(this.cache);
|
|
86
85
|
const logs = Object.values(this.cache);
|
|
87
86
|
if (ids.length) {
|
|
88
|
-
this.
|
|
87
|
+
this.offlineStore.remove(ids); // async may not executed
|
|
89
88
|
navigator.sendBeacon(this.anys.options.reportUrl, JSON.stringify(logs));
|
|
90
89
|
this.cache = {};
|
|
91
90
|
}
|
|
@@ -115,7 +114,7 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
115
114
|
* @returns
|
|
116
115
|
*/;
|
|
117
116
|
_proto.read = function read(message) {
|
|
118
|
-
return this.
|
|
117
|
+
return this.offlineStore.read(message);
|
|
119
118
|
};
|
|
120
119
|
_proto.send = function send(logs) {
|
|
121
120
|
const groups = [];
|
|
@@ -127,7 +126,7 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
127
126
|
i++;
|
|
128
127
|
}
|
|
129
128
|
});
|
|
130
|
-
groups.
|
|
129
|
+
const defers = groups.map(data => {
|
|
131
130
|
const items = [];
|
|
132
131
|
const ids = [];
|
|
133
132
|
data.forEach(item => {
|
|
@@ -146,13 +145,16 @@ let AnysRecorderPlugin = /*#__PURE__*/function (_AnysPlugin) {
|
|
|
146
145
|
reportParams
|
|
147
146
|
} = this.anys.options;
|
|
148
147
|
const url = reportParams ? (0, _anysShared.replaceUrlSearch)(reportUrl, reportParams) : reportUrl;
|
|
149
|
-
(0, _anysShared.ajaxPost)(url, items).then(() => {
|
|
150
|
-
this.offlineLogger.remove(ids);
|
|
148
|
+
return (0, _anysShared.ajaxPost)(url, items).then(() => {
|
|
151
149
|
ids.forEach(id => {
|
|
152
150
|
delete this.cache[id];
|
|
153
151
|
});
|
|
154
152
|
});
|
|
155
153
|
});
|
|
154
|
+
return Promise.all(defers);
|
|
155
|
+
};
|
|
156
|
+
_proto.clear = function clear() {
|
|
157
|
+
this.cache = {};
|
|
156
158
|
};
|
|
157
159
|
_proto.auth = function auth(info) {
|
|
158
160
|
this.anys.options.reportParams = Object.assign(this.anys.options.reportParams || {}, info);
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";function n(e){return Array.isArray(e)}function r(e,t){return"function"==typeof e&&(!t||!function(e,t){if("function"!=typeof e)return!1;if(e===Symbol)return!1;if(!e.prototype)return!1;const n=e+"",r=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim(),o=0===n.indexOf("class "),i="[native code]"===r,s=o||i;if(t>=4)return s;const c=r.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),a=/^_classCallCheck\(this,/.test(c),u=/^\(.*?_classCallCheck.*?\)\(this,/.test(c),h=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(c),d=s||a||u||h;if(3==t)return d;const p=Object.getOwnPropertyDescriptors(e.prototype),l=!!Object.keys(p).filter((e=>"constructor"!==e)).length,f=d||l;if(2==t)return f;const m=0===c.indexOf("this.")||c.indexOf(";this.")>-1||c.indexOf("=this;")>-1,y=f||m;if(1==t)return y;return!0}(e,2))}function o(e=16){const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";let n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n}function i(e,t,r){return r?(()=>{const n=Object.getOwnPropertyDescriptors(e);Object.keys(n).forEach((r=>{const o=n[r],{get:i,set:s,enumerable:c,configurable:a,writable:u}=o;(c||i||s||a&&u)&&t(o,r,e)}))})():(()=>{if(n(e))e.forEach(t);else{Object.keys(e).forEach((n=>{const r=e[n];t(r,n,e)}))}})()}e.r(t),e.d(t,{create:()=>X});Symbol("Proxy");let s=function(){function e(t){this.$events=[];const s=(c=this,Object.getPrototypeOf(c).constructor);var c;const{filters:a=[],plugins:u=[],...h}={...e.defaultOptions,...s.defaultOptions||{}},{filters:d=[],plugins:p=[],defines:l=[],...f}=t||{},m={},y=[],v={},g=p&&!n(p)&&"object"==typeof p,b=g?Object.values(p):n(p)?p:[],w=g?Object.keys(p).map((e=>({key:e,value:p[e]}))):[],O=[...u,...b],E=e=>{e.forEach((e=>{const t=e.dependencies||[];t.forEach((e=>{O.unshift(e)})),E(t)}))};E(O);const L=O.filter(((e,t)=>t===O.indexOf(e))),j=[],_={};L.forEach((e=>{const t=w.find((t=>t.value===e))?.key;if(t&&_[t])return void(t=>{const n=`[Anys]: plugin named '${t}' has been registered`;_[t]instanceof e?console.debug(n,e,_):console.error(n,e,_)})(t);const n=(e.dependencies||[]).map((e=>j.find((t=>t instanceof e)))),r=new e(this,n);r.options&&Object.assign(m,r.options()),r.filters&&y.push(...r.filters()),r.defines&&Object.assign(v,r.defines()),j.push(r),t&&(_[t]=r)})),this.$plugins=j,this.plugins=_,this.options={...h,...m,...f},this.filters=[...a,...y,...d];const x=Object.values(this.options).find((e=>e&&e instanceof Error));if(x)throw x;const P={...v,...l};this.definitions=P,this.clientId=P.client?P.client():o(8),this.traceId=P.trace?P.trace():o(8),this.requestId=o(8);const I={};Object.defineProperties(I,function(e,t){if(n(e))return e.map(t);{const n={};return i(e,((r,o)=>{n[o]=t(r,o,e)})),n}}(P,(e=>({get:r(e)?e:()=>e,enumerable:!0,configurable:!0})))),Object.defineProperties(I,{client:{get:()=>this.clientId,enumerable:!0,configurable:!0},trace:{get:()=>this.traceId,enumerable:!0,configurable:!0},request:{get:()=>this.requestId,enumerable:!0,configurable:!0}}),this.$basicLog=I,this.invoke("init"),this.options.autoStart&&this.start()}var t=e.prototype;return t.define=function(e,t){Object.defineProperty(this.$basicLog,e,{get:t,enumerable:!0,configurable:!0})},t.on=function(e,t){this.$events.push([e,t])},t.off=function(e,t){this.$events.forEach(((n,r)=>{n[0]===e&&n[1]===t&&this.$events.splice(r,1)}))},t.emit=function(e,...t){this.$events.forEach((n=>{n[0]!==e&&"*"!==n[0]||n[1](...t)}))},t.invoke=function(e,...t){for(let n=0,o=this.$plugins.length;n<o;n+=1){const o=this.$plugins[n];o[e]&&(r(o[e])&&o[e](...t))}},t.refreshTraceId=function(){const e=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():o(8),this.emit("refreshTraceId",{prev:e,next:this.traceId})},t.refreshRequestId=function(){const e=this.requestId;this.requestId=o(8),this.emit("refreshRequestId",{prev:e,next:this.requestId})},t.start=function(){this.invoke("start"),this.emit("start")},t.write=function(e){setTimeout((()=>{const t={...this.$basicLog,...e},{filters:n}=this;for(let e=0,r=n.length;e<r;e+=1){if(!(0,n[e])(t))return}this.invoke("write",t),this.emit("write",t)}),0)},t.report=function(e){return new Promise(((t,o)=>{setTimeout((()=>{this.emit("report",e);const i=[],s=[],c=[],a=[],u=(...e)=>e.reduce(((e,t)=>r(t)?e.then(t):e),Promise.resolve()),h=(e,t)=>Promise.all(e.map((e=>u((()=>e(t))))));for(let t=0,n=this.$plugins.length;t<n;t+=1){const n=this.$plugins[t];if(r(n.read)&&r(n.send)){const t=u((()=>n.read(e)),(e=>e&&Promise.resolve(n.send(e)).then((()=>e))),(e=>e&&r(n.complete)&&n.complete(e)));i.push(t)}else r(n.read)?s.push(n.read.bind(n)):r(n.send)&&c.push(n.send.bind(n)),r(n.complete)&&a.push(n.complete.bind(n))}const d=u((()=>h(s,e)),(e=>{const t=[];return e.forEach((e=>n(e)&&e.length&&t.push(...e))),this.emit("read",t),t}),(e=>{if(e.length)return this.emit("send",e),h(c,e).then((()=>e))}),(e=>{if(e)return this.emit("complete",e),h(a,e)})),p=Promise.all(i);Promise.all([d,p]).then(t,o)}),0)}))},t.stop=function(){this.invoke("stop"),this.emit("stop")},e}();function c(e,t){if(e.indexOf("?")<0){const n=Object.keys(t).map((e=>`${e}=${t[e]}`)).join("&"),[r,o]=e.split("#");return r+"?"+n+(o?"#"+o:"")}const[n,r]=e.split("?"),[o,i]=r.split("#"),s=o.split("&").map((e=>e.split("="))).reduce(((e,[t,n])=>({...e,[t]:n})),{});Object.assign(s,t);return n+"?"+Object.keys(s).map((e=>`${e}=${s[e]}`)).join("&")+(i?"#"+i:"")}s.defaultOptions={autoStart:!0,autoReport:!0};let a=function(){function e(e){this.anys=e,this.$effects={}}var t=e.prototype;return t.start=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=e=>{const t=`register${e.replace(e[0],e[0].toUpperCase())}`;if(this[t]){const n=this[t]();this.$effects[e]=n}},r=this.anys.options;t.forEach((e=>{r[e]&&n(e)}))},t.stop=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=this.anys.options;t.forEach((e=>{const t=this.$effects[e];n[e]&&t&&t(),this.$effects[e]=null}))},e}(),u=function(){function e(){this.$events=[]}var t=e.prototype;return t.on=function(e,t){this.$events.push([e,t])},t.emit=function(e,...t){this.$events.forEach((([n,r])=>{e===n&&r(...t)}))},t.off=function(e,t){this.$events.forEach((([n,r],o)=>{e===n&&r===t&&this.$events.splice(o,1)}))},e}();function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}const d=new u;!function(){const e=window.XMLHttpRequest;window.__XMLHttpRequest=e,window.XMLHttpRequest=function(){const t=new e,n={open:t.open,send:t.send},r={name:o(4)},i=e=>{const{name:n,url:o,method:i}=r;let s,c;t.responseType&&"text"!==t.responseType?"json"===t.responseType&&(s=t.response,c="json"):(s=t.responseText.toString(),c="text"),d.emit("xhr",{type:e,time:Date.now(),name:`xhr_${n}`,url:o,detail:{status:t.status,method:i,responseType:c,response:s||void 0}})},s=()=>{4===t.readyState&&(2===Math.floor(t.status/100)?i("xhr.ok"):i("xhr.fail"))};return Object.defineProperty(t,"open",{get:()=>(e,o,i=!0,...s)=>{const c={method:e,url:o};d.emit("request",c),Object.assign(r,{...c,async:i}),t.onreadystatechange&&(n.onreadystatechange=t.onreadystatechange);const{open:a}=n;return a.call(t,c.method,c.url,i,...s)},configurable:!0}),Object.defineProperty(t,"send",{get:()=>e=>{const{send:o}=n,{async:i}=r;Object.assign(r,{body:e}),(()=>{const{name:e,url:t,method:n,async:o,body:i}=r;d.emit("xhr",{type:"xhr.req",time:Date.now(),name:`xhr_${e}`,url:t,detail:{method:n,async:o,body:i}})})();const c=o.call(t,e);return i||s(),c},configurable:!0}),t.addEventListener("error",(()=>{i("xhr.err")})),t.addEventListener("readystatechange",(e=>{s()})),t}}(),function(){const e=window.fetch;window.__fetch=e,window.fetch=function(t,n={}){const{method:r,body:i}=n,s=o(4);d.emit("fetch",{type:"fetch.init",time:Date.now(),name:`fetch_${s}`,url:t,detail:{body:i,method:r}});const c={method:r,url:t};return d.emit("request",c),Promise.resolve().then((()=>e(c.url,n))).then((e=>{const{status:n}=e;return 2===Math.floor(n/100)?new Proxy(e,{get:(o,i)=>"json"===i||"text"===i?()=>e[i]().then((e=>(d.emit("fetch",{type:"fetch.ok",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,data:e,method:r}}),e))):"function"==typeof e[i]?e[i].bind(e):e[i]}):(d.emit("fetch",{type:"fetch.fail",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,method:r}}),e)}),(e=>{let n;if(e instanceof Error){const{name:t,message:o}=e;n={method:r,type:t,err:o}}else n={method:r,err:e};d.emit("fetch",{type:"fetch.err",time:Date.now(),name:`fetch_${s}`,url:t,detail:n})}))}}();let p=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,h(t,n);var o=r.prototype;return o.options=function(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}},o.registerXhr=function(){const e=e=>{this.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,this.anys.write(e)};return d.on("xhr",e),()=>d.off("xhr",e)},o.registerFetch=function(){const e=e=>{this.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,this.anys.write(e)};return d.on("fetch",e),()=>d.off("fetch",e)},o.registerPatchRequestId=function(){const e=e=>{const{url:t}=e,{traceId:n,requestId:r}=this.anys,o=c(t,{_request_id:n+r});e.url=o};return d.on("request",e),()=>d.off("request",e)},r}(a),l=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!")}},t.defines=function(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}},t.defineClientId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.clientId`;let n=localStorage.getItem(t);return n||(n=o(8),sessionStorage.setItem(t,n)),n},t.defineTraceId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.traceId`,n=o(8);return sessionStorage.setItem(t,n),n},e}();function f(e,t=document.documentElement){const{nodeName:n,path:r}=e;if(r)return r;if("BODY"===n||"HTML"===n||"HEAD"===n)return n;const o=[];let i=e,s=e.parentNode;const c=e=>{const{nodeName:t,parentNode:n}=e;if(!n)return-1;return[].filter.call(n.childNodes,(e=>e.nodeName===t)).indexOf(e)};if("#"===n[0]){const t=c(e);o.push(`${n}:${t}`),i=s,s=i.parentNode}for(;s&&i!==t;){const{nodeName:e}=i;if("BODY"===e||"HTML"===e||"HEAD"===e)o.push(e);else{const t=c(i);o.push(`${e.toLowerCase()}:${t}`)}i=s,s=i.parentNode}return o.reverse(),o.join("/")}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}let y=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,m(t,n);var o=r.prototype;return o.options=function(){return{input:!0}},o.registerInput=function(){const e=e=>t=>{const{target:n,type:r,inputType:o,data:i}=t;if("insertCompositionText"===o)return;if("compositionend"===r&&!i)return;const{tagName:s,value:c}=n;if(n.getAttribute("anys-ignore"))return;const a=n.getAttribute("type"),u=e({tagName:s,value:c,type:a,target:n});if(!u)return;const h={type:"input",time:Date.now(),el:f(n),detail:u};this.anys.write(h)},t=e((({tagName:e,value:t,type:n})=>"INPUT"===e&&"radio"!==n&&"checkbox"!==n&&"password"!==n?{value:t,type:n}:"INPUT"===e&&"password"===n?{value:"***",type:n}:"TEXTAREA"===e?{value:t,type:"textarea"}:void 0)),n=e((({tagName:e,value:t,type:n})=>"SELECT"===e?{value:t,type:"select"}:"INPUT"!==e||"radio"!==n&&"checkbox"!==n?void 0:{value:t,type:n})),r=e((({tagName:e,value:t,type:n})=>"TEXTAREA"===e?{value:t,type:"textarea"}:"INPUT"===e?{value:t,type:n}:void 0));return document.addEventListener("input",t,!0),document.addEventListener("compositionend",t,!0),document.addEventListener("change",n,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("input",t),document.removeEventListener("compositionend",t),document.removeEventListener("change",n),document.removeEventListener("paste",r)}},r}(a);function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}let g=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,v(t,n);var o=r.prototype;return o.options=function(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}},o.addEventListener=function(e,t){if(!this.anys.options.mouse)return;const n=this.createThrottleListener((t=>{const{innerWidth:n,innerHeight:r}=window,{target:o,button:i,pageX:s,pageY:c}=t;return{type:e,time:Date.now(),detail:{e:f(o),w:n,h:r,x:s,y:c,button:i}}}),t);return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerClick=function(){return this.addEventListener("click")},o.registerMouseup=function(){return this.addEventListener("mouseup")},o.registerMousedown=function(){return this.addEventListener("mousedown")},o.registerContextmenu=function(){return this.addEventListener("contextmenu")},o.registerMousemove=function(){return this.addEventListener("mousemove",100)},o.registerWheel=function(){if(!this.anys.options.mouse)return;const e="wheel",t=this.createThrottleListener((t=>{const{target:n,deltaX:r,deltaY:o,deltaZ:i,deltaMode:s}=t;return{type:e,time:Date.now(),detail:{e:f(n),deltaX:r,deltaY:o,deltaZ:i,mode:s}}}),100);return document.addEventListener(e,t),()=>document.removeEventListener(e,t)},o.createThrottleListener=function(e,t){let n=0,r=0;return o=>{if(n)return;const i=Date.now();if(t&&r+t>i)return;const s=e(o);requestAnimationFrame((()=>{this.anys.write(s),n=0,r=Date.now()})),n=1}},r}(a);function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}const w={type:"window_activity.enter",time:Date.now()};let O=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,b(t,n);var o=r.prototype;return o.options=function(){return{activity:!0,deadTimeout:0}},o.init=function(){this.anys.options.activity&&this.anys.write(w)},o.registerActivity=function(){const e=()=>{if("hidden"===document.visibilityState){const e={type:"window_activity.focusout",time:Date.now()};this.anys.write(e)}else{const e={type:"window_activity.focusin",time:Date.now()};this.anys.write(e)}},t=()=>{const e={type:"window_activity.unload",time:Date.now()};this.anys.write(e)};return window.addEventListener("beforeunload",t,!0),document.addEventListener("visibilitychange",e,!0),()=>{window.removeEventListener("beforeunload",t),document.removeEventListener("visibilitychange",e)}},o.registerDeadTimeout=function(){const{deadTimeout:e}=this.anys.options;if(!e)return;let t;const n=()=>{clearTimeout(t),t=setTimeout((()=>{const e={type:"window_activity.dead",time:Date.now()};this.anys.write(e)}),e)};return document.addEventListener("keydown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("touchstart",n,!0),document.addEventListener("touchmove",n,!0),document.addEventListener("mousemove",n,!0),document.addEventListener("scroll",n,!0),window.addEventListener("resize",n,!0),()=>{document.removeEventListener("keydown",n),document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n),document.removeEventListener("mousemove",n),document.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},r}(a);function E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}let L=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,E(t,n);var o=r.prototype;return o.options=function(){return{url:!0}},o.registerUrl=function(){const e=()=>{this.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),()=>{window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}},o.recordUrl=function(){const e=window.location.href,t=new URL(e),n=t.pathname.replace(/^([^/])/,"/$1"),r={type:"url",time:Date.now(),url:e,detail:{uri:n+(t.search?`?${t.search}`:""),path:n,protocol:t.protocol.replace(":",""),host:t.hostname,port:t.port,search:t.search,hash:t.hash.replace("#","")}};this.anys.write(r)},r}(a);function j(e,t){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j(e,t)}let _=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,j(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,touchstart:e,touchend:e,touchmove:e}},o.addEventListener=function(e){if(!this.anys.options.touch)return;let t=0;const n=n=>{if(t)return;const{innerWidth:r,innerHeight:o}=window,{target:i,identifier:s,force:c,pageX:a,pageY:u}=n,h={type:e,time:Date.now(),detail:{e:f(i),width:r,height:o,x:a,y:u,identifier:s,force:c}};requestAnimationFrame((()=>{this.anys.write(h),t=0})),t=1};return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerTouchmove=function(){return this.addEventListener("touchmove")},o.registerTouchend=function(){return this.addEventListener("touchend")},o.registerTouchstart=function(){return this.addEventListener("touchstart")},r}(a),x=function(){function e(){this.queue=[],this.status=0}return e.prototype.push=function(e){let t,n;const r=new Promise(((e,r)=>{t=e,n=r})),o={runner:e,resolve:t,reject:n};this.queue.push(o);const i=()=>{setTimeout((()=>{if(!this.queue.length)return void(this.status=0);const{runner:e,resolve:t,reject:n}=this.queue.shift();e().then(t,n).finally(i)}),0),this.status=1};return this.status||i(),r},e}(),P=function(){function e(e={}){let{name:t,version:n=1,stores:r}=e;const o=!t;t||(t="__indb__"),r&&Array.isArray(r)&&r.length||(r=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=t,this.version=n,this.stores=r;const i=indexedDB.open(t,n);if(i.onupgradeneeded=e=>{const t=e.target.result,n=Array.from(t.objectStoreNames),o=[];r.forEach((r=>{let i=null;if(n.indexOf(r.name)>-1)i=e.target.transaction.objectStore(r.name);else{const e=r.isKv?"key":r.primaryKeyPath,n=!r.isKv&&r.autoIncrement;i=t.createObjectStore(r.name,{keyPath:e,autoIncrement:n})}const s=i.indexNames;s&&s.length&&Array.from(s).forEach((e=>i.deleteIndex(e))),r.indexes&&r.indexes.length&&r.indexes.forEach((e=>{i.createIndex(e.name,e.keyPath||e.name,{unique:e.unique,multiEntry:Array.isArray(e.keyPath)})})),o.push(r.name)})),n&&n.forEach((e=>{-1===o.indexOf(e)&&t.deleteObjectStore(e)}))},i.onblocked=e=>{console.error(D(new Error("indexedDB "+t+" is blocked")))},o)return this.use(t)}var t=e.prototype;return t.connect=function(){return new Promise(((e,t)=>{const n=indexedDB.open(this.name,this.version);n.onerror=e=>{t(D(e))},n.onsuccess=t=>{e(t.target.result)}}))},t.use=function(e){const t=this.stores.find((t=>t.name===e));if(!t)throw new Error(`[InDB]: store ${e} is not existing.`);if(this.cache[e])return this.cache[e];const n=new I({db:this,store:t});return t.isKv&&Object.defineProperties(n,{key:{value:e=>n.keys().then((t=>t&&t[e]))},getItem:{value:e=>n.get(e).then((e=>e&&e.value))},setItem:{value:(e,t)=>n.put({key:e,value:t})},removeItem:{value:e=>n.delete(e)}}),this.cache[e]=n,n},t.close=function(){return this.cache=null,this.stores=null,this.connect().then((e=>{e.close()}))},e.deleteDatabase=function(e){return new Promise(((t,n)=>{const r=indexedDB.deleteDatabase(e);r.onsuccess=()=>{t()},r.onerror=e=>{n(e)}}))},e.databases=function(){return indexedDB.databases()},e}();let I=function(){function e(e={}){const{store:t,db:n}=e;if("object"!=typeof t||!t.name||"string"!=typeof t.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(n instanceof P))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=n,this.store=t,this.name=t.name,this.primaryKeyPath=t.isKv?"key":t.primaryKeyPath,this._queue=[]}var t=e.prototype;return t.transaction=function(e=!1){const t=()=>{const t=this.name,n=e?"readwrite":"readonly",r=this.db.connection;return(r?Promise.resolve(r):this.db.connect()).then((e=>{this.db.connection=e;const r=e.transaction(t,n),o=()=>{this.db.connection=null,this._queue.shift()};return r.oncomplete=o,r.onabort=o,r.onerror=o,r}))},n=this._queue[this._queue.length-1],r=n?n.then((()=>t())):t();return this._queue.push(r),r},t.objectStore=function(e=!1){const t=this.name;return this.transaction(e).then((e=>e.objectStore(t)))},t.cursor=function(e){const{index:t,range:n,direction:r,onTouch:o,onDone:i,onError:s,writable:c=!1}=e;return this.objectStore(c).then((e=>{const c=t?e.index(t):e,a=c.openCursor(n,r);a.onsuccess=e=>{const t=e.target.result;t?o(t,c):i(t,c)},a.onerror=e=>{s(D(e))}}))},t.request=function(e,t={}){const{writable:n=!1}=t;return new Promise(((t,r)=>{this.objectStore(n).then((n=>{const o=e(n);o.onsuccess=e=>{const n=e.target.result;t(n)},o.onerror=e=>{r(D(e))}}))}))},t.iterate=function(e,t={}){const{index:n,range:r,writable:o=!1,direction:i="next"}=t;return new Promise(((t,s)=>{this.cursor({index:n,range:r,writable:o,direction:i,onTouch:(n,r)=>{e(n,(()=>n.continue()),(()=>{r.transaction.commit(),t()}))},onDone:()=>{t()},onError:e=>{s(e)}})}))},t.batch=function(e,t={}){const{writable:n=!0}=t;return this.transaction(n).then((t=>{const n=this.name,r=[],o=t.objectStore(n);return e.forEach((e=>{const t=new Promise(((t,n)=>{const r=e(o);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onerror=e=>{n(D(e))}}));r.push(t)})),Promise.all(r)}))},t.get=function(e){if(!Array.isArray(e))return this.request((t=>t.get(e)));const t=e.map((e=>t=>t.get(e)));return this.batch(t,{writable:!1})},t.keys=function(){const e=this.primaryKeyPath,t=[];return this.each((n=>{const r=A(n,e);t.push(r)})).then((()=>t))},t.all=function(){const e=[];return this.each((t=>{e.push(t)})).then((()=>e))},t.count=function(){return this.request((e=>e.count()))},t.each=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}))},t.reverse=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}),{direction:"prev"})},t.some=function(e=10,t=0){return new Promise(((n,r)=>{const o=[];let i,s=0,c=t,a=t+e;t<0&&(i="prev",e=Math.min(e,-t),c=-(t+e)||0,a=c+e),this.iterate(((e,t,n)=>{s<c?(s++,t()):s<a?(o.push(e.value),s++,t()):n()}),{direction:i}).then((()=>{t<0&&o.reverse(),n(o)})).catch(r)}))},t.first=function(){return this.some(1).then((e=>e[0]))},t.last=function(){return this.some(1,-1).then((e=>e[0]))},t.find=function(e,t){return this.request((n=>n.index(e).get(t)))},t.query=function(e,t,n){const r=function(){switch(n){case">":return IDBKeyRange.lowerBound(t,!0);case">=":return IDBKeyRange.lowerBound(t);case"<":return IDBKeyRange.upperBound(t,!0);case"<=":return IDBKeyRange.upperBound(t);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(t)}}(),o=[];return new Promise(((i,s)=>{this.cursor({index:e,range:r,onTouch:(e,r)=>{const i=e.value,s=A(i,r.keyPath);"!="===n?s!==t&&o.push(i):"%"===n?"string"==typeof s&&s.indexOf(t)>-1&&o.push(i):"in"===n?Array.isArray(t)&&t.indexOf(s)>-1&&o.push(i):o.push(i),e.continue()},onDone:()=>{i(o)},onError:e=>{s(e)}})}))},t.select=function(...e){const t=this.store.indexes||[],n={};t.forEach((e=>{const{name:t,keyPath:r}=e;n[t]=r}));const r=function(e,t,n){if(void 0===e)return!1;switch(n){case">":return e>t;case">=":return e>=t;case"<":return e<t;case"<=":return e<=t;case"!=":return e!==t;case"%":return"string"==typeof e&&e.indexOf(t)>-1;case"in":return Array.isArray(t)&&t.indexOf(e)>-1;default:return e===t}},o=function(e,t,n){if(!t.length&&!n.length)return!1;for(let n=0,o=t.length;n<o;n++){const{keyPath:o,value:i,compare:s}=t[n],c=A(e,o);if(!r(c,i,s))return!1}if(!n.length)return!0;for(let t=0,o=n.length;t<o;t++){const{keyPath:o,value:i,compare:s}=n[t],c=A(e,o);if(r(c,i,s))return!0}return!1},i=[];e.forEach((e=>{const t=[],r=[];for(let o=0,i=e.length;o<i;o++){const{key:i,value:s,compare:c,optional:a}=e[o],u=n[i]||i;a?t.push({keyPath:u,value:s,compare:c}):r.push({keyPath:u,value:s,compare:c})}i.push([r,t])}));const s=[];return this.each((e=>{(e=>{for(let t=0,n=i.length;t<n;t++){const[n,r]=i[t];if(o(e,n,r))return!0}return!1})(e)&&s.push(e)})).then((()=>s))},t.add=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.add(e[0],t);const r=n.map((e=>n=>n.add(e,t)));return this.batch(r)}return e?this.request((n=>n.add(e,t)),{writable:!0}):Promise.resolve()},t.put=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.put(n[0],t);const r=n.map((e=>n=>n.put(e,t)));return this.batch(r)}return e?this.request((n=>n.put(e,t)),{writable:!0}):Promise.resolve()},t.delete=function(e){if(Array.isArray(e)){const t=e;if(t.length<2)return this.delete(t[0]);const n=t.map((e=>t=>t.delete(e)));return this.batch(n)}return e?this.request((t=>t.delete(e)),{writable:!0}):Promise.resolve()},t.remove=function(e){const t=this.primaryKeyPath;if(Array.isArray(e)){const n=e;if(n.length<2)return this.remove(n[0]);const r=n.map((e=>{const n=A(e,t);return e=>e.delete(n)}));return this.batch(r)}if(!e)return Promise.resolve();const n=A(e,t);return n?this.delete(n):Promise.resolve()},t.clear=function(){return this.request((e=>e.clear()),{writable:!0})},e}();function A(e,t){if(null==t)return;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++){const r=A(e,t[n]);if(void 0!==r)return r}return}let n=function(e){return e.toString().split(/\.|\[|\]/).filter((e=>!!e))}(t);if(!n.length)return e;let r=e;for(let e=0,t=n.length;e<t;e++){let t=n[e];if(void 0===r[t])return;r=r[t]}return r}function D(e){const{message:t}=e;return e.message=-1===t.indexOf("[IndexedDB]")?"[IndexedDB]: "+t:t,e}let q=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!"),autoReport:!1,expireTime:1728e5}},t.init=function(){const e="anyslogs",t=new P({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=t.use(e),this.queue=new x;const{expireTime:n}=this.anys.options;if(n){let e=0;const t=setInterval((()=>{this.queue.push((()=>this.db.some(100,e))).then((r=>{if(!r.length)return void clearInterval(t);const o=Date.now(),i=[];r.forEach((e=>{const{_id:t,time:r}=e;o-r>n&&i.push(t)})),i.length&&this.queue.push((()=>this.db.delete(i))),e+=100,e-=i.length}))}),1e4)}},t.write=function(e){this.queue.push((()=>this.db.add(e))).then((t=>{this.anys.emit("writeOfflineLog",{id:t,data:e})}))},t.read=function(e){if(e){if(!Array.isArray(e))return;if(e.some((e=>!e.key)))return}else e=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(e)},t.select=function(e){return this.queue.push((()=>this.db.select(e)))},t.remove=function(e){return this.queue.push((()=>this.db.delete(e))).catch((()=>{}))},e}();function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}let k=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,T(t,n);var o=r.prototype;return o.options=function(){return{mutation:!0}},o.registerMutation=function(){const e=this.createObserver((e=>{const t={type:"mutation",time:Date.now(),detail:e};this.anys.write(t)}));return window.addEventListener("load",(()=>{e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),this.recordSnapshot(),$(document.documentElement)})),()=>{e.disconnect()}},o.recordSnapshot=function(){const e=function(){const{name:e,publicId:t,systemId:n}=document.doctype,r={name:e,publicId:t,systemId:n},o=S(document.documentElement.innerHTML),i={},s=document.querySelector("html");for(let{name:e,value:t}of s.attributes)i[e]=t;const c=function(){const e=document.querySelectorAll("input, textarea, select"),t=[];return Array.from(e).forEach((e=>{const n=f(e),r="password"===e.type?"***":e.value;t.push({el:n,value:r})})),t}();return{doctype:r,attrs:i,html:o,values:c}}(),t=window.location.href,n=new URL(t),r=n.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:r+(n.search?`?${n.search}`:""),path:r,protocol:n.protocol.replace(":",""),host:n.hostname,port:n.port,search:n.search,hash:n.hash.replace("#","")},detail:e})},o.createObserver=function(e){const t=new MutationObserver((t=>{const n=[];[...t].reverse().forEach((e=>{const{type:t,target:r,attributeName:o,oldValue:i}=e;if(!(e=>{if(e.hasAttribute?.("anys-ignore"))return!0;let t=e.parentNode;for(;t;){if(t.hasAttribute?.("anys-ignore"))return!0;t=t.parentNode}return!1})(r)){if("attributes"===t){if(r.getAttribute(o)===i)return;if(n.find((e=>e.type===t&&e.target===r&&e.attributeName===o)))return}else if("characterData"===t){const e=r.data;if(e===i)return;if(n.find((n=>n.type===t&&n.target===r&&n.target.data===e)))return}n.push(e)}})),n.reverse();const r=[];n.forEach((e=>{const{type:t,target:n,attributeName:o,oldValue:i}=e,s=n.path||f(n),c=e=>f(e).replace(s+"/","");if("attributes"===t){const e=n.getAttribute(o),t=i;r.push({type:"attribute",target:s,name:o,next:e,prev:t})}else if("characterData"===t){const e=n.data,t=i;r.push({type:"text",target:s,next:e,prev:t})}else if("childList"===t){if("TEXTAREA"===n.nodeName)return;const{removedNodes:t,addedNodes:o,previousSibling:i,nextSibling:a}=e,u=[],h=Array.from(t).map((e=>{if(document.body.contains(e))return void u.push({node:e,path:f(e)});const t=e.path?c(e):null,n=i?f(i):null,r=a?f(a):null,o={};return t?o.node=t:(o.before=n,o.after=r),o})).filter(Boolean),d=[],p=Array.from(o).map((e=>{const t=e.nextSibling?c(e.nextSibling):null,n=u.find((t=>t.node===e));if(n)return void d.push({node:n.path,sibling:t});const r="#text"===e.nodeName,o="#comment"===e.nodeName,i=r?e.data:null,s=o?e.data:null;return{text:i,html:r||o?null:S(e.outerHTML),comment:s,sibling:t}})).filter(Boolean);r.push({type:"children",target:s,remove:h,insert:p,move:d}),$(n)}})),e(r)}));return $(document),t},r}(a);function $(e){if(e!==document){const t=f(e);e.path=t}const t=e.childNodes;Array.from(t).forEach((e=>{$(e)}))}function S(e){return e.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}function M(e,t){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},M(e,t)}let N=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,M(t,n);var o=r.prototype;return o.options=function(){return{size:!0}},o.createRecordLog=function(){const{innerWidth:e,innerHeight:t}=window;return{type:"window_size",time:Date.now(),detail:{width:e,height:t}}},o.registerSize=function(){let e;const t=()=>{clearTimeout(e);const t=this.createRecordLog();e=setTimeout((()=>{this.anys.write(t)}),100)};return this.recordSize(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},o.recordSize=function(){const e=this.createRecordLog();this.anys.write(e)},r}(a);function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}let B=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,R(t,n);var o=r.prototype;return o.options=function(){return{scroll:!0}},o.registerScroll=function(){let e=0;const t=t=>{if(e)return;const{target:n,bubbles:r}=t;let o;if(r){const{scrollX:e,scrollY:t}=window;o={type:"window_scroll",time:Date.now(),detail:{scrollX:e,scrollY:t}}}else{const{scrollLeft:e,scrollTop:t}=n;o={type:"scroll",time:Date.now(),target:f(n),detail:{scrollLeft:e,scrollTop:t}}}requestAnimationFrame((()=>{this.anys.write(o),e=0})),e=1};return window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("scroll",t)}},r}(a);function K(e,t){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},K(e,t)}let U=function(e){var t,n;function r(t,[n,r,o,i]){var s;return(s=e.call(this,t)||this).offlineLogger=n,s.urlMonitor=r,s.windowSizeMonitor=o,s.DOMMutationMonitor=i,s.cache={},s}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,K(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,mouse:!e,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("[Anys]: options.reportUrl is required!"),reportInterval:1e4,reportParams:null}},o.registerAutoReport=function(){const{clientId:e}=this.anys,t=({prev:t})=>{this.anys.report([{key:"client",value:e},{key:"trace",value:t}]),this.cache={},this.urlMonitor.recordUrl(),this.windowSizeMonitor.recordSize(),this.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",t);const n=setInterval((()=>{this.anys.report(),this.cache={}}),this.anys.options.reportInterval);let r=0;const o=()=>{if(r)return;r=1;const e=Object.keys(this.cache),t=Object.values(this.cache);e.length&&(this.offlineLogger.remove(e),navigator.sendBeacon(this.anys.options.reportUrl,JSON.stringify(t)),this.cache={})};window.addEventListener("beforeunload",o),window.addEventListener("pagehide",o),window.addEventListener("unload",o);const i=({id:e,data:t})=>{this.cache[e]=t};return this.anys.on("writeOfflineLog",i),()=>{this.anys.off("refreshTraceId",t),this.anys.off("writeOfflineLog",i),clearInterval(n),window.removeEventListener("beforeunload",o)}},o.read=function(e){return this.offlineLogger.read(e)},o.send=function(e){const t=[];let n=0;e.forEach((e=>{t[n]=t[n]||[],t[n].push(e),t[n].length>200&&n++})),t.forEach((e=>{const t=[],n=[];if(e.forEach((e=>{const{_id:r,...o}=e;n.push(r),t.push(o)})),!t.length)return;const{reportUrl:r,reportParams:o}=this.anys.options;(function(e,t){return new Promise(((n,r)=>{const o=new(window.__XMLHttpRequest||window.XMLHttpRequest);o.open("POST",e,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?n(o.responseText):r(new Error(`[Anys]: ajax post fail with status ${o.status}`)))},o.onerror=r,o.send(JSON.stringify(t))}))})(o?c(r,o):r,t).then((()=>{this.offlineLogger.remove(n),n.forEach((e=>{delete this.cache[e]}))}))}))},o.auth=function(e){this.anys.options.reportParams=Object.assign(this.anys.options.reportParams||{},e)},r}(a);U.dependencies=[q,L,N,k,l,p,y,g,O,_,B];const X=(e={})=>new s({namespace:"AnysTracer",autoReport:!1,...e,plugins:{...e.plugins||{},recorder:U}})})();var n=anys="undefined"==typeof anys?{}:anys;for(var r in t)n[r]=t[r];t.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";function n(e){return Array.isArray(e)}function r(e,t){return"function"==typeof e&&(!t||!function(e,t){if("function"!=typeof e)return!1;if(e===Symbol)return!1;if(!e.prototype)return!1;const n=e+"",r=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim(),o=0===n.indexOf("class "),i="[native code]"===r,s=o||i;if(t>=4)return s;const c=r.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),a=/^_classCallCheck\(this,/.test(c),u=/^\(.*?_classCallCheck.*?\)\(this,/.test(c),h=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(c),d=s||a||u||h;if(3==t)return d;const l=Object.getOwnPropertyDescriptors(e.prototype),p=!!Object.keys(l).filter((e=>"constructor"!==e)).length,f=d||p;if(2==t)return f;const m=0===c.indexOf("this.")||c.indexOf(";this.")>-1||c.indexOf("=this;")>-1,y=f||m;if(1==t)return y;return!0}(e,2))}function o(e=16){const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";let n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n}function i(e,t,r){return r?(()=>{const n=Object.getOwnPropertyDescriptors(e);Object.keys(n).forEach((r=>{const o=n[r],{get:i,set:s,enumerable:c,configurable:a,writable:u}=o;(c||i||s||a&&u)&&t(o,r,e)}))})():(()=>{if(n(e))e.forEach(t);else{Object.keys(e).forEach((n=>{const r=e[n];t(r,n,e)}))}})()}e.r(t),e.d(t,{create:()=>X});Symbol("Proxy");let s=function(){function e(t){this.$events=[],this.$queue=[];const s=(c=this,Object.getPrototypeOf(c).constructor);var c;const{filters:a=[],plugins:u=[],...h}={...e.defaultOptions,...s.defaultOptions||{}},{filters:d=[],plugins:l=[],defines:p=[],...f}=t||{},m={},y=[],v={},g=l&&!n(l)&&"object"==typeof l,b=g?Object.values(l):n(l)?l:[],w=g?Object.keys(l).map((e=>({key:e,value:l[e]}))):[],O=[...u,...b],E=e=>{e.forEach((e=>{const t=e.dependencies||[];t.forEach((e=>{O.unshift(e)})),E(t)}))};E(O);const _=O.filter(((e,t)=>t===O.indexOf(e))),j=[],L={};_.forEach((e=>{const t=w.find((t=>t.value===e))?.key;if(t&&L[t])return void(t=>{const n=`[Anys]: plugin named '${t}' has been registered`;L[t]instanceof e?console.debug(n,e,L):console.error(n,e,L)})(t);const n=(e.dependencies||[]).map((e=>j.find((t=>t instanceof e)))),r=new e(this,n);r.options&&Object.assign(m,r.options()),r.defines&&Object.assign(v,r.defines()),r.filters&&y.push(...r.filters()),j.push(r),t&&(L[t]=r)})),this.$plugins=j,this.plugins=L,this.options={...h,...m,...f},this.filters=[...a,...y,...d];const P=Object.values(this.options).find((e=>e&&e instanceof Error));if(P)throw P;const x={...v,...p};this.definitions=x,this.clientId=x.client?x.client():o(8),this.traceId=x.trace?x.trace():o(8),this.requestId=o(8);const I={};Object.defineProperties(I,function(e,t){if(n(e))return e.map(t);{const n={};return i(e,((r,o)=>{n[o]=t(r,o,e)})),n}}(x,(e=>({get:r(e)?e:()=>e,enumerable:!0,configurable:!0})))),Object.defineProperties(I,{client:{get:()=>this.clientId,enumerable:!0,configurable:!0},trace:{get:()=>this.traceId,enumerable:!0,configurable:!0},request:{get:()=>this.requestId,enumerable:!0,configurable:!0}}),this.$basicLog=I,this.invoke("init"),this.options.autoStart&&this.start()}var t=e.prototype;return t.define=function(e,t){Object.defineProperty(this.$basicLog,e,{get:t,enumerable:!0,configurable:!0})},t.on=function(e,t){this.$events.push([e,t])},t.off=function(e,t){this.$events.forEach(((n,r)=>{n[0]===e&&n[1]===t&&this.$events.splice(r,1)}))},t.emit=function(e,...t){this.$events.forEach((n=>{n[0]!==e&&"*"!==n[0]||n[1](...t)}))},t.invoke=function(e,...t){for(let n=0,o=this.$plugins.length;n<o;n+=1){const o=this.$plugins[n];o[e]&&(r(o[e])&&o[e](...t))}},t.refreshTraceId=function(){const e=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():o(8),this.emit("refreshTraceId",{prev:e,next:this.traceId})},t.refreshRequestId=function(){const e=this.requestId;this.requestId=o(8),this.emit("refreshRequestId",{prev:e,next:this.requestId})},t.start=function(){this.invoke("start"),this.emit("start")},t.write=function(e){setTimeout((()=>{const t={...this.$basicLog,...e},{filters:n}=this;for(let e=0,r=n.length;e<r;e+=1){if(!(0,n[e])(t))return}this.invoke("write",t),this.emit("write",t)}),0)},t.report=function(e){let t,o;const i=new Promise(((e,n)=>{t=e,o=n})),s={message:e,resolve:t,reject:o};this.$queue.push(s),this._reporting=!1;const c=()=>setTimeout((()=>{if(this._reporting)return;this._reporting=!0;const e=this.$queue.shift();if(!e)return;const{message:t,resolve:o,reject:i}=e;this.emit("report",t);const s=[];for(let e=0,t=this.$plugins.length;e<t;e+=1){const t=this.$plugins[e],n={};let o=0;r(t.read)&&(n.read=t.read.bind(t),o=1),r(t.send)&&(n.send=t.send.bind(t),o=1),r(t.clear)&&(n.clear=t.clear.bind(t),o=1),o&&s.push(n)}const a=(e,...t)=>Promise.resolve().then((()=>r(e)?e(...t):null));((...e)=>e.reduce(((e,t)=>r(t)?e.then(t):e),Promise.resolve()))((()=>Promise.all(s.map((e=>a(e.read,t).then((t=>(e.data=t,t))))))),(e=>{const t=[];return e.forEach((e=>{n(e)&&e.length&&t.push(...e)})),this.emit("read",t),t}),(e=>{if(e.length)return this.emit("send",e),Promise.all(s.map((t=>a(t.send,t.data,e)))).then((()=>e))}),(e=>{if(e)return this.emit("clear",e),Promise.all(s.map((e=>a(e.clear,e.data))))})).then(o,i).finally((()=>{this._reporting=!1,c()}))}),0);return c(),i},t.stop=function(){this.invoke("stop"),this.emit("stop")},e}();function c(e,t){if(e.indexOf("?")<0){const n=Object.keys(t).map((e=>`${e}=${t[e]}`)).join("&"),[r,o]=e.split("#");return r+"?"+n+(o?"#"+o:"")}const[n,r]=e.split("?"),[o,i]=r.split("#"),s=o.split("&").map((e=>e.split("="))).reduce(((e,[t,n])=>({...e,[t]:n})),{});Object.assign(s,t);return n+"?"+Object.keys(s).map((e=>`${e}=${s[e]}`)).join("&")+(i?"#"+i:"")}s.defaultOptions={autoStart:!0};let a=function(){function e(e){this.anys=e,this.$effects={}}var t=e.prototype;return t.start=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=e=>{const t=`register${e.replace(e[0],e[0].toUpperCase())}`;if(this[t]){const n=this[t]();this.$effects[e]=n}},r=this.anys.options;t.forEach((e=>{r[e]&&n(e)}))},t.stop=function(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=this.anys.options;t.forEach((e=>{const t=this.$effects[e];n[e]&&t&&t(),this.$effects[e]=null}))},e}(),u=function(){function e(){this.$events=[]}var t=e.prototype;return t.on=function(e,t){this.$events.push([e,t])},t.emit=function(e,...t){this.$events.forEach((([n,r])=>{e===n&&r(...t)}))},t.off=function(e,t){this.$events.forEach((([n,r],o)=>{e===n&&r===t&&this.$events.splice(o,1)}))},e}();function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}const d=new u;!function(){const e=window.XMLHttpRequest;window.__XMLHttpRequest=e,window.XMLHttpRequest=function(){const t=new e,n={open:t.open,send:t.send},r={name:o(4)},i=e=>{const{name:n,url:o,method:i}=r;let s,c;t.responseType&&"text"!==t.responseType?"json"===t.responseType&&(s=t.response,c="json"):(s=t.responseText.toString(),c="text"),d.emit("xhr",{type:e,time:Date.now(),name:`xhr_${n}`,url:o,detail:{status:t.status,method:i,responseType:c,response:s||void 0}})},s=()=>{4===t.readyState&&(2===Math.floor(t.status/100)?i("xhr.ok"):i("xhr.fail"))};return Object.defineProperty(t,"open",{get:()=>(e,o,i=!0,...s)=>{const c={method:e,url:o};d.emit("request",c),Object.assign(r,{...c,async:i}),t.onreadystatechange&&(n.onreadystatechange=t.onreadystatechange);const{open:a}=n;return a.call(t,c.method,c.url,i,...s)},configurable:!0}),Object.defineProperty(t,"send",{get:()=>e=>{const{send:o}=n,{async:i}=r;Object.assign(r,{body:e}),(()=>{const{name:e,url:t,method:n,async:o,body:i}=r;d.emit("xhr",{type:"xhr.req",time:Date.now(),name:`xhr_${e}`,url:t,detail:{method:n,async:o,body:i}})})();const c=o.call(t,e);return i||s(),c},configurable:!0}),t.addEventListener("error",(()=>{i("xhr.err")})),t.addEventListener("readystatechange",(e=>{s()})),t}}(),function(){const e=window.fetch;window.__fetch=e,window.fetch=function(t,n={}){const{method:r,body:i}=n,s=o(4);d.emit("fetch",{type:"fetch.init",time:Date.now(),name:`fetch_${s}`,url:t,detail:{body:i,method:r}});const c={method:r,url:t};return d.emit("request",c),Promise.resolve().then((()=>e(c.url,n))).then((e=>{const{status:n}=e;return 2===Math.floor(n/100)?new Proxy(e,{get:(o,i)=>"json"===i||"text"===i?()=>e[i]().then((e=>(d.emit("fetch",{type:"fetch.ok",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,data:e,method:r}}),e))):"function"==typeof e[i]?e[i].bind(e):e[i]}):(d.emit("fetch",{type:"fetch.fail",time:Date.now(),name:`fetch_${s}`,url:t,detail:{status:n,method:r}}),e)}),(e=>{let n;if(e instanceof Error){const{name:t,message:o}=e;n={method:r,type:t,err:o}}else n={method:r,err:e};d.emit("fetch",{type:"fetch.err",time:Date.now(),name:`fetch_${s}`,url:t,detail:n})}))}}();let l=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,h(t,n);var o=r.prototype;return o.options=function(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}},o.registerXhr=function(){const e=e=>{this.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,this.anys.write(e)};return d.on("xhr",e),()=>d.off("xhr",e)},o.registerFetch=function(){const e=e=>{this.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,this.anys.write(e)};return d.on("fetch",e),()=>d.off("fetch",e)},o.registerPatchRequestId=function(){const e=e=>{const{url:t}=e,{traceId:n,requestId:r}=this.anys,o=c(t,{_request_id:n+r});e.url=o};return d.on("request",e),()=>d.off("request",e)},r}(a),p=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!")}},t.defines=function(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}},t.defineClientId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.clientId`;let n=localStorage.getItem(t);return n||(n=o(8),sessionStorage.setItem(t,n)),n},t.defineTraceId=function(){const{namespace:e}=this.anys.options,t=`Anys.${e}.traceId`,n=o(8);return sessionStorage.setItem(t,n),n},e}();function f(e,t=document.documentElement){const{nodeName:n,path:r}=e;if(r)return r;if("BODY"===n||"HTML"===n||"HEAD"===n)return n;const o=[];let i=e,s=e.parentNode;const c=e=>{const{nodeName:t,parentNode:n}=e;if(!n)return-1;return[].filter.call(n.childNodes,(e=>e.nodeName===t)).indexOf(e)};if("#"===n[0]){const t=c(e);o.push(`${n}:${t}`),i=s,s=i.parentNode}for(;s&&i!==t;){const{nodeName:e}=i;if("BODY"===e||"HTML"===e||"HEAD"===e)o.push(e);else{const t=c(i);o.push(`${e.toLowerCase()}:${t}`)}i=s,s=i.parentNode}return o.reverse(),o.join("/")}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}let y=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,m(t,n);var o=r.prototype;return o.options=function(){return{input:!0}},o.registerInput=function(){const e=e=>t=>{const{target:n,type:r,inputType:o,data:i}=t;if("insertCompositionText"===o)return;if("compositionend"===r&&!i)return;const{tagName:s,value:c}=n;if(n.getAttribute("anys-ignore"))return;const a=n.getAttribute("type"),u=e({tagName:s,value:c,type:a,target:n});if(!u)return;const h={type:"input",time:Date.now(),el:f(n),detail:u};this.anys.write(h)},t=e((({tagName:e,value:t,type:n})=>"INPUT"===e&&"radio"!==n&&"checkbox"!==n&&"password"!==n?{value:t,type:n}:"INPUT"===e&&"password"===n?{value:"***",type:n}:"TEXTAREA"===e?{value:t,type:"textarea"}:void 0)),n=e((({tagName:e,value:t,type:n})=>"SELECT"===e?{value:t,type:"select"}:"INPUT"!==e||"radio"!==n&&"checkbox"!==n?void 0:{value:t,type:n})),r=e((({tagName:e,value:t,type:n})=>"TEXTAREA"===e?{value:t,type:"textarea"}:"INPUT"===e?{value:t,type:n}:void 0));return document.addEventListener("input",t,!0),document.addEventListener("compositionend",t,!0),document.addEventListener("change",n,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("input",t),document.removeEventListener("compositionend",t),document.removeEventListener("change",n),document.removeEventListener("paste",r)}},r}(a);function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}let g=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,v(t,n);var o=r.prototype;return o.options=function(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}},o.addEventListener=function(e,t){if(!this.anys.options.mouse)return;const n=this.createThrottleListener((t=>{const{innerWidth:n,innerHeight:r}=window,{target:o,button:i,pageX:s,pageY:c}=t;return{type:e,time:Date.now(),detail:{e:f(o),w:n,h:r,x:s,y:c,button:i}}}),t);return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerClick=function(){return this.addEventListener("click")},o.registerMouseup=function(){return this.addEventListener("mouseup")},o.registerMousedown=function(){return this.addEventListener("mousedown")},o.registerContextmenu=function(){return this.addEventListener("contextmenu")},o.registerMousemove=function(){return this.addEventListener("mousemove",100)},o.registerWheel=function(){if(!this.anys.options.mouse)return;const e="wheel",t=this.createThrottleListener((t=>{const{target:n,deltaX:r,deltaY:o,deltaZ:i,deltaMode:s}=t;return{type:e,time:Date.now(),detail:{e:f(n),deltaX:r,deltaY:o,deltaZ:i,mode:s}}}),100);return document.addEventListener(e,t),()=>document.removeEventListener(e,t)},o.createThrottleListener=function(e,t){let n=0,r=0;return o=>{if(n)return;const i=Date.now();if(t&&r+t>i)return;const s=e(o);requestAnimationFrame((()=>{this.anys.write(s),n=0,r=Date.now()})),n=1}},r}(a);function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}const w={type:"window_activity.enter",time:Date.now()};let O=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,b(t,n);var o=r.prototype;return o.options=function(){return{activity:!0,deadTimeout:0}},o.init=function(){this.anys.options.activity&&this.anys.write(w)},o.registerActivity=function(){const e=()=>{if("hidden"===document.visibilityState){const e={type:"window_activity.focusout",time:Date.now()};this.anys.write(e)}else{const e={type:"window_activity.focusin",time:Date.now()};this.anys.write(e)}},t=()=>{const e={type:"window_activity.unload",time:Date.now()};this.anys.write(e)};return window.addEventListener("beforeunload",t,!0),document.addEventListener("visibilitychange",e,!0),()=>{window.removeEventListener("beforeunload",t),document.removeEventListener("visibilitychange",e)}},o.registerDeadTimeout=function(){const{deadTimeout:e}=this.anys.options;if(!e)return;let t;const n=()=>{clearTimeout(t),t=setTimeout((()=>{const e={type:"window_activity.dead",time:Date.now()};this.anys.write(e)}),e)};return document.addEventListener("keydown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("touchstart",n,!0),document.addEventListener("touchmove",n,!0),document.addEventListener("mousemove",n,!0),document.addEventListener("scroll",n,!0),window.addEventListener("resize",n,!0),()=>{document.removeEventListener("keydown",n),document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n),document.removeEventListener("mousemove",n),document.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},r}(a);function E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}let _=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,E(t,n);var o=r.prototype;return o.options=function(){return{url:!0}},o.registerUrl=function(){const e=()=>{this.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),()=>{window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}},o.recordUrl=function(){const e=window.location.href,t=new URL(e),n=t.pathname.replace(/^([^/])/,"/$1"),r={type:"url",time:Date.now(),url:e,detail:{uri:n+(t.search?`?${t.search}`:""),path:n,protocol:t.protocol.replace(":",""),host:t.hostname,port:t.port,search:t.search,hash:t.hash.replace("#","")}};this.anys.write(r)},r}(a);function j(e,t){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},j(e,t)}let L=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,j(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,touchstart:e,touchend:e,touchmove:e}},o.addEventListener=function(e){if(!this.anys.options.touch)return;let t=0;const n=n=>{if(t)return;const{innerWidth:r,innerHeight:o}=window,{target:i,identifier:s,force:c,pageX:a,pageY:u}=n,h={type:e,time:Date.now(),detail:{e:f(i),width:r,height:o,x:a,y:u,identifier:s,force:c}};requestAnimationFrame((()=>{this.anys.write(h),t=0})),t=1};return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)},o.registerTouchmove=function(){return this.addEventListener("touchmove")},o.registerTouchend=function(){return this.addEventListener("touchend")},o.registerTouchstart=function(){return this.addEventListener("touchstart")},r}(a),P=function(){function e(){this.queue=[],this.status=0}return e.prototype.push=function(e){let t,n;const r=new Promise(((e,r)=>{t=e,n=r})),o={runner:e,resolve:t,reject:n};this.queue.push(o);const i=()=>{setTimeout((()=>{if(!this.queue.length)return void(this.status=0);const{runner:e,resolve:t,reject:n}=this.queue.shift();e().then(t,n).finally(i)}),0),this.status=1};return this.status||i(),r},e}(),x=function(){function e(e={}){let{name:t,version:n=1,stores:r}=e;const o=!t;t||(t="__indb__"),r&&Array.isArray(r)&&r.length||(r=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=t,this.version=n,this.stores=r;const i=indexedDB.open(t,n);if(i.onupgradeneeded=e=>{const t=e.target.result,n=Array.from(t.objectStoreNames),o=[];r.forEach((r=>{let i=null;if(n.indexOf(r.name)>-1)i=e.target.transaction.objectStore(r.name);else{const e=r.isKv?"key":r.primaryKeyPath,n=!r.isKv&&r.autoIncrement;i=t.createObjectStore(r.name,{keyPath:e,autoIncrement:n})}const s=i.indexNames;s&&s.length&&Array.from(s).forEach((e=>i.deleteIndex(e))),r.indexes&&r.indexes.length&&r.indexes.forEach((e=>{i.createIndex(e.name,e.keyPath||e.name,{unique:e.unique,multiEntry:Array.isArray(e.keyPath)})})),o.push(r.name)})),n&&n.forEach((e=>{-1===o.indexOf(e)&&t.deleteObjectStore(e)}))},i.onblocked=e=>{console.error(A(new Error("indexedDB "+t+" is blocked")))},o)return this.use(t)}var t=e.prototype;return t.connect=function(){return new Promise(((e,t)=>{const n=indexedDB.open(this.name,this.version);n.onerror=e=>{t(A(e))},n.onsuccess=t=>{e(t.target.result)}}))},t.use=function(e){const t=this.stores.find((t=>t.name===e));if(!t)throw new Error(`[InDB]: store ${e} is not existing.`);if(this.cache[e])return this.cache[e];const n=new I({db:this,store:t});return t.isKv&&Object.defineProperties(n,{key:{value:e=>n.keys().then((t=>t&&t[e]))},getItem:{value:e=>n.get(e).then((e=>e&&e.value))},setItem:{value:(e,t)=>n.put({key:e,value:t})},removeItem:{value:e=>n.delete(e)}}),this.cache[e]=n,n},t.close=function(){return this.cache=null,this.stores=null,this.connect().then((e=>{e.close()}))},e.deleteDatabase=function(e){return new Promise(((t,n)=>{const r=indexedDB.deleteDatabase(e);r.onsuccess=()=>{t()},r.onerror=e=>{n(e)}}))},e.databases=function(){return indexedDB.databases()},e}();let I=function(){function e(e={}){const{store:t,db:n}=e;if("object"!=typeof t||!t.name||"string"!=typeof t.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(n instanceof x))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=n,this.store=t,this.name=t.name,this.primaryKeyPath=t.isKv?"key":t.primaryKeyPath,this._queue=[]}var t=e.prototype;return t.transaction=function(e=!1){const t=()=>{const t=this.name,n=e?"readwrite":"readonly",r=this.db.connection;return(r?Promise.resolve(r):this.db.connect()).then((e=>{this.db.connection=e;const r=e.transaction(t,n),o=()=>{this.db.connection=null,this._queue.shift()};return r.oncomplete=o,r.onabort=o,r.onerror=o,r}))},n=this._queue[this._queue.length-1],r=n?n.then((()=>t())):t();return this._queue.push(r),r},t.objectStore=function(e=!1){const t=this.name;return this.transaction(e).then((e=>e.objectStore(t)))},t.cursor=function(e){const{index:t,range:n,direction:r,onTouch:o,onDone:i,onError:s,writable:c=!1}=e;return this.objectStore(c).then((e=>{const c=t?e.index(t):e,a=c.openCursor(n,r);a.onsuccess=e=>{const t=e.target.result;t?o(t,c):i(t,c)},a.onerror=e=>{s(A(e))}}))},t.request=function(e,t={}){const{writable:n=!1}=t;return new Promise(((t,r)=>{this.objectStore(n).then((n=>{const o=e(n);o.onsuccess=e=>{const n=e.target.result;t(n)},o.onerror=e=>{r(A(e))}}))}))},t.iterate=function(e,t={}){const{index:n,range:r,writable:o=!1,direction:i="next"}=t;return new Promise(((t,s)=>{this.cursor({index:n,range:r,writable:o,direction:i,onTouch:(n,r)=>{e(n,(()=>n.continue()),(()=>{r.transaction.commit(),t()}))},onDone:()=>{t()},onError:e=>{s(e)}})}))},t.batch=function(e,t={}){const{writable:n=!0}=t;return this.transaction(n).then((t=>{const n=this.name,r=[],o=t.objectStore(n);return e.forEach((e=>{const t=new Promise(((t,n)=>{const r=e(o);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onerror=e=>{n(A(e))}}));r.push(t)})),Promise.all(r)}))},t.get=function(e){if(!Array.isArray(e))return this.request((t=>t.get(e)));const t=e.map((e=>t=>t.get(e)));return this.batch(t,{writable:!1})},t.keys=function(){const e=this.primaryKeyPath,t=[];return this.each((n=>{const r=q(n,e);t.push(r)})).then((()=>t))},t.all=function(){const e=[];return this.each((t=>{e.push(t)})).then((()=>e))},t.count=function(){return this.request((e=>e.count()))},t.each=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}))},t.reverse=function(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}),{direction:"prev"})},t.some=function(e=10,t=0){return new Promise(((n,r)=>{const o=[];let i,s=0,c=t,a=t+e;t<0&&(i="prev",e=Math.min(e,-t),c=-(t+e)||0,a=c+e),this.iterate(((e,t,n)=>{s<c?(s++,t()):s<a?(o.push(e.value),s++,t()):n()}),{direction:i}).then((()=>{t<0&&o.reverse(),n(o)})).catch(r)}))},t.first=function(){return this.some(1).then((e=>e[0]))},t.last=function(){return this.some(1,-1).then((e=>e[0]))},t.find=function(e,t){return this.request((n=>n.index(e).get(t)))},t.query=function(e,t,n){const r=function(){switch(n){case">":return IDBKeyRange.lowerBound(t,!0);case">=":return IDBKeyRange.lowerBound(t);case"<":return IDBKeyRange.upperBound(t,!0);case"<=":return IDBKeyRange.upperBound(t);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(t)}}(),o=[];return new Promise(((i,s)=>{this.cursor({index:e,range:r,onTouch:(e,r)=>{const i=e.value,s=q(i,r.keyPath);"!="===n?s!==t&&o.push(i):"%"===n?"string"==typeof s&&s.indexOf(t)>-1&&o.push(i):"in"===n?Array.isArray(t)&&t.indexOf(s)>-1&&o.push(i):o.push(i),e.continue()},onDone:()=>{i(o)},onError:e=>{s(e)}})}))},t.select=function(...e){const t=this.store.indexes||[],n={};t.forEach((e=>{const{name:t,keyPath:r}=e;n[t]=r}));const r=function(e,t,n){if(void 0===e)return!1;switch(n){case">":return e>t;case">=":return e>=t;case"<":return e<t;case"<=":return e<=t;case"!=":return e!==t;case"%":return"string"==typeof e&&e.indexOf(t)>-1;case"in":return Array.isArray(t)&&t.indexOf(e)>-1;default:return e===t}},o=function(e,t,n){if(!t.length&&!n.length)return!1;for(let n=0,o=t.length;n<o;n++){const{keyPath:o,value:i,compare:s}=t[n],c=q(e,o);if(!r(c,i,s))return!1}if(!n.length)return!0;for(let t=0,o=n.length;t<o;t++){const{keyPath:o,value:i,compare:s}=n[t],c=q(e,o);if(r(c,i,s))return!0}return!1},i=[];e.forEach((e=>{const t=[],r=[];for(let o=0,i=e.length;o<i;o++){const{key:i,value:s,compare:c,optional:a}=e[o],u=n[i]||i;a?t.push({keyPath:u,value:s,compare:c}):r.push({keyPath:u,value:s,compare:c})}i.push([r,t])}));const s=[];return this.each((e=>{(e=>{for(let t=0,n=i.length;t<n;t++){const[n,r]=i[t];if(o(e,n,r))return!0}return!1})(e)&&s.push(e)})).then((()=>s))},t.add=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.add(e[0],t);const r=n.map((e=>n=>n.add(e,t)));return this.batch(r)}return e?this.request((n=>n.add(e,t)),{writable:!0}):Promise.resolve()},t.put=function(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.put(n[0],t);const r=n.map((e=>n=>n.put(e,t)));return this.batch(r)}return e?this.request((n=>n.put(e,t)),{writable:!0}):Promise.resolve()},t.delete=function(e){if(Array.isArray(e)){const t=e;if(t.length<2)return this.delete(t[0]);const n=t.map((e=>t=>t.delete(e)));return this.batch(n)}return e?this.request((t=>t.delete(e)),{writable:!0}):Promise.resolve()},t.remove=function(e){const t=this.primaryKeyPath;if(Array.isArray(e)){const n=e;if(n.length<2)return this.remove(n[0]);const r=n.map((e=>{const n=q(e,t);return e=>e.delete(n)}));return this.batch(r)}if(!e)return Promise.resolve();const n=q(e,t);return n?this.delete(n):Promise.resolve()},t.clear=function(){return this.request((e=>e.clear()),{writable:!0})},e}();function q(e,t){if(null==t)return;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++){const r=q(e,t[n]);if(void 0!==r)return r}return}let n=function(e){return e.toString().split(/\.|\[|\]/).filter((e=>!!e))}(t);if(!n.length)return e;let r=e;for(let e=0,t=n.length;e<t;e++){let t=n[e];if(void 0===r[t])return;r=r[t]}return r}function A(e){const{message:t}=e;return e.message=-1===t.indexOf("[IndexedDB]")?"[IndexedDB]: "+t:t,e}let D=function(){function e(e){this.anys=e}var t=e.prototype;return t.options=function(){return{namespace:new Error("[Anys]: options.namespace is required!"),autoReport:!1,expireTime:1728e5}},t.init=function(){const e="anyslogs",t=new x({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=t.use(e),this.queue=new P;const{expireTime:n}=this.anys.options;if(n){let e=0;const t=setInterval((()=>{this.queue.push((()=>this.db.some(100,e))).then((r=>{if(!r.length)return void clearInterval(t);const o=Date.now(),i=[];r.forEach((e=>{const{_id:t,time:r}=e;o-r>n&&i.push(t)})),i.length&&this.queue.push((()=>this.db.delete(i))),e+=100,e-=i.length}))}),1e4)}},t.write=function(e){this.queue.push((()=>this.db.add(e))).then((t=>{this.anys.emit("writeOfflineLog",{id:t,data:e})}))},t.read=function(e){if(e){if(!Array.isArray(e))return;if(e.some((e=>!e.key)))return}else e=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(e)},t.clear=function(e){return this.queue.push((()=>this.db.remove(e))).catch((()=>{}))},t.select=function(e){return this.queue.push((()=>this.db.select(e)))},t.remove=function(e){return this.queue.push((()=>this.db.delete(e))).catch((()=>{}))},e}();function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}let k=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,T(t,n);var o=r.prototype;return o.options=function(){return{mutation:!0}},o.registerMutation=function(){const e=this.createObserver((e=>{const t={type:"mutation",time:Date.now(),detail:e};this.anys.write(t)}));return window.addEventListener("load",(()=>{e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),this.recordSnapshot(),$(document.documentElement)})),()=>{e.disconnect()}},o.recordSnapshot=function(){const e=function(){const{name:e,publicId:t,systemId:n}=document.doctype,r={name:e,publicId:t,systemId:n},o=S(document.documentElement.innerHTML),i={},s=document.querySelector("html");for(let{name:e,value:t}of s.attributes)i[e]=t;const c=function(){const e=document.querySelectorAll("input, textarea, select"),t=[];return Array.from(e).forEach((e=>{const n=f(e),r="password"===e.type?"***":e.value;t.push({el:n,value:r})})),t}();return{doctype:r,attrs:i,html:o,values:c}}(),t=window.location.href,n=new URL(t),r=n.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:r+(n.search?`?${n.search}`:""),path:r,protocol:n.protocol.replace(":",""),host:n.hostname,port:n.port,search:n.search,hash:n.hash.replace("#","")},detail:e})},o.createObserver=function(e){const t=new MutationObserver((t=>{const n=[];[...t].reverse().forEach((e=>{const{type:t,target:r,attributeName:o,oldValue:i}=e;if(!(e=>{if(e.hasAttribute?.("anys-ignore"))return!0;let t=e.parentNode;for(;t;){if(t.hasAttribute?.("anys-ignore"))return!0;t=t.parentNode}return!1})(r)){if("attributes"===t){if(r.getAttribute(o)===i)return;if(n.find((e=>e.type===t&&e.target===r&&e.attributeName===o)))return}else if("characterData"===t){const e=r.data;if(e===i)return;if(n.find((n=>n.type===t&&n.target===r&&n.target.data===e)))return}n.push(e)}})),n.reverse();const r=[];n.forEach((e=>{const{type:t,target:n,attributeName:o,oldValue:i}=e,s=n.path||f(n),c=e=>f(e).replace(s+"/","");if("attributes"===t){const e=n.getAttribute(o),t=i;r.push({type:"attribute",target:s,name:o,next:e,prev:t})}else if("characterData"===t){const e=n.data,t=i;r.push({type:"text",target:s,next:e,prev:t})}else if("childList"===t){if("TEXTAREA"===n.nodeName)return;const{removedNodes:t,addedNodes:o,previousSibling:i,nextSibling:a}=e,u=[],h=Array.from(t).map((e=>{if(document.body.contains(e))return void u.push({node:e,path:f(e)});const t=e.path?c(e):null,n=i?f(i):null,r=a?f(a):null,o={};return t?o.node=t:(o.before=n,o.after=r),o})).filter(Boolean),d=[],l=Array.from(o).map((e=>{const t=e.nextSibling?c(e.nextSibling):null,n=u.find((t=>t.node===e));if(n)return void d.push({node:n.path,sibling:t});const r="#text"===e.nodeName,o="#comment"===e.nodeName,i=r?e.data:null,s=o?e.data:null;return{text:i,html:r||o?null:S(e.outerHTML),comment:s,sibling:t}})).filter(Boolean);r.push({type:"children",target:s,remove:h,insert:l,move:d}),$(n)}})),e(r)}));return $(document),t},r}(a);function $(e){if(e!==document){const t=f(e);e.path=t}const t=e.childNodes;Array.from(t).forEach((e=>{$(e)}))}function S(e){return e.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}function M(e,t){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},M(e,t)}let N=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,M(t,n);var o=r.prototype;return o.options=function(){return{size:!0}},o.createRecordLog=function(){const{innerWidth:e,innerHeight:t}=window;return{type:"window_size",time:Date.now(),detail:{width:e,height:t}}},o.registerSize=function(){let e;const t=()=>{clearTimeout(e);const t=this.createRecordLog();e=setTimeout((()=>{this.anys.write(t)}),100)};return this.recordSize(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},o.recordSize=function(){const e=this.createRecordLog();this.anys.write(e)},r}(a);function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}let B=function(e){var t,n;function r(){return e.apply(this,arguments)||this}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,R(t,n);var o=r.prototype;return o.options=function(){return{scroll:!0}},o.registerScroll=function(){let e=0;const t=t=>{if(e)return;const{target:n,bubbles:r}=t;let o;if(r){const{scrollX:e,scrollY:t}=window;o={type:"window_scroll",time:Date.now(),detail:{scrollX:e,scrollY:t}}}else{const{scrollLeft:e,scrollTop:t}=n;o={type:"scroll",time:Date.now(),target:f(n),detail:{scrollLeft:e,scrollTop:t}}}requestAnimationFrame((()=>{this.anys.write(o),e=0})),e=1};return window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("scroll",t)}},r}(a);function K(e,t){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},K(e,t)}let U=function(e){var t,n;function r(t,[n,r,o,i]){var s;return(s=e.call(this,t)||this).offlineStore=n,s.urlMonitor=r,s.windowSizeMonitor=o,s.DOMMutationMonitor=i,s.cache={},s}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,K(t,n);var o=r.prototype;return o.options=function(){const e="ontouchend"in document;return{touch:e,mouse:!e,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("[Anys]: options.reportUrl is required!"),reportInterval:1e4,reportParams:null}},o.registerAutoReport=function(){const{clientId:e}=this.anys,t=({prev:t})=>{this.anys.report([{key:"client",value:e},{key:"trace",value:t}]),this.cache={},this.urlMonitor.recordUrl(),this.windowSizeMonitor.recordSize(),this.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",t);const n=setInterval((()=>{this.anys.report()}),this.anys.options.reportInterval);let r=0;const o=()=>{if(r)return;r=1;const e=Object.keys(this.cache),t=Object.values(this.cache);e.length&&(this.offlineStore.remove(e),navigator.sendBeacon(this.anys.options.reportUrl,JSON.stringify(t)),this.cache={})};window.addEventListener("beforeunload",o),window.addEventListener("pagehide",o),window.addEventListener("unload",o);const i=({id:e,data:t})=>{this.cache[e]=t};return this.anys.on("writeOfflineLog",i),()=>{this.anys.off("refreshTraceId",t),this.anys.off("writeOfflineLog",i),clearInterval(n),window.removeEventListener("beforeunload",o)}},o.read=function(e){return this.offlineStore.read(e)},o.send=function(e){const t=[];let n=0;e.forEach((e=>{t[n]=t[n]||[],t[n].push(e),t[n].length>200&&n++}));const r=t.map((e=>{const t=[],n=[];if(e.forEach((e=>{const{_id:r,...o}=e;n.push(r),t.push(o)})),!t.length)return;const{reportUrl:r,reportParams:o}=this.anys.options;return function(e,t){return new Promise(((n,r)=>{const o=new(window.__XMLHttpRequest||window.XMLHttpRequest);o.open("POST",e,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?n(o.responseText):r(new Error(`[Anys]: ajax post fail with status ${o.status}`)))},o.onerror=r,o.send(JSON.stringify(t))}))}(o?c(r,o):r,t).then((()=>{n.forEach((e=>{delete this.cache[e]}))}))}));return Promise.all(r)},o.clear=function(){this.cache={}},o.auth=function(e){this.anys.options.reportParams=Object.assign(this.anys.options.reportParams||{},e)},r}(a);U.dependencies=[D,_,N,k,p,l,y,g,O,L,B];const X=(e={})=>new s({namespace:"AnysTracer",autoReport:!1,...e,plugins:{...e.plugins||{},recorder:U}})})();var n=anys="undefined"==typeof anys?{}:anys;for(var r in t)n[r]=t[r];t.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|