├── .gitignore ├── bin-diagrama.js ├── chrome ├── build │ └── unpacked │ │ ├── build │ │ ├── background.js │ │ ├── contentScript.js │ │ ├── importFile.worker.worker.js │ │ ├── injectGlobalHook.js │ │ ├── main.js │ │ ├── panel.js │ │ ├── parseHookNames.chunk.js │ │ ├── parseSourceAndMetadata.worker.worker.js │ │ ├── react_devtools_backend.js │ │ ├── renderer.js │ │ └── vendors~parseHookNames.chunk.js │ │ ├── icons │ │ ├── 128-deadcode.png │ │ ├── 128-development.png │ │ ├── 128-disabled.png │ │ ├── 128-outdated.png │ │ ├── 128-production.png │ │ ├── 128-restricted.png │ │ ├── 128-unminified.png │ │ ├── 16-deadcode.png │ │ ├── 16-development.png │ │ ├── 16-disabled.png │ │ ├── 16-outdated.png │ │ ├── 16-production.png │ │ ├── 16-restricted.png │ │ ├── 16-unminified.png │ │ ├── 32-deadcode.png │ │ ├── 32-development.png │ │ ├── 32-disabled.png │ │ ├── 32-outdated.png │ │ ├── 32-production.png │ │ ├── 32-restricted.png │ │ ├── 32-unminified.png │ │ ├── 48-deadcode.png │ │ ├── 48-development.png │ │ ├── 48-disabled.png │ │ ├── 48-outdated.png │ │ ├── 48-production.png │ │ ├── 48-restricted.png │ │ ├── 48-unminified.png │ │ ├── deadcode.svg │ │ ├── development.svg │ │ ├── disabled.svg │ │ ├── outdated.svg │ │ ├── production.svg │ │ └── restricted.svg │ │ ├── main.html │ │ ├── manifest.json │ │ ├── panel.html │ │ └── popups │ │ ├── deadcode.html │ │ ├── development.html │ │ ├── disabled.html │ │ ├── outdated.html │ │ ├── production.html │ │ ├── restricted.html │ │ ├── shared.css │ │ ├── shared.js │ │ └── unminified.html └── test.js ├── index.html ├── package.json ├── readme.md ├── src ├── app.tsx ├── data.ts ├── index.css ├── lib │ ├── diagram.tsx │ ├── layout.ts │ ├── smart-collapse.ts │ ├── structure.ts │ ├── types.ts │ └── use-element-size.ts ├── main.tsx └── vite-env.d.ts ├── tsconfig.json ├── vite.config.ts └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .tempUserDataDir 2 | node_modules 3 | dist -------------------------------------------------------------------------------- /bin-diagrama.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const handler = require("serve-handler"); 5 | const http = require("http"); 6 | const path = require("path"); 7 | 8 | const chromeLaunch = require("chrome-launch"); 9 | const { argv } = require("yargs"); 10 | 11 | // Serve Diagrama website 12 | const server = http.createServer((request, response) => { 13 | return handler(request, response, { 14 | public: path.resolve(__dirname, "dist"), 15 | }); 16 | }); 17 | 18 | server.listen(3333, () => { 19 | console.log("Running at http://localhost:3333"); 20 | }); 21 | 22 | const EXTENSION_PATH = path.resolve(__dirname, "chrome/build/unpacked"); 23 | 24 | const [START_URL = "http://localhost:3333/"] = argv._; 25 | console.log(EXTENSION_PATH, START_URL); 26 | 27 | chromeLaunch(START_URL, { 28 | args: [ 29 | // Load the React DevTools extension 30 | `--load-extension=${EXTENSION_PATH}`, 31 | 32 | // Automatically open DevTools window 33 | // "--auto-open-devtools-for-tabs", 34 | 35 | // Remembers previous session settings (e.g. DevTools size/position) 36 | "--user-data-dir=./.tempUserDataDir", 37 | ], 38 | }); 39 | -------------------------------------------------------------------------------- /chrome/build/unpacked/build/background.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, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = "/build/"; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = 113); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ 113: 90 | /***/ (function(module, exports, __webpack_require__) { 91 | 92 | "use strict"; 93 | /* global chrome */ 94 | 95 | 96 | const ports = {}; 97 | const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') >= 0; 98 | chrome.runtime.onConnect.addListener(function (port) { 99 | let tab = null; 100 | let name = null; 101 | 102 | if (isNumeric(port.name)) { 103 | tab = port.name; 104 | name = 'devtools'; 105 | installContentScript(+port.name); 106 | } else { 107 | tab = port.sender.tab.id; 108 | name = 'content-script'; 109 | } 110 | 111 | if (!ports[tab]) { 112 | ports[tab] = { 113 | devtools: null, 114 | 'content-script': null 115 | }; 116 | } 117 | 118 | ports[tab][name] = port; 119 | 120 | if (ports[tab].devtools && ports[tab]['content-script']) { 121 | doublePipe(ports[tab].devtools, ports[tab]['content-script']); 122 | } 123 | }); 124 | 125 | function isNumeric(str) { 126 | return +str + '' === str; 127 | } 128 | 129 | function installContentScript(tabId) { 130 | chrome.tabs.executeScript(tabId, { 131 | file: '/build/contentScript.js' 132 | }, function () {}); 133 | } 134 | 135 | function doublePipe(one, two) { 136 | one.onMessage.addListener(lOne); 137 | 138 | function lOne(message) { 139 | two.postMessage(message); 140 | } 141 | 142 | two.onMessage.addListener(lTwo); 143 | 144 | function lTwo(message) { 145 | one.postMessage(message); 146 | } 147 | 148 | function shutdown() { 149 | one.onMessage.removeListener(lOne); 150 | two.onMessage.removeListener(lTwo); 151 | one.disconnect(); 152 | two.disconnect(); 153 | } 154 | 155 | one.onDisconnect.addListener(shutdown); 156 | two.onDisconnect.addListener(shutdown); 157 | } 158 | 159 | function setIconAndPopup(reactBuildType, tabId) { 160 | chrome.browserAction.setIcon({ 161 | tabId: tabId, 162 | path: { 163 | '16': 'icons/16-' + reactBuildType + '.png', 164 | '32': 'icons/32-' + reactBuildType + '.png', 165 | '48': 'icons/48-' + reactBuildType + '.png', 166 | '128': 'icons/128-' + reactBuildType + '.png' 167 | } 168 | }); 169 | chrome.browserAction.setPopup({ 170 | tabId: tabId, 171 | popup: 'popups/' + reactBuildType + '.html' 172 | }); 173 | } 174 | 175 | function isRestrictedBrowserPage(url) { 176 | return !url || new URL(url).protocol === 'chrome:'; 177 | } 178 | 179 | function checkAndHandleRestrictedPageIfSo(tab) { 180 | if (tab && isRestrictedBrowserPage(tab.url)) { 181 | setIconAndPopup('restricted', tab.id); 182 | } 183 | } // update popup page of any existing open tabs, if they are restricted browser pages. 184 | // we can't update for any other types (prod,dev,outdated etc) 185 | // as the content script needs to be injected at document_start itself for those kinds of detection 186 | // TODO: Show a different popup page(to reload current page probably) for old tabs, opened before the extension is installed 187 | 188 | 189 | if (!IS_FIREFOX) { 190 | chrome.tabs.query({}, tabs => tabs.forEach(checkAndHandleRestrictedPageIfSo)); 191 | chrome.tabs.onCreated.addListener((tabId, changeInfo, tab) => checkAndHandleRestrictedPageIfSo(tab)); 192 | } // Listen to URL changes on the active tab and update the DevTools icon. 193 | 194 | 195 | chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { 196 | if (IS_FIREFOX) { 197 | // We don't properly detect protected URLs in Firefox at the moment. 198 | // However we can reset the DevTools icon to its loading state when the URL changes. 199 | // It will be updated to the correct icon by the onMessage callback below. 200 | if (tab.active && changeInfo.status === 'loading') { 201 | setIconAndPopup('disabled', tabId); 202 | } 203 | } else { 204 | // Don't reset the icon to the loading state for Chrome or Edge. 205 | // The onUpdated callback fires more frequently for these browsers, 206 | // often after onMessage has been called. 207 | checkAndHandleRestrictedPageIfSo(tab); 208 | } 209 | }); 210 | chrome.runtime.onMessage.addListener((request, sender) => { 211 | var _request$payload, _ports$id; 212 | 213 | const tab = sender.tab; 214 | 215 | if (tab) { 216 | const id = tab.id; // This is sent from the hook content script. 217 | // It tells us a renderer has attached. 218 | 219 | if (request.hasDetectedReact) { 220 | // We use browserAction instead of pageAction because this lets us 221 | // display a custom default popup when React is *not* detected. 222 | // It is specified in the manifest. 223 | setIconAndPopup(request.reactBuildType, id); 224 | } else { 225 | switch ((_request$payload = request.payload) === null || _request$payload === void 0 ? void 0 : _request$payload.type) { 226 | case 'fetch-file-with-cache-complete': 227 | case 'fetch-file-with-cache-error': 228 | // Forward the result of fetch-in-page requests back to the extension. 229 | const devtools = (_ports$id = ports[id]) === null || _ports$id === void 0 ? void 0 : _ports$id.devtools; 230 | 231 | if (devtools) { 232 | devtools.postMessage(request); 233 | } 234 | 235 | break; 236 | } 237 | } 238 | } 239 | }); 240 | 241 | /***/ }) 242 | 243 | /******/ }); -------------------------------------------------------------------------------- /chrome/build/unpacked/build/contentScript.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, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = "/build/"; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = 114); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ 114: 90 | /***/ (function(module, exports, __webpack_require__) { 91 | 92 | "use strict"; 93 | /* global chrome */ 94 | 95 | 96 | let backendDisconnected = false; 97 | let backendInitialized = false; 98 | 99 | function sayHelloToBackend() { 100 | window.postMessage({ 101 | source: 'react-devtools-content-script', 102 | hello: true 103 | }, '*'); 104 | } 105 | 106 | function handleMessageFromDevtools(message) { 107 | window.postMessage({ 108 | source: 'react-devtools-content-script', 109 | payload: message 110 | }, '*'); 111 | } 112 | 113 | function handleMessageFromPage(evt) { 114 | if (evt.source === window && evt.data && evt.data.source === 'react-devtools-bridge') { 115 | backendInitialized = true; 116 | port.postMessage(evt.data.payload); 117 | } 118 | } 119 | 120 | function handleDisconnect() { 121 | backendDisconnected = true; 122 | window.removeEventListener('message', handleMessageFromPage); 123 | window.postMessage({ 124 | source: 'react-devtools-content-script', 125 | payload: { 126 | type: 'event', 127 | event: 'shutdown' 128 | } 129 | }, '*'); 130 | } // proxy from main page to devtools (via the background page) 131 | 132 | 133 | const port = chrome.runtime.connect({ 134 | name: 'content-script' 135 | }); 136 | port.onMessage.addListener(handleMessageFromDevtools); 137 | port.onDisconnect.addListener(handleDisconnect); 138 | window.addEventListener('message', handleMessageFromPage); 139 | sayHelloToBackend(); // The backend waits to install the global hook until notified by the content script. 140 | // In the event of a page reload, the content script might be loaded before the backend is injected. 141 | // Because of this we need to poll the backend until it has been initialized. 142 | 143 | if (!backendInitialized) { 144 | const intervalID = setInterval(() => { 145 | if (backendInitialized || backendDisconnected) { 146 | clearInterval(intervalID); 147 | } else { 148 | sayHelloToBackend(); 149 | } 150 | }, 500); 151 | } 152 | 153 | /***/ }) 154 | 155 | /******/ }); -------------------------------------------------------------------------------- /chrome/build/unpacked/build/panel.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, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = "/build/"; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = 200); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ 200: 90 | /***/ (function(module, exports) { 91 | 92 | // Portal target container. 93 | window.container = document.getElementById('container'); 94 | let hasInjectedStyles = false; // DevTools styles are injected into the top-level document head (where the main React app is rendered). 95 | // This method copies those styles to the child window where each panel (e.g. Elements, Profiler) is portaled. 96 | 97 | window.injectStyles = getLinkTags => { 98 | if (!hasInjectedStyles) { 99 | hasInjectedStyles = true; 100 | const linkTags = getLinkTags(); // eslint-disable-next-line no-for-of-loops/no-for-of-loops 101 | 102 | for (const linkTag of linkTags) { 103 | document.head.appendChild(linkTag); 104 | } 105 | } 106 | }; 107 | 108 | /***/ }) 109 | 110 | /******/ }); -------------------------------------------------------------------------------- /chrome/build/unpacked/build/vendors~parseHookNames.chunk.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[7],{ 2 | 3 | /***/ 206: 4 | /***/ (function(module, exports, __webpack_require__) { 5 | 6 | "use strict"; 7 | /* WEBPACK VAR INJECTION */(function(global) {/*! 8 | * The buffer module from node.js, for the browser. 9 | * 10 | * @author Feross Aboukhadijeh 11 | * @license MIT 12 | */ 13 | 14 | /* eslint-disable no-proto */ 15 | 16 | 17 | var base64 = __webpack_require__(207); 18 | 19 | var ieee754 = __webpack_require__(208); 20 | 21 | var isArray = __webpack_require__(209); 22 | 23 | exports.Buffer = Buffer; 24 | exports.SlowBuffer = SlowBuffer; 25 | exports.INSPECT_MAX_BYTES = 50; 26 | /** 27 | * If `Buffer.TYPED_ARRAY_SUPPORT`: 28 | * === true Use Uint8Array implementation (fastest) 29 | * === false Use Object implementation (most compatible, even IE6) 30 | * 31 | * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 32 | * Opera 11.6+, iOS 4.2+. 33 | * 34 | * Due to various browser bugs, sometimes the Object implementation will be used even 35 | * when the browser supports typed arrays. 36 | * 37 | * Note: 38 | * 39 | * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 40 | * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 41 | * 42 | * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 43 | * 44 | * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 45 | * incorrect length in some situations. 46 | 47 | * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 48 | * get the Object implementation, which is slower but behaves correctly. 49 | */ 50 | 51 | Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ? global.TYPED_ARRAY_SUPPORT : typedArraySupport(); 52 | /* 53 | * Export kMaxLength after typed array support is determined. 54 | */ 55 | 56 | exports.kMaxLength = kMaxLength(); 57 | 58 | function typedArraySupport() { 59 | try { 60 | var arr = new Uint8Array(1); 61 | arr.__proto__ = { 62 | __proto__: Uint8Array.prototype, 63 | foo: function () { 64 | return 42; 65 | } 66 | }; 67 | return arr.foo() === 42 && // typed array instances can be augmented 68 | typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` 69 | arr.subarray(1, 1).byteLength === 0; // ie10 has broken `subarray` 70 | } catch (e) { 71 | return false; 72 | } 73 | } 74 | 75 | function kMaxLength() { 76 | return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff; 77 | } 78 | 79 | function createBuffer(that, length) { 80 | if (kMaxLength() < length) { 81 | throw new RangeError('Invalid typed array length'); 82 | } 83 | 84 | if (Buffer.TYPED_ARRAY_SUPPORT) { 85 | // Return an augmented `Uint8Array` instance, for best performance 86 | that = new Uint8Array(length); 87 | that.__proto__ = Buffer.prototype; 88 | } else { 89 | // Fallback: Return an object instance of the Buffer class 90 | if (that === null) { 91 | that = new Buffer(length); 92 | } 93 | 94 | that.length = length; 95 | } 96 | 97 | return that; 98 | } 99 | /** 100 | * The Buffer constructor returns instances of `Uint8Array` that have their 101 | * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 102 | * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 103 | * and the `Uint8Array` methods. Square bracket notation works as expected -- it 104 | * returns a single octet. 105 | * 106 | * The `Uint8Array` prototype remains unmodified. 107 | */ 108 | 109 | 110 | function Buffer(arg, encodingOrOffset, length) { 111 | if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { 112 | return new Buffer(arg, encodingOrOffset, length); 113 | } // Common case. 114 | 115 | 116 | if (typeof arg === 'number') { 117 | if (typeof encodingOrOffset === 'string') { 118 | throw new Error('If encoding is specified then the first argument must be a string'); 119 | } 120 | 121 | return allocUnsafe(this, arg); 122 | } 123 | 124 | return from(this, arg, encodingOrOffset, length); 125 | } 126 | 127 | Buffer.poolSize = 8192; // not used by this implementation 128 | // TODO: Legacy, not needed anymore. Remove in next major version. 129 | 130 | Buffer._augment = function (arr) { 131 | arr.__proto__ = Buffer.prototype; 132 | return arr; 133 | }; 134 | 135 | function from(that, value, encodingOrOffset, length) { 136 | if (typeof value === 'number') { 137 | throw new TypeError('"value" argument must not be a number'); 138 | } 139 | 140 | if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 141 | return fromArrayBuffer(that, value, encodingOrOffset, length); 142 | } 143 | 144 | if (typeof value === 'string') { 145 | return fromString(that, value, encodingOrOffset); 146 | } 147 | 148 | return fromObject(that, value); 149 | } 150 | /** 151 | * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 152 | * if value is a number. 153 | * Buffer.from(str[, encoding]) 154 | * Buffer.from(array) 155 | * Buffer.from(buffer) 156 | * Buffer.from(arrayBuffer[, byteOffset[, length]]) 157 | **/ 158 | 159 | 160 | Buffer.from = function (value, encodingOrOffset, length) { 161 | return from(null, value, encodingOrOffset, length); 162 | }; 163 | 164 | if (Buffer.TYPED_ARRAY_SUPPORT) { 165 | Buffer.prototype.__proto__ = Uint8Array.prototype; 166 | Buffer.__proto__ = Uint8Array; 167 | 168 | if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) { 169 | // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 170 | Object.defineProperty(Buffer, Symbol.species, { 171 | value: null, 172 | configurable: true 173 | }); 174 | } 175 | } 176 | 177 | function assertSize(size) { 178 | if (typeof size !== 'number') { 179 | throw new TypeError('"size" argument must be a number'); 180 | } else if (size < 0) { 181 | throw new RangeError('"size" argument must not be negative'); 182 | } 183 | } 184 | 185 | function alloc(that, size, fill, encoding) { 186 | assertSize(size); 187 | 188 | if (size <= 0) { 189 | return createBuffer(that, size); 190 | } 191 | 192 | if (fill !== undefined) { 193 | // Only pay attention to encoding if it's a string. This 194 | // prevents accidentally sending in a number that would 195 | // be interpretted as a start offset. 196 | return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill); 197 | } 198 | 199 | return createBuffer(that, size); 200 | } 201 | /** 202 | * Creates a new filled Buffer instance. 203 | * alloc(size[, fill[, encoding]]) 204 | **/ 205 | 206 | 207 | Buffer.alloc = function (size, fill, encoding) { 208 | return alloc(null, size, fill, encoding); 209 | }; 210 | 211 | function allocUnsafe(that, size) { 212 | assertSize(size); 213 | that = createBuffer(that, size < 0 ? 0 : checked(size) | 0); 214 | 215 | if (!Buffer.TYPED_ARRAY_SUPPORT) { 216 | for (var i = 0; i < size; ++i) { 217 | that[i] = 0; 218 | } 219 | } 220 | 221 | return that; 222 | } 223 | /** 224 | * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 225 | * */ 226 | 227 | 228 | Buffer.allocUnsafe = function (size) { 229 | return allocUnsafe(null, size); 230 | }; 231 | /** 232 | * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 233 | */ 234 | 235 | 236 | Buffer.allocUnsafeSlow = function (size) { 237 | return allocUnsafe(null, size); 238 | }; 239 | 240 | function fromString(that, string, encoding) { 241 | if (typeof encoding !== 'string' || encoding === '') { 242 | encoding = 'utf8'; 243 | } 244 | 245 | if (!Buffer.isEncoding(encoding)) { 246 | throw new TypeError('"encoding" must be a valid string encoding'); 247 | } 248 | 249 | var length = byteLength(string, encoding) | 0; 250 | that = createBuffer(that, length); 251 | var actual = that.write(string, encoding); 252 | 253 | if (actual !== length) { 254 | // Writing a hex string, for example, that contains invalid characters will 255 | // cause everything after the first invalid character to be ignored. (e.g. 256 | // 'abxxcd' will be treated as 'ab') 257 | that = that.slice(0, actual); 258 | } 259 | 260 | return that; 261 | } 262 | 263 | function fromArrayLike(that, array) { 264 | var length = array.length < 0 ? 0 : checked(array.length) | 0; 265 | that = createBuffer(that, length); 266 | 267 | for (var i = 0; i < length; i += 1) { 268 | that[i] = array[i] & 255; 269 | } 270 | 271 | return that; 272 | } 273 | 274 | function fromArrayBuffer(that, array, byteOffset, length) { 275 | array.byteLength; // this throws if `array` is not a valid ArrayBuffer 276 | 277 | if (byteOffset < 0 || array.byteLength < byteOffset) { 278 | throw new RangeError('\'offset\' is out of bounds'); 279 | } 280 | 281 | if (array.byteLength < byteOffset + (length || 0)) { 282 | throw new RangeError('\'length\' is out of bounds'); 283 | } 284 | 285 | if (byteOffset === undefined && length === undefined) { 286 | array = new Uint8Array(array); 287 | } else if (length === undefined) { 288 | array = new Uint8Array(array, byteOffset); 289 | } else { 290 | array = new Uint8Array(array, byteOffset, length); 291 | } 292 | 293 | if (Buffer.TYPED_ARRAY_SUPPORT) { 294 | // Return an augmented `Uint8Array` instance, for best performance 295 | that = array; 296 | that.__proto__ = Buffer.prototype; 297 | } else { 298 | // Fallback: Return an object instance of the Buffer class 299 | that = fromArrayLike(that, array); 300 | } 301 | 302 | return that; 303 | } 304 | 305 | function fromObject(that, obj) { 306 | if (Buffer.isBuffer(obj)) { 307 | var len = checked(obj.length) | 0; 308 | that = createBuffer(that, len); 309 | 310 | if (that.length === 0) { 311 | return that; 312 | } 313 | 314 | obj.copy(that, 0, 0, len); 315 | return that; 316 | } 317 | 318 | if (obj) { 319 | if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) { 320 | if (typeof obj.length !== 'number' || isnan(obj.length)) { 321 | return createBuffer(that, 0); 322 | } 323 | 324 | return fromArrayLike(that, obj); 325 | } 326 | 327 | if (obj.type === 'Buffer' && isArray(obj.data)) { 328 | return fromArrayLike(that, obj.data); 329 | } 330 | } 331 | 332 | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.'); 333 | } 334 | 335 | function checked(length) { 336 | // Note: cannot use `length < kMaxLength()` here because that fails when 337 | // length is NaN (which is otherwise coerced to zero.) 338 | if (length >= kMaxLength()) { 339 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes'); 340 | } 341 | 342 | return length | 0; 343 | } 344 | 345 | function SlowBuffer(length) { 346 | if (+length != length) { 347 | // eslint-disable-line eqeqeq 348 | length = 0; 349 | } 350 | 351 | return Buffer.alloc(+length); 352 | } 353 | 354 | Buffer.isBuffer = function isBuffer(b) { 355 | return !!(b != null && b._isBuffer); 356 | }; 357 | 358 | Buffer.compare = function compare(a, b) { 359 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 360 | throw new TypeError('Arguments must be Buffers'); 361 | } 362 | 363 | if (a === b) return 0; 364 | var x = a.length; 365 | var y = b.length; 366 | 367 | for (var i = 0, len = Math.min(x, y); i < len; ++i) { 368 | if (a[i] !== b[i]) { 369 | x = a[i]; 370 | y = b[i]; 371 | break; 372 | } 373 | } 374 | 375 | if (x < y) return -1; 376 | if (y < x) return 1; 377 | return 0; 378 | }; 379 | 380 | Buffer.isEncoding = function isEncoding(encoding) { 381 | switch (String(encoding).toLowerCase()) { 382 | case 'hex': 383 | case 'utf8': 384 | case 'utf-8': 385 | case 'ascii': 386 | case 'latin1': 387 | case 'binary': 388 | case 'base64': 389 | case 'ucs2': 390 | case 'ucs-2': 391 | case 'utf16le': 392 | case 'utf-16le': 393 | return true; 394 | 395 | default: 396 | return false; 397 | } 398 | }; 399 | 400 | Buffer.concat = function concat(list, length) { 401 | if (!isArray(list)) { 402 | throw new TypeError('"list" argument must be an Array of Buffers'); 403 | } 404 | 405 | if (list.length === 0) { 406 | return Buffer.alloc(0); 407 | } 408 | 409 | var i; 410 | 411 | if (length === undefined) { 412 | length = 0; 413 | 414 | for (i = 0; i < list.length; ++i) { 415 | length += list[i].length; 416 | } 417 | } 418 | 419 | var buffer = Buffer.allocUnsafe(length); 420 | var pos = 0; 421 | 422 | for (i = 0; i < list.length; ++i) { 423 | var buf = list[i]; 424 | 425 | if (!Buffer.isBuffer(buf)) { 426 | throw new TypeError('"list" argument must be an Array of Buffers'); 427 | } 428 | 429 | buf.copy(buffer, pos); 430 | pos += buf.length; 431 | } 432 | 433 | return buffer; 434 | }; 435 | 436 | function byteLength(string, encoding) { 437 | if (Buffer.isBuffer(string)) { 438 | return string.length; 439 | } 440 | 441 | if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 442 | return string.byteLength; 443 | } 444 | 445 | if (typeof string !== 'string') { 446 | string = '' + string; 447 | } 448 | 449 | var len = string.length; 450 | if (len === 0) return 0; // Use a for loop to avoid recursion 451 | 452 | var loweredCase = false; 453 | 454 | for (;;) { 455 | switch (encoding) { 456 | case 'ascii': 457 | case 'latin1': 458 | case 'binary': 459 | return len; 460 | 461 | case 'utf8': 462 | case 'utf-8': 463 | case undefined: 464 | return utf8ToBytes(string).length; 465 | 466 | case 'ucs2': 467 | case 'ucs-2': 468 | case 'utf16le': 469 | case 'utf-16le': 470 | return len * 2; 471 | 472 | case 'hex': 473 | return len >>> 1; 474 | 475 | case 'base64': 476 | return base64ToBytes(string).length; 477 | 478 | default: 479 | if (loweredCase) return utf8ToBytes(string).length; // assume utf8 480 | 481 | encoding = ('' + encoding).toLowerCase(); 482 | loweredCase = true; 483 | } 484 | } 485 | } 486 | 487 | Buffer.byteLength = byteLength; 488 | 489 | function slowToString(encoding, start, end) { 490 | var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 491 | // property of a typed array. 492 | // This behaves neither like String nor Uint8Array in that we set start/end 493 | // to their upper/lower bounds if the value passed is out of range. 494 | // undefined is handled specially as per ECMA-262 6th Edition, 495 | // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 496 | 497 | if (start === undefined || start < 0) { 498 | start = 0; 499 | } // Return early if start > this.length. Done here to prevent potential uint32 500 | // coercion fail below. 501 | 502 | 503 | if (start > this.length) { 504 | return ''; 505 | } 506 | 507 | if (end === undefined || end > this.length) { 508 | end = this.length; 509 | } 510 | 511 | if (end <= 0) { 512 | return ''; 513 | } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 514 | 515 | 516 | end >>>= 0; 517 | start >>>= 0; 518 | 519 | if (end <= start) { 520 | return ''; 521 | } 522 | 523 | if (!encoding) encoding = 'utf8'; 524 | 525 | while (true) { 526 | switch (encoding) { 527 | case 'hex': 528 | return hexSlice(this, start, end); 529 | 530 | case 'utf8': 531 | case 'utf-8': 532 | return utf8Slice(this, start, end); 533 | 534 | case 'ascii': 535 | return asciiSlice(this, start, end); 536 | 537 | case 'latin1': 538 | case 'binary': 539 | return latin1Slice(this, start, end); 540 | 541 | case 'base64': 542 | return base64Slice(this, start, end); 543 | 544 | case 'ucs2': 545 | case 'ucs-2': 546 | case 'utf16le': 547 | case 'utf-16le': 548 | return utf16leSlice(this, start, end); 549 | 550 | default: 551 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 552 | encoding = (encoding + '').toLowerCase(); 553 | loweredCase = true; 554 | } 555 | } 556 | } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 557 | // Buffer instances. 558 | 559 | 560 | Buffer.prototype._isBuffer = true; 561 | 562 | function swap(b, n, m) { 563 | var i = b[n]; 564 | b[n] = b[m]; 565 | b[m] = i; 566 | } 567 | 568 | Buffer.prototype.swap16 = function swap16() { 569 | var len = this.length; 570 | 571 | if (len % 2 !== 0) { 572 | throw new RangeError('Buffer size must be a multiple of 16-bits'); 573 | } 574 | 575 | for (var i = 0; i < len; i += 2) { 576 | swap(this, i, i + 1); 577 | } 578 | 579 | return this; 580 | }; 581 | 582 | Buffer.prototype.swap32 = function swap32() { 583 | var len = this.length; 584 | 585 | if (len % 4 !== 0) { 586 | throw new RangeError('Buffer size must be a multiple of 32-bits'); 587 | } 588 | 589 | for (var i = 0; i < len; i += 4) { 590 | swap(this, i, i + 3); 591 | swap(this, i + 1, i + 2); 592 | } 593 | 594 | return this; 595 | }; 596 | 597 | Buffer.prototype.swap64 = function swap64() { 598 | var len = this.length; 599 | 600 | if (len % 8 !== 0) { 601 | throw new RangeError('Buffer size must be a multiple of 64-bits'); 602 | } 603 | 604 | for (var i = 0; i < len; i += 8) { 605 | swap(this, i, i + 7); 606 | swap(this, i + 1, i + 6); 607 | swap(this, i + 2, i + 5); 608 | swap(this, i + 3, i + 4); 609 | } 610 | 611 | return this; 612 | }; 613 | 614 | Buffer.prototype.toString = function toString() { 615 | var length = this.length | 0; 616 | if (length === 0) return ''; 617 | if (arguments.length === 0) return utf8Slice(this, 0, length); 618 | return slowToString.apply(this, arguments); 619 | }; 620 | 621 | Buffer.prototype.equals = function equals(b) { 622 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); 623 | if (this === b) return true; 624 | return Buffer.compare(this, b) === 0; 625 | }; 626 | 627 | Buffer.prototype.inspect = function inspect() { 628 | var str = ''; 629 | var max = exports.INSPECT_MAX_BYTES; 630 | 631 | if (this.length > 0) { 632 | str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); 633 | if (this.length > max) str += ' ... '; 634 | } 635 | 636 | return ''; 637 | }; 638 | 639 | Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { 640 | if (!Buffer.isBuffer(target)) { 641 | throw new TypeError('Argument must be a Buffer'); 642 | } 643 | 644 | if (start === undefined) { 645 | start = 0; 646 | } 647 | 648 | if (end === undefined) { 649 | end = target ? target.length : 0; 650 | } 651 | 652 | if (thisStart === undefined) { 653 | thisStart = 0; 654 | } 655 | 656 | if (thisEnd === undefined) { 657 | thisEnd = this.length; 658 | } 659 | 660 | if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 661 | throw new RangeError('out of range index'); 662 | } 663 | 664 | if (thisStart >= thisEnd && start >= end) { 665 | return 0; 666 | } 667 | 668 | if (thisStart >= thisEnd) { 669 | return -1; 670 | } 671 | 672 | if (start >= end) { 673 | return 1; 674 | } 675 | 676 | start >>>= 0; 677 | end >>>= 0; 678 | thisStart >>>= 0; 679 | thisEnd >>>= 0; 680 | if (this === target) return 0; 681 | var x = thisEnd - thisStart; 682 | var y = end - start; 683 | var len = Math.min(x, y); 684 | var thisCopy = this.slice(thisStart, thisEnd); 685 | var targetCopy = target.slice(start, end); 686 | 687 | for (var i = 0; i < len; ++i) { 688 | if (thisCopy[i] !== targetCopy[i]) { 689 | x = thisCopy[i]; 690 | y = targetCopy[i]; 691 | break; 692 | } 693 | } 694 | 695 | if (x < y) return -1; 696 | if (y < x) return 1; 697 | return 0; 698 | }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 699 | // OR the last index of `val` in `buffer` at offset <= `byteOffset`. 700 | // 701 | // Arguments: 702 | // - buffer - a Buffer to search 703 | // - val - a string, Buffer, or number 704 | // - byteOffset - an index into `buffer`; will be clamped to an int32 705 | // - encoding - an optional encoding, relevant is val is a string 706 | // - dir - true for indexOf, false for lastIndexOf 707 | 708 | 709 | function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { 710 | // Empty buffer means no match 711 | if (buffer.length === 0) return -1; // Normalize byteOffset 712 | 713 | if (typeof byteOffset === 'string') { 714 | encoding = byteOffset; 715 | byteOffset = 0; 716 | } else if (byteOffset > 0x7fffffff) { 717 | byteOffset = 0x7fffffff; 718 | } else if (byteOffset < -0x80000000) { 719 | byteOffset = -0x80000000; 720 | } 721 | 722 | byteOffset = +byteOffset; // Coerce to Number. 723 | 724 | if (isNaN(byteOffset)) { 725 | // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 726 | byteOffset = dir ? 0 : buffer.length - 1; 727 | } // Normalize byteOffset: negative offsets start from the end of the buffer 728 | 729 | 730 | if (byteOffset < 0) byteOffset = buffer.length + byteOffset; 731 | 732 | if (byteOffset >= buffer.length) { 733 | if (dir) return -1;else byteOffset = buffer.length - 1; 734 | } else if (byteOffset < 0) { 735 | if (dir) byteOffset = 0;else return -1; 736 | } // Normalize val 737 | 738 | 739 | if (typeof val === 'string') { 740 | val = Buffer.from(val, encoding); 741 | } // Finally, search either indexOf (if dir is true) or lastIndexOf 742 | 743 | 744 | if (Buffer.isBuffer(val)) { 745 | // Special case: looking for empty string/buffer always fails 746 | if (val.length === 0) { 747 | return -1; 748 | } 749 | 750 | return arrayIndexOf(buffer, val, byteOffset, encoding, dir); 751 | } else if (typeof val === 'number') { 752 | val = val & 0xFF; // Search for a byte value [0-255] 753 | 754 | if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') { 755 | if (dir) { 756 | return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); 757 | } else { 758 | return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); 759 | } 760 | } 761 | 762 | return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); 763 | } 764 | 765 | throw new TypeError('val must be string, number or Buffer'); 766 | } 767 | 768 | function arrayIndexOf(arr, val, byteOffset, encoding, dir) { 769 | var indexSize = 1; 770 | var arrLength = arr.length; 771 | var valLength = val.length; 772 | 773 | if (encoding !== undefined) { 774 | encoding = String(encoding).toLowerCase(); 775 | 776 | if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { 777 | if (arr.length < 2 || val.length < 2) { 778 | return -1; 779 | } 780 | 781 | indexSize = 2; 782 | arrLength /= 2; 783 | valLength /= 2; 784 | byteOffset /= 2; 785 | } 786 | } 787 | 788 | function read(buf, i) { 789 | if (indexSize === 1) { 790 | return buf[i]; 791 | } else { 792 | return buf.readUInt16BE(i * indexSize); 793 | } 794 | } 795 | 796 | var i; 797 | 798 | if (dir) { 799 | var foundIndex = -1; 800 | 801 | for (i = byteOffset; i < arrLength; i++) { 802 | if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 803 | if (foundIndex === -1) foundIndex = i; 804 | if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; 805 | } else { 806 | if (foundIndex !== -1) i -= i - foundIndex; 807 | foundIndex = -1; 808 | } 809 | } 810 | } else { 811 | if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; 812 | 813 | for (i = byteOffset; i >= 0; i--) { 814 | var found = true; 815 | 816 | for (var j = 0; j < valLength; j++) { 817 | if (read(arr, i + j) !== read(val, j)) { 818 | found = false; 819 | break; 820 | } 821 | } 822 | 823 | if (found) return i; 824 | } 825 | } 826 | 827 | return -1; 828 | } 829 | 830 | Buffer.prototype.includes = function includes(val, byteOffset, encoding) { 831 | return this.indexOf(val, byteOffset, encoding) !== -1; 832 | }; 833 | 834 | Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { 835 | return bidirectionalIndexOf(this, val, byteOffset, encoding, true); 836 | }; 837 | 838 | Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { 839 | return bidirectionalIndexOf(this, val, byteOffset, encoding, false); 840 | }; 841 | 842 | function hexWrite(buf, string, offset, length) { 843 | offset = Number(offset) || 0; 844 | var remaining = buf.length - offset; 845 | 846 | if (!length) { 847 | length = remaining; 848 | } else { 849 | length = Number(length); 850 | 851 | if (length > remaining) { 852 | length = remaining; 853 | } 854 | } // must be an even number of digits 855 | 856 | 857 | var strLen = string.length; 858 | if (strLen % 2 !== 0) throw new TypeError('Invalid hex string'); 859 | 860 | if (length > strLen / 2) { 861 | length = strLen / 2; 862 | } 863 | 864 | for (var i = 0; i < length; ++i) { 865 | var parsed = parseInt(string.substr(i * 2, 2), 16); 866 | if (isNaN(parsed)) return i; 867 | buf[offset + i] = parsed; 868 | } 869 | 870 | return i; 871 | } 872 | 873 | function utf8Write(buf, string, offset, length) { 874 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); 875 | } 876 | 877 | function asciiWrite(buf, string, offset, length) { 878 | return blitBuffer(asciiToBytes(string), buf, offset, length); 879 | } 880 | 881 | function latin1Write(buf, string, offset, length) { 882 | return asciiWrite(buf, string, offset, length); 883 | } 884 | 885 | function base64Write(buf, string, offset, length) { 886 | return blitBuffer(base64ToBytes(string), buf, offset, length); 887 | } 888 | 889 | function ucs2Write(buf, string, offset, length) { 890 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); 891 | } 892 | 893 | Buffer.prototype.write = function write(string, offset, length, encoding) { 894 | // Buffer#write(string) 895 | if (offset === undefined) { 896 | encoding = 'utf8'; 897 | length = this.length; 898 | offset = 0; // Buffer#write(string, encoding) 899 | } else if (length === undefined && typeof offset === 'string') { 900 | encoding = offset; 901 | length = this.length; 902 | offset = 0; // Buffer#write(string, offset[, length][, encoding]) 903 | } else if (isFinite(offset)) { 904 | offset = offset | 0; 905 | 906 | if (isFinite(length)) { 907 | length = length | 0; 908 | if (encoding === undefined) encoding = 'utf8'; 909 | } else { 910 | encoding = length; 911 | length = undefined; 912 | } // legacy write(string, encoding, offset, length) - remove in v0.13 913 | 914 | } else { 915 | throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); 916 | } 917 | 918 | var remaining = this.length - offset; 919 | if (length === undefined || length > remaining) length = remaining; 920 | 921 | if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { 922 | throw new RangeError('Attempt to write outside buffer bounds'); 923 | } 924 | 925 | if (!encoding) encoding = 'utf8'; 926 | var loweredCase = false; 927 | 928 | for (;;) { 929 | switch (encoding) { 930 | case 'hex': 931 | return hexWrite(this, string, offset, length); 932 | 933 | case 'utf8': 934 | case 'utf-8': 935 | return utf8Write(this, string, offset, length); 936 | 937 | case 'ascii': 938 | return asciiWrite(this, string, offset, length); 939 | 940 | case 'latin1': 941 | case 'binary': 942 | return latin1Write(this, string, offset, length); 943 | 944 | case 'base64': 945 | // Warning: maxLength not taken into account in base64Write 946 | return base64Write(this, string, offset, length); 947 | 948 | case 'ucs2': 949 | case 'ucs-2': 950 | case 'utf16le': 951 | case 'utf-16le': 952 | return ucs2Write(this, string, offset, length); 953 | 954 | default: 955 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); 956 | encoding = ('' + encoding).toLowerCase(); 957 | loweredCase = true; 958 | } 959 | } 960 | }; 961 | 962 | Buffer.prototype.toJSON = function toJSON() { 963 | return { 964 | type: 'Buffer', 965 | data: Array.prototype.slice.call(this._arr || this, 0) 966 | }; 967 | }; 968 | 969 | function base64Slice(buf, start, end) { 970 | if (start === 0 && end === buf.length) { 971 | return base64.fromByteArray(buf); 972 | } else { 973 | return base64.fromByteArray(buf.slice(start, end)); 974 | } 975 | } 976 | 977 | function utf8Slice(buf, start, end) { 978 | end = Math.min(buf.length, end); 979 | var res = []; 980 | var i = start; 981 | 982 | while (i < end) { 983 | var firstByte = buf[i]; 984 | var codePoint = null; 985 | var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; 986 | 987 | if (i + bytesPerSequence <= end) { 988 | var secondByte, thirdByte, fourthByte, tempCodePoint; 989 | 990 | switch (bytesPerSequence) { 991 | case 1: 992 | if (firstByte < 0x80) { 993 | codePoint = firstByte; 994 | } 995 | 996 | break; 997 | 998 | case 2: 999 | secondByte = buf[i + 1]; 1000 | 1001 | if ((secondByte & 0xC0) === 0x80) { 1002 | tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; 1003 | 1004 | if (tempCodePoint > 0x7F) { 1005 | codePoint = tempCodePoint; 1006 | } 1007 | } 1008 | 1009 | break; 1010 | 1011 | case 3: 1012 | secondByte = buf[i + 1]; 1013 | thirdByte = buf[i + 2]; 1014 | 1015 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 1016 | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; 1017 | 1018 | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 1019 | codePoint = tempCodePoint; 1020 | } 1021 | } 1022 | 1023 | break; 1024 | 1025 | case 4: 1026 | secondByte = buf[i + 1]; 1027 | thirdByte = buf[i + 2]; 1028 | fourthByte = buf[i + 3]; 1029 | 1030 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 1031 | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; 1032 | 1033 | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 1034 | codePoint = tempCodePoint; 1035 | } 1036 | } 1037 | 1038 | } 1039 | } 1040 | 1041 | if (codePoint === null) { 1042 | // we did not generate a valid codePoint so insert a 1043 | // replacement char (U+FFFD) and advance only 1 byte 1044 | codePoint = 0xFFFD; 1045 | bytesPerSequence = 1; 1046 | } else if (codePoint > 0xFFFF) { 1047 | // encode to utf16 (surrogate pair dance) 1048 | codePoint -= 0x10000; 1049 | res.push(codePoint >>> 10 & 0x3FF | 0xD800); 1050 | codePoint = 0xDC00 | codePoint & 0x3FF; 1051 | } 1052 | 1053 | res.push(codePoint); 1054 | i += bytesPerSequence; 1055 | } 1056 | 1057 | return decodeCodePointsArray(res); 1058 | } // Based on http://stackoverflow.com/a/22747272/680742, the browser with 1059 | // the lowest limit is Chrome, with 0x10000 args. 1060 | // We go 1 magnitude less, for safety 1061 | 1062 | 1063 | var MAX_ARGUMENTS_LENGTH = 0x1000; 1064 | 1065 | function decodeCodePointsArray(codePoints) { 1066 | var len = codePoints.length; 1067 | 1068 | if (len <= MAX_ARGUMENTS_LENGTH) { 1069 | return String.fromCharCode.apply(String, codePoints); // avoid extra slice() 1070 | } // Decode in chunks to avoid "call stack size exceeded". 1071 | 1072 | 1073 | var res = ''; 1074 | var i = 0; 1075 | 1076 | while (i < len) { 1077 | res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); 1078 | } 1079 | 1080 | return res; 1081 | } 1082 | 1083 | function asciiSlice(buf, start, end) { 1084 | var ret = ''; 1085 | end = Math.min(buf.length, end); 1086 | 1087 | for (var i = start; i < end; ++i) { 1088 | ret += String.fromCharCode(buf[i] & 0x7F); 1089 | } 1090 | 1091 | return ret; 1092 | } 1093 | 1094 | function latin1Slice(buf, start, end) { 1095 | var ret = ''; 1096 | end = Math.min(buf.length, end); 1097 | 1098 | for (var i = start; i < end; ++i) { 1099 | ret += String.fromCharCode(buf[i]); 1100 | } 1101 | 1102 | return ret; 1103 | } 1104 | 1105 | function hexSlice(buf, start, end) { 1106 | var len = buf.length; 1107 | if (!start || start < 0) start = 0; 1108 | if (!end || end < 0 || end > len) end = len; 1109 | var out = ''; 1110 | 1111 | for (var i = start; i < end; ++i) { 1112 | out += toHex(buf[i]); 1113 | } 1114 | 1115 | return out; 1116 | } 1117 | 1118 | function utf16leSlice(buf, start, end) { 1119 | var bytes = buf.slice(start, end); 1120 | var res = ''; 1121 | 1122 | for (var i = 0; i < bytes.length; i += 2) { 1123 | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); 1124 | } 1125 | 1126 | return res; 1127 | } 1128 | 1129 | Buffer.prototype.slice = function slice(start, end) { 1130 | var len = this.length; 1131 | start = ~~start; 1132 | end = end === undefined ? len : ~~end; 1133 | 1134 | if (start < 0) { 1135 | start += len; 1136 | if (start < 0) start = 0; 1137 | } else if (start > len) { 1138 | start = len; 1139 | } 1140 | 1141 | if (end < 0) { 1142 | end += len; 1143 | if (end < 0) end = 0; 1144 | } else if (end > len) { 1145 | end = len; 1146 | } 1147 | 1148 | if (end < start) end = start; 1149 | var newBuf; 1150 | 1151 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1152 | newBuf = this.subarray(start, end); 1153 | newBuf.__proto__ = Buffer.prototype; 1154 | } else { 1155 | var sliceLen = end - start; 1156 | newBuf = new Buffer(sliceLen, undefined); 1157 | 1158 | for (var i = 0; i < sliceLen; ++i) { 1159 | newBuf[i] = this[i + start]; 1160 | } 1161 | } 1162 | 1163 | return newBuf; 1164 | }; 1165 | /* 1166 | * Need to make sure that buffer isn't trying to write out of bounds. 1167 | */ 1168 | 1169 | 1170 | function checkOffset(offset, ext, length) { 1171 | if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); 1172 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); 1173 | } 1174 | 1175 | Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { 1176 | offset = offset | 0; 1177 | byteLength = byteLength | 0; 1178 | if (!noAssert) checkOffset(offset, byteLength, this.length); 1179 | var val = this[offset]; 1180 | var mul = 1; 1181 | var i = 0; 1182 | 1183 | while (++i < byteLength && (mul *= 0x100)) { 1184 | val += this[offset + i] * mul; 1185 | } 1186 | 1187 | return val; 1188 | }; 1189 | 1190 | Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { 1191 | offset = offset | 0; 1192 | byteLength = byteLength | 0; 1193 | 1194 | if (!noAssert) { 1195 | checkOffset(offset, byteLength, this.length); 1196 | } 1197 | 1198 | var val = this[offset + --byteLength]; 1199 | var mul = 1; 1200 | 1201 | while (byteLength > 0 && (mul *= 0x100)) { 1202 | val += this[offset + --byteLength] * mul; 1203 | } 1204 | 1205 | return val; 1206 | }; 1207 | 1208 | Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { 1209 | if (!noAssert) checkOffset(offset, 1, this.length); 1210 | return this[offset]; 1211 | }; 1212 | 1213 | Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { 1214 | if (!noAssert) checkOffset(offset, 2, this.length); 1215 | return this[offset] | this[offset + 1] << 8; 1216 | }; 1217 | 1218 | Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { 1219 | if (!noAssert) checkOffset(offset, 2, this.length); 1220 | return this[offset] << 8 | this[offset + 1]; 1221 | }; 1222 | 1223 | Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { 1224 | if (!noAssert) checkOffset(offset, 4, this.length); 1225 | return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; 1226 | }; 1227 | 1228 | Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { 1229 | if (!noAssert) checkOffset(offset, 4, this.length); 1230 | return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); 1231 | }; 1232 | 1233 | Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { 1234 | offset = offset | 0; 1235 | byteLength = byteLength | 0; 1236 | if (!noAssert) checkOffset(offset, byteLength, this.length); 1237 | var val = this[offset]; 1238 | var mul = 1; 1239 | var i = 0; 1240 | 1241 | while (++i < byteLength && (mul *= 0x100)) { 1242 | val += this[offset + i] * mul; 1243 | } 1244 | 1245 | mul *= 0x80; 1246 | if (val >= mul) val -= Math.pow(2, 8 * byteLength); 1247 | return val; 1248 | }; 1249 | 1250 | Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { 1251 | offset = offset | 0; 1252 | byteLength = byteLength | 0; 1253 | if (!noAssert) checkOffset(offset, byteLength, this.length); 1254 | var i = byteLength; 1255 | var mul = 1; 1256 | var val = this[offset + --i]; 1257 | 1258 | while (i > 0 && (mul *= 0x100)) { 1259 | val += this[offset + --i] * mul; 1260 | } 1261 | 1262 | mul *= 0x80; 1263 | if (val >= mul) val -= Math.pow(2, 8 * byteLength); 1264 | return val; 1265 | }; 1266 | 1267 | Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { 1268 | if (!noAssert) checkOffset(offset, 1, this.length); 1269 | if (!(this[offset] & 0x80)) return this[offset]; 1270 | return (0xff - this[offset] + 1) * -1; 1271 | }; 1272 | 1273 | Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { 1274 | if (!noAssert) checkOffset(offset, 2, this.length); 1275 | var val = this[offset] | this[offset + 1] << 8; 1276 | return val & 0x8000 ? val | 0xFFFF0000 : val; 1277 | }; 1278 | 1279 | Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { 1280 | if (!noAssert) checkOffset(offset, 2, this.length); 1281 | var val = this[offset + 1] | this[offset] << 8; 1282 | return val & 0x8000 ? val | 0xFFFF0000 : val; 1283 | }; 1284 | 1285 | Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { 1286 | if (!noAssert) checkOffset(offset, 4, this.length); 1287 | return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; 1288 | }; 1289 | 1290 | Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { 1291 | if (!noAssert) checkOffset(offset, 4, this.length); 1292 | return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; 1293 | }; 1294 | 1295 | Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { 1296 | if (!noAssert) checkOffset(offset, 4, this.length); 1297 | return ieee754.read(this, offset, true, 23, 4); 1298 | }; 1299 | 1300 | Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { 1301 | if (!noAssert) checkOffset(offset, 4, this.length); 1302 | return ieee754.read(this, offset, false, 23, 4); 1303 | }; 1304 | 1305 | Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { 1306 | if (!noAssert) checkOffset(offset, 8, this.length); 1307 | return ieee754.read(this, offset, true, 52, 8); 1308 | }; 1309 | 1310 | Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { 1311 | if (!noAssert) checkOffset(offset, 8, this.length); 1312 | return ieee754.read(this, offset, false, 52, 8); 1313 | }; 1314 | 1315 | function checkInt(buf, value, offset, ext, max, min) { 1316 | if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); 1317 | if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); 1318 | if (offset + ext > buf.length) throw new RangeError('Index out of range'); 1319 | } 1320 | 1321 | Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { 1322 | value = +value; 1323 | offset = offset | 0; 1324 | byteLength = byteLength | 0; 1325 | 1326 | if (!noAssert) { 1327 | var maxBytes = Math.pow(2, 8 * byteLength) - 1; 1328 | checkInt(this, value, offset, byteLength, maxBytes, 0); 1329 | } 1330 | 1331 | var mul = 1; 1332 | var i = 0; 1333 | this[offset] = value & 0xFF; 1334 | 1335 | while (++i < byteLength && (mul *= 0x100)) { 1336 | this[offset + i] = value / mul & 0xFF; 1337 | } 1338 | 1339 | return offset + byteLength; 1340 | }; 1341 | 1342 | Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { 1343 | value = +value; 1344 | offset = offset | 0; 1345 | byteLength = byteLength | 0; 1346 | 1347 | if (!noAssert) { 1348 | var maxBytes = Math.pow(2, 8 * byteLength) - 1; 1349 | checkInt(this, value, offset, byteLength, maxBytes, 0); 1350 | } 1351 | 1352 | var i = byteLength - 1; 1353 | var mul = 1; 1354 | this[offset + i] = value & 0xFF; 1355 | 1356 | while (--i >= 0 && (mul *= 0x100)) { 1357 | this[offset + i] = value / mul & 0xFF; 1358 | } 1359 | 1360 | return offset + byteLength; 1361 | }; 1362 | 1363 | Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { 1364 | value = +value; 1365 | offset = offset | 0; 1366 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); 1367 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 1368 | this[offset] = value & 0xff; 1369 | return offset + 1; 1370 | }; 1371 | 1372 | function objectWriteUInt16(buf, value, offset, littleEndian) { 1373 | if (value < 0) value = 0xffff + value + 1; 1374 | 1375 | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 1376 | buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8; 1377 | } 1378 | } 1379 | 1380 | Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { 1381 | value = +value; 1382 | offset = offset | 0; 1383 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); 1384 | 1385 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1386 | this[offset] = value & 0xff; 1387 | this[offset + 1] = value >>> 8; 1388 | } else { 1389 | objectWriteUInt16(this, value, offset, true); 1390 | } 1391 | 1392 | return offset + 2; 1393 | }; 1394 | 1395 | Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { 1396 | value = +value; 1397 | offset = offset | 0; 1398 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); 1399 | 1400 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1401 | this[offset] = value >>> 8; 1402 | this[offset + 1] = value & 0xff; 1403 | } else { 1404 | objectWriteUInt16(this, value, offset, false); 1405 | } 1406 | 1407 | return offset + 2; 1408 | }; 1409 | 1410 | function objectWriteUInt32(buf, value, offset, littleEndian) { 1411 | if (value < 0) value = 0xffffffff + value + 1; 1412 | 1413 | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 1414 | buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff; 1415 | } 1416 | } 1417 | 1418 | Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { 1419 | value = +value; 1420 | offset = offset | 0; 1421 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); 1422 | 1423 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1424 | this[offset + 3] = value >>> 24; 1425 | this[offset + 2] = value >>> 16; 1426 | this[offset + 1] = value >>> 8; 1427 | this[offset] = value & 0xff; 1428 | } else { 1429 | objectWriteUInt32(this, value, offset, true); 1430 | } 1431 | 1432 | return offset + 4; 1433 | }; 1434 | 1435 | Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { 1436 | value = +value; 1437 | offset = offset | 0; 1438 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); 1439 | 1440 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1441 | this[offset] = value >>> 24; 1442 | this[offset + 1] = value >>> 16; 1443 | this[offset + 2] = value >>> 8; 1444 | this[offset + 3] = value & 0xff; 1445 | } else { 1446 | objectWriteUInt32(this, value, offset, false); 1447 | } 1448 | 1449 | return offset + 4; 1450 | }; 1451 | 1452 | Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { 1453 | value = +value; 1454 | offset = offset | 0; 1455 | 1456 | if (!noAssert) { 1457 | var limit = Math.pow(2, 8 * byteLength - 1); 1458 | checkInt(this, value, offset, byteLength, limit - 1, -limit); 1459 | } 1460 | 1461 | var i = 0; 1462 | var mul = 1; 1463 | var sub = 0; 1464 | this[offset] = value & 0xFF; 1465 | 1466 | while (++i < byteLength && (mul *= 0x100)) { 1467 | if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 1468 | sub = 1; 1469 | } 1470 | 1471 | this[offset + i] = (value / mul >> 0) - sub & 0xFF; 1472 | } 1473 | 1474 | return offset + byteLength; 1475 | }; 1476 | 1477 | Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { 1478 | value = +value; 1479 | offset = offset | 0; 1480 | 1481 | if (!noAssert) { 1482 | var limit = Math.pow(2, 8 * byteLength - 1); 1483 | checkInt(this, value, offset, byteLength, limit - 1, -limit); 1484 | } 1485 | 1486 | var i = byteLength - 1; 1487 | var mul = 1; 1488 | var sub = 0; 1489 | this[offset + i] = value & 0xFF; 1490 | 1491 | while (--i >= 0 && (mul *= 0x100)) { 1492 | if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 1493 | sub = 1; 1494 | } 1495 | 1496 | this[offset + i] = (value / mul >> 0) - sub & 0xFF; 1497 | } 1498 | 1499 | return offset + byteLength; 1500 | }; 1501 | 1502 | Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { 1503 | value = +value; 1504 | offset = offset | 0; 1505 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); 1506 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); 1507 | if (value < 0) value = 0xff + value + 1; 1508 | this[offset] = value & 0xff; 1509 | return offset + 1; 1510 | }; 1511 | 1512 | Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { 1513 | value = +value; 1514 | offset = offset | 0; 1515 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); 1516 | 1517 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1518 | this[offset] = value & 0xff; 1519 | this[offset + 1] = value >>> 8; 1520 | } else { 1521 | objectWriteUInt16(this, value, offset, true); 1522 | } 1523 | 1524 | return offset + 2; 1525 | }; 1526 | 1527 | Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { 1528 | value = +value; 1529 | offset = offset | 0; 1530 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); 1531 | 1532 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1533 | this[offset] = value >>> 8; 1534 | this[offset + 1] = value & 0xff; 1535 | } else { 1536 | objectWriteUInt16(this, value, offset, false); 1537 | } 1538 | 1539 | return offset + 2; 1540 | }; 1541 | 1542 | Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { 1543 | value = +value; 1544 | offset = offset | 0; 1545 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); 1546 | 1547 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1548 | this[offset] = value & 0xff; 1549 | this[offset + 1] = value >>> 8; 1550 | this[offset + 2] = value >>> 16; 1551 | this[offset + 3] = value >>> 24; 1552 | } else { 1553 | objectWriteUInt32(this, value, offset, true); 1554 | } 1555 | 1556 | return offset + 4; 1557 | }; 1558 | 1559 | Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { 1560 | value = +value; 1561 | offset = offset | 0; 1562 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); 1563 | if (value < 0) value = 0xffffffff + value + 1; 1564 | 1565 | if (Buffer.TYPED_ARRAY_SUPPORT) { 1566 | this[offset] = value >>> 24; 1567 | this[offset + 1] = value >>> 16; 1568 | this[offset + 2] = value >>> 8; 1569 | this[offset + 3] = value & 0xff; 1570 | } else { 1571 | objectWriteUInt32(this, value, offset, false); 1572 | } 1573 | 1574 | return offset + 4; 1575 | }; 1576 | 1577 | function checkIEEE754(buf, value, offset, ext, max, min) { 1578 | if (offset + ext > buf.length) throw new RangeError('Index out of range'); 1579 | if (offset < 0) throw new RangeError('Index out of range'); 1580 | } 1581 | 1582 | function writeFloat(buf, value, offset, littleEndian, noAssert) { 1583 | if (!noAssert) { 1584 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38); 1585 | } 1586 | 1587 | ieee754.write(buf, value, offset, littleEndian, 23, 4); 1588 | return offset + 4; 1589 | } 1590 | 1591 | Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { 1592 | return writeFloat(this, value, offset, true, noAssert); 1593 | }; 1594 | 1595 | Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { 1596 | return writeFloat(this, value, offset, false, noAssert); 1597 | }; 1598 | 1599 | function writeDouble(buf, value, offset, littleEndian, noAssert) { 1600 | if (!noAssert) { 1601 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308); 1602 | } 1603 | 1604 | ieee754.write(buf, value, offset, littleEndian, 52, 8); 1605 | return offset + 8; 1606 | } 1607 | 1608 | Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { 1609 | return writeDouble(this, value, offset, true, noAssert); 1610 | }; 1611 | 1612 | Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { 1613 | return writeDouble(this, value, offset, false, noAssert); 1614 | }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 1615 | 1616 | 1617 | Buffer.prototype.copy = function copy(target, targetStart, start, end) { 1618 | if (!start) start = 0; 1619 | if (!end && end !== 0) end = this.length; 1620 | if (targetStart >= target.length) targetStart = target.length; 1621 | if (!targetStart) targetStart = 0; 1622 | if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done 1623 | 1624 | if (end === start) return 0; 1625 | if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions 1626 | 1627 | if (targetStart < 0) { 1628 | throw new RangeError('targetStart out of bounds'); 1629 | } 1630 | 1631 | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds'); 1632 | if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? 1633 | 1634 | if (end > this.length) end = this.length; 1635 | 1636 | if (target.length - targetStart < end - start) { 1637 | end = target.length - targetStart + start; 1638 | } 1639 | 1640 | var len = end - start; 1641 | var i; 1642 | 1643 | if (this === target && start < targetStart && targetStart < end) { 1644 | // descending copy from end 1645 | for (i = len - 1; i >= 0; --i) { 1646 | target[i + targetStart] = this[i + start]; 1647 | } 1648 | } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 1649 | // ascending copy from start 1650 | for (i = 0; i < len; ++i) { 1651 | target[i + targetStart] = this[i + start]; 1652 | } 1653 | } else { 1654 | Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart); 1655 | } 1656 | 1657 | return len; 1658 | }; // Usage: 1659 | // buffer.fill(number[, offset[, end]]) 1660 | // buffer.fill(buffer[, offset[, end]]) 1661 | // buffer.fill(string[, offset[, end]][, encoding]) 1662 | 1663 | 1664 | Buffer.prototype.fill = function fill(val, start, end, encoding) { 1665 | // Handle string cases: 1666 | if (typeof val === 'string') { 1667 | if (typeof start === 'string') { 1668 | encoding = start; 1669 | start = 0; 1670 | end = this.length; 1671 | } else if (typeof end === 'string') { 1672 | encoding = end; 1673 | end = this.length; 1674 | } 1675 | 1676 | if (val.length === 1) { 1677 | var code = val.charCodeAt(0); 1678 | 1679 | if (code < 256) { 1680 | val = code; 1681 | } 1682 | } 1683 | 1684 | if (encoding !== undefined && typeof encoding !== 'string') { 1685 | throw new TypeError('encoding must be a string'); 1686 | } 1687 | 1688 | if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 1689 | throw new TypeError('Unknown encoding: ' + encoding); 1690 | } 1691 | } else if (typeof val === 'number') { 1692 | val = val & 255; 1693 | } // Invalid ranges are not set to a default, so can range check early. 1694 | 1695 | 1696 | if (start < 0 || this.length < start || this.length < end) { 1697 | throw new RangeError('Out of range index'); 1698 | } 1699 | 1700 | if (end <= start) { 1701 | return this; 1702 | } 1703 | 1704 | start = start >>> 0; 1705 | end = end === undefined ? this.length : end >>> 0; 1706 | if (!val) val = 0; 1707 | var i; 1708 | 1709 | if (typeof val === 'number') { 1710 | for (i = start; i < end; ++i) { 1711 | this[i] = val; 1712 | } 1713 | } else { 1714 | var bytes = Buffer.isBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString()); 1715 | var len = bytes.length; 1716 | 1717 | for (i = 0; i < end - start; ++i) { 1718 | this[i + start] = bytes[i % len]; 1719 | } 1720 | } 1721 | 1722 | return this; 1723 | }; // HELPER FUNCTIONS 1724 | // ================ 1725 | 1726 | 1727 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g; 1728 | 1729 | function base64clean(str) { 1730 | // Node strips out invalid characters like \n and \t from the string, base64-js does not 1731 | str = stringtrim(str).replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' 1732 | 1733 | if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 1734 | 1735 | while (str.length % 4 !== 0) { 1736 | str = str + '='; 1737 | } 1738 | 1739 | return str; 1740 | } 1741 | 1742 | function stringtrim(str) { 1743 | if (str.trim) return str.trim(); 1744 | return str.replace(/^\s+|\s+$/g, ''); 1745 | } 1746 | 1747 | function toHex(n) { 1748 | if (n < 16) return '0' + n.toString(16); 1749 | return n.toString(16); 1750 | } 1751 | 1752 | function utf8ToBytes(string, units) { 1753 | units = units || Infinity; 1754 | var codePoint; 1755 | var length = string.length; 1756 | var leadSurrogate = null; 1757 | var bytes = []; 1758 | 1759 | for (var i = 0; i < length; ++i) { 1760 | codePoint = string.charCodeAt(i); // is surrogate component 1761 | 1762 | if (codePoint > 0xD7FF && codePoint < 0xE000) { 1763 | // last char was a lead 1764 | if (!leadSurrogate) { 1765 | // no lead yet 1766 | if (codePoint > 0xDBFF) { 1767 | // unexpected trail 1768 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 1769 | continue; 1770 | } else if (i + 1 === length) { 1771 | // unpaired lead 1772 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 1773 | continue; 1774 | } // valid lead 1775 | 1776 | 1777 | leadSurrogate = codePoint; 1778 | continue; 1779 | } // 2 leads in a row 1780 | 1781 | 1782 | if (codePoint < 0xDC00) { 1783 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 1784 | leadSurrogate = codePoint; 1785 | continue; 1786 | } // valid surrogate pair 1787 | 1788 | 1789 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; 1790 | } else if (leadSurrogate) { 1791 | // valid bmp char, but last char was a lead 1792 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); 1793 | } 1794 | 1795 | leadSurrogate = null; // encode utf8 1796 | 1797 | if (codePoint < 0x80) { 1798 | if ((units -= 1) < 0) break; 1799 | bytes.push(codePoint); 1800 | } else if (codePoint < 0x800) { 1801 | if ((units -= 2) < 0) break; 1802 | bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); 1803 | } else if (codePoint < 0x10000) { 1804 | if ((units -= 3) < 0) break; 1805 | bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 1806 | } else if (codePoint < 0x110000) { 1807 | if ((units -= 4) < 0) break; 1808 | bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); 1809 | } else { 1810 | throw new Error('Invalid code point'); 1811 | } 1812 | } 1813 | 1814 | return bytes; 1815 | } 1816 | 1817 | function asciiToBytes(str) { 1818 | var byteArray = []; 1819 | 1820 | for (var i = 0; i < str.length; ++i) { 1821 | // Node's code seems to be doing this and not & 0x7F.. 1822 | byteArray.push(str.charCodeAt(i) & 0xFF); 1823 | } 1824 | 1825 | return byteArray; 1826 | } 1827 | 1828 | function utf16leToBytes(str, units) { 1829 | var c, hi, lo; 1830 | var byteArray = []; 1831 | 1832 | for (var i = 0; i < str.length; ++i) { 1833 | if ((units -= 2) < 0) break; 1834 | c = str.charCodeAt(i); 1835 | hi = c >> 8; 1836 | lo = c % 256; 1837 | byteArray.push(lo); 1838 | byteArray.push(hi); 1839 | } 1840 | 1841 | return byteArray; 1842 | } 1843 | 1844 | function base64ToBytes(str) { 1845 | return base64.toByteArray(base64clean(str)); 1846 | } 1847 | 1848 | function blitBuffer(src, dst, offset, length) { 1849 | for (var i = 0; i < length; ++i) { 1850 | if (i + offset >= dst.length || i >= src.length) break; 1851 | dst[i + offset] = src[i]; 1852 | } 1853 | 1854 | return i; 1855 | } 1856 | 1857 | function isnan(val) { 1858 | return val !== val; // eslint-disable-line no-self-compare 1859 | } 1860 | /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(49))) 1861 | 1862 | /***/ }), 1863 | 1864 | /***/ 207: 1865 | /***/ (function(module, exports, __webpack_require__) { 1866 | 1867 | "use strict"; 1868 | 1869 | 1870 | exports.byteLength = byteLength; 1871 | exports.toByteArray = toByteArray; 1872 | exports.fromByteArray = fromByteArray; 1873 | var lookup = []; 1874 | var revLookup = []; 1875 | var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; 1876 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 1877 | 1878 | for (var i = 0, len = code.length; i < len; ++i) { 1879 | lookup[i] = code[i]; 1880 | revLookup[code.charCodeAt(i)] = i; 1881 | } // Support decoding URL-safe base64 strings, as Node.js does. 1882 | // See: https://en.wikipedia.org/wiki/Base64#URL_applications 1883 | 1884 | 1885 | revLookup['-'.charCodeAt(0)] = 62; 1886 | revLookup['_'.charCodeAt(0)] = 63; 1887 | 1888 | function getLens(b64) { 1889 | var len = b64.length; 1890 | 1891 | if (len % 4 > 0) { 1892 | throw new Error('Invalid string. Length must be a multiple of 4'); 1893 | } // Trim off extra bytes after placeholder bytes are found 1894 | // See: https://github.com/beatgammit/base64-js/issues/42 1895 | 1896 | 1897 | var validLen = b64.indexOf('='); 1898 | if (validLen === -1) validLen = len; 1899 | var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; 1900 | return [validLen, placeHoldersLen]; 1901 | } // base64 is 4/3 + up to two characters of the original data 1902 | 1903 | 1904 | function byteLength(b64) { 1905 | var lens = getLens(b64); 1906 | var validLen = lens[0]; 1907 | var placeHoldersLen = lens[1]; 1908 | return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 1909 | } 1910 | 1911 | function _byteLength(b64, validLen, placeHoldersLen) { 1912 | return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; 1913 | } 1914 | 1915 | function toByteArray(b64) { 1916 | var tmp; 1917 | var lens = getLens(b64); 1918 | var validLen = lens[0]; 1919 | var placeHoldersLen = lens[1]; 1920 | var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); 1921 | var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars 1922 | 1923 | var len = placeHoldersLen > 0 ? validLen - 4 : validLen; 1924 | var i; 1925 | 1926 | for (i = 0; i < len; i += 4) { 1927 | tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; 1928 | arr[curByte++] = tmp >> 16 & 0xFF; 1929 | arr[curByte++] = tmp >> 8 & 0xFF; 1930 | arr[curByte++] = tmp & 0xFF; 1931 | } 1932 | 1933 | if (placeHoldersLen === 2) { 1934 | tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; 1935 | arr[curByte++] = tmp & 0xFF; 1936 | } 1937 | 1938 | if (placeHoldersLen === 1) { 1939 | tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; 1940 | arr[curByte++] = tmp >> 8 & 0xFF; 1941 | arr[curByte++] = tmp & 0xFF; 1942 | } 1943 | 1944 | return arr; 1945 | } 1946 | 1947 | function tripletToBase64(num) { 1948 | return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; 1949 | } 1950 | 1951 | function encodeChunk(uint8, start, end) { 1952 | var tmp; 1953 | var output = []; 1954 | 1955 | for (var i = start; i < end; i += 3) { 1956 | tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF); 1957 | output.push(tripletToBase64(tmp)); 1958 | } 1959 | 1960 | return output.join(''); 1961 | } 1962 | 1963 | function fromByteArray(uint8) { 1964 | var tmp; 1965 | var len = uint8.length; 1966 | var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes 1967 | 1968 | var parts = []; 1969 | var maxChunkLength = 16383; // must be multiple of 3 1970 | // go through the array every three bytes, we'll deal with trailing stuff later 1971 | 1972 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 1973 | parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); 1974 | } // pad the end with zeros, but make sure to not forget the extra bytes 1975 | 1976 | 1977 | if (extraBytes === 1) { 1978 | tmp = uint8[len - 1]; 1979 | parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '=='); 1980 | } else if (extraBytes === 2) { 1981 | tmp = (uint8[len - 2] << 8) + uint8[len - 1]; 1982 | parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '='); 1983 | } 1984 | 1985 | return parts.join(''); 1986 | } 1987 | 1988 | /***/ }), 1989 | 1990 | /***/ 208: 1991 | /***/ (function(module, exports) { 1992 | 1993 | exports.read = function (buffer, offset, isLE, mLen, nBytes) { 1994 | var e, m; 1995 | var eLen = nBytes * 8 - mLen - 1; 1996 | var eMax = (1 << eLen) - 1; 1997 | var eBias = eMax >> 1; 1998 | var nBits = -7; 1999 | var i = isLE ? nBytes - 1 : 0; 2000 | var d = isLE ? -1 : 1; 2001 | var s = buffer[offset + i]; 2002 | i += d; 2003 | e = s & (1 << -nBits) - 1; 2004 | s >>= -nBits; 2005 | nBits += eLen; 2006 | 2007 | for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} 2008 | 2009 | m = e & (1 << -nBits) - 1; 2010 | e >>= -nBits; 2011 | nBits += mLen; 2012 | 2013 | for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} 2014 | 2015 | if (e === 0) { 2016 | e = 1 - eBias; 2017 | } else if (e === eMax) { 2018 | return m ? NaN : (s ? -1 : 1) * Infinity; 2019 | } else { 2020 | m = m + Math.pow(2, mLen); 2021 | e = e - eBias; 2022 | } 2023 | 2024 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen); 2025 | }; 2026 | 2027 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { 2028 | var e, m, c; 2029 | var eLen = nBytes * 8 - mLen - 1; 2030 | var eMax = (1 << eLen) - 1; 2031 | var eBias = eMax >> 1; 2032 | var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; 2033 | var i = isLE ? 0 : nBytes - 1; 2034 | var d = isLE ? 1 : -1; 2035 | var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; 2036 | value = Math.abs(value); 2037 | 2038 | if (isNaN(value) || value === Infinity) { 2039 | m = isNaN(value) ? 1 : 0; 2040 | e = eMax; 2041 | } else { 2042 | e = Math.floor(Math.log(value) / Math.LN2); 2043 | 2044 | if (value * (c = Math.pow(2, -e)) < 1) { 2045 | e--; 2046 | c *= 2; 2047 | } 2048 | 2049 | if (e + eBias >= 1) { 2050 | value += rt / c; 2051 | } else { 2052 | value += rt * Math.pow(2, 1 - eBias); 2053 | } 2054 | 2055 | if (value * c >= 2) { 2056 | e++; 2057 | c /= 2; 2058 | } 2059 | 2060 | if (e + eBias >= eMax) { 2061 | m = 0; 2062 | e = eMax; 2063 | } else if (e + eBias >= 1) { 2064 | m = (value * c - 1) * Math.pow(2, mLen); 2065 | e = e + eBias; 2066 | } else { 2067 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); 2068 | e = 0; 2069 | } 2070 | } 2071 | 2072 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 2073 | 2074 | e = e << mLen | m; 2075 | eLen += mLen; 2076 | 2077 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 2078 | 2079 | buffer[offset + i - d] |= s * 128; 2080 | }; 2081 | 2082 | /***/ }), 2083 | 2084 | /***/ 209: 2085 | /***/ (function(module, exports) { 2086 | 2087 | var toString = {}.toString; 2088 | 2089 | module.exports = Array.isArray || function (arr) { 2090 | return toString.call(arr) == '[object Array]'; 2091 | }; 2092 | 2093 | /***/ }) 2094 | 2095 | }]); -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-deadcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-deadcode.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-development.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-development.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-disabled.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-outdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-outdated.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-production.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-production.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-restricted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-restricted.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/128-unminified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/128-unminified.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-deadcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-deadcode.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-development.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-development.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-disabled.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-outdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-outdated.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-production.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-production.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-restricted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-restricted.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/16-unminified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/16-unminified.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-deadcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-deadcode.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-development.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-development.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-disabled.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-outdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-outdated.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-production.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-production.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-restricted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-restricted.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/32-unminified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/32-unminified.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-deadcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-deadcode.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-development.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-development.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-disabled.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-outdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-outdated.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-production.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-production.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-restricted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-restricted.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/48-unminified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pomber/diagrama/bfeac942a2f0e15c1202ab47efb156fe76817ce3/chrome/build/unpacked/icons/48-unminified.png -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/deadcode.svg: -------------------------------------------------------------------------------- 1 | development780780 -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/development.svg: -------------------------------------------------------------------------------- 1 | development780780 -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/disabled.svg: -------------------------------------------------------------------------------- 1 | disabled -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/outdated.svg: -------------------------------------------------------------------------------- 1 | outdated -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/production.svg: -------------------------------------------------------------------------------- 1 | production -------------------------------------------------------------------------------- /chrome/build/unpacked/icons/restricted.svg: -------------------------------------------------------------------------------- 1 | disabled -------------------------------------------------------------------------------- /chrome/build/unpacked/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /chrome/build/unpacked/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "React Developer Tools", 4 | "description": "Adds React debugging tools to the Chrome Developer Tools.\n\nCreated from revision 3b3daf5 on 12/17/2021.", 5 | "version": "4.21.0", 6 | "version_name": "4.21.0 (12/17/2021)", 7 | "minimum_chrome_version": "60", 8 | "icons": { 9 | "16": "icons/16-production.png", 10 | "32": "icons/32-production.png", 11 | "48": "icons/48-production.png", 12 | "128": "icons/128-production.png" 13 | }, 14 | "browser_action": { 15 | "default_icon": { 16 | "16": "icons/16-disabled.png", 17 | "32": "icons/32-disabled.png", 18 | "48": "icons/48-disabled.png", 19 | "128": "icons/128-disabled.png" 20 | }, 21 | "default_popup": "popups/disabled.html" 22 | }, 23 | "devtools_page": "main.html", 24 | "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", 25 | "web_accessible_resources": [ 26 | "main.html", 27 | "panel.html", 28 | "build/react_devtools_backend.js", 29 | "build/renderer.js" 30 | ], 31 | "background": { 32 | "scripts": [ 33 | "build/background.js" 34 | ], 35 | "persistent": false 36 | }, 37 | "permissions": [ 38 | "file:///*", 39 | "http://*/*", 40 | "https://*/*" 41 | ], 42 | "content_scripts": [ 43 | { 44 | "matches": [ 45 | "" 46 | ], 47 | "js": [ 48 | "build/injectGlobalHook.js" 49 | ], 50 | "run_at": "document_start" 51 | } 52 | ] 53 | } -------------------------------------------------------------------------------- /chrome/build/unpacked/panel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 26 | 27 | 28 | 29 |
Unable to find React on the page.
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/deadcode.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 |

