Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | 2x 2x 2x 2x 2x 2x 2x 2x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 1x 7x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 2x 1x 1x 1x 2x 1x 1x 1x | "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.addReplaceHandler = void 0; var utils_1 = require("@mito/utils"); var core_1 = require("@mito/core"); var types_1 = require("@mito/types"); var common_1 = require("@mito/common"); var clickThrottle = utils_1.throttle(common_1.triggerHandlers, 600); function isFilterHttpUrl(url) { return core_1.options.filterXhrUrlRegExp && core_1.options.filterXhrUrlRegExp.test(url); } function replace(type) { switch (type) { case common_1.EVENTTYPES.XHR: xhrReplace(); break; case common_1.EVENTTYPES.FETCH: fetchReplace(); break; case common_1.EVENTTYPES.ERROR: listenError(); break; case common_1.EVENTTYPES.CONSOLE: consoleReplace(); break; case common_1.EVENTTYPES.HISTORY: historyReplace(); break; case common_1.EVENTTYPES.UNHANDLEDREJECTION: unhandledrejectionReplace(); break; case common_1.EVENTTYPES.DOM: domReplace(); break; case common_1.EVENTTYPES.HASHCHANGE: listenHashchange(); break; default: break; } } function addReplaceHandler(handler) { if (!common_1.subscribeEvent(handler)) return; replace(handler.type); } exports.addReplaceHandler = addReplaceHandler; function xhrReplace() { Iif (!('XMLHttpRequest' in utils_1._global)) { return; } var originalXhrProto = XMLHttpRequest.prototype; utils_1.replaceOld(originalXhrProto, 'open', function (originalOpen) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } this.mito_xhr = { method: utils_1.variableTypeDetection.isString(args[0]) ? args[0].toUpperCase() : args[0], url: args[1], sTime: utils_1.getTimestamp(), type: common_1.HTTPTYPE.XHR }; originalOpen.apply(this, args); }; }); utils_1.replaceOld(originalXhrProto, 'send', function (originalSend) { return function () { var _this = this; var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var _a = this.mito_xhr, method = _a.method, url = _a.url; core_1.setTraceId(url, function (headerFieldName, traceId) { _this.mito_xhr.traceId = traceId; _this.setRequestHeader(headerFieldName, traceId); }); core_1.options.beforeAppAjaxSend && core_1.options.beforeAppAjaxSend({ method: method, url: url }, this); utils_1.on(this, 'loadend', function () { if ((method === types_1.EMethods.Post && core_1.transportData.isSdkTransportUrl(url)) || isFilterHttpUrl(url)) return; var _a = this, responseType = _a.responseType, response = _a.response, status = _a.status; this.mito_xhr.reqData = args[0]; var eTime = utils_1.getTimestamp(); this.mito_xhr.time = eTime; this.mito_xhr.status = status; if (['', 'json', 'text'].indexOf(responseType) !== -1) { this.mito_xhr.responseText = typeof response === 'object' ? JSON.stringify(response) : response; } this.mito_xhr.elapsedTime = eTime - this.mito_xhr.sTime; common_1.triggerHandlers(common_1.EVENTTYPES.XHR, this.mito_xhr); }); originalSend.apply(this, args); }; }); } function fetchReplace() { Eif (!('fetch' in utils_1._global)) { return; } utils_1.replaceOld(utils_1._global, common_1.EVENTTYPES.FETCH, function (originalFetch) { return function (url, config) { if (config === void 0) { config = {}; } var sTime = utils_1.getTimestamp(); var method = (config && config.method) || 'GET'; var handlerData = { type: common_1.HTTPTYPE.FETCH, method: method, reqData: config && config.body, url: url }; var headers = new Headers(config.headers || {}); Object.assign(headers, { setRequestHeader: headers.set }); core_1.setTraceId(url, function (headerFieldName, traceId) { handlerData.traceId = traceId; headers.set(headerFieldName, traceId); }); core_1.options.beforeAppAjaxSend && core_1.options.beforeAppAjaxSend({ method: method, url: url }, headers); config = __assign(__assign({}, config), { headers: headers }); return originalFetch.apply(utils_1._global, [url, config]).then(function (res) { var tempRes = res.clone(); var eTime = utils_1.getTimestamp(); handlerData = __assign(__assign({}, handlerData), { elapsedTime: eTime - sTime, status: tempRes.status, time: eTime }); tempRes.text().then(function (data) { if (method === types_1.EMethods.Post && core_1.transportData.isSdkTransportUrl(url)) return; if (isFilterHttpUrl(url)) return; handlerData.responseText = tempRes.status > common_1.HTTP_CODE.UNAUTHORIZED && data; common_1.triggerHandlers(common_1.EVENTTYPES.FETCH, handlerData); }); return res; }, function (err) { var eTime = utils_1.getTimestamp(); if (method === types_1.EMethods.Post && core_1.transportData.isSdkTransportUrl(url)) return; if (isFilterHttpUrl(url)) return; handlerData = __assign(__assign({}, handlerData), { elapsedTime: eTime - sTime, status: 0, time: eTime }); common_1.triggerHandlers(common_1.EVENTTYPES.FETCH, handlerData); throw err; }); }; }); } function listenHashchange() { Iif (!utils_1.isExistProperty(utils_1._global, 'onpopstate')) { utils_1.on(utils_1._global, common_1.EVENTTYPES.HASHCHANGE, function (e) { common_1.triggerHandlers(common_1.EVENTTYPES.HASHCHANGE, e); }); } } function listenError() { utils_1.on(utils_1._global, 'error', function (e) { common_1.triggerHandlers(common_1.EVENTTYPES.ERROR, e); }, true); } function consoleReplace() { Iif (!('console' in utils_1._global)) { return; } var logType = ['log', 'debug', 'info', 'warn', 'error', 'assert']; logType.forEach(function (level) { Iif (!(level in utils_1._global.console)) return; utils_1.replaceOld(utils_1._global.console, level, function (originalConsole) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (originalConsole) { common_1.triggerHandlers(common_1.EVENTTYPES.CONSOLE, { args: args, level: level }); originalConsole.apply(utils_1._global.console, args); } }; }); }); } var lastHref; lastHref = utils_1.getLocationHref(); function historyReplace() { Iif (!utils_1.supportsHistory()) return; var oldOnpopstate = utils_1._global.onpopstate; utils_1._global.onpopstate = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var to = utils_1.getLocationHref(); var from = lastHref; common_1.triggerHandlers(common_1.EVENTTYPES.HISTORY, { from: from, to: to }); oldOnpopstate && oldOnpopstate.apply(this, args); }; function historyReplaceFn(originalHistoryFn) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var url = args.length > 2 ? args[2] : undefined; if (url) { var from = lastHref; var to = String(url); lastHref = to; common_1.triggerHandlers(common_1.EVENTTYPES.HISTORY, { from: from, to: to }); } return originalHistoryFn.apply(this, args); }; } utils_1.replaceOld(utils_1._global.history, 'pushState', historyReplaceFn); utils_1.replaceOld(utils_1._global.history, 'replaceState', historyReplaceFn); } function unhandledrejectionReplace() { utils_1.on(utils_1._global, common_1.EVENTTYPES.UNHANDLEDREJECTION, function (ev) { common_1.triggerHandlers(common_1.EVENTTYPES.UNHANDLEDREJECTION, ev); }); } function domReplace() { if (!('document' in utils_1._global)) return; utils_1.on(utils_1._global.document, 'click', function () { clickThrottle(common_1.EVENTTYPES.DOM, { category: 'click', data: this }); }, true); } //# sourceMappingURL=replace.js.map |