├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── DEVELOPMENT.md
├── README.md
├── hiper.conf.js
├── index.js
├── lib
├── BreadcrumbsPlugin-a1ed4add.js
├── NetworkCheckPlugin-bf920e7c.js
├── PerformancePlugin-fcf2bd30.js
├── RecordPlugin-d42c4457.js
├── index-5d5b259f.js
└── index.js
├── package.json
├── rollup.config.js
├── src
├── api
│ ├── index.js
│ └── request.js
├── common
│ ├── index.js
│ └── registBaseEvent.js
├── config
│ └── index.js
├── index.js
├── md5.js
├── pack.js
├── plugins
│ ├── BreadcrumbsPlugin.js
│ ├── NetworkCheckPlugin.js
│ ├── PerformancePlugin.js
│ ├── Plugin.js
│ └── RecordPlugin.js
├── prototype
│ └── index.js
└── utils.js
└── test
├── index.html
└── png_1x1.gif
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false,
7 | "loose": true,
8 | "targets": {
9 | "browsers": "> 1%, IE 11, not op_mini all, not dead",
10 | "node": 8
11 | }
12 | }
13 | ]
14 | ],
15 | "plugins": [
16 | "@babel/plugin-syntax-dynamic-import",
17 | // "@babel/plugin-external-helpers",
18 | ["@babel/plugin-proposal-class-properties", { "loose" : true }]
19 | ],
20 | "ignore": [
21 | "node_modules/**"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | [*]
7 | indent_style = space
8 | indent_size = 2
9 | end_of_line = lf
10 | charset = utf-8
11 | trim_trailing_whitespace = false
12 | insert_final_newline = true
13 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | # 忽略目录
2 | build/
3 | dist/
4 | test/
5 | **/*.mock*
6 |
7 | # node 覆盖率文件
8 | coverage/
9 |
10 | # 忽略文件
11 | **/*-min.js
12 | **/*.min.js
13 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | 'env': {
3 | 'browser': true,
4 | 'es6': true,
5 | 'node': true
6 | },
7 | 'extends': 'eslint:recommended',
8 | 'globals': {
9 | 'Atomics': 'readonly',
10 | 'SharedArrayBuffer': 'readonly',
11 | 'ENV': true,
12 | 'EDITH_VERSION': 'readonly',
13 | 'IS_DEV': 'readonly',
14 | 'FORMAT': 'readonly',
15 | },
16 | "parser": "babel-eslint",
17 | 'parserOptions': {
18 | 'ecmaVersion': 2018,
19 | 'sourceType': 'module',
20 | "codeFrame": false
21 | },
22 | "plugins": [],
23 | 'rules': {
24 | 'no-constant-condition': 0,
25 | 'no-global-assign': 0,
26 | 'quotes': 0,
27 | 'no-unused-vars': 0,
28 | // 'semi': [
29 | // 'error',
30 | // 'always'
31 | // ]
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 | /_dist
12 | /test/static
13 | # misc
14 | .idea
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 | *-lock.json
25 | yarn.lock
26 | .idea/*
27 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src/
2 | test/
3 | /node_modules
4 | /dist
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 2021-06-21 v1.0.0
2 |
3 |
4 | - 优化同一错误短时间内反复提交的问题,增加定时批量上报
5 | - 增加`performance`插件,可查看页面的性能各项指标
6 | - 增加获取本apiKey的白名单
7 |
8 |
9 | # 2021-06-07 v0.4.6
10 |
11 | - 修复`img`的src为空报错时,message错误的问题
12 |
13 | # 2021-06-05 v0.4.5
14 |
15 | - 修复获取`responseText`失败的问题
16 |
17 | # 2021-06-03 v0.4.0~v0.4.4
18 |
19 | - 优化数据上报量,压缩数据,优化原子参数过长造成的数据冗余的问题
20 | - 优化录屏带来的内存占用问题
21 | - 优化插件包体积大小
22 | - 增加脚本自身错误上报
23 | - 优化message类型
24 | - 优化部分已知错误
25 |
26 | # 2021-05-25 v0.3.3&v0.3.4
27 |
28 | - 压缩上报数据量,plugins, redo, breadcrumbs都进行压缩
29 | - 解决自定义事件的timeStamp不准的问题
30 | - 不在打包cdn分版本号
31 |
32 | # 2021-05-19 v0.3.2
33 |
34 | - 修复自定义上报传对象导致message错误的问题
35 | - 修复filters参数报错,没有catch住的问题
36 |
37 | # 2021-05-13 v0.3.1
38 |
39 | - 支持更好的自测
40 | - 支持在其他域名路径下引用本脚本
41 |
42 | # 2021-02-18 v0.3.0
43 |
44 | - 进一步缩小录屏插件的上报数据
45 | - 修复`unhandledrejection`错误无法上报的问题
46 |
47 | # 2020-12-16 v0.2.8
48 |
49 | - 修复用户行为的fetch请求没有记录到url的问题
50 | - 修复用户行为的记录网络请求数据有误的情况
51 | - 增加对外链js报错的解决方案,给外链js增加`crossorigin='anonymous'`的属性
52 | - 修复`WebSocket`记录数据不准的问题
53 |
54 | # 2020-12-9 v0.2.7(v0.2.6 ignore)
55 |
56 | - 修复用户行为堆栈数据过大的问题
57 |
58 | # 2020-12-4 v0.2.5
59 |
60 | - 优化script标签的属性性能,适配预渲染
61 | - 缩小录屏插件的上报数据
62 | - 优化自定义插件数据的限制
63 | - 增加上报脚本版本号
64 | - 解决img标签为空时的报错信息
65 | - 优化行为堆栈白名单的判断,减少数据量
66 | - 异常数据中不包含性能数据
67 | - 增加过滤sockjs-node的常见调试报错
68 |
69 | # 2020-11-18 0.2.4(v0.2.3有问题)
70 |
71 | - 优化Edith对象的属性及其原型链展示
72 | - 优化行为堆栈的bug
73 | - 加快监控错误的时机
74 |
75 | # 2020-09-21 v0.2.2
76 |
77 | - 修复对Promise的polyfill的判断
78 |
79 | # 2020-09-16 v0.2.1
80 |
81 | - 增加silentHttp是否监听网络错误的参数
82 |
83 | # 2020-09-16 v0.2.0
84 |
85 | - 自定义插件数据,字段统一处理
86 | - 增加上报cookie
87 |
88 | # 2020-09-16 v0.1.11
89 |
90 | - 修复http请求header和body的获取
91 | - 增加webSokect监听错误和堆栈记录
92 | - 增加错误过滤,以及控制Promise监听,资源加载监听、webSocket、是否上报http的body的参数
93 | - 修复Promise不支持的解决方法
94 | - 修复开发环境下不能上报自定义错误的bug
95 |
96 | # 2020-08-22 v0.1.10
97 |
98 | - 修复网络请求报错的判断
99 | - 修复部分bug
100 |
101 | # 2020-8-19 v0.1.6
102 |
103 | - 修复插件安装使用问题
104 |
105 | # 2020-8-19 v0.1.2
106 |
107 | - 修复插件打包bug
108 |
109 | # 2020-8-19 v0.1.1
110 |
111 | - 修复自检bug
112 |
113 | # 2020-8-19 v0.0.9
114 |
115 | - 上报错误后,state需要清空,防止产生无用数据
116 |
117 | # 2020-8-19 v0.0.8
118 |
119 | - 修复npm包的问题
120 |
121 | # 2020-8-19 v0.0.7
122 |
123 | - 优化生命周期,增加自检
124 | - 解决请求记录没有时间戳的问题
125 |
126 | # 2020-8-18 v0.0.6
127 |
128 | - 重构代码逻辑,拓展功能改为插件引入
129 |
130 | # 2020-8-11 v0.0.5
131 |
132 | - 更改请求地址
133 | - 请求错误监听的逻辑
134 |
135 | # 2020-7-30 v0.0.4
136 |
137 | - 更改检测网速的请求方法
138 | - 优化部分包大小
139 | - 增加主动埋点上报功能
140 |
--------------------------------------------------------------------------------
/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 |
2 | ### 项目启动
3 | 运行`npm run dev`,浏览器会自动打开http://localhost:7000
4 |
5 | ### 打包
6 |
7 | - cdn打包
8 | 运行`npm run build`
9 |
10 | - npm打包
11 | 运行`npm run build:es`
12 |
13 | ## 部署到npm
14 |
15 | > 升级后警告过时的包 `npm deprecate @inke-design/edith-script@xxx '该版本已过期,请及时升到最新的脚本版本,体验更好的功能,npm install @inke-design/edith-script@latest'`
16 |
17 | - `npm login`
18 | - `npm publish --access public`
19 |
20 | > 撤销包`npm unpublish @inke-design/edith-script@xxx`;
21 |
22 |
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Edith 监控平台script
2 |
3 | 上报前端错误到Edith后台
4 |
5 | [更新日志](./CHANGELOG.md)
6 |
7 | ---
8 |
9 | ## 开发
10 |
11 | [开发请看](./DEVELOPMENT.md)
12 |
13 | ## 安装
14 |
15 | ```bash
16 | npm install @inke-design/edith-script -save
17 | ```
18 |
19 | 或者CDN引用,脚本一直会更新到最新版本,不需要更换链接,也支持放在其他域名路径下,[下载cdn源码](https://webcdn.inke.cn/edith.cn/edith.cn.zip)
20 |
21 | 建议放在`
`里,以保证错误和记录数据更加准确
22 |
23 | ```javascript
24 |
25 | ```
26 |
27 | ## 使用方式
28 |
29 | - npm方式
30 |
31 | ```javascript
32 | // entry.js
33 |
34 | import Edith from '@inke-design/edith-script'
35 |
36 | Edith.init({
37 | apiKey: 'apikey', // 用于区分不同项目
38 | silentDev: true, // 开发环境下不上报,根据域名是否为ip或者localhost来判断
39 | plugins: [ // 内置插件
40 | 'breadcrumbs', // 记录用户行为堆栈
41 | 'redo', // 记录录屏
42 | 'network', // 记录网络信息
43 | ]
44 | })
45 | ```
46 |
47 | - CDN方式
48 |
49 | ```javascript
50 | window.Edith.init({
51 | apiKey: 'apikey', // 用于区分不同项目
52 | silentDev: true, // 开发环境下不上报,根据域名是否为ip或者localhost来判断
53 | plugins: [ // 内置插件
54 | 'breadcrumbs', // 记录用户行为堆栈
55 | 'redo', // 记录录屏
56 | 'network', // 记录网络信息
57 | ]
58 | })
59 | ```
60 |
61 | ## 其他参数
62 |
63 | ```javascript
64 | Edith.init({
65 | apiKey: 'apikey', // 用于区分不同项目,根据域名是否为ip或者localhost来判断
66 | silentDev: true, // 开发环境下不上报
67 | plugins: [ // 内置插件,选择引入
68 | 'breadcrumbs', // 记录用户行为堆栈
69 | 'redo', // 记录录屏
70 | 'network', // 记录网络信息
71 | 'performance', // 性能数据
72 | ],
73 | resourceWhiteList: ['www.baidu.com', /^((?!(a\.com|b\.com)).)*$/], // 资源加载监听的白名单(支持正则,字符串会忽略判断协议和query参数)
74 | ajaxWhiteList: ['//example.com/search'], // 网络请求监听的白名单(支持正则,字符串会忽略判断协议和query参数)
75 | silentPromise: true, // 是否不监听Promise错误,默认为false
76 | silentResource: true, // 是否不监听资源加载错误,默认为false
77 | silentHttp: true, // 是否需要不监控网络请求异常,默认为false
78 | silentWebsocket: true, // 是否不监听Websocket错误,默认为false
79 | setHttpBody: true, // 是否上报http请求里的body,默认为false
80 | filters: err => { // 过滤错误函数,参数为带有name, title, url, message, ajax, target的错误信息字段, 返回值为真值,则不上报错误(自定义上报不拦截)
81 | if(err.message === 'Script error.') return true
82 | }
83 | })
84 | ```
85 |
86 | ## 自定义上报方法
87 |
88 | 在某些情况下,因一些无法跟踪的业务错误,导致业务出现问题,可以采用自定义上报该错误。
89 | Edith内部有一个`debug`方法,可以传两个参数,第一个参数为错误名称(字符串),第二个参数为错误信息,可以是字符串或者对象等。
90 |
91 | ```javascript
92 | if(uid === undefined) Edith.debug('NoUID', {
93 | msg: 'uid为空',
94 | ...
95 | })
96 |
97 | ```
98 |
99 | ## 录屏隐私处理
100 |
101 | 有些业务,可能由于涉及到隐私和不宜公开的信息,不希望录屏上报到后台,需要给指定的`DOM`做隐私处理。
102 |
103 | - 在`HTML`元素中添加类名`.edith-block`将会避免该元素及其子元素被录制,回放时取而代之的是一个同等宽高的占位元素。
104 | - 在`HTML`元素中添加类名`.edith-ignore`将会避免录制该元素的输入事件。
105 | - `input[type="password"]`类型的密码输入框默认不会录制输入事件。
106 |
107 | ## filters参数示例
108 |
109 | 1. 过滤name为 TypeError 的错误
110 |
111 | ```javascript
112 | Edith.filters = err => {
113 | if(err.name === 'TypeError') return true
114 | }
115 |
116 | ```
117 |
118 | 2. 过滤 method 为 GET,且 status 为 403 的错误
119 |
120 | ```javascript
121 | Edith.filters = err => {
122 | if(err.ajax.method === 'GET' && err.ajax.stutus === 403) return true
123 | }
124 | ```
125 |
126 | 3. 过滤指定域名的资源加载错误
127 |
128 | ```javascript
129 | Edith.filters = err => {
130 | return err.name === 'resourceError' && err.message.match(/example.com/)
131 | }
132 | ```
133 |
134 | 4. 过滤url为空字符串的图片加载错误
135 |
136 | ```javascript
137 | Edith.filters = err => {
138 | const { target: { tagName = '' }, message } = err
139 | return tagName.match(/img/g) && message === ''
140 | }
141 | ```
142 |
143 | ## 自定义插件
144 |
145 | 有些业务需要上报业务需要的相关数据,就可以采用自定义插件的方式,本方式参考了`webpack`的插件接入方式
146 |
147 | 插件是一个带有`apply`方法的对象,这个方法的唯一参数`compiler`为一个函数,需要在`apply`方法内部调用它,来添加上报的插件数据。
148 | > 建议插件内部用`trycatch`捕获**异步函数**的错误,不然可能会导致错误监控和插件执行循环出错的情况
149 |
150 | ```javascript
151 | Edith.init({
152 | ...,
153 | plugins: [
154 | { // 自定义插件
155 | apply(compiler) {
156 | compiler('key', function(edith, callback) {
157 | callback({
158 | uid: 'my-data'
159 | })
160 | })
161 | }
162 | }
163 | ],
164 | })
165 | ```
166 | > 收到上报后,会在后台错误详请里查看插件数据
167 |
168 | 而这个`compiler`函数,接收两个参数:
169 | 1. 第一个为上报插件数据的Key[字符串]
170 | 2. 第二个参数为一个获取内容的方法(为了保证每次上报都会执行获取一次),该方法有两个参数
171 | > 第一个为Edith实例对象,可以通过其拿到Edith自身的配置数据;第二个为一个回调函数,通过执行这个函数来传递需要上报的内容,内容可以是对象,也可以是字符串或其他数据类型
172 |
173 | 除了在初始化时添加插件,也可以动态添加,且可以通过new 一个对象来增加自己需要的属性。
174 | ```javascript
175 | Edith.plugins.push(new MyEdithPlugins(options))
176 | ```
177 |
--------------------------------------------------------------------------------
/hiper.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // options 指向Chrome可执行程序,一般不需要配置此项,除非你想测试某个特定版本的Chrome npm publish --access public
3 | executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
4 | // required 要测试的url
5 | url: 'https://h5.yingtaorelian.com/innerapp-2020/red-packet/index.html',
6 | // options 本次测试需要用到的Cookies,通常是登录信息(即你测试的页面需要登录) Array | Object
7 | cookies: [],
8 | // options 测试次数 默认为20次
9 | count: 2,
10 | // options 是否使用无头模式 默认为true
11 | headless: true,
12 | // options 是否禁用缓存 默认为false
13 | noCache: false,
14 | // options 是否禁掉JavaScript 默认为false
15 | noJavascript: false,
16 | // options 是否禁掉网络 默认为false
17 | noOnline: false,
18 | // options 设置指定的useragent信息
19 | useragent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36',
20 | // options 设置视口信息
21 | viewport: {
22 | // options
23 | 'width': 375,
24 | // options
25 | 'height': 812,
26 | // options devicePixelRatio 默认为1
27 | 'deviceScaleFactor': 3,
28 | // options 是否模拟成mobile 默认为false
29 | 'isMobile': false,
30 | // options 是否支持touch时间 默认为false
31 | 'hasTouch': false,
32 | // options 是否是横屏模式 默认为false
33 | 'isLandscape': false
34 | }
35 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib/index.js');
2 |
--------------------------------------------------------------------------------
/lib/BreadcrumbsPlugin-a1ed4add.js:
--------------------------------------------------------------------------------
1 | import{i as e,e as t,g as i,a,b as n,_ as r,c as d,d as o}from"./index-5d5b259f.js";var s={},m=e(),l=[],h=[];function c(e,t){var i=-1;if(t.forEach((function(t,a){e.eid&&t.eid===e.eid&&-1===i&&(i=a)})),i>=0)return t.splice(i,1,r({},t[i],e));t.length>=15&&t.shift(),t.push(r({eid:d()},e))}var p=function(e){return function(t){c({type:"navigation",time:s.getCurrentTime(),method:e||t.detail.method,timeStamp:a(),detail:{from:{url:s.getSimpleString(t.oldURL||t.detail.oldURL),title:document.title},to:{url:s.getSimpleString(t.newURL||t.detail.newURL)}}},h)}},u=function(e,t){void 0===t&&(t="XMLHttpRequest");var i=e.method,a=e.status,n=e.statusText,r=e.responseURL,d=e.url,m=e.body,p=void 0===m?null:m,u=e.endTime,f=e._eid,S=e.timeStamp,v=e.startTime,g=u-v;o(l,d)||c({eid:f,type:t,time:v,timeStamp:S,elapsedTime:g,detail:{method:i,status:a,body:p,statusText:n,url:s.getSimpleString(r||d,150)}},h)},f=function(){var e=function(e,t){return function(i){var n,r=i.detail,o=r.target,s=r.time,m="open"===e;o._eid=m&&!t&&o._eid?o._eid:d(),o.openTime=o.openTime||(t?0:s),o.time=m&&o.time||s,o.startTime=t?s:o.startTime,o.elapsedTime=m?s-o.startTime:s-(o.openTime||o.startTime),o.timeStamp=o.timeStamp||a(),(n=e,function(e){var t=e._eid,i=e.time,a=e.elapsedTime,r=e.url,d=e.readyState;c({eid:t,type:"webSocket",time:i,timeStamp:e.timeStamp,method:n,elapsedTime:a,detail:{url:r,readyState:d}},h)})(o)}};s.edithAddEventListener("webSocketStart",e("open",!0)),s.edithAddEventListener("webSocketOpen",e("open")),s.edithAddEventListener("webSocketClose",e("close"))},S=function(){var e,t;if(s.edithAddEventListener("click",(e="click",function(t){var r=t.target,d=i(r).toLowerCase(),o=r.className,m=r.id,l=s.getSimpleString(r.outerHTML);c({type:e,time:s.getCurrentTime(),timeStamp:a(),detail:{className:o,id:m,outerHTML:l,tagName:d,xPath:n(r)}},h)}),!0),t=function(e){var t=e.detail,i=t.target,n=t.time;i._eid=i._eid||d(),i.timeStamp=i.timeStamp||a(),i.endTime=n,u(i)},s.edithAddEventListener("ajaxOpen",t),s.edithAddEventListener("ajaxProgress",t),s.edithAddEventListener("ajaxLoadEnd",t),function(){var e=function(e){var t=e.detail,i=t.target.options,n=t.time;i.timeStamp=i.timeStamp||a();var d=r({},i,e.detail,{endTime:n});u(d,"fetchRequest")};s.edithAddEventListener("fetchStart",e),s.edithAddEventListener("fetchEnd",e)}(),f(),m){var o=location.href;setInterval((function(){o!=location.href&&(p("intervalCheck")({oldURL:o,newURL:location.href,timeStamp:a()}),o=location.href)}),250)}else s.edithAddEventListener("hashchange",p("hashchange")),s.edithAddEventListener("navigationChange",p())},v=function(){function e(e){this.name="breadcrumbs",this.state={}}return e.prototype.apply=function(e){var i=this;e(this.name,(function(e,a){var n=e.state,r=e.ajaxWhiteList,d=e.utils;s=d,n[i.name]||(l=r,function(){function e(e,i){return function(){for(var a=arguments.length,n=new Array(a),r=0;r=t||n(++i)})).catch((function(e){}))}(0)},this.eventPresent=function(e){if(e){["preventDefault","stopPropagation"].forEach((function(t){return e[t]&&e[t]()})),e.cancelBubble=!0}},this.measureDelay=function(e,t){var n=i.utils,r=n.getCurrentTime,a=n.tryCatchFunc;t=t||1;var s=0,o="//webcdn.inke.cn/edith.cn/hm.gif?",u=new Image;u.onerror=a(i.eventPresent),u.onload=function n(){var u=r(),c=new Image;c.onload=function(){var i=r()-u;s++,e(i),s0||i.didTimeout)&&t.length>0;)t.shift()();t.length>0&&e(n)}),{timeout:7e3})},n.apply=function(t){var n=this;t(n.name,(function(t,i){var r=t.state,a=t.utils;n.utils=a,r[n.name]||n.startCheck.apply(n);var s=n.state.netWorkType;i({speed:e(n.speeds),delay:e(n.delays),netWorkType:s})}))},t}();export default t;
2 |
--------------------------------------------------------------------------------
/lib/PerformancePlugin-fcf2bd30.js:
--------------------------------------------------------------------------------
1 | var t,e,n=function(){return"".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)},i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return{name:t,value:e,delta:0,entries:[],id:n(),isFinal:!1}},a=function(t,e){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var n=new PerformanceObserver((function(t){return t.getEntries().map(e)}));return n.observe({type:t,buffered:!0}),n}}catch(t){}},r=!1,o=!1,s=function(t){r=!t.persisted},u=function(){addEventListener("pagehide",s),addEventListener("beforeunload",(function(){}))},c=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];o||(u(),o=!0),addEventListener("visibilitychange",(function(e){var n=e.timeStamp;"hidden"===document.visibilityState&&t({timeStamp:n,isUnloading:r})}),{capture:!0,once:e})},f=function(t,e,n,i){var a;return function(){n&&e.isFinal&&n.disconnect(),e.value>=0&&(i||e.isFinal||"hidden"===document.visibilityState)&&(e.delta=e.value-(a||0),(e.delta||e.isFinal||void 0===a)&&(t(e),a=e.value))}},p=function(){return void 0===t&&(t="hidden"===document.visibilityState?0:1/0,c((function(e){var n=e.timeStamp;return t=n}),!0)),{get timeStamp(){return t}}},m=function(){return e||(e=new Promise((function(t){return["scroll","keydown","pointerdown"].map((function(e){addEventListener(e,t,{once:!0,passive:!0,capture:!0})}))}))),e},l=function(){function t(){var t=this;this.getData=function(){!function(t){var e=i("FID"),n=p(),r=function(t){t.startTime1&&void 0!==arguments[1]&&arguments[1],r=i("LCP"),o=p(),s=function(t){var n=t.startTime;n=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return i}function r(){for(var e=[],t=0;t-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+i)+"')";var u=t.split("/"),s=i.split("/");u.pop();for(var c=0,l=s;ct?(o&&(window.clearTimeout(o),o=null),r=i,e.apply(s,c)):o||!1===n.trailing||(o=window.setTimeout((function(){r=!1===n.leading?0:Date.now(),o=null,e.apply(s,c)}),u))}}function I(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function N(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function M(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;return"string"==typeof t?n=e.classList.contains(t):e.classList.forEach((function(e){t.test(e)&&(n=!0)})),n||M(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,M(e.parentNode,t)}function x(e){return Boolean(e.changedTouches)}var T=function(e,t){return e+"@"+t};function k(e){return"__sn"in e}var D=function(e,t,o,r){var a=this;this.texts=[],this.attributes=[],this.removes=[],this.adds=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=function(e){var t,o,r,i;e.forEach(a.processMutation);var u=[],s=function(e){if(e.parentNode){var t=w.getId(e.parentNode),n=e.nextSibling&&w.getId(e.nextSibling);if(-1===t||-1===n)return u.push(e);a.adds.push({parentId:t,nextId:n,node:b(e,document,w.map,a.blockClass,!0,a.inlineStylesheet,a.maskInputOptions)})}};try{for(var c=n(a.movedSet),l=c.next();!l.done;l=c.next())s(f=l.value)}catch(e){t={error:e}}finally{try{l&&!l.done&&(o=c.return)&&o.call(c)}finally{if(t)throw t.error}}try{for(var d=n(a.addedSet),p=d.next();!p.done;p=d.next()){var f=p.value;R(a.droppedSet,f)||L(a.removes,f)?R(a.movedSet,f)?s(f):a.droppedSet.add(f):s(f)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}for(;u.length&&!u.every((function(e){return-1===w.getId(e.parentNode)}));)s(u.shift());a.emit()},this.emit=function(){var e={texts:a.texts.map((function(e){return{id:w.getId(e.node),value:e.value}})).filter((function(e){return w.has(e.id)})),attributes:a.attributes.map((function(e){return{id:w.getId(e.node),attributes:e.attributes}})).filter((function(e){return w.has(e.id)})),removes:a.removes,adds:a.adds};(e.texts.length||e.attributes.length||e.removes.length||e.adds.length)&&(a.emissionCallback(e),a.texts=[],a.attributes=[],a.removes=[],a.adds=[],a.addedSet=new Set,a.movedSet=new Set,a.droppedSet=new Set,a.movedMap={})},this.processMutation=function(e){switch(e.type){case"characterData":var t=e.target.textContent;M(e.target,a.blockClass)||t===e.oldValue||a.texts.push({value:t,node:e.target});break;case"attributes":if(t=e.target.getAttribute(e.attributeName),M(e.target,a.blockClass)||t===e.oldValue)return;var n=a.attributes.find((function(t){return t.node===e.target}));n||(n={node:e.target,attributes:{}},a.attributes.push(n)),n.attributes[e.attributeName]=g(document,e.attributeName,t);break;case"childList":e.addedNodes.forEach((function(t){return a.genAdds(t,e.target)})),e.removedNodes.forEach((function(t){var n=w.getId(t),o=w.getId(e.target);M(t,a.blockClass)||M(e.target,a.blockClass)||(a.addedSet.has(t)?(O(a.addedSet,t),a.droppedSet.add(t)):a.addedSet.has(e.target)&&-1===n||function e(t){var n=w.getId(t);return!w.has(n)||(!t.parentNode||t.parentNode.nodeType!==t.DOCUMENT_NODE)&&(!t.parentNode||e(t.parentNode))}(e.target)||(a.movedSet.has(t)&&a.movedMap[T(n,o)]?O(a.movedSet,t):a.removes.push({parentId:o,id:n})),w.removeNodeFromMap(t))}))}},this.genAdds=function(e,t){if(!M(e,a.blockClass)){if(k(e)){a.movedSet.add(e);var n=null;t&&k(t)&&(n=t.__sn.id),n&&(a.movedMap[T(e.__sn.id,n)]=!0)}else a.addedSet.add(e),a.droppedSet.delete(e);e.childNodes.forEach((function(e){return a.genAdds(e)}))}},this.blockClass=t,this.inlineStylesheet=o,this.maskInputOptions=r,this.emissionCallback=e};function O(e,t){e.delete(t),t.childNodes.forEach((function(t){return O(e,t)}))}function L(e,t){var n=t.parentNode;if(!n)return!1;var o=w.getId(n);return!!e.some((function(e){return e.id===o}))||L(e,n)}function R(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||R(e,n))}function _(e,t,n){if(!1===n.mouseInteraction)return function(){};var o=!0===n.mouseInteraction||void 0===n.mouseInteraction?{}:n.mouseInteraction,r=[];return Object.keys(l).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]})).forEach((function(n){var o=n.toLowerCase(),a=function(n){return function(o){if(!M(o.target,t)){var r=w.getId(o.target),a=x(o)?o.changedTouches[0]:o,i=a.clientX,u=a.clientY;e({type:l[n],id:r,x:i,y:u})}}}(n);r.push(C(o,a))})),function(){r.forEach((function(e){return e()}))}}var A,P=["INPUT","TEXTAREA","SELECT"],z=new WeakMap;function F(e,n,o,a,i){function u(e){var t=e.target;if(t&&t.tagName&&!(P.indexOf(t.tagName)<0)&&!M(t,n)){var r=t.type;if("password"!==r&&!t.classList.contains(o)){var i=t.value,u=!1;"radio"===r||"checkbox"===r?u=t.checked:(a[t.tagName.toLowerCase()]||a[r])&&(i="*".repeat(i.length)),s(t,{text:i,isChecked:u});var c=t.name;"radio"===r&&c&&u&&document.querySelectorAll('input[type="radio"][name="'+c+'"]').forEach((function(e){e!==t&&s(e,{text:e.value,isChecked:!u})}))}}}function s(n,o){var r=z.get(n);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){z.set(n,o);var a=w.getId(n);e(t(t({},o),{id:a}))}}var c=("last"===i.input?["change"]:["input","change"]).map((function(e){return C(e,u)})),l=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value"),d=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]];return l&&l.set&&c.push.apply(c,r(d.map((function(e){return function e(t,n,o,r,a){void 0===a&&(a=window);var i=a.Object.getOwnPropertyDescriptor(t,n);return a.Object.defineProperty(t,n,r?o:{set:function(e){var t=this;setTimeout((function(){o.set.call(t,e)}),0),i&&i.set&&i.set.call(this,e)}}),function(){return e(t,n,i||{},!0)}}(e[0],e[1],{set:function(){u({target:this})}})})))),function(){c.forEach((function(e){return e()}))}}function V(e,t){void 0===t&&(t={}),function(e,t){var n=e.mutationCb,o=e.mousemoveCb,a=e.mouseInteractionCb,i=e.scrollCb,u=e.viewportResizeCb,s=e.inputCb,c=e.mediaInteractionCb,l=e.styleSheetRuleCb;e.mutationCb=function(){for(var e=[],o=0;o=a,i=r&&e.timestamp-M.timestamp>r;(o||i)&&k(!0)}};try{var D=[];D.push(C("DOMContentLoaded",(function(){A(j({type:s.DomContentLoaded,data:{}}))})));var O=function(){k(),D.push(V({mutationCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.Mutation},e)}))},mousemoveCb:function(e,t){return A(j({type:s.IncrementalSnapshot,data:{source:t,positions:e}}))},mouseInteractionCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.MouseInteraction},e)}))},scrollCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.Scroll},e)}))},viewportResizeCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.ViewportResize},e)}))},inputCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.Input},e)}))},mediaInteractionCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.MediaInteraction},e)}))},styleSheetRuleCb:function(e){return A(j({type:s.IncrementalSnapshot,data:t({source:c.StyleSheetRule},e)}))},blockClass:u,ignoreClass:d,maskInputOptions:x,inlineStylesheet:f,sampling:S},v))};return"interactive"===document.readyState||"complete"===document.readyState?O():D.push(C("load",(function(){A(j({type:s.Load,data:{}})),O()}),window)),function(){D.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}return H.addCustomEvent=function(e,t){if(!A)throw new Error("please add custom event after start recording");A(j({type:s.Custom,data:{tag:e,payload:t}}))},H}();var e=function(){function e(e){var t=this;this.getRedo=function(){var e=t.eventsMatrix.slice(-2),n=e[0],o=e[1],r=[].concat(n,void 0===o?[]:o);return t.eventsMatrix=t.eventsMatrix.slice(-2),r},this.name="redo"}var t=e.prototype;return t.startRecordVideo=function(){this.eventsMatrix=[[]];var e=this;window.edithRecord({blockClass:"edith-block",ignoreClass:"edith-ignore",emit:function(t,n){n&&(e.eventsMatrix.push([]),e.eventsMatrix=e.eventsMatrix.slice(-3)),e.eventsMatrix[e.eventsMatrix.length-1].push(t)},checkoutEveryNth:30,checkoutEveryNms:3e4})},t.apply=function(e){var t=this;e(t.name,(function(e,n){var o=e.state,r=e.utils;o[t.name]||t.startRecordVideo(),n(r.compressData(t.getRedo()))}))},e}();export default e;
2 |
--------------------------------------------------------------------------------
/lib/index-5d5b259f.js:
--------------------------------------------------------------------------------
1 | function t(){return(t=Object.assign||function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o=navigator.userAgent,i=document.referrer,a=function(){return(new Date).getTime()},s=function(){return(""+a()*Math.random()).slice(0,8)},u=function(){return~~performance.now()},c=function(t){window.dispatchEvent(new CustomEvent(t,{detail:{target:this,time:a()}}))},f=function(t){return"function"==typeof t},l=function(t){return t<400},h=function t(e){if(""!==e.id)return'//*[@id="'+e.id+'"]';if(e==document.body)return"/html/"+e.tagName.toLowerCase();for(var r=1,n=e.parentNode.childNodes,o=0,i=n.length;oe){var n=Math.max(e-100,50);r=r.substr(0,n)+"... ..."+r.substr(n-e+50)}return r||""},p=function(t){return t.replace(/^[^/]*:?\/\//,"").split(/\?|#/)[0]},m=function(t,e){return t.some((function(t){return t instanceof RegExp?t.test(e):"string"==typeof t?p(t)===p(e):void 0}))};var v=function(){var t=navigator.userAgent.toLowerCase();return(t.indexOf("msie")>-1?t.match(/msie ([\d.]+)/)[1]:100)<=8},g=function(t){return t?t===document?"html":t.tagName?t.tagName:t.outerHTML.match(/<([^>\s]+)/)[1]:""},y=function(t){var e,r=t.error||{};return{type:t._type||t.type,name:null==(e=t.name||t.message&&t.message.split(":")[0]||t.type)?void 0:e.replace(/^Uncaught\s/,""),message:d(t.message||t.description||"",300),extraInfo:t.extraInfo||{},stacktrace:t.error&&r.stack,target:t._target,timeStamp:u(),title:document.title,referrer:i,url:location.href,userAgent:o,columnNumber:t.colno||r.columnNumber,lineNumber:t.lineno||r.lineNumber,cookie:document.cookie,version:"1.0.0"}},w=Uint8Array,b=Uint16Array,E=Uint32Array,S=new w([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),k=new w([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),x=new w([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),T=function(t,e){for(var r=new b(31),n=0;n<31;++n)r[n]=e+=1<>>1|(21845&N)<<1;M=(61680&(M=(52428&M)>>>2|(13107&M)<<2))>>>4|(3855&M)<<4,L[N]=((65280&M)>>>8|(255&M)<<8)>>>1}var A=function(t,e,r){for(var n=t.length,o=0,i=new b(e);o>>u]=c}else for(a=new b(n),o=0;o>>15-t[o]);return a},O=new w(288);for(N=0;N<144;++N)O[N]=8;for(N=144;N<256;++N)O[N]=9;for(N=256;N<280;++N)O[N]=7;for(N=280;N<288;++N)O[N]=8;var I=new w(32);for(N=0;N<32;++N)I[N]=5;var R=A(O,9,0),$=A(I,5,0),H=function(t){return(t+7)/8|0},U=function(t,e,r){(null==e||e<0)&&(e=0),(null==r||r>t.length)&&(r=t.length);var n=new(t instanceof b?b:t instanceof E?E:w)(r-e);return n.set(t.subarray(e,r)),n},W=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],D=function(t,e,r){var n=new Error(e||W[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,D),!r)throw n;return n},B=function(t,e,r){r<<=7&e;var n=e/8|0;t[n]|=r,t[n+1]|=r>>>8},K=function(t,e,r){r<<=7&e;var n=e/8|0;t[n]|=r,t[n+1]|=r>>>8,t[n+2]|=r>>>16},q=function(t,e){for(var r=[],n=0;nh&&(h=i[n].s);var d=new b(h+1),p=J(r[f-1],d,0);if(p>e){n=0;var m=0,v=p-e,g=1<e))break;m+=g-(1<>>=v;m>0;){var E=i[n].s;d[E]=0&&m;--n){var S=i[n].s;d[S]==e&&(--d[S],++m)}p=e}return[new w(d),p]},J=function(t,e,r){return-1==t.s?Math.max(J(t.l,e,r+1),J(t.r,e,r+1)):e[t.s]=r},F=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new b(++e),n=0,o=t[0],i=1,a=function(t){r[n++]=t},s=1;s<=e;++s)if(t[s]==o&&s!=e)++i;else{if(!o&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(o),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(o);i=1,o=t[s]}return[r.subarray(0,n),e]},G=function(t,e){for(var r=0,n=0;n>>8,t[o+2]=255^t[o],t[o+3]=255^t[o+1];for(var i=0;i4&&!L[x[M-1]];--M);var H,U,W,D,J=c+5<<3,z=G(o,O)+G(i,I)+a,Q=G(o,h)+G(i,m)+a+14+3*M+G(j,L)+(2*j[16]+3*j[17]+7*j[18]);if(J<=z&&J<=Q)return X(e,f,t.subarray(u,u+c));if(B(e,f,1+(Q15&&(B(e,f,tt[_]>>>5&127),f+=tt[_]>>>12)}}}else H=R,U=O,W=$,D=I;for(_=0;_255){et=n[_]>>>18&31;K(e,f,H[et+257]),f+=U[et+257],et>7&&(B(e,f,n[_]>>>23&31),f+=S[et]);var rt=31&n[_];K(e,f,W[rt]),f+=D[rt],rt>3&&(K(e,f,n[_]>>>5&8191),f+=k[rt])}else K(e,f,H[n[_]]),f+=U[n[_]];return K(e,f,H[256]),f+U[256]},Q=new E([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),V=new w(0),Y=function(t,e,r,n,o){return function(t,e,r,n,o,i){var a=t.length,s=new w(n+a+5*(1+Math.ceil(a/7e3))+o),u=s.subarray(n,s.length-o),c=0;if(!e||a<8)for(var f=0;f<=a;f+=65535){var l=f+65535;l>>13,p=8191&h,m=(1<7e3||A>24576)&&D>423){c=z(t,u,0,C,j,L,M,A,I,f-I,c),A=N=M=0,I=f;for(var B=0;B<286;++B)j[B]=0;for(B=0;B<30;++B)L[B]=0}var K=2,q=0,J=p,F=$-W&32767;if(D>2&&R==T(f-F))for(var G=Math.min(d,D)-1,Y=Math.min(32767,f),Z=Math.min(258,D);F<=Y&&--J&&$!=W;){if(t[f+K]==t[f+K-F]){for(var tt=0;ttK){if(K=tt,q=F,tt>G)break;var et=Math.min(F,tt-2),rt=0;for(B=0;Brt&&(rt=ot,W=nt)}}}F+=($=W)-(W=v[$])+32768&32767}if(q){C[A++]=268435456|_[K]<<18|P[q];var it=31&_[K],at=31&P[q];M+=S[it]+k[at],++j[257+it],++L[at],O=f+K,++N}else C[A++]=t[f],++j[t[f]]}}c=z(t,u,i,C,j,L,M,A,I,f-I,c),!i&&7&c&&(c=X(u,c+1,V))}return U(s,0,n+H(c)+o)}(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,r,n,!o)};function Z(t,e){e||(e={});var r=function(){var t=1,e=0;return{p:function(r){for(var n=t,o=e,i=0|r.length,a=0;a!=i;){for(var s=Math.min(a+2655,i);a>16),o=(65535&o)+15*(o>>16)}t=n,e=o},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(e%=65521))<<8|e>>>8}}}();r.p(t);var n=Y(t,e,2,4);return function(t,e){var r=e.level,n=0==r?0:r<6?1:9==r?3:2;t[0]=120,t[1]=n<<6|(n?32-2*n:1)}(n,e),function(t,e,r){for(;r;++e)t[e]=r,r>>>=8}(n,n.length-4,r.d()),n}var tt="undefined"!=typeof TextEncoder&&new TextEncoder,et="undefined"!=typeof TextDecoder&&new TextDecoder;try{et.decode(V,{stream:!0}),1}catch(t){}function rt(t,e){if(e){for(var r="",n=0;n127)+(n>223)+(n>239);if(r+o>t.length)return[e,U(t,r-1)];o?3==o?(n=((15&n)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=1&o?String.fromCharCode((31&n)<<6|63&t[r++]):String.fromCharCode((15&n)<<12|(63&t[r++])<<6|63&t[r++]):e+=String.fromCharCode(n)}}(t),i=o[0];return o[1].length&&D(8),i}function nt(t){return rt(Z(function(t,e){if(e){for(var r=new w(t.length),n=0;n>1)),a=0,s=function(t){i[a++]=t};for(n=0;ni.length){var u=new w(a+8+(o-n<<1));u.set(i),i=u}var c=t.charCodeAt(n);c<128||e?s(c):c<2048?(s(192|c>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++n))>>18),s(128|c>>12&63),s(128|c>>6&63),s(128|63&c)):(s(224|c>>12),s(128|c>>6&63),s(128|63&c))}return U(i,0,a)}(t="string"==typeof t?t:JSON.stringify(t))),!0)}var ot="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var it=function(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}((function(t){!function(e){function r(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function n(t,e,n,o,i,a){return r((s=r(r(e,t),r(o,a)))<<(u=i)|s>>>32-u,n);var s,u}function o(t,e,r,o,i,a,s){return n(e&r|~e&o,t,e,i,a,s)}function i(t,e,r,o,i,a,s){return n(e&o|r&~o,t,e,i,a,s)}function a(t,e,r,o,i,a,s){return n(e^r^o,t,e,i,a,s)}function s(t,e,r,o,i,a,s){return n(r^(e|~o),t,e,i,a,s)}function u(t,e){var n,u,c,f;t[e>>5]|=128<>>9<<4)]=e;for(var l=1732584193,h=-271733879,d=-1732584194,p=271733878,m=0;m>5]>>>n%32&255);return e}function f(t){var e=[];for(e[(t.length>>2)-1]=void 0,n=0;n>5]|=(255&t.charCodeAt(n/8))<>>4&15)+r.charAt(15&e);return n}function h(t){return unescape(encodeURIComponent(t))}function d(t){return c(u(f(e=h(t)),8*e.length));var e}function p(t,e){return function(t,e){var r,n,o=f(t),i=[],a=[];for(i[15]=a[15]=void 0,166291456?"[large size Edith Plugins Data]":n}return e}));function St(t){return(t&&"object"==typeof t&&t instanceof Error?t.stack:t)||""}function kt(t){return t=nt(St(t))}var xt="";function Tt(t,e,r){r&&r.apiKey&&(xt=r.apiKey),It({version:"1.0.0",format:"es",name:t,message:kt(e),scriptUrl:mt,userAgent:navigator.userAgent,apiKey:xt})}var Ct=wt((function(t,e){localStorage.setItem(t,JSON.stringify(e))})),jt=wt((function(t){return JSON.parse(localStorage.getItem(t))}));function _t(t){var e=jt("_edith_key")||{},r=a(),n={apiKey:t.apiKey,errs:[],now:r,cookie:document.cookie,userAgent:navigator.userAgent};Object.keys(e).forEach((function(t){var o=e[t].length,i=e[t].filter((function(t){return r-t<72e5}));if(1!==i.length||1!==o){var a=i.slice(o===i.length?1:0);n.errs.push({onlyTag:t,times:a}),delete e[t]}})),0!==n.errs.length&&(Mt(n),Ct("_edith_key",e))}var Pt=null,Lt={root:"/",setRoot:function(t){this.root=t},getRootByUrl:function(t){return(t=t.replace(/^http(s?):\/\//,"//")).match(/^\/\//)?"":this.root},get:function(t){var e=this;return function(r){void 0===r&&(r={}),Pt=new XMLHttpRequest;var n=e.getRootByUrl(t);return function(t,e){return new Promise((function(r,n){t.onreadystatechange=wt((function(){if(4===t.readyState){var e=["","text"].indexOf(t.responseType)>=0?t.responseText:"no responseText";if(200===t.status){var o={};try{o=JSON.parse(e)}catch(t){o=e}r(o)}else t.status>399&&n(e)}})),e()}))}(Pt,(function(){Pt.open("GET",""+n+t+"?"+function(t,e){var r,n,o="";for(r in t)n=t[r],o+=r+"="+("function"==typeof e?e(n,r):n&&"object"==typeof n&&!Object.getPrototypeOf(n).slice?JSON.stringify(n):n)+"&";return o.slice(0,-1)}(r),!0),Pt.send()}))}},post:function(t){var e=this;return function(r){void 0===r&&(r={}),Pt=new XMLHttpRequest;var n=e.getRootByUrl(t);Pt.open("POST",""+n+t,!0),Pt.setRequestHeader("Content-type","application/json;charset=utf-8"),Pt.withCredentials=!0,Pt.send(JSON.stringify(r))}}};Lt.setRoot("https://event-edith.op-center.cn");var Nt=Lt.post("/v1/monitor/add"),Mt=Lt.post("/v1/monitor/batch-add"),At=Lt.get("/v1/upload/test-img"),Ot=Lt.get("/v1/white-list/get"),It=Lt.post("/v1/monitor/script-add"),Rt=["resourceWhiteList","ajaxWhiteList"],$t=function(t){if(2==+t.match_type){var e=t.match.match(/\/(\w)*$/);return new RegExp(t.match.slice(1,e.index),e[1])}return t.match},Ht=function(){function e(){var e=this;this.life="",this.plugins=[],this.state={plugins:{}},this.utils={compressData:kt,compressString:kt,measureBWSimple:At,edithAddEventListener:bt},this.init=function(r){if(e.life)return console.warn("只需要初始化一次");if(!e._waitPromise(r)){var n=r||{},o=n.apiKey,i=n.silentDev;if(!r||!o)return console.warn("请传入项目的apiKey");e.$life(at),e.setState({api_key:o}),i&&location.host.match(/^localhost|[\d.]+$/)&&(e.notListening=!0),e._willMount(r),e.initState=t({},e.state),e._didMount(e.state),e._checkSelf().then((function(){e.$life(ft),e._installPlugins(e).then((function(){e._collecting(),e.initState=t({},e.state)})),f(e.pluginInstalled)&&e.pluginInstalled(),e.$life(lt)})).catch(e._sleep.bind(e))}},this.setState=function(r,n){if(e.life!==ht||n){var o=e.state;e.state=t({},o,r)}},this.compilerCallback=function(r,n){var o,i=((o={})[r]=n,o);e.setState(gt[r]?i:{plugins:t({},e.state.plugins,i)},!0)},this.compiler=function(t,r){var n=e.compilerCallback,o=e;r(e,(function(e){n.call(o,t,e)}))},this.reportDebug=Nt}var r=e.prototype;return r.$life=function(t){this.life=t},r._waitPromise=function(t){var e=this;if(!window.Promise)return bt("promisePolyfill",(function(){return e.init(t)})),!0},r._willMount=function(t){var e=this,r=t.plugins;this.$life(st),f(this.willMount)&&this.willMount(t),this.plugins=r instanceof Array?r:[],Rt.forEach((function(t){e[t]=[].concat(e[t]||[],yt[t])}));Ot({apiKey:this.apiKey}).then((function(t){Rt.forEach((function(r,n){var o,i;e[r]=e[r].concat((o=t.data||[],i=n+1,o.filter((function(t){return+t.type===i})).map($t)))}))})).catch((function(t){}))},r._didMount=function(){this.$life(ut),f(this.didMount)&&this.didMount(),function t(e,r){!r&&_t(e);var n=setTimeout((function(){_t(e),clearTimeout(n),n=null,t(e,1)}),6e5)}(this)},r._checkSelf=function(){var t=this;return this.$life(ct),new Promise((function(e,r){if(f(t.checkSelf))try{t.checkSelf()}catch(t){console.log("edith自检发生错误",t),Tt("SelfCheckError",t),r(t)}e()}))},r._installPlugins=function(){var t=this;return new Promise((function(e,r){var n,o=[];t.plugins.forEach((function(t){if(t)if("string"==typeof t){var e=pt[t];e&&o.push(e())}else o.push(t)})),(n=o,Promise.all(n.map((function(t){return t.catch?t.catch((function(t){return 0})):t})))).then((function(r){(r=r.map((function(t){return f(t.default)?new t.default:t}))).forEach((function(e){e&&Rt.forEach((function(r){t[r]=[].concat(t[r],e[r]||[])}))})),t.plugins=r,e()}))}))},r._collecting=function(){var t=this;this.plugins.forEach((function(e){var r=e.constructor.name;if(!e.apply)return gt[e]||console.warn("Edith插件["+e.constructor.name+"]必须实现apply方法");try{e.apply(t.compiler.bind(t))}catch(e){Tt("CollectError",{error:St(e),plugin:r,life:t.life})}})),f(this.collecting)&&this.collecting()},r._sleep=function(){this.$life(dt),this.$life=function(){},f(this.sleep)&&this.sleep(),this.$handleCollect=function(){}},r.$handleCollect=function(){var e=this;if(this.life===lt){this.$life(ht);var r=setTimeout(wt((function(){var n,o,i,s=e.state,u=function(t){var e=t.message,r=t.name,n=t.extraInfo,o="resourceError"===r?p(e||""):e,i=location.host+location.pathname.replace(/index\.html$/,"")+r+o+p(n.url||"")+(n.method||"");return it(i)}(s);if(n=u,o=jt("_edith_key")||{},(i=!!o[n])?o[n].push(a()):o[n]=[a()],Ct("_edith_key",o),!i){var c={name:s.name,message:s.message,url:s.url,title:s.title,ajax:s.extraInfo||{url:""},target:s.target||{}};e.filters(c)&&"customError"!==s.type||(e._collecting(),e.reportDebug(t({},e.state,{onlyTag:u,plugins:kt(Et(e.state.plugins))})))}e.state=e.initState,e.$life(lt),clearTimeout(r),r=null})),16)}},e}();function Ut(){var e,r,n,o;!function(){if(f(t))return!1;function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),r}t.prototype=Event.prototype,window.CustomEvent=t}(),e={abort:"ajaxAbort",error:"ajaxError",progress:"ajaxProgress",timeout:"ajaxTimeout",loadend:"ajaxLoadEnd"},r=window.XMLHttpRequest,n=["error","timeout","abort"],window.XMLHttpRequest=function(){var t=new r,o=!1;Object.keys(e).forEach((function(r){t.addEventListener(r,(function(t){c.call(this,e[r]),o||(o=n.indexOf(r)>=0),"loadend"===r&&(l(this.status)||o||c.call(this,e.error))}),!1)}));var i=t.send;t.send=function(){for(var e=arguments.length,r=new Array(e),n=0;n标签),umd(以amd、cjs、iife为一体)
56 | },
57 | plugins
58 | },
59 | {
60 | input: 'src/plugins/BreadcrumbsPlugin.js',
61 | output: {
62 | name: 'Edith.BreadcrumbsPlugin',
63 | dir: IS_DEV ? `test/static/plugins` : `dist/plugins`,
64 | format, // 打包的类型格式,amd(异步模块定义),cjs(commonjs),es(将软件包保存为es模块文件),iife(适合作为 -->
8 |
9 |
10 |
61 |
62 |
63 |
64 |
65 | 按钮组:
66 |
69 |
72 |
75 |
78 |
81 |
84 |
87 |
88 |
89 |
90 |
141 |
162 |
181 |
182 |
195 |
196 |
197 |