14 | This page includes an extra development build of React. 🚧 15 |

16 |

17 | The React build on this page includes both development and production versions because dead code elimination has not been applied correctly. 18 |
19 |
20 | This makes its size larger, and causes React to run slower. 21 |
22 |
23 | Make sure to set up dead code elimination before deployment. 24 |

25 |
26 |

27 | Open the developer tools, and "Components" and "Profiler" tabs will appear to the right. 28 |

29 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/development.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 |

14 | This page is using the development build of React. 🚧 15 |

16 |

17 | Note that the development build is not suitable for production. 18 |
19 | Make sure to use the production build before deployment. 20 |

21 |
22 |

23 | Open the developer tools, and "Components" and "Profiler" tabs will appear to the right. 24 |

25 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/disabled.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 |

14 | This page doesn’t appear to be using React. 15 |
16 | If this seems wrong, follow the troubleshooting instructions. 17 |

18 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/outdated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 |

14 | This page is using an outdated version of React. ⌛ 15 |

16 |

17 | We recommend updating React to ensure that you receive important bugfixes and performance improvements. 18 |
19 |
20 | You can find the upgrade instructions on the React blog. 21 |

22 |
23 |

24 | Open the developer tools, and "Components" and "Profiler" tabs will appear to the right. 25 |

26 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/production.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 |

