├── .eslintrc.yml ├── .gitignore ├── .gitlab-ci.yml ├── .yo-rc.json ├── LICENSE ├── README.md ├── dist └── index │ ├── dependencyGraph.json │ ├── index.html │ └── static │ └── js │ ├── index.debug.js │ └── index.min.js ├── lib ├── index.debug.js └── index.min.js ├── marauder.config.js ├── package-lock.json ├── package.json └── src ├── events.js ├── index.js ├── utils.js └── view └── index ├── index.html └── index.js /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | extends: 'eslint-config-sinamfe' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | node_modules 4 | *.log 5 | npm-debug.log* 6 | .idea 7 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - dummy 3 | - dev 4 | - test 5 | - deploy 6 | 7 | Ready Step: 8 | stage: dummy 9 | script: 10 | - echo "Ready" 11 | tags: 12 | - SMFE 13 | only: 14 | - /^tag__.+__.+/ 15 | 16 | dev: 17 | stage: dev 18 | script: 19 | - echo $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME $CI_COMMIT_REF_SLUG 20 | - cnpm install @mfelibs/ci-runner-script 21 | - node ./node_modules/@mfelibs/ci-runner-script/index.js $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME dev excute 22 | tags: 23 | - SMFE 24 | when: manual 25 | only: 26 | - /^tag__.+__.+/ 27 | 28 | simulate: 29 | stage: test 30 | script: 31 | - echo $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME $CI_COMMIT_REF_SLUG 32 | - cnpm install @mfelibs/ci-runner-script 33 | - node ./node_modules/@mfelibs/ci-runner-script/index.js $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME simulate excute 34 | tags: 35 | - SMFE 36 | when: manual 37 | only: 38 | - /^tag__.+__.+/ 39 | 40 | deploy: 41 | stage: deploy 42 | script: 43 | - echo $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME $CI_COMMIT_REF_SLUG 44 | - cnpm install @mfelibs/ci-runner-script 45 | - node ./node_modules/@mfelibs/ci-runner-script/index.js $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME nogrey excute 46 | tags: 47 | - SMFE 48 | when: manual 49 | only: 50 | - /^tag__.+__.+/ 51 | 52 | grey: 53 | stage: deploy 54 | script: 55 | - echo $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME $CI_COMMIT_REF_SLUG 56 | - cnpm install @mfelibs/ci-runner-script 57 | - node ./node_modules/@mfelibs/ci-runner-script/index.js $GITLAB_USER_EMAIL $USER $CI_PROJECT_URL $CI_COMMIT_REF_NAME $CI_PROJECT_NAME grey excute 58 | tags: 59 | - SMFE 60 | when: manual 61 | only: 62 | - /^tag__.+__.+/ 63 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-mcli": { 3 | "promptValues": { 4 | "authorName": "xiaojue", 5 | "authorEmail": "designsor@gmail.com" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 xiaojue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### fe-report 2 | 3 | 上报前端各种信息,统一封装模块,支持post和get,post需要支持cors,get为图片请求实现。 4 | -------------------------------------------------------------------------------- /dist/index/dependencyGraph.json: -------------------------------------------------------------------------------- 1 | [{"entry":"index","dependency":[{"name":"/Users/xiaojue/Dev/projects/fe-report/src/view/index/index.js","type":"CMD","version":"0.1.0","dependency":[{"name":"../../index","type":"CMD","version":"0.1.0","dependency":[{"name":"./events","type":"CMD","version":"0.1.0","dependency":[]},{"name":"./utils","type":"CMD","version":"0.1.0","dependency":[]}]}]}]}] -------------------------------------------------------------------------------- /dist/index/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | index 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dist/index/static/js/index.debug.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { 40 | /******/ configurable: false, 41 | /******/ enumerable: true, 42 | /******/ get: getter 43 | /******/ }); 44 | /******/ } 45 | /******/ }; 46 | /******/ 47 | /******/ // getDefaultExport function for compatibility with non-harmony modules 48 | /******/ __webpack_require__.n = function(module) { 49 | /******/ var getter = module && module.__esModule ? 50 | /******/ function getDefault() { return module['default']; } : 51 | /******/ function getModuleExports() { return module; }; 52 | /******/ __webpack_require__.d(getter, 'a', getter); 53 | /******/ return getter; 54 | /******/ }; 55 | /******/ 56 | /******/ // Object.prototype.hasOwnProperty.call 57 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 | /******/ 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = "./"; 61 | /******/ 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(__webpack_require__.s = 0); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ([ 67 | /* 0 */ 68 | /***/ (function(module, exports, __webpack_require__) { 69 | 70 | __webpack_require__(1); 71 | module.exports = __webpack_require__(8); 72 | 73 | 74 | /***/ }), 75 | /* 1 */ 76 | /***/ (function(module, exports, __webpack_require__) { 77 | 78 | "use strict"; 79 | 80 | 81 | if (typeof Promise === 'undefined') { 82 | window.Promise = __webpack_require__(2) 83 | } 84 | 85 | // Object.assign() is commonly used with React. 86 | // It will use the native implementation if it's present and isn't buggy. 87 | Object.assign = __webpack_require__(7) 88 | 89 | 90 | /***/ }), 91 | /* 2 */ 92 | /***/ (function(module, exports, __webpack_require__) { 93 | 94 | /* WEBPACK VAR INJECTION */(function(setImmediate) {(function (root) { 95 | 96 | // Store setTimeout reference so promise-polyfill will be unaffected by 97 | // other code modifying setTimeout (like sinon.useFakeTimers()) 98 | var setTimeoutFunc = setTimeout; 99 | 100 | function noop() {} 101 | 102 | // Polyfill for Function.prototype.bind 103 | function bind(fn, thisArg) { 104 | return function () { 105 | fn.apply(thisArg, arguments); 106 | }; 107 | } 108 | 109 | function Promise(fn) { 110 | if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new'); 111 | if (typeof fn !== 'function') throw new TypeError('not a function'); 112 | this._state = 0; 113 | this._handled = false; 114 | this._value = undefined; 115 | this._deferreds = []; 116 | 117 | doResolve(fn, this); 118 | } 119 | 120 | function handle(self, deferred) { 121 | while (self._state === 3) { 122 | self = self._value; 123 | } 124 | if (self._state === 0) { 125 | self._deferreds.push(deferred); 126 | return; 127 | } 128 | self._handled = true; 129 | Promise._immediateFn(function () { 130 | var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; 131 | if (cb === null) { 132 | (self._state === 1 ? resolve : reject)(deferred.promise, self._value); 133 | return; 134 | } 135 | var ret; 136 | try { 137 | ret = cb(self._value); 138 | } catch (e) { 139 | reject(deferred.promise, e); 140 | return; 141 | } 142 | resolve(deferred.promise, ret); 143 | }); 144 | } 145 | 146 | function resolve(self, newValue) { 147 | try { 148 | // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure 149 | if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); 150 | if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 151 | var then = newValue.then; 152 | if (newValue instanceof Promise) { 153 | self._state = 3; 154 | self._value = newValue; 155 | finale(self); 156 | return; 157 | } else if (typeof then === 'function') { 158 | doResolve(bind(then, newValue), self); 159 | return; 160 | } 161 | } 162 | self._state = 1; 163 | self._value = newValue; 164 | finale(self); 165 | } catch (e) { 166 | reject(self, e); 167 | } 168 | } 169 | 170 | function reject(self, newValue) { 171 | self._state = 2; 172 | self._value = newValue; 173 | finale(self); 174 | } 175 | 176 | function finale(self) { 177 | if (self._state === 2 && self._deferreds.length === 0) { 178 | Promise._immediateFn(function() { 179 | if (!self._handled) { 180 | Promise._unhandledRejectionFn(self._value); 181 | } 182 | }); 183 | } 184 | 185 | for (var i = 0, len = self._deferreds.length; i < len; i++) { 186 | handle(self, self._deferreds[i]); 187 | } 188 | self._deferreds = null; 189 | } 190 | 191 | function Handler(onFulfilled, onRejected, promise) { 192 | this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; 193 | this.onRejected = typeof onRejected === 'function' ? onRejected : null; 194 | this.promise = promise; 195 | } 196 | 197 | /** 198 | * Take a potentially misbehaving resolver function and make sure 199 | * onFulfilled and onRejected are only called once. 200 | * 201 | * Makes no guarantees about asynchrony. 202 | */ 203 | function doResolve(fn, self) { 204 | var done = false; 205 | try { 206 | fn(function (value) { 207 | if (done) return; 208 | done = true; 209 | resolve(self, value); 210 | }, function (reason) { 211 | if (done) return; 212 | done = true; 213 | reject(self, reason); 214 | }); 215 | } catch (ex) { 216 | if (done) return; 217 | done = true; 218 | reject(self, ex); 219 | } 220 | } 221 | 222 | Promise.prototype['catch'] = function (onRejected) { 223 | return this.then(null, onRejected); 224 | }; 225 | 226 | Promise.prototype.then = function (onFulfilled, onRejected) { 227 | var prom = new (this.constructor)(noop); 228 | 229 | handle(this, new Handler(onFulfilled, onRejected, prom)); 230 | return prom; 231 | }; 232 | 233 | Promise.all = function (arr) { 234 | return new Promise(function (resolve, reject) { 235 | if (!arr || typeof arr.length === 'undefined') throw new TypeError('Promise.all accepts an array'); 236 | var args = Array.prototype.slice.call(arr); 237 | if (args.length === 0) return resolve([]); 238 | var remaining = args.length; 239 | 240 | function res(i, val) { 241 | try { 242 | if (val && (typeof val === 'object' || typeof val === 'function')) { 243 | var then = val.then; 244 | if (typeof then === 'function') { 245 | then.call(val, function (val) { 246 | res(i, val); 247 | }, reject); 248 | return; 249 | } 250 | } 251 | args[i] = val; 252 | if (--remaining === 0) { 253 | resolve(args); 254 | } 255 | } catch (ex) { 256 | reject(ex); 257 | } 258 | } 259 | 260 | for (var i = 0; i < args.length; i++) { 261 | res(i, args[i]); 262 | } 263 | }); 264 | }; 265 | 266 | Promise.resolve = function (value) { 267 | if (value && typeof value === 'object' && value.constructor === Promise) { 268 | return value; 269 | } 270 | 271 | return new Promise(function (resolve) { 272 | resolve(value); 273 | }); 274 | }; 275 | 276 | Promise.reject = function (value) { 277 | return new Promise(function (resolve, reject) { 278 | reject(value); 279 | }); 280 | }; 281 | 282 | Promise.race = function (values) { 283 | return new Promise(function (resolve, reject) { 284 | for (var i = 0, len = values.length; i < len; i++) { 285 | values[i].then(resolve, reject); 286 | } 287 | }); 288 | }; 289 | 290 | // Use polyfill for setImmediate for performance gains 291 | Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) || 292 | function (fn) { 293 | setTimeoutFunc(fn, 0); 294 | }; 295 | 296 | Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { 297 | if (typeof console !== 'undefined' && console) { 298 | console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console 299 | } 300 | }; 301 | 302 | /** 303 | * Set the immediate function to execute callbacks 304 | * @param fn {function} Function to execute 305 | * @deprecated 306 | */ 307 | Promise._setImmediateFn = function _setImmediateFn(fn) { 308 | Promise._immediateFn = fn; 309 | }; 310 | 311 | /** 312 | * Change the function to execute on unhandled rejection 313 | * @param {function} fn Function to execute on unhandled rejection 314 | * @deprecated 315 | */ 316 | Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { 317 | Promise._unhandledRejectionFn = fn; 318 | }; 319 | 320 | if (typeof module !== 'undefined' && module.exports) { 321 | module.exports = Promise; 322 | } else if (!root.Promise) { 323 | root.Promise = Promise; 324 | } 325 | 326 | })(this); 327 | 328 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3).setImmediate)) 329 | 330 | /***/ }), 331 | /* 3 */ 332 | /***/ (function(module, exports, __webpack_require__) { 333 | 334 | var apply = Function.prototype.apply; 335 | 336 | // DOM APIs, for completeness 337 | 338 | exports.setTimeout = function() { 339 | return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); 340 | }; 341 | exports.setInterval = function() { 342 | return new Timeout(apply.call(setInterval, window, arguments), clearInterval); 343 | }; 344 | exports.clearTimeout = 345 | exports.clearInterval = function(timeout) { 346 | if (timeout) { 347 | timeout.close(); 348 | } 349 | }; 350 | 351 | function Timeout(id, clearFn) { 352 | this._id = id; 353 | this._clearFn = clearFn; 354 | } 355 | Timeout.prototype.unref = Timeout.prototype.ref = function() {}; 356 | Timeout.prototype.close = function() { 357 | this._clearFn.call(window, this._id); 358 | }; 359 | 360 | // Does not start the time, just sets up the members needed. 361 | exports.enroll = function(item, msecs) { 362 | clearTimeout(item._idleTimeoutId); 363 | item._idleTimeout = msecs; 364 | }; 365 | 366 | exports.unenroll = function(item) { 367 | clearTimeout(item._idleTimeoutId); 368 | item._idleTimeout = -1; 369 | }; 370 | 371 | exports._unrefActive = exports.active = function(item) { 372 | clearTimeout(item._idleTimeoutId); 373 | 374 | var msecs = item._idleTimeout; 375 | if (msecs >= 0) { 376 | item._idleTimeoutId = setTimeout(function onTimeout() { 377 | if (item._onTimeout) 378 | item._onTimeout(); 379 | }, msecs); 380 | } 381 | }; 382 | 383 | // setimmediate attaches itself to the global object 384 | __webpack_require__(4); 385 | exports.setImmediate = setImmediate; 386 | exports.clearImmediate = clearImmediate; 387 | 388 | 389 | /***/ }), 390 | /* 4 */ 391 | /***/ (function(module, exports, __webpack_require__) { 392 | 393 | /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { 394 | "use strict"; 395 | 396 | if (global.setImmediate) { 397 | return; 398 | } 399 | 400 | var nextHandle = 1; // Spec says greater than zero 401 | var tasksByHandle = {}; 402 | var currentlyRunningATask = false; 403 | var doc = global.document; 404 | var registerImmediate; 405 | 406 | function setImmediate(callback) { 407 | // Callback can either be a function or a string 408 | if (typeof callback !== "function") { 409 | callback = new Function("" + callback); 410 | } 411 | // Copy function arguments 412 | var args = new Array(arguments.length - 1); 413 | for (var i = 0; i < args.length; i++) { 414 | args[i] = arguments[i + 1]; 415 | } 416 | // Store and register the task 417 | var task = { callback: callback, args: args }; 418 | tasksByHandle[nextHandle] = task; 419 | registerImmediate(nextHandle); 420 | return nextHandle++; 421 | } 422 | 423 | function clearImmediate(handle) { 424 | delete tasksByHandle[handle]; 425 | } 426 | 427 | function run(task) { 428 | var callback = task.callback; 429 | var args = task.args; 430 | switch (args.length) { 431 | case 0: 432 | callback(); 433 | break; 434 | case 1: 435 | callback(args[0]); 436 | break; 437 | case 2: 438 | callback(args[0], args[1]); 439 | break; 440 | case 3: 441 | callback(args[0], args[1], args[2]); 442 | break; 443 | default: 444 | callback.apply(undefined, args); 445 | break; 446 | } 447 | } 448 | 449 | function runIfPresent(handle) { 450 | // From the spec: "Wait until any invocations of this algorithm started before this one have completed." 451 | // So if we're currently running a task, we'll need to delay this invocation. 452 | if (currentlyRunningATask) { 453 | // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a 454 | // "too much recursion" error. 455 | setTimeout(runIfPresent, 0, handle); 456 | } else { 457 | var task = tasksByHandle[handle]; 458 | if (task) { 459 | currentlyRunningATask = true; 460 | try { 461 | run(task); 462 | } finally { 463 | clearImmediate(handle); 464 | currentlyRunningATask = false; 465 | } 466 | } 467 | } 468 | } 469 | 470 | function installNextTickImplementation() { 471 | registerImmediate = function(handle) { 472 | process.nextTick(function () { runIfPresent(handle); }); 473 | }; 474 | } 475 | 476 | function canUsePostMessage() { 477 | // The test against `importScripts` prevents this implementation from being installed inside a web worker, 478 | // where `global.postMessage` means something completely different and can't be used for this purpose. 479 | if (global.postMessage && !global.importScripts) { 480 | var postMessageIsAsynchronous = true; 481 | var oldOnMessage = global.onmessage; 482 | global.onmessage = function() { 483 | postMessageIsAsynchronous = false; 484 | }; 485 | global.postMessage("", "*"); 486 | global.onmessage = oldOnMessage; 487 | return postMessageIsAsynchronous; 488 | } 489 | } 490 | 491 | function installPostMessageImplementation() { 492 | // Installs an event handler on `global` for the `message` event: see 493 | // * https://developer.mozilla.org/en/DOM/window.postMessage 494 | // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages 495 | 496 | var messagePrefix = "setImmediate$" + Math.random() + "$"; 497 | var onGlobalMessage = function(event) { 498 | if (event.source === global && 499 | typeof event.data === "string" && 500 | event.data.indexOf(messagePrefix) === 0) { 501 | runIfPresent(+event.data.slice(messagePrefix.length)); 502 | } 503 | }; 504 | 505 | if (global.addEventListener) { 506 | global.addEventListener("message", onGlobalMessage, false); 507 | } else { 508 | global.attachEvent("onmessage", onGlobalMessage); 509 | } 510 | 511 | registerImmediate = function(handle) { 512 | global.postMessage(messagePrefix + handle, "*"); 513 | }; 514 | } 515 | 516 | function installMessageChannelImplementation() { 517 | var channel = new MessageChannel(); 518 | channel.port1.onmessage = function(event) { 519 | var handle = event.data; 520 | runIfPresent(handle); 521 | }; 522 | 523 | registerImmediate = function(handle) { 524 | channel.port2.postMessage(handle); 525 | }; 526 | } 527 | 528 | function installReadyStateChangeImplementation() { 529 | var html = doc.documentElement; 530 | registerImmediate = function(handle) { 531 | // Create a