14 | This page is using the production build of React. ✅ 15 |
16 | Open the developer tools, and "Components" and "Profiler" tabs will appear to the right. 17 |

18 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/restricted.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 |

11 | This is a restricted browser page. 12 |
13 | React devtools cannot access this page. 14 |

15 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/shared.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-size: 14px; 3 | } 4 | 5 | body { 6 | margin: 8px; 7 | } -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/shared.js: -------------------------------------------------------------------------------- 1 | /* globals chrome */ 2 | 3 | 'use strict'; 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | // Make links work 7 | const links = document.getElementsByTagName('a'); 8 | for (let i = 0; i < links.length; i++) { 9 | (function() { 10 | const ln = links[i]; 11 | const location = ln.href; 12 | ln.onclick = function() { 13 | chrome.tabs.create({active: true, url: location}); 14 | return false; 15 | }; 16 | })(); 17 | } 18 | 19 | // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=428044 20 | document.body.style.opacity = 0; 21 | document.body.style.transition = 'opacity ease-out .4s'; 22 | requestAnimationFrame(function() { 23 | document.body.style.opacity = 1; 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /chrome/build/unpacked/popups/unminified.html: -------------------------------------------------------------------------------- 1 | 2 | 17 |

18 | This page is using an unminified build of React. 🚧 19 |

20 |

21 | The React build on this page appears to be unminified. 22 |
23 | This makes its size larger, and causes React to run slower. 24 |
25 |
26 | Make sure to set up minification before deployment. 27 |

28 |
29 |

30 | Open the developer tools, and "Components" and "Profiler" tabs will appear to the right. 31 |

32 | -------------------------------------------------------------------------------- /chrome/test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | const chromeLaunch = require("chrome-launch"); 6 | const { resolve } = require("path"); 7 | const { argv } = require("yargs"); 8 | 9 | const EXTENSION_PATH = resolve("./chrome/build/unpacked"); 10 | const START_URL = argv.url || "http://localhost:3333/"; 11 | 12 | chromeLaunch(START_URL, { 13 | args: [ 14 | // Load the React DevTools extension 15 | `--load-extension=${EXTENSION_PATH}`, 16 | 17 | // Automatically open DevTools window 18 | // "--auto-open-devtools-for-tabs", 19 | 20 | // Remembers previous session settings (e.g. DevTools size/position) 21 | "--user-data-dir=./.tempUserDataDir", 22 | ], 23 | }); 24 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Diagrama 8 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "diagrama", 3 | "version": "0.0.4", 4 | "author": "pomber", 5 | "repository": "github:pomber/diagrama", 6 | "bin": { 7 | "diagrama": "./bin-diagrama.js" 8 | }, 9 | "files": [ 10 | "chrome", 11 | "dist", 12 | "bin-diagrama.js" 13 | ], 14 | "scripts": { 15 | "chrome": "node ./chrome/test", 16 | "dev": "vite", 17 | "start": "run-p dev \"chrome -- {1}\" --", 18 | "build": "tsc && vite build", 19 | "preview": "vite preview --port 3333" 20 | }, 21 | "devDependencies": { 22 | "@types/lz-string": "^1.3.34", 23 | "@types/react": "^17.0.33", 24 | "@types/react-dom": "^17.0.10", 25 | "@vitejs/plugin-react": "^1.0.7", 26 | "npm-run-all": "^4.1.5", 27 | "typescript": "^4.4.4", 28 | "vite": "^2.7.2", 29 | "framer-motion": "^5.5.5", 30 | "lz-string": "^1.4.4", 31 | "react": "^17.0.2", 32 | "react-dom": "^17.0.2", 33 | "recoil": "^0.5.2" 34 | }, 35 | "dependencies": { 36 | "chrome-launch": "^1.1.4", 37 | "serve-handler": "^6.1.3", 38 | "yargs": "^17.3.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Work in progress. See [twitter thread](https://twitter.com/pomber/status/1471095012444319748). 2 | 3 | --- 4 | 5 | 6 | Run 7 | 8 | ``` 9 | npx diagrama https://7429z69wwj.csb.app/ 10 | ``` 11 | 12 | Replace `https://7429z69wwj.csb.app/` with the url of your app (running in dev mode). 13 | 14 | https://user-images.githubusercontent.com/1911623/147954152-414557a1-b1df-4d97-8ad9-0e5ca25b4ec5.mp4 15 | 16 | -------------------------------------------------------------------------------- /src/app.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Diagram, InputNode } from "./lib/diagram"; 3 | import { disney as input } from "./data"; 4 | import LZString from "lz-string"; 5 | import { RecoilRoot } from "recoil"; 6 | 7 | function App() { 8 | const [value, setValue] = React.useState(JSON.stringify(input, null, 2)); 9 | const [_, setData] = React.useState(null); 10 | 11 | const hash = document.location.hash.slice(1); 12 | const data = hash ? decode(hash) : null; 13 | return ( 14 |
15 | {data ? ( 16 | 17 | 18 | 19 | ) : ( 20 |
21 |